@seliseblocks/genesis-os 4.3.9 → 4.4.1

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.
Files changed (41) hide show
  1. package/dist/{chunk-BQLKADRZ.js → chunk-5WYC4OLV.js} +241 -63
  2. package/dist/chunk-5WYC4OLV.js.map +1 -0
  3. package/dist/{chunk-GACXFCNQ.cjs → chunk-GFGUKRBD.cjs} +324 -146
  4. package/dist/chunk-GFGUKRBD.cjs.map +1 -0
  5. package/dist/{chunk-QN6HLQ67.cjs → chunk-HBVSAOTQ.cjs} +53 -38
  6. package/dist/chunk-HBVSAOTQ.cjs.map +1 -0
  7. package/dist/{chunk-LNQUCEQU.js → chunk-SAY5K2GJ.js} +25 -11
  8. package/dist/chunk-SAY5K2GJ.js.map +1 -0
  9. package/dist/{chunk-46ZGVJEX.js → chunk-SG6FH72W.js} +69 -5
  10. package/dist/chunk-SG6FH72W.js.map +1 -0
  11. package/dist/{chunk-4QKE3WAW.cjs → chunk-VAWEXEJZ.cjs} +73 -4
  12. package/dist/chunk-VAWEXEJZ.cjs.map +1 -0
  13. package/dist/components/index.cjs +342 -342
  14. package/dist/components/index.js +3 -3
  15. package/dist/guards/index.cjs +9 -9
  16. package/dist/guards/index.js +3 -3
  17. package/dist/hooks/index.cjs +58 -54
  18. package/dist/hooks/index.d.cts +12 -1
  19. package/dist/hooks/index.d.ts +12 -1
  20. package/dist/hooks/index.js +2 -2
  21. package/dist/index.cjs +452 -428
  22. package/dist/index.d.cts +2 -2
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +3 -3
  25. package/dist/layouts/index.cjs +10 -10
  26. package/dist/layouts/index.js +3 -3
  27. package/dist/lib/index.cjs +37 -17
  28. package/dist/lib/index.d.cts +44 -3
  29. package/dist/lib/index.d.ts +44 -3
  30. package/dist/lib/index.js +1 -1
  31. package/dist/pages/index.cjs +8 -8
  32. package/dist/pages/index.js +3 -3
  33. package/dist/utils/index.cjs +1 -1
  34. package/dist/utils/index.js +1 -1
  35. package/package.json +4 -4
  36. package/dist/chunk-46ZGVJEX.js.map +0 -1
  37. package/dist/chunk-4QKE3WAW.cjs.map +0 -1
  38. package/dist/chunk-BQLKADRZ.js.map +0 -1
  39. package/dist/chunk-GACXFCNQ.cjs.map +0 -1
  40. package/dist/chunk-LNQUCEQU.js.map +0 -1
  41. package/dist/chunk-QN6HLQ67.cjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkXJ6DPUCV_cjs = require('./chunk-XJ6DPUCV.cjs');
4
- var chunkQN6HLQ67_cjs = require('./chunk-QN6HLQ67.cjs');
4
+ var chunkHBVSAOTQ_cjs = require('./chunk-HBVSAOTQ.cjs');
5
5
  var chunkQTSTAWK3_cjs = require('./chunk-QTSTAWK3.cjs');
6
- var chunk4QKE3WAW_cjs = require('./chunk-4QKE3WAW.cjs');
6
+ var chunkVAWEXEJZ_cjs = require('./chunk-VAWEXEJZ.cjs');
7
7
  var chunkX4YCRWXO_cjs = require('./chunk-X4YCRWXO.cjs');
8
8
  var chunkIJMKS4XG_cjs = require('./chunk-IJMKS4XG.cjs');
9
9
  var chunkBPJM3L7O_cjs = require('./chunk-BPJM3L7O.cjs');
@@ -1523,7 +1523,7 @@ function RightSidePanelProvider({
1523
1523
  const close = React8__namespace.useCallback(() => {
1524
1524
  setOpen(false);
1525
1525
  }, [setOpen]);
1526
- chunkQN6HLQ67_cjs.useKeyboardShortcut(shortcut, toggle);
1526
+ chunkHBVSAOTQ_cjs.useKeyboardShortcut(shortcut, toggle);
1527
1527
  React8__namespace.useEffect(() => {
1528
1528
  if (!syncHash || isControlled || typeof window === "undefined") return;
1529
1529
  const handleHashChange = () => {
@@ -2388,7 +2388,7 @@ var WizardStepIndicator = ({
2388
2388
  color: indicatorColor,
2389
2389
  backgroundColor: isCompleted ? "hsl(var(--foreground))" : "transparent"
2390
2390
  },
2391
- transition: chunk4QKE3WAW_cjs.fadeTransition,
2391
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
2392
2392
  className: chunkYAF2X7W5_cjs.cn(
2393
2393
  "flex size-8 items-center justify-center rounded-full border text-lg font-bold",
2394
2394
  className
@@ -2399,7 +2399,7 @@ var WizardStepIndicator = ({
2399
2399
  initial: { scale: 0, opacity: 0 },
2400
2400
  animate: { scale: 1, opacity: 1 },
2401
2401
  exit: { scale: 0, opacity: 0 },
2402
- transition: chunk4QKE3WAW_cjs.fadeTransition,
2402
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
2403
2403
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "size-[18px]", "aria-hidden": true })
2404
2404
  },
2405
2405
  "check"
@@ -2409,7 +2409,7 @@ var WizardStepIndicator = ({
2409
2409
  initial: { scale: 0.8, opacity: 0 },
2410
2410
  animate: { scale: 1, opacity: 1 },
2411
2411
  exit: { scale: 0.8, opacity: 0 },
2412
- transition: chunk4QKE3WAW_cjs.fadeTransition,
2412
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
2413
2413
  children: stepNumber
2414
2414
  },
2415
2415
  "number"
@@ -2420,7 +2420,7 @@ var WizardStepIndicator = ({
2420
2420
  var WizardVerticalTrackBar = () => {
2421
2421
  const { currentStep, totalSteps, goToStep, completedSteps, getSteps } = useWizardStepper();
2422
2422
  const steps = getSteps();
2423
- return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.div, { layout: true, transition: chunk4QKE3WAW_cjs.fadeTransition, children: steps.map((step, index) => {
2423
+ return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.div, { layout: true, transition: chunkVAWEXEJZ_cjs.fadeTransition, children: steps.map((step, index) => {
2424
2424
  const stepNumber = index + 1;
2425
2425
  const isCompleted = completedSteps.includes(stepNumber);
2426
2426
  const isCurrent = currentStep === stepNumber;
@@ -2434,7 +2434,7 @@ var WizardVerticalTrackBar = () => {
2434
2434
  {
2435
2435
  layout: true,
2436
2436
  className: "flex items-center gap-2",
2437
- transition: chunk4QKE3WAW_cjs.fadeTransition,
2437
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
2438
2438
  children: [
2439
2439
  /* @__PURE__ */ jsxRuntime.jsx(
2440
2440
  Button,
@@ -2461,7 +2461,7 @@ var WizardVerticalTrackBar = () => {
2461
2461
  animate: {
2462
2462
  color: isCurrent || isCompleted ? "hsl(var(--foreground))" : "hsl(var(--muted-foreground))"
2463
2463
  },
2464
- transition: chunk4QKE3WAW_cjs.fadeTransition,
2464
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
2465
2465
  className: "ml-4 text-base font-medium",
2466
2466
  children: step.title
2467
2467
  }
@@ -2478,7 +2478,7 @@ var WizardVerticalTrackBar = () => {
2478
2478
  scaleY: isCompleted ? 1 : 0.35,
2479
2479
  backgroundColor: isCompleted ? "hsl(var(--foreground))" : "hsl(var(--border))"
2480
2480
  },
2481
- transition: chunk4QKE3WAW_cjs.fadeTransition
2481
+ transition: chunkVAWEXEJZ_cjs.fadeTransition
2482
2482
  }
2483
2483
  ) : null
2484
2484
  ]
@@ -2495,7 +2495,7 @@ var WizardHorizontalTrackBar = () => {
2495
2495
  {
2496
2496
  layout: true,
2497
2497
  className: "flex w-full flex-row flex-wrap justify-between",
2498
- transition: chunk4QKE3WAW_cjs.fadeTransition,
2498
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
2499
2499
  children: steps.map((step, index) => {
2500
2500
  const stepNumber = index + 1;
2501
2501
  const isCompleted = completedSteps.includes(stepNumber);
@@ -2534,7 +2534,7 @@ var WizardHorizontalTrackBar = () => {
2534
2534
  animate: {
2535
2535
  color: isCurrent || isCompleted ? "hsl(var(--foreground))" : "hsl(var(--muted-foreground))"
2536
2536
  },
2537
- transition: chunk4QKE3WAW_cjs.fadeTransition,
2537
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
2538
2538
  className: "hidden md:block",
2539
2539
  children: step.title
2540
2540
  }
@@ -2555,11 +2555,11 @@ var WizardStepViewport = ({
2555
2555
  return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "wait", children: /* @__PURE__ */ jsxRuntime.jsx(
2556
2556
  framerMotion.motion.div,
2557
2557
  {
2558
- variants: chunk4QKE3WAW_cjs.fadeInUp,
2558
+ variants: chunkVAWEXEJZ_cjs.fadeInUp,
2559
2559
  initial: "initial",
2560
2560
  animate: "animate",
2561
2561
  exit: "exit",
2562
- transition: chunk4QKE3WAW_cjs.fadeTransition,
2562
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
2563
2563
  className,
2564
2564
  children
2565
2565
  },
@@ -3499,7 +3499,7 @@ function MultiSelect({
3499
3499
  onChange,
3500
3500
  value: selectedValues
3501
3501
  }) {
3502
- const [buttonRef, popoverWidth] = chunkQN6HLQ67_cjs.usePopoverWidth();
3502
+ const [buttonRef, popoverWidth] = chunkHBVSAOTQ_cjs.usePopoverWidth();
3503
3503
  const onSelectHandler = (value) => {
3504
3504
  const nextValues = selectedValues.includes(value) ? selectedValues.filter((item) => item !== value) : [...selectedValues, value];
3505
3505
  onChange(nextValues);
@@ -3815,7 +3815,7 @@ var CopyToClipboardButton = ({
3815
3815
  ),
3816
3816
  initial: false,
3817
3817
  animate: { opacity: isHoverable ? void 0 : 1 },
3818
- transition: chunk4QKE3WAW_cjs.fadeTransition,
3818
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
3819
3819
  children: [
3820
3820
  /* @__PURE__ */ jsxRuntime.jsx(
3821
3821
  Button,
@@ -3832,7 +3832,7 @@ var CopyToClipboardButton = ({
3832
3832
  initial: { scale: 0.6, opacity: 0 },
3833
3833
  animate: { scale: 1, opacity: 1 },
3834
3834
  exit: { scale: 0.6, opacity: 0 },
3835
- transition: chunk4QKE3WAW_cjs.fadeTransition,
3835
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
3836
3836
  children: /* @__PURE__ */ jsxRuntime.jsx(
3837
3837
  lucideReact.Check,
3838
3838
  {
@@ -3848,7 +3848,7 @@ var CopyToClipboardButton = ({
3848
3848
  initial: { scale: 0.6, opacity: 0 },
3849
3849
  animate: { scale: 1, opacity: 1 },
3850
3850
  exit: { scale: 0.6, opacity: 0 },
3851
- transition: chunk4QKE3WAW_cjs.fadeTransition,
3851
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
3852
3852
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "size-4 text-muted-foreground", "aria-hidden": true })
3853
3853
  },
3854
3854
  "copy"
@@ -3861,7 +3861,7 @@ var CopyToClipboardButton = ({
3861
3861
  layout: true,
3862
3862
  className: "pointer-events-none absolute left-8 top-1/2 z-10 hidden -translate-y-1/2 whitespace-nowrap rounded bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md peer-hover:block",
3863
3863
  animate: { opacity: isCopying ? 1 : 0.9 },
3864
- transition: chunk4QKE3WAW_cjs.fadeTransition,
3864
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
3865
3865
  children: isCopying ? copiedLabel : copyLabel
3866
3866
  }
3867
3867
  )
@@ -5228,7 +5228,7 @@ var InfiniteScroller = ({
5228
5228
  initial: { opacity: 0, height: 0 },
5229
5229
  animate: { opacity: 1, height: "auto" },
5230
5230
  exit: { opacity: 0, height: 0 },
5231
- transition: chunk4QKE3WAW_cjs.fadeTransition,
5231
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
5232
5232
  children: loadingIndicator
5233
5233
  },
5234
5234
  "loading"
@@ -5239,10 +5239,10 @@ var InfiniteScroller = ({
5239
5239
  framerMotion.motion.div,
5240
5240
  {
5241
5241
  layout: true,
5242
- variants: chunk4QKE3WAW_cjs.fadeInUp,
5242
+ variants: chunkVAWEXEJZ_cjs.fadeInUp,
5243
5243
  initial: "initial",
5244
5244
  animate: "animate",
5245
- transition: chunk4QKE3WAW_cjs.fadeTransition,
5245
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
5246
5246
  children: renderItem(item, index)
5247
5247
  },
5248
5248
  key
@@ -5254,7 +5254,7 @@ var InfiniteScroller = ({
5254
5254
  className: "flex h-full items-center justify-center text-muted-foreground",
5255
5255
  initial: { opacity: 0 },
5256
5256
  animate: { opacity: 1 },
5257
- transition: chunk4QKE3WAW_cjs.fadeTransition,
5257
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
5258
5258
  children: emptyContent ?? "No items"
5259
5259
  }
5260
5260
  ) }),
@@ -5265,7 +5265,7 @@ var InfiniteScroller = ({
5265
5265
  initial: { opacity: 0, y: 16 },
5266
5266
  animate: { opacity: 1, y: 0 },
5267
5267
  exit: { opacity: 0, y: 12 },
5268
- transition: chunk4QKE3WAW_cjs.fadeTransition,
5268
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
5269
5269
  children: /* @__PURE__ */ jsxRuntime.jsx(
5270
5270
  framerMotion.motion.div,
5271
5271
  {
@@ -5903,14 +5903,14 @@ var Timeline = ({
5903
5903
  framerMotion.motion.div,
5904
5904
  {
5905
5905
  className: chunkYAF2X7W5_cjs.cn("mt-4 flex flex-col items-start md:mt-5", className),
5906
- variants: chunk4QKE3WAW_cjs.staggerContainer,
5906
+ variants: chunkVAWEXEJZ_cjs.staggerContainer,
5907
5907
  initial: "initial",
5908
5908
  animate: "animate",
5909
5909
  children: events.map((event, index) => /* @__PURE__ */ jsxRuntime.jsxs(
5910
5910
  framerMotion.motion.div,
5911
5911
  {
5912
- variants: chunk4QKE3WAW_cjs.staggerItem,
5913
- transition: chunk4QKE3WAW_cjs.fadeTransition,
5912
+ variants: chunkVAWEXEJZ_cjs.staggerItem,
5913
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
5914
5914
  className: "flex min-h-[66px] w-full",
5915
5915
  children: [
5916
5916
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkYAF2X7W5_cjs.cn("relative", isMobile ? "w-[30%]" : "w-[16%]"), children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -5919,7 +5919,7 @@ var Timeline = ({
5919
5919
  className: "absolute -top-1.5 w-full pr-[18px] text-right md:pr-5",
5920
5920
  initial: { opacity: 0, x: -6 },
5921
5921
  animate: { opacity: 1, x: 0 },
5922
- transition: { ...chunk4QKE3WAW_cjs.fadeTransition, delay: index * 0.05 },
5922
+ transition: { ...chunkVAWEXEJZ_cjs.fadeTransition, delay: index * 0.05 },
5923
5923
  children: leftContent ? leftContent(event) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5924
5924
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs font-medium leading-5 md:text-sm", children: event.time }),
5925
5925
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs font-medium leading-5 md:text-sm", children: event.date })
@@ -5936,7 +5936,7 @@ var Timeline = ({
5936
5936
  ),
5937
5937
  initial: { scaleY: 0 },
5938
5938
  animate: { scaleY: 1 },
5939
- transition: { ...chunk4QKE3WAW_cjs.fadeTransition, delay: index * 0.05 }
5939
+ transition: { ...chunkVAWEXEJZ_cjs.fadeTransition, delay: index * 0.05 }
5940
5940
  }
5941
5941
  ) : null,
5942
5942
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5945,7 +5945,7 @@ var Timeline = ({
5945
5945
  className: "bg-primary relative z-10 size-4 rounded-full",
5946
5946
  initial: { scale: 0 },
5947
5947
  animate: { scale: 1 },
5948
- transition: { ...chunk4QKE3WAW_cjs.fadeTransition, delay: index * 0.05 + 0.04 }
5948
+ transition: { ...chunkVAWEXEJZ_cjs.fadeTransition, delay: index * 0.05 + 0.04 }
5949
5949
  }
5950
5950
  )
5951
5951
  ] }),
@@ -5998,11 +5998,11 @@ var ImportFileModalContent = ({
5998
5998
  return /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { className: chunkYAF2X7W5_cjs.cn("rounded-md sm:max-w-[450px]", className), children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "wait", children: !showConfirmation ? /* @__PURE__ */ jsxRuntime.jsxs(
5999
5999
  framerMotion.motion.div,
6000
6000
  {
6001
- variants: chunk4QKE3WAW_cjs.fadeInScale,
6001
+ variants: chunkVAWEXEJZ_cjs.fadeInScale,
6002
6002
  initial: "initial",
6003
6003
  animate: "animate",
6004
6004
  exit: "exit",
6005
- transition: chunk4QKE3WAW_cjs.fadeTransition,
6005
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
6006
6006
  children: [
6007
6007
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
6008
6008
  /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-left", children: dialogTitle }),
@@ -6014,7 +6014,7 @@ var ImportFileModalContent = ({
6014
6014
  className: "flex flex-col rounded-md bg-muted/50 px-3 py-2",
6015
6015
  initial: { opacity: 0, y: 6 },
6016
6016
  animate: { opacity: 1, y: 0 },
6017
- transition: { ...chunk4QKE3WAW_cjs.fadeTransition, delay: 0.05 },
6017
+ transition: { ...chunkVAWEXEJZ_cjs.fadeTransition, delay: 0.05 },
6018
6018
  children: [
6019
6019
  /* @__PURE__ */ jsxRuntime.jsxs(framerMotion.motion.div, { className: "flex flex-row items-center", children: [
6020
6020
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -6051,7 +6051,7 @@ var ImportFileModalContent = ({
6051
6051
  initial: { opacity: 0, x: -8 },
6052
6052
  animate: { opacity: 1, x: 0 },
6053
6053
  exit: { opacity: 0, x: 8 },
6054
- transition: chunk4QKE3WAW_cjs.fadeTransition,
6054
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
6055
6055
  children: /* @__PURE__ */ jsxRuntime.jsxs(FileUploaderItem, { index, children: [
6056
6056
  /* @__PURE__ */ jsxRuntime.jsx(
6057
6057
  lucideReact.Paperclip,
@@ -6101,11 +6101,11 @@ var ImportFileModalContent = ({
6101
6101
  ) : /* @__PURE__ */ jsxRuntime.jsxs(
6102
6102
  framerMotion.motion.div,
6103
6103
  {
6104
- variants: chunk4QKE3WAW_cjs.fadeInScale,
6104
+ variants: chunkVAWEXEJZ_cjs.fadeInScale,
6105
6105
  initial: "initial",
6106
6106
  animate: "animate",
6107
6107
  exit: "exit",
6108
- transition: chunk4QKE3WAW_cjs.fadeTransition,
6108
+ transition: chunkVAWEXEJZ_cjs.fadeTransition,
6109
6109
  children: [
6110
6110
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
6111
6111
  /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-left", children: processingTitle }),
@@ -6481,7 +6481,12 @@ var AppTile = ({
6481
6481
  {
6482
6482
  href: isLoading ? void 0 : app.initiateUrl,
6483
6483
  "aria-disabled": isLoading,
6484
- onClick: isLoading ? (e) => e.preventDefault() : void 0,
6484
+ onClick: isLoading ? (e) => e.preventDefault() : app.markUsed,
6485
+ onAuxClick: (e) => {
6486
+ if (!isLoading && e.button === 1) app.markUsed();
6487
+ },
6488
+ onContextMenu: isLoading ? void 0 : app.markUsed,
6489
+ onDragStart: isLoading ? void 0 : app.markUsed,
6485
6490
  className: chunkYAF2X7W5_cjs.cn(
6486
6491
  "hover:bg-accent focus-visible:ring-ring group flex flex-col items-center gap-2 rounded-xl p-3 text-center transition-colors focus-visible:outline-none focus-visible:ring-2",
6487
6492
  isLoading && "pointer-events-none opacity-50 cursor-default"
@@ -6672,49 +6677,70 @@ var filteredAppSwitcherData = APP_SWITCHER_DATA.filter((app) => {
6672
6677
  if (!isAppAllowed(app)) return false;
6673
6678
  return typeof app.isDisabled === "function" ? !app.isDisabled() : !app.isDisabled;
6674
6679
  });
6680
+ var INITIATE_URL_MAX_AGE_MS = 5 * 60 * 1e3;
6681
+ var initiateQueryKey = (clientId, redirectUri, forwardedTo) => ["idp-initiate", clientId, redirectUri, forwardedTo];
6675
6682
  function useAppRedirectUrls({
6676
6683
  open,
6677
6684
  apps,
6678
6685
  resolveForwardedTo
6679
6686
  }) {
6680
- const [redirectUrls, setRedirectUrls] = React8.useState({});
6681
- const appsKey = apps.map((a) => a.id).join("|");
6682
- const stableApps = React8.useMemo(() => apps, [appsKey]);
6683
- const resolveRef = React8.useRef(resolveForwardedTo);
6684
- resolveRef.current = resolveForwardedTo;
6685
- React8.useEffect(() => {
6686
- if (!open || stableApps.length === 0) return void 0;
6687
- setRedirectUrls({});
6688
- const controller = new AbortController();
6689
- const { signal } = controller;
6690
- stableApps.forEach((app) => {
6691
- chunkQN6HLQ67_cjs.initiateService.fetchRedirectUrl({
6692
- clientId: chunkX4YCRWXO_cjs.getRuntimeEnv(app.clientId),
6693
- redirectUri: chunkX4YCRWXO_cjs.getRuntimeEnv(app.redirectUri),
6694
- forwardedTo: resolveRef.current(app)
6695
- }).then((redirectUrl) => {
6696
- if (signal.aborted || !redirectUrl) return;
6697
- setRedirectUrls((prev) => ({ ...prev, [app.id]: redirectUrl }));
6698
- }).catch((err) => {
6699
- if (signal.aborted) return;
6700
- console.error(
6701
- `[AppSwitcher] Failed to get redirect URL for ${app.id}:`,
6702
- err
6703
- );
6704
- });
6705
- });
6706
- return () => controller.abort();
6707
- }, [open, stableApps]);
6708
- if (!open || stableApps.length === 0) return [];
6709
- return stableApps.map((app) => ({
6710
- ...app,
6711
- initiateUrl: redirectUrls[app.id] ?? app.initiateUrl,
6712
- isLoading: !redirectUrls[app.id]
6713
- }));
6687
+ const queryClient = reactQuery.useQueryClient();
6688
+ const requests = apps.map((app) => {
6689
+ const clientId = chunkX4YCRWXO_cjs.getRuntimeEnv(app.clientId);
6690
+ const redirectUri = chunkX4YCRWXO_cjs.getRuntimeEnv(app.redirectUri);
6691
+ const forwardedTo = resolveForwardedTo(app);
6692
+ return {
6693
+ app,
6694
+ clientId,
6695
+ redirectUri,
6696
+ forwardedTo,
6697
+ queryKey: initiateQueryKey(clientId, redirectUri, forwardedTo)
6698
+ };
6699
+ });
6700
+ const results = reactQuery.useQueries({
6701
+ queries: requests.map(
6702
+ ({ clientId, redirectUri, forwardedTo, queryKey }) => ({
6703
+ queryKey,
6704
+ queryFn: ({ signal }) => chunkHBVSAOTQ_cjs.initiateService.fetchRedirectUrl(
6705
+ { clientId, redirectUri, forwardedTo },
6706
+ signal
6707
+ ),
6708
+ enabled: open,
6709
+ staleTime: INITIATE_URL_MAX_AGE_MS,
6710
+ gcTime: INITIATE_URL_MAX_AGE_MS,
6711
+ // Replace a URL as it ages out while the popover stays open, rather than leaving the tile on
6712
+ // "Loading…" until it is reopened.
6713
+ refetchInterval: INITIATE_URL_MAX_AGE_MS,
6714
+ refetchOnWindowFocus: false,
6715
+ refetchOnReconnect: false,
6716
+ retry: false
6717
+ })
6718
+ )
6719
+ });
6720
+ const markUsed = React8.useCallback(
6721
+ (queryKey) => {
6722
+ setTimeout(() => {
6723
+ void queryClient.resetQueries({ queryKey, exact: true });
6724
+ }, 0);
6725
+ },
6726
+ [queryClient]
6727
+ );
6728
+ if (!open || apps.length === 0) return [];
6729
+ const now = Date.now();
6730
+ return requests.map(({ app, queryKey }, index) => {
6731
+ const result = results[index];
6732
+ const url = result?.data && now - result.dataUpdatedAt < INITIATE_URL_MAX_AGE_MS ? result.data : void 0;
6733
+ return {
6734
+ ...app,
6735
+ initiateUrl: url ?? app.initiateUrl,
6736
+ isLoading: !url,
6737
+ markUsed: () => markUsed(queryKey)
6738
+ };
6739
+ });
6714
6740
  }
6715
6741
  var AppSwitcher = ({ forwardedTo }) => {
6716
6742
  const [open, setOpen] = React8.useState(false);
6717
- const config = chunkQN6HLQ67_cjs.useBlocksAppConfigStore((state) => state.getConfig());
6743
+ const config = chunkHBVSAOTQ_cjs.useBlocksAppConfigStore((state) => state.getConfig());
6718
6744
  const filteredApps = React8.useMemo(
6719
6745
  () => filteredAppSwitcherData.filter((app) => app.id !== config.name),
6720
6746
  [config.name]
@@ -6753,7 +6779,7 @@ function ThemeSwitcher({
6753
6779
  className,
6754
6780
  showChevron = true
6755
6781
  } = {}) {
6756
- const { theme, setTheme } = chunkQN6HLQ67_cjs.useTheme();
6782
+ const { theme, setTheme } = chunkHBVSAOTQ_cjs.useTheme();
6757
6783
  const { Icon: ThemeIcon } = OPTIONS[theme];
6758
6784
  return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
6759
6785
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -6821,7 +6847,7 @@ function ThemeSwitcher({
6821
6847
  // src/services/user.service.ts
6822
6848
  var UserService = class {
6823
6849
  async getUserInfo() {
6824
- return chunk4QKE3WAW_cjs.iamClient.get(`${chunk4QKE3WAW_cjs.PROFILE_ENDPOINTS.ME}`);
6850
+ return chunkVAWEXEJZ_cjs.iamClient.get(`${chunkVAWEXEJZ_cjs.PROFILE_ENDPOINTS.ME}`);
6825
6851
  }
6826
6852
  };
6827
6853
  var userService = new UserService();
@@ -6863,14 +6889,14 @@ function UserAvatar({ size = "sm" }) {
6863
6889
  );
6864
6890
  }
6865
6891
  function UserDropdownMenu() {
6866
- const { name } = chunkQN6HLQ67_cjs.useBlocksAppConfigStore((state) => state.config);
6892
+ const { name } = chunkHBVSAOTQ_cjs.useBlocksAppConfigStore((state) => state.config);
6867
6893
  const { data } = useGetUserInfo();
6868
6894
  const userData = data?.data;
6869
- const { isPending, mutateAsync } = chunkQN6HLQ67_cjs.useLogout();
6895
+ const { isPending, mutateAsync } = chunkHBVSAOTQ_cjs.useLogout();
6870
6896
  const { resetProjectStore } = chunk6GCU5LM7_cjs.useProjectStore();
6871
6897
  const { setUnAuthenticated, clearTokens } = chunk6GCU5LM7_cjs.useAuthStore();
6872
6898
  const { resetSelectedLanguages } = chunk4QN4CYSC_cjs.useLanguageViewStore();
6873
- const { data: myOrgsData, isLoading: isOrgsLoading } = chunkQN6HLQ67_cjs.useGetMyOrganizations();
6899
+ const { data: myOrgsData, isLoading: isOrgsLoading } = chunkHBVSAOTQ_cjs.useGetMyOrganizations();
6874
6900
  const fullName = [userData?.firstName, userData?.lastName].filter(Boolean).join(" ") || "\u2014";
6875
6901
  const email = userData?.email || "";
6876
6902
  const roles = Object.values(userData?.roles || {}).flat();
@@ -7000,7 +7026,7 @@ var languages = [
7000
7026
  { key: "fr", title: "French" }
7001
7027
  ];
7002
7028
  function LanguageSelector() {
7003
- const { changeLanguage, language } = chunkQN6HLQ67_cjs.useLanguageSwitcher();
7029
+ const { changeLanguage, language } = chunkHBVSAOTQ_cjs.useLanguageSwitcher();
7004
7030
  return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
7005
7031
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
7006
7032
  "button",
@@ -7065,8 +7091,24 @@ function Logo({
7065
7091
  ] });
7066
7092
  }
7067
7093
  var logicOrigin = () => chunkX4YCRWXO_cjs.getRuntimeEnv("BLOCKS_LOGIC_BASE_URL").trim().replace(/\/$/, "");
7094
+ var RETRY_DELAYS_MS = [2e3, 5e3, 15e3, 3e4];
7095
+ var STEADY_RETRY_MS = 6e4;
7096
+ var isLoggedOut = (error) => error?.status === 401;
7097
+ var hasHttpStatus = (error) => typeof error?.status === "number";
7098
+ var refreshLoginCall = async (probe) => {
7099
+ try {
7100
+ await probe;
7101
+ } catch (error) {
7102
+ if (isLoggedOut(error) || !hasHttpStatus(error)) throw error;
7103
+ }
7104
+ };
7068
7105
  var NotificationListenerService = class {
7069
7106
  connection;
7107
+ // True from connect() until disconnect(): the app wants the hub up.
7108
+ wanted = false;
7109
+ attempt = 0;
7110
+ timer;
7111
+ inFlight;
7070
7112
  constructor() {
7071
7113
  this.connection = new signalr.HubConnectionBuilder().withUrl(
7072
7114
  `${logicOrigin()}/api/NotificationHub?x-blocks-key=${chunkX4YCRWXO_cjs.getRuntimeEnv("BLOCKS_X_BLOCKS_KEY")}`,
@@ -7074,23 +7116,78 @@ var NotificationListenerService = class {
7074
7116
  transport: signalr.HttpTransportType.WebSockets
7075
7117
  }
7076
7118
  ).withAutomaticReconnect().build();
7119
+ this.connection.onclose(() => {
7120
+ if (this.wanted) this.recover(true);
7121
+ });
7077
7122
  }
7078
7123
  async connect() {
7079
- if (this.connection.state === "Disconnected") {
7080
- await this.connection.start();
7124
+ if (!this.wanted) {
7125
+ this.wanted = true;
7126
+ this.attempt = 0;
7127
+ globalThis.addEventListener("online", this.onWake);
7128
+ document.addEventListener("visibilitychange", this.onVisibility);
7081
7129
  }
7130
+ if (this.timer === void 0) await this.recover(false);
7082
7131
  }
7083
7132
  async disconnect() {
7133
+ this.wanted = false;
7134
+ this.stopWatching();
7084
7135
  if (this.connection.state !== "Disconnected") {
7085
7136
  await this.connection.stop();
7086
7137
  }
7087
7138
  }
7139
+ onWake = () => {
7140
+ if (this.wanted) this.recover(true);
7141
+ };
7142
+ onVisibility = () => {
7143
+ if (document.visibilityState === "visible") this.onWake();
7144
+ };
7145
+ stopWatching() {
7146
+ clearTimeout(this.timer);
7147
+ this.timer = void 0;
7148
+ globalThis.removeEventListener("online", this.onWake);
7149
+ document.removeEventListener("visibilitychange", this.onVisibility);
7150
+ }
7151
+ // Never two starts at once: callers share the run that is already going.
7152
+ recover(refreshLogin) {
7153
+ this.inFlight ??= this.tryStart(refreshLogin).finally(() => {
7154
+ this.inFlight = void 0;
7155
+ });
7156
+ return this.inFlight;
7157
+ }
7158
+ async tryStart(refreshLogin) {
7159
+ clearTimeout(this.timer);
7160
+ this.timer = void 0;
7161
+ if (!this.wanted || this.connection.state !== "Disconnected") return;
7162
+ if (refreshLogin && navigator.onLine === false) return;
7163
+ try {
7164
+ if (refreshLogin)
7165
+ await refreshLoginCall(chunkHBVSAOTQ_cjs.notificationService.getNotifications(1, 1));
7166
+ if (!this.wanted) return;
7167
+ await this.connection.start();
7168
+ this.attempt = 0;
7169
+ if (!this.wanted) await this.connection.stop();
7170
+ } catch (error) {
7171
+ if (!this.wanted) return;
7172
+ if (isLoggedOut(error)) {
7173
+ this.wanted = false;
7174
+ this.stopWatching();
7175
+ return;
7176
+ }
7177
+ this.scheduleRetry();
7178
+ }
7179
+ }
7180
+ scheduleRetry() {
7181
+ const delay = RETRY_DELAYS_MS[this.attempt] ?? STEADY_RETRY_MS;
7182
+ this.attempt += 1;
7183
+ this.timer = setTimeout(() => this.recover(true), delay);
7184
+ }
7088
7185
  };
7089
7186
  var notificationListenerService = new NotificationListenerService();
7090
7187
 
7091
7188
  // src/components/common/notification/use-notification-socket.ts
7092
7189
  function useNotificationSocket() {
7093
- const { data: configData } = chunkQN6HLQ67_cjs.useGetBlocksNotificationConfig(0, 100);
7190
+ const { data: configData } = chunkHBVSAOTQ_cjs.useGetBlocksNotificationConfig(0, 100);
7094
7191
  const queryClient = reactQuery.useQueryClient();
7095
7192
  notificationListenerService.connect();
7096
7193
  React8.useEffect(() => {
@@ -7105,7 +7202,7 @@ function useNotificationSocket() {
7105
7202
  notificationListenerService.connection.on(
7106
7203
  config.notifyMethod,
7107
7204
  (message) => {
7108
- chunkQN6HLQ67_cjs.notificationService.getNotificationConfig(config, message);
7205
+ chunkHBVSAOTQ_cjs.notificationService.getNotificationConfig(config, message);
7109
7206
  try {
7110
7207
  const notice = typeof message === "string" ? JSON.parse(message) : message;
7111
7208
  const denom = JSON.parse(
@@ -7129,12 +7226,12 @@ function useNotificationFeed(open) {
7129
7226
  const [notifications, setNotifications] = React8.useState([]);
7130
7227
  const [hasMore, setHasMore] = React8.useState(true);
7131
7228
  const listRef = React8.useRef(null);
7132
- const { data, isLoading, isFetching } = chunkQN6HLQ67_cjs.useGetNotifications(
7229
+ const { data, isLoading, isFetching } = chunkHBVSAOTQ_cjs.useGetNotifications(
7133
7230
  pageNumber,
7134
7231
  PAGE_SIZE
7135
7232
  );
7136
- const markAsRead = chunkQN6HLQ67_cjs.useMarkAsRead();
7137
- const markAllAsRead = chunkQN6HLQ67_cjs.useMarkAllAsRead();
7233
+ const markAsRead = chunkHBVSAOTQ_cjs.useMarkAsRead();
7234
+ const markAllAsRead = chunkHBVSAOTQ_cjs.useMarkAllAsRead();
7138
7235
  React8.useEffect(() => {
7139
7236
  if (!data?.notifications) return;
7140
7237
  setNotifications((prev) => {
@@ -7368,7 +7465,7 @@ function ConsoleHeader() {
7368
7465
  window.addEventListener("scroll", handleScroll);
7369
7466
  return () => window.removeEventListener("scroll", handleScroll);
7370
7467
  }, []);
7371
- const { appLightLogo, appDarkLogo } = chunkQN6HLQ67_cjs.useLogo();
7468
+ const { appLightLogo, appDarkLogo } = chunkHBVSAOTQ_cjs.useLogo();
7372
7469
  return /* @__PURE__ */ jsxRuntime.jsx(
7373
7470
  "div",
7374
7471
  {
@@ -7547,7 +7644,7 @@ var EnvironmentCard = ({
7547
7644
  className
7548
7645
  }) => {
7549
7646
  const { setSelectedProject, setTenantGroup } = chunk6GCU5LM7_cjs.useProjectStore();
7550
- const { mutateAsync } = chunkQN6HLQ67_cjs.useStartImpersonation();
7647
+ const { mutateAsync } = chunkHBVSAOTQ_cjs.useStartImpersonation();
7551
7648
  const navigate = reactRouter.useNavigate();
7552
7649
  const handleCardClick = async () => {
7553
7650
  try {
@@ -7601,11 +7698,11 @@ function EnvironmentList({
7601
7698
  }) {
7602
7699
  const navigate = reactRouter.useNavigate();
7603
7700
  const { pathname } = reactRouter.useLocation();
7604
- const { data: projectGroups = [], isLoading } = chunkQN6HLQ67_cjs.useGetProjects({
7701
+ const { data: projectGroups = [], isLoading } = chunkHBVSAOTQ_cjs.useGetProjects({
7605
7702
  enabled: true
7606
7703
  });
7607
7704
  const { selectedProject, setSelectedProject } = chunk6GCU5LM7_cjs.useProjectStore();
7608
- const { data: projectData } = chunkQN6HLQ67_cjs.useGetProject();
7705
+ const { data: projectData } = chunkHBVSAOTQ_cjs.useGetProject();
7609
7706
  const pendingProjectRef = React8.useRef(null);
7610
7707
  const redirectRegexMap = React8.useMemo(
7611
7708
  () => Object.entries(redirectPaths).reduce(
@@ -7769,7 +7866,7 @@ function AuthResolver({ children }) {
7769
7866
  hasResolved.current = true;
7770
7867
  async function resolve() {
7771
7868
  try {
7772
- const res = await chunk4QKE3WAW_cjs.iamClient.get(`${chunk4QKE3WAW_cjs.AUTH_ENDPOINTS.ME}`);
7869
+ const res = await chunkVAWEXEJZ_cjs.iamClient.get(`${chunkVAWEXEJZ_cjs.AUTH_ENDPOINTS.ME}`);
7773
7870
  setUser(res);
7774
7871
  setAuthenticated();
7775
7872
  } catch {
@@ -7849,10 +7946,46 @@ var AppLoadingSpinner = ({ size = 64 }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRu
7849
7946
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-background fixed inset-0 z-50 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-breathe", children: /* @__PURE__ */ jsxRuntime.jsx(BlocksIcon, { size }) }) })
7850
7947
  ] });
7851
7948
  var projectNameFor = (projects, tenantId) => tenantId && projects.find((p) => p.tenantId === tenantId)?.name || null;
7949
+ var claimKeyOf = (claim) => claim ? `${claim.tabId}|${claim.tenantId}|${claim.ts}` : null;
7950
+ var useLiveOwnerProbe = ({
7951
+ cookieTenantId,
7952
+ ownTenantId,
7953
+ onHeldElsewhere
7954
+ }) => {
7955
+ const foreignClaim = React8.useMemo(() => {
7956
+ if (!cookieTenantId || !ownTenantId || cookieTenantId === ownTenantId) {
7957
+ return null;
7958
+ }
7959
+ const owner = chunkVAWEXEJZ_cjs.readCurrentOwner();
7960
+ return owner && owner.tabId !== chunkVAWEXEJZ_cjs.TAB_ID && owner.tenantId === cookieTenantId ? owner : null;
7961
+ }, [cookieTenantId, ownTenantId]);
7962
+ const claimKey = claimKeyOf(foreignClaim);
7963
+ const [probedKey, setProbedKey] = React8.useState(null);
7964
+ const foreignClaimRef = React8.useRef(foreignClaim);
7965
+ const onHeldElsewhereRef = React8.useRef(onHeldElsewhere);
7966
+ foreignClaimRef.current = foreignClaim;
7967
+ onHeldElsewhereRef.current = onHeldElsewhere;
7968
+ React8.useEffect(() => {
7969
+ const claim = foreignClaimRef.current;
7970
+ if (!claim || !claimKey) return;
7971
+ let cancelled = false;
7972
+ void chunkVAWEXEJZ_cjs.isTenantHeldElsewhere(claim.tenantId).then((held) => {
7973
+ if (cancelled) return;
7974
+ if (held && chunkVAWEXEJZ_cjs.isSameClaim(chunkVAWEXEJZ_cjs.readCurrentOwner(), claim)) {
7975
+ onHeldElsewhereRef.current(claim.tenantId);
7976
+ }
7977
+ setProbedKey(claimKey);
7978
+ });
7979
+ return () => {
7980
+ cancelled = true;
7981
+ };
7982
+ }, [claimKey]);
7983
+ return !!claimKey && probedKey !== claimKey;
7984
+ };
7852
7985
  var ImpersonationChecker = ({
7853
7986
  children
7854
7987
  }) => {
7855
- const { data, isLoading, isSuccess } = chunkQN6HLQ67_cjs.useImpersonationStatusChecker();
7988
+ const { data, isLoading, isSuccess } = chunkHBVSAOTQ_cjs.useImpersonationStatusChecker();
7856
7989
  const { setImpersonation, isInitialized, setInitialized } = chunk4QN4CYSC_cjs.useImpersonateStore();
7857
7990
  React8.useEffect(() => {
7858
7991
  if (!data) return;
@@ -7904,32 +8037,41 @@ function ImpersonationTerminator({
7904
8037
  const {
7905
8038
  terminate,
7906
8039
  isImpersonated,
8040
+ impersonatedTenantId,
7907
8041
  detachedReason,
7908
8042
  detachedTenantId,
7909
8043
  setDetached
7910
8044
  } = chunk4QN4CYSC_cjs.useImpersonateStore();
7911
- const { mutateAsync } = chunkQN6HLQ67_cjs.useStopImpersonation();
8045
+ const { mutateAsync } = chunkHBVSAOTQ_cjs.useStopImpersonation();
8046
+ const recordClaimedTenant = chunkHBVSAOTQ_cjs.useRecordClaimedTenant();
7912
8047
  const { projects } = chunk6GCU5LM7_cjs.useProjectStore();
7913
8048
  const isTriggering = React8.useRef(false);
7914
8049
  const [isTerminating, setIsTerminating] = React8.useState(false);
7915
8050
  const rootTenantId = window.process?.env.BLOCKS_X_BLOCKS_KEY || "";
8051
+ const isProbingOwner = useLiveOwnerProbe({
8052
+ cookieTenantId: isImpersonated ? impersonatedTenantId : null,
8053
+ ownTenantId: rootTenantId || null,
8054
+ onHeldElsewhere: (tenantId) => setDetached("another-project", tenantId)
8055
+ });
7916
8056
  React8.useEffect(() => {
7917
8057
  if (!rootTenantId) return;
7918
- const owner = chunk4QKE3WAW_cjs.readCurrentOwner();
7919
- if (owner && owner.tabId !== chunk4QKE3WAW_cjs.TAB_ID && owner.tenantId !== rootTenantId) {
7920
- setDetached("another-project", owner.tenantId);
7921
- }
7922
- return chunk4QKE3WAW_cjs.subscribeToTenantClaims((claim) => {
8058
+ return chunkVAWEXEJZ_cjs.subscribeToTenantClaims((claim) => {
8059
+ recordClaimedTenant(claim.tenantId, rootTenantId);
7923
8060
  if (claim.tenantId === rootTenantId) {
7924
8061
  setDetached(null);
7925
8062
  return;
7926
8063
  }
7927
8064
  setDetached("another-project", claim.tenantId);
7928
8065
  });
7929
- }, [rootTenantId, setDetached]);
8066
+ }, [rootTenantId, setDetached, recordClaimedTenant]);
8067
+ const isDetached = detachedReason === "another-project";
8068
+ React8.useEffect(() => {
8069
+ if (detachedReason === "console") setDetached(null);
8070
+ }, [detachedReason, setDetached]);
7930
8071
  React8.useEffect(() => {
7931
8072
  if (isTriggering.current || !isImpersonated) return;
7932
- if (detachedReason) return;
8073
+ if (isDetached) return;
8074
+ if (isProbingOwner) return;
7933
8075
  isTriggering.current = true;
7934
8076
  setIsTerminating(true);
7935
8077
  const stopImpersonation = async () => {
@@ -7944,14 +8086,21 @@ function ImpersonationTerminator({
7944
8086
  sessionIsRootScoped = error instanceof chunkX4YCRWXO_cjs.HttpError && error.status === 401;
7945
8087
  } finally {
7946
8088
  terminate(rootTenantId);
7947
- if (sessionIsRootScoped && rootTenantId) chunk4QKE3WAW_cjs.claimTenant(rootTenantId);
8089
+ if (sessionIsRootScoped && rootTenantId) chunkVAWEXEJZ_cjs.claimTenant(rootTenantId);
7948
8090
  isTriggering.current = false;
7949
8091
  setIsTerminating(false);
7950
8092
  }
7951
8093
  };
7952
8094
  void stopImpersonation();
7953
- }, [mutateAsync, terminate, isImpersonated, detachedReason, rootTenantId]);
7954
- if (detachedReason) {
8095
+ }, [
8096
+ mutateAsync,
8097
+ terminate,
8098
+ isImpersonated,
8099
+ isDetached,
8100
+ isProbingOwner,
8101
+ rootTenantId
8102
+ ]);
8103
+ if (isDetached) {
7955
8104
  const name = projectNameFor(projects, detachedTenantId);
7956
8105
  return /* @__PURE__ */ jsxRuntime.jsx(
7957
8106
  ImpersonationBlocked,
@@ -7982,8 +8131,9 @@ function ImpersonationSynchronizer({
7982
8131
  setImpersonationError,
7983
8132
  setDetached
7984
8133
  } = chunk4QN4CYSC_cjs.useImpersonateStore();
7985
- const { mutateAsync } = chunkQN6HLQ67_cjs.useStartImpersonation();
7986
- const { data: _data } = chunkQN6HLQ67_cjs.useGetProjects({ enabled: true });
8134
+ const { mutateAsync } = chunkHBVSAOTQ_cjs.useStartImpersonation();
8135
+ const recordClaimedTenant = chunkHBVSAOTQ_cjs.useRecordClaimedTenant();
8136
+ const { data: _data } = chunkHBVSAOTQ_cjs.useGetProjects({ enabled: true });
7987
8137
  const { selectedProject, setSelectedProject, projects, setTenantGroup } = chunk6GCU5LM7_cjs.useProjectStore();
7988
8138
  const isTriggering = React8.useRef(false);
7989
8139
  const [isImpersonating, setIsImpersonating] = React8.useState(false);
@@ -8018,7 +8168,7 @@ function ImpersonationSynchronizer({
8018
8168
  ]);
8019
8169
  const getImpersonatedProject = async () => {
8020
8170
  try {
8021
- const res = chunkQN6HLQ67_cjs.projectService.getProject();
8171
+ const res = chunkHBVSAOTQ_cjs.projectService.getProject();
8022
8172
  return (await res).data;
8023
8173
  } catch (error) {
8024
8174
  console.error("Error fetching projects:", error);
@@ -8067,15 +8217,23 @@ function ImpersonationSynchronizer({
8067
8217
  setDetached(null);
8068
8218
  void runImpersonation();
8069
8219
  }, [runImpersonation, setImpersonationError, setDetached]);
8220
+ const detachedHere = detachedReason === "another-project" && detachedTenantId === routeTenantId ? null : detachedReason;
8070
8221
  React8.useEffect(() => {
8071
- const owner = chunk4QKE3WAW_cjs.readCurrentOwner();
8072
- if (owner && owner.tabId !== chunk4QKE3WAW_cjs.TAB_ID && routeTenantId && owner.tenantId !== routeTenantId) {
8073
- setDetached(
8074
- owner.tenantId === rootTenantId ? "console" : "another-project",
8075
- owner.tenantId
8076
- );
8077
- }
8078
- return chunk4QKE3WAW_cjs.subscribeToTenantClaims((claim) => {
8222
+ if (detachedReason && detachedReason !== detachedHere) setDetached(null);
8223
+ }, [detachedReason, detachedHere, setDetached]);
8224
+ const isProbingOwner = useLiveOwnerProbe({
8225
+ cookieTenantId: impersonatedTenantId,
8226
+ ownTenantId: routeTenantId,
8227
+ onHeldElsewhere: (tenantId) => setDetached("another-project", tenantId)
8228
+ });
8229
+ const isAttached = !!routeTenantId && routeTenantId === impersonatedTenantId && !detachedHere && !impersonationError && !isProbingOwner;
8230
+ React8.useEffect(() => {
8231
+ if (!isAttached || !routeTenantId) return;
8232
+ return chunkVAWEXEJZ_cjs.holdTenant(routeTenantId);
8233
+ }, [isAttached, routeTenantId]);
8234
+ React8.useEffect(() => {
8235
+ return chunkVAWEXEJZ_cjs.subscribeToTenantClaims((claim) => {
8236
+ recordClaimedTenant(claim.tenantId, rootTenantId);
8079
8237
  const mine = routeTenantIdRef.current;
8080
8238
  if (!mine) return;
8081
8239
  if (claim.tenantId === mine) {
@@ -8087,11 +8245,12 @@ function ImpersonationSynchronizer({
8087
8245
  claim.tenantId
8088
8246
  );
8089
8247
  });
8090
- }, [routeTenantId, rootTenantId, setDetached]);
8248
+ }, [routeTenantId, rootTenantId, setDetached, recordClaimedTenant]);
8091
8249
  React8.useEffect(() => {
8092
8250
  if (!itemId) return;
8093
8251
  if (isTriggering.current) return;
8094
- if (impersonationError || detachedReason) return;
8252
+ if (impersonationError || detachedHere) return;
8253
+ if (isProbingOwner) return;
8095
8254
  const needsColdStart = !routeTenantId && !!impersonatedTenantId && !selectedProject;
8096
8255
  const needsRetarget = !!routeTenantId && routeTenantId !== impersonatedTenantId;
8097
8256
  if (!needsColdStart && !needsRetarget) return;
@@ -8102,7 +8261,8 @@ function ImpersonationSynchronizer({
8102
8261
  impersonatedTenantId,
8103
8262
  selectedProject,
8104
8263
  impersonationError,
8105
- detachedReason,
8264
+ detachedHere,
8265
+ isProbingOwner,
8106
8266
  runImpersonation
8107
8267
  ]);
8108
8268
  const thisProjectName = projectNameFor(projects, routeTenantId);
@@ -8118,6 +8278,14 @@ function ImpersonationSynchronizer({
8118
8278
  if (!isImpersonated || isTriggering.current) return null;
8119
8279
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
8120
8280
  }
8281
+ if (isProbingOwner && !detachedHere) {
8282
+ return /* @__PURE__ */ jsxRuntime.jsx(
8283
+ ImpersonationWaiting,
8284
+ {
8285
+ label: thisProjectName ? `Opening ${thisProjectName}\u2026` : "Opening project\u2026"
8286
+ }
8287
+ );
8288
+ }
8121
8289
  if (impersonationError) {
8122
8290
  const accessDenied = impersonationError instanceof chunkX4YCRWXO_cjs.HttpError && impersonationError.status === 403;
8123
8291
  return accessDenied ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -8138,7 +8306,7 @@ function ImpersonationSynchronizer({
8138
8306
  }
8139
8307
  );
8140
8308
  }
8141
- if (detachedReason === "console") {
8309
+ if (detachedHere === "console") {
8142
8310
  return /* @__PURE__ */ jsxRuntime.jsx(
8143
8311
  ImpersonationBlocked,
8144
8312
  {
@@ -8150,7 +8318,7 @@ function ImpersonationSynchronizer({
8150
8318
  }
8151
8319
  );
8152
8320
  }
8153
- if (detachedReason === "another-project") {
8321
+ if (detachedHere === "another-project") {
8154
8322
  const otherName = projectNameFor(projects, detachedTenantId);
8155
8323
  return /* @__PURE__ */ jsxRuntime.jsx(
8156
8324
  ImpersonationBlocked,
@@ -8281,7 +8449,7 @@ var LoginHeader = ({
8281
8449
  }) => {
8282
8450
  const {
8283
8451
  config: { appLogoUrl }
8284
- } = chunkQN6HLQ67_cjs.useBlocksAppConfigStore((state) => state);
8452
+ } = chunkHBVSAOTQ_cjs.useBlocksAppConfigStore((state) => state);
8285
8453
  const resolveLogo = (variant) => {
8286
8454
  if (!appLogoUrl) return void 0;
8287
8455
  if (typeof appLogoUrl === "string") return appLogoUrl;
@@ -9546,10 +9714,10 @@ var BlocksLoginPage = ({
9546
9714
  ] });
9547
9715
  };
9548
9716
  var LoginPage = () => {
9549
- const config = chunkQN6HLQ67_cjs.useBlocksAppConfigStore((state) => state.getConfig());
9550
- const { start, isLoading } = chunkQN6HLQ67_cjs.useLogin();
9551
- const { canSignUp } = chunkQN6HLQ67_cjs.useSignUpAffordance();
9552
- const { start: startSignUp, isLoading: isSignUpLoading } = chunkQN6HLQ67_cjs.useSignUpRedirect();
9717
+ const config = chunkHBVSAOTQ_cjs.useBlocksAppConfigStore((state) => state.getConfig());
9718
+ const { start, isLoading } = chunkHBVSAOTQ_cjs.useLogin();
9719
+ const { canSignUp } = chunkHBVSAOTQ_cjs.useSignUpAffordance();
9720
+ const { start: startSignUp, isLoading: isSignUpLoading } = chunkHBVSAOTQ_cjs.useSignUpRedirect();
9553
9721
  return /* @__PURE__ */ jsxRuntime.jsx(
9554
9722
  BlocksLoginPage,
9555
9723
  {
@@ -9664,10 +9832,10 @@ var BentoCard = ({
9664
9832
  );
9665
9833
  var DefaultDoc = () => /* @__PURE__ */ jsxRuntime.jsx(BentoGrid, { children: resources.map((resource) => /* @__PURE__ */ jsxRuntime.jsx(BentoCard, { ...resource }, resource.url)) });
9666
9834
  function useCreateProjectRedirect() {
9667
- const { name } = chunkQN6HLQ67_cjs.useBlocksAppConfigStore((state) => state.config);
9835
+ const { name } = chunkHBVSAOTQ_cjs.useBlocksAppConfigStore((state) => state.config);
9668
9836
  const navigate = reactRouter.useNavigate();
9669
9837
  const osApp = filteredAppSwitcherData.find((app) => app.id === "blocks-os");
9670
- const { isFetching, isReady, redirect } = chunkQN6HLQ67_cjs.usePrefetchRedirect({
9838
+ const { isFetching, isReady, redirect } = chunkHBVSAOTQ_cjs.usePrefetchRedirect({
9671
9839
  clientId: osApp ? chunkX4YCRWXO_cjs.getRuntimeEnv(osApp.clientId) : "",
9672
9840
  redirectUri: osApp ? chunkX4YCRWXO_cjs.getRuntimeEnv(osApp.redirectUri) : "",
9673
9841
  forwardedTo: "/app/create-project",
@@ -9759,10 +9927,10 @@ function useProjectOverviewRedirect({
9759
9927
  tenantGroupId
9760
9928
  }) {
9761
9929
  const navigate = reactRouter.useNavigate();
9762
- const { name } = chunkQN6HLQ67_cjs.useBlocksAppConfigStore((state) => state.config);
9930
+ const { name } = chunkHBVSAOTQ_cjs.useBlocksAppConfigStore((state) => state.config);
9763
9931
  const osApp = filteredAppSwitcherData.find((app) => app.id === "blocks-os");
9764
9932
  const redirectedRoute = `/app/project/${tenantGroupId}/environments`;
9765
- const { isFetching, isReady, redirect } = chunkQN6HLQ67_cjs.usePrefetchRedirect({
9933
+ const { isFetching, isReady, redirect } = chunkHBVSAOTQ_cjs.usePrefetchRedirect({
9766
9934
  clientId: osApp ? chunkX4YCRWXO_cjs.getRuntimeEnv(osApp.clientId) : "",
9767
9935
  redirectUri: osApp ? chunkX4YCRWXO_cjs.getRuntimeEnv(osApp.redirectUri) : "",
9768
9936
  forwardedTo: redirectedRoute,
@@ -10122,7 +10290,7 @@ function MultiSelect2({
10122
10290
  onChange,
10123
10291
  value: selectedValues
10124
10292
  }) {
10125
- const [buttonRef, popoverWidth] = chunkQN6HLQ67_cjs.usePopoverWidth();
10293
+ const [buttonRef, popoverWidth] = chunkHBVSAOTQ_cjs.usePopoverWidth();
10126
10294
  const onSelectHandler = (value) => {
10127
10295
  const nextValues = selectedValues.includes(value) ? selectedValues.filter((item) => item !== value) : [...selectedValues, value];
10128
10296
  onChange(nextValues);
@@ -10403,7 +10571,7 @@ var useProjectListState = (projectGroups) => {
10403
10571
  })),
10404
10572
  [projectGroups]
10405
10573
  );
10406
- const searchedGroups = chunkQN6HLQ67_cjs.useDebouncedFuseFilter(
10574
+ const searchedGroups = chunkHBVSAOTQ_cjs.useDebouncedFuseFilter(
10407
10575
  searchableGroups,
10408
10576
  searchText,
10409
10577
  SEARCH_OPTIONS
@@ -10473,7 +10641,7 @@ var SelfProjectLoading = ({ viewMode }) => {
10473
10641
  ) });
10474
10642
  };
10475
10643
  var SelfProject = ({ canCreateProject = false }) => {
10476
- const { data, isLoading, isFetching } = chunkQN6HLQ67_cjs.useGetProjects({ enabled: true });
10644
+ const { data, isLoading, isFetching } = chunkHBVSAOTQ_cjs.useGetProjects({ enabled: true });
10477
10645
  const isPending = isLoading || isFetching;
10478
10646
  const projectGroups = data || [];
10479
10647
  const {
@@ -10594,6 +10762,16 @@ var ConsolePage = ({ canCreateProject = false }) => {
10594
10762
  ] })
10595
10763
  ] });
10596
10764
  };
10765
+ var toSafeAppPath = (value) => {
10766
+ if (!value || !value.startsWith("/")) return null;
10767
+ try {
10768
+ const target = new URL(value, window.location.origin);
10769
+ if (target.origin !== window.location.origin) return null;
10770
+ return target.href;
10771
+ } catch {
10772
+ return null;
10773
+ }
10774
+ };
10597
10775
  var CallbackPage = ({ defaultRedirectUrl }) => {
10598
10776
  const [searchParams] = reactRouter.useSearchParams();
10599
10777
  const hasProcessed = React8.useRef(false);
@@ -10609,7 +10787,7 @@ var CallbackPage = ({ defaultRedirectUrl }) => {
10609
10787
  const idpBaseUrl = window.process?.env.userBaseUrl;
10610
10788
  const callbackUrl = new URL(`${idpBaseUrl}/api/idp/callback`);
10611
10789
  const tenantId = window.process?.env.BLOCKS_X_BLOCKS_KEY;
10612
- const appRedirectUrl = forwardTo || defaultRedirectUrl || "/";
10790
+ const appRedirectUrl = toSafeAppPath(forwardTo) || defaultRedirectUrl || "/";
10613
10791
  if (code) callbackUrl.searchParams.set("code", code);
10614
10792
  if (state) callbackUrl.searchParams.set("state", state);
10615
10793
  if (error) callbackUrl.searchParams.set("error", error);
@@ -10632,7 +10810,7 @@ var CallbackPage = ({ defaultRedirectUrl }) => {
10632
10810
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-h-screen items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader, { className: "h-12 w-12 animate-spin text-gray-500" }) });
10633
10811
  };
10634
10812
  function ProfilePage() {
10635
- const { isLoading, error } = chunkQN6HLQ67_cjs.useInitiateRedirect({
10813
+ const { isLoading, error } = chunkHBVSAOTQ_cjs.useInitiateRedirect({
10636
10814
  clientId: chunkX4YCRWXO_cjs.getRuntimeEnv("BLOCKS_IAM_CLIENT_ID"),
10637
10815
  redirectUri: chunkX4YCRWXO_cjs.getRuntimeEnv("BLOCKS_IAM_CALLBACK_URL"),
10638
10816
  forwardedTo: "/app/profile"
@@ -10910,8 +11088,8 @@ var ConfirmationModal = ({
10910
11088
  ] })
10911
11089
  ] });
10912
11090
  var DashboardOverview = () => {
10913
- const { name } = chunkQN6HLQ67_cjs.useBlocksAppConfigStore((state) => state.config);
10914
- const { data, isFetching } = chunkQN6HLQ67_cjs.useGetProject();
11091
+ const { name } = chunkHBVSAOTQ_cjs.useBlocksAppConfigStore((state) => state.config);
11092
+ const { data, isFetching } = chunkHBVSAOTQ_cjs.useGetProject();
10915
11093
  const {
10916
11094
  endpoints,
10917
11095
  isLoading: isLoadingEndpoints,
@@ -11005,11 +11183,11 @@ function ProjectList2({
11005
11183
  }) {
11006
11184
  const navigate = reactRouter.useNavigate();
11007
11185
  const { pathname } = reactRouter.useLocation();
11008
- const { data: projectGroups = [], isLoading } = chunkQN6HLQ67_cjs.useGetProjects({
11186
+ const { data: projectGroups = [], isLoading } = chunkHBVSAOTQ_cjs.useGetProjects({
11009
11187
  enabled: true
11010
11188
  });
11011
11189
  const { selectedProject, setSelectedProject } = chunk6GCU5LM7_cjs.useProjectStore();
11012
- const { data: projectData } = chunkQN6HLQ67_cjs.useGetProject();
11190
+ const { data: projectData } = chunkHBVSAOTQ_cjs.useGetProject();
11013
11191
  const pendingProjectRef = React8.useRef(null);
11014
11192
  const redirectRegexMap = React8.useMemo(
11015
11193
  () => Object.entries(redirectPaths).reduce(
@@ -11158,7 +11336,7 @@ var SetCustomDomainDialog = ({
11158
11336
  projectKey,
11159
11337
  projectEnv
11160
11338
  }) => {
11161
- const { mutateAsync, isPending } = chunkQN6HLQ67_cjs.useUpdateRepositories();
11339
+ const { mutateAsync, isPending } = chunkHBVSAOTQ_cjs.useUpdateRepositories();
11162
11340
  const verifiedDomains = React8.useMemo(
11163
11341
  () => Array.from(
11164
11342
  new Set(domains.filter((d) => d.isDomainVerified).map((d) => d.domain))
@@ -11342,7 +11520,7 @@ var ProjectRepoList = ({
11342
11520
  data: envRepositoriesResponse,
11343
11521
  isLoading: isLoadingEnvRepos,
11344
11522
  isFetching: isFetchingEnvRepos
11345
- } = chunkQN6HLQ67_cjs.useGetEnvRepositories(project?.tenantId || "");
11523
+ } = chunkHBVSAOTQ_cjs.useGetEnvRepositories(project?.tenantId || "");
11346
11524
  if (isLoading || isLoadingEnvRepos || isFetchingEnvRepos) {
11347
11525
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-6 rounded-lg border bg-card px-2 py-2 shadow-sm md:mt-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid-col-1 grid gap-3 px-2 py-4 md:grid-cols-2 md:gap-4 lg:gap-6", children: ["sk-1", "sk-2", "sk-3", "sk-4", "sk-5", "sk-6"].map((itemKey) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11348
11526
  /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-5 w-1/2" }),
@@ -11442,7 +11620,7 @@ var EditProjectForm = ({
11442
11620
  onAfterSubmit
11443
11621
  }) => {
11444
11622
  const queryClient = reactQuery.useQueryClient();
11445
- const { mutateAsync, isPending } = chunkQN6HLQ67_cjs.useUpdateTenantGroup();
11623
+ const { mutateAsync, isPending } = chunkHBVSAOTQ_cjs.useUpdateTenantGroup();
11446
11624
  const form = reactHookForm.useForm({
11447
11625
  resolver: zod$1.zodResolver(editProjectFormSchema),
11448
11626
  defaultValues: {
@@ -11578,7 +11756,7 @@ function SidebarMobileView({
11578
11756
  navigationMenus
11579
11757
  }) {
11580
11758
  const [open, setOpen] = React8.useState(false);
11581
- const { appLightLogo, appDarkLogo } = chunkQN6HLQ67_cjs.useLogo();
11759
+ const { appLightLogo, appDarkLogo } = chunkHBVSAOTQ_cjs.useLogo();
11582
11760
  const allowedMenu = chunkBPJM3L7O_cjs.useFilteredMenus(navigationMenus);
11583
11761
  return /* @__PURE__ */ jsxRuntime.jsxs(Sheet, { open, onOpenChange: setOpen, children: [
11584
11762
  /* @__PURE__ */ jsxRuntime.jsx(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", size: "icon", className: "shrink-0", children: [
@@ -11628,8 +11806,8 @@ function SidebarMenuDesktop({
11628
11806
  navigationMenus
11629
11807
  }) {
11630
11808
  const { isSidebarOpen, toggleSidebar } = React8.useContext(chunkIJMKS4XG_cjs.SidebarContext);
11631
- const { appLightLogo, appDarkLogo } = chunkQN6HLQ67_cjs.useLogo();
11632
- const icon = chunkQN6HLQ67_cjs.useIcon();
11809
+ const { appLightLogo, appDarkLogo } = chunkHBVSAOTQ_cjs.useLogo();
11810
+ const icon = chunkHBVSAOTQ_cjs.useIcon();
11633
11811
  const allowedMenu = chunkBPJM3L7O_cjs.useFilteredMenus(navigationMenus);
11634
11812
  const { isActivePath: isProjectOverviewRoute } = chunkBPJM3L7O_cjs.useIsActiveMenu("/app/project");
11635
11813
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -11758,7 +11936,7 @@ var ErrorBoundary = class extends React8.Component {
11758
11936
  var ArchiveProject = () => {
11759
11937
  const navigate = reactRouter.useNavigate();
11760
11938
  const projectKey = chunk6GCU5LM7_cjs.useProjectStore().selectedProject?.tenantId || "";
11761
- const { mutateAsync, isPending } = chunkQN6HLQ67_cjs.useDisableProject({ projectKey });
11939
+ const { mutateAsync, isPending } = chunkHBVSAOTQ_cjs.useDisableProject({ projectKey });
11762
11940
  const onClickHandler = async () => {
11763
11941
  try {
11764
11942
  const res = await mutateAsync();
@@ -12728,7 +12906,7 @@ var ClearButton = ({ onClear }) => {
12728
12906
  };
12729
12907
  function Radio({ label, options, onChange, value }) {
12730
12908
  const [search, setSearch] = React8.useState("");
12731
- const [buttonRef, popoverWidth] = chunkQN6HLQ67_cjs.usePopoverWidth();
12909
+ const [buttonRef, popoverWidth] = chunkHBVSAOTQ_cjs.usePopoverWidth();
12732
12910
  const isMobile = chunkBPJM3L7O_cjs.useIsMobile();
12733
12911
  const selected = React8.useMemo(
12734
12912
  () => options.find((item) => item.value === value) || null,
@@ -13737,5 +13915,5 @@ exports.usePaginationQueryParams = usePaginationQueryParams;
13737
13915
  exports.useRightSidePanel = useRightSidePanel;
13738
13916
  exports.useSortQueryParams = useSortQueryParams;
13739
13917
  exports.useWizardStepper = useWizardStepper;
13740
- //# sourceMappingURL=chunk-GACXFCNQ.cjs.map
13741
- //# sourceMappingURL=chunk-GACXFCNQ.cjs.map
13918
+ //# sourceMappingURL=chunk-GFGUKRBD.cjs.map
13919
+ //# sourceMappingURL=chunk-GFGUKRBD.cjs.map