@howone/sdk 0.1.18 → 0.1.20

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