var yn = Object.defineProperty; var di = (t) => { throw TypeError(t); }; var wn = (t, e, i) => e in t ? yn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i; var N = (t, e, i) => wn(t, typeof e != "symbol" ? e + "" : e, i), ui = (t, e, i) => e.has(t) || di("Cannot " + i); var c = (t, e, i) => (ui(t, e, "read from private field"), i ? i.call(t) : e.get(t)), x = (t, e, i) => e.has(t) ? di("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), B = (t, e, i, n) => (ui(t, e, "write to private field"), n ? n.call(t, i) : e.set(t, i), i); var pi = (t, e, i, n) => ({ set _(r) { B(t, e, r, i); }, get _() { return c(t, e, n); } }); import { jsx as h, jsxs as j } from "react/jsx-runtime"; import E, { useEffect as V, useState as L, useCallback as Y, useRef as H, useContext as pe, useMemo as U, useId as Vt, isValidElement as bn, useLayoutEffect as Cn } from "react"; import ge from "pathe"; import w from "prop-types"; import R from "classnames"; import * as gi from "react-is"; import { useNotification as kn } from "rc-notification"; import f from "lodash"; import ae, { Field as Xt, FieldContext as Ni } from "rc-field-form"; import { M as jt, N as Ze, a as Ve, s as Dt, b as Sn, S as En } from "./vender-BkiRbACr.js"; import Pi from "immutability-helper"; import { Space as $n, Form as wt, Input as vn, Button as Ct, Pagination as xn, Tree as Nn, Breadcrumb as Pn, Empty as zt, Table as hi, Popover as Tn, Popconfirm as Rn, Tooltip as On } from "antd"; import Fn from "rc-util/lib/hooks/useMergedState"; import { useMergedState as An } from "rc-util"; import { generatePath as jn, useInRouterContext as Ti, useParams as Ln, useLocation as In, createBrowserRouter as Mn, Navigate as Vn } from "react-router-dom"; import Dn from "rc-drawer"; import zn from "rc-dialog"; var Ke, tt, _e, Se, De, ze; class Ri { constructor(e, i) { x(this, Ke, /* @__PURE__ */ new Map()); x(this, tt, !0); x(this, _e, []); x(this, Se); x(this, De, () => c(this, Se)); x(this, ze, () => Promise.resolve()); N(this, "get", (...e) => new Promise((i, n) => { const r = JSON.stringify(e); if (c(this, Ke).has(r)) return i(c(this, ze).call(this, c(this, Se), ...e)); if (c(this, Se) === void 0) c(this, _e).push([e, i, n]), c(this, tt) && (B(this, tt, !1), Promise.resolve(typeof c(this, De) == "function" ? c(this, De).call(this) : c(this, De)).then((a) => B(this, Se, a || null)).finally(() => { c(this, _e).forEach(([a, o, s]) => { try { const l = c(this, ze).call(this, c(this, Se), ...a); c(this, Ke).set(JSON.stringify(a), l), o(l); } catch (l) { s(l); } }), c(this, _e).length = 0; })); else { const a = c(this, ze).call(this, c(this, Se), ...e); c(this, Ke).set(r, a), i(a); } })); B(this, ze, i), B(this, De, e); } } Ke = new WeakMap(), tt = new WeakMap(), _e = new WeakMap(), Se = new WeakMap(), De = new WeakMap(), ze = new WeakMap(); const la = () => h("div", { children: "Empty" }), pt = E.createContext({ ele: {}, mount: () => { }, unmount: () => { } }), ee = ({ rootClassName: t, className: e, children: i, actions: n, title: r, subTitle: a, extras: o, style: s = {} }) => { const { mount: l, unmount: d } = E.useContext(pt); return ee.Action({ children: n }), ee.Title({ children: r }), ee.SubTitle({ children: a }), ee.Extra({ children: o }), V(() => (l("rootClassName", t), () => d(t)), [t]), h("div", { className: R("ff-container", e), style: s, children: i }); }, yt = (t) => ({ children: e, className: i }) => { const { mount: n, unmount: r } = E.useContext(pt); return V(() => (e && n(t, E.createElement("div", { key: `ff-${t}`, className: R(`ff-popup-${t}`, i) }, e)), () => r(t)), [i, e]), null; }; ee.Action = yt("actions"), ee.Title = yt("title"), ee.SubTitle = yt("sub-title"), ee.Extra = yt("extras"), ee.propTypes = { className: w.string, style: w.object, title: w.any, subTitle: w.any, actions: w.any, extras: w.any }; const ca = () => h(ee, { className: "ff-loading", children: j("div", { className: "loader", children: [j("div", { className: "square", children: [h("span", {}), h("span", {}), h("span", {})] }), j("div", { className: "square", children: [h("span", {}), h("span", {}), h("span", {})] }), j("div", { className: "square", children: [h("span", {}), h("span", {}), h("span", {})] }), j("div", { className: "square", children: [h("span", {}), h("span", {}), h("span", {})] })] }) }), da = () => h("div", { children: "NotFound" }), Oi = ({ children: t }) => { const [e, i] = L({}), n = Y((a, o) => i((s) => ({ ...s, [a]: o })), []), r = Y((a) => i((o) => ({ ...o, [a]: void 0 })), []); return typeof (t == null ? void 0 : t.type) == "string" ? t : h(pt.Provider, { value: { ele: e, mount: n, unmount: r }, children: E.cloneElement(t, { className: e.rootClassName, title: e.title, subTitle: e["sub-title"], actions: e.actions, extras: e.extras }) }); }; Oi.propTypes = { children: w.element.isRequired }; const mi = { close: ["M563.8 512l262.5-312.9c4.4-5.2 0.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9c-4.4 5.2-0.7 13.1 6.1 13.1h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"], check: ["M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474c-6.1-7.7-15.3-12.2-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"], info: ["M512 224m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z", "M544 392h-64c-4.4 0-8 3.6-8 8v464c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V400c0-4.4-3.6-8-8-8z"] }, Qt = ({ type: t, props: e }) => h("i", { ...e, children: h("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (mi[t] || mi.info).map((i, n) => h("path", { d: i }, n)) }) }), Fi = ({ className: t, content: e, icon: i, $close: n }) => j(E.Fragment, { children: [i && h("div", { className: R("ff-notification-icon", t), children: h(Qt, { type: i }) }), e] }), Wn = ({}) => h(ee, { children: "Confirm" }); var Pe, He; const he = class he { constructor() { x(this, He, /* @__PURE__ */ new Map()); N(this, "init", (e) => B(this, He, new Map(e))); N(this, "check", (e) => !c(this, He).has(e) || c(this, He).get(e)); if (c(he, Pe)) return c(he, Pe); } }; Pe = new WeakMap(), He = new WeakMap(), x(he, Pe, null), N(he, "getInstance", () => (c(he, Pe) || B(he, Pe, new he()), c(he, Pe))); let Wt = he; const Ai = Wt.getInstance(), Bn = (t, e, i = "children") => { if (f.isEmpty(t)) return {}; const n = f.find(t, ["value", e]); if (!f.isEmpty(n)) return n; const r = t.length; for (let a = 0; a < r; a++) { const { [i]: o } = t[a], s = Bn(o, e, i); if (!f.isEmpty(s)) return s; } return {}; }, ji = (t = "Input", e = "@pkg/ff/grid-layout-forms") => t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`; var Te, it; const me = class me { constructor() { x(this, it, null); N(this, "init", (e) => B(this, it, e)); N(this, "get", (e, i) => f.get(c(this, it), e, i)); if (c(me, Te)) return c(me, Te); } }; Te = new WeakMap(), it = new WeakMap(), x(me, Te, null), N(me, "getInstance", () => (c(me, Te) || B(me, Te, new me()), c(me, Te))); let Bt = me; const qe = Bt.getInstance(), fi = { null2json: (t) => Object.create(), null2array: (t) => [], null2number: (t) => 0, null2bool: (t) => !1, null2string: (t) => "", null2integer: (t) => 0, null2float: (t) => 0, string2json: (t) => t ? JSON.parse(t) : "{}", string2array: (t) => t.substr(0, 1) === "[" && t.substr(-1) === "]" ? JSON.parse(t) : t.split(","), string2number: (t) => t == "" ? 0 : +t, string2integer: (t) => t == "" ? 0 : +t, string2float: (t) => t == "" ? 0 : +t, string2bool: (t) => { switch (`${t}`.toLowerCase()) { case "0": case "false": case "[]": case "{}": return !1; } return !!t; }, string2string: (t) => t, json2json: (t) => t, json2array: (t) => t ? Object.values(t) : [], json2number: (t) => Object.keys(t).length, json2integer: (t) => Object.keys(t).length, json2float: (t) => Object.keys(t).length, json2bool: (t) => Object.keys(t).length > 0, json2string: (t) => t ? JSON.stringify(t) : "", array2json: (t) => ({ ...t }), array2array: (t) => t, array2number: (t) => t.length, array2integer: (t) => t.length, array2float: (t) => t.length, array2bool: (t) => t.length > 0, array2string: (t) => JSON.stringify(t), number2json: (t) => ({}), number2array: (t) => [t], number2number: (t) => t, number2integer: (t) => t, number2float: (t) => t, number2bool: (t) => !!t, number2string: (t) => t.toString(), boolean2json: (t) => ({}), boolean2array: (t) => [], boolean2number: (t) => +t, boolean2integer: (t) => +t, boolean2float: (t) => +t, boolean2bool: (t) => t, boolean2string: (t) => t ? "true" : "false" }, de = (t, e) => { let i = "string"; i = Array.isArray(t) ? "array" : typeof t, f.isObject(t) && (i = "json"); const n = `${i}2${e}`; return Reflect.has(fi, n) ? fi[n](t) : t; }, qn = (t) => t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "json" : typeof t == "boolean" ? "bool" : typeof t == "string" ? "string" : typeof t == "number" ? Number.isInteger(t) ? "integer" : "float" : typeof t, gt = (t = {}, e = {}, i = {}, n = "") => Li(t, (r, a) => a === "type" && r === "code") ? Ii(t, e, i, n) : Mi(t, e, n), Li = (t, e = () => !1) => f.some(t, (i) => !!f.some(i, e) || (f.isEmpty(i) || !f.isPlainObject(i) && !f.isArray(i) ? void 0 : Li(i, e))), Ii = async (t = {}, e = {}, i = {}, n = "") => { let r = /* @__PURE__ */ Object.create(null); for (let a in t) { let o; if (Reflect.has(t[a], "type") && ["code", "field", "router", "query", "string"].includes(t[a].type)) { const { type: s, value: l = "", default: d = n } = t[a]; switch (s) { case "code": try { o = await Ie.exec(l, e, i); } catch (u) { console.error("getWidgetPropsData", u); } break; case "field": o = f.get(e, l) ?? f.get(e, l.substring(l.indexOf(".") + 1)); break; case "router": case "query": o = xe.getPageParams(l); break; case "string": o = l; } o ?? (o = d); } else o = await Ii(t[a], e, i, n); f.set(r, a, o); } return r; }, Mi = (t = {}, e = {}, i = "") => Object.keys(t || {}).reduce((n, r) => { if (f.isPlainObject(t[r])) { let a; if (Reflect.has(t[r], "type") && ["field", "router", "query", "string"].includes(t[r].type)) { const { type: o, value: s = "", default: l = i } = t[r]; switch (o) { case "field": a = f.get(e, s) ?? f.get(e, s.substring(s.indexOf(".") + 1)); break; case "router": case "query": a = xe.getPageParams(s); break; case "string": a = s; } a ?? (a = l); } else a = Mi(t[r], e, i); f.set(n, r, a); } return n; }, {}), Lt = (t, e) => t && typeof t == "object" ? Array.isArray(t) ? t.map((i) => Lt(i, e)) : Object.keys(t).reduce((i, n) => (e[n] ? i[e[n]] = Lt(t[n], e) : i[n] = Lt(t[n], e), i), {}) : t, ua = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => { const e = 16 * Math.random() | 0; return (t === "x" ? e : 3 & e | 8).toString(16); }), pa = (t) => { var e, i; return t ? (i = (e = t.match(/^@pkg(?:[^\/]*\/){3}(?[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : i.name : ""; }, ga = (t) => { var e, i; return t ? (i = (e = t.match(/^@pkg(?:[^\/]*\/){2}(?[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : i.category : ""; }, ha = (t) => { var e, i; return t ? (i = (e = t.match(/^@pkg(?:[^\/]*\/){1}(?[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : i.owner : ""; }, Un = (t, e = 32, i = "auto") => { const n = qt(t), r = i === "auto" ? "x64" : i; if (e === 32) return jt.x86.hash32(n).toString(); if (e === 128) return r === "x64" ? jt.x64.hash128(n) : jt.x86.hash128(n); throw new Error("bits 只能是 32 或 128"); }, qt = (t) => t == null ? "null" : typeof t == "string" ? t : typeof t == "number" || typeof t == "boolean" ? String(t) : typeof t == "function" ? t.toString() : Array.isArray(t) ? "[" + t.map(qt).join(",") + "]" : typeof t == "object" ? "{" + Object.keys(t).sort().map((e) => `${e}:${qt(t[e])}`).join(",") + "}" : String(t), Kn = () => { let t = 1; const e = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Map(); return (...n) => n.length === 0 ? "" : n.map((r) => { return String((a = r) === null || typeof a != "object" && typeof a != "function" ? (i.has(a) || i.set(a, t++), i.get(a)) : (e.has(a) || e.set(a, t++), e.get(a))); var a; }).join("::"); }, _n = (t) => { if (!t || typeof t != "string" || t.startsWith("/") || t.startsWith("./") || t.startsWith("../")) return !1; try { let e = t.startsWith("//") ? `http:${t}` : t; return e.includes("://") || e.startsWith("//") || (e = `http://${e}`), !!new URL(e).hostname; } catch { return !1; } }, ma = (t, e = "") => { if (!t || typeof t != "string" || _n(t)) return t; let i = e; return !i && typeof window < "u" && window.location && (i = `${window.location.protocol}//${window.location.host}`), t.startsWith("/") ? i ? `${i}${t}` : t : i ? `${i}/${t}` : t; }; var Et, nt, rt, $t; const vt = class vt { constructor(...e) { x(this, nt, []); x(this, rt, (e) => { var i; for (let n of e) Array.isArray(n[0]) ? c(this, rt).call(this, n) : c(this, nt).push(c(i = vt, Et).call(i, n[0], n[1])); }); N(this, "toValue", async (e, i = null) => { const n = { getValue: () => e, getRecord: () => i }; let r = e; for (const a of c(this, nt)) try { const o = await a; if (typeof o != "function") { console.warn("middleware is not a function, skip:", o); continue; } r = await o.call(n, r); } catch (o) { console.error("middleware error, skip:", o); } return r; }); N(this, "toRender", (e, i, n = null) => E.createElement(c(this, $t), { value: e, record: i }, n)); x(this, $t, ({ value: e, record: i, children: n }) => { const [r, a] = L(n); return mt(() => { let o = !1; return a(n), this.toValue(e, i).then((s) => !o && a(s)).catch((s) => !o && a(`${s}`)), () => o = !0; }, [e, i]), r; }); c(this, rt).call(this, e); } }; Et = new WeakMap(), nt = new WeakMap(), rt = new WeakMap(), $t = new WeakMap(), x(vt, Et, f.memoize((e, i) => { if (typeof e == "function") return e(i); if (typeof e == "string") return ue.getWidgetComponent(e).then((n) => { var r; return ((r = n.default) == null ? void 0 : r.call(n, i)) || ((a) => a); }); throw new TypeError("middleware must be a string or a function"); }, Kn())); let kt = vt; const oe = E.createContext({ listCode: "", classNames: {}, getBase62params: (t, e) => { }, getSelectedRows: () => [], onReload: () => { }, onClickCallback: () => { }, onConditionChange: () => { }, onTabChange: () => { }, onSiderChange: () => { }, onKeywordChange: () => { }, onPageChange: () => { }, onPageSizeChange: () => { }, reload: () => { }, setPage: () => { }, setPageSize: () => { }, setTab: () => { }, setSider: () => { }, setKeyword: () => { }, setCondition: () => { } }), yi = ({ className: t, record: e, column: i, ...n }) => { if (i != null && i.editableByJs && (i != null && i.uuid)) { const { formSetting: r = { primaryKey: "id" }, widgetSetting: a = {}, widgetContainerSetting: o = {} } = (i == null ? void 0 : i.editableByJsSetting) || {}; return h(P.Popover, { widget: Hn, widgetData: { record: e, column: i }, widgetSetting: { widgetSetting: a, formSetting: r }, widgetContainerProps: { title: i != null && i.title ? `${i.title} - 编辑` : "编辑", ...o, width: (o == null ? void 0 : o.width) || 260, arrow: !0 }, children: h("td", { className: R("ff-data-list-cell-editable", t), ...n }) }); } return h("td", { className: t, ...n }); }, Hn = ({ record: t, column: e, $close: i, $setting: n }) => { const r = H(qn(f.get(t, e == null ? void 0 : e.dataIndex))), { listCode: a, onClickCallback: o } = pe(oe), [s] = ae.useForm(), { formSetting: l, widgetSetting: d } = n, u = (l == null ? void 0 : l.primaryKey) || "id", p = () => { s.setFieldsValue({ value: f.get(t, e == null ? void 0 : e.dataIndex), __PROPS__: t }); }; return mt(() => p(), [t, e == null ? void 0 : e.dataIndex, a]), h(ee, { actions: j(E.Fragment, { children: [h(P, { size: "small", onClick: p, children: "重置" }), j($n.Compact, { block: !0, children: [h(P, { size: "small", widget: i, children: "取消" }), h(P, { type: "primary", size: "small", widget: () => s.validateFields().then(({ value: m }) => { const g = f.get(t, u.substring(u.indexOf(".") + 1)); if (!g) throw "获取更新主键失败!"; I.put(`/api/${a}-storeBy-${e == null ? void 0 : e.uuid}/${g}`, { value: m }).msg(() => o(2, t)).then(i); }).catch(console.warn), children: "保存" })] })] }), children: j(ae, { form: s, children: [h(ti, { label: "", type: r.current, code: "value", widget: e == null ? void 0 : e.editableByJs, extras: d }), h(Xt, { noStyle: !0, name: ["__PROPS__"], children: () => { } })] }) }); }, Jn = (t) => function(e) { return t(e, getRecord()); }, Gn = (t, e = {}) => U(() => { var i; return (i = t == null ? void 0 : t.filter(Boolean)) == null ? void 0 : i.map(({ widgetByJs: n, widgetByJsSetting: r, ...a }, o) => { const s = (d) => ({ record: d, column: a }); let l = []; return n && l.push([n, r]), l.length > 0 ? (a != null && a.render && l.push([Jn, a.render]), { ...a, onCell: s, render: (d, u) => new kt(l).toRender(d, u, "-") }) : { ...a, onCell: s }; }); }, [t, e]), Yn = (t = {}) => U(() => { var e; return t.body ?? (t.body = { cell: yi }), (e = t.body).cell ?? (e.cell = yi), t; }, [t]), fa = (t) => { const [e, i] = L({}); return V(() => { let n = !1; return t && I.get(`/api/_/${t}`).then((r) => f.pick(r, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig", "selectionType"])).then((r) => !n && i(r)), () => n = !0; }, [t]), e; }, ya = (t, e = {}) => { const [i, n] = L({ dataSource: [] }); return ht(() => { let r = !1; return t && I.get(`/api/${t}/${I.encode({ page: 1, ...e })}`).then((a) => !r && n(a)), () => r = !0; }, [t, e]), i; }, Vi = (t = [], e = /* @__PURE__ */ new Map(), i = "id", n) => { const r = Y(n ? (a) => f.get(a, i, f.get(a, [n, i])) : (a) => f.get(a, i), [i, n]); return Y((a) => t == null ? void 0 : t.filter((o) => !o.uuid || !e.has(o.uuid) || e.get(o.uuid).some((s) => s == r(a))), [t, e, r]); }, Ut = (t = [], e = /* @__PURE__ */ new Map(), i = [], n = "id", r) => { const a = Y(r ? (o) => f.get(o, n, f.get(o, [r, n])) : (o) => f.get(o, n), [n, r]); return U(() => { if (f.isEmpty(t) || !t.some(({ uuid: s }) => Ai.check(s))) return !1; if (f.isEmpty(e) || f.isEmpty(i)) return !0; const o = i.map((s) => a(s)); return t.some(({ uuid: s }) => !s || !e.has(s) || e.get(s).some((l) => o.some((d) => d == l))); }, [t, i, e, a]); }, Xn = (t, e, i = "id", n = null) => { const r = Tt(), a = H(!1), o = H(t.dataSource), s = H(t.itemOperationsAccess); return V(() => (o.current = t.dataSource, s.current = t.itemOperationsAccess, () => a.current = !1), [t.dataSource, t.itemOperationsAccess]), a.current && (t.dataSource = o.current, t.itemOperationsAccess = s.current), [t, (l = 0, d = null) => { var u, p; if (a.current = !1, l === 1) return (u = t.onReload) == null ? void 0 : u.call(t); if (l === 2) { const m = f.get(d, "__PARENT_ID__", ""), g = f.get(d, i, f.get(d, [n, i], "")), y = f.findIndex(o.current, ["__PARENT_ID__", m]), b = f.findIndex(y > -1 ? f.get(o.current, [y, "children"]) : o.current, [i, g]); if (b === -1) return (p = t.onReload) == null ? void 0 : p.call(t); Promise.all([I.get(`/api/${e}/detail/${g}`), I.post(`/api/${e}/list-operations-access`, { ids: g })]).then(([C, S]) => { const v = f.get(o.current, y > -1 ? [y, "children", b, "children"] : [b, "children"]); o.current = Pi(o.current, y > -1 ? { [y]: { children: { $splice: [[b, 1, { ...C, children: v }]] } } } : { $splice: [[b, 1, { ...C, children: v }]] }); const k = new Map(S); s.current.forEach(($, T) => { var A; (A = k.get(T)) != null && A.some((F) => F == g) || s.current.set(T, $.filter((F) => F !== g)); }), k.forEach(($, T) => { s.current.has(T) ? s.current.set(T, f.uniq([...s.current.get(T) || [], ...$])) : s.current.set(T, $); }); }).then(() => { a.current = !0, r(); }); } }]; }, Qn = (t, e) => { const i = Tt(), n = H(e), r = H(/* @__PURE__ */ new Map()), a = H([]), o = f.throttle((l) => { a.current = [], I.list(t, f.pick({ ...n.current, ...l }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: d, condition: u, total: p, tab: m, sider: g, page: y, pageSize: b, operationsAccess: C, dataSource: S }) => { n.current = { tab: m, condition: u, sider: g, keyword: d, total: p, pageSize: b, page: S != null && S.length ? y : 1 }, a.current = S, r.current = new Map(C), i(); }); }, 380, { leading: !1, trailing: !0 }); mt(() => { a.current = [], t && o(e); }, [t, e]); const s = U(() => f.pick(n.current, ["total", "tab", "page", "pageSize", "condition", "sider", "keyword"]), [n.current]); return Object.assign(s, { onTabChange: (l) => o({ tab: l, page: 1 }), onPageChange: (l, d) => o({ page: l, pageSize: d }), onPageSizeChange: (l) => o({ pageSize: l, page: 1 }), onConditionChange: (l, d) => o({ keyword: d, condition: Pi(n.current.condition || {}, { $merge: l || {} }), page: 1 }), onSiderChange: (l) => o({ sider: l, page: 1 }), onKeywordChange: (l) => o({ keyword: l, page: 1 }), itemOperationsAccess: r.current, dataSource: a.current, onReload: o, payload: e == null ? void 0 : e.payload }); }, Zn = ({ listCode: t, className: e, layouts: i = {}, dataSource: n, isPaginate: r, isItemOperations: a, isBatchOperations: o, batchOperations: s, itemOperations: l, itemOperationsAccess: d, resource: u, primaryKey: p, title: m, itemGridLayout: g, $setting: y, tabs: b, isConditionFormLayout: C, isTreeSider: S, treeSiderConfig: v }) => { const { classNames: k, onClickCallback: $ } = pe(oe), T = f.pick(y, ["column", "colWidth", "beforeRender", "afterRender", "style"]), A = Vi(l, d, p, u), F = Y((M, z, O) => h(er, { className: R("ff-data-list-framework-item", k == null ? void 0 : k.item), operations: a ? A(z) : [], data: u ? { [u]: z } : z, children: M, onClickCallback: $ }), [u, p, a, $, l, d]); return j("div", { className: R("ff-data-list-framework", e), children: [h(i.sider, { isTreeSider: S, ...v }), j("div", { className: R("ff-data-list-container", k == null ? void 0 : k.container), children: [h(i.filter, { isConditionFormLayout: C }), h(i.toolbar, { title: m, tabs: b }), h(hr, { ...T, ...g, empty: h(i.empty, { className: k == null ? void 0 : k.empty }), primaryKey: p, itemRender: F, dataSource: n }), h(i.footer, { isPaginate: r, isOperations: o, operations: s })] })] }); }, er = ({ className: t, operations: e, children: i, data: n, onClickCallback: r }) => j("div", { className: R("data-list-grid-layout-item", t), children: [h("div", { className: "data-list-grid-layout-item-container", children: i }), !!(e != null && e.length) && h("div", { className: "data-list-grid-layout-item-actions", children: e.map((a) => h("span", { className: "data-list-grid-layout-item-action", children: h(P.Link, { uuid: a.uuid, type: a.type, name: a.name, widget: a.widget, widgetType: a.widgetType, widgetProps: a.widgetProps, widgetSetting: a.widgetSetting, widgetContainerProps: a.widgetContainerSetting, data: n, confirm: a.confirm, onAfterClick: (o) => o !== !1 && (r == null ? void 0 : r(a.isRefresh, n)) }, a.uuid || Vt()) }, (a == null ? void 0 : a.uuid) || Vt())) })] }), tr = ({ listCode: t, className: e, layouts: i = {}, dataSource: n, columns: r, isItemOperations: a, isBatchOperations: o, batchOperations: s, itemOperations: l, itemOperationsAccess: d, resource: u, primaryKey: p, title: m, tabs: g, isPaginate: y, rowSelection: b, isTreeSider: C, treeSiderConfig: S, isConditionFormLayout: v, ...k }) => { const { classNames: $, onClickCallback: T } = pe(oe), A = Vi(l, d, p, u), F = Ut(l, d, n, p, u); return j("div", { className: R("ff-data-table-framework", e), children: [h(i.sider, { isTreeSider: C, ...S }), j("div", { className: R("ff-data-table-container", $ == null ? void 0 : $.container), children: [h(i.filter, { isConditionFormLayout: v }), h(i.toolbar, { title: m, tabs: g }), h(lr, { ...k, primaryKey: p, className: "ff-data-table-content", columns: r, dataSource: n, rowSelection: b, operationRender: F ? (M) => { var z; return h("div", { className: "ff-data-table-actions", children: (z = A(M)) == null ? void 0 : z.map((O, D) => h(P.Link, { size: "small", uuid: O.uuid, type: O.type, name: O.name, widget: O.widget, widgetType: O.widgetType, widgetProps: O.widgetProps, widgetData: O.widgetData, widgetSetting: O.widgetSetting, widgetContainerProps: O.widgetContainerSetting, data: M, confirm: O.confirm, onAfterClick: (K) => K !== !1 && (T == null ? void 0 : T(O.isRefresh, M)) }, O.uuid || D)) }); } : null }), h(i.footer, { isPaginate: y, isOperations: o, operations: s })] })] }); }, Zt = (t = [], e, i = null) => { var n; return (n = f.sortBy(t, ["y", "x"])) == null ? void 0 : n.map(({ i: r, x: a, y: o, w: s, h: l, field: { boxStyle: d, ...u } = {} }, p) => h("div", { className: "grid-layout-item", style: Di(a, o, s, l, d), children: h(e, { ...u, basicForm: i }) }, r ?? p)); }, Di = (t, e, i, n, r = {}, a = 0) => { const o = { "--grid-layout-h": `${n}`, "--grid-layout-w": `${i}`, "--grid-layout-x": `${t}`, "--grid-layout-y": `${e}`, "--grid-layout-row-height-offset": "0px" }; return r != null && r.autoHeight ? o.height = "fit-content" : o["--grid-layout-row"] = `${n}`, r != null && r.alignItems && (o["--grid-layout-box-align-items"] = r.alignItems), r != null && r.justifyContent && (o["--grid-layout-box-justify-content"] = r.justifyContent), o["--grid-layout-box-margin"] = wi(r == null ? void 0 : r.marginTop, r == null ? void 0 : r.marginRight, r == null ? void 0 : r.marginBottom, r == null ? void 0 : r.marginLeft), o["--grid-layout-box-padding"] = wi(r == null ? void 0 : r.paddingTop, r == null ? void 0 : r.paddingRight, r == null ? void 0 : r.paddingBottom, r == null ? void 0 : r.paddingLeft), a && (o.height = `${a}px`), o; }, wi = (t, e, i, n) => `${t || 0}px ${e || 0}px ${i || 0}px ${n || 0}px`, wa = (t = "Text", e = "@pkg/ff/grid-layouts") => t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`, zi = (t) => Object.keys(t).reduce((e, i) => (/^on[A-Z]/.test(i) && (e[i] = t[i]), e), {}), Wi = ({ className: t, isConditionFormLayout: e }) => { var m, g; const [i, n] = L({}), { listCode: r, onKeywordChange: a, onConditionChange: o, getBase62params: s, classNames: l } = E.useContext(oe), { keyword: d, condition: u } = (s == null ? void 0 : s()) || {}, [p] = wt.useForm(); return V(() => { r && e && I.get(`/api/_/${r}/list-condition-form-layout`).then(({ resource: y, marginX: b, marginY: C, rowHeight: S, cols: v, fields: k }) => { n({ resource: y, itemMargin: [b, C], rowHeight: S, cols: v, fields: k }); }).catch(() => n({})); }, [r, e]), V(() => { p.setFieldsValue({ keyword: d, ...u }); }, [JSON.stringify([d, u])]), h("div", { className: R("ff-data-list-filter", l.filter, t), children: h(wt, { form: p, layout: "vertical", autoComplete: "off", onFinish: ((m = i.fields) == null ? void 0 : m.length) > 1 ? (y) => o({ [i.resource]: y[i.resource] }, y.keyword) : () => { }, onValuesChange: (y) => { f.isEmpty(f.omit(y, ["keyword"])) || p.submit(); }, children: ((g = i.fields) == null ? void 0 : g.length) > 1 ? h(ii, { ...i, children: h(ir, { onReset: () => { const { keyword: y, condition: b } = s("init") || {}; p.setFieldsValue({ keyword: y, ...b }); } }) }) : h("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: h("div", { className: "grid-layout-item", style: Di(20, 0, 5, 2), children: h(wt.Item, { name: ["keyword"], children: h(vn.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (y) => a(y) }) }) }) }) }) }); }, ir = ({ cols: t, fields: e, onReset: i }) => { const [n, r] = L(!1), a = U(() => e == null ? void 0 : e.toReversed().some((o) => o.y > 1 || o.x + o.w >= t - 5), [t, e]); return j(wt.Item, { label: " ", style: { "--item-span": 5 }, className: R("ff-data-list-filter-actions", { expanded: n }), children: [h(Ct, { onClick: i, children: "重置" }), h(Ct, { type: "primary", htmlType: "submit", children: "查询" }), a && h(P.Link, { className: "ff-data-list-filter-expanded-button", widget: () => r((o) => !o), type: "primary", name: n ? "关闭" : "展开", icon: n ? "icon-up" : "icon-down", iconPosition: "end" })] }); }; Wi.reservedFields = [{ x: 0, y: 0, h: 3, w: 5, field: { isVirtual: !0, widgetPrefix: "@pkg/ff/grid-layout-forms", widget: "Input", code: "keyword", label: "关键字", placeholder: "多关键字 | 分割", extras: { prefix: "icon-search" } } }]; const nr = ({ className: t, operations: e, isOperations: i, isPaginate: n }) => { const { onPageChange: r, onPageSizeChange: a, onClickCallback: o, getBase62params: s } = E.useContext(oe), { total: l, page: d, pageSize: u } = (s == null ? void 0 : s()) || {}; return i && !f.isEmpty(e) || n ? j("div", { className: R("ff-data-list-footer", t), children: [h("div", { className: "ff-data-list-actions", children: e == null ? void 0 : e.map((p, m) => h(P, { uuid: p.uuid, type: p.type, name: p.name, widget: p.widget, widgetType: p.widgetType, widgetProps: p.widgetProps, widgetData: p.widgetData, widgetSetting: p.widgetSetting, widgetContainerProps: p.widgetContainerSetting, onAfterClick: (g) => g !== !1 && (o == null ? void 0 : o(p.isRefresh, null)) }, p.uuid || m)) }), n && h(xn, { size: "small", total: l, pageSize: u, showSizeChanger: !1, showTotal: (p) => `第 ${d} 页 / 总共 ${p} 条`, onChange: r, onShowSizeChange: a })] }) : null; }, rr = [{ title: "parent 1", key: "0-0", children: [{ title: "parent 1-0", key: "0-0-0", disabled: !0, children: [{ title: "leaf", key: "0-0-0-0", disableCheckbox: !0 }, { title: "leaf", key: "0-0-0-1" }] }, { title: "parent 1-1", key: "0-0-1", children: [{ title: h("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], ar = ({ className: t, width: e = 280, isTreeSider: i }) => { const { classNames: n } = pe(oe); return i ? h(Nn.DirectoryTree, { className: R("ff-data-list-sider", n.sider, t), style: { "--sider-width": e }, showLine: !0, showIcon: !1, treeData: rr }) : null; }, or = ({ className: t, title: e, tabs: i }) => { const { getBase62params: n, onTabChange: r, onReload: a, classNames: o } = pe(oe), { tab: s } = (n == null ? void 0 : n()) || {}, [l, d] = An((i == null ? void 0 : i[0].value) ?? (i == null ? void 0 : i[0].code), { value: s, onChange: r }); return j("div", { className: R("ff-data-list-toolbar", o.toolbar, t), children: [h("div", { className: "ff-data-list-title", children: e }), h(Pn, { className: "ff-data-list-tabs", itemRender: ({ label: u, code: p, value: m }) => h("span", { onClick: () => d(m ?? p), className: R("ff-data-list-tab", { active: (m ?? p) == l }), children: u }), items: i }), j("div", { className: "ff-data-list-actions", children: [h(P.Link, { icon: "icon-reload", widget: () => a() }), h(P.Link, { icon: "icon-setting" })] })] }); }, sr = ({ className: t, ...e }) => h(zt, { className: R(t, "ff-data-list-empty"), image: zt.PRESENTED_IMAGE_SIMPLE, ...e }), Bi = ({ isItemGridLayout: t, theme: e, themeProps: i, onClickCallback: n, onReload: r, listCode: a, total: o = 0, page: s = 0, onPageChange: l, pageSize: d = 30, onPageSizeChange: u, tab: p, onTabChange: m, keyword: g, onKeywordChange: y, condition: b, onConditionChange: C, sider: S, onSiderChange: v, layouts: k, classNames: $ = {}, payload: T = {}, dataSource: A = [], rowSelection: F, getSelectedRows: M, primaryKey: z, ...O }) => { const [D, K] = L(), _ = M ?? (() => A), re = Y((W, se) => { const J = { tab: p, page: s, pageSize: d, keyword: g, sider: S, condition: b, total: o, payload: T }; return W && W != "init" ? f.get(J, W, se) : J; }, [JSON.stringify(b), JSON.stringify(T), p, s, d, g, S, o]), Ne = U(() => { let W = { sider: ar, filter: Wi, footer: nr, toolbar: or, empty: sr }; k === !1 ? W = { sider: null, filter: null, footer: null, toolbar: null, empty: null } : f.isPlainObject(k) && (W = Object.assign({}, W, k)); for (const se in W) if (W[se]) { if (bn(W[se])) { const J = W[se]; W[se] = (Ot) => E.cloneElement(J, Ot); } } else W[se] = () => h(E.Fragment, {}); return W; }, [k]); return V(() => { e ? ue.getWidgetComponent(e).then((W) => { if (!W) throw `${e} not found`; return W; }).catch((W) => ({ default: () => `${W}` })).then((W) => K(E.createElement(W.default, { ...O, layouts: Ne, $setting: i }))) : K(h(t ? Zn : tr, { ...O, layouts: Ne, $setting: i })); }, [e, i]), h(oe.Provider, { value: { classNames: $, listCode: a, onClickCallback: n, onReload: r, getBase62params: re, onPageChange: l, onPageSizeChange: u, onTabChange: m, onSiderChange: v, onKeywordChange: y, onConditionChange: C, setPage: l, setPageSize: u, setTab: m, setSider: v, setKeyword: y, setCondition: C, getSelectedRows: _ }, children: D && E.cloneElement(D, { dataSource: A, primaryKey: z, rowSelection: F, ...O }) }); }; Bi.propTypes = { classNames: w.exact({ sider: w.string, filter: w.string, footer: w.string, toolbar: w.string, container: w.string, content: w.string, item: w.string, empty: w.string }), layouts: w.oneOfType([w.exact({ sider: w.oneOfType([w.elementType, w.element]), filter: w.oneOfType([w.elementType, w.element]), footer: w.oneOfType([w.elementType, w.element]), toolbar: w.oneOfType([w.elementType, w.element]), empty: w.oneOfType([w.elementType, w.element]) }), w.bool]) }; var Re, Ee, We, xt; const fe = class fe { constructor() { x(this, Ee, null); x(this, We, /* @__PURE__ */ new Map()); x(this, xt, () => { if (c(this, Ee)) return c(this, Ee).port.postMessage({ command: "status", data: [] }); B(this, Ee, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), c(this, Ee).port.onmessage = (e) => { var i, n; (i = e.data) != null && i.uuid ? c(this, We).forEach((r, a) => { var o; (r == "*" || (o = r == null ? void 0 : r.includes) != null && o.call(r, e.data.uuid)) && a(e.data); }) : ((n = e.data) == null ? void 0 : n.readyState) == WebSocket.CLOSED && I.get("/api/user-api-token").then(({ token: r, expire_at: a }) => { c(this, Ee).port.postMessage({ command: "initWs", data: [`ws${f.trimStart(I.appUrl, "http")}api/user-resource-status-ws?token=${r}`] }); }); }, c(this, Ee).port.postMessage({ command: "status", data: [] }); }); N(this, "subscribe", (e, i = []) => (i ? Array.isArray(i) && i.length == 0 ? i = "*" : Array.isArray(i) || (i = [i].flat()) : i = "*", c(this, We).set(e, i), c(this, We).size == 1 && c(this, xt).call(this), () => this.unsubscribe(e))); N(this, "unsubscribe", (e) => c(this, We).delete(e)); if (c(fe, Re)) return c(fe, Re); } }; Re = new WeakMap(), Ee = new WeakMap(), We = new WeakMap(), xt = new WeakMap(), x(fe, Re, null), N(fe, "getInstance", () => (c(fe, Re) || B(fe, Re, new fe()), c(fe, Re))); let Kt = fe; const qi = Kt.getInstance(), ei = E.forwardRef(({ listCode: t, base62params: e, className: i, theme: n, themeProps: r, layouts: a, classNames: o, onSelectionChange: s, defaultSelectedRowKeys: l, selectedRowKeys: d }, u) => { const [{ resource: p, primaryKey: m, batchOperations: g = [], itemOperations: y = [], columns: b = [], themeConfig: C, theme: S, isConditionFormLayout: v = !1, isTreeSider: k, treeSiderConfig: $, isItemGridLayout: T, itemGridLayout: { themeConfig: A, ...F } = {}, title: M, isPaginate: z, tabs: O, selectionType: D }, K] = L({ isItemGridLayout: !1, itemGridLayout: {} }), _ = Qn(t, e), [{ dataSource: re, itemOperationsAccess: Ne, condition: W, tab: se, keyword: J, page: Ot, total: en, pageSize: tn, sider: nn, onConditionChange: rn, onTabChange: an, onKeywordChange: on, onPageChange: sn, onPageSizeChange: ln, onSiderChange: cn, onReload: Ft, payload: dn }, oi] = Xn(_, t, m, p), [un, pn] = Fn([], { defaultValue: l ?? [], value: d }), [si, gn] = L([]), li = Y(() => D ? si : re, [D, si, re]), hn = Ut(y, Ne, re, m), mn = Ut(g); V(() => { let X = null; return t && I.get(`/api/_/${t}`).resp(({ data: Me, res: At }) => { Me != null && Me.isDynamicRefresh && (X = qi.subscribe(() => Ft(), At)), K(Me); }).catch(() => K({})), () => X == null ? void 0 : X(); }, [t]), E.useImperativeHandle(u, () => ({ onReload: Ft, onClickCallback: oi, getSelectedRows: li })); const fn = { listCode: t, title: M, classNames: o, layouts: a, resource: p, primaryKey: m, theme: n || S, themeProps: r || C, isTreeSider: k, treeSiderConfig: $, isPaginate: z, rowSelection: D ? { type: D, columnWidth: 80, selectedRowKeys: un, onChange: (X, Me) => { gn((At) => { const ci = new Map(At.map((le) => [le == null ? void 0 : le[m], le])); return Me.forEach((le) => ci.set(le == null ? void 0 : le[m], le)), X.map((le) => ci.get(le)).filter(Boolean); }), pn(X), s == null || s(X, Me); } } : void 0, getSelectedRows: li, tabs: O, isItemOperations: hn, itemOperations: y == null ? void 0 : y.map((X) => f.isEmpty(X == null ? void 0 : X.confirm) ? X : { ...X, confirm: Object.assign({}, X.confirm, { getPopupContainer: () => document.body }) }), isBatchOperations: mn, batchOperations: g, isItemGridLayout: T, columns: b, itemGridLayout: { ...F, themeProps: A }, isConditionFormLayout: v, itemOperationsAccess: Ne, dataSource: re, onConditionChange: rn, onTabChange: an, onKeywordChange: on, onPageChange: sn, onPageSizeChange: ln, onSiderChange: cn, condition: W, tab: se, keyword: J, page: Ot, total: en, pageSize: tn, sider: nn, payload: dn }; return h(Bi, { ...fn, className: R("ff-data-list-helper", i), onReload: Ft, onClickCallback: oi }); }), Ui = (t, e, i = !0) => i !== !0 && i-- <= 0 ? [] : f.isArray(t) && !f.isEmpty(t) ? t.reduce((n, r) => (Reflect.has(r, e) && Reflect.has(r, "children") && n.push(r[e]), Reflect.has(r, "children") && !f.isEmpty(r.children) ? n.concat(Ui(r.children, e, i)) : n), []) : [], lr = ({ className: t, primaryKey: e, columns: i = [], dataSource: n = [], operationRender: r, operationWidth: a = 180, components: o = {}, rowSelection: s, ...l }) => { const { classNames: d } = pe(oe), u = H(null), p = H(null), [m, g] = L([]), [y, b] = L({ width: 0, height: 0 }); V(() => { g(Ui(n, e)); }, [n, e]), Cn(() => { const k = new ResizeObserver(() => { var $; b({ width: (($ = u.current) == null ? void 0 : $.nativeElement.querySelector(".ant-table-body").scrollWidth) || p.current.offsetWidth, height: p.current.offsetHeight }); }); return p.current && k.observe(p.current), () => { p.current && k.unobserve(p.current); }; }, []); const C = U(() => { if (!(y != null && y.width) || !(i != null && i.length)) return i; const k = (s ? s.columnWidth ?? 32 : 0) + (r ? a : 0), $ = i.reduce((F, M) => F + (M.isWidthFixed && M.width ? M.width : 0), 0), T = i.filter((F) => !F.isWidthFixed).reduce((F, M) => F + (M.width ?? 100), 0); if ($ + T + k >= y.width) return i; const A = y.width - $ - k; return i.map((F) => F.isWidthFixed ? F : { ...F, width: Math.floor(A * (F.width ?? 100) / T) }); }, [i, y.width, s, r, a]), S = Gn(C), v = Yn(o); return h("div", { ref: p, className: R("ff-data-list-table", d.content, t), children: y.height ? h(hi, { bordered: !0, ...l, components: v, ref: u, rowKey: (k) => (k == null ? void 0 : k[e]) ?? Math.random(), rowSelection: s, columns: (() => { var $, T; const k = [...S ?? []]; return s && k.splice((T = ($ = k[0]) == null ? void 0 : $.key) != null && T.startsWith("__") ? 1 : 0, 0, hi.SELECTION_COLUMN), r && k.push({ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(a / y.width * 100).toFixed(2)}%`, render: (A, F, M) => r(F, M) }), k; })(), dataSource: n, size: "middle", scroll: { x: "max-content", y: y.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: g, expandedRowKeys: m } }) : null }); }, cr = "RC_FORM_INTERNAL_HOOKS", dr = (t) => { const [e, i] = E.useState({ items: [] }); return V(() => { t && I.get(`/api/_/${t}`).then(({ uuid: n, code: r, name: a, resource: o, primaryKey: s, marginX: l, marginY: d, cols: u, rowHeight: p, fields: m, theme: g, themeSetting: y, groups: b }) => ({ uuid: n, code: r, name: a, resource: o, primaryKey: s, marginX: l, marginY: d, cols: u, rowHeight: p, theme: g, themeProps: y, groups: b, items: m })).then(i); }, [t]), e; }, ur = (t, { initialValue: e, initialValueLanguage: i, convertJs: n, convertJsSetting: r, type: a = "string" }, o = null) => { const s = H(!1), l = pe(Ni), [d, u] = L(), [p, m] = L(i != "javascript" && t ? l.getFieldValue(t) : void 0), { registerWatch: g } = l.getInternalHooks(cr) || {}; return V(() => g == null ? void 0 : g((y, b, C) => { if (!s.current) return; const S = f.get(b, t); f.isEqual(S, p) || m(de(S, a)); }), [p]), V(() => { i == "javascript" && e ? Ie.exec(e, {}, { getFieldValueForBasicForm: (y) => o ? o.getFieldValue(y) : l.getFieldValue(y), getFieldValue: (y) => l.getFieldValue(y) }).then((y) => m(de(y, a))).catch((y) => notification.error({ message: `布局数据错误: ${JSON.stringify(y)}` })).finally(() => s.current = !0) : (e && m(de(e ?? l.getFieldValue(t), a)), s.current = !0); }, [e, i]), ht(() => { s.current && n && new kt([n, r]).toValue(p, l.getFieldsValue(!0)).then(u).catch((y) => { u(y), console.error("布局数据转换错误: ", y, n); }); }, [p, n, r]), [d ?? p, p]; }, ba = (t, e, i = null) => U(() => Zt(t, e, i), [t]), Ki = (t, e, i = {}, n = {}, r = {}, a = null) => { const o = pe(Ni), s = Tt(), l = H(!0), d = H([]), [u, p] = L(e), [m, g] = L(), y = ae.useWatch((b) => JSON.stringify(f.pick(b, d.current)), o) || "{}"; return mt(() => { t && Ie.exec(t, i, { ...n, getFieldValueForBasicForm: (b) => r ? r.getFieldValue(b) : null, getFieldValue: f.wrap(o.getFieldValue, (b, C) => (d.current.some((S) => f.isEqual(S, C)) || (d.current.push(C), s()), b == null ? void 0 : b(C))), isFieldTouched: o.isFieldTouched, isFieldsTouched: o.isFieldsTouched }).then((b) => { l.current && (p(b), g(null)); }).catch((b) => { l.current && (p(e), g(b)); }); }, [t, y, o, i, n]), V(() => () => l.current = !1, []), t ? [a ? de(u, a) : u, m] : [a ? de(e, a) : e, null]; }, pr = ({ widget: t, widgetPrefix: e = "@pkg/ff/grid-layouts", basicForm: i, ...n }) => { const r = t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`, [a, o] = L(); return V(() => { r && ue.getWidgetComponent(r).then(({ defaultProps: s = {}, default: l }) => ({ default: gr(l, s, i) })).catch((s) => ({ default: () => `${s}` })).then((s) => o(E.createElement(s.default, n))); }, [r]), a; }, gr = (t, e = {}, i = null) => (n) => { const { code: r, label: a, extras: o, isVirtual: s, initialValue: l, initialValueLanguage: d, convertJs: u, convertJsSetting: p, value: m, ...g } = f.merge({}, e, n), [y, b] = ur(s ? null : r, { initialValue: l, initialValueLanguage: d, convertJs: u, convertJsSetting: p, type: (g == null ? void 0 : g.type) || "string" }, i), C = U(() => { const k = Object.keys((e == null ? void 0 : e.extras) || {}); return f.over([f.partialRight(f.pick, k), f.partialRight(f.omit, k)]); }, [e == null ? void 0 : e.extras]), [S, v] = C(g); return h(t, { ...v, value: y, rawValue: b, $setting: Object.assign({}, o, S) }); }, _i = ({ theme: t, basicForm: e, items: i = [{ key: "default", label: "默认" }], fields: n = [], itemRender: r, chunks: a = [], children: o, $setting: s = {}, ...l }) => { const [d, u] = L(); V(() => { t ? ue.getWidgetComponent(t).then((m) => { if (!(m != null && m.default)) throw "not found"; return m; }).catch((m) => ({ default: () => `${t} ${m}` })).then((m) => u(E.createElement(m.default, {}))) : u(null); }, [t]); const p = U(() => i == null ? void 0 : i.map((m) => ({ ...m, children: r(m, n == null ? void 0 : n.filter((g) => !(g != null && g.group) && m.key == "default" || g.group == m.key), m.key == "default" ? o : null) })).concat(a), [i, o, a]); return d && E.cloneElement(d, { items: p, basicForm: e, $setting: { ...s, ...l } }); }, Hi = ({ name: t, form: e = null, basicForm: i = null, style: n = {}, className: r, cols: a = 12, rowHeight: o = 21, containerPadding: s = [0, 0], itemMargin: l = [4, 0], formProps: d = {}, formFields: u = [], fields: p = [], data: m, theme: g, themeProps: y = {}, groups: b = [{ key: "default", label: "默认" }], children: C, ...S }) => { const [v] = ae.useForm(e), k = U(() => [{ name: "__PROPS__", value: d }].concat(u), [d, u]); ht(() => (v.setFieldsValue(m), () => v.resetFields()), [m]); const $ = (T, A, F) => { const M = Zt(A, pr, i), z = zi(S); return j("div", { ...z, className: R("ff-grid-layout", r), style: { ...n, "--grid-layout-item-margin-y": `${(l == null ? void 0 : l[0]) || 0}px`, "--grid-layout-item-margin-x": `${(l == null ? void 0 : l[1]) || 0}px`, "--grid-layout-container-padding-y": `${(s == null ? void 0 : s[0]) || 0}px`, "--grid-layout-container-padding-x": `${(s == null ? void 0 : s[1]) || 0}px`, "--grid-layout-cols": a, "--grid-layout-row-height": `${o}px` }, children: [M, F && E.cloneElement(F, { cols: a, rowHeight: o, itemMargin: l, containerPadding: s, fields: A, basicForm: i })] }); }; return h(ae, { ...S, fields: k, form: v, component: !1, children: g ? h(_i, { ...y, items: b, theme: g, itemRender: $, fields: p, children: C, basicForm: i }) : $(0, p, C) }); }, Ca = /* @__PURE__ */ ((t) => function({ code: e, data: i, ...n }) { const { uuid: r, resource: a, items: o, hides: s, rowHeight: l, marginX: d, marginY: u, cols: p, theme: m, themeProps: g, groups: y } = dr(e) || {}, b = U(() => [{ name: "__RESOURCE__", value: a }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: r }], [e, r, a]); return a && h(t, { name: e, theme: m, themeProps: g, groups: y, ...n, fields: o, formFields: b, rowHeight: l, cols: p, itemMargin: [d, u], data: a ? { [a]: i } : i }); })(Hi), hr = ({ column: t = 0, colWidth: e = 0, cols: i, rowHeight: n, itemMargin: r, fields: a, primaryKey: o, dataSource: s, beforeRender: l = null, afterRender: d = null, itemClassName: u, itemRender: p = (v, k, $) => v, empty: m = h(zt, { description: null }), className: g, style: y = {}, theme: b, themeProps: C = {}, groups: S = [{ key: "default", label: "默认" }] }) => { const { classNames: v } = pe(oe), k = U(() => h(Hi, { groups: S, theme: b, themeProps: C, cols: i, rowHeight: n, itemMargin: r, fields: a, className: u }), [a, i, n, r, S, b, C]), $ = f.isEmpty(s); return j("div", { className: R("ff-data-list-content", v.content, g), style: Object.assign({}, y, t && { "--col-num": t }, e && { "--col-width": e }), children: [l == null ? void 0 : l(s), $ ? m : s.map((T, A) => { const F = p(E.cloneElement(k, { data: T }), T, A); return E.cloneElement(F, { key: `${(T == null ? void 0 : T[o]) ?? A}-${Un(T)}` }); }), d == null ? void 0 : d(s)] }); }, mr = ({ component: t, $props: e }) => { const { base62params: i } = gt(e, {}); return h(ee, { children: h(ei, { listCode: t, base62params: I.decode(i) }) }); }, ka = () => h(Ji, {}), Ji = () => "Empty", fr = ({ component: t, $setting: e, $props: i }) => { const [n, r] = L(); V(() => { if (!t) return r(h(Ji, { description: null })); ue.getWidgetComponent(t).catch((o) => ({ default: () => `${o}` })).then((o) => E.createElement(o.default, { $setting: e })).then(r); }, [t]); const a = gt(i, {}); return n ? E.cloneElement(n, a) : null; }, Sa = () => "NotFoundPage"; var Oe, ce, Fe, Ae, at, ot; const ye = class ye { constructor() { x(this, ce, /* @__PURE__ */ new Map()); x(this, Fe, {}); x(this, Ae, null); N(this, "init", (e, i) => { B(this, ce, e), B(this, Fe, i); }); N(this, "get", (e) => (c(this, ce).has(e) || (e = Array.from(c(this, ce).keys()).find((i) => c(this, ce).get(i).uri === e)), c(this, ce).get(e) || {})); N(this, "redirect", (e, i, n = {}) => { const { uri: r, type: a, widgetProps: o } = this.get(e) || {}, { router: s, query: l, ...d } = i || {}, u = Object.assign({}, d, s), p = Object.assign({}, d, l); a == "list" && (u.base62params = I.encode(u != null && u.base62params ? u.base62params : u)); let m = jn(r || e, u); const g = new URLSearchParams(); for (const y in o || {}) (o == null ? void 0 : o.type) == "query" && Object.has(p, y) && g.append(y, JSON.stringify(p[y])); return g.size > 0 && (m = `${m}?${g.toString()}`), n != null && n.isOpenWindow ? window.open(m) : c(this, Ae).navigate(m, { replace: !!(n != null && n.isReplaceRouteHistory) }); }); N(this, "getMenus", (e) => { var i; return ((i = c(this, Fe)) == null ? void 0 : i[e]) || []; }); N(this, "findMenuPathByUuid", (e) => { let i = []; for (const n in c(this, Fe)) if (i = c(this, at).call(this, c(this, Fe)[n], e, [n]), i.length > 1) return i; return i; }); N(this, "getMenusByRouteUuid", (e) => c(this, ot).call(this, e, Object.values(c(this, Fe)).flat())); x(this, at, (e, i, n = []) => { if (f.isEmpty(e)) return n; for (const { uuid: r, children: a } of e) { if (r == i) return n.concat(r); if (!f.isEmpty(a)) return n.concat(r, c(this, at).call(this, a, i)); } return n; }); x(this, ot, (e, i) => { var r; let n = []; for (const a of i) a.widgetType == "redirect" && (a.uuid == e || a.widget == e ? n.push(a) : (r = a.children) != null && r.length && (n = n.concat(c(this, ot).call(this, e, a.children)))); return n; }); N(this, "getCurrentMenu", () => { const { uuid: e } = this.getCurrentRoute() || {}; if (!e) return; const i = this.getMenusByRouteUuid(e); return f.isEmpty(i) ? void 0 : i[0]; }); N(this, "getCurrentRoute", (e = 0) => { var n; const i = (n = c(this, Ae).state.matches[c(this, Ae).state.matches.length - 1 - e]) == null ? void 0 : n.route; if (!i) return null; for (let [r, a] of c(this, ce)) if (a.uri === i.path) return a; return null; }); N(this, "getPageParams", (e) => { var r, a, o; let i = "", n = {}; if (Ti()) n = Ln(), i = (r = In()) == null ? void 0 : r.search; else { const { location: s = {}, matches: l = [] } = ((a = c(this, Ae)) == null ? void 0 : a.state) || {}; n = ((o = l[l.length - 1]) == null ? void 0 : o.params) || {}, i = s.search; } return i && new URLSearchParams(i).forEach((s, l) => { n[l] = s; }), e ? f.get(n, e) : n; }); N(this, "createBrowserRouter", (e = {}) => { if (c(this, ce).size == 0) return null; const i = qe.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/ff/frameworks/DefaultTheme"), n = qe.get(ue.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), r = { [i]: 0 }, a = (s, l) => () => Promise.all([ue.getWidgetComponent(s), gt(l)]).then(([d, u]) => [d.default || function() { return `${s}`; }, u]).then(([d, u]) => ({ Component: () => E.createElement(Oi, {}, E.createElement(d, { $setting: u })) })), o = Array.from(c(this, ce).values()).reduce((s, { uuid: l, uri: d, name: u, type: p, component: m, widgetSetting: g, widgetProps: y, isLogin: b, isLayout: C, extra: S }) => { let v = {}, k = 0; switch (p) { case "list": v.element = E.createElement(mr, { component: m, $props: y }); break; case "fsdpf-component": v.element = E.createElement(fr, { key: m, component: m, $setting: g, $props: y }); } const $ = (S == null ? void 0 : S.theme) ?? (S == null ? void 0 : S.layout); if ($) { const T = (S == null ? void 0 : S.themeProps) ?? (S == null ? void 0 : S.layoutProps); if (!r[$]) return r[$] = s.length, [...s, { path: "/", lazy: a($, T), children: [{ path: d, ...v }] }]; k = r[$]; } return C && k > -1 ? (s[k].children.push({ path: d, ...v }), s) : [...s, { path: d, ...v }]; }, [{ path: "/", lazy: a(i, {}), children: [] }]); return o.push({ index: !0, element: E.createElement(yr, { to: n, replace: !0 }) }), B(this, Ae, Mn(o, e)); }); if (c(ye, Oe)) return c(ye, Oe); } }; Oe = new WeakMap(), ce = new WeakMap(), Fe = new WeakMap(), Ae = new WeakMap(), at = new WeakMap(), ot = new WeakMap(), x(ye, Oe, null), N(ye, "getInstance", () => (c(ye, Oe) || B(ye, Oe, new ye()), c(ye, Oe))); let _t = ye; const yr = ({ to: t, replace: e }) => Ti() ? E.createElement(Vn, { to: t, replace: e }) : (window.document.location = t, "redirect"), xe = _t.getInstance(), Ue = new Worker(new URL("/ff-worker/index.js", self.location)), bi = { getConfigure: (t) => qe.get(t), route: { redirect: (...t) => xe.redirect(...t), getPageParams: (...t) => xe.getPageParams(...t), getCurrentRoute: () => xe.getCurrentRoute() }, popup: { notification: (...t) => ne.notification(...t), success: (...t) => ne.success(...t), error: (...t) => ne.error(...t), form: (...t) => ne.form(...t), modal: (...t) => ne.modal(...t), confirm: (...t) => ne.confirm(...t) } }; var Nt, Je, je; const q = class q { constructor() { N(this, "exec", (e, i = {}, n = {}, r = "") => new Promise((a, o) => { if (!/^(?!\s*(\/\/|\/\*|\*)).*?\S+/m.test(e)) return a(); const s = pi(q, Nt)._++; c(q, Je).set(s, n), q.mQueue.set(s, [a, o]), Ue.postMessage({ id: s, session: r, category: "eval", method: e, args: i }); })); N(this, "clear", (e) => Ue.postMessage({ session: e, category: "clear" })); if (c(q, je)) return c(q, je); Promise.resolve().then(() => qr).then((e) => { bi.http = e.http; }), Ue.addEventListener("message", ({ data: { id: e, task_id: i, method: n, args: r, category: a, data: o, error: s, session: l } }) => { if (a === "eval" && q.mQueue.has(e)) s !== null ? q.mQueue.get(e)[1](s) : q.mQueue.get(e)[0](o), c(q, Je).delete(e), q.mQueue.delete(e); else if (a === "util") try { const d = f.get(bi, n.split("/")) || f.get(c(q, Je).get(i), n.split("/")); if (!f.isFunction(d)) throw `${n} not found`; Promise.resolve(Reflect.apply(d, void 0, r)).then((u) => { Ue.postMessage({ id: e, task_id: i, category: a, method: n, args: r, session: l, data: u, error: null }); }).catch((u) => { Ue.postMessage({ id: e, task_id: i, category: a, method: n, args: r, session: l, data: null, error: u }); }); } catch (d) { Ue.postMessage({ id: e, task_id: i, category: a, method: n, args: r, session: l, data: null, error: d }); } }, !1); } }; Nt = new WeakMap(), Je = new WeakMap(), je = new WeakMap(), N(q, "mQueue", /* @__PURE__ */ new Map()), x(q, Nt, 0), x(q, Je, /* @__PURE__ */ new Map()), x(q, je, null), N(q, "getInstance", () => (c(q, je) || B(q, je, new q()), c(q, je))); let Ht = q; const Ie = Ht.getInstance(), Tt = () => { const t = H(!0), [, e] = E.useReducer((i) => i + 1, 0); return V(() => () => t.current = !1, []), () => t.current && e(); }, Ea = (t) => { const e = H(); return V(() => { e.current = t; }, [t]), e.current; }, $a = (t) => { const [e, i] = L(t), n = H(null), r = Y((a, o) => { n.current = o, i(a); }, []); return V(() => { n.current && (n.current(e), n.current = null); }, [e]), [e, r]; }, ht = (t = (n) => { }, e, i = f.isEqual) => { const n = E.useRef(); i(e, n.current) || (n.current = f.cloneDeep(e)), E.useEffect(t, [n.current]); }, mt = ht, Gi = (t, e = "string") => { var i; if (!Array.isArray(t)) return t; for (let n = 0; n < t.length; n++) t[n].value = de((i = t[n]) == null ? void 0 : i.value, e), t[n] && Reflect.has(t[n], "children") && (t[n].children = Gi(t[n].children, e)); return t; }, va = (t, e = "json", i = "string", n, r = null) => { const [a] = ae.useForm(n), [o, s] = L([{ label: "无", value: "", disabled: !0 }]), l = H([]), d = ae.useWatch((u) => l.current.length === 0 ? null : f.pick(u, l.current), a) || null; return V(() => { Array.isArray(t) ? s(t) : e === "javascript" && t ? Ie.exec(t, {}, { getFieldValue: (u) => (l.current.includes(u) || l.current.push(u), a.getFieldValue(u)), getFieldValueForBasicForm: (u) => (l.current.includes(u) || l.current.push(u), r ? r.getFieldValue(u) : a.getFieldValue(u)) }).then((u) => { s(de(u, "array")); }).catch((u) => console.error("useOptions", u)) : t && s(de(t, "array")); }, [t, e, d]), Gi(o, i); }, xa = (t) => { const [e, i] = L(), n = { type: "GET" }; if (typeof t == "string" ? n.url = t : f.isPlainObject(t) && Object.assign(n, t), !(n != null && n.url)) throw "url is required"; const r = (a) => I.request(n, !1).resp((o) => (console.log("useSubscribeRequest", a), i(o), o)); return ht(() => { let a = null; return r().then((o) => { a = qi.subscribe(f.throttle(r, 180, { leading: !1, trailing: !0 }), o.res); }), () => a == null ? void 0 : a(); }, n), e; }, wr = (t) => { const [e, i] = E.useState({ items: [], hides: [] }); return E.useEffect(() => { t && I.get(`/api/_/${t}`).then(({ pk: n, uuid: r, code: a, resource: o, align: s, cols: l, rowHeight: d, marginX: u, marginY: p, listenChangeFields: m, listenChangeFieldsFunc: g, fields: y, theme: b, themeSetting: C, groups: S }) => ({ pk: n, uuid: r, code: a, resource: o, align: s, cols: l, rowHeight: d, marginX: u, marginY: p, theme: b, themeProps: C, groups: S, listenChangeFields: m, listenChangeFieldsFunc: g, ...y.reduce((v, k) => { var $; return ($ = k == null ? void 0 : k.field) != null && $.hidden ? v.hides.push(k == null ? void 0 : k.field) : v.items.push(k), v; }, { items: [], hides: [] }) })).then(i); }, [t]), e; }, br = ({ max: t = 0, min: e = 0, type: i = "", message: n, pattern: r, required: a = !1, validator: o } = {}, s, l) => { const [d, u] = L([]); return V(() => { const p = []; if (a) { let m = l; switch (l) { case "number": case "string": case "array": break; case "bool": m = "boolean"; break; case "json": m = "object"; } p.push({ type: m, required: !0, whitespace: !0, message: "该项必填" }); } switch (i) { case "string": p.push({ type: i, max: t, min: e, message: n || (e && t ? `字符必须在 ${e} ~ ${t} 之间` : `${t ? "最多能有" : "最少要有"} ${e || t} 个字符`) }); break; case "pattern": p.push({ type: "string", pattern: r, message: n }); break; case "validator": o && p.push(({ getFieldValue: m }) => ({ validator: async (g, y) => { const b = await Ie.exec(o, { value: y, fieldName: s }, { getFieldValue: m }); return f.isString(b) && b ? Promise.reject(b) : f.isBoolean(b) && !b ? Promise.reject(n) : Promise.resolve(); } })); } u(p); }, [t, e, i, n, r, a, o]), d; }, Cr = (t, e, i) => { const [n, r] = L(null); return V(() => { const { initDataUri: a = `/api/${t}`, initDataMethod: o = "GET" } = i || {}; e && I.request({ method: o, url: f.trimEnd(`${a}/${e}`, "/") }).then((s) => { r(s); }); }, [t, e, i]), n; }, kr = (t, e, i) => Y((n, r = { serialize: (a) => a, onSuccess: () => { }, onFail: (a) => (a == null ? void 0 : a.errorFields) && ne.error("请先完善表单信息", { duration: 2e3 }) }) => { const a = n.getFieldValue("__RESOURCE__"), { submitDataUri: o = `/api/${t}`, submitDataMethod: s = "POST" } = i || {}; return n.validateFields().then((l) => a ? f.pick(l, [a]) : l).then(r.serialize).then((l) => I.request({ method: s, url: f.trimEnd(`${o}/${e || ""}`, "/"), data: l }).msg(r.onSuccess)).catch(r.onFail); }, [t, e, i]), Sr = (t, e, i, n) => { const r = Cr(e, i, n); V(() => { r ? t.setFieldsValue(r) : t.resetFields(); }, [t, r]); const a = kr(e, i, n); return f.partial(a, t); }, Er = (t, e, i = [], n = {}) => { const r = H({}), a = H(), o = f.debounce(Tt(), 180), s = ["disabled", "required"], l = (m, g) => { s.includes(m) && (r.current[m] = g), o(); }, d = U(() => ({ setDisabled: (m) => l("disabled", m), setRequired: (m) => l("required", m), getDisabled: () => r.current.disabled, getRequired: () => r.current.required }), [e]), [u, p] = Ki(e, -1, {}, d, n); if (!p && a.current != u && (u >= 0 || !f.isEmpty(i == null ? void 0 : i[u]))) { a.current = u; const { widget: m, widgetPrefix: g, props: y } = i == null ? void 0 : i[u]; t = ji(m, g), r.current = f.merge(y, f.pick(r.current, s)); } return [t, r.current]; }, Ci = (t) => t === void 0 || t === !1 ? "" : (Array.isArray(t) ? t : [t]).join("_"), Na = ({ value: t, onChange: e }, i = null) => { const n = H(), [r] = ae.useForm(i), a = H({}); return mt(() => { f.isEqual(n.current, t) || r.setFieldsValue(t); }, [t]), V(() => () => r.resetFields(), []), [U(() => r.__INTERNAL__ ? r : { ...r, __INTERNAL__: { itemRef: (o) => (s) => { const l = Ci(o); s ? a.current[l] = s : delete a.current[l]; } }, scrollToField: (o, s = {}) => { console.warn("useMergedFormValuesChange scrollToField not work, unreferenced antd form"); }, focusField: (o) => { console.warn("useMergedFormValuesChange focusField not work, unreferenced antd form"); }, getFieldInstance: (o) => { const s = Ci(o); return a.current[s]; } }, [r]), (o, s) => { n.current = s, e == null || e(s); }]; }, ti = ({ widget: t = "Input", widgetPrefix: e = "@pkg/ff/grid-layout-forms", widgetDecorator: i, subWidgets: n = [], basicForm: r, ...a }) => { const o = ji(t, e), [s, l] = Er(o, i, n, r), [d, u] = L(); return V(() => { s && ue.getWidgetComponent(s).then(({ defaultProps: p = {}, default: m }) => ({ default: $r(m, p, r) })).catch((p) => ({ default: () => `${p}` })).then((p) => u(E.createElement(p.default, a))); }, [s]), d && E.cloneElement(d, { ...a, ...l }); }, $r = (t, e = {}, i = null) => (n) => { const { type: r, code: a, label: o, noStyle: s, style: l, placeholder: d, required: u = !1, extras: p, validators: m, help: g, isVirtual: y, $isReserved: b, initialValue: C, initialValueLanguage: S, ...v } = f.omit(f.merge({}, e, n), ["convertJs", "convertJsSetting", "widget", "widgetPerfix", "widgetDecorator", "subWidgets", "boxStyle"]), k = br(Object.assign({}, m, u ? { required: !0 } : {}), a, r), $ = U(() => { const z = Object.keys((e == null ? void 0 : e.extras) || {}); return f.over([f.partialRight(f.pick, z), f.partialRight(f.omit, z)]); }, [e == null ? void 0 : e.extras]), [T, A] = $(v), F = { label: o, noStyle: s, style: l, colon: !1, layout: "vertical" }, M = Y((z) => z == null ? void 0 : de(z, r), [r]); return h(Xt, { name: a, rules: k, initialValue: M(C), normalize: M, children: (z, O, D) => { var K; return h(t, { type: r, rcform: D, basicForm: i, itemProps: { validateStatus: O.errors.length > 0 ? "error" : "success", tooltip: g || null, help: O.errors.length > 0 ? O.errors.join("、") : null, required: ((K = k == null ? void 0 : k[0]) == null ? void 0 : K.required) || !1, ...F }, fieldProps: { placeholder: d, ...A, ...z }, $setting: Object.assign({}, p, T) }); } }); }, ii = ({ name: t, form: e = null, basicForm: i = null, style: n = {}, className: r, cols: a = 24, rowHeight: o = 16, itemMargin: s = [8, 16], containerPadding: l = [0, 0], fields: d = [], hides: u = [], primaryKey: p = 0, formProps: m = {}, formFields: g = [], listenChangeFields: y, listenChangeFieldsFunc: b, onValuesChange: C, theme: S, themeProps: v = {}, groups: k = [{ key: "default", label: "默认" }], children: $, ...T }) => { const [A] = ae.useForm(e), F = Y((O, D) => { C == null || C(O, D), b && Array.isArray(y) && Ie.exec(b, { changedValues: O, allValues: D }, { getFieldValue: A.getFieldValue, setFieldValue: A.setFieldValue, setFieldsValue: A.setFieldsValue, isFieldTouched: A.isFieldTouched, isFieldsTouched: A.isFieldsTouched }).catch((K) => console.error("onFormValuesChange", t, K)); }, [t, A, C, y, b]), M = U(() => [{ name: "__PROPS__", value: m }, { name: "__PRIMARY_KEY__", value: p }].concat(g), [p, m, g]), z = (O, D, K) => { const _ = Zt(D, ti, i), re = zi(T); return j("div", { ...re, className: R("ff-grid-layout-form", r), style: { ...n, "--grid-layout-item-margin-x": `${(s == null ? void 0 : s[0]) ?? 8}px`, "--grid-layout-item-margin-y": `${(s == null ? void 0 : s[1]) ?? 16}px`, "--grid-layout-container-padding-y": `${(l == null ? void 0 : l[0]) || 0}px`, "--grid-layout-container-padding-x": `${(l == null ? void 0 : l[1]) || 0}px`, "--grid-layout-cols": a, "--grid-layout-row-height": `${o}px` }, children: [_, K && E.cloneElement(K, { cols: a, rowHeight: o, itemMargin: s, containerPadding: l, fields: D, basicForm: i })] }); }; return j(ae, { ...T, form: A, fields: M, onValuesChange: F, children: [S ? h(_i, { ...v, items: k, theme: S, itemRender: z, fields: d, children: $, basicForm: i }) : z(0, d, $), u == null ? void 0 : u.map((O) => { var D; return h(Xt, { name: O.code, children: h(vr, { form: A, basicForm: i, name: O.code, type: O.type, initialValue: O.initialValue, initialValueLanguage: (D = O.extras) == null ? void 0 : D.initialValueLanguage }) }, JSON.stringify(O.code)); })] }); }, vr = ({ type: t, initialValue: e, initialValueLanguage: i, onChange: n, basicForm: r }) => { const [a, o] = Ki(i == "javascript" && e, i == "javascript" ? void 0 : e, {}, {}, r); return V(() => { i == "javascript" ? n(de(a, t)) : e && n(de(e, t)); }, [t, e, a]), null; }; ii.propTypes = { fields: w.array, hides: w.array }; const xr = /* @__PURE__ */ ((t) => ({ code: e, isPreview: i = !1, ...n }) => { const { align: r, autoComplete: a, resource: o, items: s, hides: l, rowHeight: d, marginX: u, marginY: p, cols: m, listenChangeFields: g, listenChangeFieldsFunc: y, pk: b, uuid: C, theme: S, themeProps: v, groups: k } = wr(e), $ = U(() => [{ name: "__PK__", value: b }, { name: "__RESOURCE__", value: o }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: C }], [b, e, C, o]); return h(t, { name: e, autoComplete: a, theme: S, themeProps: v, groups: k, ...n, formFields: $, listenChangeFields: g, listenChangeFieldsFunc: y, fields: s, hides: l, cols: m, rowHeight: d, itemMargin: [u, p] }); })(ii), Yi = ({ $setting: t, $close: e, extras: i, code: n, primaryKey: r, ...a }) => { const [o] = ae.useForm(), s = Sr(o, n, r, t); return h(ee, { actions: j(E.Fragment, { children: [h(P, { name: (t == null ? void 0 : t.okText) || "保存", type: "primary", widget: () => s({ onSuccess: e }) }), h(P, { name: (t == null ? void 0 : t.cancelText) || "取消", widget: () => e(!1) })] }), extras: i, children: h(xr, { form: o, code: n, primaryKey: r, ...a }) }); }, ki = /* @__PURE__ */ new Set(), Jt = (t = [], e = 0) => { const i = t[e]; if (i.length && !ki.has(i)) { const n = document.createElement("script"); n.setAttribute("src", i), n.setAttribute("data-namespace", i), t.length > e + 1 && (n.onload = () => { Jt(t, e + 1); }, n.onerror = () => { Jt(t, e + 1); }), ki.add(i), document.body.appendChild(n); } }, St = ({ className: t, type: e, style: i = {}, ...n }) => h("span", { role: "img", className: R("ff-iconfont", t), style: i, ...n, children: h("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: h("use", { xlinkHref: `#${e}` }) }) }); St.propTypes = { className: w.string, type: w.string.isRequired, style: w.object }, St.init = Jt; const Nr = (t, e, i, n) => xe.redirect(i, e, n), Pr = (t, e = {}, i, n = {}) => { var a; const r = (a = n.router) == null ? void 0 : a.reduce((o, [s, l, d]) => { const u = f.get(e, ["router", s]); if (!u && u !== 0 && l) throw `请传入 ${d}`; return `${o}/${u}`; }, `/api/${i}`); return I.del(r, e.param).msg(); }, Si = (t, e, i, { status: { loading: n, disabled: r }, setStatus: a, listFn: o }) => { const s = { loading: (l) => l === void 0 ? n : a((d) => ({ ...d, loading: l })), disabled: (l) => l === void 0 ? r : a((d) => ({ ...d, disabled: l })), list: o }; return f.isFunction(i) ? i.call(null, e, s) : f.isString(i) && i ? Ie.exec(i, e, s) : null; }, Ei = (t, e, i, n, r) => f.isString(i) && i ? ue.getWidgetComponent(i).then(({ default: a }) => ne.modal(a, { ...e, $setting: n }, r != null && r.title ? { ...r, title: f.template(r.title)(t) } : r)).catch((a) => { ne.error(i, { content: a.toString() }); }) : ne.modal(i, { ...e, $setting: n }, r != null && r.title ? { ...r, title: f.template(r.title)(t) } : r), Tr = (t, e, i, n, r) => ne.modal(Yi, { ...e, $setting: n, code: i }, r != null && r.title ? { ...r, title: f.template(r.title)(t) } : r), Rr = (t, e, i, n, r) => ne.modal(ei, { base62params: e, $setting: n, listCode: i }, r != null && r.title ? { ...r, title: f.template(r.title)(t) } : r), Or = ({ widget: t, widgetType: e, widgetData: i, widgetProps: n, widgetSetting: r, widgetContainerProps: a }, { onAfterClick: o, onBeforeClick: s } = {}) => { const l = pe(oe), [d, u] = L({ leading: !0, trailing: !1 }), p = U(() => { switch (e) { case "redirect": return f.partialRight(Nr, t, r); case "func": return f.partialRight(Si, (r == null ? void 0 : r.code) ?? t, { status: d, setStatus: u, listFn: l }); case "component": case "fsdpf-component": return f.partialRight(Ei, t, r, a); case "grid-layout-form": return f.partialRight(Tr, t, r, a); case "data-list": return f.partialRight(Rr, t, r, a); case "destroy": return f.partialRight(Pr, t, r, a); default: if (ri(t) || E.isValidElement(t)) return f.partialRight(Ei, t, r, a); if (f.isFunction(t)) return f.partialRight(Si, (r == null ? void 0 : r.code) || t, { status: d, setStatus: u }); } return (...m) => console.error("useButton unknown widgetType", e, ...m); }, [t, e, l.getBase62params, l.getSelectedRows]); return [f.debounce((m) => (s == null || s(m), Promise.resolve(gt(n, m, { list: l })).then((g) => p(m, { ...i, ...g })).then((g) => o == null ? void 0 : o(g)).catch(console.error)), 300, { leading: !0, trailing: !1 }), d]; }, Xi = ({ type: t, name: e, className: i, icon: n, iconPosition: r, size: a }, o = "default") => U(() => { const s = { type: "primary", className: R("ff-button", i), iconPosition: r, size: a }; return t === "danger" ? s.danger = !0 : t === "default" && (s.type = t), o === "link" || o === "dashed" ? (s.type = o, t === "default" && (s.className = R(s.className, "ff-default"))) : o !== "circle" && o !== "round" || (s.shape = o), n && (s.icon = h(St, { type: n })), e && (s.children = e), s; }, [o, t, i, n, r]), Rt = ({ data: t, widget: e, widgetType: i = "fsdpf-component", widgetData: n, widgetProps: r, widgetSetting: a, widgetContainerProps: o, onAfterClick: s, onBeforeClick: l, children: d, extras: u }) => { const p = pe(oe), [m, g] = L(!1), [y, b] = L("hover"), [C, S] = L({}), [v, k] = L(), { placement: $, align: T, zIndex: A, arrow: F = { pointAtCenter: !0 }, getPopupContainer: M, isPopupMountBodyContainer: z = !0, ...O } = o || {}; V(() => { i == "grid-layout-form" ? k(E.createElement(Yi, { ...n, $setting: a, code: e })) : i == "data-list" ? k(E.createElement(ei, { base62params: t, $setting: a, listCode: e })) : f.isString(e) ? ue.getWidgetComponent(e).then(({ default: _ }) => { k(E.createElement(_, { ...n, $setting: a })); }).catch((_) => k(_.toString())) : ri(e) ? k(E.createElement(e, { ...n, $setting: a })) : E.isValidElement(e) && k(E.cloneElement(e, { ...n, $setting: a })); }, [e, i, n]), V(() => { Promise.resolve(gt(r, t, { list: p })).then(S); }, [r, t, p.getBase62params, p.getSelectedRows]); const D = (_, re = !1) => (g(_), !_ && b("hover"), _ ? l == null ? void 0 : l(C) : s == null ? void 0 : s(re)), K = (_) => { g(!0), b("click"); }; return h(Tn, { zIndex: A, placement: $, onPopupClick: K, onClick: K, open: m, align: T, arrow: F, trigger: y, getPopupContainer: M || z ? void 0 : (_) => _, content: h(Fr, { ...O, extras: u, children: v && E.cloneElement(v, { ...C, $close: (_) => D(!1, _) }) }), children: d, onOpenChange: D }); }, Fr = ({ title: t, className: e, classNames: i, children: n, extras: r, width: a, height: o, ...s }) => { const [l, d] = L({}), u = Y((y, b) => d((C) => ({ ...C, [y]: b })), []), p = Y((y) => d((b) => ({ ...b, [y]: void 0 })), []), m = t ? E.createElement("div", { className: "ff-popup-title" }, t) : l == null ? void 0 : l.title, g = r ?? E.createElement("div", { className: "ff-popup-reserved-extras" }, r); return h(pt.Provider, { value: { ele: l, mount: u, unmount: p }, children: j("div", { className: R("ff-popup ff-popover", e, l.rootClassName), style: { width: a ?? 260, height: o }, ...s, children: [j("div", { className: R("ff-popup-header", "ff-popover-header", i == null ? void 0 : i.header), children: [m, l == null ? void 0 : l["sub-title"]] }), h("div", { className: R("ff-popup-body", "ff-popover-body", i == null ? void 0 : i.body), children: n }), j("div", { className: R("ff-popup-footer", "ff-popover-footer", i == null ? void 0 : i.footer), children: [g, l == null ? void 0 : l.extras, l == null ? void 0 : l.actions] })] }) }); }; Rt.propTypes = { widgetType: w.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) }; const ft = (t) => function({ className: e, variant: i, children: n, name: r, icon: a, type: o = "default", iconPosition: s = "start", noAuthType: l, onAfterClick: d, onBeforeClick: u, data: p, loading: m, disabled: g, tooltip: y, confirm: b, widget: C = () => { }, widgetType: S, widgetData: v, widgetProps: k, widgetSetting: $, widgetContainerProps: T, ...A }) { const { mode: F, ...M } = T || {}, z = Xi({ className: e, name: r, type: o, icon: a, iconPosition: s }, i ?? t), O = h(Ct, { ...z, ...A, children: n || r }); if (F === "popover" && !["destroy", "redirect", "func"].includes(S)) return h(Rt, { data: p, widget: C, widgetType: S, widgetData: v, widgetProps: k, widgetSetting: $, widgetContainerProps: M, onAfterClick: d, onBeforeClick: u, children: O }); const D = f.isEmpty(y) || !y.enabled ? {} : y, K = f.isEmpty(b) ? { enabled: !1 } : Object.assign({ enabled: !0 }, b), [_, re] = L(!1), [Ne, { disabled: W, loading: se }] = Or({ widget: C, widgetType: S, widgetData: v, widgetProps: k, widgetSetting: $, widgetContainerProps: M }, { onAfterClick: d, onBeforeClick: u }); return h(Rn, { okText: "确定", cancelText: "取消", getPopupContainer: (J) => J, ...K, disabled: W || g, open: _, onOpenChange: (J) => { if (!J) return re(J); K.enabled ? re(J) : Ne(p); }, onConfirm: (J) => { Ne(p, J); }, onClick: (J) => { J.stopPropagation(); }, children: h(On, { getPopupContainer: (J) => J, ...D, title: _ ? null : D == null ? void 0 : D.title, trigger: ["hover", "click"], children: E.cloneElement(O, { loading: se || m, disabled: W || g }) }) }); }, P = ft("default"); P.propTypes = { type: w.oneOf(["primary", "default", "danger", ""]), size: w.oneOf(["large", "middle", "small"]), name: w.string, icon: w.string, iconPosition: w.oneOf(["start", "end"]), data: w.any, widget: w.any, widgetType: w.oneOf(["destroy", "redirect", "func", "component", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: w.object, widgetProps: w.object, widgetSetting: w.object, widgetContainerProps: w.object, tooltip: w.exact({ title: w.string.isRequired, placement: w.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: w.oneOfType([w.bool, w.number]), getPopupContainer: w.func }), confirm: w.exact({ title: w.string.isRequired, cancelText: w.string, okText: w.string, okType: w.oneOf(["primary", "default", "danger", ""]), placement: w.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: w.oneOfType([w.bool, w.number]), getPopupContainer: w.func, arrow: w.oneOfType([w.bool, w.exact({ pointAtCenter: w.bool })]) }) }; const Ar = ft("link"), jr = ft("circle"), Lr = ft("round"), Ir = ft("dashed"), $i = ({ options: t = [], triggerWeights: e = ["grid-layout-form", "grid-layout", "fsdpf-component", "print"], onAfterClick: i = (g, y, b) => { }, onBeforeClick: n = (g, y, b) => { }, labelVariant: r = "link", labelSize: a, labelRender: o, btnVariant: s, btnSize: l, btnRender: d = (g, y) => h(P, { ...g, data: y }, g.uuid || Vt()), widgetContainerProps: u = {}, children: p, data: m }) => { if (f.isEmpty(t)) return p; const [g, y] = U(() => (t || []).reduce((C, S) => { const v = e.indexOf(S.widgetType); return v === -1 ? C[1].push(S) : C[0] ? v < e.indexOf(C[0].widgetType) ? (C[1].push(C[0]), C[0] = S) : C[1].push(S) : C[0] = S, C; }, [null, []]), [t, e]); o ? p = o(g, m) || p : p || (p = h(Ct, { ...Xi(Object.assign(g != null && g.name || g != null && g.icon ? {} : { icon: "icon-location" }, g, { size: a }), r) })); const b = y.map((C) => d(Object.assign({ uuid: C.uuid, type: C.type, name: C.name, widget: C.widget, widgetType: C.widgetType, widgetProps: C.widgetProps, widgetData: C.widgetData, widgetSetting: C.widgetSetting, widgetContainerProps: C.widgetContainerSetting, confirm: C.confirm, onAfterClick: f.partialRight(i, C, m), onBeforeClick: f.partialRight(n, C, m) }, { size: l, variant: s }), m)); return h(Rt, { widget: g == null ? void 0 : g.widget, widgetType: g == null ? void 0 : g.widgetType, widgetProps: g == null ? void 0 : g.widgetProps, widgetSetting: g == null ? void 0 : g.widgetSetting, widgetContainerProps: Object.assign({}, u, g == null ? void 0 : g.widgetContainerProps), data: m, widgetData: g == null ? void 0 : g.widgetData, extras: b, onAfterClick: f.partialRight(i, g, m), onBeforeClick: f.partialRight(n, g, m), children: p }); }; $i.propTypes = { triggerWeights: w.array, options: w.arrayOf(w.shape({ ...P.propTypes, widgetType: P.propTypes.widgetType.isRequired })), btnSize: P.propTypes.size, btnRender: w.func, btnVariant: w.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelVariant: w.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelRender: w.func, labelSize: P.propTypes.size, onAfterClick: w.func, onBeforeClick: w.func, widgetContainerProps: P.propTypes.widgetContainerProps, data: P.propTypes.data }, P.Link = Ar, P.Link.defaultProps = P.defaultProps, P.Link.propTypes = P.propTypes, P.Circle = jr, P.Circle.defaultProps = P.defaultProps, P.Circle.propTypes = P.propTypes, P.Round = Lr, P.Round.defaultProps = P.defaultProps, P.Round.propTypes = P.propTypes, P.Dashed = Ir, P.Dashed.defaultProps = P.defaultProps, P.Dashed.propTypes = P.propTypes, P.Popover = Rt, P.GroupPopover = $i; const Mr = ({ fields: t, formProps: e, $close: i }) => { const [n] = ae.useForm(), r = U(() => [{ name: "__PROPS__", value: e }], [e]); return h(ee, { actions: j(E.Fragment, { children: [h(P, { name: "取消", widget: () => i(!1) }), h(P, { name: "确定", type: "primary", widget: () => n.validateFields(!0).then(i) })] }), children: h(ae, { fields: r, form: n, className: "ff-modal-form", children: t == null ? void 0 : t.map(({ code: a, ...o }) => h(ti, { code: a, ...o }, a)) }) }); }, Vr = ({ className: t, classNames: e, $close: i, children: n, title: r, subTitle: a, actions: o, extras: s, ...l }) => j(Dn, { ...l, prefixCls: "ff-drawer", className: R("ff-popup", t), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (d) => ({ motionAppear: !0, motionName: `panel-motion-${d}` }), children: [j("div", { className: R("ff-popup-header", "ff-drawer-header", e == null ? void 0 : e.header), children: [h("button", { "aria-label": "Close", className: R("ff-popup-close", "ff-drawer-close", e == null ? void 0 : e.close), onClick: l.onClose, children: h(Qt, { type: "close" }) }), r, a] }), h("div", { className: R("ff-popup-body", "ff-drawer-body", e == null ? void 0 : e.body), children: n }), j("div", { className: R("ff-popup-footer", "ff-drawer-footer", e == null ? void 0 : e.footer), children: [s, o] })] }), Dr = ({ className: t, classNames: e, $close: i, $event: n, children: r, title: a, subTitle: o, actions: s, extras: l, placement: d, ...u }) => { const p = (n == null ? void 0 : n.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: n == null ? void 0 : n.pageX, y: n == null ? void 0 : n.pageY } }; return h(zn, { ...u, ...p, prefixCls: "ff-modal", modalRender: () => j("div", { className: R("ff-modal-content ff-popup", t), children: [j("div", { className: R("ff-popup-header", "ff-modal-header", e == null ? void 0 : e.header), children: [h("button", { "aria-label": "Close", className: R("ff-popup-close", "ff-modal-close", e == null ? void 0 : e.close), onClick: u.onClose, children: h(Qt, { type: "close" }) }), a, o] }), h("div", { className: R("ff-popup-body", "ff-modal-body", e == null ? void 0 : e.body), children: r }), j("div", { className: R("ff-popup-footer", "ff-modal-footer", e == null ? void 0 : e.footer), children: [l, s] })] }) }); }, Qi = ({ placement: t, $close: e, $event: i, children: n, title: r, ...a }) => { const [o, s] = L({}), [l, d] = L(!0), u = Y((y, b) => s((C) => ({ ...C, [y]: b })), []), p = Y((y) => s((b) => ({ ...b, [y]: void 0 })), []); let m = { ...a, className: o.rootClassName, title: o.title || r && E.createElement("div", { className: R("ff-popup-title") }, r), subTitle: o["sub-title"], actions: o.actions, extras: o.extras, children: n, $close: e, $event: i, onClose: () => d(!1) }; const g = () => { e(!1); }; return h(pt.Provider, { value: { ele: o, mount: u, unmount: p }, children: t && t !== "center" ? h(Vr, { ...m, placement: t, open: l, afterOpenChange: (y) => !y && g() }) : h(Dr, { ...m, visible: l, afterClose: g }) }); }; Qi.propTypes = { placement: w.oneOf(["center", "left", "top", "right", "bottom"]) }; const ie = () => { const [t, e] = kn({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (a) => { const { offsetHeight: o } = a; return { height: o }; }, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, i] = E.useReducer((a) => a + 1, 0); V(() => { ie.$onClick = n, ie.$queue.forEach(([a, o, s], l, d) => { r([o, s], ...a), delete d[l]; }); }, []); const n = (a, o = {}, s = {}) => new Promise((l, d) => r([l, d], a, o, s)), r = ([a, o], s, l = {}, d = {}) => { const u = ie.$index++, p = (m) => ((g, y) => (ie.$popups.delete(g), i(), y == null ? void 0 : y()))(u, () => a(m)); if (s === Fi) return t.open({ ...d, key: u, content: E.createElement(s, { ...l, $close: () => t.close(u) }) }); ie.$popups.set(u, E.createElement(Qi, { maskClosable: !1, $event: l == null ? void 0 : l.$event, ...d, key: u, $close: p }, E.isValidElement(s) ? E.cloneElement(s, { ...l, $close: p }) : s != null && s.name || gi.isForwardRef(s) || (s == null ? void 0 : s.$$typeof) === gi.ForwardRef ? E.createElement(s, { ...l, $close: p }) : s)), i(); }; return j(E.Fragment, { children: [Array.from(ie.$popups).map(([a, o]) => o), e] }); }; ie.$popups = /* @__PURE__ */ new Map(), ie.$index = 0, ie.$queue = [], ie.$onClick = (...t) => new Promise((e, i) => { ie.$queue.push([t, e, i]); }); const vi = (t, e, i = {}) => ie.$onClick(t, e, i), It = (t, { showProgress: e, duration: i, ...n } = { duration: 1.5 }) => ie.$onClick(Fi, { content: t, ...n }, { showProgress: e, duration: i }), ne = { modal: vi, confirm: (t, e = {}) => ie.$onClick(Wn, { content: t, ...e }, { placement: "center" }), form: (t, e = {}, i = {}) => vi(Mr, { formProps: i, fields: t }, { placement: "center", ...e }).then((n) => { if (n === !1) throw !1; return n; }), notification: It, success: (t, e = { duration: 1.5 }) => It(t, { ...e, className: "ff-notification-success", icon: "check" }), error: (t, e = { duration: 1.5 }) => It(t, { ...e, className: "ff-notification-error", icon: "close" }) }; Ze.configure({ showSpinner: !1 }); const Zi = () => { const t = window.localStorage.getItem(bt); return Object.freeze({ Platform: "web", SaaS: window.localStorage.getItem("SaaS"), Authorization: t ? `Bearer ${t} ` : void 0 }); }; Ve.interceptors.request.use((t) => (Object.assign(t.headers, Zi()), Ze.inc(), t), (t) => (Ze.done(), Promise.reject({ code: -1, msg: t }))), Ve.interceptors.response.use(({ data: t, headers: e }) => (Ze.done(), { ...t, res: e == null ? void 0 : e.res }), function(t) { return Ze.done(), Promise.reject(t.message); }), window.addEventListener("unhandledrejection", Dt.onUnhandledRejection), Dt.onMsg = (t, e) => ne[[0, 1].includes(t) ? "success" : "error"](e).then(() => t === 20300 && xe.redirect(qe.get("Common.WEBSITE_LOGIN_PAGE"))); var Ge, Be, Ye; const Q = class Q { constructor() { N(this, "appUrl", ""); x(this, Ge, null); return c(Q, Be) || (B(Q, Ye, new Dt()), B(Q, Be, new Proxy(this, { get(e, i) { if (i in e) { const n = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e), i); return n != null && n.get ? Reflect.get(e, i, e) : typeof e[i] == "function" ? e[i].bind(e) : e[i]; } return c(Q, Ye)[i]; } }))), c(Q, Be); } init(e, i, n) { Ve.defaults.baseURL = this.appUrl = n, Ve.defaults.timeout = 15e3, c(Q, Ye).init(e, i, Ve); } get driver() { return Ve; } get headers() { return Zi(); } mock(e = {}) { return c(this, Ge) ?? B(this, Ge, new Sn(Ve, { onNoMatch: "passthrough", ...e })); } unmock() { var e; (e = c(this, Ge)) == null || e.restore(), B(this, Ge, null); } }; Ge = new WeakMap(), Be = new WeakMap(), Ye = new WeakMap(), x(Q, Be), x(Q, Ye), N(Q, "getInstance", () => c(Q, Be) ?? B(Q, Be, new Q())); let Gt = Q; const I = Gt.getInstance(); class ni extends Error { constructor(e, i) { super(i), Error.captureStackTrace && Error.captureStackTrace(this, ni), !i instanceof et && (this.name = `${e} Error Runtime`); } } class et extends Error { constructor(e, ...i) { super(...i), Error.captureStackTrace && Error.captureStackTrace(this, et), this.name = `${e} Not Found`; } } const Mt = "mine", bt = "token"; var Le, Xe; const we = class we { constructor() { x(this, Xe, /* @__PURE__ */ new Map()); N(this, "setVendor", (e, i) => c(this, Xe).set(e, new Ri(i, async (n, r) => { var o, s; if (!(n != null && n.default)) throw "@pkg not found"; let a = () => r; switch ("function") { case typeof (a = (o = n.default) == null ? void 0 : o[`./${r}/index.jsx`]): case typeof (a = (s = n.default) == null ? void 0 : s[`./${r}/index.js`]): return a(); } throw new et(r); }))); N(this, "getWidgetComponent", async (e) => { if (!e) throw "getWidgetComponent widget is required"; if (e != null && e.startsWith("blob:") || e != null && e.startsWith("http:") || e != null && e.startsWith("https:")) return await import(e); const [, i] = e == null ? void 0 : e.split("@pkg/"); if (!i) throw new et(e); try { return c(this, Xe).has("pkg") ? await c(this, Xe).get("pkg").get(i) : await import(`${I.appUrl}/api/pkg-import/web?name=${e}`); } catch (n) { throw new ni(e, n); } }); N(this, "getRoutes", () => I.get("/api/my-router").then((e) => [...e, { uuid: "data-list-setting", isLayout: !0, uri: "/data-list-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/DataListSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-setting", isLayout: !0, uri: "/grid-layout-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-form-setting", isLayout: !0, uri: "/grid-layout-form-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutFormSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "resource-api-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ResourceApiSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "charts-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ChartsSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "fsm-setting", isLayout: !0, uri: "/fsm-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/FsmSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "component-setting", isLayout: !0, uri: "/component-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ComponentSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "login", uri: "/login", name: "登录", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/Login" }, { uuid: "not-found", uri: "*", name: "Not Found", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/NotFound" }].map(({ uuid: i, ...n }) => [i, { uuid: i, ...n }])).then((e) => new Map(e))); N(this, "getMenus", () => I.get("/api/my-menu")); N(this, "getConfigure", () => I.get("api/init-configure")); N(this, "getWidgetOperationAuth", () => I.get("/api/init-widget-operation-auth").then((e) => e.reduce((i, { uuid: n, auth: r }) => [...i, [n, r]], []))); N(this, "getPhoneNumber", (e) => I.get(`/api/user-wx-phone-number/${e}`)); N(this, "getUserToken", () => { const e = window.localStorage.getItem(bt); if (!e) return ""; const i = e.split("."); if (!Array.isArray(i) || i.length !== 3) throw "登录令牌无效!"; const { iat: n } = JSON.parse(window.atob(i[1])); if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - n > 2592e3) throw "登录令牌已过期, 请重新登录!"; return e; }); N(this, "checkUserToken", () => { try { return !!this.getUserToken(); } catch { return !1; } }); N(this, "getUserInfo", (e = !0) => { var i; try { const n = this.getUserToken(); if (!n) return Promise.resolve(null); const { iat: r } = JSON.parse(window.atob((i = n == null ? void 0 : n.split(".")) == null ? void 0 : i[1])), { iat: a, ...o } = I.decode(window.localStorage.getItem(Mt) || "", {}); return a === r ? Promise.resolve(o) : I.get("/api/mine-info").then(({ User: s = null }) => (window.localStorage.setItem(Mt, I.encode({ ...s, iat: r })), s)); } catch (n) { console.error(n), e && ne.error("请登录").then(this.logout); } return Promise.resolve(null); }); N(this, "login", (e, i, n = {}) => I.post("/api/user-token", { username: e, passwd: En.hash(i), platform: "web", ...n }).then(({ token: r }) => (window.localStorage.setItem(bt, r), r)).then(async (r) => (await this.initAppEnv(), r))); N(this, "logout", (e) => (window.localStorage.removeItem(Mt), window.localStorage.removeItem(bt), e == null ? void 0 : e())); N(this, "initAppEnv", async () => { const [e, i, n, r] = await Promise.all([this.getWidgetOperationAuth(), this.getRoutes(), this.getMenus(), this.getConfigure()]); return Ai.init(e), qe.init(r), xe.init(i, n), St.init(qe.get("Common.ICONFONT")), { widgetOperationAuth: e, routes: i, menus: n, configures: r }; }); if (c(we, Le)) return c(we, Le); } }; Le = new WeakMap(), Xe = new WeakMap(), x(we, Le, null), N(we, "getInstance", () => (c(we, Le) || B(we, Le, new we()), c(we, Le))); let Yt = we; const ue = Yt.getInstance(), zr = E.createContext({ user: {}, initUser: () => { }, initUserComplete: !1 }), Wr = E.createContext({ set: () => { }, get: () => { }, assign: () => { }, currentRoute: () => { } }), ri = (t) => !!(t != null && t.name) && (t.prototype instanceof E.Component || /^[A-Z]/.test(t.name)), Br = (t, e) => { if (!t || typeof window > "u") return; let i = document.querySelector(`style[ff-style-token="${e}"]`); return i ? (i.innerHTML = t, t) : (i = document.createElement("style"), i.setAttribute("ff-style-token", e), i.setAttribute("type", "text/css"), i.innerHTML = t, document.head.appendChild(i), t); }, qr = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: zr, AppGlobalParamsContext: Wr, cache: Ri, configure: qe, default: ue, func: Ie, http: I, insertStyle: Br, isReactComponent: ri, route: xe }, Symbol.toStringTag, { value: "Module" })); var $e, Qe, ve, be, Ce, te, Z, G, ke, st, lt, ct, dt, Pt, ut; const ai = class ai { constructor(e, i = "/") { x(this, $e, "/"); x(this, Qe, /* @__PURE__ */ new Set()); x(this, ve, (e) => { for (const i of c(this, Qe)) try { i(e); } catch (n) { console.error("Error in VirtualFS event listener:", n); } }); x(this, be, (e) => { const i = Date.now(); if (e && (e.lastModified = i), c(this, $e) != "/") { const n = c(this, G).call(this, c(this, $e)); n && (n.lastModified = i); } this.root.lastModified = i; }); x(this, Ce, (e) => { let i = ge.normalize(e); return i.startsWith("/") || (i = "/" + i), i.length > 1 && i.endsWith("/") && (i = i.slice(0, -1)), i; }); x(this, te, (e) => { const i = ge.join(c(this, $e), e); return c(this, Ce).call(this, i); }); x(this, Z, (e) => { if (!e || typeof e != "string") return !1; const i = c(this, Ce).call(this, e); return !i.includes("..") && i.startsWith("/"); }); x(this, G, (e) => { var a; const i = c(this, Ce).call(this, e); if (i === "/") return this.root; const n = i.split("/").filter((o) => o); let r = this.root; for (const o of n) { if (r.type !== "dir") return null; const s = (a = r.children) == null ? void 0 : a.find((l) => l.name === o); if (!s) return null; r = s; } return r; }); x(this, ke, (e) => { const i = c(this, Ce).call(this, e), n = ge.basename(i), r = ge.dirname(i); return { parent: c(this, G).call(this, r), name: n }; }); x(this, st, (e, i, n) => n === !1 ? e : n === "root" ? e.map((r) => ge.join(i, r)) : n === !0 || n === "working" ? e.map((r) => ge.relative(c(this, $e), ge.join(i, r))) : e); x(this, lt, async (e, i, n, r = "") => { const a = [], o = c(this, G).call(this, e); if (!o || o.type !== "dir") return a; const s = o.children; for (const l of s) { const d = l.name, u = e === "/" ? `/${d}` : `${e}/${d}`, p = r ? `${r}/${d}` : d; try { if (l.type === "file") i(n ? p : d) && a.push(p); else if (l.type === "dir" && n) { const m = await c(this, lt).call(this, u, i, n, p); a.push(...m); } } catch { continue; } } return a; }); x(this, ct, async (e, i, n, r = "") => { const a = [], o = Array.isArray(i) ? i : [i], s = c(this, G).call(this, e); if (!s || s.type !== "dir") return a; if (!n) { for (const d of o) if (c(this, dt).call(this, d)) { const u = await c(this, Pt).call(this, e, d); a.push(...u); } else { const u = ge.join(e, d), p = c(this, Ce).call(this, u); c(this, G).call(this, p) && a.push(d); } return a; } const l = s.children; for (const d of l) { const u = d.name, p = e === "/" ? `/${u}` : `${e}/${u}`, m = r ? `${r}/${u}` : u; try { if (d.type === "file") for (const g of o) { let y = !1; if (y = c(this, dt).call(this, g) ? c(this, ut).call(this, u, g) : u === g, y) { a.push(m); break; } } else if (d.type === "dir") { const g = await c(this, ct).call(this, p, i, n, m); a.push(...g); } } catch { continue; } } return a; }); x(this, dt, (e) => /[*?[\]{}]/.test(e)); x(this, Pt, async (e, i) => { const n = [], r = c(this, G).call(this, e); if (!r || r.type !== "dir") return n; const a = r.children.map((o) => o.name); for (const o of a) c(this, ut).call(this, o, i) && n.push(o); return n; }); x(this, ut, (e, i) => { const n = i.replace(/\./g, "\\.").replace(/\*/g, ".*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (r, a) => "(" + a.split(",").join("|") + ")"); return new RegExp(`^${n}$`).test(e); }); var n, r, a; B(this, $e, i), this.root = { name: "/", type: "dir", children: [], lastModified: Date.now() }, Array.isArray(e) ? this.root.children = e : e && typeof e == "object" && (e.name && e.name !== "/" ? this.root.children.push(e) : (this.root = e, (n = this.root).name ?? (n.name = "/"), (r = this.root).children ?? (r.children = []), (a = this.root).lastModified ?? (a.lastModified = Date.now()))); } async stat(e) { const i = c(this, te).call(this, e); if (!c(this, Z).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`); const n = c(this, G).call(this, i); if (!n) throw new Error(`ENOENT: no such file or directory, stat '${e}'`); return { isFile: () => n.type === "file", isDirectory: () => n.type === "dir", lastModified: n.lastModified }; } async dir(e) { const i = c(this, te).call(this, e); if (!c(this, Z).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`); const n = c(this, G).call(this, i); if (!n) throw new Error(`ENOENT: no such file or directory, scandir '${e}'`); if (n.type !== "dir") throw new Error(`ENOTDIR: not a directory, scandir '${e}'`); return n.children.map((r) => r.name); } async readFile(e) { const i = c(this, te).call(this, e); if (!c(this, Z).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`); const n = c(this, G).call(this, i); if (!n) throw new Error(`ENOENT: no such file or directory, open '${e}'`); if (n.type !== "file") throw new Error("EISDIR: illegal operation on a directory, read"); return n.content || ""; } async writeFile(e, i) { const n = c(this, te).call(this, e); if (!c(this, Z).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`); const { parent: r, name: a } = c(this, ke).call(this, n); if (!r) throw new Error(`ENOENT: no such file or directory, open '${e}'`); if (r.type !== "dir") throw new Error("ENOTDIR: not a directory"); const o = r.children.findIndex((d) => d.name === a), s = o >= 0, l = { name: a, type: "file", content: i, lastModified: Date.now() }; s ? r.children[o] = l : r.children.push(l), c(this, be).call(this, r), c(this, ve).call(this, { action: s ? "update" : "create", path: n, type: "file", timestamp: Date.now() }); } async mkdir(e, i = {}) { const n = c(this, te).call(this, e); if (!c(this, Z).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`); const { recursive: r } = i; if (r) { const a = n.split("/").filter((s) => s); let o = "/"; for (const s of a) if (o = ge.join(o, s), !c(this, G).call(this, o)) { const { parent: l, name: d } = c(this, ke).call(this, o); if (l && l.type === "dir") { const u = { name: d, type: "dir", children: [], lastModified: Date.now() }; l.children.push(u), c(this, be).call(this, l), c(this, ve).call(this, { action: "create", path: c(this, Ce).call(this, o), type: "dir", timestamp: Date.now() }); } } } else { const { parent: a, name: o } = c(this, ke).call(this, n); if (!a) throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`); if (a.type !== "dir") throw new Error("ENOTDIR: not a directory"); if (a.children.find((l) => l.name === o)) throw new Error(`EEXIST: file already exists, mkdir '${e}'`); const s = { name: o, type: "dir", children: [], lastModified: Date.now() }; a.children.push(s), c(this, be).call(this, a), c(this, ve).call(this, { action: "create", path: n, type: "dir", timestamp: Date.now() }); } } async unlink(e) { const i = c(this, te).call(this, e); if (!c(this, Z).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`); const { parent: n, name: r } = c(this, ke).call(this, i); if (!n) throw new Error(`ENOENT: no such file or directory, unlink '${e}'`); const a = n.children.findIndex((o) => o.name === r); if (a < 0) throw new Error(`ENOENT: no such file or directory, unlink '${e}'`); if (n.children[a].type !== "file") throw new Error(`EISDIR: illegal operation on a directory, unlink '${e}'`); n.children.splice(a, 1), c(this, be).call(this, n), c(this, ve).call(this, { action: "delete", path: i, type: "file", timestamp: Date.now() }); } async rmdir(e, i = {}) { const n = c(this, te).call(this, e); if (!c(this, Z).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`); const { parent: r, name: a } = c(this, ke).call(this, n); if (!r) throw new Error(`ENOENT: no such file or directory, rmdir '${e}'`); const o = r.children.findIndex((l) => l.name === a); if (o < 0) throw new Error(`ENOENT: no such file or directory, rmdir '${e}'`); const s = r.children[o]; if (s.type !== "dir") throw new Error(`ENOTDIR: not a directory, rmdir '${e}'`); if (!i.recursive && s.children.length > 0) throw new Error(`ENOTEMPTY: directory not empty, rmdir '${e}'`); r.children.splice(o, 1), c(this, be).call(this, r), c(this, ve).call(this, { action: "delete", path: n, type: "dir", timestamp: Date.now() }); } async rename(e, i) { const n = c(this, te).call(this, e), r = c(this, te).call(this, i); if (!c(this, Z).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`); if (!c(this, Z).call(this, r)) throw new Error(`EINVAL: invalid path '${i}'`); if (!c(this, G).call(this, n)) throw new Error(`ENOENT: no such file or directory, rename '${e}' -> '${i}'`); const { parent: a, name: o } = c(this, ke).call(this, n), { parent: s, name: l } = c(this, ke).call(this, r); if (!s) throw new Error(`ENOENT: no such file or directory, rename '${e}' -> '${i}'`); if (c(this, G).call(this, r)) throw new Error(`EEXIST: file already exists, rename '${e}' -> '${i}'`); const d = a.children.findIndex((p) => p.name === o), u = { ...a.children[d], name: l, lastModified: Date.now() }; a.children.splice(d, 1), s.children.push(u), c(this, be).call(this, a), a !== s && c(this, be).call(this, s), c(this, ve).call(this, { action: "rename", path: r, oldPath: n, type: u.type, timestamp: Date.now() }); } async exists(e) { const i = c(this, te).call(this, e); return c(this, Z).call(this, i) ? c(this, G).call(this, i) !== null : !1; } getLastModified() { return this.root.lastModified; } subscribe(e) { if (typeof e != "function") throw new Error("Callback must be a function"); return c(this, Qe).add(e), () => { c(this, Qe).delete(e); }; } getWorkingDirectory() { return c(this, $e); } scope(e = "/") { const i = c(this, Ce).call(this, e); if (!c(this, Z).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`); const n = c(this, G).call(this, i); if (!n) throw new Error(`ENOENT: no such file or directory '${e}'`); if (n.type !== "dir") throw new Error(`ENOTDIR: not a directory '${e}'`); return n.children ?? (n.children = []), n.lastModified ?? (n.lastModified = Date.now()), new ai(this.root, i); } async findFiles(e, i, n = {}) { const r = c(this, te).call(this, e); if (!c(this, Z).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`); const a = c(this, G).call(this, r); if (!a) throw new Error(`ENOENT: no such file or directory '${e}'`); if (a.type !== "dir") throw new Error(`ENOTDIR: not a directory '${e}'`); const { recursive: o = !1, fullPath: s = !1 } = n; if (typeof i == "function") { const d = await c(this, lt).call(this, r, i, o); return c(this, st).call(this, d, r, s); } const l = await c(this, ct).call(this, r, i, o); return c(this, st).call(this, l, r, s); } }; $e = new WeakMap(), Qe = new WeakMap(), ve = new WeakMap(), be = new WeakMap(), Ce = new WeakMap(), te = new WeakMap(), Z = new WeakMap(), G = new WeakMap(), ke = new WeakMap(), st = new WeakMap(), lt = new WeakMap(), ct = new WeakMap(), dt = new WeakMap(), Pt = new WeakMap(), ut = new WeakMap(); let xi = ai; const Ur = async (t, e = "/", i = "") => { try { const n = await t.stat(e), r = e === "/" ? "/" : ge.basename(e), a = { title: r, key: i ? `${i}${e}` : e, isLeaf: n.isFile() }; if (n.isDirectory()) { const o = await t.dir(e); if (o.length > 0) { a.children = []; const s = [], l = []; for (const d of o) { const u = e === "/" ? `/${d}` : `${e}/${d}`; try { (await t.stat(u)).isDirectory() ? s.push(d) : l.push(d); } catch (p) { console.warn(`Failed to stat ${u}:`, p.message); } } s.sort(), l.sort(); for (const d of [...s, ...l]) { const u = e === "/" ? `/${d}` : `${e}/${d}`; try { const p = await Ur(t, u, i); a.children.push(p); } catch (p) { console.warn(`Failed to process ${u}:`, p.message); } } } } return a; } catch { return null; } }; export { Sa as $, Ki as A, Bi as B, Wi as C, kt as D, or as E, ar as F, Ca as G, cr as H, nr as I, ei as J, oe as K, lr as L, hr as M, Zn as N, tr as O, Gn as P, Yn as Q, qi as R, fa as S, ya as T, Vi as U, Ut as V, Xn as W, Qn as X, mr as Y, fr as Z, ka as _, ji as a, Tt as a0, Ea as a1, $a as a2, ht as a3, mt as a4, va as a5, xa as a6, xr as a7, ii as a8, ti as a9, Ie as aA, xe as aB, zr as aC, Wr as aD, xi as aE, Ur as aF, Yi as aa, wr as ab, br as ac, Cr as ad, kr as ae, Sr as af, Er as ag, Na as ah, St as ai, P as aj, Ai as ak, Or as al, ee as am, pt as an, Oi as ao, ie as ap, ne as aq, la as ar, ca as as, da as at, ue as au, ri as av, Br as aw, I as ax, Ri as ay, qe as az, qn as b, gt as c, Li as d, pa as e, ga as f, Bn as g, ha as h, Un as i, _n as j, ma as k, Di as l, Kn as m, wa as n, zi as o, Zt as p, Ui as q, Lt as r, Hi as s, de as t, ua as u, pr as v, _i as w, dr as x, ur as y, ba as z };