UNPKG

@dineug/erd-editor

Version:

Entity-Relationship Diagram Editor

1,743 lines (1,732 loc) 1.03 MB
var Qg = Object.defineProperty; var al = (e) => { throw TypeError(e); }; var qg = (e, t, n) => t in e ? Qg(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var Yr = (e, t, n) => qg(e, typeof t != "symbol" ? t + "" : t, n), Jg = (e, t, n) => t.has(e) || al("Cannot " + n); var dr = (e, t, n) => (Jg(e, t, "read from private field"), n ? n.call(e) : t.get(e)), sl = (e, t, n) => t.has(e) ? al("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n); import { c as zu, b as Kg, _ as ro, a as ii, S as e0, O as ft, i as t0, o as Ao, d as Vu, e as Zn, f as En, g as Tn, h as n0, r as r0, j as i0, k as Pu, l as o0, m as a0, n as s0, p as c0, q as l0, s as qn, t as Bu, u as u0, v as ju, w as Qt, x as d0, y as h0, z as cs, R as To, A as W, B as We, C as f0, D as m0, E as p0, F as Ma, H as g0, G as v0, I as y0, J as ls, K as b0, L as x0, M as k0, N as $0, P as w0, Q as C0, T as Un, U as Fu, V as A0, W as T0, X as yt, Y as S0, Z as I0, $ as Ee, a0 as E0, a1 as Hu, a2 as Uu, a3 as M0, a4 as Be, a5 as Pe, a6 as ye, a7 as _i, a8 as gr, a9 as vr, aa as Fe, ab as rt, ac as N0, ad as cl, ae as R, af as U, ag as et, ah as O0, ai as ie, aj as D0, ak as ll, al as _0, am as _e, an as L0, ao as nr, ap as Yu, aq as R0, ar as z0, as as V0, at as ul, au as So, av as us, aw as Mr, ax as Io, ay as Gu, az as qt, aA as sn, aB as Jt, aC as C, aD as da, aE as dl, aF as hl, aG as Xi, aH as P0, aI as yr, aJ as br, aK as Wu, aL as B0, aM as j0, aN as Ge, aO as ue, aP as Br, aQ as He, aR as qe, aS as je, aT as F0, aU as H0, aV as Sn, aW as fl, aX as re, aY as Eo, aZ as Nr, a_ as U0, a$ as Y0, b0 as Zu, b1 as ve, b2 as Ce, b3 as ds, b4 as Mo, b5 as G0, b6 as Xu, b7 as io, b8 as Na, b9 as hs, ba as W0, bb as fs, bc as No, bd as Qu, be as Z0, bf as X0, bg as Q0, bh as q0, bi as J0, bj as K0, bk as e1, bl as qu, bm as Qr, bn as Jn, bo as Ar, bp as ri, bq as Or, br as Ju, bs as pi, bt as cn, bu as oi, bv as rr, bw as t1, bx as Qi, by as Ku, bz as ct, bA as n1, bB as Oo, bC as oo, bD as r1, bE as ao, bF as Oa, bG as ms, bH as ed, bI as td, bJ as Tr, bK as i1, bL as so, bM as vt, bN as Yn, bO as nd, bP as rd, bQ as id, bR as ps, bS as o1, bT as a1, bU as s1, bV as od, bW as c1, bX as gs, bY as vs, bZ as ml, b_ as ad, b$ as l1, c0 as Xn, c1 as u1, c2 as d1, c3 as h1, c4 as f1, c5 as m1, c6 as p1, c7 as g1, c8 as v1, c9 as Lt, ca as sd, cb as Ie, cc as cd, cd as ld, ce as y1, cf as b1, cg as x1, ch as Do, ci as Li, cj as ud, ck as k1, cl as ys, cm as Tt, cn as dd, co as hd, cp as de, cq as pl, cr as $1, cs as w1, ct as C1, cu as A1, cv as T1, cw as gl, cx as S1, cy as I1, cz as E1, cA as M1, cB as N1, cC as mr, cD as ha, cE as Ri, cF as O1, cG as D1, cH as vl, cI as yl, cJ as bl, cK as _1, cL as L1, cM as R1, cN as Pt, cO as z1, cP as V1, cQ as Da, cR as xl, cS as P1, cT as B1, cU as j1, cV as F1, cW as H1, cX as U1, cY as Y1, cZ as G1, c_ as kl, c$ as W1, d0 as Z1, d1 as $l, d2 as X1, d3 as fd, d4 as Q1, d5 as q1, d6 as zi, d7 as J1, d8 as K1, d9 as ev, da as tv, db as nv } from "./schemaGCService-CLe8cLsy.js"; /*! * @dineug/erd-editor * @version 3.3.0 | Wed May 07 2025 * @author SeungHwan-Lee <dineug2@gmail.com> * @license MIT */ var rv = zu(function(e, t, n) { return e + (n ? "-" : "") + t.toLowerCase(); }); function fa(e, t, n) { return e == null ? e : Kg(e, t, n); } var iv = zu(function(e, t, n) { return e + (n ? "_" : "") + t.toLowerCase(); }), md = { now: function() { return (md.delegate || performance).now(); }, delegate: void 0 }, wl = { schedule: function(e) { var t = requestAnimationFrame, n = cancelAnimationFrame, r = t(function(a) { n = void 0, e(a); }); return new e0(function() { return n == null ? void 0 : n(r); }); }, requestAnimationFrame: function() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t]; return requestAnimationFrame.apply(void 0, ro([], ii(e))); }, cancelAnimationFrame: function() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t]; return cancelAnimationFrame.apply(void 0, ro([], ii(e))); }, delegate: void 0 }; function ov(e) { return e ? pd() : av; } function pd(e) { return new ft(function(t) { var n = md, r = n.now(), a = 0, c = function() { t.closed || (a = wl.requestAnimationFrame(function(l) { a = 0; var h = n.now(); t.next({ timestamp: l, elapsed: h - r }), c(); })); }; return c(), function() { a && wl.cancelAnimationFrame(a); }; }); } var av = pd(), sv = new ft(function(e) { return e.complete(); }); function gd(e) { return e[e.length - 1]; } function cv(e) { return t0(gd(e)) ? e.pop() : void 0; } function lv(e, t) { return typeof gd(e) == "number" ? e.pop() : t; } function vd(e, t) { return t === void 0 && (t = 0), Ao(function(n, r) { n.subscribe(Vu(r, function(a) { return Zn(r, e, function() { return r.next(a); }, t); }, function() { return Zn(r, e, function() { return r.complete(); }, t); }, function(a) { return Zn(r, e, function() { return r.error(a); }, t); })); }); } function yd(e, t) { return t === void 0 && (t = 0), Ao(function(n, r) { r.add(e.schedule(function() { return n.subscribe(r); }, t)); }); } function uv(e, t) { return En(e).pipe(yd(t), vd(t)); } function dv(e, t) { return En(e).pipe(yd(t), vd(t)); } function hv(e, t) { return new ft(function(n) { var r = 0; return t.schedule(function() { r === e.length ? n.complete() : (n.next(e[r++]), n.closed || this.schedule()); }); }); } function fv(e, t) { return new ft(function(n) { var r; return Zn(n, t, function() { r = e[n0](), Zn(n, t, function() { var a, c, l; try { a = r.next(), c = a.value, l = a.done; } catch (h) { n.error(h); return; } l ? n.complete() : n.next(c); }, 0, !0); }), function() { return Tn(r == null ? void 0 : r.return) && r.return(); }; }); } function bd(e, t) { if (!e) throw new Error("Iterable cannot be null"); return new ft(function(n) { Zn(n, t, function() { var r = e[Symbol.asyncIterator](); Zn(n, t, function() { r.next().then(function(a) { a.done ? n.complete() : n.next(a.value); }); }, 0, !0); }); }); } function mv(e, t) { return bd(r0(e), t); } function pv(e, t) { if (e != null) { if (i0(e)) return uv(e, t); if (Pu(e)) return hv(e, t); if (o0(e)) return dv(e, t); if (a0(e)) return bd(e, t); if (s0(e)) return fv(e, t); if (c0(e)) return mv(e, t); } throw l0(e); } function gv(e, t) { return t ? pv(e, t) : En(e); } var vv = Array.isArray; function yv(e, t) { return vv(t) ? e.apply(void 0, ro([], ii(t))) : e(t); } function bv(e) { return qn(function(t) { return yv(e, t); }); } function xv(e) { return e === void 0 && (e = 1 / 0), Bu(u0, e); } var kv = ["addListener", "removeListener"], $v = ["addEventListener", "removeEventListener"], wv = ["on", "off"]; function lt(e, t, n, r) { if (Tn(n) && (r = n, n = void 0), r) return lt(e, t, n).pipe(bv(r)); var a = ii(Tv(e) ? $v.map(function(h) { return function(f) { return e[h](t, f, n); }; }) : Cv(e) ? kv.map(Cl(e, t)) : Av(e) ? wv.map(Cl(e, t)) : [], 2), c = a[0], l = a[1]; if (!c && Pu(e)) return Bu(function(h) { return lt(h, t, n); })(En(e)); if (!c) throw new TypeError("Invalid event target"); return new ft(function(h) { var f = function() { for (var m = [], p = 0; p < arguments.length; p++) m[p] = arguments[p]; return h.next(1 < m.length ? m : m[0]); }; return c(f), function() { return l(f); }; }); } function Cl(e, t) { return function(n) { return function(r) { return e[n](t, r); }; }; } function Cv(e) { return Tn(e.addListener) && Tn(e.removeListener); } function Av(e) { return Tn(e.on) && Tn(e.off); } function Tv(e) { return Tn(e.addEventListener) && Tn(e.removeEventListener); } function Dr() { for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t]; var n = cv(e), r = lv(e, 1 / 0), a = e; return a.length ? a.length === 1 ? En(a[0]) : xv(r)(gv(a, n)) : sv; } function Sv(e) { e === void 0 && (e = {}); var t = e.connector, n = t === void 0 ? function() { return new Qt(); } : t, r = e.resetOnError, a = r === void 0 ? !0 : r, c = e.resetOnComplete, l = c === void 0 ? !0 : c, h = e.resetOnRefCountZero, f = h === void 0 ? !0 : h; return function(m) { var p, v, b, y = 0, k = !1, w = !1, A = function() { v == null || v.unsubscribe(), v = void 0; }, S = function() { A(), p = b = void 0, k = w = !1; }, E = function() { var L = p; S(), L == null || L.unsubscribe(); }; return Ao(function(L, I) { y++, !w && !k && A(); var j = b = b ?? n(); I.add(function() { y--, y === 0 && !w && !k && (v = ma(E, f)); }), j.subscribe(I), !p && y > 0 && (p = new ju({ next: function(z) { return j.next(z); }, error: function(z) { w = !0, A(), v = ma(S, a, z), j.error(z); }, complete: function() { k = !0, A(), v = ma(S, l), j.complete(); } }), En(L).subscribe(p)); })(m); }; } function ma(e, t) { for (var n = [], r = 2; r < arguments.length; r++) n[r - 2] = arguments[r]; if (t === !0) { e(); return; } if (t !== !1) { var a = new ju({ next: function() { a.unsubscribe(), e(); } }); return En(t.apply(void 0, ro([], ii(n)))).subscribe(a); } } function xd(e) { return Ao(function(t, n) { En(e).subscribe(Vu(n, function() { return n.complete(); }, d0)), !n.closed && t.subscribe(n); }); } function kd({ notify: e, dispatch: t }, n) { let r = (n == null ? void 0 : n.commands) ?? [], a = (n == null ? void 0 : n.cursor) ?? -1, c = (n == null ? void 0 : n.limit) ?? 0, l = !0; const h = () => a !== -1, f = () => a < r.length - 1, m = (S) => c = S, p = () => ({ hasRedo: f(), hasUndo: h() }), v = (S, E) => { l = !1, S[E](t), l = !0; }; return Object.freeze({ get cursor() { return a; }, get size() { return r.length; }, hasUndo: h, hasRedo: f, push: (S) => { l && (r.splice(a + 1, r.length - a), r.push(S), c !== 0 && r.length > c && (r = r.slice(r.length - c, r.length)), a = r.length - 1, e(p())); }, undo: () => { if (!h()) return; const S = r[a]; v(S, "undo"), a--, e(p()); }, redo: () => { if (!f()) return; const S = r[a + 1]; v(S, "redo"), a++, e(p()); }, clear: () => { const S = r.length; r = [], a = -1, S > 0 && e(p()); }, setLimit: m, clone: (S) => kd(S, { commands: [...r], cursor: a, limit: c }) }); } const Iv = (e, t) => (n) => n.pipe( h0( new ft((r) => { let a = !1; const c = n.subscribe(() => { a && r.next(); }); return c.add( e.subscribe(() => { a || (a = !0, r.next()); }) ), c.add( t.subscribe(() => { a = !1; }) ), c; }) ), qn((r) => r.flat()), cs ), $d = (e) => { const t = (n) => To(n.tags) || !e.some((r) => W(n.tags, r)); return (n) => new ft( (r) => n.subscribe({ next: (a) => r.next(a.filter(t)), error: (a) => r.error(a), complete: () => r.complete() }) ).pipe(cs); }, pa = (e, t = []) => { const n = We(f0), r = (a) => !To(a.tags) && t.some((c) => W(a.tags, c)) || !n(a.type); return (a) => new ft( (c) => a.subscribe({ next: (l) => { c.next(e() ? l.filter(r) : l); }, error: (l) => c.error(l), complete: () => c.complete() }) ).pipe(cs); }, bs = 2048; function Ev(e, { getReadonly: t = () => !1, getHistory: n } = {}) { const r = /* @__PURE__ */ new Set(), a = m0(e), c = p0(a), l = { notify: (E) => a.dispatch(x0(E)), dispatch: a.dispatchSync }, h = (n == null ? void 0 : n(l)) ?? kd(l); h.setLimit(bs); const f = new Qt(), m = f.pipe( Ma(g0), $d([Un.changeOnly, Un.shared]), pa(t), v0(C0, [ ["@@move", k0], ["@@scroll", $0], ["@@color", w0] ]) ), p = new ft( (E) => a.subscribe((L) => E.next(L)) ).pipe( Ma(y0), pa(t, [Un.shared]), ls(200) ), v = (...E) => { const L = e.clock.getNextVersion(); return T0( a.state, a.context, E ).map((I) => (To(I.version) && (I.version = L), I)); }, b = (...E) => { const L = v(E); f.next(L); }, y = (...E) => { A0(() => b(E)); }, k = () => { Array.from(r).forEach( (E) => Fu(E) ? E() : E.unsubscribe() ), r.clear(), a.destroy(), c.destroy(), h.clear(), f.complete(); }, w = () => { t() || h.undo(); }, A = () => { t() || h.redo(); }, S = () => a.subscribe((E) => { E.forEach((L) => e.clock.merge(L.version)); }); return r.add(m.subscribe(b0(a, h))).add( f.pipe(pa(t, [Un.shared])).subscribe(a.dispatchSync) ).add(S()), Object.freeze({ ...a, dispatch: y, dispatchSync: b, destroy: k, undo: w, redo: A, history: h, change$: p }); } const bt = { openColorPicker: "openColorPicker", closeColorPicker: "closeColorPicker", openToast: "openToast", loadShikiService: "loadShikiService", openTableProperties: "openTableProperties", dragendColumnAll: "dragendColumnAll", copy: "copy", paste: "paste", schemaGC: "schemaGC", toggleSearch: "toggleSearch", openThemeBuilder: "openThemeBuilder", setThemeOptions: "setThemeOptions", mouseTrackerStart: "mouseTrackerStart", mouseTrackerEnd: "mouseTrackerEnd", openDiffViewer: "openDiffViewer" }; var wn; class wd { constructor() { sl(this, wn, /* @__PURE__ */ new Set()); } on(t) { return dr(this, wn).has(t) || dr(this, wn).add(t), () => { dr(this, wn).delete(t); }; } emit(t) { dr(this, wn).forEach((n) => { const r = Reflect.get(n, t.type); S0(r, t); }); } clear() { dr(this, wn).clear(); } } wn = new WeakMap(); const _o = yt(bt.openColorPicker), Cd = yt(bt.closeColorPicker), un = yt(bt.openToast), Mv = yt(bt.loadShikiService), Ad = yt(bt.openTableProperties), Nv = yt(bt.dragendColumnAll), Ov = yt(bt.copy), Dv = yt(bt.paste), _v = yt(bt.schemaGC), Lv = yt(bt.toggleSearch), Rv = yt(bt.openThemeBuilder), ga = yt(bt.setThemeOptions), zv = yt(bt.mouseTrackerStart), Vv = yt(bt.mouseTrackerEnd), Td = yt(bt.openDiffViewer); function xs(e, t) { for (var n = e.length, r = 0; r < n; ++r) if (t(e[r], r)) return !0; return !1; } function Sd(e, t) { for (var n = e.length, r = 0; r < n; ++r) if (t(e[r], r)) return e[r]; return null; } function Id(e) { var t = e; if (typeof t > "u") { if (typeof navigator > "u" || !navigator) return ""; t = navigator.userAgent || ""; } return t.toLowerCase(); } function ks(e, t) { try { return new RegExp(e, "g").exec(t); } catch { return null; } } function Ed() { if (typeof navigator > "u" || !navigator || !navigator.userAgentData) return !1; var e = navigator.userAgentData, t = e.brands || e.uaList; return !!(t && t.length); } function Pv(e, t) { var n = ks("(" + e + ")((?:\\/|\\s|:)([0-9|\\.|_]+))", t); return n ? n[3] : ""; } function _a(e) { return e.replace(/_/g, "."); } function qr(e, t) { var n = null, r = "-1"; return xs(e, function(a) { var c = ks("(" + a.test + ")((?:\\/|\\s|:)([0-9|\\.|_]+))?", t); return !c || a.brand ? !1 : (n = a, r = c[3] || "-1", a.versionAlias ? r = a.versionAlias : a.versionTest && (r = Pv(a.versionTest.toLowerCase(), t) || r), r = _a(r), !0); }), { preset: n, version: r }; } function Gr(e, t) { var n = { brand: "", version: "-1" }; return xs(e, function(r) { var a = Md(t, r); return a ? (n.brand = r.id, n.version = r.versionAlias || a.version, n.version !== "-1") : !1; }), n; } function Md(e, t) { return Sd(e, function(n) { var r = n.brand; return ks("" + t.test, r.toLowerCase()); }); } var La = [{ test: "phantomjs", id: "phantomjs" }, { test: "whale", id: "whale" }, { test: "edgios|edge|edg", id: "edge" }, { test: "msie|trident|windows phone", id: "ie", versionTest: "iemobile|msie|rv" }, { test: "miuibrowser", id: "miui browser" }, { test: "samsungbrowser", id: "samsung internet" }, { test: "samsung", id: "samsung internet", versionTest: "version" }, { test: "chrome|crios", id: "chrome" }, { test: "firefox|fxios", id: "firefox" }, { test: "android", id: "android browser", versionTest: "version" }, { test: "safari|iphone|ipad|ipod", id: "safari", versionTest: "version" }], Nd = [{ test: "(?=.*applewebkit/(53[0-7]|5[0-2]|[0-4]))(?=.*\\schrome)", id: "chrome", versionTest: "chrome" }, { test: "chromium", id: "chrome" }, { test: "whale", id: "chrome", versionAlias: "-1", brand: !0 }], Ra = [{ test: "applewebkit", id: "webkit", versionTest: "applewebkit|safari" }], Od = [{ test: "(?=(iphone|ipad))(?!(.*version))", id: "webview" }, { test: "(?=(android|iphone|ipad))(?=.*(naver|daum|; wv))", id: "webview" }, { // test webview test: "webview", id: "webview" }], Dd = [{ test: "windows phone", id: "windows phone" }, { test: "windows 2000", id: "window", versionAlias: "5.0" }, { test: "windows nt", id: "window" }, { test: "win32|windows", id: "window" }, { test: "iphone|ipad|ipod", id: "ios", versionTest: "iphone os|cpu os" }, { test: "macos|macintel|mac os x", id: "mac" }, { test: "android|linux armv81", id: "android" }, { test: "tizen", id: "tizen" }, { test: "webos|web0s", id: "webos" }]; function _d(e) { return !!qr(Od, e).preset; } function Bv(e) { var t = Id(e), n = !!/mobi/g.exec(t), r = { name: "unknown", version: "-1", majorVersion: -1, webview: _d(t), chromium: !1, chromiumVersion: "-1", webkit: !1, webkitVersion: "-1" }, a = { name: "unknown", version: "-1", majorVersion: -1 }, c = qr(La, t), l = c.preset, h = c.version, f = qr(Dd, t), m = f.preset, p = f.version, v = qr(Nd, t); if (r.chromium = !!v.preset, r.chromiumVersion = v.version, !r.chromium) { var b = qr(Ra, t); r.webkit = !!b.preset, r.webkitVersion = b.version; } return m && (a.name = m.id, a.version = p, a.majorVersion = parseInt(p, 10)), l && (r.name = l.id, r.version = h, r.webview && a.name === "ios" && r.name !== "safari" && (r.webview = !1)), r.majorVersion = parseInt(r.version, 10), { browser: r, os: a, isMobile: n, isHints: !1 }; } function Ld(e) { var t = navigator.userAgentData, n = (t.uaList || t.brands).slice(), r = e && e.fullVersionList, a = t.mobile || !1, c = n[0], l = (e && e.platform || t.platform || navigator.platform).toLowerCase(), h = { name: c.brand, version: c.version, majorVersion: -1, webkit: !1, webkitVersion: "-1", chromium: !1, chromiumVersion: "-1", webview: !!Gr(Od, n).brand || _d(Id()) }, f = { name: "unknown", version: "-1", majorVersion: -1 }; h.webkit = !h.chromium && xs(Ra, function(k) { return Md(n, k); }); var m = Gr(Nd, n); if (h.chromium = !!m.brand, h.chromiumVersion = m.version, !h.chromium) { var p = Gr(Ra, n); h.webkit = !!p.brand, h.webkitVersion = p.version; } var v = Sd(Dd, function(k) { return new RegExp("" + k.test, "g").exec(l); }); if (f.name = v ? v.id : "", e && (f.version = e.platformVersion), r && r.length) { var b = Gr(La, r); h.name = b.brand || h.name, h.version = b.version || h.version; } else { var y = Gr(La, n); h.name = y.brand || h.name, h.version = y.brand && e ? e.uaFullVersion : y.version; } return h.webkit && (f.name = a ? "ios" : "mac"), f.name === "ios" && h.webview && (h.version = "-1"), f.version = _a(f.version), h.version = _a(h.version), f.majorVersion = parseInt(f.version, 10), h.majorVersion = parseInt(h.version, 10), { browser: h, os: f, isMobile: a, isHints: !0 }; } function jv(e) { return Ed() ? navigator.userAgentData.getHighEntropyValues(["architecture", "model", "platform", "platformVersion", "uaFullVersion", "fullVersionList"]).then(function(t) { var n = Ld(t); return e && e(n), n; }) : (e && e(za()), typeof Promise > "u" || !Promise ? null : Promise.resolve(za())); } function za(e) { return Ed() ? Ld() : Bv(e); } const ir = za(); let Rd = ir.os.name === "mac", zd = ir.os.name === "ios"; ir.os.name; ir.os.name; ir.browser.name; ir.browser.name; ir.browser.name; jv((e) => { Rd = e.os.name === "mac", zd = e.os.name === "ios", e.os.name, e.os.name, e.browser.name, e.browser.name, e.browser.name; }); const $s = () => Rd || zd; function Fv(e) { const t = $s() ? "Meta" : "Control"; return e.trim().split(" ").map((n) => { let r = n.split(/\b\+/); const a = r.pop(); return r = r.map((c) => c === "$mod" ? t : c), [r, a]; }); } const q = { edit: "edit", stop: "stop", search: "search", undo: "undo", redo: "redo", addTable: "addTable", addColumn: "addColumn", addMemo: "addMemo", removeTable: "removeTable", removeColumn: "removeColumn", primaryKey: "primaryKey", selectAllTable: "selectAllTable", selectAllColumn: "selectAllColumn", relationshipZeroOne: "relationshipZeroOne", relationshipZeroN: "relationshipZeroN", relationshipOneOnly: "relationshipOneOnly", relationshipOneN: "relationshipOneN", tableProperties: "tableProperties", zoomIn: "zoomIn", zoomOut: "zoomOut" }, Hv = Object.values(q), Uv = () => ({ [q.edit]: [{ shortcut: "Enter" }], [q.stop]: [{ shortcut: "Escape" }], [q.search]: [ { shortcut: "$mod+KeyK", preventDefault: !0, stopPropagation: !0 } ], [q.undo]: [ { shortcut: "$mod+KeyZ", preventDefault: !0, stopPropagation: !0 } ], [q.redo]: [ { shortcut: "$mod+Shift+KeyZ", preventDefault: !0, stopPropagation: !0 } ], [q.addTable]: [{ shortcut: "Alt+KeyN", preventDefault: !0 }], [q.addColumn]: [{ shortcut: "Alt+Enter", preventDefault: !0 }], [q.addMemo]: [{ shortcut: "Alt+KeyM", preventDefault: !0 }], [q.removeTable]: [ { shortcut: "$mod+Backspace", preventDefault: !0 }, { shortcut: "$mod+Delete", preventDefault: !0 } ], [q.removeColumn]: [ { shortcut: "Alt+Backspace", preventDefault: !0 }, { shortcut: "Alt+Delete", preventDefault: !0 } ], [q.primaryKey]: [{ shortcut: "Alt+KeyK", preventDefault: !0 }], [q.selectAllTable]: [ { shortcut: "$mod+Alt+KeyA", preventDefault: !0 } ], [q.selectAllColumn]: [ { shortcut: "Alt+KeyA", preventDefault: !0 } ], [q.relationshipZeroOne]: [ { shortcut: "$mod+Alt+Digit1", preventDefault: !0 } ], [q.relationshipZeroN]: [ { shortcut: "$mod+Alt+Digit2", preventDefault: !0 } ], [q.relationshipOneOnly]: [ { shortcut: "$mod+Alt+Digit3", preventDefault: !0 } ], [q.relationshipOneN]: [ { shortcut: "$mod+Alt+Digit4", preventDefault: !0 } ], [q.tableProperties]: [ { shortcut: "Alt+Space", preventDefault: !0 } ], [q.zoomIn]: [ { shortcut: "$mod+Equal", preventDefault: !0, stopPropagation: !0 } ], [q.zoomOut]: [ { shortcut: "$mod+Minus", preventDefault: !0, stopPropagation: !0 } ] }), Cn = { Shift: "Shift", Meta: "Meta", Alt: "Alt", Control: "Control" }, Yv = { [Cn.Shift]: "⇧", // Shift [Cn.Meta]: "⌘", // Cmd [Cn.Alt]: "⌥", // Option [Cn.Control]: "⌃" // Ctrl }, Gv = { [Cn.Shift]: "Shift", [Cn.Meta]: "Cmd", [Cn.Alt]: "Alt", [Cn.Control]: "Ctrl" }; function Wv(e) { return ($s() ? Yv : Gv)[e] ?? e; } function Zv(e) { return e.startsWith("Key") ? e.slice(3) : e.startsWith("Digit") ? e.slice(5) : e === "Backspace" ? "⌫" : e === "Escape" ? "ESC" : e === "Equal" ? "Plus" : e; } function Vd(e) { return e ? Fv(e).map(([t, n]) => [ t.map(Wv), Zv(n) ]) : []; } function dn(e) { return $s() ? e.metaKey : e.ctrlKey; } function co(e) { return Vd(e).map(([t, n]) => [...t, n].join(" + ")).join(" "); } function ai(e, t) { const n = I0(e), r = Ev(n, t), a = Ee(Uv(), { shallow: !0 }), c = new Qt(), l = new Qt(), h = new wd(); return Object.freeze({ ...n, actions: E0, store: r, keyBindingMap: a, shortcut$: c, keydown$: l, emitter: h }); } const _r = Uu({}), le = (e, t) => Hu(e, { ..._r, value: t ?? _r.value }); function si(e) { e.store.dispatchSync(M0()), e.store.destroy(), e.keydown$.complete(), e.shortcut$.complete(), e.emitter.clear(); } function Xv(e) { return { path: Qv(e.start, e.end), line: qv(e.start, e.end) }; } function Qv(e, t) { const n = { start: { x1: e.x, y1: e.y, x2: e.x, y2: e.y }, end: { x1: t.x, y1: t.y, x2: t.x, y2: t.y } }, r = { M: { x: 0, y: 0 }, L: { x: 0, y: 0 }, Q: { x: 0, y: 0 }, d() { if (e.tableId === t.tableId) return [ [ { x: this.M.x, y: this.M.y }, { x: this.L.x, y: this.L.y } ] ]; const c = this.M.x - this.L.x, l = this.M.y - this.L.y, h = c / 2, f = l / 2, m = Math.abs(l) <= Math.abs(c), p = Math.abs(m ? f : h), v = Jv(p), b = v(!0), y = v(!1), k = b(c), w = b(l), A = y(c), S = y(l), E = m ? this.M.x - h + k : this.M.x, L = m ? this.M.y : this.M.y - f + w, I = m ? this.L.x + h + A : this.L.x, j = m ? this.L.y : this.L.y + f + S; return [ [ { x: this.M.x, y: this.M.y }, { x: E, y: L } ], [ { x: E, y: L }, { x: I, y: j } ], [ { x: I, y: j }, { x: this.L.x, y: this.L.y } ] ]; } }; let a = 1; return e.direction === Be.left || e.direction === Be.right ? (e.direction === Be.left && (a *= -1), n.start.x2 = e.x + a * gr, n.start.x1 += a * vr, r.M.x = n.start.x2, r.M.y = e.y) : (e.direction === Be.top || e.direction === Be.bottom) && (e.direction === Be.top && (a *= -1), n.start.y2 = e.y + a * gr, n.start.y1 += a * vr, r.M.x = e.x, r.M.y = n.start.y2), a = 1, t.direction === Be.left || t.direction === Be.right ? (t.direction === Be.left && (a *= -1), n.end.x2 = t.x + a * gr, n.end.x1 += a * vr, r.L.x = n.end.x2, r.L.y = t.y) : (t.direction === Be.top || t.direction === Be.bottom) && (t.direction === Be.top && (a *= -1), n.end.y2 = t.y + a * gr, n.end.y1 += a * vr, r.L.x = t.x, r.L.y = n.end.y2), { line: n, path: r }; } function qv(e, t) { const n = { start: { base: { x1: e.x, y1: e.y, x2: e.x, y2: e.y }, base2: { x1: e.x, y1: e.y, x2: e.x, y2: e.y }, center: { x1: e.x, y1: e.y, x2: e.x, y2: e.y }, center2: { x1: e.x, y1: e.y, x2: e.x, y2: e.y } }, end: { base: { x1: t.x, y1: t.y, x2: t.x, y2: t.y }, base2: { x1: t.x, y1: t.y, x2: t.x, y2: t.y }, left: { x1: t.x, y1: t.y, x2: t.x, y2: t.y }, center: { x1: t.x, y1: t.y, x2: t.x, y2: t.y }, center2: { x1: t.x, y1: t.y, x2: t.x, y2: t.y }, right: { x1: t.x, y1: t.y, x2: t.x, y2: t.y } } }, r = { cx: t.x, cy: t.y }, a = { cx: e.x, cy: e.y }; let c = 1; return e.direction === Be.left || e.direction === Be.right ? (e.direction === Be.left && (c *= -1), n.start.base.x1 = n.start.base.x2 += c * Pe, n.start.base2.x1 = n.start.base2.x2 += c * (ye + Pe), n.start.center.x1 = n.start.base.x1, n.start.base.y1 -= ye, n.start.base.y2 += ye, n.start.base2.y1 -= ye, n.start.base2.y2 += ye, n.start.center2.x1 += c * (Pe + Pe + 3), a.cx += c * _i) : (e.direction === Be.top || e.direction === Be.bottom) && (e.direction === Be.top && (c *= -1), n.start.base.y1 = n.start.base.y2 += c * Pe, n.start.base2.y1 = n.start.base2.y2 += c * (ye + Pe), n.start.center.y1 = n.start.base.y1, n.start.base.x1 -= ye, n.start.base.x2 += ye, n.start.base2.x1 -= ye, n.start.base2.x2 += ye, n.start.center2.y1 += c * (Pe + Pe + 3), a.cy += c * _i), c = 1, t.direction === Be.left || t.direction === Be.right ? (t.direction === Be.left && (c *= -1), n.end.base.x1 = n.end.base.x2 += c * Pe, n.end.base2.x1 = n.end.base2.x2 += c * (ye + Pe), n.end.center.x1 = n.end.left.x1 = n.end.right.x1 = n.end.base.x1, n.end.base.y1 -= ye, n.end.base.y2 += ye, n.end.base2.y1 -= ye, n.end.base2.y2 += ye, n.end.left.y2 += ye, n.end.right.y2 -= ye, n.end.center2.x1 += c * (Pe + Pe + 3), r.cx += c * _i) : (t.direction === Be.top || t.direction === Be.bottom) && (t.direction === Be.top && (c *= -1), n.end.base.y1 = n.end.base.y2 += c * Pe, n.end.base2.y1 = n.end.base2.y2 += c * (ye + Pe), n.end.center.y1 = n.end.left.y1 = n.end.right.y1 = n.end.base.y1, n.end.base.x1 -= ye, n.end.base.x2 += ye, n.end.base2.x1 -= ye, n.end.base2.x2 += ye, n.end.left.x2 += ye, n.end.right.x2 -= ye, n.end.center2.y1 += c * (Pe + Pe + 3), r.cy += c * _i), { line: n, circle: r, startCircle: a }; } function Jv(e) { return (t) => (n) => n < 0 ? (t ? -1 : 1) * e : (t ? 1 : -1) * e; } const Kv = ({ path: e, line: t }) => rt` <line x1=${e.line.end.x1} y1=${e.line.end.y1} x2=${e.line.end.x2} y2=${e.line.end.y2} stroke-width="3" ></line> <circle cx=${t.circle.cx} cy=${t.circle.cy} r="8" fill-opacity="0.0" stroke-width="3" ></circle> <line x1=${t.line.end.base.x1} y1=${t.line.end.base.y1} x2=${t.line.end.base.x2} y2=${t.line.end.base.y2} stroke-width="3" ></line> <line x1=${t.line.end.left.x1} y1=${t.line.end.left.y1} x2=${t.line.end.left.x2} y2=${t.line.end.left.y2} stroke-width="3" ></line> <line x1=${t.line.end.center.x1} y1=${t.line.end.center.y1} x2=${t.line.end.center.x2} y2=${t.line.end.center.y2} stroke-width="3" ></line> <line x1=${t.line.end.right.x1} y1=${t.line.end.right.y1} x2=${t.line.end.right.x2} y2=${t.line.end.right.y2} stroke-width="3" ></line> `, ey = ({ path: e, line: t }) => rt` <line x1=${e.line.end.x1} y1=${e.line.end.y1} x2=${e.line.end.x2} y2=${e.line.end.y2} stroke-width="3" ></line> <circle cx=${t.circle.cx} cy=${t.circle.cy} r="8" fill-opacity="0.0" stroke-width="3" ></circle> <line x1=${t.line.end.base.x1} y1=${t.line.end.base.y1} x2=${t.line.end.base.x2} y2=${t.line.end.base.y2} stroke-width="3" ></line> <line x1=${t.line.end.center.x1} y1=${t.line.end.center.y1} x2=${t.line.end.center.x2} y2=${t.line.end.center.y2} stroke-width="3" ></line> `, ty = ({ path: e, line: t }) => rt` <line x1=${e.line.end.x1} y1=${e.line.end.y1} x2=${e.line.end.x2} y2=${e.line.end.y2} stroke-width="3" ></line> <circle cx=${t.circle.cx} cy=${t.circle.cy} r="8" fill-opacity="0.0" stroke-width="3" ></circle> <line x1=${t.line.end.left.x1} y1=${t.line.end.left.y1} x2=${t.line.end.left.x2} y2=${t.line.end.left.y2} stroke-width="3" ></line> <line x1=${t.line.end.center.x1} y1=${t.line.end.center.y1} x2=${t.line.end.center.x2} y2=${t.line.end.center.y2} stroke-width="3" ></line> <line x1=${t.line.end.right.x1} y1=${t.line.end.right.y1} x2=${t.line.end.right.x2} y2=${t.line.end.right.y2} stroke-width="3" ></line> `, ny = ({ path: e, line: t }) => rt` <line x1=${e.line.end.x1} y1=${e.line.end.y1} x2=${e.line.end.x2} y2=${e.line.end.y2} stroke-width="3" ></line> <line x1=${t.line.end.base.x1} y1=${t.line.end.base.y1} x2=${t.line.end.base.x2} y2=${t.line.end.base.y2} stroke-width="3" ></line> <line x1=${t.line.end.base2.x1} y1=${t.line.end.base2.y1} x2=${t.line.end.base2.x2} y2=${t.line.end.base2.y2} stroke-width="3" ></line> <line x1=${t.line.end.center2.x1} y1=${t.line.end.center2.y1} x2=${t.line.end.center2.x2} y2=${t.line.end.center2.y2} stroke-width="3" ></line> `, ry = ({ path: e, line: t }) => rt` <line x1=${e.line.end.x1} y1=${e.line.end.y1} x2=${e.line.end.x2} y2=${e.line.end.y2} stroke-width="3" ></line> <line x1=${t.line.end.base.x1} y1=${t.line.end.base.y1} x2=${t.line.end.base.x2} y2=${t.line.end.base.y2} stroke-width="3" ></line> <line x1=${t.line.end.left.x1} y1=${t.line.end.left.y1} x2=${t.line.end.left.x2} y2=${t.line.end.left.y2} stroke-width="3" ></line> <line x1=${t.line.end.center2.x1} y1=${t.line.end.center2.y1} x2=${t.line.end.center2.x2} y2=${t.line.end.center2.y2} stroke-width="3" ></line> <line x1=${t.line.end.right.x1} y1=${t.line.end.right.y1} x2=${t.line.end.right.x2} y2=${t.line.end.right.y2} stroke-width="3" ></line> `, iy = ({ path: e, line: t }) => rt` <line x1=${e.line.end.x1} y1=${e.line.end.y1} x2=${e.line.end.x2} y2=${e.line.end.y2} stroke-width="3" ></line> <line x1=${t.line.end.base.x1} y1=${t.line.end.base.y1} x2=${t.line.end.base.x2} y2=${t.line.end.base.y2} stroke-width="3" ></line> <line x1=${t.line.end.center2.x1} y1=${t.line.end.center2.y1} x2=${t.line.end.center2.x2} y2=${t.line.end.center2.y2} stroke-width="3" ></line> `, oy = ({ path: e, line: t }) => rt` <line x1=${e.line.end.x1} y1=${e.line.end.y1} x2=${e.line.end.x2} y2=${e.line.end.y2} stroke-width="3" ></line> <line x1=${t.line.end.left.x1} y1=${t.line.end.left.y1} x2=${t.line.end.left.x2} y2=${t.line.end.left.y2} stroke-width="3" ></line> <line x1=${t.line.end.center2.x1} y1=${t.line.end.center2.y1} x2=${t.line.end.center2.x2} y2=${t.line.end.center2.y2} stroke-width="3" ></line> <line x1=${t.line.end.right.x1} y1=${t.line.end.right.y1} x2=${t.line.end.right.x2} y2=${t.line.end.right.y2} stroke-width="3" ></line> `, ay = { 1: Kv, [Fe.ZeroOne]: ey, [Fe.ZeroN]: ty, [Fe.OneOnly]: ny, [Fe.OneN]: ry, 32: iy, 64: oy }; function sy(e, t) { const n = ay[e]; return (n == null ? void 0 : n(t)) ?? null; } const cy = (e, t) => { const n = le(t), r = (c) => { const { store: l } = n.value; l.dispatch( cl({ columnIds: [ ...c.start.columnIds, ...c.end.columnIds ] }) ); }, a = () => { const { store: c } = n.value; c.dispatch(cl({ columnIds: [] })); }; return () => { const { store: c } = n.value, { editor: l } = c.state, { relationship: h, strokeWidth: f } = e, m = Xv(h), { path: p, line: v } = m, b = p.path.d(), y = sy( h.relationshipType, m ), k = !!l.hoverRelationshipMap[h.id]; return rt` <g class=${[ "relationship", { identification: h.identification } ]} data-id=${h.id} ?data-hover=${k} @mouseenter=${() => r(h)} @mouseleave=${a} > ${b.map( ([w, A]) => rt` <line x1=${w.x} y1=${w.y} x2=${A.x} y2=${A.y} stroke-dasharray=${h.identification ? 0 : 10} stroke-width=${f} fill="transparent" ></line> ` )} <line x1=${p.line.start.x1} y1=${p.line.start.y1} x2=${p.line.start.x2} y2=${p.line.start.y2} stroke-width="3" ></line> <line x1=${v.line.start.base.x1} y1=${v.line.start.base.y1} x2=${v.line.start.base.x2} y2=${v.line.start.base.y2} stroke-width="3" ></line> ${h.startRelationshipType === N0.ring ? rt` <circle cx=${v.startCircle.cx} cy=${v.startCircle.cy} r="8" fill-opacity="0.0" stroke-width="3" ></circle> <line x1=${v.line.start.center.x1} y1=${v.line.start.center.y1} x2=${v.line.start.center.x2} y2=${v.line.start.center.y2} stroke-width="3" ></line> ` : rt` <line x1=${v.line.start.base2.x1} y1=${v.line.start.base2.y1} x2=${v.line.start.base2.x2} y2=${v.line.start.base2.y2} stroke-width="3" ></line> <line x1=${v.line.start.center2.x1} y1=${v.line.start.center2.y1} x2=${v.line.start.center2.x2} y2=${v.line.start.center2.y2} stroke-width="3" ></line> `} ${y} </g> `; }; }, ly = R` position: absolute; top: 0; left: 0; overflow: visible; .relationship { stroke: var(--key-fk); } .relationship.identification { stroke: var(--key-pfk); } .relationship:hover, .relationship[data-hover], .relationship.identification[data-hover] { stroke: var(--relationship-hover); } `, Pd = (e, t) => { const n = le(t); return () => { const { store: r } = n.value, { settings: { width: a, height: c }, doc: { relationshipIds: l }, collections: h } = r.state, f = U(h).collection("relationshipEntities").selectByIds(l); return rt` <svg class=${[ly, e.class]} style=${{ width: `${a}px`, height: `${c}px`, "min-width": `${a}px`, "min-height": `${c}px` }} > ${et( f, (m) => m.id, (m) => rt`<${cy} relationship=${m} strokeWidth=${e.strokeWidth ?? 3} /> ` )} </svg> `; }; }; function $e() { const e = /* @__PURE__ */ new Set(), t = (...n) => { n.forEach((r) => e.add(r)); }; return O0(() => { Array.from(e).forEach( (n) => Fu(n) ? n() : n.unsubscribe() ), e.clear(); }), { addUnsubscribe: t }; } function uy(e, t) { const n = { path: { path: { M: { x: 0, y: 0 }, L: { x: 0, y: 0 }, Q: { x: 0, y: 0 }, d() { return `M ${this.M.x} ${this.M.y} L ${this.L.x} ${this.L.y}`; } }, line: { start: { x1: 0, y1: 0, x2: 0, y2: 0 } } }, line: { start: { base: { x1: 0, y1: 0, x2: 0, y2: 0 }, base2: { x1: 0, y1: 0, x2: 0, y2: 0 }, center: { x1: 0, y1: 0, x2: 0, y2: 0 }, center2: { x1: 0, y1: 0, x2: 0, y2: 0 } } } }; if (!t.start) return n; const r = dy(e, t); return n.path = hy(r, t), n.line = fy(r, t), n; } function dy(e, t) { let n = ie.bottom; if (!t.start) return n; const r = U(e.collections).collection("tableEntities").selectById(t.start.tableId); if (!r) return n; const a = D0(e, r); let c = ll(a.bottom, t.end); return t.start.x = a.bottom.x, t.start.y = a.bottom.y, _0.forEach((l) => { const h = l, f = ll(a[h], t.end); c <= f || (c = f, n = h, t.start && (t.start.x = a[h].x, t.start.y = a[h].y)); }), n; } function hy(e, t) { const n = { start: { x1: 0, y1: 0, x2: 0, y2: 0 } }, r = { M: { x: 0, y: 0 }, L: { x: 0, y: 0 }, Q: { x: 0, y: 0 }, d() { return `M ${this.M.x} ${this.M.y} L ${this.L.x} ${this.L.y}`; } }; if (t.start) { n.start.x1 = t.start.x, n.start.y1 = t.start.y, n.start.x2 = t.start.x, n.start.y2 = t.start.y; let a = 1; e === ie.left || e === ie.right ? (e === ie.left && (a *= -1), n.start.x2 = t.start.x + a * gr, n.start.x1 += a * vr, r.M.x = n.start.x2, r.M.y = t.start.y) : (e === ie.top || e === ie.bottom) && (e === ie.top && (a *= -1), n.start.y2 = t.start.y + a * gr, n.start.y1 += a * vr, r.M.x = t.start.x, r.M.y = n.start.y2); } return r.L.x = t.end.x, r.L.y = t.end.y, { path: r, line: n }; } function fy(e, t) { const n = { start: { base: { x1: 0, y1: 0, x2: 0, y2: 0 }, base2: { x1: 0, y1: 0, x2: 0, y2: 0 }, center: { x1: 0, y1: 0, x2: 0, y2: 0 }, center2: { x1: 0, y1: 0, x2: 0, y2: 0 } } }; if (!t.start) return n; n.start.base.x1 = n.start.base2.x1 = n.start.center.x1 = n.start.center2.x1 = t.start.x, n.start.base.x2 = n.start.base2.x2 = n.start.center.x2 = n.start.center2.x2 = t.start.x, n.start.base.y1 = n.start.base2.y1 = n.start.center.y1 = n.start.center2.y1 = t.start.y, n.start.base.y2 = n.start.base2.y2 = n.start.center.y2 = n.start.center2.y2 = t.start.y; let r = 1; return e === ie.left || e === ie.right ? (e === ie.left && (r *= -1), n.start.base.x1 = n.start.base.x2 += r * Pe, n.start.base2.x1 = n.start.base2.x2 += r * (ye + Pe), n.start.center.x1 = n.start.base.x1, n.start.base.y1 -= ye, n.start.base.y2 += ye, n.start.base2.y1 -= ye, n.start.base2.y2 += ye, n.start.center2.x1 += r * (Pe + Pe + 3)) : (e === ie.top || e === ie.bottom) && (e === ie.top && (r *= -1), n.start.base.y1 = n.start.base.y2 += r * Pe, n.start.base2.y1 = n.start.base2.y2 += r * (ye + Pe), n.start.center.y1 = n.start.base.y1, n.start.base.x1 -= ye, n.start.base.x2 += ye, n.start.base2.x1 -= ye, n.start.base2.x2 += ye, n.start.center2.y1 += r * (Pe + Pe + 3)), n; } const my = R` position: absolute; top: 0; left: 0; pointer-events: none; stroke: var(--key-fk); overflow: visible; `, py = (e, t) => { const n = le(t), { addUnsubscribe: r } = $e(); return _e(() => { const a = e.root.value, { store: c } = n.value; r( lt(a, "mousemove").subscribe((l) => { l.preventDefault(); const { x: h, y: f } = a.getBoundingClientRect(); c.dispatch( L0({ x: l.clientX - h, y: l.clientY - f }) ); }) ); }), () => { const { store: a } = n.value, { settings: { width: c, height: l } } = a.state, { path: h, line: f } = uy(a.state, e.draw); return rt` <svg class=${my} style=${{ width: `${c}px`, height: `${l}px`, "min-width": `${c}px`, "min-height": `${l}px` }} > <g> <path d=${h.path.d()} stroke-dasharray="10" stroke-width="3" fill="transparent" ></path> <line x1=${h.line.start.x1} y1=${h.line.start.y1} x2=${h.line.start.x2} y2=${h.line.start.y2} stroke-width="3" ></line> <line x1=${f.start.base.x1} y1=${f.start.base.y1} x2=${f.start.base.x2} y2=${f.start.base.y2} stroke-width="3" ></line> <line x1=${f.start.base2.x1} y1=${f.start.base2.y1} x2=${f.start.base2.x2} y2=${f.start.base2.y2} stroke-width="3" ></line> <line x1=${f.start.center2.x1} y1=${f.start.center2.y1} x2=${f.start.center2.x2} y2=${f.start.center2.y2} stroke-width="3" ></line> </g> </svg> `; }; }, pn = (e) => R` font-size: var(--font-size-${e}); letter-spacing: var(--letter-spacing-${e}); line-height: var(--line-height-${e}); `, Bd = pn(1), ws = pn(2), jd = pn(3); pn(4); const Va = pn(5), Cs = pn(6), gy = pn(7), vy = pn(8), yy = pn(9), by = R` ${ws}; font-weight: var(--font-weight-regular); `, xy = R` ${Bd}; font-weight: var(--font-weight-regular); `, Nt = { normal: by, paragraph: xy }; function ky() { const e = document.createElement("style"); return e.textContent = /* css */ ` :host { --font-size-1: 12px; --font-size-2: 14px; --font-size-3: 16px; --font-size-4: 18px; --font-size-5: 20px; --font-size-6: 24px; --font-size-7: 28px; --font-size-8: 35px; --font-size-9: 60px; --letter-spacing-1: 0em; --letter-spacing-2: 0em; --letter-spacing-3: 0em; --letter-spacing-4: -0.0025em; --letter-spacing-5: -0.005em; --letter-spacing-6: -0.00625em; --letter-spacing-7: -0.0075em; --letter-spacing-8: -0.01em; --letter-spacing-9: -0.025em; --line-height-1: 16px; --line-height-2: 20px; --line-height-3: 24px; --line-height-4: 26px; --line-height-5: 28px; --line-height-6: 30px; --line-height-7: 36px; --line-height-8: 40px; --line-height-9: 60px; --font-weight-light: 300; --font-weight-regular: 400; --font-weight-medium: 500; --font-weight-bold: 700; } `, e; } const Lo = R` position: absolute; background-color: var(--table-background); padding: ${nr}px 0; border-radius: 6px; border: 1px solid var(--table-border); fill: transparent; color: transparent; ${Nt.paragraph}; &:hover { fill: var(--foreground); color: var(--foreground); } &[data-selected] { border: 1px solid var(--table-select); } .column-row-move { transition: transform 0.3s; } `, As = R` display: flex; flex-direction: column; position: relative; padding: 0 ${nr}px; `, Ts = R` position: absolute; top: -${nr + 1}px; left: 0; width: 100%; min-height: 4px; border-radius: 6px 6px 0 0; cursor: pointer; `, Fd = R` display: flex; height: ${Yu}px; justify-content: flex-end; margin-bottom: ${R0}px; cursor: move; & > .icon { cursor: pointer; } & > .icon:last-child { margin-left: ${z0}px; } & > .icon:hover { fill: var(--active); color: var(--active); } `, Hd = R` display: flex; height: ${V0}px; align-items: center; & > .input-padding { padding: ${ul}px ${So}px ${ul}px 0; } `; function $y(e) { const t = e.target; t && (t.value = us(t.value)); } function Kn(e) { e.preventDefault(); } function Jr(e) { e.stopPropagation(); } function Lr(e) { return e instanceof MouseEvent; } const Ss = { focus: "@dineug/erd-editor/internal-focus", forceFocus: "@dineug/erd-editor/internal-force-focus", forwardMoveStart: "@dineug/erd-editor/internal-forward-move-start" }; function Is(e, t) { function n(r, a) { return new CustomEvent(e, { detail: r, ...t, ...a }); } return n.toString = () => `${e}`, n.type = e, n; } const Rr = Is(Ss.focus), Ud = Is(Ss.forceFocus), wy = Is(Ss.forwardMoveStart, { bubbles: !0, composed: !0 }), Cy = lt(window, "keyup"), Ay = lt(window, "mousedown"), Ty = lt(window, "mousemove"), Yd = lt(window, "mouseup"), Sy = lt(window, "touchstart"), Iy = lt(window, "touchmove"), Ey = lt(window, "touchend"), My = ov().pipe(Sv()), Ny = lt(window, wy.type).pipe( qn((e) => e.detail.originEvent) ), Oy = Dr( Ay, Sy, Ny ), Dy = Dr(Yd, Ey); let xr = 0, kr = 0; Oy.subscribe((e) => { Lr(e) ? (xr = e.clientX, kr = e.clientY) : (xr = e.touches[0].clientX, kr = e.touches[0].clientY); }); const _y = Dr( Ty.pipe( qn((e) => { const t = e.clientX, n = e.clientY, r = t - xr, a = n - kr; return xr = t, kr = n, { event: e, movementX: r, movementY: a, x: t, y: n }; }) ), Iy.pipe( Mr((e) => e.touches.length === 1), qn((e) => { const t = e.touches[0].clientX, n = e.touches[0].clientY, r = t - xr, a = n - kr; return xr = t, kr = n, { event: e, movementX: r, movementY: a, x: t, y: n }; }) ) ), tn = _y.pipe(xd(Dy)); function Gd(e, t) { const n = le(e), r = ({ event: c, movementX: l, movementY: h }) => { c.type === "mousemove" && c.preventDefault(); const { store: f } = n.value; f.dispatch(Gu(l, h)); }; return { onMoveStart: (c) => { const l = c.target; if (!l) return; const { store: h } = n.value; h.dispatch(Io(t.table.id, dn(c))), !l.closest(".table-header-color") && !l.closest(".column-row") && !l.closest(".icon") && !l.closest(".input-padding") && tn.subscribe(r); } }; } const Ly = R` width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: auto; word-break: break-all; color: var(--active); font-weight: var(--font-weight-bold); &.isEmptyName { color: var(--placeholder); } `, Ry = (e, t) => { const n = le(t), { onMoveStart: r } = Gd(t, e), a = () => { const { store: l } = n.value, { settings: { zoomLevel: h } } = l.state; let f = Va.toString(); return h > 0.6 ? f = Va.toString() : h > 0.5 ? f = Cs.toString() : h > 0.4 ? f = gy.toString() : h > 0.3 ? f = vy.toString() : f = yy.toString(), f; }, c = (l) => { const { emitter: h } = n.value; h.emit( _o({ x: l.clientX, y: l.clientY, color: e.table.ui.color }) ); }; return () => { const { store: l } = n.value, { editor: h } = l.state, { table: f } = e, m = !!h.selectedMap[f.id], p = qt(f, l.state), v = sn(f), b = Jt(f.name.trim()); return C` <div class=${["table", Lo]} style=${{ top: `${f.ui.y}px`, left: `${f.ui.x}px`, "z-index": `${f.ui.zIndex}`