code-battles 1.7.11 → 1.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/cjs/index.js +8 -7
  2. package/dist/cjs/types/components/ResultStatisticsTable.d.ts +3 -0
  3. package/dist/cjs/types/components/ResultWinnerChart.d.ts +2 -1
  4. package/dist/cjs/types/particles.d.ts +2 -0
  5. package/dist/code_battles/__init__.py +2 -2
  6. package/dist/code_battles/battles.py +32 -19
  7. package/dist/code_battles/js.pyi +27 -19
  8. package/dist/code_battles/pyscript/__init__.pyi +4 -1
  9. package/dist/code_battles/testing.py +51 -0
  10. package/dist/code_battles/utilities.py +7 -7
  11. package/dist/esm/index.js +8 -7
  12. package/dist/esm/types/components/ResultStatisticsTable.d.ts +3 -0
  13. package/dist/esm/types/components/ResultWinnerChart.d.ts +2 -1
  14. package/dist/esm/types/particles.d.ts +2 -0
  15. package/dist/pyscript/codemirror-7OB423u7.js +2 -0
  16. package/dist/pyscript/codemirror-7OB423u7.js.map +1 -0
  17. package/dist/pyscript/codemirror-Cxby0EOW.js +2 -0
  18. package/dist/pyscript/codemirror-Cxby0EOW.js.map +1 -0
  19. package/dist/pyscript/codemirror-DtxT3fWl.js +2 -0
  20. package/dist/pyscript/codemirror-DtxT3fWl.js.map +1 -0
  21. package/dist/pyscript/codemirror_commands-CmeJ70sL.js +2 -0
  22. package/dist/pyscript/codemirror_commands-CmeJ70sL.js.map +1 -0
  23. package/dist/pyscript/codemirror_commands-DEH2ednO.js +2 -0
  24. package/dist/pyscript/codemirror_commands-DEH2ednO.js.map +1 -0
  25. package/dist/pyscript/codemirror_commands-DboG9iWt.js +2 -0
  26. package/dist/pyscript/codemirror_commands-DboG9iWt.js.map +1 -0
  27. package/dist/pyscript/codemirror_lang-python-B1HhJPn9.js +2 -0
  28. package/dist/pyscript/codemirror_lang-python-B1HhJPn9.js.map +1 -0
  29. package/dist/pyscript/codemirror_lang-python-BmOE5ND1.js +2 -0
  30. package/dist/pyscript/codemirror_lang-python-BmOE5ND1.js.map +1 -0
  31. package/dist/pyscript/codemirror_lang-python-C4eeLuBs.js +2 -0
  32. package/dist/pyscript/codemirror_lang-python-C4eeLuBs.js.map +1 -0
  33. package/dist/pyscript/codemirror_language-BZEymLIM.js +2 -0
  34. package/dist/pyscript/codemirror_language-BZEymLIM.js.map +1 -0
  35. package/dist/pyscript/codemirror_language-Bq5O0hUR.js +2 -0
  36. package/dist/pyscript/codemirror_language-Bq5O0hUR.js.map +1 -0
  37. package/dist/pyscript/codemirror_language-DbhkgEi1.js +2 -0
  38. package/dist/pyscript/codemirror_language-DbhkgEi1.js.map +1 -0
  39. package/dist/pyscript/codemirror_state-BIAL8JKm.js.map +1 -1
  40. package/dist/pyscript/codemirror_view-B-yd5KcV.js +2 -0
  41. package/dist/pyscript/codemirror_view-B-yd5KcV.js.map +1 -0
  42. package/dist/pyscript/codemirror_view-BwC4I3hj.js +2 -0
  43. package/dist/pyscript/codemirror_view-BwC4I3hj.js.map +1 -0
  44. package/dist/pyscript/codemirror_view-DNx7dL5k.js +2 -0
  45. package/dist/pyscript/codemirror_view-DNx7dL5k.js.map +1 -0
  46. package/dist/pyscript/core-BAg8axiz.js +4 -0
  47. package/dist/pyscript/core-BAg8axiz.js.map +1 -0
  48. package/dist/pyscript/core-BL6RO8cs.js +4 -0
  49. package/dist/pyscript/core-BL6RO8cs.js.map +1 -0
  50. package/dist/pyscript/core-D_Y2i5wV.js +4 -0
  51. package/dist/pyscript/core-D_Y2i5wV.js.map +1 -0
  52. package/dist/pyscript/core-ZERPM6xU.js +4 -0
  53. package/dist/pyscript/core-ZERPM6xU.js.map +1 -0
  54. package/dist/pyscript/core.js +1 -1
  55. package/dist/pyscript/deprecations-manager-C-kM_OOK.js +2 -0
  56. package/dist/pyscript/deprecations-manager-C-kM_OOK.js.map +1 -0
  57. package/dist/pyscript/deprecations-manager-D1JCaoik.js +2 -0
  58. package/dist/pyscript/deprecations-manager-D1JCaoik.js.map +1 -0
  59. package/dist/pyscript/deprecations-manager-DFWBNz_j.js +2 -0
  60. package/dist/pyscript/deprecations-manager-DFWBNz_j.js.map +1 -0
  61. package/dist/pyscript/deprecations-manager-DdXs-cNg.js +2 -0
  62. package/dist/pyscript/deprecations-manager-DdXs-cNg.js.map +1 -0
  63. package/dist/pyscript/donkey--RgkMgKe.js +2 -0
  64. package/dist/pyscript/donkey--RgkMgKe.js.map +1 -0
  65. package/dist/pyscript/donkey-9sgzITrF.js +2 -0
  66. package/dist/pyscript/donkey-9sgzITrF.js.map +1 -0
  67. package/dist/pyscript/donkey-CM92-SJF.js +2 -0
  68. package/dist/pyscript/donkey-CM92-SJF.js.map +1 -0
  69. package/dist/pyscript/donkey-DvYy_z4S.js +2 -0
  70. package/dist/pyscript/donkey-DvYy_z4S.js.map +1 -0
  71. package/dist/pyscript/error-ADoJa5BE.js +2 -0
  72. package/dist/pyscript/error-ADoJa5BE.js.map +1 -0
  73. package/dist/pyscript/error-BHehssqp.js +2 -0
  74. package/dist/pyscript/error-BHehssqp.js.map +1 -0
  75. package/dist/pyscript/error-BkHvnmyu.js +2 -0
  76. package/dist/pyscript/error-BkHvnmyu.js.map +1 -0
  77. package/dist/pyscript/error-Dc0g2_oA.js +2 -0
  78. package/dist/pyscript/error-Dc0g2_oA.js.map +1 -0
  79. package/dist/pyscript/index-B25jxAgK.js +2 -0
  80. package/dist/pyscript/index-B25jxAgK.js.map +1 -0
  81. package/dist/pyscript/index-BtkFDJPe.js +2 -0
  82. package/dist/pyscript/index-BtkFDJPe.js.map +1 -0
  83. package/dist/pyscript/index-DyZ04Mez.js +2 -0
  84. package/dist/pyscript/index-DyZ04Mez.js.map +1 -0
  85. package/dist/pyscript/mpy-61tR9ZQz.js +2 -0
  86. package/dist/pyscript/mpy-61tR9ZQz.js.map +1 -0
  87. package/dist/pyscript/mpy-BOCRQK6f.js +2 -0
  88. package/dist/pyscript/mpy-BOCRQK6f.js.map +1 -0
  89. package/dist/pyscript/mpy-PutLL-8K.js +2 -0
  90. package/dist/pyscript/mpy-PutLL-8K.js.map +1 -0
  91. package/dist/pyscript/mpy-lpj2Tqw5.js +2 -0
  92. package/dist/pyscript/mpy-lpj2Tqw5.js.map +1 -0
  93. package/dist/pyscript/py-ByqLLyxS.js +2 -0
  94. package/dist/pyscript/py-ByqLLyxS.js.map +1 -0
  95. package/dist/pyscript/py-C5u4njlg.js +2 -0
  96. package/dist/pyscript/py-C5u4njlg.js.map +1 -0
  97. package/dist/pyscript/py-CbCpu0Nu.js +2 -0
  98. package/dist/pyscript/py-CbCpu0Nu.js.map +1 -0
  99. package/dist/pyscript/py-CzEKg5Vq.js +2 -0
  100. package/dist/pyscript/py-CzEKg5Vq.js.map +1 -0
  101. package/dist/pyscript/py-editor-BSEgUf3R.js +2 -0
  102. package/dist/pyscript/py-editor-BSEgUf3R.js.map +1 -0
  103. package/dist/pyscript/py-editor-C_VolMVE.js +2 -0
  104. package/dist/pyscript/py-editor-C_VolMVE.js.map +1 -0
  105. package/dist/pyscript/py-editor-JsJIlo51.js +2 -0
  106. package/dist/pyscript/py-editor-JsJIlo51.js.map +1 -0
  107. package/dist/pyscript/py-editor-rQyrU9ml.js +2 -0
  108. package/dist/pyscript/py-editor-rQyrU9ml.js.map +1 -0
  109. package/dist/pyscript/py-game-CqGV5glf.js +2 -0
  110. package/dist/pyscript/py-game-CqGV5glf.js.map +1 -0
  111. package/dist/pyscript/py-game-D3nLvq_1.js +2 -0
  112. package/dist/pyscript/py-game-D3nLvq_1.js.map +1 -0
  113. package/dist/pyscript/py-game-DC-XdrKH.js +2 -0
  114. package/dist/pyscript/py-game-DC-XdrKH.js.map +1 -0
  115. package/dist/pyscript/py-game-TYE6CZwh.js +2 -0
  116. package/dist/pyscript/py-game-TYE6CZwh.js.map +1 -0
  117. package/dist/pyscript/py-terminal-Bjixd_gx.js +2 -0
  118. package/dist/pyscript/py-terminal-Bjixd_gx.js.map +1 -0
  119. package/dist/pyscript/py-terminal-CEeXlsXC.js +2 -0
  120. package/dist/pyscript/py-terminal-CEeXlsXC.js.map +1 -0
  121. package/dist/pyscript/py-terminal-CNqBj7Ns.js +2 -0
  122. package/dist/pyscript/py-terminal-CNqBj7Ns.js.map +1 -0
  123. package/dist/pyscript/py-terminal-qT02HXWZ.js +2 -0
  124. package/dist/pyscript/py-terminal-qT02HXWZ.js.map +1 -0
  125. package/dist/pyscript/storage.js.map +1 -1
  126. package/dist/pyscript/toml-BK2RWy-G.js.map +1 -1
  127. package/dist/pyscript/xterm-7LwxAMsn.js +2 -0
  128. package/dist/pyscript/xterm-7LwxAMsn.js.map +1 -0
  129. package/dist/pyscript/xterm-DrSYbXEP.js.map +1 -1
  130. package/dist/pyscript/xterm-readline-CYfUpnbV.js.map +1 -1
  131. package/dist/pyscript/xterm.css +1 -1
  132. package/dist/pyscript/xterm_addon-fit--gyF3PcZ.js.map +1 -1
  133. package/dist/pyscript/xterm_addon-web-links-D95xh2la.js.map +1 -1
  134. package/dist/pyscript/zip-BU7PvvcW.js +2 -0
  135. package/dist/pyscript/zip-BU7PvvcW.js.map +1 -0
  136. package/dist/pyscript/zip-DxlTOqbw.js +2 -0
  137. package/dist/pyscript/zip-DxlTOqbw.js.map +1 -0
  138. package/package.json +2 -2
package/dist/cjs/index.js CHANGED
@@ -2494,7 +2494,7 @@ const PickBotBlock = () => {
2494
2494
  } })));
2495
2495
  };
2496
2496
 
2497
- const ResultWinnerChart = ({ results: currentResults }) => {
2497
+ const ResultWinnerChart = ({ results: currentResults, players, }) => {
2498
2498
  var _a;
2499
2499
  const [results] = useLocalStorage({
2500
2500
  key: "Results",
@@ -2518,7 +2518,7 @@ const ResultWinnerChart = ({ results: currentResults }) => {
2518
2518
  }
2519
2519
  const winCounts = {};
2520
2520
  for (const result of currentResults) {
2521
- const winner = round.players[result.places[0]];
2521
+ const winner = (players !== null && players !== void 0 ? players : round.players)[result.places[0]];
2522
2522
  if (!winCounts[winner]) {
2523
2523
  winCounts[winner] = 1;
2524
2524
  }
@@ -2687,7 +2687,7 @@ const RunSimulationBlock = () => {
2687
2687
  "Remaining Simulations: ",
2688
2688
  remaining)),
2689
2689
  React.createElement("p", { style: { textAlign: "center", display: "none", marginTop: 10 }, id: "noui-progress" }),
2690
- React.createElement(ResultWinnerChart, { results: currentResults }),
2690
+ React.createElement(ResultWinnerChart, { results: currentResults, players: playerBots }),
2691
2691
  React.createElement(dropzone.Dropzone, { mt: "xs", multiple: false, onDrop: (files) => __awaiter(void 0, void 0, void 0, function* () {
2692
2692
  if (files.length !== 1) {
2693
2693
  return;
@@ -2983,7 +2983,7 @@ const ResultStatisticsTable = () => {
2983
2983
  key: "Current Round",
2984
2984
  defaultValue: 0,
2985
2985
  });
2986
- const navigate = reactRouterDom.useNavigate();
2986
+ reactRouterDom.useNavigate();
2987
2987
  const round = rounds[currentRound];
2988
2988
  if (!round) {
2989
2989
  return React.createElement(React.Fragment, null);
@@ -2993,6 +2993,7 @@ const ResultStatisticsTable = () => {
2993
2993
  if (!roundResults) {
2994
2994
  return React.createElement(React.Fragment, null);
2995
2995
  }
2996
+ const uniqueRoundResults = roundResults.filter((result, index, self) => self.findIndex((r) => r.seed === result.seed) === index);
2996
2997
  return (React.createElement("div", { style: {
2997
2998
  display: "flex",
2998
2999
  flexDirection: "column",
@@ -3001,12 +3002,12 @@ const ResultStatisticsTable = () => {
3001
3002
  } },
3002
3003
  React.createElement(DataTable, { tableName: "Results", data: {
3003
3004
  head: ["Seed"].concat(statistics),
3004
- body: roundResults.map((result) => [result.seed].concat(statistics.map((statistic) => { var _a; return ((_a = result === null || result === void 0 ? void 0 : result.statistics) !== null && _a !== void 0 ? _a : {})[statistic].toString(); }))),
3005
+ body: uniqueRoundResults.map((result) => [result.seed].concat(statistics.map((statistic) => { var _a; return ((_a = result === null || result === void 0 ? void 0 : result.statistics) !== null && _a !== void 0 ? _a : {})[statistic].toString(); }))),
3005
3006
  }, renderValue: (rowIndex, columnName, value) => {
3006
3007
  if (columnName === "Seed") {
3007
- return (React.createElement(core.Button, { leftSection: React.createElement("i", { className: "fa-solid fa-play" }), onClick: () => navigate(`/simulation/${round.players.map(encodeURIComponent).join(",")}?seed=${value}&${Object.keys(round.parameters)
3008
+ return (React.createElement(core.Button, { component: "a", leftSection: React.createElement("i", { className: "fa-solid fa-play" }), href: `/simulation/${round.players.map(encodeURIComponent).join(",")}?seed=${value}&${Object.keys(round.parameters)
3008
3009
  .map((p) => `${p}=${encodeURIComponent(round.parameters[p])}`)
3009
- .join("&")}`) }, "Play"));
3010
+ .join("&")}` }, "Play"));
3010
3011
  }
3011
3012
  return React.createElement(React.Fragment, { key: rowIndex }, value);
3012
3013
  } })));
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const ResultStatisticsTable: () => React.JSX.Element;
3
+ export default ResultStatisticsTable;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- declare const ResultWinnerChart: ({ results: currentResults }: {
2
+ declare const ResultWinnerChart: ({ results: currentResults, players, }: {
3
3
  results?: any;
4
+ players?: string[];
4
5
  }) => React.JSX.Element;
5
6
  export default ResultWinnerChart;
@@ -0,0 +1,2 @@
1
+ export declare const parallax: any;
2
+ export declare const confetti: any;
@@ -2,8 +2,8 @@ from __future__ import annotations
2
2
 
3
3
  import sys
4
4
 
5
- from code_battles.battles import CodeBattles
6
- from code_battles.utilities import Alignment, GameCanvas, is_web, is_worker
5
+ from battles import CodeBattles
6
+ from utilities import Alignment, GameCanvas, is_web, is_worker
7
7
 
8
8
 
9
9
  def run_game(battles: CodeBattles):
@@ -12,12 +12,13 @@ import sys
12
12
  import time
13
13
  import traceback
14
14
  import typing
15
+ from contextlib import contextmanager
15
16
  from dataclasses import dataclass
16
17
  from random import Random
17
18
  from typing import Any, Dict, Generic, List, Optional, Set, Tuple, TypeVar, Union
18
19
  from urllib.parse import quote
19
20
 
20
- from code_battles.utilities import (
21
+ from utilities import (
21
22
  GameCanvas,
22
23
  console_log,
23
24
  download_image,
@@ -326,7 +327,7 @@ class CodeBattles(
326
327
  def download_image(self, url: str) -> "asyncio.Future[js.Image]":
327
328
  from js import Image
328
329
 
329
- result = asyncio.Future()
330
+ result = asyncio.Future[Image]()
330
331
  image = Image.new()
331
332
  image.onload = lambda _: result.set_result(image)
332
333
  image.src = url
@@ -343,7 +344,7 @@ class CodeBattles(
343
344
  from js import Image
344
345
 
345
346
  remaining_images: List[str] = []
346
- result = asyncio.Future()
347
+ result = asyncio.Future[Dict[str, Image]]()
347
348
 
348
349
  images: Dict[str, Image] = {}
349
350
  remaining = len(sources)
@@ -505,7 +506,7 @@ class CodeBattles(
505
506
  if sound not in self._sounds:
506
507
  self._sounds[sound] = Audio.new(self.configure_sound_url(sound))
507
508
 
508
- volume = window.localStorage.getItem("Volume") or 0
509
+ volume = float(window.localStorage.getItem("Volume") or "0")
509
510
  s = self._sounds[sound].cloneNode(True)
510
511
  s.volume = volume
511
512
 
@@ -560,8 +561,8 @@ class CodeBattles(
560
561
  ):
561
562
  if seed is None:
562
563
  seed = Random().randint(0, 2**128)
563
- self._logs = []
564
- self._alerts = []
564
+ self._logs: List[Any] = []
565
+ self._alerts: List[Any] = []
565
566
  self._decisions = []
566
567
  self._breakpoints = set()
567
568
  self._decision_index = 0
@@ -585,7 +586,7 @@ class CodeBattles(
585
586
 
586
587
  def _run_webworker_simulation(
587
588
  self,
588
- parameters: Dict[str, str],
589
+ parameters_str: str,
589
590
  player_names_str: str,
590
591
  player_codes_str: str,
591
592
  seed: Optional[int] = None,
@@ -593,12 +594,12 @@ class CodeBattles(
593
594
  from pyscript import sync
594
595
 
595
596
  # JS to Python
596
- parameters = json.loads(parameters)
597
+ parameters: Dict[str, str] = json.loads(parameters_str)
597
598
  player_names = json.loads(player_names_str)
598
599
  player_codes = json.loads(player_codes_str)
599
600
 
600
601
  self.parameters = parameters
601
- self.map = parameters.get("map")
602
+ self.map = parameters["map"]
602
603
  self.player_names = player_names
603
604
  self.background = True
604
605
  self.console_visible = False
@@ -611,10 +612,9 @@ class CodeBattles(
611
612
  decisions = self._make_decisions()
612
613
  logs = self._logs
613
614
  alerts = self._alerts
614
- log = self.log
615
- self.log = lambda *args, **kwargs: None
616
- self.apply_decisions(decisions)
617
- self.log = log
615
+
616
+ with self._without_log():
617
+ self.apply_decisions(decisions)
618
618
 
619
619
  sync.update_step(
620
620
  base64.b64encode(decisions).decode(),
@@ -627,6 +627,17 @@ class CodeBattles(
627
627
  if not self.over:
628
628
  self.step += 1
629
629
 
630
+ @contextmanager
631
+ def _without_log(self):
632
+ log = getattr(self, "log")
633
+
634
+ def do_nothing(*args, **kwargs):
635
+ pass
636
+
637
+ setattr(self, "log", do_nothing)
638
+ yield
639
+ setattr(self, "log", log)
640
+
630
641
  def _run_local_simulation(self):
631
642
  command = sys.argv[1]
632
643
  output_file = None
@@ -741,7 +752,7 @@ class CodeBattles(
741
752
  await asyncio.sleep(0.01)
742
753
  self._initialize()
743
754
  self.parameters = simulation.parameters
744
- self.map = self.parameters.get("map")
755
+ self.map = self.parameters["map"]
745
756
  self.map_image = await download_image(
746
757
  self.configure_map_image_url(self.map)
747
758
  )
@@ -787,7 +798,7 @@ class CodeBattles(
787
798
  # JS to Python
788
799
  player_names = [str(x) for x in player_names]
789
800
  player_codes = [str(x) for x in player_codes]
790
- parameters = parameters.to_py()
801
+ parameters = parameters.to_py() # type: ignore
791
802
 
792
803
  try:
793
804
  render_status = document.getElementById("render-status")
@@ -795,7 +806,7 @@ class CodeBattles(
795
806
  render_status.textContent = "Rendering: Initializing..."
796
807
 
797
808
  self.parameters = parameters
798
- self.map = parameters.get("map")
809
+ self.map = parameters["map"]
799
810
  self.player_names = player_names
800
811
  self.map_image = await download_image(
801
812
  self.configure_map_image_url(self.map)
@@ -975,10 +986,12 @@ class CodeBattles(
975
986
  else line
976
987
  for line in api_code.splitlines()
977
988
  ]
978
- lines = "\n".join(lines)
979
- lines = lines.replace("class MyBot", f"class Player{index}Bot")
989
+ player_code = "\n".join(lines)
990
+ player_code = player_code.replace(
991
+ "class MyBot", f"class Player{index}Bot"
992
+ )
980
993
  try:
981
- exec(lines, player_globals[index])
994
+ exec(player_code, player_globals[index])
982
995
  exec(
983
996
  f"player_api = Player{index}Bot(context)",
984
997
  player_globals[index],
@@ -1,13 +1,14 @@
1
1
  """
2
- Basic type hints for JavaScript in PyOdide and PyScript.
2
+ Basic type hints for JavaScript, used in Pyodide and PyScript.
3
3
  A lot of properties are missing.
4
4
  """
5
5
 
6
- from typing import Callable, List, Literal, Optional
6
+ from typing import Any, Callable, List, Literal, Optional
7
7
 
8
- from pyodide.ffi import JsCallable
8
+ class JsCallable:
9
+ pass
9
10
 
10
- class TwoDContext:
11
+ class CanvasRenderingContext2D:
11
12
  textAlign: Literal["left", "right", "center", "start", "end"]
12
13
  textBaseline: Literal[
13
14
  "top", "hanging", "middle", "alphabetic", "ideographic", "bottom"
@@ -15,35 +16,37 @@ class TwoDContext:
15
16
  font: str
16
17
  fillStyle: str
17
18
  strokeStyle: str
18
- lineWidth: int
19
+ lineWidth: float
19
20
 
20
21
  @staticmethod
21
22
  def beginPath(): ...
22
23
  @staticmethod
23
24
  def arc(
24
- x: int,
25
- y: int,
25
+ x: float,
26
+ y: float,
26
27
  radius: float,
27
28
  startAngle: float,
28
29
  endAngle: float,
29
30
  counterclockwise=False,
30
31
  ): ...
31
32
  @staticmethod
32
- def moveTo(x: int, y: int): ...
33
+ def moveTo(x: float, y: float): ...
33
34
  @staticmethod
34
- def lineTo(x: int, y: int): ...
35
+ def lineTo(x: float, y: float): ...
35
36
  @staticmethod
36
37
  def stroke(): ...
37
38
  @staticmethod
38
39
  def fill(): ...
39
40
  @staticmethod
40
- def fillText(text: str, x: int, y: int): ...
41
+ def fillText(text: str, x: float, y: float): ...
41
42
  @staticmethod
42
- def fillRect(x: int, y: int, width: int, height: int): ...
43
+ def fillRect(x: float, y: float, width: float, height: float): ...
43
44
  @staticmethod
44
- def drawImage(image: "Image", x: int, y: int, width: int, height: int): ...
45
+ def drawImage(image: "Image", x: float, y: float, width: float, height: float): ...
45
46
  @staticmethod
46
- def clearRect(startX: int, endX: int, width: int, height: int): ...
47
+ def clearRect(startX: float, endX: float, width: float, height: float): ...
48
+ @staticmethod
49
+ def rect(startX: float, endX: float, width: float, height: float): ...
47
50
  @staticmethod
48
51
  def save(): ...
49
52
  @staticmethod
@@ -66,12 +69,12 @@ class Element:
66
69
  onclick: JsCallable
67
70
  width: float
68
71
  height: float
69
- clientWidth: Optional[int]
70
- clientHeight: Optional[int]
72
+ clientWidth: Optional[float]
73
+ clientHeight: Optional[float]
71
74
  style: Styles
72
75
 
73
76
  @staticmethod
74
- def getContext(dimensions: str) -> TwoDContext: ...
77
+ def getContext(dimensions: str) -> CanvasRenderingContext2D: ...
75
78
  @staticmethod
76
79
  def click(): ...
77
80
  @staticmethod
@@ -79,10 +82,15 @@ class Element:
79
82
 
80
83
  class document:
81
84
  body: Element
85
+ fonts: FontFaceSet
82
86
 
83
87
  @staticmethod
84
88
  def getElementById(id: str) -> Element: ...
85
89
 
90
+ class FontFaceSet:
91
+ @staticmethod
92
+ def add(font: FontFace) -> FontFaceSet: ...
93
+
86
94
  class Matches:
87
95
  matches: bool
88
96
 
@@ -94,7 +102,7 @@ class LocalStorage:
94
102
  @staticmethod
95
103
  def setItem(key: str, value: str) -> None: ...
96
104
 
97
- class window:
105
+ class window(Any):
98
106
  devicePixelRatio: float
99
107
  localStorage: LocalStorage
100
108
 
@@ -126,8 +134,8 @@ class Image(Element):
126
134
  onerror: Callable[[Event], None]
127
135
 
128
136
  def clearInterval(id: int) -> None: ...
129
- def setInterval(fn: JsCallable, period: int) -> int: ...
130
- def setTimeout(fn: JsCallable, period: int) -> None: ...
137
+ def setInterval(fn: JsCallable, period: float) -> int: ...
138
+ def setTimeout(fn: JsCallable, period: float) -> None: ...
131
139
 
132
140
  class FontFace:
133
141
  @staticmethod
@@ -1,4 +1,7 @@
1
- from typing import Literal
1
+ from typing import Any, Literal
2
2
 
3
3
  class PyWorker:
4
4
  def __init__(self, path: str, type: Literal["micropython", "pyodide"]): ...
5
+
6
+ sync: Any
7
+ workers: Any
@@ -0,0 +1,51 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import os
5
+ import sys
6
+ from pathlib import Path
7
+ from typing import Dict, List
8
+
9
+ from battles import CodeBattles, Simulation
10
+ from pytest import MonkeyPatch
11
+
12
+
13
+ def snapshot_test(
14
+ monkeypatch: MonkeyPatch,
15
+ battles: CodeBattles,
16
+ seed: int,
17
+ parameters: Dict[str, str],
18
+ bots: List[str],
19
+ name: str,
20
+ tmp_path: Path,
21
+ ):
22
+ output_path = tmp_path / "output.btl"
23
+ test_path = Path("__snapshots__") / (name + ".snapshot.btl")
24
+ with monkeypatch.context() as m:
25
+ m.setattr(
26
+ sys,
27
+ "argv",
28
+ [
29
+ "code-battles",
30
+ "simulate",
31
+ str(seed),
32
+ str(output_path),
33
+ json.dumps(parameters),
34
+ ]
35
+ + [os.path.abspath(bot) for bot in bots],
36
+ )
37
+
38
+ battles._run_local_simulation()
39
+ assert output_path.exists()
40
+ output_simulation = output_path.read_text()
41
+ simulation = Simulation.load(output_simulation)
42
+ assert simulation.seed == seed
43
+ assert simulation.parameters == parameters
44
+
45
+ if not test_path.exists():
46
+ os.makedirs(test_path.parent, exist_ok=True)
47
+ test_path.write_text(output_simulation)
48
+ else:
49
+ assert (
50
+ simulation.decisions == Simulation.load(test_path.read_text()).decisions
51
+ ), "Wrong decisions!"
@@ -52,7 +52,7 @@ class Alignment(Enum):
52
52
  def download_image(src: str):
53
53
  from js import Image
54
54
 
55
- result = asyncio.Future()
55
+ result = asyncio.Future[Image]()
56
56
  image = Image.new()
57
57
  image.onload = lambda _: result.set_result(image)
58
58
  image.src = src
@@ -173,8 +173,8 @@ class GameCanvas:
173
173
  def draw_element(
174
174
  self,
175
175
  image: "js.Image",
176
- x: int,
177
- y: int,
176
+ x: float,
177
+ y: float,
178
178
  width: int,
179
179
  board_index=0,
180
180
  direction: Union[float, None] = None,
@@ -252,10 +252,10 @@ class GameCanvas:
252
252
 
253
253
  def draw_rectangle(
254
254
  self,
255
- start_x: int,
256
- start_y: int,
257
- width: int,
258
- height: int,
255
+ start_x: float,
256
+ start_y: float,
257
+ width: float,
258
+ height: float,
259
259
  fill="black",
260
260
  stroke="transparent",
261
261
  stroke_width=2,
package/dist/esm/index.js CHANGED
@@ -2492,7 +2492,7 @@ const PickBotBlock = () => {
2492
2492
  } })));
2493
2493
  };
2494
2494
 
2495
- const ResultWinnerChart = ({ results: currentResults }) => {
2495
+ const ResultWinnerChart = ({ results: currentResults, players, }) => {
2496
2496
  var _a;
2497
2497
  const [results] = useLocalStorage({
2498
2498
  key: "Results",
@@ -2516,7 +2516,7 @@ const ResultWinnerChart = ({ results: currentResults }) => {
2516
2516
  }
2517
2517
  const winCounts = {};
2518
2518
  for (const result of currentResults) {
2519
- const winner = round.players[result.places[0]];
2519
+ const winner = (players !== null && players !== void 0 ? players : round.players)[result.places[0]];
2520
2520
  if (!winCounts[winner]) {
2521
2521
  winCounts[winner] = 1;
2522
2522
  }
@@ -2685,7 +2685,7 @@ const RunSimulationBlock = () => {
2685
2685
  "Remaining Simulations: ",
2686
2686
  remaining)),
2687
2687
  React.createElement("p", { style: { textAlign: "center", display: "none", marginTop: 10 }, id: "noui-progress" }),
2688
- React.createElement(ResultWinnerChart, { results: currentResults }),
2688
+ React.createElement(ResultWinnerChart, { results: currentResults, players: playerBots }),
2689
2689
  React.createElement(Dropzone, { mt: "xs", multiple: false, onDrop: (files) => __awaiter(void 0, void 0, void 0, function* () {
2690
2690
  if (files.length !== 1) {
2691
2691
  return;
@@ -2981,7 +2981,7 @@ const ResultStatisticsTable = () => {
2981
2981
  key: "Current Round",
2982
2982
  defaultValue: 0,
2983
2983
  });
2984
- const navigate = useNavigate();
2984
+ useNavigate();
2985
2985
  const round = rounds[currentRound];
2986
2986
  if (!round) {
2987
2987
  return React.createElement(React.Fragment, null);
@@ -2991,6 +2991,7 @@ const ResultStatisticsTable = () => {
2991
2991
  if (!roundResults) {
2992
2992
  return React.createElement(React.Fragment, null);
2993
2993
  }
2994
+ const uniqueRoundResults = roundResults.filter((result, index, self) => self.findIndex((r) => r.seed === result.seed) === index);
2994
2995
  return (React.createElement("div", { style: {
2995
2996
  display: "flex",
2996
2997
  flexDirection: "column",
@@ -2999,12 +3000,12 @@ const ResultStatisticsTable = () => {
2999
3000
  } },
3000
3001
  React.createElement(DataTable, { tableName: "Results", data: {
3001
3002
  head: ["Seed"].concat(statistics),
3002
- body: roundResults.map((result) => [result.seed].concat(statistics.map((statistic) => { var _a; return ((_a = result === null || result === void 0 ? void 0 : result.statistics) !== null && _a !== void 0 ? _a : {})[statistic].toString(); }))),
3003
+ body: uniqueRoundResults.map((result) => [result.seed].concat(statistics.map((statistic) => { var _a; return ((_a = result === null || result === void 0 ? void 0 : result.statistics) !== null && _a !== void 0 ? _a : {})[statistic].toString(); }))),
3003
3004
  }, renderValue: (rowIndex, columnName, value) => {
3004
3005
  if (columnName === "Seed") {
3005
- return (React.createElement(Button, { leftSection: React.createElement("i", { className: "fa-solid fa-play" }), onClick: () => navigate(`/simulation/${round.players.map(encodeURIComponent).join(",")}?seed=${value}&${Object.keys(round.parameters)
3006
+ return (React.createElement(Button, { component: "a", leftSection: React.createElement("i", { className: "fa-solid fa-play" }), href: `/simulation/${round.players.map(encodeURIComponent).join(",")}?seed=${value}&${Object.keys(round.parameters)
3006
3007
  .map((p) => `${p}=${encodeURIComponent(round.parameters[p])}`)
3007
- .join("&")}`) }, "Play"));
3008
+ .join("&")}` }, "Play"));
3008
3009
  }
3009
3010
  return React.createElement(React.Fragment, { key: rowIndex }, value);
3010
3011
  } })));
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const ResultStatisticsTable: () => React.JSX.Element;
3
+ export default ResultStatisticsTable;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- declare const ResultWinnerChart: ({ results: currentResults }: {
2
+ declare const ResultWinnerChart: ({ results: currentResults, players, }: {
3
3
  results?: any;
4
+ players?: string[];
4
5
  }) => React.JSX.Element;
5
6
  export default ResultWinnerChart;
@@ -0,0 +1,2 @@
1
+ export declare const parallax: any;
2
+ export declare const confetti: any;
@@ -0,0 +1,2 @@
1
+ import{E as e,V as t,b as i,a as s,c as n,d as o,r,h as l,W as a,e as c,f as h,i as d,j as u,m as f,n as m,o as p,p as g,k as v}from"./codemirror_view-B-yd5KcV.js";import{StateField as x,StateEffect as b,Prec as w,EditorSelection as k,Facet as y,combineConfig as M,codePointAt as S,fromCodePoint as C,codePointSize as L,CharCategory as q,EditorState as A,RangeSetBuilder as R,findClusterBreak as D}from"./codemirror_state-BIAL8JKm.js";import{f as W,a as F,b as I,c as P,d as E,e as $}from"./codemirror_language-BZEymLIM.js";import{history as O,defaultKeymap as z,historyKeymap as T}from"./codemirror_commands-DboG9iWt.js";import{c as B,a as j,b as _,d as V}from"./index-DyZ04Mez.js";const H="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class N{constructor(e,t,i=0,s=e.length,n,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=n?e=>n(H(e)):H,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return S(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=C(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=L(e);let s=this.normalize(t);if(s.length)for(let e=0,n=i;;e++){let o=s.charCodeAt(e),r=this.match(o,n,this.bufferPos+this.bufferStart);if(e==s.length-1){if(r)return this.value=r,this;break}n==i&&e<t.length&&t.charCodeAt(e)==o&&n++}}}match(e,t,i){let s=null;for(let t=0;t<this.matches.length;t+=2){let n=this.matches[t],o=!1;this.query.charCodeAt(n)==e&&(n==this.query.length-1?s={from:this.matches[t+1],to:i}:(this.matches[t]++,o=!0)),o||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?s={from:t,to:i}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}"undefined"!=typeof Symbol&&(N.prototype[Symbol.iterator]=function(){return this});const K={from:-1,to:-1,match:/.*/.exec("")},Q="gm"+(null==/x/.unicode?"":"u");class U{constructor(e,t,i,s=0,n=e.length){if(this.text=e,this.to=n,this.curLine="",this.done=!1,this.value=K,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Z(e,t,i,s,n);this.re=new RegExp(t,Q+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=J(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=J(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const G=new WeakMap;class Y{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=G.get(e);if(!s||s.from>=i||s.to<=t){let s=new Y(t,e.sliceString(t,i));return G.set(e,s),s}if(s.from==t&&s.to==i)return s;let{text:n,from:o}=s;return o>t&&(n=e.sliceString(t,o)+n,o=t),s.to<i&&(n+=e.sliceString(s.to,i)),G.set(e,new Y(o,n)),new Y(t,n.slice(t-o,i-o))}}class Z{constructor(e,t,i,s,n){this.text=e,this.to=n,this.done=!1,this.value=K,this.matchPos=J(e,s),this.re=new RegExp(t,Q+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=Y.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,i=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,i,t)))return this.value={from:e,to:i,match:t},this.matchPos=J(this.text,i+(e==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Y.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function J(e,t){if(t>=e.length)return t;let i,s=e.lineAt(t);for(;t<s.to&&(i=s.text.charCodeAt(t-s.from))>=56320&&i<57344;)t++;return t}function X(t){let i=String(t.state.doc.lineAt(t.state.selection.main.head).number),s=o("input",{class:"cm-textfield",name:"line",value:i});function n(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.value);if(!i)return;let{state:n}=t,o=n.doc.lineAt(n.selection.main.head),[,r,l,a,c]=i,h=a?+a.slice(1):0,d=l?+l:o.number;if(l&&c){let e=d/100;r&&(e=e*("-"==r?-1:1)+o.number/n.doc.lines),d=Math.round(n.doc.lines*e)}else l&&r&&(d=d*("-"==r?-1:1)+o.number);let u=n.doc.line(Math.max(1,Math.min(n.doc.lines,d))),f=k.cursor(u.from+Math.max(0,Math.min(h,u.length)));t.dispatch({effects:[ee.of(!1),e.scrollIntoView(f.from,{y:"center"})],selection:f}),t.focus()}return{dom:o("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:ee.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),n())},onsubmit:e=>{e.preventDefault(),n()}},o("label",t.state.phrase("Go to line"),": ",s)," ",o("button",{class:"cm-button",type:"submit"},t.state.phrase("go")),o("button",{name:"close",onclick:()=>{t.dispatch({effects:ee.of(!1)}),t.focus()},"aria-label":t.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(U.prototype[Symbol.iterator]=Z.prototype[Symbol.iterator]=function(){return this});const ee=b.define(),te=x.define({create:()=>!0,update(e,t){for(let i of t.effects)i.is(ee)&&(e=i.value);return e},provide:e=>n.from(e,e=>e?X:null)}),ie=e.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),se={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},ne=y.define({combine:e=>M(e,se,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const oe=s.mark({class:"cm-selectionMatch"}),re=s.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function le(e,t,i,s){return!(0!=i&&e(t.sliceDoc(i-1,i))==q.Word||s!=t.doc.length&&e(t.sliceDoc(s,s+1))==q.Word)}const ae=t.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(ne),{state:i}=e,n=i.selection;if(n.ranges.length>1)return s.none;let o,r=n.main,l=null;if(r.empty){if(!t.highlightWordAroundCursor)return s.none;let e=i.wordAt(r.head);if(!e)return s.none;l=i.charCategorizer(r.head),o=i.sliceDoc(e.from,e.to)}else{let e=r.to-r.from;if(e<t.minSelectionLength||e>200)return s.none;if(t.wholeWords){if(o=i.sliceDoc(r.from,r.to),l=i.charCategorizer(r.head),!le(l,i,r.from,r.to)||!function(e,t,i,s){return e(t.sliceDoc(i,i+1))==q.Word&&e(t.sliceDoc(s-1,s))==q.Word}(l,i,r.from,r.to))return s.none}else if(o=i.sliceDoc(r.from,r.to),!o)return s.none}let a=[];for(let n of e.visibleRanges){let e=new N(i.doc,o,n.from,n.to);for(;!e.next().done;){let{from:n,to:o}=e.value;if((!l||le(l,i,n,o))&&(r.empty&&n<=r.from&&o>=r.to?a.push(re.range(n,o)):(n>=r.to||o<=r.from)&&a.push(oe.range(n,o)),a.length>t.maxMatches))return s.none}}return s.set(a)}},{decorations:e=>e.decorations}),ce=e.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const he=y.define({combine:t=>M(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Te(e),scrollToMatch:t=>e.scrollIntoView(t)})});class de{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,Q),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new xe(this):new me(this)}getCursor(e,t=0,i){let s=e.doc?e:A.create({doc:e});return null==i&&(i=s.doc.length),this.regexp?pe(this,s,t,i):fe(this,s,t,i)}}class ue{constructor(e){this.spec=e}}function fe(e,t,i,s){return new N(t.doc,e.unquoted,i,s,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(n=t.doc,o=t.charCategorizer(t.selection.main.head),(e,t,i,s)=>((s>e||s+i.length<t)&&(s=Math.max(0,e-2),i=n.sliceString(s,Math.min(n.length,t+2))),!(o(ge(i,e-s))==q.Word&&o(ve(i,e-s))==q.Word||o(ve(i,t-s))==q.Word&&o(ge(i,t-s))==q.Word))):void 0);var n,o}class me extends ue{constructor(e){super(e)}nextMatch(e,t,i){let s=fe(this.spec,e,i,e.doc.length).nextOverlapping();if(s.done){let i=Math.min(e.doc.length,t+this.spec.unquoted.length);s=fe(this.spec,e,0,i).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==i?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let i=Math.max(t,s-1e4-this.spec.unquoted.length),n=fe(this.spec,e,i,s),o=null;for(;!n.nextOverlapping().done;)o=n.value;if(o)return o;if(i==t)return null;s-=1e4}}prevMatch(e,t,i){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),!s||s.from==t&&s.to==i?null:s}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=fe(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let n=fe(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!n.next().done;)s(n.value.from,n.value.to)}}function pe(e,t,i,s){return new U(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(n=t.charCategorizer(t.selection.main.head),(e,t,i)=>!i[0].length||(n(ge(i.input,i.index))!=q.Word||n(ve(i.input,i.index))!=q.Word)&&(n(ve(i.input,i.index+i[0].length))!=q.Word||n(ge(i.input,i.index+i[0].length))!=q.Word)):void 0},i,s);var n}function ge(e,t){return e.slice(D(e,t,!1),t)}function ve(e,t){return e.slice(t,D(e,t))}class xe extends ue{nextMatch(e,t,i){let s=pe(this.spec,e,i,e.doc.length).next();return s.done&&(s=pe(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let n=Math.max(t,i-1e4*s),o=pe(this.spec,e,n,i),r=null;for(;!o.next().done;)r=o.value;if(r&&(n==t||r.from>n+10))return r;if(n==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if("&"==i)return e.match[0];if("$"==i)return"$";for(let t=i.length;t>0;t--){let s=+i.slice(0,t);if(s>0&&s<e.match.length)return e.match[s]+i.slice(t)}return t})}matchAll(e,t){let i=pe(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let n=pe(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!n.next().done;)s(n.value.from,n.value.to)}}const be=b.define(),we=b.define(),ke=x.define({create:e=>new ye(Ie(e).create(),null),update(e,t){for(let i of t.effects)i.is(be)?e=new ye(i.value.create(),e.panel):i.is(we)&&(e=new ye(e.query,i.value?Fe:null));return e},provide:e=>n.from(e,e=>e.panel)});class ye{constructor(e,t){this.query=e,this.panel=t}}const Me=s.mark({class:"cm-searchMatch"}),Se=s.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Ce=t.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(ke))}update(e){let t=e.state.field(ke);(t!=e.startState.field(ke)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return s.none;let{view:i}=this,n=new R;for(let t=0,s=i.visibleRanges,o=s.length;t<o;t++){let{from:r,to:l}=s[t];for(;t<o-1&&l>s[t+1].from-500;)l=s[++t].to;e.highlight(i.state,r,l,(e,t)=>{let s=i.state.selection.ranges.some(i=>i.from==e&&i.to==t);n.add(e,t,s?Se:Me)})}return n.finish()}},{decorations:e=>e.decorations});function Le(e){return t=>{let i=t.state.field(ke,!1);return i&&i.query.spec.valid?e(t,i):$e(t)}}const qe=Le((e,{query:t})=>{let{to:i}=e.state.selection.main,s=t.nextMatch(e.state,i,i);if(!s)return!1;let n=k.single(s.from,s.to),o=e.state.facet(he);return e.dispatch({selection:n,effects:[Ve(e,s),o.scrollToMatch(n.main,e)],userEvent:"select.search"}),Ee(e),!0}),Ae=Le((e,{query:t})=>{let{state:i}=e,{from:s}=i.selection.main,n=t.prevMatch(i,s,s);if(!n)return!1;let o=k.single(n.from,n.to),r=e.state.facet(he);return e.dispatch({selection:o,effects:[Ve(e,n),r.scrollToMatch(o.main,e)],userEvent:"select.search"}),Ee(e),!0}),Re=Le((e,{query:t})=>{let i=t.matchAll(e.state,1e3);return!(!i||!i.length)&&(e.dispatch({selection:k.create(i.map(e=>k.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),De=Le((t,{query:i})=>{let{state:s}=t,{from:n,to:o}=s.selection.main;if(s.readOnly)return!1;let r=i.nextMatch(s,n,n);if(!r)return!1;let l,a,c=r,h=[],d=[];c.from==n&&c.to==o&&(a=s.toText(i.getReplacement(c)),h.push({from:c.from,to:c.to,insert:a}),c=i.nextMatch(s,c.from,c.to),d.push(e.announce.of(s.phrase("replaced match on line $",s.doc.lineAt(n).number)+".")));let u=t.state.changes(h);return c&&(l=k.single(c.from,c.to).map(u),d.push(Ve(t,c)),d.push(s.facet(he).scrollToMatch(l.main,t))),t.dispatch({changes:u,selection:l,effects:d,userEvent:"input.replace"}),!0}),We=Le((t,{query:i})=>{if(t.state.readOnly)return!1;let s=i.matchAll(t.state,1e9).map(e=>{let{from:t,to:s}=e;return{from:t,to:s,insert:i.getReplacement(e)}});if(!s.length)return!1;let n=t.state.phrase("replaced $ matches",s.length)+".";return t.dispatch({changes:s,effects:e.announce.of(n),userEvent:"input.replace.all"}),!0});function Fe(e){return e.state.facet(he).createPanel(e)}function Ie(e,t){var i,s,n,o,r;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let c=e.facet(he);return new de({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(s=null==t?void 0:t.caseSensitive)&&void 0!==s?s:c.caseSensitive,literal:null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal,regexp:null!==(o=null==t?void 0:t.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(r=null==t?void 0:t.wholeWord)&&void 0!==r?r:c.wholeWord})}function Pe(e){let t=i(e,Fe);return t&&t.dom.querySelector("[main-field]")}function Ee(e){let t=Pe(e);t&&t==e.root.activeElement&&t.select()}const $e=e=>{let t=e.state.field(ke,!1);if(t&&t.panel){let i=Pe(e);if(i&&i!=e.root.activeElement){let s=Ie(e.state,t.query.spec);s.valid&&e.dispatch({effects:be.of(s)}),i.focus(),i.select()}}else e.dispatch({effects:[we.of(!0),t?be.of(Ie(e.state,t.query.spec)):b.appendConfig.of(Ne)]});return!0},Oe=e=>{let t=e.state.field(ke,!1);if(!t||!t.panel)return!1;let s=i(e,Fe);return s&&s.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:we.of(!1)}),!0},ze=[{key:"Mod-f",run:$e,scope:"editor search-panel"},{key:"F3",run:qe,shift:Ae,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:qe,shift:Ae,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Oe,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let i=e.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:s,to:n}=i.main,o=[],r=0;for(let t=new N(e.doc,e.sliceDoc(s,n));!t.next().done;){if(o.length>1e3)return!1;t.value.from==s&&(r=o.length),o.push(k.range(t.value.from,t.value.to))}return t(e.update({selection:k.create(o,r),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let t=i(e,X);if(!t){let s=[ee.of(!0)];null==e.state.field(te,!1)&&s.push(b.appendConfig.of([te,ie])),e.dispatch({effects:s}),t=i(e,X)}return t&&t.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:i})=>{let{ranges:s}=t.selection;if(s.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:i}=e,s=k.create(i.ranges.map(t=>e.wordAt(t.head)||k.cursor(t.head)),i.mainIndex);return!s.eq(i)&&(t(e.update({selection:s})),!0)})({state:t,dispatch:i});let n=t.sliceDoc(s[0].from,s[0].to);if(t.selection.ranges.some(e=>t.sliceDoc(e.from,e.to)!=n))return!1;let o=function(e,t){let{main:i,ranges:s}=e.selection,n=e.wordAt(i.head),o=n&&n.from==i.from&&n.to==i.to;for(let i=!1,n=new N(e.doc,t,s[s.length-1].to);;){if(n.next(),!n.done){if(i&&s.some(e=>e.from==n.value.from))continue;if(o){let t=e.wordAt(n.value.from);if(!t||t.from!=n.value.from||t.to!=n.value.to)continue}return n.value}if(i)return null;n=new N(e.doc,t,0,Math.max(0,s[s.length-1].from-1)),i=!0}}(t,n);return!!o&&(i(t.update({selection:t.selection.addRange(k.range(o.from,o.to),!1),effects:e.scrollIntoView(o.to)})),!0)},preventDefault:!0}];class Te{constructor(e){this.view=e;let t=this.query=e.state.field(ke).query.spec;function i(e,t,i){return o("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=o("input",{value:t.search,placeholder:Be(e,"Find"),"aria-label":Be(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=o("input",{value:t.replace,placeholder:Be(e,"Replace"),"aria-label":Be(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=o("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=o("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=o("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=o("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",()=>qe(e),[Be(e,"next")]),i("prev",()=>Ae(e),[Be(e,"previous")]),i("select",()=>Re(e),[Be(e,"all")]),o("label",null,[this.caseField,Be(e,"match case")]),o("label",null,[this.reField,Be(e,"regexp")]),o("label",null,[this.wordField,Be(e,"by word")]),...e.state.readOnly?[]:[o("br"),this.replaceField,i("replace",()=>De(e),[Be(e,"replace")]),i("replaceAll",()=>We(e),[Be(e,"replace all")])],o("button",{name:"close",onclick:()=>Oe(e),"aria-label":Be(e,"close"),type:"button"},["×"])])}commit(){let e=new de({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:be.of(e)}))}keydown(e){r(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Ae:qe)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),De(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(be)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(he).top}}function Be(e,t){return e.state.phrase(t)}const je=30,_e=/[\s\.,:;?!]/;function Ve(t,{from:i,to:s}){let n=t.state.doc.lineAt(i),o=t.state.doc.lineAt(s).to,r=Math.max(n.from,i-je),l=Math.min(o,s+je),a=t.state.sliceDoc(r,l);if(r!=n.from)for(let e=0;e<je;e++)if(!_e.test(a[e+1])&&_e.test(a[e])){a=a.slice(e);break}if(l!=o)for(let e=a.length-1;e>a.length-je;e--)if(!_e.test(a[e-1])&&_e.test(a[e])){a=a.slice(0,e);break}return e.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const He=e.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Ne=[ke,w.low(Ce),He];class Ke{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Qe{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let n=i.facet(nt).markerFilter;n&&(e=n(e,i));let o=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),r=new R,l=[],a=0;for(let e=0;;){let t,n,c=e==o.length?null:o[e];if(!c&&!l.length)break;for(l.length?(t=a,n=l.reduce((e,t)=>Math.min(e,t.to),c&&c.from>t?c.from:1e8)):(t=c.from,n=c.to,l.push(c),e++);e<o.length;){let i=o[e];if(i.from!=t||!(i.to>i.from||i.to==t)){n=Math.min(i.from,n);break}l.push(i),e++,n=Math.min(i.to,n)}let h=ft(l);if(l.some(e=>e.from==e.to||e.from==e.to-1&&i.doc.lineAt(e.from).to==e.from))r.add(t,t,s.widget({widget:new lt(h),diagnostics:l.slice()}));else{let e=l.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");r.add(t,n,s.mark({class:"cm-lintRange cm-lintRange-"+h+e,diagnostics:l.slice(),inclusiveEnd:l.some(e=>e.to>n)}))}a=n;for(let e=0;e<l.length;e++)l[e].to<=a&&l.splice(e--,1)}let c=r.finish();return new Qe(c,t,Ue(c))}}function Ue(e,t=null,i=0){let s=null;return e.between(i,1e9,(e,i,{spec:n})=>{if(!(t&&n.diagnostics.indexOf(t)<0))if(s){if(n.diagnostics.indexOf(s.diagnostic)<0)return!1;s=new Ke(s.from,i,s.diagnostic)}else s=new Ke(e,i,t||n.diagnostics[0])}),s}const Ge=b.define(),Ye=b.define(),Ze=b.define(),Je=x.define({create:()=>new Qe(s.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let i=e.diagnostics.map(t.changes),s=null,n=e.panel;if(e.selected){let n=t.changes.mapPos(e.selected.from,1);s=Ue(i,e.selected.diagnostic,n)||Ue(i,null,n)}!i.size&&n&&t.state.facet(nt).autoPanel&&(n=null),e=new Qe(i,n,s)}for(let i of t.effects)if(i.is(Ge)){let s=t.state.facet(nt).autoPanel?i.value.length?ct.open:null:e.panel;e=Qe.init(i.value,s,t.state)}else i.is(Ye)?e=new Qe(e.diagnostics,i.value?ct.open:null,e.selected):i.is(Ze)&&(e=new Qe(e.diagnostics,e.panel,i.value));return e},provide:t=>[n.from(t,e=>e.panel),e.decorations.from(t,e=>e.diagnostics)]}),Xe=s.mark({class:"cm-lintRange cm-lintRange-active"});function et(e,t,i){let s,{diagnostics:n}=e.state.field(Je),o=-1,r=-1;n.between(t-(i<0?1:0),t+(i>0?1:0),(e,n,{spec:l})=>{if(t>=e&&t<=n&&(e==n||(t>e||i>0)&&(t<n||i<0)))return s=l.diagnostics,o=e,r=n,!1});let l=e.state.facet(nt).tooltipFilter;return s&&l&&(s=l(s,e.state)),s?{pos:o,end:r,above:e.state.doc.lineAt(o).to<r,create:()=>({dom:tt(e,s)})}:null}function tt(e,t){return o("ul",{class:"cm-tooltip-lint"},t.map(t=>rt(e,t,!1)))}const it=e=>{let t=e.state.field(Je,!1);return!(!t||!t.panel)&&(e.dispatch({effects:Ye.of(!1)}),!0)},st=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(Je,!1);var s,n;t&&t.panel||e.dispatch({effects:(s=e.state,n=[Ye.of(!0)],s.field(Je,!1)?n:n.concat(b.appendConfig.of(mt)))});let o=i(e,ct.open);return o&&o.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(Je,!1);if(!t)return!1;let i=e.state.selection.main,s=t.diagnostics.iter(i.to+1);return!(!s.value&&(s=t.diagnostics.iter(0),!s.value||s.from==i.from&&s.to==i.to))&&(e.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0}),!0)}}],nt=y.define({combine:e=>Object.assign({sources:e.map(e=>e.source).filter(e=>null!=e)},M(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))});function ot(e){let t=[];if(e)e:for(let{name:i}of e){for(let e=0;e<i.length;e++){let s=i[e];if(/[a-zA-Z]/.test(s)&&!t.some(e=>e.toLowerCase()==s.toLowerCase())){t.push(s);continue e}}t.push("")}return t}function rt(e,t,i){var s;let n=i?ot(t.actions):[];return o("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},o("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(s=t.actions)||void 0===s?void 0:s.map((i,s)=>{let r=!1,l=s=>{if(s.preventDefault(),r)return;r=!0;let n=Ue(e.state.field(Je).diagnostics,t);n&&i.apply(e,n.from,n.to)},{name:a}=i,c=n[s]?a.indexOf(n[s]):-1,h=c<0?a:[a.slice(0,c),o("u",a.slice(c,c+1)),a.slice(c+1)];return o("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${a}${c<0?"":` (access key "${n[s]})"`}.`},h)}),t.source&&o("div",{class:"cm-diagnosticSource"},t.source))}class lt extends a{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return o("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class at{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=rt(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ct{constructor(e){this.view=e,this.items=[];this.list=o("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)it(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],s=ot(i.actions);for(let n=0;n<s.length;n++)if(s[n].toUpperCase().charCodeAt(0)==t.keyCode){let t=Ue(this.view.state.field(Je).diagnostics,i);t&&i.actions[n].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=o("div",{class:"cm-panel-lint"},this.list,o("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>it(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Je).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Je),i=0,s=!1,n=null,o=new Set;for(e.between(0,this.view.state.doc.length,(e,r,{spec:l})=>{for(let e of l.diagnostics){if(o.has(e))continue;o.add(e);let r,l=-1;for(let t=i;t<this.items.length;t++)if(this.items[t].diagnostic==e){l=t;break}l<0?(r=new at(this.view,e),this.items.splice(i,0,r),s=!0):(r=this.items[l],l>i&&(this.items.splice(i,l-i),s=!0)),t&&r.diagnostic==t.diagnostic?r.dom.hasAttribute("aria-selected")||(r.dom.setAttribute("aria-selected","true"),n=r):r.dom.hasAttribute("aria-selected")&&r.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();0==this.items.length&&(this.items.push(new at(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),n?(this.list.setAttribute("aria-activedescendant",n.id),this.view.requestMeasure({key:this,read:()=>({sel:n.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let i=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/i:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Ue(this.view.state.field(Je).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Ze.of(t)})}static open(e){return new ct(e)}}function ht(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const dt=e.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:ht("#d11")},".cm-lintRange-warning":{backgroundImage:ht("orange")},".cm-lintRange-info":{backgroundImage:ht("#999")},".cm-lintRange-hint":{backgroundImage:ht("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function ut(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function ft(e){let t="hint",i=1;for(let s of e){let e=ut(s.severity);e>i&&(i=e,t=s.severity)}return t}const mt=[Je,e.decorations.compute([Je],e=>{let{selected:t,panel:i}=e.field(Je);return t&&i&&t.from!=t.to?s.set([Xe.range(t.from,t.to)]):s.none}),l(et,{hideOn:function(e,t){let i=t.pos,s=t.end||i,n=e.state.facet(nt).hideOn(e,i,s);if(null!=n)return n;let o=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(Ge))&&!e.changes.touchesRange(o.from,Math.max(o.to,s)))}}),dt],pt=(()=>[c(),h(),d(),O(),W(),u(),f(),A.allowMultipleSelections.of(!0),F(),I(E,{fallback:!0}),P(),B(),j(),m(),p(),g(),[ce,ae],v.of([..._,...z,...ze,...T,...$,...V,...st])])(),gt=(()=>[d(),O(),u(),I(E,{fallback:!0}),v.of([...z,...T])])();export{e as EditorView,pt as basicSetup,gt as minimalSetup};
2
+ //# sourceMappingURL=codemirror-7OB423u7.js.map