import { jsx as h } from "react/jsx-runtime"; import v, { useRef as d, useEffect as R } from "react"; import P from "react-dom"; import { Badge as y, ChakraProvider as O } from "@chakra-ui/react"; var s, i = P; if (process.env.NODE_ENV === "production") s = i.createRoot, i.hydrateRoot; else { var p = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; s = function(e, r) { p.usingClientEntryPoint = !0; try { return i.createRoot(e, r); } finally { p.usingClientEntryPoint = !1; } }; } const E = "https://uikit.d.aiengines.ir/GBadge.js", f = "__UIKIT_REMOTE_DEPS__", l = "__UIKIT_REMOTE_CONFIG__", a = /* @__PURE__ */ new Map(); function w(e = {}) { if (typeof window > "u") return; const r = window[f] || {}, o = window[l] || {}; window[f] = { ...r, React: e.React || r.React || v, createRoot: e.createRoot || r.createRoot || s, ChakraProvider: e.ChakraProvider || r.ChakraProvider || O, Badge: e.Badge || r.Badge || y, theme: Object.prototype.hasOwnProperty.call(e, "theme") ? e.theme : r.theme, chakraProviderProps: { ...r.chakraProviderProps || {}, ...e.chakraProviderProps || {} } }, window[l] = { ...o, ...e.remoteUrl ? { GBadgeUrl: e.remoteUrl } : {} }; } function C() { typeof window > "u" || window[f] || w(); } function k() { var e; return typeof window > "u" ? E : ((e = window[l]) == null ? void 0 : e.GBadgeUrl) || E; } function B() { const e = k(); return a.has(e) || a.set( e, import( /* webpackIgnore: true */ /* @vite-ignore */ e ).catch((r) => { throw a.delete(e), r; }) ), a.get(e); } function T(e) { if (typeof e == "string" || typeof e == "number") return e; e != null && console.warn( "[uikit/remote/ui] GBadge only accepts text/number children across the remote boundary." ); } const N = ({ children: e, remoteUrl: r, theme: o, chakraProviderProps: m, ...g }) => { const u = d(null), t = d(null), c = d(null); return c.current = { ...g, children: T(e), ...o !== void 0 ? { theme: o } : {}, ...m ? { chakraProviderProps: m } : {} }, R(() => { let _ = !0; return C(), r && w({ remoteUrl: r }), B().then(() => { if (!_ || !u.current) return; const n = document.createElement("uikit-g-badge"); n.componentProps = c.current, u.current.appendChild(n), t.current = n; }).catch((n) => { console.error("[uikit/remote/ui] Failed to load GBadge:", n); }), () => { _ = !1, t.current && (t.current.remove(), t.current = null); }; }, [r]), R(() => { t.current && (t.current.componentProps = c.current); }), /* @__PURE__ */ h( "span", { ref: u, style: { display: "contents" } } ); }; export { N as GBadge, w as setupUikitRemoteDeps };