c0ckp1t 1.0.0

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 (676) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +5 -0
  3. package/c0ckp1t-demo/Constants.mjs +125 -0
  4. package/c0ckp1t-demo/components/sidebar.vue +82 -0
  5. package/c0ckp1t-demo/main.vue +39 -0
  6. package/c0ckp1t-demo/pages/devices.vue +63 -0
  7. package/c0ckp1t-demo/pages/homepage.vue +63 -0
  8. package/c0ckp1t-demo/pages/report.vue +63 -0
  9. package/c0ckp1t-demo/store.mjs +133 -0
  10. package/components/ExecButton.vue +62 -0
  11. package/components/FsTree.vue +550 -0
  12. package/components/Markdown.mjs +274 -0
  13. package/components/MarkdownUtils.mjs +180 -0
  14. package/components/Tree.mjs +175 -0
  15. package/components/code-mirror.vue +445 -0
  16. package/components/vue3-ace-editor.vue +331 -0
  17. package/components/xbutton.vue +45 -0
  18. package/components/xcard-h.vue +175 -0
  19. package/components/xcard.vue +76 -0
  20. package/components/xcheck.vue +35 -0
  21. package/components/xcheckbox.vue +52 -0
  22. package/components/xcode.vue +139 -0
  23. package/components/xcollapse.vue +52 -0
  24. package/components/xcolor.vue +84 -0
  25. package/components/xdropdown.vue +104 -0
  26. package/components/xdropdown2.vue +140 -0
  27. package/components/xhidden.vue +30 -0
  28. package/components/xinput.vue +101 -0
  29. package/components/xinput2.vue +101 -0
  30. package/components/xjson.vue +95 -0
  31. package/components/xkv.vue +41 -0
  32. package/components/xlabel.vue +56 -0
  33. package/components/xlist.vue +83 -0
  34. package/components/xmap.vue +106 -0
  35. package/components/xmarkdown.vue +269 -0
  36. package/components/xnav.vue +98 -0
  37. package/components/xsection.vue +164 -0
  38. package/components/xsound.vue +251 -0
  39. package/components/xtable-open.vue +179 -0
  40. package/components/xtabs.vue +72 -0
  41. package/components/xterminal.vue +456 -0
  42. package/components/xtextarea.vue +83 -0
  43. package/components/xtoggle.vue +68 -0
  44. package/components/xtoggle3.vue +67 -0
  45. package/components/xtree.vue +140 -0
  46. package/components/xupload.vue +129 -0
  47. package/core/Content.mjs +92 -0
  48. package/core/DocUtils.mjs +189 -0
  49. package/core/GlobalStore.mjs +329 -0
  50. package/core/Island.mjs +429 -0
  51. package/core/IslandDefault.mjs +229 -0
  52. package/core/JsUtils.mjs +483 -0
  53. package/core/Logging.mjs +59 -0
  54. package/core/Page404.vue +152 -0
  55. package/core/PageFallback.vue +168 -0
  56. package/core/PageMain.vue +181 -0
  57. package/core/Theme.mjs +1759 -0
  58. package/core/VueUtils.mjs +200 -0
  59. package/core/WsUtils.mjs +274 -0
  60. package/core/img/Flag_of_the_United_States.svg +25 -0
  61. package/core/img/logo_v1.svg +98 -0
  62. package/core/img/logo_v2.svg +98 -0
  63. package/core/img/state-uniqueId-8k.wav +0 -0
  64. package/core/main-offcanvas.vue +99 -0
  65. package/core/nodes/_api.vue +82 -0
  66. package/core/nodes/node-container.vue +103 -0
  67. package/core/nodes/node.vue +246 -0
  68. package/core/nodes/place-holder.vue +47 -0
  69. package/core/nodes/root.vue +52 -0
  70. package/core/notify/NotifyUtils.mjs +150 -0
  71. package/core/notify/toast.vue +150 -0
  72. package/core/pages/About.vue +57 -0
  73. package/core/pages/Cache.vue +155 -0
  74. package/core/pages/Connection.vue +192 -0
  75. package/core/pages/Connections.vue +102 -0
  76. package/core/pages/Documentation.vue +263 -0
  77. package/core/pages/Notifies.vue +156 -0
  78. package/core/pages/Traffic.vue +152 -0
  79. package/core/pages/connections/connection-header-details.vue +80 -0
  80. package/core/pages/connections/page-connection-default.vue +92 -0
  81. package/core/pages/connections/page-connection.vue +176 -0
  82. package/core/pages/connections/ws-connection.vue +146 -0
  83. package/core/pages/frontend/Bootstrap.vue +1140 -0
  84. package/core/pages/frontend/Components.vue +56 -0
  85. package/core/pages/frontend/ComponentsAdv.vue +203 -0
  86. package/core/pages/frontend/ComponentsBasic.vue +336 -0
  87. package/core/pages/frontend/Theme.vue +473 -0
  88. package/core/pages/frontend/component-view.vue +65 -0
  89. package/core/pages/traffic/WsLogUtils.mjs +91 -0
  90. package/core/pages/traffic/log-ws-exec.vue +124 -0
  91. package/core/pages/traffic/log-ws-exec2.vue +129 -0
  92. package/core/sfc/code-item.vue +169 -0
  93. package/core/sfc/connection-header.vue +62 -0
  94. package/core/sfc/info-api.vue +158 -0
  95. package/core/sfc/md-toc.vue +346 -0
  96. package/core/sfc/scroll-to-top.vue +69 -0
  97. package/core/sfc/task.vue +98 -0
  98. package/core/sfc/text-to-md.vue +25 -0
  99. package/core/sfc/toc-list.vue +175 -0
  100. package/core/ws-client/AuthNState.mjs +84 -0
  101. package/core/ws-client/Connection.mjs +580 -0
  102. package/core/ws-client/Session.mjs +72 -0
  103. package/core/ws-client/WsClient.mjs +230 -0
  104. package/core/ws-client/WsLogUtils.mjs +91 -0
  105. package/core/ws-client/ws-connection.vue +144 -0
  106. package/css/Changa-Medium.ttf +0 -0
  107. package/css/Makefile +10 -0
  108. package/css/README.md +25 -0
  109. package/css/bootstrap-c0ckp1t.css +11861 -0
  110. package/css/bootstrap.min.css +6 -0
  111. package/css/fontawesome/brands.min.css +6 -0
  112. package/css/fontawesome/fontawesome.min.css +8 -0
  113. package/css/fontawesome/regular.min.css +6 -0
  114. package/css/fontawesome/solid.min.css +6 -0
  115. package/css/webfonts/fa-brands-400.woff2 +0 -0
  116. package/css/webfonts/fa-regular-400.woff2 +0 -0
  117. package/css/webfonts/fa-solid-900.woff2 +0 -0
  118. package/docs/Introduction.md +3 -0
  119. package/favicon-192x192.png +0 -0
  120. package/favicon-32x32.png +0 -0
  121. package/favicon-64x64.png +0 -0
  122. package/favicon.ico +0 -0
  123. package/index-cdn.html +66 -0
  124. package/js_ext/Makefile +26 -0
  125. package/js_ext/ace-editor/ace.js +22037 -0
  126. package/js_ext/ace-editor/ext-beautify.js +343 -0
  127. package/js_ext/ace-editor/ext-code_lens.js +204 -0
  128. package/js_ext/ace-editor/ext-command_bar.js +469 -0
  129. package/js_ext/ace-editor/ext-diff.js +4265 -0
  130. package/js_ext/ace-editor/ext-elastic_tabstops_lite.js +238 -0
  131. package/js_ext/ace-editor/ext-emmet.js +1303 -0
  132. package/js_ext/ace-editor/ext-error_marker.js +9 -0
  133. package/js_ext/ace-editor/ext-hardwrap.js +127 -0
  134. package/js_ext/ace-editor/ext-inline_autocomplete.js +3547 -0
  135. package/js_ext/ace-editor/ext-keybinding_menu.js +185 -0
  136. package/js_ext/ace-editor/ext-language_tools.js +2724 -0
  137. package/js_ext/ace-editor/ext-linking.js +66 -0
  138. package/js_ext/ace-editor/ext-modelist.js +276 -0
  139. package/js_ext/ace-editor/ext-options.js +859 -0
  140. package/js_ext/ace-editor/ext-prompt.js +3161 -0
  141. package/js_ext/ace-editor/ext-rtl.js +146 -0
  142. package/js_ext/ace-editor/ext-searchbox.js +385 -0
  143. package/js_ext/ace-editor/ext-settings_menu.js +859 -0
  144. package/js_ext/ace-editor/ext-simple_tokenizer.js +137 -0
  145. package/js_ext/ace-editor/ext-spellcheck.js +79 -0
  146. package/js_ext/ace-editor/ext-split.js +203 -0
  147. package/js_ext/ace-editor/ext-static_highlight.js +194 -0
  148. package/js_ext/ace-editor/ext-statusbar.js +63 -0
  149. package/js_ext/ace-editor/ext-textarea.js +400 -0
  150. package/js_ext/ace-editor/ext-themelist.js +80 -0
  151. package/js_ext/ace-editor/ext-whitespace.js +201 -0
  152. package/js_ext/ace-editor/keybinding-emacs.js +1067 -0
  153. package/js_ext/ace-editor/keybinding-sublime.js +409 -0
  154. package/js_ext/ace-editor/keybinding-vim.js +7101 -0
  155. package/js_ext/ace-editor/keybinding-vscode.js +255 -0
  156. package/js_ext/ace-editor/mode-abap.js +200 -0
  157. package/js_ext/ace-editor/mode-abc.js +243 -0
  158. package/js_ext/ace-editor/mode-actionscript.js +234 -0
  159. package/js_ext/ace-editor/mode-ada.js +108 -0
  160. package/js_ext/ace-editor/mode-alda.js +279 -0
  161. package/js_ext/ace-editor/mode-apache_conf.js +318 -0
  162. package/js_ext/ace-editor/mode-apex.js +402 -0
  163. package/js_ext/ace-editor/mode-applescript.js +232 -0
  164. package/js_ext/ace-editor/mode-aql.js +92 -0
  165. package/js_ext/ace-editor/mode-asciidoc.js +311 -0
  166. package/js_ext/ace-editor/mode-asl.js +357 -0
  167. package/js_ext/ace-editor/mode-assembly_arm32.js +185 -0
  168. package/js_ext/ace-editor/mode-assembly_x86.js +170 -0
  169. package/js_ext/ace-editor/mode-astro.js +2474 -0
  170. package/js_ext/ace-editor/mode-autohotkey.js +208 -0
  171. package/js_ext/ace-editor/mode-basic.js +201 -0
  172. package/js_ext/ace-editor/mode-batchfile.js +199 -0
  173. package/js_ext/ace-editor/mode-bibtex.js +318 -0
  174. package/js_ext/ace-editor/mode-c9search.js +250 -0
  175. package/js_ext/ace-editor/mode-c_cpp.js +417 -0
  176. package/js_ext/ace-editor/mode-cirru.js +192 -0
  177. package/js_ext/ace-editor/mode-clojure.js +322 -0
  178. package/js_ext/ace-editor/mode-clue.js +361 -0
  179. package/js_ext/ace-editor/mode-cobol.js +82 -0
  180. package/js_ext/ace-editor/mode-coffee.js +335 -0
  181. package/js_ext/ace-editor/mode-coldfusion.js +2409 -0
  182. package/js_ext/ace-editor/mode-crystal.js +586 -0
  183. package/js_ext/ace-editor/mode-csharp.js +413 -0
  184. package/js_ext/ace-editor/mode-csound_document.js +4072 -0
  185. package/js_ext/ace-editor/mode-csound_orchestra.js +2923 -0
  186. package/js_ext/ace-editor/mode-csound_score.js +409 -0
  187. package/js_ext/ace-editor/mode-csp.js +59 -0
  188. package/js_ext/ace-editor/mode-css.js +632 -0
  189. package/js_ext/ace-editor/mode-csv.js +97 -0
  190. package/js_ext/ace-editor/mode-curly.js +2381 -0
  191. package/js_ext/ace-editor/mode-cuttlefish.js +56 -0
  192. package/js_ext/ace-editor/mode-d.js +450 -0
  193. package/js_ext/ace-editor/mode-dart.js +618 -0
  194. package/js_ext/ace-editor/mode-diff.js +129 -0
  195. package/js_ext/ace-editor/mode-django.js +2422 -0
  196. package/js_ext/ace-editor/mode-dockerfile.js +427 -0
  197. package/js_ext/ace-editor/mode-dot.js +348 -0
  198. package/js_ext/ace-editor/mode-drools.js +607 -0
  199. package/js_ext/ace-editor/mode-edifact.js +130 -0
  200. package/js_ext/ace-editor/mode-eiffel.js +120 -0
  201. package/js_ext/ace-editor/mode-ejs.js +3277 -0
  202. package/js_ext/ace-editor/mode-elixir.js +443 -0
  203. package/js_ext/ace-editor/mode-elm.js +274 -0
  204. package/js_ext/ace-editor/mode-erlang.js +836 -0
  205. package/js_ext/ace-editor/mode-flix.js +164 -0
  206. package/js_ext/ace-editor/mode-forth.js +253 -0
  207. package/js_ext/ace-editor/mode-fortran.js +361 -0
  208. package/js_ext/ace-editor/mode-fsharp.js +277 -0
  209. package/js_ext/ace-editor/mode-fsl.js +226 -0
  210. package/js_ext/ace-editor/mode-ftl.js +1255 -0
  211. package/js_ext/ace-editor/mode-gcode.js +74 -0
  212. package/js_ext/ace-editor/mode-gherkin.js +154 -0
  213. package/js_ext/ace-editor/mode-gitignore.js +49 -0
  214. package/js_ext/ace-editor/mode-glsl.js +475 -0
  215. package/js_ext/ace-editor/mode-gobstones.js +1459 -0
  216. package/js_ext/ace-editor/mode-golang.js +341 -0
  217. package/js_ext/ace-editor/mode-graphqlschema.js +174 -0
  218. package/js_ext/ace-editor/mode-groovy.js +1401 -0
  219. package/js_ext/ace-editor/mode-haml.js +1906 -0
  220. package/js_ext/ace-editor/mode-handlebars.js +2438 -0
  221. package/js_ext/ace-editor/mode-haskell.js +324 -0
  222. package/js_ext/ace-editor/mode-haskell_cabal.js +135 -0
  223. package/js_ext/ace-editor/mode-haxe.js +313 -0
  224. package/js_ext/ace-editor/mode-hjson.js +318 -0
  225. package/js_ext/ace-editor/mode-html.js +2339 -0
  226. package/js_ext/ace-editor/mode-html_elixir.js +2845 -0
  227. package/js_ext/ace-editor/mode-html_ruby.js +3294 -0
  228. package/js_ext/ace-editor/mode-ini.js +138 -0
  229. package/js_ext/ace-editor/mode-io.js +210 -0
  230. package/js_ext/ace-editor/mode-ion.js +477 -0
  231. package/js_ext/ace-editor/mode-jack.js +293 -0
  232. package/js_ext/ace-editor/mode-jade.js +2017 -0
  233. package/js_ext/ace-editor/mode-java.js +1565 -0
  234. package/js_ext/ace-editor/mode-javascript.js +1191 -0
  235. package/js_ext/ace-editor/mode-jexl.js +270 -0
  236. package/js_ext/ace-editor/mode-json.js +275 -0
  237. package/js_ext/ace-editor/mode-json5.js +308 -0
  238. package/js_ext/ace-editor/mode-jsoniq.js +2577 -0
  239. package/js_ext/ace-editor/mode-jsp.js +1618 -0
  240. package/js_ext/ace-editor/mode-jssm.js +293 -0
  241. package/js_ext/ace-editor/mode-jsx.js +1209 -0
  242. package/js_ext/ace-editor/mode-julia.js +254 -0
  243. package/js_ext/ace-editor/mode-kotlin.js +445 -0
  244. package/js_ext/ace-editor/mode-latex.js +252 -0
  245. package/js_ext/ace-editor/mode-latte.js +2522 -0
  246. package/js_ext/ace-editor/mode-less.js +742 -0
  247. package/js_ext/ace-editor/mode-liquid.js +2741 -0
  248. package/js_ext/ace-editor/mode-lisp.js +104 -0
  249. package/js_ext/ace-editor/mode-livescript.js +272 -0
  250. package/js_ext/ace-editor/mode-logiql.js +272 -0
  251. package/js_ext/ace-editor/mode-logtalk.js +309 -0
  252. package/js_ext/ace-editor/mode-lsl.js +287 -0
  253. package/js_ext/ace-editor/mode-lua.js +393 -0
  254. package/js_ext/ace-editor/mode-luapage.js +2785 -0
  255. package/js_ext/ace-editor/mode-lucene.js +145 -0
  256. package/js_ext/ace-editor/mode-makefile.js +374 -0
  257. package/js_ext/ace-editor/mode-markdown.js +2935 -0
  258. package/js_ext/ace-editor/mode-mask.js +1757 -0
  259. package/js_ext/ace-editor/mode-matlab.js +239 -0
  260. package/js_ext/ace-editor/mode-maze.js +256 -0
  261. package/js_ext/ace-editor/mode-mediawiki.js +580 -0
  262. package/js_ext/ace-editor/mode-mel.js +213 -0
  263. package/js_ext/ace-editor/mode-mips.js +231 -0
  264. package/js_ext/ace-editor/mode-mixal.js +110 -0
  265. package/js_ext/ace-editor/mode-mushcode.js +642 -0
  266. package/js_ext/ace-editor/mode-mysql.js +150 -0
  267. package/js_ext/ace-editor/mode-nasal.js +513 -0
  268. package/js_ext/ace-editor/mode-nginx.js +262 -0
  269. package/js_ext/ace-editor/mode-nim.js +325 -0
  270. package/js_ext/ace-editor/mode-nix.js +555 -0
  271. package/js_ext/ace-editor/mode-nsis.js +279 -0
  272. package/js_ext/ace-editor/mode-nunjucks.js +2677 -0
  273. package/js_ext/ace-editor/mode-objectivec.js +626 -0
  274. package/js_ext/ace-editor/mode-ocaml.js +378 -0
  275. package/js_ext/ace-editor/mode-odin.js +449 -0
  276. package/js_ext/ace-editor/mode-partiql.js +750 -0
  277. package/js_ext/ace-editor/mode-pascal.js +204 -0
  278. package/js_ext/ace-editor/mode-perl.js +318 -0
  279. package/js_ext/ace-editor/mode-pgsql.js +1860 -0
  280. package/js_ext/ace-editor/mode-php.js +14072 -0
  281. package/js_ext/ace-editor/mode-php_laravel_blade.js +14260 -0
  282. package/js_ext/ace-editor/mode-pig.js +278 -0
  283. package/js_ext/ace-editor/mode-plain_text.js +27 -0
  284. package/js_ext/ace-editor/mode-plsql.js +268 -0
  285. package/js_ext/ace-editor/mode-powershell.js +567 -0
  286. package/js_ext/ace-editor/mode-praat.js +412 -0
  287. package/js_ext/ace-editor/mode-prisma.js +457 -0
  288. package/js_ext/ace-editor/mode-prolog.js +305 -0
  289. package/js_ext/ace-editor/mode-properties.js +69 -0
  290. package/js_ext/ace-editor/mode-protobuf.js +498 -0
  291. package/js_ext/ace-editor/mode-prql.js +323 -0
  292. package/js_ext/ace-editor/mode-puppet.js +316 -0
  293. package/js_ext/ace-editor/mode-python.js +476 -0
  294. package/js_ext/ace-editor/mode-qml.js +346 -0
  295. package/js_ext/ace-editor/mode-r.js +387 -0
  296. package/js_ext/ace-editor/mode-raku.js +516 -0
  297. package/js_ext/ace-editor/mode-razor.js +2697 -0
  298. package/js_ext/ace-editor/mode-rdoc.js +286 -0
  299. package/js_ext/ace-editor/mode-red.js +388 -0
  300. package/js_ext/ace-editor/mode-redshift.js +321 -0
  301. package/js_ext/ace-editor/mode-rhtml.js +2750 -0
  302. package/js_ext/ace-editor/mode-robot.js +168 -0
  303. package/js_ext/ace-editor/mode-rst.js +245 -0
  304. package/js_ext/ace-editor/mode-ruby.js +921 -0
  305. package/js_ext/ace-editor/mode-rust.js +393 -0
  306. package/js_ext/ace-editor/mode-sac.js +349 -0
  307. package/js_ext/ace-editor/mode-sass.js +480 -0
  308. package/js_ext/ace-editor/mode-scad.js +350 -0
  309. package/js_ext/ace-editor/mode-scala.js +1395 -0
  310. package/js_ext/ace-editor/mode-scheme.js +210 -0
  311. package/js_ext/ace-editor/mode-scrypt.js +317 -0
  312. package/js_ext/ace-editor/mode-scss.js +768 -0
  313. package/js_ext/ace-editor/mode-sh.js +387 -0
  314. package/js_ext/ace-editor/mode-sjs.js +1393 -0
  315. package/js_ext/ace-editor/mode-slim.js +4770 -0
  316. package/js_ext/ace-editor/mode-smarty.js +2436 -0
  317. package/js_ext/ace-editor/mode-smithy.js +456 -0
  318. package/js_ext/ace-editor/mode-snippets.js +183 -0
  319. package/js_ext/ace-editor/mode-soy_template.js +2611 -0
  320. package/js_ext/ace-editor/mode-space.js +151 -0
  321. package/js_ext/ace-editor/mode-sparql.js +288 -0
  322. package/js_ext/ace-editor/mode-sql.js +221 -0
  323. package/js_ext/ace-editor/mode-sqlserver.js +391 -0
  324. package/js_ext/ace-editor/mode-stylus.js +443 -0
  325. package/js_ext/ace-editor/mode-svg.js +1487 -0
  326. package/js_ext/ace-editor/mode-swift.js +342 -0
  327. package/js_ext/ace-editor/mode-tcl.js +338 -0
  328. package/js_ext/ace-editor/mode-terraform.js +346 -0
  329. package/js_ext/ace-editor/mode-tex.js +212 -0
  330. package/js_ext/ace-editor/mode-text.js +9 -0
  331. package/js_ext/ace-editor/mode-textile.js +125 -0
  332. package/js_ext/ace-editor/mode-toml.js +129 -0
  333. package/js_ext/ace-editor/mode-tsv.js +124 -0
  334. package/js_ext/ace-editor/mode-tsx.js +1276 -0
  335. package/js_ext/ace-editor/mode-turtle.js +264 -0
  336. package/js_ext/ace-editor/mode-twig.js +2502 -0
  337. package/js_ext/ace-editor/mode-typescript.js +1254 -0
  338. package/js_ext/ace-editor/mode-vala.js +554 -0
  339. package/js_ext/ace-editor/mode-vbscript.js +731 -0
  340. package/js_ext/ace-editor/mode-velocity.js +2580 -0
  341. package/js_ext/ace-editor/mode-verilog.js +98 -0
  342. package/js_ext/ace-editor/mode-vhdl.js +94 -0
  343. package/js_ext/ace-editor/mode-visualforce.js +2454 -0
  344. package/js_ext/ace-editor/mode-vue.js +3834 -0
  345. package/js_ext/ace-editor/mode-wollok.js +1329 -0
  346. package/js_ext/ace-editor/mode-xml.js +477 -0
  347. package/js_ext/ace-editor/mode-xquery.js +2589 -0
  348. package/js_ext/ace-editor/mode-yaml.js +395 -0
  349. package/js_ext/ace-editor/mode-zeek.js +502 -0
  350. package/js_ext/ace-editor/mode-zig.js +585 -0
  351. package/js_ext/ace-editor/snippets/abap.js +9 -0
  352. package/js_ext/ace-editor/snippets/abc.js +16 -0
  353. package/js_ext/ace-editor/snippets/actionscript.js +16 -0
  354. package/js_ext/ace-editor/snippets/ada.js +9 -0
  355. package/js_ext/ace-editor/snippets/alda.js +9 -0
  356. package/js_ext/ace-editor/snippets/apache_conf.js +9 -0
  357. package/js_ext/ace-editor/snippets/apex.js +9 -0
  358. package/js_ext/ace-editor/snippets/applescript.js +9 -0
  359. package/js_ext/ace-editor/snippets/aql.js +9 -0
  360. package/js_ext/ace-editor/snippets/asciidoc.js +9 -0
  361. package/js_ext/ace-editor/snippets/asl.js +9 -0
  362. package/js_ext/ace-editor/snippets/assembly_arm32.js +9 -0
  363. package/js_ext/ace-editor/snippets/assembly_x86.js +9 -0
  364. package/js_ext/ace-editor/snippets/astro.js +9 -0
  365. package/js_ext/ace-editor/snippets/autohotkey.js +9 -0
  366. package/js_ext/ace-editor/snippets/basic.js +9 -0
  367. package/js_ext/ace-editor/snippets/batchfile.js +9 -0
  368. package/js_ext/ace-editor/snippets/bibtex.js +9 -0
  369. package/js_ext/ace-editor/snippets/c9search.js +9 -0
  370. package/js_ext/ace-editor/snippets/c_cpp.js +16 -0
  371. package/js_ext/ace-editor/snippets/cirru.js +9 -0
  372. package/js_ext/ace-editor/snippets/clojure.js +16 -0
  373. package/js_ext/ace-editor/snippets/clue.js +9 -0
  374. package/js_ext/ace-editor/snippets/cobol.js +9 -0
  375. package/js_ext/ace-editor/snippets/coffee.js +16 -0
  376. package/js_ext/ace-editor/snippets/coldfusion.js +9 -0
  377. package/js_ext/ace-editor/snippets/crystal.js +9 -0
  378. package/js_ext/ace-editor/snippets/csharp.js +9 -0
  379. package/js_ext/ace-editor/snippets/csound_document.js +16 -0
  380. package/js_ext/ace-editor/snippets/csound_orchestra.js +16 -0
  381. package/js_ext/ace-editor/snippets/csound_score.js +9 -0
  382. package/js_ext/ace-editor/snippets/csp.js +9 -0
  383. package/js_ext/ace-editor/snippets/css.js +16 -0
  384. package/js_ext/ace-editor/snippets/csv.js +9 -0
  385. package/js_ext/ace-editor/snippets/curly.js +9 -0
  386. package/js_ext/ace-editor/snippets/cuttlefish.js +9 -0
  387. package/js_ext/ace-editor/snippets/d.js +9 -0
  388. package/js_ext/ace-editor/snippets/dart.js +16 -0
  389. package/js_ext/ace-editor/snippets/diff.js +16 -0
  390. package/js_ext/ace-editor/snippets/django.js +16 -0
  391. package/js_ext/ace-editor/snippets/dockerfile.js +9 -0
  392. package/js_ext/ace-editor/snippets/dot.js +9 -0
  393. package/js_ext/ace-editor/snippets/drools.js +16 -0
  394. package/js_ext/ace-editor/snippets/edifact.js +16 -0
  395. package/js_ext/ace-editor/snippets/eiffel.js +9 -0
  396. package/js_ext/ace-editor/snippets/ejs.js +9 -0
  397. package/js_ext/ace-editor/snippets/elixir.js +9 -0
  398. package/js_ext/ace-editor/snippets/elm.js +9 -0
  399. package/js_ext/ace-editor/snippets/erlang.js +16 -0
  400. package/js_ext/ace-editor/snippets/flix.js +9 -0
  401. package/js_ext/ace-editor/snippets/forth.js +9 -0
  402. package/js_ext/ace-editor/snippets/fortran.js +9 -0
  403. package/js_ext/ace-editor/snippets/fsharp.js +9 -0
  404. package/js_ext/ace-editor/snippets/fsl.js +16 -0
  405. package/js_ext/ace-editor/snippets/ftl.js +9 -0
  406. package/js_ext/ace-editor/snippets/gcode.js +9 -0
  407. package/js_ext/ace-editor/snippets/gherkin.js +9 -0
  408. package/js_ext/ace-editor/snippets/gitignore.js +9 -0
  409. package/js_ext/ace-editor/snippets/glsl.js +9 -0
  410. package/js_ext/ace-editor/snippets/gobstones.js +16 -0
  411. package/js_ext/ace-editor/snippets/golang.js +9 -0
  412. package/js_ext/ace-editor/snippets/graphqlschema.js +16 -0
  413. package/js_ext/ace-editor/snippets/groovy.js +9 -0
  414. package/js_ext/ace-editor/snippets/haml.js +16 -0
  415. package/js_ext/ace-editor/snippets/handlebars.js +9 -0
  416. package/js_ext/ace-editor/snippets/haskell.js +16 -0
  417. package/js_ext/ace-editor/snippets/haskell_cabal.js +9 -0
  418. package/js_ext/ace-editor/snippets/haxe.js +9 -0
  419. package/js_ext/ace-editor/snippets/hjson.js +9 -0
  420. package/js_ext/ace-editor/snippets/html.js +16 -0
  421. package/js_ext/ace-editor/snippets/html_elixir.js +9 -0
  422. package/js_ext/ace-editor/snippets/html_ruby.js +9 -0
  423. package/js_ext/ace-editor/snippets/ini.js +9 -0
  424. package/js_ext/ace-editor/snippets/io.js +74 -0
  425. package/js_ext/ace-editor/snippets/ion.js +9 -0
  426. package/js_ext/ace-editor/snippets/jack.js +9 -0
  427. package/js_ext/ace-editor/snippets/jade.js +9 -0
  428. package/js_ext/ace-editor/snippets/java.js +16 -0
  429. package/js_ext/ace-editor/snippets/javascript.js +16 -0
  430. package/js_ext/ace-editor/snippets/jexl.js +9 -0
  431. package/js_ext/ace-editor/snippets/json.js +9 -0
  432. package/js_ext/ace-editor/snippets/json5.js +9 -0
  433. package/js_ext/ace-editor/snippets/jsoniq.js +78 -0
  434. package/js_ext/ace-editor/snippets/jsp.js +16 -0
  435. package/js_ext/ace-editor/snippets/jssm.js +9 -0
  436. package/js_ext/ace-editor/snippets/jsx.js +9 -0
  437. package/js_ext/ace-editor/snippets/julia.js +9 -0
  438. package/js_ext/ace-editor/snippets/kotlin.js +9 -0
  439. package/js_ext/ace-editor/snippets/latex.js +9 -0
  440. package/js_ext/ace-editor/snippets/latte.js +9 -0
  441. package/js_ext/ace-editor/snippets/less.js +9 -0
  442. package/js_ext/ace-editor/snippets/liquid.js +16 -0
  443. package/js_ext/ace-editor/snippets/lisp.js +9 -0
  444. package/js_ext/ace-editor/snippets/livescript.js +9 -0
  445. package/js_ext/ace-editor/snippets/logiql.js +9 -0
  446. package/js_ext/ace-editor/snippets/logtalk.js +9 -0
  447. package/js_ext/ace-editor/snippets/lsl.js +16 -0
  448. package/js_ext/ace-editor/snippets/lua.js +16 -0
  449. package/js_ext/ace-editor/snippets/luapage.js +9 -0
  450. package/js_ext/ace-editor/snippets/lucene.js +9 -0
  451. package/js_ext/ace-editor/snippets/makefile.js +16 -0
  452. package/js_ext/ace-editor/snippets/markdown.js +16 -0
  453. package/js_ext/ace-editor/snippets/mask.js +9 -0
  454. package/js_ext/ace-editor/snippets/matlab.js +9 -0
  455. package/js_ext/ace-editor/snippets/maze.js +16 -0
  456. package/js_ext/ace-editor/snippets/mediawiki.js +9 -0
  457. package/js_ext/ace-editor/snippets/mel.js +9 -0
  458. package/js_ext/ace-editor/snippets/mips.js +9 -0
  459. package/js_ext/ace-editor/snippets/mixal.js +9 -0
  460. package/js_ext/ace-editor/snippets/mushcode.js +9 -0
  461. package/js_ext/ace-editor/snippets/mysql.js +9 -0
  462. package/js_ext/ace-editor/snippets/nasal.js +9 -0
  463. package/js_ext/ace-editor/snippets/nginx.js +9 -0
  464. package/js_ext/ace-editor/snippets/nim.js +9 -0
  465. package/js_ext/ace-editor/snippets/nix.js +9 -0
  466. package/js_ext/ace-editor/snippets/nsis.js +9 -0
  467. package/js_ext/ace-editor/snippets/nunjucks.js +9 -0
  468. package/js_ext/ace-editor/snippets/objectivec.js +9 -0
  469. package/js_ext/ace-editor/snippets/ocaml.js +9 -0
  470. package/js_ext/ace-editor/snippets/odin.js +9 -0
  471. package/js_ext/ace-editor/snippets/partiql.js +9 -0
  472. package/js_ext/ace-editor/snippets/pascal.js +9 -0
  473. package/js_ext/ace-editor/snippets/perl.js +16 -0
  474. package/js_ext/ace-editor/snippets/pgsql.js +9 -0
  475. package/js_ext/ace-editor/snippets/php.js +16 -0
  476. package/js_ext/ace-editor/snippets/php_laravel_blade.js +9 -0
  477. package/js_ext/ace-editor/snippets/pig.js +9 -0
  478. package/js_ext/ace-editor/snippets/plain_text.js +9 -0
  479. package/js_ext/ace-editor/snippets/plsql.js +9 -0
  480. package/js_ext/ace-editor/snippets/powershell.js +9 -0
  481. package/js_ext/ace-editor/snippets/praat.js +9 -0
  482. package/js_ext/ace-editor/snippets/prisma.js +9 -0
  483. package/js_ext/ace-editor/snippets/prolog.js +9 -0
  484. package/js_ext/ace-editor/snippets/properties.js +9 -0
  485. package/js_ext/ace-editor/snippets/protobuf.js +9 -0
  486. package/js_ext/ace-editor/snippets/prql.js +9 -0
  487. package/js_ext/ace-editor/snippets/puppet.js +9 -0
  488. package/js_ext/ace-editor/snippets/python.js +16 -0
  489. package/js_ext/ace-editor/snippets/qml.js +9 -0
  490. package/js_ext/ace-editor/snippets/r.js +16 -0
  491. package/js_ext/ace-editor/snippets/raku.js +9 -0
  492. package/js_ext/ace-editor/snippets/razor.js +16 -0
  493. package/js_ext/ace-editor/snippets/rdoc.js +9 -0
  494. package/js_ext/ace-editor/snippets/red.js +9 -0
  495. package/js_ext/ace-editor/snippets/redshift.js +9 -0
  496. package/js_ext/ace-editor/snippets/rhtml.js +9 -0
  497. package/js_ext/ace-editor/snippets/robot.js +16 -0
  498. package/js_ext/ace-editor/snippets/rst.js +16 -0
  499. package/js_ext/ace-editor/snippets/ruby.js +16 -0
  500. package/js_ext/ace-editor/snippets/rust.js +9 -0
  501. package/js_ext/ace-editor/snippets/sac.js +9 -0
  502. package/js_ext/ace-editor/snippets/sass.js +9 -0
  503. package/js_ext/ace-editor/snippets/scad.js +9 -0
  504. package/js_ext/ace-editor/snippets/scala.js +9 -0
  505. package/js_ext/ace-editor/snippets/scheme.js +9 -0
  506. package/js_ext/ace-editor/snippets/scrypt.js +9 -0
  507. package/js_ext/ace-editor/snippets/scss.js +9 -0
  508. package/js_ext/ace-editor/snippets/sh.js +16 -0
  509. package/js_ext/ace-editor/snippets/sjs.js +9 -0
  510. package/js_ext/ace-editor/snippets/slim.js +9 -0
  511. package/js_ext/ace-editor/snippets/smarty.js +9 -0
  512. package/js_ext/ace-editor/snippets/smithy.js +9 -0
  513. package/js_ext/ace-editor/snippets/snippets.js +16 -0
  514. package/js_ext/ace-editor/snippets/soy_template.js +9 -0
  515. package/js_ext/ace-editor/snippets/space.js +9 -0
  516. package/js_ext/ace-editor/snippets/sparql.js +9 -0
  517. package/js_ext/ace-editor/snippets/sql.js +16 -0
  518. package/js_ext/ace-editor/snippets/sqlserver.js +16 -0
  519. package/js_ext/ace-editor/snippets/stylus.js +9 -0
  520. package/js_ext/ace-editor/snippets/svg.js +9 -0
  521. package/js_ext/ace-editor/snippets/swift.js +9 -0
  522. package/js_ext/ace-editor/snippets/tcl.js +16 -0
  523. package/js_ext/ace-editor/snippets/terraform.js +9 -0
  524. package/js_ext/ace-editor/snippets/tex.js +16 -0
  525. package/js_ext/ace-editor/snippets/text.js +9 -0
  526. package/js_ext/ace-editor/snippets/textile.js +16 -0
  527. package/js_ext/ace-editor/snippets/toml.js +9 -0
  528. package/js_ext/ace-editor/snippets/tsv.js +9 -0
  529. package/js_ext/ace-editor/snippets/tsx.js +9 -0
  530. package/js_ext/ace-editor/snippets/turtle.js +9 -0
  531. package/js_ext/ace-editor/snippets/twig.js +9 -0
  532. package/js_ext/ace-editor/snippets/typescript.js +9 -0
  533. package/js_ext/ace-editor/snippets/vala.js +199 -0
  534. package/js_ext/ace-editor/snippets/vbscript.js +9 -0
  535. package/js_ext/ace-editor/snippets/velocity.js +17 -0
  536. package/js_ext/ace-editor/snippets/verilog.js +9 -0
  537. package/js_ext/ace-editor/snippets/vhdl.js +9 -0
  538. package/js_ext/ace-editor/snippets/visualforce.js +9 -0
  539. package/js_ext/ace-editor/snippets/vue.js +9 -0
  540. package/js_ext/ace-editor/snippets/wollok.js +16 -0
  541. package/js_ext/ace-editor/snippets/xml.js +9 -0
  542. package/js_ext/ace-editor/snippets/xquery.js +78 -0
  543. package/js_ext/ace-editor/snippets/yaml.js +9 -0
  544. package/js_ext/ace-editor/snippets/zeek.js +9 -0
  545. package/js_ext/ace-editor/snippets/zig.js +9 -0
  546. package/js_ext/ace-editor/theme-ambiance.js +18 -0
  547. package/js_ext/ace-editor/theme-chaos.js +18 -0
  548. package/js_ext/ace-editor/theme-chrome.js +18 -0
  549. package/js_ext/ace-editor/theme-cloud9_day.js +19 -0
  550. package/js_ext/ace-editor/theme-cloud9_night.js +18 -0
  551. package/js_ext/ace-editor/theme-cloud9_night_low_color.js +18 -0
  552. package/js_ext/ace-editor/theme-cloud_editor.js +19 -0
  553. package/js_ext/ace-editor/theme-cloud_editor_dark.js +19 -0
  554. package/js_ext/ace-editor/theme-clouds.js +18 -0
  555. package/js_ext/ace-editor/theme-clouds_midnight.js +18 -0
  556. package/js_ext/ace-editor/theme-cobalt.js +18 -0
  557. package/js_ext/ace-editor/theme-crimson_editor.js +18 -0
  558. package/js_ext/ace-editor/theme-dawn.js +18 -0
  559. package/js_ext/ace-editor/theme-dracula.js +19 -0
  560. package/js_ext/ace-editor/theme-dreamweaver.js +18 -0
  561. package/js_ext/ace-editor/theme-eclipse.js +19 -0
  562. package/js_ext/ace-editor/theme-github.js +18 -0
  563. package/js_ext/ace-editor/theme-github_dark.js +18 -0
  564. package/js_ext/ace-editor/theme-github_light_default.js +18 -0
  565. package/js_ext/ace-editor/theme-gob.js +18 -0
  566. package/js_ext/ace-editor/theme-gruvbox.js +18 -0
  567. package/js_ext/ace-editor/theme-gruvbox_dark_hard.js +18 -0
  568. package/js_ext/ace-editor/theme-gruvbox_light_hard.js +18 -0
  569. package/js_ext/ace-editor/theme-idle_fingers.js +18 -0
  570. package/js_ext/ace-editor/theme-iplastic.js +18 -0
  571. package/js_ext/ace-editor/theme-katzenmilch.js +18 -0
  572. package/js_ext/ace-editor/theme-kr_theme.js +18 -0
  573. package/js_ext/ace-editor/theme-kuroir.js +18 -0
  574. package/js_ext/ace-editor/theme-merbivore.js +18 -0
  575. package/js_ext/ace-editor/theme-merbivore_soft.js +18 -0
  576. package/js_ext/ace-editor/theme-mono_industrial.js +18 -0
  577. package/js_ext/ace-editor/theme-monokai.js +18 -0
  578. package/js_ext/ace-editor/theme-nord_dark.js +19 -0
  579. package/js_ext/ace-editor/theme-one_dark.js +18 -0
  580. package/js_ext/ace-editor/theme-pastel_on_dark.js +18 -0
  581. package/js_ext/ace-editor/theme-solarized_dark.js +18 -0
  582. package/js_ext/ace-editor/theme-solarized_light.js +18 -0
  583. package/js_ext/ace-editor/theme-sqlserver.js +18 -0
  584. package/js_ext/ace-editor/theme-terminal.js +18 -0
  585. package/js_ext/ace-editor/theme-textmate.js +16 -0
  586. package/js_ext/ace-editor/theme-tomorrow.js +18 -0
  587. package/js_ext/ace-editor/theme-tomorrow_night.js +18 -0
  588. package/js_ext/ace-editor/theme-tomorrow_night_blue.js +18 -0
  589. package/js_ext/ace-editor/theme-tomorrow_night_bright.js +18 -0
  590. package/js_ext/ace-editor/theme-tomorrow_night_eighties.js +18 -0
  591. package/js_ext/ace-editor/theme-twilight.js +18 -0
  592. package/js_ext/ace-editor/theme-vibrant_ink.js +18 -0
  593. package/js_ext/ace-editor/theme-xcode.js +18 -0
  594. package/js_ext/ace-editor/worker-base.js +1332 -0
  595. package/js_ext/ace-editor/worker-coffee.js +1381 -0
  596. package/js_ext/ace-editor/worker-css.js +8913 -0
  597. package/js_ext/ace-editor/worker-html.js +10843 -0
  598. package/js_ext/ace-editor/worker-javascript.js +15353 -0
  599. package/js_ext/ace-editor/worker-json.js +1626 -0
  600. package/js_ext/ace-editor/worker-lua.js +3519 -0
  601. package/js_ext/ace-editor/worker-php.js +3788 -0
  602. package/js_ext/ace-editor/worker-xml.js +3122 -0
  603. package/js_ext/ace-editor/worker-xquery.js +57579 -0
  604. package/js_ext/ace-editor/worker-yaml.js +5819 -0
  605. package/js_ext/bootstrap.bundle.min.js +7 -0
  606. package/js_ext/highlight/default.min.css +9 -0
  607. package/js_ext/highlight/go.min.js +14 -0
  608. package/js_ext/highlight/highlight.min.js +1207 -0
  609. package/js_ext/highlight/stackoverflow-dark.min.css +13 -0
  610. package/js_ext/idb-keyval-6.2.2.mjs +7 -0
  611. package/js_ext/json-viewer.bundle.js +52 -0
  612. package/js_ext/loglevel-plugin-prefix.min.js +1 -0
  613. package/js_ext/loglevel.min.js +2 -0
  614. package/js_ext/markdown/auto-render.min.js +1 -0
  615. package/js_ext/markdown/auto-render.mjs +245 -0
  616. package/js_ext/markdown/fonts/KaTeX_AMS-Regular.woff +0 -0
  617. package/js_ext/markdown/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  618. package/js_ext/markdown/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  619. package/js_ext/markdown/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  620. package/js_ext/markdown/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  621. package/js_ext/markdown/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  622. package/js_ext/markdown/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  623. package/js_ext/markdown/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  624. package/js_ext/markdown/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  625. package/js_ext/markdown/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  626. package/js_ext/markdown/fonts/KaTeX_Main-Bold.woff +0 -0
  627. package/js_ext/markdown/fonts/KaTeX_Main-Bold.woff2 +0 -0
  628. package/js_ext/markdown/fonts/KaTeX_Main-Italic.woff +0 -0
  629. package/js_ext/markdown/fonts/KaTeX_Main-Italic.woff2 +0 -0
  630. package/js_ext/markdown/fonts/KaTeX_Main-Regular.woff +0 -0
  631. package/js_ext/markdown/fonts/KaTeX_Main-Regular.woff2 +0 -0
  632. package/js_ext/markdown/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  633. package/js_ext/markdown/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  634. package/js_ext/markdown/fonts/KaTeX_Math-Italic.woff +0 -0
  635. package/js_ext/markdown/fonts/KaTeX_Math-Italic.woff2 +0 -0
  636. package/js_ext/markdown/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  637. package/js_ext/markdown/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  638. package/js_ext/markdown/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  639. package/js_ext/markdown/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  640. package/js_ext/markdown/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  641. package/js_ext/markdown/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  642. package/js_ext/markdown/fonts/KaTeX_Script-Regular.ttf +0 -0
  643. package/js_ext/markdown/fonts/KaTeX_Script-Regular.woff +0 -0
  644. package/js_ext/markdown/fonts/KaTeX_Script-Regular.woff2 +0 -0
  645. package/js_ext/markdown/fonts/KaTeX_Size1-Regular.ttf +0 -0
  646. package/js_ext/markdown/fonts/KaTeX_Size1-Regular.woff +0 -0
  647. package/js_ext/markdown/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  648. package/js_ext/markdown/fonts/KaTeX_Size2-Regular.woff +0 -0
  649. package/js_ext/markdown/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  650. package/js_ext/markdown/fonts/KaTeX_Size3-Regular.woff +0 -0
  651. package/js_ext/markdown/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  652. package/js_ext/markdown/fonts/KaTeX_Size4-Regular.ttf +0 -0
  653. package/js_ext/markdown/fonts/KaTeX_Size4-Regular.woff +0 -0
  654. package/js_ext/markdown/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  655. package/js_ext/markdown/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  656. package/js_ext/markdown/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  657. package/js_ext/markdown/katex.min.css +1 -0
  658. package/js_ext/markdown/katex.min.js +1 -0
  659. package/js_ext/markdown/katex.mjs +18416 -0
  660. package/js_ext/markdown/markdown-it.min.js +3 -0
  661. package/js_ext/markdown/markdownItAnchor.umd.js +2 -0
  662. package/js_ext/mitt.mjs +2 -0
  663. package/js_ext/moment.min.js +1 -0
  664. package/js_ext/msgpack.mjs +1612 -0
  665. package/js_ext/rxjs.umd.min.js +195 -0
  666. package/js_ext/rxjs.umd.min.js.map +1 -0
  667. package/js_ext/vue-router.esm-browser.prod.js +6 -0
  668. package/js_ext/vue.esm-browser.min.js +18 -0
  669. package/js_ext/vue.esm-browser.prod.min.js +3 -0
  670. package/js_ext/vue3-sfc-loader.esm.js +1840 -0
  671. package/js_ext/vue3-sfc-loader.esm.js.map +4 -0
  672. package/js_ext/vue3-sfc-loader.js +1839 -0
  673. package/js_ext/wavesurfer.esm.mjs +1 -0
  674. package/js_ext/xstate.web.mjs +15 -0
  675. package/package.json +50 -0
  676. package/style.css +31 -0
@@ -0,0 +1,3547 @@
1
+ ace.define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module){"use strict";
2
+ var dom = require("./lib/dom");
3
+ var oop = require("./lib/oop");
4
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
5
+ var lang = require("./lib/lang");
6
+ var Range = require("./range").Range;
7
+ var RangeList = require("./range_list").RangeList;
8
+ var HashHandler = require("./keyboard/hash_handler").HashHandler;
9
+ var Tokenizer = require("./tokenizer").Tokenizer;
10
+ var clipboard = require("./clipboard");
11
+ var VARIABLES = {
12
+ CURRENT_WORD: function (editor) {
13
+ return editor.session.getTextRange(editor.session.getWordRange());
14
+ },
15
+ SELECTION: function (editor, name, indentation) {
16
+ var text = editor.session.getTextRange();
17
+ if (indentation)
18
+ return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1");
19
+ return text;
20
+ },
21
+ CURRENT_LINE: function (editor) {
22
+ return editor.session.getLine(editor.getCursorPosition().row);
23
+ },
24
+ PREV_LINE: function (editor) {
25
+ return editor.session.getLine(editor.getCursorPosition().row - 1);
26
+ },
27
+ LINE_INDEX: function (editor) {
28
+ return editor.getCursorPosition().row;
29
+ },
30
+ LINE_NUMBER: function (editor) {
31
+ return editor.getCursorPosition().row + 1;
32
+ },
33
+ SOFT_TABS: function (editor) {
34
+ return editor.session.getUseSoftTabs() ? "YES" : "NO";
35
+ },
36
+ TAB_SIZE: function (editor) {
37
+ return editor.session.getTabSize();
38
+ },
39
+ CLIPBOARD: function (editor) {
40
+ return clipboard.getText && clipboard.getText();
41
+ },
42
+ FILENAME: function (editor) {
43
+ return /[^/\\]*$/.exec(this.FILEPATH(editor))[0];
44
+ },
45
+ FILENAME_BASE: function (editor) {
46
+ return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, "");
47
+ },
48
+ DIRECTORY: function (editor) {
49
+ return this.FILEPATH(editor).replace(/[^/\\]*$/, "");
50
+ },
51
+ FILEPATH: function (editor) { return "/not implemented.txt"; },
52
+ WORKSPACE_NAME: function () { return "Unknown"; },
53
+ FULLNAME: function () { return "Unknown"; },
54
+ BLOCK_COMMENT_START: function (editor) {
55
+ var mode = editor.session.$mode || {};
56
+ return mode.blockComment && mode.blockComment.start || "";
57
+ },
58
+ BLOCK_COMMENT_END: function (editor) {
59
+ var mode = editor.session.$mode || {};
60
+ return mode.blockComment && mode.blockComment.end || "";
61
+ },
62
+ LINE_COMMENT: function (editor) {
63
+ var mode = editor.session.$mode || {};
64
+ return mode.lineCommentStart || "";
65
+ },
66
+ CURRENT_YEAR: date.bind(null, { year: "numeric" }),
67
+ CURRENT_YEAR_SHORT: date.bind(null, { year: "2-digit" }),
68
+ CURRENT_MONTH: date.bind(null, { month: "numeric" }),
69
+ CURRENT_MONTH_NAME: date.bind(null, { month: "long" }),
70
+ CURRENT_MONTH_NAME_SHORT: date.bind(null, { month: "short" }),
71
+ CURRENT_DATE: date.bind(null, { day: "2-digit" }),
72
+ CURRENT_DAY_NAME: date.bind(null, { weekday: "long" }),
73
+ CURRENT_DAY_NAME_SHORT: date.bind(null, { weekday: "short" }),
74
+ CURRENT_HOUR: date.bind(null, { hour: "2-digit", hour12: false }),
75
+ CURRENT_MINUTE: date.bind(null, { minute: "2-digit" }),
76
+ CURRENT_SECOND: date.bind(null, { second: "2-digit" })
77
+ };
78
+ VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION;
79
+ function date(dateFormat) {
80
+ var str = new Date().toLocaleString("en-us", dateFormat);
81
+ return str.length == 1 ? "0" + str : str;
82
+ }
83
+ var SnippetManager = /** @class */ (function () {
84
+ function SnippetManager() {
85
+ this.snippetMap = {};
86
+ this.snippetNameMap = {};
87
+ this.variables = VARIABLES;
88
+ }
89
+ SnippetManager.prototype.getTokenizer = function () {
90
+ return SnippetManager["$tokenizer"] || this.createTokenizer();
91
+ };
92
+ SnippetManager.prototype.createTokenizer = function () {
93
+ function TabstopToken(str) {
94
+ str = str.substr(1);
95
+ if (/^\d+$/.test(str))
96
+ return [{ tabstopId: parseInt(str, 10) }];
97
+ return [{ text: str }];
98
+ }
99
+ function escape(ch) {
100
+ return "(?:[^\\\\" + ch + "]|\\\\.)";
101
+ }
102
+ var formatMatcher = {
103
+ regex: "/(" + escape("/") + "+)/",
104
+ onMatch: function (val, state, stack) {
105
+ var ts = stack[0];
106
+ ts.fmtString = true;
107
+ ts.guard = val.slice(1, -1);
108
+ ts.flag = "";
109
+ return "";
110
+ },
111
+ next: "formatString"
112
+ };
113
+ SnippetManager["$tokenizer"] = new Tokenizer({
114
+ start: [
115
+ { regex: /\\./, onMatch: function (val, state, stack) {
116
+ var ch = val[1];
117
+ if (ch == "}" && stack.length) {
118
+ val = ch;
119
+ }
120
+ else if ("`$\\".indexOf(ch) != -1) {
121
+ val = ch;
122
+ }
123
+ return [val];
124
+ } },
125
+ { regex: /}/, onMatch: function (val, state, stack) {
126
+ return [stack.length ? stack.shift() : val];
127
+ } },
128
+ { regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken },
129
+ { regex: /\$\{[\dA-Z_a-z]+/, onMatch: function (str, state, stack) {
130
+ var t = TabstopToken(str.substr(1));
131
+ stack.unshift(t[0]);
132
+ return t;
133
+ }, next: "snippetVar" },
134
+ { regex: /\n/, token: "newline", merge: false }
135
+ ],
136
+ snippetVar: [
137
+ { regex: "\\|" + escape("\\|") + "*\\|", onMatch: function (val, state, stack) {
138
+ var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function (operator) {
139
+ return operator.length == 2 ? operator[1] : "\x00";
140
+ }).split("\x00").map(function (value) {
141
+ return { value: value };
142
+ });
143
+ stack[0].choices = choices;
144
+ return [choices[0]];
145
+ }, next: "start" },
146
+ formatMatcher,
147
+ { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" }
148
+ ],
149
+ formatString: [
150
+ { regex: /:/, onMatch: function (val, state, stack) {
151
+ if (stack.length && stack[0].expectElse) {
152
+ stack[0].expectElse = false;
153
+ stack[0].ifEnd = { elseEnd: stack[0] };
154
+ return [stack[0].ifEnd];
155
+ }
156
+ return ":";
157
+ } },
158
+ { regex: /\\./, onMatch: function (val, state, stack) {
159
+ var ch = val[1];
160
+ if (ch == "}" && stack.length)
161
+ val = ch;
162
+ else if ("`$\\".indexOf(ch) != -1)
163
+ val = ch;
164
+ else if (ch == "n")
165
+ val = "\n";
166
+ else if (ch == "t")
167
+ val = "\t";
168
+ else if ("ulULE".indexOf(ch) != -1)
169
+ val = { changeCase: ch, local: ch > "a" };
170
+ return [val];
171
+ } },
172
+ { regex: "/\\w*}", onMatch: function (val, state, stack) {
173
+ var next = stack.shift();
174
+ if (next)
175
+ next.flag = val.slice(1, -1);
176
+ this.next = next && next.tabstopId ? "start" : "";
177
+ return [next || val];
178
+ }, next: "start" },
179
+ { regex: /\$(?:\d+|\w+)/, onMatch: function (val, state, stack) {
180
+ return [{ text: val.slice(1) }];
181
+ } },
182
+ { regex: /\${\w+/, onMatch: function (val, state, stack) {
183
+ var token = { text: val.slice(2) };
184
+ stack.unshift(token);
185
+ return [token];
186
+ }, next: "formatStringVar" },
187
+ { regex: /\n/, token: "newline", merge: false },
188
+ { regex: /}/, onMatch: function (val, state, stack) {
189
+ var next = stack.shift();
190
+ this.next = next && next.tabstopId ? "start" : "";
191
+ return [next || val];
192
+ }, next: "start" }
193
+ ],
194
+ formatStringVar: [
195
+ { regex: /:\/\w+}/, onMatch: function (val, state, stack) {
196
+ var ts = stack[0];
197
+ ts.formatFunction = val.slice(2, -1);
198
+ return [stack.shift()];
199
+ }, next: "formatString" },
200
+ formatMatcher,
201
+ { regex: /:[\?\-+]?/, onMatch: function (val, state, stack) {
202
+ if (val[1] == "+")
203
+ stack[0].ifEnd = stack[0];
204
+ if (val[1] == "?")
205
+ stack[0].expectElse = true;
206
+ }, next: "formatString" },
207
+ { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString" }
208
+ ]
209
+ });
210
+ return SnippetManager["$tokenizer"];
211
+ };
212
+ SnippetManager.prototype.tokenizeTmSnippet = function (str, startState) {
213
+ return this.getTokenizer().getLineTokens(str, startState).tokens.map(function (x) {
214
+ return x.value || x;
215
+ });
216
+ };
217
+ SnippetManager.prototype.getVariableValue = function (editor, name, indentation) {
218
+ if (/^\d+$/.test(name))
219
+ return (this.variables.__ || {})[name] || "";
220
+ if (/^[A-Z]\d+$/.test(name))
221
+ return (this.variables[name[0] + "__"] || {})[name.substr(1)] || "";
222
+ name = name.replace(/^TM_/, "");
223
+ if (!this.variables.hasOwnProperty(name))
224
+ return "";
225
+ var value = this.variables[name];
226
+ if (typeof value == "function")
227
+ value = this.variables[name](editor, name, indentation);
228
+ return value == null ? "" : value;
229
+ };
230
+ SnippetManager.prototype.tmStrFormat = function (str, ch, editor) {
231
+ if (!ch.fmt)
232
+ return str;
233
+ var flag = ch.flag || "";
234
+ var re = ch.guard;
235
+ re = new RegExp(re, flag.replace(/[^gim]/g, ""));
236
+ var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt;
237
+ var _self = this;
238
+ var formatted = str.replace(re, function () {
239
+ var oldArgs = _self.variables.__;
240
+ _self.variables.__ = [].slice.call(arguments);
241
+ var fmtParts = _self.resolveVariables(fmtTokens, editor);
242
+ var gChangeCase = "E";
243
+ for (var i = 0; i < fmtParts.length; i++) {
244
+ var ch = fmtParts[i];
245
+ if (typeof ch == "object") {
246
+ fmtParts[i] = "";
247
+ if (ch.changeCase && ch.local) {
248
+ var next = fmtParts[i + 1];
249
+ if (next && typeof next == "string") {
250
+ if (ch.changeCase == "u")
251
+ fmtParts[i] = next[0].toUpperCase();
252
+ else
253
+ fmtParts[i] = next[0].toLowerCase();
254
+ fmtParts[i + 1] = next.substr(1);
255
+ }
256
+ }
257
+ else if (ch.changeCase) {
258
+ gChangeCase = ch.changeCase;
259
+ }
260
+ }
261
+ else if (gChangeCase == "U") {
262
+ fmtParts[i] = ch.toUpperCase();
263
+ }
264
+ else if (gChangeCase == "L") {
265
+ fmtParts[i] = ch.toLowerCase();
266
+ }
267
+ }
268
+ _self.variables.__ = oldArgs;
269
+ return fmtParts.join("");
270
+ });
271
+ return formatted;
272
+ };
273
+ SnippetManager.prototype.tmFormatFunction = function (str, ch, editor) {
274
+ if (ch.formatFunction == "upcase")
275
+ return str.toUpperCase();
276
+ if (ch.formatFunction == "downcase")
277
+ return str.toLowerCase();
278
+ return str;
279
+ };
280
+ SnippetManager.prototype.resolveVariables = function (snippet, editor) {
281
+ var result = [];
282
+ var indentation = "";
283
+ var afterNewLine = true;
284
+ for (var i = 0; i < snippet.length; i++) {
285
+ var ch = snippet[i];
286
+ if (typeof ch == "string") {
287
+ result.push(ch);
288
+ if (ch == "\n") {
289
+ afterNewLine = true;
290
+ indentation = "";
291
+ }
292
+ else if (afterNewLine) {
293
+ indentation = /^\t*/.exec(ch)[0];
294
+ afterNewLine = /\S/.test(ch);
295
+ }
296
+ continue;
297
+ }
298
+ if (!ch)
299
+ continue;
300
+ afterNewLine = false;
301
+ if (ch.fmtString) {
302
+ var j = snippet.indexOf(ch, i + 1);
303
+ if (j == -1)
304
+ j = snippet.length;
305
+ ch.fmt = snippet.slice(i + 1, j);
306
+ i = j;
307
+ }
308
+ if (ch.text) {
309
+ var value = this.getVariableValue(editor, ch.text, indentation) + "";
310
+ if (ch.fmtString)
311
+ value = this.tmStrFormat(value, ch, editor);
312
+ if (ch.formatFunction)
313
+ value = this.tmFormatFunction(value, ch, editor);
314
+ if (value && !ch.ifEnd) {
315
+ result.push(value);
316
+ gotoNext(ch);
317
+ }
318
+ else if (!value && ch.ifEnd) {
319
+ gotoNext(ch.ifEnd);
320
+ }
321
+ }
322
+ else if (ch.elseEnd) {
323
+ gotoNext(ch.elseEnd);
324
+ }
325
+ else if (ch.tabstopId != null) {
326
+ result.push(ch);
327
+ }
328
+ else if (ch.changeCase != null) {
329
+ result.push(ch);
330
+ }
331
+ }
332
+ function gotoNext(ch) {
333
+ var i1 = snippet.indexOf(ch, i + 1);
334
+ if (i1 != -1)
335
+ i = i1;
336
+ }
337
+ return result;
338
+ };
339
+ SnippetManager.prototype.getDisplayTextForSnippet = function (editor, snippetText) {
340
+ var processedSnippet = processSnippetText.call(this, editor, snippetText);
341
+ return processedSnippet.text;
342
+ };
343
+ SnippetManager.prototype.insertSnippetForSelection = function (editor, snippetText, options) {
344
+ if (options === void 0) { options = {}; }
345
+ var processedSnippet = processSnippetText.call(this, editor, snippetText, options);
346
+ var range = editor.getSelectionRange();
347
+ var end = editor.session.replace(range, processedSnippet.text);
348
+ var tabstopManager = new TabstopManager(editor);
349
+ var selectionId = editor.inVirtualSelectionMode && editor.selection.index;
350
+ tabstopManager.addTabstops(processedSnippet.tabstops, range.start, end, selectionId);
351
+ };
352
+ SnippetManager.prototype.insertSnippet = function (editor, snippetText, options) {
353
+ if (options === void 0) { options = {}; }
354
+ var self = this;
355
+ if (editor.inVirtualSelectionMode)
356
+ return self.insertSnippetForSelection(editor, snippetText, options);
357
+ editor.forEachSelection(function () {
358
+ self.insertSnippetForSelection(editor, snippetText, options);
359
+ }, null, { keepOrder: true });
360
+ if (editor.tabstopManager)
361
+ editor.tabstopManager.tabNext();
362
+ };
363
+ SnippetManager.prototype.$getScope = function (editor) {
364
+ var scope = editor.session.$mode.$id || "";
365
+ scope = scope.split("/").pop();
366
+ if (scope === "html" || scope === "php") {
367
+ if (scope === "php" && !editor.session.$mode.inlinePhp)
368
+ scope = "html";
369
+ var c = editor.getCursorPosition();
370
+ var state = editor.session.getState(c.row);
371
+ if (typeof state === "object") {
372
+ state = state[0];
373
+ }
374
+ if (state.substring) {
375
+ if (state.substring(0, 3) == "js-")
376
+ scope = "javascript";
377
+ else if (state.substring(0, 4) == "css-")
378
+ scope = "css";
379
+ else if (state.substring(0, 4) == "php-")
380
+ scope = "php";
381
+ }
382
+ }
383
+ return scope;
384
+ };
385
+ SnippetManager.prototype.getActiveScopes = function (editor) {
386
+ var scope = this.$getScope(editor);
387
+ var scopes = [scope];
388
+ var snippetMap = this.snippetMap;
389
+ if (snippetMap[scope] && snippetMap[scope].includeScopes) {
390
+ scopes.push.apply(scopes, snippetMap[scope].includeScopes);
391
+ }
392
+ scopes.push("_");
393
+ return scopes;
394
+ };
395
+ SnippetManager.prototype.expandWithTab = function (editor, options) {
396
+ var self = this;
397
+ var result = editor.forEachSelection(function () {
398
+ return self.expandSnippetForSelection(editor, options);
399
+ }, null, { keepOrder: true });
400
+ if (result && editor.tabstopManager)
401
+ editor.tabstopManager.tabNext();
402
+ return result;
403
+ };
404
+ SnippetManager.prototype.expandSnippetForSelection = function (editor, options) {
405
+ var cursor = editor.getCursorPosition();
406
+ var line = editor.session.getLine(cursor.row);
407
+ var before = line.substring(0, cursor.column);
408
+ var after = line.substr(cursor.column);
409
+ var snippetMap = this.snippetMap;
410
+ var snippet;
411
+ this.getActiveScopes(editor).some(function (scope) {
412
+ var snippets = snippetMap[scope];
413
+ if (snippets)
414
+ snippet = this.findMatchingSnippet(snippets, before, after);
415
+ return !!snippet;
416
+ }, this);
417
+ if (!snippet)
418
+ return false;
419
+ if (options && options.dryRun)
420
+ return true;
421
+ editor.session.doc.removeInLine(cursor.row, cursor.column - snippet.replaceBefore.length, cursor.column + snippet.replaceAfter.length);
422
+ this.variables.M__ = snippet.matchBefore;
423
+ this.variables.T__ = snippet.matchAfter;
424
+ this.insertSnippetForSelection(editor, snippet.content);
425
+ this.variables.M__ = this.variables.T__ = null;
426
+ return true;
427
+ };
428
+ SnippetManager.prototype.findMatchingSnippet = function (snippetList, before, after) {
429
+ for (var i = snippetList.length; i--;) {
430
+ var s = snippetList[i];
431
+ if (s.startRe && !s.startRe.test(before))
432
+ continue;
433
+ if (s.endRe && !s.endRe.test(after))
434
+ continue;
435
+ if (!s.startRe && !s.endRe)
436
+ continue;
437
+ s.matchBefore = s.startRe ? s.startRe.exec(before) : [""];
438
+ s.matchAfter = s.endRe ? s.endRe.exec(after) : [""];
439
+ s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : "";
440
+ s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : "";
441
+ return s;
442
+ }
443
+ };
444
+ SnippetManager.prototype.register = function (snippets, scope) {
445
+ var snippetMap = this.snippetMap;
446
+ var snippetNameMap = this.snippetNameMap;
447
+ var self = this;
448
+ if (!snippets)
449
+ snippets = [];
450
+ function wrapRegexp(src) {
451
+ if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
452
+ src = "(?:" + src + ")";
453
+ return src || "";
454
+ }
455
+ function guardedRegexp(re, guard, opening) {
456
+ re = wrapRegexp(re);
457
+ guard = wrapRegexp(guard);
458
+ if (opening) {
459
+ re = guard + re;
460
+ if (re && re[re.length - 1] != "$")
461
+ re = re + "$";
462
+ }
463
+ else {
464
+ re = re + guard;
465
+ if (re && re[0] != "^")
466
+ re = "^" + re;
467
+ }
468
+ return new RegExp(re);
469
+ }
470
+ function addSnippet(s) {
471
+ if (!s.scope)
472
+ s.scope = scope || "_";
473
+ scope = s.scope;
474
+ if (!snippetMap[scope]) {
475
+ snippetMap[scope] = [];
476
+ snippetNameMap[scope] = {};
477
+ }
478
+ var map = snippetNameMap[scope];
479
+ if (s.name) {
480
+ var old = map[s.name];
481
+ if (old)
482
+ self.unregister(old);
483
+ map[s.name] = s;
484
+ }
485
+ snippetMap[scope].push(s);
486
+ if (s.prefix)
487
+ s.tabTrigger = s.prefix;
488
+ if (!s.content && s.body)
489
+ s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body;
490
+ if (s.tabTrigger && !s.trigger) {
491
+ if (!s.guard && /^\w/.test(s.tabTrigger))
492
+ s.guard = "\\b";
493
+ s.trigger = lang.escapeRegExp(s.tabTrigger);
494
+ }
495
+ if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard)
496
+ return;
497
+ s.startRe = guardedRegexp(s.trigger, s.guard, true);
498
+ s.triggerRe = new RegExp(s.trigger);
499
+ s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
500
+ s.endTriggerRe = new RegExp(s.endTrigger);
501
+ }
502
+ if (Array.isArray(snippets)) {
503
+ snippets.forEach(addSnippet);
504
+ }
505
+ else {
506
+ Object.keys(snippets).forEach(function (key) {
507
+ addSnippet(snippets[key]);
508
+ });
509
+ }
510
+ this._signal("registerSnippets", { scope: scope });
511
+ };
512
+ SnippetManager.prototype.unregister = function (snippets, scope) {
513
+ var snippetMap = this.snippetMap;
514
+ var snippetNameMap = this.snippetNameMap;
515
+ function removeSnippet(s) {
516
+ var nameMap = snippetNameMap[s.scope || scope];
517
+ if (nameMap && nameMap[s.name]) {
518
+ delete nameMap[s.name];
519
+ var map = snippetMap[s.scope || scope];
520
+ var i = map && map.indexOf(s);
521
+ if (i >= 0)
522
+ map.splice(i, 1);
523
+ }
524
+ }
525
+ if (snippets.content)
526
+ removeSnippet(snippets);
527
+ else if (Array.isArray(snippets))
528
+ snippets.forEach(removeSnippet);
529
+ };
530
+ SnippetManager.prototype.parseSnippetFile = function (str) {
531
+ str = str.replace(/\r/g, "");
532
+ var list = [], /**@type{Snippet}*/ snippet = {};
533
+ var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm;
534
+ var m;
535
+ while (m = re.exec(str)) {
536
+ if (m[1]) {
537
+ try {
538
+ snippet = JSON.parse(m[1]);
539
+ list.push(snippet);
540
+ }
541
+ catch (e) { }
542
+ }
543
+ if (m[4]) {
544
+ snippet.content = m[4].replace(/^\t/gm, "");
545
+ list.push(snippet);
546
+ snippet = {};
547
+ }
548
+ else {
549
+ var key = m[2], val = m[3];
550
+ if (key == "regex") {
551
+ var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g;
552
+ snippet.guard = guardRe.exec(val)[1];
553
+ snippet.trigger = guardRe.exec(val)[1];
554
+ snippet.endTrigger = guardRe.exec(val)[1];
555
+ snippet.endGuard = guardRe.exec(val)[1];
556
+ }
557
+ else if (key == "snippet") {
558
+ snippet.tabTrigger = val.match(/^\S*/)[0];
559
+ if (!snippet.name)
560
+ snippet.name = val;
561
+ }
562
+ else if (key) {
563
+ snippet[key] = val;
564
+ }
565
+ }
566
+ }
567
+ return list;
568
+ };
569
+ SnippetManager.prototype.getSnippetByName = function (name, editor) {
570
+ var snippetMap = this.snippetNameMap;
571
+ var snippet;
572
+ this.getActiveScopes(editor).some(function (scope) {
573
+ var snippets = snippetMap[scope];
574
+ if (snippets)
575
+ snippet = snippets[name];
576
+ return !!snippet;
577
+ }, this);
578
+ return snippet;
579
+ };
580
+ return SnippetManager;
581
+ }());
582
+ oop.implement(SnippetManager.prototype, EventEmitter);
583
+ var processSnippetText = function (editor, snippetText, options) {
584
+ if (options === void 0) { options = {}; }
585
+ var cursor = editor.getCursorPosition();
586
+ var line = editor.session.getLine(cursor.row);
587
+ var tabString = editor.session.getTabString();
588
+ var indentString = line.match(/^\s*/)[0];
589
+ if (cursor.column < indentString.length)
590
+ indentString = indentString.slice(0, cursor.column);
591
+ snippetText = snippetText.replace(/\r/g, "");
592
+ var tokens = this.tokenizeTmSnippet(snippetText);
593
+ tokens = this.resolveVariables(tokens, editor);
594
+ tokens = tokens.map(function (x) {
595
+ if (x == "\n" && !options.excludeExtraIndent)
596
+ return x + indentString;
597
+ if (typeof x == "string")
598
+ return x.replace(/\t/g, tabString);
599
+ return x;
600
+ });
601
+ var tabstops = [];
602
+ tokens.forEach(function (p, i) {
603
+ if (typeof p != "object")
604
+ return;
605
+ var id = p.tabstopId;
606
+ var ts = tabstops[id];
607
+ if (!ts) {
608
+ ts = tabstops[id] = [];
609
+ ts.index = id;
610
+ ts.value = "";
611
+ ts.parents = {};
612
+ }
613
+ if (ts.indexOf(p) !== -1)
614
+ return;
615
+ if (p.choices && !ts.choices)
616
+ ts.choices = p.choices;
617
+ ts.push(p);
618
+ var i1 = tokens.indexOf(p, i + 1);
619
+ if (i1 === -1)
620
+ return;
621
+ var value = tokens.slice(i + 1, i1);
622
+ var isNested = value.some(function (t) { return typeof t === "object"; });
623
+ if (isNested && !ts.value) {
624
+ ts.value = value;
625
+ }
626
+ else if (value.length && (!ts.value || typeof ts.value !== "string")) {
627
+ ts.value = value.join("");
628
+ }
629
+ });
630
+ tabstops.forEach(function (ts) { ts.length = 0; });
631
+ var expanding = {};
632
+ function copyValue(val) {
633
+ var copy = [];
634
+ for (var i = 0; i < val.length; i++) {
635
+ var p = val[i];
636
+ if (typeof p == "object") {
637
+ if (expanding[p.tabstopId])
638
+ continue;
639
+ var j = val.lastIndexOf(p, i - 1);
640
+ p = copy[j] || { tabstopId: p.tabstopId };
641
+ }
642
+ copy[i] = p;
643
+ }
644
+ return copy;
645
+ }
646
+ for (var i = 0; i < tokens.length; i++) {
647
+ var p = tokens[i];
648
+ if (typeof p != "object")
649
+ continue;
650
+ var id = p.tabstopId;
651
+ var ts = tabstops[id];
652
+ var i1 = tokens.indexOf(p, i + 1);
653
+ if (expanding[id]) {
654
+ if (expanding[id] === p) {
655
+ delete expanding[id];
656
+ Object.keys(expanding).forEach(function (parentId) {
657
+ ts.parents[parentId] = true;
658
+ });
659
+ }
660
+ continue;
661
+ }
662
+ expanding[id] = p;
663
+ var value = ts.value;
664
+ if (typeof value !== "string")
665
+ value = copyValue(value);
666
+ else if (p.fmt)
667
+ value = this.tmStrFormat(value, p, editor);
668
+ tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p));
669
+ if (ts.indexOf(p) === -1)
670
+ ts.push(p);
671
+ }
672
+ var row = 0, column = 0;
673
+ var text = "";
674
+ tokens.forEach(function (t) {
675
+ if (typeof t === "string") {
676
+ var lines = t.split("\n");
677
+ if (lines.length > 1) {
678
+ column = lines[lines.length - 1].length;
679
+ row += lines.length - 1;
680
+ }
681
+ else
682
+ column += t.length;
683
+ text += t;
684
+ }
685
+ else if (t) {
686
+ if (!t.start)
687
+ t.start = { row: row, column: column };
688
+ else
689
+ t.end = { row: row, column: column };
690
+ }
691
+ });
692
+ return {
693
+ text: text,
694
+ tabstops: tabstops,
695
+ tokens: tokens
696
+ };
697
+ };
698
+ var TabstopManager = /** @class */ (function () {
699
+ function TabstopManager(editor) {
700
+ this.index = 0;
701
+ this.ranges = [];
702
+ this.tabstops = [];
703
+ if (editor.tabstopManager)
704
+ return editor.tabstopManager;
705
+ editor.tabstopManager = this;
706
+ this.$onChange = this.onChange.bind(this);
707
+ this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule;
708
+ this.$onChangeSession = this.onChangeSession.bind(this);
709
+ this.$onAfterExec = this.onAfterExec.bind(this);
710
+ this.attach(editor);
711
+ }
712
+ TabstopManager.prototype.attach = function (editor) {
713
+ this.$openTabstops = null;
714
+ this.selectedTabstop = null;
715
+ this.editor = editor;
716
+ this.session = editor.session;
717
+ this.editor.on("change", this.$onChange);
718
+ this.editor.on("changeSelection", this.$onChangeSelection);
719
+ this.editor.on("changeSession", this.$onChangeSession);
720
+ this.editor.commands.on("afterExec", this.$onAfterExec);
721
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
722
+ };
723
+ TabstopManager.prototype.detach = function () {
724
+ this.tabstops.forEach(this.removeTabstopMarkers, this);
725
+ this.ranges.length = 0;
726
+ this.tabstops.length = 0;
727
+ this.selectedTabstop = null;
728
+ this.editor.off("change", this.$onChange);
729
+ this.editor.off("changeSelection", this.$onChangeSelection);
730
+ this.editor.off("changeSession", this.$onChangeSession);
731
+ this.editor.commands.off("afterExec", this.$onAfterExec);
732
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
733
+ this.editor.tabstopManager = null;
734
+ this.session = null;
735
+ this.editor = null;
736
+ };
737
+ TabstopManager.prototype.onChange = function (delta) {
738
+ var isRemove = delta.action[0] == "r";
739
+ var selectedTabstop = this.selectedTabstop || {};
740
+ var parents = selectedTabstop.parents || {};
741
+ var tabstops = this.tabstops.slice();
742
+ for (var i = 0; i < tabstops.length; i++) {
743
+ var ts = tabstops[i];
744
+ var active = ts == selectedTabstop || parents[ts.index];
745
+ ts.rangeList.$bias = active ? 0 : 1;
746
+ if (delta.action == "remove" && ts !== selectedTabstop) {
747
+ var parentActive = ts.parents && ts.parents[selectedTabstop.index];
748
+ var startIndex = ts.rangeList.pointIndex(delta.start, parentActive);
749
+ startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1;
750
+ var endIndex = ts.rangeList.pointIndex(delta.end, parentActive);
751
+ endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1;
752
+ var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex);
753
+ for (var j = 0; j < toRemove.length; j++)
754
+ this.removeRange(toRemove[j]);
755
+ }
756
+ ts.rangeList.$onChange(delta);
757
+ }
758
+ var session = this.session;
759
+ if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue())
760
+ this.detach();
761
+ };
762
+ TabstopManager.prototype.updateLinkedFields = function () {
763
+ var ts = this.selectedTabstop;
764
+ if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked)
765
+ return;
766
+ this.$inChange = true;
767
+ var session = this.session;
768
+ var text = session.getTextRange(ts.firstNonLinked);
769
+ for (var i = 0; i < ts.length; i++) {
770
+ var range = ts[i];
771
+ if (!range.linked)
772
+ continue;
773
+ var original = range.original;
774
+ var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor);
775
+ session.replace(range, fmt);
776
+ }
777
+ this.$inChange = false;
778
+ };
779
+ TabstopManager.prototype.onAfterExec = function (e) {
780
+ if (e.command && !e.command.readOnly)
781
+ this.updateLinkedFields();
782
+ };
783
+ TabstopManager.prototype.onChangeSelection = function () {
784
+ if (!this.editor)
785
+ return;
786
+ var lead = this.editor.selection.lead;
787
+ var anchor = this.editor.selection.anchor;
788
+ var isEmpty = this.editor.selection.isEmpty();
789
+ for (var i = 0; i < this.ranges.length; i++) {
790
+ if (this.ranges[i].linked)
791
+ continue;
792
+ var containsLead = this.ranges[i].contains(lead.row, lead.column);
793
+ var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column);
794
+ if (containsLead && containsAnchor)
795
+ return;
796
+ }
797
+ this.detach();
798
+ };
799
+ TabstopManager.prototype.onChangeSession = function () {
800
+ this.detach();
801
+ };
802
+ TabstopManager.prototype.tabNext = function (dir) {
803
+ var max = this.tabstops.length;
804
+ var index = this.index + (dir || 1);
805
+ index = Math.min(Math.max(index, 1), max);
806
+ if (index == max)
807
+ index = 0;
808
+ this.selectTabstop(index);
809
+ this.updateTabstopMarkers();
810
+ if (index === 0) {
811
+ this.detach();
812
+ }
813
+ };
814
+ TabstopManager.prototype.selectTabstop = function (index) {
815
+ this.$openTabstops = null;
816
+ var ts = this.tabstops[this.index];
817
+ if (ts)
818
+ this.addTabstopMarkers(ts);
819
+ this.index = index;
820
+ ts = this.tabstops[this.index];
821
+ if (!ts || !ts.length)
822
+ return;
823
+ this.selectedTabstop = ts;
824
+ var range = ts.firstNonLinked || ts;
825
+ if (ts.choices)
826
+ range.cursor = range.start;
827
+ if (!this.editor.inVirtualSelectionMode) {
828
+ var sel = this.editor.multiSelect;
829
+ sel.toSingleRange(range);
830
+ for (var i = 0; i < ts.length; i++) {
831
+ if (ts.hasLinkedRanges && ts[i].linked)
832
+ continue;
833
+ sel.addRange(ts[i].clone(), true);
834
+ }
835
+ }
836
+ else {
837
+ this.editor.selection.fromOrientedRange(range);
838
+ }
839
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
840
+ if (this.selectedTabstop && this.selectedTabstop.choices)
841
+ this.editor.execCommand("startAutocomplete", { matches: this.selectedTabstop.choices });
842
+ };
843
+ TabstopManager.prototype.addTabstops = function (tabstops, start, end) {
844
+ var useLink = this.useLink || !this.editor.getOption("enableMultiselect");
845
+ if (!this.$openTabstops)
846
+ this.$openTabstops = [];
847
+ if (!tabstops[0]) {
848
+ var p = Range.fromPoints(end, end);
849
+ moveRelative(p.start, start);
850
+ moveRelative(p.end, start);
851
+ tabstops[0] = [p];
852
+ tabstops[0].index = 0;
853
+ }
854
+ var i = this.index;
855
+ var arg = [i + 1, 0];
856
+ var ranges = this.ranges;
857
+ var snippetId = this.snippetId = (this.snippetId || 0) + 1;
858
+ tabstops.forEach(function (ts, index) {
859
+ var dest = this.$openTabstops[index] || ts;
860
+ dest.snippetId = snippetId;
861
+ for (var i = 0; i < ts.length; i++) {
862
+ var p = ts[i];
863
+ var range = Range.fromPoints(p.start, p.end || p.start);
864
+ movePoint(range.start, start);
865
+ movePoint(range.end, start);
866
+ range.original = p;
867
+ range.tabstop = dest;
868
+ ranges.push(range);
869
+ if (dest != ts)
870
+ dest.unshift(range);
871
+ else
872
+ dest[i] = range;
873
+ if (p.fmtString || (dest.firstNonLinked && useLink)) {
874
+ range.linked = true;
875
+ dest.hasLinkedRanges = true;
876
+ }
877
+ else if (!dest.firstNonLinked)
878
+ dest.firstNonLinked = range;
879
+ }
880
+ if (!dest.firstNonLinked)
881
+ dest.hasLinkedRanges = false;
882
+ if (dest === ts) {
883
+ arg.push(dest);
884
+ this.$openTabstops[index] = dest;
885
+ }
886
+ this.addTabstopMarkers(dest);
887
+ dest.rangeList = dest.rangeList || new RangeList();
888
+ dest.rangeList.$bias = 0;
889
+ dest.rangeList.addList(dest);
890
+ }, this);
891
+ if (arg.length > 2) {
892
+ if (this.tabstops.length)
893
+ arg.push(arg.splice(2, 1)[0]);
894
+ this.tabstops.splice.apply(this.tabstops, arg);
895
+ }
896
+ };
897
+ TabstopManager.prototype.addTabstopMarkers = function (ts) {
898
+ var session = this.session;
899
+ ts.forEach(function (range) {
900
+ if (!range.markerId)
901
+ range.markerId = session.addMarker(range, "ace_snippet-marker", "text");
902
+ });
903
+ };
904
+ TabstopManager.prototype.removeTabstopMarkers = function (ts) {
905
+ var session = this.session;
906
+ ts.forEach(function (range) {
907
+ session.removeMarker(range.markerId);
908
+ range.markerId = null;
909
+ });
910
+ };
911
+ TabstopManager.prototype.updateTabstopMarkers = function () {
912
+ if (!this.selectedTabstop)
913
+ return;
914
+ var currentSnippetId = this.selectedTabstop.snippetId;
915
+ if (this.selectedTabstop.index === 0) {
916
+ currentSnippetId--;
917
+ }
918
+ this.tabstops.forEach(function (ts) {
919
+ if (ts.snippetId === currentSnippetId)
920
+ this.addTabstopMarkers(ts);
921
+ else
922
+ this.removeTabstopMarkers(ts);
923
+ }, this);
924
+ };
925
+ TabstopManager.prototype.removeRange = function (range) {
926
+ var i = range.tabstop.indexOf(range);
927
+ if (i != -1)
928
+ range.tabstop.splice(i, 1);
929
+ i = this.ranges.indexOf(range);
930
+ if (i != -1)
931
+ this.ranges.splice(i, 1);
932
+ i = range.tabstop.rangeList.ranges.indexOf(range);
933
+ if (i != -1)
934
+ range.tabstop.splice(i, 1);
935
+ this.session.removeMarker(range.markerId);
936
+ if (!range.tabstop.length) {
937
+ i = this.tabstops.indexOf(range.tabstop);
938
+ if (i != -1)
939
+ this.tabstops.splice(i, 1);
940
+ if (!this.tabstops.length)
941
+ this.detach();
942
+ }
943
+ };
944
+ return TabstopManager;
945
+ }());
946
+ TabstopManager.prototype.keyboardHandler = new HashHandler();
947
+ TabstopManager.prototype.keyboardHandler.bindKeys({
948
+ "Tab": function (editor) {
949
+ if (exports.snippetManager && exports.snippetManager.expandWithTab(editor))
950
+ return;
951
+ editor.tabstopManager.tabNext(1);
952
+ editor.renderer.scrollCursorIntoView();
953
+ },
954
+ "Shift-Tab": function (editor) {
955
+ editor.tabstopManager.tabNext(-1);
956
+ editor.renderer.scrollCursorIntoView();
957
+ },
958
+ "Esc": function (editor) {
959
+ editor.tabstopManager.detach();
960
+ }
961
+ });
962
+ var movePoint = function (point, diff) {
963
+ if (point.row == 0)
964
+ point.column += diff.column;
965
+ point.row += diff.row;
966
+ };
967
+ var moveRelative = function (point, start) {
968
+ if (point.row == start.row)
969
+ point.column -= start.column;
970
+ point.row -= start.row;
971
+ };
972
+ dom.importCssString("\n.ace_snippet-marker {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n background: rgba(194, 193, 208, 0.09);\n border: 1px dotted rgba(211, 208, 235, 0.62);\n position: absolute;\n}", "snippets.css", false);
973
+ exports.snippetManager = new SnippetManager();
974
+ var Editor = require("./editor").Editor;
975
+ (function () {
976
+ this.insertSnippet = function (content, options) {
977
+ return exports.snippetManager.insertSnippet(this, content, options);
978
+ };
979
+ this.expandSnippet = function (options) {
980
+ return exports.snippetManager.expandWithTab(this, options);
981
+ };
982
+ }).call(Editor.prototype);
983
+
984
+ });
985
+
986
+ ace.define("ace/autocomplete/inline_screenreader",["require","exports","module"], function(require, exports, module){"use strict";
987
+ var AceInlineScreenReader = /** @class */ (function () {
988
+ function AceInlineScreenReader(editor) {
989
+ this.editor = editor;
990
+ this.screenReaderDiv = document.createElement("div");
991
+ this.screenReaderDiv.classList.add("ace_screenreader-only");
992
+ this.editor.container.appendChild(this.screenReaderDiv);
993
+ }
994
+ AceInlineScreenReader.prototype.setScreenReaderContent = function (content) {
995
+ if (!this.popup && this.editor.completer && /**@type{import("../autocomplete").Autocomplete}*/ (this.editor.completer).popup) {
996
+ this.popup = /**@type{import("../autocomplete").Autocomplete}*/ (this.editor.completer).popup;
997
+ this.popup.renderer.on("afterRender", function () {
998
+ var row = this.popup.getRow();
999
+ var t = this.popup.renderer.$textLayer;
1000
+ var selected = t.element.childNodes[row - t.config.firstRow];
1001
+ if (selected) {
1002
+ var idString = "doc-tooltip ";
1003
+ for (var lineIndex = 0; lineIndex < this._lines.length; lineIndex++) {
1004
+ idString += "ace-inline-screenreader-line-".concat(lineIndex, " ");
1005
+ }
1006
+ selected.setAttribute("aria-describedby", idString);
1007
+ }
1008
+ }.bind(this));
1009
+ }
1010
+ while (this.screenReaderDiv.firstChild) {
1011
+ this.screenReaderDiv.removeChild(this.screenReaderDiv.firstChild);
1012
+ }
1013
+ this._lines = content.split(/\r\n|\r|\n/);
1014
+ var codeElement = this.createCodeBlock();
1015
+ this.screenReaderDiv.appendChild(codeElement);
1016
+ };
1017
+ AceInlineScreenReader.prototype.destroy = function () {
1018
+ this.screenReaderDiv.remove();
1019
+ };
1020
+ AceInlineScreenReader.prototype.createCodeBlock = function () {
1021
+ var container = document.createElement("pre");
1022
+ container.setAttribute("id", "ace-inline-screenreader");
1023
+ for (var lineIndex = 0; lineIndex < this._lines.length; lineIndex++) {
1024
+ var codeElement = document.createElement("code");
1025
+ codeElement.setAttribute("id", "ace-inline-screenreader-line-".concat(lineIndex));
1026
+ var line = document.createTextNode(this._lines[lineIndex]);
1027
+ codeElement.appendChild(line);
1028
+ container.appendChild(codeElement);
1029
+ }
1030
+ return container;
1031
+ };
1032
+ return AceInlineScreenReader;
1033
+ }());
1034
+ exports.AceInlineScreenReader = AceInlineScreenReader;
1035
+
1036
+ });
1037
+
1038
+ ace.define("ace/autocomplete/inline",["require","exports","module","ace/snippets","ace/autocomplete/inline_screenreader"], function(require, exports, module){"use strict";
1039
+ var snippetManager = require("../snippets").snippetManager;
1040
+ var AceInlineScreenReader = require("./inline_screenreader").AceInlineScreenReader;
1041
+ var AceInline = /** @class */ (function () {
1042
+ function AceInline() {
1043
+ this.editor = null;
1044
+ }
1045
+ AceInline.prototype.show = function (editor, completion, prefix) {
1046
+ prefix = prefix || "";
1047
+ if (editor && this.editor && this.editor !== editor) {
1048
+ this.hide();
1049
+ this.editor = null;
1050
+ this.inlineScreenReader = null;
1051
+ }
1052
+ if (!editor || !completion) {
1053
+ return false;
1054
+ }
1055
+ if (!this.inlineScreenReader) {
1056
+ this.inlineScreenReader = new AceInlineScreenReader(editor);
1057
+ }
1058
+ var displayText = completion.snippet ? snippetManager.getDisplayTextForSnippet(editor, completion.snippet) : completion.value;
1059
+ if (completion.hideInlinePreview || !displayText || !displayText.startsWith(prefix)) {
1060
+ return false;
1061
+ }
1062
+ this.editor = editor;
1063
+ this.inlineScreenReader.setScreenReaderContent(displayText);
1064
+ displayText = displayText.slice(prefix.length);
1065
+ if (displayText === "") {
1066
+ editor.removeGhostText();
1067
+ }
1068
+ else {
1069
+ editor.setGhostText(displayText);
1070
+ }
1071
+ return true;
1072
+ };
1073
+ AceInline.prototype.isOpen = function () {
1074
+ if (!this.editor) {
1075
+ return false;
1076
+ }
1077
+ return !!this.editor.renderer.$ghostText;
1078
+ };
1079
+ AceInline.prototype.hide = function () {
1080
+ if (!this.editor) {
1081
+ return false;
1082
+ }
1083
+ this.editor.removeGhostText();
1084
+ return true;
1085
+ };
1086
+ AceInline.prototype.destroy = function () {
1087
+ this.hide();
1088
+ this.editor = null;
1089
+ if (this.inlineScreenReader) {
1090
+ this.inlineScreenReader.destroy();
1091
+ this.inlineScreenReader = null;
1092
+ }
1093
+ };
1094
+ return AceInline;
1095
+ }());
1096
+ exports.AceInline = AceInline;
1097
+
1098
+ });
1099
+
1100
+ ace.define("ace/autocomplete/popup",["require","exports","module","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom","ace/config","ace/lib/useragent"], function(require, exports, module){"use strict";
1101
+ var Renderer = require("../virtual_renderer").VirtualRenderer;
1102
+ var Editor = require("../editor").Editor;
1103
+ var Range = require("../range").Range;
1104
+ var event = require("../lib/event");
1105
+ var lang = require("../lib/lang");
1106
+ var dom = require("../lib/dom");
1107
+ var nls = require("../config").nls;
1108
+ var userAgent = require("./../lib/useragent");
1109
+ var getAriaId = function (index) {
1110
+ return "suggest-aria-id:".concat(index);
1111
+ };
1112
+ var popupAriaRole = userAgent.isSafari ? "menu" : "listbox";
1113
+ var optionAriaRole = userAgent.isSafari ? "menuitem" : "option";
1114
+ var ariaActiveState = userAgent.isSafari ? "aria-current" : "aria-selected";
1115
+ var $singleLineEditor = function (el) {
1116
+ var renderer = new Renderer(el);
1117
+ renderer.$maxLines = 4;
1118
+ var editor = new Editor(renderer);
1119
+ editor.setHighlightActiveLine(false);
1120
+ editor.setShowPrintMargin(false);
1121
+ editor.renderer.setShowGutter(false);
1122
+ editor.renderer.setHighlightGutterLine(false);
1123
+ editor.$mouseHandler.$focusTimeout = 0;
1124
+ editor.$highlightTagPending = true;
1125
+ return editor;
1126
+ };
1127
+ var AcePopup = /** @class */ (function () {
1128
+ function AcePopup(parentNode) {
1129
+ var el = dom.createElement("div");
1130
+ var popup = $singleLineEditor(el);
1131
+ if (parentNode) {
1132
+ parentNode.appendChild(el);
1133
+ }
1134
+ el.style.display = "none";
1135
+ popup.renderer.content.style.cursor = "default";
1136
+ popup.renderer.setStyle("ace_autocomplete");
1137
+ popup.renderer.$textLayer.element.setAttribute("role", popupAriaRole);
1138
+ popup.renderer.$textLayer.element.setAttribute("aria-roledescription", nls("autocomplete.popup.aria-roledescription", "Autocomplete suggestions"));
1139
+ popup.renderer.$textLayer.element.setAttribute("aria-label", nls("autocomplete.popup.aria-label", "Autocomplete suggestions"));
1140
+ popup.renderer.textarea.setAttribute("aria-hidden", "true");
1141
+ popup.setOption("displayIndentGuides", false);
1142
+ popup.setOption("dragDelay", 150);
1143
+ var noop = function () { };
1144
+ popup.focus = noop;
1145
+ popup.$isFocused = true;
1146
+ popup.renderer.$cursorLayer.restartTimer = noop;
1147
+ popup.renderer.$cursorLayer.element.style.opacity = "0";
1148
+ popup.renderer.$maxLines = 8;
1149
+ popup.renderer.$keepTextAreaAtCursor = false;
1150
+ popup.setHighlightActiveLine(false);
1151
+ popup.session.highlight("");
1152
+ popup.session.$searchHighlight.clazz = "ace_highlight-marker";
1153
+ popup.on("mousedown", function (e) {
1154
+ var pos = e.getDocumentPosition();
1155
+ popup.selection.moveToPosition(pos);
1156
+ selectionMarker.start.row = selectionMarker.end.row = pos.row;
1157
+ e.stop();
1158
+ });
1159
+ var lastMouseEvent;
1160
+ var hoverMarker = new Range(-1, 0, -1, Infinity);
1161
+ var selectionMarker = new Range(-1, 0, -1, Infinity);
1162
+ selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine");
1163
+ popup.setSelectOnHover = function (val) {
1164
+ if (!val) {
1165
+ hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine");
1166
+ }
1167
+ else if (hoverMarker.id) {
1168
+ popup.session.removeMarker(hoverMarker.id);
1169
+ hoverMarker.id = null;
1170
+ }
1171
+ };
1172
+ popup.setSelectOnHover(false);
1173
+ popup.on("mousemove", function (e) {
1174
+ if (!lastMouseEvent) {
1175
+ lastMouseEvent = e;
1176
+ return;
1177
+ }
1178
+ if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) {
1179
+ return;
1180
+ }
1181
+ lastMouseEvent = e;
1182
+ lastMouseEvent.scrollTop = popup.renderer.scrollTop;
1183
+ popup.isMouseOver = true;
1184
+ var row = lastMouseEvent.getDocumentPosition().row;
1185
+ if (hoverMarker.start.row != row) {
1186
+ if (!hoverMarker.id)
1187
+ popup.setRow(row);
1188
+ setHoverMarker(row);
1189
+ }
1190
+ });
1191
+ popup.renderer.on("beforeRender", function () {
1192
+ if (lastMouseEvent && hoverMarker.start.row != -1) {
1193
+ lastMouseEvent.$pos = null;
1194
+ var row = lastMouseEvent.getDocumentPosition().row;
1195
+ if (!hoverMarker.id)
1196
+ popup.setRow(row);
1197
+ setHoverMarker(row, true);
1198
+ }
1199
+ });
1200
+ popup.renderer.on("afterRender", function () {
1201
+ var t = popup.renderer.$textLayer;
1202
+ for (var row = t.config.firstRow, l = t.config.lastRow; row <= l; row++) {
1203
+ var popupRowElement = /** @type {HTMLElement|null} */ (t.element.childNodes[row - t.config.firstRow]);
1204
+ popupRowElement.setAttribute("role", optionAriaRole);
1205
+ popupRowElement.setAttribute("aria-roledescription", nls("autocomplete.popup.item.aria-roledescription", "item"));
1206
+ popupRowElement.setAttribute("aria-setsize", popup.data.length);
1207
+ popupRowElement.setAttribute("aria-describedby", "doc-tooltip");
1208
+ popupRowElement.setAttribute("aria-posinset", row + 1);
1209
+ var rowData = popup.getData(row);
1210
+ if (rowData) {
1211
+ var ariaLabel = "".concat(rowData.caption || rowData.value).concat(rowData.meta ? ", ".concat(rowData.meta) : '');
1212
+ popupRowElement.setAttribute("aria-label", ariaLabel);
1213
+ }
1214
+ var highlightedSpans = popupRowElement.querySelectorAll(".ace_completion-highlight");
1215
+ highlightedSpans.forEach(function (span) {
1216
+ span.setAttribute("role", "mark");
1217
+ });
1218
+ }
1219
+ });
1220
+ popup.renderer.on("afterRender", function () {
1221
+ var row = popup.getRow();
1222
+ var t = popup.renderer.$textLayer;
1223
+ var selected = /** @type {HTMLElement|null} */ (t.element.childNodes[row - t.config.firstRow]);
1224
+ var el = document.activeElement; // Active element is textarea of main editor
1225
+ if (selected !== popup.selectedNode && popup.selectedNode) {
1226
+ dom.removeCssClass(popup.selectedNode, "ace_selected");
1227
+ popup.selectedNode.removeAttribute(ariaActiveState);
1228
+ popup.selectedNode.removeAttribute("id");
1229
+ }
1230
+ el.removeAttribute("aria-activedescendant");
1231
+ popup.selectedNode = selected;
1232
+ if (selected) {
1233
+ var ariaId = getAriaId(row);
1234
+ dom.addCssClass(selected, "ace_selected");
1235
+ selected.id = ariaId;
1236
+ t.element.setAttribute("aria-activedescendant", ariaId);
1237
+ el.setAttribute("aria-activedescendant", ariaId);
1238
+ selected.setAttribute(ariaActiveState, "true");
1239
+ }
1240
+ });
1241
+ var hideHoverMarker = function () { setHoverMarker(-1); };
1242
+ var setHoverMarker = function (row, suppressRedraw) {
1243
+ if (row !== hoverMarker.start.row) {
1244
+ hoverMarker.start.row = hoverMarker.end.row = row;
1245
+ if (!suppressRedraw)
1246
+ popup.session._emit("changeBackMarker");
1247
+ popup._emit("changeHoverMarker");
1248
+ }
1249
+ };
1250
+ popup.getHoveredRow = function () {
1251
+ return hoverMarker.start.row;
1252
+ };
1253
+ event.addListener(popup.container, "mouseout", function () {
1254
+ popup.isMouseOver = false;
1255
+ hideHoverMarker();
1256
+ });
1257
+ popup.on("hide", hideHoverMarker);
1258
+ popup.on("changeSelection", hideHoverMarker);
1259
+ popup.session.doc.getLength = function () {
1260
+ return popup.data.length;
1261
+ };
1262
+ popup.session.doc.getLine = function (i) {
1263
+ var data = popup.data[i];
1264
+ if (typeof data == "string")
1265
+ return data;
1266
+ return (data && data.value) || "";
1267
+ };
1268
+ var bgTokenizer = popup.session.bgTokenizer;
1269
+ bgTokenizer.$tokenizeRow = function (row) {
1270
+ var data = popup.data[row];
1271
+ var tokens = [];
1272
+ if (!data)
1273
+ return tokens;
1274
+ if (typeof data == "string")
1275
+ data = { value: data };
1276
+ var caption = data.caption || data.value || data.name;
1277
+ function addToken(value, className) {
1278
+ value && tokens.push({
1279
+ type: (data.className || "") + (className || ""),
1280
+ value: value
1281
+ });
1282
+ }
1283
+ var lower = caption.toLowerCase();
1284
+ var filterText = (popup.filterText || "").toLowerCase();
1285
+ var lastIndex = 0;
1286
+ var lastI = 0;
1287
+ for (var i = 0; i <= filterText.length; i++) {
1288
+ if (i != lastI && (data.matchMask & (1 << i) || i == filterText.length)) {
1289
+ var sub = filterText.slice(lastI, i);
1290
+ lastI = i;
1291
+ var index = lower.indexOf(sub, lastIndex);
1292
+ if (index == -1)
1293
+ continue;
1294
+ addToken(caption.slice(lastIndex, index), "");
1295
+ lastIndex = index + sub.length;
1296
+ addToken(caption.slice(index, lastIndex), "completion-highlight");
1297
+ }
1298
+ }
1299
+ addToken(caption.slice(lastIndex, caption.length), "");
1300
+ tokens.push({ type: "completion-spacer", value: " " });
1301
+ if (data.meta)
1302
+ tokens.push({ type: "completion-meta", value: data.meta });
1303
+ if (data.message)
1304
+ tokens.push({ type: "completion-message", value: data.message });
1305
+ return tokens;
1306
+ };
1307
+ bgTokenizer.$updateOnChange = noop;
1308
+ bgTokenizer.start = noop;
1309
+ popup.session.$computeWidth = function () {
1310
+ return this.screenWidth = 0;
1311
+ };
1312
+ popup.isOpen = false;
1313
+ popup.isTopdown = false;
1314
+ popup.autoSelect = true;
1315
+ popup.filterText = "";
1316
+ popup.isMouseOver = false;
1317
+ popup.data = [];
1318
+ popup.setData = function (list, filterText) {
1319
+ popup.filterText = filterText || "";
1320
+ popup.setValue(lang.stringRepeat("\n", list.length), -1);
1321
+ popup.data = list || [];
1322
+ popup.setRow(0);
1323
+ };
1324
+ popup.getData = function (row) {
1325
+ return popup.data[row];
1326
+ };
1327
+ popup.getRow = function () {
1328
+ return selectionMarker.start.row;
1329
+ };
1330
+ popup.setRow = function (line) {
1331
+ line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length - 1, line));
1332
+ if (selectionMarker.start.row != line) {
1333
+ popup.selection.clearSelection();
1334
+ selectionMarker.start.row = selectionMarker.end.row = line || 0;
1335
+ popup.session._emit("changeBackMarker");
1336
+ popup.moveCursorTo(line || 0, 0);
1337
+ if (popup.isOpen)
1338
+ popup._signal("select");
1339
+ }
1340
+ };
1341
+ popup.on("changeSelection", function () {
1342
+ if (popup.isOpen)
1343
+ popup.setRow(popup.selection.lead.row);
1344
+ popup.renderer.scrollCursorIntoView();
1345
+ });
1346
+ popup.hide = function () {
1347
+ this.container.style.display = "none";
1348
+ popup.anchorPos = null;
1349
+ popup.anchor = null;
1350
+ if (popup.isOpen) {
1351
+ popup.isOpen = false;
1352
+ this._signal("hide");
1353
+ }
1354
+ };
1355
+ popup.tryShow = function (pos, lineHeight, anchor, forceShow) {
1356
+ if (!forceShow && popup.isOpen && popup.anchorPos && popup.anchor &&
1357
+ popup.anchorPos.top === pos.top && popup.anchorPos.left === pos.left &&
1358
+ popup.anchor === anchor) {
1359
+ return true;
1360
+ }
1361
+ var el = this.container;
1362
+ var scrollBarSize = this.renderer.scrollBar.width || 10;
1363
+ var screenHeight = window.innerHeight - scrollBarSize;
1364
+ var screenWidth = window.innerWidth - scrollBarSize;
1365
+ var renderer = this.renderer;
1366
+ var maxH = renderer.$maxLines * lineHeight * 1.4;
1367
+ var dims = { top: 0, bottom: 0, left: 0 };
1368
+ var spaceBelow = screenHeight - pos.top - 3 * this.$borderSize - lineHeight;
1369
+ var spaceAbove = pos.top - 3 * this.$borderSize;
1370
+ if (!anchor) {
1371
+ if (spaceAbove <= spaceBelow || spaceBelow >= maxH) {
1372
+ anchor = "bottom";
1373
+ }
1374
+ else {
1375
+ anchor = "top";
1376
+ }
1377
+ }
1378
+ if (anchor === "top") {
1379
+ dims.bottom = pos.top - this.$borderSize;
1380
+ dims.top = dims.bottom - maxH;
1381
+ }
1382
+ else if (anchor === "bottom") {
1383
+ dims.top = pos.top + lineHeight + this.$borderSize;
1384
+ dims.bottom = dims.top + maxH;
1385
+ }
1386
+ var fitsX = dims.top >= 0 && dims.bottom <= screenHeight;
1387
+ if (!forceShow && !fitsX) {
1388
+ return false;
1389
+ }
1390
+ if (!fitsX) {
1391
+ if (anchor === "top") {
1392
+ renderer.$maxPixelHeight = spaceAbove;
1393
+ }
1394
+ else {
1395
+ renderer.$maxPixelHeight = spaceBelow;
1396
+ }
1397
+ }
1398
+ else {
1399
+ renderer.$maxPixelHeight = null;
1400
+ }
1401
+ if (anchor === "top") {
1402
+ el.style.top = "";
1403
+ el.style.bottom = (screenHeight + scrollBarSize - dims.bottom) + "px";
1404
+ popup.isTopdown = false;
1405
+ }
1406
+ else {
1407
+ el.style.top = dims.top + "px";
1408
+ el.style.bottom = "";
1409
+ popup.isTopdown = true;
1410
+ }
1411
+ el.style.display = "";
1412
+ var left = pos.left;
1413
+ if (left + el.offsetWidth > screenWidth)
1414
+ left = screenWidth - el.offsetWidth;
1415
+ el.style.left = left + "px";
1416
+ el.style.right = "";
1417
+ dom.$fixPositionBug(el);
1418
+ if (!popup.isOpen) {
1419
+ popup.isOpen = true;
1420
+ this._signal("show");
1421
+ lastMouseEvent = null;
1422
+ }
1423
+ popup.anchorPos = pos;
1424
+ popup.anchor = anchor;
1425
+ return true;
1426
+ };
1427
+ popup.show = function (pos, lineHeight, topdownOnly) {
1428
+ this.tryShow(pos, lineHeight, topdownOnly ? "bottom" : undefined, true);
1429
+ };
1430
+ popup.goTo = function (where) {
1431
+ var row = this.getRow();
1432
+ var max = this.session.getLength() - 1;
1433
+ switch (where) {
1434
+ case "up":
1435
+ row = row <= 0 ? max : row - 1;
1436
+ break;
1437
+ case "down":
1438
+ row = row >= max ? -1 : row + 1;
1439
+ break;
1440
+ case "start":
1441
+ row = 0;
1442
+ break;
1443
+ case "end":
1444
+ row = max;
1445
+ break;
1446
+ }
1447
+ this.setRow(row);
1448
+ };
1449
+ popup.getTextLeftOffset = function () {
1450
+ return this.$borderSize + this.renderer.$padding + this.$imageSize;
1451
+ };
1452
+ popup.$imageSize = 0;
1453
+ popup.$borderSize = 1;
1454
+ return popup;
1455
+ }
1456
+ return AcePopup;
1457
+ }());
1458
+ dom.importCssString("\n.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #CAD6FA;\n z-index: 1;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #3a674e;\n}\n.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid #abbffe;\n margin-top: -1px;\n background: rgba(233,233,253,0.4);\n position: absolute;\n z-index: 2;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid rgba(109, 150, 13, 0.8);\n background: rgba(58, 103, 78, 0.62);\n}\n.ace_completion-meta {\n opacity: 0.5;\n margin-left: 0.9em;\n}\n.ace_completion-message {\n margin-left: 0.9em;\n color: blue;\n}\n.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #2d69c7;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #93ca12;\n}\n.ace_editor.ace_autocomplete {\n width: 300px;\n z-index: 200000;\n border: 1px lightgray solid;\n position: fixed;\n box-shadow: 2px 3px 5px rgba(0,0,0,.2);\n line-height: 1.4;\n background: #fefefe;\n color: #111;\n}\n.ace_dark.ace_editor.ace_autocomplete {\n border: 1px #484747 solid;\n box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);\n line-height: 1.4;\n background: #25282c;\n color: #c1c1c1;\n}\n.ace_autocomplete .ace_text-layer {\n width: calc(100% - 8px);\n}\n.ace_autocomplete .ace_line {\n display: flex;\n align-items: center;\n}\n.ace_autocomplete .ace_line > * {\n min-width: 0;\n flex: 0 0 auto;\n}\n.ace_autocomplete .ace_line .ace_ {\n flex: 0 1 auto;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.ace_autocomplete .ace_completion-spacer {\n flex: 1;\n}\n.ace_autocomplete.ace_loading:after {\n content: \"\";\n position: absolute;\n top: 0px;\n height: 2px;\n width: 8%;\n background: blue;\n z-index: 100;\n animation: ace_progress 3s infinite linear;\n animation-delay: 300ms;\n transform: translateX(-100%) scaleX(1);\n}\n@keyframes ace_progress {\n 0% { transform: translateX(-100%) scaleX(1) }\n 50% { transform: translateX(625%) scaleX(2) } \n 100% { transform: translateX(1500%) scaleX(3) } \n}\n@media (prefers-reduced-motion) {\n .ace_autocomplete.ace_loading:after {\n transform: translateX(625%) scaleX(2);\n animation: none;\n }\n}\n", "autocompletion.css", false);
1459
+ exports.AcePopup = AcePopup;
1460
+ exports.$singleLineEditor = $singleLineEditor;
1461
+ exports.getAriaId = getAriaId;
1462
+
1463
+ });
1464
+
1465
+ ace.define("ace/autocomplete/util",["require","exports","module"], function(require, exports, module){"use strict";
1466
+ exports.parForEach = function (array, fn, callback) {
1467
+ var completed = 0;
1468
+ var arLength = array.length;
1469
+ if (arLength === 0)
1470
+ callback();
1471
+ for (var i = 0; i < arLength; i++) {
1472
+ fn(array[i], function (result, err) {
1473
+ completed++;
1474
+ if (completed === arLength)
1475
+ callback(result, err);
1476
+ });
1477
+ }
1478
+ };
1479
+ var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\u2000\u2070-\uFFFF]/;
1480
+ exports.retrievePrecedingIdentifier = function (text, pos, regex) {
1481
+ regex = regex || ID_REGEX;
1482
+ var buf = [];
1483
+ for (var i = pos - 1; i >= 0; i--) {
1484
+ if (regex.test(text[i]))
1485
+ buf.push(text[i]);
1486
+ else
1487
+ break;
1488
+ }
1489
+ return buf.reverse().join("");
1490
+ };
1491
+ exports.retrieveFollowingIdentifier = function (text, pos, regex) {
1492
+ regex = regex || ID_REGEX;
1493
+ var buf = [];
1494
+ for (var i = pos; i < text.length; i++) {
1495
+ if (regex.test(text[i]))
1496
+ buf.push(text[i]);
1497
+ else
1498
+ break;
1499
+ }
1500
+ return buf;
1501
+ };
1502
+ exports.getCompletionPrefix = function (editor) {
1503
+ var pos = editor.getCursorPosition();
1504
+ var line = editor.session.getLine(pos.row);
1505
+ var prefix;
1506
+ editor.completers.forEach(function (completer) {
1507
+ if (completer.identifierRegexps) {
1508
+ completer.identifierRegexps.forEach(function (identifierRegex) {
1509
+ if (!prefix && identifierRegex)
1510
+ prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
1511
+ }.bind(this));
1512
+ }
1513
+ }.bind(this));
1514
+ return prefix || this.retrievePrecedingIdentifier(line, pos.column);
1515
+ };
1516
+ exports.triggerAutocomplete = function (editor, previousChar) {
1517
+ var previousChar = previousChar == null
1518
+ ? editor.session.getPrecedingCharacter()
1519
+ : previousChar;
1520
+ return editor.completers.some(function (completer) {
1521
+ if (completer.triggerCharacters && Array.isArray(completer.triggerCharacters)) {
1522
+ return completer.triggerCharacters.includes(previousChar);
1523
+ }
1524
+ });
1525
+ };
1526
+
1527
+ });
1528
+
1529
+ ace.define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/inline","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/lang","ace/lib/dom","ace/snippets","ace/config","ace/lib/event","ace/lib/scroll"], function(require, exports, module){"use strict";
1530
+ var HashHandler = require("./keyboard/hash_handler").HashHandler;
1531
+ var AcePopup = require("./autocomplete/popup").AcePopup;
1532
+ var AceInline = require("./autocomplete/inline").AceInline;
1533
+ var getAriaId = require("./autocomplete/popup").getAriaId;
1534
+ var util = require("./autocomplete/util");
1535
+ var lang = require("./lib/lang");
1536
+ var dom = require("./lib/dom");
1537
+ var snippetManager = require("./snippets").snippetManager;
1538
+ var config = require("./config");
1539
+ var event = require("./lib/event");
1540
+ var preventParentScroll = require("./lib/scroll").preventParentScroll;
1541
+ var destroyCompleter = function (e, editor) {
1542
+ editor.completer && editor.completer.destroy();
1543
+ };
1544
+ var Autocomplete = /** @class */ (function () {
1545
+ function Autocomplete() {
1546
+ this.autoInsert = false;
1547
+ this.autoSelect = true;
1548
+ this.autoShown = false;
1549
+ this.exactMatch = false;
1550
+ this.inlineEnabled = false;
1551
+ this.keyboardHandler = new HashHandler();
1552
+ this.keyboardHandler.bindKeys(this.commands);
1553
+ this.parentNode = null;
1554
+ this.setSelectOnHover = false;
1555
+ this.hasSeen = new Set();
1556
+ this.showLoadingState = false;
1557
+ this.stickySelectionDelay = 500;
1558
+ this.blurListener = this.blurListener.bind(this);
1559
+ this.changeListener = this.changeListener.bind(this);
1560
+ this.mousedownListener = this.mousedownListener.bind(this);
1561
+ this.mousewheelListener = this.mousewheelListener.bind(this);
1562
+ this.onLayoutChange = this.onLayoutChange.bind(this);
1563
+ this.changeTimer = lang.delayedCall(function () {
1564
+ this.updateCompletions(true);
1565
+ }.bind(this));
1566
+ this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
1567
+ this.popupTimer = lang.delayedCall(this.$updatePopupPosition.bind(this), 50);
1568
+ this.stickySelectionTimer = lang.delayedCall(function () {
1569
+ this.stickySelection = true;
1570
+ }.bind(this), this.stickySelectionDelay);
1571
+ this.$firstOpenTimer = lang.delayedCall(/**@this{Autocomplete}*/ function () {
1572
+ var initialPosition = this.completionProvider && this.completionProvider.initialPosition;
1573
+ if (this.autoShown || (this.popup && this.popup.isOpen) || !initialPosition || this.editor.completers.length === 0)
1574
+ return;
1575
+ this.completions = new FilteredList(Autocomplete.completionsForLoading);
1576
+ this.openPopup(this.editor, initialPosition.prefix, false);
1577
+ this.popup.renderer.setStyle("ace_loading", true);
1578
+ }.bind(this), this.stickySelectionDelay);
1579
+ }
1580
+ Object.defineProperty(Autocomplete, "completionsForLoading", {
1581
+ get: function () {
1582
+ return [{
1583
+ caption: config.nls("autocomplete.loading", "Loading..."),
1584
+ value: ""
1585
+ }];
1586
+ },
1587
+ enumerable: false,
1588
+ configurable: true
1589
+ });
1590
+ Autocomplete.prototype.$init = function () {
1591
+ this.popup = new AcePopup(this.parentNode || document.body || document.documentElement);
1592
+ this.popup.on("click", function (e) {
1593
+ this.insertMatch();
1594
+ e.stop();
1595
+ }.bind(this));
1596
+ this.popup.focus = this.editor.focus.bind(this.editor);
1597
+ this.popup.on("show", this.$onPopupShow.bind(this));
1598
+ this.popup.on("hide", this.$onHidePopup.bind(this));
1599
+ this.popup.on("select", this.$onPopupChange.bind(this));
1600
+ event.addListener(this.popup.container, "mouseout", this.mouseOutListener.bind(this));
1601
+ this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null));
1602
+ this.popup.renderer.on("afterRender", this.$onPopupRender.bind(this));
1603
+ return this.popup;
1604
+ };
1605
+ Autocomplete.prototype.$initInline = function () {
1606
+ if (!this.inlineEnabled || this.inlineRenderer)
1607
+ return;
1608
+ this.inlineRenderer = new AceInline();
1609
+ return this.inlineRenderer;
1610
+ };
1611
+ Autocomplete.prototype.getPopup = function () {
1612
+ return this.popup || this.$init();
1613
+ };
1614
+ Autocomplete.prototype.$onHidePopup = function () {
1615
+ if (this.inlineRenderer) {
1616
+ this.inlineRenderer.hide();
1617
+ }
1618
+ this.hideDocTooltip();
1619
+ this.stickySelectionTimer.cancel();
1620
+ this.popupTimer.cancel();
1621
+ this.stickySelection = false;
1622
+ };
1623
+ Autocomplete.prototype.$seen = function (completion) {
1624
+ if (!this.hasSeen.has(completion) && completion && completion.completer && completion.completer.onSeen && typeof completion.completer.onSeen === "function") {
1625
+ completion.completer.onSeen(this.editor, completion);
1626
+ this.hasSeen.add(completion);
1627
+ }
1628
+ };
1629
+ Autocomplete.prototype.$onPopupChange = function (hide) {
1630
+ if (this.inlineRenderer && this.inlineEnabled) {
1631
+ var completion = hide ? null : this.popup.getData(this.popup.getRow());
1632
+ this.$updateGhostText(completion);
1633
+ if (this.popup.isMouseOver && this.setSelectOnHover) {
1634
+ this.tooltipTimer.call(null, null);
1635
+ return;
1636
+ }
1637
+ this.popupTimer.schedule();
1638
+ this.tooltipTimer.schedule();
1639
+ }
1640
+ else {
1641
+ this.popupTimer.call(null, null);
1642
+ this.tooltipTimer.call(null, null);
1643
+ }
1644
+ };
1645
+ Autocomplete.prototype.$updateGhostText = function (completion) {
1646
+ var row = this.base.row;
1647
+ var column = this.base.column;
1648
+ var cursorColumn = this.editor.getCursorPosition().column;
1649
+ var prefix = this.editor.session.getLine(row).slice(column, cursorColumn);
1650
+ if (!this.inlineRenderer.show(this.editor, completion, prefix)) {
1651
+ this.inlineRenderer.hide();
1652
+ }
1653
+ else {
1654
+ this.$seen(completion);
1655
+ }
1656
+ };
1657
+ Autocomplete.prototype.$onPopupRender = function () {
1658
+ var inlineEnabled = this.inlineRenderer && this.inlineEnabled;
1659
+ if (this.completions && this.completions.filtered && this.completions.filtered.length > 0) {
1660
+ for (var i = this.popup.getFirstVisibleRow(); i <= this.popup.getLastVisibleRow(); i++) {
1661
+ var completion = this.popup.getData(i);
1662
+ if (completion && (!inlineEnabled || completion.hideInlinePreview)) {
1663
+ this.$seen(completion);
1664
+ }
1665
+ }
1666
+ }
1667
+ };
1668
+ Autocomplete.prototype.$onPopupShow = function (hide) {
1669
+ this.$onPopupChange(hide);
1670
+ this.stickySelection = false;
1671
+ if (this.stickySelectionDelay >= 0)
1672
+ this.stickySelectionTimer.schedule(this.stickySelectionDelay);
1673
+ };
1674
+ Autocomplete.prototype.observeLayoutChanges = function () {
1675
+ if (this.$elements || !this.editor)
1676
+ return;
1677
+ window.addEventListener("resize", this.onLayoutChange, { passive: true });
1678
+ window.addEventListener("wheel", this.mousewheelListener);
1679
+ var el = this.editor.container.parentNode;
1680
+ var elements = [];
1681
+ while (el) {
1682
+ elements.push(el);
1683
+ el.addEventListener("scroll", this.onLayoutChange, { passive: true });
1684
+ el = el.parentNode;
1685
+ }
1686
+ this.$elements = elements;
1687
+ };
1688
+ Autocomplete.prototype.unObserveLayoutChanges = function () {
1689
+ var _this = this;
1690
+ window.removeEventListener("resize", this.onLayoutChange, { passive: true });
1691
+ window.removeEventListener("wheel", this.mousewheelListener);
1692
+ this.$elements && this.$elements.forEach(function (el) {
1693
+ el.removeEventListener("scroll", _this.onLayoutChange, { passive: true });
1694
+ });
1695
+ this.$elements = null;
1696
+ };
1697
+ Autocomplete.prototype.onLayoutChange = function () {
1698
+ if (!this.popup.isOpen)
1699
+ return this.unObserveLayoutChanges();
1700
+ this.$updatePopupPosition();
1701
+ this.updateDocTooltip();
1702
+ };
1703
+ Autocomplete.prototype.$updatePopupPosition = function () {
1704
+ var editor = this.editor;
1705
+ var renderer = editor.renderer;
1706
+ var lineHeight = renderer.layerConfig.lineHeight;
1707
+ var pos = renderer.$cursorLayer.getPixelPosition(this.base, true);
1708
+ pos.left -= this.popup.getTextLeftOffset();
1709
+ var rect = editor.container.getBoundingClientRect();
1710
+ pos.top += rect.top - renderer.layerConfig.offset;
1711
+ pos.left += rect.left - editor.renderer.scrollLeft;
1712
+ pos.left += renderer.gutterWidth;
1713
+ var posGhostText = {
1714
+ top: pos.top,
1715
+ left: pos.left
1716
+ };
1717
+ if (renderer.$ghostText && renderer.$ghostTextWidget) {
1718
+ if (this.base.row === renderer.$ghostText.position.row) {
1719
+ posGhostText.top += renderer.$ghostTextWidget.el.offsetHeight;
1720
+ }
1721
+ }
1722
+ var editorContainerBottom = editor.container.getBoundingClientRect().bottom - lineHeight;
1723
+ var lowestPosition = editorContainerBottom < posGhostText.top ?
1724
+ { top: editorContainerBottom, left: posGhostText.left } :
1725
+ posGhostText;
1726
+ if (this.popup.tryShow(lowestPosition, lineHeight, "bottom")) {
1727
+ return;
1728
+ }
1729
+ if (this.popup.tryShow(pos, lineHeight, "top")) {
1730
+ return;
1731
+ }
1732
+ this.popup.show(pos, lineHeight);
1733
+ };
1734
+ Autocomplete.prototype.openPopup = function (editor, prefix, keepPopupPosition) {
1735
+ this.$firstOpenTimer.cancel();
1736
+ if (!this.popup)
1737
+ this.$init();
1738
+ if (this.inlineEnabled && !this.inlineRenderer)
1739
+ this.$initInline();
1740
+ this.popup.autoSelect = this.autoSelect;
1741
+ this.popup.setSelectOnHover(this.setSelectOnHover);
1742
+ var oldRow = this.popup.getRow();
1743
+ var previousSelectedItem = this.popup.data[oldRow];
1744
+ this.popup.setData(this.completions.filtered, this.completions.filterText);
1745
+ if (this.editor.textInput.setAriaOptions) {
1746
+ this.editor.textInput.setAriaOptions({
1747
+ activeDescendant: getAriaId(this.popup.getRow()),
1748
+ inline: this.inlineEnabled
1749
+ });
1750
+ }
1751
+ editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
1752
+ var newRow;
1753
+ if (this.stickySelection)
1754
+ newRow = this.popup.data.indexOf(previousSelectedItem);
1755
+ if (!newRow || newRow === -1)
1756
+ newRow = 0;
1757
+ this.popup.setRow(this.autoSelect ? newRow : -1);
1758
+ if (newRow === oldRow && previousSelectedItem !== this.completions.filtered[newRow])
1759
+ this.$onPopupChange();
1760
+ var inlineEnabled = this.inlineRenderer && this.inlineEnabled;
1761
+ if (newRow === oldRow && inlineEnabled) {
1762
+ var completion = this.popup.getData(this.popup.getRow());
1763
+ this.$updateGhostText(completion);
1764
+ }
1765
+ if (!keepPopupPosition) {
1766
+ this.popup.setTheme(editor.getTheme());
1767
+ this.popup.setFontSize(editor.getFontSize());
1768
+ this.$updatePopupPosition();
1769
+ if (this.tooltipNode) {
1770
+ this.updateDocTooltip();
1771
+ }
1772
+ }
1773
+ this.changeTimer.cancel();
1774
+ this.observeLayoutChanges();
1775
+ };
1776
+ Autocomplete.prototype.detach = function () {
1777
+ if (this.editor) {
1778
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
1779
+ this.editor.off("changeSelection", this.changeListener);
1780
+ this.editor.off("blur", this.blurListener);
1781
+ this.editor.off("mousedown", this.mousedownListener);
1782
+ this.editor.off("mousewheel", this.mousewheelListener);
1783
+ }
1784
+ this.$firstOpenTimer.cancel();
1785
+ this.changeTimer.cancel();
1786
+ this.hideDocTooltip();
1787
+ if (this.completionProvider) {
1788
+ this.completionProvider.detach();
1789
+ }
1790
+ if (this.popup && this.popup.isOpen)
1791
+ this.popup.hide();
1792
+ if (this.popup && this.popup.renderer) {
1793
+ this.popup.renderer.off("afterRender", this.$onPopupRender);
1794
+ }
1795
+ if (this.base)
1796
+ this.base.detach();
1797
+ this.activated = false;
1798
+ this.completionProvider = this.completions = this.base = null;
1799
+ this.unObserveLayoutChanges();
1800
+ };
1801
+ Autocomplete.prototype.changeListener = function (e) {
1802
+ var cursor = this.editor.selection.lead;
1803
+ if (cursor.row != this.base.row || cursor.column < this.base.column) {
1804
+ this.detach();
1805
+ }
1806
+ if (this.activated)
1807
+ this.changeTimer.schedule();
1808
+ else
1809
+ this.detach();
1810
+ };
1811
+ Autocomplete.prototype.blurListener = function (e) {
1812
+ var el = document.activeElement;
1813
+ var text = this.editor.textInput.getElement();
1814
+ var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget);
1815
+ var container = this.popup && this.popup.container;
1816
+ if (el != text && el.parentNode != container && !fromTooltip
1817
+ && el != this.tooltipNode && e.relatedTarget != text) {
1818
+ this.detach();
1819
+ }
1820
+ };
1821
+ Autocomplete.prototype.mousedownListener = function (e) {
1822
+ this.detach();
1823
+ };
1824
+ Autocomplete.prototype.mousewheelListener = function (e) {
1825
+ if (this.popup && !this.popup.isMouseOver)
1826
+ this.detach();
1827
+ };
1828
+ Autocomplete.prototype.mouseOutListener = function (e) {
1829
+ if (this.popup.isOpen)
1830
+ this.$updatePopupPosition();
1831
+ };
1832
+ Autocomplete.prototype.goTo = function (where) {
1833
+ this.popup.goTo(where);
1834
+ };
1835
+ Autocomplete.prototype.insertMatch = function (data, options) {
1836
+ if (!data)
1837
+ data = this.popup.getData(this.popup.getRow());
1838
+ if (!data)
1839
+ return false;
1840
+ if (data.value === "") // Explicitly given nothing to insert, e.g. "No suggestion state"
1841
+ return this.detach();
1842
+ var completions = this.completions;
1843
+ var result = this.getCompletionProvider().insertMatch(this.editor, data, completions.filterText, options);
1844
+ if (this.completions == completions)
1845
+ this.detach();
1846
+ return result;
1847
+ };
1848
+ Autocomplete.prototype.showPopup = function (editor, options) {
1849
+ if (this.editor)
1850
+ this.detach();
1851
+ this.activated = true;
1852
+ this.editor = editor;
1853
+ if (editor.completer != this) {
1854
+ if (editor.completer)
1855
+ editor.completer.detach();
1856
+ editor.completer = this;
1857
+ }
1858
+ editor.on("changeSelection", this.changeListener);
1859
+ editor.on("blur", this.blurListener);
1860
+ editor.on("mousedown", this.mousedownListener);
1861
+ editor.on("mousewheel", this.mousewheelListener);
1862
+ this.updateCompletions(false, options);
1863
+ };
1864
+ Autocomplete.prototype.getCompletionProvider = function (initialPosition) {
1865
+ if (!this.completionProvider)
1866
+ this.completionProvider = new CompletionProvider(initialPosition);
1867
+ return this.completionProvider;
1868
+ };
1869
+ Autocomplete.prototype.gatherCompletions = function (editor, callback) {
1870
+ return this.getCompletionProvider().gatherCompletions(editor, callback);
1871
+ };
1872
+ Autocomplete.prototype.updateCompletions = function (keepPopupPosition, options) {
1873
+ if (keepPopupPosition && this.base && this.completions) {
1874
+ var pos = this.editor.getCursorPosition();
1875
+ var prefix = this.editor.session.getTextRange({ start: this.base, end: pos });
1876
+ if (prefix == this.completions.filterText)
1877
+ return;
1878
+ this.completions.setFilter(prefix);
1879
+ if (!this.completions.filtered.length)
1880
+ return this.detach();
1881
+ if (this.completions.filtered.length == 1
1882
+ && this.completions.filtered[0].value == prefix
1883
+ && !this.completions.filtered[0].snippet)
1884
+ return this.detach();
1885
+ this.openPopup(this.editor, prefix, keepPopupPosition);
1886
+ return;
1887
+ }
1888
+ if (options && options.matches) {
1889
+ var pos = this.editor.getSelectionRange().start;
1890
+ this.base = this.editor.session.doc.createAnchor(pos.row, pos.column);
1891
+ this.base.$insertRight = true;
1892
+ this.completions = new FilteredList(options.matches);
1893
+ this.getCompletionProvider().completions = this.completions;
1894
+ return this.openPopup(this.editor, "", keepPopupPosition);
1895
+ }
1896
+ var session = this.editor.getSession();
1897
+ var pos = this.editor.getCursorPosition();
1898
+ var prefix = util.getCompletionPrefix(this.editor);
1899
+ this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
1900
+ this.base.$insertRight = true;
1901
+ var completionOptions = {
1902
+ exactMatch: this.exactMatch,
1903
+ ignoreCaption: this.ignoreCaption
1904
+ };
1905
+ this.getCompletionProvider({
1906
+ prefix: prefix,
1907
+ pos: pos
1908
+ }).provideCompletions(this.editor, completionOptions,
1909
+ function (err, completions, finished) {
1910
+ var filtered = completions.filtered;
1911
+ var prefix = util.getCompletionPrefix(this.editor);
1912
+ this.$firstOpenTimer.cancel();
1913
+ if (finished) {
1914
+ if (!filtered.length) {
1915
+ var emptyMessage = !this.autoShown && this.emptyMessage;
1916
+ if (typeof emptyMessage == "function")
1917
+ emptyMessage = this.emptyMessage(prefix);
1918
+ if (emptyMessage) {
1919
+ var completionsForEmpty = [{
1920
+ caption: emptyMessage,
1921
+ value: ""
1922
+ }
1923
+ ];
1924
+ this.completions = new FilteredList(completionsForEmpty);
1925
+ this.openPopup(this.editor, prefix, keepPopupPosition);
1926
+ this.popup.renderer.setStyle("ace_loading", false);
1927
+ this.popup.renderer.setStyle("ace_empty-message", true);
1928
+ return;
1929
+ }
1930
+ return this.detach();
1931
+ }
1932
+ if (filtered.length == 1 && filtered[0].value == prefix
1933
+ && !filtered[0].snippet)
1934
+ return this.detach();
1935
+ if (this.autoInsert && !this.autoShown && filtered.length == 1)
1936
+ return this.insertMatch(filtered[0]);
1937
+ }
1938
+ this.completions = !finished && this.showLoadingState ?
1939
+ new FilteredList(Autocomplete.completionsForLoading.concat(filtered), completions.filterText) :
1940
+ completions;
1941
+ this.openPopup(this.editor, prefix, keepPopupPosition);
1942
+ this.popup.renderer.setStyle("ace_empty-message", false);
1943
+ this.popup.renderer.setStyle("ace_loading", !finished);
1944
+ }.bind(this));
1945
+ if (this.showLoadingState && !this.autoShown && !(this.popup && this.popup.isOpen)) {
1946
+ this.$firstOpenTimer.delay(this.stickySelectionDelay / 2);
1947
+ }
1948
+ };
1949
+ Autocomplete.prototype.cancelContextMenu = function () {
1950
+ this.editor.$mouseHandler.cancelContextMenu();
1951
+ };
1952
+ Autocomplete.prototype.updateDocTooltip = function () {
1953
+ var popup = this.popup;
1954
+ var all = this.completions && this.completions.filtered;
1955
+ var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]);
1956
+ var doc = null;
1957
+ if (!selected || !this.editor || !this.popup.isOpen)
1958
+ return this.hideDocTooltip();
1959
+ var completersLength = this.editor.completers.length;
1960
+ for (var i = 0; i < completersLength; i++) {
1961
+ var completer = this.editor.completers[i];
1962
+ if (completer.getDocTooltip && selected.completerId === completer.id) {
1963
+ doc = completer.getDocTooltip(selected);
1964
+ break;
1965
+ }
1966
+ }
1967
+ if (!doc && typeof selected != "string")
1968
+ doc = selected;
1969
+ if (typeof doc == "string")
1970
+ doc = { docText: doc };
1971
+ if (!doc || !(doc.docHTML || doc.docText))
1972
+ return this.hideDocTooltip();
1973
+ this.showDocTooltip(doc);
1974
+ };
1975
+ Autocomplete.prototype.showDocTooltip = function (item) {
1976
+ if (!this.tooltipNode) {
1977
+ this.tooltipNode = dom.createElement("div");
1978
+ this.tooltipNode.style.margin = "0";
1979
+ this.tooltipNode.style.pointerEvents = "auto";
1980
+ this.tooltipNode.style.overscrollBehavior = "contain";
1981
+ this.tooltipNode.tabIndex = -1;
1982
+ this.tooltipNode.onblur = this.blurListener.bind(this);
1983
+ this.tooltipNode.onclick = this.onTooltipClick.bind(this);
1984
+ this.tooltipNode.id = "doc-tooltip";
1985
+ this.tooltipNode.setAttribute("role", "tooltip");
1986
+ this.tooltipNode.addEventListener("wheel", preventParentScroll);
1987
+ }
1988
+ var theme = this.editor.renderer.theme;
1989
+ this.tooltipNode.className = "ace_tooltip ace_doc-tooltip " +
1990
+ (theme.isDark ? "ace_dark " : "") + (theme.cssClass || "");
1991
+ var tooltipNode = this.tooltipNode;
1992
+ if (item.docHTML) {
1993
+ tooltipNode.innerHTML = item.docHTML;
1994
+ }
1995
+ else if (item.docText) {
1996
+ tooltipNode.textContent = item.docText;
1997
+ }
1998
+ if (!tooltipNode.parentNode)
1999
+ this.popup.container.appendChild(this.tooltipNode);
2000
+ var popup = this.popup;
2001
+ var rect = popup.container.getBoundingClientRect();
2002
+ var targetWidth = 400;
2003
+ var targetHeight = 300;
2004
+ var scrollBarSize = popup.renderer.scrollBar.width || 10;
2005
+ var leftSize = rect.left;
2006
+ var rightSize = window.innerWidth - rect.right - scrollBarSize;
2007
+ var topSize = popup.isTopdown ? window.innerHeight - scrollBarSize - rect.bottom : rect.top;
2008
+ var scores = [
2009
+ Math.min(rightSize / targetWidth, 1),
2010
+ Math.min(leftSize / targetWidth, 1),
2011
+ Math.min(topSize / targetHeight, 1) * 0.9,
2012
+ ];
2013
+ var max = Math.max.apply(Math, scores);
2014
+ var tooltipStyle = tooltipNode.style;
2015
+ tooltipStyle.display = "block";
2016
+ if (max == scores[0] || scores[0] >= 1) {
2017
+ tooltipStyle.left = (rect.right + 1) + "px";
2018
+ tooltipStyle.right = "";
2019
+ tooltipStyle.maxWidth = targetWidth * max + "px";
2020
+ tooltipStyle.top = rect.top + "px";
2021
+ tooltipStyle.bottom = "";
2022
+ tooltipStyle.maxHeight = Math.min(window.innerHeight - scrollBarSize - rect.top, targetHeight) + "px";
2023
+ }
2024
+ else if (max == scores[1] || scores[1] >= 1) {
2025
+ tooltipStyle.right = window.innerWidth - rect.left + "px";
2026
+ tooltipStyle.left = "";
2027
+ tooltipStyle.maxWidth = targetWidth * max + "px";
2028
+ tooltipStyle.top = rect.top + "px";
2029
+ tooltipStyle.bottom = "";
2030
+ tooltipStyle.maxHeight = Math.min(window.innerHeight - scrollBarSize - rect.top, targetHeight) + "px";
2031
+ }
2032
+ else if (max == scores[2]) {
2033
+ tooltipStyle.left = rect.left + "px";
2034
+ tooltipStyle.right = "";
2035
+ tooltipStyle.maxWidth = Math.min(targetWidth, window.innerWidth - rect.left) + "px";
2036
+ if (popup.isTopdown) {
2037
+ tooltipStyle.top = rect.bottom + "px";
2038
+ tooltipStyle.bottom = "";
2039
+ tooltipStyle.maxHeight = Math.min(window.innerHeight - scrollBarSize - rect.bottom, targetHeight) + "px";
2040
+ }
2041
+ else {
2042
+ tooltipStyle.top = "";
2043
+ tooltipStyle.bottom = (window.innerHeight - rect.top) + "px";
2044
+ tooltipStyle.maxHeight = Math.min(rect.top, targetHeight) + "px";
2045
+ }
2046
+ }
2047
+ dom.$fixPositionBug(tooltipNode);
2048
+ };
2049
+ Autocomplete.prototype.hideDocTooltip = function () {
2050
+ this.tooltipTimer.cancel();
2051
+ if (!this.tooltipNode)
2052
+ return;
2053
+ var el = this.tooltipNode;
2054
+ if (!this.editor.isFocused() && document.activeElement == el)
2055
+ this.editor.focus();
2056
+ this.tooltipNode = null;
2057
+ if (el.parentNode)
2058
+ el.parentNode.removeChild(el);
2059
+ };
2060
+ Autocomplete.prototype.onTooltipClick = function (e) {
2061
+ var a = e.target;
2062
+ while (a && a != this.tooltipNode) {
2063
+ if (a.nodeName == "A" && a.href) {
2064
+ a.rel = "noreferrer";
2065
+ a.target = "_blank";
2066
+ break;
2067
+ }
2068
+ a = a.parentNode;
2069
+ }
2070
+ };
2071
+ Autocomplete.prototype.destroy = function () {
2072
+ this.detach();
2073
+ if (this.popup) {
2074
+ this.popup.destroy();
2075
+ var el = this.popup.container;
2076
+ if (el && el.parentNode)
2077
+ el.parentNode.removeChild(el);
2078
+ }
2079
+ if (this.editor && this.editor.completer == this) {
2080
+ this.editor.off("destroy", destroyCompleter);
2081
+ this.editor.completer = null;
2082
+ }
2083
+ this.inlineRenderer = this.popup = this.editor = null;
2084
+ };
2085
+ Autocomplete.for = function (editor) {
2086
+ if (editor.completer instanceof Autocomplete) {
2087
+ return editor.completer;
2088
+ }
2089
+ if (editor.completer) {
2090
+ editor.completer.destroy();
2091
+ editor.completer = null;
2092
+ }
2093
+ if (config.get("sharedPopups")) {
2094
+ if (!Autocomplete["$sharedInstance"])
2095
+ Autocomplete["$sharedInstance"] = new Autocomplete();
2096
+ editor.completer = Autocomplete["$sharedInstance"];
2097
+ }
2098
+ else {
2099
+ editor.completer = new Autocomplete();
2100
+ editor.once("destroy", destroyCompleter);
2101
+ }
2102
+ return editor.completer;
2103
+ };
2104
+ return Autocomplete;
2105
+ }());
2106
+ Autocomplete.prototype.commands = {
2107
+ "Up": function (editor) { editor.completer.goTo("up"); },
2108
+ "Down": function (editor) { editor.completer.goTo("down"); },
2109
+ "Ctrl-Up|Ctrl-Home": function (editor) { editor.completer.goTo("start"); },
2110
+ "Ctrl-Down|Ctrl-End": function (editor) { editor.completer.goTo("end"); },
2111
+ "Esc": function (editor) { editor.completer.detach(); },
2112
+ "Return": function (editor) { return editor.completer.insertMatch(); },
2113
+ "Shift-Return": function (editor) { editor.completer.insertMatch(null, { deleteSuffix: true }); },
2114
+ "Tab": function (editor) {
2115
+ var result = editor.completer.insertMatch();
2116
+ if (!result && !editor.tabstopManager)
2117
+ editor.completer.goTo("down");
2118
+ else
2119
+ return result;
2120
+ },
2121
+ "Backspace": function (editor) {
2122
+ editor.execCommand("backspace");
2123
+ var prefix = util.getCompletionPrefix(editor);
2124
+ if (!prefix && editor.completer)
2125
+ editor.completer.detach();
2126
+ },
2127
+ "PageUp": function (editor) { editor.completer.popup.gotoPageUp(); },
2128
+ "PageDown": function (editor) { editor.completer.popup.gotoPageDown(); }
2129
+ };
2130
+ Autocomplete.startCommand = {
2131
+ name: "startAutocomplete",
2132
+ exec: function (editor, options) {
2133
+ var completer = Autocomplete.for(editor);
2134
+ completer.autoInsert = false;
2135
+ completer.autoSelect = true;
2136
+ completer.autoShown = false;
2137
+ completer.showPopup(editor, options);
2138
+ completer.cancelContextMenu();
2139
+ },
2140
+ bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
2141
+ };
2142
+ var CompletionProvider = /** @class */ (function () {
2143
+ function CompletionProvider(initialPosition) {
2144
+ this.initialPosition = initialPosition;
2145
+ this.active = true;
2146
+ }
2147
+ CompletionProvider.prototype.insertByIndex = function (editor, index, options) {
2148
+ if (!this.completions || !this.completions.filtered) {
2149
+ return false;
2150
+ }
2151
+ return this.insertMatch(editor, this.completions.filtered[index], options);
2152
+ };
2153
+ CompletionProvider.prototype.insertMatch = function (editor, data, options) {
2154
+ if (!data)
2155
+ return false;
2156
+ editor.startOperation({ command: { name: "insertMatch" } });
2157
+ if (data.completer && data.completer.insertMatch) {
2158
+ data.completer.insertMatch(editor, data);
2159
+ }
2160
+ else {
2161
+ if (!this.completions)
2162
+ return false;
2163
+ var replaceBefore = this.completions.filterText.length;
2164
+ var replaceAfter = 0;
2165
+ if (data.range && data.range.start.row === data.range.end.row) {
2166
+ replaceBefore -= this.initialPosition.prefix.length;
2167
+ replaceBefore += this.initialPosition.pos.column - data.range.start.column;
2168
+ replaceAfter += data.range.end.column - this.initialPosition.pos.column;
2169
+ }
2170
+ if (replaceBefore || replaceAfter) {
2171
+ var ranges;
2172
+ if (editor.selection.getAllRanges) {
2173
+ ranges = editor.selection.getAllRanges();
2174
+ }
2175
+ else {
2176
+ ranges = [editor.getSelectionRange()];
2177
+ }
2178
+ for (var i = 0, range; range = ranges[i]; i++) {
2179
+ range.start.column -= replaceBefore;
2180
+ range.end.column += replaceAfter;
2181
+ editor.session.remove(range);
2182
+ }
2183
+ }
2184
+ if (data.snippet) {
2185
+ snippetManager.insertSnippet(editor, data.snippet);
2186
+ }
2187
+ else {
2188
+ this.$insertString(editor, data);
2189
+ }
2190
+ if (data.completer && data.completer.onInsert && typeof data.completer.onInsert == "function") {
2191
+ data.completer.onInsert(editor, data);
2192
+ }
2193
+ if (data.command && data.command === "startAutocomplete") {
2194
+ editor.execCommand(data.command);
2195
+ }
2196
+ }
2197
+ editor.endOperation();
2198
+ return true;
2199
+ };
2200
+ CompletionProvider.prototype.$insertString = function (editor, data) {
2201
+ var text = data.value || data;
2202
+ editor.execCommand("insertstring", text);
2203
+ };
2204
+ CompletionProvider.prototype.gatherCompletions = function (editor, callback) {
2205
+ var session = editor.getSession();
2206
+ var pos = editor.getCursorPosition();
2207
+ var prefix = util.getCompletionPrefix(editor);
2208
+ var matches = [];
2209
+ this.completers = editor.completers;
2210
+ var total = editor.completers.length;
2211
+ editor.completers.forEach(function (completer, i) {
2212
+ completer.getCompletions(editor, session, pos, prefix, function (err, results) {
2213
+ if (completer.hideInlinePreview)
2214
+ results = results.map(function (result) {
2215
+ return Object.assign(result, { hideInlinePreview: completer.hideInlinePreview });
2216
+ });
2217
+ if (!err && results)
2218
+ matches = matches.concat(results);
2219
+ callback(null, {
2220
+ prefix: util.getCompletionPrefix(editor),
2221
+ matches: matches,
2222
+ finished: (--total === 0)
2223
+ });
2224
+ });
2225
+ });
2226
+ return true;
2227
+ };
2228
+ CompletionProvider.prototype.provideCompletions = function (editor, options, callback) {
2229
+ var processResults = function (results) {
2230
+ var prefix = results.prefix;
2231
+ var matches = results.matches;
2232
+ this.completions = new FilteredList(matches);
2233
+ if (options.exactMatch)
2234
+ this.completions.exactMatch = true;
2235
+ if (options.ignoreCaption)
2236
+ this.completions.ignoreCaption = true;
2237
+ this.completions.setFilter(prefix);
2238
+ if (results.finished || this.completions.filtered.length)
2239
+ callback(null, this.completions, results.finished);
2240
+ }.bind(this);
2241
+ var isImmediate = true;
2242
+ var immediateResults = null;
2243
+ this.gatherCompletions(editor, function (err, results) {
2244
+ if (!this.active) {
2245
+ return;
2246
+ }
2247
+ if (err) {
2248
+ callback(err, [], true);
2249
+ this.detach();
2250
+ }
2251
+ var prefix = results.prefix;
2252
+ if (prefix.indexOf(results.prefix) !== 0)
2253
+ return;
2254
+ if (isImmediate) {
2255
+ immediateResults = results;
2256
+ return;
2257
+ }
2258
+ processResults(results);
2259
+ }.bind(this));
2260
+ isImmediate = false;
2261
+ if (immediateResults) {
2262
+ var results = immediateResults;
2263
+ immediateResults = null;
2264
+ processResults(results);
2265
+ }
2266
+ };
2267
+ CompletionProvider.prototype.detach = function () {
2268
+ this.active = false;
2269
+ this.completers && this.completers.forEach(function (completer) {
2270
+ if (typeof completer.cancel === "function") {
2271
+ completer.cancel();
2272
+ }
2273
+ });
2274
+ };
2275
+ return CompletionProvider;
2276
+ }());
2277
+ var FilteredList = /** @class */ (function () {
2278
+ function FilteredList(array, filterText) {
2279
+ this.all = array;
2280
+ this.filtered = array;
2281
+ this.filterText = filterText || "";
2282
+ this.exactMatch = false;
2283
+ this.ignoreCaption = false;
2284
+ }
2285
+ FilteredList.prototype.setFilter = function (str) {
2286
+ if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0)
2287
+ var matches = this.filtered;
2288
+ else
2289
+ var matches = this.all;
2290
+ this.filterText = str;
2291
+ matches = this.filterCompletions(matches, this.filterText);
2292
+ matches = matches.sort(function (a, b) {
2293
+ return b.exactMatch - a.exactMatch || b.$score - a.$score
2294
+ || (a.caption || a.value).localeCompare(b.caption || b.value);
2295
+ });
2296
+ var prev = null;
2297
+ matches = matches.filter(function (item) {
2298
+ var caption = item.snippet || item.caption || item.value;
2299
+ if (caption === prev)
2300
+ return false;
2301
+ prev = caption;
2302
+ return true;
2303
+ });
2304
+ this.filtered = matches;
2305
+ };
2306
+ FilteredList.prototype.filterCompletions = function (items, needle) {
2307
+ var results = [];
2308
+ var upper = needle.toUpperCase();
2309
+ var lower = needle.toLowerCase();
2310
+ loop: for (var i = 0, item; item = items[i]; i++) {
2311
+ if (item.skipFilter) {
2312
+ item.$score = item.score;
2313
+ results.push(item);
2314
+ continue;
2315
+ }
2316
+ var caption = (!this.ignoreCaption && item.caption) || item.value || item.snippet;
2317
+ if (!caption)
2318
+ continue;
2319
+ var lastIndex = -1;
2320
+ var matchMask = 0;
2321
+ var penalty = 0;
2322
+ var index, distance;
2323
+ if (this.exactMatch) {
2324
+ if (needle !== caption.substr(0, needle.length))
2325
+ continue loop;
2326
+ }
2327
+ else {
2328
+ var fullMatchIndex = caption.toLowerCase().indexOf(lower);
2329
+ if (fullMatchIndex > -1) {
2330
+ penalty = fullMatchIndex;
2331
+ }
2332
+ else {
2333
+ for (var j = 0; j < needle.length; j++) {
2334
+ var i1 = caption.indexOf(lower[j], lastIndex + 1);
2335
+ var i2 = caption.indexOf(upper[j], lastIndex + 1);
2336
+ index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
2337
+ if (index < 0)
2338
+ continue loop;
2339
+ distance = index - lastIndex - 1;
2340
+ if (distance > 0) {
2341
+ if (lastIndex === -1)
2342
+ penalty += 10;
2343
+ penalty += distance;
2344
+ matchMask = matchMask | (1 << j);
2345
+ }
2346
+ lastIndex = index;
2347
+ }
2348
+ }
2349
+ }
2350
+ item.matchMask = matchMask;
2351
+ item.exactMatch = penalty ? 0 : 1;
2352
+ item.$score = (item.score || 0) - penalty;
2353
+ results.push(item);
2354
+ }
2355
+ return results;
2356
+ };
2357
+ return FilteredList;
2358
+ }());
2359
+ exports.Autocomplete = Autocomplete;
2360
+ exports.CompletionProvider = CompletionProvider;
2361
+ exports.FilteredList = FilteredList;
2362
+
2363
+ });
2364
+
2365
+ ace.define("ace/ext/command_bar",["require","exports","module","ace/tooltip","ace/lib/event_emitter","ace/lib/lang","ace/lib/dom","ace/lib/oop","ace/lib/useragent"], function(require, exports, module){/**
2366
+ * ## Command Bar extension.
2367
+ *
2368
+ * Provides an interactive command bar tooltip that displays above the editor's active line. The extension enables
2369
+ * clickable commands with keyboard shortcuts, icons, and various button types including standard buttons, checkboxes,
2370
+ * and text elements. Supports overflow handling with a secondary tooltip for additional commands when space is limited.
2371
+ * The tooltip can be configured to always show or display only on mouse hover over the active line.
2372
+ *
2373
+ * @module
2374
+ */
2375
+ var __values = (this && this.__values) || function(o) {
2376
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
2377
+ if (m) return m.call(o);
2378
+ if (o && typeof o.length === "number") return {
2379
+ next: function () {
2380
+ if (o && i >= o.length) o = void 0;
2381
+ return { value: o && o[i++], done: !o };
2382
+ }
2383
+ };
2384
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
2385
+ };
2386
+ var Tooltip = require("../tooltip").Tooltip;
2387
+ var EventEmitter = require("../lib/event_emitter").EventEmitter;
2388
+ var lang = require("../lib/lang");
2389
+ var dom = require("../lib/dom");
2390
+ var oop = require("../lib/oop");
2391
+ var useragent = require("../lib/useragent");
2392
+ var BUTTON_CLASS_NAME = 'command_bar_tooltip_button';
2393
+ var VALUE_CLASS_NAME = 'command_bar_button_value';
2394
+ var CAPTION_CLASS_NAME = 'command_bar_button_caption';
2395
+ var KEYBINDING_CLASS_NAME = 'command_bar_keybinding';
2396
+ var TOOLTIP_CLASS_NAME = 'command_bar_tooltip';
2397
+ var MORE_OPTIONS_BUTTON_ID = 'MoreOptionsButton';
2398
+ var defaultDelay = 100;
2399
+ var defaultMaxElements = 4;
2400
+ var minPosition = function (posA, posB) {
2401
+ if (posB.row > posA.row) {
2402
+ return posA;
2403
+ }
2404
+ else if (posB.row === posA.row && posB.column > posA.column) {
2405
+ return posA;
2406
+ }
2407
+ return posB;
2408
+ };
2409
+ var keyDisplayMap = {
2410
+ "Ctrl": { mac: "^" },
2411
+ "Option": { mac: "⌥" },
2412
+ "Command": { mac: "⌘" },
2413
+ "Cmd": { mac: "⌘" },
2414
+ "Shift": "⇧",
2415
+ "Left": "←",
2416
+ "Right": "→",
2417
+ "Up": "↑",
2418
+ "Down": "↓"
2419
+ };
2420
+ var CommandBarTooltip = /** @class */ (function () {
2421
+ function CommandBarTooltip(parentNode, options) {
2422
+ var e_1, _a;
2423
+ options = options || {};
2424
+ this.parentNode = parentNode;
2425
+ this.tooltip = new Tooltip(this.parentNode);
2426
+ this.moreOptions = new Tooltip(this.parentNode);
2427
+ this.maxElementsOnTooltip = options.maxElementsOnTooltip || defaultMaxElements;
2428
+ this.$alwaysShow = options.alwaysShow || false;
2429
+ this.eventListeners = {};
2430
+ this.elements = {};
2431
+ this.commands = {};
2432
+ this.tooltipEl = dom.buildDom(['div', { class: TOOLTIP_CLASS_NAME }], this.tooltip.getElement());
2433
+ this.moreOptionsEl = dom.buildDom(['div', { class: TOOLTIP_CLASS_NAME + " tooltip_more_options" }], this.moreOptions.getElement());
2434
+ this.$showTooltipTimer = lang.delayedCall(this.$showTooltip.bind(this), options.showDelay || defaultDelay);
2435
+ this.$hideTooltipTimer = lang.delayedCall(this.$hideTooltip.bind(this), options.hideDelay || defaultDelay);
2436
+ this.$tooltipEnter = this.$tooltipEnter.bind(this);
2437
+ this.$onMouseMove = this.$onMouseMove.bind(this);
2438
+ this.$onChangeScroll = this.$onChangeScroll.bind(this);
2439
+ this.$onEditorChangeSession = this.$onEditorChangeSession.bind(this);
2440
+ this.$scheduleTooltipForHide = this.$scheduleTooltipForHide.bind(this);
2441
+ this.$preventMouseEvent = this.$preventMouseEvent.bind(this);
2442
+ try {
2443
+ for (var _b = __values(["mousedown", "mouseup", "click"]), _c = _b.next(); !_c.done; _c = _b.next()) {
2444
+ var event = _c.value;
2445
+ this.tooltip.getElement().addEventListener(event, this.$preventMouseEvent);
2446
+ this.moreOptions.getElement().addEventListener(event, this.$preventMouseEvent);
2447
+ }
2448
+ }
2449
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2450
+ finally {
2451
+ try {
2452
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2453
+ }
2454
+ finally { if (e_1) throw e_1.error; }
2455
+ }
2456
+ }
2457
+ CommandBarTooltip.prototype.registerCommand = function (id, command) {
2458
+ var registerForMainTooltip = Object.keys(this.commands).length < this.maxElementsOnTooltip;
2459
+ if (!registerForMainTooltip && !this.elements[MORE_OPTIONS_BUTTON_ID]) {
2460
+ this.$createCommand(MORE_OPTIONS_BUTTON_ID, {
2461
+ name: "···",
2462
+ exec:
2463
+ function () {
2464
+ this.$shouldHideMoreOptions = false;
2465
+ this.$setMoreOptionsVisibility(!this.isMoreOptionsShown());
2466
+ }.bind(this),
2467
+ type: "checkbox",
2468
+ getValue: function () {
2469
+ return this.isMoreOptionsShown();
2470
+ }.bind(this),
2471
+ enabled: true
2472
+ }, true);
2473
+ }
2474
+ this.$createCommand(id, command, registerForMainTooltip);
2475
+ if (this.isShown()) {
2476
+ this.updatePosition();
2477
+ }
2478
+ };
2479
+ CommandBarTooltip.prototype.isShown = function () {
2480
+ return !!this.tooltip && this.tooltip.isOpen;
2481
+ };
2482
+ CommandBarTooltip.prototype.isMoreOptionsShown = function () {
2483
+ return !!this.moreOptions && this.moreOptions.isOpen;
2484
+ };
2485
+ CommandBarTooltip.prototype.getAlwaysShow = function () {
2486
+ return this.$alwaysShow;
2487
+ };
2488
+ CommandBarTooltip.prototype.setAlwaysShow = function (alwaysShow) {
2489
+ this.$alwaysShow = alwaysShow;
2490
+ this.$updateOnHoverHandlers(!this.$alwaysShow);
2491
+ this._signal("alwaysShow", this.$alwaysShow);
2492
+ };
2493
+ CommandBarTooltip.prototype.attach = function (editor) {
2494
+ if (!editor || (this.isShown() && this.editor === editor)) {
2495
+ return;
2496
+ }
2497
+ this.detach();
2498
+ this.editor = editor;
2499
+ this.editor.on("changeSession", this.$onEditorChangeSession);
2500
+ if (this.editor.session) {
2501
+ this.editor.session.on("changeScrollLeft", this.$onChangeScroll);
2502
+ this.editor.session.on("changeScrollTop", this.$onChangeScroll);
2503
+ }
2504
+ if (this.getAlwaysShow()) {
2505
+ this.$showTooltip();
2506
+ }
2507
+ else {
2508
+ this.$updateOnHoverHandlers(true);
2509
+ }
2510
+ };
2511
+ CommandBarTooltip.prototype.updatePosition = function () {
2512
+ if (!this.editor) {
2513
+ return;
2514
+ }
2515
+ var renderer = this.editor.renderer;
2516
+ var ranges;
2517
+ if (this.editor.selection.getAllRanges) {
2518
+ ranges = this.editor.selection.getAllRanges();
2519
+ }
2520
+ else {
2521
+ ranges = [this.editor.getSelectionRange()];
2522
+ }
2523
+ if (!ranges.length) {
2524
+ return;
2525
+ }
2526
+ var minPos = minPosition(ranges[0].start, ranges[0].end);
2527
+ for (var i = 0, range; range = ranges[i]; i++) {
2528
+ minPos = minPosition(minPos, minPosition(range.start, range.end));
2529
+ }
2530
+ var pos = renderer.$cursorLayer.getPixelPosition(minPos, true);
2531
+ var tooltipEl = this.tooltip.getElement();
2532
+ var screenWidth = window.innerWidth;
2533
+ var screenHeight = window.innerHeight;
2534
+ var rect = this.editor.container.getBoundingClientRect();
2535
+ pos.top += rect.top - renderer.layerConfig.offset;
2536
+ pos.left += rect.left + renderer.gutterWidth - renderer.scrollLeft;
2537
+ var cursorVisible = pos.top >= rect.top && pos.top <= rect.bottom &&
2538
+ pos.left >= rect.left + renderer.gutterWidth && pos.left <= rect.right;
2539
+ if (!cursorVisible && this.isShown()) {
2540
+ this.$hideTooltip();
2541
+ return;
2542
+ }
2543
+ else if (cursorVisible && !this.isShown() && this.getAlwaysShow()) {
2544
+ this.$showTooltip();
2545
+ return;
2546
+ }
2547
+ var top = pos.top - tooltipEl.offsetHeight;
2548
+ var left = Math.min(screenWidth - tooltipEl.offsetWidth, pos.left);
2549
+ var tooltipFits = top >= 0 && top + tooltipEl.offsetHeight <= screenHeight &&
2550
+ left >= 0 && left + tooltipEl.offsetWidth <= screenWidth;
2551
+ if (!tooltipFits) {
2552
+ this.$hideTooltip();
2553
+ return;
2554
+ }
2555
+ this.tooltip.setPosition(left, top);
2556
+ if (this.isMoreOptionsShown()) {
2557
+ top = top + tooltipEl.offsetHeight;
2558
+ left = this.elements[MORE_OPTIONS_BUTTON_ID].getBoundingClientRect().left;
2559
+ var moreOptionsEl = this.moreOptions.getElement();
2560
+ var screenHeight = window.innerHeight;
2561
+ if (top + moreOptionsEl.offsetHeight > screenHeight) {
2562
+ top -= tooltipEl.offsetHeight + moreOptionsEl.offsetHeight;
2563
+ }
2564
+ if (left + moreOptionsEl.offsetWidth > screenWidth) {
2565
+ left = screenWidth - moreOptionsEl.offsetWidth;
2566
+ }
2567
+ this.moreOptions.setPosition(left, top);
2568
+ }
2569
+ };
2570
+ CommandBarTooltip.prototype.update = function () {
2571
+ Object.keys(this.elements).forEach(this.$updateElement.bind(this));
2572
+ };
2573
+ CommandBarTooltip.prototype.detach = function () {
2574
+ this.tooltip.hide();
2575
+ this.moreOptions.hide();
2576
+ this.$updateOnHoverHandlers(false);
2577
+ if (this.editor) {
2578
+ this.editor.off("changeSession", this.$onEditorChangeSession);
2579
+ if (this.editor.session) {
2580
+ this.editor.session.off("changeScrollLeft", this.$onChangeScroll);
2581
+ this.editor.session.off("changeScrollTop", this.$onChangeScroll);
2582
+ }
2583
+ }
2584
+ this.$mouseInTooltip = false;
2585
+ this.editor = null;
2586
+ };
2587
+ CommandBarTooltip.prototype.destroy = function () {
2588
+ if (this.tooltip && this.moreOptions) {
2589
+ this.detach();
2590
+ this.tooltip.destroy();
2591
+ this.moreOptions.destroy();
2592
+ }
2593
+ this.eventListeners = {};
2594
+ this.commands = {};
2595
+ this.elements = {};
2596
+ this.tooltip = this.moreOptions = this.parentNode = null;
2597
+ };
2598
+ CommandBarTooltip.prototype.$createCommand = function (id, command, forMainTooltip) {
2599
+ var parentEl = forMainTooltip ? this.tooltipEl : this.moreOptionsEl;
2600
+ var keyParts = [];
2601
+ var bindKey = command.bindKey;
2602
+ if (bindKey) {
2603
+ if (typeof bindKey === 'object') {
2604
+ bindKey = useragent.isMac ? bindKey.mac : bindKey.win;
2605
+ }
2606
+ bindKey = bindKey.split("|")[0];
2607
+ keyParts = bindKey.split("-");
2608
+ keyParts = keyParts.map(function (key) {
2609
+ if (keyDisplayMap[key]) {
2610
+ if (typeof keyDisplayMap[key] === 'string') {
2611
+ return keyDisplayMap[key];
2612
+ }
2613
+ else if (useragent.isMac && keyDisplayMap[key].mac) {
2614
+ return keyDisplayMap[key].mac;
2615
+ }
2616
+ }
2617
+ return key;
2618
+ });
2619
+ }
2620
+ var buttonNode;
2621
+ if (forMainTooltip && command.iconCssClass) {
2622
+ buttonNode = [
2623
+ 'div',
2624
+ {
2625
+ class: ["ace_icon_svg", command.iconCssClass].join(" "),
2626
+ "aria-label": command.name + " (" + command.bindKey + ")"
2627
+ }
2628
+ ];
2629
+ }
2630
+ else {
2631
+ buttonNode = [
2632
+ ['div', { class: VALUE_CLASS_NAME }],
2633
+ ['div', { class: CAPTION_CLASS_NAME }, command.name]
2634
+ ];
2635
+ if (keyParts.length) {
2636
+ buttonNode.push([
2637
+ 'div',
2638
+ { class: KEYBINDING_CLASS_NAME },
2639
+ keyParts.map(function (keyPart) {
2640
+ return ['div', keyPart];
2641
+ })
2642
+ ]);
2643
+ }
2644
+ }
2645
+ dom.buildDom(['div', { class: [BUTTON_CLASS_NAME, command.cssClass || ""].join(" "), ref: id }, buttonNode], parentEl, this.elements);
2646
+ this.commands[id] = command;
2647
+ var eventListener =
2648
+ function (e) {
2649
+ if (this.editor) {
2650
+ this.editor.focus();
2651
+ }
2652
+ this.$shouldHideMoreOptions = this.isMoreOptionsShown();
2653
+ if (!this.elements[id].disabled && command.exec) {
2654
+ command.exec(this.editor);
2655
+ }
2656
+ if (this.$shouldHideMoreOptions) {
2657
+ this.$setMoreOptionsVisibility(false);
2658
+ }
2659
+ this.update();
2660
+ e.preventDefault();
2661
+ }.bind(this);
2662
+ this.eventListeners[id] = eventListener;
2663
+ this.elements[id].addEventListener('click', eventListener.bind(this));
2664
+ this.$updateElement(id);
2665
+ };
2666
+ CommandBarTooltip.prototype.$setMoreOptionsVisibility = function (visible) {
2667
+ if (visible) {
2668
+ this.moreOptions.setTheme(this.editor.renderer.theme);
2669
+ this.moreOptions.setClassName(TOOLTIP_CLASS_NAME + "_wrapper");
2670
+ this.moreOptions.show();
2671
+ this.update();
2672
+ this.updatePosition();
2673
+ }
2674
+ else {
2675
+ this.moreOptions.hide();
2676
+ }
2677
+ };
2678
+ CommandBarTooltip.prototype.$onEditorChangeSession = function (e) {
2679
+ if (e.oldSession) {
2680
+ e.oldSession.off("changeScrollTop", this.$onChangeScroll);
2681
+ e.oldSession.off("changeScrollLeft", this.$onChangeScroll);
2682
+ }
2683
+ this.detach();
2684
+ };
2685
+ CommandBarTooltip.prototype.$onChangeScroll = function () {
2686
+ if (this.editor.renderer && (this.isShown() || this.getAlwaysShow())) {
2687
+ this.editor.renderer.once("afterRender", this.updatePosition.bind(this));
2688
+ }
2689
+ };
2690
+ CommandBarTooltip.prototype.$onMouseMove = function (e) {
2691
+ if (this.$mouseInTooltip) {
2692
+ return;
2693
+ }
2694
+ var cursorPosition = this.editor.getCursorPosition();
2695
+ var cursorScreenPosition = this.editor.renderer.textToScreenCoordinates(cursorPosition.row, cursorPosition.column);
2696
+ var lineHeight = this.editor.renderer.lineHeight;
2697
+ var isInCurrentLine = e.clientY >= cursorScreenPosition.pageY && e.clientY < cursorScreenPosition.pageY + lineHeight;
2698
+ if (isInCurrentLine) {
2699
+ if (!this.isShown() && !this.$showTooltipTimer.isPending()) {
2700
+ this.$showTooltipTimer.delay();
2701
+ }
2702
+ if (this.$hideTooltipTimer.isPending()) {
2703
+ this.$hideTooltipTimer.cancel();
2704
+ }
2705
+ }
2706
+ else {
2707
+ if (this.isShown() && !this.$hideTooltipTimer.isPending()) {
2708
+ this.$hideTooltipTimer.delay();
2709
+ }
2710
+ if (this.$showTooltipTimer.isPending()) {
2711
+ this.$showTooltipTimer.cancel();
2712
+ }
2713
+ }
2714
+ };
2715
+ CommandBarTooltip.prototype.$preventMouseEvent = function (e) {
2716
+ if (this.editor) {
2717
+ this.editor.focus();
2718
+ }
2719
+ e.preventDefault();
2720
+ };
2721
+ CommandBarTooltip.prototype.$scheduleTooltipForHide = function () {
2722
+ this.$mouseInTooltip = false;
2723
+ this.$showTooltipTimer.cancel();
2724
+ this.$hideTooltipTimer.delay();
2725
+ };
2726
+ CommandBarTooltip.prototype.$tooltipEnter = function () {
2727
+ this.$mouseInTooltip = true;
2728
+ if (this.$showTooltipTimer.isPending()) {
2729
+ this.$showTooltipTimer.cancel();
2730
+ }
2731
+ if (this.$hideTooltipTimer.isPending()) {
2732
+ this.$hideTooltipTimer.cancel();
2733
+ }
2734
+ };
2735
+ CommandBarTooltip.prototype.$updateOnHoverHandlers = function (enableHover) {
2736
+ var tooltipEl = this.tooltip.getElement();
2737
+ var moreOptionsEl = this.moreOptions.getElement();
2738
+ if (enableHover) {
2739
+ if (this.editor) {
2740
+ this.editor.on("mousemove", this.$onMouseMove);
2741
+ this.editor.renderer.getMouseEventTarget().addEventListener("mouseout", this.$scheduleTooltipForHide, true);
2742
+ }
2743
+ tooltipEl.addEventListener('mouseenter', this.$tooltipEnter);
2744
+ tooltipEl.addEventListener('mouseleave', this.$scheduleTooltipForHide);
2745
+ moreOptionsEl.addEventListener('mouseenter', this.$tooltipEnter);
2746
+ moreOptionsEl.addEventListener('mouseleave', this.$scheduleTooltipForHide);
2747
+ }
2748
+ else {
2749
+ if (this.editor) {
2750
+ this.editor.off("mousemove", this.$onMouseMove);
2751
+ this.editor.renderer.getMouseEventTarget().removeEventListener("mouseout", this.$scheduleTooltipForHide, true);
2752
+ }
2753
+ tooltipEl.removeEventListener('mouseenter', this.$tooltipEnter);
2754
+ tooltipEl.removeEventListener('mouseleave', this.$scheduleTooltipForHide);
2755
+ moreOptionsEl.removeEventListener('mouseenter', this.$tooltipEnter);
2756
+ moreOptionsEl.removeEventListener('mouseleave', this.$scheduleTooltipForHide);
2757
+ }
2758
+ };
2759
+ CommandBarTooltip.prototype.$showTooltip = function () {
2760
+ if (this.isShown()) {
2761
+ return;
2762
+ }
2763
+ this.tooltip.setTheme(this.editor.renderer.theme);
2764
+ this.tooltip.setClassName(TOOLTIP_CLASS_NAME + "_wrapper");
2765
+ this.tooltip.show();
2766
+ this.update();
2767
+ this.updatePosition();
2768
+ this._signal("show");
2769
+ };
2770
+ CommandBarTooltip.prototype.$hideTooltip = function () {
2771
+ this.$mouseInTooltip = false;
2772
+ if (!this.isShown()) {
2773
+ return;
2774
+ }
2775
+ this.moreOptions.hide();
2776
+ this.tooltip.hide();
2777
+ this._signal("hide");
2778
+ };
2779
+ CommandBarTooltip.prototype.$updateElement = function (id) {
2780
+ var command = this.commands[id];
2781
+ if (!command) {
2782
+ return;
2783
+ }
2784
+ var el = this.elements[id];
2785
+ var commandEnabled = command.enabled;
2786
+ if (typeof commandEnabled === 'function') {
2787
+ commandEnabled = commandEnabled(this.editor);
2788
+ }
2789
+ if (typeof command.getValue === 'function') {
2790
+ var value = command.getValue(this.editor);
2791
+ if (command.type === 'text') {
2792
+ el.textContent = value;
2793
+ }
2794
+ else if (command.type === 'checkbox') {
2795
+ var domCssFn = value ? dom.addCssClass : dom.removeCssClass;
2796
+ var isOnTooltip = el.parentElement === this.tooltipEl;
2797
+ el.ariaChecked = value;
2798
+ if (isOnTooltip) {
2799
+ domCssFn(el, "ace_selected");
2800
+ }
2801
+ else {
2802
+ el = el.querySelector("." + VALUE_CLASS_NAME);
2803
+ domCssFn(el, "ace_checkmark");
2804
+ }
2805
+ }
2806
+ }
2807
+ if (commandEnabled && el.disabled) {
2808
+ dom.removeCssClass(el, "ace_disabled");
2809
+ el.ariaDisabled = el.disabled = false;
2810
+ el.removeAttribute("disabled");
2811
+ }
2812
+ else if (!commandEnabled && !el.disabled) {
2813
+ dom.addCssClass(el, "ace_disabled");
2814
+ el.ariaDisabled = el.disabled = true;
2815
+ el.setAttribute("disabled", "");
2816
+ }
2817
+ };
2818
+ return CommandBarTooltip;
2819
+ }());
2820
+ oop.implement(CommandBarTooltip.prototype, EventEmitter);
2821
+ dom.importCssString("\n.ace_tooltip.".concat(TOOLTIP_CLASS_NAME, "_wrapper {\n padding: 0;\n}\n\n.ace_tooltip .").concat(TOOLTIP_CLASS_NAME, " {\n padding: 1px 5px;\n display: flex;\n pointer-events: auto;\n}\n\n.ace_tooltip .").concat(TOOLTIP_CLASS_NAME, ".tooltip_more_options {\n padding: 1px;\n flex-direction: column;\n}\n\ndiv.").concat(BUTTON_CLASS_NAME, " {\n display: inline-flex;\n cursor: pointer;\n margin: 1px;\n border-radius: 2px;\n padding: 2px 5px;\n align-items: center;\n}\n\ndiv.").concat(BUTTON_CLASS_NAME, ".ace_selected,\ndiv.").concat(BUTTON_CLASS_NAME, ":hover:not(.ace_disabled) {\n background-color: rgba(0, 0, 0, 0.1);\n}\n\ndiv.").concat(BUTTON_CLASS_NAME, ".ace_disabled {\n color: #777;\n pointer-events: none;\n}\n\ndiv.").concat(BUTTON_CLASS_NAME, " .ace_icon_svg {\n height: 12px;\n background-color: #000;\n}\n\ndiv.").concat(BUTTON_CLASS_NAME, ".ace_disabled .ace_icon_svg {\n background-color: #777;\n}\n\n.").concat(TOOLTIP_CLASS_NAME, ".tooltip_more_options .").concat(BUTTON_CLASS_NAME, " {\n display: flex;\n}\n\n.").concat(TOOLTIP_CLASS_NAME, ".").concat(VALUE_CLASS_NAME, " {\n display: none;\n}\n\n.").concat(TOOLTIP_CLASS_NAME, ".tooltip_more_options .").concat(VALUE_CLASS_NAME, " {\n display: inline-block;\n width: 12px;\n}\n\n.").concat(CAPTION_CLASS_NAME, " {\n display: inline-block;\n}\n\n.").concat(KEYBINDING_CLASS_NAME, " {\n margin: 0 2px;\n display: inline-block;\n font-size: 8px;\n}\n\n.").concat(TOOLTIP_CLASS_NAME, ".tooltip_more_options .").concat(KEYBINDING_CLASS_NAME, " {\n margin-left: auto;\n}\n\n.").concat(KEYBINDING_CLASS_NAME, " div {\n display: inline-block;\n min-width: 8px;\n padding: 2px;\n margin: 0 1px;\n border-radius: 2px;\n background-color: #ccc;\n text-align: center;\n}\n\n.ace_dark.ace_tooltip .").concat(TOOLTIP_CLASS_NAME, " {\n background-color: #373737;\n color: #eee;\n}\n\n.ace_dark div.").concat(BUTTON_CLASS_NAME, ".ace_disabled {\n color: #979797;\n}\n\n.ace_dark div.").concat(BUTTON_CLASS_NAME, ".ace_selected,\n.ace_dark div.").concat(BUTTON_CLASS_NAME, ":hover:not(.ace_disabled) {\n background-color: rgba(255, 255, 255, 0.1);\n}\n\n.ace_dark div.").concat(BUTTON_CLASS_NAME, " .ace_icon_svg {\n background-color: #eee;\n}\n\n.ace_dark div.").concat(BUTTON_CLASS_NAME, ".ace_disabled .ace_icon_svg {\n background-color: #979797;\n}\n\n.ace_dark .").concat(BUTTON_CLASS_NAME, ".ace_disabled {\n color: #979797;\n}\n\n.ace_dark .").concat(KEYBINDING_CLASS_NAME, " div {\n background-color: #575757;\n}\n\n.ace_checkmark::before {\n content: '\u2713';\n}\n"), "commandbar.css", false);
2822
+ exports.CommandBarTooltip = CommandBarTooltip;
2823
+ exports.TOOLTIP_CLASS_NAME = TOOLTIP_CLASS_NAME;
2824
+ exports.BUTTON_CLASS_NAME = BUTTON_CLASS_NAME;
2825
+
2826
+ });
2827
+
2828
+ ace.define("ace/marker_group",["require","exports","module"], function(require, exports, module){"use strict";
2829
+ var MarkerGroup = /** @class */ (function () {
2830
+ function MarkerGroup(session, options) {
2831
+ if (options)
2832
+ this.markerType = options.markerType;
2833
+ this.markers = [];
2834
+ this.session = session;
2835
+ session.addDynamicMarker(this);
2836
+ }
2837
+ MarkerGroup.prototype.getMarkerAtPosition = function (pos) {
2838
+ return this.markers.find(function (marker) {
2839
+ return marker.range.contains(pos.row, pos.column);
2840
+ });
2841
+ };
2842
+ MarkerGroup.prototype.markersComparator = function (a, b) {
2843
+ return a.range.start.row - b.range.start.row;
2844
+ };
2845
+ MarkerGroup.prototype.setMarkers = function (markers) {
2846
+ this.markers = markers.sort(this.markersComparator).slice(0, this.MAX_MARKERS);
2847
+ this.session._signal("changeBackMarker");
2848
+ };
2849
+ MarkerGroup.prototype.update = function (html, markerLayer, session, config) {
2850
+ if (!this.markers || !this.markers.length)
2851
+ return;
2852
+ var visibleRangeStartRow = config.firstRow, visibleRangeEndRow = config.lastRow;
2853
+ var foldLine;
2854
+ var markersOnOneLine = 0;
2855
+ var lastRow = 0;
2856
+ for (var i = 0; i < this.markers.length; i++) {
2857
+ var marker = this.markers[i];
2858
+ if (marker.range.end.row < visibleRangeStartRow)
2859
+ continue;
2860
+ if (marker.range.start.row > visibleRangeEndRow)
2861
+ continue;
2862
+ if (marker.range.start.row === lastRow) {
2863
+ markersOnOneLine++;
2864
+ }
2865
+ else {
2866
+ lastRow = marker.range.start.row;
2867
+ markersOnOneLine = 0;
2868
+ }
2869
+ if (markersOnOneLine > 200) {
2870
+ continue;
2871
+ }
2872
+ var markerVisibleRange = marker.range.clipRows(visibleRangeStartRow, visibleRangeEndRow);
2873
+ if (markerVisibleRange.start.row === markerVisibleRange.end.row
2874
+ && markerVisibleRange.start.column === markerVisibleRange.end.column) {
2875
+ continue; // visible range is empty
2876
+ }
2877
+ var screenRange = markerVisibleRange.toScreenRange(session);
2878
+ if (screenRange.isEmpty()) {
2879
+ foldLine = session.getNextFoldLine(markerVisibleRange.end.row, foldLine);
2880
+ if (foldLine && foldLine.end.row > markerVisibleRange.end.row) {
2881
+ visibleRangeStartRow = foldLine.end.row;
2882
+ }
2883
+ continue;
2884
+ }
2885
+ if (this.markerType === "fullLine") {
2886
+ markerLayer.drawFullLineMarker(html, screenRange, marker.className, config);
2887
+ }
2888
+ else if (screenRange.isMultiLine()) {
2889
+ if (this.markerType === "line")
2890
+ markerLayer.drawMultiLineMarker(html, screenRange, marker.className, config);
2891
+ else
2892
+ markerLayer.drawTextMarker(html, screenRange, marker.className, config);
2893
+ }
2894
+ else {
2895
+ markerLayer.drawSingleLineMarker(html, screenRange, marker.className + " ace_br15", config);
2896
+ }
2897
+ }
2898
+ };
2899
+ return MarkerGroup;
2900
+ }());
2901
+ MarkerGroup.prototype.MAX_MARKERS = 10000;
2902
+ exports.MarkerGroup = MarkerGroup;
2903
+
2904
+ });
2905
+
2906
+ ace.define("ace/autocomplete/text_completer",["require","exports","module","ace/range"], function(require, exports, module){var Range = require("../range").Range;
2907
+ var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/;
2908
+ function getWordIndex(doc, pos) {
2909
+ var textBefore = doc.getTextRange(Range.fromPoints({
2910
+ row: 0,
2911
+ column: 0
2912
+ }, pos));
2913
+ return textBefore.split(splitRegex).length - 1;
2914
+ }
2915
+ function wordDistance(doc, pos) {
2916
+ var prefixPos = getWordIndex(doc, pos);
2917
+ var words = doc.getValue().split(splitRegex);
2918
+ var wordScores = Object.create(null);
2919
+ var currentWord = words[prefixPos];
2920
+ words.forEach(function (word, idx) {
2921
+ if (!word || word === currentWord)
2922
+ return;
2923
+ var distance = Math.abs(prefixPos - idx);
2924
+ var score = words.length - distance;
2925
+ if (wordScores[word]) {
2926
+ wordScores[word] = Math.max(score, wordScores[word]);
2927
+ }
2928
+ else {
2929
+ wordScores[word] = score;
2930
+ }
2931
+ });
2932
+ return wordScores;
2933
+ }
2934
+ exports.id = "textCompleter";
2935
+ exports.getCompletions = function (editor, session, pos, prefix, callback) {
2936
+ var wordScore = wordDistance(session, pos);
2937
+ var wordList = Object.keys(wordScore);
2938
+ callback(null, wordList.map(function (word) {
2939
+ return {
2940
+ caption: word,
2941
+ value: word,
2942
+ score: wordScore[word],
2943
+ meta: "local"
2944
+ };
2945
+ }));
2946
+ };
2947
+
2948
+ });
2949
+
2950
+ ace.define("ace/ext/language_tools",["require","exports","module","ace/snippets","ace/autocomplete","ace/config","ace/lib/lang","ace/autocomplete/util","ace/marker_group","ace/autocomplete/text_completer","ace/editor","ace/config"], function(require, exports, module){/**
2951
+ * ## Language Tools extension for Ace Editor
2952
+ *
2953
+ * Provides autocompletion, snippets, and language intelligence features for the Ace code editor.
2954
+ * This extension integrates multiple completion providers including keyword completion, snippet expansion,
2955
+ * and text-based completion to enhance the coding experience with contextual suggestions and automated code generation.
2956
+ *
2957
+ * **Configuration Options:**
2958
+ * - `enableBasicAutocompletion`: Enable/disable basic completion functionality
2959
+ * - `enableLiveAutocompletion`: Enable/disable real-time completion suggestions
2960
+ * - `enableSnippets`: Enable/disable snippet expansion with Tab key
2961
+ * - `liveAutocompletionDelay`: Delay before showing live completion popup
2962
+ * - `liveAutocompletionThreshold`: Minimum prefix length to trigger completion
2963
+ *
2964
+ * **Usage:**
2965
+ * ```javascript
2966
+ * editor.setOptions({
2967
+ * enableBasicAutocompletion: true,
2968
+ * enableLiveAutocompletion: true,
2969
+ * enableSnippets: true
2970
+ * });
2971
+ * ```
2972
+ *
2973
+ * @module
2974
+ */
2975
+ "use strict";
2976
+ var snippetManager = require("../snippets").snippetManager;
2977
+ var Autocomplete = require("../autocomplete").Autocomplete;
2978
+ var config = require("../config");
2979
+ var lang = require("../lib/lang");
2980
+ var util = require("../autocomplete/util");
2981
+ var MarkerGroup = require("../marker_group").MarkerGroup;
2982
+ var textCompleter = require("../autocomplete/text_completer");
2983
+ var keyWordCompleter = {
2984
+ getCompletions: function (editor, session, pos, prefix, callback) {
2985
+ if (session.$mode.completer) {
2986
+ return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback);
2987
+ }
2988
+ var state = editor.session.getState(pos.row);
2989
+ var completions = session.$mode.getCompletions(state, session, pos, prefix);
2990
+ completions = completions.map(function (el) {
2991
+ el.completerId = keyWordCompleter.id;
2992
+ return el;
2993
+ });
2994
+ callback(null, completions);
2995
+ },
2996
+ id: "keywordCompleter"
2997
+ };
2998
+ var transformSnippetTooltip = function (str) {
2999
+ var record = {};
3000
+ return str.replace(/\${(\d+)(:(.*?))?}/g, function (_, p1, p2, p3) {
3001
+ return (record[p1] = p3 || '');
3002
+ }).replace(/\$(\d+?)/g, function (_, p1) {
3003
+ return record[p1];
3004
+ });
3005
+ };
3006
+ var snippetCompleter = {
3007
+ getCompletions: function (editor, session, pos, prefix, callback) {
3008
+ var scopes = [];
3009
+ var token = session.getTokenAt(pos.row, pos.column);
3010
+ if (token && token.type.match(/(tag-name|tag-open|tag-whitespace|attribute-name|attribute-value)\.xml$/))
3011
+ scopes.push('html-tag');
3012
+ else
3013
+ scopes = snippetManager.getActiveScopes(editor);
3014
+ var snippetMap = snippetManager.snippetMap;
3015
+ var completions = [];
3016
+ scopes.forEach(function (scope) {
3017
+ var snippets = snippetMap[scope] || [];
3018
+ for (var i = snippets.length; i--;) {
3019
+ var s = snippets[i];
3020
+ var caption = s.name || s.tabTrigger;
3021
+ if (!caption)
3022
+ continue;
3023
+ completions.push({
3024
+ caption: caption,
3025
+ snippet: s.content,
3026
+ meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet",
3027
+ completerId: snippetCompleter.id
3028
+ });
3029
+ }
3030
+ }, this);
3031
+ callback(null, completions);
3032
+ },
3033
+ getDocTooltip: function (item) {
3034
+ if (item.snippet && !item.docHTML) {
3035
+ item.docHTML = [
3036
+ "<b>", lang.escapeHTML(item.caption), "</b>", "<hr></hr>",
3037
+ lang.escapeHTML(transformSnippetTooltip(item.snippet))
3038
+ ].join("");
3039
+ }
3040
+ },
3041
+ id: "snippetCompleter"
3042
+ };
3043
+ var completers = [snippetCompleter, textCompleter, keyWordCompleter];
3044
+ exports.setCompleters = function (val) {
3045
+ completers.length = 0;
3046
+ if (val)
3047
+ completers.push.apply(completers, val);
3048
+ };
3049
+ exports.addCompleter = function (completer) {
3050
+ completers.push(completer);
3051
+ };
3052
+ exports.textCompleter = textCompleter;
3053
+ exports.keyWordCompleter = keyWordCompleter;
3054
+ exports.snippetCompleter = snippetCompleter;
3055
+ var expandSnippet = {
3056
+ name: "expandSnippet",
3057
+ exec: function (editor) {
3058
+ return snippetManager.expandWithTab(editor);
3059
+ },
3060
+ bindKey: "Tab"
3061
+ };
3062
+ var onChangeMode = function (e, editor) {
3063
+ loadSnippetsForMode(editor.session.$mode);
3064
+ };
3065
+ var loadSnippetsForMode = function (mode) {
3066
+ if (typeof mode == "string")
3067
+ mode = config.$modes[mode];
3068
+ if (!mode)
3069
+ return;
3070
+ if (!snippetManager.files)
3071
+ snippetManager.files = {};
3072
+ loadSnippetFile(mode.$id, mode.snippetFileId);
3073
+ if (mode.modes)
3074
+ mode.modes.forEach(loadSnippetsForMode);
3075
+ };
3076
+ var loadSnippetFile = function (id, snippetFilePath) {
3077
+ if (!snippetFilePath || !id || snippetManager.files[id])
3078
+ return;
3079
+ snippetManager.files[id] = {};
3080
+ config.loadModule(snippetFilePath, function (m) {
3081
+ if (!m)
3082
+ return;
3083
+ snippetManager.files[id] = m;
3084
+ if (!m.snippets && m.snippetText)
3085
+ m.snippets = snippetManager.parseSnippetFile(m.snippetText);
3086
+ snippetManager.register(m.snippets || [], m.scope);
3087
+ if (m.includeScopes) {
3088
+ snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes;
3089
+ m.includeScopes.forEach(function (x) {
3090
+ loadSnippetsForMode("ace/mode/" + x);
3091
+ });
3092
+ }
3093
+ });
3094
+ };
3095
+ var doLiveAutocomplete = function (e) {
3096
+ var editor = e.editor;
3097
+ var hasCompleter = editor.completer && editor.completer.activated;
3098
+ if (e.command.name === "backspace") {
3099
+ if (hasCompleter && !util.getCompletionPrefix(editor))
3100
+ editor.completer.detach();
3101
+ }
3102
+ else if (e.command.name === "insertstring" && !hasCompleter) {
3103
+ lastExecEvent = e;
3104
+ var delay = e.editor.$liveAutocompletionDelay;
3105
+ if (delay) {
3106
+ liveAutocompleteTimer.delay(delay);
3107
+ }
3108
+ else {
3109
+ showLiveAutocomplete(e);
3110
+ }
3111
+ }
3112
+ };
3113
+ var lastExecEvent;
3114
+ var liveAutocompleteTimer = lang.delayedCall(function () {
3115
+ showLiveAutocomplete(lastExecEvent);
3116
+ }, 0);
3117
+ var showLiveAutocomplete = function (e) {
3118
+ var editor = e.editor;
3119
+ var prefix = util.getCompletionPrefix(editor);
3120
+ var previousChar = e.args;
3121
+ var triggerAutocomplete = util.triggerAutocomplete(editor, previousChar);
3122
+ if (prefix && prefix.length >= editor.$liveAutocompletionThreshold || triggerAutocomplete) {
3123
+ var completer = Autocomplete.for(editor);
3124
+ completer.autoShown = true;
3125
+ completer.showPopup(editor);
3126
+ }
3127
+ };
3128
+ var Editor = require("../editor").Editor;
3129
+ require("../config").defineOptions(Editor.prototype, "editor", {
3130
+ enableBasicAutocompletion: {
3131
+ set: function (val) {
3132
+ if (val) {
3133
+ Autocomplete.for(this);
3134
+ if (!this.completers)
3135
+ this.completers = Array.isArray(val) ? val : completers;
3136
+ this.commands.addCommand(Autocomplete.startCommand);
3137
+ }
3138
+ else {
3139
+ this.commands.removeCommand(Autocomplete.startCommand);
3140
+ }
3141
+ },
3142
+ value: false
3143
+ },
3144
+ enableLiveAutocompletion: {
3145
+ set: function (val) {
3146
+ if (val) {
3147
+ if (!this.completers)
3148
+ this.completers = Array.isArray(val) ? val : completers;
3149
+ this.commands.on('afterExec', doLiveAutocomplete);
3150
+ }
3151
+ else {
3152
+ this.commands.off('afterExec', doLiveAutocomplete);
3153
+ }
3154
+ },
3155
+ value: false
3156
+ },
3157
+ liveAutocompletionDelay: {
3158
+ initialValue: 0
3159
+ },
3160
+ liveAutocompletionThreshold: {
3161
+ initialValue: 0
3162
+ },
3163
+ enableSnippets: {
3164
+ set: function (val) {
3165
+ if (val) {
3166
+ this.commands.addCommand(expandSnippet);
3167
+ this.on("changeMode", onChangeMode);
3168
+ onChangeMode(null, this);
3169
+ }
3170
+ else {
3171
+ this.commands.removeCommand(expandSnippet);
3172
+ this.off("changeMode", onChangeMode);
3173
+ }
3174
+ },
3175
+ value: false
3176
+ }
3177
+ });
3178
+ exports.MarkerGroup = MarkerGroup;
3179
+
3180
+ });
3181
+
3182
+ ace.define("ace/ext/inline_autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/inline","ace/autocomplete","ace/autocomplete","ace/editor","ace/autocomplete/util","ace/lib/dom","ace/lib/lang","ace/ext/command_bar","ace/ext/command_bar","ace/ext/language_tools","ace/ext/language_tools","ace/ext/language_tools","ace/config"], function(require, exports, module){/**
3183
+ * ## Inline Autocomplete extension
3184
+ *
3185
+ * Provides lightweight, prefix-based autocompletion with inline ghost text rendering and an optional command bar tooltip.
3186
+ * Displays completion suggestions as ghost text directly in the editor with keyboard navigation and interactive controls.
3187
+ *
3188
+ * **Enable:** `editor.setOption("enableInlineAutocompletion", true)`
3189
+ * or configure it during editor initialization in the options object.
3190
+ * @module
3191
+ */
3192
+ "use strict";
3193
+ var HashHandler = require("../keyboard/hash_handler").HashHandler;
3194
+ var AceInline = require("../autocomplete/inline").AceInline;
3195
+ var FilteredList = require("../autocomplete").FilteredList;
3196
+ var CompletionProvider = require("../autocomplete").CompletionProvider;
3197
+ var Editor = require("../editor").Editor;
3198
+ var util = require("../autocomplete/util");
3199
+ var dom = require("../lib/dom");
3200
+ var lang = require("../lib/lang");
3201
+ var CommandBarTooltip = require("./command_bar").CommandBarTooltip;
3202
+ var BUTTON_CLASS_NAME = require("./command_bar").BUTTON_CLASS_NAME;
3203
+ var snippetCompleter = require("./language_tools").snippetCompleter;
3204
+ var textCompleter = require("./language_tools").textCompleter;
3205
+ var keyWordCompleter = require("./language_tools").keyWordCompleter;
3206
+ var destroyCompleter = function (e, editor) {
3207
+ editor.completer && editor.completer.destroy();
3208
+ };
3209
+ var InlineAutocomplete = /** @class */ (function () {
3210
+ function InlineAutocomplete(editor) {
3211
+ this.editor = editor;
3212
+ this.keyboardHandler = new HashHandler(this.commands);
3213
+ this.$index = -1;
3214
+ this.blurListener = this.blurListener.bind(this);
3215
+ this.changeListener = this.changeListener.bind(this);
3216
+ this.changeTimer = lang.delayedCall(function () {
3217
+ this.updateCompletions();
3218
+ }.bind(this));
3219
+ }
3220
+ InlineAutocomplete.prototype.getInlineRenderer = function () {
3221
+ if (!this.inlineRenderer)
3222
+ this.inlineRenderer = new AceInline();
3223
+ return this.inlineRenderer;
3224
+ };
3225
+ InlineAutocomplete.prototype.getInlineTooltip = function () {
3226
+ if (!this.inlineTooltip) {
3227
+ this.inlineTooltip = InlineAutocomplete.createInlineTooltip(document.body || document.documentElement);
3228
+ }
3229
+ return this.inlineTooltip;
3230
+ };
3231
+ InlineAutocomplete.prototype.show = function (options) {
3232
+ this.activated = true;
3233
+ if (this.editor.completer !== this) {
3234
+ if (this.editor.completer)
3235
+ this.editor.completer.detach();
3236
+ this.editor.completer = this;
3237
+ }
3238
+ this.editor.on("changeSelection", this.changeListener);
3239
+ this.editor.on("blur", this.blurListener);
3240
+ this.updateCompletions(options);
3241
+ };
3242
+ InlineAutocomplete.prototype.$open = function () {
3243
+ if (this.editor.textInput.setAriaOptions) {
3244
+ this.editor.textInput.setAriaOptions({});
3245
+ }
3246
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
3247
+ this.getInlineTooltip().attach(this.editor);
3248
+ if (this.$index === -1) {
3249
+ this.setIndex(0);
3250
+ }
3251
+ else {
3252
+ this.$showCompletion();
3253
+ }
3254
+ this.changeTimer.cancel();
3255
+ };
3256
+ InlineAutocomplete.prototype.insertMatch = function () {
3257
+ var result = this.getCompletionProvider().insertByIndex(this.editor, this.$index);
3258
+ this.detach();
3259
+ return result;
3260
+ };
3261
+ InlineAutocomplete.prototype.changeListener = function (e) {
3262
+ var cursor = this.editor.selection.lead;
3263
+ if (cursor.row != this.base.row || cursor.column < this.base.column) {
3264
+ this.detach();
3265
+ }
3266
+ if (this.activated)
3267
+ this.changeTimer.schedule();
3268
+ else
3269
+ this.detach();
3270
+ };
3271
+ InlineAutocomplete.prototype.blurListener = function (e) {
3272
+ this.detach();
3273
+ };
3274
+ InlineAutocomplete.prototype.goTo = function (where) {
3275
+ if (!this.completions || !this.completions.filtered) {
3276
+ return;
3277
+ }
3278
+ var completionLength = this.completions.filtered.length;
3279
+ switch (where.toLowerCase()) {
3280
+ case "prev":
3281
+ this.setIndex((this.$index - 1 + completionLength) % completionLength);
3282
+ break;
3283
+ case "next":
3284
+ this.setIndex((this.$index + 1 + completionLength) % completionLength);
3285
+ break;
3286
+ case "first":
3287
+ this.setIndex(0);
3288
+ break;
3289
+ case "last":
3290
+ this.setIndex(this.completions.filtered.length - 1);
3291
+ break;
3292
+ }
3293
+ };
3294
+ InlineAutocomplete.prototype.getLength = function () {
3295
+ if (!this.completions || !this.completions.filtered) {
3296
+ return 0;
3297
+ }
3298
+ return this.completions.filtered.length;
3299
+ };
3300
+ InlineAutocomplete.prototype.getData = function (index) {
3301
+ if (index == undefined || index === null) {
3302
+ return this.completions.filtered[this.$index];
3303
+ }
3304
+ else {
3305
+ return this.completions.filtered[index];
3306
+ }
3307
+ };
3308
+ InlineAutocomplete.prototype.getIndex = function () {
3309
+ return this.$index;
3310
+ };
3311
+ InlineAutocomplete.prototype.isOpen = function () {
3312
+ return this.$index >= 0;
3313
+ };
3314
+ InlineAutocomplete.prototype.setIndex = function (value) {
3315
+ if (!this.completions || !this.completions.filtered) {
3316
+ return;
3317
+ }
3318
+ var newIndex = Math.max(-1, Math.min(this.completions.filtered.length - 1, value));
3319
+ if (newIndex !== this.$index) {
3320
+ this.$index = newIndex;
3321
+ this.$showCompletion();
3322
+ }
3323
+ };
3324
+ InlineAutocomplete.prototype.getCompletionProvider = function (initialPosition) {
3325
+ if (!this.completionProvider)
3326
+ this.completionProvider = new CompletionProvider(initialPosition);
3327
+ return this.completionProvider;
3328
+ };
3329
+ InlineAutocomplete.prototype.$showCompletion = function () {
3330
+ if (!this.getInlineRenderer().show(this.editor, this.completions.filtered[this.$index], this.completions.filterText)) {
3331
+ this.getInlineRenderer().hide();
3332
+ }
3333
+ if (this.inlineTooltip && this.inlineTooltip.isShown()) {
3334
+ this.inlineTooltip.update();
3335
+ }
3336
+ };
3337
+ InlineAutocomplete.prototype.$updatePrefix = function () {
3338
+ var pos = this.editor.getCursorPosition();
3339
+ var prefix = this.editor.session.getTextRange({ start: this.base, end: pos });
3340
+ this.completions.setFilter(prefix);
3341
+ if (!this.completions.filtered.length)
3342
+ return this.detach();
3343
+ if (this.completions.filtered.length == 1
3344
+ && this.completions.filtered[0].value == prefix
3345
+ && !this.completions.filtered[0].snippet)
3346
+ return this.detach();
3347
+ this.$open(this.editor, prefix);
3348
+ return prefix;
3349
+ };
3350
+ InlineAutocomplete.prototype.updateCompletions = function (options) {
3351
+ var prefix = "";
3352
+ if (options && options.matches) {
3353
+ var pos = this.editor.getSelectionRange().start;
3354
+ this.base = this.editor.session.doc.createAnchor(pos.row, pos.column);
3355
+ this.base.$insertRight = true;
3356
+ this.completions = new FilteredList(options.matches);
3357
+ return this.$open(this.editor, "");
3358
+ }
3359
+ if (this.base && this.completions) {
3360
+ prefix = this.$updatePrefix();
3361
+ }
3362
+ var session = this.editor.getSession();
3363
+ var pos = this.editor.getCursorPosition();
3364
+ var prefix = util.getCompletionPrefix(this.editor);
3365
+ this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
3366
+ this.base.$insertRight = true;
3367
+ var options = {
3368
+ exactMatch: true,
3369
+ ignoreCaption: true
3370
+ };
3371
+ this.getCompletionProvider({
3372
+ prefix: prefix,
3373
+ base: this.base,
3374
+ pos: pos
3375
+ }).provideCompletions(this.editor, options,
3376
+ function (err, completions, finished) {
3377
+ var filtered = completions.filtered;
3378
+ var prefix = util.getCompletionPrefix(this.editor);
3379
+ if (finished) {
3380
+ if (!filtered.length)
3381
+ return this.detach();
3382
+ if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet)
3383
+ return this.detach();
3384
+ }
3385
+ this.completions = completions;
3386
+ this.$open(this.editor, prefix);
3387
+ }.bind(this));
3388
+ };
3389
+ InlineAutocomplete.prototype.detach = function () {
3390
+ if (this.editor) {
3391
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
3392
+ this.editor.off("changeSelection", this.changeListener);
3393
+ this.editor.off("blur", this.blurListener);
3394
+ }
3395
+ this.changeTimer.cancel();
3396
+ if (this.inlineTooltip) {
3397
+ this.inlineTooltip.detach();
3398
+ }
3399
+ this.setIndex(-1);
3400
+ if (this.completionProvider) {
3401
+ this.completionProvider.detach();
3402
+ }
3403
+ if (this.inlineRenderer && this.inlineRenderer.isOpen()) {
3404
+ this.inlineRenderer.hide();
3405
+ }
3406
+ if (this.base)
3407
+ this.base.detach();
3408
+ this.activated = false;
3409
+ this.completionProvider = this.completions = this.base = null;
3410
+ };
3411
+ InlineAutocomplete.prototype.destroy = function () {
3412
+ this.detach();
3413
+ if (this.inlineRenderer)
3414
+ this.inlineRenderer.destroy();
3415
+ if (this.inlineTooltip)
3416
+ this.inlineTooltip.destroy();
3417
+ if (this.editor && this.editor.completer == this) {
3418
+ this.editor.off("destroy", destroyCompleter);
3419
+ this.editor.completer = null;
3420
+ }
3421
+ this.inlineTooltip = this.editor = this.inlineRenderer = null;
3422
+ };
3423
+ InlineAutocomplete.prototype.updateDocTooltip = function () {
3424
+ };
3425
+ return InlineAutocomplete;
3426
+ }());
3427
+ InlineAutocomplete.prototype.commands = {
3428
+ "Previous": {
3429
+ bindKey: "Alt-[",
3430
+ name: "Previous",
3431
+ exec: function (editor) {
3432
+ editor.completer.goTo("prev");
3433
+ }
3434
+ },
3435
+ "Next": {
3436
+ bindKey: "Alt-]",
3437
+ name: "Next",
3438
+ exec: function (editor) {
3439
+ editor.completer.goTo("next");
3440
+ }
3441
+ },
3442
+ "Accept": {
3443
+ bindKey: { win: "Tab|Ctrl-Right", mac: "Tab|Cmd-Right" },
3444
+ name: "Accept",
3445
+ exec: function (editor) {
3446
+ return /**@type{InlineAutocomplete}*/ (editor.completer).insertMatch();
3447
+ }
3448
+ },
3449
+ "Close": {
3450
+ bindKey: "Esc",
3451
+ name: "Close",
3452
+ exec: function (editor) {
3453
+ editor.completer.detach();
3454
+ }
3455
+ }
3456
+ };
3457
+ InlineAutocomplete.for = function (editor) {
3458
+ if (editor.completer instanceof InlineAutocomplete) {
3459
+ return editor.completer;
3460
+ }
3461
+ if (editor.completer) {
3462
+ editor.completer.destroy();
3463
+ editor.completer = null;
3464
+ }
3465
+ editor.completer = new InlineAutocomplete(editor);
3466
+ editor.once("destroy", destroyCompleter);
3467
+ return editor.completer;
3468
+ };
3469
+ InlineAutocomplete.startCommand = {
3470
+ name: "startInlineAutocomplete",
3471
+ exec: function (editor, options) {
3472
+ var completer = InlineAutocomplete.for(editor);
3473
+ completer.show(options);
3474
+ },
3475
+ bindKey: { win: "Alt-C", mac: "Option-C" }
3476
+ };
3477
+ var completers = [snippetCompleter, textCompleter, keyWordCompleter];
3478
+ require("../config").defineOptions(Editor.prototype, "editor", {
3479
+ enableInlineAutocompletion: {
3480
+ set: function (val) {
3481
+ if (val) {
3482
+ if (!this.completers)
3483
+ this.completers = Array.isArray(val) ? val : completers;
3484
+ this.commands.addCommand(InlineAutocomplete.startCommand);
3485
+ }
3486
+ else {
3487
+ this.commands.removeCommand(InlineAutocomplete.startCommand);
3488
+ }
3489
+ },
3490
+ value: false
3491
+ }
3492
+ });
3493
+ InlineAutocomplete.createInlineTooltip = function (parentEl) {
3494
+ var inlineTooltip = new CommandBarTooltip(parentEl);
3495
+ inlineTooltip.registerCommand("Previous",
3496
+ Object.assign({}, InlineAutocomplete.prototype.commands["Previous"], {
3497
+ enabled: true,
3498
+ type: "button",
3499
+ iconCssClass: "ace_arrow_rotated"
3500
+ }));
3501
+ inlineTooltip.registerCommand("Position", {
3502
+ enabled: false,
3503
+ getValue: function (editor) {
3504
+ return editor ? [
3505
+ (editor.completer).getIndex() + 1, /**@type{InlineAutocomplete}*/ (editor.completer).getLength()
3506
+ ].join("/") : "";
3507
+ },
3508
+ type: "text",
3509
+ cssClass: "completion_position"
3510
+ });
3511
+ inlineTooltip.registerCommand("Next",
3512
+ Object.assign({}, InlineAutocomplete.prototype.commands["Next"], {
3513
+ enabled: true,
3514
+ type: "button",
3515
+ iconCssClass: "ace_arrow"
3516
+ }));
3517
+ inlineTooltip.registerCommand("Accept",
3518
+ Object.assign({}, InlineAutocomplete.prototype.commands["Accept"], {
3519
+ enabled: function (editor) {
3520
+ return !!editor && editor.completer.getIndex() >= 0;
3521
+ },
3522
+ type: "button"
3523
+ }));
3524
+ inlineTooltip.registerCommand("ShowTooltip", {
3525
+ name: "Always Show Tooltip",
3526
+ exec: function () {
3527
+ inlineTooltip.setAlwaysShow(!inlineTooltip.getAlwaysShow());
3528
+ },
3529
+ enabled: true,
3530
+ getValue: function () {
3531
+ return inlineTooltip.getAlwaysShow();
3532
+ },
3533
+ type: "checkbox"
3534
+ });
3535
+ return inlineTooltip;
3536
+ };
3537
+ dom.importCssString("\n\n.ace_icon_svg.ace_arrow,\n.ace_icon_svg.ace_arrow_rotated {\n -webkit-mask-image: url(\"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTUuODM3MDEgMTVMNC41ODc1MSAxMy43MTU1TDEwLjE0NjggOEw0LjU4NzUxIDIuMjg0NDZMNS44MzcwMSAxTDEyLjY0NjUgOEw1LjgzNzAxIDE1WiIgZmlsbD0iYmxhY2siLz48L3N2Zz4=\");\n}\n\n.ace_icon_svg.ace_arrow_rotated {\n transform: rotate(180deg);\n}\n\ndiv.".concat(BUTTON_CLASS_NAME, ".completion_position {\n padding: 0;\n}\n"), "inlineautocomplete.css", false);
3538
+ exports.InlineAutocomplete = InlineAutocomplete;
3539
+
3540
+ }); (function() {
3541
+ ace.require(["ace/ext/inline_autocomplete"], function(m) {
3542
+ if (typeof module == "object" && typeof exports == "object" && module) {
3543
+ module.exports = m;
3544
+ }
3545
+ });
3546
+ })();
3547
+