MultiBox 2.0 [Bots] Action Like The Player

command : !send [value] / for the spawn bot | !f / follow | !wood (food stone gold) / farm the resources | !aim / for aim bot to the cursor | !dc multibox / disconnect the bot and self

  1. // ==UserScript==
  2. // @name MultiBox 2.0 [Bots] Action Like The Player
  3. // @version 2
  4. // @description command : !send [value] / for the spawn bot | !f / follow | !wood (food stone gold) / farm the resources | !aim / for aim bot to the cursor | !dc multibox / disconnect the bot and self
  5. // @author Ha Thu
  6. // @namespace https://cheatx.ygto.com/
  7. // @match *://moomoo.io/*
  8. // @match *://dev.moomoo.io/*
  9. // @match *://sandbox.moomoo.io/*
  10. // @require https://cdn.jsdelivr.net/npm/msgpack-lite@0.1.26/dist/msgpack.min.js
  11. // @require https://cdn.jsdelivr.net/npm/fontfaceobserver@2.1.0/fontfaceobserver.standalone.min.js
  12. // @icon https://cheatx.ygto.com/cxteam.png
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. // I M P O R T A N T !
  17.  
  18. // READ THIS
  19. // You may use vpn to spawn bot cuz develop limit ip now
  20. // My Discord : harryhathu._.
  21. // Yea that me again Ha Thu the villain of bots
  22.  
  23.  
  24. function getEl(id) {
  25. return document.getElementById(id);
  26. }
  27.  
  28. (function () {
  29. 'use strict';
  30. const style = document.createElement('style');
  31. style.innerHTML = `
  32. #modMenu {
  33. position: fixed;
  34. top: 50%;
  35. left: 50%;
  36. transform: translate(-50%, -50%);
  37. width: 460px;
  38. height: 420px;
  39. background: #1c1c1c;
  40. border-radius: 12px;
  41. box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  42. padding: 20px;
  43. color: white;
  44. font-family: Arial, sans-serif;
  45. opacity: 0;
  46. z-index: 10000;
  47. transition: opacity 0.8s ease;
  48. pointer-events: none;
  49. }
  50.  
  51. #modMenu.show {
  52. opacity: 1;
  53. pointer-events: all;
  54. }
  55.  
  56. #modMenu.hide {
  57. opacity: 0;
  58. pointer-events: none;
  59. }
  60.  
  61. #modMenu .header {
  62. display: flex;
  63. justify-content: space-between;
  64. align-items: center;
  65. margin-bottom: 20px;
  66. }
  67.  
  68. #modMenu .header .title {
  69. font-size: 22px;
  70. font-weight: bold;
  71. display: flex;
  72. align-items: center;
  73. }
  74.  
  75. #modMenu .header .version {
  76. font-size: 14px;
  77. margin-left: 8px;
  78. color: #4caf50;
  79. opacity: 0.9;
  80. }
  81.  
  82. #modMenu .search-icon {
  83. font-size: 24px;
  84. color: #999;
  85. cursor: pointer;
  86. transition: color 0.3s ease, transform 0.3s ease;
  87. }
  88.  
  89. #modMenu .search-icon:hover {
  90. color: #4caf50;
  91. transform: scale(1.1);
  92. }
  93.  
  94. #modMenu .search-bar {
  95. display: none;
  96. margin-top: 5px;
  97. background: #2c2c2c;
  98. border-radius: 8px;
  99. padding: 8px 12px;
  100. transition: max-height 0.3s ease, padding 0.3s ease, margin-top 0.3s ease;
  101. max-height: 0;
  102. overflow: hidden;
  103. }
  104.  
  105. #modMenu .search-bar.open {
  106. display: block;
  107. max-height: 50px;
  108. padding: 8px 12px;
  109. margin-top: 5px;
  110. }
  111.  
  112. #modMenu .search-bar input {
  113. width: 100%;
  114. border: none;
  115. background: transparent;
  116. color: white;
  117. font-size: 14px;
  118. outline: none;
  119. }
  120.  
  121. #modMenu .tabs {
  122. display: flex;
  123. justify-content: space-between;
  124. margin-bottom: 15px;
  125. transition: margin-top 0.3s ease;
  126. }
  127.  
  128. #modMenu .tab {
  129. flex: 1;
  130. text-align: center;
  131. padding: 10px;
  132. margin: 0 5px;
  133. background: #333;
  134. border-radius: 8px;
  135. transition: background 0.3s ease, transform 0.2s ease;
  136. font-size: 14px;
  137. cursor: pointer;
  138. }
  139.  
  140. #modMenu .tab:hover {
  141. background: #555;
  142. transform: scale(1.05);
  143. }
  144.  
  145. #modMenu .tab.active {
  146. background: #4caf50;
  147. color: white;
  148. }
  149.  
  150. #modMenu .content {
  151. height: 240px;
  152. overflow-y: auto;
  153. display: none;
  154. transition: opacity 0.3s ease;
  155. }
  156.  
  157. #modMenu .content.active {
  158. display: block;
  159. opacity: 1;
  160. }
  161.  
  162. #modMenu .content.inactive {
  163. opacity: 0;
  164. }
  165.  
  166. .toggle {
  167. display: flex;
  168. justify-content: space-between;
  169. align-items: center;
  170. margin: 12px 0;
  171. font-size: 16px;
  172. }
  173.  
  174. .toggle-switch {
  175. position: relative;
  176. width: 50px;
  177. height: 25px;
  178. background: #ccc;
  179. border-radius: 50px;
  180. cursor: pointer;
  181. transition: background 0.3s ease;
  182. }
  183.  
  184. .toggle-switch::before {
  185. content: '';
  186. position: absolute;
  187. width: 23px;
  188. height: 23px;
  189. background: white;
  190. border-radius: 50%;
  191. top: 1px;
  192. left: 1px;
  193. transition: transform 0.3s ease;
  194. }
  195.  
  196. .toggle-switch.active {
  197. background: #4caf50;
  198. }
  199.  
  200. .toggle-switch.active::before {
  201. transform: translateX(25px);
  202. }
  203.  
  204. .toggle-switch input {
  205. display: none;
  206. }
  207. `;
  208. document.head.appendChild(style);
  209. const menu = document.createElement('div');
  210. menu.id = 'modMenu';
  211. menu.innerHTML = `
  212. <div class="header">
  213. <div class="title">
  214. CheatCore<span class="version">v1</span>
  215. </div>
  216. <div class="search-icon" id="searchIcon">🔍</div>
  217. </div>
  218. <div class="search-bar" id="searchBar">
  219. <input type="text" placeholder="Search functions..." id="functionSearch">
  220. </div>
  221. <div class="tabs">
  222. <div class="tab active" data-tab="bots">Bots</div>
  223. <div class="tab" data-tab="combat">Visuals</div>
  224. <div class="tab" data-tab="modules">Modules</div>
  225. </div>
  226. <div class="content active" id="content-bots">
  227. <div class="toggle">
  228. Enable Auto Spawn
  229. <div class="toggle-switch" data-option="autoSpawn">
  230. <input type="checkbox" id="autoSpawn">
  231. </div>
  232. </div>
  233. </div>
  234. <div class="content" id="content-combat">
  235. <div class="toggle">
  236. Disable Wiggle
  237. <div class="toggle-switch" data-option="disableWiggle">
  238. <input type="checkbox" id="disableWiggle">
  239. </div>
  240. </div>
  241. <div class="toggle">
  242. Disable Hit Animation
  243. <div class="toggle-switch" data-option="disableHitAnimation">
  244. <input type="checkbox" id="disableHitAnimation">
  245. </div>
  246. </div>
  247. <div class="toggle">
  248. Draw Player In Near
  249. <div class="toggle-switch" data-option="drawplayer">
  250. <input type="checkbox" id="drawplayer">
  251. </div>
  252. </div>
  253. </div>
  254. <div class="content" id="content-modules">
  255. <div class="toggle">
  256. Draw Tracers(Useless)
  257. <div class="toggle-switch" data-option="tracers">
  258. <input type="checkbox" id="tracers">
  259. </div>
  260. </div>
  261. </div>
  262. `;
  263. document.body.appendChild(menu);
  264. document.querySelectorAll('.tab').forEach(tab => {
  265. tab.addEventListener('click', () => {
  266. document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
  267. tab.classList.add('active');
  268.  
  269. document.querySelectorAll('.content').forEach(content => content.classList.remove('active'));
  270. document.getElementById(`content-${tab.dataset.tab}`).classList.add('active');
  271. });
  272. });
  273. document.querySelectorAll('.toggle-switch').forEach(toggle => {
  274. toggle.addEventListener('click', () => {
  275. const checkbox = toggle.querySelector('input');
  276. checkbox.checked = !checkbox.checked;
  277.  
  278. toggle.classList.toggle('active', checkbox.checked);
  279. const option = toggle.dataset.option;
  280. console.log(`${option}: ${checkbox.checked ? 'Enabled' : 'Disabled'}`);
  281. });
  282. });
  283. let isMenuVisible = false;
  284. document.addEventListener('keydown', (e) => {
  285. if (e.key === 'Escape') {
  286. isMenuVisible = !isMenuVisible;
  287. menu.classList.toggle('show', isMenuVisible);
  288. menu.classList.toggle('hide', !isMenuVisible);
  289. }
  290. });
  291. document.getElementById('searchIcon').addEventListener('click', () => {
  292. const searchBar = document.getElementById('searchBar');
  293. const tabs = document.querySelector('.tabs');
  294. searchBar.classList.toggle('open');
  295. tabs.style.marginTop = searchBar.classList.contains('open') ? '30px' : '0px';
  296. if (searchBar.classList.contains('open')) {
  297. document.getElementById('functionSearch').focus();
  298. }
  299. });
  300. document.getElementById('functionSearch').addEventListener('input', function () {
  301. const searchTerm = this.value.toLowerCase();
  302. document.querySelectorAll('.toggle').forEach(toggle => {
  303. const text = toggle.textContent.toLowerCase();
  304. toggle.style.display = text.includes(searchTerm) ? 'flex' : 'none';
  305. });
  306. });
  307. })();
  308.  
  309. let angles = [];
  310. let point = {x: null, y: null, x2: null, y2: null}
  311.  
  312. let healToggle = true;
  313. let hatToggle = false;
  314. let empToggle = false;
  315.  
  316. let ws;
  317. let cvs;
  318. let width;
  319. let height;
  320. let mouseX;
  321. let mouseY;
  322. let dir;
  323.  
  324. let primary;
  325. let secondary;
  326. let foodType;
  327. let wallType;
  328. let spikeType;
  329. let millType;
  330. let mineType;
  331. let boostType;
  332. let turretType;
  333. let spawnpadType;
  334.  
  335. let healer;
  336. let spiker;
  337. let trapper;
  338. let miller;
  339. let crashing;
  340. let playerFollowerGlobal;
  341. let ffs;
  342. let ffsps;
  343. let sockets = {};
  344. let bots = {};
  345. let closed;
  346. let myPlayer = {};
  347. let pointer = true;
  348. let pointingOnPosition = {};
  349. let enemiesNear;
  350. let players = {};
  351. let isEnemyNear;
  352. let nearestEnemy;
  353. let nearestEnemyAngle;
  354. let autoaim = false;
  355. let autoAttackWithAim3 = false;
  356. let autoInsta;
  357. let JustDied;
  358. let normalHat;
  359. let normalAcc;
  360. let oldHat;
  361. let oldAcc;
  362. let cursor = false;
  363.  
  364. let weapons = [{
  365. id: 0,
  366. type: 0,
  367. name: "tool hammer",
  368. desc: "tool for gathering all resources",
  369. src: "hammer_1",
  370. length: 140,
  371. width: 140,
  372. xOff: -3,
  373. yOff: 18,
  374. dmg: 25,
  375. range: 65,
  376. gather: 1,
  377. speed: 300
  378. }, {
  379. id: 1,
  380. type: 0,
  381. age: 2,
  382. name: "hand axe",
  383. desc: "gathers resources at a higher rate",
  384. src: "axe_1",
  385. length: 140,
  386. width: 140,
  387. xOff: 3,
  388. yOff: 24,
  389. dmg: 30,
  390. spdMult: 1,
  391. range: 70,
  392. gather: 2,
  393. speed: 400
  394. }, {
  395. id: 2,
  396. type: 0,
  397. age: 8,
  398. pre: 1,
  399. name: "great axe",
  400. desc: "deal more damage and gather more resources",
  401. src: "great_axe_1",
  402. length: 140,
  403. width: 140,
  404. xOff: -8,
  405. yOff: 25,
  406. dmg: 35,
  407. spdMult: 1,
  408. range: 75,
  409. gather: 4,
  410. speed: 400
  411. }, {
  412. id: 3,
  413. type: 0,
  414. age: 2,
  415. name: "short sword",
  416. desc: "increased attack power but slower move speed",
  417. src: "sword_1",
  418. iPad: 1.3,
  419. length: 130,
  420. width: 210,
  421. xOff: -8,
  422. yOff: 46,
  423. dmg: 35,
  424. spdMult: .85,
  425. range: 110,
  426. gather: 1,
  427. speed: 300
  428. }, {
  429. id: 4,
  430. type: 0,
  431. age: 8,
  432. pre: 3,
  433. name: "katana",
  434. desc: "greater range and damage",
  435. src: "samurai_1",
  436. iPad: 1.3,
  437. length: 130,
  438. width: 210,
  439. xOff: -8,
  440. yOff: 59,
  441. dmg: 40,
  442. spdMult: .8,
  443. range: 118,
  444. gather: 1,
  445. speed: 300
  446. }, {
  447. id: 5,
  448. type: 0,
  449. age: 2,
  450. name: "polearm",
  451. desc: "long range melee weapon",
  452. src: "spear_1",
  453. iPad: 1.3,
  454. length: 130,
  455. width: 210,
  456. xOff: -8,
  457. yOff: 53,
  458. dmg: 45,
  459. knock: .2,
  460. spdMult: .82,
  461. range: 142,
  462. gather: 1,
  463. speed: 700
  464. }, {
  465. id: 6,
  466. type: 0,
  467. age: 2,
  468. name: "bat",
  469. desc: "fast long range melee weapon",
  470. src: "bat_1",
  471. iPad: 1.3,
  472. length: 110,
  473. width: 180,
  474. xOff: -8,
  475. yOff: 53,
  476. dmg: 20,
  477. knock: .7,
  478. range: 110,
  479. gather: 1,
  480. speed: 300
  481. }, {
  482. id: 7,
  483. type: 0,
  484. age: 2,
  485. name: "daggers",
  486. desc: "really fast short range weapon",
  487. src: "dagger_1",
  488. iPad: .8,
  489. length: 110,
  490. width: 110,
  491. xOff: 18,
  492. yOff: 0,
  493. dmg: 20,
  494. knock: .1,
  495. range: 65,
  496. gather: 1,
  497. hitSlow: .1,
  498. spdMult: 1.13,
  499. speed: 100
  500. }]
  501.  
  502. let hats = [{
  503. id: 51,
  504. name: "Moo Cap",
  505. price: 0,
  506. scale: 120,
  507. desc: "coolest mooer around"
  508. }, {
  509. id: 50,
  510. name: "Apple Cap",
  511. price: 0,
  512. scale: 120,
  513. desc: "apple farms remembers"
  514. }, {
  515. id: 28,
  516. name: "Moo Head",
  517. price: 0,
  518. scale: 120,
  519. desc: "no effect"
  520. }, {
  521. id: 29,
  522. name: "Pig Head",
  523. price: 0,
  524. scale: 120,
  525. desc: "no effect"
  526. }, {
  527. id: 30,
  528. name: "Fluff Head",
  529. price: 0,
  530. scale: 120,
  531. desc: "no effect"
  532. }, {
  533. id: 36,
  534. name: "Pandou Head",
  535. price: 0,
  536. scale: 120,
  537. desc: "no effect"
  538. }, {
  539. id: 37,
  540. name: "Bear Head",
  541. price: 0,
  542. scale: 120,
  543. desc: "no effect"
  544. }, {
  545. id: 38,
  546. name: "Monkey Head",
  547. price: 0,
  548. scale: 120,
  549. desc: "no effect"
  550. }, {
  551. id: 44,
  552. name: "Polar Head",
  553. price: 0,
  554. scale: 120,
  555. desc: "no effect"
  556. }, {
  557. id: 35,
  558. name: "Fez Hat",
  559. price: 0,
  560. scale: 120,
  561. desc: "no effect"
  562. }, {
  563. id: 42,
  564. name: "Enigma Hat",
  565. price: 0,
  566. scale: 120,
  567. desc: "join the enigma army"
  568. }, {
  569. id: 43,
  570. name: "Blitz Hat",
  571. price: 0,
  572. scale: 120,
  573. desc: "hey everybody i'm blitz"
  574. }, {
  575. id: 49,
  576. name: "Bob XIII Hat",
  577. price: 0,
  578. scale: 120,
  579. desc: "like and subscribe"
  580. }, {
  581. id: 57,
  582. name: "Pumpkin",
  583. price: 50,
  584. scale: 120,
  585. desc: "Spooooky"
  586. }, {
  587. id: 8,
  588. name: "Bummle Hat",
  589. price: 100,
  590. scale: 120,
  591. desc: "no effect"
  592. }, {
  593. id: 2,
  594. name: "Straw Hat",
  595. price: 500,
  596. scale: 120,
  597. desc: "no effect"
  598. }, {
  599. id: 15,
  600. name: "Winter Cap",
  601. price: 600,
  602. scale: 120,
  603. desc: "allows you to move at normal speed in snow",
  604. coldM: 1
  605. }, {
  606. id: 5,
  607. name: "Cowboy Hat",
  608. price: 1e3,
  609. scale: 120,
  610. desc: "no effect"
  611. }, {
  612. id: 4,
  613. name: "Ranger Hat",
  614. price: 2e3,
  615. scale: 120,
  616. desc: "no effect"
  617. }, {
  618. id: 18,
  619. name: "Explorer Hat",
  620. price: 2e3,
  621. scale: 120,
  622. desc: "no effect"
  623. }, {
  624. id: 31,
  625. name: "Flipper Hat",
  626. price: 2500,
  627. scale: 120,
  628. desc: "have more control while in water",
  629. watrImm: !0
  630. }, {
  631. id: 1,
  632. name: "Marksman Cap",
  633. price: 3e3,
  634. scale: 120,
  635. desc: "increases arrow speed and range",
  636. aMlt: 1.3
  637. }, {
  638. id: 10,
  639. name: "Bush Gear",
  640. price: 3e3,
  641. scale: 160,
  642. desc: "allows you to disguise yourself as a bush"
  643. }, {
  644. id: 48,
  645. name: "Halo",
  646. price: 3e3,
  647. scale: 120,
  648. desc: "no effect"
  649. }, {
  650. id: 6,
  651. name: "Soldier Helmet",
  652. price: 4e3,
  653. scale: 120,
  654. desc: "reduces damage taken but slows movement",
  655. spdMult: .94,
  656. dmgMult: .75
  657. }, {
  658. id: 23,
  659. name: "Anti Venom Gear",
  660. price: 4e3,
  661. scale: 120,
  662. desc: "makes you immune to poison",
  663. poisonRes: 1
  664. }, {
  665. id: 13,
  666. name: "Medic Gear",
  667. price: 5e3,
  668. scale: 110,
  669. desc: "slowly regenerates health over time",
  670. healthRegen: 3
  671. }, {
  672. id: 9,
  673. name: "Miners Helmet",
  674. price: 5e3,
  675. scale: 120,
  676. desc: "earn 1 extra gold per resource",
  677. extraGold: 1
  678. }, {
  679. id: 32,
  680. name: "Musketeer Hat",
  681. price: 5e3,
  682. scale: 120,
  683. desc: "reduces cost of projectiles",
  684. projCost: .5
  685. }, {
  686. id: 7,
  687. name: "Bull Helmet",
  688. price: 6e3,
  689. scale: 120,
  690. desc: "increases damage done but drains health",
  691. healthRegen: -5,
  692. dmgMultO: 1.5,
  693. spdMult: .96
  694. }, {
  695. id: 22,
  696. name: "Emp Helmet",
  697. price: 6e3,
  698. scale: 120,
  699. desc: "turrets won't attack but you move slower",
  700. antiTurret: 1,
  701. spdMult: .7
  702. }, {
  703. id: 12,
  704. name: "Booster Hat",
  705. price: 6e3,
  706. scale: 120,
  707. desc: "increases your movement speed",
  708. spdMult: 1.16
  709. }, {
  710. id: 26,
  711. name: "Barbarian Armor",
  712. price: 8e3,
  713. scale: 120,
  714. desc: "knocks back enemies that attack you",
  715. dmgK: .6
  716. }, {
  717. id: 21,
  718. name: "Plague Mask",
  719. price: 1e4,
  720. scale: 120,
  721. desc: "melee attacks deal poison damage",
  722. poisonDmg: 5,
  723. poisonTime: 6
  724. }, {
  725. id: 46,
  726. name: "Bull Mask",
  727. price: 1e4,
  728. scale: 120,
  729. desc: "bulls won't target you unless you attack them",
  730. bullRepel: 1
  731. }, {
  732. id: 14,
  733. name: "Windmill Hat",
  734. topSprite: !0,
  735. price: 1e4,
  736. scale: 120,
  737. desc: "generates points while worn",
  738. pps: 1.5
  739. }, {
  740. id: 11,
  741. name: "Spike Gear",
  742. topSprite: !0,
  743. price: 1e4,
  744. scale: 120,
  745. desc: "deal damage to players that damage you",
  746. dmg: .45
  747. }, {
  748. id: 53,
  749. name: "Turret Gear",
  750. topSprite: !0,
  751. price: 1e4,
  752. scale: 120,
  753. desc: "you become a walking turret",
  754. turret: {
  755. proj: 1,
  756. range: 700,
  757. rate: 2500
  758. },
  759. spdMult: .7
  760. }, {
  761. id: 20,
  762. name: "Samurai Armor",
  763. price: 12e3,
  764. scale: 120,
  765. desc: "increased attack speed and fire rate",
  766. atkSpd: .78
  767. }, {
  768. id: 58,
  769. name: "Dark Knight",
  770. price: 12e3,
  771. scale: 120,
  772. desc: "restores health when you deal damage",
  773. healD: .4
  774. }, {
  775. id: 27,
  776. name: "Scavenger Gear",
  777. price: 15e3,
  778. scale: 120,
  779. desc: "earn double points for each kill",
  780. kScrM: 2
  781. }, {
  782. id: 40,
  783. name: "Tank Gear",
  784. price: 15e3,
  785. scale: 120,
  786. desc: "increased damage to buildings but slower movement",
  787. spdMult: .3,
  788. bDmg: 3.3
  789. }, {
  790. id: 52,
  791. name: "Thief Gear",
  792. price: 15e3,
  793. scale: 120,
  794. desc: "steal half of a players gold when you kill them",
  795. goldSteal: .5
  796. }, {
  797. id: 55,
  798. name: "Bloodthirster",
  799. price: 2e4,
  800. scale: 120,
  801. desc: "Restore Health when dealing damage. And increased damage",
  802. healD: .25,
  803. dmgMultO: 1.2
  804. }, {
  805. id: 56,
  806. name: "Assassin Gear",
  807. price: 2e4,
  808. scale: 120,
  809. desc: "Go invisible when not moving. Can't eat. Increased speed",
  810. noEat: !0,
  811. spdMult: 1.1,
  812. invisTimer: 1e3
  813. }]
  814.  
  815. let msgpack5 = window.msgpack; //msgpack hahah
  816. document.msgpack = msgpack5;
  817.  
  818. let autoAttack;
  819. let freeze;
  820. function dist(a, b){
  821. return Math.sqrt( Math.pow((b.y-a[2]), 2) + Math.pow((b.x-a[1]), 2) );
  822. }
  823. function acc(id) {
  824. doNewSend(["c", [1, id, 1]]);
  825. doNewSend(["c", [0, 0, 1]]);
  826. doNewSend(["c", [0, id, 1]]);
  827. }
  828.  
  829. function hat(id) {
  830. doNewSend(["c", [1, id, 0]]);
  831. doNewSend(["c", [0, id, 0]]);
  832. }
  833. let treeList = [], bushList = [], stoneList = [], goldList = [], followingfarm = false, followingtype = null, LED = Date.now(), playerss = []
  834. let handleMessage = function(e) {
  835. let temp = msgpack5.decode(new Uint8Array(e.data));
  836. let data = null;
  837. if(temp.length > 1) {
  838. data = [temp[0], ...temp[1]];
  839. if (data[1] instanceof Array){
  840. data = data;
  841. }
  842. } else {
  843. data = temp;
  844. }
  845. let item = data[0];
  846. if(!data) {return};
  847. if (item == "io-init") {
  848. const touchscreen = document.getElementById('touch-controls-fullscreen');
  849. let cvs = document.getElementById("gameCanvas");
  850. //setTimeout(() => { if (document.getElementById("mainMenu")) { document.getElementById("mainMenu").remove(); } }, 5000);
  851. let width = touchscreen.clientWidth;
  852. let height = touchscreen.clientHeight;
  853. $(window).resize(function() {
  854. width = touchscreen.clientWidth;
  855. height = touchscreen.clientHeight;
  856. });
  857. let place = (e, t = dir) => {
  858. doNewSend(['z', [e, null]]);
  859. doNewSend(['F', [1, t]]);
  860. doNewSend(['F', [0, t]]);
  861. doNewSend(['z', [1]]);
  862. }
  863. let placeForAll = (e, t = dir) => {
  864. sendForAll(['z', [e, null]]);
  865. sendForAll(['F', [1, t]]);
  866. sendForAll(['F', [0, t]]);
  867. sendForAll(['z', [1]]);
  868. }
  869. touchscreen.addEventListener('mousemove', e => {
  870. mouseX = e.clientX;
  871. mouseY = e.clientY;
  872. dir = Math.atan2(event.clientY - height / 2, event.clientX - width / 2)
  873. if (!autoaim && Date.now() - LED > 63) {
  874. LED = Date.now()
  875. if(followingfarm == true) {
  876. doNewSend(['D', [dir]]);
  877. } else {
  878. if(autoattack == true) {
  879. for (let i in sockets) {
  880. if(sockets[i].attack2 == false) {
  881. sockets[i].oldSend(new Uint8Array(Array.from(msgpack5.encode(e))));
  882. }
  883. }
  884. } else {
  885. if(cursor == true) {
  886. doNewSend(["D", [dir]])
  887. for(let i in bots) {
  888. sockets[i].oldSend(new Uint8Array(Array.from(msgpack5.encode(["D", [Math.atan2((myPlayer.y - bots[i].y) + mouseY - (height / 2), (myPlayer.x - bots[i].x) + mouseX - (width / 2))]]))))
  889. }
  890. } else {
  891. sendForAll(["D", [dir]])
  892. }
  893. }
  894. }
  895. }
  896. })
  897. document.key22 = 1;
  898. document.addEventListener('keydown', e => {
  899. if (document.key22 !== e.keyCode) {
  900. document.key22 = e.keyCode;
  901. if (document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea" && !document.getElementById('chatHolder').offsetParent) {
  902. if (e.keyCode == 82) {
  903. if(e.repeat) return
  904. autoaim=true;
  905. doNewSend(["D", [cursor?(Math.atan2(mouseY - height / 2, mouseX - width / 2)):nearestEnemyAngle]])
  906. doNewSend(["K", [1]])
  907. doNewSend(["z", [15, 1]])
  908. setTimeout(() => {
  909. autoaim=false
  910. doNewSend(["K", [1]])
  911. }, 130)
  912. }
  913. if (e.keyCode == 70) {
  914. if(e.repeat) return
  915. sendForAll(["z", [boostType]])
  916. }
  917. if (e.keyCode == 86) {
  918. if(e.repeat) return
  919. sendForAll(["z", [spikeType]])
  920. }
  921. /*if (e.keyCode == 89) {
  922. healer = true;
  923. }
  924. if (e.keyCode == 86) {
  925. spiker = true;
  926. }
  927. if (e.keyCode == 70) {
  928. trapper = true;
  929. }
  930. if (e.keyCode == 54) {
  931. miller = true;
  932. }
  933. if (e.keyCode == 0) {
  934. healToggle = !healToggle;
  935. }
  936. if (e.keyCode == 39) {
  937. hatToggle = !hatToggle;
  938. }
  939. if (e.keyCode == 40) {
  940. empToggle = !empToggle;
  941. }*/
  942. if (e.keyCode == 80) {
  943. pointer = !pointer;
  944. }
  945. /*if (e.keyCode == 84) {
  946. autoaim = true;
  947. doNewSend(["13c", [1, 6, 0]]);
  948. doNewSend(["13c", [1, 7, 0]]);
  949. doNewSend(["13c", [1, 53, 0]]);
  950. autoAttackWithAim3 = true;
  951. doNewSend(['c', [1]])
  952. doNewSend(["H", [5]]);
  953. doNewSend(["H", [17]]);
  954. doNewSend(["H", [31]]);
  955. doNewSend(["H", [23]]);
  956. doNewSend(["H", [9]]);
  957. doNewSend(["H", [18]]);
  958. doNewSend(['5', [9, true]]);
  959. doNewSend(["13c", [0, 53, 0]]);
  960. setTimeout(() => {
  961. doNewSend(['6', [12]]);
  962. }, 130);
  963. setTimeout(() => {
  964. doNewSend(['6', [15]])
  965. doNewSend(['5', [secondary, true]]);
  966. setTimeout(() => {
  967. sendForAll(['5', [primary, true]])
  968. if (!empToggle) {
  969. doNewSend(["13c", [1, 6, 0]]);
  970. doNewSend(["13c", [0, 6, 0]]);
  971. }
  972. if (empToggle) {
  973. doNewSend(["13c", [1, 22, 0]]);
  974. doNewSend(["13c", [0, 22, 0]]);
  975. }
  976. autoaim = false;
  977. autoAttackWithAim3 = false;
  978. doNewSend(['c', [0]])
  979. doNewSend(["2", [dir]]);
  980. }, 270);
  981. }, 210);
  982. }
  983. if (e.keyCode == 0) {
  984. for (let i=0;i<180;i++) {
  985. let angle = toRad(i*2);
  986. place(boostType, angle);
  987. }
  988. }
  989. if (e.keyCode == 0) {
  990. for (let i=0;i<4;i++) {
  991. let angle = toRad(i * 90);
  992. place(spikeType, angle);
  993. }
  994. }
  995. if (e.keyCode == 77) {
  996. if (myPlayer.y < 2400) {
  997. doNewSend(["13c", [1, 15, 0]]);
  998. doNewSend(["13c", [0, 15, 0]]);
  999. } else if (myPlayer.y > 6850 && myPlayer.y < 7550) {
  1000. doNewSend(["13c", [1, 31, 0]]);
  1001. doNewSend(["13c", [0, 31, 0]]);
  1002. } else {
  1003. doNewSend(["13c", [1, 12, 0]]);
  1004. doNewSend(["13c", [0, 12, 0]]);
  1005. }
  1006. doNewSend(["13c", [1, 0, 1]]);
  1007. doNewSend(["13c", [0, 0, 1]]);
  1008. }
  1009. if (e.keyCode == 37) {
  1010. sendForAll(["H", [8]]);
  1011. sendForAll(["H", [3]]);
  1012. sendForAll(["H", [5]]);
  1013. }
  1014. if(e.keyCode == 39) {
  1015. sendForAll(["H", [8]]);
  1016. sendForAll(["H", [4]]);
  1017. sendForAll(["H", [5]]);
  1018. sendForAll(["H", [10]]);
  1019. sendForAll(["H", [28]]);
  1020. sendForAll(["H", [10]]);
  1021. }
  1022. if(e.keyCode == 16) {
  1023. sendForAll(["13c", [0, 0, 0]]);
  1024. sendForAll(["13c", [0, 0, 1]]);
  1025. }
  1026. if (e.keyCode == 38) {
  1027. sendForAll(["H", [5]]);
  1028. sendForAll(["H", [17]]);
  1029. sendForAll(["H", [31]]);
  1030. sendForAll(["H", [23]]);
  1031. sendForAll(["H", [13]]);
  1032. sendForAll(["H", [18]]);
  1033. sendForAll(["H", [28]]);
  1034. }
  1035. if (e.keyCode == 120) {
  1036. sendForAll(["H", [4]]);
  1037. sendForAll(["H", [15]]);
  1038. }
  1039. if (e.keyCode == 90) {
  1040. sendForAll(["13c", [0, 0, 1]]);
  1041. sendForAll(["13c", [1, 40, 0]]);
  1042. sendForAll(["13c", [0, 40, 0]]);
  1043. }
  1044. if (e.keyCode == 32) {
  1045. if (!empToggle) {
  1046. sendForAll(["13c", [0, 0, 1]]);
  1047. sendForAll(["13c", [1, 6, 0]]);
  1048. sendForAll(["13c", [0, 6, 0]]);
  1049. }
  1050. if (empToggle) {
  1051. sendForAll(["13c", [1, 22, 0]]);
  1052. sendForAll(["13c", [0, 22, 0]]);
  1053. }
  1054. }
  1055. if (e.keyCode == 66) {
  1056. sendForAll(["13c", [0, 0, 1]]);
  1057. sendForAll(["13c", [1, 7, 0]]);
  1058. sendForAll(["13c", [0, 7, 0]]);
  1059. }
  1060. if (e.keyCode == 45) {
  1061. doNewSend(["13c", [1, 6, 0]]);
  1062. doNewSend(["13c", [1, 7, 0]]);
  1063. doNewSend(["13c", [1, 53, 0]]);
  1064. autoInsta = true;
  1065. }
  1066. if (e.keyCode == 46) {
  1067. autoInsta = false;
  1068. }
  1069. if (e.keyCode == 85) {
  1070. sendForAll(["13c", [1, 20, 0]]);
  1071. sendForAll(["13c", [0, 20, 0]]);
  1072. }
  1073. if (e.keyCode == 114) {
  1074. sendForAll(["H", [28]]);
  1075. }
  1076. if (e.keyCode == 115) {
  1077. sendForAll(["H", [4]]);
  1078. sendForAll(["H", [25]]);
  1079. }*/
  1080. }
  1081. }
  1082. })
  1083. document.addEventListener('keyup', e => {
  1084. document.key22 = null;
  1085. if (e.keyCode == 81) {
  1086. healer = false;
  1087. }
  1088. if (e.keyCode == 86) {
  1089. spiker = false;
  1090. }
  1091. if (e.keyCode == 70) {
  1092. trapper = false;
  1093. }
  1094. if (e.keyCode == 54) {
  1095. miller = false;
  1096. }
  1097. })
  1098. setInterval(() => {
  1099. if (autoaim) {
  1100. doNewSend(['D', [nearestEnemyAngle]]);
  1101. }
  1102. if (autoAttackWithAim3) {
  1103. doNewSend(['F', [1]]);
  1104. }
  1105. if (crashing && !closed) {
  1106. for (let e = 0; e < 1000; e++) {
  1107. let result = new Uint8Array(Math.round(Math.random() * 18));for (let i = 0; i < result.length; i++) {if (i == 0) {result[i] = Math.round(Math.random() * 256);} else {if (i == 1) {result[i] = Math.round(Math.random() * 256);} else {if (i == 2) {result[i] = Math.round(Math.random() * 128);} else {if (i == 3) {result[i] = Math.round(Math.random() * 85);} else {if (i == 4) {result[i] = Math.round(Math.random() * 64);} else {if (i == 5) {result[i] = Math.round(Math.random() * 51);} else {if (i == 6) {result[i] = Math.round(Math.random() * 42);} else {if (i == 7) {result[i] = Math.round(Math.random() * 36);} else {if (i == 8) {result[i] = Math.round(Math.random() * 32);} else {if (i == 9) {result[i] = Math.round(Math.random() * 28);} else {if (i == 10) {result[i] = Math.round(Math.random() * 25);} else {if (i == 11) {result[i] = Math.round(Math.random() * 23);} else {if (i == 12) {result[i] = Math.round(Math.random() * 21);} else {if (i == 13) {result[i] = Math.round(Math.random() * 19);} else {if (i == 14) {result[i] = Math.round(Math.random() * 18);} else {if (i == 15) {result[i] = Math.round(Math.random() * 17);} else {if (i == 16) {result[i] = Math.round(Math.random() * 16);} else {if (i == 17) {result[i] = Math.round(Math.random() * 15);}}}}}}}}}}}}}}}}}}}ws.oldSend(result);
  1108. }
  1109. }
  1110. if (healer) {
  1111. place(foodType, null);
  1112. }
  1113. if (spiker) {
  1114. place(spikeType, null);
  1115. }
  1116. if (trapper) {
  1117. place(boostType, null);
  1118. }
  1119. if (miller) {
  1120. place(millType, null);
  1121. }
  1122. }, 100)
  1123. primary = 0;
  1124. foodType = 0;
  1125. wallType = 3;
  1126. spikeType = 6;
  1127. millType = 10;
  1128. myPlayer.weapon = 0;
  1129. doNewSend(['M', [{name: localStorage.moo_name, moofoll: "1", skin: 4}]]);
  1130. setTimeout(() => {
  1131. let kk;
  1132. let host = "127.0.0.1" !== location.hostname && !location.hostname.startsWith("192.168.");
  1133. for (let i2 = 0; i2 < 4; i2++) {
  1134. const urlBase = document.ws.url.split("token=")[0];
  1135. const token = encodeURIComponent("alt:" + $i);
  1136. wsType(`${urlBase}token=${token}`);
  1137. }
  1138. }, 100);
  1139. }
  1140. if (item == "C" && !myPlayer.id) {
  1141. myPlayer.id = data[1];
  1142. }
  1143. if (item == "D") {
  1144. playerss.push({
  1145. sid: data[1][1],
  1146. name: data[1][2]
  1147. })
  1148. }
  1149. if (item == "E") {
  1150. let t = playerss.findIndex(e=>e.sid==data[1])
  1151. if(t !== undefined) {
  1152. playerss.splice(t, 1)
  1153. }
  1154. }
  1155. if (item == "H") {
  1156. for(let i = 0; i < data[1].length/8; i++) {
  1157. let objectData = data[1].slice(8*i, 8*i+8)
  1158. if(objectData[6] == null) {
  1159. if(objectData[5] == 0) {
  1160. treeList.push({
  1161. x: objectData[1],
  1162. y: objectData[2]
  1163. })
  1164. } else if (objectData[5] == 1) {
  1165. bushList.push({
  1166. x: objectData[1],
  1167. y: objectData[2]
  1168. })
  1169. } else if (objectData[5] == 2) {
  1170. stoneList.push({
  1171. x: objectData[1],
  1172. y: objectData[2]
  1173. })
  1174. } else if (objectData[5] == 3) {
  1175. goldList.push({
  1176. x: objectData[1],
  1177. y: objectData[2]
  1178. })
  1179. }
  1180. }
  1181. }
  1182. }
  1183. if (item == "N") {
  1184. if(data[1] == "kills") {
  1185. sendForAll(["6", ["gg - Get Deleted"]], true)
  1186. }
  1187. }
  1188. if (item == "P") {
  1189. primary = 0;
  1190. foodType = 0;
  1191. wallType = 3;
  1192. spikeType = 6;
  1193. millType = 10;
  1194. if (!autoAttack && !freeze) {
  1195. doNewSend(['M', [{name: localStorage.moo_name, moofoll: "1", skin: 4}]]);
  1196. } else {
  1197. JustDied = true;
  1198. }
  1199. let e = setInterval(() => {
  1200. if(document.getElementById('mainMenu').style.display == "block") {
  1201. clearInterval(e)
  1202. document.getElementById('mainMenu').style.display = "none"
  1203. }
  1204. })
  1205. }
  1206. if (JustDied) {
  1207. if (!autoAttack && !freeze) {
  1208. JustDied = false;
  1209. doNewSend(['M', [{name: localStorage.moo_name, moofoll: "1", skin: 4}]]);
  1210. }
  1211. }
  1212. if (item == "X") {
  1213. //console.log(data)
  1214. }
  1215. if (item == "a") {
  1216. enemiesNear = [];
  1217. players = {};
  1218. for(let i = 0; i < data[1].length / 13; i++) {
  1219. let playerInfo = data[1].slice(13*i, 13*i+13);
  1220. if(playerInfo[0] == myPlayer.id) {
  1221. myPlayer.x = playerInfo[1];
  1222. myPlayer.y = playerInfo[2];
  1223. myPlayer.dir = playerInfo[3];
  1224. myPlayer.object = playerInfo[4];
  1225. myPlayer.clan = playerInfo[7];
  1226. myPlayer.isLeader = playerInfo[8];
  1227. myPlayer.hat = playerInfo[9];
  1228. myPlayer.accessory = playerInfo[10];
  1229. myPlayer.isSkull = playerInfo[11];
  1230. } else if(playerInfo[7] !== myPlayer.clan || playerInfo[7] === null) {
  1231. enemiesNear.push(playerInfo);
  1232. }
  1233. let U = players[playerInfo[0]]
  1234. if(U && (U.clan !== myPlayer.clan && myPlayer.clan !== null || myPlayer.clan == null)) {
  1235. if(Math.sqrt(Math.pow(U.x - playerInfo[1], 2)+Math.pow(U.y - playerInfo[2], 2)) >= 70 && (Math.abs(Math.atan2(playerInfo[2] - U.y, playerInfo[1] - U.x) - Math.atan2(playerInfo[2] - myPlayer.y, playerInfo[1] - myPlayer.x)) % (2 * Math.PI)) < Math.PI/4) {
  1236. let dir = Math.atan2(playerInfo[2] - myPlayer.y, playerInfo[1] - myPlayer.x)
  1237. if(boostType) {
  1238. sendForAll(["z", [boostType]])
  1239. sendForAll(["F", [1, dir]])
  1240. sendForAll(["z", [boostType]])
  1241. sendForAll(["F", [1, dir+Math.PI/2]])
  1242. sendForAll(["z", [boostType]])
  1243. sendForAll(["F", [1, dir-Math.PI/2]])
  1244. sendForAll(["z", [boostType]])
  1245. sendForAll(["F", [1, dir+Math.PI]])
  1246. sendForAll(["F", [0]])
  1247. sendForAll(["z", [null]])
  1248. } else {
  1249. sendForAll(["z", [spikeType]])
  1250. sendForAll(["F", [1, dir]])
  1251. sendForAll(["z", [spikeType]])
  1252. sendForAll(["F", [1, dir+Math.PI/2]])
  1253. sendForAll(["z", [spikeType]])
  1254. sendForAll(["F", [1, dir-Math.PI/2]])
  1255. sendForAll(["z", [spikeType]])
  1256. sendForAll(["F", [1, dir+Math.PI]])
  1257. sendForAll(["F", [0]])
  1258. sendForAll(["z", [null]])
  1259. }
  1260. }
  1261. }
  1262. players[playerInfo[0]] = {
  1263. id: playerInfo[0],
  1264. x: playerInfo[1],
  1265. y: playerInfo[2],
  1266. dir: playerInfo[3],
  1267. object: playerInfo[4],
  1268. weapon: playerInfo[5],
  1269. clan: playerInfo[7],
  1270. isLeader: playerInfo[8],
  1271. hat: playerInfo[9],
  1272. accessory: playerInfo[10],
  1273. isSkull: playerInfo[11]
  1274. };
  1275. }
  1276. isEnemyNear = false;
  1277. if(enemiesNear) {
  1278. nearestEnemy = enemiesNear.sort((a,b) => dist(a, myPlayer) - dist(b, myPlayer))[0];
  1279. }
  1280. if(nearestEnemy) {
  1281. nearestEnemyAngle = Math.atan2(nearestEnemy[2]-myPlayer.y, nearestEnemy[1]-myPlayer.x);
  1282. if(Math.sqrt(Math.pow((myPlayer.y-nearestEnemy[2]), 2) + Math.pow((myPlayer.x-nearestEnemy[1]), 2)) < 500) {
  1283. isEnemyNear = true;
  1284. if(autoaim == false && myPlayer.hat != 7 && myPlayer.hat != 53) {
  1285. normalHat = 6;
  1286. if(primary != 8) {
  1287. normalAcc = 19;
  1288. }
  1289. };
  1290. }
  1291. }
  1292. /*if (autoaim) {
  1293. doNewSend(['2', [nearestEnemyAngle]]);
  1294. }*/
  1295. if (autoAttackWithAim3) {
  1296. doNewSend(['F', [1]]);
  1297. }
  1298. if(isEnemyNear == false && autoaim == false) {
  1299. normalAcc = 0;
  1300. if (myPlayer.y < 2400){
  1301. normalHat = 15;
  1302. } else if (myPlayer.y > 6850 && myPlayer.y < 7550){
  1303. normalHat = 31;
  1304. } else {
  1305. normalHat = 12;
  1306. }
  1307. }
  1308. if(hatToggle) {
  1309. if(oldHat != normalHat) {
  1310. hat(normalHat);
  1311. }
  1312. if(oldAcc != normalAcc) {
  1313. acc(normalAcc);
  1314. }
  1315. oldHat = normalHat;
  1316. oldAcc = normalAcc
  1317. }
  1318. if (nearestEnemy && autoInsta) {
  1319. if (Math.sqrt(Math.pow((myPlayer.y-nearestEnemy[2]), 2) + Math.pow((myPlayer.x-nearestEnemy[1]), 2)) < 215) {
  1320. autoInsta = false;
  1321. autoaim = true;
  1322. doNewSend(['9', [nearestEnemyAngle]]);
  1323. setTimeout(() => {
  1324. doNewSend(['9', []]);
  1325. doNewSend(['c', [0, 11, 1]]);
  1326. }, 300)
  1327. doNewSend(['K', [1]]);
  1328. if (myPlayer.weapon == 0) {
  1329. doNewSend(["H", [5]]);
  1330. doNewSend(["H", [17]]);
  1331. doNewSend(["H", [31]]);
  1332. doNewSend(["H", [23]]);
  1333. doNewSend(["H", [10]]);
  1334. doNewSend(["H", [18]]);
  1335. doNewSend(["H", [28]]);
  1336. }
  1337. doNewSend(["H", [15]]);
  1338. doNewSend(['c', [0, 0, 1]])
  1339. doNewSend(['c', [0, 19, 1]])
  1340. doNewSend(['c', [0, 7, 0]])
  1341. doNewSend(["z", [primary, 1]]);
  1342. for (let i = 0; i < 25; i++) {
  1343. doNewSend(['F', [1, nearestEnemyAngle]]);
  1344. }
  1345. setTimeout(() => {
  1346. doNewSend(['c', [0, 53, 0]]);
  1347. doNewSend(["z", [15, 1]]);
  1348. doNewSend(["z", [secondary, 1]]);
  1349. setTimeout(() => {
  1350. autoaim = false;
  1351. doNewSend(["z", [primary, 1]]);
  1352. if (!empToggle) {
  1353. doNewSend(["c", [1, 6, 0]]);
  1354. doNewSend(["c", [0, 6, 0]]);
  1355. }
  1356. if (empToggle) {
  1357. doNewSend(["c", [1, 22, 0]]);
  1358. doNewSend(["c", [0, 22, 0]]);
  1359. }
  1360. doNewSend(['K', [1]]);
  1361. doNewSend(['F', [0]]);
  1362. }, 270);
  1363. }, 130);
  1364. }
  1365. }
  1366. if (pointer) {
  1367. pointingOnPosition = {x: myPlayer.x, y: myPlayer.y};
  1368. }
  1369. }
  1370. if (item == "V") {
  1371. if (data[2]) {
  1372. primary = data[1][0];
  1373. secondary = data[1][1] || null;
  1374. } else {
  1375. for (let i = 0; i < data[1].length; i++) {
  1376. for (let i2 = 0; i2 < 3; i2++) {
  1377. if (i2 == data[1][i]) {
  1378. foodType = data[1][i];
  1379. }
  1380. }
  1381. for (let i2 = 3; i2 < 6; i2++) {
  1382. if (i2 == data[1][i]) {
  1383. wallType = data[1][i];
  1384. }
  1385. }
  1386. for (let i2 = 6; i2 < 10; i2++) {
  1387. if (i2 == data[1][i]) {
  1388. spikeType = data[1][i];
  1389. }
  1390. }
  1391. for (let i2 = 10; i2 < 13; i2++) {
  1392. if (i2 == data[1][i]) {
  1393. millType = data[1][i];
  1394. }
  1395. }
  1396. for (let i2 = 13; i2 < 15; i2++) {
  1397. if (i2 == data[1][i]) {
  1398. mineType = data[1][i];
  1399. }
  1400. }
  1401. for (let i2 = 15; i2 < 17; i2++) {
  1402. if (i2 == data[1][i]) {
  1403. boostType = data[1][i];
  1404. }
  1405. }
  1406. for (let i2 = 17; i2 < 23; i2++) {
  1407. if (i2 == data[1][i] && i2 !== 20) {
  1408. turretType = data[1][i];
  1409. }
  1410. }
  1411. spawnpadType = 20;
  1412. }
  1413. }
  1414. }
  1415. //player receive
  1416. if (item == "6") {
  1417. if (data[2].toLocaleLowerCase() == '!dc multibox' && data[1] == myPlayer.id) { // crash
  1418. crashing = true;
  1419. }
  1420. if (data[2].toLocaleLowerCase() == '!come' && data[1] == myPlayer.id) {
  1421. playerFollowerGlobal = true;
  1422. }
  1423. if (data[2].toLocaleLowerCase() == '!stop' && data[1] == myPlayer.id) {
  1424. playerFollowerGlobal = false;
  1425. }
  1426. if (data[2].toLocaleLowerCase() == '!go' && data[1] == myPlayer.id) { //lazy to do mouse move
  1427. ffs = true;
  1428. }
  1429. if (data[2].toLocaleLowerCase() == '!stopp' && data[1] == myPlayer.id) {
  1430. ffs = false;
  1431. }
  1432. if (data[2].toLowerCase() == "!aim" && data[1] == myPlayer.id) { // aim to cursor
  1433. cursor = !cursor
  1434. }
  1435. if (data[2].toLowerCase() == "!f" && data[1] == myPlayer.id) { // follow
  1436. playerFollowerGlobal = true
  1437. followingfarm = false
  1438. ffs = false
  1439. for (let i in sockets) {
  1440. sockets[i].attack = false
  1441. }
  1442. autoattack = false
  1443. }
  1444. if (data[2].toLowerCase().startsWith("!let") && data[1] == myPlayer.id) { // come
  1445. let pl = playerss.find(e=>e.name.toLowerCase().startsWith(data[2].slice(5).toLowerCase()))
  1446. friend.push(pl.sid)
  1447. }
  1448. if (data[2].toLowerCase() == "!rlet" && data[1] == myPlayer.id) {
  1449. friend = []
  1450. }
  1451. if (data[2].toLowerCase().includes("!send") && data[1] == myPlayer.id) { // send bot
  1452. if(!isNaN(data[2].slice(6))) {
  1453. for (let i2 = 0; i2 < data[2].slice(6); i2++) {
  1454. const urlBase = document.ws.url.split("token=")[0];
  1455. const token = encodeURIComponent("alt:" + $i);
  1456. wsType(`${urlBase}token=${token}`);
  1457. }
  1458. }
  1459. }
  1460. if (data[2].toLocaleLowerCase() == '!-' && data[1] == myPlayer.id) {
  1461. setTimeout(() => {
  1462. let kk;
  1463. let host = "127.0.0.1" !== location.hostname && !location.hostname.startsWith("192.168.");
  1464. for (let i2 = 0; i2 < 4; i2++) {
  1465. const urlBase = document.ws.url.split("token=")[0];
  1466. const token = encodeURIComponent("alt:" + $i);
  1467. wsType(`${urlBase}token=${token}`);
  1468. }
  1469. }, 100);
  1470. }
  1471. }
  1472. if(data[0] == "O" && data[1] == myPlayer.id) {
  1473. if(data[2] > 0) {
  1474. if (healToggle) {
  1475. setTimeout(() => {
  1476. doNewSend(['z', [foodType, null]]);
  1477. doNewSend(['F', [1]]);
  1478. doNewSend(['F', [0]]);
  1479. doNewSend(['z', [null]]);
  1480. }, 100);
  1481. }
  1482. }
  1483. }
  1484. }
  1485. function toRad(angle) {
  1486. return angle * (Math.PI / 180);
  1487. }
  1488. let doNewSend = (e) => {
  1489. ws.oldSend(new Uint8Array(Array.from(msgpack5.encode(e))));
  1490. }
  1491. let commandList = ["!wood", "!food", "!stone", "!gold", "~age", "~wood", "~food", "~stone", "~gold", "!attack on", "!attack off"]
  1492. WebSocket.prototype.oldSend = WebSocket.prototype.send;
  1493. WebSocket.prototype.send = function(m) {
  1494. if (!ws) {
  1495. ws = this;
  1496. document.ws = this;
  1497. this.addEventListener('message', e => { handleMessage(e); });
  1498. this.addEventListener('close', () => { closed = true; });
  1499. }
  1500. if (!closed) {
  1501. if (msgpack5.decode(m)[0] !== "D" && msgpack5.decode(m)[0] !== "F" && msgpack5.decode(m)[0] !== "9" && msgpack5.decode(m)[0] !== "6" && msgpack5.decode(m)[0] !== "H" && msgpack5.decode(m)[0] !== "z" && msgpack5.decode(m)[0] !== "c" && msgpack5.decode(m)[0] !== "K") {
  1502. this.oldSend(m);
  1503. }
  1504. if (msgpack5.decode(m)[0] == "F") {
  1505. sendForAll(msgpack5.decode(m));
  1506. }
  1507. if (msgpack5.decode(m)[0] == "H") {
  1508. sendForAll(msgpack5.decode(m), true);
  1509. }
  1510. if (msgpack5.decode(m)[0] == "z") {
  1511. sendForAll(msgpack5.decode(m));
  1512. }
  1513. if (msgpack5.decode(m)[0] == "K") {
  1514. if (msgpack5.decode(m)[1][0] == 1) {
  1515. autoAttack = !autoAttack;
  1516. }
  1517. if (msgpack5.decode(m)[1][0] == 0) {
  1518. freeze = !freeze;
  1519. }
  1520. sendForAll(msgpack5.decode(m), true);
  1521. }
  1522. if (msgpack5.decode(m)[0] == "6") {
  1523. try {
  1524. this.oldSend(m);
  1525. if (msgpack5.decode(m)[1][0].toLocaleLowerCase() !== '!f' && msgpack5.decode(m)[1][0].toLocaleLowerCase() !== '!fs' && msgpack5.decode(m)[1][0].toLocaleLowerCase().split(" ")[0] !== '!join' && msgpack5.decode(m)[1][0].toLocaleLowerCase().split(" ")[0] !== '!leave' && msgpack5.decode(m)[1][0].toLocaleLowerCase().split(" ")[0] !== '!bye' && !commandList.includes(msgpack5.decode(m)[1][0].toLocaleLowerCase()) && !(msgpack5.decode(m)[1][0].toLocaleLowerCase().startsWith("!let") || msgpack5.decode(m)[1][0].toLocaleLowerCase().startsWith("!rlet"))) {
  1526. for (let i in sockets) {
  1527. sockets[i].oldSend(m);
  1528. }
  1529. }
  1530. } catch (err) {}
  1531. }
  1532. if (msgpack5.decode(m)[0] == "c") {
  1533. sendForAll(msgpack5.decode(m), true);
  1534. }
  1535. if (msgpack5.decode(m)[0] == "9") {
  1536. this.oldSend(m);
  1537. for (let i in sockets) {
  1538. if (!sockets[i].playerFollower && !playerFollowerGlobal && !ffs) {
  1539. sockets[i].oldSend(m);
  1540. }
  1541. }
  1542. }
  1543. }
  1544. }
  1545. let sendForAll = (e, count) => {
  1546. doNewSend(e);
  1547. try {
  1548. if(Object.keys(sockets).filter(e=>e!=undefined).length > 0 && (!count?followingfarm == false:true)) {
  1549. for (let i in sockets) {
  1550. sockets[i].oldSend(new Uint8Array(Array.from(msgpack5.encode(e))));
  1551. }
  1552. }
  1553. } catch (err) {
  1554.  
  1555. }
  1556. };
  1557.  
  1558. let friend = []
  1559. let autoattack = false
  1560.  
  1561. function wsType(e) {
  1562. let ws = new WebSocket(e);
  1563. console.log(e);
  1564. ws.playerFollower = true;
  1565. ws.autoAttackWithAim3;
  1566. ws.autoAttackWithAim4 = [false, null];
  1567. ws.autoAttackWithAim5 = [false, null]
  1568. ws.attack = false
  1569. ws.autoattack2 = false
  1570. let bot = {}, age = 1;
  1571. let attacking = false, attacking2 = false
  1572. ws.binaryType = "arraybuffer";
  1573. let doNewSend = (e) => {
  1574. ws.connected && (ws.oldSend(new Uint8Array(Array.from(msgpack5.encode(e)))));
  1575. }
  1576. let msgFnc = (e) => {
  1577. let temp = msgpack5.decode(new Uint8Array(e.data));
  1578. let data = null;
  1579. if(temp.length > 1) {
  1580. data = [temp[0], ...temp[1]];
  1581. if (data[1] instanceof Array){
  1582. data = data;
  1583. }
  1584. } else {
  1585. data = temp;
  1586. }
  1587. let item = data[0];
  1588. if(!data) {return};
  1589. if (item == "io-init") {
  1590. ws.connected = !0
  1591. let place = (e, t = dir) => {
  1592. doNewSend(['z', [e, null]]);
  1593. doNewSend(['F', [1, t]]);
  1594. doNewSend(['F', [0, t]]);
  1595. doNewSend(['z', [null]]);
  1596. }
  1597. function storeEquip(id, index) {
  1598. doNewSend(["c", [0, id, index]]);
  1599. }
  1600.  
  1601. function storeBuy(id, index) {
  1602. doNewSend(["c", [1, id, index]]);
  1603. }
  1604. ws.key23 = null;
  1605. document.addEventListener('keydown', e => {
  1606. if (ws.key23 !== e.keyCode && ws.connected) {
  1607. ws.key23 = e.keyCode;
  1608. if (document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea" && !document.getElementById('chatHolder').offsetParent) {
  1609. if (e.keyCode == 82) {
  1610. if(e.repeat) return
  1611. ws.autoaim = true
  1612. doNewSend(["D", [cursor?(Math.atan2((myPlayer.y - bot.y) + mouseY - (height / 2), (myPlayer.x - bot.x) + mouseX - (width / 2))):ws.nearestEnemyAngle]])
  1613. doNewSend(["K", [1]])
  1614. doNewSend(["z", [15, 1]])
  1615. setTimeout(() => {
  1616. ws.autoaim = false
  1617. doNewSend(["K", [1]])
  1618. }, 130)
  1619. }
  1620. /*if (e.keyCode == 84) {
  1621. ws.autoaim = true;
  1622. doNewSend(["13c", [1, 6, 0]]);
  1623. doNewSend(["13c", [1, 7, 0]]);
  1624. doNewSend(["13c", [1, 53, 0]]);
  1625. doNewSend(["13c", [1, 21, 0]]);
  1626. ws.autoAttackWithAim3 = true;
  1627. doNewSend(['c', [1]])
  1628. doNewSend(["H", [5]]);
  1629. doNewSend(["H", [17]]);
  1630. doNewSend(["H", [31]]);
  1631. doNewSend(["H", [23]]);
  1632. doNewSend(["H", [9]]);
  1633. doNewSend(["H", [18]]);
  1634. doNewSend(['5', [9, true]]);
  1635. doNewSend(["13c", [0, 53, 0]]);
  1636. setTimeout(() => {
  1637. doNewSend(['6', [12]]);
  1638. }, 130);
  1639. setTimeout(() => {
  1640. doNewSend(['6', [15]])
  1641. doNewSend(['5', [secondary, true]]);
  1642. setTimeout(() => {
  1643. sendForAll(['5', [primary, true]])
  1644. if (!empToggle) {
  1645. doNewSend(["13c", [1, 6, 0]]);
  1646. doNewSend(["13c", [0, 6, 0]]);
  1647. }
  1648. if (empToggle) {
  1649. doNewSend(["13c", [1, 22, 0]]);
  1650. doNewSend(["13c", [0, 22, 0]]);
  1651. }
  1652. ws.autoaim = false;
  1653. ws.autoAttackWithAim3 = false;
  1654. doNewSend(['c', [0]])
  1655. doNewSend(["2", [dir]]);
  1656. }, 300);
  1657. }, 210);
  1658. }
  1659. if (e.keyCode == 79) {
  1660. for (let i=0;i<180;i++) {
  1661. let angle = toRad(i*2);
  1662. place(boostType, angle);
  1663. }
  1664. }
  1665. if (e.keyCode == 76) {
  1666. for (let i=0;i<4;i++) {
  1667. let angle = toRad(i * 90);
  1668. place(spikeType, angle);
  1669. }
  1670. }
  1671. if (e.keyCode == 77) {
  1672. if (bot.y < 2400) {
  1673. doNewSend(["13c", [1, 15, 0]]);
  1674. doNewSend(["13c", [0, 15, 0]]);
  1675. } else if (bot.y > 6850 && bot.y < 7550) {
  1676. doNewSend(["13c", [1, 31, 0]]);
  1677. doNewSend(["13c", [0, 31, 0]]);
  1678. } else {
  1679. doNewSend(["13c", [1, 12, 0]]);
  1680. doNewSend(["13c", [0, 12, 0]]);
  1681. }
  1682. doNewSend(["13c", [1, 11, 1]]);
  1683. doNewSend(["13c", [0, 11, 1]]);
  1684. }*/
  1685. /*if (e.keyCode == 45) {
  1686. doNewSend(['ch', ['Autoinsta:true']]);
  1687. doNewSend(["13c", [1, 6, 0]]);
  1688. doNewSend(["13c", [1, 7, 0]]);
  1689. doNewSend(["13c", [1, 53, 0]]);
  1690. ws.autoInsta = true;
  1691. }
  1692. if (e.keyCode == 46) {
  1693. doNewSend(['ch', ['Autoinsta:false']]);
  1694. ws.autoInsta = false;
  1695. }*/
  1696. }
  1697. }
  1698. })
  1699. document.addEventListener('keyup', e => {
  1700. ws.key23 = null;
  1701. })
  1702. //setInterval(() => {
  1703.  
  1704. /*if (healer) {
  1705. place(ws.foodType, null);
  1706. }
  1707. if (spiker) {
  1708. place(ws.spikeType, null);
  1709. }
  1710. if (trapper) {
  1711. place(ws.boostType, null);
  1712. }
  1713. if (miller) {
  1714. place(ws.millType, null);
  1715. }*/
  1716. //}, 100)
  1717. ws.primary = 0;
  1718. ws.foodType = 0;
  1719. ws.wallType = 3;
  1720. ws.spikeType = 6;
  1721. ws.millType = 10;
  1722. doNewSend(['M', [{name: localStorage.moo_name, moofoll: "lol", skin: 4}]]);
  1723. }
  1724. let place2 = (e, t = dir) => {
  1725. doNewSend(['z', [e, null]]);
  1726. doNewSend(['F', [1, t]]);
  1727. doNewSend(['F', [0, t]]);
  1728. doNewSend(['z', [null]]);
  1729. }
  1730. if (item == "C" && !bot.id) {
  1731. bot.id = data[1];
  1732. if (sockets) {
  1733. sockets[data[1]] = ws;
  1734. bots[data[1]] = bot;
  1735. }
  1736. }
  1737. if (item == "P") {
  1738. ws.primary = 0;
  1739. ws.foodType = 0;
  1740. ws.wallType = 3;
  1741. ws.spikeType = 6;
  1742. ws.millType = 10;
  1743. age = 1;
  1744. if (!autoAttack && !freeze) {
  1745. doNewSend(['M', [{name: localStorage.moo_name, moofoll: "acool", skin: 4}]]);
  1746. } else {
  1747. ws.JustDied = true;
  1748. }
  1749. }
  1750. if (ws.JustDied) {
  1751. if (!autoAttack && !freeze) {
  1752. ws.JustDied = false;
  1753. doNewSend(['M', [{name: localStorage.moo_name, moofoll: "u GaY", skin: 4}]]);
  1754. }
  1755. }
  1756. if (item == "a") {
  1757. ws.enemiesNear = [];
  1758. ws.players = {};
  1759. for(let i = 0; i < data[1].length / 13; i++) {
  1760. let playerInfo = data[1].slice(13*i, 13*i+13);
  1761. if(playerInfo[0] == bot.id) {
  1762. bot.x = playerInfo[1];
  1763. bot.y = playerInfo[2];
  1764. bot.dir = playerInfo[3];
  1765. bot.object = playerInfo[4];
  1766. bot.weapon = playerInfo[5];
  1767. bot.clan = playerInfo[7];
  1768. bot.isLeader = playerInfo[8];
  1769. bot.hat = playerInfo[9];
  1770. bot.accessory = playerInfo[10];
  1771. bot.isSkull = playerInfo[11];
  1772. } else if(playerInfo[7] !== bot.clan || playerInfo[7] === null) {
  1773. ws.enemiesNear.push(playerInfo);
  1774. }
  1775. ws.players[playerInfo[0]] = {
  1776. id: playerInfo[0],
  1777. x: playerInfo[1],
  1778. y: playerInfo[2],
  1779. dir: playerInfo[3],
  1780. object: playerInfo[4],
  1781. weapon: playerInfo[5],
  1782. clan: playerInfo[7],
  1783. isLeader: playerInfo[8],
  1784. hat: playerInfo[9],
  1785. accessory: playerInfo[10],
  1786. isSkull: playerInfo[11]
  1787. };
  1788. }
  1789. bots[bot.id] = bot
  1790. //place2(ws.millType, null);
  1791. if(ws.enemiesNear) {
  1792. ws.nearestEnemy = ws.enemiesNear.sort((a,b) => dist(a, bot) - dist(b, bot))[0];
  1793. }
  1794. if(ws.nearestEnemy) {
  1795. ws.nearestEnemyAngle = Math.atan2(ws.nearestEnemy[2]-bot.y, ws.nearestEnemy[1]-bot.x);
  1796. if(ws.attack == true) {
  1797. if(Math.sqrt(Math.pow(ws.nearestEnemy[1] - bot.x, 2)+Math.pow(ws.nearestEnemy[2] - bot.y, 2)) <= 240) {
  1798. ws.autoattack2 = true
  1799. if(bot.weapon !== ws.primary) {
  1800. bot.weapon = ws.primary
  1801. doNewSend(["z", [ws.primary, 1]])
  1802. }
  1803. ws.autoAttackWithAim5 = [true, ws.nearestEnemyAngle]
  1804. } else {
  1805. if(ws.autoattack2 == true) {
  1806. ws.autoattack2 = false
  1807. ws.autoAttackWithAim5 = [false, null]
  1808. doNewSend(["F", [0]])
  1809. }
  1810. }
  1811. doNewSend(["9", [ws.nearestEnemyAngle]])
  1812. }
  1813. } else {
  1814. if(ws.autoattack2 == true) {
  1815. ws.autoattack2 = false
  1816. ws.autoAttackWithAim5 = [false, null]
  1817. doNewSend(["F", [0]])
  1818. doNewSend(["9", [null]])
  1819. }
  1820. }
  1821. if (ws.nearestEnemy && ws.nearestEnemy.length) {
  1822. if(Math.sqrt(Math.pow((bot.y-ws.nearestEnemy[2]), 2) + Math.pow((bot.x-ws.nearestEnemy[1]), 2)) < 500) {
  1823. ws.isEnemyNear = true;
  1824. if(!ws.autoaim && bot.hat != 7 && bot.hat != 53) {
  1825. ws.normalHat = 6;
  1826. if(ws.primary != 8) {
  1827. ws.normalAcc = 21;
  1828. }
  1829. } else {
  1830. ws.isEnemyNear = false;
  1831. }
  1832. };
  1833. }
  1834. if(!ws.isEnemyNear && !ws.autoaim) {
  1835. ws.normalAcc = 11;
  1836. if (bot.y < 2400){
  1837. ws.normalHat = 15;
  1838. } else if (bot.y > 6850 && bot.y < 7550){
  1839. ws.normalHat = 31;
  1840. } else {
  1841. ws.normalHat = 12;
  1842. }
  1843. }
  1844.  
  1845. if(hatToggle) {
  1846. if(ws.oldHat != ws.normalHat) {
  1847. doNewSend(['c', [1, ws.normalHat, 0]]);
  1848. doNewSend(['c', [0, ws.normalHat, 0]]);
  1849. }
  1850. if(ws.oldAcc != ws.normalAcc) {
  1851. doNewSend(['c', [1, ws.normalAcc, 1]]);
  1852. doNewSend(['c', [0, ws.normalAcc, 1]]);
  1853. }
  1854. ws.oldHat = ws.normalHat;
  1855. ws.oldAcc = ws.normalAcc;
  1856. }
  1857. if (ws.nearestEnemy && ws.autoInsta) {
  1858. if (Math.sqrt(Math.pow((bot.y-ws.nearestEnemy[2]), 2) + Math.pow((bot.x-ws.nearestEnemy[1]), 2)) < 215) {
  1859. ws.autoInsta = false;
  1860. ws.autoaim = true;
  1861. doNewSend(['9', [ws.nearestEnemyAngle]]);
  1862. setTimeout(() => {
  1863. doNewSend(['9', []]);
  1864. doNewSend(['c', [0, 11, 1]]);
  1865. }, 300)
  1866. doNewSend(['c', [0, 0, 1]])
  1867. doNewSend(['c', [0, 19, 1]])
  1868. doNewSend(['c', [0, 7, 0]])
  1869. doNewSend(["z", [ws.primary, 1]]);
  1870. for (let i = 0; i < 25; i++) {
  1871. doNewSend(['F', [1, ws.nearestEnemyAngle]]);
  1872. }
  1873. setTimeout(() => {
  1874. doNewSend(['c', [0, 53, 0]]);
  1875. doNewSend(["z", [ws.secondary, 1]]);
  1876. setTimeout(() => {
  1877. ws.autoaim = false;
  1878. doNewSend(["z", [ws.primary, 1]]);
  1879. if (!empToggle) {
  1880. doNewSend(["c", [1, 6, 0]]);
  1881. doNewSend(["c", [0, 6, 0]]);
  1882. }
  1883. if (empToggle) {
  1884. doNewSend(["c", [1, 22, 0]]);
  1885. doNewSend(["c", [0, 22, 0]]);
  1886. }
  1887. doNewSend(['K', [1]]);
  1888. doNewSend(['F', [0]]);
  1889. }, 270);
  1890. }, 130);
  1891. }
  1892. }
  1893. if ((ws.playerFollower || playerFollowerGlobal) && !followingfarm && !ws.autoattack2) {
  1894. if (Math.sqrt(Math.pow((bot.y - pointingOnPosition.y), 2) + Math.pow((bot.x - pointingOnPosition.x), 2)) < (Object.keys(sockets).filter(e=>e!=undefined).length > 3 ? 160 : 105)) {
  1895. doNewSend(['9', []]);
  1896. } else {
  1897. doNewSend(['9', [Math.atan2(pointingOnPosition.y - bot.y, pointingOnPosition.x - bot.x)]]);
  1898. }
  1899. } else if (followingfarm == true && followingtype !== null) {
  1900. if(followingtype == "wood") {
  1901. let nearestWood = treeList.sort((a, b) => {return Math.sqrt(Math.pow(a.x - myPlayer.x, 2)+Math.pow(a.y - myPlayer.y, 2)) - Math.sqrt(Math.pow(b.x - myPlayer.x, 2)+Math.pow(b.y - myPlayer.y, 2))})[0]
  1902. if(Math.sqrt(Math.pow(nearestWood.x - bot.x, 2) + Math.pow(nearestWood.y - bot.y, 2)) < 165) {
  1903. doNewSend(["9", [null]])
  1904. ws.autoAttackWithAim4 = [true, Math.atan2(nearestWood.y - bot.y, nearestWood.x - bot.x)]
  1905. } else {
  1906. doNewSend(["9", [Math.atan2(nearestWood.y - bot.y, nearestWood.x - bot.x)]])
  1907. }
  1908. } else if (followingtype == "bush") {
  1909. let nearestBush = bushList.sort((a, b) => {return Math.sqrt(Math.pow(a.x - myPlayer.x, 2)+Math.pow(a.y - myPlayer.y, 2)) - Math.sqrt(Math.pow(b.x - myPlayer.x, 2)+Math.pow(b.y - myPlayer.y, 2))})[0]
  1910. if(Math.sqrt(Math.pow(nearestBush.x - bot.x, 2) + Math.pow(nearestBush.y - bot.y, 2)) < 100) {
  1911. doNewSend(["9", [null]])
  1912. ws.autoAttackWithAim4 = [true, Math.atan2(nearestBush.y - bot.y, nearestBush.x - bot.x)]
  1913. } else {
  1914. doNewSend(["9", [Math.atan2(nearestBush.y - bot.y, nearestBush.x - bot.x)]])
  1915. }
  1916. } else if (followingtype == "stone") {
  1917. let nearestStone = stoneList.sort((a, b) => {return Math.sqrt(Math.pow(a.x - myPlayer.x, 2)+Math.pow(a.y - myPlayer.y, 2)) - Math.sqrt(Math.pow(b.x - myPlayer.x, 2)+Math.pow(b.y - myPlayer.y, 2))})[0]
  1918. if(Math.sqrt(Math.pow(nearestStone.x - bot.x, 2) + Math.pow(nearestStone.y - bot.y, 2)) < 140) {
  1919. doNewSend(["9", [null]])
  1920. ws.autoAttackWithAim4 = [true, Math.atan2(nearestStone.y - bot.y, nearestStone.x - bot.x)]
  1921. } else {
  1922. doNewSend(["9", [Math.atan2(nearestStone.y - bot.y, nearestStone.x - bot.x)]])
  1923. }
  1924. } else if (followingtype == "gold") {
  1925. let nearestGold = goldList.sort((a, b) => {return Math.sqrt(Math.pow(a.x - myPlayer.x, 2)+Math.pow(a.y - myPlayer.y, 2)) - Math.sqrt(Math.pow(b.x - myPlayer.x, 2)+Math.pow(b.y - myPlayer.y, 2))})[0]
  1926. if(Math.sqrt(Math.pow(nearestGold.x - bot.x, 2) + Math.pow(nearestGold.y - bot.y, 2)) < 140) {
  1927. doNewSend(["9", [null]])
  1928. ws.autoAttackWithAim4 = [true, Math.atan2(nearestGold.y - bot.y, nearestGold.x - bot.x)]
  1929. } else {
  1930. doNewSend(["9", [Math.atan2(nearestGold.y - bot.y, nearestGold.x - bot.x)]])
  1931. }
  1932. }
  1933. } else if (followingfarm == false && followingtype !== null) {
  1934. followingtype = null
  1935. ws.autoAttackWithAim4 = [false, null]
  1936. doNewSend(["F", [0]])
  1937. }
  1938. if (ffs) {
  1939. if (ffsps !== Math.atan2((myPlayer.y - bot.y) + mouseY - (height / 2), (myPlayer.x- bot.x) + mouseX - (width / 2))) {
  1940. ffsps = Math.atan2((myPlayer.y - bot.y) + mouseY - (height / 2), (myPlayer.x- bot.x) + mouseX - (width / 2));
  1941. if (!ws.autoaim) {
  1942. doNewSend(['D', [ffsps]]);
  1943. }
  1944. doNewSend(['9', [ffsps]]);
  1945. }
  1946. }
  1947. /*if (ws.autoaim) {
  1948. doNewSend(['2', [ws.nearestEnemyAngle]]);
  1949. }*/
  1950. if (ws.autoAttackWithAim4[0] == true && followingfarm == true) {
  1951. attacking = true
  1952. doNewSend(['F', [1, ws.autoAttackWithAim4[1]]]);
  1953. doNewSend(['D', [ws.autoAttackWithAim4[1]]])
  1954. } else if (followingfarm == false && attacking == true) {
  1955. attacking = false
  1956. doNewSend(["F", [0]])
  1957. }
  1958. if (ws.autoAttackWithAim5[0] == true && ws.attack == true) {
  1959. attacking2 = true
  1960. doNewSend(['F', [1, ws.autoAttackWithAim5[1]]]);
  1961. doNewSend(['D', [ws.autoAttackWithAim5[1]]])
  1962. } else if (ws.attack == false && attacking2 == true) {
  1963. attacking2 = false
  1964. doNewSend(["F", [0]])
  1965. }
  1966. }
  1967. if (item == "N") {
  1968. if(data[1] == "kills") {
  1969. sendForAll(["6", ["gg - Get Deleted"]], true)
  1970. }
  1971. bot && (bot[data[1]] = data[2])
  1972. }
  1973. if (item == "6") {
  1974. if(data[1] == myPlayer.id || friend.includes(data[1])) {
  1975. if(data[2].toLowerCase() == "~age") {
  1976. doNewSend(["6", [age.toString()]])
  1977. }
  1978. if (data[2].toLowerCase() == "!wood") {
  1979. followingfarm = true
  1980. followingtype = "wood"
  1981. }
  1982. if (data[2].toLowerCase() == "!food") {
  1983. followingfarm = true
  1984. followingtype = "bush"
  1985. }
  1986. if (data[2].toLowerCase() == "!stone") {
  1987. followingfarm = true
  1988. followingtype = "stone"
  1989. }
  1990. if (data[2].toLowerCase() == "!gold") {
  1991. followingfarm = true
  1992. followingtype = "gold"
  1993. }
  1994. if (data[2].toLowerCase() == "~wood") {
  1995. doNewSend(["6", [bot.wood?bot.wood.toString():"100"]])
  1996. }
  1997. if (data[2].toLowerCase() == "~food") {
  1998. doNewSend(["6", [bot.food?bot.food.toString():"100"]])
  1999. }
  2000. if (data[2].toLowerCase() == "~stone") {
  2001. doNewSend(["6", [bot.stone?bot.stone.toString():"100"]])
  2002. }
  2003. if (data[2].toLowerCase() == "~gold") {
  2004. doNewSend(["6", [bot.points?bot.points.toString():"100"]])
  2005. }
  2006. if (data[2].toLowerCase() == "!attack on") {
  2007. ws.attack = true
  2008. autoattack = true
  2009. } else if (data[2].toLowerCase() == "!attack off") {
  2010. ws.attack = false
  2011. ws.autoAttackWithAim4 = [false, null]
  2012. doNewSend(["F", [0]])
  2013. autoattack = false
  2014. }
  2015. if (data[2].toLowerCase().startsWith("!b")) {
  2016. let hat = hats.find(e=>e.name.toLowerCase().startsWith(data[2].slice(3)))
  2017. if(hat !== undefined) {
  2018. if(bot.points >= hat.price) {
  2019. doNewSend(["c", [1, hat.id, 0]])
  2020. doNewSend(["6", ["Bought" + hat.name]])
  2021. } else {
  2022. doNewSend(["6", ["Not Enough Gold"]])
  2023. }
  2024. } else {
  2025. doNewSend(["6", ["Hat Is Undefined"]])
  2026. }
  2027. }
  2028. }
  2029.  
  2030.  
  2031. }
  2032. if (item == "T") {
  2033. null != data[3] && (age = data[3])
  2034. }
  2035. if (item == "V") {
  2036. if (data[2]) {
  2037. ws.primary = data[1][0];
  2038. ws.secondary = data[1][1] || null;
  2039. } else {
  2040. for (let i = 0; i < data[1].length; i++) {
  2041. for (let i2 = 0; i2 < 3; i2++) {
  2042. if (i2 == data[1][i]) {
  2043. ws.foodType = data[1][i];
  2044. }
  2045. }
  2046. for (let i2 = 3; i2 < 6; i2++) {
  2047. if (i2 == data[1][i]) {
  2048. ws.wallType = data[1][i];
  2049. }
  2050. }
  2051. for (let i2 = 6; i2 < 10; i2++) {
  2052. if (i2 == data[1][i]) {
  2053. ws.spikeType = data[1][i];
  2054. }
  2055. }
  2056. for (let i2 = 10; i2 < 13; i2++) {
  2057. if (i2 == data[1][i]) {
  2058. ws.millType = data[1][i];
  2059. }
  2060. }
  2061. for (let i2 = 13; i2 < 15; i2++) {
  2062. if (i2 == data[1][i]) {
  2063. ws.mineType = data[1][i];
  2064. }
  2065. }
  2066. for (let i2 = 15; i2 < 17; i2++) {
  2067. if (i2 == data[1][i]) {
  2068. ws.boostType = data[1][i];
  2069. }
  2070. }
  2071. for (let i2 = 17; i2 < 23; i2++) {
  2072. if (i2 == data[1][i] && i2 !== 20) {
  2073. ws.turretType = data[1][i];
  2074. }
  2075. }
  2076. ws.spawnpadType = 20;
  2077. }
  2078. }
  2079. }
  2080. if (item == "6") {
  2081. let ch = data;
  2082. if (ch[2].toLocaleLowerCase() == '!"' && ch[1] == myPlayer.id) {
  2083. ws.playerFollower = true;
  2084. doNewSend(['9', []]);
  2085. }
  2086. if (ch[2].toLocaleLowerCase() == '!*' && ch[1] == myPlayer.id) {
  2087. ws.playerFollower = false;
  2088. doNewSend(['9', []]);
  2089. }
  2090. if (ch[2].toLocaleLowerCase() == '!+' && ch[1] == myPlayer.id) {
  2091. ws.playerFollower = false;
  2092. doNewSend(['9', []]);
  2093. }
  2094. if (ch[2].toLocaleLowerCase() == '!close' && ch[1] == myPlayer.id) {
  2095. ws.close();
  2096. }
  2097. if ((ch[2].toLocaleLowerCase()).split(' ')[0] == '!join' && ch[1] == myPlayer.id) {
  2098. doNewSend(['b', [ch[2].toLocaleLowerCase().split(' ')[1]]]);
  2099. }
  2100. if ((ch[2].toLocaleLowerCase()).split(' ')[0] == '!leave' && ch[1] == myPlayer.id) {
  2101. doNewSend(['N', [null]]);
  2102. }
  2103. }
  2104. if (item == "g") {
  2105. if (data[1].owner == myPlayer.id) {
  2106. setTimeout(() => {
  2107. doNewSend(['b', [data[1].sid]]);
  2108. }, 100);
  2109. }
  2110. }
  2111. if(data[0] == "O" && data[1] == bot.id) {
  2112. if(data[2] > 0) {
  2113. setTimeout(() => {
  2114. doNewSend(['z', [ws.foodType, null]]);
  2115. doNewSend(['F', [1]]);
  2116. doNewSend(['F', [0]]);
  2117. doNewSend(['z', [null]]);
  2118. }, 100)
  2119. }
  2120. }
  2121. }
  2122. ws.onmessage = (e) => {
  2123. msgFnc(e);
  2124. }
  2125. ws.onclose = () => {
  2126. delete sockets[bot.id]
  2127. delete bots[bot.id]
  2128. ws.connected = !1
  2129. }
  2130. }
  2131.  
  2132.  
  2133.  
  2134. (function () {
  2135. const t = document.createElement("link").relList;
  2136. if (t && t.supports && t.supports("modulepreload")) {
  2137. return;
  2138. }
  2139. for (const s of document.querySelectorAll("link[rel=\"modulepreload\"]")) {
  2140. n(s);
  2141. }
  2142. new MutationObserver(s => {
  2143. for (const r of s) {
  2144. if (r.type === "childList") {
  2145. for (const o of r.addedNodes) {
  2146. if (o.tagName === "LINK" && o.rel === "modulepreload") {
  2147. n(o);
  2148. }
  2149. }
  2150. }
  2151. }
  2152. }).observe(document, {
  2153. childList: true,
  2154. subtree: true
  2155. });
  2156. function i(s) {
  2157. const r = {};
  2158. if (s.integrity) {
  2159. r.integrity = s.integrity;
  2160. }
  2161. if (s.referrerPolicy) {
  2162. r.referrerPolicy = s.referrerPolicy;
  2163. }
  2164. if (s.crossOrigin === "use-credentials") {
  2165. r.credentials = "include";
  2166. } else if (s.crossOrigin === "anonymous") {
  2167. r.credentials = "omit";
  2168. } else {
  2169. r.credentials = "same-origin";
  2170. }
  2171. return r;
  2172. }
  2173. function n(s) {
  2174. if (s.ep) {
  2175. return;
  2176. }
  2177. s.ep = true;
  2178. const r = i(s);
  2179. fetch(s.href, r);
  2180. }
  2181. })();
  2182. var Ct = 4294967295;
  2183. function al(e, t, i) {
  2184. var n = i / 4294967296;
  2185. var s = i;
  2186. e.setUint32(t, n);
  2187. e.setUint32(t + 4, s);
  2188. }
  2189. function zo(e, t, i) {
  2190. var n = Math.floor(i / 4294967296);
  2191. var s = i;
  2192. e.setUint32(t, n);
  2193. e.setUint32(t + 4, s);
  2194. }
  2195. function Bo(e, t) {
  2196. var i = e.getInt32(t);
  2197. var n = e.getUint32(t + 4);
  2198. return i * 4294967296 + n;
  2199. }
  2200. function ll(e, t) {
  2201. var i = e.getUint32(t);
  2202. var n = e.getUint32(t + 4);
  2203. return i * 4294967296 + n;
  2204. }
  2205. var Vn;
  2206. var Nn;
  2207. var Un;
  2208. var Rn = (typeof process === "undefined" || ((Vn = process == null ? undefined : process.env) === null || Vn === undefined ? undefined : Vn.TEXT_ENCODING) !== "never") && typeof TextEncoder !== "undefined" && typeof TextDecoder !== "undefined";
  2209. function vr(e) {
  2210. for (var t = e.length, i = 0, n = 0; n < t;) {
  2211. var s = e.charCodeAt(n++);
  2212. if (s & 4294967168) {
  2213. if (!(s & 4294965248)) {
  2214. i += 2;
  2215. } else {
  2216. if (s >= 55296 && s <= 56319 && n < t) {
  2217. var r = e.charCodeAt(n);
  2218. if ((r & 64512) === 56320) {
  2219. ++n;
  2220. s = ((s & 1023) << 10) + (r & 1023) + 65536;
  2221. }
  2222. }
  2223. if (s & 4294901760) {
  2224. i += 4;
  2225. } else {
  2226. i += 3;
  2227. }
  2228. }
  2229. } else {
  2230. i++;
  2231. continue;
  2232. }
  2233. }
  2234. return i;
  2235. }
  2236. function cl(e, t, i) {
  2237. for (var n = e.length, s = i, r = 0; r < n;) {
  2238. var o = e.charCodeAt(r++);
  2239. if (o & 4294967168) {
  2240. if (!(o & 4294965248)) {
  2241. t[s++] = o >> 6 & 31 | 192;
  2242. } else {
  2243. if (o >= 55296 && o <= 56319 && r < n) {
  2244. var l = e.charCodeAt(r);
  2245. if ((l & 64512) === 56320) {
  2246. ++r;
  2247. o = ((o & 1023) << 10) + (l & 1023) + 65536;
  2248. }
  2249. }
  2250. if (o & 4294901760) {
  2251. t[s++] = o >> 18 & 7 | 240;
  2252. t[s++] = o >> 12 & 63 | 128;
  2253. t[s++] = o >> 6 & 63 | 128;
  2254. } else {
  2255. t[s++] = o >> 12 & 15 | 224;
  2256. t[s++] = o >> 6 & 63 | 128;
  2257. }
  2258. }
  2259. } else {
  2260. t[s++] = o;
  2261. continue;
  2262. }
  2263. t[s++] = o & 63 | 128;
  2264. }
  2265. }
  2266. var Oi = Rn ? new TextEncoder() : undefined;
  2267. var hl = Rn ? typeof process !== "undefined" && ((Nn = process == null ? undefined : process.env) === null || Nn === undefined ? undefined : Nn.TEXT_ENCODING) !== "force" ? 200 : 0 : Ct;
  2268. function ul(e, t, i) {
  2269. t.set(Oi.encode(e), i);
  2270. }
  2271. function fl(e, t, i) {
  2272. Oi.encodeInto(e, t.subarray(i));
  2273. }
  2274. var dl = Oi != null && Oi.encodeInto ? fl : ul;
  2275. var pl = 4096;
  2276. function Ho(e, t, i) {
  2277. for (var n = t, s = n + i, r = [], o = ""; n < s;) {
  2278. var l = e[n++];
  2279. if (!(l & 128)) {
  2280. r.push(l);
  2281. } else if ((l & 224) === 192) {
  2282. var c = e[n++] & 63;
  2283. r.push((l & 31) << 6 | c);
  2284. } else if ((l & 240) === 224) {
  2285. var c = e[n++] & 63;
  2286. var a = e[n++] & 63;
  2287. r.push((l & 31) << 12 | c << 6 | a);
  2288. } else if ((l & 248) === 240) {
  2289. var c = e[n++] & 63;
  2290. var a = e[n++] & 63;
  2291. var f = e[n++] & 63;
  2292. var d = (l & 7) << 18 | c << 12 | a << 6 | f;
  2293. if (d > 65535) {
  2294. d -= 65536;
  2295. r.push(d >>> 10 & 1023 | 55296);
  2296. d = d & 1023 | 56320;
  2297. }
  2298. r.push(d);
  2299. } else {
  2300. r.push(l);
  2301. }
  2302. if (r.length >= pl) {
  2303. o += String.fromCharCode.apply(String, r);
  2304. r.length = 0;
  2305. }
  2306. }
  2307. if (r.length > 0) {
  2308. o += String.fromCharCode.apply(String, r);
  2309. }
  2310. return o;
  2311. }
  2312. var ml = Rn ? new TextDecoder() : null;
  2313. var gl = Rn ? typeof process !== "undefined" && ((Un = process == null ? undefined : process.env) === null || Un === undefined ? undefined : Un.TEXT_DECODER) !== "force" ? 200 : 0 : Ct;
  2314. function yl(e, t, i) {
  2315. var n = e.subarray(t, t + i);
  2316. return ml.decode(n);
  2317. }
  2318. var en = function () {
  2319. function e(t, i) {
  2320. this.type = t;
  2321. this.data = i;
  2322. }
  2323. return e;
  2324. }();
  2325. var wl = globalThis && globalThis.__extends || function () {
  2326. function e(t, i) {
  2327. e = Object.setPrototypeOf || {
  2328. __proto__: []
  2329. } instanceof Array && function (n, s) {
  2330. n.__proto__ = s;
  2331. } || function (n, s) {
  2332. for (var r in s) {
  2333. if (Object.prototype.hasOwnProperty.call(s, r)) {
  2334. n[r] = s[r];
  2335. }
  2336. }
  2337. };
  2338. return e(t, i);
  2339. }
  2340. return function (t, i) {
  2341. if (typeof i != "function" && i !== null) {
  2342. throw new TypeError("Class extends value " + String(i) + " is not a constructor or null");
  2343. }
  2344. e(t, i);
  2345. function n() {
  2346. this.constructor = t;
  2347. }
  2348. t.prototype = i === null ? Object.create(i) : (n.prototype = i.prototype, new n());
  2349. };
  2350. }();
  2351. var Je = function (e) {
  2352. wl(t, e);
  2353. function t(i) {
  2354. var n = e.call(this, i) || this;
  2355. var s = Object.create(t.prototype);
  2356. Object.setPrototypeOf(n, s);
  2357. Object.defineProperty(n, "name", {
  2358. configurable: true,
  2359. enumerable: false,
  2360. value: t.name
  2361. });
  2362. return n;
  2363. }
  2364. return t;
  2365. }(Error);
  2366. var vl = -1;
  2367. var kl = 4294967295;
  2368. var xl = 17179869183;
  2369. function bl(e) {
  2370. var t = e.sec;
  2371. var i = e.nsec;
  2372. if (t >= 0 && i >= 0 && t <= xl) {
  2373. if (i === 0 && t <= kl) {
  2374. var n = new Uint8Array(4);
  2375. var s = new DataView(n.buffer);
  2376. s.setUint32(0, t);
  2377. return n;
  2378. } else {
  2379. var r = t / 4294967296;
  2380. var o = t & 4294967295;
  2381. var n = new Uint8Array(8);
  2382. var s = new DataView(n.buffer);
  2383. s.setUint32(0, i << 2 | r & 3);
  2384. s.setUint32(4, o);
  2385. return n;
  2386. }
  2387. } else {
  2388. var n = new Uint8Array(12);
  2389. var s = new DataView(n.buffer);
  2390. s.setUint32(0, i);
  2391. zo(s, 4, t);
  2392. return n;
  2393. }
  2394. }
  2395. function Sl(e) {
  2396. var t = e.getTime();
  2397. var i = Math.floor(t / 1000);
  2398. var n = (t - i * 1000) * 1000000;
  2399. var s = Math.floor(n / 1000000000);
  2400. return {
  2401. sec: i + s,
  2402. nsec: n - s * 1000000000
  2403. };
  2404. }
  2405. function Il(e) {
  2406. if (e instanceof Date) {
  2407. var t = Sl(e);
  2408. return bl(t);
  2409. } else {
  2410. return null;
  2411. }
  2412. }
  2413. function Tl(e) {
  2414. var t = new DataView(e.buffer, e.byteOffset, e.byteLength);
  2415. switch (e.byteLength) {
  2416. case 4:
  2417. {
  2418. var i = t.getUint32(0);
  2419. var n = 0;
  2420. return {
  2421. sec: i,
  2422. nsec: n
  2423. };
  2424. }
  2425. case 8:
  2426. {
  2427. var s = t.getUint32(0);
  2428. var r = t.getUint32(4);
  2429. var i = (s & 3) * 4294967296 + r;
  2430. var n = s >>> 2;
  2431. return {
  2432. sec: i,
  2433. nsec: n
  2434. };
  2435. }
  2436. case 12:
  2437. {
  2438. var i = Bo(t, 4);
  2439. var n = t.getUint32(0);
  2440. return {
  2441. sec: i,
  2442. nsec: n
  2443. };
  2444. }
  2445. default:
  2446. throw new Je(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`);
  2447. }
  2448. }
  2449. function Ml(e) {
  2450. var t = Tl(e);
  2451. return new Date(t.sec * 1000 + t.nsec / 1000000);
  2452. }
  2453. var El = {
  2454. type: vl,
  2455. encode: Il,
  2456. decode: Ml
  2457. };
  2458. var Lo = function () {
  2459. function e() {
  2460. this.builtInEncoders = [];
  2461. this.builtInDecoders = [];
  2462. this.encoders = [];
  2463. this.decoders = [];
  2464. this.register(El);
  2465. }
  2466. e.prototype.register = function (t) {
  2467. var i = t.type;
  2468. var n = t.encode;
  2469. var s = t.decode;
  2470. if (i >= 0) {
  2471. this.encoders[i] = n;
  2472. this.decoders[i] = s;
  2473. } else {
  2474. var r = 1 + i;
  2475. this.builtInEncoders[r] = n;
  2476. this.builtInDecoders[r] = s;
  2477. }
  2478. };
  2479. e.prototype.tryToEncode = function (t, i) {
  2480. for (var n = 0; n < this.builtInEncoders.length; n++) {
  2481. var s = this.builtInEncoders[n];
  2482. if (s != null) {
  2483. var r = s(t, i);
  2484. if (r != null) {
  2485. var o = -1 - n;
  2486. return new en(o, r);
  2487. }
  2488. }
  2489. }
  2490. for (var n = 0; n < this.encoders.length; n++) {
  2491. var s = this.encoders[n];
  2492. if (s != null) {
  2493. var r = s(t, i);
  2494. if (r != null) {
  2495. var o = n;
  2496. return new en(o, r);
  2497. }
  2498. }
  2499. }
  2500. if (t instanceof en) {
  2501. return t;
  2502. } else {
  2503. return null;
  2504. }
  2505. };
  2506. e.prototype.decode = function (t, i, n) {
  2507. var s = i < 0 ? this.builtInDecoders[-1 - i] : this.decoders[i];
  2508. if (s) {
  2509. return s(t, i, n);
  2510. } else {
  2511. return new en(i, t);
  2512. }
  2513. };
  2514. e.defaultCodec = new e();
  2515. return e;
  2516. }();
  2517. function yn(e) {
  2518. if (e instanceof Uint8Array) {
  2519. return e;
  2520. } else if (ArrayBuffer.isView(e)) {
  2521. return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
  2522. } else if (e instanceof ArrayBuffer) {
  2523. return new Uint8Array(e);
  2524. } else {
  2525. return Uint8Array.from(e);
  2526. }
  2527. }
  2528. function Cl(e) {
  2529. if (e instanceof ArrayBuffer) {
  2530. return new DataView(e);
  2531. }
  2532. var t = yn(e);
  2533. return new DataView(t.buffer, t.byteOffset, t.byteLength);
  2534. }
  2535. var Pl = 100;
  2536. var $l = 2048;
  2537. var Rl = function () {
  2538. function e(t, i, n, s, r, o, l, c) {
  2539. if (t === undefined) {
  2540. t = Lo.defaultCodec;
  2541. }
  2542. if (i === undefined) {
  2543. i = undefined;
  2544. }
  2545. if (n === undefined) {
  2546. n = Pl;
  2547. }
  2548. if (s === undefined) {
  2549. s = $l;
  2550. }
  2551. if (r === undefined) {
  2552. r = false;
  2553. }
  2554. if (o === undefined) {
  2555. o = false;
  2556. }
  2557. if (l === undefined) {
  2558. l = false;
  2559. }
  2560. if (c === undefined) {
  2561. c = false;
  2562. }
  2563. this.extensionCodec = t;
  2564. this.context = i;
  2565. this.maxDepth = n;
  2566. this.initialBufferSize = s;
  2567. this.sortKeys = r;
  2568. this.forceFloat32 = o;
  2569. this.ignoreUndefined = l;
  2570. this.forceIntegerToFloat = c;
  2571. this.pos = 0;
  2572. this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
  2573. this.bytes = new Uint8Array(this.view.buffer);
  2574. }
  2575. e.prototype.reinitializeState = function () {
  2576. this.pos = 0;
  2577. };
  2578. e.prototype.encodeSharedRef = function (t) {
  2579. this.reinitializeState();
  2580. this.doEncode(t, 1);
  2581. return this.bytes.subarray(0, this.pos);
  2582. };
  2583. e.prototype.encode = function (t) {
  2584. this.reinitializeState();
  2585. this.doEncode(t, 1);
  2586. return this.bytes.slice(0, this.pos);
  2587. };
  2588. e.prototype.doEncode = function (t, i) {
  2589. if (i > this.maxDepth) {
  2590. throw new Error(`Too deep objects in depth ${i}`);
  2591. }
  2592. if (t == null) {
  2593. this.encodeNil();
  2594. } else if (typeof t == "boolean") {
  2595. this.encodeBoolean(t);
  2596. } else if (typeof t == "number") {
  2597. this.encodeNumber(t);
  2598. } else if (typeof t == "string") {
  2599. this.encodeString(t);
  2600. } else {
  2601. this.encodeObject(t, i);
  2602. }
  2603. };
  2604. e.prototype.ensureBufferSizeToWrite = function (t) {
  2605. var i = this.pos + t;
  2606. if (this.view.byteLength < i) {
  2607. this.resizeBuffer(i * 2);
  2608. }
  2609. };
  2610. e.prototype.resizeBuffer = function (t) {
  2611. var i = new ArrayBuffer(t);
  2612. var n = new Uint8Array(i);
  2613. var s = new DataView(i);
  2614. n.set(this.bytes);
  2615. this.view = s;
  2616. this.bytes = n;
  2617. };
  2618. e.prototype.encodeNil = function () {
  2619. this.writeU8(192);
  2620. };
  2621. e.prototype.encodeBoolean = function (t) {
  2622. if (t === false) {
  2623. this.writeU8(194);
  2624. } else {
  2625. this.writeU8(195);
  2626. }
  2627. };
  2628. e.prototype.encodeNumber = function (t) {
  2629. if (Number.isSafeInteger(t) && !this.forceIntegerToFloat) {
  2630. if (t >= 0) {
  2631. if (t < 128) {
  2632. this.writeU8(t);
  2633. } else if (t < 256) {
  2634. this.writeU8(204);
  2635. this.writeU8(t);
  2636. } else if (t < 65536) {
  2637. this.writeU8(205);
  2638. this.writeU16(t);
  2639. } else if (t < 4294967296) {
  2640. this.writeU8(206);
  2641. this.writeU32(t);
  2642. } else {
  2643. this.writeU8(207);
  2644. this.writeU64(t);
  2645. }
  2646. } else if (t >= -32) {
  2647. this.writeU8(t + 32 | 224);
  2648. } else if (t >= -128) {
  2649. this.writeU8(208);
  2650. this.writeI8(t);
  2651. } else if (t >= -32768) {
  2652. this.writeU8(209);
  2653. this.writeI16(t);
  2654. } else if (t >= -2147483648) {
  2655. this.writeU8(210);
  2656. this.writeI32(t);
  2657. } else {
  2658. this.writeU8(211);
  2659. this.writeI64(t);
  2660. }
  2661. } else if (this.forceFloat32) {
  2662. this.writeU8(202);
  2663. this.writeF32(t);
  2664. } else {
  2665. this.writeU8(203);
  2666. this.writeF64(t);
  2667. }
  2668. };
  2669. e.prototype.writeStringHeader = function (t) {
  2670. if (t < 32) {
  2671. this.writeU8(160 + t);
  2672. } else if (t < 256) {
  2673. this.writeU8(217);
  2674. this.writeU8(t);
  2675. } else if (t < 65536) {
  2676. this.writeU8(218);
  2677. this.writeU16(t);
  2678. } else if (t < 4294967296) {
  2679. this.writeU8(219);
  2680. this.writeU32(t);
  2681. } else {
  2682. throw new Error(`Too long string: ${t} bytes in UTF-8`);
  2683. }
  2684. };
  2685. e.prototype.encodeString = function (t) {
  2686. var i = 5;
  2687. var n = t.length;
  2688. if (n > hl) {
  2689. var s = vr(t);
  2690. this.ensureBufferSizeToWrite(i + s);
  2691. this.writeStringHeader(s);
  2692. dl(t, this.bytes, this.pos);
  2693. this.pos += s;
  2694. } else {
  2695. var s = vr(t);
  2696. this.ensureBufferSizeToWrite(i + s);
  2697. this.writeStringHeader(s);
  2698. cl(t, this.bytes, this.pos);
  2699. this.pos += s;
  2700. }
  2701. };
  2702. e.prototype.encodeObject = function (t, i) {
  2703. var n = this.extensionCodec.tryToEncode(t, this.context);
  2704. if (n != null) {
  2705. this.encodeExtension(n);
  2706. } else if (Array.isArray(t)) {
  2707. this.encodeArray(t, i);
  2708. } else if (ArrayBuffer.isView(t)) {
  2709. this.encodeBinary(t);
  2710. } else if (typeof t == "object") {
  2711. this.encodeMap(t, i);
  2712. } else {
  2713. throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(t)}`);
  2714. }
  2715. };
  2716. e.prototype.encodeBinary = function (t) {
  2717. var i = t.byteLength;
  2718. if (i < 256) {
  2719. this.writeU8(196);
  2720. this.writeU8(i);
  2721. } else if (i < 65536) {
  2722. this.writeU8(197);
  2723. this.writeU16(i);
  2724. } else if (i < 4294967296) {
  2725. this.writeU8(198);
  2726. this.writeU32(i);
  2727. } else {
  2728. throw new Error(`Too large binary: ${i}`);
  2729. }
  2730. var n = yn(t);
  2731. this.writeU8a(n);
  2732. };
  2733. e.prototype.encodeArray = function (t, i) {
  2734. var n = t.length;
  2735. if (n < 16) {
  2736. this.writeU8(144 + n);
  2737. } else if (n < 65536) {
  2738. this.writeU8(220);
  2739. this.writeU16(n);
  2740. } else if (n < 4294967296) {
  2741. this.writeU8(221);
  2742. this.writeU32(n);
  2743. } else {
  2744. throw new Error(`Too large array: ${n}`);
  2745. }
  2746. for (var s = 0, r = t; s < r.length; s++) {
  2747. var o = r[s];
  2748. this.doEncode(o, i + 1);
  2749. }
  2750. };
  2751. e.prototype.countWithoutUndefined = function (t, i) {
  2752. for (var n = 0, s = 0, r = i; s < r.length; s++) {
  2753. var o = r[s];
  2754. if (t[o] !== undefined) {
  2755. n++;
  2756. }
  2757. }
  2758. return n;
  2759. };
  2760. e.prototype.encodeMap = function (t, i) {
  2761. var n = Object.keys(t);
  2762. if (this.sortKeys) {
  2763. n.sort();
  2764. }
  2765. var s = this.ignoreUndefined ? this.countWithoutUndefined(t, n) : n.length;
  2766. if (s < 16) {
  2767. this.writeU8(128 + s);
  2768. } else if (s < 65536) {
  2769. this.writeU8(222);
  2770. this.writeU16(s);
  2771. } else if (s < 4294967296) {
  2772. this.writeU8(223);
  2773. this.writeU32(s);
  2774. } else {
  2775. throw new Error(`Too large map object: ${s}`);
  2776. }
  2777. for (var r = 0, o = n; r < o.length; r++) {
  2778. var l = o[r];
  2779. var c = t[l];
  2780. if (!(this.ignoreUndefined && c === undefined)) {
  2781. this.encodeString(l);
  2782. this.doEncode(c, i + 1);
  2783. }
  2784. }
  2785. };
  2786. e.prototype.encodeExtension = function (t) {
  2787. var i = t.data.length;
  2788. if (i === 1) {
  2789. this.writeU8(212);
  2790. } else if (i === 2) {
  2791. this.writeU8(213);
  2792. } else if (i === 4) {
  2793. this.writeU8(214);
  2794. } else if (i === 8) {
  2795. this.writeU8(215);
  2796. } else if (i === 16) {
  2797. this.writeU8(216);
  2798. } else if (i < 256) {
  2799. this.writeU8(199);
  2800. this.writeU8(i);
  2801. } else if (i < 65536) {
  2802. this.writeU8(200);
  2803. this.writeU16(i);
  2804. } else if (i < 4294967296) {
  2805. this.writeU8(201);
  2806. this.writeU32(i);
  2807. } else {
  2808. throw new Error(`Too large extension object: ${i}`);
  2809. }
  2810. this.writeI8(t.type);
  2811. this.writeU8a(t.data);
  2812. };
  2813. e.prototype.writeU8 = function (t) {
  2814. this.ensureBufferSizeToWrite(1);
  2815. this.view.setUint8(this.pos, t);
  2816. this.pos++;
  2817. };
  2818. e.prototype.writeU8a = function (t) {
  2819. var i = t.length;
  2820. this.ensureBufferSizeToWrite(i);
  2821. this.bytes.set(t, this.pos);
  2822. this.pos += i;
  2823. };
  2824. e.prototype.writeI8 = function (t) {
  2825. this.ensureBufferSizeToWrite(1);
  2826. this.view.setInt8(this.pos, t);
  2827. this.pos++;
  2828. };
  2829. e.prototype.writeU16 = function (t) {
  2830. this.ensureBufferSizeToWrite(2);
  2831. this.view.setUint16(this.pos, t);
  2832. this.pos += 2;
  2833. };
  2834. e.prototype.writeI16 = function (t) {
  2835. this.ensureBufferSizeToWrite(2);
  2836. this.view.setInt16(this.pos, t);
  2837. this.pos += 2;
  2838. };
  2839. e.prototype.writeU32 = function (t) {
  2840. this.ensureBufferSizeToWrite(4);
  2841. this.view.setUint32(this.pos, t);
  2842. this.pos += 4;
  2843. };
  2844. e.prototype.writeI32 = function (t) {
  2845. this.ensureBufferSizeToWrite(4);
  2846. this.view.setInt32(this.pos, t);
  2847. this.pos += 4;
  2848. };
  2849. e.prototype.writeF32 = function (t) {
  2850. this.ensureBufferSizeToWrite(4);
  2851. this.view.setFloat32(this.pos, t);
  2852. this.pos += 4;
  2853. };
  2854. e.prototype.writeF64 = function (t) {
  2855. this.ensureBufferSizeToWrite(8);
  2856. this.view.setFloat64(this.pos, t);
  2857. this.pos += 8;
  2858. };
  2859. e.prototype.writeU64 = function (t) {
  2860. this.ensureBufferSizeToWrite(8);
  2861. al(this.view, this.pos, t);
  2862. this.pos += 8;
  2863. };
  2864. e.prototype.writeI64 = function (t) {
  2865. this.ensureBufferSizeToWrite(8);
  2866. zo(this.view, this.pos, t);
  2867. this.pos += 8;
  2868. };
  2869. return e;
  2870. }();
  2871. function Wn(e) {
  2872. return `${e < 0 ? "-" : ""}0x${Math.abs(e).toString(16).padStart(2, "0")}`;
  2873. }
  2874. var Al = 16;
  2875. var Dl = 16;
  2876. var Ol = function () {
  2877. function e(t, i) {
  2878. if (t === undefined) {
  2879. t = Al;
  2880. }
  2881. if (i === undefined) {
  2882. i = Dl;
  2883. }
  2884. this.maxKeyLength = t;
  2885. this.maxLengthPerKey = i;
  2886. this.hit = 0;
  2887. this.miss = 0;
  2888. this.caches = [];
  2889. for (var n = 0; n < this.maxKeyLength; n++) {
  2890. this.caches.push([]);
  2891. }
  2892. }
  2893. e.prototype.canBeCached = function (t) {
  2894. return t > 0 && t <= this.maxKeyLength;
  2895. };
  2896. e.prototype.find = function (t, i, n) {
  2897. var s = this.caches[n - 1];
  2898. e: for (var r = 0, o = s; r < o.length; r++) {
  2899. for (var l = o[r], c = l.bytes, a = 0; a < n; a++) {
  2900. if (c[a] !== t[i + a]) {
  2901. continue e;
  2902. }
  2903. }
  2904. return l.str;
  2905. }
  2906. return null;
  2907. };
  2908. e.prototype.store = function (t, i) {
  2909. var n = this.caches[t.length - 1];
  2910. var s = {
  2911. bytes: t,
  2912. str: i
  2913. };
  2914. if (n.length >= this.maxLengthPerKey) {
  2915. n[Math.random() * n.length | 0] = s;
  2916. } else {
  2917. n.push(s);
  2918. }
  2919. };
  2920. e.prototype.decode = function (t, i, n) {
  2921. var s = this.find(t, i, n);
  2922. if (s != null) {
  2923. this.hit++;
  2924. return s;
  2925. }
  2926. this.miss++;
  2927. var r = Ho(t, i, n);
  2928. var o = Uint8Array.prototype.slice.call(t, i, i + n);
  2929. this.store(o, r);
  2930. return r;
  2931. };
  2932. return e;
  2933. }();
  2934. var _l = globalThis && globalThis.__awaiter || function (e, t, i, n) {
  2935. function s(r) {
  2936. if (r instanceof i) {
  2937. return r;
  2938. } else {
  2939. return new i(function (o) {
  2940. o(r);
  2941. });
  2942. }
  2943. }
  2944. return new (i || (i = Promise))(function (r, o) {
  2945. function l(f) {
  2946. try {
  2947. a(n.next(f));
  2948. } catch (d) {
  2949. o(d);
  2950. }
  2951. }
  2952. function c(f) {
  2953. try {
  2954. a(n.throw(f));
  2955. } catch (d) {
  2956. o(d);
  2957. }
  2958. }
  2959. function a(f) {
  2960. if (f.done) {
  2961. r(f.value);
  2962. } else {
  2963. s(f.value).then(l, c);
  2964. }
  2965. }
  2966. a((n = n.apply(e, t || [])).next());
  2967. });
  2968. };
  2969. var Xn = globalThis && globalThis.__generator || function (e, t) {
  2970. var i = {
  2971. label: 0,
  2972. sent: function () {
  2973. if (r[0] & 1) {
  2974. throw r[1];
  2975. }
  2976. return r[1];
  2977. },
  2978. trys: [],
  2979. ops: []
  2980. };
  2981. var n;
  2982. var s;
  2983. var r;
  2984. var o;
  2985. o = {
  2986. next: l(0),
  2987. throw: l(1),
  2988. return: l(2)
  2989. };
  2990. if (typeof Symbol == "function") {
  2991. o[Symbol.iterator] = function () {
  2992. return this;
  2993. };
  2994. }
  2995. return o;
  2996. function l(a) {
  2997. return function (f) {
  2998. return c([a, f]);
  2999. };
  3000. }
  3001. function c(a) {
  3002. if (n) {
  3003. throw new TypeError("Generator is already executing.");
  3004. }
  3005. for (; i;) {
  3006. try {
  3007. n = 1;
  3008. if (s && (r = a[0] & 2 ? s.return : a[0] ? s.throw || ((r = s.return) && r.call(s), 0) : s.next) && !(r = r.call(s, a[1])).done) {
  3009. return r;
  3010. }
  3011. s = 0;
  3012. if (r) {
  3013. a = [a[0] & 2, r.value];
  3014. }
  3015. switch (a[0]) {
  3016. case 0:
  3017. case 1:
  3018. r = a;
  3019. break;
  3020. case 4:
  3021. i.label++;
  3022. return {
  3023. value: a[1],
  3024. done: false
  3025. };
  3026. case 5:
  3027. i.label++;
  3028. s = a[1];
  3029. a = [0];
  3030. continue;
  3031. case 7:
  3032. a = i.ops.pop();
  3033. i.trys.pop();
  3034. continue;
  3035. default:
  3036. r = i.trys;
  3037. if (!(r = r.length > 0 && r[r.length - 1]) && (a[0] === 6 || a[0] === 2)) {
  3038. i = 0;
  3039. continue;
  3040. }
  3041. if (a[0] === 3 && (!r || a[1] > r[0] && a[1] < r[3])) {
  3042. i.label = a[1];
  3043. break;
  3044. }
  3045. if (a[0] === 6 && i.label < r[1]) {
  3046. i.label = r[1];
  3047. r = a;
  3048. break;
  3049. }
  3050. if (r && i.label < r[2]) {
  3051. i.label = r[2];
  3052. i.ops.push(a);
  3053. break;
  3054. }
  3055. if (r[2]) {
  3056. i.ops.pop();
  3057. }
  3058. i.trys.pop();
  3059. continue;
  3060. }
  3061. a = t.call(e, i);
  3062. } catch (f) {
  3063. a = [6, f];
  3064. s = 0;
  3065. } finally {
  3066. n = r = 0;
  3067. }
  3068. }
  3069. if (a[0] & 5) {
  3070. throw a[1];
  3071. }
  3072. return {
  3073. value: a[0] ? a[1] : undefined,
  3074. done: true
  3075. };
  3076. }
  3077. };
  3078. var kr = globalThis && globalThis.__asyncValues || function (e) {
  3079. if (!Symbol.asyncIterator) {
  3080. throw new TypeError("Symbol.asyncIterator is not defined.");
  3081. }
  3082. var t = e[Symbol.asyncIterator];
  3083. var i;
  3084. if (t) {
  3085. return t.call(e);
  3086. } else {
  3087. e = typeof __values == "function" ? __values(e) : e[Symbol.iterator]();
  3088. i = {};
  3089. n("next");
  3090. n("throw");
  3091. n("return");
  3092. i[Symbol.asyncIterator] = function () {
  3093. return this;
  3094. };
  3095. return i;
  3096. }
  3097. function n(r) {
  3098. i[r] = e[r] && function (o) {
  3099. return new Promise(function (l, c) {
  3100. o = e[r](o);
  3101. s(l, c, o.done, o.value);
  3102. });
  3103. };
  3104. }
  3105. function s(r, o, l, c) {
  3106. Promise.resolve(c).then(function (a) {
  3107. r({
  3108. value: a,
  3109. done: l
  3110. });
  3111. }, o);
  3112. }
  3113. };
  3114. var ai = globalThis && globalThis.__await || function (e) {
  3115. if (this instanceof ai) {
  3116. this.v = e;
  3117. return this;
  3118. } else {
  3119. return new ai(e);
  3120. }
  3121. };
  3122. var zl = globalThis && globalThis.__asyncGenerator || function (e, t, i) {
  3123. if (!Symbol.asyncIterator) {
  3124. throw new TypeError("Symbol.asyncIterator is not defined.");
  3125. }
  3126. var n = i.apply(e, t || []);
  3127. var s;
  3128. var r = [];
  3129. s = {};
  3130. o("next");
  3131. o("throw");
  3132. o("return");
  3133. s[Symbol.asyncIterator] = function () {
  3134. return this;
  3135. };
  3136. return s;
  3137. function o(u) {
  3138. if (n[u]) {
  3139. s[u] = function (p) {
  3140. return new Promise(function (w, x) {
  3141. if (!(r.push([u, p, w, x]) > 1)) {
  3142. l(u, p);
  3143. }
  3144. });
  3145. };
  3146. }
  3147. }
  3148. function l(u, p) {
  3149. try {
  3150. c(n[u](p));
  3151. } catch (w) {
  3152. d(r[0][3], w);
  3153. }
  3154. }
  3155. function c(u) {
  3156. if (u.value instanceof ai) {
  3157. Promise.resolve(u.value.v).then(a, f);
  3158. } else {
  3159. d(r[0][2], u);
  3160. }
  3161. }
  3162. function a(u) {
  3163. l("next", u);
  3164. }
  3165. function f(u) {
  3166. l("throw", u);
  3167. }
  3168. function d(u, p) {
  3169. u(p);
  3170. r.shift();
  3171. if (r.length) {
  3172. l(r[0][0], r[0][1]);
  3173. }
  3174. }
  3175. };
  3176. function Bl(e) {
  3177. var t = typeof e;
  3178. return t === "string" || t === "number";
  3179. }
  3180. var Ii = -1;
  3181. var Ys = new DataView(new ArrayBuffer(0));
  3182. var Hl = new Uint8Array(Ys.buffer);
  3183. var Ss = function () {
  3184. try {
  3185. Ys.getInt8(0);
  3186. } catch (e) {
  3187. return e.constructor;
  3188. }
  3189. throw new Error("never reached");
  3190. }();
  3191. var xr = new Ss("Insufficient data");
  3192. var Ll = new Ol();
  3193. var Fl = function () {
  3194. function e(t, i, n, s, r, o, l, c) {
  3195. if (t === undefined) {
  3196. t = Lo.defaultCodec;
  3197. }
  3198. if (i === undefined) {
  3199. i = undefined;
  3200. }
  3201. if (n === undefined) {
  3202. n = Ct;
  3203. }
  3204. if (s === undefined) {
  3205. s = Ct;
  3206. }
  3207. if (r === undefined) {
  3208. r = Ct;
  3209. }
  3210. if (o === undefined) {
  3211. o = Ct;
  3212. }
  3213. if (l === undefined) {
  3214. l = Ct;
  3215. }
  3216. if (c === undefined) {
  3217. c = Ll;
  3218. }
  3219. this.extensionCodec = t;
  3220. this.context = i;
  3221. this.maxStrLength = n;
  3222. this.maxBinLength = s;
  3223. this.maxArrayLength = r;
  3224. this.maxMapLength = o;
  3225. this.maxExtLength = l;
  3226. this.keyDecoder = c;
  3227. this.totalPos = 0;
  3228. this.pos = 0;
  3229. this.view = Ys;
  3230. this.bytes = Hl;
  3231. this.headByte = Ii;
  3232. this.stack = [];
  3233. }
  3234. e.prototype.reinitializeState = function () {
  3235. this.totalPos = 0;
  3236. this.headByte = Ii;
  3237. this.stack.length = 0;
  3238. };
  3239. e.prototype.setBuffer = function (t) {
  3240. this.bytes = yn(t);
  3241. this.view = Cl(this.bytes);
  3242. this.pos = 0;
  3243. };
  3244. e.prototype.appendBuffer = function (t) {
  3245. if (this.headByte === Ii && !this.hasRemaining(1)) {
  3246. this.setBuffer(t);
  3247. } else {
  3248. var i = this.bytes.subarray(this.pos);
  3249. var n = yn(t);
  3250. var s = new Uint8Array(i.length + n.length);
  3251. s.set(i);
  3252. s.set(n, i.length);
  3253. this.setBuffer(s);
  3254. }
  3255. };
  3256. e.prototype.hasRemaining = function (t) {
  3257. return this.view.byteLength - this.pos >= t;
  3258. };
  3259. e.prototype.createExtraByteError = function (t) {
  3260. var i = this;
  3261. var n = i.view;
  3262. var s = i.pos;
  3263. return new RangeError(`Extra ${n.byteLength - s} of ${n.byteLength} byte(s) found at buffer[${t}]`);
  3264. };
  3265. e.prototype.decode = function (t) {
  3266. this.reinitializeState();
  3267. this.setBuffer(t);
  3268. var i = this.doDecodeSync();
  3269. if (this.hasRemaining(1)) {
  3270. throw this.createExtraByteError(this.pos);
  3271. }
  3272. return i;
  3273. };
  3274. e.prototype.decodeMulti = function (t) {
  3275. return Xn(this, function (i) {
  3276. switch (i.label) {
  3277. case 0:
  3278. this.reinitializeState();
  3279. this.setBuffer(t);
  3280. i.label = 1;
  3281. case 1:
  3282. if (this.hasRemaining(1)) {
  3283. return [4, this.doDecodeSync()];
  3284. } else {
  3285. return [3, 3];
  3286. }
  3287. case 2:
  3288. i.sent();
  3289. return [3, 1];
  3290. case 3:
  3291. return [2];
  3292. }
  3293. });
  3294. };
  3295. e.prototype.decodeAsync = function (t) {
  3296. var i;
  3297. var n;
  3298. var s;
  3299. var r;
  3300. return _l(this, undefined, undefined, function () {
  3301. var o;
  3302. var l;
  3303. var c;
  3304. var a;
  3305. var f;
  3306. var d;
  3307. var u;
  3308. var p;
  3309. return Xn(this, function (w) {
  3310. switch (w.label) {
  3311. case 0:
  3312. o = false;
  3313. w.label = 1;
  3314. case 1:
  3315. w.trys.push([1, 6, 7, 12]);
  3316. i = kr(t);
  3317. w.label = 2;
  3318. case 2:
  3319. return [4, i.next()];
  3320. case 3:
  3321. n = w.sent();
  3322. if (!!n.done) {
  3323. return [3, 5];
  3324. }
  3325. c = n.value;
  3326. if (o) {
  3327. throw this.createExtraByteError(this.totalPos);
  3328. }
  3329. this.appendBuffer(c);
  3330. try {
  3331. l = this.doDecodeSync();
  3332. o = true;
  3333. } catch (x) {
  3334. if (!(x instanceof Ss)) {
  3335. throw x;
  3336. }
  3337. }
  3338. this.totalPos += this.pos;
  3339. w.label = 4;
  3340. case 4:
  3341. return [3, 2];
  3342. case 5:
  3343. return [3, 12];
  3344. case 6:
  3345. a = w.sent();
  3346. s = {
  3347. error: a
  3348. };
  3349. return [3, 12];
  3350. case 7:
  3351. w.trys.push([7,, 10, 11]);
  3352. if (n && !n.done && (r = i.return)) {
  3353. return [4, r.call(i)];
  3354. } else {
  3355. return [3, 9];
  3356. }
  3357. case 8:
  3358. w.sent();
  3359. w.label = 9;
  3360. case 9:
  3361. return [3, 11];
  3362. case 10:
  3363. if (s) {
  3364. throw s.error;
  3365. }
  3366. return [7];
  3367. case 11:
  3368. return [7];
  3369. case 12:
  3370. if (o) {
  3371. if (this.hasRemaining(1)) {
  3372. throw this.createExtraByteError(this.totalPos);
  3373. }
  3374. return [2, l];
  3375. }
  3376. f = this;
  3377. d = f.headByte;
  3378. u = f.pos;
  3379. p = f.totalPos;
  3380. throw new RangeError(`Insufficient data in parsing ${Wn(d)} at ${p} (${u} in the current buffer)`);
  3381. }
  3382. });
  3383. });
  3384. };
  3385. e.prototype.decodeArrayStream = function (t) {
  3386. return this.decodeMultiAsync(t, true);
  3387. };
  3388. e.prototype.decodeStream = function (t) {
  3389. return this.decodeMultiAsync(t, false);
  3390. };
  3391. e.prototype.decodeMultiAsync = function (t, i) {
  3392. return zl(this, arguments, function () {
  3393. var s;
  3394. var r;
  3395. var o;
  3396. var l;
  3397. var c;
  3398. var a;
  3399. var f;
  3400. var d;
  3401. var u;
  3402. return Xn(this, function (p) {
  3403. switch (p.label) {
  3404. case 0:
  3405. s = i;
  3406. r = -1;
  3407. p.label = 1;
  3408. case 1:
  3409. p.trys.push([1, 13, 14, 19]);
  3410. o = kr(t);
  3411. p.label = 2;
  3412. case 2:
  3413. return [4, ai(o.next())];
  3414. case 3:
  3415. l = p.sent();
  3416. if (!!l.done) {
  3417. return [3, 12];
  3418. }
  3419. c = l.value;
  3420. if (i && r === 0) {
  3421. throw this.createExtraByteError(this.totalPos);
  3422. }
  3423. this.appendBuffer(c);
  3424. if (s) {
  3425. r = this.readArraySize();
  3426. s = false;
  3427. this.complete();
  3428. }
  3429. p.label = 4;
  3430. case 4:
  3431. p.trys.push([4, 9,, 10]);
  3432. p.label = 5;
  3433. case 5:
  3434. return [4, ai(this.doDecodeSync())];
  3435. case 6:
  3436. return [4, p.sent()];
  3437. case 7:
  3438. p.sent();
  3439. if (--r === 0) {
  3440. return [3, 8];
  3441. } else {
  3442. return [3, 5];
  3443. }
  3444. case 8:
  3445. return [3, 10];
  3446. case 9:
  3447. a = p.sent();
  3448. if (!(a instanceof Ss)) {
  3449. throw a;
  3450. }
  3451. return [3, 10];
  3452. case 10:
  3453. this.totalPos += this.pos;
  3454. p.label = 11;
  3455. case 11:
  3456. return [3, 2];
  3457. case 12:
  3458. return [3, 19];
  3459. case 13:
  3460. f = p.sent();
  3461. d = {
  3462. error: f
  3463. };
  3464. return [3, 19];
  3465. case 14:
  3466. p.trys.push([14,, 17, 18]);
  3467. if (l && !l.done && (u = o.return)) {
  3468. return [4, ai(u.call(o))];
  3469. } else {
  3470. return [3, 16];
  3471. }
  3472. case 15:
  3473. p.sent();
  3474. p.label = 16;
  3475. case 16:
  3476. return [3, 18];
  3477. case 17:
  3478. if (d) {
  3479. throw d.error;
  3480. }
  3481. return [7];
  3482. case 18:
  3483. return [7];
  3484. case 19:
  3485. return [2];
  3486. }
  3487. });
  3488. });
  3489. };
  3490. e.prototype.doDecodeSync = function () {
  3491. e: for (;;) {
  3492. var t = this.readHeadByte();
  3493. var i = undefined;
  3494. if (t >= 224) {
  3495. i = t - 256;
  3496. } else if (t < 192) {
  3497. if (t < 128) {
  3498. i = t;
  3499. } else if (t < 144) {
  3500. var n = t - 128;
  3501. if (n !== 0) {
  3502. this.pushMapState(n);
  3503. this.complete();
  3504. continue e;
  3505. } else {
  3506. i = {};
  3507. }
  3508. } else if (t < 160) {
  3509. var n = t - 144;
  3510. if (n !== 0) {
  3511. this.pushArrayState(n);
  3512. this.complete();
  3513. continue e;
  3514. } else {
  3515. i = [];
  3516. }
  3517. } else {
  3518. var s = t - 160;
  3519. i = this.decodeUtf8String(s, 0);
  3520. }
  3521. } else if (t === 192) {
  3522. i = null;
  3523. } else if (t === 194) {
  3524. i = false;
  3525. } else if (t === 195) {
  3526. i = true;
  3527. } else if (t === 202) {
  3528. i = this.readF32();
  3529. } else if (t === 203) {
  3530. i = this.readF64();
  3531. } else if (t === 204) {
  3532. i = this.readU8();
  3533. } else if (t === 205) {
  3534. i = this.readU16();
  3535. } else if (t === 206) {
  3536. i = this.readU32();
  3537. } else if (t === 207) {
  3538. i = this.readU64();
  3539. } else if (t === 208) {
  3540. i = this.readI8();
  3541. } else if (t === 209) {
  3542. i = this.readI16();
  3543. } else if (t === 210) {
  3544. i = this.readI32();
  3545. } else if (t === 211) {
  3546. i = this.readI64();
  3547. } else if (t === 217) {
  3548. var s = this.lookU8();
  3549. i = this.decodeUtf8String(s, 1);
  3550. } else if (t === 218) {
  3551. var s = this.lookU16();
  3552. i = this.decodeUtf8String(s, 2);
  3553. } else if (t === 219) {
  3554. var s = this.lookU32();
  3555. i = this.decodeUtf8String(s, 4);
  3556. } else if (t === 220) {
  3557. var n = this.readU16();
  3558. if (n !== 0) {
  3559. this.pushArrayState(n);
  3560. this.complete();
  3561. continue e;
  3562. } else {
  3563. i = [];
  3564. }
  3565. } else if (t === 221) {
  3566. var n = this.readU32();
  3567. if (n !== 0) {
  3568. this.pushArrayState(n);
  3569. this.complete();
  3570. continue e;
  3571. } else {
  3572. i = [];
  3573. }
  3574. } else if (t === 222) {
  3575. var n = this.readU16();
  3576. if (n !== 0) {
  3577. this.pushMapState(n);
  3578. this.complete();
  3579. continue e;
  3580. } else {
  3581. i = {};
  3582. }
  3583. } else if (t === 223) {
  3584. var n = this.readU32();
  3585. if (n !== 0) {
  3586. this.pushMapState(n);
  3587. this.complete();
  3588. continue e;
  3589. } else {
  3590. i = {};
  3591. }
  3592. } else if (t === 196) {
  3593. var n = this.lookU8();
  3594. i = this.decodeBinary(n, 1);
  3595. } else if (t === 197) {
  3596. var n = this.lookU16();
  3597. i = this.decodeBinary(n, 2);
  3598. } else if (t === 198) {
  3599. var n = this.lookU32();
  3600. i = this.decodeBinary(n, 4);
  3601. } else if (t === 212) {
  3602. i = this.decodeExtension(1, 0);
  3603. } else if (t === 213) {
  3604. i = this.decodeExtension(2, 0);
  3605. } else if (t === 214) {
  3606. i = this.decodeExtension(4, 0);
  3607. } else if (t === 215) {
  3608. i = this.decodeExtension(8, 0);
  3609. } else if (t === 216) {
  3610. i = this.decodeExtension(16, 0);
  3611. } else if (t === 199) {
  3612. var n = this.lookU8();
  3613. i = this.decodeExtension(n, 1);
  3614. } else if (t === 200) {
  3615. var n = this.lookU16();
  3616. i = this.decodeExtension(n, 2);
  3617. } else if (t === 201) {
  3618. var n = this.lookU32();
  3619. i = this.decodeExtension(n, 4);
  3620. } else {
  3621. throw new Je(`Unrecognized type byte: ${Wn(t)}`);
  3622. }
  3623. this.complete();
  3624. for (var r = this.stack; r.length > 0;) {
  3625. var o = r[r.length - 1];
  3626. if (o.type === 0) {
  3627. o.array[o.position] = i;
  3628. o.position++;
  3629. if (o.position === o.size) {
  3630. r.pop();
  3631. i = o.array;
  3632. } else {
  3633. continue e;
  3634. }
  3635. } else if (o.type === 1) {
  3636. if (!Bl(i)) {
  3637. throw new Je("The type of key must be string or number but " + typeof i);
  3638. }
  3639. if (i === "__proto__") {
  3640. throw new Je("The key __proto__ is not allowed");
  3641. }
  3642. o.key = i;
  3643. o.type = 2;
  3644. continue e;
  3645. } else {
  3646. o.map[o.key] = i;
  3647. o.readCount++;
  3648. if (o.readCount === o.size) {
  3649. r.pop();
  3650. i = o.map;
  3651. } else {
  3652. o.key = null;
  3653. o.type = 1;
  3654. continue e;
  3655. }
  3656. }
  3657. }
  3658. return i;
  3659. }
  3660. };
  3661. e.prototype.readHeadByte = function () {
  3662. if (this.headByte === Ii) {
  3663. this.headByte = this.readU8();
  3664. }
  3665. return this.headByte;
  3666. };
  3667. e.prototype.complete = function () {
  3668. this.headByte = Ii;
  3669. };
  3670. e.prototype.readArraySize = function () {
  3671. var t = this.readHeadByte();
  3672. switch (t) {
  3673. case 220:
  3674. return this.readU16();
  3675. case 221:
  3676. return this.readU32();
  3677. default:
  3678. {
  3679. if (t < 160) {
  3680. return t - 144;
  3681. }
  3682. throw new Je(`Unrecognized array type byte: ${Wn(t)}`);
  3683. }
  3684. }
  3685. };
  3686. e.prototype.pushMapState = function (t) {
  3687. if (t > this.maxMapLength) {
  3688. throw new Je(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);
  3689. }
  3690. this.stack.push({
  3691. type: 1,
  3692. size: t,
  3693. key: null,
  3694. readCount: 0,
  3695. map: {}
  3696. });
  3697. };
  3698. e.prototype.pushArrayState = function (t) {
  3699. if (t > this.maxArrayLength) {
  3700. throw new Je(`Max length exceeded: array length (${t}) > maxArrayLength (${this.maxArrayLength})`);
  3701. }
  3702. this.stack.push({
  3703. type: 0,
  3704. size: t,
  3705. array: new Array(t),
  3706. position: 0
  3707. });
  3708. };
  3709. e.prototype.decodeUtf8String = function (t, i) {
  3710. var n;
  3711. if (t > this.maxStrLength) {
  3712. throw new Je(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);
  3713. }
  3714. if (this.bytes.byteLength < this.pos + i + t) {
  3715. throw xr;
  3716. }
  3717. var s = this.pos + i;
  3718. var r;
  3719. if (this.stateIsMapKey() && !((n = this.keyDecoder) === null || n === undefined) && n.canBeCached(t)) {
  3720. r = this.keyDecoder.decode(this.bytes, s, t);
  3721. } else if (t > gl) {
  3722. r = yl(this.bytes, s, t);
  3723. } else {
  3724. r = Ho(this.bytes, s, t);
  3725. }
  3726. this.pos += i + t;
  3727. return r;
  3728. };
  3729. e.prototype.stateIsMapKey = function () {
  3730. if (this.stack.length > 0) {
  3731. var t = this.stack[this.stack.length - 1];
  3732. return t.type === 1;
  3733. }
  3734. return false;
  3735. };
  3736. e.prototype.decodeBinary = function (t, i) {
  3737. if (t > this.maxBinLength) {
  3738. throw new Je(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);
  3739. }
  3740. if (!this.hasRemaining(t + i)) {
  3741. throw xr;
  3742. }
  3743. var n = this.pos + i;
  3744. var s = this.bytes.subarray(n, n + t);
  3745. this.pos += i + t;
  3746. return s;
  3747. };
  3748. e.prototype.decodeExtension = function (t, i) {
  3749. if (t > this.maxExtLength) {
  3750. throw new Je(`Max length exceeded: ext length (${t}) > maxExtLength (${this.maxExtLength})`);
  3751. }
  3752. var n = this.view.getInt8(this.pos + i);
  3753. var s = this.decodeBinary(t, i + 1);
  3754. return this.extensionCodec.decode(s, n, this.context);
  3755. };
  3756. e.prototype.lookU8 = function () {
  3757. return this.view.getUint8(this.pos);
  3758. };
  3759. e.prototype.lookU16 = function () {
  3760. return this.view.getUint16(this.pos);
  3761. };
  3762. e.prototype.lookU32 = function () {
  3763. return this.view.getUint32(this.pos);
  3764. };
  3765. e.prototype.readU8 = function () {
  3766. var t = this.view.getUint8(this.pos);
  3767. this.pos++;
  3768. return t;
  3769. };
  3770. e.prototype.readI8 = function () {
  3771. var t = this.view.getInt8(this.pos);
  3772. this.pos++;
  3773. return t;
  3774. };
  3775. e.prototype.readU16 = function () {
  3776. var t = this.view.getUint16(this.pos);
  3777. this.pos += 2;
  3778. return t;
  3779. };
  3780. e.prototype.readI16 = function () {
  3781. var t = this.view.getInt16(this.pos);
  3782. this.pos += 2;
  3783. return t;
  3784. };
  3785. e.prototype.readU32 = function () {
  3786. var t = this.view.getUint32(this.pos);
  3787. this.pos += 4;
  3788. return t;
  3789. };
  3790. e.prototype.readI32 = function () {
  3791. var t = this.view.getInt32(this.pos);
  3792. this.pos += 4;
  3793. return t;
  3794. };
  3795. e.prototype.readU64 = function () {
  3796. var t = ll(this.view, this.pos);
  3797. this.pos += 8;
  3798. return t;
  3799. };
  3800. e.prototype.readI64 = function () {
  3801. var t = Bo(this.view, this.pos);
  3802. this.pos += 8;
  3803. return t;
  3804. };
  3805. e.prototype.readF32 = function () {
  3806. var t = this.view.getFloat32(this.pos);
  3807. this.pos += 4;
  3808. return t;
  3809. };
  3810. e.prototype.readF64 = function () {
  3811. var t = this.view.getFloat64(this.pos);
  3812. this.pos += 8;
  3813. return t;
  3814. };
  3815. return e;
  3816. }();
  3817. var Vt = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
  3818. function An(e) {
  3819. if (e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default")) {
  3820. return e.default;
  3821. } else {
  3822. return e;
  3823. }
  3824. }
  3825. var Fo = {
  3826. exports: {}
  3827. };
  3828. var xe = Fo.exports = {};
  3829. var Qe;
  3830. var je;
  3831. function Is() {
  3832. throw new Error("setTimeout has not been defined");
  3833. }
  3834. function Ts() {
  3835. throw new Error("clearTimeout has not been defined");
  3836. }
  3837. (function () {
  3838. try {
  3839. if (typeof setTimeout == "function") {
  3840. Qe = setTimeout;
  3841. } else {
  3842. Qe = Is;
  3843. }
  3844. } catch {
  3845. Qe = Is;
  3846. }
  3847. try {
  3848. if (typeof clearTimeout == "function") {
  3849. je = clearTimeout;
  3850. } else {
  3851. je = Ts;
  3852. }
  3853. } catch {
  3854. je = Ts;
  3855. }
  3856. })();
  3857. function Vo(e) {
  3858. if (Qe === setTimeout) {
  3859. return (// TOLOOK
  3860. setTimeout(e, 0)
  3861. );
  3862. }
  3863. if ((Qe === Is || !Qe) && setTimeout) {
  3864. Qe = setTimeout;
  3865. return (// TOLOOK
  3866. setTimeout(e, 0)
  3867. );
  3868. }
  3869. try {
  3870. return Qe(e, 0);
  3871. } catch {
  3872. try {
  3873. return Qe.call(null, e, 0);
  3874. } catch {
  3875. return Qe.call(this, e, 0);
  3876. }
  3877. }
  3878. }
  3879. function Vl(e) {
  3880. if (je === clearTimeout) {
  3881. return clearTimeout(e);
  3882. }
  3883. if ((je === Ts || !je) && clearTimeout) {
  3884. je = clearTimeout;
  3885. return clearTimeout(e);
  3886. }
  3887. try {
  3888. return je(e);
  3889. } catch {
  3890. try {
  3891. return je.call(null, e);
  3892. } catch {
  3893. return je.call(this, e);
  3894. }
  3895. }
  3896. }
  3897. var ct = [];
  3898. var li = false;
  3899. var $t;
  3900. var on = -1;
  3901. function Nl() {
  3902. if (!(!li || !$t)) {
  3903. li = false;
  3904. if ($t.length) {
  3905. ct = $t.concat(ct);
  3906. } else {
  3907. on = -1;
  3908. }
  3909. if (ct.length) {
  3910. No();
  3911. }
  3912. }
  3913. }
  3914. function No() {
  3915. if (!li) {
  3916. var e = Vo(Nl);
  3917. li = true;
  3918. for (var t = ct.length; t;) {
  3919. $t = ct;
  3920. ct = [];
  3921. for (; ++on < t;) {
  3922. if ($t) {
  3923. $t[on].run();
  3924. }
  3925. }
  3926. on = -1;
  3927. t = ct.length;
  3928. }
  3929. $t = null;
  3930. li = false;
  3931. Vl(e);
  3932. }
  3933. }
  3934. xe.nextTick = function (e) {
  3935. var t = new Array(arguments.length - 1);
  3936. if (arguments.length > 1) {
  3937. for (var i = 1; i < arguments.length; i++) {
  3938. t[i - 1] = arguments[i];
  3939. }
  3940. }
  3941. ct.push(new Uo(e, t));
  3942. if (ct.length === 1 && !li) {
  3943. Vo(No);
  3944. }
  3945. };
  3946. function Uo(e, t) {
  3947. this.fun = e;
  3948. this.array = t;
  3949. }
  3950. Uo.prototype.run = function () {
  3951. this.fun.apply(null, this.array);
  3952. };
  3953. xe.title = "browser";
  3954. xe.browser = true;
  3955. xe.env = {};
  3956. xe.argv = [];
  3957. xe.version = "";
  3958. xe.versions = {};
  3959. function ft() {}
  3960. xe.on = ft;
  3961. xe.addListener = ft;
  3962. xe.once = ft;
  3963. xe.off = ft;
  3964. xe.removeListener = ft;
  3965. xe.removeAllListeners = ft;
  3966. xe.emit = ft;
  3967. xe.prependListener = ft;
  3968. xe.prependOnceListener = ft;
  3969. xe.listeners = function (e) {
  3970. return [];
  3971. };
  3972. xe.binding = function (e) {
  3973. throw new Error("process.binding is not supported");
  3974. };
  3975. xe.cwd = function () {
  3976. return "/";
  3977. };
  3978. xe.chdir = function (e) {
  3979. throw new Error("process.chdir is not supported");
  3980. };
  3981. xe.umask = function () {
  3982. return 0;
  3983. };
  3984. var Ul = Fo.exports;
  3985. const Ms = An(Ul);
  3986. const Wl = 1920;
  3987. const Xl = 1080;
  3988. const ql = 9;
  3989. const Wo = Ms && Ms.argv.indexOf("--largeserver") != -1 ? 80 : 40;
  3990. const Gl = Wo + 10;
  3991. const Yl = 6;
  3992. const Kl = 3000;
  3993. const Zl = 10;
  3994. const Jl = 5;
  3995. const Ql = 50;
  3996. const jl = 4.5;
  3997. const ec = 15;
  3998. const tc = 0.9;
  3999. const ic = 3000;
  4000. const nc = 60;
  4001. const sc = 35;
  4002. const rc = 3000;
  4003. const oc = 500;
  4004. const ac = Ms && {}.IS_SANDBOX;
  4005. const lc = 100;
  4006. const cc = Math.PI / 2.6;
  4007. const hc = 10;
  4008. const uc = 0.25;
  4009. const fc = Math.PI / 2;
  4010. const dc = 35;
  4011. const pc = 0.0016;
  4012. const mc = 0.993;
  4013. const gc = 34;
  4014. const yc = ["#bf8f54", "#cbb091", "#896c4b", "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3", "#8bc373"];
  4015. const wc = 7;
  4016. const vc = 0.06;
  4017. const kc = ["Sid", "Steph", "Bmoe", "Romn", "Jononthecool", "Fiona", "Vince", "Nathan", "Nick", "Flappy", "Ronald", "Otis", "Pepe", "Mc Donald", "Theo", "Fabz", "Oliver", "Jeff", "Jimmy", "Helena", "Reaper", "Ben", "Alan", "Naomi", "XYZ", "Clever", "Jeremy", "Mike", "Destined", "Stallion", "Allison", "Meaty", "Sophia", "Vaja", "Joey", "Pendy", "Murdoch", "Theo", "Jared", "July", "Sonia", "Mel", "Dexter", "Quinn", "Milky"];
  4018. const xc = Math.PI / 3;
  4019. const an = [{
  4020. id: 0,
  4021. src: "",
  4022. xp: 0,
  4023. val: 1
  4024. }, {
  4025. id: 1,
  4026. src: "_g",
  4027. xp: 3000,
  4028. val: 1.1
  4029. }, {
  4030. id: 2,
  4031. src: "_d",
  4032. xp: 7000,
  4033. val: 1.18
  4034. }, {
  4035. id: 3,
  4036. src: "_r",
  4037. poison: true,
  4038. xp: 12000,
  4039. val: 1.18
  4040. }];
  4041. const bc = function (e) {
  4042. const t = e.weaponXP[e.weaponIndex] || 0;
  4043. for (let i = an.length - 1; i >= 0; --i) {
  4044. if (t >= an[i].xp) {
  4045. return an[i];
  4046. }
  4047. }
  4048. };
  4049. const Sc = ["wood", "food", "stone", "points"];
  4050. const Ic = 7;
  4051. const Tc = 9;
  4052. const Mc = 3;
  4053. const Ec = 32;
  4054. const Cc = 7;
  4055. const Pc = 724;
  4056. const $c = 114;
  4057. const Rc = 0.0011;
  4058. const Ac = 0.0001;
  4059. const Dc = 1.3;
  4060. const Oc = [150, 160, 165, 175];
  4061. const _c = [80, 85, 95];
  4062. const zc = [80, 85, 90];
  4063. const Bc = 2400;
  4064. const Hc = 0.75;
  4065. const Lc = 15;
  4066. const Ks = 14400;
  4067. const Fc = 40;
  4068. const Vc = 2200;
  4069. const Nc = 0.6;
  4070. const Uc = 1;
  4071. const Wc = 0.3;
  4072. const Xc = 0.3;
  4073. const qc = 1440000;
  4074. const Zs = 320;
  4075. const Gc = 100;
  4076. const Yc = 2;
  4077. const Kc = 3200;
  4078. const Zc = 1440;
  4079. const Jc = 0.2;
  4080. const Qc = -1;
  4081. const jc = Ks - Zs - 120;
  4082. const eh = Ks - Zs - 120;
  4083. const T = {
  4084. maxScreenWidth: Wl,
  4085. maxScreenHeight: Xl,
  4086. serverUpdateRate: ql,
  4087. maxPlayers: Wo,
  4088. maxPlayersHard: Gl,
  4089. collisionDepth: Yl,
  4090. minimapRate: Kl,
  4091. colGrid: Zl,
  4092. clientSendRate: Jl,
  4093. healthBarWidth: Ql,
  4094. healthBarPad: jl,
  4095. iconPadding: ec,
  4096. iconPad: tc,
  4097. deathFadeout: ic,
  4098. crownIconScale: nc,
  4099. crownPad: sc,
  4100. chatCountdown: rc,
  4101. chatCooldown: oc,
  4102. inSandbox: ac,
  4103. maxAge: lc,
  4104. gatherAngle: cc,
  4105. gatherWiggle: hc,
  4106. hitReturnRatio: uc,
  4107. hitAngle: fc,
  4108. playerScale: dc,
  4109. playerSpeed: pc,
  4110. playerDecel: mc,
  4111. nameY: gc,
  4112. skinColors: yc,
  4113. animalCount: wc,
  4114. aiTurnRandom: vc,
  4115. cowNames: kc,
  4116. shieldAngle: xc,
  4117. weaponVariants: an,
  4118. fetchVariant: bc,
  4119. resourceTypes: Sc,
  4120. areaCount: Ic,
  4121. treesPerArea: Tc,
  4122. bushesPerArea: Mc,
  4123. totalRocks: Ec,
  4124. goldOres: Cc,
  4125. riverWidth: Pc,
  4126. riverPadding: $c,
  4127. waterCurrent: Rc,
  4128. waveSpeed: Ac,
  4129. waveMax: Dc,
  4130. treeScales: Oc,
  4131. bushScales: _c,
  4132. rockScales: zc,
  4133. snowBiomeTop: Bc,
  4134. snowSpeed: Hc,
  4135. maxNameLength: Lc,
  4136. mapScale: Ks,
  4137. mapPingScale: Fc,
  4138. mapPingTime: Vc,
  4139. volcanoScale: Zs,
  4140. innerVolcanoScale: Gc,
  4141. volcanoAnimalStrength: Yc,
  4142. volcanoAnimationDuration: Kc,
  4143. volcanoAggressionRadius: Zc,
  4144. volcanoAggressionPercentage: Jc,
  4145. volcanoDamagePerSecond: Qc,
  4146. volcanoLocationX: jc,
  4147. volcanoLocationY: eh,
  4148. MAX_ATTACK: Nc,
  4149. MAX_SPAWN_DELAY: Uc,
  4150. MAX_SPEED: Wc,
  4151. MAX_TURN_SPEED: Xc,
  4152. DAY_INTERVAL: qc
  4153. };
  4154. const th = new Rl();
  4155. const ih = new Fl();
  4156. const me = {
  4157. socket: null,
  4158. connected: false,
  4159. socketId: -1,
  4160. connect: function (e, t, i) {
  4161. if (this.socket) {
  4162. return;
  4163. }
  4164. const n = this;
  4165. try {
  4166. let s = false;
  4167. const r = e;
  4168. this.socket = new WebSocket(e);
  4169. this.socket.binaryType = "arraybuffer";
  4170. this.socket.onmessage = function (o) {
  4171. var a = new Uint8Array(o.data);
  4172. const l = ih.decode(a);
  4173. const c = l[0];
  4174. var a = l[1];
  4175. if (c == "io-init") {
  4176. n.socketId = a[0];
  4177. } else {
  4178. i[c].apply(undefined, a);
  4179. }
  4180. };
  4181. this.socket.onopen = function () {
  4182. n.connected = true;
  4183. t();
  4184. };
  4185. this.socket.onclose = function (o) {
  4186. n.connected = false;
  4187. if (o.code == 4001) {
  4188. t("Invalid Connection");
  4189. } else if (!s) {
  4190. t("disconnected");
  4191. }
  4192. };
  4193. this.socket.onerror = function (o) {
  4194. if (this.socket && this.socket.readyState != WebSocket.OPEN) {
  4195. s = true;
  4196. console.error("Socket error", arguments);
  4197. t("Socket error");
  4198. }
  4199. };
  4200. } catch (s) {
  4201. console.warn("Socket connection error:", s);
  4202. t(s);
  4203. }
  4204. },
  4205. send: function (e) {
  4206. const t = Array.prototype.slice.call(arguments, 1);
  4207. const i = th.encode([e, t]);
  4208. if (this.socket) {
  4209. this.socket.send(i);
  4210. }
  4211. },
  4212. socketReady: function () {
  4213. return this.socket && this.connected;
  4214. },
  4215. close: function () {
  4216. if (this.socket) {
  4217. this.socket.close();
  4218. }
  4219. this.socket = null;
  4220. this.connected = false;
  4221. }
  4222. };
  4223. var Xo = Math.abs;
  4224. const nh = Math.sqrt;
  4225. var Xo = Math.abs;
  4226. const sh = Math.atan2;
  4227. const qn = Math.PI;
  4228. const rh = function (e, t) {
  4229. return Math.floor(Math.random() * (t - e + 1)) + e;
  4230. };
  4231. const oh = function (e, t) {
  4232. return Math.random() * (t - e + 1) + e;
  4233. };
  4234. const ah = function (e, t, i) {
  4235. return e + (t - e) * i;
  4236. };
  4237. const lh = function (e, t) {
  4238. if (e > 0) {
  4239. e = Math.max(0, e - t);
  4240. } else if (e < 0) {
  4241. e = Math.min(0, e + t);
  4242. }
  4243. return e;
  4244. };
  4245. const ch = function (e, t, i, n) {
  4246. return nh((i -= e) * i + (n -= t) * n);
  4247. };
  4248. const hh = function (e, t, i, n) {
  4249. return sh(t - n, e - i);
  4250. };
  4251. const uh = function (e, t) {
  4252. const i = Xo(t - e) % (qn * 2);
  4253. if (i > qn) {
  4254. return qn * 2 - i;
  4255. } else {
  4256. return i;
  4257. }
  4258. };
  4259. const fh = function (e) {
  4260. return typeof e == "number" && !isNaN(e) && isFinite(e);
  4261. };
  4262. const dh = function (e) {
  4263. return e && typeof e == "string";
  4264. };
  4265. const ph = function (e) {
  4266. if (e > 999) {
  4267. return (e / 1000).toFixed(1) + "k";
  4268. } else {
  4269. return e;
  4270. }
  4271. };
  4272. const mh = function (e) {
  4273. return e.charAt(0).toUpperCase() + e.slice(1);
  4274. };
  4275. const gh = function (e, t) {
  4276. if (e) {
  4277. return parseFloat(e.toFixed(t));
  4278. } else {
  4279. return 0;
  4280. }
  4281. };
  4282. const yh = function (e, t) {
  4283. return parseFloat(t.points) - parseFloat(e.points);
  4284. };
  4285. const wh = function (e, t, i, n, s, r, o, l) {
  4286. let c = s;
  4287. let a = o;
  4288. if (s > o) {
  4289. c = o;
  4290. a = s;
  4291. }
  4292. if (a > i) {
  4293. a = i;
  4294. }
  4295. if (c < e) {
  4296. c = e;
  4297. }
  4298. if (c > a) {
  4299. return false;
  4300. }
  4301. let f = r;
  4302. let d = l;
  4303. const u = o - s;
  4304. if (Math.abs(u) > 1e-7) {
  4305. const p = (l - r) / u;
  4306. const w = r - p * s;
  4307. f = p * c + w;
  4308. d = p * a + w;
  4309. }
  4310. if (f > d) {
  4311. const p = d;
  4312. d = f;
  4313. f = p;
  4314. }
  4315. if (d > n) {
  4316. d = n;
  4317. }
  4318. if (f < t) {
  4319. f = t;
  4320. }
  4321. return !(f > d);
  4322. };
  4323. const qo = function (e, t, i) {
  4324. const n = e.getBoundingClientRect();
  4325. const s = n.left + window.scrollX;
  4326. const r = n.top + window.scrollY;
  4327. const o = n.width;
  4328. const l = n.height;
  4329. const c = t > s && t < s + o;
  4330. const a = i > r && i < r + l;
  4331. return c && a;
  4332. };
  4333. const ln = function (e) {
  4334. const t = e.changedTouches[0];
  4335. e.screenX = t.screenX;
  4336. e.screenY = t.screenY;
  4337. e.clientX = t.clientX;
  4338. e.clientY = t.clientY;
  4339. e.pageX = t.pageX;
  4340. e.pageY = t.pageY;
  4341. };
  4342. const Go = function (e, t) {
  4343. const i = !t;
  4344. let n = false;
  4345. const s = false;
  4346. e.addEventListener("touchstart", lt(r), s);
  4347. e.addEventListener("touchmove", lt(o), s);
  4348. e.addEventListener("touchend", lt(l), s);
  4349. e.addEventListener("touchcancel", lt(l), s);
  4350. e.addEventListener("touchleave", lt(l), s);
  4351. function r(c) {
  4352. ln(c);
  4353. window.setUsingTouch(true);
  4354. if (i) {
  4355. c.preventDefault();
  4356. c.stopPropagation();
  4357. }
  4358. if (e.onmouseover) {
  4359. e.onmouseover(c);
  4360. }
  4361. n = true;
  4362. }
  4363. function o(c) {
  4364. ln(c);
  4365. window.setUsingTouch(true);
  4366. if (i) {
  4367. c.preventDefault();
  4368. c.stopPropagation();
  4369. }
  4370. if (qo(e, c.pageX, c.pageY)) {
  4371. if (!n) {
  4372. if (e.onmouseover) {
  4373. e.onmouseover(c);
  4374. }
  4375. n = true;
  4376. }
  4377. } else if (n) {
  4378. if (e.onmouseout) {
  4379. e.onmouseout(c);
  4380. }
  4381. n = false;
  4382. }
  4383. }
  4384. function l(c) {
  4385. ln(c);
  4386. window.setUsingTouch(true);
  4387. if (i) {
  4388. c.preventDefault();
  4389. c.stopPropagation();
  4390. }
  4391. if (n) {
  4392. if (e.onclick) {
  4393. e.onclick(c);
  4394. }
  4395. if (e.onmouseout) {
  4396. e.onmouseout(c);
  4397. }
  4398. n = false;
  4399. }
  4400. }
  4401. };
  4402. const vh = function (e) {
  4403. for (; e.hasChildNodes();) {
  4404. e.removeChild(e.lastChild);
  4405. }
  4406. };
  4407. const kh = function (e) {
  4408. const t = document.createElement(e.tag || "div");
  4409. function i(n, s) {
  4410. if (e[n]) {
  4411. t[s] = e[n];
  4412. }
  4413. }
  4414. i("text", "textContent");
  4415. i("html", "innerHTML");
  4416. i("class", "className");
  4417. for (const n in e) {
  4418. switch (n) {
  4419. case "tag":
  4420. case "text":
  4421. case "html":
  4422. case "class":
  4423. case "style":
  4424. case "hookTouch":
  4425. case "parent":
  4426. case "children":
  4427. continue;
  4428. }
  4429. t[n] = e[n];
  4430. }
  4431. if (t.onclick) {
  4432. t.onclick = lt(t.onclick);
  4433. }
  4434. if (t.onmouseover) {
  4435. t.onmouseover = lt(t.onmouseover);
  4436. }
  4437. if (t.onmouseout) {
  4438. t.onmouseout = lt(t.onmouseout);
  4439. }
  4440. if (e.style) {
  4441. t.style.cssText = e.style;
  4442. }
  4443. if (e.hookTouch) {
  4444. Go(t);
  4445. }
  4446. if (e.parent) {
  4447. e.parent.appendChild(t);
  4448. }
  4449. if (e.children) {
  4450. for (let n = 0; n < e.children.length; n++) {
  4451. t.appendChild(e.children[n]);
  4452. }
  4453. }
  4454. return t;
  4455. };
  4456. const Yo = function (e) {
  4457. if (e && typeof e.isTrusted == "boolean") {
  4458. return e.isTrusted;
  4459. } else {
  4460. return true;
  4461. }
  4462. };
  4463. const lt = function (e) {
  4464. return function (t) {
  4465. if (t && t instanceof Event && Yo(t)) {
  4466. e(t);
  4467. }
  4468. };
  4469. };
  4470. const xh = function (e) {
  4471. let t = "";
  4472. const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  4473. for (let n = 0; n < e; n++) {
  4474. t += i.charAt(Math.floor(Math.random() * i.length));
  4475. }
  4476. return t;
  4477. };
  4478. const bh = function (e, t) {
  4479. let i = 0;
  4480. for (let n = 0; n < e.length; n++) {
  4481. if (e[n] === t) {
  4482. i++;
  4483. }
  4484. }
  4485. return i;
  4486. };
  4487. const A = {
  4488. randInt: rh,
  4489. randFloat: oh,
  4490. lerp: ah,
  4491. decel: lh,
  4492. getDistance: ch,
  4493. getDirection: hh,
  4494. getAngleDist: uh,
  4495. isNumber: fh,
  4496. isString: dh,
  4497. kFormat: ph,
  4498. capitalizeFirst: mh,
  4499. fixTo: gh,
  4500. sortByPoints: yh,
  4501. lineInRect: wh,
  4502. containsPoint: qo,
  4503. mousifyTouchEvent: ln,
  4504. hookTouchEvents: Go,
  4505. removeAllChildren: vh,
  4506. generateElement: kh,
  4507. eventIsTrusted: Yo,
  4508. checkTrusted: lt,
  4509. randomString: xh,
  4510. countInArray: bh
  4511. };
  4512. const Sh = function () {
  4513. this.init = function (e, t, i, n, s, r, o) {
  4514. this.x = e;
  4515. this.y = t;
  4516. this.color = o;
  4517. this.scale = i;
  4518. this.startScale = this.scale;
  4519. this.maxScale = i * 1.5;
  4520. this.scaleSpeed = 0.7;
  4521. this.speed = n;
  4522. this.life = s;
  4523. this.text = r;
  4524. };
  4525. this.update = function (e) {
  4526. if (this.life) {
  4527. this.life -= e;
  4528. this.y -= this.speed * e;
  4529. this.scale += this.scaleSpeed * e;
  4530. if (this.scale >= this.maxScale) {
  4531. this.scale = this.maxScale;
  4532. this.scaleSpeed *= -1;
  4533. } else if (this.scale <= this.startScale) {
  4534. this.scale = this.startScale;
  4535. this.scaleSpeed = 0;
  4536. }
  4537. if (this.life <= 0) {
  4538. this.life = 0;
  4539. }
  4540. }
  4541. };
  4542. this.render = function (e, t, i) {
  4543. e.fillStyle = this.color;
  4544. e.font = this.scale + "px Hammersmith One";
  4545. e.fillText(this.text, this.x - t, this.y - i);
  4546. };
  4547. };
  4548. const Ih = function () {
  4549. this.texts = [];
  4550. this.update = function (e, t, i, n) {
  4551. t.textBaseline = "middle";
  4552. t.textAlign = "center";
  4553. for (let s = 0; s < this.texts.length; ++s) {
  4554. if (this.texts[s].life) {
  4555. this.texts[s].update(e);
  4556. this.texts[s].render(t, i, n);
  4557. }
  4558. }
  4559. };
  4560. this.showText = function (e, t, i, n, s, r, o) {
  4561. let l;
  4562. for (let c = 0; c < this.texts.length; ++c) {
  4563. if (!this.texts[c].life) {
  4564. l = this.texts[c];
  4565. break;
  4566. }
  4567. }
  4568. if (!l) {
  4569. l = new Sh();
  4570. this.texts.push(l);
  4571. }
  4572. l.init(e, t, i, n, s, r, o);
  4573. };
  4574. };
  4575. const Th = function (e, t) {
  4576. let i;
  4577. this.sounds = [];
  4578. this.active = true;
  4579. this.play = function (n, s, r) {
  4580. if (!(!s || !this.active)) {
  4581. i = this.sounds[n];
  4582. if (!i) {
  4583. i = new Howl({
  4584. src: ".././sound/" + n + ".mp3"
  4585. });
  4586. this.sounds[n] = i;
  4587. }
  4588. if (!r || !i.isPlaying) {
  4589. i.isPlaying = true;
  4590. i.play();
  4591. i.volume((s || 1) * e.volumeMult);
  4592. i.loop(r);
  4593. }
  4594. }
  4595. };
  4596. this.toggleMute = function (n, s) {
  4597. i = this.sounds[n];
  4598. if (i) {
  4599. i.mute(s);
  4600. }
  4601. };
  4602. this.stop = function (n) {
  4603. i = this.sounds[n];
  4604. if (i) {
  4605. i.stop();
  4606. i.isPlaying = false;
  4607. }
  4608. };
  4609. };
  4610. const br = Math.floor;
  4611. const Sr = Math.abs;
  4612. const Ti = Math.cos;
  4613. const Mi = Math.sin;
  4614. const Mh = Math.sqrt;
  4615. function Eh(e, t, i, n, s, r) {
  4616. this.objects = t;
  4617. this.grids = {};
  4618. this.updateObjects = [];
  4619. let o;
  4620. let l;
  4621. const c = n.mapScale / n.colGrid;
  4622. this.setObjectGrids = function (u) {
  4623. const p = Math.min(n.mapScale, Math.max(0, u.x));
  4624. const w = Math.min(n.mapScale, Math.max(0, u.y));
  4625. for (let x = 0; x < n.colGrid; ++x) {
  4626. o = x * c;
  4627. for (let b = 0; b < n.colGrid; ++b) {
  4628. l = b * c;
  4629. if (p + u.scale >= o && p - u.scale <= o + c && w + u.scale >= l && w - u.scale <= l + c) {
  4630. if (!this.grids[x + "_" + b]) {
  4631. this.grids[x + "_" + b] = [];
  4632. }
  4633. this.grids[x + "_" + b].push(u);
  4634. u.gridLocations.push(x + "_" + b);
  4635. }
  4636. }
  4637. }
  4638. };
  4639. this.removeObjGrid = function (u) {
  4640. let p;
  4641. for (let w = 0; w < u.gridLocations.length; ++w) {
  4642. p = this.grids[u.gridLocations[w]].indexOf(u);
  4643. if (p >= 0) {
  4644. this.grids[u.gridLocations[w]].splice(p, 1);
  4645. }
  4646. }
  4647. };
  4648. this.disableObj = function (u) {
  4649. u.active = false;
  4650. if (r) {
  4651. if (u.owner && u.pps) {
  4652. u.owner.pps -= u.pps;
  4653. }
  4654. this.removeObjGrid(u);
  4655. const p = this.updateObjects.indexOf(u);
  4656. if (p >= 0) {
  4657. this.updateObjects.splice(p, 1);
  4658. }
  4659. }
  4660. };
  4661. this.hitObj = function (u, p) {
  4662. for (let w = 0; w < s.length; ++w) {
  4663. if (s[w].active) {
  4664. if (u.sentTo[s[w].id]) {
  4665. if (u.active) {
  4666. if (s[w].canSee(u)) {
  4667. r.send(s[w].id, "L", i.fixTo(p, 1), u.sid);
  4668. }
  4669. } else {
  4670. r.send(s[w].id, "Q", u.sid);
  4671. }
  4672. }
  4673. if (!u.active && u.owner == s[w]) {
  4674. s[w].changeItemCount(u.group.id, -1);
  4675. }
  4676. }
  4677. }
  4678. };
  4679. const a = [];
  4680. let f;
  4681. this.getGridArrays = function (u, p, w) {
  4682. o = br(u / c);
  4683. l = br(p / c);
  4684. a.length = 0;
  4685. try {
  4686. if (this.grids[o + "_" + l]) {
  4687. a.push(this.grids[o + "_" + l]);
  4688. }
  4689. if (u + w >= (o + 1) * c) {
  4690. f = this.grids[o + 1 + "_" + l];
  4691. if (f) {
  4692. a.push(f);
  4693. }
  4694. if (l && p - w <= l * c) {
  4695. f = this.grids[o + 1 + "_" + (l - 1)];
  4696. if (f) {
  4697. a.push(f);
  4698. }
  4699. } else if (p + w >= (l + 1) * c) {
  4700. f = this.grids[o + 1 + "_" + (l + 1)];
  4701. if (f) {
  4702. a.push(f);
  4703. }
  4704. }
  4705. }
  4706. if (o && u - w <= o * c) {
  4707. f = this.grids[o - 1 + "_" + l];
  4708. if (f) {
  4709. a.push(f);
  4710. }
  4711. if (l && p - w <= l * c) {
  4712. f = this.grids[o - 1 + "_" + (l - 1)];
  4713. if (f) {
  4714. a.push(f);
  4715. }
  4716. } else if (p + w >= (l + 1) * c) {
  4717. f = this.grids[o - 1 + "_" + (l + 1)];
  4718. if (f) {
  4719. a.push(f);
  4720. }
  4721. }
  4722. }
  4723. if (p + w >= (l + 1) * c) {
  4724. f = this.grids[o + "_" + (l + 1)];
  4725. if (f) {
  4726. a.push(f);
  4727. }
  4728. }
  4729. if (l && p - w <= l * c) {
  4730. f = this.grids[o + "_" + (l - 1)];
  4731. if (f) {
  4732. a.push(f);
  4733. }
  4734. }
  4735. } catch {}
  4736. return a;
  4737. };
  4738. let d;
  4739. this.add = function (u, p, w, x, b, $, v, S, R) {
  4740. d = null;
  4741. for (var G = 0; G < t.length; ++G) {
  4742. if (t[G].sid == u) {
  4743. d = t[G];
  4744. break;
  4745. }
  4746. }
  4747. if (!d) {
  4748. for (var G = 0; G < t.length; ++G) {
  4749. if (!t[G].active) {
  4750. d = t[G];
  4751. break;
  4752. }
  4753. }
  4754. }
  4755. if (!d) {
  4756. d = new e(u);
  4757. t.push(d);
  4758. }
  4759. if (S) {
  4760. d.sid = u;
  4761. }
  4762. d.init(p, w, x, b, $, v, R);
  4763. if (r) {
  4764. this.setObjectGrids(d);
  4765. if (d.doUpdate) {
  4766. this.updateObjects.push(d);
  4767. }
  4768. }
  4769. };
  4770. this.disableBySid = function (u) {
  4771. for (let p = 0; p < t.length; ++p) {
  4772. if (t[p].sid == u) {
  4773. this.disableObj(t[p]);
  4774. break;
  4775. }
  4776. }
  4777. };
  4778. this.removeAllItems = function (u, p) {
  4779. for (let w = 0; w < t.length; ++w) {
  4780. if (t[w].active && t[w].owner && t[w].owner.sid == u) {
  4781. this.disableObj(t[w]);
  4782. }
  4783. }
  4784. if (p) {
  4785. p.broadcast("R", u);
  4786. }
  4787. };
  4788. this.fetchSpawnObj = function (u) {
  4789. let p = null;
  4790. for (let w = 0; w < t.length; ++w) {
  4791. d = t[w];
  4792. if (d.active && d.owner && d.owner.sid == u && d.spawnPoint) {
  4793. p = [d.x, d.y];
  4794. this.disableObj(d);
  4795. r.broadcast("Q", d.sid);
  4796. if (d.owner) {
  4797. d.owner.changeItemCount(d.group.id, -1);
  4798. }
  4799. break;
  4800. }
  4801. }
  4802. return p;
  4803. };
  4804. this.checkItemLocation = function (u, p, w, x, b, $, v) {
  4805. for (let S = 0; S < t.length; ++S) {
  4806. const R = t[S].blocker ? t[S].blocker : t[S].getScale(x, t[S].isItem);
  4807. if (t[S].active && i.getDistance(u, p, t[S].x, t[S].y) < w + R) {
  4808. return false;
  4809. }
  4810. }
  4811. return !(!$ && b != 18 && p >= n.mapScale / 2 - n.riverWidth / 2 && p <= n.mapScale / 2 + n.riverWidth / 2);
  4812. };
  4813. this.addProjectile = function (u, p, w, x, b) {
  4814. const $ = items.projectiles[b];
  4815. let v;
  4816. for (let S = 0; S < projectiles.length; ++S) {
  4817. if (!projectiles[S].active) {
  4818. v = projectiles[S];
  4819. break;
  4820. }
  4821. }
  4822. if (!v) {
  4823. v = new Projectile(s, i);
  4824. projectiles.push(v);
  4825. }
  4826. v.init(b, u, p, w, $.speed, x, $.scale);
  4827. };
  4828. this.checkCollision = function (u, p, w) {
  4829. w = w || 1;
  4830. const x = u.x - p.x;
  4831. const b = u.y - p.y;
  4832. let $ = u.scale + p.scale;
  4833. if (Sr(x) <= $ || Sr(b) <= $) {
  4834. $ = u.scale + (p.getScale ? p.getScale() : p.scale);
  4835. let v = Mh(x * x + b * b) - $;
  4836. if (v <= 0) {
  4837. if (p.ignoreCollision) {
  4838. if (p.trap && !u.noTrap && p.owner != u && !(p.owner && p.owner.team && p.owner.team == u.team)) {
  4839. u.lockMove = true;
  4840. p.hideFromEnemy = false;
  4841. } else if (p.boostSpeed) {
  4842. u.xVel += w * p.boostSpeed * (p.weightM || 1) * Ti(p.dir);
  4843. u.yVel += w * p.boostSpeed * (p.weightM || 1) * Mi(p.dir);
  4844. } else if (p.healCol) {
  4845. u.healCol = p.healCol;
  4846. } else if (p.teleport) {
  4847. u.x = i.randInt(0, n.mapScale);
  4848. u.y = i.randInt(0, n.mapScale);
  4849. }
  4850. } else {
  4851. const S = i.getDirection(u.x, u.y, p.x, p.y);
  4852. i.getDistance(u.x, u.y, p.x, p.y);
  4853. if (p.isPlayer) {
  4854. v = v * -1 / 2;
  4855. u.x += v * Ti(S);
  4856. u.y += v * Mi(S);
  4857. p.x -= v * Ti(S);
  4858. p.y -= v * Mi(S);
  4859. } else {
  4860. u.x = p.x + $ * Ti(S);
  4861. u.y = p.y + $ * Mi(S);
  4862. u.xVel *= 0.75;
  4863. u.yVel *= 0.75;
  4864. }
  4865. if (p.dmg && p.owner != u && !(p.owner && p.owner.team && p.owner.team == u.team)) {
  4866. u.changeHealth(-p.dmg, p.owner, p);
  4867. const R = (p.weightM || 1) * 1.5;
  4868. u.xVel += R * Ti(S);
  4869. u.yVel += R * Mi(S);
  4870. if (p.pDmg && !(u.skin && u.skin.poisonRes)) {
  4871. u.dmgOverTime.dmg = p.pDmg;
  4872. u.dmgOverTime.time = 5;
  4873. u.dmgOverTime.doer = p.owner;
  4874. }
  4875. if (u.colDmg && p.health) {
  4876. if (p.changeHealth(-u.colDmg)) {
  4877. this.disableObj(p);
  4878. }
  4879. this.hitObj(p, i.getDirection(u.x, u.y, p.x, p.y));
  4880. }
  4881. }
  4882. }
  4883. if (p.zIndex > u.zIndex) {
  4884. u.zIndex = p.zIndex;
  4885. }
  4886. return true;
  4887. }
  4888. }
  4889. return false;
  4890. };
  4891. }
  4892. function Ch(e, t, i, n, s, r, o, l, c) {
  4893. this.addProjectile = function (a, f, d, u, p, w, x, b, $) {
  4894. const v = r.projectiles[w];
  4895. let S;
  4896. for (let R = 0; R < t.length; ++R) {
  4897. if (!t[R].active) {
  4898. S = t[R];
  4899. break;
  4900. }
  4901. }
  4902. if (!S) {
  4903. S = new e(i, n, s, r, o, l, c);
  4904. S.sid = t.length;
  4905. t.push(S);
  4906. }
  4907. S.init(w, a, f, d, p, v.dmg, u, v.scale, x);
  4908. S.ignoreObj = b;
  4909. S.layer = $ || v.layer;
  4910. S.src = v.src;
  4911. return S;
  4912. };
  4913. }
  4914. function Ph(e, t, i, n, s, r, o, l, c) {
  4915. this.aiTypes = [{
  4916. id: 0,
  4917. src: "cow_1",
  4918. killScore: 150,
  4919. health: 500,
  4920. weightM: 0.8,
  4921. speed: 0.00095,
  4922. turnSpeed: 0.001,
  4923. scale: 72,
  4924. drop: ["food", 50]
  4925. }, {
  4926. id: 1,
  4927. src: "pig_1",
  4928. killScore: 200,
  4929. health: 800,
  4930. weightM: 0.6,
  4931. speed: 0.00085,
  4932. turnSpeed: 0.001,
  4933. scale: 72,
  4934. drop: ["food", 80]
  4935. }, {
  4936. id: 2,
  4937. name: "Bull",
  4938. src: "bull_2",
  4939. hostile: true,
  4940. dmg: 20,
  4941. killScore: 1000,
  4942. health: 1800,
  4943. weightM: 0.5,
  4944. speed: 0.00094,
  4945. turnSpeed: 0.00074,
  4946. scale: 78,
  4947. viewRange: 800,
  4948. chargePlayer: true,
  4949. drop: ["food", 100]
  4950. }, {
  4951. id: 3,
  4952. name: "Bully",
  4953. src: "bull_1",
  4954. hostile: true,
  4955. dmg: 20,
  4956. killScore: 2000,
  4957. health: 2800,
  4958. weightM: 0.45,
  4959. speed: 0.001,
  4960. turnSpeed: 0.0008,
  4961. scale: 90,
  4962. viewRange: 900,
  4963. chargePlayer: true,
  4964. drop: ["food", 400]
  4965. }, {
  4966. id: 4,
  4967. name: "Wolf",
  4968. src: "wolf_1",
  4969. hostile: true,
  4970. dmg: 8,
  4971. killScore: 500,
  4972. health: 300,
  4973. weightM: 0.45,
  4974. speed: 0.001,
  4975. turnSpeed: 0.002,
  4976. scale: 84,
  4977. viewRange: 800,
  4978. chargePlayer: true,
  4979. drop: ["food", 200]
  4980. }, {
  4981. id: 5,
  4982. name: "Quack",
  4983. src: "chicken_1",
  4984. dmg: 8,
  4985. killScore: 2000,
  4986. noTrap: true,
  4987. health: 300,
  4988. weightM: 0.2,
  4989. speed: 0.0018,
  4990. turnSpeed: 0.006,
  4991. scale: 70,
  4992. drop: ["food", 100]
  4993. }, {
  4994. id: 6,
  4995. name: "MOOSTAFA",
  4996. nameScale: 50,
  4997. src: "enemy",
  4998. hostile: true,
  4999. dontRun: true,
  5000. fixedSpawn: true,
  5001. spawnDelay: 60000,
  5002. noTrap: true,
  5003. colDmg: 100,
  5004. dmg: 40,
  5005. killScore: 8000,
  5006. health: 18000,
  5007. weightM: 0.4,
  5008. speed: 0.0007,
  5009. turnSpeed: 0.01,
  5010. scale: 80,
  5011. spriteMlt: 1.8,
  5012. leapForce: 0.9,
  5013. viewRange: 1000,
  5014. hitRange: 210,
  5015. hitDelay: 1000,
  5016. chargePlayer: true,
  5017. drop: ["food", 100]
  5018. }, {
  5019. id: 7,
  5020. name: "Treasure",
  5021. hostile: true,
  5022. nameScale: 35,
  5023. src: "crate_1",
  5024. fixedSpawn: true,
  5025. spawnDelay: 120000,
  5026. colDmg: 200,
  5027. killScore: 5000,
  5028. health: 20000,
  5029. weightM: 0.1,
  5030. speed: 0,
  5031. turnSpeed: 0,
  5032. scale: 70,
  5033. spriteMlt: 1
  5034. }, {
  5035. id: 8,
  5036. name: "MOOFIE",
  5037. src: "wolf_2",
  5038. hostile: true,
  5039. fixedSpawn: true,
  5040. dontRun: true,
  5041. hitScare: 4,
  5042. spawnDelay: 30000,
  5043. noTrap: true,
  5044. nameScale: 35,
  5045. dmg: 10,
  5046. colDmg: 100,
  5047. killScore: 3000,
  5048. health: 7000,
  5049. weightM: 0.45,
  5050. speed: 0.0015,
  5051. turnSpeed: 0.002,
  5052. scale: 90,
  5053. viewRange: 800,
  5054. chargePlayer: true,
  5055. drop: ["food", 1000]
  5056. }, {
  5057. id: 9,
  5058. name: "💀MOOFIE",
  5059. src: "wolf_2",
  5060. hostile: true,
  5061. fixedSpawn: true,
  5062. dontRun: true,
  5063. hitScare: 50,
  5064. spawnDelay: 60000,
  5065. noTrap: true,
  5066. nameScale: 35,
  5067. dmg: 12,
  5068. colDmg: 100,
  5069. killScore: 3000,
  5070. health: 9000,
  5071. weightM: 0.45,
  5072. speed: 0.0015,
  5073. turnSpeed: 0.0025,
  5074. scale: 94,
  5075. viewRange: 1440,
  5076. chargePlayer: true,
  5077. drop: ["food", 3000],
  5078. minSpawnRange: 0.85,
  5079. maxSpawnRange: 0.9
  5080. }, {
  5081. id: 10,
  5082. name: "💀Wolf",
  5083. src: "wolf_1",
  5084. hostile: true,
  5085. fixedSpawn: true,
  5086. dontRun: true,
  5087. hitScare: 50,
  5088. spawnDelay: 30000,
  5089. dmg: 10,
  5090. killScore: 700,
  5091. health: 500,
  5092. weightM: 0.45,
  5093. speed: 0.00115,
  5094. turnSpeed: 0.0025,
  5095. scale: 88,
  5096. viewRange: 1440,
  5097. chargePlayer: true,
  5098. drop: ["food", 400],
  5099. minSpawnRange: 0.85,
  5100. maxSpawnRange: 0.9
  5101. }, {
  5102. id: 11,
  5103. name: "💀Bully",
  5104. src: "bull_1",
  5105. hostile: true,
  5106. fixedSpawn: true,
  5107. dontRun: true,
  5108. hitScare: 50,
  5109. dmg: 20,
  5110. killScore: 5000,
  5111. health: 5000,
  5112. spawnDelay: 100000,
  5113. weightM: 0.45,
  5114. speed: 0.00115,
  5115. turnSpeed: 0.0025,
  5116. scale: 94,
  5117. viewRange: 1440,
  5118. chargePlayer: true,
  5119. drop: ["food", 800],
  5120. minSpawnRange: 0.85,
  5121. maxSpawnRange: 0.9
  5122. }];
  5123. this.spawn = function (a, f, d, u) {
  5124. if (!this.aiTypes[u]) {
  5125. console.error("missing ai type", u);
  5126. return this.spawn(a, f, d, 0);
  5127. }
  5128. let p;
  5129. for (let w = 0; w < e.length; ++w) {
  5130. if (!e[w].active) {
  5131. p = e[w];
  5132. break;
  5133. }
  5134. }
  5135. if (!p) {
  5136. p = new t(e.length, s, i, n, o, r, l, c);
  5137. e.push(p);
  5138. }
  5139. p.init(a, f, d, u, this.aiTypes[u]);
  5140. return p;
  5141. };
  5142. }
  5143. const Nt = Math.PI * 2;
  5144. const Gn = 0;
  5145. function $h(e, t, i, n, s, r, o, l) {
  5146. this.sid = e;
  5147. this.isAI = true;
  5148. this.nameIndex = s.randInt(0, r.cowNames.length - 1);
  5149. this.init = function (d, u, p, w, x) {
  5150. this.x = d;
  5151. this.y = u;
  5152. this.startX = x.fixedSpawn ? d : null;
  5153. this.startY = x.fixedSpawn ? u : null;
  5154. this.xVel = 0;
  5155. this.yVel = 0;
  5156. this.zIndex = 0;
  5157. this.dir = p;
  5158. this.dirPlus = 0;
  5159. this.index = w;
  5160. this.src = x.src;
  5161. if (x.name) {
  5162. this.name = x.name;
  5163. }
  5164. if ((this.name || "").startsWith("💀")) {
  5165. this.isVolcanoAi = true;
  5166. }
  5167. this.weightM = x.weightM;
  5168. this.speed = x.speed;
  5169. this.killScore = x.killScore;
  5170. this.turnSpeed = x.turnSpeed;
  5171. this.scale = x.scale;
  5172. this.maxHealth = x.health;
  5173. this.leapForce = x.leapForce;
  5174. this.health = this.maxHealth;
  5175. this.chargePlayer = x.chargePlayer;
  5176. this.viewRange = x.viewRange;
  5177. this.drop = x.drop;
  5178. this.dmg = x.dmg;
  5179. this.hostile = x.hostile;
  5180. this.dontRun = x.dontRun;
  5181. this.hitRange = x.hitRange;
  5182. this.hitDelay = x.hitDelay;
  5183. this.hitScare = x.hitScare;
  5184. this.spriteMlt = x.spriteMlt;
  5185. this.nameScale = x.nameScale;
  5186. this.colDmg = x.colDmg;
  5187. this.noTrap = x.noTrap;
  5188. this.spawnDelay = x.spawnDelay;
  5189. this.minSpawnRange = x.minSpawnRange;
  5190. this.maxSpawnRange = x.maxSpawnRange;
  5191. this.hitWait = 0;
  5192. this.waitCount = 1000;
  5193. this.moveCount = 0;
  5194. this.targetDir = 0;
  5195. this.active = true;
  5196. this.alive = true;
  5197. this.runFrom = null;
  5198. this.chargeTarget = null;
  5199. this.dmgOverTime = {};
  5200. };
  5201. this.getVolcanoAggression = function () {
  5202. const d = s.getDistance(this.x, this.y, r.volcanoLocationX, r.volcanoLocationY);
  5203. const u = d > r.volcanoAggressionRadius ? 0 : r.volcanoAggressionRadius - d;
  5204. return 1 + r.volcanoAggressionPercentage * (1 - u / r.volcanoAggressionRadius);
  5205. };
  5206. let c = 0;
  5207. this.update = function (d) {
  5208. if (this.active) {
  5209. if (this.spawnCounter) {
  5210. this.spawnCounter -= d * 1 * this.getVolcanoAggression();
  5211. if (this.spawnCounter <= 0) {
  5212. this.spawnCounter = 0;
  5213. if (this.minSpawnRange || this.maxSpawnRange) {
  5214. const V = r.mapScale * this.minSpawnRange;
  5215. const F = r.mapScale * this.maxSpawnRange;
  5216. this.x = s.randInt(V, F);
  5217. this.y = s.randInt(V, F);
  5218. } else {
  5219. this.x = this.startX || s.randInt(0, r.mapScale);
  5220. this.y = this.startY || s.randInt(0, r.mapScale);
  5221. }
  5222. }
  5223. return;
  5224. }
  5225. c -= d;
  5226. if (c <= 0) {
  5227. if (this.dmgOverTime.dmg) {
  5228. this.changeHealth(-this.dmgOverTime.dmg, this.dmgOverTime.doer);
  5229. this.dmgOverTime.time -= 1;
  5230. if (this.dmgOverTime.time <= 0) {
  5231. this.dmgOverTime.dmg = 0;
  5232. }
  5233. }
  5234. c = 1000;
  5235. }
  5236. let v = false;
  5237. let S = 1;
  5238. if (!this.zIndex && !this.lockMove && this.y >= r.mapScale / 2 - r.riverWidth / 2 && this.y <= r.mapScale / 2 + r.riverWidth / 2) {
  5239. S = 0.33;
  5240. this.xVel += r.waterCurrent * d;
  5241. }
  5242. if (this.lockMove) {
  5243. this.xVel = 0;
  5244. this.yVel = 0;
  5245. } else if (this.waitCount > 0) {
  5246. this.waitCount -= d;
  5247. if (this.waitCount <= 0) {
  5248. if (this.chargePlayer) {
  5249. let V;
  5250. let F;
  5251. let _;
  5252. for (var u = 0; u < i.length; ++u) {
  5253. if (i[u].alive && !(i[u].skin && i[u].skin.bullRepel)) {
  5254. _ = s.getDistance(this.x, this.y, i[u].x, i[u].y);
  5255. if (_ <= this.viewRange && (!V || _ < F)) {
  5256. F = _;
  5257. V = i[u];
  5258. }
  5259. }
  5260. }
  5261. if (V) {
  5262. this.chargeTarget = V;
  5263. this.moveCount = s.randInt(8000, 12000);
  5264. } else {
  5265. this.moveCount = s.randInt(1000, 2000);
  5266. this.targetDir = s.randFloat(-Math.PI, Math.PI);
  5267. }
  5268. } else {
  5269. this.moveCount = s.randInt(4000, 10000);
  5270. this.targetDir = s.randFloat(-Math.PI, Math.PI);
  5271. }
  5272. }
  5273. } else if (this.moveCount > 0) {
  5274. var p = this.speed * S * (1 + r.MAX_SPEED * Gn) * this.getVolcanoAggression();
  5275. if (this.runFrom && this.runFrom.active && !(this.runFrom.isPlayer && !this.runFrom.alive)) {
  5276. this.targetDir = s.getDirection(this.x, this.y, this.runFrom.x, this.runFrom.y);
  5277. p *= 1.42;
  5278. } else if (this.chargeTarget && this.chargeTarget.alive) {
  5279. this.targetDir = s.getDirection(this.chargeTarget.x, this.chargeTarget.y, this.x, this.y);
  5280. p *= 1.75;
  5281. v = true;
  5282. }
  5283. if (this.hitWait) {
  5284. p *= 0.3;
  5285. }
  5286. if (this.dir != this.targetDir) {
  5287. this.dir %= Nt;
  5288. const V = (this.dir - this.targetDir + Nt) % Nt;
  5289. const F = Math.min(Math.abs(V - Nt), V, this.turnSpeed * d);
  5290. const _ = V - Math.PI >= 0 ? 1 : -1;
  5291. this.dir += _ * F + Nt;
  5292. }
  5293. this.dir %= Nt;
  5294. this.xVel += p * d * Math.cos(this.dir);
  5295. this.yVel += p * d * Math.sin(this.dir);
  5296. this.moveCount -= d;
  5297. if (this.moveCount <= 0) {
  5298. this.runFrom = null;
  5299. this.chargeTarget = null;
  5300. this.waitCount = this.hostile ? 1500 : s.randInt(1500, 6000);
  5301. }
  5302. }
  5303. this.zIndex = 0;
  5304. this.lockMove = false;
  5305. var w;
  5306. const R = s.getDistance(0, 0, this.xVel * d, this.yVel * d);
  5307. const G = Math.min(4, Math.max(1, Math.round(R / 40)));
  5308. const X = 1 / G;
  5309. for (var u = 0; u < G; ++u) {
  5310. if (this.xVel) {
  5311. this.x += this.xVel * d * X;
  5312. }
  5313. if (this.yVel) {
  5314. this.y += this.yVel * d * X;
  5315. }
  5316. w = t.getGridArrays(this.x, this.y, this.scale);
  5317. for (var x = 0; x < w.length; ++x) {
  5318. for (let F = 0; F < w[x].length; ++F) {
  5319. if (w[x][F].active) {
  5320. t.checkCollision(this, w[x][F], X);
  5321. }
  5322. }
  5323. }
  5324. }
  5325. let W = false;
  5326. if (this.hitWait > 0 && (this.hitWait -= d, this.hitWait <= 0)) {
  5327. W = true;
  5328. this.hitWait = 0;
  5329. if (this.leapForce && !s.randInt(0, 2)) {
  5330. this.xVel += this.leapForce * Math.cos(this.dir);
  5331. this.yVel += this.leapForce * Math.sin(this.dir);
  5332. }
  5333. var w = t.getGridArrays(this.x, this.y, this.hitRange);
  5334. var b;
  5335. var $;
  5336. for (let F = 0; F < w.length; ++F) {
  5337. for (var x = 0; x < w[F].length; ++x) {
  5338. b = w[F][x];
  5339. if (b.health) {
  5340. $ = s.getDistance(this.x, this.y, b.x, b.y);
  5341. if ($ < b.scale + this.hitRange) {
  5342. if (b.changeHealth(-this.dmg * 5)) {
  5343. t.disableObj(b);
  5344. }
  5345. t.hitObj(b, s.getDirection(this.x, this.y, b.x, b.y));
  5346. }
  5347. }
  5348. }
  5349. }
  5350. for (var x = 0; x < i.length; ++x) {
  5351. if (i[x].canSee(this)) {
  5352. l.send(i[x].id, "J", this.sid);
  5353. }
  5354. }
  5355. }
  5356. if (v || W) {
  5357. var b;
  5358. var $;
  5359. let _;
  5360. for (var u = 0; u < i.length; ++u) {
  5361. b = i[u];
  5362. if (b && b.alive) {
  5363. $ = s.getDistance(this.x, this.y, b.x, b.y);
  5364. if (this.hitRange) {
  5365. if (!this.hitWait && $ <= this.hitRange + b.scale) {
  5366. if (W) {
  5367. _ = s.getDirection(b.x, b.y, this.x, this.y);
  5368. b.changeHealth(-this.dmg * (1 + r.MAX_ATTACK * Gn) * this.getVolcanoAggression());
  5369. b.xVel += Math.cos(_) * 0.6;
  5370. b.yVel += Math.sin(_) * 0.6;
  5371. this.runFrom = null;
  5372. this.chargeTarget = null;
  5373. this.waitCount = 3000;
  5374. this.hitWait = s.randInt(0, 2) ? 0 : 600;
  5375. } else {
  5376. this.hitWait = this.hitDelay;
  5377. }
  5378. }
  5379. } else if ($ <= this.scale + b.scale) {
  5380. _ = s.getDirection(b.x, b.y, this.x, this.y);
  5381. b.changeHealth(-this.dmg * (1 + r.MAX_ATTACK * Gn) * this.getVolcanoAggression());
  5382. b.xVel += Math.cos(_) * 0.55;
  5383. b.yVel += Math.sin(_) * 0.55;
  5384. }
  5385. }
  5386. }
  5387. }
  5388. if (this.xVel) {
  5389. this.xVel *= Math.pow(r.playerDecel, d);
  5390. }
  5391. if (this.yVel) {
  5392. this.yVel *= Math.pow(r.playerDecel, d);
  5393. }
  5394. const M = this.scale;
  5395. if (this.x - M < 0) {
  5396. this.x = M;
  5397. this.xVel = 0;
  5398. } else if (this.x + M > r.mapScale) {
  5399. this.x = r.mapScale - M;
  5400. this.xVel = 0;
  5401. }
  5402. if (this.y - M < 0) {
  5403. this.y = M;
  5404. this.yVel = 0;
  5405. } else if (this.y + M > r.mapScale) {
  5406. this.y = r.mapScale - M;
  5407. this.yVel = 0;
  5408. }
  5409. if (this.isVolcanoAi) {
  5410. if (this.chargeTarget && (s.getDistance(this.chargeTarget.x, this.chargeTarget.y, r.volcanoLocationX, r.volcanoLocationY) || 0) > r.volcanoAggressionRadius) {
  5411. this.chargeTarget = null;
  5412. }
  5413. if (this.xVel) {
  5414. if (this.x < r.volcanoLocationX - r.volcanoAggressionRadius) {
  5415. this.x = r.volcanoLocationX - r.volcanoAggressionRadius;
  5416. this.xVel = 0;
  5417. } else if (this.x > r.volcanoLocationX + r.volcanoAggressionRadius) {
  5418. this.x = r.volcanoLocationX + r.volcanoAggressionRadius;
  5419. this.xVel = 0;
  5420. }
  5421. }
  5422. if (this.yVel) {
  5423. if (this.y < r.volcanoLocationY - r.volcanoAggressionRadius) {
  5424. this.y = r.volcanoLocationY - r.volcanoAggressionRadius;
  5425. this.yVel = 0;
  5426. } else if (this.y > r.volcanoLocationY + r.volcanoAggressionRadius) {
  5427. this.y = r.volcanoLocationY + r.volcanoAggressionRadius;
  5428. this.yVel = 0;
  5429. }
  5430. }
  5431. }
  5432. }
  5433. };
  5434. this.canSee = function (d) {
  5435. if (!d || d.skin && d.skin.invisTimer && d.noMovTimer >= d.skin.invisTimer) {
  5436. return false;
  5437. }
  5438. const u = Math.abs(d.x - this.x) - d.scale;
  5439. const p = Math.abs(d.y - this.y) - d.scale;
  5440. return u <= r.maxScreenWidth / 2 * 1.3 && p <= r.maxScreenHeight / 2 * 1.3;
  5441. };
  5442. let a = 0;
  5443. let f = 0;
  5444. this.animate = function (d) {
  5445. if (this.animTime > 0) {
  5446. this.animTime -= d;
  5447. if (this.animTime <= 0) {
  5448. this.animTime = 0;
  5449. this.dirPlus = 0;
  5450. a = 0;
  5451. f = 0;
  5452. } else if (f == 0) {
  5453. a += d / (this.animSpeed * r.hitReturnRatio);
  5454. this.dirPlus = s.lerp(0, this.targetAngle, Math.min(1, a));
  5455. if (a >= 1) {
  5456. a = 1;
  5457. f = 1;
  5458. }
  5459. } else {
  5460. a -= d / (this.animSpeed * (1 - r.hitReturnRatio));
  5461. this.dirPlus = s.lerp(0, this.targetAngle, Math.max(0, a));
  5462. }
  5463. }
  5464. };
  5465. this.startAnim = function () {
  5466. this.animTime = this.animSpeed = 600;
  5467. this.targetAngle = Math.PI * 0.8;
  5468. a = 0;
  5469. f = 0;
  5470. };
  5471. this.changeHealth = function (d, u, p) {
  5472. if (this.active && (this.health += d, p && (this.hitScare && !s.randInt(0, this.hitScare) ? (this.runFrom = p, this.waitCount = 0, this.moveCount = 2000) : this.hostile && this.chargePlayer && p.isPlayer ? (this.chargeTarget = p, this.waitCount = 0, this.moveCount = 8000) : this.dontRun || (this.runFrom = p, this.waitCount = 0, this.moveCount = 2000)), d < 0 && this.hitRange && s.randInt(0, 1) && (this.hitWait = 500), u && u.canSee(this) && d < 0 && l.send(u.id, "8", Math.round(this.x), Math.round(this.y), Math.round(-d), 1), this.health <= 0)) {
  5473. if (this.spawnDelay) {
  5474. this.spawnCounter = this.spawnDelay;
  5475. this.x = -1000000;
  5476. this.y = -1000000;
  5477. } else if (this.minSpawnRange || this.maxSpawnRange) {
  5478. const w = r.mapScale * this.minSpawnRange;
  5479. const x = r.mapScale * this.maxSpawnRange;
  5480. this.x = s.randInt(w, x);
  5481. this.y = s.randInt(w, x);
  5482. } else {
  5483. this.x = this.startX || s.randInt(0, r.mapScale);
  5484. this.y = this.startY || s.randInt(0, r.mapScale);
  5485. }
  5486. this.health = this.maxHealth;
  5487. this.runFrom = null;
  5488. if (u && (o(u, this.killScore), this.drop)) {
  5489. for (let w = 0; w < this.drop.length;) {
  5490. u.addResource(r.resourceTypes.indexOf(this.drop[w]), this.drop[w + 1]);
  5491. w += 2;
  5492. }
  5493. }
  5494. }
  5495. };
  5496. }
  5497. function Rh(e) {
  5498. this.sid = e;
  5499. this.init = function (t, i, n, s, r, o, l) {
  5500. o = o || {};
  5501. this.sentTo = {};
  5502. this.gridLocations = [];
  5503. this.active = true;
  5504. this.doUpdate = o.doUpdate;
  5505. this.x = t;
  5506. this.y = i;
  5507. this.dir = n;
  5508. this.xWiggle = 0;
  5509. this.yWiggle = 0;
  5510. this.scale = s;
  5511. this.type = r;
  5512. this.id = o.id;
  5513. this.owner = l;
  5514. this.name = o.name;
  5515. this.isItem = this.id != null;
  5516. this.group = o.group;
  5517. this.health = o.health;
  5518. this.layer = 2;
  5519. if (this.group != null) {
  5520. this.layer = this.group.layer;
  5521. } else if (this.type == 0) {
  5522. this.layer = 3;
  5523. } else if (this.type == 2) {
  5524. this.layer = 0;
  5525. } else if (this.type == 4) {
  5526. this.layer = -1;
  5527. }
  5528. this.colDiv = o.colDiv || 1;
  5529. this.blocker = o.blocker;
  5530. this.ignoreCollision = o.ignoreCollision;
  5531. this.dontGather = o.dontGather;
  5532. this.hideFromEnemy = o.hideFromEnemy;
  5533. this.friction = o.friction;
  5534. this.projDmg = o.projDmg;
  5535. this.dmg = o.dmg;
  5536. this.pDmg = o.pDmg;
  5537. this.pps = o.pps;
  5538. this.zIndex = o.zIndex || 0;
  5539. this.turnSpeed = o.turnSpeed;
  5540. this.req = o.req;
  5541. this.trap = o.trap;
  5542. this.healCol = o.healCol;
  5543. this.teleport = o.teleport;
  5544. this.boostSpeed = o.boostSpeed;
  5545. this.projectile = o.projectile;
  5546. this.shootRange = o.shootRange;
  5547. this.shootRate = o.shootRate;
  5548. this.shootCount = this.shootRate;
  5549. this.spawnPoint = o.spawnPoint;
  5550. };
  5551. this.changeHealth = function (t, i) {
  5552. this.health += t;
  5553. return this.health <= 0;
  5554. };
  5555. this.getScale = function (t, i) {
  5556. t = t || 1;
  5557. return this.scale * (this.isItem || this.type == 2 || this.type == 3 || this.type == 4 ? 1 : t * 0.6) * (i ? 1 : this.colDiv);
  5558. };
  5559. this.visibleToPlayer = function (t) {
  5560. return !this.hideFromEnemy || this.owner && (this.owner == t || this.owner.team && t.team == this.owner.team);
  5561. };
  5562. this.update = function (t) {
  5563. if (this.active) {
  5564. if (this.xWiggle) {
  5565. this.xWiggle *= Math.pow(0.99, t);
  5566. }
  5567. if (this.yWiggle) {
  5568. this.yWiggle *= Math.pow(0.99, t);
  5569. }
  5570. //if (this.turnSpeed) {
  5571. // this.dir += this.turnSpeed * t;
  5572. //}
  5573. }
  5574. };
  5575. }
  5576. const de = [{
  5577. id: 0,
  5578. name: "food",
  5579. layer: 0
  5580. }, {
  5581. id: 1,
  5582. name: "walls",
  5583. place: true,
  5584. limit: 30,
  5585. layer: 0
  5586. }, {
  5587. id: 2,
  5588. name: "spikes",
  5589. place: true,
  5590. limit: 15,
  5591. layer: 0
  5592. }, {
  5593. id: 3,
  5594. name: "mill",
  5595. place: true,
  5596. limit: 7,
  5597. sandboxLimit: 299,
  5598. layer: 1
  5599. }, {
  5600. id: 4,
  5601. name: "mine",
  5602. place: true,
  5603. limit: 1,
  5604. layer: 0
  5605. }, {
  5606. id: 5,
  5607. name: "trap",
  5608. place: true,
  5609. limit: 6,
  5610. layer: -1
  5611. }, {
  5612. id: 6,
  5613. name: "booster",
  5614. place: true,
  5615. limit: 12,
  5616. sandboxLimit: 299,
  5617. layer: -1
  5618. }, {
  5619. id: 7,
  5620. name: "turret",
  5621. place: true,
  5622. limit: 2,
  5623. layer: 1
  5624. }, {
  5625. id: 8,
  5626. name: "watchtower",
  5627. place: true,
  5628. limit: 12,
  5629. layer: 1
  5630. }, {
  5631. id: 9,
  5632. name: "buff",
  5633. place: true,
  5634. limit: 4,
  5635. layer: -1
  5636. }, {
  5637. id: 10,
  5638. name: "spawn",
  5639. place: true,
  5640. limit: 1,
  5641. layer: -1
  5642. }, {
  5643. id: 11,
  5644. name: "sapling",
  5645. place: true,
  5646. limit: 2,
  5647. layer: 0
  5648. }, {
  5649. id: 12,
  5650. name: "blocker",
  5651. place: true,
  5652. limit: 3,
  5653. layer: -1
  5654. }, {
  5655. id: 13,
  5656. name: "teleporter",
  5657. place: true,
  5658. limit: 2,
  5659. sandboxLimit: 299,
  5660. layer: -1
  5661. }];
  5662. const Ah = [{
  5663. indx: 0,
  5664. layer: 0,
  5665. src: "arrow_1",
  5666. dmg: 25,
  5667. speed: 1.6,
  5668. scale: 103,
  5669. range: 1000
  5670. }, {
  5671. indx: 1,
  5672. layer: 1,
  5673. dmg: 25,
  5674. scale: 20
  5675. }, {
  5676. indx: 0,
  5677. layer: 0,
  5678. src: "arrow_1",
  5679. dmg: 35,
  5680. speed: 2.5,
  5681. scale: 103,
  5682. range: 1200
  5683. }, {
  5684. indx: 0,
  5685. layer: 0,
  5686. src: "arrow_1",
  5687. dmg: 30,
  5688. speed: 2,
  5689. scale: 103,
  5690. range: 1200
  5691. }, {
  5692. indx: 1,
  5693. layer: 1,
  5694. dmg: 16,
  5695. scale: 20
  5696. }, {
  5697. indx: 0,
  5698. layer: 0,
  5699. src: "bullet_1",
  5700. dmg: 50,
  5701. speed: 3.6,
  5702. scale: 160,
  5703. range: 1400
  5704. }];
  5705. const Dh = [{
  5706. id: 0,
  5707. type: 0,
  5708. name: "tool hammer",
  5709. desc: "tool for gathering all resources",
  5710. src: "hammer_1",
  5711. length: 140,
  5712. width: 140,
  5713. xOff: -3,
  5714. yOff: 18,
  5715. dmg: 25,
  5716. range: 65,
  5717. gather: 1,
  5718. speed: 300
  5719. }, {
  5720. id: 1,
  5721. type: 0,
  5722. age: 2,
  5723. name: "hand axe",
  5724. desc: "gathers resources at a higher rate",
  5725. src: "axe_1",
  5726. length: 140,
  5727. width: 140,
  5728. xOff: 3,
  5729. yOff: 24,
  5730. dmg: 30,
  5731. spdMult: 1,
  5732. range: 70,
  5733. gather: 2,
  5734. speed: 400
  5735. }, {
  5736. id: 2,
  5737. type: 0,
  5738. age: 8,
  5739. pre: 1,
  5740. name: "great axe",
  5741. desc: "deal more damage and gather more resources",
  5742. src: "great_axe_1",
  5743. length: 140,
  5744. width: 140,
  5745. xOff: -8,
  5746. yOff: 25,
  5747. dmg: 35,
  5748. spdMult: 1,
  5749. range: 75,
  5750. gather: 4,
  5751. speed: 400
  5752. }, {
  5753. id: 3,
  5754. type: 0,
  5755. age: 2,
  5756. name: "short sword",
  5757. desc: "increased attack power but slower move speed",
  5758. src: "sword_1",
  5759. iPad: 1.3,
  5760. length: 130,
  5761. width: 210,
  5762. xOff: -8,
  5763. yOff: 46,
  5764. dmg: 35,
  5765. spdMult: 0.85,
  5766. range: 110,
  5767. gather: 1,
  5768. speed: 300
  5769. }, {
  5770. id: 4,
  5771. type: 0,
  5772. age: 8,
  5773. pre: 3,
  5774. name: "katana",
  5775. desc: "greater range and damage",
  5776. src: "samurai_1",
  5777. iPad: 1.3,
  5778. length: 130,
  5779. width: 210,
  5780. xOff: -8,
  5781. yOff: 59,
  5782. dmg: 40,
  5783. spdMult: 0.8,
  5784. range: 118,
  5785. gather: 1,
  5786. speed: 300
  5787. }, {
  5788. id: 5,
  5789. type: 0,
  5790. age: 2,
  5791. name: "polearm",
  5792. desc: "long range melee weapon",
  5793. src: "spear_1",
  5794. iPad: 1.3,
  5795. length: 130,
  5796. width: 210,
  5797. xOff: -8,
  5798. yOff: 53,
  5799. dmg: 45,
  5800. knock: 0.2,
  5801. spdMult: 0.82,
  5802. range: 142,
  5803. gather: 1,
  5804. speed: 700
  5805. }, {
  5806. id: 6,
  5807. type: 0,
  5808. age: 2,
  5809. name: "bat",
  5810. desc: "fast long range melee weapon",
  5811. src: "bat_1",
  5812. iPad: 1.3,
  5813. length: 110,
  5814. width: 180,
  5815. xOff: -8,
  5816. yOff: 53,
  5817. dmg: 20,
  5818. knock: 0.7,
  5819. range: 110,
  5820. gather: 1,
  5821. speed: 300
  5822. }, {
  5823. id: 7,
  5824. type: 0,
  5825. age: 2,
  5826. name: "daggers",
  5827. desc: "really fast short range weapon",
  5828. src: "dagger_1",
  5829. iPad: 0.8,
  5830. length: 110,
  5831. width: 110,
  5832. xOff: 18,
  5833. yOff: 0,
  5834. dmg: 20,
  5835. knock: 0.1,
  5836. range: 65,
  5837. gather: 1,
  5838. hitSlow: 0.1,
  5839. spdMult: 1.13,
  5840. speed: 100
  5841. }, {
  5842. id: 8,
  5843. type: 0,
  5844. age: 2,
  5845. name: "stick",
  5846. desc: "great for gathering but very weak",
  5847. src: "stick_1",
  5848. length: 140,
  5849. width: 140,
  5850. xOff: 3,
  5851. yOff: 24,
  5852. dmg: 1,
  5853. spdMult: 1,
  5854. range: 70,
  5855. gather: 7,
  5856. speed: 400
  5857. }, {
  5858. id: 9,
  5859. type: 1,
  5860. age: 6,
  5861. name: "hunting bow",
  5862. desc: "bow used for ranged combat and hunting",
  5863. src: "bow_1",
  5864. req: ["wood", 4],
  5865. length: 120,
  5866. width: 120,
  5867. xOff: -6,
  5868. yOff: 0,
  5869. projectile: 0,
  5870. spdMult: 0.75,
  5871. speed: 600
  5872. }, {
  5873. id: 10,
  5874. type: 1,
  5875. age: 6,
  5876. name: "great hammer",
  5877. desc: "hammer used for destroying structures",
  5878. src: "great_hammer_1",
  5879. length: 140,
  5880. width: 140,
  5881. xOff: -9,
  5882. yOff: 25,
  5883. dmg: 10,
  5884. spdMult: 0.88,
  5885. range: 75,
  5886. sDmg: 7.5,
  5887. gather: 1,
  5888. speed: 400
  5889. }, {
  5890. id: 11,
  5891. type: 1,
  5892. age: 6,
  5893. name: "wooden shield",
  5894. desc: "blocks projectiles and reduces melee damage",
  5895. src: "shield_1",
  5896. length: 120,
  5897. width: 120,
  5898. shield: 0.2,
  5899. xOff: 6,
  5900. yOff: 0,
  5901. spdMult: 0.7
  5902. }, {
  5903. id: 12,
  5904. type: 1,
  5905. age: 8,
  5906. pre: 9,
  5907. name: "crossbow",
  5908. desc: "deals more damage and has greater range",
  5909. src: "crossbow_1",
  5910. req: ["wood", 5],
  5911. aboveHand: true,
  5912. armS: 0.75,
  5913. length: 120,
  5914. width: 120,
  5915. xOff: -4,
  5916. yOff: 0,
  5917. projectile: 2,
  5918. spdMult: 0.7,
  5919. speed: 700
  5920. }, {
  5921. id: 13,
  5922. type: 1,
  5923. age: 9,
  5924. pre: 12,
  5925. name: "repeater crossbow",
  5926. desc: "high firerate crossbow with reduced damage",
  5927. src: "crossbow_2",
  5928. req: ["wood", 10],
  5929. aboveHand: true,
  5930. armS: 0.75,
  5931. length: 120,
  5932. width: 120,
  5933. xOff: -4,
  5934. yOff: 0,
  5935. projectile: 3,
  5936. spdMult: 0.7,
  5937. speed: 230
  5938. }, {
  5939. id: 14,
  5940. type: 1,
  5941. age: 6,
  5942. name: "mc grabby",
  5943. desc: "steals resources from enemies",
  5944. src: "grab_1",
  5945. length: 130,
  5946. width: 210,
  5947. xOff: -8,
  5948. yOff: 53,
  5949. dmg: 0,
  5950. steal: 250,
  5951. knock: 0.2,
  5952. spdMult: 1.05,
  5953. range: 125,
  5954. gather: 0,
  5955. speed: 700
  5956. }, {
  5957. id: 15,
  5958. type: 1,
  5959. age: 9,
  5960. pre: 12,
  5961. name: "musket",
  5962. desc: "slow firerate but high damage and range",
  5963. src: "musket_1",
  5964. req: ["stone", 10],
  5965. aboveHand: true,
  5966. rec: 0.35,
  5967. armS: 0.6,
  5968. hndS: 0.3,
  5969. hndD: 1.6,
  5970. length: 205,
  5971. width: 205,
  5972. xOff: 25,
  5973. yOff: 0,
  5974. projectile: 5,
  5975. hideProjectile: true,
  5976. spdMult: 0.6,
  5977. speed: 1500
  5978. }];
  5979. const Zt = [{
  5980. group: de[0],
  5981. name: "apple",
  5982. desc: "restores 20 health when consumed",
  5983. req: ["food", 10],
  5984. consume: function (e) {
  5985. return e.changeHealth(20, e);
  5986. },
  5987. scale: 22,
  5988. holdOffset: 15
  5989. }, {
  5990. age: 3,
  5991. group: de[0],
  5992. name: "cookie",
  5993. desc: "restores 40 health when consumed",
  5994. req: ["food", 15],
  5995. consume: function (e) {
  5996. return e.changeHealth(40, e);
  5997. },
  5998. scale: 27,
  5999. holdOffset: 15
  6000. }, {
  6001. age: 7,
  6002. group: de[0],
  6003. name: "cheese",
  6004. desc: "restores 30 health and another 50 over 5 seconds",
  6005. req: ["food", 25],
  6006. consume: function (e) {
  6007. if (e.changeHealth(30, e) || e.health < 100) {
  6008. e.dmgOverTime.dmg = -10;
  6009. e.dmgOverTime.doer = e;
  6010. e.dmgOverTime.time = 5;
  6011. return true;
  6012. } else {
  6013. return false;
  6014. }
  6015. },
  6016. scale: 27,
  6017. holdOffset: 15
  6018. }, {
  6019. group: de[1],
  6020. name: "wood wall",
  6021. desc: "provides protection for your village",
  6022. req: ["wood", 10],
  6023. projDmg: true,
  6024. health: 380,
  6025. scale: 50,
  6026. holdOffset: 20,
  6027. placeOffset: -5
  6028. }, {
  6029. age: 3,
  6030. group: de[1],
  6031. name: "stone wall",
  6032. desc: "provides improved protection for your village",
  6033. req: ["stone", 25],
  6034. health: 900,
  6035. scale: 50,
  6036. holdOffset: 20,
  6037. placeOffset: -5
  6038. }, {
  6039. age: 7,
  6040. pre: 1,
  6041. group: de[1],
  6042. name: "castle wall",
  6043. desc: "provides powerful protection for your village",
  6044. req: ["stone", 35],
  6045. health: 1500,
  6046. scale: 52,
  6047. holdOffset: 20,
  6048. placeOffset: -5
  6049. }, {
  6050. group: de[2],
  6051. name: "spikes",
  6052. desc: "damages enemies when they touch them",
  6053. req: ["wood", 20, "stone", 5],
  6054. health: 400,
  6055. dmg: 20,
  6056. scale: 49,
  6057. spritePadding: -23,
  6058. holdOffset: 8,
  6059. placeOffset: -5
  6060. }, {
  6061. age: 5,
  6062. group: de[2],
  6063. name: "greater spikes",
  6064. desc: "damages enemies when they touch them",
  6065. req: ["wood", 30, "stone", 10],
  6066. health: 500,
  6067. dmg: 35,
  6068. scale: 52,
  6069. spritePadding: -23,
  6070. holdOffset: 8,
  6071. placeOffset: -5
  6072. }, {
  6073. age: 9,
  6074. pre: 1,
  6075. group: de[2],
  6076. name: "poison spikes",
  6077. desc: "poisons enemies when they touch them",
  6078. req: ["wood", 35, "stone", 15],
  6079. health: 600,
  6080. dmg: 30,
  6081. pDmg: 5,
  6082. scale: 52,
  6083. spritePadding: -23,
  6084. holdOffset: 8,
  6085. placeOffset: -5
  6086. }, {
  6087. age: 9,
  6088. pre: 2,
  6089. group: de[2],
  6090. name: "spinning spikes",
  6091. desc: "damages enemies when they touch them",
  6092. req: ["wood", 30, "stone", 20],
  6093. health: 500,
  6094. dmg: 45,
  6095. turnSpeed: 0.003,
  6096. scale: 52,
  6097. spritePadding: -23,
  6098. holdOffset: 8,
  6099. placeOffset: -5
  6100. }, {
  6101. group: de[3],
  6102. name: "windmill",
  6103. desc: "generates gold over time",
  6104. req: ["wood", 50, "stone", 10],
  6105. health: 400,
  6106. pps: 1,
  6107. turnSpeed: 0.0016,
  6108. spritePadding: 25,
  6109. iconLineMult: 12,
  6110. scale: 45,
  6111. holdOffset: 20,
  6112. placeOffset: 5
  6113. }, {
  6114. age: 5,
  6115. pre: 1,
  6116. group: de[3],
  6117. name: "faster windmill",
  6118. desc: "generates more gold over time",
  6119. req: ["wood", 60, "stone", 20],
  6120. health: 500,
  6121. pps: 1.5,
  6122. turnSpeed: 0.0025,
  6123. spritePadding: 25,
  6124. iconLineMult: 12,
  6125. scale: 47,
  6126. holdOffset: 20,
  6127. placeOffset: 5
  6128. }, {
  6129. age: 8,
  6130. pre: 1,
  6131. group: de[3],
  6132. name: "power mill",
  6133. desc: "generates more gold over time",
  6134. req: ["wood", 100, "stone", 50],
  6135. health: 800,
  6136. pps: 2,
  6137. turnSpeed: 0.005,
  6138. spritePadding: 25,
  6139. iconLineMult: 12,
  6140. scale: 47,
  6141. holdOffset: 20,
  6142. placeOffset: 5
  6143. }, {
  6144. age: 5,
  6145. group: de[4],
  6146. type: 2,
  6147. name: "mine",
  6148. desc: "allows you to mine stone",
  6149. req: ["wood", 20, "stone", 100],
  6150. iconLineMult: 12,
  6151. scale: 65,
  6152. holdOffset: 20,
  6153. placeOffset: 0
  6154. }, {
  6155. age: 5,
  6156. group: de[11],
  6157. type: 0,
  6158. name: "sapling",
  6159. desc: "allows you to farm wood",
  6160. req: ["wood", 150],
  6161. iconLineMult: 12,
  6162. colDiv: 0.5,
  6163. scale: 110,
  6164. holdOffset: 50,
  6165. placeOffset: -15
  6166. }, {
  6167. age: 4,
  6168. group: de[5],
  6169. name: "pit trap",
  6170. desc: "pit that traps enemies if they walk over it",
  6171. req: ["wood", 30, "stone", 30],
  6172. trap: true,
  6173. ignoreCollision: true,
  6174. hideFromEnemy: true,
  6175. health: 500,
  6176. colDiv: 0.2,
  6177. scale: 50,
  6178. holdOffset: 20,
  6179. placeOffset: -5
  6180. }, {
  6181. age: 4,
  6182. group: de[6],
  6183. name: "boost pad",
  6184. desc: "provides boost when stepped on",
  6185. req: ["stone", 20, "wood", 5],
  6186. ignoreCollision: true,
  6187. boostSpeed: 1.5,
  6188. health: 150,
  6189. colDiv: 0.7,
  6190. scale: 45,
  6191. holdOffset: 20,
  6192. placeOffset: -5
  6193. }, {
  6194. age: 7,
  6195. group: de[7],
  6196. doUpdate: true,
  6197. name: "turret",
  6198. desc: "defensive structure that shoots at enemies",
  6199. req: ["wood", 200, "stone", 150],
  6200. health: 800,
  6201. projectile: 1,
  6202. shootRange: 700,
  6203. shootRate: 2200,
  6204. scale: 43,
  6205. holdOffset: 20,
  6206. placeOffset: -5
  6207. }, {
  6208. age: 7,
  6209. group: de[8],
  6210. name: "platform",
  6211. desc: "platform to shoot over walls and cross over water",
  6212. req: ["wood", 20],
  6213. ignoreCollision: true,
  6214. zIndex: 1,
  6215. health: 300,
  6216. scale: 43,
  6217. holdOffset: 20,
  6218. placeOffset: -5
  6219. }, {
  6220. age: 7,
  6221. group: de[9],
  6222. name: "healing pad",
  6223. desc: "standing on it will slowly heal you",
  6224. req: ["wood", 30, "food", 10],
  6225. ignoreCollision: true,
  6226. healCol: 15,
  6227. health: 400,
  6228. colDiv: 0.7,
  6229. scale: 45,
  6230. holdOffset: 20,
  6231. placeOffset: -5
  6232. }, {
  6233. age: 9,
  6234. group: de[10],
  6235. name: "spawn pad",
  6236. desc: "you will spawn here when you die but it will dissapear",
  6237. req: ["wood", 100, "stone", 100],
  6238. health: 400,
  6239. ignoreCollision: true,
  6240. spawnPoint: true,
  6241. scale: 45,
  6242. holdOffset: 20,
  6243. placeOffset: -5
  6244. }, {
  6245. age: 7,
  6246. group: de[12],
  6247. name: "blocker",
  6248. desc: "blocks building in radius",
  6249. req: ["wood", 30, "stone", 25],
  6250. ignoreCollision: true,
  6251. blocker: 300,
  6252. health: 400,
  6253. colDiv: 0.7,
  6254. scale: 45,
  6255. holdOffset: 20,
  6256. placeOffset: -5
  6257. }, {
  6258. age: 7,
  6259. group: de[13],
  6260. name: "teleporter",
  6261. desc: "teleports you to a random point on the map",
  6262. req: ["wood", 60, "stone", 60],
  6263. ignoreCollision: true,
  6264. teleport: true,
  6265. health: 200,
  6266. colDiv: 0.7,
  6267. scale: 45,
  6268. holdOffset: 20,
  6269. placeOffset: -5
  6270. }];
  6271. for (let e = 0; e < Zt.length; ++e) {
  6272. Zt[e].id = e;
  6273. if (Zt[e].pre) {
  6274. Zt[e].pre = e - Zt[e].pre;
  6275. }
  6276. }
  6277. const L = {
  6278. groups: de,
  6279. projectiles: Ah,
  6280. weapons: Dh,
  6281. list: Zt
  6282. };
  6283. const Oh = ["ahole", "anus", "ash0le", "ash0les", "asholes", "ass", "Ass Monkey", "Assface", "assh0le", "assh0lez", "asshole", "assholes", "assholz", "asswipe", "azzhole", "bassterds", "bastard", "bastards", "bastardz", "basterds", "basterdz", "Biatch", "bitch", "bitches", "Blow Job", "boffing", "butthole", "buttwipe", "c0ck", "c0cks", "c0k", "Carpet Muncher", "cawk", "cawks", "Clit", "cnts", "cntz", "cock", "cockhead", "cock-head", "cocks", "CockSucker", "cock-sucker", "crap", "cum", "cunt", "cunts", "cuntz", "dick", "dild0", "dild0s", "dildo", "dildos", "dilld0", "dilld0s", "dominatricks", "dominatrics", "dominatrix", "dyke", "enema", "f u c k", "f u c k e r", "fag", "fag1t", "faget", "fagg1t", "faggit", "faggot", "fagg0t", "fagit", "fags", "fagz", "faig", "faigs", "fart", "flipping the bird", "fuck", "fucker", "fuckin", "fucking", "fucks", "Fudge Packer", "fuk", "Fukah", "Fuken", "fuker", "Fukin", "Fukk", "Fukkah", "Fukken", "Fukker", "Fukkin", "g00k", "God-damned", "h00r", "h0ar", "h0re", "hells", "hoar", "hoor", "hoore", "jackoff", "jap", "japs", "jerk-off", "jisim", "jiss", "jizm", "jizz", "knob", "knobs", "knobz", "kunt", "kunts", "kuntz", "Lezzian", "Lipshits", "Lipshitz", "masochist", "masokist", "massterbait", "masstrbait", "masstrbate", "masterbaiter", "masterbate", "masterbates", "Motha Fucker", "Motha Fuker", "Motha Fukkah", "Motha Fukker", "Mother Fucker", "Mother Fukah", "Mother Fuker", "Mother Fukkah", "Mother Fukker", "mother-fucker", "Mutha Fucker", "Mutha Fukah", "Mutha Fuker", "Mutha Fukkah", "Mutha Fukker", "n1gr", "nastt", "nigger;", "nigur;", "niiger;", "niigr;", "orafis", "orgasim;", "orgasm", "orgasum", "oriface", "orifice", "orifiss", "packi", "packie", "packy", "paki", "pakie", "paky", "pecker", "peeenus", "peeenusss", "peenus", "peinus", "pen1s", "penas", "penis", "penis-breath", "penus", "penuus", "Phuc", "Phuck", "Phuk", "Phuker", "Phukker", "polac", "polack", "polak", "Poonani", "pr1c", "pr1ck", "pr1k", "pusse", "pussee", "pussy", "puuke", "puuker", "qweir", "recktum", "rectum", "retard", "sadist", "scank", "schlong", "screwing", "semen", "sex", "sexy", "Sh!t", "sh1t", "sh1ter", "sh1ts", "sh1tter", "sh1tz", "shit", "shits", "shitter", "Shitty", "Shity", "shitz", "Shyt", "Shyte", "Shytty", "Shyty", "skanck", "skank", "skankee", "skankey", "skanks", "Skanky", "slag", "slut", "sluts", "Slutty", "slutz", "son-of-a-bitch", "tit", "turd", "va1jina", "vag1na", "vagiina", "vagina", "vaj1na", "vajina", "vullva", "vulva", "w0p", "wh00r", "wh0re", "whore", "xrated", "xxx", "b!+ch", "bitch", "blowjob", "clit", "arschloch", "fuck", "shit", "ass", "asshole", "b!tch", "b17ch", "b1tch", "bastard", "bi+ch", "boiolas", "buceta", "c0ck", "cawk", "chink", "cipa", "clits", "cock", "cum", "cunt", "dildo", "dirsa", "ejakulate", "fatass", "fcuk", "fuk", "fux0r", "hoer", "hore", "jism", "kawk", "l3itch", "l3i+ch", "masturbate", "masterbat*", "masterbat3", "motherfucker", "s.o.b.", "mofo", "nazi", "nigga", "nigger", "nutsack", "phuck", "pimpis", "pusse", "pussy", "scrotum", "sh!t", "shemale", "shi+", "sh!+", "slut", "smut", "teets", "tits", "boobs", "b00bs", "teez", "testical", "testicle", "titt", "w00se", "jackoff", "wank", "whoar", "whore", "*damn", "*dyke", "*fuck*", "*shit*", "@$$", "amcik", "andskota", "arse*", "assrammer", "ayir", "bi7ch", "bitch*", "bollock*", "breasts", "butt-pirate", "cabron", "cazzo", "chraa", "chuj", "Cock*", "cunt*", "d4mn", "daygo", "dego", "dick*", "dike*", "dupa", "dziwka", "ejackulate", "Ekrem*", "Ekto", "enculer", "faen", "fag*", "fanculo", "fanny", "feces", "feg", "Felcher", "ficken", "fitt*", "Flikker", "foreskin", "Fotze", "Fu(*", "fuk*", "futkretzn", "gook", "guiena", "h0r", "h4x0r", "hell", "helvete", "hoer*", "honkey", "Huevon", "hui", "injun", "jizz", "kanker*", "kike", "klootzak", "kraut", "knulle", "kuk", "kuksuger", "Kurac", "kurwa", "kusi*", "kyrpa*", "lesbo", "mamhoon", "masturbat*", "merd*", "mibun", "monkleigh", "mouliewop", "muie", "mulkku", "muschi", "nazis", "nepesaurio", "nigger*", "orospu", "paska*", "perse", "picka", "pierdol*", "pillu*", "pimmel", "piss*", "pizda", "poontsee", "poop", "porn", "p0rn", "pr0n", "preteen", "pula", "pule", "puta", "puto", "qahbeh", "queef*", "rautenberg", "schaffer", "scheiss*", "schlampe", "schmuck", "screw", "sh!t*", "sharmuta", "sharmute", "shipal", "shiz", "skribz", "skurwysyn", "sphencter", "spic", "spierdalaj", "splooge", "suka", "b00b*", "testicle*", "titt*", "twat", "vittu", "wank*", "wetback*", "wichser", "wop*", "yed", "zabourah"];
  6284. const _h = {
  6285. words: Oh
  6286. };
  6287. var zh = {
  6288. "4r5e": 1,
  6289. "5h1t": 1,
  6290. "5hit": 1,
  6291. a55: 1,
  6292. anal: 1,
  6293. anus: 1,
  6294. ar5e: 1,
  6295. arrse: 1,
  6296. arse: 1,
  6297. ass: 1,
  6298. "ass-fucker": 1,
  6299. asses: 1,
  6300. assfucker: 1,
  6301. assfukka: 1,
  6302. asshole: 1,
  6303. assholes: 1,
  6304. asswhole: 1,
  6305. a_s_s: 1,
  6306. "b!tch": 1,
  6307. b00bs: 1,
  6308. b17ch: 1,
  6309. b1tch: 1,
  6310. ballbag: 1,
  6311. balls: 1,
  6312. ballsack: 1,
  6313. bastard: 1,
  6314. beastial: 1,
  6315. beastiality: 1,
  6316. bellend: 1,
  6317. bestial: 1,
  6318. bestiality: 1,
  6319. "bi+ch": 1,
  6320. biatch: 1,
  6321. bitch: 1,
  6322. bitcher: 1,
  6323. bitchers: 1,
  6324. bitches: 1,
  6325. bitchin: 1,
  6326. bitching: 1,
  6327. bloody: 1,
  6328. "blow job": 1,
  6329. blowjob: 1,
  6330. blowjobs: 1,
  6331. boiolas: 1,
  6332. bollock: 1,
  6333. bollok: 1,
  6334. boner: 1,
  6335. boob: 1,
  6336. boobs: 1,
  6337. booobs: 1,
  6338. boooobs: 1,
  6339. booooobs: 1,
  6340. booooooobs: 1,
  6341. breasts: 1,
  6342. buceta: 1,
  6343. bugger: 1,
  6344. bum: 1,
  6345. "bunny fucker": 1,
  6346. butt: 1,
  6347. butthole: 1,
  6348. buttmuch: 1,
  6349. buttplug: 1,
  6350. c0ck: 1,
  6351. c0cksucker: 1,
  6352. "carpet muncher": 1,
  6353. cawk: 1,
  6354. chink: 1,
  6355. cipa: 1,
  6356. cl1t: 1,
  6357. clit: 1,
  6358. clitoris: 1,
  6359. clits: 1,
  6360. cnut: 1,
  6361. cock: 1,
  6362. "cock-sucker": 1,
  6363. cockface: 1,
  6364. cockhead: 1,
  6365. cockmunch: 1,
  6366. cockmuncher: 1,
  6367. cocks: 1,
  6368. cocksuck: 1,
  6369. cocksucked: 1,
  6370. cocksucker: 1,
  6371. cocksucking: 1,
  6372. cocksucks: 1,
  6373. cocksuka: 1,
  6374. cocksukka: 1,
  6375. cok: 1,
  6376. cokmuncher: 1,
  6377. coksucka: 1,
  6378. coon: 1,
  6379. cox: 1,
  6380. crap: 1,
  6381. cum: 1,
  6382. cummer: 1,
  6383. cumming: 1,
  6384. cums: 1,
  6385. cumshot: 1,
  6386. cunilingus: 1,
  6387. cunillingus: 1,
  6388. cunnilingus: 1,
  6389. cunt: 1,
  6390. cuntlick: 1,
  6391. cuntlicker: 1,
  6392. cuntlicking: 1,
  6393. cunts: 1,
  6394. cyalis: 1,
  6395. cyberfuc: 1,
  6396. cyberfuck: 1,
  6397. cyberfucked: 1,
  6398. cyberfucker: 1,
  6399. cyberfuckers: 1,
  6400. cyberfucking: 1,
  6401. d1ck: 1,
  6402. damn: 1,
  6403. dick: 1,
  6404. dickhead: 1,
  6405. dildo: 1,
  6406. dildos: 1,
  6407. dink: 1,
  6408. dinks: 1,
  6409. dirsa: 1,
  6410. dlck: 1,
  6411. "dog-fucker": 1,
  6412. doggin: 1,
  6413. dogging: 1,
  6414. donkeyribber: 1,
  6415. doosh: 1,
  6416. duche: 1,
  6417. dyke: 1,
  6418. ejaculate: 1,
  6419. ejaculated: 1,
  6420. ejaculates: 1,
  6421. ejaculating: 1,
  6422. ejaculatings: 1,
  6423. ejaculation: 1,
  6424. ejakulate: 1,
  6425. "f u c k": 1,
  6426. "f u c k e r": 1,
  6427. f4nny: 1,
  6428. fag: 1,
  6429. fagging: 1,
  6430. faggitt: 1,
  6431. faggot: 1,
  6432. faggs: 1,
  6433. fagot: 1,
  6434. fagots: 1,
  6435. fags: 1,
  6436. fanny: 1,
  6437. fannyflaps: 1,
  6438. fannyfucker: 1,
  6439. fanyy: 1,
  6440. fatass: 1,
  6441. fcuk: 1,
  6442. fcuker: 1,
  6443. fcuking: 1,
  6444. feck: 1,
  6445. fecker: 1,
  6446. felching: 1,
  6447. fellate: 1,
  6448. fellatio: 1,
  6449. fingerfuck: 1,
  6450. fingerfucked: 1,
  6451. fingerfucker: 1,
  6452. fingerfuckers: 1,
  6453. fingerfucking: 1,
  6454. fingerfucks: 1,
  6455. fistfuck: 1,
  6456. fistfucked: 1,
  6457. fistfucker: 1,
  6458. fistfuckers: 1,
  6459. fistfucking: 1,
  6460. fistfuckings: 1,
  6461. fistfucks: 1,
  6462. flange: 1,
  6463. fook: 1,
  6464. fooker: 1,
  6465. fuck: 1,
  6466. fucka: 1,
  6467. fucked: 1,
  6468. fucker: 1,
  6469. fuckers: 1,
  6470. fuckhead: 1,
  6471. fuckheads: 1,
  6472. fuckin: 1,
  6473. fucking: 1,
  6474. fuckings: 1,
  6475. fuckingshitmotherfucker: 1,
  6476. fuckme: 1,
  6477. fucks: 1,
  6478. fuckwhit: 1,
  6479. fuckwit: 1,
  6480. "fudge packer": 1,
  6481. fudgepacker: 1,
  6482. fuk: 1,
  6483. fuker: 1,
  6484. fukker: 1,
  6485. fukkin: 1,
  6486. fuks: 1,
  6487. fukwhit: 1,
  6488. fukwit: 1,
  6489. fux: 1,
  6490. fux0r: 1,
  6491. f_u_c_k: 1,
  6492. gangbang: 1,
  6493. gangbanged: 1,
  6494. gangbangs: 1,
  6495. gaylord: 1,
  6496. gaysex: 1,
  6497. goatse: 1,
  6498. God: 1,
  6499. "god-dam": 1,
  6500. "god-damned": 1,
  6501. goddamn: 1,
  6502. goddamned: 1,
  6503. hardcoresex: 1,
  6504. hell: 1,
  6505. heshe: 1,
  6506. hoar: 1,
  6507. hoare: 1,
  6508. hoer: 1,
  6509. homo: 1,
  6510. hore: 1,
  6511. horniest: 1,
  6512. horny: 1,
  6513. hotsex: 1,
  6514. "jack-off": 1,
  6515. jackoff: 1,
  6516. jap: 1,
  6517. "jerk-off": 1,
  6518. jism: 1,
  6519. jiz: 1,
  6520. jizm: 1,
  6521. jizz: 1,
  6522. kawk: 1,
  6523. knob: 1,
  6524. knobead: 1,
  6525. knobed: 1,
  6526. knobend: 1,
  6527. knobhead: 1,
  6528. knobjocky: 1,
  6529. knobjokey: 1,
  6530. kock: 1,
  6531. kondum: 1,
  6532. kondums: 1,
  6533. kum: 1,
  6534. kummer: 1,
  6535. kumming: 1,
  6536. kums: 1,
  6537. kunilingus: 1,
  6538. "l3i+ch": 1,
  6539. l3itch: 1,
  6540. labia: 1,
  6541. lust: 1,
  6542. lusting: 1,
  6543. m0f0: 1,
  6544. m0fo: 1,
  6545. m45terbate: 1,
  6546. ma5terb8: 1,
  6547. ma5terbate: 1,
  6548. masochist: 1,
  6549. "master-bate": 1,
  6550. masterb8: 1,
  6551. "masterbat*": 1,
  6552. masterbat3: 1,
  6553. masterbate: 1,
  6554. masterbation: 1,
  6555. masterbations: 1,
  6556. masturbate: 1,
  6557. "mo-fo": 1,
  6558. mof0: 1,
  6559. mofo: 1,
  6560. mothafuck: 1,
  6561. mothafucka: 1,
  6562. mothafuckas: 1,
  6563. mothafuckaz: 1,
  6564. mothafucked: 1,
  6565. mothafucker: 1,
  6566. mothafuckers: 1,
  6567. mothafuckin: 1,
  6568. mothafucking: 1,
  6569. mothafuckings: 1,
  6570. mothafucks: 1,
  6571. "mother fucker": 1,
  6572. motherfuck: 1,
  6573. motherfucked: 1,
  6574. motherfucker: 1,
  6575. motherfuckers: 1,
  6576. motherfuckin: 1,
  6577. motherfucking: 1,
  6578. motherfuckings: 1,
  6579. motherfuckka: 1,
  6580. motherfucks: 1,
  6581. muff: 1,
  6582. mutha: 1,
  6583. muthafecker: 1,
  6584. muthafuckker: 1,
  6585. muther: 1,
  6586. mutherfucker: 1,
  6587. n1gga: 1,
  6588. n1gger: 1,
  6589. nazi: 1,
  6590. nigg3r: 1,
  6591. nigg4h: 1,
  6592. nigga: 1,
  6593. niggah: 1,
  6594. niggas: 1,
  6595. niggaz: 1,
  6596. nigger: 1,
  6597. niggers: 1,
  6598. nob: 1,
  6599. "nob jokey": 1,
  6600. nobhead: 1,
  6601. nobjocky: 1,
  6602. nobjokey: 1,
  6603. numbnuts: 1,
  6604. nutsack: 1,
  6605. orgasim: 1,
  6606. orgasims: 1,
  6607. orgasm: 1,
  6608. orgasms: 1,
  6609. p0rn: 1,
  6610. pawn: 1,
  6611. pecker: 1,
  6612. penis: 1,
  6613. penisfucker: 1,
  6614. phonesex: 1,
  6615. phuck: 1,
  6616. phuk: 1,
  6617. phuked: 1,
  6618. phuking: 1,
  6619. phukked: 1,
  6620. phukking: 1,
  6621. phuks: 1,
  6622. phuq: 1,
  6623. pigfucker: 1,
  6624. pimpis: 1,
  6625. piss: 1,
  6626. pissed: 1,
  6627. pisser: 1,
  6628. pissers: 1,
  6629. pisses: 1,
  6630. pissflaps: 1,
  6631. pissin: 1,
  6632. pissing: 1,
  6633. pissoff: 1,
  6634. poop: 1,
  6635. porn: 1,
  6636. porno: 1,
  6637. pornography: 1,
  6638. pornos: 1,
  6639. prick: 1,
  6640. pricks: 1,
  6641. pron: 1,
  6642. pube: 1,
  6643. pusse: 1,
  6644. pussi: 1,
  6645. pussies: 1,
  6646. pussy: 1,
  6647. pussys: 1,
  6648. rectum: 1,
  6649. retard: 1,
  6650. rimjaw: 1,
  6651. rimming: 1,
  6652. "s hit": 1,
  6653. "s.o.b.": 1,
  6654. sadist: 1,
  6655. schlong: 1,
  6656. screwing: 1,
  6657. scroat: 1,
  6658. scrote: 1,
  6659. scrotum: 1,
  6660. semen: 1,
  6661. sex: 1,
  6662. "sh!+": 1,
  6663. "sh!t": 1,
  6664. sh1t: 1,
  6665. shag: 1,
  6666. shagger: 1,
  6667. shaggin: 1,
  6668. shagging: 1,
  6669. shemale: 1,
  6670. "shi+": 1,
  6671. shit: 1,
  6672. shitdick: 1,
  6673. shite: 1,
  6674. shited: 1,
  6675. shitey: 1,
  6676. shitfuck: 1,
  6677. shitfull: 1,
  6678. shithead: 1,
  6679. shiting: 1,
  6680. shitings: 1,
  6681. shits: 1,
  6682. shitted: 1,
  6683. shitter: 1,
  6684. shitters: 1,
  6685. shitting: 1,
  6686. shittings: 1,
  6687. shitty: 1,
  6688. skank: 1,
  6689. slut: 1,
  6690. sluts: 1,
  6691. smegma: 1,
  6692. smut: 1,
  6693. snatch: 1,
  6694. "son-of-a-bitch": 1,
  6695. spac: 1,
  6696. spunk: 1,
  6697. s_h_i_t: 1,
  6698. t1tt1e5: 1,
  6699. t1tties: 1,
  6700. teets: 1,
  6701. teez: 1,
  6702. testical: 1,
  6703. testicle: 1,
  6704. tit: 1,
  6705. titfuck: 1,
  6706. tits: 1,
  6707. titt: 1,
  6708. tittie5: 1,
  6709. tittiefucker: 1,
  6710. titties: 1,
  6711. tittyfuck: 1,
  6712. tittywank: 1,
  6713. titwank: 1,
  6714. tosser: 1,
  6715. turd: 1,
  6716. tw4t: 1,
  6717. twat: 1,
  6718. twathead: 1,
  6719. twatty: 1,
  6720. twunt: 1,
  6721. twunter: 1,
  6722. v14gra: 1,
  6723. v1gra: 1,
  6724. vagina: 1,
  6725. viagra: 1,
  6726. vulva: 1,
  6727. w00se: 1,
  6728. wang: 1,
  6729. wank: 1,
  6730. wanker: 1,
  6731. wanky: 1,
  6732. whoar: 1,
  6733. whore: 1,
  6734. willies: 1,
  6735. willy: 1,
  6736. xrated: 1,
  6737. xxx: 1
  6738. };
  6739. var Hh = /\b(4r5e|5h1t|5hit|a55|anal|anus|ar5e|arrse|arse|ass|ass-fucker|asses|assfucker|assfukka|asshole|assholes|asswhole|a_s_s|b!tch|b00bs|b17ch|b1tch|ballbag|balls|ballsack|bastard|beastial|beastiality|bellend|bestial|bestiality|bi\+ch|biatch|bitch|bitcher|bitchers|bitches|bitchin|bitching|bloody|blow job|blowjob|blowjobs|boiolas|bollock|bollok|boner|boob|boobs|booobs|boooobs|booooobs|booooooobs|breasts|buceta|bugger|bum|bunny fucker|butt|butthole|buttmuch|buttplug|c0ck|c0cksucker|carpet muncher|cawk|chink|cipa|cl1t|clit|clitoris|clits|cnut|cock|cock-sucker|cockface|cockhead|cockmunch|cockmuncher|cocks|cocksuck|cocksucked|cocksucker|cocksucking|cocksucks|cocksuka|cocksukka|cok|cokmuncher|coksucka|coon|cox|crap|cum|cummer|cumming|cums|cumshot|cunilingus|cunillingus|cunnilingus|cunt|cuntlick|cuntlicker|cuntlicking|cunts|cyalis|cyberfuc|cyberfuck|cyberfucked|cyberfucker|cyberfuckers|cyberfucking|d1ck|damn|dick|dickhead|dildo|dildos|dink|dinks|dirsa|dlck|dog-fucker|doggin|dogging|donkeyribber|doosh|duche|dyke|ejaculate|ejaculated|ejaculates|ejaculating|ejaculatings|ejaculation|ejakulate|f u c k|f u c k e r|f4nny|fag|fagging|faggitt|faggot|faggs|fagot|fagots|fags|fanny|fannyflaps|fannyfucker|fanyy|fatass|fcuk|fcuker|fcuking|feck|fecker|felching|fellate|fellatio|fingerfuck|fingerfucked|fingerfucker|fingerfuckers|fingerfucking|fingerfucks|fistfuck|fistfucked|fistfucker|fistfuckers|fistfucking|fistfuckings|fistfucks|flange|fook|fooker|fuck|fucka|fucked|fucker|fuckers|fuckhead|fuckheads|fuckin|fucking|fuckings|fuckingshitmotherfucker|fuckme|fucks|fuckwhit|fuckwit|fudge packer|fudgepacker|fuk|fuker|fukker|fukkin|fuks|fukwhit|fukwit|fux|fux0r|f_u_c_k|gangbang|gangbanged|gangbangs|gaylord|gaysex|goatse|God|god-dam|god-damned|goddamn|goddamned|hardcoresex|hell|heshe|hoar|hoare|hoer|homo|hore|horniest|horny|hotsex|jack-off|jackoff|jap|jerk-off|jism|jiz|jizm|jizz|kawk|knob|knobead|knobed|knobend|knobhead|knobjocky|knobjokey|kock|kondum|kondums|kum|kummer|kumming|kums|kunilingus|l3i\+ch|l3itch|labia|lust|lusting|m0f0|m0fo|m45terbate|ma5terb8|ma5terbate|masochist|master-bate|masterb8|masterbat*|masterbat3|masterbate|masterbation|masterbations|masturbate|mo-fo|mof0|mofo|mothafuck|mothafucka|mothafuckas|mothafuckaz|mothafucked|mothafucker|mothafuckers|mothafuckin|mothafucking|mothafuckings|mothafucks|mother fucker|motherfuck|motherfucked|motherfucker|motherfuckers|motherfuckin|motherfucking|motherfuckings|motherfuckka|motherfucks|muff|mutha|muthafecker|muthafuckker|muther|mutherfucker|n1gga|n1gger|nazi|nigg3r|nigg4h|nigga|niggah|niggas|niggaz|nigger|niggers|nob|nob jokey|nobhead|nobjocky|nobjokey|numbnuts|nutsack|orgasim|orgasims|orgasm|orgasms|p0rn|pawn|pecker|penis|penisfucker|phonesex|phuck|phuk|phuked|phuking|phukked|phukking|phuks|phuq|pigfucker|pimpis|piss|pissed|pisser|pissers|pisses|pissflaps|pissin|pissing|pissoff|poop|porn|porno|pornography|pornos|prick|pricks|pron|pube|pusse|pussi|pussies|pussy|pussys|rectum|retard|rimjaw|rimming|s hit|s.o.b.|sadist|schlong|screwing|scroat|scrote|scrotum|semen|sex|sh!\+|sh!t|sh1t|shag|shagger|shaggin|shagging|shemale|shi\+|shit|shitdick|shite|shited|shitey|shitfuck|shitfull|shithead|shiting|shitings|shits|shitted|shitter|shitters|shitting|shittings|shitty|skank|slut|sluts|smegma|smut|snatch|son-of-a-bitch|spac|spunk|s_h_i_t|t1tt1e5|t1tties|teets|teez|testical|testicle|tit|titfuck|tits|titt|tittie5|tittiefucker|titties|tittyfuck|tittywank|titwank|tosser|turd|tw4t|twat|twathead|twatty|twunt|twunter|v14gra|v1gra|vagina|viagra|vulva|w00se|wang|wank|wanker|wanky|whoar|whore|willies|willy|xrated|xxx)\b/gi;
  6740. var Lh = {
  6741. object: zh,
  6742. array: 0,
  6743. regex: Hh
  6744. };
  6745. const Fh = _h.words;
  6746. const Vh = Lh.array;
  6747. class Nh {
  6748. constructor(t = {}) {
  6749. Object.assign(this, {
  6750. list: t.emptyList && [] || Array.prototype.concat.apply(Fh, [Vh, t.list || []]),
  6751. exclude: t.exclude || [],
  6752. splitRegex: t.splitRegex || /\b/,
  6753. placeHolder: t.placeHolder || "*",
  6754. regex: t.regex || /[^a-zA-Z0-9|\$|\@]|\^/g,
  6755. replaceRegex: t.replaceRegex || /\w/g
  6756. });
  6757. }
  6758. isProfane(t) {
  6759. return this.list.filter(i => {
  6760. const n = new RegExp(`\\b${i.replace(/(\W)/g, "\\$1")}\\b`, "gi");
  6761. return !this.exclude.includes(i.toLowerCase()) && n.test(t);
  6762. }).length > 0 || false;
  6763. }
  6764. replaceWord(t) {
  6765. return t.replace(this.regex, "").replace(this.replaceRegex, this.placeHolder);
  6766. }
  6767. clean(t) {
  6768. return t.split(this.splitRegex).map(i => this.isProfane(i) ? this.replaceWord(i) : i).join(this.splitRegex.exec(t)[0]);
  6769. }
  6770. addWords() {
  6771. let t = Array.from(arguments);
  6772. this.list.push(...t);
  6773. t.map(i => i.toLowerCase()).forEach(i => {
  6774. if (this.exclude.includes(i)) {
  6775. this.exclude.splice(this.exclude.indexOf(i), 1);
  6776. }
  6777. });
  6778. }
  6779. removeWords() {
  6780. this.exclude.push(...Array.from(arguments).map(t => t.toLowerCase()));
  6781. }
  6782. }
  6783. var Uh = Nh;
  6784. const Wh = An(Uh);
  6785. const Ko = new Wh();
  6786. const Xh = ["jew", "black", "baby", "child", "white", "porn", "pedo", "trump", "clinton", "hitler", "nazi", "gay", "pride", "sex", "pleasure", "touch", "poo", "kids", "rape", "white power", "nigga", "nig nog", "doggy", "rapist", "boner", "nigger", "nigg", "finger", "nogger", "nagger", "nig", "fag", "gai", "pole", "stripper", "penis", "vagina", "pussy", "nazi", "hitler", "stalin", "burn", "chamber", "cock", "peen", "dick", "spick", "nieger", "die", "satan", "n|ig", "nlg", "cunt", "c0ck", "fag", "lick", "condom", "anal", "shit", "phile", "little", "kids", "free KR", "tiny", "sidney", "ass", "kill", ".io", "(dot)", "[dot]", "mini", "whiore", "whore", "faggot", "github", "1337", "666", "satan", "senpa", "discord", "d1scord", "mistik", ".io", "senpa.io", "sidney", "sid", "senpaio", "vries", "asa"];
  6787. Ko.addWords(...Xh);
  6788. const Ir = Math.abs;
  6789. const Ut = Math.cos;
  6790. const Wt = Math.sin;
  6791. const Tr = Math.pow;
  6792. const qh = Math.sqrt;
  6793. function Gh(e, t, i, n, s, r, o, l, c, a, f, d, u, p) {
  6794. this.id = e;
  6795. this.sid = t;
  6796. this.tmpScore = 0;
  6797. this.team = null;
  6798. this.skinIndex = 0;
  6799. this.tailIndex = 0;
  6800. this.hitTime = 0;
  6801. this.tails = {};
  6802. for (var w = 0; w < f.length; ++w) {
  6803. if (f[w].price <= 0) {
  6804. this.tails[f[w].id] = 1;
  6805. }
  6806. }
  6807. this.skins = {};
  6808. for (var w = 0; w < a.length; ++w) {
  6809. if (a[w].price <= 0) {
  6810. this.skins[a[w].id] = 1;
  6811. }
  6812. }
  6813. this.points = 0;
  6814. this.dt = 0;
  6815. this.hidden = false;
  6816. this.itemCounts = {};
  6817. this.isPlayer = true;
  6818. this.pps = 0;
  6819. this.moveDir = undefined;
  6820. this.skinRot = 0;
  6821. this.lastPing = 0;
  6822. this.iconIndex = 0;
  6823. this.skinColor = 0;
  6824. this.spawn = function (v) {
  6825. this.active = true;
  6826. this.alive = true;
  6827. this.lockMove = false;
  6828. this.lockDir = false;
  6829. this.minimapCounter = 0;
  6830. this.chatCountdown = 0;
  6831. this.shameCount = 0;
  6832. this.shameTimer = 0;
  6833. this.sentTo = {};
  6834. this.gathering = 0;
  6835. this.autoGather = 0;
  6836. this.animTime = 0;
  6837. this.animSpeed = 0;
  6838. this.mouseState = 0;
  6839. this.buildIndex = -1;
  6840. this.weaponIndex = 0;
  6841. this.dmgOverTime = {};
  6842. this.noMovTimer = 0;
  6843. this.maxXP = 300;
  6844. this.XP = 0;
  6845. this.age = 1;
  6846. this.kills = 0;
  6847. this.upgrAge = 2;
  6848. this.upgradePoints = 0;
  6849. this.x = 0;
  6850. this.y = 0;
  6851. this.zIndex = 0;
  6852. this.xVel = 0;
  6853. this.yVel = 0;
  6854. this.slowMult = 1;
  6855. this.dir = 0;
  6856. this.dirPlus = 0;
  6857. this.targetDir = 0;
  6858. this.targetAngle = 0;
  6859. this.maxHealth = 100;
  6860. this.health = this.maxHealth;
  6861. this.scale = i.playerScale;
  6862. this.speed = i.playerSpeed;
  6863. this.resetMoveDir();
  6864. this.resetResources(v);
  6865. this.items = [0, 3, 6, 10];
  6866. this.weapons = [0];
  6867. this.shootCount = 0;
  6868. this.weaponXP = [];
  6869. this.reloads = {};
  6870. this.timeSpentNearVolcano = 0;
  6871. };
  6872. this.resetMoveDir = function () {
  6873. this.moveDir = undefined;
  6874. };
  6875. this.resetResources = function (v) {
  6876. for (let S = 0; S < i.resourceTypes.length; ++S) {
  6877. this[i.resourceTypes[S]] = v ? 100 : 0;
  6878. }
  6879. };
  6880. this.addItem = function (v) {
  6881. const S = c.list[v];
  6882. if (S) {
  6883. for (let R = 0; R < this.items.length; ++R) {
  6884. if (c.list[this.items[R]].group == S.group) {
  6885. if (this.buildIndex == this.items[R]) {
  6886. this.buildIndex = v;
  6887. }
  6888. this.items[R] = v;
  6889. return true;
  6890. }
  6891. }
  6892. this.items.push(v);
  6893. return true;
  6894. }
  6895. return false;
  6896. };
  6897. this.setUserData = function (v) {
  6898. if (v) {
  6899. this.name = "unknown";
  6900. let S = v.name + "";
  6901. S = S.slice(0, i.maxNameLength);
  6902. S = S.replace(/[^\w:\(\)\/? -]+/gmi, " ");
  6903. S = S.replace(/[^\x00-\x7F]/g, " ");
  6904. S = S.trim();
  6905. let R = false;
  6906. const G = S.toLowerCase().replace(/\s/g, "").replace(/1/g, "i").replace(/0/g, "o").replace(/5/g, "s");
  6907. for (const X of Ko.list) {
  6908. if (G.indexOf(X) != -1) {
  6909. R = true;
  6910. break;
  6911. }
  6912. }
  6913. if (S.length > 0 && !R) {
  6914. this.name = S;
  6915. }
  6916. this.skinColor = 0;
  6917. if (i.skinColors[v.skin]) {
  6918. this.skinColor = v.skin;
  6919. }
  6920. }
  6921. };
  6922. this.getData = function () {
  6923. return [this.id, this.sid, this.name, n.fixTo(this.x, 2), n.fixTo(this.y, 2), n.fixTo(this.dir, 3), this.health, this.maxHealth, this.scale, this.skinColor];
  6924. };
  6925. this.setData = function (v) {
  6926. this.id = v[0];
  6927. this.sid = v[1];
  6928. this.name = v[2];
  6929. this.x = v[3];
  6930. this.y = v[4];
  6931. this.dir = v[5];
  6932. this.health = v[6];
  6933. this.maxHealth = v[7];
  6934. this.scale = v[8];
  6935. this.skinColor = v[9];
  6936. };
  6937. let x = 0;
  6938. this.update = function (v) {
  6939. if (!this.alive) {
  6940. return;
  6941. }
  6942. if ((n.getDistance(this.x, this.y, i.volcanoLocationX, i.volcanoLocationY) || 0) < i.volcanoAggressionRadius) {
  6943. this.timeSpentNearVolcano += v;
  6944. if (this.timeSpentNearVolcano >= 1000) {
  6945. this.changeHealth(i.volcanoDamagePerSecond, null);
  6946. d.send(this.id, "8", Math.round(this.x), Math.round(this.y), i.volcanoDamagePerSecond, -1);
  6947. this.timeSpentNearVolcano %= 1000;
  6948. }
  6949. }
  6950. if (this.shameTimer > 0) {
  6951. this.shameTimer -= v;
  6952. if (this.shameTimer <= 0) {
  6953. this.shameTimer = 0;
  6954. this.shameCount = 0;
  6955. }
  6956. }
  6957. x -= v;
  6958. if (x <= 0) {
  6959. const _ = (this.skin && this.skin.healthRegen ? this.skin.healthRegen : 0) + (this.tail && this.tail.healthRegen ? this.tail.healthRegen : 0);
  6960. if (_) {
  6961. this.changeHealth(_, this);
  6962. }
  6963. if (this.dmgOverTime.dmg) {
  6964. this.changeHealth(-this.dmgOverTime.dmg, this.dmgOverTime.doer);
  6965. this.dmgOverTime.time -= 1;
  6966. if (this.dmgOverTime.time <= 0) {
  6967. this.dmgOverTime.dmg = 0;
  6968. }
  6969. }
  6970. if (this.healCol) {
  6971. this.changeHealth(this.healCol, this);
  6972. }
  6973. x = 1000;
  6974. }
  6975. if (!this.alive) {
  6976. return;
  6977. }
  6978. if (this.slowMult < 1) {
  6979. this.slowMult += v * 0.0008;
  6980. if (this.slowMult > 1) {
  6981. this.slowMult = 1;
  6982. }
  6983. }
  6984. this.noMovTimer += v;
  6985. if (this.xVel || this.yVel) {
  6986. this.noMovTimer = 0;
  6987. }
  6988. if (this.lockMove) {
  6989. this.xVel = 0;
  6990. this.yVel = 0;
  6991. } else {
  6992. let _ = (this.buildIndex >= 0 ? 0.5 : 1) * (c.weapons[this.weaponIndex].spdMult || 1) * (this.skin && this.skin.spdMult || 1) * (this.tail && this.tail.spdMult || 1) * (this.y <= i.snowBiomeTop ? this.skin && this.skin.coldM ? 1 : i.snowSpeed : 1) * this.slowMult;
  6993. if (!this.zIndex && this.y >= i.mapScale / 2 - i.riverWidth / 2 && this.y <= i.mapScale / 2 + i.riverWidth / 2) {
  6994. if (this.skin && this.skin.watrImm) {
  6995. _ *= 0.75;
  6996. this.xVel += i.waterCurrent * 0.4 * v;
  6997. } else {
  6998. _ *= 0.33;
  6999. this.xVel += i.waterCurrent * v;
  7000. }
  7001. }
  7002. let D = this.moveDir != null ? Ut(this.moveDir) : 0;
  7003. let z = this.moveDir != null ? Wt(this.moveDir) : 0;
  7004. const N = qh(D * D + z * z);
  7005. if (N != 0) {
  7006. D /= N;
  7007. z /= N;
  7008. }
  7009. if (D) {
  7010. this.xVel += D * this.speed * _ * v;
  7011. }
  7012. if (z) {
  7013. this.yVel += z * this.speed * _ * v;
  7014. }
  7015. }
  7016. this.zIndex = 0;
  7017. this.lockMove = false;
  7018. this.healCol = 0;
  7019. let R;
  7020. const G = n.getDistance(0, 0, this.xVel * v, this.yVel * v);
  7021. const X = Math.min(4, Math.max(1, Math.round(G / 40)));
  7022. const W = 1 / X;
  7023. let M = {};
  7024. for (var V = 0; V < X; ++V) {
  7025. if (this.xVel) {
  7026. this.x += this.xVel * v * W;
  7027. }
  7028. if (this.yVel) {
  7029. this.y += this.yVel * v * W;
  7030. }
  7031. R = r.getGridArrays(this.x, this.y, this.scale);
  7032. for (let _ = 0; _ < R.length; ++_) {
  7033. for (let D = 0; D < R[_].length && !(R[_][D].active && !M[R[_][D].sid] && r.checkCollision(this, R[_][D], W) && (M[R[_][D].sid] = true, !this.alive)); ++D);
  7034. if (!this.alive) {
  7035. break;
  7036. }
  7037. }
  7038. if (!this.alive) {
  7039. break;
  7040. }
  7041. }
  7042. for (var F = o.indexOf(this), V = F + 1; V < o.length; ++V) {
  7043. if (o[V] != this && o[V].alive) {
  7044. r.checkCollision(this, o[V]);
  7045. }
  7046. }
  7047. if (this.xVel) {
  7048. this.xVel *= Tr(i.playerDecel, v);
  7049. if (this.xVel <= 0.01 && this.xVel >= -0.01) {
  7050. this.xVel = 0;
  7051. }
  7052. }
  7053. if (this.yVel) {
  7054. this.yVel *= Tr(i.playerDecel, v);
  7055. if (this.yVel <= 0.01 && this.yVel >= -0.01) {
  7056. this.yVel = 0;
  7057. }
  7058. }
  7059. if (this.x - this.scale < 0) {
  7060. this.x = this.scale;
  7061. } else if (this.x + this.scale > i.mapScale) {
  7062. this.x = i.mapScale - this.scale;
  7063. }
  7064. if (this.y - this.scale < 0) {
  7065. this.y = this.scale;
  7066. } else if (this.y + this.scale > i.mapScale) {
  7067. this.y = i.mapScale - this.scale;
  7068. }
  7069. if (this.buildIndex < 0) {
  7070. if (this.reloads[this.weaponIndex] > 0) {
  7071. this.reloads[this.weaponIndex] -= v;
  7072. this.gathering = this.mouseState;
  7073. } else if (this.gathering || this.autoGather) {
  7074. let _ = true;
  7075. if (c.weapons[this.weaponIndex].gather != null) {
  7076. this.gather(o);
  7077. } else if (c.weapons[this.weaponIndex].projectile != null && this.hasRes(c.weapons[this.weaponIndex], this.skin ? this.skin.projCost : 0)) {
  7078. this.useRes(c.weapons[this.weaponIndex], this.skin ? this.skin.projCost : 0);
  7079. this.noMovTimer = 0;
  7080. var F = c.weapons[this.weaponIndex].projectile;
  7081. const z = this.scale * 2;
  7082. const N = this.skin && this.skin.aMlt ? this.skin.aMlt : 1;
  7083. if (c.weapons[this.weaponIndex].rec) {
  7084. this.xVel -= c.weapons[this.weaponIndex].rec * Ut(this.dir);
  7085. this.yVel -= c.weapons[this.weaponIndex].rec * Wt(this.dir);
  7086. }
  7087. s.addProjectile(this.x + z * Ut(this.dir), this.y + z * Wt(this.dir), this.dir, c.projectiles[F].range * N, c.projectiles[F].speed * N, F, this, null, this.zIndex);
  7088. } else {
  7089. _ = false;
  7090. }
  7091. this.gathering = this.mouseState;
  7092. if (_) {
  7093. this.reloads[this.weaponIndex] = c.weapons[this.weaponIndex].speed * (this.skin && this.skin.atkSpd || 1);
  7094. }
  7095. }
  7096. }
  7097. };
  7098. this.addWeaponXP = function (v) {
  7099. if (!this.weaponXP[this.weaponIndex]) {
  7100. this.weaponXP[this.weaponIndex] = 0;
  7101. }
  7102. this.weaponXP[this.weaponIndex] += v;
  7103. };
  7104. this.earnXP = function (v) {
  7105. if (this.age < i.maxAge) {
  7106. this.XP += v;
  7107. if (this.XP >= this.maxXP) {
  7108. if (this.age < i.maxAge) {
  7109. this.age++;
  7110. this.XP = 0;
  7111. this.maxXP *= 1.2;
  7112. } else {
  7113. this.XP = this.maxXP;
  7114. }
  7115. this.upgradePoints++;
  7116. d.send(this.id, "U", this.upgradePoints, this.upgrAge);
  7117. d.send(this.id, "T", this.XP, n.fixTo(this.maxXP, 1), this.age);
  7118. } else {
  7119. d.send(this.id, "T", this.XP);
  7120. }
  7121. }
  7122. };
  7123. this.changeHealth = function (v, S) {
  7124. if (v > 0 && this.health >= this.maxHealth) {
  7125. return false;
  7126. }
  7127. if (v < 0 && this.skin) {
  7128. v *= this.skin.dmgMult || 1;
  7129. }
  7130. if (v < 0 && this.tail) {
  7131. v *= this.tail.dmgMult || 1;
  7132. }
  7133. if (v < 0) {
  7134. this.hitTime = Date.now();
  7135. }
  7136. this.health += v;
  7137. if (this.health > this.maxHealth) {
  7138. v -= this.health - this.maxHealth;
  7139. this.health = this.maxHealth;
  7140. }
  7141. if (this.health <= 0) {
  7142. this.kill(S);
  7143. }
  7144. for (let R = 0; R < o.length; ++R) {
  7145. if (this.sentTo[o[R].id]) {
  7146. d.send(o[R].id, "O", this.sid, this.health);
  7147. }
  7148. }
  7149. if (S && S.canSee(this) && !(S == this && v < 0)) {
  7150. d.send(S.id, "8", Math.round(this.x), Math.round(this.y), Math.round(-v), 1);
  7151. }
  7152. return true;
  7153. };
  7154. this.kill = function (v) {
  7155. if (v && v.alive) {
  7156. v.kills++;
  7157. if (v.skin && v.skin.goldSteal) {
  7158. u(v, Math.round(this.points / 2));
  7159. } else {
  7160. u(v, Math.round(this.age * 100 * (v.skin && v.skin.kScrM ? v.skin.kScrM : 1)));
  7161. }
  7162. d.send(v.id, "N", "kills", v.kills, 1);
  7163. }
  7164. this.alive = false;
  7165. d.send(this.id, "P");
  7166. p();
  7167. };
  7168. this.addResource = function (v, S, R) {
  7169. if (!R && S > 0) {
  7170. this.addWeaponXP(S);
  7171. }
  7172. if (v == 3) {
  7173. u(this, S, true);
  7174. } else {
  7175. this[i.resourceTypes[v]] += S;
  7176. d.send(this.id, "N", i.resourceTypes[v], this[i.resourceTypes[v]], 1);
  7177. }
  7178. };
  7179. this.changeItemCount = function (v, S) {
  7180. this.itemCounts[v] = this.itemCounts[v] || 0;
  7181. this.itemCounts[v] += S;
  7182. d.send(this.id, "S", v, this.itemCounts[v]);
  7183. };
  7184. this.buildItem = function (v) {
  7185. const S = this.scale + v.scale + (v.placeOffset || 0);
  7186. const R = this.x + S * Ut(this.dir);
  7187. const G = this.y + S * Wt(this.dir);
  7188. if (this.canBuild(v) && !(v.consume && this.skin && this.skin.noEat) && (v.consume || r.checkItemLocation(R, G, v.scale, 0.6, v.id, false, this))) {
  7189. let X = false;
  7190. if (v.consume) {
  7191. if (this.hitTime) {
  7192. const W = Date.now() - this.hitTime;
  7193. this.hitTime = 0;
  7194. if (W <= 120) {
  7195. this.shameCount++;
  7196. if (this.shameCount >= 8) {
  7197. this.shameTimer = 30000;
  7198. this.shameCount = 0;
  7199. }
  7200. } else {
  7201. this.shameCount -= 2;
  7202. if (this.shameCount <= 0) {
  7203. this.shameCount = 0;
  7204. }
  7205. }
  7206. }
  7207. if (this.shameTimer <= 0) {
  7208. X = v.consume(this);
  7209. }
  7210. } else {
  7211. X = true;
  7212. if (v.group.limit) {
  7213. this.changeItemCount(v.group.id, 1);
  7214. }
  7215. if (v.pps) {
  7216. this.pps += v.pps;
  7217. }
  7218. r.add(r.objects.length, R, G, this.dir, v.scale, v.type, v, false, this);
  7219. }
  7220. if (X) {
  7221. this.useRes(v);
  7222. this.buildIndex = -1;
  7223. }
  7224. }
  7225. };
  7226. this.hasRes = function (v, S) {
  7227. for (let R = 0; R < v.req.length;) {
  7228. if (this[v.req[R]] < Math.round(v.req[R + 1] * (S || 1))) {
  7229. return false;
  7230. }
  7231. R += 2;
  7232. }
  7233. return true;
  7234. };
  7235. this.useRes = function (v, S) {
  7236. if (!i.inSandbox) {
  7237. for (let R = 0; R < v.req.length;) {
  7238. this.addResource(i.resourceTypes.indexOf(v.req[R]), -Math.round(v.req[R + 1] * (S || 1)));
  7239. R += 2;
  7240. }
  7241. }
  7242. };
  7243. this.canBuild = function (v) {
  7244. const S = i.inSandbox ? v.group.sandboxLimit || Math.max(v.group.limit * 3, 99) : v.group.limit;
  7245. if (S && this.itemCounts[v.group.id] >= S) {
  7246. return false;
  7247. } else if (i.inSandbox) {
  7248. return true;
  7249. } else {
  7250. return this.hasRes(v);
  7251. }
  7252. };
  7253. this.gather = function () {
  7254. this.noMovTimer = 0;
  7255. this.slowMult -= c.weapons[this.weaponIndex].hitSlow || 0.3;
  7256. if (this.slowMult < 0) {
  7257. this.slowMult = 0;
  7258. }
  7259. const v = i.fetchVariant(this);
  7260. const S = v.poison;
  7261. const R = v.val;
  7262. const G = {};
  7263. let X;
  7264. let W;
  7265. let M;
  7266. let V;
  7267. const F = r.getGridArrays(this.x, this.y, c.weapons[this.weaponIndex].range);
  7268. for (let D = 0; D < F.length; ++D) {
  7269. for (var _ = 0; _ < F[D].length; ++_) {
  7270. M = F[D][_];
  7271. if (M.active && !M.dontGather && !G[M.sid] && M.visibleToPlayer(this) && (X = n.getDistance(this.x, this.y, M.x, M.y) - M.scale, X <= c.weapons[this.weaponIndex].range && (W = n.getDirection(M.x, M.y, this.x, this.y), n.getAngleDist(W, this.dir) <= i.gatherAngle))) {
  7272. G[M.sid] = 1;
  7273. if (M.health) {
  7274. if (M.changeHealth(-c.weapons[this.weaponIndex].dmg * R * (c.weapons[this.weaponIndex].sDmg || 1) * (this.skin && this.skin.bDmg ? this.skin.bDmg : 1), this)) {
  7275. for (let z = 0; z < M.req.length;) {
  7276. this.addResource(i.resourceTypes.indexOf(M.req[z]), M.req[z + 1]);
  7277. z += 2;
  7278. }
  7279. r.disableObj(M);
  7280. }
  7281. } else {
  7282. if (M.name === "volcano") {
  7283. this.hitVolcano(c.weapons[this.weaponIndex].gather);
  7284. } else {
  7285. this.earnXP(c.weapons[this.weaponIndex].gather * 4);
  7286. const z = c.weapons[this.weaponIndex].gather + (M.type == 3 ? 4 : 0);
  7287. this.addResource(M.type, z);
  7288. }
  7289. if (this.skin && this.skin.extraGold) {
  7290. this.addResource(3, 1);
  7291. }
  7292. }
  7293. V = true;
  7294. r.hitObj(M, W);
  7295. }
  7296. }
  7297. }
  7298. for (var _ = 0; _ < o.length + l.length; ++_) {
  7299. M = o[_] || l[_ - o.length];
  7300. if (M != this && M.alive && !(M.team && M.team == this.team) && (X = n.getDistance(this.x, this.y, M.x, M.y) - M.scale * 1.8, X <= c.weapons[this.weaponIndex].range && (W = n.getDirection(M.x, M.y, this.x, this.y), n.getAngleDist(W, this.dir) <= i.gatherAngle))) {
  7301. let z = c.weapons[this.weaponIndex].steal;
  7302. if (z && M.addResource) {
  7303. z = Math.min(M.points || 0, z);
  7304. this.addResource(3, z);
  7305. M.addResource(3, -z);
  7306. }
  7307. let N = R;
  7308. if (M.weaponIndex != null && c.weapons[M.weaponIndex].shield && n.getAngleDist(W + Math.PI, M.dir) <= i.shieldAngle) {
  7309. N = c.weapons[M.weaponIndex].shield;
  7310. }
  7311. const Y = c.weapons[this.weaponIndex].dmg;
  7312. const K = Y * (this.skin && this.skin.dmgMultO ? this.skin.dmgMultO : 1) * (this.tail && this.tail.dmgMultO ? this.tail.dmgMultO : 1);
  7313. const ie = (M.weightM || 1) * 0.3 + (c.weapons[this.weaponIndex].knock || 0);
  7314. M.xVel += ie * Ut(W);
  7315. M.yVel += ie * Wt(W);
  7316. if (this.skin && this.skin.healD) {
  7317. this.changeHealth(K * N * this.skin.healD, this);
  7318. }
  7319. if (this.tail && this.tail.healD) {
  7320. this.changeHealth(K * N * this.tail.healD, this);
  7321. }
  7322. if (M.skin && M.skin.dmg) {
  7323. this.changeHealth(-Y * M.skin.dmg, M);
  7324. }
  7325. if (M.tail && M.tail.dmg) {
  7326. this.changeHealth(-Y * M.tail.dmg, M);
  7327. }
  7328. if (M.dmgOverTime && this.skin && this.skin.poisonDmg && !(M.skin && M.skin.poisonRes)) {
  7329. M.dmgOverTime.dmg = this.skin.poisonDmg;
  7330. M.dmgOverTime.time = this.skin.poisonTime || 1;
  7331. M.dmgOverTime.doer = this;
  7332. }
  7333. if (M.dmgOverTime && S && !(M.skin && M.skin.poisonRes)) {
  7334. M.dmgOverTime.dmg = 5;
  7335. M.dmgOverTime.time = 5;
  7336. M.dmgOverTime.doer = this;
  7337. }
  7338. if (M.skin && M.skin.dmgK) {
  7339. this.xVel -= M.skin.dmgK * Ut(W);
  7340. this.yVel -= M.skin.dmgK * Wt(W);
  7341. }
  7342. M.changeHealth(-K * N, this, this);
  7343. }
  7344. }
  7345. this.sendAnimation(V ? 1 : 0);
  7346. };
  7347. this.hitVolcano = function (v) {
  7348. const S = 5 + Math.round(v / 3.5);
  7349. this.addResource(2, S);
  7350. this.addResource(3, S);
  7351. };
  7352. this.sendAnimation = function (v) {
  7353. for (let S = 0; S < o.length; ++S) {
  7354. if (this.sentTo[o[S].id] && this.canSee(o[S])) {
  7355. d.send(o[S].id, "K", this.sid, v ? 1 : 0, this.weaponIndex);
  7356. }
  7357. }
  7358. };
  7359. let b = 0;
  7360. let $ = 0;
  7361. this.animate = function (v) {
  7362. if (this.animTime > 0) {
  7363. this.animTime -= v;
  7364. if (this.animTime <= 0) {
  7365. this.animTime = 0;
  7366. this.dirPlus = 0;
  7367. b = 0;
  7368. $ = 0;
  7369. } else if ($ == 0) {
  7370. b += v / (this.animSpeed * i.hitReturnRatio);
  7371. this.dirPlus = n.lerp(0, this.targetAngle, Math.min(1, b));
  7372. if (b >= 1) {
  7373. b = 1;
  7374. $ = 1;
  7375. }
  7376. } else {
  7377. b -= v / (this.animSpeed * (1 - i.hitReturnRatio));
  7378. this.dirPlus = n.lerp(0, this.targetAngle, Math.max(0, b));
  7379. }
  7380. }
  7381. };
  7382. this.startAnim = function (v, S) {
  7383. this.animTime = this.animSpeed = c.weapons[S].speed;
  7384. this.targetAngle = v ? -i.hitAngle : -Math.PI;
  7385. b = 0;
  7386. $ = 0;
  7387. };
  7388. this.canSee = function (v) {
  7389. if (!v || v.skin && v.skin.invisTimer && v.noMovTimer >= v.skin.invisTimer) {
  7390. return false;
  7391. }
  7392. const S = Ir(v.x - this.x) - v.scale;
  7393. const R = Ir(v.y - this.y) - v.scale;
  7394. return S <= i.maxScreenWidth / 2 * 1.3 && R <= i.maxScreenHeight / 2 * 1.3;
  7395. };
  7396. }
  7397. const Yh = [{
  7398. id: 45,
  7399. name: "Shame!",
  7400. dontSell: true,
  7401. price: 0,
  7402. scale: 120,
  7403. desc: "hacks are for losers"
  7404. }, {
  7405. id: 51,
  7406. name: "Moo Cap",
  7407. price: 0,
  7408. scale: 120,
  7409. desc: "coolest mooer around"
  7410. }, {
  7411. id: 50,
  7412. name: "Apple Cap",
  7413. price: 0,
  7414. scale: 120,
  7415. desc: "apple farms remembers"
  7416. }, {
  7417. id: 28,
  7418. name: "Moo Head",
  7419. price: 0,
  7420. scale: 120,
  7421. desc: "no effect"
  7422. }, {
  7423. id: 29,
  7424. name: "Pig Head",
  7425. price: 0,
  7426. scale: 120,
  7427. desc: "no effect"
  7428. }, {
  7429. id: 30,
  7430. name: "Fluff Head",
  7431. price: 0,
  7432. scale: 120,
  7433. desc: "no effect"
  7434. }, {
  7435. id: 36,
  7436. name: "Pandou Head",
  7437. price: 0,
  7438. scale: 120,
  7439. desc: "no effect"
  7440. }, {
  7441. id: 37,
  7442. name: "Bear Head",
  7443. price: 0,
  7444. scale: 120,
  7445. desc: "no effect"
  7446. }, {
  7447. id: 38,
  7448. name: "Monkey Head",
  7449. price: 0,
  7450. scale: 120,
  7451. desc: "no effect"
  7452. }, {
  7453. id: 44,
  7454. name: "Polar Head",
  7455. price: 0,
  7456. scale: 120,
  7457. desc: "no effect"
  7458. }, {
  7459. id: 35,
  7460. name: "Fez Hat",
  7461. price: 0,
  7462. scale: 120,
  7463. desc: "no effect"
  7464. }, {
  7465. id: 42,
  7466. name: "Enigma Hat",
  7467. price: 0,
  7468. scale: 120,
  7469. desc: "join the enigma army"
  7470. }, {
  7471. id: 43,
  7472. name: "Blitz Hat",
  7473. price: 0,
  7474. scale: 120,
  7475. desc: "hey everybody i'm blitz"
  7476. }, {
  7477. id: 49,
  7478. name: "Bob XIII Hat",
  7479. price: 0,
  7480. scale: 120,
  7481. desc: "like and subscribe"
  7482. }, {
  7483. id: 57,
  7484. name: "Pumpkin",
  7485. price: 50,
  7486. scale: 120,
  7487. desc: "Spooooky"
  7488. }, {
  7489. id: 8,
  7490. name: "Bummle Hat",
  7491. price: 100,
  7492. scale: 120,
  7493. desc: "no effect"
  7494. }, {
  7495. id: 2,
  7496. name: "Straw Hat",
  7497. price: 500,
  7498. scale: 120,
  7499. desc: "no effect"
  7500. }, {
  7501. id: 15,
  7502. name: "Winter Cap",
  7503. price: 600,
  7504. scale: 120,
  7505. desc: "allows you to move at normal speed in snow",
  7506. coldM: 1
  7507. }, {
  7508. id: 5,
  7509. name: "Cowboy Hat",
  7510. price: 1000,
  7511. scale: 120,
  7512. desc: "no effect"
  7513. }, {
  7514. id: 4,
  7515. name: "Ranger Hat",
  7516. price: 2000,
  7517. scale: 120,
  7518. desc: "no effect"
  7519. }, {
  7520. id: 18,
  7521. name: "Explorer Hat",
  7522. price: 2000,
  7523. scale: 120,
  7524. desc: "no effect"
  7525. }, {
  7526. id: 31,
  7527. name: "Flipper Hat",
  7528. price: 2500,
  7529. scale: 120,
  7530. desc: "have more control while in water",
  7531. watrImm: true
  7532. }, {
  7533. id: 1,
  7534. name: "Marksman Cap",
  7535. price: 3000,
  7536. scale: 120,
  7537. desc: "increases arrow speed and range",
  7538. aMlt: 1.3
  7539. }, {
  7540. id: 10,
  7541. name: "Bush Gear",
  7542. price: 3000,
  7543. scale: 160,
  7544. desc: "allows you to disguise yourself as a bush"
  7545. }, {
  7546. id: 48,
  7547. name: "Halo",
  7548. price: 3000,
  7549. scale: 120,
  7550. desc: "no effect"
  7551. }, {
  7552. id: 6,
  7553. name: "Soldier Helmet",
  7554. price: 4000,
  7555. scale: 120,
  7556. desc: "reduces damage taken but slows movement",
  7557. spdMult: 0.94,
  7558. dmgMult: 0.75
  7559. }, {
  7560. id: 23,
  7561. name: "Anti Venom Gear",
  7562. price: 4000,
  7563. scale: 120,
  7564. desc: "makes you immune to poison",
  7565. poisonRes: 1
  7566. }, {
  7567. id: 13,
  7568. name: "Medic Gear",
  7569. price: 5000,
  7570. scale: 110,
  7571. desc: "slowly regenerates health over time",
  7572. healthRegen: 3
  7573. }, {
  7574. id: 9,
  7575. name: "Miners Helmet",
  7576. price: 5000,
  7577. scale: 120,
  7578. desc: "earn 1 extra gold per resource",
  7579. extraGold: 1
  7580. }, {
  7581. id: 32,
  7582. name: "Musketeer Hat",
  7583. price: 5000,
  7584. scale: 120,
  7585. desc: "reduces cost of projectiles",
  7586. projCost: 0.5
  7587. }, {
  7588. id: 7,
  7589. name: "Bull Helmet",
  7590. price: 6000,
  7591. scale: 120,
  7592. desc: "increases damage done but drains health",
  7593. healthRegen: -5,
  7594. dmgMultO: 1.5,
  7595. spdMult: 0.96
  7596. }, {
  7597. id: 22,
  7598. name: "Emp Helmet",
  7599. price: 6000,
  7600. scale: 120,
  7601. desc: "turrets won't attack but you move slower",
  7602. antiTurret: 1,
  7603. spdMult: 0.7
  7604. }, {
  7605. id: 12,
  7606. name: "Booster Hat",
  7607. price: 6000,
  7608. scale: 120,
  7609. desc: "increases your movement speed",
  7610. spdMult: 1.16
  7611. }, {
  7612. id: 26,
  7613. name: "Barbarian Armor",
  7614. price: 8000,
  7615. scale: 120,
  7616. desc: "knocks back enemies that attack you",
  7617. dmgK: 0.6
  7618. }, {
  7619. id: 21,
  7620. name: "Plague Mask",
  7621. price: 10000,
  7622. scale: 120,
  7623. desc: "melee attacks deal poison damage",
  7624. poisonDmg: 5,
  7625. poisonTime: 6
  7626. }, {
  7627. id: 46,
  7628. name: "Bull Mask",
  7629. price: 10000,
  7630. scale: 120,
  7631. desc: "bulls won't target you unless you attack them",
  7632. bullRepel: 1
  7633. }, {
  7634. id: 14,
  7635. name: "Windmill Hat",
  7636. topSprite: true,
  7637. price: 10000,
  7638. scale: 120,
  7639. desc: "generates points while worn",
  7640. pps: 1.5
  7641. }, {
  7642. id: 11,
  7643. name: "Spike Gear",
  7644. topSprite: true,
  7645. price: 10000,
  7646. scale: 120,
  7647. desc: "deal damage to players that damage you",
  7648. dmg: 0.45
  7649. }, {
  7650. id: 53,
  7651. name: "Turret Gear",
  7652. topSprite: true,
  7653. price: 10000,
  7654. scale: 120,
  7655. desc: "you become a walking turret",
  7656. turret: {
  7657. proj: 1,
  7658. range: 700,
  7659. rate: 2500
  7660. },
  7661. spdMult: 0.7
  7662. }, {
  7663. id: 20,
  7664. name: "Samurai Armor",
  7665. price: 12000,
  7666. scale: 120,
  7667. desc: "increased attack speed and fire rate",
  7668. atkSpd: 0.78
  7669. }, {
  7670. id: 58,
  7671. name: "Dark Knight",
  7672. price: 12000,
  7673. scale: 120,
  7674. desc: "restores health when you deal damage",
  7675. healD: 0.4
  7676. }, {
  7677. id: 27,
  7678. name: "Scavenger Gear",
  7679. price: 15000,
  7680. scale: 120,
  7681. desc: "earn double points for each kill",
  7682. kScrM: 2
  7683. }, {
  7684. id: 40,
  7685. name: "Tank Gear",
  7686. price: 15000,
  7687. scale: 120,
  7688. desc: "increased damage to buildings but slower movement",
  7689. spdMult: 0.3,
  7690. bDmg: 3.3
  7691. }, {
  7692. id: 52,
  7693. name: "Thief Gear",
  7694. price: 15000,
  7695. scale: 120,
  7696. desc: "steal half of a players gold when you kill them",
  7697. goldSteal: 0.5
  7698. }, {
  7699. id: 55,
  7700. name: "Bloodthirster",
  7701. price: 20000,
  7702. scale: 120,
  7703. desc: "Restore Health when dealing damage. And increased damage",
  7704. healD: 0.25,
  7705. dmgMultO: 1.2
  7706. }, {
  7707. id: 56,
  7708. name: "Assassin Gear",
  7709. price: 20000,
  7710. scale: 120,
  7711. desc: "Go invisible when not moving. Can't eat. Increased speed",
  7712. noEat: true,
  7713. spdMult: 1.1,
  7714. invisTimer: 1000
  7715. }];
  7716. const Kh = [{
  7717. id: 12,
  7718. name: "Snowball",
  7719. price: 1000,
  7720. scale: 105,
  7721. xOff: 18,
  7722. desc: "no effect"
  7723. }, {
  7724. id: 9,
  7725. name: "Tree Cape",
  7726. price: 1000,
  7727. scale: 90,
  7728. desc: "no effect"
  7729. }, {
  7730. id: 10,
  7731. name: "Stone Cape",
  7732. price: 1000,
  7733. scale: 90,
  7734. desc: "no effect"
  7735. }, {
  7736. id: 3,
  7737. name: "Cookie Cape",
  7738. price: 1500,
  7739. scale: 90,
  7740. desc: "no effect"
  7741. }, {
  7742. id: 8,
  7743. name: "Cow Cape",
  7744. price: 2000,
  7745. scale: 90,
  7746. desc: "no effect"
  7747. }, {
  7748. id: 11,
  7749. name: "Monkey Tail",
  7750. price: 2000,
  7751. scale: 97,
  7752. xOff: 25,
  7753. desc: "Super speed but reduced damage",
  7754. spdMult: 1.35,
  7755. dmgMultO: 0.2
  7756. }, {
  7757. id: 17,
  7758. name: "Apple Basket",
  7759. price: 3000,
  7760. scale: 80,
  7761. xOff: 12,
  7762. desc: "slowly regenerates health over time",
  7763. healthRegen: 1
  7764. }, {
  7765. id: 6,
  7766. name: "Winter Cape",
  7767. price: 3000,
  7768. scale: 90,
  7769. desc: "no effect"
  7770. }, {
  7771. id: 4,
  7772. name: "Skull Cape",
  7773. price: 4000,
  7774. scale: 90,
  7775. desc: "no effect"
  7776. }, {
  7777. id: 5,
  7778. name: "Dash Cape",
  7779. price: 5000,
  7780. scale: 90,
  7781. desc: "no effect"
  7782. }, {
  7783. id: 2,
  7784. name: "Dragon Cape",
  7785. price: 6000,
  7786. scale: 90,
  7787. desc: "no effect"
  7788. }, {
  7789. id: 1,
  7790. name: "Super Cape",
  7791. price: 8000,
  7792. scale: 90,
  7793. desc: "no effect"
  7794. }, {
  7795. id: 7,
  7796. name: "Troll Cape",
  7797. price: 8000,
  7798. scale: 90,
  7799. desc: "no effect"
  7800. }, {
  7801. id: 14,
  7802. name: "Thorns",
  7803. price: 10000,
  7804. scale: 115,
  7805. xOff: 20,
  7806. desc: "no effect"
  7807. }, {
  7808. id: 15,
  7809. name: "Blockades",
  7810. price: 10000,
  7811. scale: 95,
  7812. xOff: 15,
  7813. desc: "no effect"
  7814. }, {
  7815. id: 20,
  7816. name: "Devils Tail",
  7817. price: 10000,
  7818. scale: 95,
  7819. xOff: 20,
  7820. desc: "no effect"
  7821. }, {
  7822. id: 16,
  7823. name: "Sawblade",
  7824. price: 12000,
  7825. scale: 90,
  7826. spin: true,
  7827. xOff: 0,
  7828. desc: "deal damage to players that damage you",
  7829. dmg: 0.15
  7830. }, {
  7831. id: 13,
  7832. name: "Angel Wings",
  7833. price: 15000,
  7834. scale: 138,
  7835. xOff: 22,
  7836. desc: "slowly regenerates health over time",
  7837. healthRegen: 3
  7838. }, {
  7839. id: 19,
  7840. name: "Shadow Wings",
  7841. price: 15000,
  7842. scale: 138,
  7843. xOff: 22,
  7844. desc: "increased movement speed",
  7845. spdMult: 1.1
  7846. }, {
  7847. id: 18,
  7848. name: "Blood Wings",
  7849. price: 20000,
  7850. scale: 178,
  7851. xOff: 26,
  7852. desc: "restores health when you deal damage",
  7853. healD: 0.2
  7854. }, {
  7855. id: 21,
  7856. name: "Corrupt X Wings",
  7857. price: 20000,
  7858. scale: 178,
  7859. xOff: 26,
  7860. desc: "deal damage to players that damage you",
  7861. dmg: 0.25
  7862. }];
  7863. const Zo = {
  7864. hats: Yh,
  7865. accessories: Kh
  7866. };
  7867. function Zh(e, t, i, n, s, r, o) {
  7868. this.init = function (a, f, d, u, p, w, x, b, $) {
  7869. this.active = true;
  7870. this.indx = a;
  7871. this.x = f;
  7872. this.y = d;
  7873. this.dir = u;
  7874. this.skipMov = true;
  7875. this.speed = p;
  7876. this.dmg = w;
  7877. this.scale = b;
  7878. this.range = x;
  7879. this.owner = $;
  7880. if (o) {
  7881. this.sentTo = {};
  7882. }
  7883. };
  7884. const l = [];
  7885. let c;
  7886. this.update = function (a) {
  7887. if (this.active) {
  7888. let d = this.speed * a;
  7889. let u;
  7890. if (this.skipMov) {
  7891. this.skipMov = false;
  7892. } else {
  7893. this.x += d * Math.cos(this.dir);
  7894. this.y += d * Math.sin(this.dir);
  7895. this.range -= d;
  7896. if (this.range <= 0) {
  7897. this.x += this.range * Math.cos(this.dir);
  7898. this.y += this.range * Math.sin(this.dir);
  7899. d = 1;
  7900. this.range = 0;
  7901. this.active = false;
  7902. }
  7903. }
  7904. if (o) {
  7905. for (var f = 0; f < e.length; ++f) {
  7906. if (!this.sentTo[e[f].id] && e[f].canSee(this)) {
  7907. this.sentTo[e[f].id] = 1;
  7908. o.send(e[f].id, "X", r.fixTo(this.x, 1), r.fixTo(this.y, 1), r.fixTo(this.dir, 2), r.fixTo(this.range, 1), this.speed, this.indx, this.layer, this.sid);
  7909. }
  7910. }
  7911. l.length = 0;
  7912. for (var f = 0; f < e.length + t.length; ++f) {
  7913. c = e[f] || t[f - e.length];
  7914. if (c.alive && c != this.owner && !(this.owner.team && c.team == this.owner.team) && r.lineInRect(c.x - c.scale, c.y - c.scale, c.x + c.scale, c.y + c.scale, this.x, this.y, this.x + d * Math.cos(this.dir), this.y + d * Math.sin(this.dir))) {
  7915. l.push(c);
  7916. }
  7917. }
  7918. const p = i.getGridArrays(this.x, this.y, this.scale);
  7919. for (let w = 0; w < p.length; ++w) {
  7920. for (let x = 0; x < p[w].length; ++x) {
  7921. c = p[w][x];
  7922. u = c.getScale();
  7923. if (c.active && this.ignoreObj != c.sid && this.layer <= c.layer && l.indexOf(c) < 0 && !c.ignoreCollision && r.lineInRect(c.x - u, c.y - u, c.x + u, c.y + u, this.x, this.y, this.x + d * Math.cos(this.dir), this.y + d * Math.sin(this.dir))) {
  7924. l.push(c);
  7925. }
  7926. }
  7927. }
  7928. if (l.length > 0) {
  7929. let w = null;
  7930. let x = null;
  7931. let b = null;
  7932. for (var f = 0; f < l.length; ++f) {
  7933. b = r.getDistance(this.x, this.y, l[f].x, l[f].y);
  7934. if (x == null || b < x) {
  7935. x = b;
  7936. w = l[f];
  7937. }
  7938. }
  7939. if (w.isPlayer || w.isAI) {
  7940. const $ = (w.weightM || 1) * 0.3;
  7941. w.xVel += $ * Math.cos(this.dir);
  7942. w.yVel += $ * Math.sin(this.dir);
  7943. if (w.weaponIndex == null || !(n.weapons[w.weaponIndex].shield && r.getAngleDist(this.dir + Math.PI, w.dir) <= s.shieldAngle)) {
  7944. w.changeHealth(-this.dmg, this.owner, this.owner);
  7945. }
  7946. } else {
  7947. if (w.projDmg && w.health && w.changeHealth(-this.dmg)) {
  7948. i.disableObj(w);
  7949. }
  7950. for (var f = 0; f < e.length; ++f) {
  7951. if (e[f].active) {
  7952. if (w.sentTo[e[f].id]) {
  7953. if (w.active) {
  7954. if (e[f].canSee(w)) {
  7955. o.send(e[f].id, "L", r.fixTo(this.dir, 2), w.sid);
  7956. }
  7957. } else {
  7958. o.send(e[f].id, "Q", w.sid);
  7959. }
  7960. }
  7961. if (!w.active && w.owner == e[f]) {
  7962. e[f].changeItemCount(w.group.id, -1);
  7963. }
  7964. }
  7965. }
  7966. }
  7967. this.active = false;
  7968. for (var f = 0; f < e.length; ++f) {
  7969. if (this.sentTo[e[f].id]) {
  7970. o.send(e[f].id, "Y", this.sid, r.fixTo(x, 1));
  7971. }
  7972. }
  7973. }
  7974. }
  7975. }
  7976. };
  7977. }
  7978. var Jo = {
  7979. exports: {}
  7980. };
  7981. var Qo = {
  7982. exports: {}
  7983. };
  7984. (function () {
  7985. var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  7986. var t = {
  7987. rotl: function (i, n) {
  7988. return i << n | i >>> 32 - n;
  7989. },
  7990. rotr: function (i, n) {
  7991. return i << 32 - n | i >>> n;
  7992. },
  7993. endian: function (i) {
  7994. if (i.constructor == Number) {
  7995. return t.rotl(i, 8) & 16711935 | t.rotl(i, 24) & 4278255360;
  7996. }
  7997. for (var n = 0; n < i.length; n++) {
  7998. i[n] = t.endian(i[n]);
  7999. }
  8000. return i;
  8001. },
  8002. randomBytes: function (i) {
  8003. for (var n = []; i > 0; i--) {
  8004. n.push(Math.floor(Math.random() * 256));
  8005. }
  8006. return n;
  8007. },
  8008. bytesToWords: function (i) {
  8009. for (var n = [], s = 0, r = 0; s < i.length; s++, r += 8) {
  8010. n[r >>> 5] |= i[s] << 24 - r % 32;
  8011. }
  8012. return n;
  8013. },
  8014. wordsToBytes: function (i) {
  8015. for (var n = [], s = 0; s < i.length * 32; s += 8) {
  8016. n.push(i[s >>> 5] >>> 24 - s % 32 & 255);
  8017. }
  8018. return n;
  8019. },
  8020. bytesToHex: function (i) {
  8021. for (var n = [], s = 0; s < i.length; s++) {
  8022. n.push((i[s] >>> 4).toString(16));
  8023. n.push((i[s] & 15).toString(16));
  8024. }
  8025. return n.join("");
  8026. },
  8027. hexToBytes: function (i) {
  8028. for (var n = [], s = 0; s < i.length; s += 2) {
  8029. n.push(parseInt(i.substr(s, 2), 16));
  8030. }
  8031. return n;
  8032. },
  8033. bytesToBase64: function (i) {
  8034. for (var n = [], s = 0; s < i.length; s += 3) {
  8035. for (var r = i[s] << 16 | i[s + 1] << 8 | i[s + 2], o = 0; o < 4; o++) {
  8036. if (s * 8 + o * 6 <= i.length * 8) {
  8037. n.push(e.charAt(r >>> (3 - o) * 6 & 63));
  8038. } else {
  8039. n.push("=");
  8040. }
  8041. }
  8042. }
  8043. return n.join("");
  8044. },
  8045. base64ToBytes: function (i) {
  8046. i = i.replace(/[^A-Z0-9+\/]/ig, "");
  8047. for (var n = [], s = 0, r = 0; s < i.length; r = ++s % 4) {
  8048. if (r != 0) {
  8049. n.push((e.indexOf(i.charAt(s - 1)) & Math.pow(2, r * -2 + 8) - 1) << r * 2 | e.indexOf(i.charAt(s)) >>> 6 - r * 2);
  8050. }
  8051. }
  8052. return n;
  8053. }
  8054. };
  8055. Qo.exports = t;
  8056. })();
  8057. var Jh = Qo.exports;
  8058. var Es = {
  8059. utf8: {
  8060. stringToBytes: function (e) {
  8061. return Es.bin.stringToBytes(unescape(encodeURIComponent(e)));
  8062. },
  8063. bytesToString: function (e) {
  8064. return decodeURIComponent(escape(Es.bin.bytesToString(e)));
  8065. }
  8066. },
  8067. bin: {
  8068. stringToBytes: function (e) {
  8069. for (var t = [], i = 0; i < e.length; i++) {
  8070. t.push(e.charCodeAt(i) & 255);
  8071. }
  8072. return t;
  8073. },
  8074. bytesToString: function (e) {
  8075. for (var t = [], i = 0; i < e.length; i++) {
  8076. t.push(String.fromCharCode(e[i]));
  8077. }
  8078. return t.join("");
  8079. }
  8080. }
  8081. };
  8082. var Mr = Es;
  8083. /*!
  8084. * Determine if an object is a Buffer
  8085. *
  8086. * @author Feross Aboukhadijeh <https://feross.org>
  8087. * @license MIT
  8088. */
  8089. function Qh(e) {
  8090. return e != null && (jo(e) || jh(e) || !!e._isBuffer);
  8091. }
  8092. function jo(e) {
  8093. return !!e.constructor && typeof e.constructor.isBuffer == "function" && e.constructor.isBuffer(e);
  8094. }
  8095. function jh(e) {
  8096. return typeof e.readFloatLE == "function" && typeof e.slice == "function" && jo(e.slice(0, 0));
  8097. }
  8098. (function () {
  8099. var e = Jh;
  8100. var t = Mr.utf8;
  8101. var i = Qh;
  8102. var n = Mr.bin;
  8103. function s(r, o) {
  8104. if (r.constructor == String) {
  8105. if (o && o.encoding === "binary") {
  8106. r = n.stringToBytes(r);
  8107. } else {
  8108. r = t.stringToBytes(r);
  8109. }
  8110. } else if (i(r)) {
  8111. r = Array.prototype.slice.call(r, 0);
  8112. } else if (!Array.isArray(r) && r.constructor !== Uint8Array) {
  8113. r = r.toString();
  8114. }
  8115. for (var l = e.bytesToWords(r), c = r.length * 8, a = 1732584193, f = -271733879, d = -1732584194, u = 271733878, p = 0; p < l.length; p++) {
  8116. l[p] = (l[p] << 8 | l[p] >>> 24) & 16711935 | (l[p] << 24 | l[p] >>> 8) & 4278255360;
  8117. }
  8118. l[c >>> 5] |= 128 << c % 32;
  8119. l[(c + 64 >>> 9 << 4) + 14] = c;
  8120. for (var w = s._ff, x = s._gg, b = s._hh, $ = s._ii, p = 0; p < l.length; p += 16) {
  8121. var v = a;
  8122. var S = f;
  8123. var R = d;
  8124. var G = u;
  8125. a = w(a, f, d, u, l[p + 0], 7, -680876936);
  8126. u = w(u, a, f, d, l[p + 1], 12, -389564586);
  8127. d = w(d, u, a, f, l[p + 2], 17, 606105819);
  8128. f = w(f, d, u, a, l[p + 3], 22, -1044525330);
  8129. a = w(a, f, d, u, l[p + 4], 7, -176418897);
  8130. u = w(u, a, f, d, l[p + 5], 12, 1200080426);
  8131. d = w(d, u, a, f, l[p + 6], 17, -1473231341);
  8132. f = w(f, d, u, a, l[p + 7], 22, -45705983);
  8133. a = w(a, f, d, u, l[p + 8], 7, 1770035416);
  8134. u = w(u, a, f, d, l[p + 9], 12, -1958414417);
  8135. d = w(d, u, a, f, l[p + 10], 17, -42063);
  8136. f = w(f, d, u, a, l[p + 11], 22, -1990404162);
  8137. a = w(a, f, d, u, l[p + 12], 7, 1804603682);
  8138. u = w(u, a, f, d, l[p + 13], 12, -40341101);
  8139. d = w(d, u, a, f, l[p + 14], 17, -1502002290);
  8140. f = w(f, d, u, a, l[p + 15], 22, 1236535329);
  8141. a = x(a, f, d, u, l[p + 1], 5, -165796510);
  8142. u = x(u, a, f, d, l[p + 6], 9, -1069501632);
  8143. d = x(d, u, a, f, l[p + 11], 14, 643717713);
  8144. f = x(f, d, u, a, l[p + 0], 20, -373897302);
  8145. a = x(a, f, d, u, l[p + 5], 5, -701558691);
  8146. u = x(u, a, f, d, l[p + 10], 9, 38016083);
  8147. d = x(d, u, a, f, l[p + 15], 14, -660478335);
  8148. f = x(f, d, u, a, l[p + 4], 20, -405537848);
  8149. a = x(a, f, d, u, l[p + 9], 5, 568446438);
  8150. u = x(u, a, f, d, l[p + 14], 9, -1019803690);
  8151. d = x(d, u, a, f, l[p + 3], 14, -187363961);
  8152. f = x(f, d, u, a, l[p + 8], 20, 1163531501);
  8153. a = x(a, f, d, u, l[p + 13], 5, -1444681467);
  8154. u = x(u, a, f, d, l[p + 2], 9, -51403784);
  8155. d = x(d, u, a, f, l[p + 7], 14, 1735328473);
  8156. f = x(f, d, u, a, l[p + 12], 20, -1926607734);
  8157. a = b(a, f, d, u, l[p + 5], 4, -378558);
  8158. u = b(u, a, f, d, l[p + 8], 11, -2022574463);
  8159. d = b(d, u, a, f, l[p + 11], 16, 1839030562);
  8160. f = b(f, d, u, a, l[p + 14], 23, -35309556);
  8161. a = b(a, f, d, u, l[p + 1], 4, -1530992060);
  8162. u = b(u, a, f, d, l[p + 4], 11, 1272893353);
  8163. d = b(d, u, a, f, l[p + 7], 16, -155497632);
  8164. f = b(f, d, u, a, l[p + 10], 23, -1094730640);
  8165. a = b(a, f, d, u, l[p + 13], 4, 681279174);
  8166. u = b(u, a, f, d, l[p + 0], 11, -358537222);
  8167. d = b(d, u, a, f, l[p + 3], 16, -722521979);
  8168. f = b(f, d, u, a, l[p + 6], 23, 76029189);
  8169. a = b(a, f, d, u, l[p + 9], 4, -640364487);
  8170. u = b(u, a, f, d, l[p + 12], 11, -421815835);
  8171. d = b(d, u, a, f, l[p + 15], 16, 530742520);
  8172. f = b(f, d, u, a, l[p + 2], 23, -995338651);
  8173. a = $(a, f, d, u, l[p + 0], 6, -198630844);
  8174. u = $(u, a, f, d, l[p + 7], 10, 1126891415);
  8175. d = $(d, u, a, f, l[p + 14], 15, -1416354905);
  8176. f = $(f, d, u, a, l[p + 5], 21, -57434055);
  8177. a = $(a, f, d, u, l[p + 12], 6, 1700485571);
  8178. u = $(u, a, f, d, l[p + 3], 10, -1894986606);
  8179. d = $(d, u, a, f, l[p + 10], 15, -1051523);
  8180. f = $(f, d, u, a, l[p + 1], 21, -2054922799);
  8181. a = $(a, f, d, u, l[p + 8], 6, 1873313359);
  8182. u = $(u, a, f, d, l[p + 15], 10, -30611744);
  8183. d = $(d, u, a, f, l[p + 6], 15, -1560198380);
  8184. f = $(f, d, u, a, l[p + 13], 21, 1309151649);
  8185. a = $(a, f, d, u, l[p + 4], 6, -145523070);
  8186. u = $(u, a, f, d, l[p + 11], 10, -1120210379);
  8187. d = $(d, u, a, f, l[p + 2], 15, 718787259);
  8188. f = $(f, d, u, a, l[p + 9], 21, -343485551);
  8189. a = a + v >>> 0;
  8190. f = f + S >>> 0;
  8191. d = d + R >>> 0;
  8192. u = u + G >>> 0;
  8193. }
  8194. return e.endian([a, f, d, u]);
  8195. }
  8196. s._ff = function (r, o, l, c, a, f, d) {
  8197. var u = r + (o & l | ~o & c) + (a >>> 0) + d;
  8198. return (u << f | u >>> 32 - f) + o;
  8199. };
  8200. s._gg = function (r, o, l, c, a, f, d) {
  8201. var u = r + (o & c | l & ~c) + (a >>> 0) + d;
  8202. return (u << f | u >>> 32 - f) + o;
  8203. };
  8204. s._hh = function (r, o, l, c, a, f, d) {
  8205. var u = r + (o ^ l ^ c) + (a >>> 0) + d;
  8206. return (u << f | u >>> 32 - f) + o;
  8207. };
  8208. s._ii = function (r, o, l, c, a, f, d) {
  8209. var u = r + (l ^ (o | ~c)) + (a >>> 0) + d;
  8210. return (u << f | u >>> 32 - f) + o;
  8211. };
  8212. s._blocksize = 16;
  8213. s._digestsize = 16;
  8214. Jo.exports = function (r, o) {
  8215. if (r == null) {
  8216. throw new Error("Illegal argument " + r);
  8217. }
  8218. var l = e.wordsToBytes(s(r, o));
  8219. if (o && o.asBytes) {
  8220. return l;
  8221. } else if (o && o.asString) {
  8222. return n.bytesToString(l);
  8223. } else {
  8224. return e.bytesToHex(l);
  8225. }
  8226. };
  8227. })();
  8228. var eu = Jo.exports;
  8229. const tu = An(eu);
  8230. var Yn;
  8231. var Er;
  8232. function It() {
  8233. if (Er) {
  8234. return Yn;
  8235. }
  8236. Er = 1;
  8237. function e(t, i, n, s, r, o) {
  8238. return {
  8239. tag: t,
  8240. key: i,
  8241. attrs: n,
  8242. children: s,
  8243. text: r,
  8244. dom: o,
  8245. domSize: undefined,
  8246. state: undefined,
  8247. events: undefined,
  8248. instance: undefined
  8249. };
  8250. }
  8251. e.normalize = function (t) {
  8252. if (Array.isArray(t)) {
  8253. return e("[", undefined, undefined, e.normalizeChildren(t), undefined, undefined);
  8254. } else if (t == null || typeof t == "boolean") {
  8255. return null;
  8256. } else if (typeof t == "object") {
  8257. return t;
  8258. } else {
  8259. return e("#", undefined, undefined, String(t), undefined, undefined);
  8260. }
  8261. };
  8262. e.normalizeChildren = function (t) {
  8263. var i = [];
  8264. if (t.length) {
  8265. for (var n = t[0] != null && t[0].key != null, s = 1; s < t.length; s++) {
  8266. if ((t[s] != null && t[s].key != null) !== n) {
  8267. throw new TypeError(n && (t[s] != null || typeof t[s] == "boolean") ? "In fragments, vnodes must either all have keys or none have keys. You may wish to consider using an explicit keyed empty fragment, m.fragment({key: ...}), instead of a hole." : "In fragments, vnodes must either all have keys or none have keys.");
  8268. }
  8269. }
  8270. for (var s = 0; s < t.length; s++) {
  8271. i[s] = e.normalize(t[s]);
  8272. }
  8273. }
  8274. return i;
  8275. };
  8276. Yn = e;
  8277. return Yn;
  8278. }
  8279. var iu = It();
  8280. function ea() {
  8281. var e = arguments[this];
  8282. var t = this + 1;
  8283. var i;
  8284. if (e == null) {
  8285. e = {};
  8286. } else if (typeof e != "object" || e.tag != null || Array.isArray(e)) {
  8287. e = {};
  8288. t = this;
  8289. }
  8290. if (arguments.length === t + 1) {
  8291. i = arguments[t];
  8292. if (!Array.isArray(i)) {
  8293. i = [i];
  8294. }
  8295. } else {
  8296. for (i = []; t < arguments.length;) {
  8297. i.push(arguments[t++]);
  8298. }
  8299. }
  8300. return iu("", e.key, e, i);
  8301. }
  8302. var Dn = {}.hasOwnProperty;
  8303. var nu = It();
  8304. var su = ea;
  8305. var Jt = Dn;
  8306. var ru = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g;
  8307. var ta = {};
  8308. function Cr(e) {
  8309. for (var t in e) {
  8310. if (Jt.call(e, t)) {
  8311. return false;
  8312. }
  8313. }
  8314. return true;
  8315. }
  8316. function ou(e) {
  8317. for (var t, i = "div", n = [], s = {}; t = ru.exec(e);) {
  8318. var r = t[1];
  8319. var o = t[2];
  8320. if (r === "" && o !== "") {
  8321. i = o;
  8322. } else if (r === "#") {
  8323. s.id = o;
  8324. } else if (r === ".") {
  8325. n.push(o);
  8326. } else if (t[3][0] === "[") {
  8327. var l = t[6];
  8328. if (l) {
  8329. l = l.replace(/\\(["'])/g, "$1").replace(/\\\\/g, "\\");
  8330. }
  8331. if (t[4] === "class") {
  8332. n.push(l);
  8333. } else {
  8334. s[t[4]] = l === "" ? l : l || true;
  8335. }
  8336. }
  8337. }
  8338. if (n.length > 0) {
  8339. s.className = n.join(" ");
  8340. }
  8341. return ta[e] = {
  8342. tag: i,
  8343. attrs: s
  8344. };
  8345. }
  8346. function au(e, t) {
  8347. var i = t.attrs;
  8348. var n = Jt.call(i, "class");
  8349. var s = n ? i.class : i.className;
  8350. t.tag = e.tag;
  8351. t.attrs = {};
  8352. if (!Cr(e.attrs) && !Cr(i)) {
  8353. var r = {};
  8354. for (var o in i) {
  8355. if (Jt.call(i, o)) {
  8356. r[o] = i[o];
  8357. }
  8358. }
  8359. i = r;
  8360. }
  8361. for (var o in e.attrs) {
  8362. if (Jt.call(e.attrs, o) && o !== "className" && !Jt.call(i, o)) {
  8363. i[o] = e.attrs[o];
  8364. }
  8365. }
  8366. if (s != null || e.attrs.className != null) {
  8367. i.className = s != null ? e.attrs.className != null ? String(e.attrs.className) + " " + String(s) : s : e.attrs.className != null ? e.attrs.className : null;
  8368. }
  8369. if (n) {
  8370. i.class = null;
  8371. }
  8372. for (var o in i) {
  8373. if (Jt.call(i, o) && o !== "key") {
  8374. t.attrs = i;
  8375. break;
  8376. }
  8377. }
  8378. return t;
  8379. }
  8380. function lu(e) {
  8381. if (e == null || typeof e != "string" && typeof e != "function" && typeof e.view != "function") {
  8382. throw Error("The selector must be either a string or a component.");
  8383. }
  8384. var t = su.apply(1, arguments);
  8385. if (typeof e == "string" && (t.children = nu.normalizeChildren(t.children), e !== "[")) {
  8386. return au(ta[e] || ou(e), t);
  8387. } else {
  8388. t.tag = e;
  8389. return t;
  8390. }
  8391. }
  8392. var ia = lu;
  8393. var cu = It();
  8394. function hu(e) {
  8395. if (e == null) {
  8396. e = "";
  8397. }
  8398. return cu("<", undefined, undefined, e, undefined, undefined);
  8399. }
  8400. var uu = It();
  8401. var fu = ea;
  8402. function du() {
  8403. var e = fu.apply(0, arguments);
  8404. e.tag = "[";
  8405. e.children = uu.normalizeChildren(e.children);
  8406. return e;
  8407. }
  8408. var Js = ia;
  8409. Js.trust = hu;
  8410. Js.fragment = du;
  8411. var pu = Js;
  8412. var cn = {
  8413. exports: {}
  8414. };
  8415. var Kn;
  8416. var Pr;
  8417. function na() {
  8418. if (Pr) {
  8419. return Kn;
  8420. }
  8421. Pr = 1;
  8422. function e(t) {
  8423. if (!(this instanceof e)) {
  8424. throw new Error("Promise must be called with 'new'.");
  8425. }
  8426. if (typeof t != "function") {
  8427. throw new TypeError("executor must be a function.");
  8428. }
  8429. var i = this;
  8430. var n = [];
  8431. var s = [];
  8432. var r = a(n, true);
  8433. var o = a(s, false);
  8434. var l = i._instance = {
  8435. resolvers: n,
  8436. rejectors: s
  8437. };
  8438. var c = typeof setImmediate == "function" ? setImmediate : setTimeout;
  8439. function a(d, u) {
  8440. return function p(w) {
  8441. var x;
  8442. try {
  8443. if (u && w != null && (typeof w == "object" || typeof w == "function") && typeof (x = w.then) == "function") {
  8444. if (w === i) {
  8445. throw new TypeError("Promise can't be resolved with itself.");
  8446. }
  8447. f(x.bind(w));
  8448. } else {
  8449. c(function () {
  8450. if (!u && d.length === 0) {
  8451. console.error("Possible unhandled promise rejection:", w);
  8452. }
  8453. for (var b = 0; b < d.length; b++) {
  8454. d[b](w);
  8455. }
  8456. n.length = 0;
  8457. s.length = 0;
  8458. l.state = u;
  8459. l.retry = function () {
  8460. p(w);
  8461. };
  8462. });
  8463. }
  8464. } catch (b) {
  8465. o(b);
  8466. }
  8467. };
  8468. }
  8469. function f(d) {
  8470. var u = 0;
  8471. function p(x) {
  8472. return function (b) {
  8473. if (!(u++ > 0)) {
  8474. x(b);
  8475. }
  8476. };
  8477. }
  8478. var w = p(o);
  8479. try {
  8480. d(p(r), w);
  8481. } catch (x) {
  8482. w(x);
  8483. }
  8484. }
  8485. f(t);
  8486. }
  8487. e.prototype.then = function (t, i) {
  8488. var n = this;
  8489. var s = n._instance;
  8490. function r(a, f, d, u) {
  8491. f.push(function (p) {
  8492. if (typeof a != "function") {
  8493. d(p);
  8494. } else {
  8495. try {
  8496. o(a(p));
  8497. } catch (w) {
  8498. if (l) {
  8499. l(w);
  8500. }
  8501. }
  8502. }
  8503. });
  8504. if (typeof s.retry == "function" && u === s.state) {
  8505. s.retry();
  8506. }
  8507. }
  8508. var o;
  8509. var l;
  8510. var c = new e(function (a, f) {
  8511. o = a;
  8512. l = f;
  8513. });
  8514. r(t, s.resolvers, o, true);
  8515. r(i, s.rejectors, l, false);
  8516. return c;
  8517. };
  8518. e.prototype.catch = function (t) {
  8519. return this.then(null, t);
  8520. };
  8521. e.prototype.finally = function (t) {
  8522. return this.then(function (i) {
  8523. return e.resolve(t()).then(function () {
  8524. return i;
  8525. });
  8526. }, function (i) {
  8527. return e.resolve(t()).then(function () {
  8528. return e.reject(i);
  8529. });
  8530. });
  8531. };
  8532. e.resolve = function (t) {
  8533. if (t instanceof e) {
  8534. return t;
  8535. } else {
  8536. return new e(function (i) {
  8537. i(t);
  8538. });
  8539. }
  8540. };
  8541. e.reject = function (t) {
  8542. return new e(function (i, n) {
  8543. n(t);
  8544. });
  8545. };
  8546. e.all = function (t) {
  8547. return new e(function (i, n) {
  8548. var s = t.length;
  8549. var r = 0;
  8550. var o = [];
  8551. if (t.length === 0) {
  8552. i([]);
  8553. } else {
  8554. for (var l = 0; l < t.length; l++) {
  8555. (function (c) {
  8556. function a(f) {
  8557. r++;
  8558. o[c] = f;
  8559. if (r === s) {
  8560. i(o);
  8561. }
  8562. }
  8563. if (t[c] != null && (typeof t[c] == "object" || typeof t[c] == "function") && typeof t[c].then == "function") {
  8564. t[c].then(a, n);
  8565. } else {
  8566. a(t[c]);
  8567. }
  8568. })(l);
  8569. }
  8570. }
  8571. });
  8572. };
  8573. e.race = function (t) {
  8574. return new e(function (i, n) {
  8575. for (var s = 0; s < t.length; s++) {
  8576. t[s].then(i, n);
  8577. }
  8578. });
  8579. };
  8580. Kn = e;
  8581. return Kn;
  8582. }
  8583. var Ei = na();
  8584. if (typeof window !== "undefined") {
  8585. if (typeof window.Promise === "undefined") {
  8586. window.Promise = Ei;
  8587. } else if (!window.Promise.prototype.finally) {
  8588. window.Promise.prototype.finally = Ei.prototype.finally;
  8589. }
  8590. cn.exports = window.Promise;
  8591. } else if (typeof Vt !== "undefined") {
  8592. if (typeof Vt.Promise === "undefined") {
  8593. Vt.Promise = Ei;
  8594. } else if (!Vt.Promise.prototype.finally) {
  8595. Vt.Promise.prototype.finally = Ei.prototype.finally;
  8596. }
  8597. cn.exports = Vt.Promise;
  8598. } else {
  8599. cn.exports = Ei;
  8600. }
  8601. var sa = cn.exports;
  8602. var Zn = It();
  8603. function mu(e) {
  8604. var t = e && e.document;
  8605. var i;
  8606. var n = {
  8607. svg: "http://www.w3.org/2000/svg",
  8608. math: "http://www.w3.org/1998/Math/MathML"
  8609. };
  8610. function s(m) {
  8611. return m.attrs && m.attrs.xmlns || n[m.tag];
  8612. }
  8613. function r(m, h) {
  8614. if (m.state !== h) {
  8615. throw new Error("'vnode.state' must not be modified.");
  8616. }
  8617. }
  8618. function o(m) {
  8619. var h = m.state;
  8620. try {
  8621. return this.apply(h, arguments);
  8622. } finally {
  8623. r(m, h);
  8624. }
  8625. }
  8626. function l() {
  8627. try {
  8628. return t.activeElement;
  8629. } catch {
  8630. return null;
  8631. }
  8632. }
  8633. function c(m, h, g, I, E, O, q) {
  8634. for (var Z = g; Z < I; Z++) {
  8635. var U = h[Z];
  8636. if (U != null) {
  8637. a(m, U, E, q, O);
  8638. }
  8639. }
  8640. }
  8641. function a(m, h, g, I, E) {
  8642. var O = h.tag;
  8643. if (typeof O == "string") {
  8644. h.state = {};
  8645. if (h.attrs != null) {
  8646. yi(h.attrs, h, g);
  8647. }
  8648. switch (O) {
  8649. case "#":
  8650. f(m, h, E);
  8651. break;
  8652. case "<":
  8653. u(m, h, I, E);
  8654. break;
  8655. case "[":
  8656. p(m, h, g, I, E);
  8657. break;
  8658. default:
  8659. w(m, h, g, I, E);
  8660. }
  8661. } else {
  8662. b(m, h, g, I, E);
  8663. }
  8664. }
  8665. function f(m, h, g) {
  8666. h.dom = t.createTextNode(h.children);
  8667. N(m, h.dom, g);
  8668. }
  8669. var d = {
  8670. caption: "table",
  8671. thead: "table",
  8672. tbody: "table",
  8673. tfoot: "table",
  8674. tr: "tbody",
  8675. th: "tr",
  8676. td: "tr",
  8677. colgroup: "table",
  8678. col: "colgroup"
  8679. };
  8680. function u(m, h, g, I) {
  8681. var E = h.children.match(/^\s*?<(\w+)/im) || [];
  8682. var O = t.createElement(d[E[1]] || "div");
  8683. if (g === "http://www.w3.org/2000/svg") {
  8684. O.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\">" + h.children + "</svg>";
  8685. O = O.firstChild;
  8686. } else {
  8687. O.innerHTML = h.children;
  8688. }
  8689. h.dom = O.firstChild;
  8690. h.domSize = O.childNodes.length;
  8691. h.instance = [];
  8692. for (var q = t.createDocumentFragment(), Z; Z = O.firstChild;) {
  8693. h.instance.push(Z);
  8694. q.appendChild(Z);
  8695. }
  8696. N(m, q, I);
  8697. }
  8698. function p(m, h, g, I, E) {
  8699. var O = t.createDocumentFragment();
  8700. if (h.children != null) {
  8701. var q = h.children;
  8702. c(O, q, 0, q.length, g, null, I);
  8703. }
  8704. h.dom = O.firstChild;
  8705. h.domSize = O.childNodes.length;
  8706. N(m, O, E);
  8707. }
  8708. function w(m, h, g, I, E) {
  8709. var O = h.tag;
  8710. var q = h.attrs;
  8711. var Z = q && q.is;
  8712. I = s(h) || I;
  8713. var U = I ? Z ? t.createElementNS(I, O, {
  8714. is: Z
  8715. }) : t.createElementNS(I, O) : Z ? t.createElement(O, {
  8716. is: Z
  8717. }) : t.createElement(O);
  8718. h.dom = U;
  8719. if (q != null) {
  8720. zt(h, q, I);
  8721. }
  8722. N(m, U, E);
  8723. if (!Y(h) && h.children != null) {
  8724. var j = h.children;
  8725. c(U, j, 0, j.length, g, null, I);
  8726. if (h.tag === "select" && q != null) {
  8727. Be(h, q);
  8728. }
  8729. }
  8730. }
  8731. function x(m, h) {
  8732. var g;
  8733. if (typeof m.tag.view == "function") {
  8734. m.state = Object.create(m.tag);
  8735. g = m.state.view;
  8736. if (g.$$reentrantLock$$ != null) {
  8737. return;
  8738. }
  8739. g.$$reentrantLock$$ = true;
  8740. } else {
  8741. m.state = undefined;
  8742. g = m.tag;
  8743. if (g.$$reentrantLock$$ != null) {
  8744. return;
  8745. }
  8746. g.$$reentrantLock$$ = true;
  8747. m.state = m.tag.prototype != null && typeof m.tag.prototype.view == "function" ? new m.tag(m) : m.tag(m);
  8748. }
  8749. yi(m.state, m, h);
  8750. if (m.attrs != null) {
  8751. yi(m.attrs, m, h);
  8752. }
  8753. m.instance = Zn.normalize(o.call(m.state.view, m));
  8754. if (m.instance === m) {
  8755. throw Error("A view cannot return the vnode it received as argument");
  8756. }
  8757. g.$$reentrantLock$$ = null;
  8758. }
  8759. function b(m, h, g, I, E) {
  8760. x(h, g);
  8761. if (h.instance != null) {
  8762. a(m, h.instance, g, I, E);
  8763. h.dom = h.instance.dom;
  8764. h.domSize = h.dom != null ? h.instance.domSize : 0;
  8765. } else {
  8766. h.domSize = 0;
  8767. }
  8768. }
  8769. function $(m, h, g, I, E, O) {
  8770. if (!(h === g || h == null && g == null)) {
  8771. if (h == null || h.length === 0) {
  8772. c(m, g, 0, g.length, I, E, O);
  8773. } else if (g == null || g.length === 0) {
  8774. K(m, h, 0, h.length);
  8775. } else {
  8776. var q = h[0] != null && h[0].key != null;
  8777. var Z = g[0] != null && g[0].key != null;
  8778. var U = 0;
  8779. var j = 0;
  8780. if (!q) {
  8781. for (; j < h.length && h[j] == null;) {
  8782. j++;
  8783. }
  8784. }
  8785. if (!Z) {
  8786. for (; U < g.length && g[U] == null;) {
  8787. U++;
  8788. }
  8789. }
  8790. if (q !== Z) {
  8791. K(m, h, j, h.length);
  8792. c(m, g, U, g.length, I, E, O);
  8793. } else if (Z) {
  8794. for (var Ce = h.length - 1, pe = g.length - 1, Bt, be, ue, Ie, re, ki; Ce >= j && pe >= U && (Ie = h[Ce], re = g[pe], Ie.key === re.key);) {
  8795. if (Ie !== re) {
  8796. v(m, Ie, re, I, E, O);
  8797. }
  8798. if (re.dom != null) {
  8799. E = re.dom;
  8800. }
  8801. Ce--;
  8802. pe--;
  8803. }
  8804. for (; Ce >= j && pe >= U && (be = h[j], ue = g[U], be.key === ue.key);) {
  8805. j++;
  8806. U++;
  8807. if (be !== ue) {
  8808. v(m, be, ue, I, _(h, j, E), O);
  8809. }
  8810. }
  8811. for (; Ce >= j && pe >= U && !(U === pe || be.key !== re.key || Ie.key !== ue.key);) {
  8812. ki = _(h, j, E);
  8813. D(m, Ie, ki);
  8814. if (Ie !== ue) {
  8815. v(m, Ie, ue, I, ki, O);
  8816. }
  8817. if (++U <= --pe) {
  8818. D(m, be, E);
  8819. }
  8820. if (be !== re) {
  8821. v(m, be, re, I, E, O);
  8822. }
  8823. if (re.dom != null) {
  8824. E = re.dom;
  8825. }
  8826. j++;
  8827. Ce--;
  8828. Ie = h[Ce];
  8829. re = g[pe];
  8830. be = h[j];
  8831. ue = g[U];
  8832. }
  8833. for (; Ce >= j && pe >= U && Ie.key === re.key;) {
  8834. if (Ie !== re) {
  8835. v(m, Ie, re, I, E, O);
  8836. }
  8837. if (re.dom != null) {
  8838. E = re.dom;
  8839. }
  8840. Ce--;
  8841. pe--;
  8842. Ie = h[Ce];
  8843. re = g[pe];
  8844. }
  8845. if (U > pe) {
  8846. K(m, h, j, Ce + 1);
  8847. } else if (j > Ce) {
  8848. c(m, g, U, pe + 1, I, E, O);
  8849. } else {
  8850. var Mt = E;
  8851. var xi = pe - U + 1;
  8852. var gt = new Array(xi);
  8853. var Ht = 0;
  8854. var fe = 0;
  8855. var Lt = 2147483647;
  8856. var nt = 0;
  8857. var Bt;
  8858. var Ft;
  8859. for (fe = 0; fe < xi; fe++) {
  8860. gt[fe] = -1;
  8861. }
  8862. for (fe = pe; fe >= U; fe--) {
  8863. if (Bt == null) {
  8864. Bt = M(h, j, Ce + 1);
  8865. }
  8866. re = g[fe];
  8867. var st = Bt[re.key];
  8868. if (st != null) {
  8869. Lt = st < Lt ? st : -1;
  8870. gt[fe - U] = st;
  8871. Ie = h[st];
  8872. h[st] = null;
  8873. if (Ie !== re) {
  8874. v(m, Ie, re, I, E, O);
  8875. }
  8876. if (re.dom != null) {
  8877. E = re.dom;
  8878. }
  8879. nt++;
  8880. }
  8881. }
  8882. E = Mt;
  8883. if (nt !== Ce - j + 1) {
  8884. K(m, h, j, Ce + 1);
  8885. }
  8886. if (nt === 0) {
  8887. c(m, g, U, pe + 1, I, E, O);
  8888. } else if (Lt === -1) {
  8889. Ft = F(gt);
  8890. Ht = Ft.length - 1;
  8891. fe = pe;
  8892. Ft = F(gt);
  8893. Ht = Ft.length - 1;
  8894. fe = pe;
  8895. for (; fe >= U; fe--) {
  8896. ue = g[fe];
  8897. if (gt[fe - U] === -1) {
  8898. a(m, ue, I, O, E);
  8899. } else if (Ft[Ht] === fe - U) {
  8900. Ht--;
  8901. } else {
  8902. D(m, ue, E);
  8903. }
  8904. if (ue.dom != null) {
  8905. E = g[fe].dom;
  8906. }
  8907. }
  8908. } else {
  8909. for (fe = pe; fe >= U; fe--) {
  8910. ue = g[fe];
  8911. if (gt[fe - U] === -1) {
  8912. a(m, ue, I, O, E);
  8913. }
  8914. if (ue.dom != null) {
  8915. E = g[fe].dom;
  8916. }
  8917. }
  8918. }
  8919. }
  8920. } else {
  8921. var vi = h.length < g.length ? h.length : g.length;
  8922. for (U = U < j ? U : j; U < vi; U++) {
  8923. be = h[U];
  8924. ue = g[U];
  8925. if (!(be === ue || be == null && ue == null)) {
  8926. if (be == null) {
  8927. a(m, ue, I, O, _(h, U + 1, E));
  8928. } else if (ue == null) {
  8929. ie(m, be);
  8930. } else {
  8931. v(m, be, ue, I, _(h, U + 1, E), O);
  8932. }
  8933. }
  8934. }
  8935. if (h.length > vi) {
  8936. K(m, h, U, h.length);
  8937. }
  8938. if (g.length > vi) {
  8939. c(m, g, U, g.length, I, E, O);
  8940. }
  8941. }
  8942. }
  8943. }
  8944. }
  8945. function v(m, h, g, I, E, O) {
  8946. var q = h.tag;
  8947. var Z = g.tag;
  8948. if (q === Z) {
  8949. g.state = h.state;
  8950. g.events = h.events;
  8951. if (Ln(g, h)) {
  8952. return;
  8953. }
  8954. if (typeof q == "string") {
  8955. if (g.attrs != null) {
  8956. wi(g.attrs, g, I);
  8957. }
  8958. switch (q) {
  8959. case "#":
  8960. S(h, g);
  8961. break;
  8962. case "<":
  8963. R(m, h, g, O, E);
  8964. break;
  8965. case "[":
  8966. G(m, h, g, I, E, O);
  8967. break;
  8968. default:
  8969. X(h, g, I, O);
  8970. }
  8971. } else {
  8972. W(m, h, g, I, E, O);
  8973. }
  8974. } else {
  8975. ie(m, h);
  8976. a(m, g, I, O, E);
  8977. }
  8978. }
  8979. function S(m, h) {
  8980. if (m.children.toString() !== h.children.toString()) {
  8981. m.dom.nodeValue = h.children;
  8982. }
  8983. h.dom = m.dom;
  8984. }
  8985. function R(m, h, g, I, E) {
  8986. if (h.children !== g.children) {
  8987. ae(m, h);
  8988. u(m, g, I, E);
  8989. } else {
  8990. g.dom = h.dom;
  8991. g.domSize = h.domSize;
  8992. g.instance = h.instance;
  8993. }
  8994. }
  8995. function G(m, h, g, I, E, O) {
  8996. $(m, h.children, g.children, I, E, O);
  8997. var q = 0;
  8998. var Z = g.children;
  8999. g.dom = null;
  9000. if (Z != null) {
  9001. for (var U = 0; U < Z.length; U++) {
  9002. var j = Z[U];
  9003. if (j != null && j.dom != null) {
  9004. if (g.dom == null) {
  9005. g.dom = j.dom;
  9006. }
  9007. q += j.domSize || 1;
  9008. }
  9009. }
  9010. if (q !== 1) {
  9011. g.domSize = q;
  9012. }
  9013. }
  9014. }
  9015. function X(m, h, g, I) {
  9016. var E = h.dom = m.dom;
  9017. I = s(h) || I;
  9018. if (h.tag === "textarea" && h.attrs == null) {
  9019. h.attrs = {};
  9020. }
  9021. pt(h, m.attrs, h.attrs, I);
  9022. if (!Y(h)) {
  9023. $(E, m.children, h.children, g, null, I);
  9024. }
  9025. }
  9026. function W(m, h, g, I, E, O) {
  9027. g.instance = Zn.normalize(o.call(g.state.view, g));
  9028. if (g.instance === g) {
  9029. throw Error("A view cannot return the vnode it received as argument");
  9030. }
  9031. wi(g.state, g, I);
  9032. if (g.attrs != null) {
  9033. wi(g.attrs, g, I);
  9034. }
  9035. if (g.instance != null) {
  9036. if (h.instance == null) {
  9037. a(m, g.instance, I, O, E);
  9038. } else {
  9039. v(m, h.instance, g.instance, I, E, O);
  9040. }
  9041. g.dom = g.instance.dom;
  9042. g.domSize = g.instance.domSize;
  9043. } else if (h.instance != null) {
  9044. ie(m, h.instance);
  9045. g.dom = undefined;
  9046. g.domSize = 0;
  9047. } else {
  9048. g.dom = h.dom;
  9049. g.domSize = h.domSize;
  9050. }
  9051. }
  9052. function M(m, h, g) {
  9053. for (var I = Object.create(null); h < g; h++) {
  9054. var E = m[h];
  9055. if (E != null) {
  9056. var O = E.key;
  9057. if (O != null) {
  9058. I[O] = h;
  9059. }
  9060. }
  9061. }
  9062. return I;
  9063. }
  9064. var V = [];
  9065. function F(m) {
  9066. for (var h = [0], g = 0, I = 0, E = 0, O = V.length = m.length, E = 0; E < O; E++) {
  9067. V[E] = m[E];
  9068. }
  9069. for (var E = 0; E < O; ++E) {
  9070. if (m[E] !== -1) {
  9071. var q = h[h.length - 1];
  9072. if (m[q] < m[E]) {
  9073. V[E] = q;
  9074. h.push(E);
  9075. continue;
  9076. }
  9077. g = 0;
  9078. I = h.length - 1;
  9079. for (; g < I;) {
  9080. var Z = (g >>> 1) + (I >>> 1) + (g & I & 1);
  9081. if (m[h[Z]] < m[E]) {
  9082. g = Z + 1;
  9083. } else {
  9084. I = Z;
  9085. }
  9086. }
  9087. if (m[E] < m[h[g]]) {
  9088. if (g > 0) {
  9089. V[E] = h[g - 1];
  9090. }
  9091. h[g] = E;
  9092. }
  9093. }
  9094. }
  9095. g = h.length;
  9096. I = h[g - 1];
  9097. for (; g-- > 0;) {
  9098. h[g] = I;
  9099. I = V[I];
  9100. }
  9101. V.length = 0;
  9102. return h;
  9103. }
  9104. function _(m, h, g) {
  9105. for (; h < m.length; h++) {
  9106. if (m[h] != null && m[h].dom != null) {
  9107. return m[h].dom;
  9108. }
  9109. }
  9110. return g;
  9111. }
  9112. function D(m, h, g) {
  9113. var I = t.createDocumentFragment();
  9114. z(m, I, h);
  9115. N(m, I, g);
  9116. }
  9117. function z(m, h, g) {
  9118. for (; g.dom != null && g.dom.parentNode === m;) {
  9119. if (typeof g.tag != "string") {
  9120. g = g.instance;
  9121. if (g != null) {
  9122. continue;
  9123. }
  9124. } else if (g.tag === "<") {
  9125. for (var I = 0; I < g.instance.length; I++) {
  9126. h.appendChild(g.instance[I]);
  9127. }
  9128. } else if (g.tag !== "[") {
  9129. h.appendChild(g.dom);
  9130. } else if (g.children.length === 1) {
  9131. g = g.children[0];
  9132. if (g != null) {
  9133. continue;
  9134. }
  9135. } else {
  9136. for (var I = 0; I < g.children.length; I++) {
  9137. var E = g.children[I];
  9138. if (E != null) {
  9139. z(m, h, E);
  9140. }
  9141. }
  9142. }
  9143. break;
  9144. }
  9145. }
  9146. function N(m, h, g) {
  9147. if (g != null) {
  9148. m.insertBefore(h, g);
  9149. } else {
  9150. m.appendChild(h);
  9151. }
  9152. }
  9153. function Y(m) {
  9154. if (m.attrs == null || m.attrs.contenteditable == null && m.attrs.contentEditable == null) {
  9155. return false;
  9156. }
  9157. var h = m.children;
  9158. if (h != null && h.length === 1 && h[0].tag === "<") {
  9159. var g = h[0].children;
  9160. if (m.dom.innerHTML !== g) {
  9161. m.dom.innerHTML = g;
  9162. }
  9163. } else if (h != null && h.length !== 0) {
  9164. throw new Error("Child node of a contenteditable must be trusted.");
  9165. }
  9166. return true;
  9167. }
  9168. function K(m, h, g, I) {
  9169. for (var E = g; E < I; E++) {
  9170. var O = h[E];
  9171. if (O != null) {
  9172. ie(m, O);
  9173. }
  9174. }
  9175. }
  9176. function ie(m, h) {
  9177. var g = 0;
  9178. var I = h.state;
  9179. var E;
  9180. var O;
  9181. if (typeof h.tag != "string" && typeof h.state.onbeforeremove == "function") {
  9182. var q = o.call(h.state.onbeforeremove, h);
  9183. if (q != null && typeof q.then == "function") {
  9184. g = 1;
  9185. E = q;
  9186. }
  9187. }
  9188. if (h.attrs && typeof h.attrs.onbeforeremove == "function") {
  9189. var q = o.call(h.attrs.onbeforeremove, h);
  9190. if (q != null && typeof q.then == "function") {
  9191. g |= 2;
  9192. O = q;
  9193. }
  9194. }
  9195. r(h, I);
  9196. if (!g) {
  9197. Se(h);
  9198. J(m, h);
  9199. } else {
  9200. if (E != null) {
  9201. function Z() {
  9202. if (g & 1) {
  9203. g &= 2;
  9204. if (!g) {
  9205. U();
  9206. }
  9207. }
  9208. }
  9209. E.then(Z, Z);
  9210. }
  9211. if (O != null) {
  9212. function Z() {
  9213. if (g & 2) {
  9214. g &= 1;
  9215. if (!g) {
  9216. U();
  9217. }
  9218. }
  9219. }
  9220. O.then(Z, Z);
  9221. }
  9222. }
  9223. function U() {
  9224. r(h, I);
  9225. Se(h);
  9226. J(m, h);
  9227. }
  9228. }
  9229. function ae(m, h) {
  9230. for (var g = 0; g < h.instance.length; g++) {
  9231. m.removeChild(h.instance[g]);
  9232. }
  9233. }
  9234. function J(m, h) {
  9235. for (; h.dom != null && h.dom.parentNode === m;) {
  9236. if (typeof h.tag != "string") {
  9237. h = h.instance;
  9238. if (h != null) {
  9239. continue;
  9240. }
  9241. } else if (h.tag === "<") {
  9242. ae(m, h);
  9243. } else {
  9244. if (h.tag !== "[" && (m.removeChild(h.dom), !Array.isArray(h.children))) {
  9245. break;
  9246. }
  9247. if (h.children.length === 1) {
  9248. h = h.children[0];
  9249. if (h != null) {
  9250. continue;
  9251. }
  9252. } else {
  9253. for (var g = 0; g < h.children.length; g++) {
  9254. var I = h.children[g];
  9255. if (I != null) {
  9256. J(m, I);
  9257. }
  9258. }
  9259. }
  9260. }
  9261. break;
  9262. }
  9263. }
  9264. function Se(m) {
  9265. if (typeof m.tag != "string" && typeof m.state.onremove == "function") {
  9266. o.call(m.state.onremove, m);
  9267. }
  9268. if (m.attrs && typeof m.attrs.onremove == "function") {
  9269. o.call(m.attrs.onremove, m);
  9270. }
  9271. if (typeof m.tag != "string") {
  9272. if (m.instance != null) {
  9273. Se(m.instance);
  9274. }
  9275. } else {
  9276. var h = m.children;
  9277. if (Array.isArray(h)) {
  9278. for (var g = 0; g < h.length; g++) {
  9279. var I = h[g];
  9280. if (I != null) {
  9281. Se(I);
  9282. }
  9283. }
  9284. }
  9285. }
  9286. }
  9287. function zt(m, h, g) {
  9288. if (m.tag === "input" && h.type != null) {
  9289. m.dom.setAttribute("type", h.type);
  9290. }
  9291. var I = h != null && m.tag === "input" && h.type === "file";
  9292. for (var E in h) {
  9293. Ve(m, E, null, h[E], g, I);
  9294. }
  9295. }
  9296. function Ve(m, h, g, I, E, O) {
  9297. if (!(h === "key" || h === "is" || I == null || mt(h) || g === I && !ne(m, h) && typeof I != "object" || h === "type" && m.tag === "input")) {
  9298. if (h[0] === "o" && h[1] === "n") {
  9299. return gi(m, h, I);
  9300. }
  9301. if (h.slice(0, 6) === "xlink:") {
  9302. m.dom.setAttributeNS("http://www.w3.org/1999/xlink", h.slice(6), I);
  9303. } else if (h === "style") {
  9304. pi(m.dom, g, I);
  9305. } else if (Ne(m, h, E)) {
  9306. if (h === "value") {
  9307. if ((m.tag === "input" || m.tag === "textarea") && m.dom.value === "" + I && (O || m.dom === l()) || m.tag === "select" && g !== null && m.dom.value === "" + I || m.tag === "option" && g !== null && m.dom.value === "" + I) {
  9308. return;
  9309. }
  9310. if (O && "" + I != "") {
  9311. console.error("`value` is read-only on file inputs!");
  9312. return;
  9313. }
  9314. }
  9315. m.dom[h] = I;
  9316. } else if (typeof I == "boolean") {
  9317. if (I) {
  9318. m.dom.setAttribute(h, "");
  9319. } else {
  9320. m.dom.removeAttribute(h);
  9321. }
  9322. } else {
  9323. m.dom.setAttribute(h === "className" ? "class" : h, I);
  9324. }
  9325. }
  9326. }
  9327. function te(m, h, g, I) {
  9328. if (!(h === "key" || h === "is" || g == null || mt(h))) {
  9329. if (h[0] === "o" && h[1] === "n") {
  9330. gi(m, h, undefined);
  9331. } else if (h === "style") {
  9332. pi(m.dom, g, null);
  9333. } else if (Ne(m, h, I) && h !== "className" && h !== "title" && !(h === "value" && (m.tag === "option" || m.tag === "select" && m.dom.selectedIndex === -1 && m.dom === l())) && !(m.tag === "input" && h === "type")) {
  9334. m.dom[h] = null;
  9335. } else {
  9336. var E = h.indexOf(":");
  9337. if (E !== -1) {
  9338. h = h.slice(E + 1);
  9339. }
  9340. if (g !== false) {
  9341. m.dom.removeAttribute(h === "className" ? "class" : h);
  9342. }
  9343. }
  9344. }
  9345. }
  9346. function Be(m, h) {
  9347. if ("value" in h) {
  9348. if (h.value === null) {
  9349. if (m.dom.selectedIndex !== -1) {
  9350. m.dom.value = null;
  9351. }
  9352. } else {
  9353. var g = "" + h.value;
  9354. if (m.dom.value !== g || m.dom.selectedIndex === -1) {
  9355. m.dom.value = g;
  9356. }
  9357. }
  9358. }
  9359. if ("selectedIndex" in h) {
  9360. Ve(m, "selectedIndex", null, h.selectedIndex, undefined);
  9361. }
  9362. }
  9363. function pt(m, h, g, I) {
  9364. if (h && h === g) {
  9365. console.warn("Don't reuse attrs object, use new object for every redraw, this will throw in next major");
  9366. }
  9367. if (g != null) {
  9368. if (m.tag === "input" && g.type != null) {
  9369. m.dom.setAttribute("type", g.type);
  9370. }
  9371. var E = m.tag === "input" && g.type === "file";
  9372. for (var O in g) {
  9373. Ve(m, O, h && h[O], g[O], I, E);
  9374. }
  9375. }
  9376. var q;
  9377. if (h != null) {
  9378. for (var O in h) {
  9379. if ((q = h[O]) != null && (g == null || g[O] == null)) {
  9380. te(m, O, q, I);
  9381. }
  9382. }
  9383. }
  9384. }
  9385. function ne(m, h) {
  9386. return h === "value" || h === "checked" || h === "selectedIndex" || h === "selected" && m.dom === l() || m.tag === "option" && m.dom.parentNode === t.activeElement;
  9387. }
  9388. function mt(m) {
  9389. return m === "oninit" || m === "oncreate" || m === "onupdate" || m === "onremove" || m === "onbeforeremove" || m === "onbeforeupdate";
  9390. }
  9391. function Ne(m, h, g) {
  9392. return g === undefined && (m.tag.indexOf("-") > -1 || m.attrs != null && m.attrs.is || h !== "href" && h !== "list" && h !== "form" && h !== "width" && h !== "height") && h in m.dom;
  9393. }
  9394. var it = /[A-Z]/g;
  9395. function Ze(m) {
  9396. return "-" + m.toLowerCase();
  9397. }
  9398. function se(m) {
  9399. if (m[0] === "-" && m[1] === "-") {
  9400. return m;
  9401. } else if (m === "cssFloat") {
  9402. return "float";
  9403. } else {
  9404. return m.replace(it, Ze);
  9405. }
  9406. }
  9407. function pi(m, h, g) {
  9408. if (h !== g) {
  9409. if (g == null) {
  9410. m.style.cssText = "";
  9411. } else if (typeof g != "object") {
  9412. m.style.cssText = g;
  9413. } else if (h == null || typeof h != "object") {
  9414. m.style.cssText = "";
  9415. for (var I in g) {
  9416. var E = g[I];
  9417. if (E != null) {
  9418. m.style.setProperty(se(I), String(E));
  9419. }
  9420. }
  9421. } else {
  9422. for (var I in g) {
  9423. var E = g[I];
  9424. if (E != null && (E = String(E)) !== String(h[I])) {
  9425. m.style.setProperty(se(I), E);
  9426. }
  9427. }
  9428. for (var I in h) {
  9429. if (h[I] != null && g[I] == null) {
  9430. m.style.removeProperty(se(I));
  9431. }
  9432. }
  9433. }
  9434. }
  9435. }
  9436. function mi() {
  9437. this._ = i;
  9438. }
  9439. mi.prototype = Object.create(null);
  9440. mi.prototype.handleEvent = function (m) {
  9441. var h = this["on" + m.type];
  9442. var g;
  9443. if (typeof h == "function") {
  9444. g = h.call(m.currentTarget, m);
  9445. } else if (typeof h.handleEvent == "function") {
  9446. h.handleEvent(m);
  9447. }
  9448. if (this._ && m.redraw !== false) {
  9449. (0, this._)();
  9450. }
  9451. if (g === false) {
  9452. m.preventDefault();
  9453. m.stopPropagation();
  9454. }
  9455. };
  9456. function gi(m, h, g) {
  9457. if (m.events != null) {
  9458. m.events._ = i;
  9459. if (m.events[h] === g) {
  9460. return;
  9461. }
  9462. if (g != null && (typeof g == "function" || typeof g == "object")) {
  9463. if (m.events[h] == null) {
  9464. m.dom.addEventListener(h.slice(2), m.events, false);
  9465. }
  9466. m.events[h] = g;
  9467. } else {
  9468. if (m.events[h] != null) {
  9469. m.dom.removeEventListener(h.slice(2), m.events, false);
  9470. }
  9471. m.events[h] = undefined;
  9472. }
  9473. } else if (g != null && (typeof g == "function" || typeof g == "object")) {
  9474. m.events = new mi();
  9475. m.dom.addEventListener(h.slice(2), m.events, false);
  9476. m.events[h] = g;
  9477. }
  9478. }
  9479. function yi(m, h, g) {
  9480. if (typeof m.oninit == "function") {
  9481. o.call(m.oninit, h);
  9482. }
  9483. if (typeof m.oncreate == "function") {
  9484. g.push(o.bind(m.oncreate, h));
  9485. }
  9486. }
  9487. function wi(m, h, g) {
  9488. if (typeof m.onupdate == "function") {
  9489. g.push(o.bind(m.onupdate, h));
  9490. }
  9491. }
  9492. function Ln(m, h) {
  9493. do {
  9494. if (m.attrs != null && typeof m.attrs.onbeforeupdate == "function") {
  9495. var g = o.call(m.attrs.onbeforeupdate, m, h);
  9496. if (g !== undefined && !g) {
  9497. break;
  9498. }
  9499. }
  9500. if (typeof m.tag != "string" && typeof m.state.onbeforeupdate == "function") {
  9501. var g = o.call(m.state.onbeforeupdate, m, h);
  9502. if (g !== undefined && !g) {
  9503. break;
  9504. }
  9505. }
  9506. return false;
  9507. } while (false);
  9508. m.dom = h.dom;
  9509. m.domSize = h.domSize;
  9510. m.instance = h.instance;
  9511. m.attrs = h.attrs;
  9512. m.children = h.children;
  9513. m.text = h.text;
  9514. return true;
  9515. }
  9516. var Tt;
  9517. return function (m, h, g) {
  9518. if (!m) {
  9519. throw new TypeError("DOM element being rendered to does not exist.");
  9520. }
  9521. if (Tt != null && m.contains(Tt)) {
  9522. throw new TypeError("Node is currently being rendered to and thus is locked.");
  9523. }
  9524. var I = i;
  9525. var E = Tt;
  9526. var O = [];
  9527. var q = l();
  9528. var Z = m.namespaceURI;
  9529. Tt = m;
  9530. i = typeof g == "function" ? g : undefined;
  9531. try {
  9532. if (m.vnodes == null) {
  9533. m.textContent = "";
  9534. }
  9535. h = Zn.normalizeChildren(Array.isArray(h) ? h : [h]);
  9536. $(m, m.vnodes, h, O, null, Z === "http://www.w3.org/1999/xhtml" ? undefined : Z);
  9537. m.vnodes = h;
  9538. if (q != null && l() !== q && typeof q.focus == "function") {
  9539. q.focus();
  9540. }
  9541. for (var U = 0; U < O.length; U++) {
  9542. O[U]();
  9543. }
  9544. } finally {
  9545. i = I;
  9546. Tt = E;
  9547. }
  9548. };
  9549. }
  9550. var ra = mu(typeof window !== "undefined" ? window : null);
  9551. var $r = It();
  9552. function gu(e, t, i) {
  9553. var n = [];
  9554. var s = false;
  9555. var r = -1;
  9556. function o() {
  9557. for (r = 0; r < n.length; r += 2) {
  9558. try {
  9559. e(n[r], $r(n[r + 1]), l);
  9560. } catch (a) {
  9561. i.error(a);
  9562. }
  9563. }
  9564. r = -1;
  9565. }
  9566. function l() {
  9567. if (!s) {
  9568. s = true;
  9569. t(function () {
  9570. s = false;
  9571. o();
  9572. });
  9573. }
  9574. }
  9575. l.sync = o;
  9576. function c(a, f) {
  9577. if (f != null && f.view == null && typeof f != "function") {
  9578. throw new TypeError("m.mount expects a component, not a vnode.");
  9579. }
  9580. var d = n.indexOf(a);
  9581. if (d >= 0) {
  9582. n.splice(d, 2);
  9583. if (d <= r) {
  9584. r -= 2;
  9585. }
  9586. e(a, []);
  9587. }
  9588. if (f != null) {
  9589. n.push(a, f);
  9590. e(a, $r(f), l);
  9591. }
  9592. }
  9593. return {
  9594. mount: c,
  9595. redraw: l
  9596. };
  9597. }
  9598. var yu = ra;
  9599. var Qs = gu(yu, typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : null, typeof console !== "undefined" ? console : null);
  9600. var Jn;
  9601. var Rr;
  9602. function oa() {
  9603. if (!Rr) {
  9604. Rr = 1;
  9605. Jn = function (e) {
  9606. if (Object.prototype.toString.call(e) !== "[object Object]") {
  9607. return "";
  9608. }
  9609. var t = [];
  9610. for (var i in e) {
  9611. n(i, e[i]);
  9612. }
  9613. return t.join("&");
  9614. function n(s, r) {
  9615. if (Array.isArray(r)) {
  9616. for (var o = 0; o < r.length; o++) {
  9617. n(s + "[" + o + "]", r[o]);
  9618. }
  9619. } else if (Object.prototype.toString.call(r) === "[object Object]") {
  9620. for (var o in r) {
  9621. n(s + "[" + o + "]", r[o]);
  9622. }
  9623. } else {
  9624. t.push(encodeURIComponent(s) + (r != null && r !== "" ? "=" + encodeURIComponent(r) : ""));
  9625. }
  9626. }
  9627. };
  9628. }
  9629. return Jn;
  9630. }
  9631. var Qn;
  9632. var Ar;
  9633. function aa() {
  9634. if (Ar) {
  9635. return Qn;
  9636. }
  9637. Ar = 1;
  9638. var e = Dn;
  9639. Qn = Object.assign || function (t, i) {
  9640. for (var n in i) {
  9641. if (e.call(i, n)) {
  9642. t[n] = i[n];
  9643. }
  9644. }
  9645. };
  9646. return Qn;
  9647. }
  9648. var jn;
  9649. var Dr;
  9650. function js() {
  9651. if (Dr) {
  9652. return jn;
  9653. }
  9654. Dr = 1;
  9655. var e = oa();
  9656. var t = aa();
  9657. jn = function (i, n) {
  9658. if (/:([^\/\.-]+)(\.{3})?:/.test(i)) {
  9659. throw new SyntaxError("Template parameter names must be separated by either a '/', '-', or '.'.");
  9660. }
  9661. if (n == null) {
  9662. return i;
  9663. }
  9664. var s = i.indexOf("?");
  9665. var r = i.indexOf("#");
  9666. var o = r < 0 ? i.length : r;
  9667. var l = s < 0 ? o : s;
  9668. var c = i.slice(0, l);
  9669. var a = {};
  9670. t(a, n);
  9671. var f = c.replace(/:([^\/\.-]+)(\.{3})?/g, function ($, v, S) {
  9672. delete a[v];
  9673. if (n[v] == null) {
  9674. return $;
  9675. } else if (S) {
  9676. return n[v];
  9677. } else {
  9678. return encodeURIComponent(String(n[v]));
  9679. }
  9680. });
  9681. var d = f.indexOf("?");
  9682. var u = f.indexOf("#");
  9683. var p = u < 0 ? f.length : u;
  9684. var w = d < 0 ? p : d;
  9685. var x = f.slice(0, w);
  9686. if (s >= 0) {
  9687. x += i.slice(s, o);
  9688. }
  9689. if (d >= 0) {
  9690. x += (s < 0 ? "?" : "&") + f.slice(d, p);
  9691. }
  9692. var b = e(a);
  9693. if (b) {
  9694. x += (s < 0 && d < 0 ? "?" : "&") + b;
  9695. }
  9696. if (r >= 0) {
  9697. x += i.slice(r);
  9698. }
  9699. if (u >= 0) {
  9700. x += (r < 0 ? "" : "&") + f.slice(u);
  9701. }
  9702. return x;
  9703. };
  9704. return jn;
  9705. }
  9706. var wu = js();
  9707. var Or = Dn;
  9708. function vu(e, t, i) {
  9709. var n = 0;
  9710. function s(l) {
  9711. return new t(l);
  9712. }
  9713. s.prototype = t.prototype;
  9714. s.__proto__ = t;
  9715. function r(l) {
  9716. return function (c, a) {
  9717. if (typeof c != "string") {
  9718. a = c;
  9719. c = c.url;
  9720. } else if (a == null) {
  9721. a = {};
  9722. }
  9723. var f = new t(function (w, x) {
  9724. l(wu(c, a.params), a, function (b) {
  9725. if (typeof a.type == "function") {
  9726. if (Array.isArray(b)) {
  9727. for (var $ = 0; $ < b.length; $++) {
  9728. b[$] = new a.type(b[$]);
  9729. }
  9730. } else {
  9731. b = new a.type(b);
  9732. }
  9733. }
  9734. w(b);
  9735. }, x);
  9736. });
  9737. if (a.background === true) {
  9738. return f;
  9739. }
  9740. var d = 0;
  9741. function u() {
  9742. if (--d === 0 && typeof i == "function") {
  9743. i();
  9744. }
  9745. }
  9746. return p(f);
  9747. function p(w) {
  9748. var x = w.then;
  9749. w.constructor = s;
  9750. w.then = function () {
  9751. d++;
  9752. var b = x.apply(w, arguments);
  9753. b.then(u, function ($) {
  9754. u();
  9755. if (d === 0) {
  9756. throw $;
  9757. }
  9758. });
  9759. return p(b);
  9760. };
  9761. return w;
  9762. }
  9763. };
  9764. }
  9765. function o(l, c) {
  9766. for (var a in l.headers) {
  9767. if (Or.call(l.headers, a) && a.toLowerCase() === c) {
  9768. return true;
  9769. }
  9770. }
  9771. return false;
  9772. }
  9773. return {
  9774. request: r(function (l, c, a, f) {
  9775. var d = c.method != null ? c.method.toUpperCase() : "GET";
  9776. var u = c.body;
  9777. var p = (c.serialize == null || c.serialize === JSON.serialize) && !(u instanceof e.FormData || u instanceof e.URLSearchParams);
  9778. var w = c.responseType || (typeof c.extract == "function" ? "" : "json");
  9779. var x = new e.XMLHttpRequest();
  9780. var b = false;
  9781. var $ = false;
  9782. var v = x;
  9783. var S;
  9784. var R = x.abort;
  9785. x.abort = function () {
  9786. b = true;
  9787. R.call(this);
  9788. };
  9789. x.open(d, l, c.async !== false, typeof c.user == "string" ? c.user : undefined, typeof c.password == "string" ? c.password : undefined);
  9790. if (p && u != null && !o(c, "content-type")) {
  9791. x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
  9792. }
  9793. if (typeof c.deserialize != "function" && !o(c, "accept")) {
  9794. x.setRequestHeader("Accept", "application/json, text/*");
  9795. }
  9796. if (c.withCredentials) {
  9797. x.withCredentials = c.withCredentials;
  9798. }
  9799. if (c.timeout) {
  9800. x.timeout = c.timeout;
  9801. }
  9802. x.responseType = w;
  9803. for (var G in c.headers) {
  9804. if (Or.call(c.headers, G)) {
  9805. x.setRequestHeader(G, c.headers[G]);
  9806. }
  9807. }
  9808. x.onreadystatechange = function (X) {
  9809. if (!b && X.target.readyState === 4) {
  9810. try {
  9811. var W = X.target.status >= 200 && X.target.status < 300 || X.target.status === 304 || /^file:\/\//i.test(l);
  9812. var M = X.target.response;
  9813. var V;
  9814. if (w === "json") {
  9815. if (!X.target.responseType && typeof c.extract != "function") {
  9816. try {
  9817. M = JSON.parse(X.target.responseText);
  9818. } catch {
  9819. M = null;
  9820. }
  9821. }
  9822. } else if ((!w || w === "text") && M == null) {
  9823. M = X.target.responseText;
  9824. }
  9825. if (typeof c.extract == "function") {
  9826. M = c.extract(X.target, c);
  9827. W = true;
  9828. } else if (typeof c.deserialize == "function") {
  9829. M = c.deserialize(M);
  9830. }
  9831. if (W) {
  9832. a(M);
  9833. } else {
  9834. function F() {
  9835. try {
  9836. V = X.target.responseText;
  9837. } catch {
  9838. V = M;
  9839. }
  9840. var _ = new Error(V);
  9841. _.code = X.target.status;
  9842. _.response = M;
  9843. f(_);
  9844. }
  9845. if (x.status === 0) {
  9846. // TOLOOK
  9847. setTimeout(function () {
  9848. if (!$) {
  9849. F();
  9850. }
  9851. });
  9852. } else {
  9853. F();
  9854. }
  9855. }
  9856. } catch (_) {
  9857. f(_);
  9858. }
  9859. }
  9860. };
  9861. x.ontimeout = function (X) {
  9862. $ = true;
  9863. var W = new Error("Request timed out");
  9864. W.code = X.target.status;
  9865. f(W);
  9866. };
  9867. if (typeof c.config == "function") {
  9868. x = c.config(x, c, l) || x;
  9869. if (x !== v) {
  9870. S = x.abort;
  9871. x.abort = function () {
  9872. b = true;
  9873. S.call(this);
  9874. };
  9875. }
  9876. }
  9877. if (u == null) {
  9878. x.send();
  9879. } else if (typeof c.serialize == "function") {
  9880. x.send(c.serialize(u));
  9881. } else if (u instanceof e.FormData || u instanceof e.URLSearchParams) {
  9882. x.send(u);
  9883. } else {
  9884. x.send(JSON.stringify(u));
  9885. }
  9886. }),
  9887. jsonp: r(function (l, c, a, f) {
  9888. var d = c.callbackName || "_mithril_" + Math.round(Math.random() * 10000000000000000) + "_" + n++;
  9889. var u = e.document.createElement("script");
  9890. e[d] = function (p) {
  9891. delete e[d];
  9892. u.parentNode.removeChild(u);
  9893. a(p);
  9894. };
  9895. u.onerror = function () {
  9896. delete e[d];
  9897. u.parentNode.removeChild(u);
  9898. f(new Error("JSONP request failed"));
  9899. };
  9900. u.src = l + (l.indexOf("?") < 0 ? "?" : "&") + encodeURIComponent(c.callbackKey || "callback") + "=" + encodeURIComponent(d);
  9901. e.document.documentElement.appendChild(u);
  9902. })
  9903. };
  9904. }
  9905. var ku = sa;
  9906. var xu = Qs;
  9907. var bu = vu(typeof window !== "undefined" ? window : null, ku, xu.redraw);
  9908. var es;
  9909. var _r;
  9910. function la() {
  9911. if (_r) {
  9912. return es;
  9913. }
  9914. _r = 1;
  9915. function e(t) {
  9916. try {
  9917. return decodeURIComponent(t);
  9918. } catch {
  9919. return t;
  9920. }
  9921. }
  9922. es = function (t) {
  9923. if (t === "" || t == null) {
  9924. return {};
  9925. }
  9926. if (t.charAt(0) === "?") {
  9927. t = t.slice(1);
  9928. }
  9929. for (var i = t.split("&"), n = {}, s = {}, r = 0; r < i.length; r++) {
  9930. var o = i[r].split("=");
  9931. var l = e(o[0]);
  9932. var c = o.length === 2 ? e(o[1]) : "";
  9933. if (c === "true") {
  9934. c = true;
  9935. } else if (c === "false") {
  9936. c = false;
  9937. }
  9938. var a = l.split(/\]\[?|\[/);
  9939. var f = s;
  9940. if (l.indexOf("[") > -1) {
  9941. a.pop();
  9942. }
  9943. for (var d = 0; d < a.length; d++) {
  9944. var u = a[d];
  9945. var p = a[d + 1];
  9946. var w = p == "" || !isNaN(parseInt(p, 10));
  9947. if (u === "") {
  9948. var l = a.slice(0, d).join();
  9949. if (n[l] == null) {
  9950. n[l] = Array.isArray(f) ? f.length : 0;
  9951. }
  9952. u = n[l]++;
  9953. } else if (u === "__proto__") {
  9954. break;
  9955. }
  9956. if (d === a.length - 1) {
  9957. f[u] = c;
  9958. } else {
  9959. var x = Object.getOwnPropertyDescriptor(f, u);
  9960. if (x != null) {
  9961. x = x.value;
  9962. }
  9963. if (x == null) {
  9964. f[u] = x = w ? [] : {};
  9965. }
  9966. f = x;
  9967. }
  9968. }
  9969. }
  9970. return s;
  9971. };
  9972. return es;
  9973. }
  9974. var ts;
  9975. var zr;
  9976. function er() {
  9977. if (zr) {
  9978. return ts;
  9979. }
  9980. zr = 1;
  9981. var e = la();
  9982. ts = function (t) {
  9983. var i = t.indexOf("?");
  9984. var n = t.indexOf("#");
  9985. var s = n < 0 ? t.length : n;
  9986. var r = i < 0 ? s : i;
  9987. var o = t.slice(0, r).replace(/\/{2,}/g, "/");
  9988. if (o) {
  9989. if (o[0] !== "/") {
  9990. o = "/" + o;
  9991. }
  9992. if (o.length > 1 && o[o.length - 1] === "/") {
  9993. o = o.slice(0, -1);
  9994. }
  9995. } else {
  9996. o = "/";
  9997. }
  9998. return {
  9999. path: o,
  10000. params: i < 0 ? {} : e(t.slice(i + 1, s))
  10001. };
  10002. };
  10003. return ts;
  10004. }
  10005. var is;
  10006. var Br;
  10007. function Su() {
  10008. if (Br) {
  10009. return is;
  10010. }
  10011. Br = 1;
  10012. var e = er();
  10013. is = function (t) {
  10014. var i = e(t);
  10015. var n = Object.keys(i.params);
  10016. var s = [];
  10017. var r = new RegExp("^" + i.path.replace(/:([^\/.-]+)(\.{3}|\.(?!\.)|-)?|[\\^$*+.()|\[\]{}]/g, function (o, l, c) {
  10018. if (l == null) {
  10019. return "\\" + o;
  10020. } else {
  10021. s.push({
  10022. k: l,
  10023. r: c === "..."
  10024. });
  10025. if (c === "...") {
  10026. return "(.*)";
  10027. } else if (c === ".") {
  10028. return "([^/]+)\\.";
  10029. } else {
  10030. return "([^/]+)" + (c || "");
  10031. }
  10032. }
  10033. }) + "$");
  10034. return function (o) {
  10035. for (var l = 0; l < n.length; l++) {
  10036. if (i.params[n[l]] !== o.params[n[l]]) {
  10037. return false;
  10038. }
  10039. }
  10040. if (!s.length) {
  10041. return r.test(o.path);
  10042. }
  10043. var c = r.exec(o.path);
  10044. if (c == null) {
  10045. return false;
  10046. }
  10047. for (var l = 0; l < s.length; l++) {
  10048. o.params[s[l].k] = s[l].r ? c[l + 1] : decodeURIComponent(c[l + 1]);
  10049. }
  10050. return true;
  10051. };
  10052. };
  10053. return is;
  10054. }
  10055. var ns;
  10056. var Hr;
  10057. function ca() {
  10058. if (Hr) {
  10059. return ns;
  10060. }
  10061. Hr = 1;
  10062. var e = Dn;
  10063. var t = new RegExp("^(?:key|oninit|oncreate|onbeforeupdate|onupdate|onbeforeremove|onremove)$");
  10064. ns = function (i, n) {
  10065. var s = {};
  10066. if (n != null) {
  10067. for (var r in i) {
  10068. if (e.call(i, r) && !t.test(r) && n.indexOf(r) < 0) {
  10069. s[r] = i[r];
  10070. }
  10071. }
  10072. } else {
  10073. for (var r in i) {
  10074. if (e.call(i, r) && !t.test(r)) {
  10075. s[r] = i[r];
  10076. }
  10077. }
  10078. }
  10079. return s;
  10080. };
  10081. return ns;
  10082. }
  10083. var ss;
  10084. var Lr;
  10085. function Iu() {
  10086. if (Lr) {
  10087. return ss;
  10088. }
  10089. Lr = 1;
  10090. var e = It();
  10091. var t = ia;
  10092. var i = sa;
  10093. var n = js();
  10094. var s = er();
  10095. var r = Su();
  10096. var o = aa();
  10097. var l = ca();
  10098. var c = {};
  10099. function a(f) {
  10100. try {
  10101. return decodeURIComponent(f);
  10102. } catch {
  10103. return f;
  10104. }
  10105. }
  10106. ss = function (f, d) {
  10107. var u = f == null ? null : typeof f.setImmediate == "function" ? f.setImmediate : f.setTimeout;
  10108. var p = i.resolve();
  10109. var w = false;
  10110. var x = false;
  10111. var b = 0;
  10112. var $;
  10113. var v;
  10114. var S = c;
  10115. var R;
  10116. var G;
  10117. var X;
  10118. var W;
  10119. var M = {
  10120. onbeforeupdate: function () {
  10121. b = b ? 2 : 1;
  10122. return !(!b || c === S);
  10123. },
  10124. onremove: function () {
  10125. f.removeEventListener("popstate", _, false);
  10126. f.removeEventListener("hashchange", F, false);
  10127. },
  10128. view: function () {
  10129. if (!(!b || c === S)) {
  10130. var N = [e(R, G.key, G)];
  10131. if (S) {
  10132. N = S.render(N[0]);
  10133. }
  10134. return N;
  10135. }
  10136. }
  10137. };
  10138. var V = z.SKIP = {};
  10139. function F() {
  10140. w = false;
  10141. var N = f.location.hash;
  10142. if (z.prefix[0] !== "#") {
  10143. N = f.location.search + N;
  10144. if (z.prefix[0] !== "?") {
  10145. N = f.location.pathname + N;
  10146. if (N[0] !== "/") {
  10147. N = "/" + N;
  10148. }
  10149. }
  10150. }
  10151. var Y = N.concat().replace(/(?:%[a-f89][a-f0-9])+/gim, a).slice(z.prefix.length);
  10152. var K = s(Y);
  10153. o(K.params, f.history.state);
  10154. function ie(J) {
  10155. console.error(J);
  10156. D(v, null, {
  10157. replace: true
  10158. });
  10159. }
  10160. ae(0);
  10161. function ae(J) {
  10162. for (; J < $.length; J++) {
  10163. if ($[J].check(K)) {
  10164. var Se = $[J].component;
  10165. var zt = $[J].route;
  10166. var Ve = Se;
  10167. var te = W = function (Be) {
  10168. if (te === W) {
  10169. if (Be === V) {
  10170. return ae(J + 1);
  10171. }
  10172. R = Be != null && (typeof Be.view == "function" || typeof Be == "function") ? Be : "div";
  10173. G = K.params;
  10174. X = Y;
  10175. W = null;
  10176. S = Se.render ? Se : null;
  10177. if (b === 2) {
  10178. d.redraw();
  10179. } else {
  10180. b = 2;
  10181. d.redraw.sync();
  10182. }
  10183. }
  10184. };
  10185. if (Se.view || typeof Se == "function") {
  10186. Se = {};
  10187. te(Ve);
  10188. } else if (Se.onmatch) {
  10189. p.then(function () {
  10190. return Se.onmatch(K.params, Y, zt);
  10191. }).then(te, Y === v ? null : ie);
  10192. } else {
  10193. te("div");
  10194. }
  10195. return;
  10196. }
  10197. }
  10198. if (Y === v) {
  10199. throw new Error("Could not resolve default route " + v + ".");
  10200. }
  10201. D(v, null, {
  10202. replace: true
  10203. });
  10204. }
  10205. }
  10206. function _() {
  10207. if (!w) {
  10208. w = true;
  10209. u(F);
  10210. }
  10211. }
  10212. function D(N, Y, K) {
  10213. N = n(N, Y);
  10214. if (x) {
  10215. _();
  10216. var ie = K ? K.state : null;
  10217. var ae = K ? K.title : null;
  10218. if (K && K.replace) {
  10219. f.history.replaceState(ie, ae, z.prefix + N);
  10220. } else {
  10221. f.history.pushState(ie, ae, z.prefix + N);
  10222. }
  10223. } else {
  10224. f.location.href = z.prefix + N;
  10225. }
  10226. }
  10227. function z(N, Y, K) {
  10228. if (!N) {
  10229. throw new TypeError("DOM element being rendered to does not exist.");
  10230. }
  10231. $ = Object.keys(K).map(function (ae) {
  10232. if (ae[0] !== "/") {
  10233. throw new SyntaxError("Routes must start with a '/'.");
  10234. }
  10235. if (/:([^\/\.-]+)(\.{3})?:/.test(ae)) {
  10236. throw new SyntaxError("Route parameter names must be separated with either '/', '.', or '-'.");
  10237. }
  10238. return {
  10239. route: ae,
  10240. component: K[ae],
  10241. check: r(ae)
  10242. };
  10243. });
  10244. v = Y;
  10245. if (Y != null) {
  10246. var ie = s(Y);
  10247. if (!$.some(function (ae) {
  10248. return ae.check(ie);
  10249. })) {
  10250. throw new ReferenceError("Default route doesn't match any known routes.");
  10251. }
  10252. }
  10253. if (typeof f.history.pushState == "function") {
  10254. f.addEventListener("popstate", _, false);
  10255. } else if (z.prefix[0] === "#") {
  10256. f.addEventListener("hashchange", F, false);
  10257. }
  10258. x = true;
  10259. d.mount(N, M);
  10260. F();
  10261. }
  10262. z.set = function (N, Y, K) {
  10263. if (W != null) {
  10264. K = K || {};
  10265. K.replace = true;
  10266. }
  10267. W = null;
  10268. D(N, Y, K);
  10269. };
  10270. z.get = function () {
  10271. return X;
  10272. };
  10273. z.prefix = "#!";
  10274. z.Link = {
  10275. view: function (N) {
  10276. var Y = t(N.attrs.selector || "a", l(N.attrs, ["options", "params", "selector", "onclick"]), N.children);
  10277. var K;
  10278. var ie;
  10279. var ae;
  10280. if (Y.attrs.disabled = !!Y.attrs.disabled) {
  10281. Y.attrs.href = null;
  10282. Y.attrs["aria-disabled"] = "true";
  10283. } else {
  10284. K = N.attrs.options;
  10285. ie = N.attrs.onclick;
  10286. ae = n(Y.attrs.href, N.attrs.params);
  10287. Y.attrs.href = z.prefix + ae;
  10288. Y.attrs.onclick = function (J) {
  10289. var Se;
  10290. if (typeof ie == "function") {
  10291. Se = ie.call(J.currentTarget, J);
  10292. } else if (!(ie == null || typeof ie != "object")) {
  10293. if (typeof ie.handleEvent == "function") {
  10294. ie.handleEvent(J);
  10295. }
  10296. }
  10297. if (Se !== false && !J.defaultPrevented && (J.button === 0 || J.which === 0 || J.which === 1) && (!J.currentTarget.target || J.currentTarget.target === "_self") && !J.ctrlKey && !J.metaKey && !J.shiftKey && !J.altKey) {
  10298. J.preventDefault();
  10299. J.redraw = false;
  10300. z.set(ae, null, K);
  10301. }
  10302. };
  10303. }
  10304. return Y;
  10305. }
  10306. };
  10307. z.param = function (N) {
  10308. if (G && N != null) {
  10309. return G[N];
  10310. } else {
  10311. return G;
  10312. }
  10313. };
  10314. return z;
  10315. };
  10316. return ss;
  10317. }
  10318. var rs;
  10319. var Fr;
  10320. function Tu() {
  10321. if (Fr) {
  10322. return rs;
  10323. }
  10324. Fr = 1;
  10325. var e = Qs;
  10326. rs = Iu()(typeof window !== "undefined" ? window : null, e);
  10327. return rs;
  10328. }
  10329. var On = pu;
  10330. var ha = bu;
  10331. var ua = Qs;
  10332. function Ae() {
  10333. return On.apply(this, arguments);
  10334. }
  10335. Ae.m = On;
  10336. Ae.trust = On.trust;
  10337. Ae.fragment = On.fragment;
  10338. Ae.Fragment = "[";
  10339. Ae.mount = ua.mount;
  10340. Ae.route = Tu();
  10341. Ae.render = ra;
  10342. Ae.redraw = ua.redraw;
  10343. Ae.request = ha.request;
  10344. Ae.jsonp = ha.jsonp;
  10345. Ae.parseQueryString = la();
  10346. Ae.buildQueryString = oa();
  10347. Ae.parsePathname = er();
  10348. Ae.buildPathname = js();
  10349. Ae.vnode = It();
  10350. Ae.PromisePolyfill = na();
  10351. Ae.censor = ca();
  10352. var Mu = Ae;
  10353. const kt = An(Mu);
  10354. function ze(e, t, i, n, s) {
  10355. this.debugLog = false;
  10356. this.baseUrl = e;
  10357. this.lobbySize = i;
  10358. this.devPort = t;
  10359. this.lobbySpread = n;
  10360. this.rawIPs = !!s;
  10361. this.server = undefined;
  10362. this.gameIndex = undefined;
  10363. this.callback = undefined;
  10364. this.errorCallback = undefined;
  10365. }
  10366. ze.prototype.regionInfo = {
  10367. 0: {
  10368. name: "Local",
  10369. latitude: 0,
  10370. longitude: 0
  10371. },
  10372. "us-east": {
  10373. name: "Miami",
  10374. latitude: 40.1393329,
  10375. longitude: -75.8521818
  10376. },
  10377. miami: {
  10378. name: "Miami",
  10379. latitude: 40.1393329,
  10380. longitude: -75.8521818
  10381. },
  10382. "us-west": {
  10383. name: "Silicon Valley",
  10384. latitude: 47.6149942,
  10385. longitude: -122.4759879
  10386. },
  10387. siliconvalley: {
  10388. name: "Silicon Valley",
  10389. latitude: 47.6149942,
  10390. longitude: -122.4759879
  10391. },
  10392. gb: {
  10393. name: "London",
  10394. latitude: 51.5283063,
  10395. longitude: -0.382486
  10396. },
  10397. london: {
  10398. name: "London",
  10399. latitude: 51.5283063,
  10400. longitude: -0.382486
  10401. },
  10402. "eu-west": {
  10403. name: "Frankfurt",
  10404. latitude: 50.1211273,
  10405. longitude: 8.496137
  10406. },
  10407. frankfurt: {
  10408. name: "Frankfurt",
  10409. latitude: 50.1211273,
  10410. longitude: 8.496137
  10411. },
  10412. au: {
  10413. name: "Sydney",
  10414. latitude: -33.8479715,
  10415. longitude: 150.651084
  10416. },
  10417. sydney: {
  10418. name: "Sydney",
  10419. latitude: -33.8479715,
  10420. longitude: 150.651084
  10421. },
  10422. saopaulo: {
  10423. name: "São Paulo",
  10424. latitude: 23.5558,
  10425. longitude: 46.6396
  10426. },
  10427. sg: {
  10428. name: "Singapore",
  10429. latitude: 1.3147268,
  10430. longitude: 103.7065876
  10431. },
  10432. singapore: {
  10433. name: "Singapore",
  10434. latitude: 1.3147268,
  10435. longitude: 103.7065876
  10436. }
  10437. };
  10438. ze.prototype.start = function (e, t, i, n) {
  10439. this.callback = t;
  10440. this.errorCallback = i;
  10441. if (n) {
  10442. return t();
  10443. }
  10444. const s = this.parseServerQuery(e);
  10445. if (s && s.length > 0) {
  10446. this.log("Found server in query.");
  10447. this.password = s[3];
  10448. this.connect(s[0], s[1], s[2]);
  10449. } else {
  10450. this.errorCallback("Unable to find server");
  10451. }
  10452. };
  10453. ze.prototype.parseServerQuery = function (e) {
  10454. const t = new URLSearchParams(location.search, true);
  10455. const i = e || t.get("server");
  10456. if (typeof i != "string") {
  10457. return [];
  10458. }
  10459. const [n, s] = i.split(":");
  10460. return [n, s, t.get("password")];
  10461. };
  10462. ze.prototype.findServer = function (e, t) {
  10463. var i = this.servers[e];
  10464. for (let n = 0; n < i.length; n++) {
  10465. const s = i[n];
  10466. if (s.name === t) {
  10467. return s;
  10468. }
  10469. }
  10470. console.warn("Could not find server in region " + e + " with serverName " + t + ".");
  10471. };
  10472. ze.prototype.seekServer = function (e, t, i) {
  10473. if (i == null) {
  10474. i = "random";
  10475. }
  10476. if (t == null) {
  10477. t = false;
  10478. }
  10479. const n = ["random"];
  10480. const s = this.lobbySize;
  10481. const r = this.lobbySpread;
  10482. const o = this.servers[e].flatMap(function (u) {
  10483. let p = 0;
  10484. return u.games.map(function (w) {
  10485. const x = p++;
  10486. return {
  10487. region: u.region,
  10488. index: u.index * u.games.length + x,
  10489. gameIndex: x,
  10490. gameCount: u.games.length,
  10491. playerCount: w.playerCount,
  10492. playerCapacity: w.playerCapacity,
  10493. isPrivate: w.isPrivate
  10494. };
  10495. });
  10496. }).filter(function (u) {
  10497. return !u.isPrivate;
  10498. }).filter(function (u) {
  10499. if (t) {
  10500. return u.playerCount == 0 && u.gameIndex >= u.gameCount / 2;
  10501. } else {
  10502. return true;
  10503. }
  10504. }).filter(function (u) {
  10505. if (i == "random") {
  10506. return true;
  10507. } else {
  10508. return n[u.index % n.length].key == i;
  10509. }
  10510. }).sort(function (u, p) {
  10511. return p.playerCount - u.playerCount;
  10512. }).filter(function (u) {
  10513. return u.playerCount < s;
  10514. });
  10515. if (t) {
  10516. o.reverse();
  10517. }
  10518. if (o.length == 0) {
  10519. this.errorCallback("No open servers.");
  10520. return;
  10521. }
  10522. const l = Math.min(r, o.length);
  10523. var f = Math.floor(Math.random() * l);
  10524. f = Math.min(f, o.length - 1);
  10525. const c = o[f];
  10526. const a = c.region;
  10527. var f = Math.floor(c.index / c.gameCount);
  10528. const d = c.index % c.gameCount;
  10529. this.log("Found server.");
  10530. return [a, f, d];
  10531. };
  10532. ze.prototype.connect = function (e, t, i) {
  10533. if (this.connected) {
  10534. return;
  10535. }
  10536. const n = this.findServer(e, t);
  10537. if (n == null) {
  10538. this.errorCallback("Failed to find server for region " + e + " and serverName " + t);
  10539. return;
  10540. }
  10541. this.log("Connecting to server", n, "with game index", i);
  10542. if (n.playerCount >= n.playerCapacity) {
  10543. this.errorCallback("Server is already full.");
  10544. return;
  10545. }
  10546. window.history.replaceState(document.title, document.title, this.generateHref(e, t, this.password));
  10547. this.server = n;
  10548. this.gameIndex = i;
  10549. this.log("Calling callback with address", this.serverAddress(n), "on port", this.serverPort(n));
  10550. this.callback(this.serverAddress(n), this.serverPort(n), i);
  10551. if (_i) {
  10552. clearInterval(_i);
  10553. }
  10554. };
  10555. ze.prototype.switchServer = function (e, t) {
  10556. this.switchingServers = true;
  10557. window.location = this.generateHref(e, t, null);
  10558. };
  10559. ze.prototype.generateHref = function (e, t, i) {
  10560. let n = window.location.href.split("?")[0];
  10561. n += "?server=" + e + ":" + t;
  10562. if (i) {
  10563. n += "&password=" + encodeURIComponent(i);
  10564. }
  10565. return n;
  10566. };
  10567. ze.prototype.serverAddress = function (e) {
  10568. if (e.region == 0) {
  10569. return "localhost";
  10570. } else {
  10571. return e.key + "." + e.region + "." + this.baseUrl;
  10572. }
  10573. };
  10574. ze.prototype.serverPort = function (e) {
  10575. return e.port;
  10576. };
  10577. let _i;
  10578. function Eu(e) {
  10579. e = e.filter(s => s.playerCount !== s.playerCapacity);
  10580. const t = Math.min(...e.map(s => s.ping || Infinity));
  10581. const i = e.filter(s => s.ping === t);
  10582. if (!i.length > 0) {
  10583. return null;
  10584. } else {
  10585. return i.reduce((s, r) => s.playerCount > r.playerCount ? s : r);
  10586. }
  10587. }
  10588. ze.prototype.processServers = function (e) {
  10589. if (_i) {
  10590. clearInterval(_i);
  10591. }
  10592. return new Promise(t => {
  10593. const i = {};
  10594. const n = c => {
  10595. const a = i[c];
  10596. const f = a[0];
  10597. let d = this.serverAddress(f);
  10598. const u = this.serverPort(f);
  10599. if (u) {
  10600. d += `:${u}`;
  10601. }
  10602. const p = `https://${d}/ping`;
  10603. const w = new Date().getTime();
  10604. return Promise.race([fetch(p).then(() => {
  10605. const x = new Date().getTime() - w;
  10606. a.forEach(b => {
  10607. b.pings = b.pings ?? [];
  10608. b.pings.push(x);
  10609. if (b.pings.length > 10) {
  10610. b.pings.shift();
  10611. }
  10612. b.ping = Math.floor(b.pings.reduce(($, v) => $ + v, 0) / b.pings.length);
  10613. });
  10614. }).catch(() => {}), new Promise(x => // TOLOOK
  10615. setTimeout(() => x(), 100))]);
  10616. };
  10617. const s = async () => {
  10618. await Promise.all(Object.keys(i).map(n));
  10619. if (!window.blockRedraw) {
  10620. kt.redraw();
  10621. }
  10622. };
  10623. e.forEach(c => {
  10624. i[c.region] = i[c.region] || [];
  10625. i[c.region].push(c);
  10626. });
  10627. for (const c in i) {
  10628. i[c] = i[c].sort(function (a, f) {
  10629. return f.playerCount - a.playerCount;
  10630. });
  10631. }
  10632. this.servers = i;
  10633. let r;
  10634. const [o, l] = this.parseServerQuery();
  10635. e.forEach(c => {
  10636. if (o === c.region && l === c.name) {
  10637. c.selected = true;
  10638. r = c;
  10639. }
  10640. });
  10641. s().then(s).then(() => {
  10642. if (r) {
  10643. return;
  10644. }
  10645. let c = Eu(e);
  10646. if (!c) {
  10647. c = e[0];
  10648. }
  10649. if (c) {
  10650. c.selected = true;
  10651. window.history.replaceState(document.title, document.title, this.generateHref(c.region, c.name, this.password));
  10652. }
  10653. if (!window.blockRedraw) {
  10654. kt.redraw();
  10655. }
  10656. }).then(s).catch(c => {}).finally(t);
  10657. _i = // TOLOOK
  10658. setInterval(s, 5000);
  10659. });
  10660. };
  10661. ze.prototype.ipToHex = function (e) {
  10662. return e.split(".").map(i => ("00" + parseInt(i).toString(16)).substr(-2)).join("").toLowerCase();
  10663. };
  10664. ze.prototype.hashIP = function (e) {
  10665. return tu(this.ipToHex(e));
  10666. };
  10667. ze.prototype.log = function () {
  10668. if (this.debugLog) {
  10669. return console.log.apply(undefined, arguments);
  10670. }
  10671. if (console.verbose) {
  10672. return console.verbose.apply(undefined, arguments);
  10673. }
  10674. };
  10675. ze.prototype.stripRegion = function (e) {
  10676. if (e.startsWith("vultr:")) {
  10677. e = e.slice(6);
  10678. } else if (e.startsWith("do:")) {
  10679. e = e.slice(3);
  10680. }
  10681. return e;
  10682. };
  10683. const Cu = function (e, t) {
  10684. return e.concat(t);
  10685. };
  10686. const Pu = function (e, t) {
  10687. return t.map(e).reduce(Cu, []);
  10688. };
  10689. Array.prototype.flatMap = function (e) {
  10690. return Pu(e, this);
  10691. };
  10692. const hn = (e, t) => {
  10693. const i = t.x - e.x;
  10694. const n = t.y - e.y;
  10695. return Math.sqrt(i * i + n * n);
  10696. };
  10697. const $u = (e, t) => {
  10698. const i = t.x - e.x;
  10699. const n = t.y - e.y;
  10700. return Au(Math.atan2(n, i));
  10701. };
  10702. const Ru = (e, t, i) => {
  10703. const n = {
  10704. x: 0,
  10705. y: 0
  10706. };
  10707. i = Cs(i);
  10708. n.x = e.x - t * Math.cos(i);
  10709. n.y = e.y - t * Math.sin(i);
  10710. return n;
  10711. };
  10712. const Cs = e => e * (Math.PI / 180);
  10713. const Au = e => e * (180 / Math.PI);
  10714. const Du = e => isNaN(e.buttons) ? e.pressure !== 0 : e.buttons !== 0;
  10715. const os = new Map();
  10716. const Vr = e => {
  10717. if (os.has(e)) {
  10718. clearTimeout(os.get(e));
  10719. }
  10720. os.set(e, // TOLOOK
  10721. setTimeout(e, 100));
  10722. };
  10723. const wn = (e, t, i) => {
  10724. const n = t.split(/[ ,]+/g);
  10725. let s;
  10726. for (let r = 0; r < n.length; r += 1) {
  10727. s = n[r];
  10728. if (e.addEventListener) {
  10729. e.addEventListener(s, i, false);
  10730. } else if (e.attachEvent) {
  10731. e.attachEvent(s, i);
  10732. }
  10733. }
  10734. };
  10735. const Nr = (e, t, i) => {
  10736. const n = t.split(/[ ,]+/g);
  10737. let s;
  10738. for (let r = 0; r < n.length; r += 1) {
  10739. s = n[r];
  10740. if (e.removeEventListener) {
  10741. e.removeEventListener(s, i);
  10742. } else if (e.detachEvent) {
  10743. e.detachEvent(s, i);
  10744. }
  10745. }
  10746. };
  10747. const fa = e => {
  10748. e.preventDefault();
  10749. if (e.type.match(/^touch/)) {
  10750. return e.changedTouches;
  10751. } else {
  10752. return e;
  10753. }
  10754. };
  10755. const Ur = () => {
  10756. const e = window.pageXOffset !== undefined ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft;
  10757. const t = window.pageYOffset !== undefined ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
  10758. return {
  10759. x: e,
  10760. y: t
  10761. };
  10762. };
  10763. const Wr = (e, t) => {
  10764. if (t.top || t.right || t.bottom || t.left) {
  10765. e.style.top = t.top;
  10766. e.style.right = t.right;
  10767. e.style.bottom = t.bottom;
  10768. e.style.left = t.left;
  10769. } else {
  10770. e.style.left = t.x + "px";
  10771. e.style.top = t.y + "px";
  10772. }
  10773. };
  10774. const tr = (e, t, i) => {
  10775. const n = da(e);
  10776. for (let s in n) {
  10777. if (n.hasOwnProperty(s)) {
  10778. if (typeof t == "string") {
  10779. n[s] = t + " " + i;
  10780. } else {
  10781. let r = "";
  10782. for (let o = 0, l = t.length; o < l; o += 1) {
  10783. r += t[o] + " " + i + ", ";
  10784. }
  10785. n[s] = r.slice(0, -2);
  10786. }
  10787. }
  10788. }
  10789. return n;
  10790. };
  10791. const Ou = (e, t) => {
  10792. const i = da(e);
  10793. for (let n in i) {
  10794. if (i.hasOwnProperty(n)) {
  10795. i[n] = t;
  10796. }
  10797. }
  10798. return i;
  10799. };
  10800. const da = e => {
  10801. const t = {
  10802. [e]: ""
  10803. };
  10804. ["webkit", "Moz", "o"].forEach(function (n) {
  10805. t[n + e.charAt(0).toUpperCase() + e.slice(1)] = "";
  10806. });
  10807. return t;
  10808. };
  10809. const as = (e, t) => {
  10810. for (let i in t) {
  10811. if (t.hasOwnProperty(i)) {
  10812. e[i] = t[i];
  10813. }
  10814. }
  10815. return e;
  10816. };
  10817. const _u = (e, t) => {
  10818. const i = {};
  10819. for (let n in e) {
  10820. if (e.hasOwnProperty(n) && t.hasOwnProperty(n)) {
  10821. i[n] = t[n];
  10822. } else if (e.hasOwnProperty(n)) {
  10823. i[n] = e[n];
  10824. }
  10825. }
  10826. return i;
  10827. };
  10828. const Ps = (e, t) => {
  10829. if (e.length) {
  10830. for (let i = 0, n = e.length; i < n; i += 1) {
  10831. t(e[i]);
  10832. }
  10833. } else {
  10834. t(e);
  10835. }
  10836. };
  10837. const zu = (e, t, i) => ({
  10838. x: Math.min(Math.max(e.x, t.x - i), t.x + i),
  10839. y: Math.min(Math.max(e.y, t.y - i), t.y + i)
  10840. });
  10841. var Bu = ("ontouchstart" in window);
  10842. var Hu = !!window.PointerEvent;
  10843. var Lu = !!window.MSPointerEvent;
  10844. var Ci = {
  10845. touch: {
  10846. start: "touchstart",
  10847. move: "touchmove",
  10848. end: "touchend, touchcancel"
  10849. },
  10850. mouse: {
  10851. start: "mousedown",
  10852. move: "mousemove",
  10853. end: "mouseup"
  10854. },
  10855. pointer: {
  10856. start: "pointerdown",
  10857. move: "pointermove",
  10858. end: "pointerup, pointercancel"
  10859. },
  10860. MSPointer: {
  10861. start: "MSPointerDown",
  10862. move: "MSPointerMove",
  10863. end: "MSPointerUp"
  10864. }
  10865. };
  10866. var si;
  10867. var Wi = {};
  10868. if (Hu) {
  10869. si = Ci.pointer;
  10870. } else if (Lu) {
  10871. si = Ci.MSPointer;
  10872. } else if (Bu) {
  10873. si = Ci.touch;
  10874. Wi = Ci.mouse;
  10875. } else {
  10876. si = Ci.mouse;
  10877. }
  10878. function dt() {}
  10879. dt.prototype.on = function (e, t) {
  10880. var i = this;
  10881. var n = e.split(/[ ,]+/g);
  10882. var s;
  10883. i._handlers_ = i._handlers_ || {};
  10884. for (var r = 0; r < n.length; r += 1) {
  10885. s = n[r];
  10886. i._handlers_[s] = i._handlers_[s] || [];
  10887. i._handlers_[s].push(t);
  10888. }
  10889. return i;
  10890. };
  10891. dt.prototype.off = function (e, t) {
  10892. var i = this;
  10893. i._handlers_ = i._handlers_ || {};
  10894. if (e === undefined) {
  10895. i._handlers_ = {};
  10896. } else if (t === undefined) {
  10897. i._handlers_[e] = null;
  10898. } else if (i._handlers_[e] && i._handlers_[e].indexOf(t) >= 0) {
  10899. i._handlers_[e].splice(i._handlers_[e].indexOf(t), 1);
  10900. }
  10901. return i;
  10902. };
  10903. dt.prototype.trigger = function (e, t) {
  10904. var i = this;
  10905. var n = e.split(/[ ,]+/g);
  10906. var s;
  10907. i._handlers_ = i._handlers_ || {};
  10908. for (var r = 0; r < n.length; r += 1) {
  10909. s = n[r];
  10910. if (i._handlers_[s] && i._handlers_[s].length) {
  10911. i._handlers_[s].forEach(function (o) {
  10912. o.call(i, {
  10913. type: s,
  10914. target: i
  10915. }, t);
  10916. });
  10917. }
  10918. }
  10919. };
  10920. dt.prototype.config = function (e) {
  10921. var t = this;
  10922. t.options = t.defaults || {};
  10923. if (e) {
  10924. t.options = _u(t.options, e);
  10925. }
  10926. };
  10927. dt.prototype.bindEvt = function (e, t) {
  10928. var i = this;
  10929. i._domHandlers_ = i._domHandlers_ || {};
  10930. i._domHandlers_[t] = function () {
  10931. if (typeof i["on" + t] == "function") {
  10932. i["on" + t].apply(i, arguments);
  10933. } else {
  10934. console.warn("[WARNING] : Missing \"on" + t + "\" handler.");
  10935. }
  10936. };
  10937. wn(e, si[t], i._domHandlers_[t]);
  10938. if (Wi[t]) {
  10939. wn(e, Wi[t], i._domHandlers_[t]);
  10940. }
  10941. return i;
  10942. };
  10943. dt.prototype.unbindEvt = function (e, t) {
  10944. var i = this;
  10945. i._domHandlers_ = i._domHandlers_ || {};
  10946. Nr(e, si[t], i._domHandlers_[t]);
  10947. if (Wi[t]) {
  10948. Nr(e, Wi[t], i._domHandlers_[t]);
  10949. }
  10950. delete i._domHandlers_[t];
  10951. return this;
  10952. };
  10953. function Ee(e, t) {
  10954. this.identifier = t.identifier;
  10955. this.position = t.position;
  10956. this.frontPosition = t.frontPosition;
  10957. this.collection = e;
  10958. this.defaults = {
  10959. size: 100,
  10960. threshold: 0.1,
  10961. color: "white",
  10962. fadeTime: 250,
  10963. dataOnly: false,
  10964. restJoystick: true,
  10965. restOpacity: 0.5,
  10966. mode: "dynamic",
  10967. zone: document.body,
  10968. lockX: false,
  10969. lockY: false,
  10970. shape: "circle"
  10971. };
  10972. this.config(t);
  10973. if (this.options.mode === "dynamic") {
  10974. this.options.restOpacity = 0;
  10975. }
  10976. this.id = Ee.id;
  10977. Ee.id += 1;
  10978. this.buildEl().stylize();
  10979. this.instance = {
  10980. el: this.ui.el,
  10981. on: this.on.bind(this),
  10982. off: this.off.bind(this),
  10983. show: this.show.bind(this),
  10984. hide: this.hide.bind(this),
  10985. add: this.addToDom.bind(this),
  10986. remove: this.removeFromDom.bind(this),
  10987. destroy: this.destroy.bind(this),
  10988. setPosition: this.setPosition.bind(this),
  10989. resetDirection: this.resetDirection.bind(this),
  10990. computeDirection: this.computeDirection.bind(this),
  10991. trigger: this.trigger.bind(this),
  10992. position: this.position,
  10993. frontPosition: this.frontPosition,
  10994. ui: this.ui,
  10995. identifier: this.identifier,
  10996. id: this.id,
  10997. options: this.options
  10998. };
  10999. return this.instance;
  11000. }
  11001. Ee.prototype = new dt();
  11002. Ee.constructor = Ee;
  11003. Ee.id = 0;
  11004. Ee.prototype.buildEl = function (e) {
  11005. this.ui = {};
  11006. if (this.options.dataOnly) {
  11007. return this;
  11008. } else {
  11009. this.ui.el = document.createElement("div");
  11010. this.ui.back = document.createElement("div");
  11011. this.ui.front = document.createElement("div");
  11012. this.ui.el.className = "nipple collection_" + this.collection.id;
  11013. this.ui.back.className = "back";
  11014. this.ui.front.className = "front";
  11015. this.ui.el.setAttribute("id", "nipple_" + this.collection.id + "_" + this.id);
  11016. this.ui.el.appendChild(this.ui.back);
  11017. this.ui.el.appendChild(this.ui.front);
  11018. return this;
  11019. }
  11020. };
  11021. Ee.prototype.stylize = function () {
  11022. if (this.options.dataOnly) {
  11023. return this;
  11024. }
  11025. var e = this.options.fadeTime + "ms";
  11026. var t = Ou("borderRadius", "50%");
  11027. var i = tr("transition", "opacity", e);
  11028. var n = {
  11029. el: {
  11030. position: "absolute",
  11031. opacity: this.options.restOpacity,
  11032. display: "block",
  11033. zIndex: 999
  11034. },
  11035. back: {
  11036. position: "absolute",
  11037. display: "block",
  11038. width: this.options.size + "px",
  11039. height: this.options.size + "px",
  11040. marginLeft: -this.options.size / 2 + "px",
  11041. marginTop: -this.options.size / 2 + "px",
  11042. background: this.options.color,
  11043. opacity: ".5"
  11044. },
  11045. front: {
  11046. width: this.options.size / 2 + "px",
  11047. height: this.options.size / 2 + "px",
  11048. position: "absolute",
  11049. display: "block",
  11050. marginLeft: -this.options.size / 4 + "px",
  11051. marginTop: -this.options.size / 4 + "px",
  11052. background: this.options.color,
  11053. opacity: ".5",
  11054. transform: "translate(0px, 0px)"
  11055. }
  11056. };
  11057. as(n.el, i);
  11058. if (this.options.shape === "circle") {
  11059. as(n.back, t);
  11060. }
  11061. as(n.front, t);
  11062. this.applyStyles(n);
  11063. return this;
  11064. };
  11065. Ee.prototype.applyStyles = function (e) {
  11066. for (var t in this.ui) {
  11067. if (this.ui.hasOwnProperty(t)) {
  11068. for (var i in e[t]) {
  11069. this.ui[t].style[i] = e[t][i];
  11070. }
  11071. }
  11072. }
  11073. return this;
  11074. };
  11075. Ee.prototype.addToDom = function () {
  11076. if (this.options.dataOnly || document.body.contains(this.ui.el)) {
  11077. return this;
  11078. } else {
  11079. this.options.zone.appendChild(this.ui.el);
  11080. return this;
  11081. }
  11082. };
  11083. Ee.prototype.removeFromDom = function () {
  11084. if (this.options.dataOnly || !document.body.contains(this.ui.el)) {
  11085. return this;
  11086. } else {
  11087. this.options.zone.removeChild(this.ui.el);
  11088. return this;
  11089. }
  11090. };
  11091. Ee.prototype.destroy = function () {
  11092. clearTimeout(this.removeTimeout);
  11093. clearTimeout(this.showTimeout);
  11094. clearTimeout(this.restTimeout);
  11095. this.trigger("destroyed", this.instance);
  11096. this.removeFromDom();
  11097. this.off();
  11098. };
  11099. Ee.prototype.show = function (e) {
  11100. var t = this;
  11101. if (!t.options.dataOnly) {
  11102. clearTimeout(t.removeTimeout);
  11103. clearTimeout(t.showTimeout);
  11104. clearTimeout(t.restTimeout);
  11105. t.addToDom();
  11106. t.restCallback();
  11107. // TOLOOK
  11108. setTimeout(function () {
  11109. t.ui.el.style.opacity = 1;
  11110. }, 0);
  11111. t.showTimeout = // TOLOOK
  11112. setTimeout(function () {
  11113. t.trigger("shown", t.instance);
  11114. if (typeof e == "function") {
  11115. e.call(this);
  11116. }
  11117. }, t.options.fadeTime);
  11118. }
  11119. return t;
  11120. };
  11121. Ee.prototype.hide = function (e) {
  11122. var t = this;
  11123. if (t.options.dataOnly) {
  11124. return t;
  11125. }
  11126. t.ui.el.style.opacity = t.options.restOpacity;
  11127. clearTimeout(t.removeTimeout);
  11128. clearTimeout(t.showTimeout);
  11129. clearTimeout(t.restTimeout);
  11130. t.removeTimeout = // TOLOOK
  11131. setTimeout(function () {
  11132. var i = t.options.mode === "dynamic" ? "none" : "block";
  11133. t.ui.el.style.display = i;
  11134. if (typeof e == "function") {
  11135. e.call(t);
  11136. }
  11137. t.trigger("hidden", t.instance);
  11138. }, t.options.fadeTime);
  11139. if (t.options.restJoystick) {
  11140. const i = t.options.restJoystick;
  11141. const n = {
  11142. x: i === true || i.x !== false ? 0 : t.instance.frontPosition.x,
  11143. y: i === true || i.y !== false ? 0 : t.instance.frontPosition.y
  11144. };
  11145. t.setPosition(e, n);
  11146. }
  11147. return t;
  11148. };
  11149. Ee.prototype.setPosition = function (e, t) {
  11150. var i = this;
  11151. i.frontPosition = {
  11152. x: t.x,
  11153. y: t.y
  11154. };
  11155. var n = i.options.fadeTime + "ms";
  11156. var s = {};
  11157. s.front = tr("transition", ["transform"], n);
  11158. var r = {
  11159. front: {}
  11160. };
  11161. r.front = {
  11162. transform: "translate(" + i.frontPosition.x + "px," + i.frontPosition.y + "px)"
  11163. };
  11164. i.applyStyles(s);
  11165. i.applyStyles(r);
  11166. i.restTimeout = // TOLOOK
  11167. setTimeout(function () {
  11168. if (typeof e == "function") {
  11169. e.call(i);
  11170. }
  11171. i.restCallback();
  11172. }, i.options.fadeTime);
  11173. };
  11174. Ee.prototype.restCallback = function () {
  11175. var e = this;
  11176. var t = {};
  11177. t.front = tr("transition", "none", "");
  11178. e.applyStyles(t);
  11179. e.trigger("rested", e.instance);
  11180. };
  11181. Ee.prototype.resetDirection = function () {
  11182. this.direction = {
  11183. x: false,
  11184. y: false,
  11185. angle: false
  11186. };
  11187. };
  11188. Ee.prototype.computeDirection = function (e) {
  11189. var t = e.angle.radian;
  11190. var i = Math.PI / 4;
  11191. var n = Math.PI / 2;
  11192. var s;
  11193. var r;
  11194. var o;
  11195. if (t > i && t < i * 3 && !e.lockX) {
  11196. s = "up";
  11197. } else if (t > -i && t <= i && !e.lockY) {
  11198. s = "left";
  11199. } else if (t > -i * 3 && t <= -i && !e.lockX) {
  11200. s = "down";
  11201. } else if (!e.lockY) {
  11202. s = "right";
  11203. }
  11204. if (!e.lockY) {
  11205. if (t > -n && t < n) {
  11206. r = "left";
  11207. } else {
  11208. r = "right";
  11209. }
  11210. }
  11211. if (!e.lockX) {
  11212. if (t > 0) {
  11213. o = "up";
  11214. } else {
  11215. o = "down";
  11216. }
  11217. }
  11218. if (e.force > this.options.threshold) {
  11219. var l = {};
  11220. var c;
  11221. for (c in this.direction) {
  11222. if (this.direction.hasOwnProperty(c)) {
  11223. l[c] = this.direction[c];
  11224. }
  11225. }
  11226. var a = {};
  11227. this.direction = {
  11228. x: r,
  11229. y: o,
  11230. angle: s
  11231. };
  11232. e.direction = this.direction;
  11233. for (c in l) {
  11234. if (l[c] === this.direction[c]) {
  11235. a[c] = true;
  11236. }
  11237. }
  11238. if (a.x && a.y && a.angle) {
  11239. return e;
  11240. }
  11241. if (!a.x || !a.y) {
  11242. this.trigger("plain", e);
  11243. }
  11244. if (!a.x) {
  11245. this.trigger("plain:" + r, e);
  11246. }
  11247. if (!a.y) {
  11248. this.trigger("plain:" + o, e);
  11249. }
  11250. if (!a.angle) {
  11251. this.trigger("dir dir:" + s, e);
  11252. }
  11253. } else {
  11254. this.resetDirection();
  11255. }
  11256. return e;
  11257. };
  11258. function ke(e, t) {
  11259. var i = this;
  11260. i.nipples = [];
  11261. i.idles = [];
  11262. i.actives = [];
  11263. i.ids = [];
  11264. i.pressureIntervals = {};
  11265. i.manager = e;
  11266. i.id = ke.id;
  11267. ke.id += 1;
  11268. i.defaults = {
  11269. zone: document.body,
  11270. multitouch: false,
  11271. maxNumberOfNipples: 10,
  11272. mode: "dynamic",
  11273. position: {
  11274. top: 0,
  11275. left: 0
  11276. },
  11277. catchDistance: 200,
  11278. size: 100,
  11279. threshold: 0.1,
  11280. color: "white",
  11281. fadeTime: 250,
  11282. dataOnly: false,
  11283. restJoystick: true,
  11284. restOpacity: 0.5,
  11285. lockX: false,
  11286. lockY: false,
  11287. shape: "circle",
  11288. dynamicPage: false,
  11289. follow: false
  11290. };
  11291. i.config(t);
  11292. if (i.options.mode === "static" || i.options.mode === "semi") {
  11293. i.options.multitouch = false;
  11294. }
  11295. if (!i.options.multitouch) {
  11296. i.options.maxNumberOfNipples = 1;
  11297. }
  11298. const n = getComputedStyle(i.options.zone.parentElement);
  11299. if (n && n.display === "flex") {
  11300. i.parentIsFlex = true;
  11301. }
  11302. i.updateBox();
  11303. i.prepareNipples();
  11304. i.bindings();
  11305. i.begin();
  11306. return i.nipples;
  11307. }
  11308. ke.prototype = new dt();
  11309. ke.constructor = ke;
  11310. ke.id = 0;
  11311. ke.prototype.prepareNipples = function () {
  11312. var e = this;
  11313. var t = e.nipples;
  11314. t.on = e.on.bind(e);
  11315. t.off = e.off.bind(e);
  11316. t.options = e.options;
  11317. t.destroy = e.destroy.bind(e);
  11318. t.ids = e.ids;
  11319. t.id = e.id;
  11320. t.processOnMove = e.processOnMove.bind(e);
  11321. t.processOnEnd = e.processOnEnd.bind(e);
  11322. t.get = function (i) {
  11323. if (i === undefined) {
  11324. return t[0];
  11325. }
  11326. for (var n = 0, s = t.length; n < s; n += 1) {
  11327. if (t[n].identifier === i) {
  11328. return t[n];
  11329. }
  11330. }
  11331. return false;
  11332. };
  11333. };
  11334. ke.prototype.bindings = function () {
  11335. var e = this;
  11336. e.bindEvt(e.options.zone, "start");
  11337. e.options.zone.style.touchAction = "none";
  11338. e.options.zone.style.msTouchAction = "none";
  11339. };
  11340. ke.prototype.begin = function () {
  11341. var e = this;
  11342. var t = e.options;
  11343. if (t.mode === "static") {
  11344. var i = e.createNipple(t.position, e.manager.getIdentifier());
  11345. i.add();
  11346. e.idles.push(i);
  11347. }
  11348. };
  11349. ke.prototype.createNipple = function (e, t) {
  11350. var i = this;
  11351. var n = i.manager.scroll;
  11352. var s = {};
  11353. var r = i.options;
  11354. var o = {
  11355. x: i.parentIsFlex ? n.x : n.x + i.box.left,
  11356. y: i.parentIsFlex ? n.y : n.y + i.box.top
  11357. };
  11358. if (e.x && e.y) {
  11359. s = {
  11360. x: e.x - o.x,
  11361. y: e.y - o.y
  11362. };
  11363. } else if (e.top || e.right || e.bottom || e.left) {
  11364. var l = document.createElement("DIV");
  11365. l.style.display = "hidden";
  11366. l.style.top = e.top;
  11367. l.style.right = e.right;
  11368. l.style.bottom = e.bottom;
  11369. l.style.left = e.left;
  11370. l.style.position = "absolute";
  11371. r.zone.appendChild(l);
  11372. var c = l.getBoundingClientRect();
  11373. r.zone.removeChild(l);
  11374. s = e;
  11375. e = {
  11376. x: c.left + n.x,
  11377. y: c.top + n.y
  11378. };
  11379. }
  11380. var a = new Ee(i, {
  11381. color: r.color,
  11382. size: r.size,
  11383. threshold: r.threshold,
  11384. fadeTime: r.fadeTime,
  11385. dataOnly: r.dataOnly,
  11386. restJoystick: r.restJoystick,
  11387. restOpacity: r.restOpacity,
  11388. mode: r.mode,
  11389. identifier: t,
  11390. position: e,
  11391. zone: r.zone,
  11392. frontPosition: {
  11393. x: 0,
  11394. y: 0
  11395. },
  11396. shape: r.shape
  11397. });
  11398. if (!r.dataOnly) {
  11399. Wr(a.ui.el, s);
  11400. Wr(a.ui.front, a.frontPosition);
  11401. }
  11402. i.nipples.push(a);
  11403. i.trigger("added " + a.identifier + ":added", a);
  11404. i.manager.trigger("added " + a.identifier + ":added", a);
  11405. i.bindNipple(a);
  11406. return a;
  11407. };
  11408. ke.prototype.updateBox = function () {
  11409. var e = this;
  11410. e.box = e.options.zone.getBoundingClientRect();
  11411. };
  11412. ke.prototype.bindNipple = function (e) {
  11413. var t = this;
  11414. var i;
  11415. function n(s, r) {
  11416. i = s.type + " " + r.id + ":" + s.type;
  11417. t.trigger(i, r);
  11418. }
  11419. e.on("destroyed", t.onDestroyed.bind(t));
  11420. e.on("shown hidden rested dir plain", n);
  11421. e.on("dir:up dir:right dir:down dir:left", n);
  11422. e.on("plain:up plain:right plain:down plain:left", n);
  11423. };
  11424. ke.prototype.pressureFn = function (e, t, i) {
  11425. var n = this;
  11426. var s = 0;
  11427. clearInterval(n.pressureIntervals[i]);
  11428. n.pressureIntervals[i] = // TOLOOK
  11429. setInterval(function () {
  11430. var r = e.force || e.pressure || e.webkitForce || 0;
  11431. if (r !== s) {
  11432. t.trigger("pressure", r);
  11433. n.trigger("pressure " + t.identifier + ":pressure", r);
  11434. s = r;
  11435. }
  11436. }.bind(n), 100);
  11437. };
  11438. ke.prototype.onstart = function (e) {
  11439. var t = this;
  11440. var i = t.options;
  11441. var n = e;
  11442. e = fa(e);
  11443. t.updateBox();
  11444. function s(r) {
  11445. if (t.actives.length < i.maxNumberOfNipples) {
  11446. t.processOnStart(r);
  11447. } else if (n.type.match(/^touch/)) {
  11448. Object.keys(t.manager.ids).forEach(function (o) {
  11449. if (Object.values(n.touches).findIndex(function (c) {
  11450. return c.identifier === o;
  11451. }) < 0) {
  11452. var l = [e[0]];
  11453. l.identifier = o;
  11454. t.processOnEnd(l);
  11455. }
  11456. });
  11457. if (t.actives.length < i.maxNumberOfNipples) {
  11458. t.processOnStart(r);
  11459. }
  11460. }
  11461. }
  11462. Ps(e, s);
  11463. t.manager.bindDocument();
  11464. return false;
  11465. };
  11466. ke.prototype.processOnStart = function (e) {
  11467. var t = this;
  11468. var i = t.options;
  11469. var n;
  11470. var s = t.manager.getIdentifier(e);
  11471. var r = e.force || e.pressure || e.webkitForce || 0;
  11472. var o = {
  11473. x: e.pageX,
  11474. y: e.pageY
  11475. };
  11476. var l = t.getOrCreate(s, o);
  11477. if (l.identifier !== s) {
  11478. t.manager.removeIdentifier(l.identifier);
  11479. }
  11480. l.identifier = s;
  11481. function c(f) {
  11482. f.trigger("start", f);
  11483. t.trigger("start " + f.id + ":start", f);
  11484. f.show();
  11485. if (r > 0) {
  11486. t.pressureFn(e, f, f.identifier);
  11487. }
  11488. t.processOnMove(e);
  11489. }
  11490. if ((n = t.idles.indexOf(l)) >= 0) {
  11491. t.idles.splice(n, 1);
  11492. }
  11493. t.actives.push(l);
  11494. t.ids.push(l.identifier);
  11495. if (i.mode !== "semi") {
  11496. c(l);
  11497. } else {
  11498. var a = hn(o, l.position);
  11499. if (a <= i.catchDistance) {
  11500. c(l);
  11501. } else {
  11502. l.destroy();
  11503. t.processOnStart(e);
  11504. return;
  11505. }
  11506. }
  11507. return l;
  11508. };
  11509. ke.prototype.getOrCreate = function (e, t) {
  11510. var i = this;
  11511. var n = i.options;
  11512. var s;
  11513. if (/(semi|static)/.test(n.mode)) {
  11514. s = i.idles[0];
  11515. if (s) {
  11516. i.idles.splice(0, 1);
  11517. return s;
  11518. } else if (n.mode === "semi") {
  11519. return i.createNipple(t, e);
  11520. } else {
  11521. console.warn("Coudln't find the needed nipple.");
  11522. return false;
  11523. }
  11524. } else {
  11525. s = i.createNipple(t, e);
  11526. return s;
  11527. }
  11528. };
  11529. ke.prototype.processOnMove = function (e) {
  11530. var t = this;
  11531. var i = t.options;
  11532. var n = t.manager.getIdentifier(e);
  11533. var s = t.nipples.get(n);
  11534. var r = t.manager.scroll;
  11535. if (!Du(e)) {
  11536. this.processOnEnd(e);
  11537. return;
  11538. }
  11539. if (!s) {
  11540. console.error("Found zombie joystick with ID " + n);
  11541. t.manager.removeIdentifier(n);
  11542. return;
  11543. }
  11544. if (i.dynamicPage) {
  11545. var o = s.el.getBoundingClientRect();
  11546. s.position = {
  11547. x: r.x + o.left,
  11548. y: r.y + o.top
  11549. };
  11550. }
  11551. s.identifier = n;
  11552. var l = s.options.size / 2;
  11553. var c = {
  11554. x: e.pageX,
  11555. y: e.pageY
  11556. };
  11557. if (i.lockX) {
  11558. c.y = s.position.y;
  11559. }
  11560. if (i.lockY) {
  11561. c.x = s.position.x;
  11562. }
  11563. var a = hn(c, s.position);
  11564. var f = $u(c, s.position);
  11565. var d = Cs(f);
  11566. var u = a / l;
  11567. var p = {
  11568. distance: a,
  11569. position: c
  11570. };
  11571. var w;
  11572. var x;
  11573. if (s.options.shape === "circle") {
  11574. w = Math.min(a, l);
  11575. x = Ru(s.position, w, f);
  11576. } else {
  11577. x = zu(c, s.position, l);
  11578. w = hn(x, s.position);
  11579. }
  11580. if (i.follow) {
  11581. if (a > l) {
  11582. let S = c.x - x.x;
  11583. let R = c.y - x.y;
  11584. s.position.x += S;
  11585. s.position.y += R;
  11586. s.el.style.top = s.position.y - (t.box.top + r.y) + "px";
  11587. s.el.style.left = s.position.x - (t.box.left + r.x) + "px";
  11588. a = hn(c, s.position);
  11589. }
  11590. } else {
  11591. c = x;
  11592. a = w;
  11593. }
  11594. var b = c.x - s.position.x;
  11595. var $ = c.y - s.position.y;
  11596. s.frontPosition = {
  11597. x: b,
  11598. y: $
  11599. };
  11600. if (!i.dataOnly) {
  11601. s.ui.front.style.transform = "translate(" + b + "px," + $ + "px)";
  11602. }
  11603. var v = {
  11604. identifier: s.identifier,
  11605. position: c,
  11606. force: u,
  11607. pressure: e.force || e.pressure || e.webkitForce || 0,
  11608. distance: a,
  11609. angle: {
  11610. radian: d,
  11611. degree: f
  11612. },
  11613. vector: {
  11614. x: b / l,
  11615. y: -$ / l
  11616. },
  11617. raw: p,
  11618. instance: s,
  11619. lockX: i.lockX,
  11620. lockY: i.lockY
  11621. };
  11622. v = s.computeDirection(v);
  11623. v.angle = {
  11624. radian: Cs(180 - f),
  11625. degree: 180 - f
  11626. };
  11627. s.trigger("move", v);
  11628. t.trigger("move " + s.id + ":move", v);
  11629. };
  11630. ke.prototype.processOnEnd = function (e) {
  11631. var t = this;
  11632. var i = t.options;
  11633. var n = t.manager.getIdentifier(e);
  11634. var s = t.nipples.get(n);
  11635. var r = t.manager.removeIdentifier(s.identifier);
  11636. if (s) {
  11637. if (!i.dataOnly) {
  11638. s.hide(function () {
  11639. if (i.mode === "dynamic") {
  11640. s.trigger("removed", s);
  11641. t.trigger("removed " + s.id + ":removed", s);
  11642. t.manager.trigger("removed " + s.id + ":removed", s);
  11643. s.destroy();
  11644. }
  11645. });
  11646. }
  11647. clearInterval(t.pressureIntervals[s.identifier]);
  11648. s.resetDirection();
  11649. s.trigger("end", s);
  11650. t.trigger("end " + s.id + ":end", s);
  11651. if (t.ids.indexOf(s.identifier) >= 0) {
  11652. t.ids.splice(t.ids.indexOf(s.identifier), 1);
  11653. }
  11654. if (t.actives.indexOf(s) >= 0) {
  11655. t.actives.splice(t.actives.indexOf(s), 1);
  11656. }
  11657. if (/(semi|static)/.test(i.mode)) {
  11658. t.idles.push(s);
  11659. } else if (t.nipples.indexOf(s) >= 0) {
  11660. t.nipples.splice(t.nipples.indexOf(s), 1);
  11661. }
  11662. t.manager.unbindDocument();
  11663. if (/(semi|static)/.test(i.mode)) {
  11664. t.manager.ids[r.id] = r.identifier;
  11665. }
  11666. }
  11667. };
  11668. ke.prototype.onDestroyed = function (e, t) {
  11669. var i = this;
  11670. if (i.nipples.indexOf(t) >= 0) {
  11671. i.nipples.splice(i.nipples.indexOf(t), 1);
  11672. }
  11673. if (i.actives.indexOf(t) >= 0) {
  11674. i.actives.splice(i.actives.indexOf(t), 1);
  11675. }
  11676. if (i.idles.indexOf(t) >= 0) {
  11677. i.idles.splice(i.idles.indexOf(t), 1);
  11678. }
  11679. if (i.ids.indexOf(t.identifier) >= 0) {
  11680. i.ids.splice(i.ids.indexOf(t.identifier), 1);
  11681. }
  11682. i.manager.removeIdentifier(t.identifier);
  11683. i.manager.unbindDocument();
  11684. };
  11685. ke.prototype.destroy = function () {
  11686. var e = this;
  11687. e.unbindEvt(e.options.zone, "start");
  11688. e.nipples.forEach(function (i) {
  11689. i.destroy();
  11690. });
  11691. for (var t in e.pressureIntervals) {
  11692. if (e.pressureIntervals.hasOwnProperty(t)) {
  11693. clearInterval(e.pressureIntervals[t]);
  11694. }
  11695. }
  11696. e.trigger("destroyed", e.nipples);
  11697. e.manager.unbindDocument();
  11698. e.off();
  11699. };
  11700. function Re(e) {
  11701. var t = this;
  11702. t.ids = {};
  11703. t.index = 0;
  11704. t.collections = [];
  11705. t.scroll = Ur();
  11706. t.config(e);
  11707. t.prepareCollections();
  11708. function i() {
  11709. var s;
  11710. t.collections.forEach(function (r) {
  11711. r.forEach(function (o) {
  11712. s = o.el.getBoundingClientRect();
  11713. o.position = {
  11714. x: t.scroll.x + s.left,
  11715. y: t.scroll.y + s.top
  11716. };
  11717. });
  11718. });
  11719. }
  11720. wn(window, "resize", function () {
  11721. Vr(i);
  11722. });
  11723. function n() {
  11724. t.scroll = Ur();
  11725. }
  11726. wn(window, "scroll", function () {
  11727. Vr(n);
  11728. });
  11729. return t.collections;
  11730. }
  11731. Re.prototype = new dt();
  11732. Re.constructor = Re;
  11733. Re.prototype.prepareCollections = function () {
  11734. var e = this;
  11735. e.collections.create = e.create.bind(e);
  11736. e.collections.on = e.on.bind(e);
  11737. e.collections.off = e.off.bind(e);
  11738. e.collections.destroy = e.destroy.bind(e);
  11739. e.collections.get = function (t) {
  11740. var i;
  11741. e.collections.every(function (n) {
  11742. i = n.get(t);
  11743. return !i;
  11744. });
  11745. return i;
  11746. };
  11747. };
  11748. Re.prototype.create = function (e) {
  11749. return this.createCollection(e);
  11750. };
  11751. Re.prototype.createCollection = function (e) {
  11752. var t = this;
  11753. var i = new ke(t, e);
  11754. t.bindCollection(i);
  11755. t.collections.push(i);
  11756. return i;
  11757. };
  11758. Re.prototype.bindCollection = function (e) {
  11759. var t = this;
  11760. var i;
  11761. function n(s, r) {
  11762. i = s.type + " " + r.id + ":" + s.type;
  11763. t.trigger(i, r);
  11764. }
  11765. e.on("destroyed", t.onDestroyed.bind(t));
  11766. e.on("shown hidden rested dir plain", n);
  11767. e.on("dir:up dir:right dir:down dir:left", n);
  11768. e.on("plain:up plain:right plain:down plain:left", n);
  11769. };
  11770. Re.prototype.bindDocument = function () {
  11771. var e = this;
  11772. if (!e.binded) {
  11773. e.bindEvt(document, "move").bindEvt(document, "end");
  11774. e.binded = true;
  11775. }
  11776. };
  11777. Re.prototype.unbindDocument = function (e) {
  11778. var t = this;
  11779. if (!Object.keys(t.ids).length || e === true) {
  11780. t.unbindEvt(document, "move").unbindEvt(document, "end");
  11781. t.binded = false;
  11782. }
  11783. };
  11784. Re.prototype.getIdentifier = function (e) {
  11785. var t;
  11786. if (e) {
  11787. t = e.identifier === undefined ? e.pointerId : e.identifier;
  11788. if (t === undefined) {
  11789. t = this.latest || 0;
  11790. }
  11791. } else {
  11792. t = this.index;
  11793. }
  11794. if (this.ids[t] === undefined) {
  11795. this.ids[t] = this.index;
  11796. this.index += 1;
  11797. }
  11798. this.latest = t;
  11799. return this.ids[t];
  11800. };
  11801. Re.prototype.removeIdentifier = function (e) {
  11802. var t = {};
  11803. for (var i in this.ids) {
  11804. if (this.ids[i] === e) {
  11805. t.id = i;
  11806. t.identifier = this.ids[i];
  11807. delete this.ids[i];
  11808. break;
  11809. }
  11810. }
  11811. return t;
  11812. };
  11813. Re.prototype.onmove = function (e) {
  11814. var t = this;
  11815. t.onAny("move", e);
  11816. return false;
  11817. };
  11818. Re.prototype.onend = function (e) {
  11819. var t = this;
  11820. t.onAny("end", e);
  11821. return false;
  11822. };
  11823. Re.prototype.oncancel = function (e) {
  11824. var t = this;
  11825. t.onAny("end", e);
  11826. return false;
  11827. };
  11828. Re.prototype.onAny = function (e, t) {
  11829. var i = this;
  11830. var n;
  11831. var s = "processOn" + e.charAt(0).toUpperCase() + e.slice(1);
  11832. t = fa(t);
  11833. function r(l, c, a) {
  11834. if (a.ids.indexOf(c) >= 0) {
  11835. a[s](l);
  11836. l._found_ = true;
  11837. }
  11838. }
  11839. function o(l) {
  11840. n = i.getIdentifier(l);
  11841. Ps(i.collections, r.bind(null, l, n));
  11842. if (!l._found_) {
  11843. i.removeIdentifier(n);
  11844. }
  11845. }
  11846. Ps(t, o);
  11847. return false;
  11848. };
  11849. Re.prototype.destroy = function () {
  11850. var e = this;
  11851. e.unbindDocument(true);
  11852. e.ids = {};
  11853. e.index = 0;
  11854. e.collections.forEach(function (t) {
  11855. t.destroy();
  11856. });
  11857. e.off();
  11858. };
  11859. Re.prototype.onDestroyed = function (e, t) {
  11860. var i = this;
  11861. if (i.collections.indexOf(t) < 0) {
  11862. return false;
  11863. }
  11864. i.collections.splice(i.collections.indexOf(t), 1);
  11865. };
  11866. const Xr = new Re();
  11867. const qr = {
  11868. create: function (e) {
  11869. return Xr.create(e);
  11870. },
  11871. factory: Xr
  11872. };
  11873. let Gr = false;
  11874. const Fu = e => {
  11875. if (Gr) {
  11876. return;
  11877. }
  11878. Gr = true;
  11879. const t = document.getElementById("touch-controls-left");
  11880. const i = qr.create({
  11881. zone: t
  11882. });
  11883. i.on("start", e.onStartMoving);
  11884. i.on("end", e.onStopMoving);
  11885. i.on("move", e.onRotateMoving);
  11886. const n = document.getElementById("touch-controls-right");
  11887. const s = qr.create({
  11888. zone: n
  11889. });
  11890. s.on("start", e.onStartAttacking);
  11891. s.on("end", e.onStopAttacking);
  11892. s.on("move", e.onRotateAttacking);
  11893. t.style.display = "block";
  11894. n.style.display = "block";
  11895. };
  11896. const Vu = {
  11897. enable: Fu
  11898. };
  11899. var Nu = Object.defineProperty;
  11900. var Uu = (e, t, i) => t in e ? Nu(e, t, {
  11901. enumerable: true,
  11902. configurable: true,
  11903. writable: true,
  11904. value: i
  11905. }) : e[t] = i;
  11906. var Ge = (e, t, i) => Uu(e, typeof t != "symbol" ? t + "" : t, i);
  11907. const pa = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIHAoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiB3KGUsdCxyKXtyZXR1cm4gcChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChyLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGIoZSx0LHI9IlNIQS0yNTYiLG49MWU2LHM9MCl7Y29uc3Qgbz1uZXcgQWJvcnRDb250cm9sbGVyLGE9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgYz1zO2M8PW47Yys9MSl7aWYoby5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCB3KHQsYyxyKT09PWUpcmV0dXJue251bWJlcjpjLHRvb2s6RGF0ZS5ub3coKS1hfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjpvfX1mdW5jdGlvbiBoKGUpe2NvbnN0IHQ9YXRvYihlKSxyPW5ldyBVaW50OEFycmF5KHQubGVuZ3RoKTtmb3IobGV0IG49MDtuPHQubGVuZ3RoO24rKylyW25dPXQuY2hhckNvZGVBdChuKTtyZXR1cm4gcn1mdW5jdGlvbiBnKGUsdD0xMil7Y29uc3Qgcj1uZXcgVWludDhBcnJheSh0KTtmb3IobGV0IG49MDtuPHQ7bisrKXJbbl09ZSUyNTYsZT1NYXRoLmZsb29yKGUvMjU2KTtyZXR1cm4gcn1hc3luYyBmdW5jdGlvbiBtKGUsdD0iIixyPTFlNixuPTApe2NvbnN0IHM9IkFFUy1HQ00iLG89bmV3IEFib3J0Q29udHJvbGxlcixhPURhdGUubm93KCksbD1hc3luYygpPT57Zm9yKGxldCB1PW47dTw9cjt1Kz0xKXtpZihvLnNpZ25hbC5hYm9ydGVkfHwhY3x8IXkpcmV0dXJuIG51bGw7dHJ5e2NvbnN0IGQ9YXdhaXQgY3J5cHRvLnN1YnRsZS5kZWNyeXB0KHtuYW1lOnMsaXY6Zyh1KX0sYyx5KTtpZihkKXJldHVybntjbGVhclRleHQ6bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKGQpLHRvb2s6RGF0ZS5ub3coKS1hfX1jYXRjaHt9fXJldHVybiBudWxsfTtsZXQgYz1udWxsLHk9bnVsbDt0cnl7eT1oKGUpO2NvbnN0IHU9YXdhaXQgY3J5cHRvLnN1YnRsZS5kaWdlc3QoIlNIQS0yNTYiLGYuZW5jb2RlKHQpKTtjPWF3YWl0IGNyeXB0by5zdWJ0bGUuaW1wb3J0S2V5KCJyYXciLHUscywhMSxbImRlY3J5cHQiXSl9Y2F0Y2h7cmV0dXJue3Byb21pc2U6UHJvbWlzZS5yZWplY3QoKSxjb250cm9sbGVyOm99fXJldHVybntwcm9taXNlOmwoKSxjb250cm9sbGVyOm99fWxldCBpO29ubWVzc2FnZT1hc3luYyBlPT57Y29uc3R7dHlwZTp0LHBheWxvYWQ6cixzdGFydDpuLG1heDpzfT1lLmRhdGE7bGV0IG89bnVsbDtpZih0PT09ImFib3J0IilpPT1udWxsfHxpLmFib3J0KCksaT12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtpZigib2JmdXNjYXRlZCJpbiByKXtjb25zdHtrZXk6YSxvYmZ1c2NhdGVkOmx9PXJ8fHt9O289YXdhaXQgbShsLGEscyxuKX1lbHNle2NvbnN0e2FsZ29yaXRobTphLGNoYWxsZW5nZTpsLHNhbHQ6Y309cnx8e307bz1iKGwsYyxhLHMsbil9aT1vLmNvbnRyb2xsZXIsby5wcm9taXNlLnRoZW4oYT0+e3NlbGYucG9zdE1lc3NhZ2UoYSYmey4uLmEsd29ya2VyOiEwfSl9KX19fSkoKTsK";
  11908. const Wu = e => Uint8Array.from(atob(e), t => t.charCodeAt(0));
  11909. const Yr = typeof self !== "undefined" && self.Blob && new Blob([Wu(pa)], {
  11910. type: "text/javascript;charset=utf-8"
  11911. });
  11912. function Xu(e) {
  11913. let t;
  11914. try {
  11915. t = Yr && (self.URL || self.webkitURL).createObjectURL(Yr);
  11916. if (!t) {
  11917. throw "";
  11918. }
  11919. const i = new Worker(t, {
  11920. name: e == null ? undefined : e.name
  11921. });
  11922. i.addEventListener("error", () => {
  11923. (self.URL || self.webkitURL).revokeObjectURL(t);
  11924. });
  11925. return i;
  11926. } catch {
  11927. return new Worker("data:text/javascript;base64," + pa, {
  11928. name: e == null ? undefined : e.name
  11929. });
  11930. } finally {
  11931. if (t) {
  11932. (self.URL || self.webkitURL).revokeObjectURL(t);
  11933. }
  11934. }
  11935. }
  11936. function vn() {}
  11937. function qu(e, t) {
  11938. for (const i in t) {
  11939. e[i] = t[i];
  11940. }
  11941. return e;
  11942. }
  11943. function ma(e) {
  11944. return e();
  11945. }
  11946. function Kr() {
  11947. return Object.create(null);
  11948. }
  11949. function Ji(e) {
  11950. e.forEach(ma);
  11951. }
  11952. function ga(e) {
  11953. return typeof e == "function";
  11954. }
  11955. function Gu(e, t) {
  11956. if (e != e) {
  11957. return t == t;
  11958. } else {
  11959. return e !== t || e && typeof e == "object" || typeof e == "function";
  11960. }
  11961. }
  11962. function Yu(e) {
  11963. return Object.keys(e).length === 0;
  11964. }
  11965. function Ku(e, t, i, n) {
  11966. if (e) {
  11967. const s = ya(e, t, i, n);
  11968. return e[0](s);
  11969. }
  11970. }
  11971. function ya(e, t, i, n) {
  11972. if (e[1] && n) {
  11973. return qu(i.ctx.slice(), e[1](n(t)));
  11974. } else {
  11975. return i.ctx;
  11976. }
  11977. }
  11978. function Zu(e, t, i, n) {
  11979. if (e[2] && n) {
  11980. const s = e[2](n(i));
  11981. if (t.dirty === undefined) {
  11982. return s;
  11983. }
  11984. if (typeof s == "object") {
  11985. const r = [];
  11986. const o = Math.max(t.dirty.length, s.length);
  11987. for (let l = 0; l < o; l += 1) {
  11988. r[l] = t.dirty[l] | s[l];
  11989. }
  11990. return r;
  11991. }
  11992. return t.dirty | s;
  11993. }
  11994. return t.dirty;
  11995. }
  11996. function Ju(e, t, i, n, s, r) {
  11997. if (s) {
  11998. const o = ya(t, i, n, r);
  11999. e.p(o, s);
  12000. }
  12001. }
  12002. function Qu(e) {
  12003. if (e.ctx.length > 32) {
  12004. const t = [];
  12005. const i = e.ctx.length / 32;
  12006. for (let n = 0; n < i; n++) {
  12007. t[n] = -1;
  12008. }
  12009. return t;
  12010. }
  12011. return -1;
  12012. }
  12013. function we(e, t) {
  12014. e.appendChild(t);
  12015. }
  12016. function ju(e, t, i) {
  12017. const n = ef(e);
  12018. if (!n.getElementById(t)) {
  12019. const s = Me("style");
  12020. s.id = t;
  12021. s.textContent = i;
  12022. tf(n, s);
  12023. }
  12024. }
  12025. function ef(e) {
  12026. if (!e) {
  12027. return document;
  12028. }
  12029. const t = e.getRootNode ? e.getRootNode() : e.ownerDocument;
  12030. if (t && t.host) {
  12031. return t;
  12032. } else {
  12033. return e.ownerDocument;
  12034. }
  12035. }
  12036. function tf(e, t) {
  12037. we(e.head || e, t);
  12038. return t.sheet;
  12039. }
  12040. function He(e, t, i) {
  12041. e.insertBefore(t, i || null);
  12042. }
  12043. function _e(e) {
  12044. if (e.parentNode) {
  12045. e.parentNode.removeChild(e);
  12046. }
  12047. }
  12048. function Me(e) {
  12049. return document.createElement(e);
  12050. }
  12051. function ht(e) {
  12052. return document.createElementNS("http://www.w3.org/2000/svg", e);
  12053. }
  12054. function nf(e) {
  12055. return document.createTextNode(e);
  12056. }
  12057. function rt() {
  12058. return nf(" ");
  12059. }
  12060. function ls(e, t, i, n) {
  12061. e.addEventListener(t, i, n);
  12062. return () => e.removeEventListener(t, i, n);
  12063. }
  12064. function H(e, t, i) {
  12065. if (i == null) {
  12066. e.removeAttribute(t);
  12067. } else if (e.getAttribute(t) !== i) {
  12068. e.setAttribute(t, i);
  12069. }
  12070. }
  12071. function sf(e) {
  12072. return Array.from(e.childNodes);
  12073. }
  12074. function Zr(e, t, i) {
  12075. e.classList.toggle(t, !!i);
  12076. }
  12077. function rf(e, t, {
  12078. bubbles: i = false,
  12079. cancelable: n = false
  12080. } = {}) {
  12081. return new CustomEvent(e, {
  12082. detail: t,
  12083. bubbles: i,
  12084. cancelable: n
  12085. });
  12086. }
  12087. function of(e) {
  12088. const t = {};
  12089. e.childNodes.forEach(i => {
  12090. t[i.slot || "default"] = true;
  12091. });
  12092. return t;
  12093. }
  12094. let Xi;
  12095. function zi(e) {
  12096. Xi = e;
  12097. }
  12098. function ir() {
  12099. if (!Xi) {
  12100. throw new Error("Function called outside component initialization");
  12101. }
  12102. return Xi;
  12103. }
  12104. function af(e) {
  12105. ir().$$.on_mount.push(e);
  12106. }
  12107. function lf(e) {
  12108. ir().$$.on_destroy.push(e);
  12109. }
  12110. function cf() {
  12111. const e = ir();
  12112. return (t, i, {
  12113. cancelable: n = false
  12114. } = {}) => {
  12115. const s = e.$$.callbacks[t];
  12116. if (s) {
  12117. const r = rf(t, i, {
  12118. cancelable: n
  12119. });
  12120. s.slice().forEach(o => {
  12121. o.call(e, r);
  12122. });
  12123. return !r.defaultPrevented;
  12124. }
  12125. return true;
  12126. };
  12127. }
  12128. const Qt = [];
  12129. const kn = [];
  12130. let ci = [];
  12131. const Jr = [];
  12132. const wa = Promise.resolve();
  12133. let $s = false;
  12134. function va() {
  12135. if (!$s) {
  12136. $s = true;
  12137. wa.then(ce);
  12138. }
  12139. }
  12140. function hf() {
  12141. va();
  12142. return wa;
  12143. }
  12144. function Rs(e) {
  12145. ci.push(e);
  12146. }
  12147. const cs = new Set();
  12148. let Xt = 0;
  12149. function ce() {
  12150. if (Xt !== 0) {
  12151. return;
  12152. }
  12153. const e = Xi;
  12154. do {
  12155. try {
  12156. for (; Xt < Qt.length;) {
  12157. const t = Qt[Xt];
  12158. Xt++;
  12159. zi(t);
  12160. uf(t.$$);
  12161. }
  12162. } catch (t) {
  12163. Qt.length = 0;
  12164. Xt = 0;
  12165. throw t;
  12166. }
  12167. zi(null);
  12168. Qt.length = 0;
  12169. Xt = 0;
  12170. for (; kn.length;) {
  12171. kn.pop()();
  12172. }
  12173. for (let t = 0; t < ci.length; t += 1) {
  12174. const i = ci[t];
  12175. if (!cs.has(i)) {
  12176. cs.add(i);
  12177. i();
  12178. }
  12179. }
  12180. ci.length = 0;
  12181. } while (Qt.length);
  12182. for (; Jr.length;) {
  12183. Jr.pop()();
  12184. }
  12185. $s = false;
  12186. cs.clear();
  12187. zi(e);
  12188. }
  12189. function uf(e) {
  12190. if (e.fragment !== null) {
  12191. e.update();
  12192. Ji(e.before_update);
  12193. const t = e.dirty;
  12194. e.dirty = [-1];
  12195. if (e.fragment) {
  12196. e.fragment.p(e.ctx, t);
  12197. }
  12198. e.after_update.forEach(Rs);
  12199. }
  12200. }
  12201. function ff(e) {
  12202. const t = [];
  12203. const i = [];
  12204. ci.forEach(n => e.indexOf(n) === -1 ? t.push(n) : i.push(n));
  12205. i.forEach(n => n());
  12206. ci = t;
  12207. }
  12208. const un = new Set();
  12209. let df;
  12210. function ka(e, t) {
  12211. if (e && e.i) {
  12212. un.delete(e);
  12213. e.i(t);
  12214. }
  12215. }
  12216. function pf(e, t, i, n) {
  12217. if (e && e.o) {
  12218. if (un.has(e)) {
  12219. return;
  12220. }
  12221. un.add(e);
  12222. df.c.push(() => {
  12223. un.delete(e);
  12224. });
  12225. e.o(t);
  12226. }
  12227. }
  12228. function mf(e, t, i) {
  12229. const {
  12230. fragment: n,
  12231. after_update: s
  12232. } = e.$$;
  12233. if (n) {
  12234. n.m(t, i);
  12235. }
  12236. Rs(() => {
  12237. const r = e.$$.on_mount.map(ma).filter(ga);
  12238. if (e.$$.on_destroy) {
  12239. e.$$.on_destroy.push(...r);
  12240. } else {
  12241. Ji(r);
  12242. }
  12243. e.$$.on_mount = [];
  12244. });
  12245. s.forEach(Rs);
  12246. }
  12247. function gf(e, t) {
  12248. const i = e.$$;
  12249. if (i.fragment !== null) {
  12250. ff(i.after_update);
  12251. Ji(i.on_destroy);
  12252. if (i.fragment) {
  12253. i.fragment.d(t);
  12254. }
  12255. i.on_destroy = i.fragment = null;
  12256. i.ctx = [];
  12257. }
  12258. }
  12259. function yf(e, t) {
  12260. if (e.$$.dirty[0] === -1) {
  12261. Qt.push(e);
  12262. va();
  12263. e.$$.dirty.fill(0);
  12264. }
  12265. e.$$.dirty[t / 31 | 0] |= 1 << t % 31;
  12266. }
  12267. function wf(e, t, i, n, s, r, o = null, l = [-1]) {
  12268. const c = Xi;
  12269. zi(e);
  12270. const a = e.$$ = {
  12271. fragment: null,
  12272. ctx: [],
  12273. props: r,
  12274. update: vn,
  12275. not_equal: s,
  12276. bound: Kr(),
  12277. on_mount: [],
  12278. on_destroy: [],
  12279. on_disconnect: [],
  12280. before_update: [],
  12281. after_update: [],
  12282. context: new Map(t.context || (c ? c.$$.context : [])),
  12283. callbacks: Kr(),
  12284. dirty: l,
  12285. skip_bound: false,
  12286. root: t.target || c.$$.root
  12287. };
  12288. if (o) {
  12289. o(a.root);
  12290. }
  12291. let f = false;
  12292. a.ctx = i ? i(e, t.props || {}, (d, u, ...p) => {
  12293. const w = p.length ? p[0] : u;
  12294. if (a.ctx && s(a.ctx[d], a.ctx[d] = w)) {
  12295. if (!a.skip_bound && a.bound[d]) {
  12296. a.bound[d](w);
  12297. }
  12298. if (f) {
  12299. yf(e, d);
  12300. }
  12301. }
  12302. return u;
  12303. }) : [];
  12304. a.update();
  12305. f = true;
  12306. Ji(a.before_update);
  12307. a.fragment = n ? n(a.ctx) : false;
  12308. if (t.target) {
  12309. if (t.hydrate) {
  12310. const d = sf(t.target);
  12311. if (a.fragment) {
  12312. a.fragment.l(d);
  12313. }
  12314. d.forEach(_e);
  12315. } else if (a.fragment) {
  12316. a.fragment.c();
  12317. }
  12318. if (t.intro) {
  12319. ka(e.$$.fragment);
  12320. }
  12321. mf(e, t.target, t.anchor);
  12322. ce();
  12323. }
  12324. zi(c);
  12325. }
  12326. let xa;
  12327. if (typeof HTMLElement == "function") {
  12328. xa = class extends HTMLElement {
  12329. constructor(e, t, i) {
  12330. super();
  12331. Ge(this, "$$ctor");
  12332. Ge(this, "$$s");
  12333. Ge(this, "$$c");
  12334. Ge(this, "$$cn", false);
  12335. Ge(this, "$$d", {});
  12336. Ge(this, "$$r", false);
  12337. Ge(this, "$$p_d", {});
  12338. Ge(this, "$$l", {});
  12339. Ge(this, "$$l_u", new Map());
  12340. this.$$ctor = e;
  12341. this.$$s = t;
  12342. if (i) {
  12343. this.attachShadow({
  12344. mode: "open"
  12345. });
  12346. }
  12347. }
  12348. addEventListener(e, t, i) {
  12349. this.$$l[e] = this.$$l[e] || [];
  12350. this.$$l[e].push(t);
  12351. if (this.$$c) {
  12352. const n = this.$$c.$on(e, t);
  12353. this.$$l_u.set(t, n);
  12354. }
  12355. super.addEventListener(e, t, i);
  12356. }
  12357. removeEventListener(e, t, i) {
  12358. super.removeEventListener(e, t, i);
  12359. if (this.$$c) {
  12360. const n = this.$$l_u.get(t);
  12361. if (n) {
  12362. n();
  12363. this.$$l_u.delete(t);
  12364. }
  12365. }
  12366. if (this.$$l[e]) {
  12367. const n = this.$$l[e].indexOf(t);
  12368. if (n >= 0) {
  12369. this.$$l[e].splice(n, 1);
  12370. }
  12371. }
  12372. }
  12373. async connectedCallback() {
  12374. this.$$cn = true;
  12375. if (!this.$$c) {
  12376. let e = function (s) {
  12377. return () => {
  12378. let r;
  12379. return {
  12380. c: function () {
  12381. r = Me("slot");
  12382. if (s !== "default") {
  12383. H(r, "name", s);
  12384. }
  12385. },
  12386. m: function (o, l) {
  12387. He(o, r, l);
  12388. },
  12389. d: function (o) {
  12390. if (o) {
  12391. _e(r);
  12392. }
  12393. }
  12394. };
  12395. };
  12396. };
  12397. await Promise.resolve();
  12398. if (!this.$$cn || this.$$c) {
  12399. return;
  12400. }
  12401. const t = {};
  12402. const i = of(this);
  12403. for (const s of this.$$s) {
  12404. if (s in i) {
  12405. t[s] = [e(s)];
  12406. }
  12407. }
  12408. for (const s of this.attributes) {
  12409. const r = this.$$g_p(s.name);
  12410. if (!(r in this.$$d)) {
  12411. this.$$d[r] = fn(r, s.value, this.$$p_d, "toProp");
  12412. }
  12413. }
  12414. for (const s in this.$$p_d) {
  12415. if (!(s in this.$$d) && this[s] !== undefined) {
  12416. this.$$d[s] = this[s];
  12417. delete this[s];
  12418. }
  12419. }
  12420. this.$$c = new this.$$ctor({
  12421. target: this.shadowRoot || this,
  12422. props: {
  12423. ...this.$$d,
  12424. $$slots: t,
  12425. $$scope: {
  12426. ctx: []
  12427. }
  12428. }
  12429. });
  12430. const n = () => {
  12431. this.$$r = true;
  12432. for (const s in this.$$p_d) {
  12433. this.$$d[s] = this.$$c.$$.ctx[this.$$c.$$.props[s]];
  12434. if (this.$$p_d[s].reflect) {
  12435. const r = fn(s, this.$$d[s], this.$$p_d, "toAttribute");
  12436. if (r == null) {
  12437. this.removeAttribute(this.$$p_d[s].attribute || s);
  12438. } else {
  12439. this.setAttribute(this.$$p_d[s].attribute || s, r);
  12440. }
  12441. }
  12442. }
  12443. this.$$r = false;
  12444. };
  12445. this.$$c.$$.after_update.push(n);
  12446. n();
  12447. for (const s in this.$$l) {
  12448. for (const r of this.$$l[s]) {
  12449. const o = this.$$c.$on(s, r);
  12450. this.$$l_u.set(r, o);
  12451. }
  12452. }
  12453. this.$$l = {};
  12454. }
  12455. }
  12456. attributeChangedCallback(e, t, i) {
  12457. var n;
  12458. if (!this.$$r) {
  12459. e = this.$$g_p(e);
  12460. this.$$d[e] = fn(e, i, this.$$p_d, "toProp");
  12461. if (!((n = this.$$c) == null)) {
  12462. n.$set({
  12463. [e]: this.$$d[e]
  12464. });
  12465. }
  12466. }
  12467. }
  12468. disconnectedCallback() {
  12469. this.$$cn = false;
  12470. Promise.resolve().then(() => {
  12471. if (!this.$$cn && this.$$c) {
  12472. this.$$c.$destroy();
  12473. this.$$c = undefined;
  12474. }
  12475. });
  12476. }
  12477. $$g_p(e) {
  12478. return Object.keys(this.$$p_d).find(t => this.$$p_d[t].attribute === e || !this.$$p_d[t].attribute && t.toLowerCase() === e) || e;
  12479. }
  12480. };
  12481. }
  12482. function fn(e, t, i, n) {
  12483. var s;
  12484. const r = (s = i[e]) == null ? undefined : s.type;
  12485. t = r === "Boolean" && typeof t != "boolean" ? t != null : t;
  12486. if (!n || !i[e]) {
  12487. return t;
  12488. }
  12489. if (n === "toAttribute") {
  12490. switch (r) {
  12491. case "Object":
  12492. case "Array":
  12493. if (t == null) {
  12494. return null;
  12495. } else {
  12496. return JSON.stringify(t);
  12497. }
  12498. case "Boolean":
  12499. if (t) {
  12500. return "";
  12501. } else {
  12502. return null;
  12503. }
  12504. case "Number":
  12505. return t ?? null;
  12506. default:
  12507. return t;
  12508. }
  12509. } else {
  12510. switch (r) {
  12511. case "Object":
  12512. case "Array":
  12513. return t && JSON.parse(t);
  12514. case "Boolean":
  12515. return t;
  12516. case "Number":
  12517. if (t != null) {
  12518. return +t;
  12519. } else {
  12520. return t;
  12521. }
  12522. default:
  12523. return t;
  12524. }
  12525. }
  12526. }
  12527. function vf(e, t, i, n, s, r) {
  12528. let o = class extends xa {
  12529. constructor() {
  12530. super(e, i, s);
  12531. this.$$p_d = t;
  12532. }
  12533. static get observedAttributes() {
  12534. return Object.keys(t).map(l => (t[l].attribute || l).toLowerCase());
  12535. }
  12536. };
  12537. Object.keys(t).forEach(l => {
  12538. Object.defineProperty(o.prototype, l, {
  12539. get() {
  12540. if (this.$$c && l in this.$$c) {
  12541. return this.$$c[l];
  12542. } else {
  12543. return this.$$d[l];
  12544. }
  12545. },
  12546. set(c) {
  12547. var a;
  12548. c = fn(l, c, t);
  12549. this.$$d[l] = c;
  12550. if (!((a = this.$$c) == null)) {
  12551. a.$set({
  12552. [l]: c
  12553. });
  12554. }
  12555. }
  12556. });
  12557. });
  12558. n.forEach(l => {
  12559. Object.defineProperty(o.prototype, l, {
  12560. get() {
  12561. var c;
  12562. if ((c = this.$$c) == null) {
  12563. return undefined;
  12564. } else {
  12565. return c[l];
  12566. }
  12567. }
  12568. });
  12569. });
  12570. e.element = o;
  12571. return o;
  12572. }
  12573. class kf {
  12574. constructor() {
  12575. Ge(this, "$$");
  12576. Ge(this, "$$set");
  12577. }
  12578. $destroy() {
  12579. gf(this, 1);
  12580. this.$destroy = vn;
  12581. }
  12582. $on(t, i) {
  12583. if (!ga(i)) {
  12584. return vn;
  12585. }
  12586. const n = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
  12587. n.push(i);
  12588. return () => {
  12589. const s = n.indexOf(i);
  12590. if (s !== -1) {
  12591. n.splice(s, 1);
  12592. }
  12593. };
  12594. }
  12595. $set(t) {
  12596. if (this.$$set && !Yu(t)) {
  12597. this.$$.skip_bound = true;
  12598. this.$$set(t);
  12599. this.$$.skip_bound = false;
  12600. }
  12601. }
  12602. }
  12603. const xf = "4";
  12604. if (typeof window !== "undefined") {
  12605. (window.__svelte || (window.__svelte = {
  12606. v: new Set()
  12607. })).v.add(xf);
  12608. }
  12609. const ba = new TextEncoder();
  12610. function bf(e) {
  12611. return [...new Uint8Array(e)].map(t => t.toString(16).padStart(2, "0")).join("");
  12612. }
  12613. async function Sf(e, t = "SHA-256", i = 100000) {
  12614. const n = Date.now().toString(16);
  12615. if (!e) {
  12616. e = Math.round(Math.random() * i);
  12617. }
  12618. const s = await Sa(n, e, t);
  12619. return {
  12620. algorithm: t,
  12621. challenge: s,
  12622. salt: n,
  12623. signature: ""
  12624. };
  12625. }
  12626. async function Sa(e, t, i) {
  12627. return bf(await crypto.subtle.digest(i.toUpperCase(), ba.encode(e + t)));
  12628. }
  12629. function If(e, t, i = "SHA-256", n = 1000000, s = 0) {
  12630. const r = new AbortController();
  12631. const o = Date.now();
  12632. return {
  12633. promise: (async () => {
  12634. for (let l = s; l <= n; l += 1) {
  12635. if (r.signal.aborted) {
  12636. return null;
  12637. }
  12638. if ((await Sa(t, l, i)) === e) {
  12639. return {
  12640. number: l,
  12641. took: Date.now() - o
  12642. };
  12643. }
  12644. }
  12645. return null;
  12646. })(),
  12647. controller: r
  12648. };
  12649. }
  12650. function Tf() {
  12651. try {
  12652. return Intl.DateTimeFormat().resolvedOptions().timeZone;
  12653. } catch {}
  12654. }
  12655. function Mf(e) {
  12656. const t = atob(e);
  12657. const i = new Uint8Array(t.length);
  12658. for (let n = 0; n < t.length; n++) {
  12659. i[n] = t.charCodeAt(n);
  12660. }
  12661. return i;
  12662. }
  12663. function Ef(e, t = 12) {
  12664. const i = new Uint8Array(t);
  12665. for (let n = 0; n < t; n++) {
  12666. i[n] = e % 256;
  12667. e = Math.floor(e / 256);
  12668. }
  12669. return i;
  12670. }
  12671. async function Cf(e, t = "", i = 1000000, n = 0) {
  12672. const s = "AES-GCM";
  12673. const r = new AbortController();
  12674. const o = Date.now();
  12675. const l = async () => {
  12676. for (let f = n; f <= i; f += 1) {
  12677. if (r.signal.aborted || !c || !a) {
  12678. return null;
  12679. }
  12680. try {
  12681. const d = await crypto.subtle.decrypt({
  12682. name: s,
  12683. iv: Ef(f)
  12684. }, c, a);
  12685. if (d) {
  12686. return {
  12687. clearText: new TextDecoder().decode(d),
  12688. took: Date.now() - o
  12689. };
  12690. }
  12691. } catch {}
  12692. }
  12693. return null;
  12694. };
  12695. let c = null;
  12696. let a = null;
  12697. try {
  12698. a = Mf(e);
  12699. const f = await crypto.subtle.digest("SHA-256", ba.encode(t));
  12700. c = await crypto.subtle.importKey("raw", f, s, false, ["decrypt"]);
  12701. } catch {
  12702. return {
  12703. promise: Promise.reject(),
  12704. controller: r
  12705. };
  12706. }
  12707. return {
  12708. promise: l(),
  12709. controller: r
  12710. };
  12711. }
  12712. var Q = (e => {
  12713. e.ERROR = "error";
  12714. e.VERIFIED = "verified";
  12715. e.VERIFYING = "verifying";
  12716. e.UNVERIFIED = "unverified";
  12717. e.EXPIRED = "expired";
  12718. return e;
  12719. })(Q || {});
  12720. function Pf(e) {
  12721. ju(e, "svelte-ddsc3z", ".altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:\"\";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}");
  12722. }
  12723. function Qr(e) {
  12724. let t;
  12725. let i;
  12726. let n;
  12727. return {
  12728. c() {
  12729. t = ht("svg");
  12730. i = ht("path");
  12731. n = ht("path");
  12732. H(i, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z");
  12733. H(i, "fill", "currentColor");
  12734. H(i, "opacity", ".25");
  12735. H(n, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z");
  12736. H(n, "fill", "currentColor");
  12737. H(n, "class", "altcha-spinner svelte-ddsc3z");
  12738. H(t, "width", "24");
  12739. H(t, "height", "24");
  12740. H(t, "viewBox", "0 0 24 24");
  12741. H(t, "xmlns", "http://www.w3.org/2000/svg");
  12742. },
  12743. m(s, r) {
  12744. He(s, t, r);
  12745. we(t, i);
  12746. we(t, n);
  12747. },
  12748. d(s) {
  12749. if (s) {
  12750. _e(t);
  12751. }
  12752. }
  12753. };
  12754. }
  12755. function $f(e) {
  12756. let t;
  12757. let i = e[11].label + "";
  12758. let n;
  12759. return {
  12760. c() {
  12761. t = Me("label");
  12762. H(t, "for", n = e[4] + "_checkbox");
  12763. H(t, "class", "svelte-ddsc3z");
  12764. },
  12765. m(s, r) {
  12766. He(s, t, r);
  12767. t.innerHTML = i;
  12768. },
  12769. p(s, r) {
  12770. if (r[0] & 2048 && i !== (i = s[11].label + "")) {
  12771. t.innerHTML = i;
  12772. }
  12773. if (r[0] & 16 && n !== (n = s[4] + "_checkbox")) {
  12774. H(t, "for", n);
  12775. }
  12776. },
  12777. d(s) {
  12778. if (s) {
  12779. _e(t);
  12780. }
  12781. }
  12782. };
  12783. }
  12784. function Rf(e) {
  12785. let t;
  12786. let i = e[11].verifying + "";
  12787. return {
  12788. c() {
  12789. t = Me("span");
  12790. },
  12791. m(n, s) {
  12792. He(n, t, s);
  12793. t.innerHTML = i;
  12794. },
  12795. p(n, s) {
  12796. if (s[0] & 2048 && i !== (i = n[11].verifying + "")) {
  12797. t.innerHTML = i;
  12798. }
  12799. },
  12800. d(n) {
  12801. if (n) {
  12802. _e(t);
  12803. }
  12804. }
  12805. };
  12806. }
  12807. function Af(e) {
  12808. let t;
  12809. let i = e[11].verified + "";
  12810. let n;
  12811. let s;
  12812. return {
  12813. c() {
  12814. t = Me("span");
  12815. n = rt();
  12816. s = Me("input");
  12817. H(s, "type", "hidden");
  12818. H(s, "name", e[4]);
  12819. s.value = e[6];
  12820. },
  12821. m(r, o) {
  12822. He(r, t, o);
  12823. t.innerHTML = i;
  12824. He(r, n, o);
  12825. He(r, s, o);
  12826. },
  12827. p(r, o) {
  12828. if (o[0] & 2048 && i !== (i = r[11].verified + "")) {
  12829. t.innerHTML = i;
  12830. }
  12831. if (o[0] & 16) {
  12832. H(s, "name", r[4]);
  12833. }
  12834. if (o[0] & 64) {
  12835. s.value = r[6];
  12836. }
  12837. },
  12838. d(r) {
  12839. if (r) {
  12840. _e(t);
  12841. _e(n);
  12842. _e(s);
  12843. }
  12844. }
  12845. };
  12846. }
  12847. function jr(e) {
  12848. let t;
  12849. let i;
  12850. let n;
  12851. let s;
  12852. let r;
  12853. let o;
  12854. let l;
  12855. return {
  12856. c() {
  12857. t = Me("div");
  12858. i = Me("a");
  12859. n = ht("svg");
  12860. s = ht("path");
  12861. r = ht("path");
  12862. o = ht("path");
  12863. H(s, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z");
  12864. H(s, "fill", "currentColor");
  12865. H(r, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z");
  12866. H(r, "fill", "currentColor");
  12867. H(o, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z");
  12868. H(o, "fill", "currentColor");
  12869. H(n, "width", "22");
  12870. H(n, "height", "22");
  12871. H(n, "viewBox", "0 0 20 20");
  12872. H(n, "fill", "none");
  12873. H(n, "xmlns", "http://www.w3.org/2000/svg");
  12874. H(i, "href", Ia);
  12875. H(i, "target", "_blank");
  12876. H(i, "class", "altcha-logo svelte-ddsc3z");
  12877. H(i, "aria-label", l = e[11].ariaLinkLabel);
  12878. },
  12879. m(c, a) {
  12880. He(c, t, a);
  12881. we(t, i);
  12882. we(i, n);
  12883. we(n, s);
  12884. we(n, r);
  12885. we(n, o);
  12886. },
  12887. p(c, a) {
  12888. if (a[0] & 2048 && l !== (l = c[11].ariaLinkLabel)) {
  12889. H(i, "aria-label", l);
  12890. }
  12891. },
  12892. d(c) {
  12893. if (c) {
  12894. _e(t);
  12895. }
  12896. }
  12897. };
  12898. }
  12899. function eo(e) {
  12900. let t;
  12901. let i;
  12902. let n;
  12903. let s;
  12904. function r(c, a) {
  12905. if (c[7] === Q.EXPIRED) {
  12906. return Of;
  12907. } else {
  12908. return Df;
  12909. }
  12910. }
  12911. let o = r(e);
  12912. let l = o(e);
  12913. return {
  12914. c() {
  12915. t = Me("div");
  12916. i = ht("svg");
  12917. n = ht("path");
  12918. s = rt();
  12919. l.c();
  12920. H(n, "stroke-linecap", "round");
  12921. H(n, "stroke-linejoin", "round");
  12922. H(n, "d", "M6 18L18 6M6 6l12 12");
  12923. H(i, "width", "14");
  12924. H(i, "height", "14");
  12925. H(i, "xmlns", "http://www.w3.org/2000/svg");
  12926. H(i, "fill", "none");
  12927. H(i, "viewBox", "0 0 24 24");
  12928. H(i, "stroke-width", "1.5");
  12929. H(i, "stroke", "currentColor");
  12930. H(t, "class", "altcha-error svelte-ddsc3z");
  12931. },
  12932. m(c, a) {
  12933. He(c, t, a);
  12934. we(t, i);
  12935. we(i, n);
  12936. we(t, s);
  12937. l.m(t, null);
  12938. },
  12939. p(c, a) {
  12940. if (o === (o = r(c)) && l) {
  12941. l.p(c, a);
  12942. } else {
  12943. l.d(1);
  12944. l = o(c);
  12945. if (l) {
  12946. l.c();
  12947. l.m(t, null);
  12948. }
  12949. }
  12950. },
  12951. d(c) {
  12952. if (c) {
  12953. _e(t);
  12954. }
  12955. l.d();
  12956. }
  12957. };
  12958. }
  12959. function Df(e) {
  12960. let t;
  12961. let i = e[11].error + "";
  12962. return {
  12963. c() {
  12964. t = Me("div");
  12965. H(t, "title", e[5]);
  12966. },
  12967. m(n, s) {
  12968. He(n, t, s);
  12969. t.innerHTML = i;
  12970. },
  12971. p(n, s) {
  12972. if (s[0] & 2048 && i !== (i = n[11].error + "")) {
  12973. t.innerHTML = i;
  12974. }
  12975. if (s[0] & 32) {
  12976. H(t, "title", n[5]);
  12977. }
  12978. },
  12979. d(n) {
  12980. if (n) {
  12981. _e(t);
  12982. }
  12983. }
  12984. };
  12985. }
  12986. function Of(e) {
  12987. let t;
  12988. let i = e[11].expired + "";
  12989. return {
  12990. c() {
  12991. t = Me("div");
  12992. H(t, "title", e[5]);
  12993. },
  12994. m(n, s) {
  12995. He(n, t, s);
  12996. t.innerHTML = i;
  12997. },
  12998. p(n, s) {
  12999. if (s[0] & 2048 && i !== (i = n[11].expired + "")) {
  13000. t.innerHTML = i;
  13001. }
  13002. if (s[0] & 32) {
  13003. H(t, "title", n[5]);
  13004. }
  13005. },
  13006. d(n) {
  13007. if (n) {
  13008. _e(t);
  13009. }
  13010. }
  13011. };
  13012. }
  13013. function to(e) {
  13014. let t;
  13015. let i;
  13016. let n = e[11].footer + "";
  13017. return {
  13018. c() {
  13019. t = Me("div");
  13020. i = Me("div");
  13021. H(i, "class", "svelte-ddsc3z");
  13022. H(t, "class", "altcha-footer svelte-ddsc3z");
  13023. },
  13024. m(s, r) {
  13025. He(s, t, r);
  13026. we(t, i);
  13027. i.innerHTML = n;
  13028. },
  13029. p(s, r) {
  13030. if (r[0] & 2048 && n !== (n = s[11].footer + "")) {
  13031. i.innerHTML = n;
  13032. }
  13033. },
  13034. d(s) {
  13035. if (s) {
  13036. _e(t);
  13037. }
  13038. }
  13039. };
  13040. }
  13041. function io(e) {
  13042. let t;
  13043. return {
  13044. c() {
  13045. t = Me("div");
  13046. H(t, "class", "altcha-anchor-arrow svelte-ddsc3z");
  13047. },
  13048. m(i, n) {
  13049. He(i, t, n);
  13050. e[48](t);
  13051. },
  13052. p: vn,
  13053. d(i) {
  13054. if (i) {
  13055. _e(t);
  13056. }
  13057. e[48](null);
  13058. }
  13059. };
  13060. }
  13061. function _f(e) {
  13062. let t;
  13063. let i;
  13064. let n;
  13065. let s;
  13066. let r;
  13067. let o;
  13068. let l;
  13069. let c;
  13070. let a;
  13071. let f;
  13072. let d;
  13073. let u;
  13074. let p;
  13075. let w;
  13076. let x;
  13077. let b;
  13078. let $;
  13079. const v = e[46].default;
  13080. const S = Ku(v, e, e[45], null);
  13081. let R = e[7] === Q.VERIFYING && Qr();
  13082. function G(D, z) {
  13083. if (D[7] === Q.VERIFIED) {
  13084. return Af;
  13085. } else if (D[7] === Q.VERIFYING) {
  13086. return Rf;
  13087. } else {
  13088. return $f;
  13089. }
  13090. }
  13091. let X = G(e);
  13092. let W = X(e);
  13093. let M = (e[3] !== true || e[12]) && jr(e);
  13094. let V = (e[5] || e[7] === Q.EXPIRED) && eo(e);
  13095. let F = e[11].footer && (e[2] !== true || e[12]) && to(e);
  13096. let _ = e[1] && io(e);
  13097. return {
  13098. c() {
  13099. if (S) {
  13100. S.c();
  13101. }
  13102. t = rt();
  13103. i = Me("div");
  13104. n = Me("div");
  13105. if (R) {
  13106. R.c();
  13107. }
  13108. s = rt();
  13109. r = Me("div");
  13110. o = Me("input");
  13111. a = rt();
  13112. f = Me("div");
  13113. W.c();
  13114. d = rt();
  13115. if (M) {
  13116. M.c();
  13117. }
  13118. u = rt();
  13119. if (V) {
  13120. V.c();
  13121. }
  13122. p = rt();
  13123. if (F) {
  13124. F.c();
  13125. }
  13126. w = rt();
  13127. if (_) {
  13128. _.c();
  13129. }
  13130. H(o, "type", "checkbox");
  13131. H(o, "id", l = e[4] + "_checkbox");
  13132. o.required = c = e[0] !== "onsubmit" && (!e[1] || e[0] !== "off");
  13133. H(o, "class", "svelte-ddsc3z");
  13134. H(r, "class", "altcha-checkbox svelte-ddsc3z");
  13135. Zr(r, "altcha-hidden", e[7] === Q.VERIFYING);
  13136. H(f, "class", "altcha-label svelte-ddsc3z");
  13137. H(n, "class", "altcha-main svelte-ddsc3z");
  13138. H(i, "class", "altcha svelte-ddsc3z");
  13139. H(i, "data-state", e[7]);
  13140. H(i, "data-floating", e[1]);
  13141. },
  13142. m(D, z) {
  13143. if (S) {
  13144. S.m(D, z);
  13145. }
  13146. He(D, t, z);
  13147. He(D, i, z);
  13148. we(i, n);
  13149. if (R) {
  13150. R.m(n, null);
  13151. }
  13152. we(n, s);
  13153. we(n, r);
  13154. we(r, o);
  13155. o.checked = e[8];
  13156. we(n, a);
  13157. we(n, f);
  13158. W.m(f, null);
  13159. we(n, d);
  13160. if (M) {
  13161. M.m(n, null);
  13162. }
  13163. we(i, u);
  13164. if (V) {
  13165. V.m(i, null);
  13166. }
  13167. we(i, p);
  13168. if (F) {
  13169. F.m(i, null);
  13170. }
  13171. we(i, w);
  13172. if (_) {
  13173. _.m(i, null);
  13174. }
  13175. e[49](i);
  13176. x = true;
  13177. if (!b) {
  13178. $ = [ls(o, "change", e[47]), ls(o, "change", e[13]), ls(o, "invalid", e[14])];
  13179. b = true;
  13180. }
  13181. },
  13182. p(D, z) {
  13183. if (S && S.p && (!x || z[1] & 16384)) {
  13184. Ju(S, v, D, D[45], x ? Zu(v, D[45], z, null) : Qu(D[45]), null);
  13185. }
  13186. if (D[7] === Q.VERIFYING) {
  13187. if (!R) {
  13188. R = Qr();
  13189. R.c();
  13190. R.m(n, s);
  13191. }
  13192. } else if (R) {
  13193. R.d(1);
  13194. R = null;
  13195. }
  13196. if (!x || z[0] & 16 && l !== (l = D[4] + "_checkbox")) {
  13197. H(o, "id", l);
  13198. }
  13199. if (!x || z[0] & 3 && c !== (c = D[0] !== "onsubmit" && (!D[1] || D[0] !== "off"))) {
  13200. o.required = c;
  13201. }
  13202. if (z[0] & 256) {
  13203. o.checked = D[8];
  13204. }
  13205. if (!x || z[0] & 128) {
  13206. Zr(r, "altcha-hidden", D[7] === Q.VERIFYING);
  13207. }
  13208. if (X === (X = G(D)) && W) {
  13209. W.p(D, z);
  13210. } else {
  13211. W.d(1);
  13212. W = X(D);
  13213. if (W) {
  13214. W.c();
  13215. W.m(f, null);
  13216. }
  13217. }
  13218. if (D[3] !== true || D[12]) {
  13219. if (M) {
  13220. M.p(D, z);
  13221. } else {
  13222. M = jr(D);
  13223. M.c();
  13224. M.m(n, null);
  13225. }
  13226. } else if (M) {
  13227. M.d(1);
  13228. M = null;
  13229. }
  13230. if (D[5] || D[7] === Q.EXPIRED) {
  13231. if (V) {
  13232. V.p(D, z);
  13233. } else {
  13234. V = eo(D);
  13235. V.c();
  13236. V.m(i, p);
  13237. }
  13238. } else if (V) {
  13239. V.d(1);
  13240. V = null;
  13241. }
  13242. if (D[11].footer && (D[2] !== true || D[12])) {
  13243. if (F) {
  13244. F.p(D, z);
  13245. } else {
  13246. F = to(D);
  13247. F.c();
  13248. F.m(i, w);
  13249. }
  13250. } else if (F) {
  13251. F.d(1);
  13252. F = null;
  13253. }
  13254. if (D[1]) {
  13255. if (_) {
  13256. _.p(D, z);
  13257. } else {
  13258. _ = io(D);
  13259. _.c();
  13260. _.m(i, null);
  13261. }
  13262. } else if (_) {
  13263. _.d(1);
  13264. _ = null;
  13265. }
  13266. if (!x || z[0] & 128) {
  13267. H(i, "data-state", D[7]);
  13268. }
  13269. if (!x || z[0] & 2) {
  13270. H(i, "data-floating", D[1]);
  13271. }
  13272. },
  13273. i(D) {
  13274. if (!x) {
  13275. ka(S, D);
  13276. x = true;
  13277. }
  13278. },
  13279. o(D) {
  13280. pf(S, D);
  13281. x = false;
  13282. },
  13283. d(D) {
  13284. if (D) {
  13285. _e(t);
  13286. _e(i);
  13287. }
  13288. if (S) {
  13289. S.d(D);
  13290. }
  13291. if (R) {
  13292. R.d();
  13293. }
  13294. W.d();
  13295. if (M) {
  13296. M.d();
  13297. }
  13298. if (V) {
  13299. V.d();
  13300. }
  13301. if (F) {
  13302. F.d();
  13303. }
  13304. if (_) {
  13305. _.d();
  13306. }
  13307. e[49](null);
  13308. b = false;
  13309. Ji($);
  13310. }
  13311. };
  13312. }
  13313. const no = "Visit Altcha.org";
  13314. const Ia = "https://altcha.org/";
  13315. function so(e) {
  13316. return JSON.parse(e);
  13317. }
  13318. function zf(e, t, i) {
  13319. var n;
  13320. var s;
  13321. let r;
  13322. let o;
  13323. let l;
  13324. let c;
  13325. let {
  13326. $$slots: a = {},
  13327. $$scope: f
  13328. } = t;
  13329. let {
  13330. auto: d = undefined
  13331. } = t;
  13332. let {
  13333. blockspam: u = undefined
  13334. } = t;
  13335. let {
  13336. challengeurl: p = undefined
  13337. } = t;
  13338. let {
  13339. challengejson: w = undefined
  13340. } = t;
  13341. let {
  13342. debug: x = false
  13343. } = t;
  13344. let {
  13345. delay: b = 0
  13346. } = t;
  13347. let {
  13348. expire: $ = undefined
  13349. } = t;
  13350. let {
  13351. floating: v = undefined
  13352. } = t;
  13353. let {
  13354. floatinganchor: S = undefined
  13355. } = t;
  13356. let {
  13357. floatingoffset: R = undefined
  13358. } = t;
  13359. let {
  13360. hidefooter: G = false
  13361. } = t;
  13362. let {
  13363. hidelogo: X = false
  13364. } = t;
  13365. let {
  13366. name: W = "altcha"
  13367. } = t;
  13368. let {
  13369. maxnumber: M = 1000000
  13370. } = t;
  13371. let {
  13372. mockerror: V = false
  13373. } = t;
  13374. let {
  13375. obfuscated: F = undefined
  13376. } = t;
  13377. let {
  13378. plugins: _ = undefined
  13379. } = t;
  13380. let {
  13381. refetchonexpire: D = true
  13382. } = t;
  13383. let {
  13384. spamfilter: z = false
  13385. } = t;
  13386. let {
  13387. strings: N = undefined
  13388. } = t;
  13389. let {
  13390. test: Y = false
  13391. } = t;
  13392. let {
  13393. verifyurl: K = undefined
  13394. } = t;
  13395. let {
  13396. workers: ie = Math.min(16, navigator.hardwareConcurrency || 8)
  13397. } = t;
  13398. let {
  13399. workerurl: ae = undefined
  13400. } = t;
  13401. const J = cf();
  13402. const Se = ["SHA-256", "SHA-384", "SHA-512"];
  13403. const zt = (s = (n = document.documentElement.lang) == null ? undefined : n.split("-")) == null ? undefined : s[0];
  13404. let Ve = false;
  13405. let te;
  13406. let Be = null;
  13407. let pt = null;
  13408. let ne = null;
  13409. let mt = null;
  13410. let Ne = null;
  13411. let it = null;
  13412. let Ze = [];
  13413. let se = Q.UNVERIFIED;
  13414. lf(() => {
  13415. mi();
  13416. if (ne) {
  13417. ne.removeEventListener("submit", Z);
  13418. ne.removeEventListener("reset", U);
  13419. ne.removeEventListener("focusin", q);
  13420. ne = null;
  13421. }
  13422. if (Ne) {
  13423. clearTimeout(Ne);
  13424. Ne = null;
  13425. }
  13426. document.removeEventListener("click", I);
  13427. document.removeEventListener("scroll", E);
  13428. window.removeEventListener("resize", Ce);
  13429. });
  13430. af(() => {
  13431. h("mounted", "1.0.6");
  13432. h("workers", ie);
  13433. m();
  13434. h("plugins", Ze.length ? Ze.map(y => y.constructor.pluginName).join(", ") : "none");
  13435. if (Y) {
  13436. h("using test mode");
  13437. }
  13438. if ($) {
  13439. be($);
  13440. }
  13441. if (d !== undefined) {
  13442. h("auto", d);
  13443. }
  13444. if (v !== undefined) {
  13445. ue(v);
  13446. }
  13447. ne = te.closest("form");
  13448. if (ne) {
  13449. ne.addEventListener("submit", Z, {
  13450. capture: true
  13451. });
  13452. ne.addEventListener("reset", U);
  13453. if (d === "onfocus") {
  13454. ne.addEventListener("focusin", q);
  13455. }
  13456. }
  13457. if (d === "onload") {
  13458. if (F) {
  13459. Mt();
  13460. } else {
  13461. yt();
  13462. }
  13463. }
  13464. if (r && (G || X)) {
  13465. h("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution.");
  13466. }
  13467. requestAnimationFrame(() => {
  13468. J("load");
  13469. });
  13470. });
  13471. function pi(y, B) {
  13472. return (JSON.stringify({
  13473. algorithm: y.algorithm,
  13474. challenge: y.challenge,
  13475. number: B.number,
  13476. salt: y.salt,
  13477. signature: y.signature,
  13478. test: Y ? true : undefined,
  13479. took: B.took
  13480. }));
  13481. }
  13482. function mi() {
  13483. for (const y of Ze) {
  13484. y.destroy();
  13485. }
  13486. }
  13487. function gi() {
  13488. if (p && D && se === Q.VERIFIED) {
  13489. yt();
  13490. } else {
  13491. nt(Q.EXPIRED, c.expired);
  13492. }
  13493. }
  13494. async function yi() {
  13495. var y;
  13496. if (V) {
  13497. h("mocking error");
  13498. throw new Error("Mocked error.");
  13499. }
  13500. if (o) {
  13501. h("using provided json data");
  13502. return o;
  13503. }
  13504. if (Y) {
  13505. h("generating test challenge", {
  13506. test: Y
  13507. });
  13508. return Sf(typeof Y != "boolean" ? +Y : undefined);
  13509. }
  13510. {
  13511. if (!p && ne) {
  13512. const le = ne.getAttribute("action");
  13513. if (le != null && le.includes("/form/")) {
  13514. i(15, p = le + "/altcha");
  13515. }
  13516. }
  13517. if (!p) {
  13518. throw new Error("Attribute challengeurl not set.");
  13519. }
  13520. h("fetching challenge from", p);
  13521. const B = await fetch(p, {
  13522. headers: z ? {
  13523. "x-altcha-spam-filter": "1"
  13524. } : {}
  13525. });
  13526. if (B.status !== 200) {
  13527. throw new Error(`Server responded with ${B.status}.`);
  13528. }
  13529. const ee = B.headers.get("Expires");
  13530. const ve = B.headers.get("X-Altcha-Config");
  13531. const Le = await B.json();
  13532. const wt = new URLSearchParams((y = Le.salt.split("?")) == null ? undefined : y[1]);
  13533. const Pe = wt.get("expires") || wt.get("expire");
  13534. if (Pe) {
  13535. const le = new Date(+Pe * 1000);
  13536. const Xe = isNaN(le.getTime()) ? 0 : le.getTime() - Date.now();
  13537. if (Xe > 0) {
  13538. be(Xe);
  13539. }
  13540. }
  13541. if (ve) {
  13542. try {
  13543. const le = JSON.parse(ve);
  13544. if (le && typeof le == "object") {
  13545. if (le.verifyurl) {
  13546. le.verifyurl = new URL(le.verifyurl, new URL(p)).toString();
  13547. }
  13548. xi(le);
  13549. }
  13550. } catch (le) {
  13551. h("unable to configure from X-Altcha-Config", le);
  13552. }
  13553. }
  13554. if (!$ && ee != null && ee.length) {
  13555. const le = Date.parse(ee);
  13556. if (le) {
  13557. const Xe = le - Date.now();
  13558. if (Xe > 0) {
  13559. be(Xe);
  13560. }
  13561. }
  13562. }
  13563. return Le;
  13564. }
  13565. }
  13566. function wi(y) {
  13567. var B;
  13568. const ee = ne == null ? undefined : ne.querySelector(typeof y == "string" ? `input[name="${y}"]` : "input[type=\"email\"]:not([data-no-spamfilter])");
  13569. return ((B = ee == null ? undefined : ee.value) == null ? undefined : B.slice(ee.value.indexOf("@"))) || undefined;
  13570. }
  13571. function Ln() {
  13572. if (z === "ipAddress") {
  13573. return {
  13574. blockedCountries: undefined,
  13575. classifier: undefined,
  13576. disableRules: undefined,
  13577. email: false,
  13578. expectedCountries: undefined,
  13579. expectedLanguages: undefined,
  13580. fields: false,
  13581. ipAddress: undefined,
  13582. text: undefined,
  13583. timeZone: undefined
  13584. };
  13585. } else if (typeof z == "object") {
  13586. return z;
  13587. } else {
  13588. return {
  13589. blockedCountries: undefined,
  13590. classifier: undefined,
  13591. disableRules: undefined,
  13592. email: undefined,
  13593. expectedCountries: undefined,
  13594. expectedLanguages: undefined,
  13595. fields: undefined,
  13596. ipAddress: undefined,
  13597. text: undefined,
  13598. timeZone: undefined
  13599. };
  13600. }
  13601. }
  13602. function Tt(y) {
  13603. return [...((ne == null ? undefined : ne.querySelectorAll(y != null && y.length ? y.map(B => `input[name="${B}"]`).join(", ") : "input[type=\"text\"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])")) || [])].reduce((B, ee) => {
  13604. const ve = ee.name;
  13605. const Le = ee.value;
  13606. if (ve && Le) {
  13607. B[ve] = /\n/.test(Le) ? Le.replace(new RegExp("(?<!\\r)\\n", "g"), `\r
  13608. `) : Le;
  13609. }
  13610. return B;
  13611. }, {});
  13612. }
  13613. function m() {
  13614. const y = _ !== undefined ? _.split(",") : undefined;
  13615. for (const B of globalThis.altchaPlugins) {
  13616. if (!y || y.includes(B.pluginName)) {
  13617. Ze.push(new B({
  13618. el: te,
  13619. clarify: Mt,
  13620. dispatch: J,
  13621. getConfiguration: gt,
  13622. getFloatingAnchor: Ht,
  13623. getState: Lt,
  13624. log: h,
  13625. reset: nt,
  13626. solve: re,
  13627. setState: st,
  13628. setFloatingAnchor: Ft,
  13629. verify: yt
  13630. }));
  13631. }
  13632. }
  13633. }
  13634. function h(...y) {
  13635. if (x || y.some(B => B instanceof Error)) {
  13636. console[y[0] instanceof Error ? "error" : "log"]("ALTCHA", `[name=${W}]`, ...y);
  13637. }
  13638. }
  13639. function g() {
  13640. if ([Q.UNVERIFIED, Q.ERROR, Q.EXPIRED].includes(se)) {
  13641. if (z && (ne == null ? undefined : ne.reportValidity()) === false) {
  13642. i(8, Ve = false);
  13643. } else if (F) {
  13644. Mt();
  13645. } else {
  13646. yt();
  13647. }
  13648. } else {
  13649. i(8, Ve = true);
  13650. }
  13651. }
  13652. function I(y) {
  13653. const B = y.target;
  13654. if (v && B && !te.contains(B) && (se === Q.VERIFIED || d === "off" && se === Q.UNVERIFIED)) {
  13655. i(9, te.style.display = "none", te);
  13656. }
  13657. }
  13658. function E() {
  13659. if (v && se !== Q.UNVERIFIED) {
  13660. pe();
  13661. }
  13662. }
  13663. function O(y) {
  13664. for (const B of Ze) {
  13665. if (typeof B.onErrorChange == "function") {
  13666. B.onErrorChange(mt);
  13667. }
  13668. }
  13669. }
  13670. function q(y) {
  13671. if (se === Q.UNVERIFIED) {
  13672. yt();
  13673. }
  13674. }
  13675. function Z(y) {
  13676. if (ne && d === "onsubmit") {
  13677. if (se === Q.UNVERIFIED) {
  13678. y.preventDefault();
  13679. y.stopPropagation();
  13680. yt().then(() => {
  13681. if (!(ne == null)) {
  13682. ne.requestSubmit();
  13683. }
  13684. });
  13685. } else if (se !== Q.VERIFIED) {
  13686. y.preventDefault();
  13687. y.stopPropagation();
  13688. if (se === Q.VERIFYING) {
  13689. j();
  13690. }
  13691. }
  13692. } else if (ne && v && d === "off" && se === Q.UNVERIFIED) {
  13693. y.preventDefault();
  13694. y.stopPropagation();
  13695. i(9, te.style.display = "block", te);
  13696. pe();
  13697. }
  13698. }
  13699. function U() {
  13700. nt();
  13701. }
  13702. function j() {
  13703. if (se === Q.VERIFYING && c.waitAlert) {
  13704. alert(c.waitAlert);
  13705. }
  13706. }
  13707. function vi(y) {
  13708. for (const B of Ze) {
  13709. if (typeof B.onStateChange == "function") {
  13710. B.onStateChange(se);
  13711. }
  13712. }
  13713. if (v && se !== Q.UNVERIFIED) {
  13714. requestAnimationFrame(() => {
  13715. pe();
  13716. });
  13717. }
  13718. i(8, Ve = se === Q.VERIFIED);
  13719. }
  13720. function Ce() {
  13721. if (v) {
  13722. pe();
  13723. }
  13724. }
  13725. function pe(y = 20) {
  13726. if (te) {
  13727. if (!pt) {
  13728. pt = (S ? document.querySelector(S) : ne == null ? undefined : ne.querySelector("input[type=\"submit\"], button[type=\"submit\"], button:not([type=\"button\"]):not([type=\"reset\"])")) || ne;
  13729. }
  13730. if (pt) {
  13731. const B = parseInt(R, 10) || 12;
  13732. const ee = pt.getBoundingClientRect();
  13733. const ve = te.getBoundingClientRect();
  13734. const Le = document.documentElement.clientHeight;
  13735. const wt = document.documentElement.clientWidth;
  13736. const Pe = v === "auto" ? ee.bottom + ve.height + B + y > Le : v === "top";
  13737. const le = Math.max(y, Math.min(wt - y - ve.width, ee.left + ee.width / 2 - ve.width / 2));
  13738. if (Pe) {
  13739. i(9, te.style.top = `${ee.top - (ve.height + B)}px`, te);
  13740. } else {
  13741. i(9, te.style.top = `${ee.bottom + B}px`, te);
  13742. }
  13743. i(9, te.style.left = `${le}px`, te);
  13744. te.setAttribute("data-floating", Pe ? "top" : "bottom");
  13745. if (Be) {
  13746. const Xe = Be.getBoundingClientRect();
  13747. i(10, Be.style.left = ee.left - le + ee.width / 2 - Xe.width / 2 + "px", Be);
  13748. }
  13749. } else {
  13750. h("unable to find floating anchor element");
  13751. }
  13752. }
  13753. }
  13754. async function Bt(y) {
  13755. if (!K) {
  13756. throw new Error("Attribute verifyurl not set.");
  13757. }
  13758. h("requesting server verification from", K);
  13759. const B = {
  13760. payload: y
  13761. };
  13762. if (z) {
  13763. const {
  13764. blockedCountries: Le,
  13765. classifier: wt,
  13766. disableRules: Pe,
  13767. email: le,
  13768. expectedLanguages: Xe,
  13769. expectedCountries: Fn,
  13770. fields: bi,
  13771. ipAddress: Si,
  13772. text: ol,
  13773. timeZone: wr
  13774. } = Ln();
  13775. B.blockedCountries = Le;
  13776. B.classifier = wt;
  13777. B.disableRules = Pe;
  13778. B.email = le === false ? undefined : wi(le);
  13779. B.expectedCountries = Fn;
  13780. B.expectedLanguages = Xe || (zt ? [zt] : undefined);
  13781. B.fields = bi === false ? undefined : Tt(bi);
  13782. B.ipAddress = Si === false ? undefined : Si || "auto";
  13783. B.text = ol;
  13784. B.timeZone = wr === false ? undefined : wr || Tf();
  13785. }
  13786. const ee = await fetch(K, {
  13787. body: JSON.stringify(B),
  13788. headers: {
  13789. "content-type": "application/json"
  13790. },
  13791. method: "POST"
  13792. });
  13793. if (ee.status !== 200) {
  13794. throw new Error(`Server responded with ${ee.status}.`);
  13795. }
  13796. const ve = await ee.json();
  13797. if (ve != null && ve.payload) {
  13798. i(6, it = ve.payload);
  13799. }
  13800. J("serververification", ve);
  13801. if (u && ve.classification === "BAD") {
  13802. throw new Error("SpamFilter returned negative classification.");
  13803. }
  13804. }
  13805. function be(y) {
  13806. h("expire", y);
  13807. if (Ne) {
  13808. clearTimeout(Ne);
  13809. Ne = null;
  13810. }
  13811. if (y < 1) {
  13812. gi();
  13813. } else {
  13814. Ne = // TOLOOK
  13815. setTimeout(gi, y);
  13816. }
  13817. }
  13818. function ue(y) {
  13819. h("floating", y);
  13820. if (v !== y) {
  13821. i(9, te.style.left = "", te);
  13822. i(9, te.style.top = "", te);
  13823. }
  13824. i(1, v = y === true || y === "" ? "auto" : y === false || y === "false" ? undefined : v);
  13825. if (v) {
  13826. if (!d) {
  13827. i(0, d = "onsubmit");
  13828. }
  13829. document.addEventListener("scroll", E);
  13830. document.addEventListener("click", I);
  13831. window.addEventListener("resize", Ce);
  13832. } else if (d === "onsubmit") {
  13833. i(0, d = undefined);
  13834. }
  13835. }
  13836. function Ie(y) {
  13837. if (!y.algorithm) {
  13838. throw new Error("Invalid challenge. Property algorithm is missing.");
  13839. }
  13840. if (y.signature === undefined) {
  13841. throw new Error("Invalid challenge. Property signature is missing.");
  13842. }
  13843. if (!Se.includes(y.algorithm.toUpperCase())) {
  13844. throw new Error(`Unknown algorithm value. Allowed values: ${Se.join(", ")}`);
  13845. }
  13846. if (!y.challenge || y.challenge.length < 40) {
  13847. throw new Error("Challenge is too short. Min. 40 chars.");
  13848. }
  13849. if (!y.salt || y.salt.length < 10) {
  13850. throw new Error("Salt is too short. Min. 10 chars.");
  13851. }
  13852. }
  13853. async function re(y) {
  13854. let B = null;
  13855. if ("Worker" in window) {
  13856. try {
  13857. B = await ki(y, y.maxnumber);
  13858. } catch (ee) {
  13859. h(ee);
  13860. }
  13861. if ((B == null ? undefined : B.number) !== undefined || "obfuscated" in y) {
  13862. return {
  13863. data: y,
  13864. solution: B
  13865. };
  13866. }
  13867. }
  13868. if ("obfuscated" in y) {
  13869. const ee = await Cf(y.obfuscated, y.key, y.maxnumber);
  13870. return {
  13871. data: y,
  13872. solution: await ee.promise
  13873. };
  13874. }
  13875. return {
  13876. data: y,
  13877. solution: await If(y.challenge, y.salt, y.algorithm, y.maxnumber || M).promise
  13878. };
  13879. }
  13880. async function ki(y, B = typeof Y == "number" ? Y : M, ee = Math.ceil(ie)) {
  13881. const ve = [];
  13882. ee = Math.min(16, Math.max(1, ee));
  13883. for (let Pe = 0; Pe < ee; Pe++) {
  13884. ve.push(altchaCreateWorker(ae));
  13885. }
  13886. const Le = Math.ceil(B / ee);
  13887. const wt = await Promise.all(ve.map((Pe, le) => {
  13888. const Xe = le * Le;
  13889. return new Promise(Fn => {
  13890. Pe.addEventListener("message", bi => {
  13891. if (bi.data) {
  13892. for (const Si of ve) {
  13893. if (Si !== Pe) {
  13894. Si.postMessage({
  13895. type: "abort"
  13896. });
  13897. }
  13898. }
  13899. }
  13900. Fn(bi.data);
  13901. });
  13902. Pe.postMessage({
  13903. payload: y,
  13904. max: Xe + Le,
  13905. start: Xe,
  13906. type: "work"
  13907. });
  13908. });
  13909. }));
  13910. for (const Pe of ve) {
  13911. Pe.terminate();
  13912. }
  13913. return wt.find(Pe => !!Pe) || null;
  13914. }
  13915. async function Mt() {
  13916. if (!F) {
  13917. i(7, se = Q.ERROR);
  13918. return;
  13919. }
  13920. const y = Ze.find(B => B.constructor.pluginName === "obfuscation");
  13921. if (!y || !("clarify" in y)) {
  13922. i(7, se = Q.ERROR);
  13923. h("Plugin `obfuscation` not found. Import `altcha/plugins/obfuscation` to load it.");
  13924. return;
  13925. }
  13926. if ("clarify" in y && typeof y.clarify == "function") {
  13927. return y.clarify();
  13928. }
  13929. }
  13930. function xi(y) {
  13931. if (y.obfuscated !== undefined) {
  13932. i(24, F = y.obfuscated);
  13933. }
  13934. if (y.auto !== undefined) {
  13935. i(0, d = y.auto);
  13936. if (d === "onload") {
  13937. if (F) {
  13938. Mt();
  13939. } else {
  13940. yt();
  13941. }
  13942. }
  13943. }
  13944. if (y.blockspam !== undefined) {
  13945. i(16, u = !!y.blockspam);
  13946. }
  13947. if (y.floatinganchor !== undefined) {
  13948. i(20, S = y.floatinganchor);
  13949. }
  13950. if (y.delay !== undefined) {
  13951. i(18, b = y.delay);
  13952. }
  13953. if (y.floatingoffset !== undefined) {
  13954. i(21, R = y.floatingoffset);
  13955. }
  13956. if (y.floating !== undefined) {
  13957. ue(y.floating);
  13958. }
  13959. if (y.expire !== undefined) {
  13960. be(y.expire);
  13961. i(19, $ = y.expire);
  13962. }
  13963. if (y.challenge) {
  13964. Ie(y.challenge);
  13965. o = y.challenge;
  13966. }
  13967. if (y.challengeurl !== undefined) {
  13968. i(15, p = y.challengeurl);
  13969. }
  13970. if (y.debug !== undefined) {
  13971. i(17, x = !!y.debug);
  13972. }
  13973. if (y.hidefooter !== undefined) {
  13974. i(2, G = !!y.hidefooter);
  13975. }
  13976. if (y.hidelogo !== undefined) {
  13977. i(3, X = !!y.hidelogo);
  13978. }
  13979. if (y.maxnumber !== undefined) {
  13980. i(22, M = +y.maxnumber);
  13981. }
  13982. if (y.mockerror !== undefined) {
  13983. i(23, V = !!y.mockerror);
  13984. }
  13985. if (y.name !== undefined) {
  13986. i(4, W = y.name);
  13987. }
  13988. if (y.refetchonexpire !== undefined) {
  13989. i(25, D = !!y.refetchonexpire);
  13990. }
  13991. if (y.spamfilter !== undefined) {
  13992. i(26, z = typeof y.spamfilter == "object" ? y.spamfilter : !!y.spamfilter);
  13993. }
  13994. if (y.strings) {
  13995. i(44, l = y.strings);
  13996. }
  13997. if (y.test !== undefined) {
  13998. i(27, Y = typeof y.test == "number" ? y.test : !!y.test);
  13999. }
  14000. if (y.verifyurl !== undefined) {
  14001. i(28, K = y.verifyurl);
  14002. }
  14003. if (y.workers !== undefined) {
  14004. i(29, ie = +y.workers);
  14005. }
  14006. if (y.workerurl !== undefined) {
  14007. i(30, ae = y.workerurl);
  14008. }
  14009. }
  14010. function gt() {
  14011. return {
  14012. auto: d,
  14013. blockspam: u,
  14014. challengeurl: p,
  14015. debug: x,
  14016. delay: b,
  14017. expire: $,
  14018. floating: v,
  14019. floatinganchor: S,
  14020. floatingoffset: R,
  14021. hidefooter: G,
  14022. hidelogo: X,
  14023. name: W,
  14024. maxnumber: M,
  14025. mockerror: V,
  14026. obfuscated: F,
  14027. refetchonexpire: D,
  14028. spamfilter: z,
  14029. strings: c,
  14030. test: Y,
  14031. verifyurl: K,
  14032. workers: ie,
  14033. workerurl: ae
  14034. };
  14035. }
  14036. function Ht() {
  14037. return pt;
  14038. }
  14039. function fe(y) {
  14040. return Ze.find(B => B.constructor.pluginName === y);
  14041. }
  14042. function Lt() {
  14043. return se;
  14044. }
  14045. function nt(y = Q.UNVERIFIED, B = null) {
  14046. if (Ne) {
  14047. clearTimeout(Ne);
  14048. Ne = null;
  14049. }
  14050. i(8, Ve = false);
  14051. i(5, mt = B);
  14052. i(6, it = null);
  14053. i(7, se = y);
  14054. }
  14055. function Ft(y) {
  14056. pt = y;
  14057. }
  14058. function st(y, B = null) {
  14059. i(7, se = y);
  14060. i(5, mt = B);
  14061. }
  14062. async function yt() {
  14063. nt(Q.VERIFYING);
  14064. await new Promise(y => // TOLOOK
  14065. setTimeout(y, b || 0));
  14066. return yi().then(y => {
  14067. Ie(y);
  14068. h("challenge", y);
  14069. return re(y);
  14070. }).then(({
  14071. data: y,
  14072. solution: B
  14073. }) => {
  14074. h("solution", B);
  14075. if ("challenge" in y && B && !("clearText" in B)) {
  14076. if ((B == null ? undefined : B.number) !== undefined) {
  14077. if (K) {
  14078. return Bt(pi(y, B));
  14079. }
  14080. i(6, it = pi(y, B));
  14081. h("payload", it);
  14082. } else {
  14083. h("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number.");
  14084. throw new Error("Unexpected result returned.");
  14085. }
  14086. }
  14087. }).then(() => {
  14088. i(7, se = Q.VERIFIED);
  14089. h("verified");
  14090. hf().then(() => {
  14091. J("verified", {
  14092. payload: it
  14093. });
  14094. });
  14095. }).catch(y => {
  14096. h(y);
  14097. i(7, se = Q.ERROR);
  14098. i(5, mt = y.message);
  14099. });
  14100. }
  14101. function nl() {
  14102. Ve = this.checked;
  14103. i(8, Ve);
  14104. }
  14105. function sl(y) {
  14106. kn[y ? "unshift" : "push"](() => {
  14107. Be = y;
  14108. i(10, Be);
  14109. });
  14110. }
  14111. function rl(y) {
  14112. kn[y ? "unshift" : "push"](() => {
  14113. te = y;
  14114. i(9, te);
  14115. });
  14116. }
  14117. e.$$set = y => {
  14118. if ("auto" in y) {
  14119. i(0, d = y.auto);
  14120. }
  14121. if ("blockspam" in y) {
  14122. i(16, u = y.blockspam);
  14123. }
  14124. if ("challengeurl" in y) {
  14125. i(15, p = y.challengeurl);
  14126. }
  14127. if ("challengejson" in y) {
  14128. i(31, w = y.challengejson);
  14129. }
  14130. if ("debug" in y) {
  14131. i(17, x = y.debug);
  14132. }
  14133. if ("delay" in y) {
  14134. i(18, b = y.delay);
  14135. }
  14136. if ("expire" in y) {
  14137. i(19, $ = y.expire);
  14138. }
  14139. if ("floating" in y) {
  14140. i(1, v = y.floating);
  14141. }
  14142. if ("floatinganchor" in y) {
  14143. i(20, S = y.floatinganchor);
  14144. }
  14145. if ("floatingoffset" in y) {
  14146. i(21, R = y.floatingoffset);
  14147. }
  14148. if ("hidefooter" in y) {
  14149. i(2, G = y.hidefooter);
  14150. }
  14151. if ("hidelogo" in y) {
  14152. i(3, X = y.hidelogo);
  14153. }
  14154. if ("name" in y) {
  14155. i(4, W = y.name);
  14156. }
  14157. if ("maxnumber" in y) {
  14158. i(22, M = y.maxnumber);
  14159. }
  14160. if ("mockerror" in y) {
  14161. i(23, V = y.mockerror);
  14162. }
  14163. if ("obfuscated" in y) {
  14164. i(24, F = y.obfuscated);
  14165. }
  14166. if ("plugins" in y) {
  14167. i(32, _ = y.plugins);
  14168. }
  14169. if ("refetchonexpire" in y) {
  14170. i(25, D = y.refetchonexpire);
  14171. }
  14172. if ("spamfilter" in y) {
  14173. i(26, z = y.spamfilter);
  14174. }
  14175. if ("strings" in y) {
  14176. i(33, N = y.strings);
  14177. }
  14178. if ("test" in y) {
  14179. i(27, Y = y.test);
  14180. }
  14181. if ("verifyurl" in y) {
  14182. i(28, K = y.verifyurl);
  14183. }
  14184. if ("workers" in y) {
  14185. i(29, ie = y.workers);
  14186. }
  14187. if ("workerurl" in y) {
  14188. i(30, ae = y.workerurl);
  14189. }
  14190. if ("$$scope" in y) {
  14191. i(45, f = y.$$scope);
  14192. }
  14193. };
  14194. e.$$.update = () => {
  14195. if (e.$$.dirty[0] & 32768) {
  14196. i(12, r = !!(p != null && p.includes(".altcha.org")) && !!(p != null && p.includes("apiKey=ckey_")));
  14197. }
  14198. if (e.$$.dirty[1] & 1) {
  14199. o = w ? so(w) : undefined;
  14200. }
  14201. if (e.$$.dirty[1] & 4) {
  14202. i(44, l = N ? so(N) : {});
  14203. }
  14204. if (e.$$.dirty[1] & 8192) {
  14205. i(11, c = {
  14206. ariaLinkLabel: no,
  14207. error: "Verification failed. Try again later.",
  14208. expired: "Verification expired. Try again.",
  14209. footer: `Protected by <a href="${Ia}" target="_blank" aria-label="${l.ariaLinkLabel || no}">ALTCHA</a>`,
  14210. label: "I'm not a robot",
  14211. verified: "Verified",
  14212. verifying: "Verifying...",
  14213. waitAlert: "Verifying... please wait.",
  14214. ...l
  14215. });
  14216. }
  14217. if (e.$$.dirty[0] & 192) {
  14218. J("statechange", {
  14219. payload: it,
  14220. state: se
  14221. });
  14222. }
  14223. if (e.$$.dirty[0] & 32) {
  14224. O();
  14225. }
  14226. if (e.$$.dirty[0] & 128) {
  14227. vi();
  14228. }
  14229. };
  14230. return [d, v, G, X, W, mt, it, se, Ve, te, Be, c, r, g, j, p, u, x, b, $, S, R, M, V, F, D, z, Y, K, ie, ae, w, _, N, Mt, xi, gt, Ht, fe, Lt, nt, Ft, st, yt, l, f, a, nl, sl, rl];
  14231. }
  14232. class Bf extends kf {
  14233. constructor(t) {
  14234. super();
  14235. wf(this, t, zf, _f, Gu, {
  14236. auto: 0,
  14237. blockspam: 16,
  14238. challengeurl: 15,
  14239. challengejson: 31,
  14240. debug: 17,
  14241. delay: 18,
  14242. expire: 19,
  14243. floating: 1,
  14244. floatinganchor: 20,
  14245. floatingoffset: 21,
  14246. hidefooter: 2,
  14247. hidelogo: 3,
  14248. name: 4,
  14249. maxnumber: 22,
  14250. mockerror: 23,
  14251. obfuscated: 24,
  14252. plugins: 32,
  14253. refetchonexpire: 25,
  14254. spamfilter: 26,
  14255. strings: 33,
  14256. test: 27,
  14257. verifyurl: 28,
  14258. workers: 29,
  14259. workerurl: 30,
  14260. clarify: 34,
  14261. configure: 35,
  14262. getConfiguration: 36,
  14263. getFloatingAnchor: 37,
  14264. getPlugin: 38,
  14265. getState: 39,
  14266. reset: 40,
  14267. setFloatingAnchor: 41,
  14268. setState: 42,
  14269. verify: 43
  14270. }, Pf, [-1, -1, -1]);
  14271. }
  14272. get auto() {
  14273. return this.$$.ctx[0];
  14274. }
  14275. set auto(t) {
  14276. this.$$set({
  14277. auto: t
  14278. });
  14279. ce();
  14280. }
  14281. get blockspam() {
  14282. return this.$$.ctx[16];
  14283. }
  14284. set blockspam(t) {
  14285. this.$$set({
  14286. blockspam: t
  14287. });
  14288. ce();
  14289. }
  14290. get challengeurl() {
  14291. return this.$$.ctx[15];
  14292. }
  14293. set challengeurl(t) {
  14294. this.$$set({
  14295. challengeurl: t
  14296. });
  14297. ce();
  14298. }
  14299. get challengejson() {
  14300. return this.$$.ctx[31];
  14301. }
  14302. set challengejson(t) {
  14303. this.$$set({
  14304. challengejson: t
  14305. });
  14306. ce();
  14307. }
  14308. get debug() {
  14309. return this.$$.ctx[17];
  14310. }
  14311. set debug(t) {
  14312. this.$$set({
  14313. debug: t
  14314. });
  14315. ce();
  14316. }
  14317. get delay() {
  14318. return this.$$.ctx[18];
  14319. }
  14320. set delay(t) {
  14321. this.$$set({
  14322. delay: t
  14323. });
  14324. ce();
  14325. }
  14326. get expire() {
  14327. return this.$$.ctx[19];
  14328. }
  14329. set expire(t) {
  14330. this.$$set({
  14331. expire: t
  14332. });
  14333. ce();
  14334. }
  14335. get floating() {
  14336. return this.$$.ctx[1];
  14337. }
  14338. set floating(t) {
  14339. this.$$set({
  14340. floating: t
  14341. });
  14342. ce();
  14343. }
  14344. get floatinganchor() {
  14345. return this.$$.ctx[20];
  14346. }
  14347. set floatinganchor(t) {
  14348. this.$$set({
  14349. floatinganchor: t
  14350. });
  14351. ce();
  14352. }
  14353. get floatingoffset() {
  14354. return this.$$.ctx[21];
  14355. }
  14356. set floatingoffset(t) {
  14357. this.$$set({
  14358. floatingoffset: t
  14359. });
  14360. ce();
  14361. }
  14362. get hidefooter() {
  14363. return this.$$.ctx[2];
  14364. }
  14365. set hidefooter(t) {
  14366. this.$$set({
  14367. hidefooter: t
  14368. });
  14369. ce();
  14370. }
  14371. get hidelogo() {
  14372. return this.$$.ctx[3];
  14373. }
  14374. set hidelogo(t) {
  14375. this.$$set({
  14376. hidelogo: t
  14377. });
  14378. ce();
  14379. }
  14380. get name() {
  14381. return this.$$.ctx[4];
  14382. }
  14383. set name(t) {
  14384. this.$$set({
  14385. name: t
  14386. });
  14387. ce();
  14388. }
  14389. get maxnumber() {
  14390. return this.$$.ctx[22];
  14391. }
  14392. set maxnumber(t) {
  14393. this.$$set({
  14394. maxnumber: t
  14395. });
  14396. ce();
  14397. }
  14398. get mockerror() {
  14399. return this.$$.ctx[23];
  14400. }
  14401. set mockerror(t) {
  14402. this.$$set({
  14403. mockerror: t
  14404. });
  14405. ce();
  14406. }
  14407. get obfuscated() {
  14408. return this.$$.ctx[24];
  14409. }
  14410. set obfuscated(t) {
  14411. this.$$set({
  14412. obfuscated: t
  14413. });
  14414. ce();
  14415. }
  14416. get plugins() {
  14417. return this.$$.ctx[32];
  14418. }
  14419. set plugins(t) {
  14420. this.$$set({
  14421. plugins: t
  14422. });
  14423. ce();
  14424. }
  14425. get refetchonexpire() {
  14426. return this.$$.ctx[25];
  14427. }
  14428. set refetchonexpire(t) {
  14429. this.$$set({
  14430. refetchonexpire: t
  14431. });
  14432. ce();
  14433. }
  14434. get spamfilter() {
  14435. return this.$$.ctx[26];
  14436. }
  14437. set spamfilter(t) {
  14438. this.$$set({
  14439. spamfilter: t
  14440. });
  14441. ce();
  14442. }
  14443. get strings() {
  14444. return this.$$.ctx[33];
  14445. }
  14446. set strings(t) {
  14447. this.$$set({
  14448. strings: t
  14449. });
  14450. ce();
  14451. }
  14452. get test() {
  14453. return this.$$.ctx[27];
  14454. }
  14455. set test(t) {
  14456. this.$$set({
  14457. test: t
  14458. });
  14459. ce();
  14460. }
  14461. get verifyurl() {
  14462. return this.$$.ctx[28];
  14463. }
  14464. set verifyurl(t) {
  14465. this.$$set({
  14466. verifyurl: t
  14467. });
  14468. ce();
  14469. }
  14470. get workers() {
  14471. return this.$$.ctx[29];
  14472. }
  14473. set workers(t) {
  14474. this.$$set({
  14475. workers: t
  14476. });
  14477. ce();
  14478. }
  14479. get workerurl() {
  14480. return this.$$.ctx[30];
  14481. }
  14482. set workerurl(t) {
  14483. this.$$set({
  14484. workerurl: t
  14485. });
  14486. ce();
  14487. }
  14488. get clarify() {
  14489. return this.$$.ctx[34];
  14490. }
  14491. get configure() {
  14492. return this.$$.ctx[35];
  14493. }
  14494. get getConfiguration() {
  14495. return this.$$.ctx[36];
  14496. }
  14497. get getFloatingAnchor() {
  14498. return this.$$.ctx[37];
  14499. }
  14500. get getPlugin() {
  14501. return this.$$.ctx[38];
  14502. }
  14503. get getState() {
  14504. return this.$$.ctx[39];
  14505. }
  14506. get reset() {
  14507. return this.$$.ctx[40];
  14508. }
  14509. get setFloatingAnchor() {
  14510. return this.$$.ctx[41];
  14511. }
  14512. get setState() {
  14513. return this.$$.ctx[42];
  14514. }
  14515. get verify() {
  14516. return this.$$.ctx[43];
  14517. }
  14518. }
  14519. window.loadedScript = true;
  14520. const Hf = location.hostname !== "localhost" && location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  14521. const Ta = location.hostname === "sandbox-dev.moomoo.io" || location.hostname === "sandbox.moomoo.io";
  14522. const Lf = location.hostname === "dev.moomoo.io" || location.hostname === "dev2.moomoo.io";
  14523. const As = new Ih();
  14524. let $i;
  14525. let dn;
  14526. let pn;
  14527. const xn = location.hostname === "localhost" || location.hostname === "127.0.0.1";
  14528. const Ff = false;
  14529. const nr = xn || Ff;
  14530. if (Ta) {
  14531. dn = "https://api-sandbox.moomoo.io";
  14532. pn = "moomoo.io";
  14533. } else if (Lf) {
  14534. dn = "https://api-dev.moomoo.io";
  14535. pn = "moomoo.io";
  14536. } else {
  14537. dn = "https://api.moomoo.io";
  14538. pn = "moomoo.io";
  14539. }
  14540. const Vf = !nr;
  14541. const xt = new ze(pn, 443, T.maxPlayers, 5, Vf);
  14542. xt.debugLog = false;
  14543. const Ye = {
  14544. animationTime: 0,
  14545. land: null,
  14546. lava: null,
  14547. x: T.volcanoLocationX,
  14548. y: T.volcanoLocationY
  14549. };
  14550. function Nf() {
  14551. let e = false;
  14552. (function (t) {
  14553. if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(t) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0, 4))) {
  14554. e = true;
  14555. }
  14556. })(navigator.userAgent || navigator.vendor || window.opera);
  14557. return e;
  14558. }
  14559. const Ma = Nf();
  14560. let bn = false;
  14561. let Ds = false;
  14562. function ro() {
  14563. if (!(!cr || Ds)) {
  14564. Ds = true;
  14565. if (Hf || nr) {
  14566. if ($i) {
  14567. hs("alt:" + $i);
  14568. }
  14569. } else if ($i) {
  14570. hs("alt:" + $i);
  14571. } else {
  14572. hs();
  14573. }
  14574. }
  14575. }
  14576. let Os = false;
  14577. function hs(e) {
  14578. xt.start(In, function (t, i, n) {
  14579. let r = "wss://" + t;
  14580. if (xn) {
  14581. r = "wss://localhost:3000";
  14582. }
  14583. if (e) {
  14584. r += "?token=" + encodeURIComponent(e);
  14585. }
  14586. me.connect(r, function (o) {
  14587. if (Os) {
  14588. Os = false;
  14589. return;
  14590. }
  14591. el();
  14592. if (o) {
  14593. gs(o);
  14594. } else {
  14595. bn = true;
  14596. Pn();
  14597. }
  14598. }, {
  14599. A: jf,
  14600. B: gs,
  14601. C: _d,
  14602. D: ap,
  14603. E: lp,
  14604. a: fp,
  14605. G: Vd,
  14606. H: jd,
  14607. I: rp,
  14608. J: sp,
  14609. K: Wd,
  14610. L: ep,
  14611. M: tp,
  14612. N: hp,
  14613. O: up,
  14614. P: Bd,
  14615. Q: Ld,
  14616. R: Hd,
  14617. S: cp,
  14618. T: Ya,
  14619. U: Ga,
  14620. V: La,
  14621. X: ip,
  14622. Y: np,
  14623. Z: mp,
  14624. g: cd,
  14625. 1: fd,
  14626. 2: ld,
  14627. 3: hd,
  14628. 4: ud,
  14629. 5: xd,
  14630. 6: Md,
  14631. 7: yd,
  14632. 8: zd,
  14633. 9: md,
  14634. 0: pp
  14635. });
  14636. }, function (t) {
  14637. console.error("Vultr error:", t);
  14638. alert(`Error:
  14639. ` + t);
  14640. gs("disconnected");
  14641. }, xn);
  14642. }
  14643. function sr() {
  14644. return me.connected;
  14645. }
  14646. function Uf() {
  14647. const t = prompt("party key", In);
  14648. if (t) {
  14649. window.onbeforeunload = undefined;
  14650. window.location.href = "/?server=" + t;
  14651. }
  14652. }
  14653. const Wf = new Th(T);
  14654. const Ea = Math.PI;
  14655. const Rt = Ea * 2;
  14656. Math.lerpAngle = function (e, t, i) {
  14657. if (Math.abs(t - e) > Ea) {
  14658. if (e > t) {
  14659. t += Rt;
  14660. } else {
  14661. e += Rt;
  14662. }
  14663. }
  14664. const s = t + (e - t) * i;
  14665. if (s >= 0 && s <= Rt) {
  14666. return s;
  14667. } else {
  14668. return s % Rt;
  14669. }
  14670. };
  14671. CanvasRenderingContext2D.prototype.roundRect = function (e, t, i, n, s) {
  14672. if (i < s * 2) {
  14673. s = i / 2;
  14674. }
  14675. if (n < s * 2) {
  14676. s = n / 2;
  14677. }
  14678. if (s < 0) {
  14679. s = 0;
  14680. }
  14681. this.beginPath();
  14682. this.moveTo(e + s, t);
  14683. this.arcTo(e + i, t, e + i, t + n, s);
  14684. this.arcTo(e + i, t + n, e, t + n, s);
  14685. this.arcTo(e, t + n, e, t, s);
  14686. this.arcTo(e, t, e + i, t, s);
  14687. this.closePath();
  14688. return this;
  14689. };
  14690. let rr;
  14691. if (typeof Storage !== "undefined") {
  14692. rr = true;
  14693. }
  14694. function _n(e, t) {
  14695. if (rr) {
  14696. localStorage.setItem(e, t);
  14697. }
  14698. }
  14699. function Bi(e) {
  14700. if (rr) {
  14701. return localStorage.getItem(e);
  14702. } else {
  14703. return null;
  14704. }
  14705. }
  14706. let Sn = Bi("moofoll");
  14707. function Xf() {
  14708. if (!Sn) {
  14709. Sn = true;
  14710. _n("moofoll", 1);
  14711. }
  14712. }
  14713. let Ca;
  14714. let Et;
  14715. let jt = 1;
  14716. let Fe;
  14717. let hi;
  14718. let us;
  14719. let oo = Date.now();
  14720. var ut;
  14721. let Ke;
  14722. const Oe = [];
  14723. const oe = [];
  14724. let tt = [];
  14725. const Dt = [];
  14726. const ui = [];
  14727. const Pa = new Ch(Zh, ui, oe, Oe, $e, L, T, A);
  14728. const ao = new Ph(Oe, $h, oe, L, null, T, A);
  14729. let P;
  14730. let $a;
  14731. let k;
  14732. let qt = 1;
  14733. let fs = 0;
  14734. let Ra = 0;
  14735. let Aa = 0;
  14736. let ot;
  14737. let at;
  14738. let lo;
  14739. let or = 0;
  14740. const ge = T.maxScreenWidth;
  14741. const ye = T.maxScreenHeight;
  14742. let ei;
  14743. let ti;
  14744. let qi = false;
  14745. document.getElementById("ad-container");
  14746. const zn = document.getElementById("mainMenu");
  14747. const Hi = document.getElementById("enterGame");
  14748. const ds = document.getElementById("promoImg");
  14749. document.getElementById("partyButton");
  14750. const ps = document.getElementById("joinPartyButton");
  14751. const _s = document.getElementById("settingsButton");
  14752. const co = _s.getElementsByTagName("span")[0];
  14753. const ho = document.getElementById("allianceButton");
  14754. const uo = document.getElementById("storeButton");
  14755. const fo = document.getElementById("chatButton");
  14756. const ri = document.getElementById("gameCanvas");
  14757. const C = ri.getContext("2d");
  14758. var qf = document.getElementById("serverBrowser");
  14759. const zs = document.getElementById("nativeResolution");
  14760. const ms = document.getElementById("showPing");
  14761. document.getElementById("playMusic");
  14762. const Gi = document.getElementById("pingDisplay");
  14763. const po = document.getElementById("shutdownDisplay");
  14764. const Yi = document.getElementById("menuCardHolder");
  14765. const Li = document.getElementById("guideCard");
  14766. const fi = document.getElementById("loadingText");
  14767. const ar = document.getElementById("gameUI");
  14768. const mo = document.getElementById("actionBar");
  14769. const Gf = document.getElementById("scoreDisplay");
  14770. const Yf = document.getElementById("foodDisplay");
  14771. const Kf = document.getElementById("woodDisplay");
  14772. const Zf = document.getElementById("stoneDisplay");
  14773. const Jf = document.getElementById("killCounter");
  14774. const go = document.getElementById("leaderboardData");
  14775. const Ki = document.getElementById("nameInput");
  14776. const vt = document.getElementById("itemInfoHolder");
  14777. const yo = document.getElementById("ageText");
  14778. const wo = document.getElementById("ageBarBody");
  14779. const Gt = document.getElementById("upgradeHolder");
  14780. const tn = document.getElementById("upgradeCounter");
  14781. const We = document.getElementById("allianceMenu");
  14782. const nn = document.getElementById("allianceHolder");
  14783. const sn = document.getElementById("allianceManager");
  14784. const De = document.getElementById("mapDisplay");
  14785. const Fi = document.getElementById("diedText");
  14786. const Qf = document.getElementById("skinColorHolder");
  14787. const Te = De.getContext("2d");
  14788. De.width = 300;
  14789. De.height = 300;
  14790. const bt = document.getElementById("storeMenu");
  14791. const vo = document.getElementById("storeHolder");
  14792. const Yt = document.getElementById("noticationDisplay");
  14793. const Vi = Zo.hats;
  14794. const Ni = Zo.accessories;
  14795. var $e = new Eh(Rh, Dt, A, T);
  14796. const Zi = "#525252";
  14797. const ko = "#3d3f42";
  14798. const St = 5.5;
  14799. T.DAY_INTERVAL / 24;
  14800. T.DAY_INTERVAL / 2;
  14801. function jf(e) {
  14802. tt = e.teams;
  14803. }
  14804. let lr = true;
  14805. var cr = false;
  14806. if (!nr || xn) {
  14807. cr = true;
  14808. }
  14809. window.onblur = function () {
  14810. lr = false;
  14811. };
  14812. window.onfocus = function () {
  14813. lr = true;
  14814. if (P && P.alive) {
  14815. gr();
  14816. }
  14817. };
  14818. window.captchaCallbackHook = function () {
  14819. cr = true;
  14820. };
  14821. if (window.captchaCallbackComplete) {
  14822. window.captchaCallbackHook();
  14823. }
  14824. window.addEventListener("keydown", function (e) {
  14825. if (e.keyCode == 32 && e.target == document.body) {
  14826. e.preventDefault();
  14827. }
  14828. });
  14829. ri.oncontextmenu = function () {
  14830. return false;
  14831. };
  14832. ["touch-controls-left", "touch-controls-right", "touch-controls-fullscreen", "storeMenu"].forEach(e => {
  14833. if (document.getElementById(e)) {
  14834. document.getElementById(e).oncontextmenu = function (t) {
  14835. t.preventDefault();
  14836. };
  14837. }
  14838. });
  14839. function gs(e) {
  14840. bn = false;
  14841. me.close();
  14842. hr(e);
  14843. }
  14844. function hr(e, t) {
  14845. zn.style.display = "block";
  14846. ar.style.display = "none";
  14847. Yi.style.display = "none";
  14848. Fi.style.display = "none";
  14849. fi.style.display = "block";
  14850. fi.innerHTML = e + (t ? "<a href='javascript:window.location.href=window.location.href' class='ytLink'>reload</a>" : "");
  14851. }
  14852. function ed() {
  14853. Gi.hidden = true;
  14854. fi.style.display = "none";
  14855. zn.style.display = "block";
  14856. Yi.style.display = "block";
  14857. bd();
  14858. id();
  14859. Fd();
  14860. fi.style.display = "none";
  14861. Yi.style.display = "block";
  14862. let e = Bi("moo_name") || "";
  14863. if (!e.length && FRVR.profile) {
  14864. e = FRVR.profile.name();
  14865. if (e) {
  14866. e += Math.floor(Math.random() * 90) + 9;
  14867. }
  14868. }
  14869. Ki.value = e || "";
  14870. }
  14871. function td(e) {
  14872. var t;
  14873. if (((t = e == null ? undefined : e.detail) == null ? undefined : t.state) === "verified") {
  14874. $i = e.detail.payload, document.getElementById("altcha").remove(), document.getElementById("enterGame").innerText = "Enter Game";;
  14875. Hi.classList.remove("disabled");
  14876. }
  14877. }
  14878. window.addEventListener("load", () => {
  14879. document.getElementById("altcha_checkbox").click();
  14880. document.getElementById("enterGame").innerText = "Auto Verify Shit";
  14881. const e = document.getElementById("altcha");
  14882. if (!(e == null)) {
  14883. e.addEventListener("statechange", td);
  14884. }
  14885. });
  14886. let rn = false;
  14887. function id() {
  14888. Hi.onclick = A.checkTrusted(function () {
  14889. if (!Hi.classList.contains("disabled")) {
  14890. hr("Connecting...");
  14891. if (sr()) {
  14892. if (rn) {
  14893. FRVR.ads.show("interstitial").catch(console.error).finally(Pn);
  14894. } else {
  14895. Pn();
  14896. rn = true;
  14897. }
  14898. } else if (rn) {
  14899. FRVR.ads.show("interstitial").catch(console.error).finally(ro);
  14900. } else {
  14901. ro();
  14902. rn = true;
  14903. }
  14904. }
  14905. });
  14906. A.hookTouchEvents(Hi);
  14907. if (ds) {
  14908. ds.onclick = A.checkTrusted(function () {
  14909. il("https://krunker.io/?play=SquidGame_KB");
  14910. });
  14911. A.hookTouchEvents(ds);
  14912. }
  14913. if (ps) {
  14914. ps.onclick = A.checkTrusted(function () {
  14915. // TOLOOK
  14916. setTimeout(function () {
  14917. Uf();
  14918. }, 10);
  14919. });
  14920. A.hookTouchEvents(ps);
  14921. }
  14922. _s.onclick = A.checkTrusted(function () {
  14923. Id();
  14924. });
  14925. A.hookTouchEvents(_s);
  14926. ho.onclick = A.checkTrusted(function () {
  14927. dd();
  14928. });
  14929. A.hookTouchEvents(ho);
  14930. uo.onclick = A.checkTrusted(function () {
  14931. kd();
  14932. });
  14933. A.hookTouchEvents(uo);
  14934. fo.onclick = A.checkTrusted(function () {
  14935. Va();
  14936. });
  14937. A.hookTouchEvents(fo);
  14938. De.onclick = A.checkTrusted(function () {
  14939. Xa();
  14940. });
  14941. A.hookTouchEvents(De);
  14942. }
  14943. let In;
  14944. const nd = {
  14945. view: () => {
  14946. if (!xt.servers) {
  14947. return;
  14948. }
  14949. let e = 0;
  14950. const t = Object.keys(xt.servers).map(i => {
  14951. const n = xt.regionInfo[i].name;
  14952. let s = 0;
  14953. const r = xt.servers[i].map(o => {
  14954. var u;
  14955. s += o.playerCount;
  14956. const l = o.selected;
  14957. let c = n + " " + o.name + " [" + Math.min(o.playerCount, o.playerCapacity) + "/" + o.playerCapacity + "]";
  14958. const a = o.name;
  14959. const f = l ? "selected" : "";
  14960. if (o.ping && ((u = o.pings) == null ? undefined : u.length) >= 2) {
  14961. c += ` [${Math.floor(o.ping)}ms]`;
  14962. } else if (!l) {
  14963. c += " [?]";
  14964. }
  14965. let d = {
  14966. value: i + ":" + a
  14967. };
  14968. if (f) {
  14969. In = i + ":" + a;
  14970. d.selected = true;
  14971. }
  14972. return kt("option", d, c);
  14973. });
  14974. e += s;
  14975. return [kt("option[disabled]", `${n} - ${s} players`), r, kt("option[disabled]")];
  14976. });
  14977. return kt("select", {
  14978. value: In,
  14979. onfocus: () => {
  14980. window.blockRedraw = true;
  14981. },
  14982. onblur: () => {
  14983. window.blockRedraw = false;
  14984. },
  14985. onchange: od
  14986. }, [t, kt("option[disabled]", `All Servers - ${e} players`)]);
  14987. }
  14988. };
  14989. kt.mount(qf, nd);
  14990. var Bs;
  14991. var Hs;
  14992. if (location.hostname == "sandbox.moomoo.io") {
  14993. Bs = "Back to MooMoo";
  14994. Hs = "//moomoo.io/";
  14995. } else {
  14996. Bs = "Try the sandbox";
  14997. Hs = "//sandbox.moomoo.io/";
  14998. }
  14999. document.getElementById("altServer").innerHTML = "<a href='" + Hs + "'>" + Bs + "<i class='material-icons' style='font-size:10px;vertical-align:middle'>arrow_forward_ios</i></a>";
  15000. const sd = `${dn}/servers?v=1.26`;
  15001. const Da = async () => fetch(sd).then(e => e.json()).then(async e => xt.processServers(e)).catch(e => {
  15002. console.error("Failed to load server data with status code:", e);
  15003. });
  15004. const rd = () => Da().then(ed).catch(e => {
  15005. console.error("Failed to load.");
  15006. });
  15007. window.frvrSdkInitPromise.then(() => window.FRVR.bootstrapper.complete()).then(() => rd());
  15008. const od = e => {
  15009. window.blockRedraw = false;
  15010. if (FRVR.channelCharacteristics.allowNavigation) {
  15011. const [t, i] = e.target.value.split(":");
  15012. xt.switchServer(t, i);
  15013. } else if (bn) {
  15014. bn = false;
  15015. Ds = false;
  15016. Os = true;
  15017. $n = true;
  15018. me.close();
  15019. }
  15020. };
  15021. document.getElementById("pre-content-container");
  15022. function ad() {
  15023. FRVR.ads.show("interstitial", Pn);
  15024. }
  15025. window.showPreAd = ad;
  15026. function Ue(e, t, i) {
  15027. if (P && e) {
  15028. A.removeAllChildren(vt);
  15029. vt.classList.add("visible");
  15030. A.generateElement({
  15031. id: "itemInfoName",
  15032. text: A.capitalizeFirst(e.name),
  15033. parent: vt
  15034. });
  15035. A.generateElement({
  15036. id: "itemInfoDesc",
  15037. text: e.desc,
  15038. parent: vt
  15039. });
  15040. if (!i) {
  15041. if (t) {
  15042. A.generateElement({
  15043. class: "itemInfoReq",
  15044. text: e.type ? "secondary" : "primary",
  15045. parent: vt
  15046. });
  15047. } else {
  15048. for (let s = 0; s < e.req.length; s += 2) {
  15049. A.generateElement({
  15050. class: "itemInfoReq",
  15051. html: e.req[s] + "<span class='itemInfoReqVal'> x" + e.req[s + 1] + "</span>",
  15052. parent: vt
  15053. });
  15054. }
  15055. const n = Ta ? e.group.sandboxLimit || Math.max(e.group.limit * 3, 99) : e.group.limit;
  15056. if (e.group.limit) {
  15057. A.generateElement({
  15058. class: "itemInfoLmt",
  15059. text: (P.itemCounts[e.group.id] || 0) + "/" + n,
  15060. parent: vt
  15061. });
  15062. }
  15063. }
  15064. }
  15065. } else {
  15066. vt.classList.remove("visible");
  15067. }
  15068. }
  15069. let di = [];
  15070. let ii = [];
  15071. function ld(e, t) {
  15072. di.push({
  15073. sid: e,
  15074. name: t
  15075. });
  15076. ur();
  15077. }
  15078. function ur() {
  15079. if (di[0]) {
  15080. const e = di[0];
  15081. A.removeAllChildren(Yt);
  15082. Yt.style.display = "block";
  15083. A.generateElement({
  15084. class: "notificationText",
  15085. text: e.name,
  15086. parent: Yt
  15087. });
  15088. A.generateElement({
  15089. class: "notifButton",
  15090. html: "<i class='material-icons' style='font-size:28px;color:#cc5151;'>&#xE14C;</i>",
  15091. parent: Yt,
  15092. onclick: function () {
  15093. Fs(0);
  15094. },
  15095. hookTouch: true
  15096. });
  15097. A.generateElement({
  15098. class: "notifButton",
  15099. html: "<i class='material-icons' style='font-size:28px;color:#8ecc51;'>&#xE876;</i>",
  15100. parent: Yt,
  15101. onclick: function () {
  15102. Fs(1);
  15103. },
  15104. hookTouch: true
  15105. });
  15106. } else {
  15107. Yt.style.display = "none";
  15108. }
  15109. }
  15110. function cd(e) {
  15111. tt.push(e);
  15112. if (We.style.display == "block") {
  15113. Qi();
  15114. }
  15115. }
  15116. function hd(e, t) {
  15117. if (P) {
  15118. P.team = e;
  15119. P.isOwner = t;
  15120. if (We.style.display == "block") {
  15121. Qi();
  15122. }
  15123. }
  15124. }
  15125. function ud(e) {
  15126. ii = e;
  15127. if (We.style.display == "block") {
  15128. Qi();
  15129. }
  15130. }
  15131. function fd(e) {
  15132. for (let t = tt.length - 1; t >= 0; t--) {
  15133. if (tt[t].sid == e) {
  15134. tt.splice(t, 1);
  15135. }
  15136. }
  15137. if (We.style.display == "block") {
  15138. Qi();
  15139. }
  15140. }
  15141. function dd() {
  15142. gr();
  15143. if (We.style.display != "block") {
  15144. Qi();
  15145. } else {
  15146. Ls();
  15147. }
  15148. }
  15149. function Ls() {
  15150. if (We.style.display == "block") {
  15151. We.style.display = "none";
  15152. }
  15153. }
  15154. function Qi() {
  15155. if (P && P.alive) {
  15156. Bn();
  15157. bt.style.display = "none";
  15158. We.style.display = "block";
  15159. A.removeAllChildren(nn);
  15160. if (P.team) {
  15161. for (var e = 0; e < ii.length; e += 2) {
  15162. (function (t) {
  15163. const i = A.generateElement({
  15164. class: "allianceItem",
  15165. style: "color:" + (ii[t] == P.sid ? "#fff" : "rgba(255,255,255,0.6)"),
  15166. text: ii[t + 1],
  15167. parent: nn
  15168. });
  15169. if (P.isOwner && ii[t] != P.sid) {
  15170. A.generateElement({
  15171. class: "joinAlBtn",
  15172. text: "Kick",
  15173. onclick: function () {
  15174. Oa(ii[t]);
  15175. },
  15176. hookTouch: true,
  15177. parent: i
  15178. });
  15179. }
  15180. })(e);
  15181. }
  15182. } else if (tt.length) {
  15183. for (var e = 0; e < tt.length; ++e) {
  15184. (function (i) {
  15185. const n = A.generateElement({
  15186. class: "allianceItem",
  15187. style: "color:" + (tt[i].sid == P.team ? "#fff" : "rgba(255,255,255,0.6)"),
  15188. text: tt[i].sid,
  15189. parent: nn
  15190. });
  15191. A.generateElement({
  15192. class: "joinAlBtn",
  15193. text: "Join",
  15194. onclick: function () {
  15195. _a(i);
  15196. },
  15197. hookTouch: true,
  15198. parent: n
  15199. });
  15200. })(e);
  15201. }
  15202. } else {
  15203. A.generateElement({
  15204. class: "allianceItem",
  15205. text: "No Tribes Yet",
  15206. parent: nn
  15207. });
  15208. }
  15209. A.removeAllChildren(sn);
  15210. if (P.team) {
  15211. A.generateElement({
  15212. class: "allianceButtonM",
  15213. style: "width: 360px",
  15214. text: P.isOwner ? "Delete Tribe" : "Leave Tribe",
  15215. onclick: function () {
  15216. za();
  15217. },
  15218. hookTouch: true,
  15219. parent: sn
  15220. });
  15221. } else {
  15222. A.generateElement({
  15223. tag: "input",
  15224. type: "text",
  15225. id: "allianceInput",
  15226. maxLength: 7,
  15227. placeholder: "unique name",
  15228. onchange: t => {
  15229. t.target.value = (t.target.value || "").slice(0, 7);
  15230. },
  15231. onkeypress: t => {
  15232. if (t.key === "Enter") {
  15233. t.preventDefault();
  15234. Vs();
  15235. return false;
  15236. }
  15237. },
  15238. parent: sn
  15239. });
  15240. A.generateElement({
  15241. tag: "div",
  15242. class: "allianceButtonM",
  15243. style: "width: 140px;",
  15244. text: "Create",
  15245. onclick: function () {
  15246. Vs();
  15247. },
  15248. hookTouch: true,
  15249. parent: sn
  15250. });
  15251. }
  15252. }
  15253. }
  15254. function Fs(e) {
  15255. me.send("P", di[0].sid, e);
  15256. di.splice(0, 1);
  15257. ur();
  15258. }
  15259. function Oa(e) {
  15260. me.send("Q", e);
  15261. }
  15262. function _a(e) {
  15263. me.send("b", tt[e].sid);
  15264. }
  15265. function Vs() {
  15266. me.send("L", document.getElementById("allianceInput").value);
  15267. }
  15268. function za() {
  15269. di = [];
  15270. ur();
  15271. me.send("N");
  15272. }
  15273. let mn;
  15274. let Ri;
  15275. let At;
  15276. const oi = [];
  15277. let Pt;
  15278. function pd() {
  15279. this.init = function (e, t) {
  15280. this.scale = 0;
  15281. this.x = e;
  15282. this.y = t;
  15283. this.active = true;
  15284. };
  15285. this.update = function (e, t) {
  15286. if (this.active) {
  15287. this.scale += t * 0.05;
  15288. if (this.scale >= T.mapPingScale) {
  15289. this.active = false;
  15290. } else {
  15291. e.globalAlpha = 1 - Math.max(0, this.scale / T.mapPingScale);
  15292. e.beginPath();
  15293. e.arc(this.x / T.mapScale * De.width, this.y / T.mapScale * De.width, this.scale, 0, Math.PI * 2);
  15294. e.stroke();
  15295. }
  15296. }
  15297. };
  15298. }
  15299. function md(e, t) {
  15300. for (let i = 0; i < oi.length; ++i) {
  15301. if (!oi[i].active) {
  15302. Pt = oi[i];
  15303. break;
  15304. }
  15305. }
  15306. if (!Pt) {
  15307. Pt = new pd();
  15308. oi.push(Pt);
  15309. }
  15310. Pt.init(e, t);
  15311. }
  15312. function gd() {
  15313. if (!At) {
  15314. At = {};
  15315. }
  15316. At.x = P.x;
  15317. At.y = P.y;
  15318. }
  15319. function yd(e) {
  15320. Ri = e;
  15321. }
  15322. function wd(e) {
  15323. if (P && P.alive) {
  15324. Te.clearRect(0, 0, De.width, De.height);
  15325. Te.strokeStyle = "#fff";
  15326. Te.lineWidth = 4;
  15327. for (var t = 0; t < oi.length; ++t) {
  15328. Pt = oi[t];
  15329. Pt.update(Te, e);
  15330. }
  15331. Te.globalAlpha = 1;
  15332. Te.fillStyle = "#fff";
  15333. he(P.x / T.mapScale * De.width, P.y / T.mapScale * De.height, 7, Te, true);
  15334. Te.fillStyle = "rgba(255,255,255,0.35)";
  15335. if (P.team && Ri) {
  15336. for (var t = 0; t < Ri.length;) {
  15337. he(Ri[t] / T.mapScale * De.width, Ri[t + 1] / T.mapScale * De.height, 7, Te, true);
  15338. t += 2;
  15339. }
  15340. }
  15341. if (mn) {
  15342. Te.fillStyle = "#fc5553";
  15343. Te.font = "34px Hammersmith One";
  15344. Te.textBaseline = "middle";
  15345. Te.textAlign = "center";
  15346. Te.fillText("x", mn.x / T.mapScale * De.width, mn.y / T.mapScale * De.height);
  15347. }
  15348. if (At) {
  15349. Te.fillStyle = "#fff";
  15350. Te.font = "34px Hammersmith One";
  15351. Te.textBaseline = "middle";
  15352. Te.textAlign = "center";
  15353. Te.fillText("x", At.x / T.mapScale * De.width, At.y / T.mapScale * De.height);
  15354. }
  15355. }
  15356. }
  15357. let Ns = 0;
  15358. function vd(e) {
  15359. if (Ns != e) {
  15360. Ns = e;
  15361. fr();
  15362. }
  15363. }
  15364. function kd() {
  15365. if (bt.style.display != "block") {
  15366. bt.style.display = "block";
  15367. We.style.display = "none";
  15368. Bn();
  15369. fr();
  15370. } else {
  15371. Us();
  15372. }
  15373. }
  15374. function Us() {
  15375. if (bt.style.display == "block") {
  15376. bt.style.display = "none";
  15377. Ue();
  15378. }
  15379. }
  15380. function xd(e, t, i) {
  15381. if (i) {
  15382. if (e) {
  15383. P.tailIndex = t;
  15384. } else {
  15385. P.tails[t] = 1;
  15386. }
  15387. } else if (e) {
  15388. P.skinIndex = t;
  15389. } else {
  15390. P.skins[t] = 1;
  15391. }
  15392. if (bt.style.display == "block") {
  15393. fr();
  15394. }
  15395. }
  15396. function fr() {
  15397. if (P) {
  15398. A.removeAllChildren(vo);
  15399. const e = Ns;
  15400. const t = e ? Ni : Vi;
  15401. for (let i = 0; i < t.length; ++i) {
  15402. if (!t[i].dontSell) {
  15403. (function (n) {
  15404. const s = A.generateElement({
  15405. id: "storeDisplay" + n,
  15406. class: "storeItem",
  15407. onmouseout: function () {
  15408. Ue();
  15409. },
  15410. onmouseover: function () {
  15411. Ue(t[n], false, true);
  15412. },
  15413. parent: vo
  15414. });
  15415. A.hookTouchEvents(s, true);
  15416. A.generateElement({
  15417. tag: "img",
  15418. class: "hatPreview",
  15419. src: "./img/" + (e ? "accessories/access_" : "hats/hat_") + t[n].id + (t[n].topSprite ? "_p" : "") + ".png",
  15420. parent: s
  15421. });
  15422. A.generateElement({
  15423. tag: "span",
  15424. text: t[n].name,
  15425. parent: s
  15426. });
  15427. if (e ? !P.tails[t[n].id] : !P.skins[t[n].id]) {
  15428. A.generateElement({
  15429. class: "joinAlBtn",
  15430. style: "margin-top: 5px",
  15431. text: "Buy",
  15432. onclick: function () {
  15433. Ba(t[n].id, e);
  15434. },
  15435. hookTouch: true,
  15436. parent: s
  15437. });
  15438. A.generateElement({
  15439. tag: "span",
  15440. class: "itemPrice",
  15441. text: t[n].price,
  15442. parent: s
  15443. });
  15444. } else if ((e ? P.tailIndex : P.skinIndex) == t[n].id) {
  15445. A.generateElement({
  15446. class: "joinAlBtn",
  15447. style: "margin-top: 5px",
  15448. text: "Unequip",
  15449. onclick: function () {
  15450. Ws(0, e);
  15451. },
  15452. hookTouch: true,
  15453. parent: s
  15454. });
  15455. } else {
  15456. A.generateElement({
  15457. class: "joinAlBtn",
  15458. style: "margin-top: 5px",
  15459. text: "Equip",
  15460. onclick: function () {
  15461. Ws(t[n].id, e);
  15462. },
  15463. hookTouch: true,
  15464. parent: s
  15465. });
  15466. }
  15467. })(i);
  15468. }
  15469. }
  15470. }
  15471. }
  15472. function Ws(e, t) {
  15473. me.send("c", 0, e, t);
  15474. }
  15475. function Ba(e, t) {
  15476. me.send("c", 1, e, t);
  15477. }
  15478. function Ha() {
  15479. bt.style.display = "none";
  15480. We.style.display = "none";
  15481. Bn();
  15482. }
  15483. function bd() {
  15484. const e = Bi("native_resolution");
  15485. ys(e ? e == "true" : typeof cordova !== "undefined");
  15486. Et = Bi("show_ping") == "true";
  15487. Gi.hidden = !Et || !qi;
  15488. Bi("moo_moosic");
  15489. // TOLOOK
  15490. setInterval(function () {
  15491. if (window.cordova) {
  15492. document.getElementById("downloadButtonContainer").classList.add("cordova");
  15493. document.getElementById("mobileDownloadButtonContainer").classList.add("cordova");
  15494. }
  15495. }, 1000);
  15496. Fa();
  15497. A.removeAllChildren(mo);
  15498. for (var t = 0; t < L.weapons.length + L.list.length; ++t) {
  15499. (function (i) {
  15500. A.generateElement({
  15501. id: "actionBarItem" + i,
  15502. class: "actionBarItem",
  15503. style: "display:none",
  15504. onmouseout: function () {
  15505. Ue();
  15506. },
  15507. parent: mo
  15508. });
  15509. })(t);
  15510. }
  15511. for (var t = 0; t < L.list.length + L.weapons.length; ++t) {
  15512. (function (n) {
  15513. const s = document.createElement("canvas");
  15514. s.width = s.height = 66;
  15515. const r = s.getContext("2d");
  15516. r.translate(s.width / 2, s.height / 2);
  15517. r.imageSmoothingEnabled = false;
  15518. r.webkitImageSmoothingEnabled = false;
  15519. r.mozImageSmoothingEnabled = false;
  15520. if (L.weapons[n]) {
  15521. r.rotate(Math.PI / 4 + Math.PI);
  15522. var o = new Image();
  15523. Gs[L.weapons[n].src] = o;
  15524. o.onload = function () {
  15525. this.isLoaded = true;
  15526. const c = 1 / (this.height / this.width);
  15527. const a = L.weapons[n].iPad || 1;
  15528. r.drawImage(this, -(s.width * a * T.iconPad * c) / 2, -(s.height * a * T.iconPad) / 2, s.width * a * c * T.iconPad, s.height * a * T.iconPad);
  15529. r.fillStyle = "rgba(0, 0, 70, 0.1)";
  15530. r.globalCompositeOperation = "source-atop";
  15531. r.fillRect(-s.width / 2, -s.height / 2, s.width, s.height);
  15532. document.getElementById("actionBarItem" + n).style.backgroundImage = "url(" + s.toDataURL() + ")";
  15533. };
  15534. o.src = "./img/weapons/" + L.weapons[n].src + ".png";
  15535. var l = document.getElementById("actionBarItem" + n);
  15536. l.onmouseover = A.checkTrusted(function () {
  15537. Ue(L.weapons[n], true);
  15538. });
  15539. l.onclick = A.checkTrusted(function () {
  15540. Ui(n, true);
  15541. });
  15542. A.hookTouchEvents(l);
  15543. } else {
  15544. var o = yr(L.list[n - L.weapons.length], true);
  15545. const a = Math.min(s.width - T.iconPadding, o.width);
  15546. r.globalAlpha = 1;
  15547. r.drawImage(o, -a / 2, -a / 2, a, a);
  15548. r.fillStyle = "rgba(0, 0, 70, 0.1)";
  15549. r.globalCompositeOperation = "source-atop";
  15550. r.fillRect(-a / 2, -a / 2, a, a);
  15551. document.getElementById("actionBarItem" + n).style.backgroundImage = "url(" + s.toDataURL() + ")";
  15552. var l = document.getElementById("actionBarItem" + n);
  15553. l.onmouseover = A.checkTrusted(function () {
  15554. Ue(L.list[n - L.weapons.length]);
  15555. });
  15556. l.onclick = A.checkTrusted(function () {
  15557. Ui(n - L.weapons.length);
  15558. });
  15559. A.hookTouchEvents(l);
  15560. }
  15561. })(t);
  15562. }
  15563. Ki.onchange = i => {
  15564. i.target.value = (i.target.value || "").slice(0, 15);
  15565. };
  15566. Ki.onkeypress = i => {
  15567. if (i.key === "Enter") {
  15568. i.preventDefault();
  15569. Hi.onclick(i);
  15570. return false;
  15571. }
  15572. };
  15573. zs.checked = Ca;
  15574. zs.onchange = A.checkTrusted(function (i) {
  15575. ys(i.target.checked);
  15576. });
  15577. ms.checked = Et;
  15578. ms.onchange = A.checkTrusted(function (i) {
  15579. Et = ms.checked;
  15580. Gi.hidden = !Et;
  15581. _n("show_ping", Et ? "true" : "false");
  15582. });
  15583. }
  15584. function La(e, t) {
  15585. if (e) {
  15586. if (t) {
  15587. P.weapons = e;
  15588. } else {
  15589. P.items = e;
  15590. }
  15591. }
  15592. for (var i = 0; i < L.list.length; ++i) {
  15593. const n = L.weapons.length + i;
  15594. document.getElementById("actionBarItem" + n).style.display = P.items.indexOf(L.list[i].id) >= 0 ? "inline-block" : "none";
  15595. }
  15596. for (var i = 0; i < L.weapons.length; ++i) {
  15597. document.getElementById("actionBarItem" + i).style.display = P.weapons[L.weapons[i].type] == L.weapons[i].id ? "inline-block" : "none";
  15598. }
  15599. }
  15600. function ys(e) {
  15601. Ca = e;
  15602. jt = e && window.devicePixelRatio || 1;
  15603. zs.checked = e;
  15604. _n("native_resolution", e.toString());
  15605. dr();
  15606. }
  15607. function Sd() {
  15608. if (ji) {
  15609. Li.classList.add("touch");
  15610. } else {
  15611. Li.classList.remove("touch");
  15612. }
  15613. }
  15614. function Id() {
  15615. if (Li.classList.contains("showing")) {
  15616. Li.classList.remove("showing");
  15617. co.innerText = "Settings";
  15618. } else {
  15619. Li.classList.add("showing");
  15620. co.innerText = "Close";
  15621. }
  15622. }
  15623. function Fa() {
  15624. let e = "";
  15625. for (let t = 0; t < T.skinColors.length; ++t) {
  15626. if (t == or) {
  15627. e += "<div class='skinColorItem activeSkin' style='background-color:" + T.skinColors[t] + "' onclick='selectSkinColor(" + t + ")'></div>";
  15628. } else {
  15629. e += "<div class='skinColorItem' style='background-color:" + T.skinColors[t] + "' onclick='selectSkinColor(" + t + ")'></div>";
  15630. }
  15631. }
  15632. Qf.innerHTML = e;
  15633. }
  15634. function Td(e) {
  15635. or = e;
  15636. Fa();
  15637. }
  15638. const Ai = document.getElementById("chatBox");
  15639. const Tn = document.getElementById("chatHolder");
  15640. function Va() {
  15641. if (ji) {
  15642. // TOLOOK
  15643. setTimeout(function () {
  15644. const e = prompt("chat message");
  15645. if (e) {
  15646. xo(e);
  15647. }
  15648. }, 1);
  15649. } else if (Tn.style.display == "block") {
  15650. if (Ai.value) {
  15651. xo(Ai.value);
  15652. }
  15653. Bn();
  15654. } else {
  15655. bt.style.display = "none";
  15656. We.style.display = "none";
  15657. Tn.style.display = "block";
  15658. Ai.focus();
  15659. gr();
  15660. }
  15661. Ai.value = "";
  15662. }
  15663. function xo(e) {
  15664. me.send("6", e.slice(0, 30));
  15665. }
  15666. function Bn() {
  15667. Ai.value = "";
  15668. Tn.style.display = "none";
  15669. }
  15670. function Md(e, t) {
  15671. const i = Hn(e);
  15672. if (i) {
  15673. i.chatMessage = t;
  15674. i.chatCountdown = T.chatCountdown;
  15675. }
  15676. }
  15677. window.addEventListener("resize", A.checkTrusted(dr));
  15678. function dr() {
  15679. ei = window.innerWidth;
  15680. ti = window.innerHeight;
  15681. const e = Math.max(ei / ge, ti / ye) * jt;
  15682. ri.width = ei * jt;
  15683. ri.height = ti * jt;
  15684. ri.style.width = ei + "px";
  15685. ri.style.height = ti + "px";
  15686. C.setTransform(e, 0, 0, e, (ei * jt - ge * e) / 2, (ti * jt - ye * e) / 2);
  15687. }
  15688. dr();
  15689. let ji;
  15690. Ot(false);
  15691. function Ot(e) {
  15692. ji = e;
  15693. Sd();
  15694. }
  15695. window.setUsingTouch = Ot;
  15696. let Ed = document.getElementById("leaderboardButton");
  15697. let Na = document.getElementById("leaderboard");
  15698. Ed.addEventListener("touchstart", () => {
  15699. Na.classList.add("is-showing");
  15700. });
  15701. const pr = () => {
  15702. Na.classList.remove("is-showing");
  15703. };
  15704. document.body.addEventListener("touchend", pr);
  15705. document.body.addEventListener("touchleave", pr);
  15706. document.body.addEventListener("touchcancel", pr);
  15707. if (!Ma) {
  15708. let t = function (s) {
  15709. s.preventDefault();
  15710. s.stopPropagation();
  15711. Ot(false);
  15712. Ra = s.clientX;
  15713. Aa = s.clientY;
  15714. };
  15715. let i = function (s) {
  15716. Ot(false);
  15717. if (Ke != 1) {
  15718. Ke = 1;
  15719. _t();
  15720. }
  15721. };
  15722. let n = function (s) {
  15723. Ot(false);
  15724. if (Ke != 0) {
  15725. Ke = 0;
  15726. _t();
  15727. }
  15728. };
  15729. var gp = t;
  15730. var yp = i;
  15731. var wp = n;
  15732. const e = document.getElementById("touch-controls-fullscreen");
  15733. e.style.display = "block";
  15734. e.addEventListener("mousemove", t, false);
  15735. e.addEventListener("mousedown", i, false);
  15736. e.addEventListener("mouseup", n, false);
  15737. }
  15738. let Xs = false;
  15739. let Ua;
  15740. function Cd() {
  15741. let e = 0;
  15742. let t = 0;
  15743. let i;
  15744. if (ji) {
  15745. if (!Xs) {
  15746. return;
  15747. }
  15748. i = Ua;
  15749. }
  15750. for (const n in En) {
  15751. const s = En[n];
  15752. e += !!ut[n] * s[0];
  15753. t += !!ut[n] * s[1];
  15754. }
  15755. if (e != 0 || t != 0) {
  15756. i = Math.atan2(t, e);
  15757. }
  15758. if (i !== undefined) {
  15759. return A.fixTo(i, 2);
  15760. }
  15761. }
  15762. let Mn;
  15763. function mr() {
  15764. if (P) {
  15765. if (!P.lockDir && !ji) {
  15766. Mn = Math.atan2(Aa - ti / 2, Ra - ei / 2);
  15767. }
  15768. return A.fixTo(Mn || 0, 2);
  15769. } else {
  15770. return 0;
  15771. }
  15772. }
  15773. var ut = {};
  15774. var En = {
  15775. 87: [0, -1],
  15776. 38: [0, -1],
  15777. 83: [0, 1],
  15778. 40: [0, 1],
  15779. 65: [-1, 0],
  15780. 37: [-1, 0],
  15781. 68: [1, 0],
  15782. 39: [1, 0]
  15783. };
  15784. function gr() {
  15785. ut = {};
  15786. me.send("e");
  15787. }
  15788. function Wa() {
  15789. return We.style.display != "block" && Tn.style.display != "block";
  15790. }
  15791. function Pd(e) {
  15792. const t = e.which || e.keyCode || 0;
  15793. if (t == 27) {
  15794. Ha();
  15795. } else if (P && P.alive && Wa()) {
  15796. if (!ut[t]) {
  15797. ut[t] = 1;
  15798. if (t == 69) {
  15799. Ad();
  15800. } else if (t == 67) {
  15801. gd();
  15802. } else if (t == 88) {
  15803. Rd();
  15804. } else if (P.weapons[t - 49] != null) {
  15805. Ui(P.weapons[t - 49], true);
  15806. } else if (P.items[t - 49 - P.weapons.length] != null) {
  15807. Ui(P.items[t - 49 - P.weapons.length]);
  15808. } else if (t == 81) {
  15809. Ui(P.items[0]);
  15810. } else if (t == 82) {
  15811. Xa();
  15812. } else if (En[t]) {
  15813. Cn();
  15814. } else if (t == 32) {
  15815. Ke = 1;
  15816. _t();
  15817. }
  15818. }
  15819. }
  15820. }
  15821. window.addEventListener("keydown", A.checkTrusted(Pd));
  15822. function $d(e) {
  15823. if (P && P.alive) {
  15824. const t = e.which || e.keyCode || 0;
  15825. if (t == 13) {
  15826. if (We.style.display === "block") {
  15827. return;
  15828. }
  15829. Va();
  15830. } else if (Wa() && ut[t]) {
  15831. ut[t] = 0;
  15832. if (En[t]) {
  15833. Cn();
  15834. } else if (t == 32) {
  15835. Ke = 0;
  15836. _t();
  15837. }
  15838. }
  15839. }
  15840. }
  15841. window.addEventListener("keyup", A.checkTrusted($d));
  15842. function _t() {
  15843. if (P && P.alive) {
  15844. me.send("F", Ke, P.buildIndex >= 0 ? mr() : null);
  15845. }
  15846. }
  15847. let ws1;
  15848. function Cn() {
  15849. const e = Cd();
  15850. if (ws1 == null || e == null || Math.abs(e - ws1) > 0.3) {
  15851. me.send("9", e);
  15852. ws1 = e;
  15853. }
  15854. }
  15855. function Rd() {
  15856. P.lockDir = P.lockDir ? 0 : 1;
  15857. me.send("K", 0);
  15858. }
  15859. function Xa() {
  15860. me.send("S", 1);
  15861. }
  15862. function Ad() {
  15863. me.send("K", 1);
  15864. }
  15865. function Ui(e, t) {
  15866. me.send("z", e, t);
  15867. }
  15868. function Pn() {
  15869. Gi.hidden = !Et;
  15870. window.onbeforeunload = function (e) {
  15871. return "Are you sure?";
  15872. };
  15873. if (window.FRVR) {
  15874. window.FRVR.tracker.levelStart("game_start");
  15875. }
  15876. _n("moo_name", Ki.value);
  15877. if (!qi && sr()) {
  15878. qi = true;
  15879. Wf.stop("menu");
  15880. hr("Loading...");
  15881. me.send("M", {
  15882. name: Ki.value,
  15883. moofoll: Sn,
  15884. skin: or
  15885. });
  15886. }
  15887. Dd();
  15888. }
  15889. function Dd() {
  15890. var e = document.getElementById("ot-sdk-btn-floating");
  15891. if (e) {
  15892. e.style.display = "none";
  15893. }
  15894. }
  15895. function Od() {
  15896. var e = document.getElementById("ot-sdk-btn-floating");
  15897. if (e) {
  15898. e.style.display = "block";
  15899. }
  15900. }
  15901. let $n = true;
  15902. let vs = false;
  15903. function _d(e) {
  15904. fi.style.display = "none";
  15905. Yi.style.display = "block";
  15906. zn.style.display = "none";
  15907. ut = {};
  15908. $a = e;
  15909. Ke = 0;
  15910. qi = true;
  15911. if ($n) {
  15912. $n = false;
  15913. Dt.length = 0;
  15914. }
  15915. if (Ma) {
  15916. Vu.enable({
  15917. onStartMoving: () => {
  15918. Us();
  15919. Ls();
  15920. Ot(true);
  15921. Xs = true;
  15922. },
  15923. onStopMoving: () => {
  15924. Xs = false;
  15925. Cn();
  15926. },
  15927. onRotateMoving: (t, i) => {
  15928. if (!(i.force < 0.25)) {
  15929. Ua = -i.angle.radian;
  15930. Cn();
  15931. if (!vs) {
  15932. Mn = -i.angle.radian;
  15933. }
  15934. }
  15935. },
  15936. onStartAttacking: () => {
  15937. Us();
  15938. Ls();
  15939. Ot(true);
  15940. vs = true;
  15941. if (P.buildIndex < 0) {
  15942. Ke = 1;
  15943. _t();
  15944. }
  15945. },
  15946. onStopAttacking: () => {
  15947. if (P.buildIndex >= 0) {
  15948. Ke = 1;
  15949. _t();
  15950. }
  15951. Ke = 0;
  15952. _t();
  15953. vs = false;
  15954. },
  15955. onRotateAttacking: (t, i) => {
  15956. if (!(i.force < 0.25)) {
  15957. Mn = -i.angle.radian;
  15958. }
  15959. }
  15960. });
  15961. }
  15962. }
  15963. function zd(e, t, i, n) {
  15964. if (n === -1) {
  15965. As.showText(e, t, 50, 0.18, 500, i, "#ee5551");
  15966. } else {
  15967. As.showText(e, t, 50, 0.18, 500, Math.abs(i), i >= 0 ? "#fff" : "#8ecc51");
  15968. }
  15969. }
  15970. let gn = 99999;
  15971. function Bd() {
  15972. qi = false;
  15973. Od();
  15974. try {
  15975. factorem.refreshAds([2], true);
  15976. } catch {}
  15977. ar.style.display = "none";
  15978. Ha();
  15979. mn = {
  15980. x: P.x,
  15981. y: P.y
  15982. };
  15983. fi.style.display = "none";
  15984. Fi.style.display = "block";
  15985. Fi.style.fontSize = "0px";
  15986. gn = 0;
  15987. // TOLOOK
  15988. setTimeout(function () {
  15989. Yi.style.display = "block";
  15990. zn.style.display = "block";
  15991. Fi.style.display = "none";
  15992. }, T.deathFadeout);
  15993. Da();
  15994. }
  15995. function Hd(e) {
  15996. if (P) {
  15997. $e.removeAllItems(e);
  15998. }
  15999. }
  16000. function Ld(e) {
  16001. $e.disableBySid(e);
  16002. }
  16003. function qa() {
  16004. Gf.innerText = P.points;
  16005. Yf.innerText = P.food;
  16006. Kf.innerText = P.wood;
  16007. Zf.innerText = P.stone;
  16008. Jf.innerText = P.kills;
  16009. }
  16010. const Di = {};
  16011. const ks = ["crown", "skull"];
  16012. function Fd() {
  16013. for (let e = 0; e < ks.length; ++e) {
  16014. const t = new Image();
  16015. t.onload = function () {
  16016. this.isLoaded = true;
  16017. };
  16018. t.src = "./img/icons/" + ks[e] + ".png";
  16019. Di[ks[e]] = t;
  16020. }
  16021. }
  16022. const Kt = [];
  16023. function Ga(e, t) {
  16024. P.upgradePoints = e;
  16025. P.upgrAge = t;
  16026. if (e > 0) {
  16027. Kt.length = 0;
  16028. A.removeAllChildren(Gt);
  16029. for (var i = 0; i < L.weapons.length; ++i) {
  16030. if (L.weapons[i].age == t && (L.weapons[i].pre == null || P.weapons.indexOf(L.weapons[i].pre) >= 0)) {
  16031. var n = A.generateElement({
  16032. id: "upgradeItem" + i,
  16033. class: "actionBarItem",
  16034. onmouseout: function () {
  16035. Ue();
  16036. },
  16037. parent: Gt
  16038. });
  16039. n.style.backgroundImage = document.getElementById("actionBarItem" + i).style.backgroundImage;
  16040. Kt.push(i);
  16041. }
  16042. }
  16043. for (var i = 0; i < L.list.length; ++i) {
  16044. if (L.list[i].age == t && (L.list[i].pre == null || P.items.indexOf(L.list[i].pre) >= 0)) {
  16045. const r = L.weapons.length + i;
  16046. var n = A.generateElement({
  16047. id: "upgradeItem" + r,
  16048. class: "actionBarItem",
  16049. onmouseout: function () {
  16050. Ue();
  16051. },
  16052. parent: Gt
  16053. });
  16054. n.style.backgroundImage = document.getElementById("actionBarItem" + r).style.backgroundImage;
  16055. Kt.push(r);
  16056. }
  16057. }
  16058. for (var i = 0; i < Kt.length; i++) {
  16059. (function (r) {
  16060. const o = document.getElementById("upgradeItem" + r);
  16061. o.onmouseover = function () {
  16062. if (L.weapons[r]) {
  16063. Ue(L.weapons[r], true);
  16064. } else {
  16065. Ue(L.list[r - L.weapons.length]);
  16066. }
  16067. };
  16068. o.onclick = A.checkTrusted(function () {
  16069. me.send("H", r);
  16070. });
  16071. A.hookTouchEvents(o);
  16072. })(Kt[i]);
  16073. }
  16074. if (Kt.length) {
  16075. Gt.style.display = "block";
  16076. tn.style.display = "block";
  16077. tn.innerHTML = "SELECT ITEMS (" + e + ")";
  16078. } else {
  16079. Gt.style.display = "none";
  16080. tn.style.display = "none";
  16081. Ue();
  16082. }
  16083. } else {
  16084. Gt.style.display = "none";
  16085. tn.style.display = "none";
  16086. Ue();
  16087. }
  16088. }
  16089. function Ya(e, t, i) {
  16090. if (e != null) {
  16091. P.XP = e;
  16092. }
  16093. if (t != null) {
  16094. P.maxXP = t;
  16095. }
  16096. if (i != null) {
  16097. P.age = i;
  16098. }
  16099. if (i == T.maxAge) {
  16100. yo.innerHTML = "MAX AGE";
  16101. wo.style.width = "100%";
  16102. } else {
  16103. yo.innerHTML = "AGE " + P.age;
  16104. wo.style.width = P.XP / P.maxXP * 100 + "%";
  16105. }
  16106. }
  16107. function Vd(e) {
  16108. A.removeAllChildren(go);
  16109. let t = 1;
  16110. for (let i = 0; i < e.length; i += 3) {
  16111. (function (n) {
  16112. A.generateElement({
  16113. class: "leaderHolder",
  16114. parent: go,
  16115. children: [A.generateElement({
  16116. class: "leaderboardItem",
  16117. style: "color:" + (e[n] == $a ? "#fff" : "rgba(255,255,255,0.6)"),
  16118. text: t + ". " + (e[n + 1] != "" ? e[n + 1] : "unknown")
  16119. }), A.generateElement({
  16120. class: "leaderScore",
  16121. text: A.kFormat(e[n + 2]) || "0"
  16122. })]
  16123. });
  16124. })(i);
  16125. t++;
  16126. }
  16127. }
  16128. let bo = null;
  16129. function Nd() {
  16130. {
  16131. if (P && (!us || hi - us >= 1000 / T.clientSendRate)) {
  16132. us = hi;
  16133. const a = mr();
  16134. if (bo !== a) {
  16135. bo = a;
  16136. me.send("D", a);
  16137. }
  16138. }
  16139. if (gn < 120) {
  16140. gn += Fe * 0.1;
  16141. Fi.style.fontSize = Math.min(Math.round(gn), 120) + "px";
  16142. }
  16143. if (P) {
  16144. const a = A.getDistance(ot, at, P.x, P.y);
  16145. const f = A.getDirection(P.x, P.y, ot, at);
  16146. const d = Math.min(a * 0.01 * Fe, a);
  16147. if (a > 0.05) {
  16148. ot += d * Math.cos(f);
  16149. at += d * Math.sin(f);
  16150. } else {
  16151. ot = P.x;
  16152. at = P.y;
  16153. }
  16154. } else {
  16155. ot = T.mapScale / 2;
  16156. at = T.mapScale / 2;
  16157. }
  16158. const o = hi - 1000 / T.serverUpdateRate;
  16159. for (var e, t = 0; t < oe.length + Oe.length; ++t) {
  16160. k = oe[t] || Oe[t - oe.length];
  16161. if (k && k.visible) {
  16162. if (k.forcePos) {
  16163. k.x = k.x2;
  16164. k.y = k.y2;
  16165. k.dir = k.d2;
  16166. } else {
  16167. const a = k.t2 - k.t1;
  16168. const d = (o - k.t1) / a;
  16169. const u = 170;
  16170. k.dt += Fe;
  16171. const p = Math.min(1.7, k.dt / u);
  16172. var e = k.x2 - k.x1;
  16173. k.x = k.x1 + e * p;
  16174. e = k.y2 - k.y1;
  16175. k.y = k.y1 + e * p;
  16176. k.dir = Math.lerpAngle(k.d2, k.d1, Math.min(1.2, d));
  16177. }
  16178. }
  16179. }
  16180. const l = ot - ge / 2;
  16181. const c = at - ye / 2;
  16182. if (T.snowBiomeTop - c <= 0 && T.mapScale - T.snowBiomeTop - c >= ye) {
  16183. C.fillStyle = "#b6db66";
  16184. C.fillRect(0, 0, ge, ye);
  16185. } else if (T.mapScale - T.snowBiomeTop - c <= 0) {
  16186. C.fillStyle = "#dbc666";
  16187. C.fillRect(0, 0, ge, ye);
  16188. } else if (T.snowBiomeTop - c >= ye) {
  16189. C.fillStyle = "#fff";
  16190. C.fillRect(0, 0, ge, ye);
  16191. } else if (T.snowBiomeTop - c >= 0) {
  16192. C.fillStyle = "#fff";
  16193. C.fillRect(0, 0, ge, T.snowBiomeTop - c);
  16194. C.fillStyle = "#b6db66";
  16195. C.fillRect(0, T.snowBiomeTop - c, ge, ye - (T.snowBiomeTop - c));
  16196. } else {
  16197. C.fillStyle = "#b6db66";
  16198. C.fillRect(0, 0, ge, T.mapScale - T.snowBiomeTop - c);
  16199. C.fillStyle = "#dbc666";
  16200. C.fillRect(0, T.mapScale - T.snowBiomeTop - c, ge, ye - (T.mapScale - T.snowBiomeTop - c));
  16201. }
  16202. if (!$n) {
  16203. qt += fs * T.waveSpeed * Fe;
  16204. if (qt >= T.waveMax) {
  16205. qt = T.waveMax;
  16206. fs = -1;
  16207. } else if (qt <= 1) {
  16208. qt = fs = 1;
  16209. }
  16210. C.globalAlpha = 1;
  16211. C.fillStyle = "#dbc666";
  16212. To(l, c, C, T.riverPadding);
  16213. C.fillStyle = "#91b2db";
  16214. To(l, c, C, (qt - 1) * 250);
  16215. }
  16216. /*C.lineWidth = 4;
  16217. C.strokeStyle = "#000";
  16218. C.globalAlpha = 0.06;
  16219. C.beginPath();
  16220. for (var i = -ot; i < ge; i += ye / 18) {
  16221. if (i > 0) {
  16222. C.moveTo(i, 0);
  16223. C.lineTo(i, ye);
  16224. }
  16225. }
  16226. for (let a = -at; a < ye; a += ye / 18) {
  16227. if (i > 0) {
  16228. C.moveTo(0, a);
  16229. C.lineTo(ge, a);
  16230. }
  16231. }
  16232. C.stroke();
  16233. C.globalAlpha = 1;
  16234. C.strokeStyle = Zi;*/
  16235. Pi(-1, l, c);
  16236. C.globalAlpha = 1;
  16237. C.lineWidth = St;
  16238. So(0, l, c);
  16239. Mo(l, c, 0);
  16240. C.globalAlpha = 1;
  16241. for (var t = 0; t < Oe.length; ++t) {
  16242. k = Oe[t];
  16243. if (k.active && k.visible) {
  16244. k.animate(Fe);
  16245. C.save();
  16246. C.translate(k.x - l, k.y - c);
  16247. C.rotate(k.dir + k.dirPlus - Math.PI / 2);
  16248. op(k, C);
  16249. C.restore();
  16250. }
  16251. }
  16252. Pi(0, l, c);
  16253. So(1, l, c);
  16254. Pi(1, l, c);
  16255. Mo(l, c, 1);
  16256. Pi(2, l, c);
  16257. Pi(3, l, c);
  16258. C.fillStyle = "#000";
  16259. C.globalAlpha = 0.09;
  16260. if (l <= 0) {
  16261. C.fillRect(0, 0, -l, ye);
  16262. }
  16263. if (T.mapScale - l <= ge) {
  16264. var n = Math.max(0, -c);
  16265. C.fillRect(T.mapScale - l, n, ge - (T.mapScale - l), ye - n);
  16266. }
  16267. if (c <= 0) {
  16268. C.fillRect(-l, 0, ge + l, -c);
  16269. }
  16270. if (T.mapScale - c <= ye) {
  16271. var s = Math.max(0, -l);
  16272. let a = 0;
  16273. if (T.mapScale - l <= ge) {
  16274. a = ge - (T.mapScale - l);
  16275. }
  16276. C.fillRect(s, T.mapScale - c, ge - s - a, ye - (T.mapScale - c));
  16277. }
  16278. C.globalAlpha = 1;
  16279. C.fillStyle = "rgba(0, 0, 70, 0.35)";
  16280. C.fillRect(0, 0, ge, ye);
  16281. C.strokeStyle = ko;
  16282. for (var t = 0; t < oe.length + Oe.length; ++t) {
  16283. k = oe[t] || Oe[t - oe.length];
  16284. if (k.visible && (k.skinIndex != 10 || k == P || k.team && k.team == P.team)) {
  16285. const f = (k.team ? "[" + k.team + "] " : "") + (k.name || "");
  16286. if (f != "") {
  16287. C.font = (k.nameScale || 30) + "px Hammersmith One";
  16288. C.fillStyle = "#fff";
  16289. C.textBaseline = "middle";
  16290. C.textAlign = "center";
  16291. C.lineWidth = k.nameScale ? 11 : 8;
  16292. C.lineJoin = "round";
  16293. C.strokeText(f, k.x - l, k.y - c - k.scale - T.nameY);
  16294. C.fillText(f, k.x - l, k.y - c - k.scale - T.nameY);
  16295. if (k.isLeader && Di.crown.isLoaded) {
  16296. var r = T.crownIconScale;
  16297. var s = k.x - l - r / 2 - C.measureText(f).width / 2 - T.crownPad;
  16298. C.drawImage(Di.crown, s, k.y - c - k.scale - T.nameY - r / 2 - 5, r, r);
  16299. }
  16300. if (k.iconIndex == 1 && Di.skull.isLoaded) {
  16301. var r = T.crownIconScale;
  16302. var s = k.x - l - r / 2 + C.measureText(f).width / 2 + T.crownPad;
  16303. C.drawImage(Di.skull, s, k.y - c - k.scale - T.nameY - r / 2 - 5, r, r);
  16304. }
  16305. }
  16306. if (k.health > 0) {
  16307. T.healthBarWidth;
  16308. C.fillStyle = ko;
  16309. C.roundRect(k.x - l - T.healthBarWidth - T.healthBarPad, k.y - c + k.scale + T.nameY, T.healthBarWidth * 2 + T.healthBarPad * 2, 17, 8);
  16310. C.fill();
  16311. C.fillStyle = k == P || k.team && k.team == P.team ? "#8ecc51" : "#cc5151";
  16312. C.roundRect(k.x - l - T.healthBarWidth, k.y - c + k.scale + T.nameY + T.healthBarPad, T.healthBarWidth * 2 * (k.health / k.maxHealth), 17 - T.healthBarPad * 2, 7);
  16313. C.fill();
  16314. }
  16315. }
  16316. }
  16317. As.update(Fe, C, l, c);
  16318. for (var t = 0; t < oe.length; ++t) {
  16319. k = oe[t];
  16320. if (k.visible && k.chatCountdown > 0) {
  16321. k.chatCountdown -= Fe;
  16322. if (k.chatCountdown <= 0) {
  16323. k.chatCountdown = 0;
  16324. }
  16325. C.font = "32px Hammersmith One";
  16326. const f = C.measureText(k.chatMessage);
  16327. C.textBaseline = "middle";
  16328. C.textAlign = "center";
  16329. var s = k.x - l;
  16330. var n = k.y - k.scale - c - 90;
  16331. const p = 47;
  16332. const w = f.width + 17;
  16333. C.fillStyle = "rgba(0,0,0,0.2)";
  16334. C.roundRect(s - w / 2, n - p / 2, w, p, 6);
  16335. C.fill();
  16336. C.fillStyle = "#fff";
  16337. C.fillText(k.chatMessage, s, n);
  16338. }
  16339. }
  16340. }
  16341. wd(Fe);
  16342. }
  16343. function So(e, t, i) {
  16344. for (let n = 0; n < ui.length; ++n) {
  16345. k = ui[n];
  16346. if (k.active && k.layer == e) {
  16347. k.update(Fe);
  16348. if (k.active && Za(k.x - t, k.y - i, k.scale)) {
  16349. C.save();
  16350. C.translate(k.x - t, k.y - i);
  16351. C.rotate(k.dir);
  16352. qs(0, 0, k, C);
  16353. C.restore();
  16354. }
  16355. }
  16356. }
  16357. }
  16358. const Io = {};
  16359. function qs(e, t, i, n, s) {
  16360. if (i.src) {
  16361. const r = L.projectiles[i.indx].src;
  16362. let o = Io[r];
  16363. if (!o) {
  16364. o = new Image();
  16365. o.onload = function () {
  16366. this.isLoaded = true;
  16367. };
  16368. o.src = "./img/weapons/" + r + ".png";
  16369. Io[r] = o;
  16370. }
  16371. if (o.isLoaded) {
  16372. n.drawImage(o, e - i.scale / 2, t - i.scale / 2, i.scale, i.scale);
  16373. }
  16374. } else if (i.indx == 1) {
  16375. n.fillStyle = "#939393";
  16376. he(e, t, i.scale, n);
  16377. }
  16378. }
  16379. function Ud() {
  16380. const e = ot - ge / 2;
  16381. const t = at - ye / 2;
  16382. Ye.animationTime += Fe;
  16383. Ye.animationTime %= T.volcanoAnimationDuration;
  16384. const i = T.volcanoAnimationDuration / 2;
  16385. const n = 1.7 + Math.abs(i - Ye.animationTime) / i * 0.3;
  16386. const s = T.innerVolcanoScale * n;
  16387. C.drawImage(Ye.land, Ye.x - T.volcanoScale - e, Ye.y - T.volcanoScale - t, T.volcanoScale * 2, T.volcanoScale * 2);
  16388. C.drawImage(Ye.lava, Ye.x - s - e, Ye.y - s - t, s * 2, s * 2);
  16389. }
  16390. function To(e, t, i, n) {
  16391. const s = T.riverWidth + n;
  16392. const r = T.mapScale / 2 - t - s / 2;
  16393. if (r < ye && r + s > 0) {
  16394. i.fillRect(0, r, ge, s);
  16395. }
  16396. }
  16397. function Pi(e, t, i) {
  16398. let n;
  16399. let s;
  16400. let r;
  16401. for (let o = 0; o < Dt.length; ++o) {
  16402. k = Dt[o];
  16403. if (k.active) {
  16404. s = k.x + k.xWiggle - t;
  16405. r = k.y + k.yWiggle - i;
  16406. if (e == 0) {
  16407. k.update(Fe);
  16408. }
  16409. if (k.layer == e && Za(s, r, k.scale + (k.blocker || 0))) {
  16410. C.globalAlpha = k.hideFromEnemy ? 0.6 : 1;
  16411. if (k.isItem) {
  16412. n = yr(k);
  16413. C.save();
  16414. C.translate(s, r);
  16415. C.rotate(k.dir);
  16416. C.drawImage(n, -(n.width / 2), -(n.height / 2));
  16417. if (k.blocker) {
  16418. C.strokeStyle = "#db6e6e";
  16419. C.globalAlpha = 0.3;
  16420. C.lineWidth = 6;
  16421. he(0, 0, k.blocker, C, false, true);
  16422. }
  16423. C.restore();
  16424. } else if (k.type === 4) {
  16425. Ud();
  16426. } else {
  16427. n = Gd(k);
  16428. C.drawImage(n, s - n.width / 2, r - n.height / 2);
  16429. }
  16430. }
  16431. }
  16432. }
  16433. }
  16434. function Wd(e, t, i) {
  16435. k = Hn(e);
  16436. if (k) {
  16437. k.startAnim(t, i);
  16438. }
  16439. }
  16440. function Mo(e, t, i) {
  16441. C.globalAlpha = 1;
  16442. for (let n = 0; n < oe.length; ++n) {
  16443. k = oe[n];
  16444. if (k.zIndex == i) {
  16445. k.animate(Fe);
  16446. if (k.visible) {
  16447. k.skinRot += Fe * 0.002;
  16448. lo = (k == P ? mr() : k.dir) + k.dirPlus;
  16449. C.save();
  16450. C.translate(k.x - e, k.y - t);
  16451. C.rotate(lo);
  16452. Xd(k, C);
  16453. C.restore();
  16454. }
  16455. }
  16456. }
  16457. }
  16458. function Xd(e, t) {
  16459. t = t || C;
  16460. t.lineWidth = St;
  16461. t.lineJoin = "miter";
  16462. const i = Math.PI / 4 * (L.weapons[e.weaponIndex].armS || 1);
  16463. const n = e.buildIndex < 0 && L.weapons[e.weaponIndex].hndS || 1;
  16464. const s = e.buildIndex < 0 && L.weapons[e.weaponIndex].hndD || 1;
  16465. if (e.tailIndex > 0) {
  16466. qd(e.tailIndex, t, e);
  16467. }
  16468. if (e.buildIndex < 0 && !L.weapons[e.weaponIndex].aboveHand) {
  16469. Ro(L.weapons[e.weaponIndex], T.weaponVariants[e.weaponVariant].src, e.scale, 0, t);
  16470. if (L.weapons[e.weaponIndex].projectile != null && !L.weapons[e.weaponIndex].hideProjectile) {
  16471. qs(e.scale, 0, L.projectiles[L.weapons[e.weaponIndex].projectile], C);
  16472. }
  16473. }
  16474. t.fillStyle = T.skinColors[e.skinColor];
  16475. he(e.scale * Math.cos(i), e.scale * Math.sin(i), 14);
  16476. he(e.scale * s * Math.cos(-i * n), e.scale * s * Math.sin(-i * n), 14);
  16477. if (e.buildIndex < 0 && L.weapons[e.weaponIndex].aboveHand) {
  16478. Ro(L.weapons[e.weaponIndex], T.weaponVariants[e.weaponVariant].src, e.scale, 0, t);
  16479. if (L.weapons[e.weaponIndex].projectile != null && !L.weapons[e.weaponIndex].hideProjectile) {
  16480. qs(e.scale, 0, L.projectiles[L.weapons[e.weaponIndex].projectile], C);
  16481. }
  16482. }
  16483. if (e.buildIndex >= 0) {
  16484. const r = yr(L.list[e.buildIndex]);
  16485. t.drawImage(r, e.scale - L.list[e.buildIndex].holdOffset, -r.width / 2);
  16486. }
  16487. he(0, 0, e.scale, t);
  16488. if (e.skinIndex > 0) {
  16489. t.rotate(Math.PI / 2);
  16490. Ka(e.skinIndex, t, null, e);
  16491. }
  16492. }
  16493. const Eo = {};
  16494. const Co = {};
  16495. let et;
  16496. function Ka(e, t, i, n) {
  16497. et = Eo[e];
  16498. if (!et) {
  16499. const r = new Image();
  16500. r.onload = function () {
  16501. this.isLoaded = true;
  16502. this.onload = null;
  16503. };
  16504. r.src = "./img/hats/hat_" + e + ".png";
  16505. Eo[e] = r;
  16506. et = r;
  16507. }
  16508. let s = i || Co[e];
  16509. if (!s) {
  16510. for (let r = 0; r < Vi.length; ++r) {
  16511. if (Vi[r].id == e) {
  16512. s = Vi[r];
  16513. break;
  16514. }
  16515. }
  16516. Co[e] = s;
  16517. }
  16518. if (et.isLoaded) {
  16519. t.drawImage(et, -s.scale / 2, -s.scale / 2, s.scale, s.scale);
  16520. }
  16521. if (!i && s.topSprite) {
  16522. t.save();
  16523. t.rotate(n.skinRot);
  16524. Ka(e + "_top", t, s, n);
  16525. t.restore();
  16526. }
  16527. }
  16528. const Po = {};
  16529. const $o = {};
  16530. function qd(e, t, i) {
  16531. et = Po[e];
  16532. if (!et) {
  16533. const s = new Image();
  16534. s.onload = function () {
  16535. this.isLoaded = true;
  16536. this.onload = null;
  16537. };
  16538. s.src = "./img/accessories/access_" + e + ".png";
  16539. Po[e] = s;
  16540. et = s;
  16541. }
  16542. let n = $o[e];
  16543. if (!n) {
  16544. for (let s = 0; s < Ni.length; ++s) {
  16545. if (Ni[s].id == e) {
  16546. n = Ni[s];
  16547. break;
  16548. }
  16549. }
  16550. $o[e] = n;
  16551. }
  16552. if (et.isLoaded) {
  16553. t.save();
  16554. t.translate(-20 - (n.xOff || 0), 0);
  16555. if (n.spin) {
  16556. t.rotate(i.skinRot);
  16557. }
  16558. t.drawImage(et, -(n.scale / 2), -(n.scale / 2), n.scale, n.scale);
  16559. t.restore();
  16560. }
  16561. }
  16562. var Gs = {};
  16563. function Ro(e, t, i, n, s) {
  16564. const r = e.src + (t || "");
  16565. let o = Gs[r];
  16566. if (!o) {
  16567. o = new Image();
  16568. o.onload = function () {
  16569. this.isLoaded = true;
  16570. };
  16571. o.src = "./img/weapons/" + r + ".png";
  16572. Gs[r] = o;
  16573. }
  16574. if (o.isLoaded) {
  16575. s.drawImage(o, i + e.xOff - e.length / 2, n + e.yOff - e.width / 2, e.length, e.width);
  16576. }
  16577. }
  16578. const Ao = {};
  16579. function Gd(e) {
  16580. const t = e.y >= T.mapScale - T.snowBiomeTop ? 2 : e.y <= T.snowBiomeTop ? 1 : 0;
  16581. const i = e.type + "_" + e.scale + "_" + t;
  16582. let n = Ao[i];
  16583. if (!n) {
  16584. const r = document.createElement("canvas");
  16585. r.width = r.height = e.scale * 2.1 + St;
  16586. const o = r.getContext("2d");
  16587. o.translate(r.width / 2, r.height / 2);
  16588. o.rotate(A.randFloat(0, Math.PI));
  16589. o.strokeStyle = Zi;
  16590. o.lineWidth = St;
  16591. if (e.type == 0) {
  16592. let l;
  16593. for (var s = 0; s < 2; ++s) {
  16594. l = k.scale * (s ? 0.5 : 1);
  16595. qe(o, k.sid % 2 === 0 ? 5 : 7, l, l * 0.7);
  16596. o.fillStyle = t ? s ? "#fff" : "#e3f1f4" : s ? "#b4db62" : "#9ebf57";
  16597. o.fill();
  16598. if (!s) {
  16599. o.stroke();
  16600. }
  16601. }
  16602. } else if (e.type == 1) {
  16603. if (t == 2) {
  16604. o.fillStyle = "#606060";
  16605. qe(o, 6, e.scale * 0.3, e.scale * 0.71);
  16606. o.fill();
  16607. o.stroke();
  16608. o.fillStyle = "#89a54c";
  16609. he(0, 0, e.scale * 0.55, o);
  16610. o.fillStyle = "#a5c65b";
  16611. he(0, 0, e.scale * 0.3, o, true);
  16612. } else {
  16613. Zd(o, 6, k.scale, k.scale * 0.7);
  16614. o.fillStyle = t ? "#e3f1f4" : "#89a54c";
  16615. o.fill();
  16616. o.stroke();
  16617. o.fillStyle = t ? "#6a64af" : "#c15555";
  16618. let l;
  16619. const c = 4;
  16620. const a = Rt / c;
  16621. for (var s = 0; s < c; ++s) {
  16622. l = A.randInt(k.scale / 3.5, k.scale / 2.3);
  16623. he(l * Math.cos(a * s), l * Math.sin(a * s), A.randInt(10, 12), o);
  16624. }
  16625. }
  16626. } else if (e.type == 2 || e.type == 3) {
  16627. o.fillStyle = e.type == 2 ? t == 2 ? "#938d77" : "#939393" : "#e0c655";
  16628. qe(o, 3, e.scale, e.scale);
  16629. o.fill();
  16630. o.stroke();
  16631. o.fillStyle = e.type == 2 ? t == 2 ? "#b2ab90" : "#bcbcbc" : "#ebdca3";
  16632. qe(o, 3, e.scale * 0.55, e.scale * 0.65);
  16633. o.fill();
  16634. }
  16635. n = r;
  16636. Ao[i] = n;
  16637. }
  16638. return n;
  16639. }
  16640. function Do(e, t, i) {
  16641. const n = e.lineWidth || 0;
  16642. i /= 2;
  16643. e.beginPath();
  16644. let s = Math.PI * 2 / t;
  16645. for (let r = 0; r < t; r++) {
  16646. e.lineTo(i + (i - n / 2) * Math.cos(s * r), i + (i - n / 2) * Math.sin(s * r));
  16647. }
  16648. e.closePath();
  16649. }
  16650. function Yd() {
  16651. const t = T.volcanoScale * 2;
  16652. const i = document.createElement("canvas");
  16653. i.width = t;
  16654. i.height = t;
  16655. const n = i.getContext("2d");
  16656. n.strokeStyle = "#3e3e3e";
  16657. n.lineWidth = St * 2;
  16658. n.fillStyle = "#7f7f7f";
  16659. Do(n, 10, t);
  16660. n.fill();
  16661. n.stroke();
  16662. Ye.land = i;
  16663. const s = document.createElement("canvas");
  16664. const r = T.innerVolcanoScale * 2;
  16665. s.width = r;
  16666. s.height = r;
  16667. const o = s.getContext("2d");
  16668. o.strokeStyle = Zi;
  16669. o.lineWidth = St * 1.6;
  16670. o.fillStyle = "#f54e16";
  16671. o.strokeStyle = "#f56f16";
  16672. Do(o, 10, r);
  16673. o.fill();
  16674. o.stroke();
  16675. Ye.lava = s;
  16676. }
  16677. Yd();
  16678. const Oo = [];
  16679. function yr(e, t) {
  16680. let i = Oo[e.id];
  16681. if (!i || t) {
  16682. const c = document.createElement("canvas");
  16683. c.width = c.height = e.scale * 2.5 + St + (L.list[e.id].spritePadding || 0);
  16684. const a = c.getContext("2d");
  16685. a.translate(c.width / 2, c.height / 2);
  16686. a.rotate(t ? 0 : Math.PI / 2);
  16687. a.strokeStyle = Zi;
  16688. a.lineWidth = St * (t ? c.width / 81 : 1);
  16689. if (e.name == "apple") {
  16690. a.fillStyle = "#c15555";
  16691. he(0, 0, e.scale, a);
  16692. a.fillStyle = "#89a54c";
  16693. const f = -(Math.PI / 2);
  16694. Kd(e.scale * Math.cos(f), e.scale * Math.sin(f), 25, f + Math.PI / 2, a);
  16695. } else if (e.name == "cookie") {
  16696. a.fillStyle = "#cca861";
  16697. he(0, 0, e.scale, a);
  16698. a.fillStyle = "#937c4b";
  16699. for (var n = 4, s = Rt / n, r, o = 0; o < n; ++o) {
  16700. r = A.randInt(e.scale / 2.5, e.scale / 1.7);
  16701. he(r * Math.cos(s * o), r * Math.sin(s * o), A.randInt(4, 5), a, true);
  16702. }
  16703. } else if (e.name == "cheese") {
  16704. a.fillStyle = "#f4f3ac";
  16705. he(0, 0, e.scale, a);
  16706. a.fillStyle = "#c3c28b";
  16707. for (var n = 4, s = Rt / n, r, o = 0; o < n; ++o) {
  16708. r = A.randInt(e.scale / 2.5, e.scale / 1.7);
  16709. he(r * Math.cos(s * o), r * Math.sin(s * o), A.randInt(4, 5), a, true);
  16710. }
  16711. } else if (e.name == "wood wall" || e.name == "stone wall" || e.name == "castle wall") {
  16712. a.fillStyle = e.name == "castle wall" ? "#83898e" : e.name == "wood wall" ? "#a5974c" : "#939393";
  16713. const f = e.name == "castle wall" ? 4 : 3;
  16714. qe(a, f, e.scale * 1.1, e.scale * 1.1);
  16715. a.fill();
  16716. a.stroke();
  16717. a.fillStyle = e.name == "castle wall" ? "#9da4aa" : e.name == "wood wall" ? "#c9b758" : "#bcbcbc";
  16718. qe(a, f, e.scale * 0.65, e.scale * 0.65);
  16719. a.fill();
  16720. } else if (e.name == "spikes" || e.name == "greater spikes" || e.name == "poison spikes" || e.name == "spinning spikes") {
  16721. a.fillStyle = e.name == "poison spikes" ? "#7b935d" : "#939393";
  16722. var l = e.scale * 0.6;
  16723. qe(a, e.name == "spikes" ? 5 : 6, e.scale, l);
  16724. a.fill();
  16725. a.stroke();
  16726. a.fillStyle = "#a5974c";
  16727. he(0, 0, l, a);
  16728. a.fillStyle = "#c9b758";
  16729. he(0, 0, l / 2, a, true);
  16730. } else if (e.name == "windmill" || e.name == "faster windmill" || e.name == "power mill") {
  16731. a.fillStyle = "#a5974c";
  16732. he(0, 0, e.scale, a);
  16733. a.fillStyle = "#c9b758";
  16734. xs(0, 0, e.scale * 1.5, 29, 4, a);
  16735. a.fillStyle = "#a5974c";
  16736. he(0, 0, e.scale * 0.5, a);
  16737. } else if (e.name == "mine") {
  16738. a.fillStyle = "#939393";
  16739. qe(a, 3, e.scale, e.scale);
  16740. a.fill();
  16741. a.stroke();
  16742. a.fillStyle = "#bcbcbc";
  16743. qe(a, 3, e.scale * 0.55, e.scale * 0.65);
  16744. a.fill();
  16745. } else if (e.name == "sapling") {
  16746. for (var o = 0; o < 2; ++o) {
  16747. var l = e.scale * (o ? 0.5 : 1);
  16748. qe(a, 7, l, l * 0.7);
  16749. a.fillStyle = o ? "#b4db62" : "#9ebf57";
  16750. a.fill();
  16751. if (!o) {
  16752. a.stroke();
  16753. }
  16754. }
  16755. } else if (e.name == "pit trap") {
  16756. a.fillStyle = "#a5974c";
  16757. qe(a, 3, e.scale * 1.1, e.scale * 1.1);
  16758. a.fill();
  16759. a.stroke();
  16760. a.fillStyle = Zi;
  16761. qe(a, 3, e.scale * 0.65, e.scale * 0.65);
  16762. a.fill();
  16763. } else if (e.name == "boost pad") {
  16764. a.fillStyle = "#7e7f82";
  16765. ni(0, 0, e.scale * 2, e.scale * 2, a);
  16766. a.fill();
  16767. a.stroke();
  16768. a.fillStyle = "#dbd97d";
  16769. Jd(e.scale * 1, a);
  16770. } else if (e.name == "turret") {
  16771. a.fillStyle = "#a5974c";
  16772. he(0, 0, e.scale, a);
  16773. a.fill();
  16774. a.stroke();
  16775. a.fillStyle = "#939393";
  16776. const f = 50;
  16777. ni(0, -f / 2, e.scale * 0.9, f, a);
  16778. he(0, 0, e.scale * 0.6, a);
  16779. a.fill();
  16780. a.stroke();
  16781. } else if (e.name == "platform") {
  16782. a.fillStyle = "#cebd5f";
  16783. const f = 4;
  16784. const d = e.scale * 2;
  16785. const u = d / f;
  16786. let p = -(e.scale / 2);
  16787. for (var o = 0; o < f; ++o) {
  16788. ni(p - u / 2, 0, u, e.scale * 2, a);
  16789. a.fill();
  16790. a.stroke();
  16791. p += d / f;
  16792. }
  16793. } else if (e.name == "healing pad") {
  16794. a.fillStyle = "#7e7f82";
  16795. ni(0, 0, e.scale * 2, e.scale * 2, a);
  16796. a.fill();
  16797. a.stroke();
  16798. a.fillStyle = "#db6e6e";
  16799. xs(0, 0, e.scale * 0.65, 20, 4, a, true);
  16800. } else if (e.name == "spawn pad") {
  16801. a.fillStyle = "#7e7f82";
  16802. ni(0, 0, e.scale * 2, e.scale * 2, a);
  16803. a.fill();
  16804. a.stroke();
  16805. a.fillStyle = "#71aad6";
  16806. he(0, 0, e.scale * 0.6, a);
  16807. } else if (e.name == "blocker") {
  16808. a.fillStyle = "#7e7f82";
  16809. he(0, 0, e.scale, a);
  16810. a.fill();
  16811. a.stroke();
  16812. a.rotate(Math.PI / 4);
  16813. a.fillStyle = "#db6e6e";
  16814. xs(0, 0, e.scale * 0.65, 20, 4, a, true);
  16815. } else if (e.name == "teleporter") {
  16816. a.fillStyle = "#7e7f82";
  16817. he(0, 0, e.scale, a);
  16818. a.fill();
  16819. a.stroke();
  16820. a.rotate(Math.PI / 4);
  16821. a.fillStyle = "#d76edb";
  16822. he(0, 0, e.scale * 0.5, a, true);
  16823. }
  16824. i = c;
  16825. if (!t) {
  16826. Oo[e.id] = i;
  16827. }
  16828. }
  16829. return i;
  16830. }
  16831. function Kd(e, t, i, n, s) {
  16832. const r = e + i * Math.cos(n);
  16833. const o = t + i * Math.sin(n);
  16834. const l = i * 0.4;
  16835. s.moveTo(e, t);
  16836. s.beginPath();
  16837. s.quadraticCurveTo((e + r) / 2 + l * Math.cos(n + Math.PI / 2), (t + o) / 2 + l * Math.sin(n + Math.PI / 2), r, o);
  16838. s.quadraticCurveTo((e + r) / 2 - l * Math.cos(n + Math.PI / 2), (t + o) / 2 - l * Math.sin(n + Math.PI / 2), e, t);
  16839. s.closePath();
  16840. s.fill();
  16841. s.stroke();
  16842. }
  16843. function he(e, t, i, n, s, r) {
  16844. n = n || C;
  16845. n.beginPath();
  16846. n.arc(e, t, i, 0, Math.PI * 2);
  16847. if (!r) {
  16848. n.fill();
  16849. }
  16850. if (!s) {
  16851. n.stroke();
  16852. }
  16853. }
  16854. function qe(e, t, i, n) {
  16855. let s = Math.PI / 2 * 3;
  16856. let r;
  16857. let o;
  16858. const l = Math.PI / t;
  16859. e.beginPath();
  16860. e.moveTo(0, -i);
  16861. for (let c = 0; c < t; c++) {
  16862. r = Math.cos(s) * i;
  16863. o = Math.sin(s) * i;
  16864. e.lineTo(r, o);
  16865. s += l;
  16866. r = Math.cos(s) * n;
  16867. o = Math.sin(s) * n;
  16868. e.lineTo(r, o);
  16869. s += l;
  16870. }
  16871. e.lineTo(0, -i);
  16872. e.closePath();
  16873. }
  16874. function ni(e, t, i, n, s, r) {
  16875. s.fillRect(e - i / 2, t - n / 2, i, n);
  16876. if (!r) {
  16877. s.strokeRect(e - i / 2, t - n / 2, i, n);
  16878. }
  16879. }
  16880. function xs(e, t, i, n, s, r, o) {
  16881. r.save();
  16882. r.translate(e, t);
  16883. s = Math.ceil(s / 2);
  16884. for (let l = 0; l < s; l++) {
  16885. ni(0, 0, i * 2, n, r, o);
  16886. r.rotate(Math.PI / s);
  16887. }
  16888. r.restore();
  16889. }
  16890. function Zd(e, t, i, n) {
  16891. let s = Math.PI / 2 * 3;
  16892. const r = Math.PI / t;
  16893. let o;
  16894. e.beginPath();
  16895. e.moveTo(0, -n);
  16896. for (let l = 0; l < t; l++) {
  16897. o = A.randInt(i + 0.9, i * 1.2);
  16898. e.quadraticCurveTo(Math.cos(s + r) * o, Math.sin(s + r) * o, Math.cos(s + r * 2) * n, Math.sin(s + r * 2) * n);
  16899. s += r * 2;
  16900. }
  16901. e.lineTo(0, -n);
  16902. e.closePath();
  16903. }
  16904. function Jd(e, t) {
  16905. t = t || C;
  16906. const i = e * (Math.sqrt(3) / 2);
  16907. t.beginPath();
  16908. t.moveTo(0, -i / 2);
  16909. t.lineTo(-e / 2, i / 2);
  16910. t.lineTo(e / 2, i / 2);
  16911. t.lineTo(0, -i / 2);
  16912. t.fill();
  16913. t.closePath();
  16914. }
  16915. function Qd() {
  16916. const e = T.mapScale / 2;
  16917. $e.add(0, e, e + 200, 0, T.treeScales[3], 0);
  16918. $e.add(1, e, e - 480, 0, T.treeScales[3], 0);
  16919. $e.add(2, e + 300, e + 450, 0, T.treeScales[3], 0);
  16920. $e.add(3, e - 950, e - 130, 0, T.treeScales[2], 0);
  16921. $e.add(4, e - 750, e - 400, 0, T.treeScales[3], 0);
  16922. $e.add(5, e - 700, e + 400, 0, T.treeScales[2], 0);
  16923. $e.add(6, e + 800, e - 200, 0, T.treeScales[3], 0);
  16924. $e.add(7, e - 260, e + 340, 0, T.bushScales[3], 1);
  16925. $e.add(8, e + 760, e + 310, 0, T.bushScales[3], 1);
  16926. $e.add(9, e - 800, e + 100, 0, T.bushScales[3], 1);
  16927. $e.add(10, e - 800, e + 300, 0, L.list[4].scale, L.list[4].id, L.list[10]);
  16928. $e.add(11, e + 650, e - 390, 0, L.list[4].scale, L.list[4].id, L.list[10]);
  16929. $e.add(12, e - 400, e - 450, 0, T.rockScales[2], 2);
  16930. }
  16931. function jd(e) {
  16932. for (let t = 0; t < e.length;) {
  16933. $e.add(e[t], e[t + 1], e[t + 2], e[t + 3], e[t + 4], e[t + 5], L.list[e[t + 6]], true, e[t + 7] >= 0 ? {
  16934. sid: e[t + 7]
  16935. } : null);
  16936. t += 8;
  16937. }
  16938. }
  16939. function ep(e, t) {
  16940. k = Qa(t);
  16941. if (k) {
  16942. k.xWiggle += T.gatherWiggle * Math.cos(e);
  16943. k.yWiggle += T.gatherWiggle * Math.sin(e);
  16944. }
  16945. }
  16946. function tp(e, t) {
  16947. k = Qa(e);
  16948. if (k) {
  16949. k.dir = t;
  16950. k.xWiggle += T.gatherWiggle * Math.cos(t + Math.PI);
  16951. k.yWiggle += T.gatherWiggle * Math.sin(t + Math.PI);
  16952. }
  16953. }
  16954. function ip(e, t, i, n, s, r, o, l) {
  16955. if (lr) {
  16956. Pa.addProjectile(e, t, i, n, s, r, null, null, o).sid = l;
  16957. }
  16958. }
  16959. function np(e, t) {
  16960. for (let i = 0; i < ui.length; ++i) {
  16961. if (ui[i].sid == e) {
  16962. ui[i].range = t;
  16963. }
  16964. }
  16965. }
  16966. function sp(e) {
  16967. k = Ja(e);
  16968. if (k) {
  16969. k.startAnim();
  16970. }
  16971. }
  16972. function rp(e) {
  16973. for (var t = 0; t < Oe.length; ++t) {
  16974. Oe[t].forcePos = !Oe[t].visible;
  16975. Oe[t].visible = false;
  16976. }
  16977. if (e) {
  16978. const i = Date.now();
  16979. for (var t = 0; t < e.length;) {
  16980. k = Ja(e[t]);
  16981. if (k) {
  16982. k.index = e[t + 1];
  16983. k.t1 = k.t2 === undefined ? i : k.t2;
  16984. k.t2 = i;
  16985. k.x1 = k.x;
  16986. k.y1 = k.y;
  16987. k.x2 = e[t + 2];
  16988. k.y2 = e[t + 3];
  16989. k.d1 = k.d2 === undefined ? e[t + 4] : k.d2;
  16990. k.d2 = e[t + 4];
  16991. k.health = e[t + 5];
  16992. k.dt = 0;
  16993. k.visible = true;
  16994. } else {
  16995. k = ao.spawn(e[t + 2], e[t + 3], e[t + 4], e[t + 1]);
  16996. k.x2 = k.x;
  16997. k.y2 = k.y;
  16998. k.d2 = k.dir;
  16999. k.health = e[t + 5];
  17000. if (!ao.aiTypes[e[t + 1]].name) {
  17001. k.name = T.cowNames[e[t + 6]];
  17002. }
  17003. k.forcePos = true;
  17004. k.sid = e[t];
  17005. k.visible = true;
  17006. }
  17007. t += 7;
  17008. }
  17009. }
  17010. }
  17011. const _o = {};
  17012. function op(e, t) {
  17013. const i = e.index;
  17014. let n = _o[i];
  17015. if (!n) {
  17016. const s = new Image();
  17017. s.onload = function () {
  17018. this.isLoaded = true;
  17019. this.onload = null;
  17020. };
  17021. s.src = "./img/animals/" + e.src + ".png";
  17022. n = s;
  17023. _o[i] = n;
  17024. }
  17025. if (n.isLoaded) {
  17026. const s = e.scale * 1.2 * (e.spriteMlt || 1);
  17027. t.drawImage(n, -s, -s, s * 2, s * 2);
  17028. }
  17029. }
  17030. function Za(e, t, i) {
  17031. return e + i >= 0 && e - i <= ge && t + i >= 0 && t - i <= ye;
  17032. }
  17033. function ap(e, t) {
  17034. let i = dp(e[0]);
  17035. if (!i) {
  17036. i = new Gh(e[0], e[1], T, A, Pa, $e, oe, Oe, L, Vi, Ni);
  17037. oe.push(i);
  17038. }
  17039. i.spawn(t ? Sn : null);
  17040. i.visible = false;
  17041. i.x2 = undefined;
  17042. i.y2 = undefined;
  17043. i.setData(e);
  17044. if (t) {
  17045. P = i;
  17046. ot = P.x;
  17047. at = P.y;
  17048. La();
  17049. qa();
  17050. Ya();
  17051. Ga(0);
  17052. ar.style.display = "block";
  17053. }
  17054. }
  17055. function lp(e) {
  17056. for (let t = 0; t < oe.length; t++) {
  17057. if (oe[t].id == e) {
  17058. oe.splice(t, 1);
  17059. break;
  17060. }
  17061. }
  17062. }
  17063. function cp(e, t) {
  17064. if (P) {
  17065. P.itemCounts[e] = t;
  17066. }
  17067. }
  17068. function hp(e, t, i) {
  17069. if (P) {
  17070. P[e] = t;
  17071. if (i) {
  17072. qa();
  17073. }
  17074. }
  17075. }
  17076. function up(e, t) {
  17077. k = Hn(e);
  17078. if (k) {
  17079. k.health = t;
  17080. }
  17081. }
  17082. function fp(e) {
  17083. const t = Date.now();
  17084. for (var i = 0; i < oe.length; ++i) {
  17085. oe[i].forcePos = !oe[i].visible;
  17086. oe[i].visible = false;
  17087. }
  17088. for (var i = 0; i < e.length;) {
  17089. k = Hn(e[i]);
  17090. if (k) {
  17091. k.t1 = k.t2 === undefined ? t : k.t2;
  17092. k.t2 = t;
  17093. k.x1 = k.x;
  17094. k.y1 = k.y;
  17095. k.x2 = e[i + 1];
  17096. k.y2 = e[i + 2];
  17097. k.d1 = k.d2 === undefined ? e[i + 3] : k.d2;
  17098. k.d2 = e[i + 3];
  17099. k.dt = 0;
  17100. k.buildIndex = e[i + 4];
  17101. k.weaponIndex = e[i + 5];
  17102. k.weaponVariant = e[i + 6];
  17103. k.team = e[i + 7];
  17104. k.isLeader = e[i + 8];
  17105. k.skinIndex = e[i + 9];
  17106. k.tailIndex = e[i + 10];
  17107. k.iconIndex = e[i + 11];
  17108. k.zIndex = e[i + 12];
  17109. k.visible = true;
  17110. }
  17111. i += 13;
  17112. }
  17113. }
  17114. function dp(e) {
  17115. for (let t = 0; t < oe.length; ++t) {
  17116. if (oe[t].id == e) {
  17117. return oe[t];
  17118. }
  17119. }
  17120. return null;
  17121. }
  17122. function Hn(e) {
  17123. for (let t = 0; t < oe.length; ++t) {
  17124. if (oe[t].sid == e) {
  17125. return oe[t];
  17126. }
  17127. }
  17128. return null;
  17129. }
  17130. function Ja(e) {
  17131. for (let t = 0; t < Oe.length; ++t) {
  17132. if (Oe[t].sid == e) {
  17133. return Oe[t];
  17134. }
  17135. }
  17136. return null;
  17137. }
  17138. function Qa(e) {
  17139. for (let t = 0; t < Dt.length; ++t) {
  17140. if (Dt[t].sid == e) {
  17141. return Dt[t];
  17142. }
  17143. }
  17144. return null;
  17145. }
  17146. let ja = -1;
  17147. function pp() {
  17148. const e = Date.now() - ja;
  17149. window.pingTime = e;
  17150. Gi.innerText = "Ping: " + e + "Â ms";
  17151. }
  17152. let bs;
  17153. function el() {
  17154. if (bs) {
  17155. clearTimeout(bs);
  17156. }
  17157. if (sr()) {
  17158. ja = Date.now();
  17159. me.send("0");
  17160. }
  17161. bs = // TOLOOK
  17162. setTimeout(el, 2500);
  17163. }
  17164. function mp(e) {
  17165. if (e < 0) {
  17166. return;
  17167. }
  17168. const t = Math.floor(e / 60);
  17169. let i = e % 60;
  17170. i = ("0" + i).slice(-2);
  17171. po.innerText = "Server restarting in " + t + ":" + i;
  17172. po.hidden = false;
  17173. }
  17174. window.requestAnimFrame = function () {
  17175. return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (e) {
  17176. window.setTimeout(e, 1000 / 60);
  17177. };
  17178. }();
  17179. function tl() {
  17180. hi = Date.now();
  17181. Fe = hi - oo;
  17182. oo = hi;
  17183. Nd();
  17184. requestAnimFrame(tl);
  17185. }
  17186. Qd();
  17187. tl();
  17188. function il(e) {
  17189. window.open(e, "_blank");
  17190. }
  17191. window.openLink = il;
  17192. window.aJoinReq = Fs;
  17193. window.follmoo = Xf;
  17194. window.kickFromClan = Oa;
  17195. window.sendJoin = _a;
  17196. window.leaveAlliance = za;
  17197. window.createAlliance = Vs;
  17198. window.storeBuy = Ba;
  17199. window.storeEquip = Ws;
  17200. window.showItemInfo = Ue;
  17201. window.selectSkinColor = Td;
  17202. window.changeStoreIndex = vd;
  17203. window.config = T;

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址