@squirrel-cloud/ui-vue
Version:
松鼠的坚果屋前端VUE框架
1,696 lines • 125 kB
JavaScript
import { defineComponent as L, computed as b, createBlock as C, openBlock as v, unref as c, normalizeClass as V, withCtx as A, createCommentVNode as D, createTextVNode as Re, resolveDynamicComponent as ce, toDisplayString as X, h as Te, ref as R, watch as oe, createElementBlock as _, normalizeStyle as K, onMounted as ie, onBeforeUnmount as he, Transition as be, withDirectives as ae, createElementVNode as O, renderSlot as F, vShow as ve, useSlots as Le, createVNode as T, inject as pe, provide as qe, toRef as ne, mergeModels as G, useModel as le, vModelCheckbox as Qe, toRaw as ke, Fragment as te, renderList as de, useAttrs as Ne, Teleport as et, mergeProps as fe, shallowRef as ue, withModifiers as me, nextTick as Ie, vModelDynamic as yt, vModelText as xt, render as Me, cloneVNode as _t, Text as $t, Comment as kt, vModelRadio as tt } from "vue";
import { WarningFilled as st, CloseFilled as nt, InfoFilled as Xe, CheckFilled as ot, JumpTo as wt, CaretUp as qt, Loading as Ee, Check as at, Close as Ue, Bold as Ct, Italic as St, Underline as Bt, Strikethrough as zt, Hide as lt, ListUl as Tt, ListOl as Rt, View as it, ArrowLeft as rt, ArrowRight as ut, ZoomIn as Lt, ZoomOut as It, FlipHorizontal as Mt, FlipVertical as Et, Clockwise as At, Couterclockwise as Dt, FitSize as Ot, Fullscreen as Pt, Ellipsis as Nt, ArrowDown as Ut } from "@squirrel-cloud/icons-vue";
import Ft from "markdown-it";
import { createHighlighter as Vt } from "shiki";
import { RouterLink as Ht } from "vue-router";
import { autoUpdate as jt, computePosition as Wt, offset as Xt, flip as Yt, shift as Kt } from "@floating-ui/dom";
const Fe = {
primary: Xe,
success: ot,
info: Xe,
error: nt,
warn: st
}, Gt = "sq-alert", ha = /* @__PURE__ */ L({
name: Gt,
__name: "alert",
props: {
type: { default: "info" },
showIcon: { type: Boolean },
icon: {},
text: {}
},
setup(d) {
const o = d, n = b(() => {
const t = [];
return o.type && t.push(`is-${o.type}`), t;
}), e = b(() => o.icon ? o.icon : o.showIcon && o.type ? Fe[o.type] : void 0);
return (t, s) => (v(), C(c(ge), {
class: V(["sq-alert", n.value])
}, {
default: A(() => [
e.value ? (v(), C(ce(e.value), { key: 0 })) : D("", !0),
Re(" " + X(o.text), 1)
]),
_: 1
}, 8, ["class"]));
}
});
let Ye = 0;
const Ae = () => ({
/**
* 获取下一个ID
* @returns 下一个ID
*/
nextId: () => (Ye++, Ye)
});
function Ve() {
function d(n) {
const e = document.documentElement;
return getComputedStyle(e).getPropertyValue(n).trim();
}
function o(n) {
return typeof n == "number" ? `${n}px` : n;
}
return { getCssVar: d, getCssUnit: o };
}
function Zt() {
function d(o = [0.3, 0.8], n = [0.1, 0.3], e = [0, 360]) {
const { getRandomNum: t } = Jt(), s = t(o, 4), l = t(n, 4), u = t(e, 4);
return `oklch(${s} ${l} ${u})`;
}
return {
/**
* 获取随机颜色
* @param lRange 明度范围
* @param cRange 彩度范围
* @param hRange 色调范围
* @returns 随机颜色
*/
getRandomColor: d
};
}
function Ce() {
function d(...o) {
for (const n of o) {
const e = c(n);
if (e != null) return e;
}
}
return {
/**
* 获取配置项
* @param args 配置项数组
* @returns 目标配置项
*/
getOption: d
};
}
function Jt() {
function d(o, n = 2) {
const e = Math.random(), t = Math.abs(o[1] - o[0]), s = Math.min(...o) + e * t;
return Number(s.toFixed(n));
}
return {
/**
* 获取随机数
* @param range 随机范围
* @param digits 保留位数
* @returns 随机数
*/
getRandomNum: d
};
}
let Ke = 2e3;
const He = () => ({
/**
* 获取下一个层级
* @returns 下一个层级
*/
nextZIndex: () => (Ke++, Ke)
});
function Se(d, o, n) {
this.type = d, this.tag = o, this.attrs = null, this.map = null, this.nesting = n, this.level = 0, this.children = null, this.content = "", this.markup = "", this.info = "", this.meta = null, this.block = !1, this.hidden = !1;
}
Se.prototype.attrIndex = function(o) {
if (!this.attrs)
return -1;
const n = this.attrs;
for (let e = 0, t = n.length; e < t; e++)
if (n[e][0] === o)
return e;
return -1;
};
Se.prototype.attrPush = function(o) {
this.attrs ? this.attrs.push(o) : this.attrs = [o];
};
Se.prototype.attrSet = function(o, n) {
const e = this.attrIndex(o), t = [o, n];
e < 0 ? this.attrPush(t) : this.attrs[e] = t;
};
Se.prototype.attrGet = function(o) {
const n = this.attrIndex(o);
let e = null;
return n >= 0 && (e = this.attrs[n][1]), e;
};
Se.prototype.attrJoin = function(o, n) {
const e = this.attrIndex(o);
e < 0 ? this.attrPush([o, n]) : this.attrs[e][1] = this.attrs[e][1] + " " + n;
};
function Qt(d) {
d.core.ruler.push("task-lists", (o) => {
var e, t;
const { tokens: n } = o;
for (let s = 0; s < n.length; s++) {
const l = n[s];
if (l.type === "list_item_open") {
const u = n[s + 2];
if (u && u.type === "inline") {
const r = u.content;
if (/^\[[ xX]\]/.test(r.trim())) {
l.attrSet("class", "sq-article-task-list-item");
const a = (e = u.children) == null ? void 0 : e[0];
a && (a.content = a.content.replace(/^\[[ xX]\]/, ""));
const i = /^\[[xX]\]/.test(r), f = [
["type", "checkbox"],
["disabled", ""]
];
i && f.push(["checked", ""]);
const g = new Se("input", "input", 0);
g.attrs = f, (t = u.children) == null || t.unshift(g);
}
}
}
}
});
}
let Ge = 1;
function es() {
function d(s, l) {
const u = new Ft({
html: !0,
typographer: !0
});
return u.use(Qt), l && l.forEach((r) => u.use(r)), u.parse(s, "");
}
function o(s, l) {
const u = e(s, l) ?? [];
return Te("article", { class: "sq-article" }, [
Te(
"div",
{
class: "sq-article-content"
},
n(u)
)
]);
}
function n(s) {
if (!s) return;
const l = s.map((u) => {
if (typeof u == "string")
return u;
{
const r = n(u.children);
return Te(
u.tag,
u.attrs,
typeof u.tag != "string" ? t(r) : r
);
}
});
return l.length > 1 ? l : l[0];
}
function e(s, l) {
const u = [], r = { children: [] };
let a = r;
return s.forEach((i) => {
var M, I, j, J, ee, se, Z, w, y, m, k, x;
const { type: f, children: g, content: h, attrs: p, tag: $, hidden: z, info: B } = i;
switch (f) {
case "heading_open":
case "paragraph_open":
case "bullet_list_open":
case "ordered_list_open":
case "list_item_open":
case "table_open":
case "thead_open":
case "tbody_open":
case "tr_open":
case "th_open":
case "td_open":
case "blockquote_open":
case "strong_open":
case "em_open":
case "s_open":
case "link_open": {
if (z) break;
const S = {
tag: (l == null ? void 0 : l[$]) ?? $,
children: [],
attrs: p ? Object.fromEntries(p) : {}
};
if (f === "link_open") {
const N = i.attrGet("href") ?? "", H = document.location.origin;
N != null && N.startsWith("http") && !N.includes(H) && (S.attrs.target = "_blank", S.attrs.rel = "noopener noreferrer", S.attrs.dataOuter = "", (M = S.children) == null || M.push({ tag: wt }));
}
if (f === "table_open") {
const N = {
tag: "div",
children: [],
attrs: { class: "sq-article-table" }
};
(I = a.children) == null || I.push(N), u.push(a), a = N;
}
(j = a.children) == null || j.push(S), u.push(a), a = S;
break;
}
case "heading_close":
case "paragraph_close":
case "bullet_list_close":
case "ordered_list_close":
case "list_item_close":
case "table_close":
case "thead_close":
case "tbody_close":
case "tr_close":
case "th_close":
case "td_close":
case "blockquote_close":
case "strong_close":
case "em_close":
case "s_close":
case "link_close": {
if (z) break;
a = u.pop();
break;
}
case "code_inline": {
(J = a.children) == null || J.push({
tag: (l == null ? void 0 : l[$]) ?? $,
children: [h],
attrs: p ? Object.fromEntries(p) : {}
});
break;
}
case "inline": {
if (g) {
const S = e(g, l);
(ee = a.children) == null || ee.push(...S ?? []);
} else
(se = a.children) == null || se.push(h);
break;
}
case "text": {
h !== "" && ((Z = a.children) == null || Z.push(h));
break;
}
case "image": {
(w = a.children) == null || w.push({
tag: (l == null ? void 0 : l[$]) ?? $,
children: [],
attrs: p ? Object.fromEntries(p) : {}
});
break;
}
case "fence": {
(y = a.children) == null || y.push({
tag: (l == null ? void 0 : l.fence) ?? "pre",
attrs: p ? Object.fromEntries(p) : {
code: h,
lang: (B ?? "").trim()
}
});
break;
}
case "hr": {
(m = a.children) == null || m.push({
tag: (l == null ? void 0 : l[$]) ?? $
});
break;
}
case "input": {
const S = p ? Object.fromEntries(p) : {}, N = S.type ?? "text", H = `${$}-${N}`, E = {
tag: (l == null ? void 0 : l[H]) ?? $,
children: [],
attrs: S
};
N === "checkbox" && (E.attrs.value = `task-list-${Ge}`, Ge++), (k = a.children) == null || k.push(E);
break;
}
case "html_inline": {
if (h.startsWith("</"))
a = u.pop();
else {
const S = h.match(/^<(\w+)/);
if (!S) return;
const N = S[1], H = {
tag: (l == null ? void 0 : l[N]) ?? N,
children: []
}, E = h.match(/<[^>]+>/);
if (E) {
const U = E[0], q = {};
U.replace(/(\w+)=["']?([^"'\s>]+)["']?/g, (P, W, Q) => (q[W] = Q, "")), Object.keys(q).length > 0 && (H.attrs = q);
}
(x = a.children) == null || x.push(H), u.push(a), a = H;
}
break;
}
}
}), r.children;
}
function t(s) {
return s === void 0 ? void 0 : { default: () => s };
}
return {
/**
* 将Markdown转换为Tokens
* @param markdown Markdown文本
* @returns Tokens
*/
md2tokens: d,
/**
* 将Tokens转换为Vue渲染函数
* @param tokens Tokens
* @returns Vue渲染函数
*/
tokens2vueh: o
};
}
function ts() {
function d(o, n = 100) {
let e;
return function(...t) {
e || (e = setTimeout(() => {
o.apply(this, t), e = void 0;
}, n));
};
}
return {
/**
* 包装节流方法
* @param func 原方法
* @param timeout 延时
* @returns 包装后函数
*/
throttle: d
};
}
let xe, ze, _e = 0;
function ss() {
async function d(n = [
"html",
"css",
"csharp",
"vue",
"json",
"tsx",
"typescript"
], e = ["github-light"]) {
if (xe)
return _e++, xe;
if (ze) {
const t = await ze;
return _e++, t;
}
return ze = (async () => {
const t = await Vt({ langs: n, themes: e });
return xe = t, ze = void 0, t;
})(), _e++, await ze;
}
function o() {
_e === 0 || !xe || (_e--, _e === 0 && (xe.dispose(), xe = void 0));
}
return { getHighlighterAsync: d, releaseHighlighter: o };
}
const { md2tokens: ns, tokens2vueh: os } = es(), as = "sq-article", ls = L({
name: as,
props: {
text: {
type: String,
required: !0
},
md: {
type: Boolean,
default: !0
},
customNodeMap: {
type: Object
},
plugins: {
type: Object
}
},
setup(d) {
const o = b(() => ({
hr: we,
blur: ms,
img: qn,
fence: Ps,
"input-checkbox": dt,
...d.customNodeMap
}));
return () => {
if (!d.md)
return Te(
"article",
{
class: "sq-article"
},
[
Te("div", {
class: "sq-article-content",
innerHTML: d.text
})
]
);
const n = ns(d.text, d.plugins);
return os(n, o.value);
};
}
}), is = ["src", "alt"], rs = ["textContent"], us = "sq-avatar", ga = /* @__PURE__ */ L({
name: us,
__name: "avatar",
props: {
img: {},
alt: {},
randomColor: { type: Boolean, default: !0 },
round: { type: Boolean, default: !0 },
size: { default: "md" }
},
setup(d) {
const o = d, n = R(!0), e = b(() => {
const u = [];
return o.size !== "md" && u.push(`sq-avatar--${o.size}`), o.round && u.push("is-round"), u;
}), t = b(() => {
if (!o.randomColor) return;
const { getRandomColor: u } = Zt();
return {
"--avatar-bg-color": u()
};
}), s = b(() => o.alt.charAt(0).toUpperCase());
oe(
() => o.img,
() => {
n.value = !0;
}
);
function l() {
n.value = !1;
}
return (u, r) => (v(), _("div", {
class: V(["sq-avatar", e.value]),
style: K(t.value)
}, [
o.img && n.value ? (v(), _("img", {
key: 0,
src: o.img,
alt: o.alt,
onError: l
}, null, 40, is)) : (v(), _("span", {
key: 1,
textContent: X(s.value)
}, null, 8, rs))
], 6));
}
}), cs = { class: "sq-backtop" }, ds = "sq-backtop", ba = /* @__PURE__ */ L({
name: ds,
__name: "backtop",
props: {
progress: { type: Boolean, default: !0 },
icon: { default: qt },
transition: { default: "sq-rotate-in-left" },
visibilityHeight: { default: 100 },
target: { default: "#app" },
progressProps: {}
},
setup(d) {
const { throttle: o } = ts(), n = o(r), e = new ResizeObserver(a), t = d, s = R(100), l = R(0), u = b(() => l.value > t.visibilityHeight);
ie(() => {
var g;
a(), n(), window.addEventListener("scroll", n);
const f = document.querySelector(t.target) ?? document.body;
e.observe(f), (g = window.visualViewport) == null || g.addEventListener("resize", a);
}), he(() => {
var f;
window.removeEventListener("scroll", n), e.disconnect(), (f = window.visualViewport) == null || f.removeEventListener("resize", a);
});
function r() {
l.value = window.scrollY;
}
function a() {
const f = (document.scrollingElement ?? document.body).scrollHeight, g = window.innerHeight;
s.value = f - g;
}
function i() {
window.scrollTo({ top: 0, behavior: "smooth" });
}
return (f, g) => (v(), C(be, {
name: t.transition
}, {
default: A(() => {
var h, p, $;
return [
ae(O("div", cs, [
O("div", {
class: "sq-backtop-wrap",
onClick: i
}, [
t.progress ? (v(), C(c(go), {
key: 0,
variant: "circle",
label: !1,
value: l.value,
max: s.value,
type: (h = t.progressProps) == null ? void 0 : h.type,
stroke: (p = t.progressProps) == null ? void 0 : p.stroke,
color: ($ = t.progressProps) == null ? void 0 : $.color
}, null, 8, ["value", "max", "type", "stroke", "color"])) : D("", !0),
F(f.$slots, "default", {}, () => [
(v(), C(ce(t.icon)))
])
])
], 512), [
[ve, u.value]
])
];
}),
_: 3
}, 8, ["name"]));
}
}), fs = ["textContent"], ps = "sq-badge", Ze = /* @__PURE__ */ L({
name: ps,
__name: "badge",
props: {
type: { default: "error" },
color: {},
showZero: { type: Boolean },
max: { default: 99 },
count: { default: 0 },
text: {},
dot: { type: Boolean }
},
setup(d) {
const o = Le(), n = d, e = b(() => {
const u = [`is-${n.type}`];
return n.dot && u.push("is-dot"), u;
}), t = b(() => o.default ? "sup" : "div"), s = b(() => !n.dot && n.text || n.showZero ? !0 : n.count > 0), l = b(() => n.dot ? "" : n.text ? n.text : n.max && n.count > n.max ? `${n.max}+` : `${n.count}`);
return (u, r) => (v(), C(be, { name: "sq-zoom" }, {
default: A(() => [
c(o).default || s.value ? (v(), _("span", {
key: 0,
class: V(["sq-badge", e.value]),
style: K({ "--badge-color": n.color })
}, [
F(u.$slots, "default"),
(v(), C(ce(t.value), { class: "sq-badge-label" }, {
default: A(() => [
T(be, {
name: c(o).default ? "sq-zoom" : ""
}, {
default: A(() => [
s.value ? (v(), _("span", {
key: 0,
class: "sq-badge-label-inner",
textContent: X(l.value)
}, null, 8, fs)) : D("", !0)
]),
_: 1
}, 8, ["name"])
]),
_: 1
}))
], 6)) : D("", !0)
]),
_: 3
}));
}
}), vs = "sq-blur", ms = /* @__PURE__ */ L({
name: vs,
__name: "blur",
setup(d) {
return (o, n) => (v(), C(c(ge), { class: "sq-blur" }, {
default: A(() => [
F(o.$slots, "default")
]),
_: 3
}));
}
});
function hs(d) {
const { getOption: o } = Ce(), n = pe(Be, void 0), e = pe(ct, void 0), t = b(
() => c(e) ? void 0 : d.text
), s = b(
() => {
var a, i;
return o(
(a = c(e)) == null ? void 0 : a.size,
d.size,
(i = c(n)) == null ? void 0 : i.size,
"md"
);
}
), l = b(
() => {
var a;
return o((a = c(e)) == null ? void 0 : a.type, d.type);
}
), u = b(
() => {
var a, i;
return o(
(a = c(e)) == null ? void 0 : a.round,
d.round,
(i = c(n)) == null ? void 0 : i.round
);
}
), r = b(
() => {
var a, i, f;
return o(
(a = c(n)) == null ? void 0 : a.disabled,
(i = c(n)) == null ? void 0 : i.readonly,
(f = c(e)) == null ? void 0 : f.disabled,
d.disabled
);
}
);
return { btnTextType: t, btnSize: s, btnType: l, btnRound: u, btnDisabled: r };
}
function gs(d) {
const { getOption: o } = Ce(), n = pe(Be, void 0), e = pe(ft, void 0), t = b(
() => {
var a, i;
return o(
(a = c(e)) == null ? void 0 : a.size,
d.size,
(i = c(n)) == null ? void 0 : i.size,
"md"
);
}
), s = b(
() => {
var a;
return o((a = c(e)) == null ? void 0 : a.form, d.form);
}
), l = b(
() => {
var a;
return o((a = c(e)) == null ? void 0 : a.name, d.name);
}
), u = b(
() => {
var a;
return o((a = c(e)) == null ? void 0 : a.variant, d.variant);
}
), r = b(
() => {
var a, i, f;
return o(
(a = c(n)) == null ? void 0 : a.disabled,
(i = c(n)) == null ? void 0 : i.readonly,
(f = c(e)) == null ? void 0 : f.disabled,
d.disabled
);
}
);
return {
checkboxSize: t,
checkboxForm: s,
checkboxName: l,
checkboxVariant: u,
checkboxDisabled: r,
groupContext: e
};
}
function bs(d) {
const { getOption: o } = Ce(), n = pe(Be, void 0), e = pe(je, void 0), t = b(
() => {
var r;
return o(d.size, (r = c(n)) == null ? void 0 : r.size, "md");
}
), s = b(
() => {
var r;
return o(d.round, (r = c(n)) == null ? void 0 : r.round);
}
), l = b(
() => {
var r;
return o((r = c(n)) == null ? void 0 : r.disabled, d.disabled);
}
), u = b(
() => {
var r;
return o((r = c(n)) == null ? void 0 : r.readonly, d.readonly);
}
);
return { inputSize: t, inputRound: s, inputDisabled: l, inputReadonly: u, id: e };
}
function ys(d) {
const { getOption: o } = Ce(), n = pe(Be, void 0), e = pe(ht, void 0), t = b(
() => {
var a, i;
return o(
(a = c(e)) == null ? void 0 : a.size,
d.size,
(i = c(n)) == null ? void 0 : i.size,
"md"
);
}
), s = b(
() => {
var a;
return o((a = c(e)) == null ? void 0 : a.form, d.form);
}
), l = b(
() => {
var a;
return o((a = c(e)) == null ? void 0 : a.name, d.name);
}
), u = b(
() => {
var a;
return o((a = c(e)) == null ? void 0 : a.variant, d.variant);
}
), r = b(
() => {
var a, i, f;
return o(
(a = c(n)) == null ? void 0 : a.disabled,
(i = c(n)) == null ? void 0 : i.readonly,
(f = c(e)) == null ? void 0 : f.disabled,
d.disabled
);
}
);
return {
radioSize: t,
radioForm: s,
radioName: l,
radioVariant: u,
radioDisabled: r,
groupContext: e
};
}
function xs(d) {
const { getOption: o } = Ce(), n = pe(gt, void 0);
return {
segmentedDisabled: b(
() => {
var t;
return o((t = c(n)) == null ? void 0 : t.disabled, d.disabled);
}
),
parentContext: n
};
}
function _s(d) {
const { getOption: o } = Ce(), n = pe(Be, void 0), e = pe(je, void 0), t = b(
() => {
var l;
return o(d.size, (l = c(n)) == null ? void 0 : l.size, "md");
}
), s = b(
() => {
var l, u;
return o(
(l = c(n)) == null ? void 0 : l.disabled,
(u = c(n)) == null ? void 0 : u.readonly,
d.disabled
);
}
);
return { switchSize: t, switchDisabled: s, id: e };
}
const $s = ["disabled", "form", "type"], ks = "sq-button", Y = /* @__PURE__ */ L({
name: ks,
__name: "button",
props: {
type: {},
round: { type: Boolean, default: void 0 },
text: { type: Boolean },
icon: {},
loading: { type: Boolean },
form: {},
bg: { type: Boolean },
nativeType: { default: "button" },
disabled: { type: Boolean, default: void 0 },
size: {}
},
emits: ["click"],
setup(d, { emit: o }) {
const n = o, e = d, { btnTextType: t, btnSize: s, btnType: l, btnRound: u, btnDisabled: r } = hs(e), a = b(() => {
const g = [], h = c(s), p = c(l), $ = c(u), z = c(t);
return h !== "md" && g.push(`sq-button--${h}`), p && g.push(`is-${p}`), $ && g.push("is-round"), z && g.push("is-text"), z && e.bg && g.push("has-bg"), g;
}), i = b(() => e.loading ? Ee : e.icon), f = b(() => e.loading || c(r));
return (g, h) => (v(), _("button", {
class: V(["sq-button", a.value]),
disabled: f.value,
form: e.form,
type: e.nativeType,
onClick: h[0] || (h[0] = (p) => n("click", p))
}, [
T(c(ge), {
size: c(s) === "lg" ? "md" : c(s)
}, {
default: A(() => [
i.value ? (v(), C(ce(i.value), { key: 0 })) : D("", !0),
F(g.$slots, "default")
]),
_: 3
}, 8, ["size"])
], 10, $s));
}
}), ws = { class: "sq-button-group" }, qs = "sq-button-group", ya = /* @__PURE__ */ L({
name: qs,
__name: "button-group",
props: {
size: {},
type: {},
round: { type: Boolean, default: void 0 },
disabled: { type: Boolean, default: void 0 }
},
setup(d) {
const o = d;
return qe(
ct,
R({
size: ne(o, "size"),
type: ne(o, "type"),
round: ne(o, "round"),
disabled: ne(o, "disabled")
})
), (n, e) => (v(), _("div", ws, [
F(n.$slots, "default")
]));
}
}), ct = Symbol("button-group-context-keys"), Cs = { class: "sq-card" }, Ss = {
key: 0,
class: "sq-card-header"
}, Bs = ["textContent"], zs = {
key: 1,
class: "sq-card-footer"
}, Ts = "sq-card", xa = /* @__PURE__ */ L({
name: Ts,
__name: "card",
props: {
title: {},
decorative: { type: Boolean, default: !1 }
},
setup(d) {
const o = Le(), n = d;
return (e, t) => (v(), _("section", Cs, [
n.title || c(o).title ? (v(), _("div", Ss, [
O("h2", {
class: V({ "has-decorative": n.decorative }),
textContent: X(n.title)
}, null, 10, Bs),
F(e.$slots, "title")
])) : D("", !0),
F(e.$slots, "default"),
c(o).footer ? (v(), _("div", zs, [
F(e.$slots, "footer")
])) : D("", !0)
]));
}
}), Rs = ["autofocus", "name", "form", "value", "disabled"], Ls = ["textContent"], Is = "sq-checkbox", dt = /* @__PURE__ */ L({
name: Is,
__name: "checkbox",
props: /* @__PURE__ */ G({
form: {},
name: {},
disabled: { type: Boolean, default: void 0 },
size: {},
indeterminate: { type: Boolean },
variant: {},
autofocus: { type: Boolean },
label: {},
value: {}
}, {
checked: { type: Boolean, default: !1 },
checkedModifiers: {}
}),
emits: /* @__PURE__ */ G(["change"], ["update:checked"]),
setup(d, { emit: o }) {
const n = o, e = d, {
checkboxSize: t,
checkboxDisabled: s,
checkboxForm: l,
checkboxName: u,
checkboxVariant: r,
groupContext: a
} = gs(e), i = le(d, "checked"), f = b(() => {
const h = [], p = c(t), $ = c(s), z = c(r);
return p !== "md" && h.push(`sq-selection--${p}`), g.value && h.push("is-checked"), $ && h.push("is-disabled"), z && h.push(`is-${z}`), h;
}), g = b(() => a ? c(a).list.includes(e.value) : i.value);
return oe(g, (h) => {
if (i.value !== h) {
i.value = h;
return;
}
}), oe(i, (h) => {
g.value !== h && a && a.value.toggleItem(e.value);
}), ie(() => {
i.value = g.value;
}), (h, p) => (v(), _("label", {
class: V(["sq-selection sq-checkbox", f.value])
}, [
ae(O("input", {
type: "checkbox",
autofocus: e.autofocus,
name: c(u),
form: c(l),
value: e.value,
disabled: c(s),
"onUpdate:modelValue": p[0] || (p[0] = ($) => i.value = $),
onChange: p[1] || (p[1] = ($) => n("change", i.value))
}, null, 40, Rs), [
[Qe, i.value]
]),
c(r) !== "solid" ? (v(), _("span", {
key: 0,
class: V(["sq-checkbox-box", { "is-indeterminate": e.indeterminate && !g.value }])
}, [
g.value ? (v(), C(c(at), {
key: 0,
class: "sq-checkbox-inner"
})) : D("", !0)
], 2)) : D("", !0),
e.label ? (v(), _("span", {
key: 1,
class: "sq-selection-label",
textContent: X(e.label)
}, null, 8, Ls)) : D("", !0)
], 2));
}
}), Ms = { class: "sq-checkbox-group sq-selection-group" }, Es = "sq-checkbox-group", As = /* @__PURE__ */ L({
name: Es,
__name: "checkbox-group",
props: {
items: { default: () => [] },
value: {},
form: {},
name: {},
disabled: { type: Boolean, default: void 0 },
size: {},
variant: {}
},
emits: ["change", "update:value"],
setup(d, { emit: o }) {
const { nextId: n } = Ae(), e = o, t = d, s = R(t.value ?? []), l = b(() => t.name ?? `sq-checkbox-${n()}`);
qe(
ft,
R({
form: ne(t, "form"),
name: l,
disabled: ne(t, "disabled"),
size: ne(t, "size"),
variant: ne(t, "variant"),
list: s,
toggleItem: u
})
), oe(
() => t.value,
(r) => {
const a = r || [], i = [.../* @__PURE__ */ new Set([...a, s.value])];
i.length === a.length && i.length === s.value.length || (s.value = a);
}
);
function u(r) {
s.value.includes(r) ? s.value = s.value.filter((a) => a !== r) : s.value.push(r), e("change", ke(s.value)), e("update:value", ke(s.value));
}
return (r, a) => (v(), _("div", Ms, [
F(r.$slots, "default", {}, () => [
(v(!0), _(te, null, de(t.items, (i, f) => (v(), C(c(dt), {
key: f,
label: i.toString(),
value: i
}, null, 8, ["label", "value"]))), 128))
])
]));
}
}), ft = Symbol("checkbox-group-context-keys"), Ds = ["innerHTML"], Os = "sq-code", Ps = /* @__PURE__ */ L({
name: Os,
__name: "code",
props: {
code: {},
theme: { default: "github-light" },
lang: {}
},
setup(d) {
const { getHighlighterAsync: o, releaseHighlighter: n } = ss(), e = d, t = R("");
return ie(async () => {
const s = await o();
t.value = s.codeToHtml(e.code, {
theme: e.theme,
lang: e.lang
});
}), he(() => {
n();
}), (s, l) => (v(), _("div", {
class: "sq-code",
innerHTML: t.value
}, null, 8, Ds));
}
}), Ns = "sq-mask", pt = /* @__PURE__ */ L({
name: Ns,
inheritAttrs: !1,
__name: "mask",
props: /* @__PURE__ */ G({
keyboard: { type: Boolean, default: !0 },
maskCloseable: { type: Boolean },
beforeClose: {}
}, {
visible: { type: Boolean, default: !1 },
visibleModifiers: {}
}),
emits: /* @__PURE__ */ G(["open", "opened", "close", "closed"], ["update:visible"]),
setup(d, { emit: o }) {
const { nextZIndex: n } = He(), e = Ne();
let t;
const s = o, l = d, u = R(0), r = R(!1), a = le(d, "visible");
r.value = a.value, oe(a, (h) => {
const p = document.scrollingElement;
h ? (t = p.style.overflow, p.style.overflow = "hidden", u.value = n(), r.value = !0, document.addEventListener("keydown", i)) : (p.style.overflow = t, document.removeEventListener("keydown", i));
}), he(() => {
document.removeEventListener("keydown", i);
});
function i(h) {
h.key === "Escape" && l.keyboard && g();
}
function f() {
l.maskCloseable && g();
}
function g() {
if (typeof l.beforeClose != "function") {
a.value = !1;
return;
}
const h = l.beforeClose();
h instanceof Promise ? h.then((p) => {
p && (a.value = !1);
}).catch(() => {
}) : h && (a.value = !1);
}
return (h, p) => (v(), C(et, { to: "body" }, [
T(be, {
name: "sq-fade",
onBeforeEnter: p[0] || (p[0] = ($) => s("open")),
onAfterEnter: p[1] || (p[1] = ($) => s("opened")),
onBeforeLeave: p[2] || (p[2] = ($) => s("close")),
onAfterLeave: p[3] || (p[3] = ($) => s("closed"))
}, {
default: A(() => [
r.value ? ae((v(), _("div", fe({
key: 0,
class: "sq-mask",
style: { zIndex: u.value }
}, c(e), { onClick: f }), [
F(h.$slots, "default")
], 16)), [
[ve, a.value]
]) : D("", !0)
]),
_: 3
})
]));
}
}), Us = {
key: 0,
class: "sq-dialog-header"
}, Fs = ["textContent"], Vs = { class: "sq-dialog-body" }, Hs = {
key: 1,
class: "sq-dialog-footer"
}, js = "sq-dialog", Ws = /* @__PURE__ */ L({
name: js,
inheritAttrs: !1,
__name: "dialog",
props: /* @__PURE__ */ G({
type: {},
title: {},
okText: { default: "确认" },
cancelText: { default: "取消" },
okButtonProps: {},
cancelButtonProps: {},
footer: { type: Boolean, default: !0 },
closeable: { type: Boolean },
onOk: {},
keyboard: { type: Boolean, default: void 0 },
maskCloseable: { type: Boolean, default: void 0 },
beforeClose: {}
}, {
visible: { type: Boolean, default: !1 },
visibleModifiers: {}
}),
emits: /* @__PURE__ */ G(["open", "opened", "close", "closed"], ["update:visible"]),
setup(d, { emit: o }) {
const n = Le(), e = Ne(), t = o, s = d, l = R(!1), u = R(!1), r = le(d, "visible"), a = b(() => !!s.title || !!n.header), i = b(() => {
const M = [];
return s.type && M.push(`is-${s.type}`), a.value && M.push("has-header"), [M];
}), f = b(() => s.type ? Fe[s.type] : void 0), g = b(() => ({
type: s.type ?? "primary",
loading: l.value && u.value,
disabled: l.value && !u.value,
...s.okButtonProps
})), h = b(() => ({
text: !0,
bg: !0,
loading: l.value && !u.value,
disabled: l.value && u.value,
...s.cancelButtonProps
})), p = b(
() => g.value.loading || h.value.loading || !r.value
);
function $(M) {
if (p.value) return !1;
if (typeof M != "function") return !0;
const I = M();
return I instanceof Promise ? (l.value = !0, I.finally(() => {
l.value = !1;
})) : I;
}
async function z() {
if (p.value) return !1;
u.value = !1, await $(s.beforeClose) && (r.value = !1);
}
async function B() {
u.value = !0, await $(s.onOk) && (r.value = !1);
}
return (M, I) => (v(), C(c(pt), {
visible: r.value,
"onUpdate:visible": I[0] || (I[0] = (j) => r.value = j),
"mask-closeable": s.maskCloseable,
keyboard: s.keyboard,
"before-close": () => $(s.beforeClose),
onOpen: I[1] || (I[1] = (j) => t("open")),
onOpened: I[2] || (I[2] = (j) => t("opened")),
onClose: I[3] || (I[3] = (j) => t("close")),
onClosed: I[4] || (I[4] = (j) => t("closed"))
}, {
default: A(() => [
O("div", {
class: V(["sq-dialog", [i.value, c(e).class]]),
style: K(c(e).style)
}, [
a.value ? (v(), _("div", Us, [
f.value ? (v(), C(ce(f.value), {
key: 0,
class: "sq-dialog-header-icon"
})) : D("", !0),
F(M.$slots, "header", {}, () => [
O("span", {
class: "sq-dialog-header-title",
textContent: X(s.title)
}, null, 8, Fs)
]),
T(c(Ue), {
class: "sq-dialog-close",
onClick: z
})
])) : D("", !0),
O("div", Vs, [
F(M.$slots, "default")
]),
s.footer ? (v(), _("div", Hs, [
F(M.$slots, "footer", {}, () => [
T(c(Y), fe(h.value, { onClick: z }), {
default: A(() => [
Re(X(s.cancelText), 1)
]),
_: 1
}, 16),
T(c(Y), fe(g.value, { onClick: B }), {
default: A(() => [
Re(X(s.okText), 1)
]),
_: 1
}, 16)
])
])) : D("", !0)
], 6)
]),
_: 3
}, 8, ["visible", "mask-closeable", "keyboard", "before-close"]));
}
}), Xs = "sq-divider", we = /* @__PURE__ */ L({
name: Xs,
__name: "divider",
props: {
direction: { default: "horizontal" },
variant: { default: "solid" },
orientation: { default: "left" },
ellipsis: { type: [Boolean, Number] },
size: {}
},
setup(d) {
const o = Le(), n = d, e = b(() => {
const t = [`sq-divider--${n.direction}`];
return ["none", "solid", "dotted", "dashed"].includes(n.variant) && t.push("is-thin"), o.default && n.direction !== "vertical" && t.push(`text-${n.orientation}`), t;
});
return (t, s) => (v(), _("div", {
class: V(["sq-divider", e.value]),
style: K({ "--divider-line-type": n.variant })
}, [
c(o).default && n.direction !== "vertical" ? (v(), C(c(ge), {
key: 0,
ellipsis: n.ellipsis,
size: n.size
}, {
default: A(() => [
F(t.$slots, "default")
]),
_: 3
}, 8, ["ellipsis", "size"])) : D("", !0)
], 6));
}
}), Ys = "sq-editor-bold", Ks = /* @__PURE__ */ L({
name: Ys,
__name: "editor-bold",
props: {
disabled: { type: Boolean },
rows: { default: () => [] },
selectedVal: {},
selectedRow: {},
selectInfo: { default: () => ({}) }
},
emits: ["updateText"],
setup(d, { expose: o, emit: n }) {
const e = n, t = d;
function s() {
if (t.disabled) return;
const l = [...t.rows], u = l[t.selectedRow], r = u.substring(0, t.selectInfo.startOfRow), a = u.substring(t.selectInfo.endOfRow);
let i = t.selectedVal ?? "";
if (i.match(/\*\*\*.*?\*\*\*/)) {
i = i.replaceAll("***", "*"), l[t.selectedRow] = `${r}${i}${a}`, e("updateText", l, 0, -4);
return;
}
if (i.match(/\*\*.*?\*\*/)) {
i = i.replaceAll("**", ""), l[t.selectedRow] = `${r}${i}${a}`, e("updateText", l, 0, -4);
return;
}
i = `**${i}**`, l[t.selectedRow] = `${r}${i}${a}`, e("updateText", l, 0, 4);
}
return o({ setBold: s }), (l, u) => (v(), C(c(re), {
tip: "加粗 ( Ctrl + B )",
disabled: t.disabled
}, {
default: A(() => [
T(c(Y), {
text: "",
icon: c(Ct),
disabled: t.disabled,
onClick: s
}, null, 8, ["icon", "disabled"])
]),
_: 1
}, 8, ["disabled"]));
}
}), Gs = "sq-editor-italic", Zs = /* @__PURE__ */ L({
name: Gs,
__name: "editor-italic",
props: {
disabled: { type: Boolean },
rows: { default: () => [] },
selectedVal: {},
selectedRow: {},
selectInfo: { default: () => ({}) }
},
emits: ["updateText"],
setup(d, { expose: o, emit: n }) {
const e = n, t = d;
function s() {
if (t.disabled) return;
const l = [...t.rows], u = l[t.selectedRow], r = u.substring(0, t.selectInfo.startOfRow), a = u.substring(t.selectInfo.endOfRow);
let i = t.selectedVal ?? "";
if (i.match(/\*\*\*.*?\*\*\*/)) {
i = i.replaceAll("***", "**"), l[t.selectedRow] = `${r}${i}${a}`, e("updateText", l, 0, -2);
return;
}
const g = i.match(/\*\*.*?\*\*/), p = ((g == null ? void 0 : g[0]) ?? "").replaceAll("**", "").match(/\*.*?\*/);
if (g && !p) {
i = `*${i}*`, l[t.selectedRow] = `${r}${i}${a}`, e("updateText", l, 0, 2);
return;
} else if (p) {
i = i.replaceAll("**", "[B]").replaceAll("*", "").replaceAll("[B]", "**"), l[t.selectedRow] = `${r}${i}${a}`, e("updateText", l, 0, -2);
return;
}
if (i.match(/\*.*?\*/)) {
i = i.replaceAll("*", ""), l[t.selectedRow] = `${r}${i}${a}`, e("updateText", l, 0, -2);
return;
}
i = `*${i}*`, l[t.selectedRow] = `${r}${i}${a}`, e("updateText", l, 0, 2);
}
return o({ setItalic: s }), (l, u) => (v(), C(c(re), {
tip: "斜体 ( Ctrl + I )",
disabled: t.disabled
}, {
default: A(() => [
T(c(Y), {
text: "",
icon: c(St),
disabled: t.disabled,
onClick: s
}, null, 8, ["icon", "disabled"])
]),
_: 1
}, 8, ["disabled"]));
}
}), Js = "sq-editor-underline", Qs = /* @__PURE__ */ L({
name: Js,
__name: "editor-underline",
props: {
disabled: { type: Boolean },
rows: { default: () => [] },
selectedVal: {},
selectedRow: {},
selectInfo: { default: () => ({}) }
},
emits: ["updateText"],
setup(d, { expose: o, emit: n }) {
const e = n, t = d;
function s() {
var p;
if (t.disabled) return;
const l = [...t.rows], u = l[t.selectedRow], r = u.substring(0, t.selectInfo.startOfRow), a = u.substring(t.selectInfo.endOfRow), i = /<u\b.*?>/;
let f = t.selectedVal ?? "";
const g = ((p = f.match(i)) == null ? void 0 : p[0]) ?? "";
if (f.match(/<u\b.*?>.*?<\/u>/)) {
f = f.replace(g, "").replace("</u>", "");
const $ = g.length + 4;
l[t.selectedRow] = `${r}${f}${a}`, e("updateText", l, 0, -$);
return;
}
f = `<u>${f}</u>`, l[t.selectedRow] = `${r}${f}${a}`, e("updateText", l, 0, 7);
}
return o({ setUnderline: s }), (l, u) => (v(), C(c(re), {
tip: "下划线 ( Ctrl + U )",
disabled: t.disabled
}, {
default: A(() => [
T(c(Y), {
text: "",
icon: c(Bt),
disabled: t.disabled,
onClick: s
}, null, 8, ["icon", "disabled"])
]),
_: 1
}, 8, ["disabled"]));
}
}), en = "sq-editor-strikethrough", tn = /* @__PURE__ */ L({
name: en,
__name: "editor-strikethrough",
props: {
disabled: { type: Boolean },
rows: { default: () => [] },
selectedVal: {},
selectedRow: {},
selectInfo: { default: () => ({}) }
},
emits: ["updateText"],
setup(d, { emit: o }) {
const n = o, e = d;
function t() {
if (e.disabled) return;
const s = [...e.rows], l = s[e.selectedRow], u = l.substring(0, e.selectInfo.startOfRow), r = l.substring(e.selectInfo.endOfRow);
let a = e.selectedVal ?? "";
if (a.match(/\~\~.*?\~\~/)) {
a = a.replaceAll("~~", ""), s[e.selectedRow] = `${u}${a}${r}`, n("updateText", s, 0, -4);
return;
}
a = `~~${a}~~`, s[e.selectedRow] = `${u}${a}${r}`, n("updateText", s, 0, 4);
}
return (s, l) => (v(), C(c(re), {
tip: "删除线",
disabled: e.disabled
}, {
default: A(() => [
T(c(Y), {
text: "",
icon: c(zt),
disabled: e.disabled,
onClick: t
}, null, 8, ["icon", "disabled"])
]),
_: 1
}, 8, ["disabled"]));
}
}), sn = "sq-editor-blur", nn = /* @__PURE__ */ L({
name: sn,
__name: "editor-blur",
props: {
disabled: { type: Boolean },
rows: { default: () => [] },
selectedVal: {},
selectedRow: {},
selectInfo: { default: () => ({}) }
},
emits: ["updateText"],
setup(d, { emit: o }) {
const n = o, e = d;
function t() {
var h;
if (e.disabled) return;
const s = [...e.rows], l = s[e.selectedRow], u = l.substring(0, e.selectInfo.startOfRow), r = l.substring(e.selectInfo.endOfRow), a = /<blur\b.*?>/;
let i = e.selectedVal ?? "";
const f = ((h = i.match(a)) == null ? void 0 : h[0]) ?? "";
if (i.match(/<blur\b.*?>.*?<\/blur>/)) {
i = i.replace(f, "").replace("</blur>", "");
const p = f.length + 7;
s[e.selectedRow] = `${u}${i}${r}`, n("updateText", s, 0, -p);
return;
}
i = `<blur>${i}</blur>`, s[e.selectedRow] = `${u}${i}${r}`, n("updateText", s, 0, 13);
}
return (s, l) => (v(), C(c(re), {
tip: "模糊块",
disabled: e.disabled
}, {
default: A(() => [
T(c(Y), {
text: "",
icon: c(lt),
disabled: e.disabled,
onClick: t
}, null, 8, ["icon", "disabled"])
]),
_: 1
}, 8, ["disabled"]));
}
}), on = "sq-editor-ul", an = /* @__PURE__ */ L({
name: on,
__name: "editor-ul",
props: {
disabled: { type: Boolean },
rows: { default: () => [] },
selectedVal: {},
selectedRow: {},
selectInfo: { default: () => ({}) }
},
emits: ["updateText"],
setup(d, { emit: o }) {
const n = o, e = d;
function t() {
const r = e.selectedRow, a = [...e.rows], i = a[r];
if (s(i)) {
a[r] = i.replace("- ", ""), n("updateText", a, -2, -2);
return;
}
if (l(i)) {
const f = u(i), g = 2 - f.length;
a[r] = i.replace(f, "- "), n("updateText", a, g, g);
return;
}
a[r] = `- ${i}`, n("updateText", a, 2, 2);
}
function s(r) {
return r.replace(" ", "").startsWith("- ");
}
function l(r) {
return /^\d+\.\s+/.test(r.replace(" ", ""));
}
function u(r) {
return r.replace(" ", "").match(/^\d+\.\s/)[0];
}
return (r, a) => (v(), C(c(re), {
tip: "无序列表",
disabled: e.disabled
}, {
default: A(() => [
T(c(Y), {
text: "",
icon: c(Tt),
disabled: e.disabled,
onClick: t
}, null, 8, ["icon", "disabled"])
]),
_: 1
}, 8, ["disabled"]));
}
}), ln = "sq-editor-ol", rn = /* @__PURE__ */ L({
name: ln,
__name: "editor-ol",
props: {
disabled: { type: Boolean },
rows: { default: () => [] },
selectedVal: {},
selectedRow: {},
selectInfo: { default: () => ({}) }
},
emits: ["updateText"],
setup(d, { emit: o }) {
const n = o, e = d;
function t() {
const r = e.selectedRow, a = [...e.rows], i = a[r], f = r > 0 ? a[r - 1] : "";
let g = 1;
if (s(i)) {
f && l(f) && (g = parseInt(u(f)) + 1);
const $ = `${g}. `, z = $.length - 2;
a[r] = i.replace("- ", $), n("updateText", a, z, z);
return;
}
if (l(i)) {
const $ = u(i), z = -$.length;
a[r] = i.replace($, ""), n("updateText", a, z, z);
return;
}
f && l(f) && (g = parseInt(u(f)) + 1);
const h = `${g}. `, p = h.length;
a[r] = `${h}${i}`, n("updateText", a, p, p);
}
function s(r) {
return r.replace(" ", "").startsWith("- ");
}
function l(r) {
return /^\d+\.\s+/.test(r.replace(" ", ""));
}
function u(r) {
return r.replace(" ", "").match(/^\d+\.\s/)[0];
}
return (r, a) => (v(), C(c(re), {
tip: "有序列表",
disabled: e.disabled
}, {
default: A(() => [
T(c(Y), {
text: "",
icon: c(Rt),
disabled: e.disabled,
onClick: t
}, null, 8, ["icon", "disabled"])
]),
_: 1
}, 8, ["disabled"]));
}
}), un = { class: "sq-editor-body" }, cn = { class: "sq-editor-toolbar" }, dn = { class: "sq-editor-control" }, fn = "sq-editor", _a = /* @__PURE__ */ L({
name: fn,
__name: "editor",
props: /* @__PURE__ */ G({
round: { type: Boolean },
disabled: { type: Boolean },
placeholder: {},
maxlength: {},
minlength: {},
md: { type: Boolean, default: !0 },
size: { default: "md" },
beforePreview: {}
}, {
value: { default: "" },
valueModifiers: {}
}),
emits: ["update:value"],
setup(d) {
const o = [
{
text: "编辑",
value: "edit"
},
{
text: "预览",
value: "preview"
}
];
let n;
const e = d, t = R("edit"), s = R([]), l = R(!1), u = R(""), r = R(), a = R({}), i = ue(null), f = ue(null), g = ue(null), h = ue(
null
), p = le(d, "value"), $ = b(() => {
const k = [];
return e.size !== "md" && k.push(`sq-editor--${e.size}`), e.round && k.push("is-round"), k;
}), z = b(
() => u.value.length && !u.value.includes(`
`) && u.value !== " " && !e.disabled
), B = b(
() => r.value !== void 0 && !u.value.length && !e.disabled
), M = b(
() => typeof e.beforePreview == "function" ? e.beforePreview(p.value) : p.value
);
ie(() => {
document.addEventListener("selectionchange", J), document.addEventListener("click", ee);
}), he(() => {
document.removeEventListener("selectionchange", J), document.removeEventListener("click", ee);
});
function I(k) {
k === "edit" && Ie(() => {
var x;
(x = i.value) == null || x.focus();
});
}
function j(k) {
var N, H, E;
const x = s.value[r.value], S = (x == null ? void 0 : x.replace(" ", "")) ?? "";
if (k.key === "Tab") {
k.preventDefault();
const U = x.substring(0, a.value.startOfRow), q = x.substring(a.value.endOfRow);
s.value[r.value] = `${U} ${q}`, m(s.value, 1, 1);
return;
}
if (k.ctrlKey)
switch (k.key.toUpperCase()) {
case "B":
(N = f.value) == null || N.setBold();
return;
case "I":
(H = g.value) == null || H.setItalic();
return;
case "U":
k.preventDefault(), (E = h.value) == null || E.setUnderline();
return;
}
if (k.key === "Enter") {
if (w(x)) {
k.preventDefault();
const U = x.substring(0, x.indexOf("- "));
if (S !== "- ") {
const P = 3 + U.length;
s.value[r.value] = `${x}
${U}- `, se(k.target), m(s.value, P, P);
return;
}
const q = 2 + U.length;
s.value[r.value] = x.substring(q), m(s.value, -q, -q);
return;
}
if (y(x)) {
k.preventDefault();
const U = S.match(/^\d+\.\s/)[0], P = `${parseInt(U) + 1}. `, W = x.substring(0, x.indexOf(U));
if (S !== U) {
const ye = P.length + W.length + 1;
s.value[r.value] = `${x}
${W}${P}`, se(k.target), m(s.value, ye, ye);
return;
}
const Q = U.length + W.length;
s.value[r.value] = x.substring(Q), m(s.value, -Q, -Q);
return;
}
}
}
function J(k) {
var S;
const x = window.getSelection();
(x == null ? void 0 : x.focusNode) === ((S = i.value) == null ? void 0 : S.$el) && (n = k.target, !((n == null ? void 0 : n.selectionStart) === void 0 || (n == null ? void 0 : n.selectionEnd) === void 0) && (a.value.start = (n == null ? void 0 : n.selectionStart) ?? 0, a.value.end = (n == null ? void 0 : n.selectionEnd) ?? 0, u.value = p.value.substring(
a.value.start,
a.value.end
), Z()));
}
function ee() {
u.value = "", r.value = void 0;
}
function se(k) {
const x = k.selectionStart, N = p.value.substring(0, x ?? 0).split(`
`).length + 1, H = k.scrollTop, E = window.getComputedStyle(k), U = parseFloat(E.lineHeight), q = parseFloat(E.height), W = parseFloat(E.paddingBlockStart) + U * N;
q + H > W || requestAnimationFrame(() => {
k.scrollTo({ top: W - q });
});
}
function Z() {
const k = n.selectionStart, x = p.value.substring(0, k ?? 0);
r.value = x.split(`
`).length - 1;
const S = Math.max(x.lastIndexOf(`
`) + 1, 0);
a.value.startOfRow = a.value.start - S, a.value.endOfRow = a.value.startOfRow + u.value.length, s.value = p.value.split(`
`);
}
function w(k) {
return k.replace(" ", "").startsWith(