@howone/sdk 0.1.18 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -236,12 +236,16 @@ __export(index_exports, {
236
236
  AUTH_ROOT: () => AUTH_ROOT,
237
237
  AUTH_TOKEN_KEY: () => AUTH_TOKEN_KEY,
238
238
  AuthProvider: () => AuthProvider,
239
+ ClayxToast: () => ClayxToast,
239
240
  DefaultErrorFallback: () => DefaultErrorFallback,
240
241
  ErrorBoundary: () => ErrorBoundary,
241
242
  FloatingButton: () => FloatingButton,
243
+ GlobalToastContainer: () => GlobalToastContainer,
242
244
  Loading: () => Loading,
243
245
  LoadingSpinner: () => LoadingSpinner,
244
246
  LoginForm: () => LoginForm,
247
+ ThemeProvider: () => ThemeProvider,
248
+ ThemeToggle: () => ThemeToggle,
245
249
  aiRequest: () => aiRequest,
246
250
  aiWorkflow: () => aiWorkflow,
247
251
  canAccessArtifact: () => canAccessArtifact,
@@ -270,6 +274,7 @@ __export(index_exports, {
270
274
  useAuthContext: () => useAuthContext,
271
275
  useDebounce: () => useDebounce,
272
276
  useIsMobile: () => useIsMobile,
277
+ useTheme: () => useTheme,
273
278
  workflowRequest: () => workflowRequest
274
279
  });
275
280
  module.exports = __toCommonJS(index_exports);
@@ -287,7 +292,7 @@ var FloatingButton = ({
287
292
  {
288
293
  onClick,
289
294
  id: "floating-howone-btn",
290
- className: `fixed flex bg-white gap-2 items-center right-4 z-50 text-black px-3 py-2 rounded-lg shadow-lg transition-colors duration-200 ${className}`,
295
+ className: `fixed flex bg-white dark:bg-gray-800 gap-2 items-center right-4 z-50 text-black dark:text-white px-3 py-2 rounded-lg shadow-lg transition-colors duration-200 border border-gray-200 dark:border-gray-700 ${className}`,
291
296
  style: {
292
297
  fontSize: "14px",
293
298
  fontWeight: "bold",
@@ -300,7 +305,7 @@ var FloatingButton = ({
300
305
  e.stopPropagation();
301
306
  const btn = document.getElementById("floating-howone-btn");
302
307
  if (btn) btn.style.display = "none";
303
- }, className: "w-5 h-5 font-bold pointer-events-auto" })
308
+ }, className: "w-5 h-5 font-bold pointer-events-auto text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200" })
304
309
  ] })
305
310
  }
306
311
  );
@@ -1555,109 +1560,11 @@ var LoginForm = ({
1555
1560
  // src/components/auth/AuthProvider.tsx
1556
1561
  var import_react4 = require("react");
1557
1562
  init_auth();
1558
- init_config();
1559
-
1560
- // src/components/ui/Loading.tsx
1561
1563
  var import_jsx_runtime3 = require("react/jsx-runtime");
1562
- var Loading = ({
1563
- size = "md",
1564
- text = "Loading...",
1565
- className = "",
1566
- fullScreen = false
1567
- }) => {
1568
- const sizeClasses = {
1569
- sm: "h-4 w-4",
1570
- md: "h-8 w-8",
1571
- lg: "h-12 w-12"
1572
- };
1573
- const containerClasses = fullScreen ? "fixed inset-0 flex items-center justify-center bg-white/80 backdrop-blur-sm z-50" : "flex items-center justify-center p-4";
1574
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "text-center", children: [
1575
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1576
- "div",
1577
- {
1578
- className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
1579
- }
1580
- ),
1581
- text && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "mt-2 text-sm text-gray-600", children: text })
1582
- ] }) });
1583
- };
1584
- var LoadingSpinner = ({
1585
- size = "md",
1586
- className = ""
1587
- }) => {
1588
- const sizeClasses = {
1589
- sm: "h-4 w-4",
1590
- md: "h-8 w-8",
1591
- lg: "h-12 w-12"
1592
- };
1593
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1594
- "div",
1595
- {
1596
- className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
1597
- }
1598
- );
1599
- };
1600
-
1601
- // src/components/auth/AuthProvider.tsx
1602
- var import_jsx_runtime4 = require("react/jsx-runtime");
1603
1564
  var AuthContext = (0, import_react4.createContext)(null);
1604
- var AuthProvider = ({ children, autoRedirect = true, showFloatingButton = true, projectId }) => {
1565
+ var AuthProvider = ({ children, showFloatingButton = true }) => {
1605
1566
  const [user, setUser] = (0, import_react4.useState)(() => parseUserFromToken(getToken()));
1606
1567
  const [token, setTokenState] = (0, import_react4.useState)(() => getToken());
1607
- const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
1608
- (0, import_react4.useEffect)(() => {
1609
- try {
1610
- if (projectId) setDefaultProjectId(String(projectId));
1611
- } catch {
1612
- }
1613
- setIsLoading(true);
1614
- try {
1615
- const cb = unifiedAuth.checkOAuthCallback();
1616
- if (cb && cb.success) {
1617
- setTokenState(cb.token ?? getToken());
1618
- setUser(cb.user ?? parseUserFromToken(cb.token ?? getToken()));
1619
- setIsLoading(false);
1620
- return;
1621
- }
1622
- } catch {
1623
- }
1624
- const unsubscribe = onAuthStateChanged((state) => {
1625
- try {
1626
- setTokenState(getToken());
1627
- setUser(state.user ?? parseUserFromToken(getToken()));
1628
- } catch {
1629
- }
1630
- setIsLoading(false);
1631
- if (autoRedirect && !state.user) {
1632
- try {
1633
- const root = getAuthRoot();
1634
- const authUrl = new URL("/auth", String(root));
1635
- authUrl.searchParams.set("redirect_uri", window.location.href);
1636
- const pid = getDefaultProjectId();
1637
- if (pid) authUrl.searchParams.set("project_id", pid);
1638
- try {
1639
- if (window.top && window.top !== window) {
1640
- window.top.location.replace(authUrl.toString());
1641
- } else {
1642
- window.location.replace(authUrl.toString());
1643
- }
1644
- } catch (e) {
1645
- try {
1646
- window.location.replace(authUrl.toString());
1647
- } catch {
1648
- }
1649
- }
1650
- } catch {
1651
- }
1652
- }
1653
- });
1654
- return () => {
1655
- try {
1656
- unsubscribe();
1657
- } catch {
1658
- }
1659
- };
1660
- }, [autoRedirect]);
1661
1568
  const logout = () => {
1662
1569
  try {
1663
1570
  setToken(null);
@@ -1672,12 +1579,9 @@ var AuthProvider = ({ children, autoRedirect = true, showFloatingButton = true,
1672
1579
  isAuthenticated: !!token,
1673
1580
  logout
1674
1581
  };
1675
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AuthContext.Provider, { value, children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1676
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Loading, { fullScreen: true, text: "Checking authentication..." }),
1677
- showFloatingButton && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
1678
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1582
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AuthContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1679
1583
  children,
1680
- showFloatingButton && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
1584
+ showFloatingButton && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
1681
1585
  ] }) });
1682
1586
  };
1683
1587
  function useAuthContext() {
@@ -1784,6 +1688,47 @@ var howone = {
1784
1688
  };
1785
1689
  var client_default = howone;
1786
1690
 
1691
+ // src/components/ui/Loading.tsx
1692
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1693
+ var Loading = ({
1694
+ size = "md",
1695
+ text = "Loading...",
1696
+ className = "",
1697
+ fullScreen = false
1698
+ }) => {
1699
+ const sizeClasses = {
1700
+ sm: "h-4 w-4",
1701
+ md: "h-8 w-8",
1702
+ lg: "h-12 w-12"
1703
+ };
1704
+ const containerClasses = fullScreen ? "fixed inset-0 flex items-center justify-center bg-white/80 backdrop-blur-sm z-50" : "flex items-center justify-center p-4";
1705
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "text-center", children: [
1706
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1707
+ "div",
1708
+ {
1709
+ className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
1710
+ }
1711
+ ),
1712
+ text && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "mt-2 text-sm text-gray-600", children: text })
1713
+ ] }) });
1714
+ };
1715
+ var LoadingSpinner = ({
1716
+ size = "md",
1717
+ className = ""
1718
+ }) => {
1719
+ const sizeClasses = {
1720
+ sm: "h-4 w-4",
1721
+ md: "h-8 w-8",
1722
+ lg: "h-12 w-12"
1723
+ };
1724
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1725
+ "div",
1726
+ {
1727
+ className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
1728
+ }
1729
+ );
1730
+ };
1731
+
1787
1732
  // src/components/ui/ErrorBoundary.tsx
1788
1733
  var import_react5 = require("react");
1789
1734
  var import_jsx_runtime5 = require("react/jsx-runtime");
@@ -1842,12 +1787,273 @@ var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ (0, import_jsx_runtime
1842
1787
  )
1843
1788
  ] }) });
1844
1789
 
1845
- // src/hooks/use-mobile.ts
1790
+ // src/components/theme/ThemeProvider.tsx
1791
+ var import_react6 = require("react");
1792
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1793
+ var initialState = {
1794
+ theme: "system",
1795
+ setTheme: () => null
1796
+ };
1797
+ var ThemeProviderContext = (0, import_react6.createContext)(initialState);
1798
+ function ThemeProvider({
1799
+ children,
1800
+ defaultTheme = "system",
1801
+ storageKey = "vite-ui-theme",
1802
+ ...props
1803
+ }) {
1804
+ const [theme, setTheme] = (0, import_react6.useState)(
1805
+ () => localStorage.getItem(storageKey) || defaultTheme
1806
+ );
1807
+ (0, import_react6.useEffect)(() => {
1808
+ const root = window.document.documentElement;
1809
+ root.classList.remove("light", "dark");
1810
+ if (theme === "system") {
1811
+ const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
1812
+ root.classList.add(systemTheme);
1813
+ return;
1814
+ }
1815
+ root.classList.add(theme);
1816
+ }, [theme]);
1817
+ const value = {
1818
+ theme,
1819
+ setTheme: (theme2) => {
1820
+ localStorage.setItem(storageKey, theme2);
1821
+ setTheme(theme2);
1822
+ }
1823
+ };
1824
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ThemeProviderContext.Provider, { ...props, value, children });
1825
+ }
1826
+ var useTheme = () => {
1827
+ const context = (0, import_react6.useContext)(ThemeProviderContext);
1828
+ if (context === void 0)
1829
+ throw new Error("useTheme must be used within a ThemeProvider");
1830
+ return context;
1831
+ };
1832
+
1833
+ // src/components/theme/ThemeToggle.tsx
1846
1834
  var React4 = __toESM(require("react"));
1835
+ var import_next_themes = require("next-themes");
1836
+ var import_react7 = require("@iconify/react");
1837
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1838
+ function ThemeToggle({ className }) {
1839
+ const { setTheme, theme } = (0, import_next_themes.useTheme)();
1840
+ const [mounted, setMounted] = React4.useState(false);
1841
+ React4.useEffect(() => {
1842
+ setMounted(true);
1843
+ }, []);
1844
+ if (!mounted) {
1845
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1846
+ "button",
1847
+ {
1848
+ className: `relative inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground ${className || ""}`,
1849
+ disabled: true,
1850
+ children: [
1851
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react7.Icon, { icon: "solar:sun-2-linear", width: 20, height: 20 }),
1852
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sr-only", children: "Toggle theme" })
1853
+ ]
1854
+ }
1855
+ );
1856
+ }
1857
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1858
+ "button",
1859
+ {
1860
+ className: `inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors ${className || ""}`,
1861
+ onClick: () => setTheme(theme === "light" ? "dark" : "light"),
1862
+ children: [
1863
+ theme === "light" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react7.Icon, { icon: "solar:sun-2-linear", width: 20, height: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react7.Icon, { icon: "solar:moon-linear", width: 20, height: 20 }),
1864
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sr-only", children: "Toggle theme" })
1865
+ ]
1866
+ }
1867
+ );
1868
+ }
1869
+
1870
+ // src/components/ui/Toast/GlobalToastContainer.tsx
1871
+ var import_react_toastify = require("react-toastify");
1872
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1873
+ function GlobalToastContainer() {
1874
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1875
+ import_react_toastify.ToastContainer,
1876
+ {
1877
+ newestOnTop: false,
1878
+ closeButton: false
1879
+ }
1880
+ );
1881
+ }
1882
+
1883
+ // src/components/ui/Toast/ClayxToast.tsx
1884
+ var import_react8 = __toESM(require("react"));
1885
+ var import_react_toastify2 = require("react-toastify");
1886
+ var import_react9 = require("@iconify/react");
1887
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1888
+ var TOAST_ICONS = {
1889
+ success: {
1890
+ icon: "mdi:success",
1891
+ color: "text-green-400",
1892
+ className: "text-green-400",
1893
+ bgGradient: "bg-[#14181df2]",
1894
+ gradientColor: "#389726",
1895
+ borderGradient: "border-[#389726]",
1896
+ borderGradientColor: "#389726"
1897
+ },
1898
+ error: {
1899
+ icon: "ic:outline-close",
1900
+ color: "text-red-400",
1901
+ className: "text-red-400",
1902
+ bgGradient: "bg-[#14181df2]",
1903
+ gradientColor: "#ef4444",
1904
+ borderGradient: "border-[#ef4444]",
1905
+ borderGradientColor: "#ef4444"
1906
+ },
1907
+ warning: {
1908
+ icon: "mi:warning",
1909
+ color: "text-yellow-400",
1910
+ className: "text-yellow-400",
1911
+ bgGradient: "bg-[#14181df2]",
1912
+ gradientColor: "#facc15",
1913
+ borderGradient: "border-[#facc15]",
1914
+ borderGradientColor: "#facc15"
1915
+ },
1916
+ info: {
1917
+ icon: "ic:outline-info",
1918
+ color: "text-blue-400",
1919
+ className: "text-blue-400",
1920
+ bgGradient: "bg-[#14181df2]",
1921
+ gradientColor: "#60a5fa",
1922
+ borderGradient: "border-[#60a5fa]",
1923
+ borderGradientColor: "#f0f0f0"
1924
+ },
1925
+ default: {
1926
+ icon: "ic:round-notifications",
1927
+ color: "text-gray-400",
1928
+ className: "text-gray-400",
1929
+ bgGradient: "bg-[#14181df2]",
1930
+ gradientColor: "#9ca3af",
1931
+ borderGradient: "border-[#9ca3af]",
1932
+ borderGradientColor: "#9ca3af"
1933
+ }
1934
+ };
1935
+ var CloseButton = import_react8.default.memo(({ closeToast }) => {
1936
+ const handleClick = (0, import_react8.useCallback)((e) => {
1937
+ e.preventDefault();
1938
+ e.stopPropagation();
1939
+ closeToast?.();
1940
+ }, [closeToast]);
1941
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1942
+ import_react9.Icon,
1943
+ {
1944
+ icon: "vaadin:close",
1945
+ className: "flex items-center justify-center rounded-full relative z-10 flex-shrink-0 cursor-pointer \n !text-[#b4b4b4] hover:text-white transition-colors duration-200 drop-shadow-sm",
1946
+ onClick: handleClick,
1947
+ width: 14,
1948
+ height: 14
1949
+ }
1950
+ );
1951
+ });
1952
+ CloseButton.displayName = "CloseButton";
1953
+ var ToastContent = ({ type, title, message, component, closeToast }) => {
1954
+ const iconConfig = TOAST_ICONS[type];
1955
+ const handleClose = (0, import_react8.useCallback)(() => {
1956
+ closeToast?.();
1957
+ }, [closeToast]);
1958
+ console.log(iconConfig, "????????");
1959
+ if (component) {
1960
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `flex items-start gap-3 min-h-[80px] w-full backdrop-blur-md
1961
+ rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
1962
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 relative z-10", children: component }),
1963
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, { closeToast: handleClose }) })
1964
+ ] });
1965
+ }
1966
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `flex items-start gap-3 min-h-[60px] w-full backdrop-blur-md
1967
+ rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
1968
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1969
+ "div",
1970
+ {
1971
+ className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
1972
+ style: {
1973
+ background: `linear-gradient(135deg, ${iconConfig.gradientColor}30 0%, ${iconConfig.gradientColor}20 15%, #14181df2 30%)`
1974
+ }
1975
+ }
1976
+ ),
1977
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1978
+ "div",
1979
+ {
1980
+ className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
1981
+ style: {
1982
+ border: "2px solid transparent",
1983
+ backgroundImage: `linear-gradient(135deg, ${iconConfig.borderGradientColor}60 0%, ${iconConfig.borderGradientColor}40 5%, transparent 22%)`,
1984
+ backgroundOrigin: "border-box",
1985
+ backgroundClip: "border-box",
1986
+ WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
1987
+ WebkitMaskComposite: "xor",
1988
+ mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
1989
+ maskComposite: "exclude"
1990
+ }
1991
+ }
1992
+ ),
1993
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-shrink-0 mt-0.5 relative z-10 ", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "w-7 h-7 bg-white/10 backdrop-blur-sm rounded-full flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1994
+ import_react9.Icon,
1995
+ {
1996
+ icon: iconConfig.icon,
1997
+ width: 16,
1998
+ height: 16,
1999
+ className: iconConfig.color
2000
+ }
2001
+ ) }) }),
2002
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-1 flex-1 relative z-10", children: [
2003
+ title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[16px] font-semibold leading-tight text-white/95 drop-shadow-sm", children: title }),
2004
+ message && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[13px] font-normal leading-relaxed text-white/75 drop-shadow-sm", children: message })
2005
+ ] }),
2006
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, { closeToast: handleClose }) })
2007
+ ] });
2008
+ };
2009
+ var defaultToastOptions = {
2010
+ position: "bottom-right",
2011
+ autoClose: 3e3,
2012
+ hideProgressBar: true,
2013
+ closeOnClick: false,
2014
+ pauseOnHover: true,
2015
+ draggable: true,
2016
+ pauseOnFocusLoss: false,
2017
+ theme: "dark",
2018
+ transition: import_react_toastify2.Bounce
2019
+ };
2020
+ var createToast = (type) => {
2021
+ return (params) => {
2022
+ const { title, message, component, options } = params;
2023
+ (0, import_react_toastify2.toast)(
2024
+ ({ closeToast }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2025
+ ToastContent,
2026
+ {
2027
+ type,
2028
+ title,
2029
+ message: message || "",
2030
+ component,
2031
+ closeToast
2032
+ }
2033
+ ),
2034
+ {
2035
+ ...defaultToastOptions,
2036
+ ...options,
2037
+ className: "!bg-transparent !p-0 !shadow-none",
2038
+ style: { background: "transparent", padding: 0 }
2039
+ }
2040
+ );
2041
+ };
2042
+ };
2043
+ var ClayxToast = {
2044
+ success: createToast("success"),
2045
+ error: createToast("error"),
2046
+ warning: createToast("warning"),
2047
+ info: createToast("info"),
2048
+ default: createToast("default")
2049
+ };
2050
+
2051
+ // src/hooks/use-mobile.ts
2052
+ var React6 = __toESM(require("react"));
1847
2053
  var MOBILE_BREAKPOINT = 768;
1848
2054
  function useIsMobile() {
1849
- const [isMobile, setIsMobile] = React4.useState(void 0);
1850
- React4.useEffect(() => {
2055
+ const [isMobile, setIsMobile] = React6.useState(void 0);
2056
+ React6.useEffect(() => {
1851
2057
  const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
1852
2058
  const onChange = () => {
1853
2059
  setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
@@ -1860,10 +2066,10 @@ function useIsMobile() {
1860
2066
  }
1861
2067
 
1862
2068
  // src/hooks/use-debounce.ts
1863
- var import_react6 = require("react");
2069
+ var import_react10 = require("react");
1864
2070
  function useDebounce(value, delay) {
1865
- const [debouncedValue, setDebouncedValue] = (0, import_react6.useState)(value);
1866
- (0, import_react6.useEffect)(() => {
2071
+ const [debouncedValue, setDebouncedValue] = (0, import_react10.useState)(value);
2072
+ (0, import_react10.useEffect)(() => {
1867
2073
  const handler = setTimeout(() => {
1868
2074
  setDebouncedValue(value);
1869
2075
  }, delay);
@@ -1874,214 +2080,335 @@ function useDebounce(value, delay) {
1874
2080
  return debouncedValue;
1875
2081
  }
1876
2082
 
1877
- // src/utils/earlyErrorHandler.ts
1878
- function injectEarlyErrorHandler() {
1879
- if (typeof window === "undefined" || typeof document === "undefined") return;
1880
- const code = `
1881
- (function () {
1882
- const isIframe = window.self !== window.top;
1883
- console.log("isIframe", isIframe);
2083
+ // src/utils/errorHandler.ts
2084
+ var ERROR_HANDLER_SCRIPT = `(function () {
2085
+ // \u68C0\u67E5\u662F\u5426\u5728 iframe \u4E2D\u8FD0\u884C
2086
+ const isIframe = window.self !== window.top;
2087
+ console.log("isIframe", isIframe);
1884
2088
 
1885
- console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316");
2089
+ console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316");
1886
2090
 
1887
- window.__SEND_ERROR_TO_PARENT__ = function (error, details) {
1888
- try {
1889
- const errorPayload = {
1890
- message: error instanceof Error ? error.message : String(error),
1891
- stack: error instanceof Error ? error.stack : undefined,
1892
- filename: details?.file || details?.filename,
1893
- lineno: details?.line,
1894
- colno: details?.column,
1895
- timestamp: Date.now(),
1896
- type: details?.type || "compile-error",
1897
- details: details,
1898
- };
2091
+ // \u76F4\u63A5\u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u7684\u51FD\u6570
2092
+ window.__SEND_ERROR_TO_PARENT__ = function (error, details) {
2093
+ try {
2094
+ const errorPayload = {
2095
+ message: error instanceof Error ? error.message : String(error),
2096
+ stack: error instanceof Error ? error.stack : undefined,
2097
+ filename: details?.file || details?.filename,
2098
+ lineno: details?.line,
2099
+ colno: details?.column,
2100
+ timestamp: Date.now(),
2101
+ type: details?.type || "compile-error",
2102
+ details: details,
2103
+ };
1899
2104
 
1900
- window.parent.postMessage({ type: "ERROR_EVENT", payload: errorPayload }, "*");
1901
- console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u9519\u8BEF\u5DF2\u53D1\u9001\u5230\u7236\u7A97\u53E3:", errorPayload);
1902
- } catch (e) {
1903
- console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u5931\u8D25:", e);
1904
- }
1905
- };
2105
+ window.parent.postMessage(
2106
+ {
2107
+ type: "ERROR_EVENT",
2108
+ payload: errorPayload,
2109
+ },
2110
+ "*"
2111
+ );
2112
+
2113
+ console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u9519\u8BEF\u5DF2\u53D1\u9001\u5230\u7236\u7A97\u53E3:", errorPayload);
2114
+ } catch (e) {
2115
+ console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u5931\u8D25:", e);
2116
+ }
2117
+ };
1906
2118
 
1907
- function setupViteOverlayObserver() {
1908
- if (!window.MutationObserver) return;
2119
+ // \u8BBE\u7F6E MutationObserver \u76D1\u542C vite-error-overlay
2120
+ function setupViteOverlayObserver() {
2121
+ if (!window.MutationObserver) return;
1909
2122
 
1910
- console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u8BBE\u7F6E Vite \u9519\u8BEF overlay \u76D1\u542C\u5668");
2123
+ console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u8BBE\u7F6E Vite \u9519\u8BEF overlay \u76D1\u542C\u5668");
1911
2124
 
1912
- function processViteErrorOverlay(overlay) {
1913
- try {
1914
- if (overlay.hasAttribute("data-error-sent")) return;
1915
- const shadowRoot = overlay.shadowRoot;
1916
- if (!shadowRoot) return;
2125
+ function processViteErrorOverlay(overlay) {
2126
+ try {
2127
+ if (overlay.hasAttribute("data-error-sent")) return;
2128
+
2129
+ const shadowRoot = overlay.shadowRoot;
2130
+ if (!shadowRoot) {
2131
+ console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] vite-error-overlay \u6CA1\u6709 Shadow DOM");
2132
+ return;
2133
+ }
1917
2134
 
1918
- const messageElement = shadowRoot.querySelector("pre.message");
1919
- const fileElement = shadowRoot.querySelector("pre.file");
1920
- const frameElements = shadowRoot.querySelectorAll("pre.frame");
1921
- const stackElement = shadowRoot.querySelector("pre.stack");
2135
+ const messageElement = shadowRoot.querySelector("pre.message");
2136
+ const fileElement = shadowRoot.querySelector("pre.file");
2137
+ const frameElements = shadowRoot.querySelectorAll("pre.frame");
2138
+ const stackElement = shadowRoot.querySelector("pre.stack");
1922
2139
 
1923
- const message = messageElement ? messageElement.textContent : "";
1924
- const file = fileElement ? fileElement.textContent : "";
1925
- const frames = Array.from(frameElements).map((el) => el.textContent).join("
2140
+ const message = messageElement ? messageElement.textContent : "";
2141
+ const file = fileElement ? fileElement.textContent : "";
2142
+ const frames = Array.from(frameElements)
2143
+ .map((el) => el.textContent)
2144
+ .join("
1926
2145
  ");
1927
- const stack = stackElement ? stackElement.textContent : "";
2146
+ const stack = stackElement ? stackElement.textContent : "";
1928
2147
 
1929
- let line, column;
1930
- const fileStr = file || "";
1931
- const lineColMatch = fileStr.match(/(?:line|at|:)(?:.*?)(?::| )(d+)(?::| )(d+)/i);
1932
- if (lineColMatch) {
1933
- line = parseInt(lineColMatch[1], 10);
1934
- column = parseInt(lineColMatch[2], 10);
1935
- }
2148
+ let line, column;
2149
+ const fileStr = file || "";
2150
+ const lineColMatch = fileStr.match(/(?:line|at|:)(?:.*?)(?::| )(d+)(?::| )(d+)/i);
2151
+ if (lineColMatch) {
2152
+ line = parseInt(lineColMatch[1], 10);
2153
+ column = parseInt(lineColMatch[2], 10);
2154
+ }
1936
2155
 
1937
- const messageStr = message || "";
1938
- const isReactError =
1939
- messageStr.includes("React") ||
1940
- messageStr.includes("JSX") ||
1941
- messageStr.includes("Unexpected token") ||
1942
- messageStr.includes("vite:react-babel");
2156
+ const messageStr = message || "";
2157
+ const isReactError =
2158
+ messageStr.includes("React") ||
2159
+ messageStr.includes("JSX") ||
2160
+ messageStr.includes("Unexpected token") ||
2161
+ messageStr.includes("vite:react-babel");
1943
2162
 
1944
- const viteError = new Error(messageStr);
2163
+ const viteError = new Error(messageStr);
1945
2164
 
1946
- window.__SEND_ERROR_TO_PARENT__(viteError, {
1947
- file,
1948
- line,
1949
- column,
1950
- frames,
1951
- stack,
1952
- isReactError,
1953
- type: isReactError ? "react-syntax" : "vite-error-overlay",
1954
- });
2165
+ window.__SEND_ERROR_TO_PARENT__(viteError, {
2166
+ file,
2167
+ line,
2168
+ column,
2169
+ frames,
2170
+ stack,
2171
+ isReactError,
2172
+ type: isReactError ? "react-syntax" : "vite-error-overlay",
2173
+ });
1955
2174
 
1956
- overlay.setAttribute("data-error-sent", "true");
1957
- } catch (e) {
1958
- console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u5904\u7406 vite-error-overlay \u5931\u8D25:", e);
1959
- }
2175
+ overlay.setAttribute("data-error-sent", "true");
2176
+ } catch (e) {
2177
+ console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u5904\u7406 vite-error-overlay \u5931\u8D25:", e);
1960
2178
  }
2179
+ }
1961
2180
 
1962
- function checkExistingOverlays() {
1963
- const viteErrorOverlays = document.querySelectorAll("vite-error-overlay");
1964
- if (viteErrorOverlays.length > 0) {
1965
- viteErrorOverlays.forEach((overlay) => {
1966
- if (!overlay.hasAttribute("data-error-sent")) {
1967
- processViteErrorOverlay(overlay);
1968
- }
1969
- });
1970
- }
2181
+ function checkExistingOverlays() {
2182
+ const viteErrorOverlays = document.querySelectorAll("vite-error-overlay");
2183
+ if (viteErrorOverlays.length > 0) {
2184
+ viteErrorOverlays.forEach((overlay) => {
2185
+ if (!overlay.hasAttribute("data-error-sent")) {
2186
+ processViteErrorOverlay(overlay);
2187
+ }
2188
+ });
1971
2189
  }
2190
+ }
1972
2191
 
1973
- const observer = new MutationObserver((mutations) => {
1974
- for (const mutation of mutations) {
1975
- if (mutation.addedNodes.length > 0) {
1976
- for (const node of Array.from(mutation.addedNodes)) {
1977
- if (node.nodeType === Node.ELEMENT_NODE) {
1978
- const element = node;
1979
- if (element.tagName === "VITE-ERROR-OVERLAY" && !element.hasAttribute("data-error-sent")) {
1980
- setTimeout(() => processViteErrorOverlay(element), 100);
1981
- }
1982
- const viteErrorOverlays = element.querySelectorAll("vite-error-overlay");
1983
- for (const viteErrorOverlay of Array.from(viteErrorOverlays)) {
1984
- if (!viteErrorOverlay.hasAttribute("data-error-sent")) {
1985
- setTimeout(() => processViteErrorOverlay(viteErrorOverlay), 100);
1986
- }
2192
+ const observer = new MutationObserver((mutations) => {
2193
+ for (const mutation of mutations) {
2194
+ if (mutation.addedNodes.length > 0) {
2195
+ for (const node of Array.from(mutation.addedNodes)) {
2196
+ if (node.nodeType === Node.ELEMENT_NODE) {
2197
+ const element = node;
2198
+
2199
+ if (
2200
+ element.tagName === "VITE-ERROR-OVERLAY" &&
2201
+ !element.hasAttribute("data-error-sent")
2202
+ ) {
2203
+ setTimeout(() => processViteErrorOverlay(element), 100);
2204
+ }
2205
+
2206
+ const viteErrorOverlays = element.querySelectorAll("vite-error-overlay");
2207
+ for (const viteErrorOverlay of Array.from(viteErrorOverlays)) {
2208
+ if (!viteErrorOverlay.hasAttribute("data-error-sent")) {
2209
+ setTimeout(() => processViteErrorOverlay(viteErrorOverlay), 100);
1987
2210
  }
1988
2211
  }
1989
2212
  }
1990
2213
  }
1991
2214
  }
1992
- });
2215
+ }
2216
+ });
1993
2217
 
1994
- observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
1995
- setTimeout(checkExistingOverlays, 500);
1996
- setInterval(checkExistingOverlays, 2000);
1997
- }
2218
+ observer.observe(document.documentElement, {
2219
+ childList: true,
2220
+ subtree: true,
2221
+ attributes: true,
2222
+ characterData: true,
2223
+ });
1998
2224
 
1999
- window.addEventListener(
2000
- "error",
2001
- function (event) {
2002
- const target = event && (event.target || event.srcElement);
2003
- const tagName = target && target.tagName;
2004
- if (tagName) {
2005
- const url = (target && (target.src || target.href || target.currentSrc)) || (target && target.getAttribute && (target.getAttribute('src') || target.getAttribute('href')));
2006
- const preview = target && target.outerHTML ? String(target.outerHTML).slice(0, 300) : undefined;
2007
- const resourceError = new Error('Resource load error: ' + tagName + ' ' + (url || 'unknown'));
2008
- window.__SEND_ERROR_TO_PARENT__(resourceError, { filename: url, tagName: tagName, element: preview, type: "resource" });
2009
- return;
2010
- }
2225
+ setTimeout(checkExistingOverlays, 500);
2226
+ setInterval(checkExistingOverlays, 2000);
2227
+ }
2011
2228
 
2012
- var stack = (event && event.error && event.error.stack) || "";
2013
- var message = typeof event.message === "string" ? event.message : "";
2014
- if ((stack && stack.indexOf('error-handler') !== -1) || !message) return;
2229
+ window.addEventListener(
2230
+ "error",
2231
+ function (event) {
2232
+ const target = event && (event.target || event.srcElement);
2233
+ const tagName = target && target.tagName;
2234
+ if (tagName) {
2235
+ const url = (target && (target.src || target.href || target.currentSrc)) ||
2236
+ (target && target.getAttribute && (target.getAttribute('src') || target.getAttribute('href')));
2237
+ const preview = target && target.outerHTML ? String(target.outerHTML).slice(0, 300) : undefined;
2238
+ const resourceError = new Error('Resource load error: ' + tagName + ' ' + (url || 'unknown'));
2239
+ window.__SEND_ERROR_TO_PARENT__(resourceError, {
2240
+ filename: url,
2241
+ tagName: tagName,
2242
+ element: preview,
2243
+ type: "resource"
2244
+ });
2245
+ return;
2246
+ }
2015
2247
 
2016
- window.__SEND_ERROR_TO_PARENT__(event.error || new Error(event.message), { filename: event.filename, line: event.lineno, column: event.colno, type: "runtime" });
2017
- },
2018
- true
2248
+ var stack = (event && event.error && event.error.stack) || "";
2249
+ var message = typeof event.message === "string" ? event.message : "";
2250
+ if ((stack && stack.indexOf('error-handler') !== -1) || !message) return;
2251
+
2252
+ window.__SEND_ERROR_TO_PARENT__(event.error || new Error(event.message), {
2253
+ filename: event.filename,
2254
+ line: event.lineno,
2255
+ column: event.colno,
2256
+ type: "runtime",
2257
+ });
2258
+ },
2259
+ true
2260
+ );
2261
+
2262
+ window.addEventListener("unhandledrejection", function (event) {
2263
+ const reason = event.reason;
2264
+ window.__SEND_ERROR_TO_PARENT__(
2265
+ reason instanceof Error ? reason : new Error(String(reason)),
2266
+ { type: "promise" }
2019
2267
  );
2268
+ });
2020
2269
 
2021
- window.addEventListener("unhandledrejection", function (event) {
2022
- const reason = event.reason;
2023
- window.__SEND_ERROR_TO_PARENT__(reason instanceof Error ? reason : new Error(String(reason)), { type: "promise" });
2024
- });
2270
+ setupViteOverlayObserver();
2025
2271
 
2026
- setupViteOverlayObserver();
2272
+ if (!window.__FETCH_INTERCEPTED__) {
2273
+ window.__FETCH_INTERCEPTED__ = true;
2274
+ const originalFetch = window.fetch;
2275
+
2276
+ function handleFetchError(error, url, response = null) {
2277
+ const errorDetails = {
2278
+ type: "network",
2279
+ method: "fetch",
2280
+ url: url
2281
+ };
2282
+
2283
+ if (response && !response.ok) {
2284
+ errorDetails.status = response.status;
2285
+ errorDetails.statusText = response.statusText;
2286
+ errorDetails.networkError = false;
2287
+ } else {
2288
+ errorDetails.networkError = true;
2289
+ }
2290
+ window.__SEND_ERROR_TO_PARENT__(error, errorDetails);
2291
+ }
2292
+
2293
+ window.fetch = function(...args) {
2294
+ const url = args[0] instanceof Request ? args[0].url : args[0];
2295
+
2296
+ return originalFetch.apply(this, args)
2297
+ .then(response => {
2298
+ if (!response.ok) {
2299
+ const networkError = new Error(\`HTTP \${response.status}: \${response.statusText}\`);
2300
+ handleFetchError(networkError, url, response);
2301
+ }
2302
+ return response;
2303
+ })
2304
+ .catch(error => {
2305
+ handleFetchError(error, url);
2306
+ throw error;
2307
+ });
2308
+ };
2309
+ }
2027
2310
 
2028
- if (!window.__CONSOLE_ERROR_INTERCEPTED__) {
2029
- window.__CONSOLE_ERROR_INTERCEPTED__ = true;
2030
- const originalConsoleError = console.error;
2031
- console.error = function () {
2032
- try {
2033
- var args = Array.prototype.slice.call(arguments);
2034
- var first = args[0];
2035
- var firstStr = typeof first === "string" ? first : "";
2036
- var isReact = firstStr.indexOf("React") !== -1;
2037
- var isVite = firstStr.indexOf("[vite]") !== -1 || firstStr.indexOf("Failed to reload") !== -1;
2038
- if (isReact || isVite) {
2039
- var joined = args.map(function (a) {
2311
+ if (!window.__XHR_INTERCEPTED__) {
2312
+ window.__XHR_INTERCEPTED__ = true;
2313
+ const originalXHROpen = XMLHttpRequest.prototype.open;
2314
+ const originalXHRSend = XMLHttpRequest.prototype.send;
2315
+
2316
+ function handleXHRError(error, xhr, isNetworkError = false) {
2317
+ const errorDetails = {
2318
+ type: "network",
2319
+ method: "xhr",
2320
+ url: xhr.__intercepted_url__
2321
+ };
2322
+
2323
+ if (!isNetworkError && xhr.status >= 400) {
2324
+ errorDetails.status = xhr.status;
2325
+ errorDetails.statusText = xhr.statusText;
2326
+ errorDetails.networkError = false;
2327
+ } else {
2328
+ errorDetails.networkError = true;
2329
+ }
2330
+
2331
+ window.__SEND_ERROR_TO_PARENT__(error, errorDetails);
2332
+ }
2333
+
2334
+ XMLHttpRequest.prototype.open = function(method, url, ...args) {
2335
+ this.__intercepted_method__ = method;
2336
+ this.__intercepted_url__ = url;
2337
+ return originalXHROpen.apply(this, [method, url, ...args]);
2338
+ };
2339
+
2340
+ XMLHttpRequest.prototype.send = function(...args) {
2341
+ const xhr = this;
2342
+
2343
+ const originalOnReadyStateChange = xhr.onreadystatechange;
2344
+ xhr.onreadystatechange = function() {
2345
+ if (xhr.readyState === 4) {
2346
+ if (xhr.status >= 400) {
2347
+ const networkError = new Error(\`HTTP \${xhr.status}: \${xhr.statusText}\`);
2348
+ handleXHRError(networkError, xhr, false);
2349
+ }
2350
+ }
2351
+
2352
+ if (originalOnReadyStateChange) {
2353
+ return originalOnReadyStateChange.apply(this, arguments);
2354
+ }
2355
+ };
2356
+
2357
+ const originalOnError = xhr.onerror;
2358
+ xhr.onerror = function() {
2359
+ const networkError = new Error(\`Network error for \${xhr.__intercepted_method__} \${xhr.__intercepted_url__}\`);
2360
+ handleXHRError(networkError, xhr, true);
2361
+
2362
+ if (originalOnError) {
2363
+ return originalOnError.apply(this, arguments);
2364
+ }
2365
+ };
2366
+
2367
+ return originalXHRSend.apply(this, args);
2368
+ };
2369
+ }
2370
+
2371
+ if (!window.__CONSOLE_ERROR_INTERCEPTED__) {
2372
+ window.__CONSOLE_ERROR_INTERCEPTED__ = true;
2373
+ const originalConsoleError = console.error;
2374
+ console.error = function () {
2375
+ try {
2376
+ var args = Array.prototype.slice.call(arguments);
2377
+ var first = args[0];
2378
+ var firstStr = typeof first === "string" ? first : "";
2379
+ var isReact = firstStr.indexOf("React") !== -1;
2380
+ var isVite = firstStr.indexOf("[vite]") !== -1 || firstStr.indexOf("Failed to reload") !== -1;
2381
+ if (isReact || isVite) {
2382
+ var joined = args
2383
+ .map(function (a) {
2040
2384
  if (a instanceof Error) return a.message;
2041
2385
  if (typeof a === "string") return a;
2042
2386
  if (a && typeof a.message === "string") return a.message;
2043
- try { return JSON.stringify(a); } catch (e) { return String(a); }
2044
- }).join(" ");
2045
- var errorForReport = new Error(joined);
2046
- window.__SEND_ERROR_TO_PARENT__(errorForReport, { type: "runtime", viteErrorType: "console" });
2047
- }
2048
- } catch (e) { void e }
2049
- return originalConsoleError.apply(console, arguments);
2050
- };
2051
- }
2387
+ try { return JSON.stringify(a); } catch (_) { return String(a); }
2388
+ })
2389
+ .join(" ");
2390
+ var errorForReport = new Error(joined);
2391
+ window.__SEND_ERROR_TO_PARENT__(errorForReport, { type: "runtime", viteErrorType: "console" });
2392
+ }
2393
+ } catch (_) {}
2394
+ return originalConsoleError.apply(console, arguments);
2395
+ };
2396
+ }
2052
2397
 
2053
- console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316\u5B8C\u6210");
2054
- })();
2055
- `;
2398
+ console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316\u5B8C\u6210");
2399
+ })();`;
2400
+ function injectEarlyErrorHandler() {
2401
+ if (typeof document === "undefined") return;
2056
2402
  try {
2057
- const parent = document.head || document.documentElement;
2058
- try {
2059
- const external = document.createElement("script");
2060
- external.type = "text/javascript";
2061
- external.src = "/error-handler.js";
2062
- external.async = false;
2063
- parent.prepend(external);
2064
- return;
2065
- } catch (e) {
2066
- void e;
2067
- }
2403
+ if (window.__EARLY_ERROR_HANDLER_INJECTED__) return;
2068
2404
  const script = document.createElement("script");
2069
2405
  script.type = "text/javascript";
2070
- try {
2071
- if ("textContent" in script) {
2072
- script.textContent = code;
2073
- } else {
2074
- script.appendChild(document.createTextNode(code));
2075
- }
2076
- } catch (e) {
2077
- try {
2078
- script.appendChild(document.createTextNode(code));
2079
- } catch {
2080
- }
2081
- }
2082
- parent.prepend(script);
2406
+ script.text = ERROR_HANDLER_SCRIPT;
2407
+ const head = document.head || document.getElementsByTagName("head")[0];
2408
+ if (head && head.firstChild) head.insertBefore(script, head.firstChild);
2409
+ else if (head) head.appendChild(script);
2410
+ window.__EARLY_ERROR_HANDLER_INJECTED__ = true;
2083
2411
  } catch (e) {
2084
- void e;
2085
2412
  }
2086
2413
  }
2087
2414
 
@@ -2093,12 +2420,16 @@ init_config();
2093
2420
  AUTH_ROOT,
2094
2421
  AUTH_TOKEN_KEY,
2095
2422
  AuthProvider,
2423
+ ClayxToast,
2096
2424
  DefaultErrorFallback,
2097
2425
  ErrorBoundary,
2098
2426
  FloatingButton,
2427
+ GlobalToastContainer,
2099
2428
  Loading,
2100
2429
  LoadingSpinner,
2101
2430
  LoginForm,
2431
+ ThemeProvider,
2432
+ ThemeToggle,
2102
2433
  aiRequest,
2103
2434
  aiWorkflow,
2104
2435
  canAccessArtifact,
@@ -2127,6 +2458,7 @@ init_config();
2127
2458
  useAuthContext,
2128
2459
  useDebounce,
2129
2460
  useIsMobile,
2461
+ useTheme,
2130
2462
  workflowRequest
2131
2463
  });
2132
2464
  //# sourceMappingURL=index.js.map