@embedreach/components 0.1.30 → 0.1.32

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.umd.js CHANGED
@@ -8001,192 +8001,6 @@
8001
8001
  },
8002
8002
  authListeners
8003
8003
  );
8004
- const normalizeColor = (color2) => {
8005
- const div = document.createElement("div");
8006
- div.style.color = color2;
8007
- document.body.appendChild(div);
8008
- const computed = window.getComputedStyle(div).color;
8009
- document.body.removeChild(div);
8010
- return computed;
8011
- };
8012
- const isValidColor = (color2) => {
8013
- if (/^\d+\s+\d+(?:\.\d+)?%\s+\d+(?:\.\d+)?%$/.test(color2.trim())) {
8014
- return true;
8015
- }
8016
- const div = document.createElement("div");
8017
- const prevColor = div.style.color;
8018
- div.style.color = color2;
8019
- return div.style.color !== prevColor;
8020
- };
8021
- const rgbToShadcnHsl = (r2, g2, b2) => {
8022
- r2 /= 255;
8023
- g2 /= 255;
8024
- b2 /= 255;
8025
- const max2 = Math.max(r2, g2, b2);
8026
- const min2 = Math.min(r2, g2, b2);
8027
- let h2 = 0, s2 = 0;
8028
- const l2 = (max2 + min2) / 2;
8029
- if (max2 !== min2) {
8030
- const d2 = max2 - min2;
8031
- s2 = l2 > 0.5 ? d2 / (2 - max2 - min2) : d2 / (max2 + min2);
8032
- switch (max2) {
8033
- case r2:
8034
- h2 = (g2 - b2) / d2 + (g2 < b2 ? 6 : 0);
8035
- break;
8036
- case g2:
8037
- h2 = (b2 - r2) / d2 + 2;
8038
- break;
8039
- case b2:
8040
- h2 = (r2 - g2) / d2 + 4;
8041
- break;
8042
- }
8043
- h2 *= 60;
8044
- }
8045
- return `${Math.round(h2)} ${Math.round(s2 * 100)}% ${Math.round(l2 * 100)}%`;
8046
- };
8047
- const extractRgb = (rgbColor) => {
8048
- const matches = rgbColor.match(/\d+/g);
8049
- if (!matches || matches.length < 3) {
8050
- throw new Error(`Invalid RGB color format: ${rgbColor}`);
8051
- }
8052
- return [
8053
- parseInt(matches[0], 10),
8054
- parseInt(matches[1], 10),
8055
- parseInt(matches[2], 10)
8056
- ];
8057
- };
8058
- const toShadcnFormat = (color2) => {
8059
- if (/^\d+\s+\d+(?:\.\d+)?%\s+\d+(?:\.\d+)?%$/.test(color2.trim())) {
8060
- return color2.trim();
8061
- }
8062
- try {
8063
- const rgbColor = normalizeColor(color2);
8064
- const [r2, g2, b2] = extractRgb(rgbColor);
8065
- return rgbToShadcnHsl(r2, g2, b2);
8066
- } catch (e2) {
8067
- console.warn(`Failed to convert color to shadcn format: ${color2}`, e2);
8068
- return color2;
8069
- }
8070
- };
8071
- const DEFAULT_THEME_STYLES = {
8072
- primary: "hsl(222.2 47.4% 11.2%)",
8073
- background: "hsl(0 0% 100%)",
8074
- foreground: "hsl(222.2 47.4% 11.2%)",
8075
- "primary-foreground": "hsl(210 40% 98%)",
8076
- secondary: "hsl(210 40% 96.1%)",
8077
- "secondary-foreground": "hsl(222.2 47.4% 11.2%)",
8078
- muted: "hsl(210 40% 96.1%)",
8079
- "muted-foreground": "hsl(215.4 16.3% 46.9%)",
8080
- accent: "hsl(210 40% 96.1%)",
8081
- "accent-foreground": "hsl(222.2 47.4% 11.2%)",
8082
- border: "hsl(214.3 31.8% 91.4%)",
8083
- input: "hsl(214.3 31.8% 91.4%)",
8084
- ring: "hsl(222.2 84% 4.9%)",
8085
- destructive: "hsl(0 84.2% 60.2%)",
8086
- "destructive-foreground": "hsl(210 40% 98%)",
8087
- card: "hsl(0 0% 100%)",
8088
- "card-foreground": "hsl(222.2 47.4% 11.2%)",
8089
- popover: "hsl(0 0% 100%)",
8090
- "popover-foreground": "hsl(222.2 47.4% 11.2%)",
8091
- "font-body": 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8092
- "font-heading": 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
8093
- };
8094
- const applyThemeStyles = (styles2) => {
8095
- const existingStyles = document.getElementById("reach-theme-styles");
8096
- if (existingStyles) {
8097
- existingStyles.remove();
8098
- }
8099
- const styleElement = document.createElement("style");
8100
- styleElement.id = "reach-theme-styles";
8101
- const cssText = `
8102
- [data-reach-root] {
8103
- ${Object.entries(DEFAULT_THEME_STYLES).map(([key, defaultValue]) => {
8104
- const userValue = styles2[key];
8105
- let finalValue = defaultValue;
8106
- if (userValue !== void 0) {
8107
- if (key === "radius" || key === "font-body" || key === "font-heading") {
8108
- finalValue = userValue;
8109
- } else if (isValidColor(userValue)) {
8110
- try {
8111
- finalValue = toShadcnFormat(userValue);
8112
- } catch (e2) {
8113
- console.warn(
8114
- `Failed to convert color for ${key}, using default`
8115
- );
8116
- }
8117
- }
8118
- }
8119
- return `--reach-${key}: ${finalValue};`;
8120
- }).join("\n")}
8121
- }
8122
-
8123
- /* Apply font families directly */
8124
- [data-reach-root] {
8125
- font-family: var(--reach-font-body);
8126
- }
8127
-
8128
- [data-reach-root] h1,
8129
- [data-reach-root] h2,
8130
- [data-reach-root] h3,
8131
- [data-reach-root] h4,
8132
- [data-reach-root] h5,
8133
- [data-reach-root] h6 {
8134
- font-family: var(--reach-font-heading);
8135
- }
8136
- `;
8137
- styleElement.textContent = cssText;
8138
- document.head.appendChild(styleElement);
8139
- };
8140
- const mergeThemeStyles = (themeConfig, overrides) => {
8141
- return {
8142
- ...DEFAULT_THEME_STYLES,
8143
- ...themeConfig?.styles || {},
8144
- ...{}
8145
- };
8146
- };
8147
- const themeReducer = (state, action) => {
8148
- switch (action.type) {
8149
- case "set_theme":
8150
- if (action.payload && !state.theme) {
8151
- applyThemeStyles(action.payload.styles);
8152
- }
8153
- return {
8154
- ...state,
8155
- loading: false,
8156
- error: null,
8157
- theme: action.payload
8158
- };
8159
- case "set_loading":
8160
- return {
8161
- ...state,
8162
- loading: action.payload
8163
- };
8164
- case "set_error":
8165
- return {
8166
- ...state,
8167
- loading: false,
8168
- error: action.payload
8169
- };
8170
- default:
8171
- return state;
8172
- }
8173
- };
8174
- const setTheme = (dispatch2) => (theme2) => dispatch2({ type: "set_theme", payload: theme2 });
8175
- const setLoading = (dispatch2) => (loading2) => dispatch2({ type: "set_loading", payload: loading2 });
8176
- const setError = (dispatch2) => (error2) => dispatch2({ type: "set_error", payload: error2 });
8177
- const { Context, Provider: Provider$2 } = createDataContext(
8178
- themeReducer,
8179
- {
8180
- setTheme,
8181
- setLoading,
8182
- setError
8183
- },
8184
- {
8185
- theme: null,
8186
- loading: true,
8187
- error: null
8188
- }
8189
- );
8190
8004
  const warn = (...args) => {
8191
8005
  if (console?.warn) {
8192
8006
  if (isString$2(args[0])) args[0] = `react-i18next:: ${args[0]}`;
@@ -8422,6 +8236,359 @@
8422
8236
  value
8423
8237
  }, children2);
8424
8238
  }
8239
+ const H3 = ({ children: children2 }) => {
8240
+ return /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "scroll-m-20 text-2xl font-semibold tracking-tight", children: children2 });
8241
+ };
8242
+ const SpinLoader = ({
8243
+ size: size3 = 35,
8244
+ color: color2 = "black",
8245
+ speed = 0.9,
8246
+ strokeWidth = 3.5,
8247
+ text,
8248
+ textSpeed = 2e3,
8249
+ // Default 2 seconds per text
8250
+ textColor = "black"
8251
+ }) => {
8252
+ const [currentTextIndex, setCurrentTextIndex] = React.useState(0);
8253
+ const textArray = Array.isArray(text) ? text : text ? [text] : [];
8254
+ React.useEffect(() => {
8255
+ if (textArray.length <= 1) return;
8256
+ if (currentTextIndex >= textArray.length - 1) return;
8257
+ const interval = setInterval(() => {
8258
+ setCurrentTextIndex(
8259
+ (current) => current < textArray.length - 1 ? current + 1 : current
8260
+ );
8261
+ }, textSpeed);
8262
+ return () => clearInterval(interval);
8263
+ }, [textArray.length, textSpeed, currentTextIndex]);
8264
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col justify-center items-center h-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-4", children: [
8265
+ /* @__PURE__ */ jsxRuntime.jsxs(
8266
+ "div",
8267
+ {
8268
+ className: "loader-container",
8269
+ style: {
8270
+ "--uib-size": `${size3}px`,
8271
+ "--uib-color": color2,
8272
+ "--uib-speed": `${speed}s`,
8273
+ "--uib-stroke": `${strokeWidth}px`
8274
+ },
8275
+ children: [
8276
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
8277
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
8278
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
8279
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
8280
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
8281
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" })
8282
+ ]
8283
+ }
8284
+ ),
8285
+ textArray.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
8286
+ "div",
8287
+ {
8288
+ className: `text-center text-sm text-muted-foreground animate-fade-in ${textColor ? `text-${textColor}` : ""}`,
8289
+ children: /* @__PURE__ */ jsxRuntime.jsx(H3, { children: textArray[currentTextIndex] })
8290
+ },
8291
+ currentTextIndex
8292
+ ),
8293
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
8294
+ .loader-container {
8295
+ position: relative;
8296
+ display: flex;
8297
+ align-items: center;
8298
+ justify-content: center;
8299
+ height: var(--uib-size);
8300
+ width: var(--uib-size);
8301
+ }
8302
+ .line {
8303
+ position: absolute;
8304
+ top: calc(50% - var(--uib-stroke) / 2);
8305
+ left: 0;
8306
+ height: var(--uib-stroke);
8307
+ width: 100%;
8308
+ border-radius: calc(var(--uib-stroke) / 2);
8309
+ background-color: var(--uib-color);
8310
+ animation: rotate var(--uib-speed) ease-in-out infinite;
8311
+ transition: background-color 0.3s ease;
8312
+ }
8313
+ .line:nth-child(1) {
8314
+ animation-delay: calc(var(--uib-speed) * -0.375);
8315
+ }
8316
+ .line:nth-child(2) {
8317
+ animation-delay: calc(var(--uib-speed) * -0.375);
8318
+ opacity: 0.8;
8319
+ }
8320
+ .line:nth-child(3) {
8321
+ animation-delay: calc(var(--uib-speed) * -0.3);
8322
+ opacity: 0.6;
8323
+ }
8324
+ .line:nth-child(4) {
8325
+ animation-delay: calc(var(--uib-speed) * -0.225);
8326
+ opacity: 0.4;
8327
+ }
8328
+ .line:nth-child(5) {
8329
+ animation-delay: calc(var(--uib-speed) * -0.15);
8330
+ opacity: 0.2;
8331
+ }
8332
+ .line:nth-child(6) {
8333
+ animation-delay: calc(var(--uib-speed) * -0.075);
8334
+ opacity: 0.1;
8335
+ }
8336
+ @keyframes rotate {
8337
+ 0% {
8338
+ transform: rotate(0deg);
8339
+ }
8340
+ 100% {
8341
+ transform: rotate(180deg);
8342
+ }
8343
+ }
8344
+ .animate-fade-in {
8345
+ animation: fadeIn 0.5s ease-in-out;
8346
+ }
8347
+ @keyframes fadeIn {
8348
+ from {
8349
+ opacity: 0;
8350
+ transform: translateY(5px);
8351
+ }
8352
+ to {
8353
+ opacity: 1;
8354
+ transform: translateY(0);
8355
+ }
8356
+ }
8357
+ ` })
8358
+ ] }) });
8359
+ };
8360
+ const normalizeColor = (color2) => {
8361
+ const div = document.createElement("div");
8362
+ div.style.color = color2;
8363
+ document.body.appendChild(div);
8364
+ const computed = window.getComputedStyle(div).color;
8365
+ document.body.removeChild(div);
8366
+ return computed;
8367
+ };
8368
+ const isValidColor = (color2) => {
8369
+ if (/^\d+\s+\d+(?:\.\d+)?%\s+\d+(?:\.\d+)?%$/.test(color2.trim())) {
8370
+ return true;
8371
+ }
8372
+ const div = document.createElement("div");
8373
+ const prevColor = div.style.color;
8374
+ div.style.color = color2;
8375
+ return div.style.color !== prevColor;
8376
+ };
8377
+ const rgbToShadcnHsl = (r2, g2, b2) => {
8378
+ r2 /= 255;
8379
+ g2 /= 255;
8380
+ b2 /= 255;
8381
+ const max2 = Math.max(r2, g2, b2);
8382
+ const min2 = Math.min(r2, g2, b2);
8383
+ let h2 = 0, s2 = 0;
8384
+ const l2 = (max2 + min2) / 2;
8385
+ if (max2 !== min2) {
8386
+ const d2 = max2 - min2;
8387
+ s2 = l2 > 0.5 ? d2 / (2 - max2 - min2) : d2 / (max2 + min2);
8388
+ switch (max2) {
8389
+ case r2:
8390
+ h2 = (g2 - b2) / d2 + (g2 < b2 ? 6 : 0);
8391
+ break;
8392
+ case g2:
8393
+ h2 = (b2 - r2) / d2 + 2;
8394
+ break;
8395
+ case b2:
8396
+ h2 = (r2 - g2) / d2 + 4;
8397
+ break;
8398
+ }
8399
+ h2 *= 60;
8400
+ }
8401
+ return `${Math.round(h2)} ${Math.round(s2 * 100)}% ${Math.round(l2 * 100)}%`;
8402
+ };
8403
+ const extractRgb = (rgbColor) => {
8404
+ const matches = rgbColor.match(/\d+/g);
8405
+ if (!matches || matches.length < 3) {
8406
+ throw new Error(`Invalid RGB color format: ${rgbColor}`);
8407
+ }
8408
+ return [
8409
+ parseInt(matches[0], 10),
8410
+ parseInt(matches[1], 10),
8411
+ parseInt(matches[2], 10)
8412
+ ];
8413
+ };
8414
+ const toShadcnFormat = (color2) => {
8415
+ if (/^\d+\s+\d+(?:\.\d+)?%\s+\d+(?:\.\d+)?%$/.test(color2.trim())) {
8416
+ return color2.trim();
8417
+ }
8418
+ try {
8419
+ const rgbColor = normalizeColor(color2);
8420
+ const [r2, g2, b2] = extractRgb(rgbColor);
8421
+ return rgbToShadcnHsl(r2, g2, b2);
8422
+ } catch (e2) {
8423
+ console.warn(`Failed to convert color to shadcn format: ${color2}`, e2);
8424
+ return color2;
8425
+ }
8426
+ };
8427
+ const DEFAULT_THEME_STYLES = {
8428
+ primary: "hsl(222.2 47.4% 11.2%)",
8429
+ background: "hsl(0 0% 100%)",
8430
+ foreground: "hsl(222.2 47.4% 11.2%)",
8431
+ "primary-foreground": "hsl(210 40% 98%)",
8432
+ secondary: "hsl(210 40% 96.1%)",
8433
+ "secondary-foreground": "hsl(222.2 47.4% 11.2%)",
8434
+ muted: "hsl(210 40% 96.1%)",
8435
+ "muted-foreground": "hsl(215.4 16.3% 46.9%)",
8436
+ accent: "hsl(210 40% 96.1%)",
8437
+ "accent-foreground": "hsl(222.2 47.4% 11.2%)",
8438
+ border: "hsl(214.3 31.8% 91.4%)",
8439
+ input: "hsl(214.3 31.8% 91.4%)",
8440
+ ring: "hsl(222.2 84% 4.9%)",
8441
+ destructive: "hsl(0 84.2% 60.2%)",
8442
+ "destructive-foreground": "hsl(210 40% 98%)",
8443
+ card: "hsl(0 0% 100%)",
8444
+ "card-foreground": "hsl(222.2 47.4% 11.2%)",
8445
+ popover: "hsl(0 0% 100%)",
8446
+ "popover-foreground": "hsl(222.2 47.4% 11.2%)",
8447
+ "font-body": 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8448
+ "font-heading": 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
8449
+ };
8450
+ const applyThemeStyles = (styles2) => {
8451
+ const existingStyles = document.getElementById("reach-theme-styles");
8452
+ if (existingStyles) {
8453
+ existingStyles.remove();
8454
+ }
8455
+ const styleElement = document.createElement("style");
8456
+ styleElement.id = "reach-theme-styles";
8457
+ const cssText = `
8458
+ [data-reach-root] {
8459
+ ${Object.entries(DEFAULT_THEME_STYLES).map(([key, defaultValue]) => {
8460
+ const userValue = styles2[key];
8461
+ let finalValue = defaultValue;
8462
+ if (userValue !== void 0) {
8463
+ if (key === "radius" || key === "font-body" || key === "font-heading") {
8464
+ finalValue = userValue;
8465
+ } else if (isValidColor(userValue)) {
8466
+ try {
8467
+ finalValue = toShadcnFormat(userValue);
8468
+ } catch (e2) {
8469
+ console.warn(
8470
+ `Failed to convert color for ${key}, using default`
8471
+ );
8472
+ }
8473
+ }
8474
+ }
8475
+ return `--reach-${key}: ${finalValue};`;
8476
+ }).join("\n")}
8477
+ }
8478
+
8479
+ /* Apply font families directly */
8480
+ [data-reach-root] {
8481
+ font-family: var(--reach-font-body);
8482
+ }
8483
+
8484
+ [data-reach-root] h1,
8485
+ [data-reach-root] h2,
8486
+ [data-reach-root] h3,
8487
+ [data-reach-root] h4,
8488
+ [data-reach-root] h5,
8489
+ [data-reach-root] h6 {
8490
+ font-family: var(--reach-font-heading);
8491
+ }
8492
+ `;
8493
+ styleElement.textContent = cssText;
8494
+ document.head.appendChild(styleElement);
8495
+ };
8496
+ const mergeThemeStyles = (themeConfig, overrides) => {
8497
+ return {
8498
+ ...DEFAULT_THEME_STYLES,
8499
+ ...themeConfig?.styles || {},
8500
+ ...{}
8501
+ };
8502
+ };
8503
+ const themeReducer = (state, action) => {
8504
+ switch (action.type) {
8505
+ case "set_theme":
8506
+ if (action.payload && !state.theme) {
8507
+ applyThemeStyles(action.payload.styles);
8508
+ }
8509
+ return {
8510
+ ...state,
8511
+ loading: false,
8512
+ error: null,
8513
+ theme: action.payload
8514
+ };
8515
+ case "set_loading":
8516
+ return {
8517
+ ...state,
8518
+ loading: action.payload
8519
+ };
8520
+ case "set_error":
8521
+ return {
8522
+ ...state,
8523
+ loading: false,
8524
+ error: action.payload
8525
+ };
8526
+ default:
8527
+ return state;
8528
+ }
8529
+ };
8530
+ const setTheme = (dispatch2) => (theme2) => dispatch2({ type: "set_theme", payload: theme2 });
8531
+ const setLoading = (dispatch2) => (loading2) => dispatch2({ type: "set_loading", payload: loading2 });
8532
+ const setError = (dispatch2) => (error2) => dispatch2({ type: "set_error", payload: error2 });
8533
+ const { Context, Provider: Provider$2 } = createDataContext(
8534
+ themeReducer,
8535
+ {
8536
+ setTheme,
8537
+ setLoading,
8538
+ setError
8539
+ },
8540
+ {
8541
+ theme: null,
8542
+ loading: true,
8543
+ error: null
8544
+ }
8545
+ );
8546
+ const useThemeContext = () => {
8547
+ const context = React.useContext(Context);
8548
+ if (context === void 0) {
8549
+ throw new Error("useThemeContext must be used within a ThemeProvider");
8550
+ }
8551
+ const applyTheme = (themeConfig) => {
8552
+ if (!themeConfig) return;
8553
+ const mergedStyles = mergeThemeStyles(themeConfig);
8554
+ const finalTheme = {
8555
+ styles: mergedStyles
8556
+ };
8557
+ context.setTheme(finalTheme);
8558
+ };
8559
+ return {
8560
+ ...context.state,
8561
+ setTheme: context.setTheme,
8562
+ setLoading: context.setLoading,
8563
+ setError: context.setError,
8564
+ // Add the helper function
8565
+ applyTheme
8566
+ };
8567
+ };
8568
+ const InnerThemeProvider = ({
8569
+ children: children2,
8570
+ theme: theme2
8571
+ }) => {
8572
+ const { t: t2 } = useTranslation();
8573
+ const { loading: themeLoading, applyTheme } = useThemeContext();
8574
+ const themeApplied = React.useRef(false);
8575
+ React.useEffect(() => {
8576
+ if (!themeApplied.current && theme2) {
8577
+ applyTheme(theme2);
8578
+ themeApplied.current = true;
8579
+ }
8580
+ }, [applyTheme, theme2]);
8581
+ if (themeLoading && theme2) {
8582
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col justify-center items-center h-screen", children: /* @__PURE__ */ jsxRuntime.jsx(SpinLoader, { text: [t2("loading")] }) });
8583
+ }
8584
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children2 });
8585
+ };
8586
+ const ThemeProvider = ({
8587
+ children: children2,
8588
+ theme: theme2
8589
+ }) => {
8590
+ return /* @__PURE__ */ jsxRuntime.jsx(Provider$2, { children: /* @__PURE__ */ jsxRuntime.jsx(InnerThemeProvider, { theme: theme2, children: children2 }) });
8591
+ };
8425
8592
  const isString$1 = (obj) => typeof obj === "string";
8426
8593
  const defer = () => {
8427
8594
  let res;
@@ -11894,167 +12061,6 @@
11894
12061
  }, [initialLanguage]);
11895
12062
  return /* @__PURE__ */ jsxRuntime.jsx(I18nextProvider, { i18n: instance, children: children2 });
11896
12063
  };
11897
- const useThemeContext = () => {
11898
- const context = React.useContext(Context);
11899
- if (context === void 0) {
11900
- throw new Error("useThemeContext must be used within a ThemeProvider");
11901
- }
11902
- const applyTheme = (themeConfig) => {
11903
- if (!themeConfig) return;
11904
- const mergedStyles = mergeThemeStyles(themeConfig);
11905
- const finalTheme = {
11906
- styles: mergedStyles
11907
- };
11908
- context.setTheme(finalTheme);
11909
- };
11910
- return {
11911
- ...context.state,
11912
- setTheme: context.setTheme,
11913
- setLoading: context.setLoading,
11914
- setError: context.setError,
11915
- // Add the helper function
11916
- applyTheme
11917
- };
11918
- };
11919
- const H3 = ({ children: children2 }) => {
11920
- return /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "scroll-m-20 text-2xl font-semibold tracking-tight", children: children2 });
11921
- };
11922
- const SpinLoader = ({
11923
- size: size3 = 35,
11924
- color: color2 = "black",
11925
- speed = 0.9,
11926
- strokeWidth = 3.5,
11927
- text,
11928
- textSpeed = 2e3,
11929
- // Default 2 seconds per text
11930
- textColor = "black"
11931
- }) => {
11932
- const [currentTextIndex, setCurrentTextIndex] = React.useState(0);
11933
- const textArray = Array.isArray(text) ? text : text ? [text] : [];
11934
- React.useEffect(() => {
11935
- if (textArray.length <= 1) return;
11936
- if (currentTextIndex >= textArray.length - 1) return;
11937
- const interval = setInterval(() => {
11938
- setCurrentTextIndex(
11939
- (current) => current < textArray.length - 1 ? current + 1 : current
11940
- );
11941
- }, textSpeed);
11942
- return () => clearInterval(interval);
11943
- }, [textArray.length, textSpeed, currentTextIndex]);
11944
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col justify-center items-center h-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-4", children: [
11945
- /* @__PURE__ */ jsxRuntime.jsxs(
11946
- "div",
11947
- {
11948
- className: "loader-container",
11949
- style: {
11950
- "--uib-size": `${size3}px`,
11951
- "--uib-color": color2,
11952
- "--uib-speed": `${speed}s`,
11953
- "--uib-stroke": `${strokeWidth}px`
11954
- },
11955
- children: [
11956
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
11957
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
11958
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
11959
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
11960
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
11961
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" })
11962
- ]
11963
- }
11964
- ),
11965
- textArray.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
11966
- "div",
11967
- {
11968
- className: `text-center text-sm text-muted-foreground animate-fade-in ${textColor ? `text-${textColor}` : ""}`,
11969
- children: /* @__PURE__ */ jsxRuntime.jsx(H3, { children: textArray[currentTextIndex] })
11970
- },
11971
- currentTextIndex
11972
- ),
11973
- /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
11974
- .loader-container {
11975
- position: relative;
11976
- display: flex;
11977
- align-items: center;
11978
- justify-content: center;
11979
- height: var(--uib-size);
11980
- width: var(--uib-size);
11981
- }
11982
- .line {
11983
- position: absolute;
11984
- top: calc(50% - var(--uib-stroke) / 2);
11985
- left: 0;
11986
- height: var(--uib-stroke);
11987
- width: 100%;
11988
- border-radius: calc(var(--uib-stroke) / 2);
11989
- background-color: var(--uib-color);
11990
- animation: rotate var(--uib-speed) ease-in-out infinite;
11991
- transition: background-color 0.3s ease;
11992
- }
11993
- .line:nth-child(1) {
11994
- animation-delay: calc(var(--uib-speed) * -0.375);
11995
- }
11996
- .line:nth-child(2) {
11997
- animation-delay: calc(var(--uib-speed) * -0.375);
11998
- opacity: 0.8;
11999
- }
12000
- .line:nth-child(3) {
12001
- animation-delay: calc(var(--uib-speed) * -0.3);
12002
- opacity: 0.6;
12003
- }
12004
- .line:nth-child(4) {
12005
- animation-delay: calc(var(--uib-speed) * -0.225);
12006
- opacity: 0.4;
12007
- }
12008
- .line:nth-child(5) {
12009
- animation-delay: calc(var(--uib-speed) * -0.15);
12010
- opacity: 0.2;
12011
- }
12012
- .line:nth-child(6) {
12013
- animation-delay: calc(var(--uib-speed) * -0.075);
12014
- opacity: 0.1;
12015
- }
12016
- @keyframes rotate {
12017
- 0% {
12018
- transform: rotate(0deg);
12019
- }
12020
- 100% {
12021
- transform: rotate(180deg);
12022
- }
12023
- }
12024
- .animate-fade-in {
12025
- animation: fadeIn 0.5s ease-in-out;
12026
- }
12027
- @keyframes fadeIn {
12028
- from {
12029
- opacity: 0;
12030
- transform: translateY(5px);
12031
- }
12032
- to {
12033
- opacity: 1;
12034
- transform: translateY(0);
12035
- }
12036
- }
12037
- ` })
12038
- ] }) });
12039
- };
12040
- const ReachProviderThemeProvider = ({
12041
- children: children2,
12042
- theme: theme2
12043
- }) => {
12044
- const { t: t2 } = useTranslation();
12045
- const { loading: themeLoading, applyTheme } = useThemeContext();
12046
- const themeApplied = React.useRef(false);
12047
- React.useEffect(() => {
12048
- if (!themeApplied.current && theme2) {
12049
- applyTheme(theme2);
12050
- themeApplied.current = true;
12051
- }
12052
- }, [applyTheme, theme2]);
12053
- if (themeLoading && theme2) {
12054
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col justify-center items-center h-screen", children: /* @__PURE__ */ jsxRuntime.jsx(SpinLoader, { text: [t2("loading")] }) });
12055
- }
12056
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children2 });
12057
- };
12058
12064
  const TOAST_LIMIT = 1;
12059
12065
  const TOAST_REMOVE_DELAY = 1e6;
12060
12066
  let count$2 = 0;
@@ -16600,8 +16606,8 @@
16600
16606
  useCamelCaseFlagKeys: false,
16601
16607
  sendEventsOnFlagRead: true
16602
16608
  },
16603
- children: /* @__PURE__ */ jsxRuntime.jsx(I18nProvider, { initialLanguage: language, children: /* @__PURE__ */ jsxRuntime.jsx(Provider$2, { children: /* @__PURE__ */ jsxRuntime.jsxs(Provider$3, { children: [
16604
- /* @__PURE__ */ jsxRuntime.jsx(ReachProviderThemeProvider, { theme: theme2, children: children2 }),
16609
+ children: /* @__PURE__ */ jsxRuntime.jsx(I18nProvider, { initialLanguage: language, children: /* @__PURE__ */ jsxRuntime.jsx(ThemeProvider, { theme: theme2, children: /* @__PURE__ */ jsxRuntime.jsxs(Provider$3, { children: [
16610
+ children2,
16605
16611
  /* @__PURE__ */ jsxRuntime.jsx(Toaster, {})
16606
16612
  ] }) }) })
16607
16613
  }
@@ -46735,6 +46741,11 @@ ${message2 ?? ""}`);
46735
46741
  ] })
46736
46742
  ] });
46737
46743
  };
46744
+ const useRouterParams = () => {
46745
+ const params = useParams();
46746
+ const [searchParams] = useSearchParams();
46747
+ return { params, searchParams };
46748
+ };
46738
46749
  const ViewAutomationModal = ({
46739
46750
  iconDefinitions,
46740
46751
  autoOpenEditPopup,
@@ -46742,9 +46753,8 @@ ${message2 ?? ""}`);
46742
46753
  showBackButton = false,
46743
46754
  logoUrl
46744
46755
  }) => {
46745
- const params = useParams();
46746
- const [searchParams] = useSearchParams();
46747
- const FINAL_AUTOMATION_ID = automationId || params.automationId || searchParams.get("automationId");
46756
+ const { params, searchParams } = useRouterParams();
46757
+ const FINAL_AUTOMATION_ID = automationId || params?.automationId || searchParams.get("automationId");
46748
46758
  const AUTO_OPEN_EDIT_POPUP = autoOpenEditPopup || searchParams.get("autoOpenEditPopup");
46749
46759
  const FINAL_SHOW_BACK_BUTTON = searchParams.get("showBackButton") === "true" || showBackButton;
46750
46760
  const mergedIconDefinitions = mergeIconDefinitions(iconDefinitions);