UNPKG

@aegenet/au2-prism

Version:

DRAFT - Aurelia 2 - Prism View/Editor plugin

381 lines (378 loc) 25 kB
import { inject as V, customElement as q, bindable as E } from "aurelia"; import O from "prismjs"; import "prismjs/components/prism-cmake.js"; import "prismjs/components/prism-javascript.js"; import "prismjs/components/prism-json.js"; import "prismjs/plugins/line-numbers/prism-line-numbers.js"; const fe = "code[class*=language-],pre[class*=language-]{color:#ccc;background:none;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.comment,.token.block-comment,.token.prolog,.token.doctype,.token.cdata{color:#999}.token.punctuation{color:#ccc}.token.tag,.token.attr-name,.token.namespace,.token.deleted{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.number,.token.function{color:#f08d49}.token.property,.token.class-name,.token.constant,.token.symbol{color:#f8c555}.token.selector,.token.important,.token.atrule,.token.keyword,.token.builtin{color:#cc99cd}.token.string,.token.char,.token.attr-value,.token.regex,.token.variable{color:#7ec699}.token.operator,.token.entity,.token.url{color:#67cdcc}.token.important,.token.bold{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}pre[class*=language-].line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.my-editor{background-color:#2d2d2d;color:#ccc;height:auto!important;font-family:Fira code,Fira Mono,Consolas,Menlo,Courier,monospace;font-size:14px;line-height:1.5;padding:1em}.prism-editor-wrapper{height:100%;display:flex;align-items:flex-start;overflow:auto;tab-size:1.5em;-moz-tab-size:1.5em}@media all and (-ms-high-contrast: none),(-ms-high-contrast: active){.prism-editor-wrapper .prism-editor__textarea{color:transparent!important}.prism-editor-wrapper .prism-editor__textarea::selection{background-color:#accef7!important;color:transparent!important}}.prism-editor-wrapper .prism-editor__container{position:relative;text-align:left;box-sizing:border-box;padding:0;overflow:hidden;width:100%}.prism-editor-wrapper .prism-editor__line-numbers{height:100%;overflow:hidden;flex-shrink:0;padding-top:4px;margin-top:0;margin-right:10px}.prism-editor-wrapper .prism-editor__line-number{text-align:right;white-space:nowrap}.prism-editor-wrapper .prism-editor__textarea{position:absolute;top:0;left:0;height:100%;width:100%;resize:none;color:inherit;overflow:hidden;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;-webkit-text-fill-color:transparent}.prism-editor-wrapper .prism-editor__textarea:focus{outline:none!important}.prism-editor-wrapper .prism-editor__textarea,.prism-editor-wrapper .prism-editor__editor{margin:0;border:0;background:none;box-sizing:inherit;display:inherit;font-family:inherit;font-size:inherit;font-style:inherit;font-variant-ligatures:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;-moz-tab-size:inherit;tab-size:inherit;text-indent:inherit;text-rendering:inherit;text-transform:inherit;white-space:pre-wrap;word-wrap:keep-all;overflow-wrap:break-word;padding:0}.prism-editor-wrapper .prism-editor__textarea--empty{-webkit-text-fill-color:inherit!important}.prism-editor-wrapper .prism-editor__editor{position:relative;pointer-events:none}", ge = `<div class="prism-editor"> <div class="prism-editor-wrapper my-editor" language.bind="language"> <div if.bind="lineNumbers" aria-hidden="true" class="prism-editor__line-numbers" style.bind="{ minHeight: lineNumbersHeight, borderRight: '1px solid darkgrey' }"> <div style="padding-right: 1em;" > <div class="prism-editor__line-width-calc" style="height: 0px; visibility: hidden; pointer-events: none;"> 999 </div> <div repeat.for="nbr of lineIndexWraps" class="prism-editor__line-number token comment"> \${$first || lineIndexWraps[$index - 1].idx !== nbr.idx ? nbr.idx : '-'} </div> </div> </div> <div class="prism-editor__container" style.bind="lineNumbers === true ? { wordBreak: 'break-all' } : {}"> <textarea value.bind="code" style="padding-top:4px" ref="textAreaRef" spellcheck="false" autocapitalize="off" autocomplete="off" autocorrect="off" data-gramm="false" placeholder.bind="placeholder" readonly.bind="readonly" data-testid="textarea" class="prism-editor__textarea \${isEmpty ? 'prism-editor__textarea--empty' : ''}" > </textarea> <pre ref="preRef" data-testid="preview" class="prism-editor__editor" style="padding-top:4px; border-top-left-radius: 0px; border-bottom-left-radius: 0px;" innerhtml.bind="content" ></pre> </div> </div> </div> <span ref="measureRef" class="" style="visibility: hidden; position: absolute;white-space:pre"></span> `; var _e = Object.create, H = Object.defineProperty, be = Object.getOwnPropertyDescriptor, ye = (i, e) => (e = Symbol[i]) ? e : Symbol.for("Symbol." + i), L = (i) => { throw TypeError(i); }, J = (i, e, t) => e in i ? H(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, F = (i, e) => H(i, "name", { value: e, configurable: !0 }), ve = (i) => [, , , _e(null)], X = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Y = (i) => i !== void 0 && typeof i != "function" ? L("Function expected") : i, ke = (i, e, t, o, r) => ({ kind: X[i], name: e, metadata: o, addInitializer: (s) => t._ ? L("Already initialized") : r.push(Y(s || null)) }), we = (i, e) => J(e, ye("metadata"), i[3]), y = (i, e, t, o) => { for (var r = 0, s = i[e >> 1], c = s && s.length; r < c; r++) e & 1 ? s[r].call(t) : o = s[r].call(t, o); return o; }, x = (i, e, t, o, r, s) => { var c, l, p, a, _, n = e & 7, v = !!(e & 8), d = !!(e & 16), k = n > 3 ? i.length + 1 : n ? v ? 1 : 2 : 0, R = X[n + 5], A = n > 3 && (i[k - 1] = []), N = i[k] || (i[k] = []), g = n && (!d && !v && (r = r.prototype), n < 5 && (n > 3 || !d) && be(n < 4 ? r : { get [t]() { return U(this, s); }, set [t](u) { return Q(this, s, u); } }, t)); n ? d && n < 4 && F(s, (n > 2 ? "set " : n > 1 ? "get " : "") + t) : F(r, t); for (var K = o.length - 1; K >= 0; K--) a = ke(n, t, p = {}, i[3], N), n && (a.static = v, a.private = d, _ = a.access = { has: d ? (u) => Ee(r, u) : (u) => t in u }, n ^ 3 && (_.get = d ? (u) => (n ^ 1 ? U : xe)(u, r, n ^ 4 ? s : g.get) : (u) => u[t]), n > 2 && (_.set = d ? (u, S) => Q(u, r, S, n ^ 4 ? s : g.set) : (u, S) => u[t] = S)), l = (0, o[K])(n ? n < 4 ? d ? s : g[R] : n > 4 ? void 0 : { get: g.get, set: g.set } : r, a), p._ = 1, n ^ 4 || l === void 0 ? Y(l) && (n > 4 ? A.unshift(l) : n ? d ? s = l : g[R] = l : r = l) : typeof l != "object" || l === null ? L("Object expected") : (Y(c = l.get) && (g.get = c), Y(c = l.set) && (g.set = c), Y(c = l.init) && A.unshift(c)); return n || we(i, r), g && H(r, t, g), d ? n ^ 4 ? s : g : r; }, h = (i, e, t) => J(i, typeof e != "symbol" ? e + "" : e, t), W = (i, e, t) => e.has(i) || L("Cannot " + t), Ee = (i, e) => Object(e) !== e ? L('Cannot use the "in" operator on this value') : i.has(e), U = (i, e, t) => (W(i, e, "read from private field"), t ? t.call(i) : e.get(i)), Q = (i, e, t, o) => (W(i, e, "write to private field"), o ? o.call(i, t) : e.set(i, t), t), xe = (i, e, t) => (W(i, e, "access private method"), t), ee, te, ie, ne, se, re, oe, ae, le, m; const Ke = typeof window < "u" && navigator && /Win/i.test(navigator.platform), M = typeof window < "u" && navigator && /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform); le = [V(HTMLElement), q({ name: "prism-editor", template: ge })], ae = [E()], oe = [E()], re = [E()], se = [E()], ne = [E()], ie = [E()], te = [E()], ee = [E()]; let f = class b { constructor(e) { this._element = e, h(this, "preRef"), h(this, "textAreaRef"), h(this, "measureRef"), h(this, "_boundedKeydown"), h(this, "observer"), h(this, "lineNumbers", y(m, 8, this, !1)), y(m, 11, this), h(this, "lineIndexWraps", []), h(this, "readonly", y(m, 12, this, !1)), y(m, 15, this), h(this, "code", y(m, 16, this, "")), y(m, 19, this), h(this, "highlight", y(m, 20, this)), y(m, 23, this), h(this, "tabSize", y(m, 24, this, 2)), y(m, 27, this), h(this, "insertSpaces", y(m, 28, this, !0)), y(m, 31, this), h(this, "ignoreTabKey", y(m, 32, this, !1)), y(m, 35, this), h(this, "placeholder", y(m, 36, this, "")), y(m, 39, this), h(this, "capture", !0), h(this, "history", { stack: [], offset: -1 }), h(this, "lineNumbersHeight", "20px"); const t = document.createElement("style"); t.textContent = fe, this._element.appendChild(t); } lineNumbersChanged() { this.setLineNumbersHeight(), this.setLineNumbersWrap(); } contentChanged() { this.lineNumbers && (this.setLineNumbersHeight(), this.setLineNumbersWrap()); } get isEmpty() { var e; return ((e = this.code) == null ? void 0 : e.length) === 0; } generateContent() { const e = O.highlight(this.code, O.languages.javascript, "javascript") + "<br />"; return this.contentChanged(), e; } get lineNumbersCount() { return this.code.split(/\r\n|\n/).length; } // eslint-disable-next-line @typescript-eslint/no-unused-vars bound(e, t) { this.code == null && (this.code = ""); } // eslint-disable-next-line @typescript-eslint/no-unused-vars attached(e) { const t = getComputedStyle(this.preRef); this.measureRef.style.font = t.font, this.measureRef.style.padding = t.padding, this.measureRef.style.margin = t.margin, this.measureRef.style.border = t.border, this.measureRef.style.lineHeight = t.lineHeight, this.measureRef.style.textAlign = t.textAlign, this.measureRef.style.overflow = t.overflow, this.measureRef.style.letterSpacing = t.letterSpacing, this._boundedKeydown = this.handleKeyDown.bind(this), this.textAreaRef.addEventListener("keydown", this._boundedKeydown), this.codeChanged(this.code, this.code); let o = this.observer; o === void 0 && (o = this.observer = new ResizeObserver(() => { this.setLineNumbersHeight(), this.setLineNumbersWrap(); })), o.observe(this.textAreaRef, { box: "border-box" }); } // eslint-disable-next-line @typescript-eslint/no-unused-vars detaching(e, t) { this._boundedKeydown && this.textAreaRef.removeEventListener("keydown", this._boundedKeydown), this.observer.disconnect(), this.observer = void 0; } setLineNumbersHeight() { this.lineNumbersHeight = getComputedStyle(this.preRef).height; } setLineNumbersWrap() { const e = this.preRef, t = this.code.split(/\r\n|\n/), o = []; let r = 0, s = 0; this.measureRef.textContent = "M"; const c = this.measureRef.offsetWidth; t.forEach((l, p) => { r = c * (l.length || 1), s = Math.ceil(r / e.clientWidth); for (let a = 0; a < s; a++) o.push({ idx: p + 1, wrap: a }); }), this.measureRef.textContent = "", this.lineIndexWraps = o; } _getLines(e, t) { return e.substring(0, t).split(` `); } _applyEdits(e) { const t = this.textAreaRef, o = this.history.stack[this.history.offset]; o && t && (this.history.stack[this.history.offset] = { ...o, selectionStart: t.selectionStart, selectionEnd: t.selectionEnd }), this._recordChange(e), this._updateInput(e); } _recordChange(e, t = !1) { var c, l; const { stack: o, offset: r } = this.history; if (o.length && r > -1) { this.history.stack = o.slice(0, r + 1); const p = this.history.stack.length; if (p > b._HISTORY_LIMIT) { const a = p - b._HISTORY_LIMIT; this.history.stack = o.slice(a, p), this.history.offset = Math.max(this.history.offset - a, 0); } } const s = Date.now(); if (t) { const p = this.history.stack[this.history.offset]; if (p && s - p.timestamp < b._HISTORY_TIME_GAP) { const a = /[^a-z0-9]([a-z0-9]+)$/i, _ = (c = this._getLines(p.value, p.selectionStart).pop()) == null ? void 0 : c.match(a), n = (l = this._getLines(e.value, e.selectionStart).pop()) == null ? void 0 : l.match(a); if (_ && n && n[1].startsWith(_[1])) { this.history.stack[this.history.offset] = { ...e, timestamp: s }; return; } } } this.history.stack.push({ ...e, timestamp: s }), this.history.offset++; } _updateInput(e) { const t = this.textAreaRef; t && (this.code = e.value || "", t.value = e.value, t.selectionStart = e.selectionStart, t.selectionEnd = e.selectionEnd); } // eslint-disable-next-line @typescript-eslint/no-unused-vars codeChanged(e, t) { e == null && (this.code = ""); const { value: o, selectionStart: r, selectionEnd: s } = this.textAreaRef; this._recordChange( { value: o, selectionStart: r, selectionEnd: s }, !0 ), this.preRef.innerHTML = this.generateContent(); } // public handleChange(e: KeyboardEvent): void { // this.$emit('input', value); // // this.props.onValueChange(value); // } /** Undo */ undo() { const { stack: e, offset: t } = this.history, o = e[t - 1]; o && (this._updateInput(o), this.history.offset = Math.max(t - 1, 0)); } /** Redo */ redo() { const { stack: e, offset: t } = this.history, o = e[t + 1]; o && (this._updateInput(o), this.history.offset = Math.min(t + 1, e.length - 1)); } handleKeyDown(e) { const { tabSize: t, insertSpaces: o, ignoreTabKey: r } = this; if (e.defaultPrevented) return; e.key === b._KEY_ESCAPE && (e.target.blur(), this.$emit("blur", e)); const { value: s, selectionStart: c, selectionEnd: l } = e.target, p = (o ? " " : " ").repeat(t); if (e.key === b._KEY_TAB && !r && this.capture) if (e.preventDefault(), e.shiftKey) { const a = this._getLines(s, c), _ = a.length - 1, n = this._getLines(s, l).length - 1, v = s.split(` `).map((d, k) => k >= _ && k <= n && d.startsWith(p) ? d.substring(p.length) : d).join(` `); if (s !== v) { const d = a[_]; this._applyEdits({ value: v, // Move the start cursor if first line in selection was modified // It was modified only if it started with a tab selectionStart: d.startsWith(p) ? c - p.length : c, // Move the end cursor by total number of characters removed selectionEnd: l - (s.length - v.length) }); } } else if (c !== l) { const a = this._getLines(s, c), _ = a.length - 1, n = this._getLines(s, l).length - 1, v = a[_]; this._applyEdits({ value: s.split(` `).map((d, k) => k >= _ && k <= n ? p + d : d).join(` `), // Move the start cursor by number of characters added in first line of selection // Don't move it if it there was no text before cursor selectionStart: /\S/.test(v) ? c + p.length : c, // Move the end cursor by total number of characters added selectionEnd: l + p.length * (n - _ + 1) }); } else { const a = c + p.length; this._applyEdits({ // Insert tab character at caret value: s.substring(0, c) + p + s.substring(l), // Update caret position selectionStart: a, selectionEnd: a }); } else if (e.key === b._KEY_BACKSPACE) { const a = c !== l; if (s.substring(0, c).endsWith(p) && !a) { e.preventDefault(); const n = c - p.length; this._applyEdits({ // Remove tab character at caret value: s.substring(0, c - p.length) + s.substring(l), // Update caret position selectionStart: n, selectionEnd: n }); } } else if (e.key === b._KEY_ENTER) { if (c === l) { const a = this._getLines(s, c).pop(), _ = a == null ? void 0 : a.match(/^\s+/); if (_ && _[0]) { e.preventDefault(); const n = ` ` + _[0], v = c + n.length; this._applyEdits({ // Insert indentation character at caret value: s.substring(0, c) + n + s.substring(l), // Update caret position selectionStart: v, selectionEnd: v }); } } } else if (e.key === b._KEY_PARENS || e.key === b._KEY_BRACKETS || e.key === b._KEY_QUOTE || e.key === b._KEY_BACK_QUOTE) { let a; e.key === b._KEY_PARENS && e.shiftKey ? a = ["(", ")"] : e.key === b._KEY_BRACKETS ? e.shiftKey ? a = ["{", "}"] : a = ["[", "]"] : e.key === b._KEY_QUOTE ? e.shiftKey ? a = ['"', '"'] : a = ["'", "'"] : e.key === b._KEY_BACK_QUOTE && !e.shiftKey && (a = ["`", "`"]), c !== l && a && (e.preventDefault(), this._applyEdits({ value: s.substring(0, c) + a[0] + s.substring(c, l) + a[1] + s.substring(l), // Update caret position selectionStart: c, selectionEnd: l + 2 })); } else (M ? ( // Trigger undo with ⌘+Z on Mac e.metaKey && e.key === b._KEY_Z ) : ( // Trigger undo with Ctrl+Z on other platforms e.ctrlKey && e.key === b._KEY_Z )) && !e.shiftKey && !e.altKey ? (e.preventDefault(), this.undo()) : (M ? ( // Trigger redo with ⌘+Shift+Z on Mac e.metaKey && e.key === b._KEY_Z && e.shiftKey ) : Ke ? ( // Trigger redo with Ctrl+Y on Windows e.ctrlKey && e.key === b._KEY_Y ) : ( // Trigger redo with Ctrl+Shift+Z on other platforms e.ctrlKey && e.key === b._KEY_Z && e.shiftKey )) && !e.altKey ? (e.preventDefault(), this.redo()) : e.key === b._KEY_M && e.ctrlKey && (!M || e.shiftKey) && (e.preventDefault(), this.capture = !this.capture); } $emit(e, t) { console.log(e, t); } }; m = ve(); x(m, 5, "lineNumbers", ae, f); x(m, 5, "readonly", oe, f); x(m, 5, "code", re, f); x(m, 5, "highlight", se, f); x(m, 5, "tabSize", ne, f); x(m, 5, "insertSpaces", ie, f); x(m, 5, "ignoreTabKey", te, f); x(m, 5, "placeholder", ee, f); f = x(m, 0, "PrismEditor", le, f); h(f, "_KEY_ENTER", "Enter"); h(f, "_KEY_TAB", "Tab"); h(f, "_KEY_BACKSPACE", "Backspace"); h(f, "_KEY_Y", "y"); h(f, "_KEY_Z", "z"); h(f, "_KEY_M", "m"); h(f, "_KEY_PARENS", "("); h(f, "_KEY_BRACKETS", "{"); h(f, "_KEY_QUOTE", '"'); h(f, "_KEY_BACK_QUOTE", "'"); h(f, "_KEY_ESCAPE", "Escape"); h(f, "_HISTORY_LIMIT", 100); h(f, "_HISTORY_TIME_GAP", 3e3); y(m, 1, f); let Be = f; const Se = "code[class*=language-],pre[class*=language-]{color:#ccc;background:none;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.comment,.token.block-comment,.token.prolog,.token.doctype,.token.cdata{color:#999}.token.punctuation{color:#ccc}.token.tag,.token.attr-name,.token.namespace,.token.deleted{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.number,.token.function{color:#f08d49}.token.property,.token.class-name,.token.constant,.token.symbol{color:#f8c555}.token.selector,.token.important,.token.atrule,.token.keyword,.token.builtin{color:#cc99cd}.token.string,.token.char,.token.attr-value,.token.regex,.token.variable{color:#7ec699}.token.operator,.token.entity,.token.url{color:#67cdcc}.token.important,.token.bold{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}pre[class*=language-].line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}", Ce = `<div> <pre class="\${lineNumbers ? 'line-numbers' : ''}" data-start="1"><code ref="codeArea" class="language-\${language}"></code></pre> </div> `; var ze = Object.create, B = Object.defineProperty, Re = Object.getOwnPropertyDescriptor, Ae = (i, e) => (e = Symbol[i]) ? e : Symbol.for("Symbol." + i), $ = (i) => { throw TypeError(i); }, ce = (i, e, t) => e in i ? B(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, Z = (i, e) => B(i, "name", { value: e, configurable: !0 }), Ye = (i) => [, , , ze(null)], de = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], T = (i) => i !== void 0 && typeof i != "function" ? $("Function expected") : i, Te = (i, e, t, o, r) => ({ kind: de[i], name: e, metadata: o, addInitializer: (s) => t._ ? $("Already initialized") : r.push(T(s || null)) }), Le = (i, e) => ce(e, Ae("metadata"), i[3]), C = (i, e, t, o) => { for (var r = 0, s = i[e >> 1], c = s && s.length; r < c; r++) e & 1 ? s[r].call(t) : o = s[r].call(t, o); return o; }, I = (i, e, t, o, r, s) => { var c, l, p, a, _, n = e & 7, v = !!(e & 8), d = !!(e & 16), k = n > 3 ? i.length + 1 : n ? v ? 1 : 2 : 0, R = de[n + 5], A = n > 3 && (i[k - 1] = []), N = i[k] || (i[k] = []), g = n && (!d && !v && (r = r.prototype), n < 5 && (n > 3 || !d) && Re(n < 4 ? r : { get [t]() { return j(this, s); }, set [t](u) { return G(this, s, u); } }, t)); n ? d && n < 4 && Z(s, (n > 2 ? "set " : n > 1 ? "get " : "") + t) : Z(r, t); for (var K = o.length - 1; K >= 0; K--) a = Te(n, t, p = {}, i[3], N), n && (a.static = v, a.private = d, _ = a.access = { has: d ? (u) => $e(r, u) : (u) => t in u }, n ^ 3 && (_.get = d ? (u) => (n ^ 1 ? j : Pe)(u, r, n ^ 4 ? s : g.get) : (u) => u[t]), n > 2 && (_.set = d ? (u, S) => G(u, r, S, n ^ 4 ? s : g.set) : (u, S) => u[t] = S)), l = (0, o[K])(n ? n < 4 ? d ? s : g[R] : n > 4 ? void 0 : { get: g.get, set: g.set } : r, a), p._ = 1, n ^ 4 || l === void 0 ? T(l) && (n > 4 ? A.unshift(l) : n ? d ? s = l : g[R] = l : r = l) : typeof l != "object" || l === null ? $("Object expected") : (T(c = l.get) && (g.get = c), T(c = l.set) && (g.set = c), T(c = l.init) && A.unshift(c)); return n || Le(i, r), g && B(r, t, g), d ? n ^ 4 ? s : g : r; }, P = (i, e, t) => ce(i, typeof e != "symbol" ? e + "" : e, t), D = (i, e, t) => e.has(i) || $("Cannot " + t), $e = (i, e) => Object(e) !== e ? $('Cannot use the "in" operator on this value') : i.has(e), j = (i, e, t) => (D(i, e, "read from private field"), t ? t.call(i) : e.get(i)), G = (i, e, t, o) => (D(i, e, "write to private field"), o ? o.call(i, t) : e.set(i, t), t), Pe = (i, e, t) => (D(i, e, "access private method"), t), he, pe, ue, me, w; me = [q({ name: "prism-view", template: Ce }), V(HTMLElement)], ue = [E()], pe = [E()], he = [E()]; class z { constructor(e) { this._element = e, P(this, "codeArea"), P(this, "code", C(w, 8, this)), C(w, 11, this), P(this, "language", C(w, 12, this, "javascript")), C(w, 15, this), P(this, "lineNumbers", C(w, 16, this, !1)), C(w, 19, this); const t = document.createElement("style"); t.textContent = Se, this._element.appendChild(t); } // eslint-disable-next-line @typescript-eslint/no-unused-vars attached(e) { this.codeChanged(this.code, ""); } codeChanged(e, t) { e !== t && (this.codeArea.textContent = e, O.highlightElement(this.codeArea)); } } w = Ye(); I(w, 5, "code", ue, z); I(w, 5, "language", pe, z); I(w, 5, "lineNumbers", he, z); z = I(w, 0, "PrismView", me, z); C(w, 1, z); export { Be as PrismEditor, z as PrismView }; //# sourceMappingURL=index.mjs.map