PageSourceSearch

https://karasev.ru/i/ace/ext-emmet.js?15

js karasev.ru collected 2026-10-08 10:01:43 UTC 45,543 bytes, 1,244 lines download raw bytes

1(ace.define(
2  "ace/snippets",
3  [
4    "require",
5    "exports",
6    "module",
7    "ace/lib/dom",
8    "ace/lib/oop",
9    "ace/lib/event_emitter",
10    "ace/lib/lang",
11    "ace/range",
12    "ace/range_list",
13    "ace/keyboard/hash_handler",
14    "ace/tokenizer",
15    "ace/clipboard",
16    "ace/editor",
17  ],
18  function (e, t, n) {
19    "use strict";
20    function p(e) {
21      var t = new Date().toLocaleString("en-us", e);
22      return t.length == 1 ? "0" + t : t;
23    }
24    var r = e("./lib/dom"),
25      i = e("./lib/oop"),
26      s = e("./lib/event_emitter").EventEmitter,
27      o = e("./lib/lang"),
28      u = e("./range").Range,
29      a = e("./range_list").RangeList,
30      f = e("./keyboard/hash_handler").HashHandler,
31      l = e("./tokenizer").Tokenizer,
32      c = e("./clipboard"),
33      h = {
34        CURRENT_WORD: function (e) {
35          return e.session.getTextRange(e.session.getWordRange());
36        },
37        SELECTION: function (e, t, n) {
38          var r = e.session.getTextRange();
39          return n ? r.replace(/\n\r?([ \t]*\S)/g, "\n" + n + "$1") : r;
40        },
41        CURRENT_LINE: function (e) {
42          return e.session.getLine(e.getCursorPosition().row);
43        },
44        PREV_LINE: function (e) {
45          return e.session.getLine(e.getCursorPosition().row - 1);
46        },
47        LINE_INDEX: function (e) {
48          return e.getCursorPosition().row;
49        },
50        LINE_NUMBER: function (e) {
51          return e.getCursorPosition().row + 1;
52        },
53        SOFT_TABS: function (e) {
54          return e.session.getUseSoftTabs() ? "YES" : "NO";
55        },
56        TAB_SIZE: function (e) {
57          return e.session.getTabSize();
58        },
59        CLIPBOARD: function (e) {
60          return c.getText && c.getText();
61        },
62        FILENAME: function (e) {
63          return /[^/\\]*$/.exec(this.FILEPATH(e))[0];
64        },
65        FILENAME_BASE: function (e) {
66          return /[^/\\]*$/.exec(this.FILEPATH(e))[0].replace(/\.[^.]*$/, "");
67        },
68        DIRECTORY: function (e) {
69          return this.FILEPATH(e).replace(/[^/\\]*$/, "");
70        },
71        FILEPATH: function (e) {
72          return "/not implemented.txt";
73        },
74        WORKSPACE_NAME: function () {
75          return "Unknown";
76        },
77        FULLNAME: function () {
78          return "Unknown";
79        },
80        BLOCK_COMMENT_START: function (e) {
81          var t = e.session.$mode || {};
82          return (t.blockComment && t.blockComment.start) || "";
83        },
84        BLOCK_COMMENT_END: function (e) {
85          var t = e.session.$mode || {};
86          return (t.blockComment && t.blockComment.end) || "";
87        },
88        LINE_COMMENT: function (e) {
89          var t = e.session.$mode || {};
90          return t.lineCommentStart || "";
91        },
92        CURRENT_YEAR: p.bind(null, { year: "numeric" }),
93        CURRENT_YEAR_SHORT: p.bind(null, { year: "2-digit" }),
94        CURRENT_MONTH: p.bind(null, { month: "numeric" }),
95        CURRENT_MONTH_NAME: p.bind(null, { month: "long" }),
96        CURRENT_MONTH_NAME_SHORT: p.bind(null, { month: "short" }),
97        CURRENT_DATE: p.bind(null, { day: "2-digit" }),
98        CURRENT_DAY_NAME: p.bind(null, { weekday: "long" }),
99        CURRENT_DAY_NAME_SHORT: p.bind(null, { weekday: "short" }),
100        CURRENT_HOUR: p.bind(null, { hour: "2-digit", hour12: !1 }),
101        CURRENT_MINUTE: p.bind(null, { minute: "2-digit" }),
102        CURRENT_SECOND: p.bind(null, { second: "2-digit" }),
103      };
104    h.SELECTED_TEXT = h.SELECTION;
105    var d = (function () {
106      function e() {
107        ((this.snippetMap = {}),
108          (this.snippetNameMap = {}),
109          (this.variables = h));
110      }
111      return (
112        (e.prototype.getTokenizer = function () {
113          return e.$tokenizer || this.createTokenizer();
114        }),
115        (e.prototype.createTokenizer = function () {
116          function t(e) {
117            return (
118              (e = e.substr(1)),
119              /^\d+$/.test(e) ? [{ tabstopId: parseInt(e, 10) }] : [{ text: e }]
120            );
121          }
122          function n(e) {
123            return "(?:[^\\\\" + e + "]|\\\\.)";
124          }
125          var r = {
126            regex: "/(" + n("/") + "+)/",
127            onMatch: function (e, t, n) {
128              var r = n[0];
129              return (
130                (r.fmtString = !0),
131                (r.guard = e.slice(1, -1)),
132                (r.flag = ""),
133                ""
134              );
135            },
136            next: "formatString",
137          };
138          return (
139            (e.$tokenizer = new l({
140              start: [
141                {
142                  regex: /\\./,
143                  onMatch: function (e, t, n) {
144                    var r = e[1];
145                    return (
146                      r == "}" && n.length
147                        ? (e = r)
148                        : "`$\\".indexOf(r) != -1 && (e = r),
149                      [e]
150                    );
151                  },
152                },
153                {
154                  regex: /}/,
155                  onMatch: function (e, t, n) {
156                    return [n.length ? n.shift() : e];
157                  },
158                },
159                { regex: /\$(?:\d+|\w+)/, onMatch: t },
160                {
161                  regex: /\$\{[\dA-Z_a-z]+/,
162                  onMatch: function (e, n, r) {
163                    var i = t(e.substr(1));
164                    return (r.unshift(i[0]), i);
165                  },
166                  next: "snippetVar",
167                },
168                { regex: /\n/, token: "newline", merge: !1 },
169              ],
170              snippetVar: [
171                {
172                  regex: "\\|" + n("\\|") + "*\\|",
173                  onMatch: function (e, t, n) {
174                    var r = e
175                      .slice(1, -1)
176                      .replace(/\\[,|\\]|,/g, function (e) {
177                        return e.length == 2 ? e[1] : "\0";
178                      })
179                      .split("\0")
180                      .map(function (e) {
181                        return { value: e };
182                      });
183                    return ((n[0].choices = r), [r[0]]);
184                  },
185                  next: "start",
186                },
187                r,
188                { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" },
189              ],
190              formatString: [
191                {
192                  regex: /:/,
193                  onMatch: function (e, t, n) {
194                    return n.length && n[0].expectElse
195                      ? ((n[0].expectElse = !1),
196                        (n[0].ifEnd = { elseEnd: n[0] }),
197                        [n[0].ifEnd])
198                      : ":";
199                  },
200                },
201                {
202                  regex: /\\./,
203                  onMatch: function (e, t, n) {
204                    var r = e[1];
205                    return (
206                      r == "}" && n.length
207                        ? (e = r)
208                        : "`$\\".indexOf(r) != -1
209                          ? (e = r)
210                          : r == "n"
211                            ? (e = "\n")
212                            : r == "t"
213                              ? (e = "	")
214                              : "ulULE".indexOf(r) != -1 &&
215                                (e = { changeCase: r, local: r > "a" }),
216                      [e]
217                    );
218                  },
219                },
220                {
221                  regex: "/\\w*}",
222                  onMatch: function (e, t, n) {
223                    var r = n.shift();
224                    return (
225                      r && (r.flag = e.slice(1, -1)),
226                      (this.next = r && r.tabstopId ? "start" : ""),
227                      [r || e]
228                    );
229                  },
230                  next: "start",
231                },
232                {
233                  regex: /\$(?:\d+|\w+)/,
234                  onMatch: function (e, t, n) {
235                    return [{ text: e.slice(1) }];
236                  },
237                },
238                {
239                  regex: /\${\w+/,
240                  onMatch: function (e, t, n) {
241                    var r = { text: e.slice(2) };
242                    return (n.unshift(r), [r]);
243                  },
244                  next: "formatStringVar",
245                },
246                { regex: /\n/, token: "newline", merge: !1 },
247                {
248                  regex: /}/,
249                  onMatch: function (e, t, n) {
250                    var r = n.shift();
251                    return (
252                      (this.next = r && r.tabstopId ? "start" : ""),
253                      [r || e]
254                    );
255                  },
256                  next: "start",
257                },
258              ],
259              formatStringVar: [
260                {
261                  regex: /:\/\w+}/,
262                  onMatch: function (e, t, n) {
263                    var r = n[0];
264                    return ((r.formatFunction = e.slice(2, -1)), [n.shift()]);
265                  },
266                  next: "formatString",
267                },
268                r,
269                {
270                  regex: /:[\?\-+]?/,
271                  onMatch: function (e, t, n) {
272                    (e[1] == "+" && (n[0].ifEnd = n[0]),
273                      e[1] == "?" && (n[0].expectElse = !0));
274                  },
275                  next: "formatString",
276                },
277                {
278                  regex: "([^:}\\\\]|\\\\.)*:?",
279                  token: "",
280                  next: "formatString",
281                },
282              ],
283            })),
284            e.$tokenizer
285          );
286        }),
287        (e.prototype.tokenizeTmSnippet = function (e, t) {
288          return this.getTokenizer()
289            .getLineTokens(e, t)
290            .tokens.map(function (e) {
291              return e.value || e;
292            });
293        }),
294        (e.prototype.getVariableValue = function (e, t, n) {
295          if (/^\d+$/.test(t)) return (this.variables.__ || {})[t] || "";
296          if (/^[A-Z]\d+$/.test(t))
297            return (this.variables[t[0] + "__"] || {})[t.substr(1)] || "";
298          t = t.replace(/^TM_/, "");
299          if (!this.variables.hasOwnProperty(t)) return "";
300          var r = this.variables[t];
301          return (
302            typeof r == "function" && (r = this.variables[t](e, t, n)),
303            r == null ? "" : r
304          );
305        }),
306        (e.prototype.tmStrFormat = function (e, t, n) {
307          if (!t.fmt) return e;
308          var r = t.flag || "",
309            i = t.guard;
310          i = new RegExp(i, r.replace(/[^gim]/g, ""));
311          var s =
312              typeof t.fmt == "string"
313                ? this.tokenizeTmSnippet(t.fmt, "formatString")
314                : t.fmt,
315            o = this,
316            u = e.replace(i, function () {
317              var e = o.variables.__;
318              o.variables.__ = [].slice.call(arguments);
319              var t = o.resolveVariables(s, n),
320                r = "E";
321              for (var i = 0; i < t.length; i++) {
322                var u = t[i];
323                if (typeof u == "object") {
324                  t[i] = "";
325                  if (u.changeCase && u.local) {
326                    var a = t[i + 1];
327                    a &&
328                      typeof a == "string" &&
329                      (u.changeCase == "u"
330                        ? (t[i] = a[0].toUpperCase())
331                        : (t[i] = a[0].toLowerCase()),
332                      (t[i + 1] = a.substr(1)));
333                  } else u.changeCase && (r = u.changeCase);
334                } else
335                  r == "U"
336                    ? (t[i] = u.toUpperCase())
337                    : r == "L" && (t[i] = u.toLowerCase());
338              }
339              return ((o.variables.__ = e), t.join(""));
340            });
341          return u;
342        }),
343        (e.prototype.tmFormatFunction = function (e, t, n) {
344          return t.formatFunction == "upcase"
345            ? e.toUpperCase()
346            : t.formatFunction == "downcase"
347              ? e.toLowerCase()
348              : e;
349        }),
350        (e.prototype.resolveVariables = function (e, t) {
351          function f(t) {
352            var n = e.indexOf(t, s + 1);
353            n != -1 && (s = n);
354          }
355          var n = [],
356            r = "",
357            i = !0;
358          for (var s = 0; s < e.length; s++) {
359            var o = e[s];
360            if (typeof o == "string") {
361              (n.push(o),
362                o == "\n"
363                  ? ((i = !0), (r = ""))
364                  : i && ((r = /^\t*/.exec(o)[0]), (i = /\S/.test(o))));
365              continue;
366            }
367            if (!o) continue;
368            i = !1;
369            if (o.fmtString) {
370              var u = e.indexOf(o, s + 1);
371              (u == -1 && (u = e.length), (o.fmt = e.slice(s + 1, u)), (s = u));
372            }
373            if (o.text) {
374              var a = this.getVariableValue(t, o.text, r) + "";
375              (o.fmtString && (a = this.tmStrFormat(a, o, t)),
376                o.formatFunction && (a = this.tmFormatFunction(a, o, t)),
377                a && !o.ifEnd
378                  ? (n.push(a), f(o))
379                  : !a && o.ifEnd && f(o.ifEnd));
380            } else
381              o.elseEnd
382                ? f(o.elseEnd)
383                : o.tabstopId != null
384                  ? n.push(o)
385                  : o.changeCase != null && n.push(o);
386          }
387          return n;
388        }),
389        (e.prototype.getDisplayTextForSnippet = function (e, t) {
390          var n = v.call(this, e, t);
391          return n.text;
392        }),
393        (e.prototype.insertSnippetForSelection = function (e, t, n) {
394          n === void 0 && (n = {});
395          var r = v.call(this, e, t, n),
396            i = e.getSelectionRange(),
397            s = e.session.replace(i, r.text),
398            o = new m(e),
399            u = e.inVirtualSelectionMode && e.selection.index;
400          o.addTabstops(r.tabstops, i.start, s, u);
401        }),
402        (e.prototype.insertSnippet = function (e, t, n) {
403          n === void 0 && (n = {});
404          var r = this;
405          if (e.inVirtualSelectionMode)
406            return r.insertSnippetForSelection(e, t, n);
407          (e.forEachSelection(
408            function () {
409              r.insertSnippetForSelection(e, t, n);
410            },
411            null,
412            { keepOrder: !0 },
413          ),
414            e.tabstopManager && e.tabstopManager.tabNext());
415        }),
416        (e.prototype.$getScope = function (e) {
417          var t = e.session.$mode.$id || "";
418          t = t.split("/").pop();
419          if (t === "html" || t === "php") {
420            t === "php" && !e.session.$mode.inlinePhp && (t = "html");
421            var n = e.getCursorPosition(),
422              r = e.session.getState(n.row);
423            (typeof r == "object" && (r = r[0]),
424              r.substring &&
425                (r.substring(0, 3) == "js-"
426                  ? (t = "javascript")
427                  : r.substring(0, 4) == "css-"
428                    ? (t = "css")
429                    : r.substring(0, 4) == "php-" && (t = "php")));
430          }
431          return t;
432        }),
433        (e.prototype.getActiveScopes = function (e) {
434          var t = this.$getScope(e),
435            n = [t],
436            r = this.snippetMap;
437          return (
438            r[t] && r[t].includeScopes && n.push.apply(n, r[t].includeScopes),
439            n.push("_"),
440            n
441          );
442        }),
443        (e.prototype.expandWithTab = function (e, t) {
444          var n = this,
445            r = e.forEachSelection(
446              function () {
447                return n.expandSnippetForSelection(e, t);
448              },
449              null,
450              { keepOrder: !0 },
451            );
452          return (r && e.tabstopManager && e.tabstopManager.tabNext(), r);
453        }),
454        (e.prototype.expandSnippetForSelection = function (e, t) {
455          var n = e.getCursorPosition(),
456            r = e.session.getLine(n.row),
457            i = r.substring(0, n.column),
458            s = r.substr(n.column),
459            o = this.snippetMap,
460            u;
461          return (
462            this.getActiveScopes(e).some(function (e) {
463              var t = o[e];
464              return (t && (u = this.findMatchingSnippet(t, i, s)), !!u);
465            }, this),
466            u
467              ? t && t.dryRun
468                ? !0
469                : (e.session.doc.removeInLine(
470 
470                   n.row,
471                    n.column - u.replaceBefore.length,
472                    n.column + u.replaceAfter.length,
473                  ),
474                  (this.variables.M__ = u.matchBefore),
475                  (this.variables.T__ = u.matchAfter),
476                  this.insertSnippetForSelection(e, u.content),
477                  (this.variables.M__ = this.variables.T__ = null),
478                  !0)
479              : !1
480          );
481        }),
482        (e.prototype.findMatchingSnippet = function (e, t, n) {
483          for (var r = e.length; r--; ) {
484            var i = e[r];
485            if (i.startRe && !i.startRe.test(t)) continue;
486            if (i.endRe && !i.endRe.test(n)) continue;
487            if (!i.startRe && !i.endRe) continue;
488            return (
489              (i.matchBefore = i.startRe ? i.startRe.exec(t) : [""]),
490              (i.matchAfter = i.endRe ? i.endRe.exec(n) : [""]),
491              (i.replaceBefore = i.triggerRe ? i.triggerRe.exec(t)[0] : ""),
492              (i.replaceAfter = i.endTriggerRe
493                ? i.endTriggerRe.exec(n)[0]
494                : ""),
495              i
496            );
497          }
498        }),
499        (e.prototype.register = function (e, t) {
500          function s(e) {
501            return (
502              e && !/^\^?\(.*\)\$?$|^\\b$/.test(e) && (e = "(?:" + e + ")"),
503              e || ""
504            );
505          }
506          function u(e, t, n) {
507            return (
508              (e = s(e)),
509              (t = s(t)),
510              n
511                ? ((e = t + e), e && e[e.length - 1] != "$" && (e += "$"))
512                : ((e += t), e && e[0] != "^" && (e = "^" + e)),
513              new RegExp(e)
514            );
515          }
516          function a(e) {
517            (e.scope || (e.scope = t || "_"),
518              (t = e.scope),
519              n[t] || ((n[t] = []), (r[t] = {})));
520            var s = r[t];
521            if (e.name) {
522              var a = s[e.name];
523              (a && i.unregister(a), (s[e.name] = e));
524            }
525            (n[t].push(e),
526              e.prefix && (e.tabTrigger = e.prefix),
527              !e.content &&
528                e.body &&
529                (e.content = Array.isArray(e.body)
530                  ? e.body.join("\n")
531                  : e.body),
532              e.tabTrigger &&
533                !e.trigger &&
534                (!e.guard && /^\w/.test(e.tabTrigger) && (e.guard = "\\b"),
535                (e.trigger = o.escapeRegExp(e.tabTrigger))));
536            if (!e.trigger && !e.guard && !e.endTrigger && !e.endGuard) return;
537            ((e.startRe = u(e.trigger, e.guard, !0)),
538              (e.triggerRe = new RegExp(e.trigger)),
539              (e.endRe = u(e.endTrigger, e.endGuard, !0)),
540              (e.endTriggerRe = new RegExp(e.endTrigger)));
541          }
542          var n = this.snippetMap,
543            r = this.snippetNameMap,
544            i = this;
545          (e || (e = []),
546            Array.isArray(e)
547              ? e.forEach(a)
548              : Object.keys(e).forEach(function (t) {
549                  a(e[t]);
550                }),
551            this._signal("registerSnippets", { scope: t }));
552        }),
553        (e.prototype.unregister = function (e, t) {
554          function i(e) {
555            var i = r[e.scope || t];
556            if (i && i[e.name]) {
557              delete i[e.name];
558              var s = n[e.scope || t],
559                o = s && s.indexOf(e);
560              o >= 0 && s.splice(o, 1);
561            }
562          }
563          var n = this.snippetMap,
564            r = this.snippetNameMap;
565          e.content ? i(e) : Array.isArray(e) && e.forEach(i);
566        }),
567        (e.prototype.parseSnippetFile = function (e) {
568          e = e.replace(/\r/g, "");
569          var t = [],
570            n = {},
571            r = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm,
572            i;
573          while ((i = r.exec(e))) {
574            if (i[1])
575              try {
576                ((n = JSON.parse(i[1])), t.push(n));
577              } catch (s) {}
578            if (i[4])
579              ((n.content = i[4].replace(/^\t/gm, "")), t.push(n), (n = {}));
580            else {
581              var o = i[2],
582                u = i[3];
583              if (o == "regex") {
584                var a = /\/((?:[^\/\\]|\\.)*)|$/g;
585                ((n.guard = a.exec(u)[1]),
586                  (n.trigger = a.exec(u)[1]),
587                  (n.endTrigger = a.exec(u)[1]),
588                  (n.endGuard = a.exec(u)[1]));
589              } else
590                o == "snippet"
591                  ? ((n.tabTrigger = u.match(/^\S*/)[0]),
592                    n.name || (n.name = u))
593                  : o && (n[o] = u);
594            }
595          }
596          return t;
597        }),
598        (e.prototype.getSnippetByName = function (e, t) {
599          var n = this.snippetNameMap,
600            r;
601          return (
602            this.getActiveScopes(t).some(function (t) {
603              var i = n[t];
604              return (i && (r = i[e]), !!r);
605            }, this),
606            r
607          );
608        }),
609        e
610      );
611    })();
612    i.implement(d.prototype, s);
613    var v = function (e, t, n) {
614        function l(e) {
615          var t = [];
616          for (var n = 0; n < e.length; n++) {
617            var r = e[n];
618            if (typeof r == "object") {
619              if (f[r.tabstopId]) continue;
620              var i = e.lastIndexOf(r, n - 1);
621              r = t[i] || { tabstopId: r.tabstopId };
622            }
623            t[n] = r;
624          }
625          return t;
626        }
627        n === void 0 && (n = {});
628        var r = e.getCursorPosition(),
629          i = e.session.getLine(r.row),
630          s = e.session.getTabString(),
631          o = i.match(/^\s*/)[0];
632        (r.column < o.length && (o = o.slice(0, r.column)),
633          (t = t.replace(/\r/g, "")));
634        var u = this.tokenizeTmSnippet(t);
635        ((u = this.resolveVariables(u, e)),
636          (u = u.map(function (e) {
637            return e == "\n" && !n.excludeExtraIndent
638              ? e + o
639              : typeof e == "string"
640                ? e.replace(/\t/g, s)
641                : e;
642          })));
643        var a = [];
644        (u.forEach(function (e, t) {
645          if (typeof e != "object") return;
646          var n = e.tabstopId,
647            r = a[n];
648          r ||
649            ((r = a[n] = []), (r.index = n), (r.value = ""), (r.parents = {}));
650          if (r.indexOf(e) !== -1) return;
651          (e.choices && !r.choices && (r.choices = e.choices), r.push(e));
652          var i = u.indexOf(e, t + 1);
653          if (i === -1) return;
654          var s = u.slice(t + 1, i),
655            o = s.some(function (e) {
656              return typeof e == "object";
657            });
658          o && !r.value
659            ? (r.value = s)
660            : s.length &&
661              (!r.value || typeof r.value != "string") &&
662              (r.value = s.join(""));
663        }),
664          a.forEach(function (e) {
665            e.length = 0;
666          }));
667        var f = {};
668        for (var c = 0; c < u.length; c++) {
669          var h = u[c];
670          if (typeof h != "object") continue;
671          var p = h.tabstopId,
672            d = a[p],
673            v = u.indexOf(h, c + 1);
674          if (f[p]) {
675            f[p] === h &&
676              (delete f[p],
677              Object.keys(f).forEach(function (e) {
678                d.parents[e] = !0;
679              }));
680            continue;
681          }
682          f[p] = h;
683          var m = d.value;
684          (typeof m != "string"
685            ? (m = l(m))
686            : h.fmt && (m = this.tmStrFormat(m, h, e)),
687            u.splice.apply(u, [c + 1, Math.max(0, v - c)].concat(m, h)),
688            d.indexOf(h) === -1 && d.push(h));
689        }
690        var g = 0,
691          y = 0,
692          b = "";
693        return (
694          u.forEach(function (e) {
695            if (typeof e == "string") {
696              var t = e.split("\n");
697              (t.length > 1
698                ? ((y = t[t.length - 1].length), (g += t.length - 1))
699                : (y += e.length),
700                (b += e));
701            } else
702              e &&
703                (e.start
704                  ? (e.end = { row: g, column: y })
705                  : (e.start = { row: g, column: y }));
706          }),
707          { text: b, tabstops: a, tokens: u }
708        );
709      },
710      m = (function () {
711        function e(e) {
712          ((this.index = 0), (this.ranges = []), (this.tabstops = []));
713          if (e.tabstopManager) return e.tabstopManager;
714          ((e.tabstopManager = this),
715            (this.$onChange = this.onChange.bind(this)),
716            (this.$onChangeSelection = o.delayedCall(
717              this.onChangeSelection.bind(this),
718            ).schedule),
719            (this.$onChangeSession = this.onChangeSession.bind(this)),
720            (this.$onAfterExec = this.onAfterExec.bind(this)),
721            this.attach(e));
722        }
723        return (
724          (e.prototype.attach = function (e) {
725            ((this.$openTabstops = null),
726              (this.selectedTabstop = null),
727              (this.editor = e),
728              (this.session = e.session),
729              this.editor.on("change", this.$onChange),
730              this.editor.on("changeSelection", this.$onChangeSelection),
731              this.editor.on("changeSession", this.$onChangeSession),
732              this.editor.commands.on("afterExec", this.$onAfterExec),
733              this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler));
734          }),
735          (e.prototype.detach = function () {
736            (this.tabstops.forEach(this.removeTabstopMarkers, this),
737              (this.ranges.length = 0),
738              (this.tabstops.length = 0),
739              (this.selectedTabstop = null),
740              this.editor.off("change", this.$onChange),
741              this.editor.off("changeSelection", this.$onChangeSelection),
742              this.editor.off("changeSession", this.$onChangeSession),
743              this.editor.commands.off("afterExec", this.$onAfterExec),
744              this.editor.keyBinding.removeKeyboardHandler(
745                this.keyboardHandler,
746              ),
747              (this.editor.tabstopManager = null),
748              (this.session = null),
749              (this.editor = null));
750          }),
751          (e.prototype.onChange = function (e) {
752            var t = e.action[0] == "r",
753              n = this.selectedTabstop || {},
754              r = n.parents || {},
755              i = this.tabstops.slice();
756            for (var s = 0; s < i.length; s++) {
757              var o = i[s],
758                u = o == n || r[o.index];
759              o.rangeList.$bias = u ? 0 : 1;
760              if (e.action == "remove" && o !== n) {
761                var a = o.parents && o.parents[n.index],
762                  f = o.rangeList.pointIndex(e.start, a);
763                f = f < 0 ? -f - 1 : f + 1;
764                var l = o.rangeList.pointIndex(e.end, a);
765                l = l < 0 ? -l - 1 : l - 1;
766                var c = o.rangeList.ranges.slice(f, l);
767                for (var h = 0; h < c.length; h++) this.removeRange(c[h]);
768              }
769              o.rangeList.$onChange(e);
770            }
771            var p = this.session;
772            !this.$inChange &&
773              t &&
774              p.getLength() == 1 &&
775              !p.getValue() &&
776              this.detach();
777          }),
778          (e.prototype.updateLinkedFields = function () {
779            var e = this.selectedTabstop;
780            if (!e || !e.hasLinkedRanges || !e.firstNonLinked) return;
781            this.$inChange = !0;
782            var n = this.session,
783              r = n.getTextRange(e.firstNonLinked);
784            for (var i = 0; i < e.length; i++) {
785              var s = e[i];
786              if (!s.linked) continue;
787              var o = s.original,
788                u = t.snippetManager.tmStrFormat(r, o, this.editor);
789              n.replace(s, u);
790            }
791            this.$inChange = !1;
792          }),
793          (e.prototype.onAfterExec = function (e) {
794            e.command && !e.command.readOnly && this.updateLinkedFields();
795          }),
796          (e.prototype.onChangeSelection = function () {
797            if (!this.editor) return;
798            var e = this.editor.selection.lead,
799              t = this.editor.selection.anchor,
800              n = this.editor.selection.isEmpty();
801            for (var r = 0; r < this.ranges.length; r++) {
802              if (this.ranges[r].linked) continue;
803              var i = this.ranges[r].contains(e.row, e.column),
804                s = n || this.ranges[r].contains(t.row, t.column);
805              if (i && s) return;
806            }
807            this.detach();
808          }),
809          (e.prototype.onChangeSession = function () {
810            this.detach();
811          }),
812          (e.prototype.tabNext = function (e) {
813            var t = this.tabstops.length,
814              n = this.index + (e || 1);
815            ((n = Math.min(Math.max(n, 1), t)),
816              n == t && (n = 0),
817              this.selectTabstop(n),
818              n === 0 && this.detach());
819          }),
820          (e.prototype.selectTabstop = function (e) {
821            this.$openTabstops = null;
822            var t = this.tabstops[this.index];
823            (t && this.addTabstopMarkers(t),
824              (this.index = e),
825              (t = this.tabstops[this.index]));
826            if (!t || !t.length) return;
827            this.selectedTabstop = t;
828            var n = t.firstNonLinked || t;
829            t.choices && (n.cursor = n.start);
830            if (!this.editor.inVirtualSelectionMode) {
831              var r = this.editor.multiSelect;
832              r.toSingleRange(n);
833              for (var i = 0; i < t.length; i++) {
834                if (t.hasLinkedRanges && t[i].linked) continue;
835                r.addRange(t[i].clone(), !0);
836              }
837            } else this.editor.selection.fromOrientedRange(n);
838            (this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler),
839              this.selectedTabstop &&
840                this.selectedTabstop.choices &&
841                this.editor.execCommand("startAutocomplete", {
842                  matches: this.selectedTabstop.choices,
843                }));
844          }),
845          (e.prototype.addTabstops = function (e, t, n) {
846            var r = this.useLink || !this.editor.getOption("enableMultiselect");
847            this.$openTabstops || (this.$openTabstops = []);
848            if (!e[0]) {
849              var i = u.fromPoints(n, n);
850              (y(i.start, t), y(i.end, t), (e[0] = [i]), (e[0].index = 0));
851            }
852            var s = this.index,
853              o = [s + 1, 0],
854              f = this.ranges;
855            (e.forEach(function (e, n) {
856              var i = this.$openTabstops[n] || e;
857              for (var s = 0; s < e.length; s++) {
858                var l = e[s],
859                  c = u.fromPoints(l.start, l.end || l.start);
860                (g(c.start, t),
861                  g(c.end, t),
862                  (c.original = l),
863                  (c.tabstop = i),
864                  f.push(c),
865                  i != e ? i.unshift(c) : (i[s] = c),
866                  l.fmtString || (i.firstNonLinked && r)
867                    ? ((c.linked = !0), (i.hasLinkedRanges = !0))
868                    : i.firstNonLinked || (i.firstNonLinked = c));
869              }
870              (i.firstNonLinked || (i.hasLinkedRanges = !1),
871                i === e && (o.push(i), (this.$openTabstops[n] = i)),
872                this.addTabstopMarkers(i),
873                (i.rangeList = i.rangeList || new a()),
874                (i.rangeList.$bias = 0),
875                i.rangeList.addList(i));
876            }, this),
877              o.length > 2 &&
878                (this.tabstops.length && o.push(o.splice(2, 1)[0]),
879                this.tabstops.splice.apply(this.tabstops, o)));
880          }),
881          (e.prototype.addTabstopMarkers = function (e) {
882            var t = this.session;
883            e.forEach(function (e) {
884              e.markerId ||
885                (e.markerId = t.addMarker(e, "ace_snippet-marker", "text"));
886            });
887          }),
888          (e.prototype.removeTabstopMarkers = function (e) {
889            var t = this.session;
890            e.forEach(function (e) {
891              (t.removeMarker(e.markerId), (e.markerId = null));
892            });
893          }),
894          (e.prototype.removeRange = function (e) {
895            var t = e.tabstop.indexOf(e);
896            (t != -1 && e.tabstop.splice(t, 1),
897              (t = this.ranges.indexOf(e)),
898              t != -1 && this.ranges.splice(t, 1),
899              (t = e.tabstop.rangeList.ranges.indexOf(e)),
900              t != -1 && e.tabstop.splice(t, 1),
901              this.session.removeMarker(e.markerId),
902              e.tabstop.length ||
903                ((t = this.tabstops.indexOf(e.tabstop)),
904                t != -1 && this.tabstops.splice(t, 1),
905                this.tabstops.length || this.detach()));
906          }),
907          e
908        );
909      })();
910    ((m.prototype.keyboardHandler = new f()),
911      m.prototype.keyboardHandler.bindKeys({
912        Tab: function (e) {
913          if (t.snippetManager && t.snippetManager.expandWithTab(e)) return;
914          (e.tabstopManager.tabNext(1), e.renderer.scrollCursorIntoView());
915        },
916        "Shift-Tab": function (e) {
917          (e.tabstopManager.tabNext(-1), e.renderer.scrollCursorIntoView());
918        },
919        Esc: function (e) {
920          e.tabstopManager.detach();
921        },
922      }));
923    var g = function (e, t) {
924        (e.row == 0 && (e.column += t.column), (e.row += t.row));
925      },
926      y = function (e, t) {
927        (e.row == t.row && (e.column -= t.column), (e.row -= t.row));
928      };
929    (r.importCssString(
930      "\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}",
931      "snippets.css",
932      !1,
933    ),
934      (t.snippetManager = new d()));
935    var b = e("./editor").Editor;
936    (function () {
937      ((this.insertSnippet = function (e, n) {
938        return t.snippetManager.insertSnippet(this, e, n);
939      }),
940        (this.expandSnippet = function (e) {
941          return t.snippetManager.expandWithTab(this, e);
942        }));
943    }).call(b.prototype);
944  },
945),
946  ace.define(
947    "ace/ext/emmet",
948    [
949      "require",
950      "exports",
951      "module",
952      "ace/keyboard/hash_handler",
953      "ace/editor",
954      "ace/snippets",
955      "ace/range",
956      "ace/config",
957      "resources",
958      "resources",
959      "tabStops",
960      "resources",
961      "utils",
962      "actions",
963    ],
964    function (e, t, n) {
965      "use strict";
966      var r = e("../keyboard/hash_handler").HashHandler,
967        i = e("../editor").Editor,
968        s = e("../snippets").snippetManager,
969        o = e("../range").Range,
970        u = e("../config"),
971        a,
972        f,
973        l = (function () {
974          function e() {}
975          return (
976            (e.prototype.setupContext = function (e) {
977              ((this.ace = e),
978                (this.indentation = e.session.getTabString()),
979                a || (a = window.emmet));
980              var t = a.resources || a.require("resources");
981              (t.setVariable("indentation", this.indentation),
982                (this.$syntax = null),
983                (this.$syntax = this.getSyntax()));
984            }),
985            (e.prototype.getSelectionRange = function () {
986              var e = this.ace.getSelectionRange(),
987                t = this.ace.session.doc;
988              return {
989                start: t.positionToIndex(e.start),
990                end: t.positionToIndex(e.end),
991              };
992            }),
993            (e.prototype.createSelection = function (e, t) {
994              var n = this.ace.session.doc;
995              this.ace.selection.setRange({
996                start: n.indexToPosition(e),
997                end: n.indexToPosition(t),
998              });
999            }),
1000            (e.prototype.getCurrentLineRange = function () {
1001              var e = this.ace,
1002                t = e.getCursorPosition().row,
1003                n = e.session.getLine(t).length,
1004                r = e.session.doc.positionToIndex({ row: t, column: 0 });
1005              return { start: r, end: r + n };
1006            }),
1007            (e.prototype.getCaretPos = function () {
1008              var e = this.ace.getCursorPosition();
1009              return this.ace.session.doc.positionToIndex(e);
1010            }),
1011            (e.prototype.setCaretPos = function (e) {
1012              var t = this.ace.session.doc.indexToPosition(e);
1013              this.ace.selection.moveToPosition(t);
1014            }),
1015            (e.prototype.getCurrentLine = function () {
1016              var e = this.ace.getCursorPosition().row;
1017              return this.ace.session.getLine(e);
1018            }),
1019            (e.prototype.replaceContent = function (e, t, n, r) {
1020              (n == null && (n = t == null ? this.getContent().length : t),
1021                t == null && (t = 0));
1022              var i = this.ace,
1023                u = i.session.doc,
1024                a = o.fromPoints(u.indexToPosition(t), u.indexToPosition(n));
1025              (i.session.remove(a),
1026                (a.end = a.start),
1027                (e = this.$updateTabstops(e)),
1028                s.insertSnippet(i, e));
1029            }),
1030            (e.prototype.getContent = function () {
1031              return this.ace.getValue();
1032            }),
1033            (e.prototype.getSyntax = function () {
1034              if (this.$syntax) return this.$syntax;
1035              var e = this.ace.session.$modeId.split("/").pop();
1036              if (e == "html" || e == "php") {
1037                var t = this.ace.getCursorPosition(),
1038                  n = this.ace.session.getState(t.row);
1039                (typeof n != "string" && (n = n[0]),
1040                  n &&
1041                    ((n = n.split("-")),
1042                    n.length > 1 ? (e = n[0]) : e == "php" && (e = "html")));
1043              }
1044              return e;
1045            }),
1046            (e.prototype.getProfileName = function () {
1047              var e = a.resources || a.require("resources");
1048              switch (this.getSyntax()) {
1049                case "css":
1050                  return "css";
1051                case "xml":
1052                case "xsl":
1053                  return "xml";
1054                case "html":
1055                  var t = e.getVariable("profile");
1056                  return (
1057                    t ||
1058                      (t =
1059                        this.ace.session
1060                          .getLines(0, 2)
1061                          .join("")
1062                          .search(/<!DOCTYPE[^>]+XHTML/i) != -1
1063                          ? "xhtml"
1064                          : "html"),
1065                    t
1066                  );
1067                default:
1068                  var n = this.ace.session.$mode;
1069                  return (n.emmetConfig && n.emmetConfig.profile) || "xhtml";
1070              }
1071            }),
1072            (e.prototype.prompt = function (e) {
1073              return prompt(e);
1074            }),
1075            (e.prototype.getSelection = function () {
1076              return this.ace.session.getTextRange();
1077            }),
1078            (e.prototype.getFilePath = function () {
1079              return "";
1080            }),
1081            (e.prototype.$updateTabstops = function (e) {
1082              var t = 1e3,
1083                n = 0,
1084                r = null,
1085                i = a.tabStops || a.require("tabStops"),
1086                s = a.resources || a.require("resources"),
1087                o = s.getVocabulary("user"),
1088                u = {
1089                  tabstop: function (e) {
1090                    var s = parseInt(e.group, 10),
1091                      o = s === 0;
1092                    o ? (s = ++n) : (s += t);
1093                    var a = e.placeholder;
1094                    a && (a = i.processText(a, u));
1095                    var f = "${" + s + (a ? ":" + a : "") + "}";
1096                    return (o && (r = [e.start, f]), f);
1097                  },
1098                  escape: function (e) {
1099                    return e == "$" ? "\\$" : e == "\\" ? "\\\\" : e;
1100                  },
1101                };
1102              e = i.processText(e, u);
1103              if (o.variables.insert_final_tabstop && !/\$\{0\}$/.test(e))
1104                e += "${0}";
1105              else if (r) {
1106                var f = a.utils ? a.utils.common : a.require("utils");
1107                e = f.replaceSubstring(e, "${0}", r[0], r[1]);
1108              }
1109              return e;
1110            }),
1111            e
1112          );
1113        })(),
1114        c = {
1115          expand_abbreviation: { mac: "%", win: "%" },
1116          match_pair_outward: { mac: "ctrl+d", win: "ctrl+," },
1117          match_pair_inward: { mac: "ctrl+j", win: "ctrl+shift+0" },
1118          matching_pair: { mac: "ctrl+alt+j", win: "alt+j" },
1119          next_edit_point: "alt+right",
1120          prev_edit_point: "alt+left",
1121          toggle_comment: { mac: "command+/", win: "ctrl+/" },
1122          split_join_tag: { mac: "shift+command+'", win: "shift+ctrl+`" },
1123          remove_tag: { mac: "command+'", win: "shift+ctrl+;" },
1124          evaluate_math_expression: {
1125            mac: "shift+command+y",
1126            win: "shift+ctrl+y",
1127          },
1128          increment_number_by_1: "ctrl+up",
1129          decrement_number_by_1: "ctrl+down",
1130          increment_number_by_01: "alt+up",
1131          decrement_number_by_01: "alt+down",
1132          increment_number_by_10: {
1133            mac: "alt+command+up",
1134            win: "shift+alt+up",
1135          },
1136          decrement_number_by_10: {
1137            mac: "alt+command+down",
1138            win: "shift+alt+down",
1139          },
1140          select_next_item: { mac: "shift+command+.", win: "shift+ctrl+." },
1141          select_previous_item: { mac: "shift+command+,", win: "shift+ctrl+," },
1142          reflect_css_value: { mac: "shift+command+r", win: "shift+ctrl+r" },
1143          encode_decode_data_url: { mac: "shift+ctrl+d", win: "ctrl+'" },
1144          expand_abbreviation_with_tab: "Tab",
1145          wrap_with_abbreviation: { mac: "shift+ctrl+a", win: "shift+ctrl+a" },
1146        },
1147        h = new l();
1148      ((t.commands = new r()),
1149        (t.runEmmetCommand = function v(e) {
1150          if (this.action == "expand_abbreviation_with_tab") {
1151            if (!e.selection.isEmpty()) return !1;
1152            var n = e.selection.lead,
1153              r = e.session.getTokenAt(n.row, n.column);
1154            if (r && /\btag\b/.test(r.type)) return !1;
1155          }
1156          try {
1157            h.setupContext(e);
1158            var i = a.actions || a.require("actions");
1159            if (this.action == "wrap_with_abbreviation")
1160              return setTimeout(function () {
1161                i.run("wrap_with_abbreviation", h);
1162              }, 0);
1163            var s = i.run(this.action, h);
1164          } catch (o) {
1165            if (!a) {
1166              var f = t.load(v.bind(this, e));
1167              return this.action == "expand_abbreviation_with_tab" ? !1 : f;
1168            }
1169            (e._signal("changeStatus", typeof o == "string" ? o : o.message),
1170              u.warn(o),
1171              (s = !1));
1172          }
1173          return s;
1174        }));
1175      for (var p in c)
1176        t.commands.addCommand({
1177          name: "emmet:" + p,
1178          action: p,
1179          bindKey: c[p],
1180          exec: t.runEmmetCommand,
1181          multiSelectAction: "forEach",
1182        });
1183      ((t.updateCommands = function (e, n) {
1184        n
1185          ? e.keyBinding.addKeyboardHandler(t.commands)
1186          : e.keyBinding.removeKeyboardHandler(t.commands);
1187      }),
1188        (t.isSupportedMode = function (e) {
1189          if (!e) return !1;
1190          if (e.emmetConfig) return !0;
1191          var t = e.$id || e;
1192          return /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(
1193            t,
1194          );
1195        }),
1196        (t.isAvailable = function (e, n) {
1197          if (/(evaluate_math_expression|expand_abbreviation)$/.test(n))
1198            return !0;
1199          var r = e.session.$mode,
1200            i = t.isSupportedMode(r);
1201          if (i && r.$modes)
1202            try {
1203              (h.setupContext(e), /js|php/.test(h.getSyntax()) && (i = !1));
1204            } catch (s) {}
1205          return i;
1206        }));
1207      var d = function (e, n) {
1208        var r = n;
1209        if (!r) return;
1210        var i = t.isSupportedMode(r.session.$mode);
1211        (e.enableEmmet === !1 && (i = !1),
1212          i && t.load(),
1213          t.updateCommands(r, i));
1214      };
1215      ((t.load = function (e) {
1216        return typeof f != "string"
1217          ? !1
1218          : (u.loadModule(f, function () {
1219              ((f = null), e && e());
1220            }),
1221            !0);
1222      }),
1223        (t.AceEmmetEditor = l),
1224        u.defineOptions(i.prototype, "editor", {
1225          enableEmmet: {
1226            set: function (e) {
1227              (this[e ? "on" : "removeListener"]("changeMode", d),
1228                d({ enableEmmet: !!e }, this));
1229            },
1230            value: !0,
1231          },
1232        }),
1233        (t.setCore = function (e) {
1234          typeof e == "string" ? (f = e) : (a = e);
1235        }));
1236    },
1237  ));
1238(function () {
1239  ace.require(["ace/ext/emmet"], function (m) {
1240    if (typeof module == "object" && typeof exports == "object" && module) {
1241      module.exports = m;
1242    }
1243  });
1244})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.