@almadar/ui 2.20.1 → 2.20.6

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 (39) hide show
  1. package/LICENSE +72 -21
  2. package/dist/avl/index.cjs +1345 -1323
  3. package/dist/avl/index.d.cts +47 -47
  4. package/dist/avl/index.js +1321 -1299
  5. package/dist/components/atoms/avl/Avl3DLabel.d.ts +23 -0
  6. package/dist/components/atoms/avl/Avl3DTooltip.d.ts +25 -0
  7. package/dist/components/atoms/avl/index.d.ts +2 -0
  8. package/dist/components/index.cjs +3 -1
  9. package/dist/components/index.js +3 -1
  10. package/dist/components/molecules/avl/Avl3DCrossWire.d.ts +22 -0
  11. package/dist/components/molecules/avl/Avl3DEntityCore.d.ts +26 -0
  12. package/dist/components/molecules/avl/Avl3DExprTree.d.ts +21 -0
  13. package/dist/components/molecules/avl/Avl3DOrbitalNode.d.ts +29 -0
  14. package/dist/components/molecules/avl/Avl3DStateNode.d.ts +34 -0
  15. package/dist/components/molecules/avl/Avl3DTransitionArc.d.ts +38 -0
  16. package/dist/components/molecules/avl/index.d.ts +6 -0
  17. package/dist/components/organisms/avl/Avl3DApplicationScene.d.ts +19 -0
  18. package/dist/components/organisms/avl/Avl3DEffects.d.ts +18 -0
  19. package/dist/components/organisms/avl/Avl3DOrbitalScene.d.ts +23 -0
  20. package/dist/components/organisms/avl/Avl3DTraitScene.d.ts +19 -0
  21. package/dist/components/organisms/avl/Avl3DTransitionScene.d.ts +17 -0
  22. package/dist/components/organisms/avl/Avl3DViewer.d.ts +40 -0
  23. package/dist/components/organisms/avl/avl-3d-context.d.ts +32 -0
  24. package/dist/components/organisms/avl/avl-3d-layout.d.ts +116 -0
  25. package/dist/components/organisms/game/three/index.cjs +2549 -120
  26. package/dist/components/organisms/game/three/index.d.ts +8 -0
  27. package/dist/components/organisms/game/three/index.js +2419 -5
  28. package/dist/illustrations/index.cjs +2880 -109
  29. package/dist/illustrations/index.js +2879 -108
  30. package/dist/providers/OrbitalProvider.d.ts +4 -2
  31. package/dist/providers/index.cjs +263 -284
  32. package/dist/providers/index.js +189 -210
  33. package/dist/runtime/OrbPreview.d.ts +9 -6
  34. package/dist/runtime/ServerBridge.d.ts +23 -0
  35. package/dist/runtime/enrichFromResponse.d.ts +21 -0
  36. package/dist/runtime/index.cjs +31754 -2587
  37. package/dist/runtime/index.d.ts +2 -0
  38. package/dist/runtime/index.js +31735 -2571
  39. package/package.json +5 -2
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React110 = require('react');
3
+ var React108 = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var providers = require('@almadar/ui/providers');
6
6
  require('react-dom');
@@ -41,7 +41,7 @@ function _interopNamespace(e) {
41
41
  return Object.freeze(n);
42
42
  }
43
43
 
44
- var React110__namespace = /*#__PURE__*/_interopNamespace(React110);
44
+ var React108__namespace = /*#__PURE__*/_interopNamespace(React108);
45
45
  var LucideIcons__namespace = /*#__PURE__*/_interopNamespace(LucideIcons);
46
46
  var L__default = /*#__PURE__*/_interopDefault(L);
47
47
  var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
@@ -153,7 +153,7 @@ var BUILT_IN_THEMES = [
153
153
  hasDarkMode: true
154
154
  }
155
155
  ];
156
- var ThemeContext = React110.createContext(void 0);
156
+ var ThemeContext = React108.createContext(void 0);
157
157
  var THEME_STORAGE_KEY = "theme";
158
158
  var MODE_STORAGE_KEY = "theme-mode";
159
159
  function getSystemMode() {
@@ -173,14 +173,14 @@ var ThemeProvider = ({
173
173
  defaultMode = "system",
174
174
  targetRef
175
175
  }) => {
176
- const availableThemes = React110.useMemo(() => {
176
+ const availableThemes = React108.useMemo(() => {
177
177
  const themeMap = /* @__PURE__ */ new Map();
178
178
  BUILT_IN_THEMES.forEach((t) => themeMap.set(t.name, t));
179
179
  themes.forEach((t) => themeMap.set(t.name, t));
180
180
  return Array.from(themeMap.values());
181
181
  }, [themes]);
182
182
  const isScoped = !!targetRef;
183
- const [theme, setThemeState] = React110.useState(() => {
183
+ const [theme, setThemeState] = React108.useState(() => {
184
184
  if (isScoped || typeof window === "undefined") return defaultTheme;
185
185
  const stored = localStorage.getItem(THEME_STORAGE_KEY);
186
186
  const validThemes = [
@@ -192,7 +192,7 @@ var ThemeProvider = ({
192
192
  }
193
193
  return defaultTheme;
194
194
  });
195
- const [mode, setModeState] = React110.useState(() => {
195
+ const [mode, setModeState] = React108.useState(() => {
196
196
  if (isScoped || typeof window === "undefined") return defaultMode;
197
197
  const stored = localStorage.getItem(MODE_STORAGE_KEY);
198
198
  if (stored === "light" || stored === "dark" || stored === "system") {
@@ -200,14 +200,14 @@ var ThemeProvider = ({
200
200
  }
201
201
  return defaultMode;
202
202
  });
203
- const [resolvedMode, setResolvedMode] = React110.useState(
203
+ const [resolvedMode, setResolvedMode] = React108.useState(
204
204
  () => resolveMode(mode)
205
205
  );
206
- const appliedTheme = React110.useMemo(
206
+ const appliedTheme = React108.useMemo(
207
207
  () => `${theme}-${resolvedMode}`,
208
208
  [theme, resolvedMode]
209
209
  );
210
- React110.useEffect(() => {
210
+ React108.useEffect(() => {
211
211
  const updateResolved = () => {
212
212
  setResolvedMode(resolveMode(mode));
213
213
  };
@@ -220,7 +220,7 @@ var ThemeProvider = ({
220
220
  }
221
221
  return void 0;
222
222
  }, [mode]);
223
- React110.useEffect(() => {
223
+ React108.useEffect(() => {
224
224
  if (isScoped) {
225
225
  if (targetRef?.current) {
226
226
  targetRef.current.setAttribute("data-theme", appliedTheme);
@@ -234,7 +234,7 @@ var ThemeProvider = ({
234
234
  root.classList.remove("light", "dark");
235
235
  root.classList.add(resolvedMode);
236
236
  }, [appliedTheme, resolvedMode, targetRef, isScoped]);
237
- const setTheme = React110.useCallback(
237
+ const setTheme = React108.useCallback(
238
238
  (newTheme) => {
239
239
  const validTheme = availableThemes.find((t) => t.name === newTheme);
240
240
  if (validTheme) {
@@ -250,17 +250,17 @@ var ThemeProvider = ({
250
250
  },
251
251
  [availableThemes]
252
252
  );
253
- const setMode = React110.useCallback((newMode) => {
253
+ const setMode = React108.useCallback((newMode) => {
254
254
  setModeState(newMode);
255
255
  if (!isScoped && typeof window !== "undefined") {
256
256
  localStorage.setItem(MODE_STORAGE_KEY, newMode);
257
257
  }
258
258
  }, []);
259
- const toggleMode = React110.useCallback(() => {
259
+ const toggleMode = React108.useCallback(() => {
260
260
  const newMode = resolvedMode === "dark" ? "light" : "dark";
261
261
  setMode(newMode);
262
262
  }, [resolvedMode, setMode]);
263
- const contextValue = React110.useMemo(
263
+ const contextValue = React108.useMemo(
264
264
  () => ({
265
265
  theme,
266
266
  mode,
@@ -356,15 +356,15 @@ var fallbackEventBus = {
356
356
  }
357
357
  };
358
358
  function useEventBus() {
359
- const context = React110.useContext(providers.EventBusContext);
359
+ const context = React108.useContext(providers.EventBusContext);
360
360
  return context ?? getGlobalEventBus() ?? fallbackEventBus;
361
361
  }
362
- var EventBusContext2 = React110.createContext(null);
362
+ var EventBusContext2 = React108.createContext(null);
363
363
  function EventBusProvider({ children, debug: debug2 = false }) {
364
- const listenersRef = React110.useRef(/* @__PURE__ */ new Map());
365
- const anyListenersRef = React110.useRef(/* @__PURE__ */ new Set());
366
- const deprecationWarningShown = React110.useRef(false);
367
- const getSelectedEntity = React110.useCallback(() => {
364
+ const listenersRef = React108.useRef(/* @__PURE__ */ new Map());
365
+ const anyListenersRef = React108.useRef(/* @__PURE__ */ new Set());
366
+ const deprecationWarningShown = React108.useRef(false);
367
+ const getSelectedEntity = React108.useCallback(() => {
368
368
  if (!deprecationWarningShown.current) {
369
369
  console.warn(
370
370
  "[EventBus] getSelectedEntity is deprecated. Use SelectionProvider and useSelection hook instead. See SelectionProvider.tsx for migration guide."
@@ -373,7 +373,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
373
373
  }
374
374
  return null;
375
375
  }, []);
376
- const clearSelectedEntity = React110.useCallback(() => {
376
+ const clearSelectedEntity = React108.useCallback(() => {
377
377
  if (!deprecationWarningShown.current) {
378
378
  console.warn(
379
379
  "[EventBus] clearSelectedEntity is deprecated. Use SelectionProvider and useSelection hook instead. See SelectionProvider.tsx for migration guide."
@@ -381,7 +381,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
381
381
  deprecationWarningShown.current = true;
382
382
  }
383
383
  }, []);
384
- const emit = React110.useCallback((type, payload) => {
384
+ const emit = React108.useCallback((type, payload) => {
385
385
  const event = {
386
386
  type,
387
387
  payload,
@@ -415,7 +415,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
415
415
  }
416
416
  }
417
417
  }, [debug2]);
418
- const on = React110.useCallback((type, listener) => {
418
+ const on = React108.useCallback((type, listener) => {
419
419
  if (!listenersRef.current.has(type)) {
420
420
  listenersRef.current.set(type, /* @__PURE__ */ new Set());
421
421
  }
@@ -434,18 +434,18 @@ function EventBusProvider({ children, debug: debug2 = false }) {
434
434
  }
435
435
  };
436
436
  }, [debug2]);
437
- const once = React110.useCallback((type, listener) => {
437
+ const once = React108.useCallback((type, listener) => {
438
438
  const wrappedListener = (event) => {
439
439
  listenersRef.current.get(type)?.delete(wrappedListener);
440
440
  listener(event);
441
441
  };
442
442
  return on(type, wrappedListener);
443
443
  }, [on]);
444
- const hasListeners = React110.useCallback((type) => {
444
+ const hasListeners = React108.useCallback((type) => {
445
445
  const listeners7 = listenersRef.current.get(type);
446
446
  return listeners7 !== void 0 && listeners7.size > 0;
447
447
  }, []);
448
- const onAny = React110.useCallback((listener) => {
448
+ const onAny = React108.useCallback((listener) => {
449
449
  anyListenersRef.current.add(listener);
450
450
  if (debug2) {
451
451
  console.log(`[EventBus] onAny subscribed, total: ${anyListenersRef.current.size}`);
@@ -457,7 +457,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
457
457
  }
458
458
  };
459
459
  }, [debug2]);
460
- const contextValue = React110.useMemo(
460
+ const contextValue = React108.useMemo(
461
461
  () => ({
462
462
  emit,
463
463
  on,
@@ -469,7 +469,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
469
469
  }),
470
470
  [emit, on, once, hasListeners, onAny, getSelectedEntity, clearSelectedEntity]
471
471
  );
472
- React110.useEffect(() => {
472
+ React108.useEffect(() => {
473
473
  setGlobalEventBus(contextValue);
474
474
  return () => {
475
475
  setGlobalEventBus(null);
@@ -477,7 +477,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
477
477
  }, [contextValue]);
478
478
  return /* @__PURE__ */ jsxRuntime.jsx(EventBusContext2.Provider, { value: contextValue, children });
479
479
  }
480
- var SelectionContext = React110.createContext(null);
480
+ var SelectionContext = React108.createContext(null);
481
481
  var defaultCompareEntities = (a, b) => {
482
482
  if (a === b) return true;
483
483
  if (!a || !b) return false;
@@ -494,8 +494,8 @@ function SelectionProvider({
494
494
  compareEntities = defaultCompareEntities
495
495
  }) {
496
496
  const eventBus = useEventBus();
497
- const [selected, setSelectedState] = React110.useState(null);
498
- const setSelected = React110.useCallback(
497
+ const [selected, setSelectedState] = React108.useState(null);
498
+ const setSelected = React108.useCallback(
499
499
  (entity) => {
500
500
  setSelectedState(entity);
501
501
  if (debug2) {
@@ -504,19 +504,19 @@ function SelectionProvider({
504
504
  },
505
505
  [debug2]
506
506
  );
507
- const clearSelection = React110.useCallback(() => {
507
+ const clearSelection = React108.useCallback(() => {
508
508
  setSelectedState(null);
509
509
  if (debug2) {
510
510
  console.log("[SelectionProvider] Selection cleared");
511
511
  }
512
512
  }, [debug2]);
513
- const isSelected = React110.useCallback(
513
+ const isSelected = React108.useCallback(
514
514
  (entity) => {
515
515
  return compareEntities(selected, entity);
516
516
  },
517
517
  [selected, compareEntities]
518
518
  );
519
- React110.useEffect(() => {
519
+ React108.useEffect(() => {
520
520
  const handleSelect = (event) => {
521
521
  const row = event.payload?.row;
522
522
  if (row) {
@@ -554,182 +554,16 @@ function SelectionProvider({
554
554
  return /* @__PURE__ */ jsxRuntime.jsx(SelectionContext.Provider, { value: contextValue, children });
555
555
  }
556
556
  function useSelection() {
557
- const context = React110.useContext(SelectionContext);
557
+ const context = React108.useContext(SelectionContext);
558
558
  if (!context) {
559
559
  throw new Error("useSelection must be used within a SelectionProvider");
560
560
  }
561
561
  return context;
562
562
  }
563
563
  function useSelectionOptional() {
564
- const context = React110.useContext(SelectionContext);
564
+ const context = React108.useContext(SelectionContext);
565
565
  return context;
566
566
  }
567
- var FetchedDataContext = React110.createContext(null);
568
- function FetchedDataProvider({
569
- initialData,
570
- children
571
- }) {
572
- const [state, setState] = React110.useState(() => ({
573
- data: initialData || {},
574
- fetchedAt: {},
575
- loading: false,
576
- error: null
577
- }));
578
- const getData = React110.useCallback(
579
- (entityName) => {
580
- return state.data[entityName] || [];
581
- },
582
- [state.data]
583
- );
584
- const getById = React110.useCallback(
585
- (entityName, id) => {
586
- const records = state.data[entityName];
587
- return records?.find((r) => r.id === id);
588
- },
589
- [state.data]
590
- );
591
- const hasData = React110.useCallback(
592
- (entityName) => {
593
- return entityName in state.data && state.data[entityName].length > 0;
594
- },
595
- [state.data]
596
- );
597
- const getFetchedAt = React110.useCallback(
598
- (entityName) => {
599
- return state.fetchedAt[entityName];
600
- },
601
- [state.fetchedAt]
602
- );
603
- const setData = React110.useCallback((data) => {
604
- const now = Date.now();
605
- setState((prev) => ({
606
- ...prev,
607
- data: {
608
- ...prev.data,
609
- ...data
610
- },
611
- fetchedAt: {
612
- ...prev.fetchedAt,
613
- ...Object.keys(data).reduce(
614
- (acc, key) => ({ ...acc, [key]: now }),
615
- {}
616
- )
617
- },
618
- loading: false,
619
- error: null
620
- }));
621
- }, []);
622
- const clearData = React110.useCallback(() => {
623
- setState((prev) => ({
624
- ...prev,
625
- data: {},
626
- fetchedAt: {}
627
- }));
628
- }, []);
629
- const clearEntity = React110.useCallback((entityName) => {
630
- setState((prev) => {
631
- const newData = { ...prev.data };
632
- const newFetchedAt = { ...prev.fetchedAt };
633
- delete newData[entityName];
634
- delete newFetchedAt[entityName];
635
- return {
636
- ...prev,
637
- data: newData,
638
- fetchedAt: newFetchedAt
639
- };
640
- });
641
- }, []);
642
- const setLoading = React110.useCallback((loading) => {
643
- setState((prev) => ({ ...prev, loading }));
644
- }, []);
645
- const setError = React110.useCallback((error) => {
646
- setState((prev) => ({ ...prev, error, loading: false }));
647
- }, []);
648
- const contextValue = React110.useMemo(
649
- () => ({
650
- getData,
651
- getById,
652
- hasData,
653
- getFetchedAt,
654
- setData,
655
- clearData,
656
- clearEntity,
657
- loading: state.loading,
658
- setLoading,
659
- error: state.error,
660
- setError
661
- }),
662
- [
663
- getData,
664
- getById,
665
- hasData,
666
- getFetchedAt,
667
- setData,
668
- clearData,
669
- clearEntity,
670
- state.loading,
671
- setLoading,
672
- state.error,
673
- setError
674
- ]
675
- );
676
- return /* @__PURE__ */ jsxRuntime.jsx(FetchedDataContext.Provider, { value: contextValue, children });
677
- }
678
- function useFetchedDataContext() {
679
- return React110.useContext(FetchedDataContext);
680
- }
681
- function useFetchedData() {
682
- const context = React110.useContext(FetchedDataContext);
683
- if (!context) {
684
- return {
685
- getData: () => [],
686
- getById: () => void 0,
687
- hasData: () => false,
688
- getFetchedAt: () => void 0,
689
- setData: () => {
690
- },
691
- clearData: () => {
692
- },
693
- clearEntity: () => {
694
- },
695
- loading: false,
696
- setLoading: () => {
697
- },
698
- error: null,
699
- setError: () => {
700
- }
701
- };
702
- }
703
- return context;
704
- }
705
- function useFetchedEntity(entityName) {
706
- const context = useFetchedData();
707
- return {
708
- /** All fetched records for this entity */
709
- records: context.getData(entityName),
710
- /** Get a record by ID */
711
- getById: (id) => context.getById(entityName, id),
712
- /** Whether data has been fetched for this entity */
713
- hasData: context.hasData(entityName),
714
- /** When data was last fetched */
715
- fetchedAt: context.getFetchedAt(entityName),
716
- /** Whether data is loading */
717
- loading: context.loading,
718
- /** Current error */
719
- error: context.error
720
- };
721
- }
722
- var EntityDataContext = React110.createContext(null);
723
- function EntityDataProvider({
724
- adapter,
725
- children
726
- }) {
727
- return React110__namespace.default.createElement(
728
- EntityDataContext.Provider,
729
- { value: adapter },
730
- children
731
- );
732
- }
733
567
  function cn(...inputs) {
734
568
  return tailwindMerge.twMerge(clsx.clsx(inputs));
735
569
  }
@@ -870,7 +704,7 @@ var positionStyles = {
870
704
  fixed: "fixed",
871
705
  sticky: "sticky"
872
706
  };
873
- var Box = React110__namespace.default.forwardRef(
707
+ var Box = React108__namespace.default.forwardRef(
874
708
  ({
875
709
  padding,
876
710
  paddingX,
@@ -899,20 +733,20 @@ var Box = React110__namespace.default.forwardRef(
899
733
  ...rest
900
734
  }, ref) => {
901
735
  const eventBus = useEventBus();
902
- const handleClick = React110.useCallback((e) => {
736
+ const handleClick = React108.useCallback((e) => {
903
737
  if (action) {
904
738
  e.stopPropagation();
905
739
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
906
740
  }
907
741
  onClick?.(e);
908
742
  }, [action, actionPayload, eventBus, onClick]);
909
- const handleMouseEnter = React110.useCallback((e) => {
743
+ const handleMouseEnter = React108.useCallback((e) => {
910
744
  if (hoverEvent) {
911
745
  eventBus.emit(`UI:${hoverEvent}`, { hovered: true });
912
746
  }
913
747
  onMouseEnter?.(e);
914
748
  }, [hoverEvent, eventBus, onMouseEnter]);
915
- const handleMouseLeave = React110.useCallback((e) => {
749
+ const handleMouseLeave = React108.useCallback((e) => {
916
750
  if (hoverEvent) {
917
751
  eventBus.emit(`UI:${hoverEvent}`, { hovered: false });
918
752
  }
@@ -1140,7 +974,7 @@ function resolveIconProp(value, sizeClass) {
1140
974
  const IconComp = value;
1141
975
  return /* @__PURE__ */ jsxRuntime.jsx(IconComp, { className: sizeClass });
1142
976
  }
1143
- if (React110__namespace.default.isValidElement(value)) {
977
+ if (React108__namespace.default.isValidElement(value)) {
1144
978
  return value;
1145
979
  }
1146
980
  if (typeof value === "object" && value !== null && "render" in value) {
@@ -1149,7 +983,7 @@ function resolveIconProp(value, sizeClass) {
1149
983
  }
1150
984
  return value;
1151
985
  }
1152
- var Button = React110__namespace.default.forwardRef(
986
+ var Button = React108__namespace.default.forwardRef(
1153
987
  ({
1154
988
  className,
1155
989
  variant = "primary",
@@ -1244,7 +1078,7 @@ var sizeStyles3 = {
1244
1078
  md: "px-2.5 py-1 text-sm",
1245
1079
  lg: "px-3 py-1.5 text-base"
1246
1080
  };
1247
- var Badge = React110__namespace.default.forwardRef(
1081
+ var Badge = React108__namespace.default.forwardRef(
1248
1082
  ({ className, variant = "default", size = "sm", amount, label, icon, children, ...props }, ref) => {
1249
1083
  const iconSizes2 = { sm: "w-3 h-3", md: "w-3.5 h-3.5", lg: "w-4 h-4" };
1250
1084
  const resolvedIcon = typeof icon === "string" ? (() => {
@@ -1271,7 +1105,7 @@ var Badge = React110__namespace.default.forwardRef(
1271
1105
  }
1272
1106
  );
1273
1107
  Badge.displayName = "Badge";
1274
- var Input = React110__namespace.default.forwardRef(
1108
+ var Input = React108__namespace.default.forwardRef(
1275
1109
  ({
1276
1110
  className,
1277
1111
  inputType,
@@ -1383,7 +1217,7 @@ var Input = React110__namespace.default.forwardRef(
1383
1217
  }
1384
1218
  );
1385
1219
  Input.displayName = "Input";
1386
- var Label = React110__namespace.default.forwardRef(
1220
+ var Label = React108__namespace.default.forwardRef(
1387
1221
  ({ className, required, children, ...props }, ref) => {
1388
1222
  return /* @__PURE__ */ jsxRuntime.jsxs(
1389
1223
  "label",
@@ -1403,7 +1237,7 @@ var Label = React110__namespace.default.forwardRef(
1403
1237
  }
1404
1238
  );
1405
1239
  Label.displayName = "Label";
1406
- var Textarea = React110__namespace.default.forwardRef(
1240
+ var Textarea = React108__namespace.default.forwardRef(
1407
1241
  ({ className, error, ...props }, ref) => {
1408
1242
  return /* @__PURE__ */ jsxRuntime.jsx(
1409
1243
  "textarea",
@@ -1426,7 +1260,7 @@ var Textarea = React110__namespace.default.forwardRef(
1426
1260
  }
1427
1261
  );
1428
1262
  Textarea.displayName = "Textarea";
1429
- var Select = React110__namespace.default.forwardRef(
1263
+ var Select = React108__namespace.default.forwardRef(
1430
1264
  ({ className, options, placeholder, error, ...props }, ref) => {
1431
1265
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
1432
1266
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1462,7 +1296,7 @@ var Select = React110__namespace.default.forwardRef(
1462
1296
  }
1463
1297
  );
1464
1298
  Select.displayName = "Select";
1465
- var Checkbox = React110__namespace.default.forwardRef(
1299
+ var Checkbox = React108__namespace.default.forwardRef(
1466
1300
  ({ className, label, id, ...props }, ref) => {
1467
1301
  const inputId = id || `checkbox-${Math.random().toString(36).substr(2, 9)}`;
1468
1302
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
@@ -1536,7 +1370,7 @@ var shadowStyles2 = {
1536
1370
  md: "shadow-[var(--shadow-main)]",
1537
1371
  lg: "shadow-[var(--shadow-lg)]"
1538
1372
  };
1539
- var Card = React110__namespace.default.forwardRef(
1373
+ var Card = React108__namespace.default.forwardRef(
1540
1374
  ({
1541
1375
  className,
1542
1376
  variant = "bordered",
@@ -1572,9 +1406,9 @@ var Card = React110__namespace.default.forwardRef(
1572
1406
  }
1573
1407
  );
1574
1408
  Card.displayName = "Card";
1575
- var CardHeader = React110__namespace.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("mb-4", className), ...props }));
1409
+ var CardHeader = React108__namespace.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("mb-4", className), ...props }));
1576
1410
  CardHeader.displayName = "CardHeader";
1577
- var CardTitle = React110__namespace.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1411
+ var CardTitle = React108__namespace.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1578
1412
  "h3",
1579
1413
  {
1580
1414
  ref,
@@ -1587,11 +1421,11 @@ var CardTitle = React110__namespace.default.forwardRef(({ className, ...props },
1587
1421
  }
1588
1422
  ));
1589
1423
  CardTitle.displayName = "CardTitle";
1590
- var CardContent = React110__namespace.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("", className), ...props }));
1424
+ var CardContent = React108__namespace.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("", className), ...props }));
1591
1425
  CardContent.displayName = "CardContent";
1592
1426
  var CardBody = CardContent;
1593
1427
  CardBody.displayName = "CardBody";
1594
- var CardFooter = React110__namespace.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1428
+ var CardFooter = React108__namespace.default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1595
1429
  "div",
1596
1430
  {
1597
1431
  ref,
@@ -1606,7 +1440,7 @@ var sizeStyles4 = {
1606
1440
  md: "h-6 w-6",
1607
1441
  lg: "h-8 w-8"
1608
1442
  };
1609
- var Spinner = React110__namespace.default.forwardRef(
1443
+ var Spinner = React108__namespace.default.forwardRef(
1610
1444
  ({ className, size = "md", ...props }, ref) => {
1611
1445
  return /* @__PURE__ */ jsxRuntime.jsx(
1612
1446
  "div",
@@ -1620,7 +1454,7 @@ var Spinner = React110__namespace.default.forwardRef(
1620
1454
  }
1621
1455
  );
1622
1456
  Spinner.displayName = "Spinner";
1623
- var Radio = React110__namespace.default.forwardRef(
1457
+ var Radio = React108__namespace.default.forwardRef(
1624
1458
  ({
1625
1459
  label,
1626
1460
  helperText,
@@ -1724,7 +1558,7 @@ var Radio = React110__namespace.default.forwardRef(
1724
1558
  }
1725
1559
  );
1726
1560
  Radio.displayName = "Radio";
1727
- var Switch = React110__namespace.forwardRef(
1561
+ var Switch = React108__namespace.forwardRef(
1728
1562
  ({
1729
1563
  checked,
1730
1564
  defaultChecked = false,
@@ -1735,10 +1569,10 @@ var Switch = React110__namespace.forwardRef(
1735
1569
  name,
1736
1570
  className
1737
1571
  }, ref) => {
1738
- const [isChecked, setIsChecked] = React110__namespace.useState(
1572
+ const [isChecked, setIsChecked] = React108__namespace.useState(
1739
1573
  checked !== void 0 ? checked : defaultChecked
1740
1574
  );
1741
- React110__namespace.useEffect(() => {
1575
+ React108__namespace.useEffect(() => {
1742
1576
  if (checked !== void 0) {
1743
1577
  setIsChecked(checked);
1744
1578
  }
@@ -1896,7 +1730,7 @@ var sizeStyles5 = {
1896
1730
  md: "w-2.5 h-2.5",
1897
1731
  lg: "w-3 h-3"
1898
1732
  };
1899
- var StatusDot = React110__namespace.default.forwardRef(
1733
+ var StatusDot = React108__namespace.default.forwardRef(
1900
1734
  ({ className, status = "offline", pulse = false, size = "md", label, ...props }, ref) => {
1901
1735
  return /* @__PURE__ */ jsxRuntime.jsx(
1902
1736
  "span",
@@ -1943,7 +1777,7 @@ var iconMap2 = {
1943
1777
  down: LucideIcons.TrendingDown,
1944
1778
  flat: LucideIcons.ArrowRight
1945
1779
  };
1946
- var TrendIndicator = React110__namespace.default.forwardRef(
1780
+ var TrendIndicator = React108__namespace.default.forwardRef(
1947
1781
  ({
1948
1782
  className,
1949
1783
  value,
@@ -2002,7 +1836,7 @@ var thumbSizes = {
2002
1836
  md: "w-4 h-4",
2003
1837
  lg: "w-5 h-5"
2004
1838
  };
2005
- var RangeSlider = React110__namespace.default.forwardRef(
1839
+ var RangeSlider = React108__namespace.default.forwardRef(
2006
1840
  ({
2007
1841
  className,
2008
1842
  min = 0,
@@ -2020,14 +1854,14 @@ var RangeSlider = React110__namespace.default.forwardRef(
2020
1854
  formatValue: formatValue5,
2021
1855
  ...props
2022
1856
  }, ref) => {
2023
- const [isDragging, setIsDragging] = React110.useState(false);
2024
- const [showTip, setShowTip] = React110.useState(false);
2025
- const inputRef = React110.useRef(null);
1857
+ const [isDragging, setIsDragging] = React108.useState(false);
1858
+ const [showTip, setShowTip] = React108.useState(false);
1859
+ const inputRef = React108.useRef(null);
2026
1860
  const eventBus = useSafeEventBus();
2027
1861
  const percentage = max !== min ? (value - min) / (max - min) * 100 : 0;
2028
1862
  const bufferedPercentage = buffered !== void 0 ? Math.min(buffered, 100) : void 0;
2029
1863
  const displayValue = formatValue5 ? formatValue5(value) : String(value);
2030
- const handleChange = React110.useCallback(
1864
+ const handleChange = React108.useCallback(
2031
1865
  (e) => {
2032
1866
  const newValue = Number(e.target.value);
2033
1867
  onChange?.(newValue);
@@ -2205,7 +2039,7 @@ var paddingClasses = {
2205
2039
  md: "py-16",
2206
2040
  lg: "py-24"
2207
2041
  };
2208
- var ContentSection = React110__namespace.default.forwardRef(
2042
+ var ContentSection = React108__namespace.default.forwardRef(
2209
2043
  ({ children, background = "default", padding = "lg", id, className }, ref) => {
2210
2044
  return /* @__PURE__ */ jsxRuntime.jsx(
2211
2045
  Box,
@@ -2334,7 +2168,7 @@ var en_default = {
2334
2168
  // hooks/useTranslate.ts
2335
2169
  var { $meta: _meta, ...coreMessages } = en_default;
2336
2170
  var coreLocale = coreMessages;
2337
- var I18nContext = React110.createContext({
2171
+ var I18nContext = React108.createContext({
2338
2172
  locale: "en",
2339
2173
  direction: "ltr",
2340
2174
  t: (key) => coreLocale[key] ?? key
@@ -2343,7 +2177,7 @@ var I18nContext = React110.createContext({
2343
2177
  I18nContext.displayName = "I18nContext";
2344
2178
  I18nContext.Provider;
2345
2179
  function useTranslate() {
2346
- return React110.useContext(I18nContext);
2180
+ return React108.useContext(I18nContext);
2347
2181
  }
2348
2182
  var ErrorState = ({
2349
2183
  title,
@@ -2379,7 +2213,7 @@ var ErrorState = ({
2379
2213
  );
2380
2214
  };
2381
2215
  ErrorState.displayName = "ErrorState";
2382
- var ErrorBoundary = class extends React110__namespace.default.Component {
2216
+ var ErrorBoundary = class extends React108__namespace.default.Component {
2383
2217
  constructor(props) {
2384
2218
  super(props);
2385
2219
  __publicField(this, "reset", () => {
@@ -2478,7 +2312,7 @@ function executeNotify(message, options, config) {
2478
2312
  function executeEmit(event, payload, config) {
2479
2313
  config.eventBus.emit(event, payload);
2480
2314
  }
2481
- var ClientEffectConfigContext = React110.createContext(null);
2315
+ var ClientEffectConfigContext = React108.createContext(null);
2482
2316
  ClientEffectConfigContext.Provider;
2483
2317
  var effectIdCounter = 0;
2484
2318
  function generateEffectId() {
@@ -2717,14 +2551,14 @@ var OfflineExecutor = class {
2717
2551
  }
2718
2552
  };
2719
2553
  function useOfflineExecutor(options) {
2720
- const executorRef = React110.useRef(null);
2721
- const [state, setState] = React110.useState({
2554
+ const executorRef = React108.useRef(null);
2555
+ const [state, setState] = React108.useState({
2722
2556
  isOffline: false,
2723
2557
  syncQueue: [],
2724
2558
  localEffectsProcessed: 0,
2725
2559
  effectsSynced: 0
2726
2560
  });
2727
- React110.useEffect(() => {
2561
+ React108.useEffect(() => {
2728
2562
  const executor = new OfflineExecutor({
2729
2563
  ...options,
2730
2564
  onQueueChange: (queue) => {
@@ -2739,7 +2573,7 @@ function useOfflineExecutor(options) {
2739
2573
  executorRef.current = null;
2740
2574
  };
2741
2575
  }, []);
2742
- React110.useEffect(() => {
2576
+ React108.useEffect(() => {
2743
2577
  if (!options.autoSync || !options.serverUrl) return;
2744
2578
  const handleOnline = async () => {
2745
2579
  if (executorRef.current) {
@@ -2753,13 +2587,13 @@ function useOfflineExecutor(options) {
2753
2587
  window.addEventListener("online", handleOnline);
2754
2588
  return () => window.removeEventListener("online", handleOnline);
2755
2589
  }, [options.autoSync, options.serverUrl, options.authToken]);
2756
- const executeEffects = React110.useCallback((effects) => {
2590
+ const executeEffects = React108.useCallback((effects) => {
2757
2591
  executorRef.current?.executeClientEffects(effects);
2758
2592
  if (executorRef.current) {
2759
2593
  setState(executorRef.current.getState());
2760
2594
  }
2761
2595
  }, []);
2762
- const processEventOffline = React110.useCallback(
2596
+ const processEventOffline = React108.useCallback(
2763
2597
  (event, payload, effects) => {
2764
2598
  const result = executorRef.current?.processEventOffline(event, payload, effects);
2765
2599
  if (executorRef.current) {
@@ -2769,7 +2603,7 @@ function useOfflineExecutor(options) {
2769
2603
  },
2770
2604
  []
2771
2605
  );
2772
- const sync = React110.useCallback(async () => {
2606
+ const sync = React108.useCallback(async () => {
2773
2607
  if (!executorRef.current || !options.serverUrl) return 0;
2774
2608
  const count = await executorRef.current.syncPendingEffects(
2775
2609
  options.serverUrl,
@@ -2778,7 +2612,7 @@ function useOfflineExecutor(options) {
2778
2612
  setState(executorRef.current.getState());
2779
2613
  return count;
2780
2614
  }, [options.serverUrl, options.authToken]);
2781
- const clearQueue = React110.useCallback(() => {
2615
+ const clearQueue = React108.useCallback(() => {
2782
2616
  executorRef.current?.clearQueue();
2783
2617
  if (executorRef.current) {
2784
2618
  setState(executorRef.current.getState());
@@ -2794,7 +2628,7 @@ function useOfflineExecutor(options) {
2794
2628
  clearQueue
2795
2629
  };
2796
2630
  }
2797
- React110.createContext(null);
2631
+ React108.createContext(null);
2798
2632
  var defaultIcon = L__default.default.icon({
2799
2633
  iconUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png",
2800
2634
  iconRetinaUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png",
@@ -2959,7 +2793,7 @@ function bindTraitStateGetter(getter) {
2959
2793
  }
2960
2794
  }
2961
2795
  exposeOnWindow();
2962
- var MarkdownContent = React110__namespace.default.memo(
2796
+ var MarkdownContent = React108__namespace.default.memo(
2963
2797
  ({ content, direction, className }) => {
2964
2798
  const { t: _t } = useTranslate();
2965
2799
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -3060,7 +2894,7 @@ var MarkdownContent = React110__namespace.default.memo(
3060
2894
  (prev, next) => prev.content === next.content && prev.className === next.className && prev.direction === next.direction
3061
2895
  );
3062
2896
  MarkdownContent.displayName = "MarkdownContent";
3063
- var CodeBlock = React110__namespace.default.memo(
2897
+ var CodeBlock = React108__namespace.default.memo(
3064
2898
  ({
3065
2899
  code,
3066
2900
  language = "text",
@@ -3071,20 +2905,20 @@ var CodeBlock = React110__namespace.default.memo(
3071
2905
  }) => {
3072
2906
  const eventBus = useEventBus();
3073
2907
  const { t: _t } = useTranslate();
3074
- const scrollRef = React110.useRef(null);
3075
- const savedScrollLeftRef = React110.useRef(0);
3076
- const [copied, setCopied] = React110.useState(false);
3077
- React110.useLayoutEffect(() => {
2908
+ const scrollRef = React108.useRef(null);
2909
+ const savedScrollLeftRef = React108.useRef(0);
2910
+ const [copied, setCopied] = React108.useState(false);
2911
+ React108.useLayoutEffect(() => {
3078
2912
  const el = scrollRef.current;
3079
2913
  return () => {
3080
2914
  if (el) savedScrollLeftRef.current = el.scrollLeft;
3081
2915
  };
3082
2916
  }, [language, code]);
3083
- React110.useLayoutEffect(() => {
2917
+ React108.useLayoutEffect(() => {
3084
2918
  const el = scrollRef.current;
3085
2919
  if (el) el.scrollLeft = savedScrollLeftRef.current;
3086
2920
  }, [language, code]);
3087
- React110.useEffect(() => {
2921
+ React108.useEffect(() => {
3088
2922
  const el = scrollRef.current;
3089
2923
  if (!el) return;
3090
2924
  const handle = () => {
@@ -3170,18 +3004,18 @@ CodeBlock.displayName = "CodeBlock";
3170
3004
 
3171
3005
  // lib/debug.ts
3172
3006
  typeof window !== "undefined" && (localStorage.getItem("debug") === "true" || process.env.NODE_ENV === "development");
3173
- React110.lazy(() => import('react-markdown'));
3174
- var GameAudioContext = React110.createContext(null);
3007
+ React108.lazy(() => import('react-markdown'));
3008
+ var GameAudioContext = React108.createContext(null);
3175
3009
  GameAudioContext.displayName = "GameAudioContext";
3176
3010
 
3177
3011
  // components/organisms/component-registry.generated.ts
3178
3012
  function lazyThree(name, loader) {
3179
- const Lazy = React110__namespace.default.lazy(() => loader().then((m) => ({ default: m[name] })));
3013
+ const Lazy = React108__namespace.default.lazy(() => loader().then((m) => ({ default: m[name] })));
3180
3014
  function ThreeWrapper(props) {
3181
- return React110__namespace.default.createElement(
3182
- React110__namespace.default.Suspense,
3015
+ return React108__namespace.default.createElement(
3016
+ React108__namespace.default.Suspense,
3183
3017
  { fallback: null },
3184
- React110__namespace.default.createElement(Lazy, props)
3018
+ React108__namespace.default.createElement(Lazy, props)
3185
3019
  );
3186
3020
  }
3187
3021
  ThreeWrapper.displayName = `Lazy(${name})`;
@@ -3202,13 +3036,13 @@ lazyThree("PhysicsObject3D", () => import('@almadar/ui/components/organisms/game
3202
3036
  lazyThree("Scene3D", () => import('@almadar/ui/components/organisms/game/three'));
3203
3037
  lazyThree("TileRenderer", () => import('@almadar/ui/components/organisms/game/three'));
3204
3038
  lazyThree("UnitRenderer", () => import('@almadar/ui/components/organisms/game/three'));
3205
- var SuspenseConfigContext = React110.createContext({ enabled: false });
3206
- React110.createContext(false);
3039
+ var SuspenseConfigContext = React108.createContext({ enabled: false });
3040
+ React108.createContext(false);
3207
3041
  function SuspenseConfigProvider({
3208
3042
  config,
3209
3043
  children
3210
3044
  }) {
3211
- return React110__namespace.default.createElement(
3045
+ return React108__namespace.default.createElement(
3212
3046
  SuspenseConfigContext.Provider,
3213
3047
  { value: config },
3214
3048
  children
@@ -3253,8 +3087,8 @@ function VerificationProvider({
3253
3087
  }) {
3254
3088
  const isEnabled = enabled ?? (typeof process !== "undefined" && process.env?.NODE_ENV !== "production");
3255
3089
  const eventBus = useEventBus();
3256
- const pendingRef = React110.useRef(/* @__PURE__ */ new Map());
3257
- React110.useEffect(() => {
3090
+ const pendingRef = React108.useRef(/* @__PURE__ */ new Map());
3091
+ React108.useEffect(() => {
3258
3092
  if (!isEnabled) return;
3259
3093
  if (!eventBus.onAny) return;
3260
3094
  const unsub = eventBus.onAny((evt) => {
@@ -3315,7 +3149,7 @@ function VerificationProvider({
3315
3149
  );
3316
3150
  return unsub;
3317
3151
  }, [isEnabled, eventBus]);
3318
- React110.useEffect(() => {
3152
+ React108.useEffect(() => {
3319
3153
  if (!isEnabled) return;
3320
3154
  if (!runtimeManager) return;
3321
3155
  runtimeManager.setObserver({
@@ -3337,11 +3171,11 @@ function VerificationProvider({
3337
3171
  "pass"
3338
3172
  );
3339
3173
  }, [isEnabled, runtimeManager]);
3340
- React110.useEffect(() => {
3174
+ React108.useEffect(() => {
3341
3175
  if (!isEnabled) return;
3342
3176
  bindEventBus(eventBus);
3343
3177
  }, [isEnabled, eventBus]);
3344
- React110.useEffect(() => {
3178
+ React108.useEffect(() => {
3345
3179
  if (!isEnabled) return;
3346
3180
  if (traitStateGetter) {
3347
3181
  bindTraitStateGetter(traitStateGetter);
@@ -3353,16 +3187,6 @@ function VerificationProvider({
3353
3187
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
3354
3188
  }
3355
3189
  VerificationProvider.displayName = "VerificationProvider";
3356
- function FetchedDataBridge({ children }) {
3357
- const fetchedData = useFetchedData();
3358
- const adapter = React110.useMemo(() => ({
3359
- getData: (entity) => fetchedData.getData(entity),
3360
- getById: (entity, id) => fetchedData.getById(entity, id),
3361
- isLoading: fetchedData.loading,
3362
- error: fetchedData.error
3363
- }), [fetchedData.getData, fetchedData.getById, fetchedData.loading, fetchedData.error]);
3364
- return /* @__PURE__ */ jsxRuntime.jsx(EntityDataProvider, { adapter, children });
3365
- }
3366
3190
  function OrbitalProvider({
3367
3191
  children,
3368
3192
  themes,
@@ -3375,11 +3199,11 @@ function OrbitalProvider({
3375
3199
  suspense = false,
3376
3200
  verification
3377
3201
  }) {
3378
- const suspenseConfig = React110.useMemo(
3202
+ const suspenseConfig = React108.useMemo(
3379
3203
  () => ({ enabled: suspense }),
3380
3204
  [suspense]
3381
3205
  );
3382
- const inner = /* @__PURE__ */ jsxRuntime.jsx(FetchedDataProvider, { initialData, children: /* @__PURE__ */ jsxRuntime.jsx(FetchedDataBridge, { children: /* @__PURE__ */ jsxRuntime.jsx(EventBusProvider, { debug: debug2, children: /* @__PURE__ */ jsxRuntime.jsx(VerificationProvider, { enabled: verification, children: /* @__PURE__ */ jsxRuntime.jsx(SelectionProvider, { debug: debug2, children: /* @__PURE__ */ jsxRuntime.jsx(SuspenseConfigProvider, { config: suspenseConfig, children }) }) }) }) }) });
3206
+ const inner = /* @__PURE__ */ jsxRuntime.jsx(EventBusProvider, { debug: debug2, children: /* @__PURE__ */ jsxRuntime.jsx(VerificationProvider, { enabled: verification, children: /* @__PURE__ */ jsxRuntime.jsx(SelectionProvider, { debug: debug2, children: /* @__PURE__ */ jsxRuntime.jsx(SuspenseConfigProvider, { config: suspenseConfig, children }) }) }) });
3383
3207
  if (skipTheme) {
3384
3208
  return inner;
3385
3209
  }
@@ -3395,15 +3219,170 @@ function OrbitalProvider({
3395
3219
  );
3396
3220
  }
3397
3221
  OrbitalProvider.displayName = "OrbitalProvider";
3398
- var OfflineModeContext = React110.createContext(null);
3222
+ var FetchedDataContext = React108.createContext(null);
3223
+ function FetchedDataProvider({
3224
+ initialData,
3225
+ children
3226
+ }) {
3227
+ const [state, setState] = React108.useState(() => ({
3228
+ data: initialData || {},
3229
+ fetchedAt: {},
3230
+ loading: false,
3231
+ error: null
3232
+ }));
3233
+ const getData = React108.useCallback(
3234
+ (entityName) => {
3235
+ return state.data[entityName] || [];
3236
+ },
3237
+ [state.data]
3238
+ );
3239
+ const getById = React108.useCallback(
3240
+ (entityName, id) => {
3241
+ const records = state.data[entityName];
3242
+ return records?.find((r) => r.id === id);
3243
+ },
3244
+ [state.data]
3245
+ );
3246
+ const hasData = React108.useCallback(
3247
+ (entityName) => {
3248
+ return entityName in state.data && state.data[entityName].length > 0;
3249
+ },
3250
+ [state.data]
3251
+ );
3252
+ const getFetchedAt = React108.useCallback(
3253
+ (entityName) => {
3254
+ return state.fetchedAt[entityName];
3255
+ },
3256
+ [state.fetchedAt]
3257
+ );
3258
+ const setData = React108.useCallback((data) => {
3259
+ const now = Date.now();
3260
+ setState((prev) => ({
3261
+ ...prev,
3262
+ data: {
3263
+ ...prev.data,
3264
+ ...data
3265
+ },
3266
+ fetchedAt: {
3267
+ ...prev.fetchedAt,
3268
+ ...Object.keys(data).reduce(
3269
+ (acc, key) => ({ ...acc, [key]: now }),
3270
+ {}
3271
+ )
3272
+ },
3273
+ loading: false,
3274
+ error: null
3275
+ }));
3276
+ }, []);
3277
+ const clearData = React108.useCallback(() => {
3278
+ setState((prev) => ({
3279
+ ...prev,
3280
+ data: {},
3281
+ fetchedAt: {}
3282
+ }));
3283
+ }, []);
3284
+ const clearEntity = React108.useCallback((entityName) => {
3285
+ setState((prev) => {
3286
+ const newData = { ...prev.data };
3287
+ const newFetchedAt = { ...prev.fetchedAt };
3288
+ delete newData[entityName];
3289
+ delete newFetchedAt[entityName];
3290
+ return {
3291
+ ...prev,
3292
+ data: newData,
3293
+ fetchedAt: newFetchedAt
3294
+ };
3295
+ });
3296
+ }, []);
3297
+ const setLoading = React108.useCallback((loading) => {
3298
+ setState((prev) => ({ ...prev, loading }));
3299
+ }, []);
3300
+ const setError = React108.useCallback((error) => {
3301
+ setState((prev) => ({ ...prev, error, loading: false }));
3302
+ }, []);
3303
+ const contextValue = React108.useMemo(
3304
+ () => ({
3305
+ getData,
3306
+ getById,
3307
+ hasData,
3308
+ getFetchedAt,
3309
+ setData,
3310
+ clearData,
3311
+ clearEntity,
3312
+ loading: state.loading,
3313
+ setLoading,
3314
+ error: state.error,
3315
+ setError
3316
+ }),
3317
+ [
3318
+ getData,
3319
+ getById,
3320
+ hasData,
3321
+ getFetchedAt,
3322
+ setData,
3323
+ clearData,
3324
+ clearEntity,
3325
+ state.loading,
3326
+ setLoading,
3327
+ state.error,
3328
+ setError
3329
+ ]
3330
+ );
3331
+ return /* @__PURE__ */ jsxRuntime.jsx(FetchedDataContext.Provider, { value: contextValue, children });
3332
+ }
3333
+ function useFetchedDataContext() {
3334
+ return React108.useContext(FetchedDataContext);
3335
+ }
3336
+ function useFetchedData() {
3337
+ const context = React108.useContext(FetchedDataContext);
3338
+ if (!context) {
3339
+ return {
3340
+ getData: () => [],
3341
+ getById: () => void 0,
3342
+ hasData: () => false,
3343
+ getFetchedAt: () => void 0,
3344
+ setData: () => {
3345
+ },
3346
+ clearData: () => {
3347
+ },
3348
+ clearEntity: () => {
3349
+ },
3350
+ loading: false,
3351
+ setLoading: () => {
3352
+ },
3353
+ error: null,
3354
+ setError: () => {
3355
+ }
3356
+ };
3357
+ }
3358
+ return context;
3359
+ }
3360
+ function useFetchedEntity(entityName) {
3361
+ const context = useFetchedData();
3362
+ return {
3363
+ /** All fetched records for this entity */
3364
+ records: context.getData(entityName),
3365
+ /** Get a record by ID */
3366
+ getById: (id) => context.getById(entityName, id),
3367
+ /** Whether data has been fetched for this entity */
3368
+ hasData: context.hasData(entityName),
3369
+ /** When data was last fetched */
3370
+ fetchedAt: context.getFetchedAt(entityName),
3371
+ /** Whether data is loading */
3372
+ loading: context.loading,
3373
+ /** Current error */
3374
+ error: context.error
3375
+ };
3376
+ }
3377
+ var OfflineModeContext = React108.createContext(null);
3399
3378
  function OfflineModeProvider({
3400
3379
  children,
3401
3380
  ...executorOptions
3402
3381
  }) {
3403
- const [forceOffline, setForceOffline] = React110.useState(false);
3382
+ const [forceOffline, setForceOffline] = React108.useState(false);
3404
3383
  const executor = useOfflineExecutor(executorOptions);
3405
3384
  const effectivelyOffline = executor.isOffline || forceOffline;
3406
- const contextValue = React110.useMemo(
3385
+ const contextValue = React108.useMemo(
3407
3386
  () => ({
3408
3387
  ...executor,
3409
3388
  forceOffline,
@@ -3415,14 +3394,14 @@ function OfflineModeProvider({
3415
3394
  return /* @__PURE__ */ jsxRuntime.jsx(OfflineModeContext.Provider, { value: contextValue, children });
3416
3395
  }
3417
3396
  function useOfflineMode() {
3418
- const context = React110.useContext(OfflineModeContext);
3397
+ const context = React108.useContext(OfflineModeContext);
3419
3398
  if (!context) {
3420
3399
  throw new Error("useOfflineMode must be used within OfflineModeProvider");
3421
3400
  }
3422
3401
  return context;
3423
3402
  }
3424
3403
  function useOptionalOfflineMode() {
3425
- return React110.useContext(OfflineModeContext);
3404
+ return React108.useContext(OfflineModeContext);
3426
3405
  }
3427
3406
 
3428
3407
  exports.EventBusContext = EventBusContext2;