@mmapp/react 0.1.0-alpha.18 → 0.1.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/actions-HOXZPBTT.mjs +116 -0
  2. package/dist/actions-MFI2V4DX.mjs +116 -0
  3. package/dist/atoms/index.d.mts +2 -2
  4. package/dist/atoms/index.d.ts +2 -2
  5. package/dist/atoms/index.js +1 -1
  6. package/dist/atoms/index.mjs +1 -1
  7. package/dist/builtin-atoms-C-sNyYJl.d.mts +647 -0
  8. package/dist/builtin-atoms-C-sNyYJl.d.ts +647 -0
  9. package/dist/builtin-atoms-DCKrjG7i.d.mts +96 -0
  10. package/dist/builtin-atoms-DCKrjG7i.d.ts +96 -0
  11. package/dist/builtin-atoms-DRD3EwG6.d.mts +648 -0
  12. package/dist/builtin-atoms-DRD3EwG6.d.ts +648 -0
  13. package/dist/builtin-atoms-jt04b7Rw.d.mts +643 -0
  14. package/dist/builtin-atoms-jt04b7Rw.d.ts +643 -0
  15. package/dist/chunk-247T4GDJ.mjs +677 -0
  16. package/dist/chunk-3H6CR7E7.mjs +1924 -0
  17. package/dist/chunk-3PL6FL6I.mjs +96 -0
  18. package/dist/chunk-3SJSW3C4.mjs +2039 -0
  19. package/dist/chunk-5OI2VI57.mjs +1964 -0
  20. package/dist/chunk-CL6FYZ43.mjs +105 -0
  21. package/dist/chunk-ENQOCZI5.mjs +1938 -0
  22. package/dist/chunk-FB3WCZAU.mjs +512 -0
  23. package/dist/chunk-FBKUGKQI.mjs +1938 -0
  24. package/dist/chunk-GLJ7VC7Z.mjs +684 -0
  25. package/dist/chunk-HHMWR6NA.mjs +504 -0
  26. package/dist/chunk-HULEMSN2.mjs +120 -0
  27. package/dist/chunk-J5MW6CRU.mjs +1938 -0
  28. package/dist/chunk-PNTTKNYU.mjs +677 -0
  29. package/dist/chunk-TY5OTJP4.mjs +684 -0
  30. package/dist/chunk-WV7DVCP6.mjs +513 -0
  31. package/dist/chunk-YFMPTGUF.mjs +677 -0
  32. package/dist/chunk-ZAHMWAER.mjs +1960 -0
  33. package/dist/{chunk-2VJQJM7S.mjs → chunk-ZDWACXZN.mjs} +1 -1
  34. package/dist/composition-BJ6QQTWT.mjs +12 -0
  35. package/dist/composition-XBGKKCI7.mjs +57 -0
  36. package/dist/content-QVPFUG4P.mjs +246 -0
  37. package/dist/control-flow-CBREHWJW.mjs +35 -0
  38. package/dist/control-flow-FWBOI6SM.mjs +35 -0
  39. package/dist/control-flow-ZWUGCDSP.mjs +35 -0
  40. package/dist/data-WCMIZYKD.mjs +97 -0
  41. package/dist/grouping-E6F377VZ.mjs +204 -0
  42. package/dist/grouping-FRPOEXO3.mjs +233 -0
  43. package/dist/index.d.mts +4 -433
  44. package/dist/index.d.ts +4 -433
  45. package/dist/index.js +3671 -582
  46. package/dist/index.mjs +335 -1040
  47. package/dist/input-PUOZDNSI.mjs +222 -0
  48. package/dist/layout-RATDMCLP.mjs +106 -0
  49. package/dist/navigation-VCT7ZBMA.mjs +15 -0
  50. package/dist/navigation-WFV7YWOU.mjs +14 -0
  51. package/dist/player/index.d.mts +37 -11
  52. package/dist/player/index.d.ts +37 -11
  53. package/dist/player/index.js +3321 -193
  54. package/dist/player/index.mjs +55 -5
  55. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -1,3 +1,71 @@
1
+ import {
2
+ Accordion,
3
+ AnimatedBox,
4
+ Badge,
5
+ Button,
6
+ Canvas3D,
7
+ Card,
8
+ Chart,
9
+ Column,
10
+ DataGrid,
11
+ Divider,
12
+ Each,
13
+ Field,
14
+ Grid,
15
+ Heading,
16
+ Icon,
17
+ Image,
18
+ Link,
19
+ Markdown,
20
+ MetricCard,
21
+ Modal,
22
+ NavLink,
23
+ RoleGuard,
24
+ Route,
25
+ Router,
26
+ Row,
27
+ ScrollArea,
28
+ Section,
29
+ Select,
30
+ ServerGrid,
31
+ Show,
32
+ Slot,
33
+ Spacer,
34
+ Stack,
35
+ Tabs,
36
+ Text,
37
+ TextInput
38
+ } from "./chunk-ZDWACXZN.mjs";
39
+ import {
40
+ AtomRegistryImpl,
41
+ ComponentTreeRenderer,
42
+ DevPlayer,
43
+ ExperienceRenderer,
44
+ PlayerProvider,
45
+ buildActionScope,
46
+ buildEvalContext,
47
+ builtinAtoms,
48
+ createApiResolver,
49
+ createCoreAtomRegistry,
50
+ mergeRegistries,
51
+ resolveAllBindings,
52
+ resolveBinding,
53
+ setMutationResolver,
54
+ setQueryResolver,
55
+ useMutation,
56
+ usePlayerContext,
57
+ useQuery
58
+ } from "./chunk-ZAHMWAER.mjs";
59
+ import {
60
+ ScopeContext,
61
+ buildLoopScope,
62
+ buildScope,
63
+ builtinFunctions,
64
+ evaluateExpression,
65
+ mergeScope,
66
+ useScope
67
+ } from "./chunk-WV7DVCP6.mjs";
68
+
1
69
  // src/core/WorkflowRuntime.ts
2
70
  import {
3
71
  StateMachine,
@@ -314,184 +382,19 @@ function useDuringAction(config) {
314
382
  }, [runtime2, intervalMs, immediate, enabled, ...states]);
315
383
  }
316
384
 
317
- // src/hooks/useQuery.ts
318
- import { useState, useEffect as useEffect8, useCallback, useRef as useRef8 } from "react";
319
- var _globalResolver = null;
320
- function setQueryResolver(resolver) {
321
- _globalResolver = resolver;
322
- }
323
- function useQuery(slugOrDef, params = {}) {
324
- const slug = typeof slugOrDef === "string" ? slugOrDef : slugOrDef.slug;
325
- const [data, setData] = useState([]);
326
- const [loading, setLoading] = useState(true);
327
- const [error, setError] = useState(null);
328
- const [total, setTotal] = useState(void 0);
329
- const paramsRef = useRef8(params);
330
- paramsRef.current = params;
331
- const fetchData = useCallback(async () => {
332
- if (paramsRef.current.enabled === false) {
333
- setLoading(false);
334
- return;
335
- }
336
- const resolver = _globalResolver;
337
- if (!resolver) {
338
- setError(new Error(`useQuery: No query resolver configured. Wrap your app in a WorkflowProvider.`));
339
- setLoading(false);
340
- return;
341
- }
342
- try {
343
- setLoading(true);
344
- setError(null);
345
- const result2 = await resolver.query(slug, paramsRef.current);
346
- setData(result2.data);
347
- setTotal(result2.total);
348
- } catch (err) {
349
- setError(err instanceof Error ? err : new Error(String(err)));
350
- } finally {
351
- setLoading(false);
352
- }
353
- }, [slug]);
354
- useEffect8(() => {
355
- fetchData();
356
- }, [fetchData]);
357
- useEffect8(() => {
358
- if (!params.refetchInterval || params.refetchInterval <= 0) return;
359
- const interval = setInterval(fetchData, params.refetchInterval);
360
- return () => clearInterval(interval);
361
- }, [fetchData, params.refetchInterval]);
362
- const hasMore = total !== void 0 && data.length < total;
363
- const result = {
364
- data,
365
- loading,
366
- error,
367
- refetch: fetchData,
368
- total,
369
- hasMore
370
- };
371
- return result;
372
- }
373
-
374
- // src/hooks/useMutation.ts
375
- import { useState as useState2, useCallback as useCallback2, useRef as useRef9 } from "react";
376
- var _globalMutationResolver = null;
377
- function setMutationResolver(resolver) {
378
- _globalMutationResolver = resolver;
379
- }
380
- function useMutation(slugOrDef) {
381
- const slug = typeof slugOrDef === "string" ? slugOrDef : slugOrDef.slug;
382
- const [isPending, setIsPending] = useState2(false);
383
- const [error, setError] = useState2(null);
384
- const slugRef = useRef9(slug);
385
- slugRef.current = slug;
386
- const getResolver = useCallback2(() => {
387
- const resolver = _globalMutationResolver;
388
- if (!resolver) {
389
- throw new Error(`useMutation: No mutation resolver configured. Wrap your app in a WorkflowProvider.`);
390
- }
391
- return resolver;
392
- }, []);
393
- const create = useCallback2(async (input) => {
394
- try {
395
- setIsPending(true);
396
- setError(null);
397
- const resolver = getResolver();
398
- return await resolver.create(slugRef.current, input);
399
- } catch (err) {
400
- const e = err instanceof Error ? err : new Error(String(err));
401
- setError(e);
402
- throw e;
403
- } finally {
404
- setIsPending(false);
405
- }
406
- }, [getResolver]);
407
- const update = useCallback2(async (instanceId, fields) => {
408
- try {
409
- setIsPending(true);
410
- setError(null);
411
- const resolver = getResolver();
412
- await resolver.update(slugRef.current, instanceId, fields);
413
- } catch (err) {
414
- const e = err instanceof Error ? err : new Error(String(err));
415
- setError(e);
416
- throw e;
417
- } finally {
418
- setIsPending(false);
419
- }
420
- }, [getResolver]);
421
- const transitionFn = useCallback2(async (instanceId, transitionName, input) => {
422
- try {
423
- setIsPending(true);
424
- setError(null);
425
- const resolver = getResolver();
426
- await resolver.transition(slugRef.current, instanceId, transitionName, input);
427
- } catch (err) {
428
- const e = err instanceof Error ? err : new Error(String(err));
429
- setError(e);
430
- throw e;
431
- } finally {
432
- setIsPending(false);
433
- }
434
- }, [getResolver]);
435
- const next = useCallback2(async (instanceId, input) => {
436
- try {
437
- setIsPending(true);
438
- setError(null);
439
- const resolver = getResolver();
440
- if (resolver.next) {
441
- await resolver.next(slugRef.current, instanceId, input);
442
- } else {
443
- await resolver.transition(slugRef.current, instanceId, "__next__", input);
444
- }
445
- } catch (err) {
446
- const e = err instanceof Error ? err : new Error(String(err));
447
- setError(e);
448
- throw e;
449
- } finally {
450
- setIsPending(false);
451
- }
452
- }, [getResolver]);
453
- const remove = useCallback2(async (instanceId) => {
454
- try {
455
- setIsPending(true);
456
- setError(null);
457
- const resolver = getResolver();
458
- await resolver.remove(slugRef.current, instanceId);
459
- } catch (err) {
460
- const e = err instanceof Error ? err : new Error(String(err));
461
- setError(e);
462
- throw e;
463
- } finally {
464
- setIsPending(false);
465
- }
466
- }, [getResolver]);
467
- const reset = useCallback2(() => setError(null), []);
468
- const handle = {
469
- create,
470
- update,
471
- transition: transitionFn,
472
- trigger: transitionFn,
473
- next,
474
- remove,
475
- isPending,
476
- error,
477
- reset
478
- };
479
- return handle;
480
- }
481
-
482
385
  // src/hooks/useView.ts
483
- import { useState as useState3, useEffect as useEffect9, useCallback as useCallback3, useRef as useRef10 } from "react";
386
+ import { useState, useEffect as useEffect8, useCallback, useRef as useRef8 } from "react";
484
387
  var _globalViewResolver = null;
485
388
  function setViewResolver(resolver) {
486
389
  _globalViewResolver = resolver;
487
390
  }
488
391
  function useView(idOrSlug) {
489
- const [view, setView] = useState3(null);
490
- const [loading, setLoading] = useState3(!!idOrSlug);
491
- const [error, setError] = useState3(null);
492
- const idRef = useRef10(idOrSlug);
392
+ const [view, setView] = useState(null);
393
+ const [loading, setLoading] = useState(!!idOrSlug);
394
+ const [error, setError] = useState(null);
395
+ const idRef = useRef8(idOrSlug);
493
396
  idRef.current = idOrSlug;
494
- const fetchView = useCallback3(async () => {
397
+ const fetchView = useCallback(async () => {
495
398
  const id = idRef.current;
496
399
  if (!id) {
497
400
  setView(null);
@@ -515,7 +418,7 @@ function useView(idOrSlug) {
515
418
  setLoading(false);
516
419
  }
517
420
  }, []);
518
- useEffect9(() => {
421
+ useEffect8(() => {
519
422
  fetchView();
520
423
  }, [idOrSlug, fetchView]);
521
424
  const result = { view, loading, error, refetch: fetchView };
@@ -523,18 +426,18 @@ function useView(idOrSlug) {
523
426
  }
524
427
 
525
428
  // src/hooks/useExpressionLibrary.ts
526
- import { useState as useState4, useEffect as useEffect10, useCallback as useCallback4, useRef as useRef11 } from "react";
429
+ import { useState as useState2, useEffect as useEffect9, useCallback as useCallback2, useRef as useRef9 } from "react";
527
430
  var _globalExpressionLibraryResolver = null;
528
431
  function setExpressionLibraryResolver(resolver) {
529
432
  _globalExpressionLibraryResolver = resolver;
530
433
  }
531
434
  function useExpressionLibrary(slug) {
532
- const [record, setRecord] = useState4(null);
533
- const [loading, setLoading] = useState4(!!slug);
534
- const [error, setError] = useState4(null);
535
- const slugRef = useRef11(slug);
435
+ const [record, setRecord] = useState2(null);
436
+ const [loading, setLoading] = useState2(!!slug);
437
+ const [error, setError] = useState2(null);
438
+ const slugRef = useRef9(slug);
536
439
  slugRef.current = slug;
537
- const fetchLibrary = useCallback4(async () => {
440
+ const fetchLibrary = useCallback2(async () => {
538
441
  const s = slugRef.current;
539
442
  if (!s) {
540
443
  setRecord(null);
@@ -558,7 +461,7 @@ function useExpressionLibrary(slug) {
558
461
  setLoading(false);
559
462
  }
560
463
  }, []);
561
- useEffect10(() => {
464
+ useEffect9(() => {
562
465
  fetchLibrary();
563
466
  }, [slug, fetchLibrary]);
564
467
  const handle = {
@@ -575,7 +478,7 @@ function useExpressionLibrary(slug) {
575
478
  }
576
479
 
577
480
  // src/hooks/useServerAction.ts
578
- import { useState as useState5, useCallback as useCallback5, useRef as useRef12 } from "react";
481
+ import { useState as useState3, useCallback as useCallback3, useRef as useRef10 } from "react";
579
482
  var _globalServerActionResolver = null;
580
483
  function setServerActionResolver(resolver) {
581
484
  _globalServerActionResolver = resolver;
@@ -603,12 +506,12 @@ function getDefaultResolver() {
603
506
  };
604
507
  }
605
508
  function useServerAction(actionName, options) {
606
- const [loading, setLoading] = useState5(false);
607
- const [error, setError] = useState5(null);
608
- const [result, setResult] = useState5(null);
609
- const optionsRef = useRef12(options);
509
+ const [loading, setLoading] = useState3(false);
510
+ const [error, setError] = useState3(null);
511
+ const [result, setResult] = useState3(null);
512
+ const optionsRef = useRef10(options);
610
513
  optionsRef.current = options;
611
- const execute = useCallback5(
514
+ const execute = useCallback3(
612
515
  async (input) => {
613
516
  const resolver = _globalServerActionResolver || getDefaultResolver();
614
517
  const { instanceId, definitionId, onSuccess, onError } = optionsRef.current;
@@ -630,7 +533,7 @@ function useServerAction(actionName, options) {
630
533
  },
631
534
  [actionName]
632
535
  );
633
- const reset = useCallback5(() => {
536
+ const reset = useCallback3(() => {
634
537
  setError(null);
635
538
  setResult(null);
636
539
  }, []);
@@ -645,7 +548,7 @@ function useServerAction(actionName, options) {
645
548
  }
646
549
 
647
550
  // src/hooks/useServerState.ts
648
- import { useState as useState6, useEffect as useEffect11, useRef as useRef13, useCallback as useCallback6 } from "react";
551
+ import { useState as useState4, useEffect as useEffect10, useRef as useRef11, useCallback as useCallback4 } from "react";
649
552
  var _globalServerStateResolver = null;
650
553
  function setServerStateResolver(resolver) {
651
554
  _globalServerStateResolver = resolver;
@@ -675,21 +578,21 @@ async function fetchInitialState(instanceId) {
675
578
  };
676
579
  }
677
580
  function useServerState(instanceId, options = {}) {
678
- const [state2, setState] = useState6("");
679
- const [stateData, setStateData] = useState6({});
680
- const [status, setStatus] = useState6("UNKNOWN");
681
- const [loading, setLoading] = useState6(true);
682
- const [error, setError] = useState6(null);
683
- const [connected, setConnected] = useState6(false);
684
- const [lastTransition, setLastTransition] = useState6();
685
- const [reconnectKey, setReconnectKey] = useState6(0);
686
- const optionsRef = useRef13(options);
581
+ const [state2, setState] = useState4("");
582
+ const [stateData, setStateData] = useState4({});
583
+ const [status, setStatus] = useState4("UNKNOWN");
584
+ const [loading, setLoading] = useState4(true);
585
+ const [error, setError] = useState4(null);
586
+ const [connected, setConnected] = useState4(false);
587
+ const [lastTransition, setLastTransition] = useState4();
588
+ const [reconnectKey, setReconnectKey] = useState4(0);
589
+ const optionsRef = useRef11(options);
687
590
  optionsRef.current = options;
688
- const eventSourceRef = useRef13(null);
689
- const reconnect = useCallback6(() => {
591
+ const eventSourceRef = useRef11(null);
592
+ const reconnect = useCallback4(() => {
690
593
  setReconnectKey((k) => k + 1);
691
594
  }, []);
692
- useEffect11(() => {
595
+ useEffect10(() => {
693
596
  if (options.enabled === false || !instanceId) return;
694
597
  let cancelled = false;
695
598
  setLoading(true);
@@ -708,7 +611,7 @@ function useServerState(instanceId, options = {}) {
708
611
  cancelled = true;
709
612
  };
710
613
  }, [instanceId, options.enabled, reconnectKey]);
711
- useEffect11(() => {
614
+ useEffect10(() => {
712
615
  if (options.enabled === false || !instanceId) return;
713
616
  const token = getToken();
714
617
  if (!token) {
@@ -802,19 +705,19 @@ function useServerState(instanceId, options = {}) {
802
705
  }
803
706
 
804
707
  // src/hooks/useWorkflow.ts
805
- import { useState as useState7, useEffect as useEffect12, useMemo, useCallback as useCallback7 } from "react";
708
+ import { useState as useState5, useEffect as useEffect11, useMemo, useCallback as useCallback5 } from "react";
806
709
  function useWorkflow(definition, options) {
807
710
  const runtime2 = useMemo(() => new WorkflowRuntime({
808
711
  definition,
809
712
  initialData: options?.initialData,
810
713
  actionHandlers: options?.actionHandlers
811
714
  }), [definition.id]);
812
- const [snapshot, setSnapshot] = useState7(() => runtime2.getSnapshot());
813
- useEffect12(() => {
715
+ const [snapshot, setSnapshot] = useState5(() => runtime2.getSnapshot());
716
+ useEffect11(() => {
814
717
  const unsub = runtime2.subscribe(setSnapshot);
815
718
  return unsub;
816
719
  }, [runtime2]);
817
- const transition2 = useCallback7(async (name, data) => {
720
+ const transition2 = useCallback5(async (name, data) => {
818
721
  const result = await runtime2.transition(name, data);
819
722
  options?.onTransition?.(result);
820
723
  return result;
@@ -832,12 +735,12 @@ function useWorkflow(definition, options) {
832
735
  }
833
736
 
834
737
  // src/hooks/useTransition.ts
835
- import { useCallback as useCallback8, useState as useState8 } from "react";
738
+ import { useCallback as useCallback6, useState as useState6 } from "react";
836
739
  function useTransition(transitionName, _config) {
837
740
  const runtime2 = useRuntimeContext();
838
- const [pending, setPending] = useState8(false);
741
+ const [pending, setPending] = useState6(false);
839
742
  const available = runtime2.sm.getAvailableTransitions().some((t) => t.name === transitionName);
840
- const fire = useCallback8(async (data) => {
743
+ const fire = useCallback6(async (data) => {
841
744
  setPending(true);
842
745
  try {
843
746
  return await runtime2.transition(transitionName, data);
@@ -850,7 +753,7 @@ function useTransition(transitionName, _config) {
850
753
  }
851
754
 
852
755
  // src/hooks/useRole.ts
853
- import { useMemo as useMemo2, useCallback as useCallback9 } from "react";
756
+ import { useMemo as useMemo2, useCallback as useCallback7 } from "react";
854
757
  var _globalHierarchy = null;
855
758
  function setRoleHierarchy(hierarchy) {
856
759
  _globalHierarchy = hierarchy;
@@ -910,7 +813,7 @@ function useRole(roleName, options = {}) {
910
813
  }
911
814
  return { hasRole: hasRole2, permissions, roles: userRoles, highestRole };
912
815
  }, [runtime2, roleName, hierarchy, inheritPermissions]);
913
- const isAbove = useCallback9(
816
+ const isAbove = useCallback7(
914
817
  (role) => {
915
818
  if (hierarchy.length === 0) return false;
916
819
  const targetIdx = hierarchy.indexOf(role);
@@ -923,7 +826,7 @@ function useRole(roleName, options = {}) {
923
826
  },
924
827
  [hierarchy, result.roles]
925
828
  );
926
- const isBelow = useCallback9(
829
+ const isBelow = useCallback7(
927
830
  (role) => {
928
831
  if (hierarchy.length === 0) return false;
929
832
  const targetIdx = hierarchy.indexOf(role);
@@ -940,7 +843,7 @@ function useRole(roleName, options = {}) {
940
843
  },
941
844
  [hierarchy, result.roles]
942
845
  );
943
- const hasPermission = useCallback9(
846
+ const hasPermission = useCallback7(
944
847
  (permission) => {
945
848
  return result.permissions.includes(permission);
946
849
  },
@@ -1041,7 +944,7 @@ function usePackage(packageSlug) {
1041
944
  }
1042
945
 
1043
946
  // src/hooks/useRouter.ts
1044
- import { useState as useState9, useEffect as useEffect13, useCallback as useCallback10, useMemo as useMemo5, useRef as useRef14 } from "react";
947
+ import { useState as useState7, useEffect as useEffect12, useCallback as useCallback8, useMemo as useMemo5, useRef as useRef12 } from "react";
1045
948
  function parsePath(fullPath, basePath) {
1046
949
  let path = fullPath;
1047
950
  if (basePath && path.startsWith(basePath)) {
@@ -1130,26 +1033,26 @@ function buildLocation(basePath, routes) {
1130
1033
  }
1131
1034
  function useRouter(options = {}) {
1132
1035
  const { routes = [], guards: globalGuards = [], onGuardReject, basePath = "" } = options;
1133
- const routesRef = useRef14(routes);
1036
+ const routesRef = useRef12(routes);
1134
1037
  routesRef.current = routes;
1135
- const guardsRef = useRef14(globalGuards);
1038
+ const guardsRef = useRef12(globalGuards);
1136
1039
  guardsRef.current = globalGuards;
1137
- const onRejectRef = useRef14(onGuardReject);
1040
+ const onRejectRef = useRef12(onGuardReject);
1138
1041
  onRejectRef.current = onGuardReject;
1139
- const basePathRef = useRef14(basePath);
1042
+ const basePathRef = useRef12(basePath);
1140
1043
  basePathRef.current = basePath;
1141
- const [location, setLocation] = useState9(
1044
+ const [location, setLocation] = useState7(
1142
1045
  () => buildLocation(basePath, routes)
1143
1046
  );
1144
- const [isNavigating, setIsNavigating] = useState9(false);
1145
- useEffect13(() => {
1047
+ const [isNavigating, setIsNavigating] = useState7(false);
1048
+ useEffect12(() => {
1146
1049
  const handler = () => {
1147
1050
  setLocation(buildLocation(basePathRef.current, routesRef.current));
1148
1051
  };
1149
1052
  window.addEventListener("popstate", handler);
1150
1053
  return () => window.removeEventListener("popstate", handler);
1151
1054
  }, []);
1152
- const navigate = useCallback10(
1055
+ const navigate = useCallback8(
1153
1056
  async (path, replace2) => {
1154
1057
  const { pathname, query, hash } = parsePath(path, basePathRef.current);
1155
1058
  const found = findRoute(pathname, routesRef.current);
@@ -1198,15 +1101,15 @@ function useRouter(options = {}) {
1198
1101
  },
1199
1102
  [location]
1200
1103
  );
1201
- const push = useCallback10((path) => navigate(path, false), [navigate]);
1202
- const replace = useCallback10((path) => navigate(path, true), [navigate]);
1203
- const back = useCallback10(() => {
1104
+ const push = useCallback8((path) => navigate(path, false), [navigate]);
1105
+ const replace = useCallback8((path) => navigate(path, true), [navigate]);
1106
+ const back = useCallback8(() => {
1204
1107
  window.history.back();
1205
1108
  }, []);
1206
- const forward = useCallback10(() => {
1109
+ const forward = useCallback8(() => {
1207
1110
  window.history.forward();
1208
1111
  }, []);
1209
- const isActive = useCallback10(
1112
+ const isActive = useCallback8(
1210
1113
  (pattern) => {
1211
1114
  return matchRoute(location.pathname, pattern).match;
1212
1115
  },
@@ -1231,7 +1134,7 @@ function useRouter(options = {}) {
1231
1134
  }
1232
1135
 
1233
1136
  // src/hooks/useRouteParams.ts
1234
- import { useState as useState10, useEffect as useEffect14, useMemo as useMemo6, useRef as useRef15 } from "react";
1137
+ import { useState as useState8, useEffect as useEffect13, useMemo as useMemo6, useRef as useRef13 } from "react";
1235
1138
  function extractParams(pathname, pattern) {
1236
1139
  const pathParts = pathname.split("/").filter(Boolean);
1237
1140
  const patternParts = pattern.split("/").filter(Boolean);
@@ -1253,7 +1156,7 @@ function extractAllSegments(pathname) {
1253
1156
  }
1254
1157
  function useRouteParams(options = {}) {
1255
1158
  const { pattern, basePath = "" } = options;
1256
- const patternRef = useRef15(pattern);
1159
+ const patternRef = useRef13(pattern);
1257
1160
  patternRef.current = pattern;
1258
1161
  const getPathname2 = () => {
1259
1162
  if (typeof window === "undefined") return "/";
@@ -1263,8 +1166,8 @@ function useRouteParams(options = {}) {
1263
1166
  }
1264
1167
  return path;
1265
1168
  };
1266
- const [pathname, setPathname] = useState10(getPathname2);
1267
- useEffect14(() => {
1169
+ const [pathname, setPathname] = useState8(getPathname2);
1170
+ useEffect13(() => {
1268
1171
  const handler = () => setPathname(getPathname2());
1269
1172
  window.addEventListener("popstate", handler);
1270
1173
  return () => window.removeEventListener("popstate", handler);
@@ -1278,7 +1181,7 @@ function useRouteParams(options = {}) {
1278
1181
  }
1279
1182
 
1280
1183
  // src/hooks/useRealtimeQuery.ts
1281
- import { useState as useState11, useEffect as useEffect15, useCallback as useCallback11, useRef as useRef16 } from "react";
1184
+ import { useState as useState9, useEffect as useEffect14, useCallback as useCallback9, useRef as useRef14 } from "react";
1282
1185
  var _queryResolver = null;
1283
1186
  function setRealtimeQueryResolver(resolver) {
1284
1187
  _queryResolver = resolver;
@@ -1296,16 +1199,16 @@ function useRealtimeQuery(slug, params = {}) {
1296
1199
  enabled,
1297
1200
  ...queryParams
1298
1201
  } = params;
1299
- const [data, setData] = useState11([]);
1300
- const [loading, setLoading] = useState11(true);
1301
- const [error, setError] = useState11(null);
1302
- const [total, setTotal] = useState11(void 0);
1303
- const [connected, setConnected] = useState11(false);
1304
- const [reconnectKey, setReconnectKey] = useState11(0);
1305
- const queryParamsRef = useRef16(queryParams);
1202
+ const [data, setData] = useState9([]);
1203
+ const [loading, setLoading] = useState9(true);
1204
+ const [error, setError] = useState9(null);
1205
+ const [total, setTotal] = useState9(void 0);
1206
+ const [connected, setConnected] = useState9(false);
1207
+ const [reconnectKey, setReconnectKey] = useState9(0);
1208
+ const queryParamsRef = useRef14(queryParams);
1306
1209
  queryParamsRef.current = queryParams;
1307
- const debounceRef = useRef16(null);
1308
- const fetchData = useCallback11(async () => {
1210
+ const debounceRef = useRef14(null);
1211
+ const fetchData = useCallback9(async () => {
1309
1212
  if (enabled === false) {
1310
1213
  setLoading(false);
1311
1214
  return;
@@ -1328,10 +1231,10 @@ function useRealtimeQuery(slug, params = {}) {
1328
1231
  setLoading(false);
1329
1232
  }
1330
1233
  }, [slug, enabled]);
1331
- useEffect15(() => {
1234
+ useEffect14(() => {
1332
1235
  fetchData();
1333
1236
  }, [fetchData]);
1334
- useEffect15(() => {
1237
+ useEffect14(() => {
1335
1238
  if (enabled === false) return;
1336
1239
  const token = getToken2();
1337
1240
  if (!token) return;
@@ -1384,7 +1287,7 @@ function useRealtimeQuery(slug, params = {}) {
1384
1287
  setConnected(false);
1385
1288
  };
1386
1289
  }, [slug, channel, sseUrl, enabled, autoReconnect, reconnectDelay, debounce, fetchData, reconnectKey]);
1387
- const forceReconnect = useCallback11(() => {
1290
+ const forceReconnect = useCallback9(() => {
1388
1291
  setReconnectKey((k) => k + 1);
1389
1292
  }, []);
1390
1293
  const hasMore = total !== void 0 && data.length < total;
@@ -1402,7 +1305,7 @@ function useRealtimeQuery(slug, params = {}) {
1402
1305
  }
1403
1306
 
1404
1307
  // src/hooks/useChannel.ts
1405
- import { useState as useState12, useEffect as useEffect16, useCallback as useCallback12, useRef as useRef17, useMemo as useMemo7 } from "react";
1308
+ import { useState as useState10, useEffect as useEffect15, useCallback as useCallback10, useRef as useRef15, useMemo as useMemo7 } from "react";
1406
1309
  var _globalTransport = null;
1407
1310
  function setChannelTransport(transport) {
1408
1311
  _globalTransport = transport;
@@ -1501,14 +1404,14 @@ function useChannel(channelName, options = {}) {
1501
1404
  reconnect: autoReconnect = true,
1502
1405
  reconnectDelay = 3e3
1503
1406
  } = options;
1504
- const [messages, setMessages] = useState12([]);
1505
- const [connected, setConnected] = useState12(false);
1506
- const [reconnectKey, setReconnectKey] = useState12(0);
1507
- const handlersRef = useRef17(/* @__PURE__ */ new Map());
1508
- const transportRef = useRef17(null);
1509
- const bufferSizeRef = useRef17(bufferSize);
1407
+ const [messages, setMessages] = useState10([]);
1408
+ const [connected, setConnected] = useState10(false);
1409
+ const [reconnectKey, setReconnectKey] = useState10(0);
1410
+ const handlersRef = useRef15(/* @__PURE__ */ new Map());
1411
+ const transportRef = useRef15(null);
1412
+ const bufferSizeRef = useRef15(bufferSize);
1510
1413
  bufferSizeRef.current = bufferSize;
1511
- useEffect16(() => {
1414
+ useEffect15(() => {
1512
1415
  if (!enabled) return;
1513
1416
  const transport = _globalTransport ?? createDefaultTransport(wsUrl, {
1514
1417
  enabled: autoReconnect,
@@ -1542,13 +1445,13 @@ function useChannel(channelName, options = {}) {
1542
1445
  }
1543
1446
  };
1544
1447
  }, [channelName, wsUrl, enabled, autoReconnect, reconnectDelay, reconnectKey]);
1545
- const publish = useCallback12(
1448
+ const publish = useCallback10(
1546
1449
  (event, data) => {
1547
1450
  transportRef.current?.send(channelName, event, data);
1548
1451
  },
1549
1452
  [channelName]
1550
1453
  );
1551
- const subscribe = useCallback12(
1454
+ const subscribe = useCallback10(
1552
1455
  (event, handler) => {
1553
1456
  if (!handlersRef.current.has(event)) {
1554
1457
  handlersRef.current.set(event, /* @__PURE__ */ new Set());
@@ -1566,7 +1469,7 @@ function useChannel(channelName, options = {}) {
1566
1469
  },
1567
1470
  []
1568
1471
  );
1569
- const forceReconnect = useCallback12(() => {
1472
+ const forceReconnect = useCallback10(() => {
1570
1473
  setReconnectKey((k) => k + 1);
1571
1474
  setMessages([]);
1572
1475
  }, []);
@@ -1583,7 +1486,7 @@ function useChannel(channelName, options = {}) {
1583
1486
  }
1584
1487
 
1585
1488
  // src/hooks/useGeolocation.ts
1586
- import { useState as useState13, useEffect as useEffect17, useCallback as useCallback13, useRef as useRef18, useMemo as useMemo8 } from "react";
1489
+ import { useState as useState11, useEffect as useEffect16, useCallback as useCallback11, useRef as useRef16, useMemo as useMemo8 } from "react";
1587
1490
  var INITIAL_POSITION = {
1588
1491
  latitude: null,
1589
1492
  longitude: null,
@@ -1602,17 +1505,17 @@ function useGeolocation(options = {}) {
1602
1505
  watch = false,
1603
1506
  enabled = true
1604
1507
  } = options;
1605
- const [position, setPosition] = useState13(INITIAL_POSITION);
1606
- const [loading, setLoading] = useState13(true);
1607
- const [error, setError] = useState13(null);
1608
- const [watching, setWatching] = useState13(false);
1609
- const watchIdRef = useRef18(null);
1508
+ const [position, setPosition] = useState11(INITIAL_POSITION);
1509
+ const [loading, setLoading] = useState11(true);
1510
+ const [error, setError] = useState11(null);
1511
+ const [watching, setWatching] = useState11(false);
1512
+ const watchIdRef = useRef16(null);
1610
1513
  const supported = typeof navigator !== "undefined" && "geolocation" in navigator;
1611
1514
  const positionOptions = useMemo8(
1612
1515
  () => ({ enableHighAccuracy, maximumAge, timeout: timeout2 }),
1613
1516
  [enableHighAccuracy, maximumAge, timeout2]
1614
1517
  );
1615
- const handleSuccess = useCallback13((pos) => {
1518
+ const handleSuccess = useCallback11((pos) => {
1616
1519
  setPosition({
1617
1520
  latitude: pos.coords.latitude,
1618
1521
  longitude: pos.coords.longitude,
@@ -1626,11 +1529,11 @@ function useGeolocation(options = {}) {
1626
1529
  setError(null);
1627
1530
  setLoading(false);
1628
1531
  }, []);
1629
- const handleError = useCallback13((err) => {
1532
+ const handleError = useCallback11((err) => {
1630
1533
  setError({ code: err.code, message: err.message });
1631
1534
  setLoading(false);
1632
1535
  }, []);
1633
- const getCurrentPosition = useCallback13(() => {
1536
+ const getCurrentPosition = useCallback11(() => {
1634
1537
  if (!supported) {
1635
1538
  setError({ code: 0, message: "Geolocation is not supported" });
1636
1539
  setLoading(false);
@@ -1639,20 +1542,20 @@ function useGeolocation(options = {}) {
1639
1542
  setLoading(true);
1640
1543
  navigator.geolocation.getCurrentPosition(handleSuccess, handleError, positionOptions);
1641
1544
  }, [supported, handleSuccess, handleError, positionOptions]);
1642
- const startWatching = useCallback13(() => {
1545
+ const startWatching = useCallback11(() => {
1643
1546
  if (!supported || watchIdRef.current !== null) return;
1644
1547
  const id = navigator.geolocation.watchPosition(handleSuccess, handleError, positionOptions);
1645
1548
  watchIdRef.current = id;
1646
1549
  setWatching(true);
1647
1550
  }, [supported, handleSuccess, handleError, positionOptions]);
1648
- const stopWatching = useCallback13(() => {
1551
+ const stopWatching = useCallback11(() => {
1649
1552
  if (watchIdRef.current !== null) {
1650
1553
  navigator.geolocation.clearWatch(watchIdRef.current);
1651
1554
  watchIdRef.current = null;
1652
1555
  setWatching(false);
1653
1556
  }
1654
1557
  }, []);
1655
- useEffect17(() => {
1558
+ useEffect16(() => {
1656
1559
  if (!enabled || !supported) {
1657
1560
  if (!supported) {
1658
1561
  setError({ code: 0, message: "Geolocation is not supported" });
@@ -1683,7 +1586,7 @@ function useGeolocation(options = {}) {
1683
1586
  }
1684
1587
 
1685
1588
  // src/hooks/useMapView.ts
1686
- import { useState as useState14, useCallback as useCallback14, useMemo as useMemo9 } from "react";
1589
+ import { useState as useState12, useCallback as useCallback12, useMemo as useMemo9 } from "react";
1687
1590
  function haversineDistance(from, to) {
1688
1591
  const R = 6371e3;
1689
1592
  const dLat = (to.lat - from.lat) * Math.PI / 180;
@@ -1729,23 +1632,23 @@ function useMapView(options = {}) {
1729
1632
  minZoom = 0,
1730
1633
  maxZoom = 22
1731
1634
  } = options;
1732
- const [center, setCenterState] = useState14(initialCenter);
1733
- const [zoom, setZoomState] = useState14(initialZoom);
1734
- const [bounds, setBoundsState] = useState14(null);
1735
- const [markers, setMarkers] = useState14([]);
1736
- const setCenter = useCallback14((lat, lng) => {
1635
+ const [center, setCenterState] = useState12(initialCenter);
1636
+ const [zoom, setZoomState] = useState12(initialZoom);
1637
+ const [bounds, setBoundsState] = useState12(null);
1638
+ const [markers, setMarkers] = useState12([]);
1639
+ const setCenter = useCallback12((lat, lng) => {
1737
1640
  setCenterState({ lat, lng });
1738
1641
  }, []);
1739
- const setZoom = useCallback14(
1642
+ const setZoom = useCallback12(
1740
1643
  (z) => {
1741
1644
  setZoomState(Math.max(minZoom, Math.min(maxZoom, z)));
1742
1645
  },
1743
1646
  [minZoom, maxZoom]
1744
1647
  );
1745
- const panTo = useCallback14((lat, lng) => {
1648
+ const panTo = useCallback12((lat, lng) => {
1746
1649
  setCenterState({ lat, lng });
1747
1650
  }, []);
1748
- const fitBounds = useCallback14(
1651
+ const fitBounds = useCallback12(
1749
1652
  (points, padding = 0.1) => {
1750
1653
  if (points.length === 0) return;
1751
1654
  if (points.length === 1) {
@@ -1760,24 +1663,24 @@ function useMapView(options = {}) {
1760
1663
  },
1761
1664
  [minZoom, maxZoom]
1762
1665
  );
1763
- const setBounds = useCallback14((b) => {
1666
+ const setBounds = useCallback12((b) => {
1764
1667
  setBoundsState(b);
1765
1668
  }, []);
1766
- const addMarker = useCallback14((marker) => {
1669
+ const addMarker = useCallback12((marker) => {
1767
1670
  setMarkers((prev) => [...prev.filter((m) => m.id !== marker.id), marker]);
1768
1671
  }, []);
1769
- const removeMarker = useCallback14((id) => {
1672
+ const removeMarker = useCallback12((id) => {
1770
1673
  setMarkers((prev) => prev.filter((m) => m.id !== id));
1771
1674
  }, []);
1772
- const updateMarker = useCallback14((id, position) => {
1675
+ const updateMarker = useCallback12((id, position) => {
1773
1676
  setMarkers(
1774
1677
  (prev) => prev.map((m) => m.id === id ? { ...m, position } : m)
1775
1678
  );
1776
1679
  }, []);
1777
- const clearMarkers = useCallback14(() => {
1680
+ const clearMarkers = useCallback12(() => {
1778
1681
  setMarkers([]);
1779
1682
  }, []);
1780
- const distance = useCallback14((from, to) => {
1683
+ const distance = useCallback12((from, to) => {
1781
1684
  return haversineDistance(from, to);
1782
1685
  }, []);
1783
1686
  return useMemo9(
@@ -1802,7 +1705,7 @@ function useMapView(options = {}) {
1802
1705
  }
1803
1706
 
1804
1707
  // src/hooks/useAuth.ts
1805
- import { useState as useState15, useEffect as useEffect18, useCallback as useCallback15, useMemo as useMemo10, useRef as useRef19 } from "react";
1708
+ import { useState as useState13, useEffect as useEffect17, useCallback as useCallback13, useMemo as useMemo10, useRef as useRef17 } from "react";
1806
1709
  var _globalAuthResolver = null;
1807
1710
  function setAuthResolver(resolver) {
1808
1711
  _globalAuthResolver = resolver;
@@ -1848,23 +1751,23 @@ function useAuth(options = {}) {
1848
1751
  onLogout,
1849
1752
  onError
1850
1753
  } = options;
1851
- const [user, setUser] = useState15(null);
1852
- const [loading, setLoading] = useState15(true);
1853
- const [error, setError] = useState15(null);
1854
- const [token, setToken] = useState15(() => {
1754
+ const [user, setUser] = useState13(null);
1755
+ const [loading, setLoading] = useState13(true);
1756
+ const [error, setError] = useState13(null);
1757
+ const [token, setToken] = useState13(() => {
1855
1758
  return typeof localStorage !== "undefined" ? localStorage.getItem(tokenKey) : null;
1856
1759
  });
1857
- const onLoginRef = useRef19(onLogin);
1760
+ const onLoginRef = useRef17(onLogin);
1858
1761
  onLoginRef.current = onLogin;
1859
- const onLogoutRef = useRef19(onLogout);
1762
+ const onLogoutRef = useRef17(onLogout);
1860
1763
  onLogoutRef.current = onLogout;
1861
- const onErrorRef = useRef19(onError);
1764
+ const onErrorRef = useRef17(onError);
1862
1765
  onErrorRef.current = onError;
1863
- const getResolver = useCallback15(
1766
+ const getResolver = useCallback13(
1864
1767
  () => _globalAuthResolver ?? createDefaultResolver(apiUrl),
1865
1768
  [apiUrl]
1866
1769
  );
1867
- useEffect18(() => {
1770
+ useEffect17(() => {
1868
1771
  if (!autoFetch || !token) {
1869
1772
  setLoading(false);
1870
1773
  return;
@@ -1892,7 +1795,7 @@ function useAuth(options = {}) {
1892
1795
  cancelled = true;
1893
1796
  };
1894
1797
  }, [token, autoFetch, getResolver, tokenKey]);
1895
- const login = useCallback15(
1798
+ const login = useCallback13(
1896
1799
  async (credentials) => {
1897
1800
  setLoading(true);
1898
1801
  setError(null);
@@ -1915,7 +1818,7 @@ function useAuth(options = {}) {
1915
1818
  },
1916
1819
  [getResolver, tokenKey]
1917
1820
  );
1918
- const logout = useCallback15(async () => {
1821
+ const logout = useCallback13(async () => {
1919
1822
  try {
1920
1823
  if (token) {
1921
1824
  const resolver = getResolver();
@@ -1929,7 +1832,7 @@ function useAuth(options = {}) {
1929
1832
  onLogoutRef.current?.();
1930
1833
  }
1931
1834
  }, [token, getResolver, tokenKey]);
1932
- const refreshUser = useCallback15(async () => {
1835
+ const refreshUser = useCallback13(async () => {
1933
1836
  if (!token) return;
1934
1837
  try {
1935
1838
  const resolver = getResolver();
@@ -1942,7 +1845,7 @@ function useAuth(options = {}) {
1942
1845
  onErrorRef.current?.(authError);
1943
1846
  }
1944
1847
  }, [token, getResolver]);
1945
- const hasRole2 = useCallback15(
1848
+ const hasRole2 = useCallback13(
1946
1849
  (role) => {
1947
1850
  return user?.roles.includes(role) ?? false;
1948
1851
  },
@@ -1966,7 +1869,7 @@ function useAuth(options = {}) {
1966
1869
  }
1967
1870
 
1968
1871
  // src/hooks/useForm.ts
1969
- import { useState as useState16, useCallback as useCallback16, useMemo as useMemo11, useRef as useRef20 } from "react";
1872
+ import { useState as useState14, useCallback as useCallback14, useMemo as useMemo11, useRef as useRef18 } from "react";
1970
1873
  function useForm(config) {
1971
1874
  const {
1972
1875
  initialValues,
@@ -1977,19 +1880,19 @@ function useForm(config) {
1977
1880
  validateOnChange = false,
1978
1881
  validateOnBlur = true
1979
1882
  } = config;
1980
- const [values, setValuesState] = useState16(initialValues);
1981
- const [errors, setErrors] = useState16({});
1982
- const [touched, setTouched] = useState16({});
1983
- const [isSubmitting, setIsSubmitting] = useState16(false);
1984
- const [submitCount, setSubmitCount] = useState16(0);
1985
- const initialRef = useRef20(initialValues);
1986
- const validateRef = useRef20(validate2);
1883
+ const [values, setValuesState] = useState14(initialValues);
1884
+ const [errors, setErrors] = useState14({});
1885
+ const [touched, setTouched] = useState14({});
1886
+ const [isSubmitting, setIsSubmitting] = useState14(false);
1887
+ const [submitCount, setSubmitCount] = useState14(0);
1888
+ const initialRef = useRef18(initialValues);
1889
+ const validateRef = useRef18(validate2);
1987
1890
  validateRef.current = validate2;
1988
- const fieldValidatorsRef = useRef20(fieldValidators);
1891
+ const fieldValidatorsRef = useRef18(fieldValidators);
1989
1892
  fieldValidatorsRef.current = fieldValidators;
1990
- const onSubmitRef = useRef20(onSubmit);
1893
+ const onSubmitRef = useRef18(onSubmit);
1991
1894
  onSubmitRef.current = onSubmit;
1992
- const onErrorRef = useRef20(onError);
1895
+ const onErrorRef = useRef18(onError);
1993
1896
  onErrorRef.current = onError;
1994
1897
  const dirtyFields = useMemo11(() => {
1995
1898
  const result = {};
@@ -2006,7 +1909,7 @@ function useForm(config) {
2006
1909
  () => Object.keys(errors).length === 0,
2007
1910
  [errors]
2008
1911
  );
2009
- const validateField = useCallback16(
1912
+ const validateField = useCallback14(
2010
1913
  async (name, value) => {
2011
1914
  const validator = fieldValidatorsRef.current?.[name];
2012
1915
  if (validator) {
@@ -2016,7 +1919,7 @@ function useForm(config) {
2016
1919
  },
2017
1920
  []
2018
1921
  );
2019
- const validateForm = useCallback16(async () => {
1922
+ const validateForm = useCallback14(async () => {
2020
1923
  let formErrors = {};
2021
1924
  if (validateRef.current) {
2022
1925
  formErrors = await validateRef.current(values);
@@ -2034,7 +1937,7 @@ function useForm(config) {
2034
1937
  setErrors(formErrors);
2035
1938
  return formErrors;
2036
1939
  }, [values]);
2037
- const setField2 = useCallback16(
1940
+ const setField2 = useCallback14(
2038
1941
  (name, value) => {
2039
1942
  setValuesState((prev) => ({ ...prev, [name]: value }));
2040
1943
  if (validateOnChange) {
@@ -2052,20 +1955,20 @@ function useForm(config) {
2052
1955
  },
2053
1956
  [validateOnChange, validateField]
2054
1957
  );
2055
- const setError = useCallback16((name, message) => {
1958
+ const setError = useCallback14((name, message) => {
2056
1959
  setErrors((prev) => ({ ...prev, [name]: message }));
2057
1960
  }, []);
2058
- const clearError = useCallback16((name) => {
1961
+ const clearError = useCallback14((name) => {
2059
1962
  setErrors((prev) => {
2060
1963
  const next = { ...prev };
2061
1964
  delete next[name];
2062
1965
  return next;
2063
1966
  });
2064
1967
  }, []);
2065
- const setValues = useCallback16((partial) => {
1968
+ const setValues = useCallback14((partial) => {
2066
1969
  setValuesState((prev) => ({ ...prev, ...partial }));
2067
1970
  }, []);
2068
- const reset = useCallback16((newInitial) => {
1971
+ const reset = useCallback14((newInitial) => {
2069
1972
  const resetTo = newInitial ?? initialRef.current;
2070
1973
  if (newInitial) {
2071
1974
  initialRef.current = newInitial;
@@ -2075,7 +1978,7 @@ function useForm(config) {
2075
1978
  setTouched({});
2076
1979
  setIsSubmitting(false);
2077
1980
  }, []);
2078
- const handleSubmit = useCallback16(async () => {
1981
+ const handleSubmit = useCallback14(async () => {
2079
1982
  setSubmitCount((c) => c + 1);
2080
1983
  const allTouched = {};
2081
1984
  for (const key of Object.keys(values)) {
@@ -2098,7 +2001,7 @@ function useForm(config) {
2098
2001
  setIsSubmitting(false);
2099
2002
  }
2100
2003
  }, [values, validateForm]);
2101
- const register = useCallback16(
2004
+ const register = useCallback14(
2102
2005
  (name) => {
2103
2006
  return {
2104
2007
  name,
@@ -2133,7 +2036,7 @@ function useForm(config) {
2133
2036
  },
2134
2037
  [values, errors, setField2, validateOnBlur, validateField]
2135
2038
  );
2136
- const getField = useCallback16(
2039
+ const getField = useCallback14(
2137
2040
  (name) => values[name],
2138
2041
  [values]
2139
2042
  );
@@ -2180,13 +2083,13 @@ function useForm(config) {
2180
2083
  }
2181
2084
 
2182
2085
  // src/hooks/useNotification.ts
2183
- import { useState as useState17, useCallback as useCallback17, useEffect as useEffect19, useMemo as useMemo12 } from "react";
2086
+ import { useState as useState15, useCallback as useCallback15, useEffect as useEffect18, useMemo as useMemo12 } from "react";
2184
2087
  function useNotification() {
2185
2088
  const supported = typeof window !== "undefined" && "Notification" in window;
2186
- const [permission, setPermission] = useState17(
2089
+ const [permission, setPermission] = useState15(
2187
2090
  supported ? Notification.permission : "denied"
2188
2091
  );
2189
- useEffect19(() => {
2092
+ useEffect18(() => {
2190
2093
  if (!supported) return;
2191
2094
  const interval = setInterval(() => {
2192
2095
  if (Notification.permission !== permission) {
@@ -2195,13 +2098,13 @@ function useNotification() {
2195
2098
  }, 1e3);
2196
2099
  return () => clearInterval(interval);
2197
2100
  }, [supported, permission]);
2198
- const requestPermission = useCallback17(async () => {
2101
+ const requestPermission = useCallback15(async () => {
2199
2102
  if (!supported) return "denied";
2200
2103
  const result = await Notification.requestPermission();
2201
2104
  setPermission(result);
2202
2105
  return result;
2203
2106
  }, [supported]);
2204
- const notify3 = useCallback17(
2107
+ const notify3 = useCallback15(
2205
2108
  (title, options = {}) => {
2206
2109
  if (!supported || permission !== "granted") return null;
2207
2110
  const {
@@ -2240,7 +2143,7 @@ function useNotification() {
2240
2143
  }
2241
2144
 
2242
2145
  // src/hooks/useToast.ts
2243
- import { useState as useState18, useCallback as useCallback18, useRef as useRef21, useMemo as useMemo13 } from "react";
2146
+ import { useState as useState16, useCallback as useCallback16, useRef as useRef19, useMemo as useMemo13 } from "react";
2244
2147
  var _nextId = 0;
2245
2148
  var _toasts = [];
2246
2149
  var _listeners = /* @__PURE__ */ new Set();
@@ -2286,20 +2189,20 @@ function clearAllToasts() {
2286
2189
  notifyListeners();
2287
2190
  }
2288
2191
  function useToast() {
2289
- const [toasts, setToasts] = useState18(() => [..._toasts]);
2290
- const listenerRef = useRef21(null);
2192
+ const [toasts, setToasts] = useState16(() => [..._toasts]);
2193
+ const listenerRef = useRef19(null);
2291
2194
  if (!listenerRef.current) {
2292
2195
  const listener = (newToasts) => setToasts(newToasts);
2293
2196
  listenerRef.current = listener;
2294
2197
  _listeners.add(listener);
2295
2198
  }
2296
- const toast = useCallback18((config) => {
2199
+ const toast = useCallback16((config) => {
2297
2200
  return addToast(config);
2298
2201
  }, []);
2299
- const dismiss = useCallback18((id) => {
2202
+ const dismiss = useCallback16((id) => {
2300
2203
  removeToast(id);
2301
2204
  }, []);
2302
- const dismissAll = useCallback18(() => {
2205
+ const dismissAll = useCallback16(() => {
2303
2206
  clearAllToasts();
2304
2207
  }, []);
2305
2208
  return useMemo13(
@@ -2365,7 +2268,7 @@ function makeResult(fields, states) {
2365
2268
  }
2366
2269
 
2367
2270
  // src/hooks/usePresence.ts
2368
- import { useState as useState19, useEffect as useEffect20, useCallback as useCallback19, useRef as useRef22 } from "react";
2271
+ import { useState as useState17, useEffect as useEffect19, useCallback as useCallback17, useRef as useRef20 } from "react";
2369
2272
  var PRESENCE_EVENTS = {
2370
2273
  JOIN: "presence:join",
2371
2274
  LEAVE: "presence:leave",
@@ -2387,11 +2290,11 @@ function usePresence(instanceId, options = {}) {
2387
2290
  wsUrl,
2388
2291
  enabled
2389
2292
  });
2390
- const [viewers, setViewers] = useState19([]);
2391
- const [editors, setEditors] = useState19([]);
2392
- const viewersRef = useRef22(/* @__PURE__ */ new Map());
2393
- const editorsRef = useRef22(/* @__PURE__ */ new Map());
2394
- useEffect20(() => {
2293
+ const [viewers, setViewers] = useState17([]);
2294
+ const [editors, setEditors] = useState17([]);
2295
+ const viewersRef = useRef20(/* @__PURE__ */ new Map());
2296
+ const editorsRef = useRef20(/* @__PURE__ */ new Map());
2297
+ useEffect19(() => {
2395
2298
  if (!connected || !enabled) return;
2396
2299
  publish(PRESENCE_EVENTS.JOIN, { id: userId, name: userName, connectedAt: Date.now() });
2397
2300
  const hb = setInterval(() => {
@@ -2402,7 +2305,7 @@ function usePresence(instanceId, options = {}) {
2402
2305
  publish(PRESENCE_EVENTS.LEAVE, { id: userId });
2403
2306
  };
2404
2307
  }, [connected, enabled, userId, userName, heartbeatInterval, publish]);
2405
- useEffect20(() => {
2308
+ useEffect19(() => {
2406
2309
  if (!enabled) return;
2407
2310
  const cleanup = setInterval(() => {
2408
2311
  const now = Date.now();
@@ -2421,7 +2324,7 @@ function usePresence(instanceId, options = {}) {
2421
2324
  }, staleTimeout / 3);
2422
2325
  return () => clearInterval(cleanup);
2423
2326
  }, [enabled, staleTimeout]);
2424
- useEffect20(() => {
2327
+ useEffect19(() => {
2425
2328
  if (!enabled) return;
2426
2329
  const unsubs = [];
2427
2330
  unsubs.push(subscribe(PRESENCE_EVENTS.JOIN, (data) => {
@@ -2469,13 +2372,13 @@ function usePresence(instanceId, options = {}) {
2469
2372
  }));
2470
2373
  return () => unsubs.forEach((fn) => fn());
2471
2374
  }, [enabled, userId, subscribe]);
2472
- const startEditing = useCallback19((field2) => {
2375
+ const startEditing = useCallback17((field2) => {
2473
2376
  publish(PRESENCE_EVENTS.EDIT_START, { id: userId, name: userName, field: field2 });
2474
2377
  }, [publish, userId, userName]);
2475
- const stopEditing = useCallback19((_field) => {
2378
+ const stopEditing = useCallback17((_field) => {
2476
2379
  publish(PRESENCE_EVENTS.EDIT_STOP, { id: userId });
2477
2380
  }, [publish, userId]);
2478
- const isEditing = useCallback19((field2) => {
2381
+ const isEditing = useCallback17((field2) => {
2479
2382
  for (const editor of editorsRef.current.values()) {
2480
2383
  if (editor.field === field2 && editor.id !== userId) return true;
2481
2384
  }
@@ -2492,7 +2395,7 @@ function usePresence(instanceId, options = {}) {
2492
2395
  }
2493
2396
 
2494
2397
  // src/hooks/useMiddleware.ts
2495
- import { useState as useState20, useEffect as useEffect21, useRef as useRef23, useMemo as useMemo15 } from "react";
2398
+ import { useState as useState18, useEffect as useEffect20, useRef as useRef21, useMemo as useMemo15 } from "react";
2496
2399
  function requireAuth(loginPath = "/login") {
2497
2400
  return (ctx) => {
2498
2401
  if (!ctx.token) {
@@ -2564,24 +2467,24 @@ function useMiddleware(middlewares, options = {}) {
2564
2467
  watchPathname = true,
2565
2468
  onRedirect
2566
2469
  } = options;
2567
- const [ready, setReady] = useState20(false);
2568
- const [loading, setLoading] = useState20(true);
2569
- const [redirect, setRedirect] = useState20(null);
2570
- const [error, setError] = useState20(null);
2571
- const [data, setData] = useState20({});
2572
- const [runKey, setRunKey] = useState20(0);
2573
- const middlewaresRef = useRef23(middlewares);
2470
+ const [ready, setReady] = useState18(false);
2471
+ const [loading, setLoading] = useState18(true);
2472
+ const [redirect, setRedirect] = useState18(null);
2473
+ const [error, setError] = useState18(null);
2474
+ const [data, setData] = useState18({});
2475
+ const [runKey, setRunKey] = useState18(0);
2476
+ const middlewaresRef = useRef21(middlewares);
2574
2477
  middlewaresRef.current = middlewares;
2575
- const onRedirectRef = useRef23(onRedirect);
2478
+ const onRedirectRef = useRef21(onRedirect);
2576
2479
  onRedirectRef.current = onRedirect;
2577
- const [pathname, setPathname] = useState20(getPathname);
2578
- useEffect21(() => {
2480
+ const [pathname, setPathname] = useState18(getPathname);
2481
+ useEffect20(() => {
2579
2482
  if (!watchPathname) return;
2580
2483
  const handler = () => setPathname(getPathname());
2581
2484
  window.addEventListener("popstate", handler);
2582
2485
  return () => window.removeEventListener("popstate", handler);
2583
2486
  }, [watchPathname]);
2584
- useEffect21(() => {
2487
+ useEffect20(() => {
2585
2488
  if (!enabled) {
2586
2489
  setReady(true);
2587
2490
  setLoading(false);
@@ -3312,7 +3215,7 @@ function defineBlueprint(config) {
3312
3215
  ...config,
3313
3216
  mode: config.mode || "infer",
3314
3217
  defaultRuntime: config.defaultRuntime || "local",
3315
- category: config.category || "blueprint"
3218
+ category: config.category ? Array.isArray(config.category) ? config.category : [config.category] : ["blueprint"]
3316
3219
  };
3317
3220
  }
3318
3221
  function defineModule(manifest) {
@@ -3451,7 +3354,7 @@ function refHasAnyRole(slug, lookupField, lookupValue, roles) {
3451
3354
  }
3452
3355
 
3453
3356
  // src/hooks/useModel.ts
3454
- import { useCallback as useCallback20, useRef as useRef24, useMemo as useMemo16 } from "react";
3357
+ import { useCallback as useCallback18, useRef as useRef22, useMemo as useMemo16 } from "react";
3455
3358
  function getDefaultFields(definition) {
3456
3359
  const defaults = {};
3457
3360
  for (const [key, field2] of Object.entries(definition.fields)) {
@@ -3515,9 +3418,9 @@ function useModel(definition, options = {}) {
3515
3418
  if (!instanceFields) return defaultFields;
3516
3419
  return { ...defaultFields, ...instanceFields };
3517
3420
  }, [instanceFields, defaultFields]);
3518
- const instanceIdRef = useRef24(instanceId);
3421
+ const instanceIdRef = useRef22(instanceId);
3519
3422
  instanceIdRef.current = instanceId;
3520
- const trigger = useCallback20(async (name, input) => {
3423
+ const trigger = useCallback18(async (name, input) => {
3521
3424
  const id = instanceIdRef.current;
3522
3425
  if (!id) {
3523
3426
  throw new Error(`useModel(${slug}): No instance loaded. Cannot trigger '${name}'.`);
@@ -3525,12 +3428,12 @@ function useModel(definition, options = {}) {
3525
3428
  await mutation.transition(id, name, input);
3526
3429
  await query.refetch();
3527
3430
  }, [slug, mutation, query]);
3528
- const create = useCallback20(async (input) => {
3431
+ const create = useCallback18(async (input) => {
3529
3432
  const id = await mutation.create(input);
3530
3433
  await query.refetch();
3531
3434
  return id;
3532
3435
  }, [mutation, query]);
3533
- const update = useCallback20(async (fieldUpdates) => {
3436
+ const update = useCallback18(async (fieldUpdates) => {
3534
3437
  const id = instanceIdRef.current;
3535
3438
  if (!id) {
3536
3439
  throw new Error(`useModel(${slug}): No instance loaded. Cannot update.`);
@@ -3566,20 +3469,20 @@ function useCollection(definition, options = {}) {
3566
3469
  state: instance2.currentState ?? ""
3567
3470
  }));
3568
3471
  }, [query.data]);
3569
- const trigger = useCallback20(async (instanceId, name, input) => {
3472
+ const trigger = useCallback18(async (instanceId, name, input) => {
3570
3473
  await mutation.transition(instanceId, name, input);
3571
3474
  await query.refetch();
3572
3475
  }, [mutation, query]);
3573
- const create = useCallback20(async (input) => {
3476
+ const create = useCallback18(async (input) => {
3574
3477
  const id = await mutation.create(input);
3575
3478
  await query.refetch();
3576
3479
  return id;
3577
3480
  }, [mutation, query]);
3578
- const update = useCallback20(async (instanceId, fieldUpdates) => {
3481
+ const update = useCallback18(async (instanceId, fieldUpdates) => {
3579
3482
  await mutation.update(instanceId, fieldUpdates);
3580
3483
  await query.refetch();
3581
3484
  }, [mutation, query]);
3582
- const remove = useCallback20(async (instanceId) => {
3485
+ const remove = useCallback18(async (instanceId) => {
3583
3486
  await mutation.remove(instanceId);
3584
3487
  await query.refetch();
3585
3488
  }, [mutation, query]);
@@ -3599,623 +3502,6 @@ function useCollection(definition, options = {}) {
3599
3502
  return handle;
3600
3503
  }
3601
3504
 
3602
- // src/player/ComponentTreeRenderer.tsx
3603
- import React, { useMemo as useMemo17, useCallback as useCallback21 } from "react";
3604
-
3605
- // src/player/evaluator.ts
3606
- var EXPR_PATTERN = /\{\{(.+?)\}\}/g;
3607
- function containsExpression(value) {
3608
- return typeof value === "string" && EXPR_PATTERN.test(value);
3609
- }
3610
- function resolvePath(path, scope) {
3611
- const parts = path.trim().split(".");
3612
- let current = scope;
3613
- for (const part of parts) {
3614
- if (current == null || typeof current !== "object") return void 0;
3615
- current = current[part];
3616
- }
3617
- return current;
3618
- }
3619
- function evaluateExpression(expr2, scopes) {
3620
- const trimmed = expr2.trim();
3621
- if (trimmed.startsWith("'") && trimmed.endsWith("'") || trimmed.startsWith('"') && trimmed.endsWith('"')) {
3622
- return trimmed.slice(1, -1);
3623
- }
3624
- if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
3625
- return Number(trimmed);
3626
- }
3627
- if (trimmed === "true") return true;
3628
- if (trimmed === "false") return false;
3629
- if (trimmed === "null" || trimmed === "undefined") return void 0;
3630
- const flatScope = { ...scopes };
3631
- if (scopes.state_data && typeof scopes.state_data === "object") {
3632
- Object.assign(flatScope, scopes.state_data);
3633
- }
3634
- if (scopes.context && typeof scopes.context === "object") {
3635
- Object.assign(flatScope, scopes.context);
3636
- }
3637
- return resolvePath(trimmed, flatScope);
3638
- }
3639
- function evaluateProp(value, scopes) {
3640
- if (typeof value !== "string") return value;
3641
- const fullMatch = value.match(/^\{\{(.+)\}\}$/s);
3642
- if (fullMatch) {
3643
- return evaluateExpression(fullMatch[1], scopes);
3644
- }
3645
- if (containsExpression(value)) {
3646
- return value.replace(EXPR_PATTERN, (_, expr2) => {
3647
- const result = evaluateExpression(expr2, scopes);
3648
- return result == null ? "" : String(result);
3649
- });
3650
- }
3651
- return value;
3652
- }
3653
-
3654
- // src/player/ComponentTreeRenderer.tsx
3655
- import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
3656
- var UnknownAtom = ({ type, children }) => /* @__PURE__ */ jsxs("div", { style: { border: "1px dashed #e53e3e", borderRadius: 6, padding: "8px 12px", margin: 4, fontSize: 13, color: "#e53e3e", background: "#fff5f5" }, children: [
3657
- /* @__PURE__ */ jsxs("span", { style: { fontWeight: 600 }, children: [
3658
- "Unknown: ",
3659
- type
3660
- ] }),
3661
- children && /* @__PURE__ */ jsx2("div", { style: { marginTop: 4 }, children })
3662
- ] });
3663
- var RenderNode = ({ node, scopes, atoms, onEvent }) => {
3664
- if (node.$if) {
3665
- const condition = evaluateProp(node.$if, scopes);
3666
- if (!condition) return null;
3667
- }
3668
- if (node.$for) {
3669
- const { each, as, key: keyField } = node.$for;
3670
- const items = evaluateProp(each, scopes);
3671
- if (!Array.isArray(items)) return null;
3672
- return /* @__PURE__ */ jsx2(Fragment, { children: items.map((item, index) => {
3673
- const loopScopes = {
3674
- ...scopes,
3675
- state_data: {
3676
- ...scopes.state_data ?? {},
3677
- [as]: item,
3678
- [`${as}Index`]: index
3679
- }
3680
- };
3681
- const nodeWithoutFor = { ...node, $for: void 0 };
3682
- const itemKey = keyField ? String(item[keyField] ?? index) : String(index);
3683
- return /* @__PURE__ */ jsx2(RenderNode, { node: nodeWithoutFor, scopes: loopScopes, atoms, onEvent }, itemKey);
3684
- }) });
3685
- }
3686
- const Component = atoms[node.type];
3687
- if (!Component) {
3688
- return /* @__PURE__ */ jsx2(UnknownAtom, { type: node.type });
3689
- }
3690
- const evaluatedProps = {};
3691
- if (node.props) {
3692
- for (const [key, value] of Object.entries(node.props)) {
3693
- if (key.startsWith("on") && typeof value === "string") {
3694
- evaluatedProps[key] = (...args) => {
3695
- if (containsExpression(value)) {
3696
- evaluateExpression(value.replace(/^\{\{|\}\}$/g, ""), scopes);
3697
- } else {
3698
- onEvent(value, args[0]);
3699
- }
3700
- };
3701
- } else {
3702
- evaluatedProps[key] = evaluateProp(value, scopes);
3703
- }
3704
- }
3705
- }
3706
- let children = null;
3707
- if (node.children) {
3708
- if (typeof node.children === "string") {
3709
- children = evaluateProp(node.children, scopes);
3710
- } else if (Array.isArray(node.children)) {
3711
- children = node.children.map((child, index) => /* @__PURE__ */ jsx2(RenderNode, { node: child, scopes, atoms, onEvent }, index));
3712
- }
3713
- }
3714
- return /* @__PURE__ */ jsx2(Component, { ...evaluatedProps, children });
3715
- };
3716
- var CTRErrorBoundary = class extends React.Component {
3717
- constructor(props) {
3718
- super(props);
3719
- this.state = { hasError: false };
3720
- }
3721
- static getDerivedStateFromError(error) {
3722
- return { hasError: true, error };
3723
- }
3724
- componentDidCatch(error, errorInfo) {
3725
- console.error("CTR rendering error:", error, errorInfo);
3726
- }
3727
- render() {
3728
- if (this.state.hasError) {
3729
- return this.props.fallback || /* @__PURE__ */ jsxs("div", { style: { padding: 16, background: "#fff5f5", border: "1px solid #fed7d7", borderRadius: 8 }, children: [
3730
- /* @__PURE__ */ jsx2("strong", { style: { color: "#c53030" }, children: "Rendering Error" }),
3731
- /* @__PURE__ */ jsx2("p", { style: { color: "#e53e3e", fontSize: 14, marginTop: 4 }, children: this.state.error?.message || "An error occurred while rendering" })
3732
- ] });
3733
- }
3734
- return this.props.children;
3735
- }
3736
- };
3737
- var ComponentTreeRenderer = ({
3738
- tree,
3739
- scopes,
3740
- atoms = {},
3741
- onEvent = () => {
3742
- },
3743
- fallback
3744
- }) => {
3745
- const allAtoms = useMemo17(() => ({ ...atoms }), [atoms]);
3746
- const handleEvent = useCallback21(
3747
- (eventName, payload) => onEvent(eventName, payload),
3748
- [onEvent]
3749
- );
3750
- const nodes = Array.isArray(tree) ? tree : [tree];
3751
- return /* @__PURE__ */ jsx2(CTRErrorBoundary, { fallback, children: nodes.map((node, index) => /* @__PURE__ */ jsx2(RenderNode, { node, scopes, atoms: allAtoms, onEvent: handleEvent }, index)) });
3752
- };
3753
-
3754
- // src/player/DevPlayer.tsx
3755
- import { useState as useState21, useCallback as useCallback22, useRef as useRef25, useEffect as useEffect22, useMemo as useMemo18 } from "react";
3756
-
3757
- // src/player/builtin-atoms.tsx
3758
- import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
3759
- var Stack = ({ children, gap = 8, style, ...rest }) => /* @__PURE__ */ jsx3("div", { style: { display: "flex", flexDirection: "column", gap, ...style }, ...rest, children });
3760
- var Row = ({ children, gap = 8, align, justify, style, ...rest }) => /* @__PURE__ */ jsx3("div", { style: { display: "flex", flexDirection: "row", gap, alignItems: align, justifyContent: justify, ...style }, ...rest, children });
3761
- var Column = ({ children, span, style, ...rest }) => /* @__PURE__ */ jsx3("div", { style: { flex: span ? `0 0 ${Number(span) / 12 * 100}%` : 1, ...style }, ...rest, children });
3762
- var Grid = ({ children, columns = 2, gap = 8, style, ...rest }) => /* @__PURE__ */ jsx3("div", { style: { display: "grid", gridTemplateColumns: `repeat(${columns}, 1fr)`, gap, ...style }, ...rest, children });
3763
- var Divider = ({ style }) => /* @__PURE__ */ jsx3("hr", { style: { border: "none", borderTop: "1px solid #e2e8f0", margin: "8px 0", ...style } });
3764
- var Spacer = ({ size = 16 }) => /* @__PURE__ */ jsx3("div", { style: { height: size, flexShrink: 0 } });
3765
- var Text = ({ children, size, weight, color, style, ...rest }) => /* @__PURE__ */ jsx3("span", { style: { fontSize: size, fontWeight: weight, color, ...style }, ...rest, children });
3766
- var Heading = ({ children, level = 2, style, ...rest }) => {
3767
- const lvl = Math.min(Math.max(Number(level), 1), 6);
3768
- const s = { margin: "0 0 8px", ...style };
3769
- const c = children;
3770
- if (lvl === 1) return /* @__PURE__ */ jsx3("h1", { style: s, ...rest, children: c });
3771
- if (lvl === 2) return /* @__PURE__ */ jsx3("h2", { style: s, ...rest, children: c });
3772
- if (lvl === 3) return /* @__PURE__ */ jsx3("h3", { style: s, ...rest, children: c });
3773
- if (lvl === 4) return /* @__PURE__ */ jsx3("h4", { style: s, ...rest, children: c });
3774
- if (lvl === 5) return /* @__PURE__ */ jsx3("h5", { style: s, ...rest, children: c });
3775
- return /* @__PURE__ */ jsx3("h6", { style: s, ...rest, children: c });
3776
- };
3777
- var Field = ({ label, value, children, style }) => /* @__PURE__ */ jsxs2("div", { style: { marginBottom: 8, ...style }, children: [
3778
- label ? /* @__PURE__ */ jsx3("div", { style: { fontSize: 12, color: "#718096", marginBottom: 2 }, children: label }) : null,
3779
- /* @__PURE__ */ jsx3("div", { style: { fontSize: 14 }, children: children ?? value ?? "\u2014" })
3780
- ] });
3781
- var Badge = ({ children, variant = "default", style }) => {
3782
- const colors = {
3783
- default: { bg: "#edf2f7", fg: "#4a5568" },
3784
- success: { bg: "#c6f6d5", fg: "#276749" },
3785
- warning: { bg: "#fefcbf", fg: "#975a16" },
3786
- error: { bg: "#fed7d7", fg: "#9b2c2c" },
3787
- info: { bg: "#bee3f8", fg: "#2a4365" }
3788
- };
3789
- const c = colors[variant] ?? colors.default;
3790
- return /* @__PURE__ */ jsx3("span", { style: { display: "inline-block", padding: "2px 8px", borderRadius: 9999, fontSize: 12, fontWeight: 500, background: c.bg, color: c.fg, ...style }, children });
3791
- };
3792
- var ImageAtom = ({ src, alt, width, height, style, ...rest }) => /* @__PURE__ */ jsx3("img", { src, alt: alt ?? "", width, height, style: { maxWidth: "100%", ...style }, ...rest });
3793
- var Button = ({ children, onClick, variant = "primary", disabled, style, ...rest }) => {
3794
- const styles = {
3795
- primary: { background: "#3182ce", color: "#fff", border: "none" },
3796
- secondary: { background: "#edf2f7", color: "#4a5568", border: "1px solid #e2e8f0" },
3797
- danger: { background: "#e53e3e", color: "#fff", border: "none" },
3798
- ghost: { background: "transparent", color: "#4a5568", border: "none" }
3799
- };
3800
- const base = styles[variant] ?? styles.primary;
3801
- return /* @__PURE__ */ jsx3(
3802
- "button",
3803
- {
3804
- onClick,
3805
- disabled,
3806
- style: { padding: "6px 16px", borderRadius: 6, fontSize: 14, fontWeight: 500, cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.5 : 1, ...base, ...style },
3807
- ...rest,
3808
- children
3809
- }
3810
- );
3811
- };
3812
- var LinkAtom = ({ children, href, style, ...rest }) => /* @__PURE__ */ jsx3("a", { href, style: { color: "#3182ce", textDecoration: "underline", ...style }, ...rest, children });
3813
- var TextInput = ({ value, onChange, placeholder, label, style, ...rest }) => /* @__PURE__ */ jsxs2("div", { style: { marginBottom: 8 }, children: [
3814
- label ? /* @__PURE__ */ jsx3("label", { style: { display: "block", fontSize: 12, color: "#718096", marginBottom: 2 }, children: label }) : null,
3815
- /* @__PURE__ */ jsx3(
3816
- "input",
3817
- {
3818
- type: "text",
3819
- value: value ?? "",
3820
- onChange,
3821
- placeholder,
3822
- style: { width: "100%", padding: "6px 10px", border: "1px solid #e2e8f0", borderRadius: 6, fontSize: 14, ...style },
3823
- ...rest
3824
- }
3825
- )
3826
- ] });
3827
- var SelectAtom = ({ value, onChange, options, label, placeholder, style }) => /* @__PURE__ */ jsxs2("div", { style: { marginBottom: 8 }, children: [
3828
- label ? /* @__PURE__ */ jsx3("label", { style: { display: "block", fontSize: 12, color: "#718096", marginBottom: 2 }, children: label }) : null,
3829
- /* @__PURE__ */ jsxs2(
3830
- "select",
3831
- {
3832
- value: value ?? "",
3833
- onChange,
3834
- style: { width: "100%", padding: "6px 10px", border: "1px solid #e2e8f0", borderRadius: 6, fontSize: 14, ...style },
3835
- children: [
3836
- placeholder ? /* @__PURE__ */ jsx3("option", { value: "", children: placeholder }) : null,
3837
- Array.isArray(options) && options.map((opt) => {
3838
- const v = typeof opt === "string" ? opt : opt.value;
3839
- const l = typeof opt === "string" ? opt : opt.label;
3840
- return /* @__PURE__ */ jsx3("option", { value: v, children: l }, v);
3841
- })
3842
- ]
3843
- }
3844
- )
3845
- ] });
3846
- var Card = ({ children, title, style, ...rest }) => /* @__PURE__ */ jsxs2("div", { style: { border: "1px solid #e2e8f0", borderRadius: 8, padding: 16, background: "#fff", ...style }, ...rest, children: [
3847
- title ? /* @__PURE__ */ jsx3("div", { style: { fontWeight: 600, fontSize: 16, marginBottom: 12 }, children: title }) : null,
3848
- children
3849
- ] });
3850
- var Section = ({ children, title, style, ...rest }) => /* @__PURE__ */ jsxs2("section", { style: { marginBottom: 24, ...style }, ...rest, children: [
3851
- title ? /* @__PURE__ */ jsx3("h3", { style: { fontSize: 18, fontWeight: 600, marginBottom: 8 }, children: title }) : null,
3852
- children
3853
- ] });
3854
- var Show = ({ when: when2, children, fallback }) => when2 ? /* @__PURE__ */ jsx3(Fragment2, { children }) : /* @__PURE__ */ jsx3(Fragment2, { children: fallback ?? null });
3855
- var Each = ({ items, children, renderItem }) => {
3856
- if (!Array.isArray(items)) return null;
3857
- if (typeof renderItem === "function") return /* @__PURE__ */ jsx3(Fragment2, { children: items.map((item, i) => renderItem(item, i)) });
3858
- return /* @__PURE__ */ jsx3(Fragment2, { children });
3859
- };
3860
- var builtinAtoms = {
3861
- Stack,
3862
- Row,
3863
- Column,
3864
- Grid,
3865
- Divider,
3866
- Spacer,
3867
- Text,
3868
- Heading,
3869
- Field,
3870
- Badge,
3871
- Image: ImageAtom,
3872
- Button,
3873
- Link: LinkAtom,
3874
- TextInput,
3875
- Select: SelectAtom,
3876
- Card,
3877
- Section,
3878
- Show,
3879
- Each
3880
- };
3881
-
3882
- // src/player/DevPlayer.tsx
3883
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
3884
- var S = {
3885
- shell: {
3886
- display: "flex",
3887
- flexDirection: "column",
3888
- height: "100%",
3889
- minHeight: "100vh",
3890
- fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
3891
- background: "#f7fafc",
3892
- color: "#1a202c"
3893
- },
3894
- toolbar: {
3895
- display: "flex",
3896
- alignItems: "center",
3897
- gap: 12,
3898
- padding: "8px 16px",
3899
- background: "#1a202c",
3900
- color: "#e2e8f0",
3901
- fontSize: 13,
3902
- flexShrink: 0
3903
- },
3904
- toolbarTitle: { fontWeight: 600, fontSize: 14 },
3905
- toolbarBadge: {
3906
- display: "inline-block",
3907
- padding: "1px 8px",
3908
- borderRadius: 4,
3909
- background: "#2d3748",
3910
- color: "#a0aec0",
3911
- fontSize: 11,
3912
- fontFamily: "monospace"
3913
- },
3914
- toolbarBtn: {
3915
- background: "none",
3916
- border: "1px solid #4a5568",
3917
- borderRadius: 4,
3918
- color: "#a0aec0",
3919
- padding: "2px 10px",
3920
- fontSize: 12,
3921
- cursor: "pointer"
3922
- },
3923
- toolbarBtnActive: {
3924
- background: "#2b6cb0",
3925
- borderColor: "#2b6cb0",
3926
- color: "#fff"
3927
- },
3928
- body: { display: "flex", flex: 1, overflow: "hidden" },
3929
- preview: { flex: 1, overflow: "auto", padding: 24 },
3930
- sidebar: {
3931
- width: 340,
3932
- flexShrink: 0,
3933
- borderLeft: "1px solid #e2e8f0",
3934
- background: "#fff",
3935
- overflow: "auto",
3936
- fontSize: 13
3937
- },
3938
- sidebarSection: { padding: "12px 16px", borderBottom: "1px solid #f0f0f0" },
3939
- sidebarHeading: {
3940
- fontSize: 11,
3941
- fontWeight: 700,
3942
- textTransform: "uppercase",
3943
- color: "#a0aec0",
3944
- letterSpacing: "0.05em",
3945
- marginBottom: 8
3946
- },
3947
- pre: {
3948
- background: "#f7fafc",
3949
- border: "1px solid #e2e8f0",
3950
- borderRadius: 6,
3951
- padding: "8px 12px",
3952
- fontSize: 12,
3953
- fontFamily: "monospace",
3954
- whiteSpace: "pre-wrap",
3955
- wordBreak: "break-word",
3956
- maxHeight: 260,
3957
- overflow: "auto"
3958
- },
3959
- eventRow: {
3960
- display: "flex",
3961
- gap: 8,
3962
- padding: "4px 0",
3963
- borderBottom: "1px solid #f7fafc",
3964
- fontSize: 12,
3965
- fontFamily: "monospace"
3966
- },
3967
- eventTime: { color: "#a0aec0", flexShrink: 0 },
3968
- eventName: { color: "#3182ce", fontWeight: 500 },
3969
- dot: (connected) => ({
3970
- width: 8,
3971
- height: 8,
3972
- borderRadius: "50%",
3973
- background: connected ? "#48bb78" : "#e53e3e",
3974
- flexShrink: 0
3975
- })
3976
- };
3977
- function useDevSocket(wsUrl, onReload) {
3978
- const [connected, setConnected] = useState21(false);
3979
- const wsRef = useRef25(null);
3980
- useEffect22(() => {
3981
- if (typeof window === "undefined") return;
3982
- const url = wsUrl ?? `ws://${window.location.host}/__mm_dev`;
3983
- let ws;
3984
- let reconnectTimer;
3985
- function connect() {
3986
- try {
3987
- ws = new WebSocket(url);
3988
- wsRef.current = ws;
3989
- ws.onopen = () => setConnected(true);
3990
- ws.onclose = () => {
3991
- setConnected(false);
3992
- reconnectTimer = setTimeout(connect, 3e3);
3993
- };
3994
- ws.onmessage = (ev) => {
3995
- try {
3996
- const msg = JSON.parse(ev.data);
3997
- if (msg.type === "workflow:compiled" || msg.type === "workflow:rebuild") {
3998
- onReload?.();
3999
- }
4000
- } catch {
4001
- }
4002
- };
4003
- } catch {
4004
- reconnectTimer = setTimeout(connect, 3e3);
4005
- }
4006
- }
4007
- connect();
4008
- return () => {
4009
- clearTimeout(reconnectTimer);
4010
- wsRef.current?.close();
4011
- wsRef.current = null;
4012
- };
4013
- }, [wsUrl, onReload]);
4014
- return connected;
4015
- }
4016
- var DevPlayer = ({
4017
- tree,
4018
- scopes = {},
4019
- atoms: userAtoms,
4020
- title = "DevPlayer",
4021
- bare = false,
4022
- wsUrl,
4023
- onReload,
4024
- onEvent: externalOnEvent
4025
- }) => {
4026
- const [showSidebar, setShowSidebar] = useState21(true);
4027
- const [events, setEvents] = useState21([]);
4028
- const nextId = useRef25(0);
4029
- const connected = useDevSocket(wsUrl, onReload);
4030
- const mergedAtoms = useMemo18(
4031
- () => ({ ...builtinAtoms, ...userAtoms }),
4032
- [userAtoms]
4033
- );
4034
- const handleEvent = useCallback22(
4035
- (name, payload) => {
4036
- setEvents((prev) => {
4037
- const entry = {
4038
- id: nextId.current++,
4039
- time: (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: false }),
4040
- name,
4041
- payload
4042
- };
4043
- const next = [entry, ...prev];
4044
- return next.length > 100 ? next.slice(0, 100) : next;
4045
- });
4046
- externalOnEvent?.(name, payload);
4047
- },
4048
- [externalOnEvent]
4049
- );
4050
- if (bare) {
4051
- return /* @__PURE__ */ jsx4(
4052
- ComponentTreeRenderer,
4053
- {
4054
- tree,
4055
- scopes,
4056
- atoms: mergedAtoms,
4057
- onEvent: handleEvent
4058
- }
4059
- );
4060
- }
4061
- return /* @__PURE__ */ jsxs3("div", { style: S.shell, children: [
4062
- /* @__PURE__ */ jsxs3("div", { style: S.toolbar, children: [
4063
- /* @__PURE__ */ jsx4("div", { style: S.dot(connected), title: connected ? "HMR connected" : "HMR disconnected" }),
4064
- /* @__PURE__ */ jsx4("span", { style: S.toolbarTitle, children: title }),
4065
- /* @__PURE__ */ jsxs3("span", { style: S.toolbarBadge, children: [
4066
- Array.isArray(tree) ? tree.length : 1,
4067
- " node",
4068
- Array.isArray(tree) && tree.length !== 1 ? "s" : ""
4069
- ] }),
4070
- /* @__PURE__ */ jsxs3("span", { style: S.toolbarBadge, children: [
4071
- Object.keys(mergedAtoms).length,
4072
- " atoms"
4073
- ] }),
4074
- /* @__PURE__ */ jsx4("div", { style: { flex: 1 } }),
4075
- /* @__PURE__ */ jsx4(
4076
- "button",
4077
- {
4078
- style: { ...S.toolbarBtn, ...showSidebar ? S.toolbarBtnActive : {} },
4079
- onClick: () => setShowSidebar((v) => !v),
4080
- children: "Inspector"
4081
- }
4082
- )
4083
- ] }),
4084
- /* @__PURE__ */ jsxs3("div", { style: S.body, children: [
4085
- /* @__PURE__ */ jsx4("div", { style: S.preview, children: /* @__PURE__ */ jsx4(
4086
- ComponentTreeRenderer,
4087
- {
4088
- tree,
4089
- scopes,
4090
- atoms: mergedAtoms,
4091
- onEvent: handleEvent
4092
- }
4093
- ) }),
4094
- showSidebar && /* @__PURE__ */ jsxs3("div", { style: S.sidebar, children: [
4095
- /* @__PURE__ */ jsxs3("div", { style: S.sidebarSection, children: [
4096
- /* @__PURE__ */ jsx4("div", { style: S.sidebarHeading, children: "Scopes" }),
4097
- /* @__PURE__ */ jsx4("pre", { style: S.pre, children: JSON.stringify(scopes, null, 2) })
4098
- ] }),
4099
- /* @__PURE__ */ jsxs3("div", { style: S.sidebarSection, children: [
4100
- /* @__PURE__ */ jsxs3("div", { style: S.sidebarHeading, children: [
4101
- "Atoms (",
4102
- Object.keys(mergedAtoms).length,
4103
- ")"
4104
- ] }),
4105
- /* @__PURE__ */ jsx4("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: Object.keys(mergedAtoms).sort().map((name) => /* @__PURE__ */ jsx4(
4106
- "span",
4107
- {
4108
- style: {
4109
- display: "inline-block",
4110
- padding: "1px 6px",
4111
- borderRadius: 3,
4112
- background: userAtoms?.[name] ? "#ebf8ff" : "#f7fafc",
4113
- border: `1px solid ${userAtoms?.[name] ? "#90cdf4" : "#e2e8f0"}`,
4114
- fontSize: 11,
4115
- fontFamily: "monospace",
4116
- color: userAtoms?.[name] ? "#2b6cb0" : "#718096"
4117
- },
4118
- children: name
4119
- },
4120
- name
4121
- )) })
4122
- ] }),
4123
- /* @__PURE__ */ jsxs3("div", { style: S.sidebarSection, children: [
4124
- /* @__PURE__ */ jsxs3("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 8 }, children: [
4125
- /* @__PURE__ */ jsxs3("div", { style: S.sidebarHeading, children: [
4126
- "Events (",
4127
- events.length,
4128
- ")"
4129
- ] }),
4130
- events.length > 0 && /* @__PURE__ */ jsx4(
4131
- "button",
4132
- {
4133
- style: { background: "none", border: "none", color: "#a0aec0", fontSize: 11, cursor: "pointer" },
4134
- onClick: () => setEvents([]),
4135
- children: "Clear"
4136
- }
4137
- )
4138
- ] }),
4139
- events.length === 0 && /* @__PURE__ */ jsx4("div", { style: { color: "#a0aec0", fontSize: 12, fontStyle: "italic" }, children: "No events yet" }),
4140
- events.slice(0, 50).map((e) => /* @__PURE__ */ jsxs3("div", { style: S.eventRow, children: [
4141
- /* @__PURE__ */ jsx4("span", { style: S.eventTime, children: e.time }),
4142
- /* @__PURE__ */ jsx4("span", { style: S.eventName, children: e.name }),
4143
- e.payload !== void 0 && /* @__PURE__ */ jsx4("span", { style: { color: "#718096", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: JSON.stringify(e.payload) })
4144
- ] }, e.id))
4145
- ] }),
4146
- /* @__PURE__ */ jsxs3("div", { style: S.sidebarSection, children: [
4147
- /* @__PURE__ */ jsx4("div", { style: S.sidebarHeading, children: "Tree (JSON)" }),
4148
- /* @__PURE__ */ jsx4("pre", { style: { ...S.pre, maxHeight: 400 }, children: JSON.stringify(tree, null, 2) })
4149
- ] })
4150
- ] })
4151
- ] })
4152
- ] });
4153
- };
4154
-
4155
- // src/atoms/index.ts
4156
- function stub(displayName) {
4157
- const Component = () => {
4158
- throw new Error(
4159
- `<${displayName}> is a compile-time stub from @mmapp/react/atoms. It should only appear in .workflow.tsx files processed by the compiler. At runtime, use the ComponentTreeRenderer which resolves "${displayName}" from the component registry.`
4160
- );
4161
- };
4162
- Component.displayName = displayName;
4163
- return Component;
4164
- }
4165
- var Stack2 = stub("Stack");
4166
- var Row2 = stub("Row");
4167
- var Column2 = stub("Column");
4168
- var Grid2 = stub("Grid");
4169
- var Divider2 = stub("Divider");
4170
- var Spacer2 = stub("Spacer");
4171
- var Text2 = stub("Text");
4172
- var Heading2 = stub("Heading");
4173
- var Field2 = stub("Field");
4174
- var Image = stub("Image");
4175
- var Badge2 = stub("Badge");
4176
- var Icon = stub("Icon");
4177
- var Button2 = stub("Button");
4178
- var Link = stub("Link");
4179
- var Show2 = stub("Show");
4180
- var Each2 = stub("Each");
4181
- var Card2 = stub("Card");
4182
- var Tabs = stub("Tabs");
4183
- var Accordion = stub("Accordion");
4184
- var Section2 = stub("Section");
4185
- var Modal = stub("Modal");
4186
- var TextInput2 = stub("TextInput");
4187
- var Select = stub("Select");
4188
- var Markdown = stub("Markdown");
4189
- var ScrollArea = stub("ScrollArea");
4190
- var Canvas3D = stub("Canvas3D");
4191
- var DataGrid = stub("DataGrid");
4192
- var AnimatedBox = stub("AnimatedBox");
4193
- var ServerGrid = stub("ServerGrid");
4194
- var Chart = stub("Chart");
4195
- var MetricCard = stub("MetricCard");
4196
- var Slot = stub("Slot");
4197
- var ModuleOutlet = stub("ModuleOutlet");
4198
- var MetricsGrid = stub("MetricsGrid");
4199
- var AdaptiveCardGrid = stub("AdaptiveCardGrid");
4200
- var AdaptiveFilters = stub("AdaptiveFilters");
4201
- var Pagination = stub("Pagination");
4202
- var EntityHeader = stub("EntityHeader");
4203
- var ProgressTracker = stub("ProgressTracker");
4204
- var RatingWidget = stub("RatingWidget");
4205
- var FieldSection = stub("FieldSection");
4206
- var TransitionActions = stub("TransitionActions");
4207
- var ChildInstanceList = stub("ChildInstanceList");
4208
- var BreakdownCharts = stub("BreakdownCharts");
4209
- var TabbedLayout = stub("TabbedLayout");
4210
- var HierarchyBreadcrumb = stub("HierarchyBreadcrumb");
4211
- var SearchInput = stub("SearchInput");
4212
- var SortControl = stub("SortControl");
4213
- var AggregateStats = stub("AggregateStats");
4214
- var Router = stub("Router");
4215
- var Route = stub("Route");
4216
- var NavLink = stub("NavLink");
4217
- var RoleGuard = stub("RoleGuard");
4218
-
4219
3505
  // src/grammar/index.ts
4220
3506
  function createIsland(contextTag, strings, values) {
4221
3507
  let rawSource = "";
@@ -4283,7 +3569,7 @@ function djb2Hash(str) {
4283
3569
  }
4284
3570
 
4285
3571
  // src/authoring.ts
4286
- function useState22(_defaultOrKey) {
3572
+ function useState19(_defaultOrKey) {
4287
3573
  return [void 0, () => {
4288
3574
  }];
4289
3575
  }
@@ -4294,10 +3580,10 @@ function defineWorkspace(config) {
4294
3580
  }
4295
3581
 
4296
3582
  // src/hooks/useModule.ts
4297
- import { useMemo as useMemo19 } from "react";
3583
+ import { useMemo as useMemo17 } from "react";
4298
3584
  function useModule(slug, config = {}, options = {}) {
4299
3585
  const { enabled = true } = options;
4300
- return useMemo19(() => ({
3586
+ return useMemo17(() => ({
4301
3587
  slug,
4302
3588
  config,
4303
3589
  isLoaded: enabled
@@ -4305,7 +3591,7 @@ function useModule(slug, config = {}, options = {}) {
4305
3591
  }
4306
3592
 
4307
3593
  // src/hooks/useModuleConfig.ts
4308
- import { useCallback as useCallback23, useMemo as useMemo20, useState as useState23 } from "react";
3594
+ import { useCallback as useCallback19, useMemo as useMemo18, useState as useState20 } from "react";
4309
3595
  var installedModulesStore = [];
4310
3596
  var configDefaultsStore = /* @__PURE__ */ new Map();
4311
3597
  function setInstalledModules(modules) {
@@ -4321,7 +3607,7 @@ function getInstalledModules() {
4321
3607
  return installedModulesStore;
4322
3608
  }
4323
3609
  function useModuleConfig(moduleSlug) {
4324
- return useMemo20(() => {
3610
+ return useMemo18(() => {
4325
3611
  const installed = getInstalledModule(moduleSlug);
4326
3612
  const defaults = configDefaultsStore.get(moduleSlug) ?? {};
4327
3613
  const persisted = persistedConfigStore.get(moduleSlug) ?? {};
@@ -4369,8 +3655,8 @@ async function updateDefinitionConfig(values, definitionId) {
4369
3655
  }
4370
3656
  function useModuleConfigWithMutation(moduleSlug) {
4371
3657
  const config = useModuleConfig(moduleSlug);
4372
- const [isSaving, setIsSaving] = useState23(false);
4373
- const updateConfig = useCallback23(async (values) => {
3658
+ const [isSaving, setIsSaving] = useState20(false);
3659
+ const updateConfig = useCallback19(async (values) => {
4374
3660
  setIsSaving(true);
4375
3661
  try {
4376
3662
  return await updateDefinitionConfig(values);
@@ -6573,7 +5859,7 @@ function describeModel(def) {
6573
5859
  }
6574
5860
 
6575
5861
  // src/hooks/usePlayer.ts
6576
- import { useCallback as useCallback24, useEffect as useEffect23, useMemo as useMemo21, useRef as useRef26, useState as useState24 } from "react";
5862
+ import { useCallback as useCallback20, useEffect as useEffect21, useMemo as useMemo19, useRef as useRef23, useState as useState21 } from "react";
6577
5863
  import {
6578
5864
  StateMachine as StateMachine2,
6579
5865
  EventBus as EventBus2,
@@ -6620,18 +5906,18 @@ function computePlayerState(sm) {
6620
5906
  };
6621
5907
  }
6622
5908
  function usePlayer(config) {
6623
- const configRef = useRef26(config);
5909
+ const configRef = useRef23(config);
6624
5910
  configRef.current = config;
6625
- useEffect23(() => {
5911
+ useEffect21(() => {
6626
5912
  if (config.debug) setPlayerDebug(true);
6627
5913
  }, [config.debug]);
6628
- const evaluator = useMemo21(() => {
5914
+ const evaluator = useMemo19(() => {
6629
5915
  return createEvaluator2({
6630
5916
  functions: config.functions ?? [],
6631
5917
  failurePolicy: WEB_FAILURE_POLICIES2.EVENT_REACTION
6632
5918
  });
6633
5919
  }, [config.definition.id]);
6634
- const engine = useMemo21(() => {
5920
+ const engine = useMemo19(() => {
6635
5921
  const actionHandlers = /* @__PURE__ */ new Map();
6636
5922
  if (config.actionHandlers) {
6637
5923
  for (const [type, handler] of Object.entries(config.actionHandlers)) {
@@ -6685,8 +5971,8 @@ function usePlayer(config) {
6685
5971
  return { sm: sm2, eventBus: eventBus2, dispatcher };
6686
5972
  }, [config.definition.id, evaluator]);
6687
5973
  const { sm, eventBus } = engine;
6688
- const [playerState, setPlayerState] = useState24(() => computePlayerState(sm));
6689
- useEffect23(() => {
5974
+ const [playerState, setPlayerState] = useState21(() => computePlayerState(sm));
5975
+ useEffect21(() => {
6690
5976
  const stateDef = sm.getCurrentStateDefinition();
6691
5977
  if (!stateDef?.on_event?.length) return;
6692
5978
  const unsubs = [];
@@ -6750,7 +6036,7 @@ function usePlayer(config) {
6750
6036
  for (const unsub of unsubs) unsub();
6751
6037
  };
6752
6038
  }, [sm, eventBus, evaluator, engine.dispatcher, playerState.currentState]);
6753
- useEffect23(() => {
6039
+ useEffect21(() => {
6754
6040
  const unsub = sm.on((event) => {
6755
6041
  if (event.type === "transition" || event.type === "state_enter") {
6756
6042
  setPlayerState(computePlayerState(sm));
@@ -6766,7 +6052,7 @@ function usePlayer(config) {
6766
6052
  });
6767
6053
  return unsub;
6768
6054
  }, [sm]);
6769
- const transition2 = useCallback24(
6055
+ const transition2 = useCallback20(
6770
6056
  async (name, data) => {
6771
6057
  playerLog({
6772
6058
  level: "info",
@@ -6793,20 +6079,20 @@ function usePlayer(config) {
6793
6079
  },
6794
6080
  [sm]
6795
6081
  );
6796
- const setField2 = useCallback24(
6082
+ const setField2 = useCallback20(
6797
6083
  (field2, value) => {
6798
6084
  sm.setField(field2, value);
6799
6085
  setPlayerState(computePlayerState(sm));
6800
6086
  },
6801
6087
  [sm]
6802
6088
  );
6803
- const setMemory = useCallback24(
6089
+ const setMemory = useCallback20(
6804
6090
  (key, value) => {
6805
6091
  sm.setMemory(key, value);
6806
6092
  },
6807
6093
  [sm]
6808
6094
  );
6809
- const publishEvent = useCallback24(
6095
+ const publishEvent = useCallback20(
6810
6096
  (topic, payload) => {
6811
6097
  playerLog({
6812
6098
  level: "debug",
@@ -6832,11 +6118,11 @@ function usePlayer(config) {
6832
6118
  }
6833
6119
 
6834
6120
  // src/hooks/useDomainSubscription.ts
6835
- import { useEffect as useEffect24, useRef as useRef27 } from "react";
6121
+ import { useEffect as useEffect22, useRef as useRef24 } from "react";
6836
6122
  function useDomainSubscription(eventBus, transport, config) {
6837
- const configRef = useRef27(config);
6123
+ const configRef = useRef24(config);
6838
6124
  configRef.current = config;
6839
- useEffect24(() => {
6125
+ useEffect22(() => {
6840
6126
  if (!transport || config.enabled === false) return;
6841
6127
  const unsub = transport.subscribe(
6842
6128
  {
@@ -6889,11 +6175,11 @@ function useDomainSubscription(eventBus, transport, config) {
6889
6175
  }
6890
6176
 
6891
6177
  // src/hooks/useExperienceState.ts
6892
- import { useCallback as useCallback25, useRef as useRef28 } from "react";
6178
+ import { useCallback as useCallback21, useRef as useRef25 } from "react";
6893
6179
  function useExperienceState(player, selector) {
6894
- const selectorRef = useRef28(selector);
6180
+ const selectorRef = useRef25(selector);
6895
6181
  selectorRef.current = selector;
6896
- const getSnapshot = useCallback25(() => {
6182
+ const getSnapshot = useCallback21(() => {
6897
6183
  return selectorRef.current({
6898
6184
  currentState: player.currentState,
6899
6185
  stateData: player.stateData,
@@ -6909,20 +6195,20 @@ function useStateField(player, field2, defaultValue) {
6909
6195
  }
6910
6196
 
6911
6197
  // src/hooks/useComputed.ts
6912
- import { useMemo as useMemo22, useRef as useRef29 } from "react";
6198
+ import { useMemo as useMemo20, useRef as useRef26 } from "react";
6913
6199
  function useComputed(_name, compute, options) {
6914
6200
  const mode = options?.mode ?? "read-time";
6915
6201
  const deps = options?.deps ?? [];
6916
- const computeRef = useRef29(compute);
6202
+ const computeRef = useRef26(compute);
6917
6203
  computeRef.current = compute;
6918
6204
  if (mode === "read-time") {
6919
- return useMemo22(() => computeRef.current(), [
6205
+ return useMemo20(() => computeRef.current(), [
6920
6206
  // We intentionally depend on deps.join to recompute when tracked fields change
6921
6207
  // The actual dependency tracking happens at the compiler level
6922
6208
  deps.join(",")
6923
6209
  ]);
6924
6210
  }
6925
- return useMemo22(() => computeRef.current(), [deps.join(",")]);
6211
+ return useMemo20(() => computeRef.current(), [deps.join(",")]);
6926
6212
  }
6927
6213
  function useComputedWithMeta(name, compute, options) {
6928
6214
  const value = useComputed(name, compute, options);
@@ -6938,25 +6224,18 @@ function useComputedWithMeta(name, compute, options) {
6938
6224
 
6939
6225
  // src/components/PlayerProvider.tsx
6940
6226
  import { createContext as createContext3, useContext as useContext3 } from "react";
6941
- import { jsx as jsx5 } from "react/jsx-runtime";
6227
+ import { jsx as jsx2 } from "react/jsx-runtime";
6942
6228
  var PlayerContext = createContext3(null);
6943
- function PlayerProvider({ player, children }) {
6944
- return /* @__PURE__ */ jsx5(PlayerContext.Provider, { value: player, children });
6945
- }
6946
- function usePlayerContext() {
6947
- const ctx = useContext3(PlayerContext);
6948
- if (!ctx) {
6949
- throw new Error("usePlayerContext must be used within a <PlayerProvider>");
6950
- }
6951
- return ctx;
6229
+ function PlayerProvider2({ player, children }) {
6230
+ return /* @__PURE__ */ jsx2(PlayerContext.Provider, { value: player, children });
6952
6231
  }
6953
6232
  function usePlayerContextSafe() {
6954
6233
  return useContext3(PlayerContext);
6955
6234
  }
6956
6235
 
6957
6236
  // src/components/ExperienceWorkflowBridge.tsx
6958
- import { useMemo as useMemo23 } from "react";
6959
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
6237
+ import { useMemo as useMemo21 } from "react";
6238
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
6960
6239
  function ExperienceWorkflowBridgeInner({
6961
6240
  definition,
6962
6241
  initialData,
@@ -6973,12 +6252,12 @@ function ExperienceWorkflowBridgeInner({
6973
6252
  actionHandlers,
6974
6253
  debug
6975
6254
  });
6976
- const viewConfig = useMemo23(() => {
6255
+ const viewConfig = useMemo21(() => {
6977
6256
  if (!definition.state_views) return void 0;
6978
6257
  return definition.state_views[player.currentState];
6979
6258
  }, [definition.state_views, player.currentState]);
6980
- return /* @__PURE__ */ jsxs4(PlayerProvider, { player, children: [
6981
- /* @__PURE__ */ jsx6(
6259
+ return /* @__PURE__ */ jsxs(PlayerProvider2, { player, children: [
6260
+ /* @__PURE__ */ jsx3(
6982
6261
  DomainSubscriptionBridge,
6983
6262
  {
6984
6263
  player,
@@ -7004,12 +6283,12 @@ function DomainSubscriptionBridge({
7004
6283
  return null;
7005
6284
  }
7006
6285
  function ExperienceWorkflowBridge(props) {
7007
- return /* @__PURE__ */ jsx6(ExperienceWorkflowBridgeInner, { ...props });
6286
+ return /* @__PURE__ */ jsx3(ExperienceWorkflowBridgeInner, { ...props });
7008
6287
  }
7009
6288
 
7010
6289
  // src/components/atoms/index.tsx
7011
- import React3 from "react";
7012
- import { Fragment as Fragment3, jsx as jsx7 } from "react/jsx-runtime";
6290
+ import React from "react";
6291
+ import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
7013
6292
 
7014
6293
  // src/loader/experience-workflow-loader.ts
7015
6294
  function validateExperienceWorkflow(def) {
@@ -8060,25 +7339,27 @@ var instance = compileTimeProxy("instance");
8060
7339
  export {
8061
7340
  Accordion,
8062
7341
  AnimatedBox,
7342
+ AtomRegistryImpl,
8063
7343
  BUILT_IN_CONSTRAINTS,
8064
- Badge2 as Badge,
7344
+ Badge,
8065
7345
  Blueprint,
8066
7346
  BrowserPlayer,
8067
- Button2 as Button,
7347
+ Button,
8068
7348
  Canvas3D,
8069
- Card2 as Card,
7349
+ Card,
8070
7350
  Chart,
8071
- Column2 as Column,
7351
+ Column,
8072
7352
  ComponentTreeRenderer,
8073
7353
  DataGrid,
8074
7354
  DevPlayer,
8075
- Divider2 as Divider,
8076
- Each2 as Each,
7355
+ Divider,
7356
+ Each,
7357
+ ExperienceRenderer,
8077
7358
  ExperienceWorkflowBridge,
8078
- Field2 as Field,
7359
+ Field,
8079
7360
  FieldBuilder,
8080
- Grid2 as Grid,
8081
- Heading2 as Heading,
7361
+ Grid,
7362
+ Heading,
8082
7363
  Icon,
8083
7364
  Image,
8084
7365
  Link,
@@ -8094,20 +7375,21 @@ export {
8094
7375
  RoleGuard,
8095
7376
  Route,
8096
7377
  Router,
8097
- Row2 as Row,
7378
+ Row,
8098
7379
  RuntimeContext,
7380
+ ScopeContext,
8099
7381
  ScrollArea,
8100
- Section2 as Section,
7382
+ Section,
8101
7383
  Select,
8102
7384
  ServerGrid,
8103
- Show2 as Show,
7385
+ Show,
8104
7386
  Slot,
8105
- Spacer2 as Spacer,
8106
- Stack2 as Stack,
7387
+ Spacer,
7388
+ Stack,
8107
7389
  StateBuilder,
8108
7390
  Tabs,
8109
- Text2 as Text,
8110
- TextInput2 as TextInput,
7391
+ Text,
7392
+ TextInput,
8111
7393
  TransitionBuilder,
8112
7394
  TypedTransitionBuilder,
8113
7395
  WorkflowProvider,
@@ -8120,7 +7402,12 @@ export {
8120
7402
  applyMixins,
8121
7403
  approval,
8122
7404
  assertModelValid,
7405
+ buildActionScope,
7406
+ buildEvalContext,
7407
+ buildLoopScope,
7408
+ buildScope,
8123
7409
  builtinAtoms,
7410
+ builtinFunctions,
8124
7411
  cedar,
8125
7412
  compose,
8126
7413
  computeVisibility,
@@ -8128,7 +7415,9 @@ export {
8128
7415
  connector,
8129
7416
  constraints,
8130
7417
  createActions,
7418
+ createApiResolver,
8131
7419
  createCRUD,
7420
+ createCoreAtomRegistry,
8132
7421
  createLocalDataResolver,
8133
7422
  createLocalEngineAdapter,
8134
7423
  createPipeline,
@@ -8192,6 +7481,8 @@ export {
8192
7481
  llm,
8193
7482
  loadExperienceWorkflow,
8194
7483
  logEvent,
7484
+ mergeRegistries,
7485
+ mergeScope,
8195
7486
  model,
8196
7487
  named,
8197
7488
  normalizeDefinition,
@@ -8203,6 +7494,7 @@ export {
8203
7494
  orchestration,
8204
7495
  patch,
8205
7496
  pipe,
7497
+ evaluateExpression as playerEvaluateExpression,
8206
7498
  playerLog,
8207
7499
  prefetchData,
8208
7500
  refHasAnyRole,
@@ -8210,6 +7502,8 @@ export {
8210
7502
  requireAuth,
8211
7503
  requireField,
8212
7504
  requireRole,
7505
+ resolveAllBindings,
7506
+ resolveBinding,
8213
7507
  resolveOrchestration,
8214
7508
  restrict,
8215
7509
  review,
@@ -8279,6 +7573,7 @@ export {
8279
7573
  useRouteParams,
8280
7574
  useRouter,
8281
7575
  useRuntimeContext,
7576
+ useScope,
8282
7577
  useServerAction,
8283
7578
  useServerState,
8284
7579
  useStateField,
@@ -8288,7 +7583,7 @@ export {
8288
7583
  useVisibility,
8289
7584
  useWhileIn,
8290
7585
  useWorkflow,
8291
- useState22 as useWorkflowState,
7586
+ useState19 as useWorkflowState,
8292
7587
  userAction,
8293
7588
  userChoice,
8294
7589
  validate,