3594 lines
100 KiB
JavaScript

/*!
* Tiny Enhanced Code Editor plugin
*
* Copyright (c) 2023 Ephox Corporation DBA Tiny Technologies, Inc.
* Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/
*
* Version: 8.3.0-112
*/
/*!
* This resource uses the code from the following libraries:
*
* highlight
* Copyright (C) 2018 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
* https://github.com/lezer-parser/highlight
*
* js-beautify
* Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
* https://github.com/beautifier/js-beautify
*/
!(function () {
"use strict";
const t = (t) => (e) => typeof e === t,
e = (t) =>
"string" ===
((t) => {
const e = typeof t;
return null === t
? "null"
: "object" === e && Array.isArray(t)
? "array"
: "object" === e &&
((n = i = t),
(r = String).prototype.isPrototypeOf(n) ||
i.constructor?.name === r.name)
? "string"
: e;
var n, i, r;
})(t);
const n = t("boolean"),
i = (t) => null == t,
r = (t) => !i(t),
s = t("function"),
o = t("number"),
_ = () => {},
a = () => !1;
class c {
tag;
value;
static singletonNone = new c(!1);
constructor(t, e) {
((this.tag = t), (this.value = e));
}
static some(t) {
return new c(!0, t);
}
static none() {
return c.singletonNone;
}
fold(t, e) {
return this.tag ? e(this.value) : t();
}
isSome() {
return this.tag;
}
isNone() {
return !this.tag;
}
map(t) {
return this.tag ? c.some(t(this.value)) : c.none();
}
bind(t) {
return this.tag ? t(this.value) : c.none();
}
exists(t) {
return this.tag && t(this.value);
}
forall(t) {
return !this.tag || t(this.value);
}
filter(t) {
return !this.tag || t(this.value) ? this : c.none();
}
getOr(t) {
return this.tag ? this.value : t;
}
or(t) {
return this.tag ? this : t;
}
getOrThunk(t) {
return this.tag ? this.value : t();
}
orThunk(t) {
return this.tag ? this : t();
}
getOrDie(t) {
if (this.tag) return this.value;
throw new Error(t ?? "Called getOrDie on None");
}
static from(t) {
return r(t) ? c.some(t) : c.none();
}
getOrNull() {
return this.tag ? this.value : null;
}
getOrUndefined() {
return this.value;
}
each(t) {
this.tag && t(this.value);
}
toArray() {
return this.tag ? [this.value] : [];
}
toString() {
return this.tag ? `some(${this.value})` : "none()";
}
}
const p = (t, e) => {
for (let n = 0, i = t.length; n < i; n++) if (e(t[n], n)) return !0;
return !1;
},
l = (t, e) => {
for (let n = 0, i = t.length; n < i; n++) e(t[n], n);
},
u = Object.keys,
h = Object.hasOwnProperty,
d = (t, e) => g(t, (t, n) => ({ k: n, v: e(t, n) })),
g = (t, e) => {
const n = {};
return (
((t, e) => {
const n = u(t);
for (let i = 0, r = n.length; i < r; i++) {
const r = n[i];
e(t[r], r);
}
})(t, (t, i) => {
const r = e(t, i);
n[r.k] = r.v;
}),
n
);
},
m = (t, e) => h.call(t, e),
f = (t) => {
let e = t;
return {
get: () => e,
set: (t) => {
e = t;
},
};
};
let y = 0;
const w = (t) => {
const e = new Date().getTime(),
n = Math.floor(
(window.crypto.getRandomValues(new Uint32Array(1))[0] / 4294967295) *
1e9,
);
return (y++, t + "_" + n + y + String(e));
},
v = () => {
const t = ((t) => {
const e = f(c.none()),
n = () => e.get().each(t);
return {
clear: () => {
(n(), e.set(c.none()));
},
isSet: () => e.get().isSome(),
get: () => e.get(),
set: (t) => {
(n(), e.set(c.some(t)));
},
};
})(_);
return { ...t, on: (e) => t.get().each(e) };
},
b = (t, e) => {
const { type: n, message: i } = e;
t.notificationManager.open({ type: n, text: i });
},
x = (t) => {
const e = ((t) => {
switch (t) {
case "error":
return console.error;
case "info":
return console.info;
case "warn":
return console.warn;
default:
return console.log;
}
})(t.type);
e(t.message);
},
k = (t, e) => {
const {
protect: n,
allowList: i = [],
blockList: s = [],
} = null != t ? t : {};
let o;
return (
(o = r(n) ? n : i.length > 0 || s.length > 0 || e),
{ protect: o, allowList: i, blockList: s }
);
},
T = (t) => {
const { protect: e, allowList: n, blockList: i } = null != t ? t : {};
return (t) => {
const r = t.toLowerCase();
return n.length > 0
? !p(n, (t) => t.toLowerCase() === r)
: i.length > 0
? p(i, (t) => t.toLowerCase() === r)
: e;
};
},
O = (t) => {
const e = T(t);
return (t, n) => {
const i = ((t, e) => `${t}:${e}`)(n, t.toLowerCase());
return e(i);
};
},
C = (t, e, n, i) => {
const r = Reflect.get(t, "on"),
s = { protectedEventHandlers: [], cleanupScheduled: !1 },
o = (t, e) => {
i && console.log(`[EventsProxy] ${t}`, e || "");
},
a = (e) => {
"invalid" === e &&
s.protectedEventHandlers.length > 0 &&
(o("Removing event handlers", s.protectedEventHandlers),
l(s.protectedEventHandlers, (e) => {
t.off(e.name, e.callback);
}),
(s.protectedEventHandlers = []));
},
c = e.onStatusChange(a);
return (
t.on("remove", c),
(i, c, p) => {
o(`Adding event listener: ${i}`, { shouldProtect: n(i) });
const l = ((t, i) => {
const r = n(t),
o = e.getStatus(),
a = r && "invalid" === o ? _ : i;
return (
r && s.protectedEventHandlers.push({ name: t, callback: a }),
a
);
})(i, c);
return (
s.cleanupScheduled ||
((s.cleanupScheduled = !0),
window.setTimeout(() => {
(a(e.getStatus()), (s.cleanupScheduled = !1));
}, 0)),
Reflect.apply(r, t, [i, l, p])
);
}
);
},
E = (t, e, n) => (i) => {
const s = "invalid" !== e.getStatus() && r(n) ? n(i) : _,
o = ((t, e, n) => {
const i = (t) => {
"invalid" === t && n.setEnabled(!1);
},
r = () => i(e.getStatus());
(i(e.getStatus()), t.on("NodeChange", r));
const s = e.onStatusChange(i);
return () => {
(t.off("NodeChange", r), s());
};
})(t, e, i);
return (t) => {
(null == s || s(t), o());
};
},
S =
(t, e, n) =>
(...i) => {
var r;
return "invalid" === t.getStatus()
? n
: null !== (r = null == e ? void 0 : e(...i)) && void 0 !== r
? r
: n;
},
A = (t, e) => S(t, e, Promise.resolve([])),
L = (t, e) => S(t, e, []),
N = (t, e) => S(t, e, !1),
R = (t, n, i, r) => {
const s = (n) => {
const { command: s, value: o } = n,
_ = c
.from(o)
.filter(e)
.map((t) => t.toLowerCase()),
a = s.toLowerCase() === r.toLowerCase(),
p = _.exists((t) => i.has(t)),
l = _.exists((e) => e === t.queryCommandValue(r));
a && p && !l && n.preventDefault();
},
o = n.onStatusChange((e) => {
if ("invalid" === e) {
t.on("BeforeExecCommand", s);
const e = () => {
const e = t.queryCommandValue(r);
i.has(e.toLowerCase()) && t.execCommand(r, !1, e);
};
t.initialized ? e() : t.on("init", e);
}
});
t.on("remove", () => {
(o(), t.off("BeforeExecCommand", s));
});
},
z = (t, n, i, r, s, o = !1) => {
const _ = new Set(),
a = new Set(),
c = (t, e) => {
o && console.log(`[UiProxy] ${t}`, e || "");
};
(((t, e, n) => {
R(t, e, n, "ToggleView");
})(t, i, _),
((t, e, n) => {
R(t, e, n, "ToggleSidebar");
})(t, i, a));
const p = (e, n, o, _) => {
const a = s(e, o);
return (
c(`${_}: ${e}`, { spec: n, context: r, shouldProtect: a }),
a ? { ...n, onSetup: E(t, i, n.onSetup) } : n
);
};
return new Proxy(n, {
get: (t, n, o) => {
const l = Reflect.get(t, n, o);
if (!e(n)) return l;
switch (n) {
case "addButton":
case "addGroupToolbarButton":
case "addToggleButton":
case "addMenuButton":
case "addSplitButton":
return (...e) => {
const [i, r, ...s] = e,
o = p(i, r, "button", String(n));
return Reflect.apply(l, t, [i, o, ...s]);
};
case "addMenuItem":
case "addToggleMenuItem":
case "addNestedMenuItem":
return (...e) => {
const [i, r, ...s] = e,
o = p(i, r, "menuitem", String(n));
return Reflect.apply(l, t, [i, o, ...s]);
};
case "addAutocompleter":
return (...e) => {
const [o, _, ...a] = e,
p = s(o, "autocompleter");
if (
(c(`${String(n)}: ${o}`, {
spec: _,
context: r,
shouldProtect: p,
}),
p)
) {
const e = { ..._, fetch: A(i, _.fetch) };
return Reflect.apply(l, t, [o, e, ...a]);
}
return Reflect.apply(l, t, [o, _, ...a]);
};
case "addSidebar":
return (...e) => {
const [i, o, ..._] = e,
p = s(i, "sidebar");
if (
(c(`${String(n)}: ${i}`, {
spec: o,
context: r,
shouldProtect: p,
}),
p)
) {
a.add(i.toLowerCase());
const e = { ...o };
return Reflect.apply(l, t, [i, e, ..._]);
}
return Reflect.apply(l, t, [i, o, ..._]);
};
case "addView":
return (...e) => {
const [i, o, ...a] = e,
p = s(i, "view");
if (
(c(`${String(n)}: ${i}`, {
spec: o,
context: r,
shouldProtect: p,
}),
p)
) {
_.add(i.toLowerCase());
const e = { ...o };
return Reflect.apply(l, t, [i, e, ...a]);
}
return Reflect.apply(l, t, [i, o, ...a]);
};
case "addContextMenu":
return (...e) => {
const [o, _, ...a] = e,
p = s(o, "contextmenu");
if (
(c(`${String(n)}: ${o}`, {
spec: _,
context: r,
shouldProtect: p,
}),
p)
) {
const e = { ..._, update: L(i, _.update) };
return Reflect.apply(l, t, [o, e, ...a]);
}
return Reflect.apply(l, t, [o, _, ...a]);
};
case "addContextToolbar":
case "addContextForm":
return (...e) => {
const [o, _, ...a] = e,
p = s(o, "contexttoolbar");
if (
(c(`${String(n)}: ${o}`, {
spec: _,
context: r,
shouldProtect: p,
}),
p)
) {
const e = { ..._, predicate: N(i, _.predicate) };
return Reflect.apply(l, t, [o, e, ...a]);
}
return Reflect.apply(l, t, [o, _, ...a]);
};
case "addIcon":
case "getAll":
case "addContext":
return l;
}
},
});
},
P = new Set([
"addCommand",
"addCommands",
"addQueryStateHandler",
"addQueryValueHandler",
]),
j = (t) => (e, n) => {
t && console.log(`[EditorProxy] ${e}`, n || "");
},
I = (t, e) => {
const {
statusProvider: n,
uiContext: i,
protection: r,
debug: o = !1,
} = e,
{ events: a, commands: c, ui: p } = r;
j(o)("Creating enhanced editor with options:", {
hasStatusProvider: !!n,
uiContext: i,
debug: o,
protection: r,
});
const {
editorUiProxy: u,
editorCommandsProxy: h,
editorEventListenerProxy: g,
} = ((t, e, n, i, r, s, o) => {
const a = s.protect
? { ...t.ui, registry: z(t, t.ui.registry, e, n, O(s), o) }
: t.ui,
c = i.protect
? ((t, e, n, i, r) => {
const s = { protectedCommands: [], cleanupScheduled: !1 },
o = (t, e) => {
r && console.log(`[CommandsProxy] ${t}`, e || "");
},
a = (t, e) => {
const r = i(t),
o = n.getStatus();
return (
r && s.protectedCommands.push(t),
r && "invalid" === o ? _ : e
);
},
c = (e) => {
"invalid" === e &&
s.protectedCommands.length > 0 &&
(o("Removing commands", s.protectedCommands),
l(s.protectedCommands, (e) => {
t.editorCommands.removeCommand(e);
}),
(s.protectedCommands = []));
},
p = () => {
s.cleanupScheduled ||
((s.cleanupScheduled = !0),
window.setTimeout(() => {
(c(n.getStatus()), (s.cleanupScheduled = !1));
}, 0));
},
u = n.onStatusChange(c);
return (
t.on("remove", u),
new Proxy(e, {
get: (t, n, r) => {
if (
(o(`Accessing property: ${String(n)}`),
"addCommand" === n)
) {
const s = Reflect.get(t, n, r);
return (t, n, ...r) => {
o(`Adding command: ${t}`, { shouldProtect: i(t) });
const _ = a(t, n);
return (p(), Reflect.apply(s, e, [t, _, ...r]));
};
}
if ("addCommands" === n) {
const i = Reflect.get(t, n, r);
return (t, n = "exec") => {
o(`Adding commands (${n})`, {
commandCount: Object.keys(t).length,
willApplyEnforcement: "exec" === n,
});
const r =
"exec" !== n ? t : d(t, (t, e) => a(e, t));
return (p(), Reflect.apply(i, e, [r, n]));
};
}
return Reflect.get(t, n, r);
},
})
);
})(t, t.editorCommands, e, T(i), o)
: t.editorCommands;
return {
editorUiProxy: a,
editorCommandsProxy: c,
editorEventListenerProxy: r.protect
? C(t, e, T(r), o)
: t.on.bind(t),
};
})(t, n, i || "", c, a, p, o),
m = ((t, e, n, i) => (r, o, _) => {
const a = String(o);
if ("on" === o) return (j(i)("on intercepted"), n);
if (P.has(a)) return (j(i)(`${a} intercepted`), e[a].bind(e));
if ("editorCommands" === o)
return (j(i)("editorCommands accessed"), e);
if ("ui" === o) return (j(i)("ui accessed"), t);
const c = Reflect.get(r, o, _);
return s(c) ? c.bind(r) : c;
})(u, h, g, o);
return new Proxy(t, {
get: m,
set: (t, e, n, i) => Reflect.set(t, e, n, i),
has: (t, e) => Reflect.has(t, e),
ownKeys: (t) => Reflect.ownKeys(t),
getOwnPropertyDescriptor: (t, e) =>
Reflect.getOwnPropertyDescriptor(t, e),
defineProperty: (t, e, n) => Reflect.defineProperty(t, e, n),
deleteProperty: (t, e) => Reflect.deleteProperty(t, e),
isExtensible: (t) => Reflect.isExtensible(t),
preventExtensions: (t) => Reflect.preventExtensions(t),
getPrototypeOf: (t) => Reflect.getPrototypeOf(t),
setPrototypeOf: (t, e) => Reflect.setPrototypeOf(t, e),
});
},
U = (t) => parseInt(t, 10),
$ = (t, e) => {
const n = t - e;
return 0 === n ? 0 : n > 0 ? 1 : -1;
},
F = (t, e, n) => ({ major: t, minor: e, patch: n }),
M = (t) => {
const e = /([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(t);
return e ? F(U(e[1]), U(e[2]), U(e[3])) : F(0, 0, 0);
},
W = (t, e) =>
!!t &&
-1 ===
((t, e) => {
const n = $(t.major, e.major);
if (0 !== n) return n;
const i = $(t.minor, e.minor);
if (0 !== i) return i;
const r = $(t.patch, e.patch);
return 0 !== r ? r : 0;
})(
((t) =>
M(
((t) =>
[t.majorVersion, t.minorVersion]
.join(".")
.split(".")
.slice(0, 3)
.join("."))(t),
))(t),
M(e),
),
K = M("8.3.0"),
B = `${K.major}.${K.minor}.0`,
V = `${K.major + 1}.0.0`,
G = (t, e) => {
const { setup: n, protection: o } = e;
return (_, a) => {
if (
!((t, e) =>
W(t, B)
? (console.error(
`The "${e}" plugin requires at least version ${B} of TinyMCE.`,
),
!1)
: !!W(t, V) ||
(console.error(
`The "${e}" plugin requires at least version ${B} of TinyMCE but less than ${V}.`,
),
!1))(tinymce, t) ||
((t, e) =>
!!((t) => {
var e;
const n =
null === (e = t.options.get("license_key")) || void 0 === e
? void 0
: e.toLowerCase(),
r = t.options.get("online_license_key");
return i(r) && "gpl" === n;
})(t) &&
(((t, e) => {
const { console: n, editor: i } = e;
(r(i) &&
(t._skinLoaded
? b(t, i)
: t.on("SkinLoaded", () => {
b(t, i);
})),
r(n) && x(n));
})(t, {
console: {
type: "error",
message: [
`The "${e}" plugin requires a valid TinyMCE license key.`,
"Read more: https://www.tiny.cloud/docs/tinymce/latest/license-key/",
].join(" "),
},
}),
!0))(_, t)
)
return {};
const c = ((t) => {
const {
protect: e = !0,
events: n,
commands: i,
ui: r,
api: s,
} = null != t ? t : {};
return {
protect: e,
events: k(n, false),
commands: k(i, true),
ui: k(r, true),
api: k(s, true),
};
})(o),
p = ((t = "pre-validation") => {
const e = f(t),
n = new Set();
let i = !1;
const { enableLogging: r = !1 } = {},
s = (t, ...e) => {
r && console.log(`[StatusProvider] ${t}`, ...e);
};
return {
setStatus: (t) => {
const i = e.get();
if (i === t) return (s("Status unchanged:", t), !1);
(e.set(t), s("Status changed:", i, "->", t));
const r = { currentStatus: t, previousStatus: i },
o = Array.from(n);
return (
l(o, (t) => {
t(r.currentStatus, r.previousStatus);
}),
!0
);
},
onStatusChange: (t) => (
n.add(t),
s("Callback registered, total listeners:", n.size),
() => {
n.delete(t) &&
s("Callback unregistered, remaining listeners:", n.size);
}
),
getStatus: e.get,
hasListeners: () => n.size > 0,
destroy: () => {
i ||
(s(
"Destroying StatusProvider, clearing",
n.size,
"listeners",
),
n.clear(),
(i = !0));
},
};
})(),
u = ((t, e, n) => {
const i = `commercial-license-${e}`;
return (
t.ui.registry.addContext(
i,
() => "invalid" !== n.getStatus() && !t.mode.isReadOnly(),
),
t.licenseKeyManager.validate({ plugin: e }).then(
(t) => {
n.setStatus(t ? "valid" : "invalid");
},
(t) => {
(console.error(t),
console.error(
`An unknown error occurred when trying to validate "${e}" plugin.`,
),
n.setStatus("invalid"));
},
),
{ ui: { context: i } }
);
})(_, t, p),
h = c.protect
? I(_, {
statusProvider: p,
uiContext: u.ui.context,
debug: e.debug || !1,
protection: c,
})
: _,
g = ((t, e) => ({
pluginCode: t,
enforcer: {
isInvalid: () => "invalid" === e.getStatus(),
onInvalid: (t) =>
e.onStatusChange((e, n) => {
"invalid" === e && t(e, n);
}),
},
}))(t, p);
return ((t, e, n, i) => {
if (e.protect && e.api.protect && r(t)) {
const _ = T(e.api);
return ((o = (t) => "invalid" === n.getStatus() && _(t)),
(t, e) =>
d(t, (t, n) =>
s(t)
? (...i) => {
if (o(n.toLowerCase())) {
const t = `Method "${r(e) ? `${e}.` : ""}${n}" is not available due to license key restrictions.`,
i = new Error(t);
throw (console.error(t), i);
}
return t(...i);
}
: t,
))(t, i);
}
var o;
return t;
})(n(h, a, g), c, p, t);
};
};
function D(t) {
return t &&
t.__esModule &&
Object.prototype.hasOwnProperty.call(t, "default")
? t.default
: t;
}
var q,
H,
Q = { exports: {} },
X = {},
Y = {},
Z = {};
function J() {
if (H) return Y;
H = 1;
var t = (function () {
if (q) return Z;
function t(t, n) {
((this.raw_options = e(t, n)),
(this.disabled = this._get_boolean("disabled")),
(this.eol = this._get_characters("eol", "auto")),
(this.end_with_newline = this._get_boolean("end_with_newline")),
(this.indent_size = this._get_number("indent_size", 4)),
(this.indent_char = this._get_characters("indent_char", " ")),
(this.indent_level = this._get_number("indent_level")),
(this.preserve_newlines = this._get_boolean("preserve_newlines", !0)),
(this.max_preserve_newlines = this._get_number(
"max_preserve_newlines",
32786,
)),
this.preserve_newlines || (this.max_preserve_newlines = 0),
(this.indent_with_tabs = this._get_boolean(
"indent_with_tabs",
"\t" === this.indent_char,
)),
this.indent_with_tabs &&
((this.indent_char = "\t"),
1 === this.indent_size && (this.indent_size = 4)),
(this.wrap_line_length = this._get_number(
"wrap_line_length",
this._get_number("max_char"),
)),
(this.indent_empty_lines = this._get_boolean("indent_empty_lines")),
(this.templating = this._get_selection_list(
"templating",
[
"auto",
"none",
"angular",
"django",
"erb",
"handlebars",
"php",
"smarty",
],
["auto"],
)));
}
function e(t, e) {
var i,
r = {};
for (i in (t = n(t))) i !== e && (r[i] = t[i]);
if (e && t[e]) for (i in t[e]) r[i] = t[e][i];
return r;
}
function n(t) {
var e,
n = {};
for (e in t) n[e.replace(/-/g, "_")] = t[e];
return n;
}
return (
(q = 1),
(t.prototype._get_array = function (t, e) {
var n = this.raw_options[t],
i = e || [];
return (
"object" == typeof n
? null !== n && "function" == typeof n.concat && (i = n.concat())
: "string" == typeof n && (i = n.split(/[^a-zA-Z0-9_\/\-]+/)),
i
);
}),
(t.prototype._get_boolean = function (t, e) {
var n = this.raw_options[t];
return void 0 === n ? !!e : !!n;
}),
(t.prototype._get_characters = function (t, e) {
var n = this.raw_options[t],
i = e || "";
return (
"string" == typeof n &&
(i = n
.replace(/\\r/, "\r")
.replace(/\\n/, "\n")
.replace(/\\t/, "\t")),
i
);
}),
(t.prototype._get_number = function (t, e) {
var n = this.raw_options[t];
((e = parseInt(e, 10)), isNaN(e) && (e = 0));
var i = parseInt(n, 10);
return (isNaN(i) && (i = e), i);
}),
(t.prototype._get_selection = function (t, e, n) {
var i = this._get_selection_list(t, e, n);
if (1 !== i.length)
throw new Error(
"Invalid Option Value: The option '" +
t +
"' can only be one of the following values:\n" +
e +
"\nYou passed in: '" +
this.raw_options[t] +
"'",
);
return i[0];
}),
(t.prototype._get_selection_list = function (t, e, n) {
if (!e || 0 === e.length)
throw new Error("Selection list cannot be empty.");
if (((n = n || [e[0]]), !this._is_valid_selection(n, e)))
throw new Error("Invalid Default Value!");
var i = this._get_array(t, n);
if (!this._is_valid_selection(i, e))
throw new Error(
"Invalid Option Value: The option '" +
t +
"' can contain only the following values:\n" +
e +
"\nYou passed in: '" +
this.raw_options[t] +
"'",
);
return i;
}),
(t.prototype._is_valid_selection = function (t, e) {
return (
t.length &&
e.length &&
!t.some(function (t) {
return -1 === e.indexOf(t);
})
);
}),
(Z.Options = t),
(Z.normalizeOpts = n),
(Z.mergeOpts = e),
Z
);
})().Options;
function e(e) {
(t.call(this, e, "html"),
1 === this.templating.length &&
"auto" === this.templating[0] &&
(this.templating = ["django", "erb", "handlebars", "php"]),
(this.indent_inner_html = this._get_boolean("indent_inner_html")),
(this.indent_body_inner_html = this._get_boolean(
"indent_body_inner_html",
!0,
)),
(this.indent_head_inner_html = this._get_boolean(
"indent_head_inner_html",
!0,
)),
(this.indent_handlebars = this._get_boolean("indent_handlebars", !0)),
(this.wrap_attributes = this._get_selection("wrap_attributes", [
"auto",
"force",
"force-aligned",
"force-expand-multiline",
"aligned-multiple",
"preserve",
"preserve-aligned",
])),
(this.wrap_attributes_min_attrs = this._get_number(
"wrap_attributes_min_attrs",
2,
)),
(this.wrap_attributes_indent_size = this._get_number(
"wrap_attributes_indent_size",
this.indent_size,
)),
(this.extra_liners = this._get_array("extra_liners", [
"head",
"body",
"/html",
])),
(this.inline = this._get_array("inline", [
"a",
"abbr",
"area",
"audio",
"b",
"bdi",
"bdo",
"br",
"button",
"canvas",
"cite",
"code",
"data",
"datalist",
"del",
"dfn",
"em",
"embed",
"i",
"iframe",
"img",
"input",
"ins",
"kbd",
"keygen",
"label",
"map",
"mark",
"math",
"meter",
"noscript",
"object",
"output",
"progress",
"q",
"ruby",
"s",
"samp",
"select",
"small",
"span",
"strong",
"sub",
"sup",
"svg",
"template",
"textarea",
"time",
"u",
"var",
"video",
"wbr",
"text",
"acronym",
"big",
"strike",
"tt",
])),
(this.inline_custom_elements = this._get_boolean(
"inline_custom_elements",
!0,
)),
(this.void_elements = this._get_array("void_elements", [
"area",
"base",
"br",
"col",
"embed",
"hr",
"img",
"input",
"keygen",
"link",
"menuitem",
"meta",
"param",
"source",
"track",
"wbr",
"!doctype",
"?xml",
"basefont",
"isindex",
])),
(this.unformatted = this._get_array("unformatted", [])),
(this.content_unformatted = this._get_array("content_unformatted", [
"pre",
"textarea",
])),
(this.unformatted_content_delimiter = this._get_characters(
"unformatted_content_delimiter",
)),
(this.indent_scripts = this._get_selection("indent_scripts", [
"normal",
"keep",
"separate",
])));
}
return ((e.prototype = new t()), (Y.Options = e), Y);
}
var tt,
et,
nt,
it,
rt,
st,
ot,
_t = {},
at = {},
ct = {},
pt = {},
lt = {},
ut = {},
ht = {},
dt = {};
function gt() {
if (rt) return dt;
function t(t, e) {
((this._input = t),
(this._starting_pattern = null),
(this._match_pattern = null),
(this._until_pattern = null),
(this._until_after = !1),
e &&
((this._starting_pattern = this._input.get_regexp(
e._starting_pattern,
!0,
)),
(this._match_pattern = this._input.get_regexp(e._match_pattern, !0)),
(this._until_pattern = this._input.get_regexp(e._until_pattern)),
(this._until_after = e._until_after)));
}
return (
(rt = 1),
(t.prototype.read = function () {
var t = this._input.read(this._starting_pattern);
return (
(this._starting_pattern && !t) ||
(t += this._input.read(
this._match_pattern,
this._until_pattern,
this._until_after,
)),
t
);
}),
(t.prototype.read_match = function () {
return this._input.match(this._match_pattern);
}),
(t.prototype.until_after = function (t) {
var e = this._create();
return (
(e._until_after = !0),
(e._until_pattern = this._input.get_regexp(t)),
e._update(),
e
);
}),
(t.prototype.until = function (t) {
var e = this._create();
return (
(e._until_after = !1),
(e._until_pattern = this._input.get_regexp(t)),
e._update(),
e
);
}),
(t.prototype.starting_with = function (t) {
var e = this._create();
return (
(e._starting_pattern = this._input.get_regexp(t, !0)),
e._update(),
e
);
}),
(t.prototype.matching = function (t) {
var e = this._create();
return (
(e._match_pattern = this._input.get_regexp(t, !0)),
e._update(),
e
);
}),
(t.prototype._create = function () {
return new t(this._input, this);
}),
(t.prototype._update = function () {}),
(dt.Pattern = t),
dt
);
}
function mt() {
if (ot) return ct;
ot = 1;
var t = (function () {
if (et) return pt;
et = 1;
var t = RegExp.prototype.hasOwnProperty("sticky");
function e(t) {
((this.__input = t || ""),
(this.__input_length = this.__input.length),
(this.__position = 0));
}
return (
(e.prototype.restart = function () {
this.__position = 0;
}),
(e.prototype.back = function () {
this.__position > 0 && (this.__position -= 1);
}),
(e.prototype.hasNext = function () {
return this.__position < this.__input_length;
}),
(e.prototype.next = function () {
var t = null;
return (
this.hasNext() &&
((t = this.__input.charAt(this.__position)),
(this.__position += 1)),
t
);
}),
(e.prototype.peek = function (t) {
var e = null;
return (
(t = t || 0),
(t += this.__position) >= 0 &&
t < this.__input_length &&
(e = this.__input.charAt(t)),
e
);
}),
(e.prototype.__match = function (e, n) {
e.lastIndex = n;
var i = e.exec(this.__input);
return (!i || (t && e.sticky) || (i.index !== n && (i = null)), i);
}),
(e.prototype.test = function (t, e) {
return (
(e = e || 0),
(e += this.__position) >= 0 &&
e < this.__input_length &&
!!this.__match(t, e)
);
}),
(e.prototype.testChar = function (t, e) {
var n = this.peek(e);
return ((t.lastIndex = 0), null !== n && t.test(n));
}),
(e.prototype.match = function (t) {
var e = this.__match(t, this.__position);
return (e ? (this.__position += e[0].length) : (e = null), e);
}),
(e.prototype.read = function (t, e, n) {
var i,
r = "";
return (
t && (i = this.match(t)) && (r += i[0]),
!e || (!i && t) || (r += this.readUntil(e, n)),
r
);
}),
(e.prototype.readUntil = function (t, e) {
var n,
i = this.__position;
t.lastIndex = this.__position;
var r = t.exec(this.__input);
return (
r
? ((i = r.index), e && (i += r[0].length))
: (i = this.__input_length),
(n = this.__input.substring(this.__position, i)),
(this.__position = i),
n
);
}),
(e.prototype.readUntilAfter = function (t) {
return this.readUntil(t, !0);
}),
(e.prototype.get_regexp = function (e, n) {
var i = null,
r = "g";
return (
n && t && (r = "y"),
"string" == typeof e && "" !== e
? (i = new RegExp(e, r))
: e && (i = new RegExp(e.source, r)),
i
);
}),
(e.prototype.get_literal_regexp = function (t) {
return RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"));
}),
(e.prototype.peekUntilAfter = function (t) {
var e = this.__position,
n = this.readUntilAfter(t);
return ((this.__position = e), n);
}),
(e.prototype.lookBack = function (t) {
var e = this.__position - 1;
return (
e >= t.length &&
this.__input.substring(e - t.length, e).toLowerCase() === t
);
}),
(pt.InputScanner = e),
pt
);
})().InputScanner,
e = (nt ||
((nt = 1),
(lt.Token = function (t, e, n, i) {
((this.type = t),
(this.text = e),
(this.comments_before = null),
(this.newlines = n || 0),
(this.whitespace_before = i || ""),
(this.parent = null),
(this.next = null),
(this.previous = null),
(this.opened = null),
(this.closed = null),
(this.directives = null));
})),
lt).Token,
n = (function () {
if (it) return ut;
function t(t) {
((this.__tokens = []),
(this.__tokens_length = this.__tokens.length),
(this.__position = 0),
(this.__parent_token = t));
}
return (
(it = 1),
(t.prototype.restart = function () {
this.__position = 0;
}),
(t.prototype.isEmpty = function () {
return 0 === this.__tokens_length;
}),
(t.prototype.hasNext = function () {
return this.__position < this.__tokens_length;
}),
(t.prototype.next = function () {
var t = null;
return (
this.hasNext() &&
((t = this.__tokens[this.__position]), (this.__position += 1)),
t
);
}),
(t.prototype.peek = function (t) {
var e = null;
return (
(t = t || 0),
(t += this.__position) >= 0 &&
t < this.__tokens_length &&
(e = this.__tokens[t]),
e
);
}),
(t.prototype.add = function (t) {
(this.__parent_token && (t.parent = this.__parent_token),
this.__tokens.push(t),
(this.__tokens_length += 1));
}),
(ut.TokenStream = t),
ut
);
})().TokenStream,
i = (function () {
if (st) return ht;
st = 1;
var t = gt().Pattern;
function e(e, n) {
(t.call(this, e, n),
n
? (this._line_regexp = this._input.get_regexp(n._line_regexp))
: this.__set_whitespace_patterns("", ""),
(this.newline_count = 0),
(this.whitespace_before_token = ""));
}
return (
(e.prototype = new t()),
(e.prototype.__set_whitespace_patterns = function (t, e) {
((t += "\\t "),
(e += "\\n\\r"),
(this._match_pattern = this._input.get_regexp(
"[" + t + e + "]+",
!0,
)),
(this._newline_regexp = this._input.get_regexp(
"\\r\\n|[" + e + "]",
)));
}),
(e.prototype.read = function () {
((this.newline_count = 0), (this.whitespace_before_token = ""));
var t = this._input.read(this._match_pattern);
if (" " === t) this.whitespace_before_token = " ";
else if (t) {
var e = this.__split(this._newline_regexp, t);
((this.newline_count = e.length - 1),
(this.whitespace_before_token = e[this.newline_count]));
}
return t;
}),
(e.prototype.matching = function (t, e) {
var n = this._create();
return (n.__set_whitespace_patterns(t, e), n._update(), n);
}),
(e.prototype._create = function () {
return new e(this._input, this);
}),
(e.prototype.__split = function (t, e) {
t.lastIndex = 0;
for (var n = 0, i = [], r = t.exec(e); r; )
(i.push(e.substring(n, r.index)),
(n = r.index + r[0].length),
(r = t.exec(e)));
return (
n < e.length ? i.push(e.substring(n, e.length)) : i.push(""),
i
);
}),
(ht.WhitespacePattern = e),
ht
);
})().WhitespacePattern,
r = { START: "TK_START", RAW: "TK_RAW", EOF: "TK_EOF" },
s = function (e, n) {
((this._input = new t(e)),
(this._options = n || {}),
(this.__tokens = null),
(this._patterns = {}),
(this._patterns.whitespace = new i(this._input)));
};
return (
(s.prototype.tokenize = function () {
var t;
(this._input.restart(), (this.__tokens = new n()), this._reset());
for (
var i = new e(r.START, ""), s = null, o = [], _ = new n();
i.type !== r.EOF;
) {
for (t = this._get_next_token(i, s); this._is_comment(t); )
(_.add(t), (t = this._get_next_token(i, s)));
(_.isEmpty() || ((t.comments_before = _), (_ = new n())),
(t.parent = s),
this._is_opening(t)
? (o.push(s), (s = t))
: s &&
this._is_closing(t, s) &&
((t.opened = s), (s.closed = t), (s = o.pop()), (t.parent = s)),
(t.previous = i),
(i.next = t),
this.__tokens.add(t),
(i = t));
}
return this.__tokens;
}),
(s.prototype._is_first_token = function () {
return this.__tokens.isEmpty();
}),
(s.prototype._reset = function () {}),
(s.prototype._get_next_token = function (t, e) {
this._readWhitespace();
var n = this._input.read(/.+/g);
return n ? this._create_token(r.RAW, n) : this._create_token(r.EOF, "");
}),
(s.prototype._is_comment = function (t) {
return !1;
}),
(s.prototype._is_opening = function (t) {
return !1;
}),
(s.prototype._is_closing = function (t, e) {
return !1;
}),
(s.prototype._create_token = function (t, n) {
return new e(
t,
n,
this._patterns.whitespace.newline_count,
this._patterns.whitespace.whitespace_before_token,
);
}),
(s.prototype._readWhitespace = function () {
return this._patterns.whitespace.read();
}),
(ct.Tokenizer = s),
(ct.TOKEN = r),
ct
);
}
var ft,
yt,
wt,
vt,
bt,
xt = {},
kt = {};
function Tt() {
if (wt) return at;
wt = 1;
var t = mt().Tokenizer,
e = mt().TOKEN,
n = (function () {
if (ft) return xt;
function t(t, e) {
((t = "string" == typeof t ? t : t.source),
(e = "string" == typeof e ? e : e.source),
(this.__directives_block_pattern = new RegExp(
t + / beautify( \w+[:]\w+)+ /.source + e,
"g",
)),
(this.__directive_pattern = / (\w+)[:](\w+)/g),
(this.__directives_end_ignore_pattern = new RegExp(
t + /\sbeautify\signore:end\s/.source + e,
"g",
)));
}
return (
(ft = 1),
(t.prototype.get_directives = function (t) {
if (!t.match(this.__directives_block_pattern)) return null;
var e = {};
this.__directive_pattern.lastIndex = 0;
for (var n = this.__directive_pattern.exec(t); n; )
((e[n[1]] = n[2]), (n = this.__directive_pattern.exec(t)));
return e;
}),
(t.prototype.readIgnored = function (t) {
return t.readUntilAfter(this.__directives_end_ignore_pattern);
}),
(xt.Directives = t),
xt
);
})().Directives,
i = (function () {
if (yt) return kt;
yt = 1;
var t = gt().Pattern,
e = {
django: !1,
erb: !1,
handlebars: !1,
php: !1,
smarty: !1,
angular: !1,
};
function n(n, i) {
(t.call(this, n, i),
(this.__template_pattern = null),
(this._disabled = Object.assign({}, e)),
(this._excluded = Object.assign({}, e)),
i &&
((this.__template_pattern = this._input.get_regexp(
i.__template_pattern,
)),
(this._excluded = Object.assign(this._excluded, i._excluded)),
(this._disabled = Object.assign(this._disabled, i._disabled))));
var r = new t(n);
this.__patterns = {
handlebars_comment: r.starting_with(/{{!--/).until_after(/--}}/),
handlebars_unescaped: r.starting_with(/{{{/).until_after(/}}}/),
handlebars: r.starting_with(/{{/).until_after(/}}/),
php: r.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),
erb: r.starting_with(/<%[^%]/).until_after(/[^%]%>/),
django: r.starting_with(/{%/).until_after(/%}/),
django_value: r.starting_with(/{{/).until_after(/}}/),
django_comment: r.starting_with(/{#/).until_after(/#}/),
smarty: r.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),
smarty_comment: r.starting_with(/{\*/).until_after(/\*}/),
smarty_literal: r
.starting_with(/{literal}/)
.until_after(/{\/literal}/),
};
}
return (
(n.prototype = new t()),
(n.prototype._create = function () {
return new n(this._input, this);
}),
(n.prototype._update = function () {
this.__set_templated_pattern();
}),
(n.prototype.disable = function (t) {
var e = this._create();
return ((e._disabled[t] = !0), e._update(), e);
}),
(n.prototype.read_options = function (t) {
var n = this._create();
for (var i in e) n._disabled[i] = -1 === t.templating.indexOf(i);
return (n._update(), n);
}),
(n.prototype.exclude = function (t) {
var e = this._create();
return ((e._excluded[t] = !0), e._update(), e);
}),
(n.prototype.read = function () {
var t = "";
t = this._match_pattern
? this._input.read(this._starting_pattern)
: this._input.read(
this._starting_pattern,
this.__template_pattern,
);
for (var e = this._read_template(); e; )
(this._match_pattern
? (e += this._input.read(this._match_pattern))
: (e += this._input.readUntil(this.__template_pattern)),
(t += e),
(e = this._read_template()));
return (
this._until_after &&
(t += this._input.readUntilAfter(this._until_pattern)),
t
);
}),
(n.prototype.__set_templated_pattern = function () {
var t = [];
(this._disabled.php ||
t.push(this.__patterns.php._starting_pattern.source),
this._disabled.handlebars ||
t.push(this.__patterns.handlebars._starting_pattern.source),
this._disabled.erb ||
t.push(this.__patterns.erb._starting_pattern.source),
this._disabled.django ||
(t.push(this.__patterns.django._starting_pattern.source),
t.push(this.__patterns.django_value._starting_pattern.source),
t.push(
this.__patterns.django_comment._starting_pattern.source,
)),
this._disabled.smarty ||
t.push(this.__patterns.smarty._starting_pattern.source),
this._until_pattern && t.push(this._until_pattern.source),
(this.__template_pattern = this._input.get_regexp(
"(?:" + t.join("|") + ")",
)));
}),
(n.prototype._read_template = function () {
var t = "",
e = this._input.peek();
if ("<" === e) {
var n = this._input.peek(1);
(this._disabled.php ||
this._excluded.php ||
"?" !== n ||
(t = t || this.__patterns.php.read()),
this._disabled.erb ||
this._excluded.erb ||
"%" !== n ||
(t = t || this.__patterns.erb.read()));
} else
"{" === e &&
(this._disabled.handlebars ||
this._excluded.handlebars ||
(t =
(t =
(t = t || this.__patterns.handlebars_comment.read()) ||
this.__patterns.handlebars_unescaped.read()) ||
this.__patterns.handlebars.read()),
this._disabled.django ||
(this._excluded.django ||
this._excluded.handlebars ||
(t = t || this.__patterns.django_value.read()),
this._excluded.django ||
(t =
(t = t || this.__patterns.django_comment.read()) ||
this.__patterns.django.read())),
this._disabled.smarty ||
(this._disabled.django &&
this._disabled.handlebars &&
(t =
(t =
(t = t || this.__patterns.smarty_comment.read()) ||
this.__patterns.smarty_literal.read()) ||
this.__patterns.smarty.read())));
return t;
}),
(kt.TemplatablePattern = n),
kt
);
})().TemplatablePattern,
r = gt().Pattern,
s = {
TAG_OPEN: "TK_TAG_OPEN",
TAG_CLOSE: "TK_TAG_CLOSE",
CONTROL_FLOW_OPEN: "TK_CONTROL_FLOW_OPEN",
CONTROL_FLOW_CLOSE: "TK_CONTROL_FLOW_CLOSE",
ATTRIBUTE: "TK_ATTRIBUTE",
EQUALS: "TK_EQUALS",
VALUE: "TK_VALUE",
COMMENT: "TK_COMMENT",
TEXT: "TK_TEXT",
UNKNOWN: "TK_UNKNOWN",
START: e.START,
RAW: e.RAW,
EOF: e.EOF,
},
o = new n(/<\!--/, /-->/),
_ = function (e, n) {
(t.call(this, e, n), (this._current_tag_name = ""));
var s = new i(this._input).read_options(this._options),
o = new r(this._input);
if (
((this.__patterns = {
word: s.until(/[\n\r\t <]/),
word_control_flow_close_excluded: s.until(/[\n\r\t <}]/),
single_quote: s.until_after(/'/),
double_quote: s.until_after(/"/),
attribute: s.until(/[\n\r\t =>]|\/>/),
element_name: s.until(/[\n\r\t >\/]/),
angular_control_flow_start: o.matching(/\@[a-zA-Z]+[^({]*[({]/),
handlebars_comment: o.starting_with(/{{!--/).until_after(/--}}/),
handlebars: o.starting_with(/{{/).until_after(/}}/),
handlebars_open: o.until(/[\n\r\t }]/),
handlebars_raw_close: o.until(/}}/),
comment: o.starting_with(/<!--/).until_after(/-->/),
cdata: o.starting_with(/<!\[CDATA\[/).until_after(/]]>/),
conditional_comment: o.starting_with(/<!\[/).until_after(/]>/),
processing: o.starting_with(/<\?/).until_after(/\?>/),
}),
this._options.indent_handlebars &&
((this.__patterns.word =
this.__patterns.word.exclude("handlebars")),
(this.__patterns.word_control_flow_close_excluded =
this.__patterns.word_control_flow_close_excluded.exclude(
"handlebars",
))),
(this._unformatted_content_delimiter = null),
this._options.unformatted_content_delimiter)
) {
var _ = this._input.get_literal_regexp(
this._options.unformatted_content_delimiter,
);
this.__patterns.unformatted_content_delimiter = o
.matching(_)
.until_after(_);
}
};
return (
((_.prototype = new t())._is_comment = function (t) {
return !1;
}),
(_.prototype._is_opening = function (t) {
return t.type === s.TAG_OPEN || t.type === s.CONTROL_FLOW_OPEN;
}),
(_.prototype._is_closing = function (t, e) {
return (
(t.type === s.TAG_CLOSE &&
e &&
(((">" === t.text || "/>" === t.text) && "<" === e.text[0]) ||
("}}" === t.text && "{" === e.text[0] && "{" === e.text[1]))) ||
(t.type === s.CONTROL_FLOW_CLOSE &&
"}" === t.text &&
e.text.endsWith("{"))
);
}),
(_.prototype._reset = function () {
this._current_tag_name = "";
}),
(_.prototype._get_next_token = function (t, e) {
var n = null;
this._readWhitespace();
var i = this._input.peek();
return null === i
? this._create_token(s.EOF, "")
: (n =
(n =
(n =
(n =
(n =
(n =
(n =
(n =
(n =
(n = n || this._read_open_handlebars(i, e)) ||
this._read_attribute(i, t, e)) ||
this._read_close(i, e)) ||
this._read_control_flows(i, e)) ||
this._read_raw_content(i, t, e)) ||
this._read_content_word(i, e)) ||
this._read_comment_or_cdata(i)) ||
this._read_processing(i)) || this._read_open(i, e)) ||
this._create_token(s.UNKNOWN, this._input.next()));
}),
(_.prototype._read_comment_or_cdata = function (t) {
var e = null,
n = null,
i = null;
return (
"<" === t &&
("!" === this._input.peek(1) &&
((n = this.__patterns.comment.read())
? (i = o.get_directives(n)) &&
"start" === i.ignore &&
(n += o.readIgnored(this._input))
: (n = this.__patterns.cdata.read())),
n && ((e = this._create_token(s.COMMENT, n)).directives = i)),
e
);
}),
(_.prototype._read_processing = function (t) {
var e = null,
n = null;
if ("<" === t) {
var i = this._input.peek(1);
(("!" !== i && "?" !== i) ||
(n =
(n = this.__patterns.conditional_comment.read()) ||
this.__patterns.processing.read()),
n && ((e = this._create_token(s.COMMENT, n)).directives = null));
}
return e;
}),
(_.prototype._read_open = function (t, e) {
var n = null,
i = null;
return (
(e && e.type !== s.CONTROL_FLOW_OPEN) ||
("<" === t &&
((n = this._input.next()),
"/" === this._input.peek() && (n += this._input.next()),
(n += this.__patterns.element_name.read()),
(i = this._create_token(s.TAG_OPEN, n)))),
i
);
}),
(_.prototype._read_open_handlebars = function (t, e) {
var n = null,
i = null;
return (
(e && e.type !== s.CONTROL_FLOW_OPEN) ||
(this._options.indent_handlebars &&
"{" === t &&
"{" === this._input.peek(1) &&
("!" === this._input.peek(2)
? ((n =
(n = this.__patterns.handlebars_comment.read()) ||
this.__patterns.handlebars.read()),
(i = this._create_token(s.COMMENT, n)))
: ((n = this.__patterns.handlebars_open.read()),
(i = this._create_token(s.TAG_OPEN, n))))),
i
);
}),
(_.prototype._read_control_flows = function (t, e) {
var n = "",
i = null;
if (
!this._options.templating.includes("angular") ||
!this._options.indent_handlebars
)
return i;
if ("@" === t) {
if ("" === (n = this.__patterns.angular_control_flow_start.read()))
return i;
for (
var r = n.endsWith("(") ? 1 : 0, o = 0;
!n.endsWith("{") || r !== o;
) {
var _ = this._input.next();
if (null === _) break;
("(" === _ ? r++ : ")" === _ && o++, (n += _));
}
i = this._create_token(s.CONTROL_FLOW_OPEN, n);
} else
"}" === t &&
e &&
e.type === s.CONTROL_FLOW_OPEN &&
((n = this._input.next()),
(i = this._create_token(s.CONTROL_FLOW_CLOSE, n)));
return i;
}),
(_.prototype._read_close = function (t, e) {
var n = null,
i = null;
return (
e &&
e.type === s.TAG_OPEN &&
("<" === e.text[0] &&
(">" === t || ("/" === t && ">" === this._input.peek(1)))
? ((n = this._input.next()),
"/" === t && (n += this._input.next()),
(i = this._create_token(s.TAG_CLOSE, n)))
: "{" === e.text[0] &&
"}" === t &&
"}" === this._input.peek(1) &&
(this._input.next(),
this._input.next(),
(i = this._create_token(s.TAG_CLOSE, "}}")))),
i
);
}),
(_.prototype._read_attribute = function (t, e, n) {
var i = null,
r = "";
if (n && "<" === n.text[0])
if ("=" === t) i = this._create_token(s.EQUALS, this._input.next());
else if ('"' === t || "'" === t) {
var o = this._input.next();
((o +=
'"' === t
? this.__patterns.double_quote.read()
: this.__patterns.single_quote.read()),
(i = this._create_token(s.VALUE, o)));
} else
(r = this.__patterns.attribute.read()) &&
(i =
e.type === s.EQUALS
? this._create_token(s.VALUE, r)
: this._create_token(s.ATTRIBUTE, r));
return i;
}),
(_.prototype._is_content_unformatted = function (t) {
return (
-1 === this._options.void_elements.indexOf(t) &&
(-1 !== this._options.content_unformatted.indexOf(t) ||
-1 !== this._options.unformatted.indexOf(t))
);
}),
(_.prototype._read_raw_content = function (t, e, n) {
var i = "";
if (n && "{" === n.text[0])
i = this.__patterns.handlebars_raw_close.read();
else if (
e.type === s.TAG_CLOSE &&
"<" === e.opened.text[0] &&
"/" !== e.text[0]
) {
var r = e.opened.text.substr(1).toLowerCase();
if ("script" === r || "style" === r) {
var o = this._read_comment_or_cdata(t);
if (o) return ((o.type = s.TEXT), o);
i = this._input.readUntil(
new RegExp("</" + r + "[\\n\\r\\t ]*?>", "ig"),
);
} else
this._is_content_unformatted(r) &&
(i = this._input.readUntil(
new RegExp("</" + r + "[\\n\\r\\t ]*?>", "ig"),
));
}
return i ? this._create_token(s.TEXT, i) : null;
}),
(_.prototype._read_content_word = function (t, e) {
var n = "";
if (
(this._options.unformatted_content_delimiter &&
t === this._options.unformatted_content_delimiter[0] &&
(n = this.__patterns.unformatted_content_delimiter.read()),
n ||
(n =
e && e.type === s.CONTROL_FLOW_OPEN
? this.__patterns.word_control_flow_close_excluded.read()
: this.__patterns.word.read()),
n)
)
return this._create_token(s.TEXT, n);
}),
(at.Tokenizer = _),
(at.TOKEN = s),
at
);
}
function Ot() {
if (vt) return X;
vt = 1;
var t = J().Options,
e = (function () {
if (tt) return _t;
function t(t) {
((this.__parent = t),
(this.__character_count = 0),
(this.__indent_count = -1),
(this.__alignment_count = 0),
(this.__wrap_point_index = 0),
(this.__wrap_point_character_count = 0),
(this.__wrap_point_indent_count = -1),
(this.__wrap_point_alignment_count = 0),
(this.__items = []));
}
function e(t, e) {
((this.__cache = [""]),
(this.__indent_size = t.indent_size),
(this.__indent_string = t.indent_char),
t.indent_with_tabs ||
(this.__indent_string = new Array(t.indent_size + 1).join(
t.indent_char,
)),
(e = e || ""),
t.indent_level > 0 &&
(e = new Array(t.indent_level + 1).join(this.__indent_string)),
(this.__base_string = e),
(this.__base_string_length = e.length));
}
function n(n, i) {
((this.__indent_cache = new e(n, i)),
(this.raw = !1),
(this._end_with_newline = n.end_with_newline),
(this.indent_size = n.indent_size),
(this.wrap_line_length = n.wrap_line_length),
(this.indent_empty_lines = n.indent_empty_lines),
(this.__lines = []),
(this.previous_line = null),
(this.current_line = null),
(this.next_line = new t(this)),
(this.space_before_token = !1),
(this.non_breaking_space = !1),
(this.previous_token_wrapped = !1),
this.__add_outputline());
}
return (
(tt = 1),
(t.prototype.clone_empty = function () {
var e = new t(this.__parent);
return (
e.set_indent(this.__indent_count, this.__alignment_count),
e
);
}),
(t.prototype.item = function (t) {
return t < 0
? this.__items[this.__items.length + t]
: this.__items[t];
}),
(t.prototype.has_match = function (t) {
for (var e = this.__items.length - 1; e >= 0; e--)
if (this.__items[e].match(t)) return !0;
return !1;
}),
(t.prototype.set_indent = function (t, e) {
this.is_empty() &&
((this.__indent_count = t || 0),
(this.__alignment_count = e || 0),
(this.__character_count = this.__parent.get_indent_size(
this.__indent_count,
this.__alignment_count,
)));
}),
(t.prototype._set_wrap_point = function () {
this.__parent.wrap_line_length &&
((this.__wrap_point_index = this.__items.length),
(this.__wrap_point_character_count = this.__character_count),
(this.__wrap_point_indent_count =
this.__parent.next_line.__indent_count),
(this.__wrap_point_alignment_count =
this.__parent.next_line.__alignment_count));
}),
(t.prototype._should_wrap = function () {
return (
this.__wrap_point_index &&
this.__character_count > this.__parent.wrap_line_length &&
this.__wrap_point_character_count >
this.__parent.next_line.__character_count
);
}),
(t.prototype._allow_wrap = function () {
if (this._should_wrap()) {
this.__parent.add_new_line();
var t = this.__parent.current_line;
return (
t.set_indent(
this.__wrap_point_indent_count,
this.__wrap_point_alignment_count,
),
(t.__items = this.__items.slice(this.__wrap_point_index)),
(this.__items = this.__items.slice(0, this.__wrap_point_index)),
(t.__character_count +=
this.__character_count - this.__wrap_point_character_count),
(this.__character_count = this.__wrap_point_character_count),
" " === t.__items[0] &&
(t.__items.splice(0, 1), (t.__character_count -= 1)),
!0
);
}
return !1;
}),
(t.prototype.is_empty = function () {
return 0 === this.__items.length;
}),
(t.prototype.last = function () {
return this.is_empty()
? null
: this.__items[this.__items.length - 1];
}),
(t.prototype.push = function (t) {
this.__items.push(t);
var e = t.lastIndexOf("\n");
-1 !== e
? (this.__character_count = t.length - e)
: (this.__character_count += t.length);
}),
(t.prototype.pop = function () {
var t = null;
return (
this.is_empty() ||
((t = this.__items.pop()),
(this.__character_count -= t.length)),
t
);
}),
(t.prototype._remove_indent = function () {
this.__indent_count > 0 &&
((this.__indent_count -= 1),
(this.__character_count -= this.__parent.indent_size));
}),
(t.prototype._remove_wrap_indent = function () {
this.__wrap_point_indent_count > 0 &&
(this.__wrap_point_indent_count -= 1);
}),
(t.prototype.trim = function () {
for (; " " === this.last(); )
(this.__items.pop(), (this.__character_count -= 1));
}),
(t.prototype.toString = function () {
var t = "";
return (
this.is_empty()
? this.__parent.indent_empty_lines &&
(t = this.__parent.get_indent_string(this.__indent_count))
: ((t = this.__parent.get_indent_string(
this.__indent_count,
this.__alignment_count,
)),
(t += this.__items.join(""))),
t
);
}),
(e.prototype.get_indent_size = function (t, e) {
var n = this.__base_string_length;
return (
(e = e || 0),
t < 0 && (n = 0),
(n += t * this.__indent_size) + e
);
}),
(e.prototype.get_indent_string = function (t, e) {
var n = this.__base_string;
return (
(e = e || 0),
t < 0 && ((t = 0), (n = "")),
(e += t * this.__indent_size),
this.__ensure_cache(e),
n + this.__cache[e]
);
}),
(e.prototype.__ensure_cache = function (t) {
for (; t >= this.__cache.length; ) this.__add_column();
}),
(e.prototype.__add_column = function () {
var t = this.__cache.length,
e = 0,
n = "";
(this.__indent_size &&
t >= this.__indent_size &&
((t -=
(e = Math.floor(t / this.__indent_size)) * this.__indent_size),
(n = new Array(e + 1).join(this.__indent_string))),
t && (n += new Array(t + 1).join(" ")),
this.__cache.push(n));
}),
(n.prototype.__add_outputline = function () {
((this.previous_line = this.current_line),
(this.current_line = this.next_line.clone_empty()),
this.__lines.push(this.current_line));
}),
(n.prototype.get_line_number = function () {
return this.__lines.length;
}),
(n.prototype.get_indent_string = function (t, e) {
return this.__indent_cache.get_indent_string(t, e);
}),
(n.prototype.get_indent_size = function (t, e) {
return this.__indent_cache.get_indent_size(t, e);
}),
(n.prototype.is_empty = function () {
return !this.previous_line && this.current_line.is_empty();
}),
(n.prototype.add_new_line = function (t) {
return !(
this.is_empty() ||
(!t && this.just_added_newline()) ||
(this.raw || this.__add_outputline(), 0)
);
}),
(n.prototype.get_code = function (t) {
this.trim(!0);
var e = this.current_line.pop();
(e &&
("\n" === e[e.length - 1] && (e = e.replace(/\n+$/g, "")),
this.current_line.push(e)),
this._end_with_newline && this.__add_outputline());
var n = this.__lines.join("\n");
return ("\n" !== t && (n = n.replace(/[\n]/g, t)), n);
}),
(n.prototype.set_wrap_point = function () {
this.current_line._set_wrap_point();
}),
(n.prototype.set_indent = function (t, e) {
return (
(t = t || 0),
(e = e || 0),
this.next_line.set_indent(t, e),
this.__lines.length > 1
? (this.current_line.set_indent(t, e), !0)
: (this.current_line.set_indent(), !1)
);
}),
(n.prototype.add_raw_token = function (t) {
for (var e = 0; e < t.newlines; e++) this.__add_outputline();
(this.current_line.set_indent(-1),
this.current_line.push(t.whitespace_before),
this.current_line.push(t.text),
(this.space_before_token = !1),
(this.non_breaking_space = !1),
(this.previous_token_wrapped = !1));
}),
(n.prototype.add_token = function (t) {
(this.__add_space_before_token(),
this.current_line.push(t),
(this.space_before_token = !1),
(this.non_breaking_space = !1),
(this.previous_token_wrapped = this.current_line._allow_wrap()));
}),
(n.prototype.__add_space_before_token = function () {
this.space_before_token &&
!this.just_added_newline() &&
(this.non_breaking_space || this.set_wrap_point(),
this.current_line.push(" "));
}),
(n.prototype.remove_indent = function (t) {
for (var e = this.__lines.length; t < e; )
(this.__lines[t]._remove_indent(), t++);
this.current_line._remove_wrap_indent();
}),
(n.prototype.trim = function (t) {
for (
t = void 0 !== t && t, this.current_line.trim();
t && this.__lines.length > 1 && this.current_line.is_empty();
)
(this.__lines.pop(),
(this.current_line = this.__lines[this.__lines.length - 1]),
this.current_line.trim());
this.previous_line =
this.__lines.length > 1
? this.__lines[this.__lines.length - 2]
: null;
}),
(n.prototype.just_added_newline = function () {
return this.current_line.is_empty();
}),
(n.prototype.just_added_blankline = function () {
return (
this.is_empty() ||
(this.current_line.is_empty() && this.previous_line.is_empty())
);
}),
(n.prototype.ensure_empty_line_above = function (e, n) {
for (var i = this.__lines.length - 2; i >= 0; ) {
var r = this.__lines[i];
if (r.is_empty()) break;
if (0 !== r.item(0).indexOf(e) && r.item(-1) !== n) {
(this.__lines.splice(i + 1, 0, new t(this)),
(this.previous_line = this.__lines[this.__lines.length - 2]));
break;
}
i--;
}
}),
(_t.Output = n),
_t
);
})().Output,
n = Tt().Tokenizer,
i = Tt().TOKEN,
r = /\r\n|[\r\n]/,
s = /\r\n|[\r\n]/g,
o = function (t, n) {
((this.indent_level = 0),
(this.alignment_size = 0),
(this.max_preserve_newlines = t.max_preserve_newlines),
(this.preserve_newlines = t.preserve_newlines),
(this._output = new e(t, n)));
};
((o.prototype.current_line_has_match = function (t) {
return this._output.current_line.has_match(t);
}),
(o.prototype.set_space_before_token = function (t, e) {
((this._output.space_before_token = t),
(this._output.non_breaking_space = e));
}),
(o.prototype.set_wrap_point = function () {
(this._output.set_indent(this.indent_level, this.alignment_size),
this._output.set_wrap_point());
}),
(o.prototype.add_raw_token = function (t) {
this._output.add_raw_token(t);
}),
(o.prototype.print_preserved_newlines = function (t) {
var e = 0;
(t.type !== i.TEXT &&
t.previous.type !== i.TEXT &&
(e = t.newlines ? 1 : 0),
this.preserve_newlines &&
(e =
t.newlines < this.max_preserve_newlines + 1
? t.newlines
: this.max_preserve_newlines + 1));
for (var n = 0; n < e; n++) this.print_newline(n > 0);
return 0 !== e;
}),
(o.prototype.traverse_whitespace = function (t) {
return !(
(!t.whitespace_before && !t.newlines) ||
(this.print_preserved_newlines(t) ||
(this._output.space_before_token = !0),
0)
);
}),
(o.prototype.previous_token_wrapped = function () {
return this._output.previous_token_wrapped;
}),
(o.prototype.print_newline = function (t) {
this._output.add_new_line(t);
}),
(o.prototype.print_token = function (t) {
t.text &&
(this._output.set_indent(this.indent_level, this.alignment_size),
this._output.add_token(t.text));
}),
(o.prototype.indent = function () {
this.indent_level++;
}),
(o.prototype.deindent = function () {
this.indent_level > 0 &&
(this.indent_level--,
this._output.set_indent(this.indent_level, this.alignment_size));
}),
(o.prototype.get_full_indent = function (t) {
return (t = this.indent_level + (t || 0)) < 1
? ""
: this._output.get_indent_string(t);
}));
function _(t, e) {
return -1 !== e.indexOf(t);
}
function a(t, e, n) {
((this.parent = t || null),
(this.tag = e ? e.tag_name : ""),
(this.indent_level = n || 0),
(this.parser_token = e || null));
}
function c(t) {
((this._printer = t), (this._current_frame = null));
}
function p(e, n, i, r) {
((this._source_text = e || ""),
(n = n || {}),
(this._js_beautify = i),
(this._css_beautify = r),
(this._tag_stack = null));
var s = new t(n, "html");
((this._options = s),
(this._is_wrap_attributes_force =
"force" === this._options.wrap_attributes.substr(0, 5)),
(this._is_wrap_attributes_force_expand_multiline =
"force-expand-multiline" === this._options.wrap_attributes),
(this._is_wrap_attributes_force_aligned =
"force-aligned" === this._options.wrap_attributes),
(this._is_wrap_attributes_aligned_multiple =
"aligned-multiple" === this._options.wrap_attributes),
(this._is_wrap_attributes_preserve =
"preserve" === this._options.wrap_attributes.substr(0, 8)),
(this._is_wrap_attributes_preserve_aligned =
"preserve-aligned" === this._options.wrap_attributes));
}
((c.prototype.get_parser_token = function () {
return this._current_frame ? this._current_frame.parser_token : null;
}),
(c.prototype.record_tag = function (t) {
var e = new a(this._current_frame, t, this._printer.indent_level);
this._current_frame = e;
}),
(c.prototype._try_pop_frame = function (t) {
var e = null;
return (
t &&
((e = t.parser_token),
(this._printer.indent_level = t.indent_level),
(this._current_frame = t.parent)),
e
);
}),
(c.prototype._get_frame = function (t, e) {
for (var n = this._current_frame; n && -1 === t.indexOf(n.tag); ) {
if (e && -1 !== e.indexOf(n.tag)) {
n = null;
break;
}
n = n.parent;
}
return n;
}),
(c.prototype.try_pop = function (t, e) {
var n = this._get_frame([t], e);
return this._try_pop_frame(n);
}),
(c.prototype.indent_to_tag = function (t) {
var e = this._get_frame(t);
e && (this._printer.indent_level = e.indent_level);
}),
(p.prototype.beautify = function () {
if (this._options.disabled) return this._source_text;
var t = this._source_text,
e = this._options.eol;
"auto" === this._options.eol &&
((e = "\n"), t && r.test(t) && (e = t.match(r)[0]));
var _ = (t = t.replace(s, "\n")).match(/^[\t ]*/)[0],
a = { text: "", type: "" },
p = new l(),
u = new o(this._options, _),
h = new n(t, this._options).tokenize();
this._tag_stack = new c(u);
for (var d = null, g = h.next(); g.type !== i.EOF; )
(g.type === i.TAG_OPEN || g.type === i.COMMENT
? (p = d = this._handle_tag_open(u, g, p, a, h))
: g.type === i.ATTRIBUTE ||
g.type === i.EQUALS ||
g.type === i.VALUE ||
(g.type === i.TEXT && !p.tag_complete)
? (d = this._handle_inside_tag(u, g, p, a))
: g.type === i.TAG_CLOSE
? (d = this._handle_tag_close(u, g, p))
: g.type === i.TEXT
? (d = this._handle_text(u, g, p))
: g.type === i.CONTROL_FLOW_OPEN
? (d = this._handle_control_flow_open(u, g))
: g.type === i.CONTROL_FLOW_CLOSE
? (d = this._handle_control_flow_close(u, g))
: u.add_raw_token(g),
(a = d),
(g = h.next()));
return u._output.get_code(e);
}),
(p.prototype._handle_control_flow_open = function (t, e) {
var n = { text: e.text, type: e.type };
return (
t.set_space_before_token(
e.newlines || "" !== e.whitespace_before,
!0,
),
e.newlines
? t.print_preserved_newlines(e)
: t.set_space_before_token(
e.newlines || "" !== e.whitespace_before,
!0,
),
t.print_token(e),
t.indent(),
n
);
}),
(p.prototype._handle_control_flow_close = function (t, e) {
var n = { text: e.text, type: e.type };
return (
t.deindent(),
e.newlines
? t.print_preserved_newlines(e)
: t.set_space_before_token(
e.newlines || "" !== e.whitespace_before,
!0,
),
t.print_token(e),
n
);
}),
(p.prototype._handle_tag_close = function (t, e, n) {
var i = { text: e.text, type: e.type };
return (
(t.alignment_size = 0),
(n.tag_complete = !0),
t.set_space_before_token(
e.newlines || "" !== e.whitespace_before,
!0,
),
n.is_unformatted
? t.add_raw_token(e)
: ("<" === n.tag_start_char &&
(t.set_space_before_token("/" === e.text[0], !0),
this._is_wrap_attributes_force_expand_multiline &&
n.has_wrapped_attrs &&
t.print_newline(!1)),
t.print_token(e)),
!n.indent_content ||
n.is_unformatted ||
n.is_content_unformatted ||
(t.indent(), (n.indent_content = !1)),
n.is_inline_element ||
n.is_unformatted ||
n.is_content_unformatted ||
t.set_wrap_point(),
i
);
}),
(p.prototype._handle_inside_tag = function (t, e, n, r) {
var s = n.has_wrapped_attrs,
o = { text: e.text, type: e.type };
return (
t.set_space_before_token(
e.newlines || "" !== e.whitespace_before,
!0,
),
n.is_unformatted
? t.add_raw_token(e)
: "{" === n.tag_start_char && e.type === i.TEXT
? t.print_preserved_newlines(e)
? ((e.newlines = 0), t.add_raw_token(e))
: t.print_token(e)
: (e.type === i.ATTRIBUTE
? t.set_space_before_token(!0)
: (e.type === i.EQUALS ||
(e.type === i.VALUE && e.previous.type === i.EQUALS)) &&
t.set_space_before_token(!1),
e.type === i.ATTRIBUTE &&
"<" === n.tag_start_char &&
((this._is_wrap_attributes_preserve ||
this._is_wrap_attributes_preserve_aligned) &&
(t.traverse_whitespace(e), (s = s || 0 !== e.newlines)),
this._is_wrap_attributes_force &&
n.attr_count >= this._options.wrap_attributes_min_attrs &&
(r.type !== i.TAG_OPEN ||
this._is_wrap_attributes_force_expand_multiline) &&
(t.print_newline(!1), (s = !0))),
t.print_token(e),
(s = s || t.previous_token_wrapped()),
(n.has_wrapped_attrs = s)),
o
);
}),
(p.prototype._handle_text = function (t, e, n) {
var i = { text: e.text, type: "TK_CONTENT" };
return (
n.custom_beautifier_name
? this._print_custom_beatifier_text(t, e, n)
: n.is_unformatted || n.is_content_unformatted
? t.add_raw_token(e)
: (t.traverse_whitespace(e), t.print_token(e)),
i
);
}),
(p.prototype._print_custom_beatifier_text = function (t, e, n) {
var i = this;
if ("" !== e.text) {
var r,
s = e.text,
o = 1,
_ = "",
a = "";
("javascript" === n.custom_beautifier_name &&
"function" == typeof this._js_beautify
? (r = this._js_beautify)
: "css" === n.custom_beautifier_name &&
"function" == typeof this._css_beautify
? (r = this._css_beautify)
: "html" === n.custom_beautifier_name &&
(r = function (t, e) {
return new p(
t,
e,
i._js_beautify,
i._css_beautify,
).beautify();
}),
"keep" === this._options.indent_scripts
? (o = 0)
: "separate" === this._options.indent_scripts &&
(o = -t.indent_level));
var c = t.get_full_indent(o);
if (
((s = s.replace(/\n[ \t]*$/, "")),
"html" !== n.custom_beautifier_name &&
"<" === s[0] &&
s.match(/^(<!--|<!\[CDATA\[)/))
) {
var l =
/^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(
s,
);
if (!l) return void t.add_raw_token(e);
((_ = c + l[1] + "\n"),
(s = l[4]),
l[5] && (a = c + l[5]),
(s = s.replace(/\n[ \t]*$/, "")),
(l[2] || -1 !== l[3].indexOf("\n")) &&
(l = l[3].match(/[ \t]+$/)) &&
(e.whitespace_before = l[0]));
}
if (s)
if (r) {
var u = function () {
this.eol = "\n";
};
((u.prototype = this._options.raw_options),
(s = r(c + s, new u())));
} else {
var h = e.whitespace_before;
(h && (s = s.replace(new RegExp("\n(" + h + ")?", "g"), "\n")),
(s = c + s.replace(/\n/g, "\n" + c)));
}
(_ && (s = s ? _ + s + "\n" + a : _ + a),
t.print_newline(!1),
s &&
((e.text = s),
(e.whitespace_before = ""),
(e.newlines = 0),
t.add_raw_token(e),
t.print_newline(!0)));
}
}),
(p.prototype._handle_tag_open = function (t, e, n, r, s) {
var o = this._get_tag_open_token(e);
if (
((!n.is_unformatted && !n.is_content_unformatted) ||
n.is_empty_element ||
e.type !== i.TAG_OPEN ||
o.is_start_tag
? (t.traverse_whitespace(e),
this._set_tag_position(t, e, o, n, r),
o.is_inline_element || t.set_wrap_point(),
t.print_token(e))
: (t.add_raw_token(e),
(o.start_tag_token = this._tag_stack.try_pop(o.tag_name))),
o.is_start_tag && this._is_wrap_attributes_force)
) {
var _,
a = 0;
do {
((_ = s.peek(a)).type === i.ATTRIBUTE && (o.attr_count += 1),
(a += 1));
} while (_.type !== i.EOF && _.type !== i.TAG_CLOSE);
}
return (
(this._is_wrap_attributes_force_aligned ||
this._is_wrap_attributes_aligned_multiple ||
this._is_wrap_attributes_preserve_aligned) &&
(o.alignment_size = e.text.length + 1),
o.tag_complete ||
o.is_unformatted ||
(t.alignment_size = o.alignment_size),
o
);
}));
var l = function (t, e) {
if (
((this.parent = t || null),
(this.text = ""),
(this.type = "TK_TAG_OPEN"),
(this.tag_name = ""),
(this.is_inline_element = !1),
(this.is_unformatted = !1),
(this.is_content_unformatted = !1),
(this.is_empty_element = !1),
(this.is_start_tag = !1),
(this.is_end_tag = !1),
(this.indent_content = !1),
(this.multiline_content = !1),
(this.custom_beautifier_name = null),
(this.start_tag_token = null),
(this.attr_count = 0),
(this.has_wrapped_attrs = !1),
(this.alignment_size = 0),
(this.tag_complete = !1),
(this.tag_start_char = ""),
(this.tag_check = ""),
e)
) {
var n;
((this.tag_start_char = e.text[0]),
(this.text = e.text),
"<" === this.tag_start_char
? ((n = e.text.match(/^<([^\s>]*)/)),
(this.tag_check = n ? n[1] : ""))
: ((n = e.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/)),
(this.tag_check = n ? n[1] : ""),
(e.text.startsWith("{{#>") || e.text.startsWith("{{~#>")) &&
">" === this.tag_check[0] &&
(">" === this.tag_check && null !== e.next
? (this.tag_check = e.next.text.split(" ")[0])
: (this.tag_check = e.text.split(">")[1]))),
(this.tag_check = this.tag_check.toLowerCase()),
e.type === i.COMMENT && (this.tag_complete = !0),
(this.is_start_tag = "/" !== this.tag_check.charAt(0)),
(this.tag_name = this.is_start_tag
? this.tag_check
: this.tag_check.substr(1)),
(this.is_end_tag =
!this.is_start_tag || (e.closed && "/>" === e.closed.text)));
var r = 2;
("{" === this.tag_start_char &&
this.text.length >= 3 &&
"~" === this.text.charAt(2) &&
(r = 3),
(this.is_end_tag =
this.is_end_tag ||
("{" === this.tag_start_char &&
(this.text.length < 3 || /[^#\^]/.test(this.text.charAt(r))))));
} else this.tag_complete = !0;
};
((p.prototype._get_tag_open_token = function (t) {
var e = new l(this._tag_stack.get_parser_token(), t);
return (
(e.alignment_size = this._options.wrap_attributes_indent_size),
(e.is_end_tag =
e.is_end_tag || _(e.tag_check, this._options.void_elements)),
(e.is_empty_element =
e.tag_complete || (e.is_start_tag && e.is_end_tag)),
(e.is_unformatted =
!e.tag_complete && _(e.tag_check, this._options.unformatted)),
(e.is_content_unformatted =
!e.is_empty_element &&
_(e.tag_check, this._options.content_unformatted)),
(e.is_inline_element =
_(e.tag_name, this._options.inline) ||
(this._options.inline_custom_elements && e.tag_name.includes("-")) ||
"{" === e.tag_start_char),
e
);
}),
(p.prototype._set_tag_position = function (t, e, n, r, s) {
if (
(n.is_empty_element ||
(n.is_end_tag
? (n.start_tag_token = this._tag_stack.try_pop(n.tag_name))
: (this._do_optional_end_element(n) &&
(n.is_inline_element || t.print_newline(!1)),
this._tag_stack.record_tag(n),
("script" !== n.tag_name && "style" !== n.tag_name) ||
n.is_unformatted ||
n.is_content_unformatted ||
(n.custom_beautifier_name = (function (t, e) {
var n = null,
r = null;
return e.closed
? ("script" === t
? (n = "text/javascript")
: "style" === t && (n = "text/css"),
(n =
(function (t) {
for (
var e = null, n = t.next;
n.type !== i.EOF && t.closed !== n;
) {
if (n.type === i.ATTRIBUTE && "type" === n.text) {
n.next &&
n.next.type === i.EQUALS &&
n.next.next &&
n.next.next.type === i.VALUE &&
(e = n.next.next.text);
break;
}
n = n.next;
}
return e;
})(e) || n),
n.search("text/css") > -1
? (r = "css")
: n.search(
/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/,
) > -1
? (r = "javascript")
: n.search(/(text|application|dojo)\/(x-)?(html)/) >
-1
? (r = "html")
: n.search(/test\/null/) > -1 && (r = "null"),
r)
: null;
})(n.tag_check, e)))),
_(n.tag_check, this._options.extra_liners) &&
(t.print_newline(!1),
t._output.just_added_blankline() || t.print_newline(!0)),
n.is_empty_element)
)
("{" === n.tag_start_char &&
"else" === n.tag_check &&
(this._tag_stack.indent_to_tag(["if", "unless", "each"]),
(n.indent_content = !0),
t.current_line_has_match(/{{#if/) || t.print_newline(!1)),
("!--" === n.tag_name &&
s.type === i.TAG_CLOSE &&
r.is_end_tag &&
-1 === n.text.indexOf("\n")) ||
(n.is_inline_element || n.is_unformatted || t.print_newline(!1),
this._calcluate_parent_multiline(t, n)));
else if (n.is_end_tag) {
var o = !1;
((o =
(o = n.start_tag_token && n.start_tag_token.multiline_content) ||
(!n.is_inline_element &&
!(r.is_inline_element || r.is_unformatted) &&
!(s.type === i.TAG_CLOSE && n.start_tag_token === r) &&
"TK_CONTENT" !== s.type)),
(n.is_content_unformatted || n.is_unformatted) && (o = !1),
o && t.print_newline(!1));
} else
((n.indent_content = !n.custom_beautifier_name),
"<" === n.tag_start_char &&
("html" === n.tag_name
? (n.indent_content = this._options.indent_inner_html)
: "head" === n.tag_name
? (n.indent_content = this._options.indent_head_inner_html)
: "body" === n.tag_name &&
(n.indent_content = this._options.indent_body_inner_html)),
n.is_inline_element ||
n.is_unformatted ||
("TK_CONTENT" === s.type && !n.is_content_unformatted) ||
t.print_newline(!1),
this._calcluate_parent_multiline(t, n));
}),
(p.prototype._calcluate_parent_multiline = function (t, e) {
!e.parent ||
!t._output.just_added_newline() ||
((e.is_inline_element || e.is_unformatted) &&
e.parent.is_inline_element) ||
(e.parent.multiline_content = !0);
}));
var u = [
"address",
"article",
"aside",
"blockquote",
"details",
"div",
"dl",
"fieldset",
"figcaption",
"figure",
"footer",
"form",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"header",
"hr",
"main",
"menu",
"nav",
"ol",
"p",
"pre",
"section",
"table",
"ul",
],
h = ["a", "audio", "del", "ins", "map", "noscript", "video"];
return (
(p.prototype._do_optional_end_element = function (t) {
var e = null;
if (!t.is_empty_element && t.is_start_tag && t.parent) {
if ("body" === t.tag_name) e = e || this._tag_stack.try_pop("head");
else if ("li" === t.tag_name)
e = e || this._tag_stack.try_pop("li", ["ol", "ul", "menu"]);
else if ("dd" === t.tag_name || "dt" === t.tag_name)
e =
(e = e || this._tag_stack.try_pop("dt", ["dl"])) ||
this._tag_stack.try_pop("dd", ["dl"]);
else if ("p" === t.parent.tag_name && -1 !== u.indexOf(t.tag_name)) {
var n = t.parent.parent;
(n && -1 !== h.indexOf(n.tag_name)) ||
(e = e || this._tag_stack.try_pop("p"));
} else
"rp" === t.tag_name || "rt" === t.tag_name
? (e =
(e = e || this._tag_stack.try_pop("rt", ["ruby", "rtc"])) ||
this._tag_stack.try_pop("rp", ["ruby", "rtc"]))
: "optgroup" === t.tag_name
? (e = e || this._tag_stack.try_pop("optgroup", ["select"]))
: "option" === t.tag_name
? (e =
e ||
this._tag_stack.try_pop("option", [
"select",
"datalist",
"optgroup",
]))
: "colgroup" === t.tag_name
? (e = e || this._tag_stack.try_pop("caption", ["table"]))
: "thead" === t.tag_name
? (e =
(e =
e ||
this._tag_stack.try_pop("caption", ["table"])) ||
this._tag_stack.try_pop("colgroup", ["table"]))
: "tbody" === t.tag_name || "tfoot" === t.tag_name
? (e =
(e =
(e =
(e =
e ||
this._tag_stack.try_pop("caption", [
"table",
])) ||
this._tag_stack.try_pop("colgroup", [
"table",
])) ||
this._tag_stack.try_pop("thead", ["table"])) ||
this._tag_stack.try_pop("tbody", ["table"]))
: "tr" === t.tag_name
? (e =
(e =
(e =
e ||
this._tag_stack.try_pop("caption", [
"table",
])) ||
this._tag_stack.try_pop("colgroup", [
"table",
])) ||
this._tag_stack.try_pop("tr", [
"table",
"thead",
"tbody",
"tfoot",
]))
: ("th" !== t.tag_name && "td" !== t.tag_name) ||
(e =
(e =
e ||
this._tag_stack.try_pop("td", [
"table",
"thead",
"tbody",
"tfoot",
"tr",
])) ||
this._tag_stack.try_pop("th", [
"table",
"thead",
"tbody",
"tfoot",
"tr",
]));
return ((t.parent = this._tag_stack.get_parser_token()), e);
}
}),
(X.Beautifier = p),
X
);
}
var Ct = (function () {
if (bt) return Q.exports;
bt = 1;
var t = Ot().Beautifier,
e = J().Options;
return (
(Q.exports = function (e, n, i, r) {
return new t(e, n, i, r).beautify();
}),
(Q.exports.defaultOptions = function () {
return new e();
}),
Q.exports
);
})(),
Et = D(Ct);
const St = (t) => (e) => e.options.get(t),
At = St("codemirror_script"),
Lt = St("codemirror_linewrapping"),
Nt = St("codemirror_linenumbers"),
Rt = St("codemirror_foldgutter"),
zt = St("codemirror_gutter"),
Pt = St("advcode_headless"),
jt = St("advcode_inline"),
It = St("advcode_prettify_editor"),
Ut = St("advcode_prettify_getcontent"),
$t = (t, e, n) => ({
customEditorScriptUrl: e + "/customeditor.min.js",
codeMirrorScriptUrl: At(t),
lineWrapping: Lt(t),
lineNumbers: Nt(t),
foldGutter: Rt(t),
gutter: zt(t),
editorId: t.id,
advcodeInstanceId: w("advcode_instance"),
currentAdvStatus: n,
}),
Ft = (t) => {
if (null == t) throw new Error("Node cannot be null or undefined");
return { dom: t };
},
Mt = (t, e) => {
const n = (e || document).createElement("div");
if (((n.innerHTML = t), !n.hasChildNodes() || n.childNodes.length > 1)) {
const e = "HTML does not have a single root node";
throw (console.error(e, t), new Error(e));
}
return Ft(n.childNodes[0]);
},
Wt = (t, e) => {
const n = (e || document).createElement(t);
return Ft(n);
},
Kt = Ft,
Bt = (t) => {
const e = t.dom;
null !== e.parentNode && e.parentNode.removeChild(e);
},
Vt = (t, e, n) => {
let i = t.dom;
const r = s(n) ? n : a;
for (; i.parentNode; ) {
i = i.parentNode;
const t = Kt(i);
if (e(t)) return c.some(t);
if (r(t)) break;
}
return c.none();
},
Gt = (t, i) =>
((t, i, r) => {
const s = ((t, e) => {
const n = ((t, e) => {
const n = t.dom.getAttribute(e);
return null === n ? void 0 : n;
})(t, e);
return void 0 === n || "" === n ? [] : n.split(" ");
})(t, i);
return (
((t, i, r) => {
((t, i, r) => {
if (!(e(r) || n(r) || o(r)))
throw (
console.error(
"Invalid call to Attribute.set. Key ",
i,
":: Value ",
r,
":: Element ",
t,
),
new Error("Attribute value was not simple")
);
t.setAttribute(i, r + "");
})(t.dom, i, r);
})(t, i, s.concat([r]).join(" ")),
!0
);
})(t, "class", i),
Dt = "\x3c!--mce_cursor--\x3e",
qt = (t, e) => {
const n = t.dom,
i = t.selection,
r = i.getBookmark(),
o = ((t) => m(t, "name"))(r)
? n.select(r.name)[r.index]
: n.select(`#${r.id}_start`)[0],
_ = c.from(o).map((e) => {
const n = Kt(t.getBody());
return ((t) => {
const e = Mt(Dt),
i = Kt(t),
r = ((t, e, n) =>
((t, e, n, i, r) =>
i(n) ? c.some(n) : s(r) && r(n) ? c.none() : e(n, i, r))(
0,
Vt,
t,
e,
n,
))(
i,
(t) =>
((t) => {
const e = t.dom;
return (
!(!e || !e.hasAttribute) &&
e.hasAttribute("data-mce-bogus")
);
})(t),
(t) => {
return ((e = n), t.dom === e.dom);
var e;
},
).getOr(i);
return (
((t, e) => {
const n = ((t) => c.from(t.dom.parentNode).map(Kt))(t);
n.each((n) => {
n.dom.insertBefore(e.dom, t.dom);
});
})(r, e),
e
);
})(e);
}),
a = e();
return (_.each(Bt), i.moveToBookmark(r), a);
},
Ht = (t) => {
const e = It(t),
n = ((t) => {
const e = t.indexOf(Dt);
return -1 === e ? 0 : e;
})(qt(t, () => t.getContent({ source_view: !0, prettify: e })));
return {
content: t.getContent({ source_view: !0, prettify: e }),
cursor: n,
};
},
Qt = (t, e) => {
(t.focus(),
t.undoManager.transact(() => {
t.setContent(e);
}),
t.selection.setCursorLocation(),
t.nodeChanged());
},
Xt = (t) => {
return ((e = tinymce), m(e, "get") ? c.from(e.get) : c.none()).bind((e) =>
c.from(e.call(tinymce, t)),
);
var e;
},
Yt = (t, e) =>
Xt(t)
.bind((t) => c.from(t.plugins.advcode))
.map((t) => (t[e] || (t[e] = v()), t[e])),
Zt = (t, e) => {
Xt(t)
.bind((t) => c.from(t.plugins.advcode))
.each((t) => {
t[e] && delete t[e];
});
},
Jt = (t) => ({
name: "codeview",
type: "customeditor",
tag: "div",
/*onFocus: (t) => {
((t) => {
const e = (t) => {
for (let n = 0; n < t.childNodes.length; n++) {
const i = Kt(t.childNodes[n]);
if (i.dom.shadowRoot) return c.some(i);
const r = e(t.childNodes[n]);
if (r.isSome()) return r;
}
return c.none();
};
return e(t.dom);
})(Kt(t)).each((t) => {
var e;
null === (e = t.dom.shadowRoot.querySelector(".cm-content")) ||
void 0 === e ||
e.focus();
});
},*/
scriptId: "tinymce.plugins.advcode.customeditor",
scriptUrl: t.customEditorScriptUrl,
settings: t,
}),
te = (t, e) => {
const n = { dark: !1, fullscreen: !1, fontSize: c.none() };
t.addCommand("mceCodeEditor", () => {
jt(t) && !t.inline
? "code" === t.mode.get()
? t.mode.set("design")
: t.mode.set("code")
: (() => {
const i = $t(t, e, n);
((t, e) => {
const n = Ht(t),
i = { ...e, cursor: n.cursor },
r = e.currentAdvStatus,
s = Yt(e.editorId, e.advcodeInstanceId);
var o;
t.windowManager.open(
((o = n.content),
{
title: "Source Code",
size: "large",
body: { type: "panel", items: [Jt(i)] },
buttons: (() => {
let t = [
{
type: "togglebutton",
name: "format_code",
icon: "format-code",
text: "Format code",
align: "start",
tooltip: "",
},
{
type: "togglebutton",
name: "dark_theme_toggle",
text: "Dark/light mode",
active: r.dark,
align: "start",
tooltip: "",
},
{
type: "custom",
name: "increase_font_size",
text: "Increase font size",
icon: "text-size-increase",
align: "start",
},
{
type: "custom",
name: "decrease_font_size",
text: "Decrease font size",
icon: "text-size-decrease",
align: "start",
},
{
type: "cancel",
name: "cancel",
text: "Cancel",
align: "end",
},
{
type: "submit",
name: "save",
text: "Save",
primary: !0,
align: "end",
},
];
return (
window.isSecureContext
? (t = [
{
type: "togglebutton",
name: "copy_code",
icon: "copy",
text: "Copy code",
align: "start",
},
].concat(t))
: console.warn(
"Copy code is not allowed since window.isSecureContext is false",
),
t
);
})(),
initialData: { codeview: o },
onSubmit: (n) => {
(Qt(t, n.getData().codeview),
Zt(e.editorId, e.advcodeInstanceId),
n.close());
},
onClose: () => {
Zt(e.editorId, e.advcodeInstanceId);
},
onAction: (t, e) => {
("copy_code" === e.name &&
s.each((e) =>
e.get().each((e) => {
(async () => {
const n = setTimeout(() => {
t.block("copying");
}, 150);
(await e.copyCode(),
clearTimeout(n),
t.unblock());
})();
}),
),
"format_code" === e.name &&
s.each((e) =>
e.get().each((e) => {
(e.formatCode(), t.focus("format_code"));
}),
),
"increase_font_size" === e.name &&
s.each((t) =>
t.get().each((t) => {
r.fontSize = t.changeFontSize("increase");
}),
),
"decrease_font_size" === e.name &&
s.each((t) =>
t.get().each((t) => {
r.fontSize = t.changeFontSize("decrease");
}),
),
"dark_theme_toggle" === e.name &&
s.each((t) =>
t.get().each((t) => {
(t.setDarkMode(!r.dark), (r.dark = !r.dark));
}),
));
},
}),
);
})(t, i);
})();
});
},
ee = (t) => t.plugins.fullscreen && t.plugins.fullscreen.isFullscreen(),
ne = (t, e, n) => {
const i = f({ dark: !1, fullscreen: !1, fontSize: c.none() }),
r = f(ee(t)),
s = v(),
o = f(c.none()),
_ = { dark: !1, fullscreen: !1, fontSize: c.none() },
a = () => o.get().bind((e) => Yt(t.id, e)),
p = () => {
(s.get().each(({ destroy: e }) => {
(e(),
i.get().fullscreen !== r.get() && t.execCommand("mceFullScreen"));
}),
s.clear());
};
t.ui.registry.addView("code", {
buttons:
1 === n
? [
{
type: "group",
buttons: [
...(t.hasPlugin("fullscreen")
? [
{
type: "togglebutton",
icon: "fullscreen",
tooltip: "Fullscreen",
onAction: (e) => {
t.execCommand("mceFullScreen", void 0, void 0, {
skip_focus: !0,
});
const n = !e.isActive();
(i.set({ ...i.get(), fullscreen: n }),
e.setActive(n));
},
context: "any",
},
]
: []),
{
type: "togglebutton",
icon: "copy",
text: "Copy code",
onAction: (t) =>
a().each((t) =>
t.get().each((t) => {
(async () => {
await t.copyCode();
})();
}),
),
context: "any",
},
{
type: "togglebutton",
icon: "format-code",
text: "Format code",
onAction: (t) =>
a().each((e) =>
e.get().each((e) => {
(e.formatCode(), t.focus());
}),
),
context: "any",
},
],
},
{
type: "group",
buttons: [
{
type: "togglebutton",
text: "Dark/light mode",
onAction: (t) => {
a().each((e) =>
e.get().each((e) => {
(i.set({ ...i.get(), dark: !t.isActive() }),
t.setActive(i.get().dark),
e.setDarkMode(i.get().dark));
}),
);
},
context: "any",
},
{
type: "togglebutton",
icon: "text-size-increase",
tooltip: "Increase font size",
onAction: (t) =>
a().each((t) =>
t.get().each((t) =>
i.set({
...i.get(),
fontSize: t.changeFontSize("increase"),
}),
),
),
context: "any",
},
{
type: "togglebutton",
icon: "text-size-decrease",
tooltip: "Decrease font size",
onAction: (t) =>
a().each((t) =>
t.get().each((t) =>
i.set({
...i.get(),
fontSize: t.changeFontSize("decrease"),
}),
),
),
context: "any",
},
],
},
{
type: "group",
buttons: [
{
type: "button",
text: "Cancel",
onAction: () => {
s.get().each(() => {
(p(), t.mode.set("design"));
});
},
context: "any",
},
{
type: "button",
text: "Save code",
buttonType: "primary",
onAction: () => {
s.get().each(({ syncWithEditor: e }) => {
(e(), p(), t.mode.set("design"));
});
},
context: "any",
},
],
},
]
: [],
onShow: (a) => {
const p = a.getContainer(),
u = $t(t, e, _);
(o.set(c.some(u.advcodeInstanceId)),
r.set(ee(t)),
t.setProgressState(!0),
i.get().fullscreen !== ee(t) && t.execCommand("mceFullScreen"),
(async (t) => {
var e;
return (
await ((e = t),
tinymce.Resource.load("tinymce.plugins.advcode.CodeMirror", e))
)();
})(At(t)).then((e) => {
(t.setProgressState(!1),
s.set(
((t, e, n, i, r, s) => {
const o = Ht(n),
_ = { ...r, cursor: o.cursor },
a = Wt("div");
var c;
((c = a),
l(
0 === e
? ["tox-inline-headless-codemirror", "mce-codemirror"]
: [
"tox-custom-editor",
"tox-inline-codemirror",
"mce-codemirror",
],
(t) => {
((t, e) => {
((t) => void 0 !== t.dom.classList)(t)
? t.dom.classList.add(e)
: Gt(t, e);
})(c, t);
},
),
((t, e) => {
t.dom.appendChild(e.dom);
})(Kt(t), a));
const {
getValue: p,
destroy: u,
copyCode: h,
formatCode: d,
changeFontSize: g,
setDarkMode: m,
setFontSize: f,
focus: y,
} = i(a.dom, _, o.content, s),
w = y;
(t.addEventListener("focus", w),
Yt(r.editorId, r.advcodeInstanceId).each((t) =>
t.set({
copyCode: h,
formatCode: d,
changeFontSize: g,
setDarkMode: m,
setFontSize: f,
}),
),
f(s.fontSize));
const v = () => Qt(n, p());
return (
0 === e && n.on("BeforeGetContent", v),
{
syncWithEditor: v,
destroy: () => {
(0 === e && (n.off("BeforeGetContent", v), v()),
Bt(a),
t.removeEventListener("focus", w),
u());
},
}
);
})(p, n, t, e, u, i.get()),
));
}));
},
onHide: p,
});
};
((t, e) => {
const { i18n: n = !0 } = e;
(n &&
tinymce.PluginManager.requireLangPack(
t,
"ar,bg-BG,ca,cs,da,de,el,es,eu,fa,fi,fr-FR,he-IL,hi,hr,hu-HU,id,it,ja,kk,ko-KR,ms,nb-NO,nl,pl,pt-BR,pt-PT,ro,ru,sk,sl-SI,sv-SE,th-TH,tr,uk,vi,zh-CN,zh-TW",
),
tinymce.PluginManager.add(t, G(t, e)));
})("advcode", {
setup: (t, e) => {
(((t, e) => {
(((t, e) => {
const n = t.options.register;
(n("codemirror_script", {
processor: "string",
default: e + "/codemirror.min.js",
}),
n("codemirror_linewrapping", { processor: "boolean", default: !0 }),
n("codemirror_linenumbers", { processor: "boolean", default: !0 }),
n("codemirror_foldgutter", { processor: "boolean", default: !0 }),
n("codemirror_gutter", { processor: "boolean", default: !0 }),
n("advcode_headless", { processor: "boolean", default: !1 }),
n("advcode_inline", { processor: "boolean", default: !1 }),
n("advcode_prettify_editor", { processor: "boolean", default: !0 }),
n("advcode_prettify_getcontent", {
processor: "boolean",
default: !1,
}));
})(t, e),
te(t, e),
((t) => {
const e = "sourcecode",
n = () => t.execCommand("mceCodeEditor");
(t.ui.registry.addButton("code", {
icon: e,
tooltip: "Source code",
onAction: n,
}),
t.ui.registry.addMenuItem("code", {
icon: e,
text: "Source code",
onAction: n,
}));
})(t),
((t, e) => {
ne(t, e, Pt(t) ? 0 : 1);
})(t, e),
((t) => {
t.mode.register("code", {
activate: () => {
"code" !== t.queryCommandValue("ToggleView") &&
t.execCommand("ToggleView", !1, "code");
},
deactivate: () => {
"code" === t.queryCommandValue("ToggleView") &&
t.execCommand("ToggleView", !1, "code");
},
editorReadOnly: !1,
});
})(t));
})(t, e),
t.on("getContent", (e) => {
if (!1 === e.prettify) return;
const n = !0 === e.prettify,
i = Ut(t);
var r;
(n || i) &&
(e.content =
((r = e.content),
Et(r, { indent_size: 2, preserve_newlines: !1 })));
}));
},
});
})();