var kn = Object.defineProperty; var Et = (e) => { throw TypeError(e); }; var vn = (e, t, n) => t in e ? kn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var x = (e, t, n) => vn(e, typeof t != "symbol" ? t + "" : t, n), Rt = (e, t, n) => t.has(e) || Et("Cannot " + n); var m = (e, t, n) => (Rt(e, t, "read from private field"), n ? n.call(e) : t.get(e)), E = (e, t, n) => t.has(e) ? Et("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), B = (e, t, n, a) => (Rt(e, t, "write to private field"), a ? a.call(e, n) : t.set(e, n), n); var Ft = (e, t, n, a) => ({ set _(r) { B(e, t, r, n); }, get _() { return m(e, t, a); } }); import { jsx as d, jsxs as O } from "react/jsx-runtime"; import C, { useEffect as R, useState as N, useCallback as ce, useMemo as G, useRef as D, useContext as de, useId as Ge, useLayoutEffect as xn } from "react"; import p from "lodash"; import qt from "immutability-helper"; import { Form as Ke, Input as Sn, Button as lt, Pagination as $n, Tree as Pn, Breadcrumb as Nn, Table as Tn, Empty as En, Popconfirm as Rn, Tooltip as Fn, Popover as On } from "antd"; import { useMergedState as Ln } from "rc-util"; import V from "classnames"; import Q, { FieldContext as Vn, Field as Ht } from "rc-field-form"; import { useParams as jn, generatePath as An, createBrowserRouter as In, useInRouterContext as Mn, Navigate as zn } from "react-router-dom"; import k from "prop-types"; import * as Ot from "react-is"; import { useNotification as Wn } from "rc-notification"; import { N as Re, a as Fe, T as ct, S as Bn } from "./vender-DMK1apIA.js"; import "rc-util/lib/hooks/useMergedState"; import Un from "rc-drawer"; import Dn from "rc-dialog"; var $e, Ve, Pe, se, ke, ve; class Jt { constructor(t, n) { E(this, $e, /* @__PURE__ */ new Map()); E(this, Ve, !0); E(this, Pe, []); E(this, se); E(this, ke, () => m(this, se)); E(this, ve, () => Promise.resolve()); x(this, "get", (...t) => new Promise((n, a) => { const r = JSON.stringify(t); if (m(this, $e).has(r)) return n(m(this, ve).call(this, m(this, se), ...t)); if (m(this, se) === void 0) m(this, Pe).push([t, n, a]), m(this, Ve) && (B(this, Ve, !1), Promise.resolve(typeof m(this, ke) == "function" ? m(this, ke).call(this) : m(this, ke)).then((i) => B(this, se, i || null)).finally(() => { m(this, Pe).forEach(([i, s, o]) => { try { const l = m(this, ve).call(this, m(this, se), ...i); m(this, $e).set(JSON.stringify(i), l), s(l); } catch (l) { o(l); } }), m(this, Pe).length = 0; })); else { const i = m(this, ve).call(this, m(this, se), ...t); m(this, $e).set(r, i), n(i); } })); B(this, ve, n), B(this, ke, t); } } $e = new WeakMap(), Ve = new WeakMap(), Pe = new WeakMap(), se = new WeakMap(), ke = new WeakMap(), ve = new WeakMap(); const er = () => d("div", { children: "Empty" }), We = C.createContext({ ele: {}, mount: () => { }, unmount: () => { } }), J = ({ rootClassName: e, className: t, children: n, actions: a, title: r, subTitle: i, extras: s, style: o = {} }) => { const { mount: l, unmount: c } = C.useContext(We); return a && J.Action({ children: a }), r && J.Title({ children: r }), i && J.SubTitle({ children: i }), s && J.Extra({ children: s }), R(() => (l("rootClassName", e), () => c(e)), [e]), d("div", { className: V("ff-container", t), style: o, children: n }); }, Je = (e) => ({ children: t, className: n }) => { const { mount: a, unmount: r } = C.useContext(We); return R(() => (a(e, C.createElement("div", { key: `ff-${e}`, className: V(`ff-popup-${e}`, n) }, t)), () => r(e)), [n, t]), null; }; J.Action = Je("actions"), J.Title = Je("title"), J.SubTitle = Je("sub-title"), J.Extra = Je("extras"), J.propTypes = { className: k.string, style: k.object, title: k.any, subTitle: k.any, actions: k.any, extras: k.any }; const tr = () => d(J, { className: "ff-loading", children: O("div", { className: "loader", children: [O("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), O("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), O("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), O("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] })] }) }), nr = () => d("div", { children: "NotFound" }), Kt = ({ children: e }) => { const [t, n] = N({}), a = ce((i, s) => n((o) => ({ ...o, [i]: s })), []), r = ce((i) => n((s) => ({ ...s, [i]: void 0 })), []); return typeof (e == null ? void 0 : e.type) == "string" ? e : d(We.Provider, { value: { ele: t, mount: a, unmount: r }, children: C.cloneElement(e, { className: t.rootClassName, title: t.title, subTitle: t["sub-title"], actions: t.actions, extras: t.extras }) }); }; Kt.propTypes = { children: k.element.isRequired }; const Lt = { 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"] }, Ct = ({ type: e, props: t }) => d("i", { ...t, children: d("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (Lt[e] || Lt.info).map((n, a) => d("path", { d: n }, a)) }) }), _t = ({ className: e, content: t, icon: n, $close: a }) => O(C.Fragment, { children: [n && d("div", { className: V("ff-notification-icon", e), children: d(Ct, { type: n }) }), t] }), qn = ({}) => d(J, { children: "Confirm" }); var ge, Ne; const te = class te { constructor() { E(this, Ne, /* @__PURE__ */ new Map()); x(this, "init", (t) => B(this, Ne, new Map(t))); x(this, "check", (t) => !m(this, Ne).has(t) || m(this, Ne).get(t)); if (m(te, ge)) return m(te, ge); } }; ge = new WeakMap(), Ne = new WeakMap(), E(te, ge, null), x(te, "getInstance", () => (m(te, ge) || B(te, ge, new te()), m(te, ge))); let dt = te; const Hn = dt.getInstance(); var pe, je; const ne = class ne { constructor() { E(this, je, null); x(this, "init", (t) => B(this, je, t)); x(this, "get", (t, n) => p.get(m(this, je), t, n)); if (m(ne, pe)) return m(ne, pe); } }; pe = new WeakMap(), je = new WeakMap(), E(ne, pe, null), x(ne, "getInstance", () => (m(ne, pe) || B(ne, pe, new ne()), m(ne, pe))); let ut = ne; const Oe = ut.getInstance(), Vt = { null2json: (e) => Object.create(), null2array: (e) => [], null2number: (e) => 0, null2bool: (e) => !1, null2string: (e) => "", null2integer: (e) => 0, null2float: (e) => 0, string2json: (e) => e ? JSON.parse(e) : "{}", string2array: (e) => e.substr(0, 1) === "[" && e.substr(-1) === "]" ? JSON.parse(e) : e.split(","), string2number: (e) => e == "" ? 0 : +e, string2integer: (e) => e == "" ? 0 : +e, string2float: (e) => e == "" ? 0 : +e, string2bool: (e) => { switch (`${e}`.toLowerCase()) { case "0": case "false": case "[]": case "{}": return !1; } return !!e; }, string2string: (e) => e, json2json: (e) => e, json2array: (e) => e ? Object.values(e) : [], json2number: (e) => Object.keys(e).length, json2integer: (e) => Object.keys(e).length, json2float: (e) => Object.keys(e).length, json2bool: (e) => Object.keys(e).length > 0, json2string: (e) => e ? JSON.stringify(e) : "", array2json: (e) => ({ ...e }), array2array: (e) => e, array2number: (e) => e.length, array2integer: (e) => e.length, array2float: (e) => e.length, array2bool: (e) => e.length > 0, array2string: (e) => JSON.stringify(e), number2json: (e) => ({}), number2array: (e) => [e], number2number: (e) => e, number2integer: (e) => e, number2float: (e) => e, number2bool: (e) => !!e, number2string: (e) => e.toString(), boolean2json: (e) => ({}), boolean2array: (e) => [], boolean2number: (e) => +e, boolean2integer: (e) => +e, boolean2float: (e) => +e, boolean2bool: (e) => e, boolean2string: (e) => e ? "true" : "false" }, X = (e, t) => { let n = "string"; n = Array.isArray(e) ? "array" : typeof e, p.isObject(e) && (n = "json"); const a = `${n}2${t}`; return Reflect.has(Vt, a) ? Vt[a](e) : e; }, Gt = (e = {}, t = {}, n = {}, a = "") => Yt(e, (r, i) => i === "type" && r === "code") ? Xt(e, t, n, a) : Qt(e, t, a), Yt = (e, t = () => !1) => p.some(e, (n) => !!p.some(n, t) || (p.isEmpty(n) || !p.isPlainObject(n) && !p.isArray(n) ? void 0 : Yt(n, t))), Xt = async (e = {}, t = {}, n = {}, a = "") => { let r = /* @__PURE__ */ Object.create(null); for (let i in e) { let s; if (Reflect.has(e[i], "type") && ["code", "field", "router", "query", "string"].includes(e[i].type)) { const { type: o, value: l = "", default: c = a } = e[i]; switch (o) { case "code": s = await Ce.exec(l, t, n); break; case "field": s = p.get(t, l) ?? p.get(t, l.substring(l.indexOf(".") + 1)); break; case "router": case "query": s = le.getPageParams(l); break; case "string": s = l; } s ?? (s = c); } else s = await Xt(e[i], t, n, a); p.set(r, i, s); } return r; }, Qt = (e = {}, t = {}, n = "") => Object.keys(e || {}).reduce((a, r) => { if (p.isPlainObject(e[r])) { let i; if (Reflect.has(e[r], "type") && ["field", "router", "query", "string"].includes(e[r].type)) { const { type: s, value: o = "", default: l = n } = e[r]; switch (s) { case "field": i = p.get(t, o) ?? p.get(t, o.substring(o.indexOf(".") + 1)); break; case "router": case "query": i = le.getPageParams(o); break; case "string": i = o; } i ?? (i = l); } else i = Qt(e[r], t, n); p.set(a, r, i); } return a; }, {}), it = (e, t) => e && typeof e == "object" ? Array.isArray(e) ? e.map((n) => it(n, t)) : Object.keys(e).reduce((n, a) => (t[a] ? n[t[a]] = it(e[a], t) : n[a] = it(e[a], t), n), {}) : e, ar = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => { const t = 16 * Math.random() | 0; return (e === "x" ? t : 3 & t | 8).toString(16); }), rr = (e) => { var t, n; return e ? (n = (t = e.match(/^@pkg(?:[^\/]*\/){3}(?[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : n.name : ""; }, ir = (e) => { var t, n; return e ? (n = (t = e.match(/^@pkg(?:[^\/]*\/){2}(?[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : n.category : ""; }, sr = (e) => { var t, n; return e ? (n = (t = e.match(/^@pkg(?:[^\/]*\/){1}(?[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : n.owner : ""; }; var Xe, Ae, Ie, Qe; const Ze = class Ze { constructor(...t) { E(this, Ae, []); E(this, Ie, (t) => { var n; for (let a of t) Array.isArray(a[0]) ? m(this, Ie).call(this, a) : m(this, Ae).push(m(n = Ze, Xe).call(n, a[0], a[1])); }); x(this, "toValue", async (t, n = null) => { const a = { getValue: () => t, getRecord: () => n }; return await m(this, Ae).reduce(async (r, i) => { try { const s = await r; return (await i).call(a, s); } catch (s) { return console.error(s), r; } }, t); }); x(this, "toRender", (t, n, a = null) => C.createElement(m(this, Qe), { value: t, record: n }, a)); E(this, Qe, ({ value: t, record: n, children: a }) => { const [r, i] = N(a); return xt(() => { let s = !1; return i(a), this.toValue(t, n).then((o) => X(o, "string")).then((o) => !s && i(o)).catch((o) => !s && i(`${o}`)), () => s = !0; }, [t, n]), r; }); m(this, Ie).call(this, t); } }; Xe = new WeakMap(), Ae = new WeakMap(), Ie = new WeakMap(), Qe = new WeakMap(), E(Ze, Xe, p.memoize((t, n) => Z.getWidgetComponent(t).then((a) => { var r; return ((r = a.default) == null ? void 0 : r.call(a, n)) || ((i) => i); }), (t, n) => `${t}::${X(n, "string")}`)); let Ye = Ze; const Jn = (e, t = {}) => G(() => e == null ? void 0 : e.map(({ widgetByJs: n, widgetByJsSetting: a, ...r }, i) => n ? { ...r, render: (s, o) => new Ye([n, a]).toRender(s, o, "-") } : r), [e, t]), or = (e) => { const [t, n] = N({}); return R(() => { let a = !1; return e && F.get(`/api/_/${e}`).then((r) => p.pick(r, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig"])).then((r) => !a && n(r)), () => a = !0; }, [e]), t; }, lr = (e, t = {}) => { const [n, a] = N({ dataSource: [] }); return Be(() => { let r = !1; return e && F.get(`/api/${e}/${F.encode({ page: 1, ...t })}`).then((i) => !r && a(i)), () => r = !0; }, [e, t]), n; }, gt = (e, t = null, n = null, a = "id") => G(() => { if (p.isEmpty(e) || !e.some(({ uuid: i }) => Hn.check(i))) return !1; if (p.isEmpty(n) || p.isEmpty(t)) return !0; const r = t.map((i) => `${i == null ? void 0 : i[a]}`); return e.some(({ uuid: i }) => !i || !n.has(i) || n.get(i).some((s) => r.includes(`${s}`))); }, [e, t, n, a]), Kn = (e, t, n = "id", a = null) => { const r = vt(), i = D(!1), s = D(e.dataSource), o = D(e.itemOperationsAccess); return R(() => (s.current = e.dataSource, o.current = e.itemOperationsAccess, () => i.current = !1), [e.dataSource, e.itemOperationsAccess]), i.current && (e.dataSource = s.current, e.itemOperationsAccess = o.current), [e, (l = 0, c = null) => { var u, g; if (i.current = !1, l === 1) return (u = e.onReload) == null ? void 0 : u.call(e); if (l === 2) { const h = p.get(c, "__PARENT_ID__", ""), y = p.get(c, n, p.get(c, [a, n], "")), f = p.findIndex(s.current, ["__PARENT_ID__", h]), b = p.findIndex(f > -1 ? p.get(s.current, [f, "children"]) : s.current, [n, y]); if (b === -1) return (g = e.onReload) == null ? void 0 : g.call(e); Promise.all([F.get(`/api/${t}/detail/${y}`), F.post(`/api/${t}/list-operations-access`, { ids: y })]).then(([w, $]) => { const I = p.get(s.current, f > -1 ? [f, "children", b, "children"] : [b, "children"]); s.current = qt(s.current, f > -1 ? { [f]: { children: { $splice: [[b, 1, { ...w, children: I }]] } } } : { $splice: [[b, 1, { ...w, children: I }]] }); const L = new Map($); o.current.forEach((M, j) => { var A; (A = L.get(j)) != null && A.some((T) => T == y) || o.current.set(j, M.filter((T) => T !== y)); }), L.forEach((M, j) => { o.current.has(j) ? o.current.set(j, p.uniq([...o.current.get(j) || [], ...M])) : o.current.set(j, M); }); }).then(() => { i.current = !0, r(); }); } }]; }, _n = (e, t) => { const n = vt(), a = D(t), r = D(/* @__PURE__ */ new Map()), i = D([]), s = p.throttle((l) => { i.current = [], F.list(e, p.pick({ ...a.current, ...l }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: c, condition: u, total: g, tab: h, sider: y, page: f, pageSize: b, operationsAccess: w, dataSource: $ }) => { a.current = { tab: h, condition: u, sider: y, keyword: c, total: g, pageSize: b, page: $ != null && $.length ? f : 1 }, i.current = $, r.current = new Map(w), n(); }); }, 380, { leading: !1, trailing: !0 }); xt(() => { i.current = [], e && s(t); }, [e, t]); const o = G(() => p.pick(a.current, ["total", "tab", "page", "pageSize", "condition", "sider", "keyword"]), [a.current]); return Object.assign(o, { onTabChange: (l) => s({ tab: l, page: 1 }), onPageChange: (l, c) => s({ page: l, pageSize: c }), onPageSizeChange: (l) => s({ pageSize: l, page: 1 }), onConditionChange: (l, c) => s({ keyword: c, condition: qt(a.current.condition || {}, { $merge: l || {} }), page: 1 }), onSiderChange: (l) => s({ sider: l, page: 1 }), onKeywordChange: (l) => s({ keyword: l, page: 1 }), itemOperationsAccess: r.current, dataSource: i.current, onReload: s }); }, Gn = ({ listCode: e, className: t, layouts: n, dataSource: a, isPaginate: r, isItemOperations: i, isBatchOperations: s, batchOperations: o, itemOperations: l, itemOperationsAccess: c, resource: u, primaryKey: g, title: h, itemGridLayout: y, $setting: f, tabs: b, isConditionFormLayout: w, isTreeSider: $, treeSiderConfig: I }) => { const { classNames: L, onClickCallback: M } = de(ee), j = ce((A, T, v) => d(Yn, { className: V("ff-data-list-framework-item", L.item), operations: i && T ? l == null ? void 0 : l.filter((S) => !(g && S.uuid && c.has(S.uuid)) || c.get(S.uuid).includes(T == null ? void 0 : T[g])) : [], data: u ? { [u]: T } : T, children: A, onClickCallback: M }), [u, g, i, M, l, c]); return O("div", { className: V("ff-data-list-framework", t), children: [d(n.sider, { isTreeSider: $, ...I }), O("div", { className: V("ff-data-list-container", L == null ? void 0 : L.container), children: [d(n.filter, { isConditionFormLayout: w }), d(n.toolbar, { title: h, tabs: b }), d(la, { ...y, style: { "--col-num": (f == null ? void 0 : f.colNum) || 1 }, primaryKey: g, itemRender: j, dataSource: a }), d(n.footer, { isPaginate: r, isOperations: s, operations: o })] })] }); }, Yn = ({ className: e, operations: t, children: n, data: a, onClickCallback: r }) => O("div", { className: V("data-list-grid-layout-item-container", e), children: [n, !!(t != null && t.length) && d("div", { className: "data-list-grid-layout-item-actions", children: t.map((i) => d("span", { className: "data-list-grid-layout-item-action", children: d(P.Link, { uuid: i.uuid, type: i.type, name: i.name, widget: i.widget, widgetType: i.widgetType, widgetProps: i.widgetProps, widgetSetting: i.widgetSetting, widgetContainerProps: i.widgetContainerSetting, data: a, confirm: i.confirm, onAfterClick: (s) => s !== !1 && (r == null ? void 0 : r(i.isRefresh, a)) }, i.uuid || Ge()) }, (i == null ? void 0 : i.uuid) || Ge())) })] }), Xn = ({ listCode: e, className: t, layouts: n, dataSource: a, columns: r, isItemOperations: i, isBatchOperations: s, batchOperations: o, itemOperations: l, itemOperationsAccess: c, resource: u, primaryKey: g, title: h, tabs: y, isPaginate: f, isTreeSider: b, treeSiderConfig: w, isConditionFormLayout: $, ...I }) => { const { classNames: L, onClickCallback: M } = de(ee), j = gt(l, a, c, g); return O("div", { className: V("ff-data-table-framework", t), children: [d(n.sider, { isTreeSider: b, ...w }), O("div", { className: V("ff-data-table-container", L == null ? void 0 : L.container), children: [d(n.filter, { isConditionFormLayout: $ }), d(n.toolbar, { title: h, tabs: y }), d(aa, { ...I, primaryKey: g, className: "ff-data-table-content", columns: r, dataSource: a, operationRender: j ? (A) => d("div", { className: "ff-data-table-actions", children: l == null ? void 0 : l.reduce((T, v, S) => [...T, d(P.Link, { size: "small", uuid: v.uuid, type: v.type, name: v.name, widget: v.widget, widgetType: v.widgetType, widgetProps: v.widgetProps, widgetData: v.widgetData, widgetSetting: v.widgetSetting, widgetContainerProps: v.widgetContainerSetting, data: A, confirm: v.confirm, onAfterClick: (U) => U !== !1 && (M == null ? void 0 : M(v.isRefresh, A)) }, v.uuid || S)], []) }) : null }), d(n.footer, { isPaginate: f, isOperations: s, operations: o })] })] }); }, ee = C.createContext({ listCode: "", classNames: {}, getBase62params: (e, t) => { }, onReload: () => { }, onClickCallback: () => { }, onConditionChange: () => { }, onTabChange: () => { }, onSiderChange: () => { }, onKeywordChange: () => { }, onPageChange: () => { }, onPageSizeChange: () => { } }), Zt = (e, t, n, a, r = {}, i = 0) => { const s = { "--grid-layout-h": `${a}`, "--grid-layout-w": `${n}`, "--grid-layout-x": `${e}`, "--grid-layout-y": `${t}`, "--grid-layout-row-height-offset": "0px" }; return r != null && r.autoHeight ? s.height = "fit-content" : s["--grid-layout-row"] = `${a}`, r != null && r.alignItems && (s["--grid-layout-box-align-items"] = r.alignItems), r != null && r.justifyContent && (s["--grid-layout-box-justify-content"] = r.justifyContent), s["--grid-layout-box-margin"] = jt(r == null ? void 0 : r.marginTop, r == null ? void 0 : r.marginRight, r == null ? void 0 : r.marginBottom, r == null ? void 0 : r.marginLeft), s["--grid-layout-box-padding"] = jt(r == null ? void 0 : r.paddingTop, r == null ? void 0 : r.paddingRight, r == null ? void 0 : r.paddingBottom, r == null ? void 0 : r.paddingLeft), i && (s.height = `${i}px`), s; }, jt = (e, t, n, a) => `${e || 0}px ${t || 0}px ${n || 0}px ${a || 0}px`, en = ({ className: e, isConditionFormLayout: t }) => { var h, y; const [n, a] = N({}), { listCode: r, onKeywordChange: i, onConditionChange: s, getBase62params: o, classNames: l } = C.useContext(ee), { keyword: c, condition: u } = (o == null ? void 0 : o()) || {}, [g] = Ke.useForm(); return R(() => { r && t && F.get(`/api/_/${r}/list-condition-form-layout`).then(({ resource: f, marginX: b, marginY: w, rowHeight: $, cols: I, fields: L }) => { a({ resource: f, itemMargin: [b, w], rowHeight: $, cols: I, fields: L }); }).catch(() => a({})); }, [r, t]), R(() => { g.setFieldsValue({ keyword: c, ...u }); }, [JSON.stringify([c, u])]), d("div", { className: V("ff-data-list-filter", l.filter, e), children: d(Ke, { form: g, layout: "vertical", autoComplete: "off", onFinish: ((h = n.fields) == null ? void 0 : h.length) > 1 ? (f) => s({ [n.resource]: f[n.resource] }, f.keyword) : () => { }, onValuesChange: (f) => { p.isEmpty(p.omit(f, ["keyword"])) || g.submit(); }, children: ((y = n.fields) == null ? void 0 : y.length) > 1 ? d(St, { ...n, children: d(Qn, { onReset: () => { const { keyword: f, condition: b } = o("init") || {}; g.setFieldsValue({ keyword: f, ...b }); } }) }) : d("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: d("div", { className: "grid-layout-item", style: Zt(20, 0, 5, 2), children: d(Ke.Item, { name: ["keyword"], children: d(Sn.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (f) => i(f) }) }) }) }) }) }); }, Qn = ({ cols: e, fields: t, onReset: n }) => { const [a, r] = N(!1), i = G(() => t == null ? void 0 : t.toReversed().some((s) => s.y > 1 || s.x + s.w >= e - 5), [e, t]); return O(Ke.Item, { label: " ", style: { "--item-span": 5 }, className: V("ff-data-list-filter-actions", { expanded: a }), children: [d(lt, { onClick: n, children: "重置" }), d(lt, { type: "primary", htmlType: "submit", children: "查询" }), i && d(P.Link, { className: "ff-data-list-filter-expanded-button", widget: () => r((s) => !s), type: "primary", name: a ? "关闭" : "展开", icon: a ? "icon-up" : "icon-down", iconPosition: "end" })] }); }; en.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 Zn = ({ className: e, operations: t, isOperations: n, isPaginate: a }) => { const { onPageChange: r, onPageSizeChange: i, onClickCallback: s, getBase62params: o } = C.useContext(ee), { total: l, page: c, pageSize: u } = (o == null ? void 0 : o()) || {}; return n && !p.isEmpty(t) || a ? O("div", { className: V("ff-data-list-footer", e), children: [d("div", { className: "ff-data-list-actions", children: t == null ? void 0 : t.map((g, h) => d(P, { uuid: g.uuid, type: g.type, name: g.name, widget: g.widget, widgetType: g.widgetType, widgetProps: g.widgetProps, widgetData: g.widgetData, widgetSetting: g.widgetSetting, widgetContainerProps: g.widgetContainerSetting, onAfterClick: (y) => y !== !1 && (s == null ? void 0 : s(g.isRefresh, null)) }, g.uuid || h)) }), a && d($n, { size: "small", total: l, pageSize: u, showSizeChanger: !1, showTotal: (g) => `第 ${c} 页 / 总共 ${g} 条`, onChange: r, onShowSizeChange: i })] }) : null; }, ea = [{ 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: d("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], ta = ({ className: e, width: t = 280, isTreeSider: n }) => { const { classNames: a } = de(ee); return n ? d(Pn.DirectoryTree, { className: V("ff-data-list-sider", a.sider, e), style: { "--sider-width": t }, showLine: !0, showIcon: !1, treeData: ea }) : null; }, na = ({ className: e, title: t, tabs: n }) => { const { getBase62params: a, onTabChange: r, onReload: i, classNames: s } = de(ee), { tab: o } = (a == null ? void 0 : a()) || {}, [l, c] = Ln((n == null ? void 0 : n[0].value) ?? (n == null ? void 0 : n[0].code), { value: o, onChange: r }); return O("div", { className: V("ff-data-list-toolbar", s.toolbar, e), children: [d("div", { className: "ff-data-list-title", children: t }), d(Nn, { className: "ff-data-list-tabs", itemRender: ({ label: u, code: g, value: h }) => d("span", { onClick: () => c(h ?? g), className: V("ff-data-list-tab", { active: (h ?? g) == l }), children: u }), items: n }), O("div", { className: "ff-data-list-actions", children: [d(P.Link, { icon: "icon-reload", widget: () => i() }), d(P.Link, { icon: "icon-setting" })] })] }); }, tn = ({ isItemGridLayout: e, theme: t, themeProps: n, onClickCallback: a, onReload: r, listCode: i, total: s = 0, page: o = 0, onPageChange: l, pageSize: c = 30, onPageSizeChange: u, tab: g, onTabChange: h, keyword: y, onKeywordChange: f, condition: b, onConditionChange: w, sider: $, onSiderChange: I, layouts: L, classNames: M = {}, ...j }) => { const [A, T] = N(), v = G(() => { let S = { sider: ta, filter: en, footer: Zn, toolbar: na }; L === !1 ? S = { sider: null, filter: null, footer: null, toolbar: null } : p.isPlainObject(L) && (S = Object.assign({}, S, L)); for (const U in S) S[U] || (S[U] = () => d(C.Fragment, {})); return S; }, [L]); return R(() => { t ? Z.getWidgetComponent(t).then((S) => { if (!S) throw `${t} not found`; return S; }).catch((S) => ({ default: () => `${S}` })).then((S) => T(C.createElement(S.default, { ...j, layouts: v, $setting: n }))) : T(d(e ? Gn : Xn, { ...j, layouts: v, $setting: n })); }, [t, n]), d(ee.Provider, { value: { classNames: M, listCode: i, onClickCallback: a, onReload: r, getBase62params: (S, U) => { const z = { tab: g, page: o, pageSize: c, keyword: y, sider: $, condition: b, total: s }; return S && S != "init" ? z[S] ?? U : z; }, onPageChange: l, onPageSizeChange: u, onTabChange: h, onSiderChange: I, onKeywordChange: f, onConditionChange: w }, children: A && C.cloneElement(A, j) }); }; tn.propTypes = { layouts: k.oneOfType([k.exact({ sider: k.elementType, filter: k.elementType, footer: k.elementType, toolbar: k.elementType }), k.bool]) }; var me, oe, xe, et; const ae = class ae { constructor() { E(this, oe, null); E(this, xe, /* @__PURE__ */ new Map()); E(this, et, () => { if (m(this, oe)) return m(this, oe).port.postMessage({ command: "status", data: [] }); B(this, oe, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), m(this, oe).port.onmessage = (t) => { var n, a; (n = t.data) != null && n.uuid ? m(this, xe).forEach((r, i) => { var s; (r == "*" || (s = r == null ? void 0 : r.includes) != null && s.call(r, t.data.uuid)) && i(t.data); }) : ((a = t.data) == null ? void 0 : a.readyState) == WebSocket.CLOSED && F.get("/api/user-api-token").then(({ token: r, expire_at: i }) => { m(this, oe).port.postMessage({ command: "initWs", data: [`ws${p.trimStart(F.appUrl, "http")}api/user-resource-status-ws?token=${r}`] }); }); }, m(this, oe).port.postMessage({ command: "status", data: [] }); }); x(this, "subscribe", (t, n = []) => (n ? Array.isArray(n) && n.length == 0 ? n = "*" : Array.isArray(n) || (n = [n].flat()) : n = "*", m(this, xe).set(t, n), m(this, xe).size == 1 && m(this, et).call(this), () => this.unsubscribe(t))); x(this, "unsubscribe", (t) => m(this, xe).delete(t)); if (m(ae, me)) return m(ae, me); } }; me = new WeakMap(), oe = new WeakMap(), xe = new WeakMap(), et = new WeakMap(), E(ae, me, null), x(ae, "getInstance", () => (m(ae, me) || B(ae, me, new ae()), m(ae, me))); let pt = ae; const nn = pt.getInstance(), kt = C.forwardRef(({ listCode: e, base62params: t, className: n, itemClassName: a, theme: r, themeProps: i, layouts: s, classNames: o }, l) => { const [{ resource: c, primaryKey: u, batchOperations: g = [], itemOperations: h = [], columns: y = [], themeConfig: f, theme: b, isConditionFormLayout: w = !1, isTreeSider: $, treeSiderConfig: I, isItemGridLayout: L, itemGridLayout: M, title: j, isPaginate: A, tabs: T }, v] = N({ isItemGridLayout: !1, itemGridLayout: {} }), S = _n(e, t), [{ dataSource: U, itemOperationsAccess: z, condition: K, tab: ue, keyword: _, page: nt, total: De, pageSize: at, sider: Nt, onConditionChange: gn, onTabChange: pn, onKeywordChange: mn, onPageChange: hn, onPageSizeChange: fn, onSiderChange: yn, onReload: rt }, Tt] = Kn(S, e, u, c), wn = gt(h, U, z, u), bn = gt(g); return R(() => { let qe = null; return e && F.get(`/api/_/${e}`).resp(({ data: He, res: Cn }) => { He != null && He.isDynamicRefresh && (qe = nn.subscribe(() => rt(), Cn)), v(He); }).catch(() => v({})), () => qe == null ? void 0 : qe(); }, [e]), C.useImperativeHandle(l, () => ({ onReload: rt, onClickCallback: Tt })), d(tn, { listCode: e, title: j, itemClassName: a, classNames: o, resource: c, primaryKey: u, theme: r || b, themeProps: i || f, isTreeSider: $, treeSiderConfig: I, isPaginate: A, tabs: T, isItemOperations: wn, isBatchOperations: bn, batchOperations: g, itemOperations: h, isItemGridLayout: L, columns: y, itemGridLayout: M, isConditionFormLayout: w, itemOperationsAccess: z, dataSource: U, onConditionChange: gn, onTabChange: pn, onKeywordChange: mn, onPageChange: hn, onPageSizeChange: fn, onSiderChange: yn, condition: K, tab: ue, keyword: _, page: nt, total: De, pageSize: at, sider: Nt, layouts: { footer: null }, className: V("ff-data-list-helper", n), onReload: rt, onClickCallback: Tt }); }), an = (e, t, n = !0) => n !== !0 && n-- <= 0 ? [] : p.isArray(e) && !p.isEmpty(e) ? e.reduce((a, r) => (Reflect.has(r, t) && Reflect.has(r, "children") && a.push(r[t]), Reflect.has(r, "children") && !p.isEmpty(r.children) ? a.concat(an(r.children, t, n)) : a), []) : [], aa = ({ className: e, primaryKey: t, columns: n = [], dataSource: a = [], operationRender: r, operationWidth: i = 180, ...s }) => { const { classNames: o } = de(ee); Ge(); const l = D(null), c = D(null), [u, g] = N([]), [h, y] = N({ width: 0, height: 0 }); R(() => { g(an(a, t)); }, [a, t]), xn(() => { const b = new ResizeObserver(() => { var w; y({ width: ((w = l.current) == null ? void 0 : w.nativeElement.querySelector(".ant-table-body").scrollWidth) || c.current.offsetWidth, height: c.current.offsetHeight }); }); return c.current && b.observe(c.current), () => { c.current && b.unobserve(c.current); }; }, []); const f = Jn(n); return d("div", { ref: c, className: V("ff-data-list-table", o.content, e), children: h.height ? d(Tn, { ...s, ref: l, rowKey: (b) => (b == null ? void 0 : b[t]) ?? Math.random(), columns: f == null ? void 0 : f.concat(r ? [{ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(i / h.width * 100).toFixed(2)}%`, render: (b, w, $) => r(w, $) }] : []), dataSource: a, size: "middle", scroll: { x: "max-content", y: h.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: g, expandedRowKeys: u } }) : null }); }, ra = "RC_FORM_INTERNAL_HOOKS", rn = (e, { initialValue: t, initialValueLanguage: n, convertJs: a, convertJsSetting: r, type: i = "string" }, s = null) => { const o = D(!1), l = de(Vn), [c, u] = N(), [g, h] = N(n != "javascript" && e ? l.getFieldValue(e) : void 0), { registerWatch: y } = l.getInternalHooks(ra) || {}; return R(() => y == null ? void 0 : y((f, b, w) => { if (!o.current) return; const $ = p.get(b, e); p.isEqual($, g) || h(X($, i)); }), [g]), R(() => { n == "javascript" && t ? Ce.exec(t, {}, { getFieldValueForBasicForm: (f) => s ? s.getFieldValue(f) : l.getFieldValue(f), getFieldValue: (f) => l.getFieldValue(f) }).then((f) => h(X(f, i))).catch((f) => notification.error({ message: `布局数据错误: ${JSON.stringify(f)}` })).finally(() => o.current = !0) : (t && h(X(t ?? l.getFieldValue(e), i)), o.current = !0); }, [t, n]), Be(() => { o.current && a && new Ye([a, r]).toValue(g, l.getFieldsValue(!0)).then(u).catch((f) => { u(f), console.error("布局数据转换错误: ", f, a); }); }, [g, a, r]), [c ?? g, g]; }, sn = (e, t, n = "@pkg/ff/grid-layouts", a = null) => G(() => { var r; return (r = p.sortBy(e, ["y", "x"])) == null ? void 0 : r.map(({ i, x: s, y: o, w: l, h: c, field: { boxStyle: u, widgetPrefix: g = n, widget: h, ...y } }, f) => d("div", { className: "grid-layout-item", style: Zt(s, o, l, c, u, h === "Height" && (y == null ? void 0 : y.initialValue)), children: d(ia, { ...y, basicForm: a, itemWidget: h != null && h.startsWith("@") || h != null && h.startsWith("blob:") ? h : `${g}/${h}`, itemWidgetRender: t }) }, i || f)); }, [e]), ia = ({ itemWidget: e, itemWidgetRender: t, basicForm: n, ...a }) => { const [r, i] = N(); return R(() => { Z.getWidgetComponent(e).then(({ defaultProps: s = {}, default: o }) => { i(C.createElement(t(o, s, n), a)); }).catch((s) => { console.error(s), i(e); }); }, [e]), r; }, on = ({ cols: e = 12, rowHeight: t = 21, fields: n = [], data: a, containerPadding: r = [0, 0], itemMargin: i = [4, 0], formProps: s = {}, className: o, ...l }) => { const [c] = Q.useForm(), u = sn(n, sa, "@pkg/ff/grid-layouts"), g = G(() => [{ name: "__PROPS__", value: s }], [s]); return Be(() => (c.setFieldsValue(a), () => c.resetFields()), [a]), d(Q, { fields: g, form: c, component: !1, children: d("div", { ...l, className: V("ff-grid-layout", o), style: { "--grid-layout-item-margin-y": `${(i == null ? void 0 : i[0]) || 0}px`, "--grid-layout-item-margin-x": `${(i == null ? void 0 : i[1]) || 0}px`, "--grid-layout-container-padding-y": `${(r == null ? void 0 : r[0]) || 0}px`, "--grid-layout-container-padding-x": `${(r == null ? void 0 : r[1]) || 0}px`, "--grid-layout-cols": e, "--grid-layout-row-height": `${t}px` }, children: u }) }); }, sa = (e, t = {}, n = null) => (a) => { const { code: r, label: i, extras: s, isVirtual: o, initialValue: l, initialValueLanguage: c, convertJs: u, convertJsSetting: g, ...h } = p.merge({}, t, a), [y, f] = rn(o ? null : r, { initialValue: l, initialValueLanguage: c, convertJs: u, convertJsSetting: g, type: (h == null ? void 0 : h.type) || "string" }, n); return d(e, { ...h, value: y, rawValue: f, $setting: s || {} }); }, cr = (At = on, function({ code: e, data: t, ...n }) { const [a, r] = N({ resource: null, cols: 12, rowHeight: 21, fields: [] }); return R(() => { e && F.get(`/api/_/${e}`).then((i) => r(p.pick(i, ["resource", "cols", "rowHeight", "fields"]))); }, [e]), (a == null ? void 0 : a.resource) && d(At, { ...n, rowHeight: a.rowHeight, cols: a.cols, fields: a.fields, data: a != null && a.resource ? { [a == null ? void 0 : a.resource]: t } : {} }); }); var At; const dr = ({ widget: e, widgetPrefix: t = "@pkg/ff/grid-layouts", basicForm: n, ...a }) => { const r = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [i, s] = N(); return R(() => { r && Z.getWidgetComponent(r).then(({ defaultProps: o = {}, default: l }) => ({ default: oa(l, o, n) })).catch((o) => ({ default: () => `${o}` })).then((o) => s(C.createElement(o.default, a))); }, [r]), i; }, oa = (e, t = {}, n = null) => (a) => { const { code: r, label: i, extras: s, isVirtual: o, initialValue: l, initialValueLanguage: c, convertJs: u, convertJsSetting: g, value: h, ...y } = p.merge({}, t, a), [f, b] = rn(o ? null : r, { initialValue: l, initialValueLanguage: c, convertJs: u, convertJsSetting: g, type: (y == null ? void 0 : y.type) || "string" }, n); return d(e, { ...y, value: f, rawValue: b, $setting: s || {} }); }, la = ({ cols: e, rowHeight: t, itemMargin: n, fields: a, primaryKey: r, dataSource: i, itemClassName: s, itemRender: o = (g, h, y) => g, empty: l = d(En, { description: null }), className: c, style: u = {} }) => { const { classNames: g } = de(ee), h = Ge(), y = G(() => d(on, { cols: e, rowHeight: t, itemMargin: n, fields: a, className: s }), [a, e, t, n]); return d("div", { className: V("ff-data-list-content", g.content, c), style: u, children: p.isEmpty(i) ? l : i.map((f, b) => { const w = o(C.cloneElement(y, { data: f }), f, b); return C.cloneElement(w, { key: `${h}-${(f == null ? void 0 : f[r]) || b}` }); }) }); }, ca = ({ component: e }) => { const { base62params: t } = jn(); return d(J, { children: d(kt, { listCode: e, base62params: F.decode(t) }) }); }, da = () => "Empty", ua = ({ component: e, $setting: t }) => { const [n, a] = N(); R(() => { if (!e) return a(d(da, { description: null })); Z.getWidgetComponent(e).catch((i) => ({ default: () => `${i}` })).then((i) => C.createElement(i.default, { $setting: t })).then(a); }, [e]); const r = le.getPageParams() || {}; return n ? C.cloneElement(n, r) : null; }; var he, Y, fe, ye, Me, ze; const re = class re { constructor() { E(this, Y, /* @__PURE__ */ new Map()); E(this, fe, {}); E(this, ye, null); x(this, "init", (t, n) => { B(this, Y, t), B(this, fe, n); }); x(this, "get", (t) => (m(this, Y).has(t) || (t = Array.from(m(this, Y).keys()).find((n) => m(this, Y).get(n).uri === t)), m(this, Y).get(t) || {})); x(this, "redirect", (t, n, a = {}) => { const { uri: r, type: i, widgetProps: s } = this.get(t) || {}; let o = An(r || t, i != "list" ? n : p.mapValues(n, (c) => F.encode(c))); const l = new URLSearchParams(); for (const c in s || {}) (s == null ? void 0 : s.type) == "query" && l.append(c, n[c]); return l.size > 0 && (o = `${o}?${l.toString()}`), m(this, ye).navigate(o, a); }); x(this, "getMenus", (t) => { var n; return ((n = m(this, fe)) == null ? void 0 : n[t]) || []; }); x(this, "findMenuPathByUuid", (t) => { let n = []; for (const a in m(this, fe)) if (n = m(this, Me).call(this, m(this, fe)[a], t, [a]), n.length > 1) return n; return n; }); x(this, "getMenusByRouteUuid", (t) => m(this, ze).call(this, t, Object.values(m(this, fe)).flat())); E(this, Me, (t, n, a = []) => { if (p.isEmpty(t)) return a; for (const { uuid: r, children: i } of t) { if (r == n) return a.concat(r); if (!p.isEmpty(i)) return a.concat(r, m(this, Me).call(this, i, n)); } return a; }); E(this, ze, (t, n) => { var r; let a = []; for (const i of n) i.widgetType == "redirect" && (i.uuid == t || i.widget == t ? a.push(i) : (r = i.children) != null && r.length && (a = a.concat(m(this, ze).call(this, t, i.children)))); return a; }); x(this, "getCurrentMenu", () => { const { uuid: t } = this.getCurrentRoute() || {}; if (!t) return; const n = this.getMenusByRouteUuid(t); return p.isEmpty(n) ? void 0 : n[0]; }); x(this, "getCurrentRoute", (t = 0) => { var a; const n = (a = m(this, ye).state.matches[m(this, ye).state.matches.length - 1 - t]) == null ? void 0 : a.route; if (!n) return null; for (let [r, i] of m(this, Y)) if (i.uri === n.path) return i; return null; }); x(this, "getPageParams", (t) => { var i, s; const { location: n = {}, matches: a = [] } = ((i = m(this, ye)) == null ? void 0 : i.state) || {}, r = ((s = a[a.length - 1]) == null ? void 0 : s.params) || {}; return n.search && new URLSearchParams(n.search).forEach((o, l) => { r[l] = o; }), t ? p.get(r, t) : r; }); x(this, "createBrowserRouter", (t = {}) => { if (m(this, Y).size == 0) return null; const n = Oe.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/ff/frameworks/DefaultTheme"), a = Oe.get(Z.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), r = { [n]: 0 }, i = (o, l) => () => Z.getWidgetComponent(o).then((c) => c.default || function() { return `${o}`; }).then((c) => ({ Component: () => C.createElement(Kt, {}, C.createElement(c, l)) })), s = Array.from(m(this, Y).values()).reduce((o, { uuid: l, uri: c, name: u, type: g, component: h, widgetSetting: y, isLogin: f, isLayout: b, extra: w }) => { let $ = {}, I = 0; switch (g) { case "list": $.element = C.createElement(ca, { component: h }); break; case "fsdpf-component": $.element = C.createElement(ua, { key: h, component: h, $setting: y }); } if (w != null && w.layout) { if (!r[w == null ? void 0 : w.layout]) return r[w == null ? void 0 : w.layout] = o.length, [...o, { path: "/", lazy: i(w == null ? void 0 : w.layout, {}), children: [{ path: c, ...$ }] }]; I = r[w == null ? void 0 : w.layout]; } return b && I > -1 ? (o[I].children.push({ path: c, ...$ }), o) : [...o, { path: c, ...$ }]; }, [{ path: "/", lazy: i(n, {}), children: [] }]); return s.push({ index: !0, element: C.createElement(ga, { to: a, replace: !0 }) }), B(this, ye, In(s, t)); }); if (m(re, he)) return m(re, he); } }; he = new WeakMap(), Y = new WeakMap(), fe = new WeakMap(), ye = new WeakMap(), Me = new WeakMap(), ze = new WeakMap(), E(re, he, null), x(re, "getInstance", () => (m(re, he) || B(re, he, new re()), m(re, he))); let mt = re; const ga = ({ to: e, replace: t }) => Mn() ? C.createElement(zn, { to: e, replace: t }) : (window.document.location = e, "redirect"), le = mt.getInstance(), Se = new Worker(new URL("/ff-worker/index.js", self.location)), It = { getConfigure: (e) => Oe.get(e), route: { redirect: (...e) => le.redirect(...e), getPageParams: (...e) => le.getPageParams(...e), getCurrentRoute: () => le.getCurrentRoute() }, popup: { notification: (...e) => H.notification(...e), success: (...e) => H.success(...e), error: (...e) => H.error(...e), form: (...e) => H.form(...e), modal: (...e) => H.modal(...e), confirm: (...e) => H.confirm(...e) } }; var tt, Te, we; const W = class W { constructor() { x(this, "exec", (t, n = {}, a = {}, r = "") => new Promise((i, s) => { const o = Ft(W, tt)._++; m(W, Te).set(o, a), W.mQueue.set(o, [i, s]), Se.postMessage({ id: o, session: r, category: "eval", method: t, args: n }); })); x(this, "clear", (t) => Se.postMessage({ session: t, category: "clear" })); if (m(W, we)) return m(W, we); Promise.resolve().then(() => Aa).then((t) => { It.http = t.http; }), Se.addEventListener("message", ({ data: { id: t, task_id: n, method: a, args: r, category: i, data: s, error: o, session: l } }) => { if (i === "eval" && W.mQueue.has(t)) o !== null ? W.mQueue.get(t)[1](o) : W.mQueue.get(t)[0](s), m(W, Te).delete(t), W.mQueue.delete(t); else if (i === "util") try { const c = p.get(It, a.split("/")) || p.get(m(W, Te).get(n), a.split("/")); if (!p.isFunction(c)) throw `${a} not found`; Promise.resolve(Reflect.apply(c, void 0, r)).then((u) => { Se.postMessage({ id: t, task_id: n, category: i, method: a, args: r, session: l, data: u, error: null }); }).catch((u) => { Se.postMessage({ id: t, task_id: n, category: i, method: a, args: r, session: l, data: null, error: u }); }); } catch (c) { Se.postMessage({ id: t, task_id: n, category: i, method: a, args: r, session: l, data: null, error: c }); } }, !1); } }; tt = new WeakMap(), Te = new WeakMap(), we = new WeakMap(), x(W, "mQueue", /* @__PURE__ */ new Map()), E(W, tt, 0), E(W, Te, /* @__PURE__ */ new Map()), E(W, we, null), x(W, "getInstance", () => (m(W, we) || B(W, we, new W()), m(W, we))); let ht = W; const Ce = ht.getInstance(), vt = () => { const e = D(!0), [, t] = C.useReducer((n) => n + 1, 0); return R(() => () => e.current = !1, []), () => e.current && t(); }, ur = (e) => { const t = D(); return R(() => { t.current = e; }, [e]), t.current; }, gr = (e) => { const [t, n] = N(e), a = D(null), r = ce((i, s) => { a.current = s, n(i); }, []); return R(() => { a.current && (a.current(t), a.current = null); }, [t]), [t, r]; }, Be = (e = (a) => { }, t, n = p.isEqual) => { const a = C.useRef(); n(t, a.current) || (a.current = p.cloneDeep(t)), C.useEffect(e, [a.current]); }, xt = Be, ln = (e, t = "string") => { var n; if (!Array.isArray(e)) return e; for (let a = 0; a < e.length; a++) e[a].value = X((n = e[a]) == null ? void 0 : n.value, t), e[a] && Reflect.has(e[a], "children") && (e[a].children = ln(e[a].children, t)); return e; }, pr = (e, t = "json", n = "string", a, r = null) => { const [i] = Q.useForm(a), [s, o] = N([{ label: "无", value: "", disabled: !0 }]), l = D([]), c = Q.useWatch((u) => l.current.length === 0 ? null : p.pick(u, l.current), i) || null; return R(() => { Array.isArray(e) ? o(e) : t === "javascript" && e ? Ce.exec(e, {}, { getFieldValue: (u) => (l.current.includes(u) || l.current.push(u), i.getFieldValue(u)), getFieldValueForBasicForm: (u) => (l.current.includes(u) || l.current.push(u), r ? r.getFieldValue(u) : i.getFieldValue(u)) }).then((u) => { o(X(u, "array")); }) : e && o(X(e, "array")); }, [e, t, c]), ln(s, n); }, mr = (e) => { const [t, n] = N(), a = { type: "GET" }; if (typeof e == "string" ? a.url = e : p.isPlainObject(e) && Object.assign(a, e), !(a != null && a.url)) throw "url is required"; const r = (i) => F.request(a, !1).resp((s) => (console.log("useSubscribeRequest", i), n(s), s)); return Be(() => { let i = null; return r().then((s) => { i = nn.subscribe(p.throttle(r, 180, { leading: !1, trailing: !0 }), s.res); }), () => i == null ? void 0 : i(); }, a), t; }, pa = (e) => { const [t, n] = C.useState({ gridItems: [], hideItems: [] }); return C.useEffect(() => { e && F.get(`/api/_/${e}`).then(({ pk: a, uuid: r, code: i, resource: s, align: o, cols: l, rowHeight: c, marginX: u, marginY: g, listenChangeFields: h, listenChangeFieldsFunc: y, fields: f }) => ({ pk: a, uuid: r, code: i, resource: s, align: o, cols: l, rowHeight: c, marginX: u, marginY: g, listenChangeFields: h, listenChangeFieldsFunc: y, ...f.reduce((b, w) => { var $; return ($ = w == null ? void 0 : w.field) != null && $.hidden ? b.hides.push(w == null ? void 0 : w.field) : b.items.push(w), b; }, { items: [], hides: [] }) })).then(n); }, [e]), t; }, ma = ({ max: e = 0, min: t = 0, type: n = "", message: a, pattern: r, required: i = !1, validator: s } = {}, o, l) => { const [c, u] = N([]); return R(() => { const g = []; if (i) { let h = l; switch (l) { case "number": case "string": case "array": break; case "bool": h = "boolean"; break; case "json": h = "object"; } g.push({ type: h, required: !0, whitespace: !0, message: "该项必填" }); } switch (n) { case "string": g.push({ type: n, max: e, min: t, message: a || (t && e ? `字符必须在 ${t} ~ ${e} 之间` : `${e ? "最多能有" : "最少要有"} ${t || e} 个字符`) }); break; case "pattern": g.push({ type: "string", pattern: r, message: a }); break; case "validator": s && g.push(({ getFieldValue: h }) => ({ validator: async (y, f) => { const b = await Ce.exec(s, { value: f, fieldName: o }, { getFieldValue: h }); return p.isString(b) && b ? Promise.reject(b) : p.isBoolean(b) && !b ? Promise.reject(a) : Promise.resolve(); } })); } u(g); }, [e, t, n, a, r, i, s]), c; }, ha = (e, t, n) => { const [a, r] = N(null); return R(() => { const { initDataUri: i = `/api/${e}`, initDataMethod: s = "GET" } = n || {}; t && F.request({ method: s, url: p.trimEnd(`${i}/${t}`, "/") }).then((o) => { r(o); }); }, [e, t, n]), a; }, fa = (e, t, n, a = {}) => { const r = vt(), i = D(!0), s = D([]), [o, l] = N(n), c = Q.useWatch((u) => JSON.stringify(p.pick(u, s.current)), t) || "{}"; return R(() => { e && Ce.exec(e, a, { getFieldValue: p.wrap(t.getFieldValue, (u, g) => (s.current.some((h) => p.isEqual(h, g)) || (s.current.push(g), r()), u(g))), isFieldTouched: t.isFieldTouched, isFieldsTouched: t.isFieldsTouched }).then((u) => i.current && l(u)); }, [e, c, t, a]), R(() => () => i.current = !1, []), o; }, hr = ({ value: e, onChange: t }, n = null) => { const a = D(), [r] = Q.useForm(n); return xt(() => { p.isEqual(a.current, e) || r.setFieldsValue(e); }, [e]), R(() => () => r.resetFields(), []), [G(() => r.__INTERNAL__ ? r : { ...r, __INTERNAL__: {} }, [r]), (i, s) => { a.current = s, t(s); }]; }, ya = ({ type: e, initialValue: t, initialValueLanguage: n, onChange: a, form: r }) => { const i = fa(n == "javascript" && t, r, n == "javascript" ? void 0 : t, {}); return R(() => { n == "javascript" ? a(X(i, e)) : t && a(X(t, e)); }, [e, t, i]), null; }, wa = ({ widget: e = "Input", widgetPrefix: t = "@pkg/ff/grid-layout-forms", widgetDecorator: n, subWidgets: a, basicForm: r, ...i }) => { const s = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [o, l] = N(); return R(() => { s && Z.getWidgetComponent(s).then(({ defaultProps: c = {}, default: u }) => ({ default: cn(u, c, r) })).catch((c) => ({ default: () => `${c}` })).then((c) => l(C.createElement(c.default, i))); }, [s]), o && C.cloneElement(o, i); }, cn = (e, t = {}, n = null) => (a) => { const { type: r, code: i, label: s, noStyle: o, placeholder: l, extras: c, validators: u, help: g, isVirtual: h, $isReserved: y, initialValue: f, initialValueLanguage: b, convertJs: w, convertJsSetting: $, widgetPerfix: I, boxStyle: L, widgetDecorator: M, subWidgets: j, ...A } = { ...t, ...a }, T = ma(u || {}, i, r), v = { label: s, noStyle: o, colon: !1, layout: "vertical" }, S = { placeholder: l, ...A }, U = ce((z) => z == null ? void 0 : X(z, r), [r]); return d(Ht, { name: i, rules: T, initialValue: U(f), normalize: U, children: (z, K, ue) => { var _; return d(e, { type: r, rcform: ue, itemProps: { validateStatus: K.errors.length > 0 ? "error" : "success", tooltip: g, help: K.errors.length > 0 ? K.errors.join("、") : null, required: ((_ = T == null ? void 0 : T[0]) == null ? void 0 : _.required) || !1, ...v }, fieldProps: { ...S, ...z }, $setting: c || {} }); } }); }, St = ({ cols: e = 24, rowHeight: t = 16, itemMargin: n = [8, 16], containerPadding: a = [0, 0], fields: r = [], children: i, basicForm: s = null }) => { const o = sn(r, cn, "@pkg/ff/grid-layout-forms"); return O("div", { className: "ff-grid-layout-form", style: { "--grid-layout-item-margin-x": `${(n == null ? void 0 : n[0]) ?? 8}px`, "--grid-layout-item-margin-y": `${(n == null ? void 0 : n[1]) ?? 16}px`, "--grid-layout-container-padding-y": `${(a == null ? void 0 : a[0]) || 0}px`, "--grid-layout-container-padding-x": `${(a == null ? void 0 : a[1]) || 0}px`, "--grid-layout-cols": e, "--grid-layout-row-height": `${t}px` }, children: [o, i && C.cloneElement(i, { cols: e, rowHeight: t, itemMargin: n, containerPadding: a, fields: r })] }); }; St.propTypes = { fields: k.array }; const ba = (Mt = St, ({ code: e, layout: t, name: n, primaryKey: a = 0, style: r = {}, formProps: i = {}, form: s, isPreview: o = !1, className: l, onFinish: c, onValuesChange: u = () => { }, ...g }) => { const { align: h, autoComplete: y, resource: f, items: b, hides: w, rowHeight: $, marginX: I, marginY: L, cols: M, listenChangeFields: j, listenChangeFieldsFunc: A, pk: T, uuid: v } = pa(e), [S] = Q.useForm(s), U = G(() => [{ name: "__PK__", value: T }, { name: "__PROPS__", value: i }, { name: "__RESOURCE__", value: f }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: v }, { name: "__PRIMARY_KEY__", value: a }], [T, e, v, f, a, i]); return O(Q, { className: l, name: n || e, layout: t || h, fields: U, form: S, autoComplete: y, style: { ...r, position: "relative" }, onFinish: c, onValuesChange: (z, K) => (({ changedValues: ue, allValues: _, listenChangeFields: nt, listenChangeFieldsFunc: De, onValuesChange: at, code: Nt }) => { at(ue, _), De && Array.isArray(nt) && Ce.exec(De, { changedValues: ue, allValues: _ }, { getFieldValue: S.getFieldValue, setFieldValue: S.setFieldValue, setFieldsValue: S.setFieldsValue, isFieldTouched: S.isFieldTouched, isFieldsTouched: S.isFieldsTouched }); })({ changedValues: z, allValues: K, listenChangeFields: j, listenChangeFieldsFunc: A, onValuesChange: u, code: e }), children: [d(Mt, { ...g, form: S, code: e, fields: b, cols: M, rowHeight: $, itemMargin: [I, L] }), w == null ? void 0 : w.map((z) => { var K; return d(Ht, { name: z.code, children: d(ya, { form: S, name: z.code, type: z.type, initialValue: z.initialValue, initialValueLanguage: (K = z.extras) == null ? void 0 : K.initialValueLanguage }) }, JSON.stringify(z.code)); })] }, e); }); var Mt; const dn = ({ $setting: e, $close: t, extras: n, code: a, primaryKey: r, ...i }) => { const [s] = Q.useForm(), o = ha(a, r, e); return R(() => { o && s.setFieldsValue(o); }, [o]), d(J, { actions: O(C.Fragment, { children: [d(P, { name: "保存", type: "primary", widget: () => { const l = s.getFieldValue("__RESOURCE__"), { initDataUri: c = `/api/${a}` } = e || {}; s.validateFields(!0).then((u) => l ? p.pick(u, [l]) : u).then((u) => F.post(r ? `${c}/${r}` : `${c}`, u).msg(t)).catch(() => H.error("请先完善表单信息", { duration: 2e3 })); } }), d(P, { name: "取消", widget: () => t(!1) })] }), extras: n, children: d(ba, { form: s, code: a, primaryKey: r, ...i }) }); }, Ca = (e, t, n, { isReplaceRouteHistory: a = !1 } = {}) => le.redirect(n, t, { replace: a }), ka = (e, t = {}, n, a = {}) => { var i; const r = (i = a.router) == null ? void 0 : i.reduce((s, [o, l, c]) => { const u = p.get(t, ["router", o]); if (!u && u !== 0 && l) throw `请传入 ${c}`; return `${s}/${u}`; }, `/api/${n}`); return F.del(r, t.param).msg(); }, zt = (e, t, n, { status: { loading: a, disabled: r }, setStatus: i }) => { const s = { loading: (o) => o === void 0 ? a : i((l) => ({ ...l, loading: o })), disabled: (o) => o === void 0 ? r : i((l) => ({ ...l, disabled: o })) }; return p.isFunction(n) ? n.call(null, { ...t, ...s }) : p.isString(n) && n ? Ce.exec(n, t, s) : null; }, Wt = (e, t, n, a, r) => p.isString(n) && n ? Z.getWidgetComponent(n).then(({ default: i }) => H.modal(i, { ...t, $setting: a }, r != null && r.title ? { ...r, title: p.template(r.title)(e) } : r)).catch((i) => { H.error(n, { content: i.toString() }); }) : H.modal(n, { ...t, $setting: a }, r != null && r.title ? { ...r, title: p.template(r.title)(e) } : r), va = (e, t, n, a, r) => H.modal(dn, { ...t, $setting: a, code: n }, r != null && r.title ? { ...r, title: p.template(r.title)(e) } : r), xa = (e, t, n, a, r) => H.modal(kt, { base62params: t, $setting: a, listCode: n }, r != null && r.title ? { ...r, title: p.template(r.title)(e) } : r), Sa = ({ widget: e, widgetType: t, widgetData: n, widgetProps: a, widgetSetting: r, widgetContainerProps: i }, { onAfterClick: s, onBeforeClick: o }) => { const l = de(ee), [c, u] = N({ leading: !0, trailing: !1 }), g = G(() => { switch (t) { case "redirect": return p.partialRight(Ca, e, r); case "func": return p.partialRight(zt, (r == null ? void 0 : r.code) ?? e, { status: c, setStatus: u }); case "fsdpf-component": return p.partialRight(Wt, e, r, i); case "grid-layout-form": return p.partialRight(va, e, r, i); case "data-list": return p.partialRight(xa, e, r, i); case "destroy": return p.partialRight(ka, e, r, i); default: if (Pt(e) || C.isValidElement(e)) return p.partialRight(Wt, e, r, i); if (p.isFunction(e)) return p.partialRight(zt, (r == null ? void 0 : r.code) || e, { status: c, setStatus: u }); } return (...h) => console.error("useButton unknown widgetType", t, ...h); }, [e, t]); return [p.debounce((h) => (o == null || o(h), Promise.resolve(Gt(a, h, { list: l })).then((y) => g(h, { ...n, ...y })).then((y) => s == null ? void 0 : s(y)).catch(console.error)), 300, { leading: !0, trailing: !1 }), c]; }, Bt = /* @__PURE__ */ new Set(), ft = (e = [], t = 0) => { const n = e[t]; if (n.length && !Bt.has(n)) { const a = document.createElement("script"); a.setAttribute("src", n), a.setAttribute("data-namespace", n), e.length > t + 1 && (a.onload = () => { ft(e, t + 1); }, a.onerror = () => { ft(e, t + 1); }), Bt.add(n), document.body.appendChild(a); } }, yt = ({ className: e, type: t, style: n = {}, ...a }) => d("span", { role: "img", className: V("ff-iconfont", e), style: n, ...a, children: d("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: d("use", { xlinkHref: `#${t}` }) }) }); yt.propTypes = { className: k.string, type: k.string.isRequired, style: k.object }, yt.init = ft; const Ue = (e) => function({ className: t, children: n, name: a, icon: r, type: i = "default", iconPosition: s = "start", noAuthType: o, onAfterClick: l, onBeforeClick: c, data: u, loading: g, disabled: h, tooltip: y, confirm: f, widget: b, widgetType: w, widgetData: $, widgetProps: I, widgetSetting: L, widgetContainerProps: M, ...j }) { const A = p.isEmpty(y) || !y.enabled ? {} : y, T = p.isEmpty(f) ? { enabled: !1 } : Object.assign({ enabled: !0 }, f), v = { type: "primary", className: V("ff-button", t), iconPosition: s }; i === "danger" ? v.danger = !0 : i === "default" && (v.type = i), e === "link" || e === "dashed" ? (v.type = e, i === "default" && (v.className = V(v.className, "ff-default"))) : e !== "circle" && e !== "round" || (v.shape = e), r && (v.icon = d(yt, { type: r })); const [S, U] = N(!1), [z, { disabled: K, loading: ue }] = Sa({ widget: b, widgetType: w, widgetData: $, widgetProps: I, widgetSetting: L, widgetContainerProps: M }, { onAfterClick: l, onBeforeClick: c }); return d(Rn, { okText: "确定", cancelText: "取消", ...T, disabled: K || h, open: S, onOpenChange: (_) => { if (!_) return U(_); T.enabled ? U(_) : z(u); }, onConfirm: () => { z(u); }, onClick: (_) => { _.stopPropagation(); }, children: d(Fn, { ...A, title: S ? null : A == null ? void 0 : A.title, trigger: ["hover", "click"], children: d(lt, { loading: ue || g, disabled: K || h, ...v, ...j, children: n || a }) }) }); }, P = Ue("default"), $a = Ue("link"), Pa = Ue("circle"), Na = Ue("round"), Ta = Ue("dashed"), Ut = ({ data: e, widget: t, widgetType: n = "fsdpf-component", children: a, widgetData: r, widgetProps: i, widgetSetting: s, widgetContainerProps: o }) => { const l = de(ee), [c, u] = N(!1), [g, h] = N("hover"), [y, f] = N({}), [b, w] = N(), { placement: $, align: I, arrow: L = { pointAtCenter: !0 }, getPopupContainer: M, ...j } = o || {}; R(() => { n == "grid-layout-form" ? w(C.createElement(dn, { ...r, $setting: s, code: t })) : n == "data-list" ? w(C.createElement(kt, { base62params: e, $setting: s, listCode: t })) : p.isString(t) ? Z.getWidgetComponent(t).then(({ default: v }) => { w(C.createElement(v, { ...r, $setting: s })); }).catch((v) => w(v.toString())) : Pt(t) ? w(C.createElement(t, { ...r, $setting: s })) : C.isValidElement(t) && w(C.cloneElement(t, { ...r, $setting: s })); }, [t, n, r]), R(() => { Promise.resolve(Gt(i, e, { list: l })).then(f); }, [i, e]); const A = (v) => { u(v), !v && h("hover"); }, T = (v) => { u(!0), h("click"); }; return d(On, { zIndex: 1080, placement: $, onPopupClick: T, onClick: T, open: c, align: I, arrow: L, trigger: g, getPopupContainer: M, content: d(Ea, { ...j, children: b && C.cloneElement(b, { ...y, $close: () => A(!1) }) }), children: a, onOpenChange: A }); }, Ea = ({ title: e, className: t, children: n, width: a, height: r, ...i }) => { const [s, o] = N({}), l = ce((g, h) => o((y) => ({ ...y, [g]: h })), []), c = ce((g) => o((h) => ({ ...h, [g]: void 0 })), []), u = e ? C.createElement("div", { className: "ff-popup-title" }, e) : s == null ? void 0 : s.title; return d(We.Provider, { value: { ele: s, mount: l, unmount: c }, children: O("div", { className: V("ff-popup ff-popover", t), style: { width: a, height: r }, ...i, children: [O("div", { className: "ff-popup-header", children: [u, s == null ? void 0 : s["sub-title"]] }), n, O("div", { className: "ff-popup-footer", children: [s == null ? void 0 : s.extras, s == null ? void 0 : s.actions] })] }) }); }; Ut.propTypes = { widgetType: k.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) }, P.propTypes = { type: k.oneOf(["primary", "default", "danger", ""]), name: k.string, icon: k.string, iconPosition: k.oneOf(["start", "end"]), data: k.any, widget: k.any, widgetType: k.oneOf(["destroy", "redirect", "func", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: k.object, widgetProps: k.object, widgetSetting: k.object, widgetContainerProps: k.object, tooltip: k.exact({ title: k.string.isRequired, placement: k.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: k.oneOfType([k.bool, k.number]), getPopupContainer: k.func }), confirm: k.exact({ title: k.string.isRequired, cancelText: k.string, okText: k.string, okType: k.oneOf(["primary", "default", "danger", ""]), placement: k.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: k.oneOfType([k.bool, k.number]), getPopupContainer: k.func, arrow: k.oneOfType([k.bool, k.exact({ pointAtCenter: k.bool })]) }) }, P.Link = $a, P.Link.defaultProps = P.defaultProps, P.Link.propTypes = P.propTypes, P.Circle = Pa, P.Circle.defaultProps = P.defaultProps, P.Circle.propTypes = P.propTypes, P.Round = Na, P.Round.defaultProps = P.defaultProps, P.Round.propTypes = P.propTypes, P.Dashed = Ta, P.Dashed.defaultProps = P.defaultProps, P.Dashed.propTypes = P.propTypes, P.Popover = Ut; const Ra = ({ fields: e, formProps: t, $close: n }) => { const [a] = Q.useForm(), r = G(() => [{ name: "__PROPS__", value: t }], [t]); return d(J, { actions: O(C.Fragment, { children: [d(P, { name: "取消", widget: () => n(!1) }), d(P, { name: "确定", type: "primary", widget: () => a.validateFields(!0).then(n) })] }), children: d(Q, { fields: r, form: a, className: "ff-modal-form", children: e == null ? void 0 : e.map(({ code: i, ...s }) => d(wa, { code: i, ...s }, i)) }) }); }, Fa = ({ className: e, $close: t, children: n, title: a, subTitle: r, actions: i, extras: s, zIndex: o, ...l }) => O(Un, { ...l, prefixCls: "ff-drawer", className: V("ff-popup", e), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (c) => ({ motionAppear: !0, motionName: `panel-motion-${c}` }), children: [O("div", { className: "ff-popup-header", children: [d("button", { "aria-label": "Close", className: "ff-popup-close", onClick: l.onClose, children: d(Ct, { type: "close" }) }), a, r] }), d("div", { className: "ff-popup-body", children: n }), O("div", { className: "ff-popup-footer", children: [s, i] })] }), Oa = ({ className: e, $close: t, $event: n, children: a, title: r, subTitle: i, actions: s, extras: o, zIndex: l, placement: c, ...u }) => { const g = (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 d(Dn, { ...u, ...g, prefixCls: "ff-modal", modalRender: () => O("div", { className: V("ff-modal-content ff-popup", e), children: [O("div", { className: "ff-popup-header", children: [d("button", { "aria-label": "Close", className: "ff-popup-close", onClick: u.onClose, children: d(Ct, { type: "close" }) }), r, i] }), d("div", { className: "ff-popup-body", children: a }), O("div", { className: "ff-popup-footer", children: [o, s] })] }) }); }, un = ({ placement: e, $close: t, $event: n, children: a, title: r, ...i }) => { const [s, o] = N({}), [l, c] = N(!0), u = ce((f, b) => o((w) => ({ ...w, [f]: b })), []), g = ce((f) => o((b) => ({ ...b, [f]: void 0 })), []); let h = { ...i, className: s.rootClassName, title: s.title || r && C.createElement("div", { className: V("ff-popup-title") }, r), subTitle: s["sub-title"], actions: s.actions, extras: s.extras, children: a, $close: t, $event: n, onClose: () => c(!1) }; const y = () => { t(!1); }; return d(We.Provider, { value: { ele: s, mount: u, unmount: g }, children: e && e !== "center" ? d(Fa, { ...h, placement: e, open: l, afterOpenChange: (f) => !f && y() }) : d(Oa, { ...h, visible: l, afterClose: y }) }); }; un.propTypes = { placement: k.oneOf(["center", "left", "top", "right", "bottom"]) }; const q = () => { const [e, t] = Wn({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (i) => { const { offsetHeight: s } = i; return { height: s }; }, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, n] = C.useReducer((i) => i + 1, 0); R(() => { q.$onClick = a, q.$queue.forEach(([i, s, o], l, c) => { r([s, o], ...i), delete c[l]; }); }, []); const a = (i, s = {}, o = {}) => new Promise((l, c) => r([l, c], i, s, o)), r = ([i, s], o, l = {}, c = {}) => { const u = q.$index++, g = (h) => ((y, f) => (q.$popups.delete(y), n(), f == null ? void 0 : f()))(u, () => i(h)); if (o === _t) return e.open({ ...c, key: u, content: C.createElement(o, { ...l, $close: () => e.close(u) }) }); q.$popups.set(u, C.createElement(un, { zIndex: u, maskClosable: !1, $event: l == null ? void 0 : l.$event, ...c, key: u, $close: g }, C.isValidElement(o) ? C.cloneElement(o, { ...l, $close: g }) : o != null && o.name || Ot.isForwardRef(o) || (o == null ? void 0 : o.$$typeof) === Ot.ForwardRef ? C.createElement(o, { ...l, $close: g }) : o)), n(); }; return O(C.Fragment, { children: [Array.from(q.$popups).map(([i, s]) => s), t] }); }; q.$popups = /* @__PURE__ */ new Map(), q.$index = 0, q.$queue = [], q.$onClick = (...e) => new Promise((t, n) => { q.$queue.push([e, t, n]); }); const Dt = (e, t, n = {}) => q.$onClick(e, t, n), st = (e, { showProgress: t, duration: n, ...a } = { duration: 1.5 }) => q.$onClick(_t, { content: e, ...a }, { showProgress: t, duration: n }), H = { modal: Dt, confirm: (e, t = {}) => q.$onClick(qn, { content: e, ...t }, { placement: "center" }), form: (e, t = {}, n = {}) => Dt(Ra, { formProps: n, fields: e }, { placement: "center", ...t }).then((a) => { if (a === !1) throw !1; return a; }), notification: st, success: (e, t = { duration: 1.5 }) => st(e, { ...t, className: "ff-notification-success", icon: "check" }), error: (e, t = { duration: 1.5 }) => st(e, { ...t, className: "ff-notification-error", icon: "close" }) }; Re.configure({ showSpinner: !1 }), Fe.interceptors.request.use((e) => { e.headers.Platform = "web", e.headers.SaaS = window.localStorage.getItem("SaaS"); const t = window.localStorage.getItem(_e); return e.headers.Authorization = t ? `Bearer ${t} ` : void 0, Re.inc(), e; }, (e) => (Re.done(), Promise.reject({ code: -1, msg: e }))), Fe.interceptors.response.use(({ data: e, headers: t }) => (Re.done(), { ...e, res: t == null ? void 0 : t.res }), function(e) { return Re.done(), Promise.reject(e.message); }), window.addEventListener("unhandledrejection", ct.onUnhandledRejection), ct.onMsg = (e, t) => H[[0, 1].includes(e) ? "success" : "error"](t).then(() => e === 20300 && le.redirect(Oe.get("Common.WEBSITE_LOGIN_PAGE"))); const wt = { appUrl: "", init: (e, t, n) => { wt.appUrl = n, Fe.defaults.baseURL = n, Fe.defaults.timeout = 15e3, Object.assign(wt, new ct(e, t, Fe)); } }, F = wt; class $t extends Error { constructor(t, n) { super(n), Error.captureStackTrace && Error.captureStackTrace(this, $t), !n instanceof Le && (this.name = `${t} Error Runtime`); } } class Le extends Error { constructor(t, ...n) { super(...n), Error.captureStackTrace && Error.captureStackTrace(this, Le), this.name = `${t} Not Found`; } } const ot = "mine", _e = "token"; var be, Ee; const ie = class ie { constructor() { E(this, Ee, /* @__PURE__ */ new Map()); x(this, "setVendor", (t, n) => m(this, Ee).set(t, new Jt(n, async (a, r) => { var s, o; if (!(a != null && a.default)) throw "@pkg not found"; let i = () => r; switch ("function") { case typeof (i = (s = a.default) == null ? void 0 : s[`./${r}/index.jsx`]): case typeof (i = (o = a.default) == null ? void 0 : o[`./${r}/index.js`]): return i(); } throw new Le(r); }))); x(this, "getWidgetComponent", async (t) => { if (!t) throw "getWidgetComponent widget is required"; if (t != null && t.startsWith("blob:") || t != null && t.startsWith("http:") || t != null && t.startsWith("https:")) return await import(t); const [, n] = t == null ? void 0 : t.split("@pkg/"); if (!n) throw new Le(t); try { return m(this, Ee).has("pkg") ? await m(this, Ee).get("pkg").get(n) : await import(`${F.appUrl}/api/pkg-import/web?name=${t}`); } catch (a) { throw new $t(t, a); } }); x(this, "getRoutes", () => F.get("/api/my-router").then((t) => [...t, { 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: n, ...a }) => [n, { uuid: n, ...a }])).then((t) => new Map(t))); x(this, "getMenus", () => F.get("/api/my-menu")); x(this, "getConfigure", () => F.get("api/init-configure")); x(this, "getWidgetOperationAuth", () => F.get("/api/init-widget-operation-auth").then((t) => t.reduce((n, { uuid: a, auth: r }) => [...n, [a, r]], []))); x(this, "getPhoneNumber", (t) => F.get(`/api/user-wx-phone-number/${t}`)); x(this, "getUserToken", () => { const t = window.localStorage.getItem(_e); if (!t) return ""; const n = t.split("."); if (!Array.isArray(n) || n.length !== 3) throw "登录令牌无效!"; const { iat: a } = JSON.parse(window.atob(n[1])); if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - a > 2592e3) throw "登录令牌已过期, 请重新登录!"; return t; }); x(this, "checkUserToken", () => { try { return !!this.getUserToken(); } catch { return !1; } }); x(this, "getUserInfo", (t = !0) => { var n; try { const a = this.getUserToken(); if (!a) return Promise.resolve(null); const { iat: r } = JSON.parse(window.atob((n = a == null ? void 0 : a.split(".")) == null ? void 0 : n[1])), { iat: i, ...s } = F.decode(window.localStorage.getItem(ot) || "", {}); return i === r ? Promise.resolve(s) : F.get("/api/mine-info").then(({ User: o = null }) => (window.localStorage.setItem(ot, F.encode({ ...o, iat: r })), o)); } catch (a) { console.error(a), t && H.error("请登录").then(this.logout); } return Promise.resolve(null); }); x(this, "login", (t, n, a = {}) => F.post("/api/user-token", { username: t, passwd: Bn.hash(n), platform: "web", ...a }).then(({ token: r }) => (window.localStorage.setItem(_e, r), r))); x(this, "logout", (t) => (window.localStorage.removeItem(ot), window.localStorage.removeItem(_e), t == null ? void 0 : t())); if (m(ie, be)) return m(ie, be); } }; be = new WeakMap(), Ee = new WeakMap(), E(ie, be, null), x(ie, "getInstance", () => (m(ie, be) || B(ie, be, new ie()), m(ie, be))); let bt = ie; const Z = bt.getInstance(), La = C.createContext({ user: {}, initUser: () => { }, initUserComplete: !1 }), Va = C.createContext({ set: () => { }, get: () => { }, assign: () => { }, currentRoute: () => { } }), Pt = (e) => !!(e != null && e.name) && (e.prototype instanceof C.Component || /^[A-Z]/.test(e.name)), ja = (e, t) => { if (!e || typeof window > "u") return; let n = document.querySelector(`style[ff-style-token="${t}"]`); return n ? (n.innerHTML = e, e) : (n = document.createElement("style"), n.setAttribute("ff-style-token", t), n.setAttribute("type", "text/css"), n.innerHTML = e, document.head.appendChild(n), e); }, Aa = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: La, AppGlobalParamsContext: Va, cache: Jt, configure: Oe, default: Z, func: Ce, http: F, insertStyle: ja, isReactComponent: Pt, route: le }, Symbol.toStringTag, { value: "Module" })), Ia = (e, t, n = "children") => { if (p.isEmpty(e)) return {}; const a = p.find(e, ["value", t]); if (!p.isEmpty(a)) return a; const r = e.length; for (let i = 0; i < r; i++) { const { [n]: s } = e[i], o = Ia(s, t, n); if (!p.isEmpty(o)) return o; } return {}; }; export { Hn as $, or as A, lr as B, gt as C, Ye as D, Kn as E, _n as F, cr as G, ra as H, vt as I, ur as J, gr as K, Be as L, xt as M, pr as N, mr as O, ba as P, St as Q, nn as R, wa as S, dn as T, pa as U, ma as V, ha as W, fa as X, hr as Y, yt as Z, P as _, rr as a, Sa as a0, J as a1, We as a2, Kt as a3, q as a4, H as a5, er as a6, tr as a7, nr as a8, Z as a9, Pt as aa, ja as ab, F as ac, Jt as ad, Oe as ae, Ce as af, le as ag, La as ah, Va as ai, Ia as aj, ir as b, sr as c, Yt as d, Zt as e, an as f, Gt as g, on as h, dr as i, rn as j, sn as k, tn as l, en as m, na as n, ta as o, Zn as p, kt as q, it as r, ee as s, X as t, ar as u, aa as v, la as w, Gn as x, Xn as y, Jn as z };