octane 0.2.2 → 0.2.3

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 (50) hide show
  1. package/dist/cjs/compatibility.cjs +35 -0
  2. package/dist/cjs/component-flags.cjs +8 -1
  3. package/dist/cjs/dom-tables.cjs +2 -0
  4. package/dist/cjs/error-codes.client.generated.cjs +15 -2
  5. package/dist/cjs/error-codes.server.generated.cjs +5 -0
  6. package/dist/cjs/event-names.cjs +39 -0
  7. package/dist/cjs/index.cjs +13 -0
  8. package/dist/cjs/runtime.cjs +1223 -332
  9. package/dist/cjs/runtime.server.cjs +362 -120
  10. package/dist/cjs/server/index.cjs +22 -0
  11. package/dist/cjs/version.cjs +1 -1
  12. package/dist/compatibility.d.ts +7 -0
  13. package/dist/compatibility.js +10 -0
  14. package/dist/compiler/bundler.js +13 -30
  15. package/dist/compiler/compile-renderer-boundaries.js +1 -0
  16. package/dist/compiler/compile-universal.js +3 -0
  17. package/dist/compiler/compile.js +619 -99
  18. package/dist/compiler/hook-deps.js +100 -3
  19. package/dist/compiler/hook-names.js +1 -0
  20. package/dist/compiler/manual-hooks.js +171 -0
  21. package/dist/compiler/plain-hook-memo.js +54 -5
  22. package/dist/compiler/slot-hooks.d.ts +43 -0
  23. package/dist/compiler/slot-hooks.js +154 -35
  24. package/dist/component-flags.d.ts +1 -1
  25. package/dist/component-flags.js +8 -1
  26. package/dist/dom-tables.js +2 -0
  27. package/dist/error-codes.client.generated.d.ts +3 -1
  28. package/dist/error-codes.client.generated.js +15 -2
  29. package/dist/error-codes.server.generated.d.ts +1 -0
  30. package/dist/error-codes.server.generated.js +5 -0
  31. package/dist/event-names.d.ts +1 -0
  32. package/dist/event-names.js +15 -0
  33. package/dist/html-tree-validation.d.ts +17 -34
  34. package/dist/index.d.ts +3 -1
  35. package/dist/index.js +12 -1
  36. package/dist/jsx-runtime.d.ts +6 -1
  37. package/dist/public-types.d.ts +188 -0
  38. package/dist/public-types.js +0 -0
  39. package/dist/runtime.d.ts +109 -66
  40. package/dist/runtime.js +1220 -332
  41. package/dist/runtime.server.d.ts +39 -14
  42. package/dist/runtime.server.js +356 -120
  43. package/dist/server/index.d.ts +4 -2
  44. package/dist/server/index.js +19 -0
  45. package/dist/static/index.d.ts +2 -1
  46. package/dist/static/index.js +3 -1
  47. package/dist/universal-core.d.ts +8 -1
  48. package/dist/universal-core.js +95 -9
  49. package/dist/version.js +1 -1
  50. package/package.json +2 -1
@@ -128,15 +128,18 @@ __export(runtime_exports, {
128
128
  hydrateRoot: () => hydrateRoot,
129
129
  ifBlock: () => ifBlock,
130
130
  injectStyle: () => injectStyle,
131
+ invokeManualHook: () => invokeManualHook,
131
132
  isChildrenBlock: () => isChildrenBlock,
132
133
  isValidElement: () => isValidElement,
133
134
  keyedForBlock: () => keyedForBlock,
134
135
  lazy: () => lazy,
136
+ manualHook: () => manualHook,
135
137
  mapSlot: () => mapSlot,
136
138
  markChildrenBlock: () => markChildrenBlock,
137
139
  markDangerouslySetInnerHTMLChildren: () => markDangerouslySetInnerHTMLChildren,
138
140
  markNativeChangeDiagnosticStatic: () => markNativeChangeDiagnosticStatic,
139
141
  markSingleRoot: () => markSingleRoot,
142
+ markWarm: () => markWarm,
140
143
  memo: () => memo,
141
144
  memoPublish: () => memoPublish,
142
145
  memoPublishAlways: () => memoPublishAlways,
@@ -268,6 +271,7 @@ __export(runtime_exports, {
268
271
  });
269
272
  module.exports = __toCommonJS(runtime_exports);
270
273
  var import_constants = require("./constants.cjs");
274
+ var import_event_names = require("./event-names.cjs");
271
275
  var import_has_own = require("./has-own.cjs");
272
276
  var import_head_ownership = require("./head-ownership.cjs");
273
277
  var import_resource_hint_diagnostics = require("./resource-hint-diagnostics.cjs");
@@ -343,15 +347,22 @@ function beginActiveNativeReadScope(scope) {
343
347
  const block = CURRENT_BLOCK;
344
348
  return block === null ? -1 : NATIVE_READ_DRIVER.beginScope(scope, block);
345
349
  }
350
+ function scheduleNativeRead(target) {
351
+ invalidateRender(target, target);
352
+ const retainPriority = SCHEDULED_VISIBILITY_DRIVER?.holdsNativeRead(target) === true;
353
+ if (retainPriority) TRANSITION_DEPTH++;
354
+ try {
355
+ scheduleRender(target);
356
+ } finally {
357
+ if (retainPriority) TRANSITION_DEPTH--;
358
+ }
359
+ }
346
360
  function ensureNativeReadDriver() {
347
361
  if (NATIVE_READ_DRIVER !== null) return NATIVE_READ_DRIVER;
348
362
  NATIVE_READ_DRIVER = (0, import_native_read_client.createNativeReadDriver)({
349
363
  capture: () => WIP_CAPTURE,
350
364
  cleanup: registerHookCleanup,
351
- schedule: (target) => {
352
- invalidateRender(target, target);
353
- scheduleRender(target);
354
- },
365
+ schedule: scheduleNativeRead,
355
366
  suspended: retainNativeRetryReads,
356
367
  replayRefs: (capture, owner) => replayNativeUnpublishedRefs(capture, owner),
357
368
  refDisposed: (entry) => blockSubtreeDisposed(entry.block)
@@ -440,10 +451,7 @@ function retainNativeRetryReads(block, reads) {
440
451
  if (retry2 === void 0) {
441
452
  const owner2 = current;
442
453
  retry2 = (0, import_native_read_retry.createNativeReadRetry)(() => {
443
- if (!owner2.disposed) {
444
- invalidateRender(owner2, owner2);
445
- scheduleRender(owner2);
446
- }
454
+ if (!owner2.disposed) scheduleNativeRead(owner2);
447
455
  });
448
456
  retries.set(owner2, retry2);
449
457
  const owned = retry2;
@@ -640,6 +648,9 @@ const RENDERER_REGION_DOM_OWNERS = /* @__PURE__ */ new WeakMap();
640
648
  const RENDERER_REGION_DOM_BINDINGS = /* @__PURE__ */ new WeakMap();
641
649
  const DOM_ROOT_DISPOSERS = /* @__PURE__ */ new WeakMap();
642
650
  let EFFECT_BODY_DEPTH = 0;
651
+ let CURRENT_EFFECT_PHASE = -1;
652
+ let EFFECT_COMMIT_DEPTH = 0;
653
+ let COMMIT_PHASE_ERRORS = null;
643
654
  let REF_CALLBACK_DEPTH = 0;
644
655
  let STORE_SYNC_DEPTH = 0;
645
656
  let EFFECT_EVENT_LIFECYCLE_DEPTH = 0;
@@ -653,12 +664,15 @@ function runEffectLifecycleCallback(callback) {
653
664
  EFFECT_EVENT_LIFECYCLE_DEPTH--;
654
665
  }
655
666
  }
656
- function runEffectCleanupCallback(callback) {
667
+ function runEffectCleanupCallback(callback, phase = -1) {
668
+ const previousPhase = CURRENT_EFFECT_PHASE;
669
+ CURRENT_EFFECT_PHASE = phase;
657
670
  EFFECT_BODY_DEPTH++;
658
671
  try {
659
672
  runEffectLifecycleCallback(callback);
660
673
  } finally {
661
674
  EFFECT_BODY_DEPTH--;
675
+ CURRENT_EFFECT_PHASE = previousPhase;
662
676
  }
663
677
  }
664
678
  const QUEUE = [];
@@ -677,17 +691,31 @@ function ensureTransitionSwapDriver() {
677
691
  splice: spliceWipCapture,
678
692
  begin: beginTransitionAttempt,
679
693
  end: endTransitionAttempt,
694
+ beginUrgent: beginUrgentTransitionRender,
695
+ endUrgent: endUrgentTransitionRender,
680
696
  holdRoot: holdRootTransition,
681
697
  retryRoot: retryRootTransition,
682
698
  commitRoot: commitRootTransition,
683
699
  discardRoot: discardRootTransition,
684
- keepsRoot: keepsRootTransition
700
+ keepsRoot: keepsRootTransition,
701
+ cancelEqual: cancelHeldTransitionUpdate,
702
+ hasHeld: hasHeldTransitionUpdate,
703
+ heldUpdate: getHeldTransitionUpdate,
704
+ rebaseHeld: rebaseHeldTransitionUpdate
685
705
  };
686
706
  }
687
707
  let ACTIVE_TRANSITION_ACTION_BATCH = null;
688
708
  let IN_FLIGHT_TRANSITION_ACTION_BATCH = null;
689
709
  function createTransitionActionBatch() {
690
- return { updates: /* @__PURE__ */ new Map(), pendingActions: 0, closed: false, flushed: false };
710
+ return {
711
+ updates: /* @__PURE__ */ new Map(),
712
+ pendingActions: 0,
713
+ closed: false,
714
+ flushed: false,
715
+ hook: null,
716
+ hooks: null,
717
+ hooksPending: false
718
+ };
691
719
  }
692
720
  function transitionActionBatchForUpdate() {
693
721
  if (ACTIVE_TRANSITION_ACTION_BATCH !== null) return ACTIVE_TRANSITION_ACTION_BATCH;
@@ -695,6 +723,7 @@ function transitionActionBatchForUpdate() {
695
723
  return IN_FLIGHT_TRANSITION_ACTION_BATCH;
696
724
  }
697
725
  function rebaseTransitionActionUpdate(update) {
726
+ if (update.state !== void 0 || update.reducer !== void 0) return update.value;
698
727
  if (Object.is(update.baseValue, update.slot.value)) return update.value;
699
728
  let value = update.slot.value;
700
729
  for (const operation of update.operations) value = operation(value);
@@ -703,26 +732,31 @@ function rebaseTransitionActionUpdate(update) {
703
732
  if (update.slot.pendingActionBatch !== void 0) update.slot.pendingActionValue = value;
704
733
  return value;
705
734
  }
706
- function stagedTransitionValue(slot) {
735
+ function stagedTransitionValue(slot, block) {
707
736
  const batch = transitionActionBatchForUpdate();
708
737
  if (batch === null) return slot.value;
709
738
  const update = batch.updates.get(slot);
710
- return update === void 0 ? slot.value : rebaseTransitionActionUpdate(update);
739
+ if (update !== void 0) return rebaseTransitionActionUpdate(update);
740
+ if (slot.renderTransition !== void 0) return slot.renderTransition.value;
741
+ const held = block === void 0 ? void 0 : TRANSITION_SWAP_DRIVER?.heldUpdate(slot, block);
742
+ return held === void 0 ? slot.value : held.value;
711
743
  }
712
744
  function stageTransitionValue(slot, block, operation, value, forceRender = false) {
713
745
  const batch = transitionActionBatchForUpdate();
714
- if (batch === null) return false;
746
+ if (batch === null) return null;
715
747
  const replay = typeof operation === "function" ? operation : () => operation;
716
- const current = batch.updates.get(slot);
748
+ let current = batch.updates.get(slot);
717
749
  if (current === void 0) {
718
- batch.updates.set(slot, {
750
+ current = {
751
+ batch,
719
752
  slot,
720
753
  block,
721
754
  operations: [replay],
722
755
  baseValue: slot.value,
723
756
  value,
724
757
  forceRender
725
- });
758
+ };
759
+ batch.updates.set(slot, current);
726
760
  } else {
727
761
  current.operations.push(replay);
728
762
  current.value = value;
@@ -730,23 +764,36 @@ function stageTransitionValue(slot, block, operation, value, forceRender = false
730
764
  }
731
765
  slot.pendingActionBatch = batch;
732
766
  slot.pendingActionValue = value;
733
- return true;
767
+ return current;
734
768
  }
735
769
  function flushTransitionActionBatch(batch) {
736
770
  if (batch.flushed) return;
737
771
  batch.flushed = true;
738
772
  for (const update of batch.updates.values()) {
739
773
  const { slot, block, forceRender } = update;
740
- const value = rebaseTransitionActionUpdate(update);
774
+ const value = update.state === void 0 && update.reducer === void 0 ? rebaseTransitionActionUpdate(update) : update.value;
741
775
  if (slot.pendingActionBatch === batch) {
742
776
  slot.pendingActionBatch = void 0;
743
777
  slot.pendingActionValue = void 0;
744
778
  }
745
779
  if (block.disposed) continue;
780
+ const state = update.state;
781
+ const reducer = update.reducer;
782
+ const previous = state?.renderTransition ?? reducer?.renderTransition;
783
+ if (state !== void 0 || reducer !== void 0) {
784
+ update.baseValue = previous === void 0 ? slot.value : previous.baseValue;
785
+ if (state !== void 0) {
786
+ state.updates = void 0;
787
+ } else if (reducer !== void 0) {
788
+ reducer.renderPhaseActions = void 0;
789
+ }
790
+ }
746
791
  const changed = !Object.is(slot.value, value);
747
- if (!changed && !forceRender) continue;
792
+ if (!changed && !forceRender && update.previous === void 0) continue;
748
793
  if (changed) slot.value = value;
749
- if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
794
+ if (update.reducer !== void 0) update.reducer.renderTransition = update;
795
+ if (update.state !== void 0) update.state.renderTransition = update;
796
+ if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && (changed || update.profileType !== "state"))
750
797
  (0, import_profiling.__profileSchedule)(
751
798
  block,
752
799
  update.profileType ?? (forceRender ? "reducer" : "state"),
@@ -772,6 +819,74 @@ function flushTransitionActionBatchIfReady(batch) {
772
819
  let DEFERRED_SPAWN = false;
773
820
  let TRANSITION_PENDING_COUNT = 0;
774
821
  const TRANSITION_LISTENERS = /* @__PURE__ */ new Set();
822
+ let TRANSITION_HOOK_HOLDERS = null;
823
+ function addTransitionHookToBatch(batch, hook) {
824
+ if (batch.hook === null) batch.hook = hook;
825
+ else if (batch.hook !== hook) {
826
+ const hooks = batch.hooks;
827
+ if (hooks === null) batch.hooks = [hook];
828
+ else if (hooks.includes(hook)) return;
829
+ else hooks.push(hook);
830
+ } else return;
831
+ if (batch.hooksPending) {
832
+ hook.pendingBatches++;
833
+ hook.publish(true);
834
+ }
835
+ }
836
+ function publishTransitionHookBatch(batch) {
837
+ const hook = batch.hook;
838
+ if (hook === null || batch.hooksPending) return;
839
+ batch.hooksPending = true;
840
+ hook.pendingBatches++;
841
+ hook.publish(true);
842
+ const hooks = batch.hooks;
843
+ if (hooks !== null) {
844
+ for (let i = 0; i < hooks.length; i++) {
845
+ hooks[i].pendingBatches++;
846
+ hooks[i].publish(true);
847
+ }
848
+ }
849
+ }
850
+ function finishTransitionHookBatch(batch) {
851
+ if (!batch.workComplete || batch.pendingActions !== 0 || (batch.pendingHolds ?? 0) !== 0) return;
852
+ if (!batch.hooksPending) return;
853
+ batch.hooksPending = false;
854
+ const hook = batch.hook;
855
+ if (--hook.pendingBatches === 0) hook.publish(false);
856
+ const hooks = batch.hooks;
857
+ if (hooks !== null) {
858
+ for (let i = 0; i < hooks.length; i++) {
859
+ if (--hooks[i].pendingBatches === 0) hooks[i].publish(false);
860
+ }
861
+ }
862
+ }
863
+ function holdTransitionHookBatch(holder, batch) {
864
+ if (batch.hook === null) return;
865
+ const holders = TRANSITION_HOOK_HOLDERS ??= /* @__PURE__ */ new WeakMap();
866
+ let batches = holders.get(holder);
867
+ if (batches === void 0) holders.set(holder, batches = /* @__PURE__ */ new Set());
868
+ if (batches.has(batch)) return;
869
+ batches.add(batch);
870
+ batch.pendingHolds = (batch.pendingHolds ?? 0) + 1;
871
+ publishTransitionHookBatch(batch);
872
+ }
873
+ function releaseTransitionHookHolder(holder) {
874
+ const batches = TRANSITION_HOOK_HOLDERS?.get(holder);
875
+ if (batches === void 0) return;
876
+ TRANSITION_HOOK_HOLDERS.delete(holder);
877
+ for (const batch of batches) {
878
+ batch.pendingHolds--;
879
+ finishTransitionHookBatch(batch);
880
+ }
881
+ }
882
+ function holdTransitionHooksForBlock(holder, block) {
883
+ for (const entries of FLUSHED_TRANSITION_UPDATES) {
884
+ for (const entry of entries) {
885
+ if (entry.batch !== void 0 && blockIsAncestor(entry.block, block))
886
+ holdTransitionHookBatch(holder, entry.batch);
887
+ }
888
+ }
889
+ }
775
890
  let TRANSITION_LISTENER_PUBLISH_DEPTH = 0;
776
891
  const HELD_TRANSITIONS = /* @__PURE__ */ new Set();
777
892
  const STAGED_REVEALS = /* @__PURE__ */ new Set();
@@ -780,6 +895,111 @@ let deferringStagedRevealEffects = false;
780
895
  let ACTIVE_TRANSITION_ATTEMPT = null;
781
896
  let FLUSHED_TRANSITION_UPDATES = [];
782
897
  let HELD_SYNC_TRANSITION = null;
898
+ function urgentTransitionCellUpdate(block) {
899
+ return TRANSITION_DEPTH === 0 && !(CURRENT_BLOCK === block && block.currentRenderMode === "transition") && (syncFlush || _dispatchDepth > 0 || ASYNC_TRANSITION_COUNT === 0);
900
+ }
901
+ function latestHeldTransitionUpdate(entry) {
902
+ while (entry.next?.batch?.flushed === true && !entry.next.superseded) entry = entry.next;
903
+ return entry;
904
+ }
905
+ function findHeldTransitionUpdate(slot, block) {
906
+ if (!urgentTransitionCellUpdate(block)) return;
907
+ return getHeldTransitionUpdate(slot, block);
908
+ }
909
+ function getHeldTransitionUpdate(slot, block) {
910
+ if (block.disposed) return;
911
+ const rootHeld = block.idState.renderOwner?.transition;
912
+ if (HELD_SYNC_TRANSITION === null && rootHeld === void 0 && FLUSHED_TRANSITION_UPDATES.length === 0)
913
+ return;
914
+ const groups = [HELD_SYNC_TRANSITION?.entries, rootHeld?.entries];
915
+ for (const entries of groups) {
916
+ if (entries === void 0) continue;
917
+ for (let i = entries.length - 1; i >= 0; i--) {
918
+ const entry = entries[i];
919
+ if (entry.slot === slot && !entry.superseded && Object.is(slot.value, entry.baseValue))
920
+ return latestHeldTransitionUpdate(entry);
921
+ }
922
+ }
923
+ for (let i = FLUSHED_TRANSITION_UPDATES.length - 1; i >= 0; i--) {
924
+ const entries = FLUSHED_TRANSITION_UPDATES[i];
925
+ for (let j = entries.length - 1; j >= 0; j--) {
926
+ const entry = entries[j];
927
+ if (entry.slot === slot && !entry.superseded && Object.is(slot.value, entry.baseValue) && // A completed hook render clears this pointer before the flush's
928
+ // retained-entry list is released. Returning to an old base value
929
+ // must not turn that completed update into pending work again.
930
+ (entry.state === void 0 && entry.reducer === void 0 || slot.renderTransition !== void 0))
931
+ return latestHeldTransitionUpdate(entry);
932
+ }
933
+ }
934
+ }
935
+ function hasHeldTransitionUpdate(slot, block) {
936
+ return findHeldTransitionUpdate(slot, block) !== void 0;
937
+ }
938
+ function cancelHeldTransitionUpdate(slot, block) {
939
+ if (!urgentTransitionCellUpdate(block)) return false;
940
+ const rootHeld = block.idState.renderOwner?.transition;
941
+ if (HELD_SYNC_TRANSITION === null && rootHeld === void 0 && FLUSHED_TRANSITION_UPDATES.length === 0)
942
+ return false;
943
+ let cancelled = false;
944
+ const cancel = (entries) => {
945
+ if (entries === void 0) return;
946
+ for (const entry of entries) {
947
+ if (entry.slot === slot && !entry.superseded) {
948
+ entry.superseded = true;
949
+ cancelled = true;
950
+ }
951
+ }
952
+ };
953
+ cancel(HELD_SYNC_TRANSITION?.entries);
954
+ cancel(rootHeld?.entries);
955
+ for (const entries of FLUSHED_TRANSITION_UPDATES) cancel(entries);
956
+ return cancelled;
957
+ }
958
+ function rebaseHeldTransitionUpdate(slot, block, actions, reducer) {
959
+ const entry = findHeldTransitionUpdate(slot, block);
960
+ if (entry === void 0) return;
961
+ if (slot.pendingActionBatch?.flushed === false) return;
962
+ let value = entry.value;
963
+ for (const action of actions) {
964
+ value = reducer ? reducer(value, action) : typeof action === "function" ? action(value) : action;
965
+ }
966
+ if (Object.is(value, entry.baseValue)) {
967
+ cancelHeldTransitionUpdate(slot, block);
968
+ return;
969
+ }
970
+ const changed = !Object.is(value, entry.value);
971
+ for (let current = entry; current; current = current.previous)
972
+ current.value = value;
973
+ for (const action of actions) {
974
+ entry.operations.push(
975
+ reducer ? (previous) => reducer(previous, action) : typeof action === "function" ? action : () => action
976
+ );
977
+ }
978
+ if (changed) scheduleHeldTransitionReplay(entry, block);
979
+ }
980
+ function scheduleHeldTransitionReplay(entry, block) {
981
+ const held = HELD_SYNC_TRANSITION;
982
+ if (held !== null && held.entries.includes(entry)) {
983
+ if (held.replayScheduled) return;
984
+ held.replayScheduled = true;
985
+ queueMicrotask(() => {
986
+ if (HELD_SYNC_TRANSITION !== held) return;
987
+ held.replayScheduled = false;
988
+ promoteHeldSyncTransition();
989
+ });
990
+ return;
991
+ }
992
+ const owner = block.idState.renderOwner;
993
+ const rootHeld = owner?.transition;
994
+ if (rootHeld === void 0 || !rootHeld.entries.includes(entry) || rootHeld.replayScheduled)
995
+ return;
996
+ rootHeld.replayScheduled = true;
997
+ queueMicrotask(() => {
998
+ if (owner.transition !== rootHeld) return;
999
+ rootHeld.replayScheduled = false;
1000
+ retryRootTransition(owner);
1001
+ });
1002
+ }
783
1003
  let PROMOTED_MEMO_SWAPS = null;
784
1004
  let PROMOTED_WARM_HARVEST = null;
785
1005
  function takeSingleOriginTransitionUpdates(origin) {
@@ -943,18 +1163,24 @@ function heldSyncCellsIntact(state) {
943
1163
  if (held === null || !held.holders.has(state)) return false;
944
1164
  for (let i = 0; i < held.entries.length; i++) {
945
1165
  const entry = held.entries[i];
946
- if (!Object.is(entry.slot.value, entry.baseValue)) return false;
1166
+ if (entry.superseded || !Object.is(entry.slot.value, entry.baseValue)) return false;
947
1167
  }
948
1168
  return true;
949
1169
  }
1170
+ function heldTransitionHasPendingAction(entries) {
1171
+ for (const entry of entries) {
1172
+ if (!entry.superseded && entry.slot.pendingActionBatch?.flushed === false) return true;
1173
+ }
1174
+ return false;
1175
+ }
950
1176
  function promoteHeldSyncTransition() {
951
1177
  const held = HELD_SYNC_TRANSITION;
952
- if (held === null) return false;
1178
+ if (held === null || heldTransitionHasPendingAction(held.entries)) return false;
953
1179
  HELD_SYNC_TRANSITION = null;
954
1180
  const promoted = [];
955
1181
  for (let i = 0; i < held.entries.length; i++) {
956
1182
  const entry = held.entries[i];
957
- if (!Object.is(entry.slot.value, entry.baseValue)) continue;
1183
+ if (entry.superseded || !Object.is(entry.slot.value, entry.baseValue)) continue;
958
1184
  entry.slot.value = entry.value;
959
1185
  if (!entry.block.disposed) promoted.push(entry);
960
1186
  }
@@ -990,7 +1216,7 @@ function discardHeldSyncTransition(state) {
990
1216
  function rootTransitionCellsIntact(held) {
991
1217
  for (let i = 0; i < held.entries.length; i++) {
992
1218
  const entry = held.entries[i];
993
- if (!Object.is(entry.slot.value, entry.baseValue)) return false;
1219
+ if (entry.superseded || !Object.is(entry.slot.value, entry.baseValue)) return false;
994
1220
  }
995
1221
  return true;
996
1222
  }
@@ -1037,6 +1263,9 @@ function holdRootTransition(owner, transaction, attempt) {
1037
1263
  promoted: false,
1038
1264
  cue: !continuing
1039
1265
  };
1266
+ for (const entry of entries) {
1267
+ if (entry.batch !== void 0) holdTransitionHookBatch(owner, entry.batch);
1268
+ }
1040
1269
  if (previous === void 0 || previous.promoted) tickTransitionCount(1);
1041
1270
  return true;
1042
1271
  }
@@ -1047,6 +1276,7 @@ function retryRootTransition(owner) {
1047
1276
  discardRootTransition(owner);
1048
1277
  return false;
1049
1278
  }
1279
+ if (heldTransitionHasPendingAction(held.entries)) return true;
1050
1280
  held.promoted = true;
1051
1281
  held.cue = false;
1052
1282
  if (held.memoSwaps !== null) {
@@ -1056,6 +1286,7 @@ function retryRootTransition(owner) {
1056
1286
  TRANSITION_DEPTH++;
1057
1287
  try {
1058
1288
  tickTransitionCount(-1);
1289
+ releaseTransitionHookHolder(owner);
1059
1290
  for (let i = 0; i < held.entries.length; i++) {
1060
1291
  const entry = held.entries[i];
1061
1292
  entry.slot.value = entry.value;
@@ -1091,6 +1322,7 @@ function discardRootTransition(owner) {
1091
1322
  owner.wakeable = null;
1092
1323
  owner.generation++;
1093
1324
  if (!held.promoted) tickTransitionCount(-1);
1325
+ releaseTransitionHookHolder(owner);
1094
1326
  }
1095
1327
  const JOURNAL_TEXT = 0;
1096
1328
  const JOURNAL_ATTR = 1;
@@ -2044,9 +2276,27 @@ let actScopeDepth = 0;
2044
2276
  function setIsOctaneActEnvironment(value) {
2045
2277
  IS_OCTANE_ACT_ENVIRONMENT = value;
2046
2278
  }
2279
+ function isActEnvironment() {
2280
+ return IS_OCTANE_ACT_ENVIRONMENT || globalThis.IS_REACT_ACT_ENVIRONMENT === true;
2281
+ }
2047
2282
  const NESTED_UPDATE_LIMIT = 50;
2048
2283
  const ACT_DRAIN_LIMIT = NESTED_UPDATE_LIMIT + 50;
2049
2284
  let UPDATE_CHAIN_ID = 0;
2285
+ let PASSIVE_UPDATE_COUNTS = null;
2286
+ function countPassiveUpdate(block) {
2287
+ if (process.env.NODE_ENV === "production") return;
2288
+ const counts = PASSIVE_UPDATE_COUNTS ??= /* @__PURE__ */ new WeakMap();
2289
+ let state = counts.get(block);
2290
+ if (state === void 0 || state.chain !== UPDATE_CHAIN_ID) {
2291
+ state = { chain: UPDATE_CHAIN_ID, count: 0 };
2292
+ counts.set(block, state);
2293
+ }
2294
+ if (++state.count === NESTED_UPDATE_LIMIT + 1) {
2295
+ console.error(
2296
+ "Maximum update depth exceeded. Check the dependencies of effects that schedule state updates."
2297
+ );
2298
+ }
2299
+ }
2050
2300
  function inNestedUpdateCallback() {
2051
2301
  return EFFECT_BODY_DEPTH > 0 || REF_CALLBACK_DEPTH > 0 || STORE_SYNC_DEPTH > 0;
2052
2302
  }
@@ -2076,9 +2326,23 @@ function warnCrossComponentRenderUpdate(target, source) {
2076
2326
  }
2077
2327
  function scheduleRender(block) {
2078
2328
  if (block.disposed) return;
2079
- if (process.env.NODE_ENV !== "production" && IS_OCTANE_ACT_ENVIRONMENT && actScopeDepth === 0 && !syncFlush) {
2329
+ if (process.env.NODE_ENV !== "production" && CURRENT_EFFECT_PHASE === INSERTION) {
2330
+ console.error(
2331
+ "useInsertionEffect must not schedule state updates. Move this work to a layout or passive effect."
2332
+ );
2333
+ }
2334
+ if (process.env.NODE_ENV !== "production" && isActEnvironment() && actScopeDepth === 0 && !syncFlush) {
2080
2335
  console.error(
2081
- "An update to a component was not wrapped in act(...).\n\nWhen testing, code that causes state updates should be wrapped into act(...):\n\n act(() => {\n /* fire events that update state */\n });\n /* assert on the output */\n\nThis ensures you're testing the behavior the user would see in the browser."
2336
+ `An update to ${componentName(block)} was not wrapped in act(...).
2337
+
2338
+ When testing, code that causes state updates should be wrapped into act(...):
2339
+
2340
+ act(() => {
2341
+ /* fire events that update state */
2342
+ });
2343
+ /* assert on the output */
2344
+
2345
+ This ensures you're testing the behavior the user would see in the browser.`
2082
2346
  );
2083
2347
  }
2084
2348
  const renderPhaseSelf = CURRENT_BLOCK === block;
@@ -2096,7 +2360,9 @@ function scheduleRender(block) {
2096
2360
  }
2097
2361
  return;
2098
2362
  }
2099
- if (inNestedUpdateCallback()) {
2363
+ if (CURRENT_EFFECT_PHASE === PASSIVE && !syncFlush) {
2364
+ countPassiveUpdate(block);
2365
+ } else if (inNestedUpdateCallback()) {
2100
2366
  if (block.nestedUpdateChain !== UPDATE_CHAIN_ID) {
2101
2367
  block.nestedUpdateChain = UPDATE_CHAIN_ID;
2102
2368
  block.nestedUpdateCount = 0;
@@ -2138,14 +2404,19 @@ function drainHydrationRenderPhaseUpdates(root) {
2138
2404
  QUEUE[write++] = block;
2139
2405
  continue;
2140
2406
  }
2141
- if (!block.pending || block.disposed) continue;
2142
- const seen = (renders ??= /* @__PURE__ */ new Map()).get(block) ?? 0;
2143
- if (seen >= RENDER_PHASE_UPDATE_LIMIT) {
2144
- throw new Error((0, import_error_codes_client_generated.formatClientError)(9));
2145
- }
2146
- renders.set(block, seen + 1);
2147
- block.crossRenderUpdate = false;
2407
+ if (!block.pending && !block.nestedUpdateError || block.disposed) continue;
2148
2408
  try {
2409
+ if (block.nestedUpdateError) {
2410
+ block.nestedUpdateError = false;
2411
+ throw maximumUpdateDepthError();
2412
+ }
2413
+ const seen = (renders ??= /* @__PURE__ */ new Map()).get(block) ?? 0;
2414
+ const crossRenderUpdate = block.crossRenderUpdate;
2415
+ if (seen >= (crossRenderUpdate ? NESTED_UPDATE_LIMIT : RENDER_PHASE_UPDATE_LIMIT)) {
2416
+ throw crossRenderUpdate ? maximumUpdateDepthError() : new Error((0, import_error_codes_client_generated.formatClientError)(9));
2417
+ }
2418
+ renders.set(block, seen + 1);
2419
+ block.crossRenderUpdate = false;
2149
2420
  renderBlock(block);
2150
2421
  } catch (error) {
2151
2422
  handleRenderError(block, error);
@@ -2193,12 +2464,21 @@ let SCHEDULED_VISIBILITY_DRIVER = null;
2193
2464
  function ensureScheduledVisibilityDriver() {
2194
2465
  SCHEDULED_VISIBILITY_DRIVER ??= {
2195
2466
  find: findScheduledVisibilityOwner,
2467
+ holdsNativeRead,
2196
2468
  reveal: attemptHiddenReveal,
2197
2469
  visible: renderVisibleTry,
2198
2470
  rehide: rehideActivityAfterDescendantRender,
2199
2471
  retryActivity: renderHiddenActivity
2200
2472
  };
2201
2473
  }
2474
+ function holdsNativeRead(block) {
2475
+ for (const state of HELD_TRANSITIONS) {
2476
+ const primary = state.tryBlock;
2477
+ if (state.transitionHeld && state.hiddenDom === null && primary !== null && (primary === block || blockIsAncestorOf(primary, block) || blockIsAncestorOf(block, primary)))
2478
+ return true;
2479
+ }
2480
+ return false;
2481
+ }
2202
2482
  function drainQueue() {
2203
2483
  let pendingError = null;
2204
2484
  let activitiesToRehide = null;
@@ -2242,7 +2522,7 @@ function drainQueue() {
2242
2522
  throw maximumUpdateDepthError();
2243
2523
  }
2244
2524
  if (block.drainStamp === drainId) {
2245
- if (++block.drainRenders > RENDER_PHASE_UPDATE_LIMIT) {
2525
+ if (++block.drainRenders > (crossRenderUpdate ? NESTED_UPDATE_LIMIT : RENDER_PHASE_UPDATE_LIMIT)) {
2246
2526
  throw crossRenderUpdate ? maximumUpdateDepthError() : new Error((0, import_error_codes_client_generated.formatClientError)(9));
2247
2527
  }
2248
2528
  } else {
@@ -2822,6 +3102,11 @@ function drainPassivesBeforeRender() {
2822
3102
  if (effectQueues[PASSIVE].length > 0 || pendingPassiveUnmounts.length > 0) drainPassiveEffects();
2823
3103
  }
2824
3104
  function flushSync(fn) {
3105
+ if (process.env.NODE_ENV !== "production" && (CURRENT_BLOCK !== null || EFFECT_BODY_DEPTH > 0 || REF_CALLBACK_DEPTH > 0)) {
3106
+ console.error(
3107
+ "flushSync was called while rendering or running a lifecycle callback. Move the call to an event or scheduled task."
3108
+ );
3109
+ }
2825
3110
  if (inFlush) return (0, import_read_protocol.runNativeBatch)(fn);
2826
3111
  VIEW_TRANSITION_DRIVER?.interrupt();
2827
3112
  const prevSync = syncFlush;
@@ -3034,6 +3319,7 @@ function commitEffects() {
3034
3319
  return;
3035
3320
  }
3036
3321
  const nativeFrame = NATIVE_READ_DRIVER?.pauseLifecycle() ?? -1;
3322
+ EFFECT_COMMIT_DEPTH++;
3037
3323
  try {
3038
3324
  drainEffectEventUpdates();
3039
3325
  const caughtReports = drainEffectEventCommitActions();
@@ -3051,6 +3337,7 @@ function commitEffects() {
3051
3337
  }
3052
3338
  } finally {
3053
3339
  if (nativeFrame >= 0) NATIVE_READ_DRIVER.resumeLifecycle(nativeFrame);
3340
+ finishEffectCommit();
3054
3341
  }
3055
3342
  }
3056
3343
  function schedulePassiveFlush() {
@@ -3155,15 +3442,25 @@ function compareEffectPostOrder(a, b) {
3155
3442
  if (a.scope === b.scope) return a.order - b.order || a.seq - b.seq;
3156
3443
  return comparePostOrder(a.scope.block, a.seq, b.scope.block, b.seq);
3157
3444
  }
3158
- function reportEffectError(block, error) {
3159
- const handler = findTryHandler(block);
3445
+ function finishEffectCommit() {
3446
+ if (--EFFECT_COMMIT_DEPTH !== 0 || COMMIT_PHASE_ERRORS === null) return;
3447
+ const errors = COMMIT_PHASE_ERRORS;
3448
+ COMMIT_PHASE_ERRORS = null;
3449
+ for (const { block, error, handler } of errors) reportEffectError(block, error, handler);
3450
+ }
3451
+ function reportEffectError(block, error, capturedHandler) {
3452
+ if (EFFECT_COMMIT_DEPTH > 0) {
3453
+ (COMMIT_PHASE_ERRORS ??= []).push({ block, error, handler: capturedHandler });
3454
+ return;
3455
+ }
3456
+ const handler = capturedHandler === void 0 ? findTryHandler(block) : capturedHandler;
3160
3457
  if (handler !== null) {
3161
3458
  reportCaughtError(block, error, handler(error));
3162
3459
  return;
3163
3460
  }
3164
3461
  let root = block;
3165
- while (root.parentBlock !== null) root = root.parentBlock;
3166
- if (root.kind === "root" && !root.disposed) {
3462
+ while (root !== null && root.parentBlock !== null) root = root.parentBlock;
3463
+ if (root !== null && root.kind === "root" && !root.disposed) {
3167
3464
  unmountBlock(root);
3168
3465
  drainRefDetaches();
3169
3466
  }
@@ -3183,7 +3480,7 @@ function fireEffectCleanup(e) {
3183
3480
  if (cleanup) {
3184
3481
  slot.cleanup = void 0;
3185
3482
  try {
3186
- runEffectCleanupCallback(cleanup);
3483
+ runEffectCleanupCallback(cleanup, e.phase);
3187
3484
  } catch (err) {
3188
3485
  if (err instanceof MaximumUpdateDepthError) throw err;
3189
3486
  reportEffectError(e.scope.block, err);
@@ -3200,17 +3497,27 @@ function runEffectBody(e) {
3200
3497
  slot.connectedArgs = e.args;
3201
3498
  slot.disconnected = false;
3202
3499
  try {
3500
+ const previousPhase = CURRENT_EFFECT_PHASE;
3501
+ CURRENT_EFFECT_PHASE = e.phase;
3203
3502
  EFFECT_BODY_DEPTH++;
3204
3503
  try {
3205
3504
  cleanup = e.fn.apply(null, e.args ?? []);
3206
3505
  } finally {
3207
3506
  EFFECT_BODY_DEPTH--;
3507
+ CURRENT_EFFECT_PHASE = previousPhase;
3208
3508
  }
3209
3509
  } catch (err) {
3210
3510
  if (err instanceof MaximumUpdateDepthError) throw err;
3211
3511
  reportEffectError(e.scope.block, err);
3212
3512
  return;
3213
3513
  }
3514
+ if (process.env.NODE_ENV !== "production" && cleanup !== void 0 && typeof cleanup !== "function") {
3515
+ const name = e.phase === PASSIVE ? "useEffect" : e.phase === LAYOUT ? "useLayoutEffect" : "useInsertionEffect";
3516
+ const thenable = cleanup !== null && typeof cleanup.then === "function";
3517
+ console.error(
3518
+ name + " must return a cleanup function or nothing." + (thenable ? " Start asynchronous work inside the effect and return its cleanup separately." : "")
3519
+ );
3520
+ }
3214
3521
  if (typeof cleanup === "function") {
3215
3522
  slot.cleanup = cleanup;
3216
3523
  }
@@ -3260,20 +3567,25 @@ function runLayoutEffects(q) {
3260
3567
  }
3261
3568
  }
3262
3569
  function drainPassivePhase() {
3263
- drainDeferredPassiveUnmounts();
3264
- const pending = effectQueues[PASSIVE];
3265
- if (pending.length === 0) return;
3266
- const q = pending.splice(0);
3267
- q.sort(compareEffectPostOrder);
3268
- for (let i = 0; i < q.length; i++) {
3269
- const e = q[i];
3270
- if (e.scope.block.disposed || e.fn !== null && inInactiveSubtree(e.scope.block)) continue;
3271
- fireEffectCleanup(e);
3272
- }
3273
- for (let i = 0; i < q.length; i++) {
3274
- const e = q[i];
3275
- if (e.scope.block.disposed || inInactiveSubtree(e.scope.block)) continue;
3276
- runEffectBody(e);
3570
+ EFFECT_COMMIT_DEPTH++;
3571
+ try {
3572
+ drainDeferredPassiveUnmounts();
3573
+ const pending = effectQueues[PASSIVE];
3574
+ if (pending.length === 0) return;
3575
+ const q = pending.splice(0);
3576
+ q.sort(compareEffectPostOrder);
3577
+ for (let i = 0; i < q.length; i++) {
3578
+ const e = q[i];
3579
+ if (e.scope.block.disposed || e.fn !== null && inInactiveSubtree(e.scope.block)) continue;
3580
+ fireEffectCleanup(e);
3581
+ }
3582
+ for (let i = 0; i < q.length; i++) {
3583
+ const e = q[i];
3584
+ if (e.scope.block.disposed || inInactiveSubtree(e.scope.block)) continue;
3585
+ runEffectBody(e);
3586
+ }
3587
+ } finally {
3588
+ finishEffectCommit();
3277
3589
  }
3278
3590
  }
3279
3591
  function drainEffectEventCommitActions() {
@@ -3296,14 +3608,12 @@ function drainDeferredPassiveUnmounts() {
3296
3608
  const q = pendingPassiveUnmounts.splice(0);
3297
3609
  for (let i = 0; i < q.length; i += 3) {
3298
3610
  try {
3299
- runEffectCleanupCallback(q[i]);
3611
+ runEffectCleanupCallback(q[i], PASSIVE);
3300
3612
  } catch (err) {
3301
3613
  if (err instanceof MaximumUpdateDepthError) throw err;
3302
3614
  const handler = q[i + 1];
3303
3615
  const owner = q[i + 2];
3304
- if (handler !== null) {
3305
- reportCaughtError(owner, err, handler(err));
3306
- } else if (!reportUncaughtError(owner, err)) console.error(err);
3616
+ reportEffectError(owner, err, handler);
3307
3617
  }
3308
3618
  }
3309
3619
  }
@@ -3567,10 +3877,17 @@ function createBlock(kind, parentBlock, parentNode, startMarker, endMarker, body
3567
3877
  function renderBlock(block) {
3568
3878
  const hydration = activeHydration();
3569
3879
  if (hydration !== null && !hydration.owns(block)) {
3570
- hydration.suspend(() => renderBlockInner(block));
3880
+ hydration.suspend(() => renderBlock(block));
3571
3881
  return;
3572
3882
  }
3573
- renderBlockInner(block);
3883
+ let retries = 0;
3884
+ while (renderBlockInner(block)) {
3885
+ if (block.nestedUpdateError) {
3886
+ block.nestedUpdateError = false;
3887
+ throw maximumUpdateDepthError();
3888
+ }
3889
+ if (++retries > RENDER_PHASE_UPDATE_LIMIT) throw new Error((0, import_error_codes_client_generated.formatClientError)(9));
3890
+ }
3574
3891
  }
3575
3892
  function enqueueEffectEventUpdate(entry) {
3576
3893
  EFFECT_EVENT_RENDER_TARGET.push(entry);
@@ -3595,6 +3912,45 @@ function recordCapturedRender(capture, block) {
3595
3912
  (capture.renderedBlocks ??= /* @__PURE__ */ new Set()).add(block);
3596
3913
  }
3597
3914
  }
3915
+ function beginUrgentTransitionRender(block, render) {
3916
+ const slots = /* @__PURE__ */ new Map();
3917
+ for (const entries of FLUSHED_TRANSITION_UPDATES) {
3918
+ for (const update of entries) {
3919
+ if (update.block !== block || update.superseded) continue;
3920
+ const previous = slots.get(update.slot);
3921
+ if (previous !== void 0) {
3922
+ render.cells[previous].update = update;
3923
+ } else {
3924
+ slots.set(update.slot, render.cells.length);
3925
+ render.cells.push({
3926
+ update,
3927
+ baseValue: update.baseValue,
3928
+ value: update.slot.value,
3929
+ hook: void 0
3930
+ });
3931
+ }
3932
+ }
3933
+ }
3934
+ for (const cell of render.cells) {
3935
+ cell.hook = beginUrgentTransitionCell(cell.update);
3936
+ if (cell.hook === null) cell.update.slot.value = cell.baseValue;
3937
+ }
3938
+ }
3939
+ function endUrgentTransitionRender(block, render) {
3940
+ for (let i = render.cells.length - 1; i >= 0; i--) {
3941
+ const cell = render.cells[i];
3942
+ if (cell.hook === void 0) continue;
3943
+ if (cell.hook !== null) endUrgentTransitionCell(cell.hook);
3944
+ else if (!block.disposed && !cell.update.superseded && Object.is(cell.update.slot.value, cell.baseValue))
3945
+ cell.update.slot.value = cell.value;
3946
+ }
3947
+ if (block.disposed || block.pending && block.pendingMode === "urgent") return;
3948
+ if (render.cells.length !== 0 && render.cells.every((cell) => cell.update.superseded)) return;
3949
+ block.pending = true;
3950
+ block.pendingMode = "transition";
3951
+ block.pendingDeferred = render.pendingDeferred;
3952
+ if (render.queueEpoch !== QUEUE_REINDEX_EPOCH && !QUEUE.includes(block)) QUEUE.push(block);
3953
+ }
3598
3954
  function renderBlockInner(block) {
3599
3955
  if (block.renderStatus === RENDER_INVALID) block.renderStatus = RENDER_RETRYING;
3600
3956
  if (WIP_CAPTURE !== null) recordCapturedRender(WIP_CAPTURE, block);
@@ -3618,6 +3974,8 @@ function renderBlockInner(block) {
3618
3974
  CURRENT_EFFECT_RENDER_VERSION = block.effectSlots === null ? 0 : NEXT_EFFECT_RENDER_VERSION++;
3619
3975
  CURRENT_EFFECT_REACHED = 0;
3620
3976
  const continuesParentTree = prevBlock !== null && blockIsAncestor(prevBlock, block);
3977
+ const urgentTransitionDriver = block.pending && block.pendingMode === "transition" && continuesParentTree && prevBlock.currentRenderMode === "urgent" ? TRANSITION_SWAP_DRIVER : null;
3978
+ const urgentTransitionRender = urgentTransitionDriver === null ? null : { pendingDeferred: block.pendingDeferred, queueEpoch: QUEUE_REINDEX_EPOCH, cells: [] };
3621
3979
  if (!continuesParentTree) {
3622
3980
  const replayEpisode = prevBlock === null && RESUME_REPLAY ? block.__warmEpisode : void 0;
3623
3981
  CURRENT_WARM_EPISODE = typeof replayEpisode === "number" ? replayEpisode : NEXT_WARM_EPISODE++;
@@ -3629,6 +3987,7 @@ function renderBlockInner(block) {
3629
3987
  EFFECT_EVENT_ACTION_TARGET = effectEventActionTarget;
3630
3988
  if (block.effectEventRenderVersion !== 0) block.effectEventRenderVersion++;
3631
3989
  block.pending = false;
3990
+ block.crossRenderUpdate = false;
3632
3991
  block.__thenableIdx = 0;
3633
3992
  {
3634
3993
  const tState = block.__thenables;
@@ -3639,22 +3998,29 @@ function renderBlockInner(block) {
3639
3998
  }
3640
3999
  if (block.$$ctxReads !== null) block.$$ctxReads.clear();
3641
4000
  if (block.$$ctxDirect !== null) block.$$ctxDirect.clear();
3642
- block.currentRenderMode = block.pendingMode ?? prevBlock?.currentRenderMode ?? "urgent";
3643
- block.currentRenderDeferred = block.pendingMode !== null ? block.pendingDeferred : prevBlock?.currentRenderDeferred ?? false;
4001
+ block.currentRenderMode = urgentTransitionRender !== null ? "urgent" : block.pendingMode ?? prevBlock?.currentRenderMode ?? "urgent";
4002
+ block.currentRenderDeferred = urgentTransitionRender !== null ? false : block.pendingMode !== null ? block.pendingDeferred : prevBlock?.currentRenderDeferred ?? false;
3644
4003
  block.pendingMode = null;
3645
4004
  block.pendingDeferred = false;
3646
4005
  const profileFrame = typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && (block.kind === "root" || block.kind === "dynamic" || block.kind === "portal") ? (0, import_profiling.__profileBeginRender)(block, block.body, block.mounted) : null;
3647
4006
  let profileDidThrow = false;
3648
4007
  let profileThrown;
3649
4008
  let renderCompleted = false;
4009
+ let renderRetry = false;
3650
4010
  NATIVE_READ_DRIVER?.beginRender(block);
3651
4011
  NATIVE_BLOCK_RETRIES?.get(block)?.clear();
3652
4012
  try {
4013
+ if (urgentTransitionRender !== null)
4014
+ urgentTransitionDriver.beginUrgent(block, urgentTransitionRender);
3653
4015
  const out = block.body(
3654
4016
  block.props,
3655
4017
  block,
3656
4018
  block.extra
3657
4019
  );
4020
+ if (block.pending && !block.crossRenderUpdate) {
4021
+ renderRetry = true;
4022
+ return true;
4023
+ }
3658
4024
  if (out !== void 0 && block.outputHandler !== null) block.outputHandler(block, out);
3659
4025
  finishEffectRender(block);
3660
4026
  if (!block.mounted) block.mounted = true;
@@ -3680,6 +4046,7 @@ function renderBlockInner(block) {
3680
4046
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && profileFrame !== null)
3681
4047
  (0, import_profiling.__profileEndRender)(profileFrame, profileDidThrow, profileThrown);
3682
4048
  if (!renderCompleted) {
4049
+ if (renderRetry) block.renderStatus = RENDER_INVALID;
3683
4050
  if (block.renderStatus !== RENDER_INVALID) {
3684
4051
  let owner = null;
3685
4052
  const suspension = isSuspenseException(profileThrown);
@@ -3705,7 +4072,12 @@ function renderBlockInner(block) {
3705
4072
  CURRENT_EFFECT_REACHED = prevEffectReached;
3706
4073
  CURRENT_SCOPE = prevScope;
3707
4074
  CURRENT_BLOCK = prevBlock;
3708
- NATIVE_READ_DRIVER?.endRender(block, renderCompleted, isSuspenseException(profileThrown));
4075
+ try {
4076
+ NATIVE_READ_DRIVER?.endRender(block, renderCompleted, isSuspenseException(profileThrown));
4077
+ } finally {
4078
+ if (urgentTransitionRender !== null)
4079
+ urgentTransitionDriver.endUrgent(block, urgentTransitionRender);
4080
+ }
3709
4081
  }
3710
4082
  }
3711
4083
  function returnSlotTail(block, state) {
@@ -3912,6 +4284,7 @@ class LiteBlockImpl {
3912
4284
  }
3913
4285
  }
3914
4286
  function componentSlotLite(parentScope, slotKey, host, comp, props, anchor) {
4287
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
3915
4288
  const hydration = activeHydration();
3916
4289
  let scope = parentScope.slots[slotKey];
3917
4290
  let adoptedOpen = null;
@@ -4075,7 +4448,7 @@ function unmountScope(scope, detachDom = true) {
4075
4448
  if (!passiveScheduled) schedulePassiveFlush();
4076
4449
  } else {
4077
4450
  try {
4078
- runEffectCleanupCallback(cleanup);
4451
+ runEffectCleanupCallback(cleanup, slot.phase);
4079
4452
  } catch (err) {
4080
4453
  reportTeardownError(err);
4081
4454
  }
@@ -4150,12 +4523,66 @@ function missingSlot(name) {
4150
4523
  throw new Error((0, import_error_codes_client_generated.formatClientError)(15, name));
4151
4524
  }
4152
4525
  const slotStack = [];
4526
+ let MANUAL_HOOK_DRIVER = null;
4527
+ function invokeManualHook(fn, receiver, args) {
4528
+ const driver = MANUAL_HOOK_DRIVER ??= {
4529
+ pending: slotStack[slotStack.length - 1],
4530
+ active: false
4531
+ };
4532
+ const pending = driver.pending;
4533
+ const active = driver.active;
4534
+ driver.pending = void 0;
4535
+ driver.active = true;
4536
+ try {
4537
+ if (pending === void 0) return Reflect.apply(fn, receiver, args);
4538
+ switch (args.length) {
4539
+ case 0:
4540
+ return fn.call(receiver, pending);
4541
+ case 1:
4542
+ return fn.call(receiver, args[0], pending);
4543
+ case 2:
4544
+ return fn.call(receiver, args[0], args[1], pending);
4545
+ case 3:
4546
+ return fn.call(receiver, args[0], args[1], args[2], pending);
4547
+ case 4:
4548
+ return fn.call(receiver, args[0], args[1], args[2], args[3], pending);
4549
+ default: {
4550
+ const forwarded = new Array(args.length + 1);
4551
+ for (let index = 0; index < args.length; index++) forwarded[index] = args[index];
4552
+ forwarded[args.length] = pending;
4553
+ return fn.apply(receiver, forwarded);
4554
+ }
4555
+ }
4556
+ } finally {
4557
+ driver.pending = pending;
4558
+ driver.active = active;
4559
+ }
4560
+ }
4561
+ function manualHook(fn, name) {
4562
+ function provider() {
4563
+ return invokeManualHook(fn, this, arguments);
4564
+ }
4565
+ Object.defineProperty(provider, "name", { value: name ?? fn.name, configurable: true });
4566
+ Object.defineProperty(provider, "length", { value: fn.length, configurable: true });
4567
+ return provider;
4568
+ }
4153
4569
  function withSlot(sym, fn, ...args) {
4570
+ const driver = MANUAL_HOOK_DRIVER;
4571
+ const pending = driver?.pending;
4572
+ const active = driver?.active ?? false;
4573
+ if (driver !== null) {
4574
+ driver.pending = sym;
4575
+ driver.active = false;
4576
+ }
4154
4577
  slotStack.push(sym);
4155
4578
  try {
4156
4579
  return fn(...args);
4157
4580
  } finally {
4158
4581
  slotStack.pop();
4582
+ if (MANUAL_HOOK_DRIVER !== null) {
4583
+ MANUAL_HOOK_DRIVER.pending = driver === null ? slotStack[slotStack.length - 1] : pending;
4584
+ MANUAL_HOOK_DRIVER.active = active;
4585
+ }
4159
4586
  }
4160
4587
  }
4161
4588
  function appendSlotKey(key, slot) {
@@ -4186,7 +4613,7 @@ function nativeLocalHook(name, initialize, dispose, slot) {
4186
4613
  return cell.nativeValue;
4187
4614
  }
4188
4615
  function useState(initial, slot) {
4189
- if (slot === void 0 && typeof initial === "symbol") {
4616
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4190
4617
  slot = initial;
4191
4618
  initial = void 0;
4192
4619
  }
@@ -4200,16 +4627,44 @@ function useState(initial, slot) {
4200
4627
  s = {
4201
4628
  value: initVal,
4202
4629
  setter: (next) => {
4203
- const previous = stagedTransitionValue(s);
4204
- const computed = typeof next === "function" ? next(previous) : next;
4205
- if (Object.is(computed, previous)) return;
4206
- if (stageTransitionValue(s, block, next, computed)) {
4630
+ if (block.disposed) return;
4631
+ if (s.pendingActionBatch !== void 0 && transitionActionBatchForUpdate() === null)
4632
+ recordUrgentActionUpdate(s, next);
4633
+ if ((s.updates !== void 0 || s.renderTransition !== void 0 || typeof next === "function" && TRANSITION_PENDING_COUNT > 0 && TRANSITION_SWAP_DRIVER?.hasHeld(s, block) || block.pending && typeof next === "function") && transitionActionBatchForUpdate() === null) {
4634
+ (s.updates ??= []).push(next);
4635
+ scheduleRender(block);
4636
+ return;
4637
+ }
4638
+ const previous = stagedTransitionValue(s, block);
4639
+ let computed;
4640
+ let failed = false;
4641
+ try {
4642
+ computed = typeof next === "function" ? next(previous) : next;
4643
+ } catch {
4644
+ if (transitionActionBatchForUpdate() === null) {
4645
+ (s.updates ??= []).push(next);
4646
+ scheduleRender(block);
4647
+ return;
4648
+ }
4649
+ computed = previous;
4650
+ failed = true;
4651
+ }
4652
+ const forceRender = failed || s.updates !== void 0 || s.renderTransition !== void 0 || s.pendingActionBatch !== void 0 || block.pending && typeof next === "function";
4653
+ if (Object.is(computed, previous) && !forceRender) {
4654
+ if (typeof next !== "function" && TRANSITION_SWAP_DRIVER?.cancelEqual(s, block)) {
4655
+ scheduleRender(block);
4656
+ }
4657
+ return;
4658
+ }
4659
+ const update = stageTransitionValue(s, block, next, computed, forceRender);
4660
+ if (update !== null) {
4661
+ if (update.state === void 0) {
4662
+ update.state = s;
4663
+ captureTransitionHookQueue(update, s);
4664
+ }
4207
4665
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
4208
- const update = s.pendingActionBatch?.updates.get(s);
4209
- if (update !== void 0) {
4210
- update.profileType = "state";
4211
- update.profileSlot = slot;
4212
- }
4666
+ update.profileType = "state";
4667
+ update.profileSlot = slot;
4213
4668
  }
4214
4669
  return;
4215
4670
  }
@@ -4221,10 +4676,95 @@ function useState(initial, slot) {
4221
4676
  };
4222
4677
  ensureHooks(scope).set(slot, s);
4223
4678
  }
4679
+ if (s.renderTransition !== void 0 || s.updates !== void 0) {
4680
+ const value = readQueuedState(s);
4681
+ if (!s.urgentTransition && s.updates !== void 0 && Object.is(value, s.value))
4682
+ TRANSITION_SWAP_DRIVER?.rebaseHeld(s, block, s.updates);
4683
+ s.value = value;
4684
+ if (!s.urgentTransition) {
4685
+ if (s.renderTransition !== void 0) {
4686
+ finishQueuedTransition(s.renderTransition, s.value);
4687
+ s.renderTransition = void 0;
4688
+ }
4689
+ s.updates = void 0;
4690
+ }
4691
+ }
4224
4692
  return [s.value, s.setter];
4225
4693
  }
4694
+ function readQueuedState(state) {
4695
+ const transition = state.renderTransition;
4696
+ let value = transition === void 0 ? state.value : readQueuedTransition(transition, state.urgentTransition === true);
4697
+ if (state.updates !== void 0) {
4698
+ for (const update of state.updates)
4699
+ value = typeof update === "function" ? update(value) : update;
4700
+ }
4701
+ return value;
4702
+ }
4703
+ function readQueuedTransition(last, urgent, reducer) {
4704
+ let first = last;
4705
+ while (first.previous !== void 0) first = first.previous;
4706
+ let value = first.replayBaseValue;
4707
+ for (let entry = first; ; entry = entry.next) {
4708
+ if (entry.stateUpdates !== void 0) {
4709
+ for (const update of entry.stateUpdates)
4710
+ value = typeof update === "function" ? update(value) : update;
4711
+ }
4712
+ if (entry.reducerActions !== void 0) {
4713
+ for (const action of entry.reducerActions) value = reducer(value, action);
4714
+ }
4715
+ if ((urgent || entry.superseded) && entry.urgentOperations !== void 0) {
4716
+ for (const index of entry.urgentOperations) value = entry.operations[index](value);
4717
+ } else if (!urgent && !entry.superseded) {
4718
+ for (const operation of entry.operations) value = operation(value);
4719
+ }
4720
+ if (entry === last) return value;
4721
+ }
4722
+ }
4723
+ function captureTransitionHookQueue(update, cell) {
4724
+ update.replayBaseValue = cell.value;
4725
+ const previous = cell.renderTransition ?? TRANSITION_SWAP_DRIVER?.heldUpdate(cell, update.block);
4726
+ if (previous !== void 0) {
4727
+ update.previous = previous;
4728
+ previous.next = update;
4729
+ }
4730
+ if (update.state !== void 0) update.stateUpdates = update.state.updates?.slice();
4731
+ else update.reducerActions = update.reducer.renderPhaseActions?.slice();
4732
+ }
4733
+ function recordUrgentActionUpdate(cell, operation) {
4734
+ const update = cell.pendingActionBatch.updates.get(cell);
4735
+ if (update === void 0) return;
4736
+ (update.urgentOperations ??= []).push(update.operations.length);
4737
+ update.operations.push(
4738
+ typeof operation === "function" ? operation : () => operation
4739
+ );
4740
+ update.forceRender = true;
4741
+ }
4742
+ function finishQueuedTransition(last, value) {
4743
+ for (let entry = last; entry; entry = entry.previous) {
4744
+ entry.value = value;
4745
+ if (entry !== last && Object.is(value, entry.baseValue)) entry.superseded = true;
4746
+ }
4747
+ }
4748
+ function beginUrgentTransitionCell(update) {
4749
+ const cell = update.state ?? update.reducer;
4750
+ if (update.block.disposed || update.superseded || cell === void 0 || cell.renderTransition === void 0)
4751
+ return null;
4752
+ cell.urgentTransition = true;
4753
+ cell.value = update.baseValue;
4754
+ return { update, cell };
4755
+ }
4756
+ function endUrgentTransitionCell(snapshot) {
4757
+ const { update, cell } = snapshot;
4758
+ cell.urgentTransition = false;
4759
+ if (update.block.disposed || update.superseded) {
4760
+ cell.renderTransition = void 0;
4761
+ return;
4762
+ }
4763
+ for (let entry = update; entry; entry = entry.previous)
4764
+ entry.baseValue = cell.value;
4765
+ }
4226
4766
  function __useStateWithGetter(initial, slot) {
4227
- if (slot === void 0 && typeof initial === "symbol") {
4767
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4228
4768
  slot = initial;
4229
4769
  initial = void 0;
4230
4770
  }
@@ -4234,9 +4774,9 @@ function __useStateWithGetter(initial, slot) {
4234
4774
  const s = CURRENT_SCOPE.hooks.get(resolved);
4235
4775
  const getter = s.getter ?? (s.getter = () => {
4236
4776
  const batch = s.pendingActionBatch;
4237
- if (batch === void 0) return s.value;
4777
+ if (batch === void 0) return readQueuedState(s);
4238
4778
  const update = batch.updates.get(s);
4239
- return update === void 0 ? s.value : rebaseTransitionActionUpdate(update);
4779
+ return update === void 0 ? readQueuedState(s) : readQueuedTransition(update, false);
4240
4780
  });
4241
4781
  return [pair[0], pair[1], getter];
4242
4782
  }
@@ -4336,13 +4876,11 @@ function useLinkedState(source, reconcile, options, slot) {
4336
4876
  else scheduleRender(block);
4337
4877
  return;
4338
4878
  }
4339
- if (stageTransitionValue(state, block, operation, computed)) {
4879
+ const update = stageTransitionValue(state, block, operation, computed);
4880
+ if (update !== null) {
4340
4881
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
4341
- const update = state.pendingActionBatch?.updates.get(state);
4342
- if (update !== void 0) {
4343
- update.profileType = "state";
4344
- update.profileSlot = slot;
4345
- }
4882
+ update.profileType = "state";
4883
+ update.profileSlot = slot;
4346
4884
  }
4347
4885
  return;
4348
4886
  }
@@ -4460,26 +4998,31 @@ function useReducer(reducer, initialArg, initOrSlot, slot) {
4460
4998
  // the component once (children then bail as usual). Per
4461
4999
  // ReactHooksWithNoopRenderer-test.js:3889.
4462
5000
  dispatch: (action) => {
4463
- if (CURRENT_BLOCK === block) {
5001
+ if (block.disposed) return;
5002
+ if (CURRENT_BLOCK === block || transitionActionBatchForUpdate() === null) {
5003
+ if (s.pendingActionBatch !== void 0 && transitionActionBatchForUpdate() === null)
5004
+ recordUrgentActionUpdate(s, (value) => s.reducer(value, action));
4464
5005
  const actions = s.renderPhaseActions ??= [];
4465
- const previous2 = actions.length === 0 ? s.value : s.renderPhaseValue;
4466
5006
  actions.push(action);
4467
- if (s.getter !== void 0) {
4468
- s.renderPhaseValue = s.reducer(previous2, action);
4469
- }
4470
5007
  scheduleRender(block);
4471
5008
  return;
4472
5009
  }
4473
- const previous = stagedTransitionValue(s);
5010
+ const previous = stagedTransitionValue(s, block);
4474
5011
  const operation = (value) => s.reducer(value, action);
4475
- const computed = operation(previous);
4476
- if (stageTransitionValue(s, block, operation, computed, true)) {
5012
+ let computed = previous;
5013
+ try {
5014
+ computed = operation(previous);
5015
+ } catch {
5016
+ }
5017
+ const update = stageTransitionValue(s, block, operation, computed, true);
5018
+ if (update !== null) {
5019
+ if (update.reducer === void 0) {
5020
+ update.reducer = s;
5021
+ captureTransitionHookQueue(update, s);
5022
+ }
4477
5023
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
4478
- const update = s.pendingActionBatch?.updates.get(s);
4479
- if (update !== void 0) {
4480
- update.profileType = "reducer";
4481
- update.profileSlot = slot;
4482
- }
5024
+ update.profileType = "reducer";
5025
+ update.profileSlot = slot;
4483
5026
  }
4484
5027
  return;
4485
5028
  }
@@ -4492,17 +5035,32 @@ function useReducer(reducer, initialArg, initOrSlot, slot) {
4492
5035
  ensureHooks(scope).set(slot, s);
4493
5036
  } else {
4494
5037
  s.reducer = reducer;
4495
- const actions = s.renderPhaseActions;
4496
- if (actions !== void 0) {
4497
- let value = s.value;
4498
- for (let i = 0; i < actions.length; i++) value = reducer(value, actions[i]);
5038
+ if (s.renderTransition !== void 0 || s.renderPhaseActions !== void 0) {
5039
+ const value = readQueuedReducer(s);
5040
+ if (!s.urgentTransition && s.renderPhaseActions !== void 0 && Object.is(value, s.value))
5041
+ TRANSITION_SWAP_DRIVER?.rebaseHeld(s, block, s.renderPhaseActions, reducer);
4499
5042
  s.value = value;
4500
- s.renderPhaseActions = void 0;
4501
- s.renderPhaseValue = void 0;
5043
+ if (!s.urgentTransition) {
5044
+ if (s.renderTransition !== void 0) {
5045
+ finishQueuedTransition(s.renderTransition, s.value);
5046
+ s.renderTransition = void 0;
5047
+ }
5048
+ s.renderPhaseActions = void 0;
5049
+ }
4502
5050
  }
4503
5051
  }
4504
5052
  return [s.value, s.dispatch];
4505
5053
  }
5054
+ function readQueuedReducer(state) {
5055
+ let value = state.renderTransition === void 0 ? state.value : readQueuedTransition(
5056
+ state.renderTransition,
5057
+ state.urgentTransition === true,
5058
+ state.reducer
5059
+ );
5060
+ if (state.renderPhaseActions !== void 0)
5061
+ for (const action of state.renderPhaseActions) value = state.reducer(value, action);
5062
+ return value;
5063
+ }
4506
5064
  function __useReducerWithGetter(reducer, initialArg, initOrSlot, slot) {
4507
5065
  const resolvedInput = typeof initOrSlot === "symbol" ? initOrSlot : slot;
4508
5066
  const pair = useReducer(reducer, initialArg, initOrSlot, slot);
@@ -4510,18 +5068,26 @@ function __useReducerWithGetter(reducer, initialArg, initOrSlot, slot) {
4510
5068
  if (resolved === void 0) missingSlot("useReducer");
4511
5069
  const s = CURRENT_SCOPE.hooks.get(resolved);
4512
5070
  const getter = s.getter ?? (s.getter = () => {
4513
- if (s.renderPhaseActions !== void 0) return s.renderPhaseValue;
4514
5071
  const batch = s.pendingActionBatch;
4515
- if (batch === void 0) return s.value;
5072
+ if (batch === void 0) return readQueuedReducer(s);
4516
5073
  const update = batch.updates.get(s);
4517
- return update === void 0 ? s.value : rebaseTransitionActionUpdate(update);
5074
+ return update === void 0 ? readQueuedReducer(s) : readQueuedTransition(update, false, s.reducer);
4518
5075
  });
4519
5076
  return [pair[0], pair[1], getter];
4520
5077
  }
4521
- function depsChanged(prev, next) {
5078
+ function depsChanged(prev, next, hook = false) {
4522
5079
  if (prev === void 0 || next === void 0) return true;
4523
- if (prev.length !== next.length) return true;
4524
- for (let i = 0; i < prev.length; i++) {
5080
+ let length = prev.length;
5081
+ if (length !== next.length) {
5082
+ if (!hook) return true;
5083
+ if (process.env.NODE_ENV !== "production") {
5084
+ console.error(
5085
+ `The dependency array must keep the same length between renders (previous: ${length}, next: ${next.length}).`
5086
+ );
5087
+ }
5088
+ length = Math.min(length, next.length);
5089
+ }
5090
+ for (let i = 0; i < length; i++) {
4525
5091
  if (!Object.is(prev[i], next[i])) return true;
4526
5092
  }
4527
5093
  return false;
@@ -4588,7 +5154,7 @@ function enqueueEffect(slot, fn, deps, phase) {
4588
5154
  return;
4589
5155
  }
4590
5156
  if (prev) {
4591
- const changed = depsChanged(prev.deps, deps);
5157
+ const changed = depsChanged(prev.deps, deps, true);
4592
5158
  if (prev.active && !changed) return;
4593
5159
  if (ROOT_RENDER_TRANSACTION !== null) journalObjectOnce(prev);
4594
5160
  let reactivated = false;
@@ -4692,7 +5258,7 @@ function adoptMemoEntry(scope, slot, deps) {
4692
5258
  }
4693
5259
  function readMemoEntry(scope, slot, deps) {
4694
5260
  const prev = scope.hooks?.get(slot);
4695
- if (prev && deps !== void 0 && !depsChanged(prev.deps, deps)) {
5261
+ if (prev && deps !== void 0 && !depsChanged(prev.deps, deps, true)) {
4696
5262
  return memoEntryHit(slot, prev);
4697
5263
  }
4698
5264
  return WARM_EVER && deps !== void 0 ? adoptMemoEntry(scope, slot, deps) : null;
@@ -4707,12 +5273,21 @@ function publishMemoEntry(scope, slot, deps, value, nativeWitness) {
4707
5273
  }
4708
5274
  return value;
4709
5275
  }
5276
+ let devMemoComputeDepth = 0;
5277
+ function computeMemoWithDiagnostics(compute, deps) {
5278
+ devMemoComputeDepth++;
5279
+ try {
5280
+ return compute.apply(null, deps ?? []);
5281
+ } finally {
5282
+ devMemoComputeDepth--;
5283
+ }
5284
+ }
4710
5285
  function useMemo(compute, deps, slot) {
4711
5286
  const [d, s] = resolveHookArgs("useMemo", deps, slot);
4712
5287
  const scope = CURRENT_SCOPE;
4713
5288
  const entry = readMemoEntry(scope, s, d);
4714
5289
  if (entry !== null) return entry.value;
4715
- const value = compute.apply(null, d ?? []);
5290
+ const value = process.env.NODE_ENV !== "production" ? computeMemoWithDiagnostics(compute, d) : compute.apply(null, d ?? []);
4716
5291
  return publishMemoEntry(scope, s, d, value);
4717
5292
  }
4718
5293
  function useCallback(fn, deps, slot) {
@@ -4784,7 +5359,7 @@ function hookMemoPublishInvariant(cells, base, value) {
4784
5359
  return value;
4785
5360
  }
4786
5361
  function useRef(initial, slot) {
4787
- if (slot === void 0 && typeof initial === "symbol") {
5362
+ if (slot === void 0 && typeof initial === "symbol" && arguments.length === 1 && (slotStack.length === 0 || MANUAL_HOOK_DRIVER?.active === true)) {
4788
5363
  slot = initial;
4789
5364
  initial = void 0;
4790
5365
  }
@@ -4898,13 +5473,33 @@ function subscribeToStore(inst, subscribe) {
4898
5473
  if (checkStoreChanged(inst)) inst.forceUpdate();
4899
5474
  return subscribe(inst.onStoreChange);
4900
5475
  }
5476
+ function scheduleStoreRender(block) {
5477
+ const depth = TRANSITION_DEPTH;
5478
+ const asyncCount = ASYNC_TRANSITION_COUNT;
5479
+ TRANSITION_DEPTH = 0;
5480
+ ASYNC_TRANSITION_COUNT = 0;
5481
+ try {
5482
+ scheduleRender(block);
5483
+ } finally {
5484
+ TRANSITION_DEPTH = depth;
5485
+ ASYNC_TRANSITION_COUNT = asyncCount;
5486
+ }
5487
+ }
5488
+ let DID_WARN_UNCACHED_SNAPSHOT = false;
4901
5489
  function useSyncExternalStore(subscribe, getSnapshot, ...rest) {
4902
5490
  let slot = rest[rest.length - 1];
4903
5491
  slot = resolveSlot(slot);
4904
5492
  if (slot === void 0) missingSlot("useSyncExternalStore");
4905
5493
  const getServerSnapshot = rest.length >= 2 ? rest[0] : void 0;
4906
5494
  const subs = usesSubslots(slot);
4907
- const value = activeHydration() !== null && getServerSnapshot !== void 0 ? getServerSnapshot() : getSnapshot();
5495
+ const readSnapshot = activeHydration() !== null && getServerSnapshot !== void 0 ? getServerSnapshot : getSnapshot;
5496
+ const value = readSnapshot();
5497
+ if (process.env.NODE_ENV !== "production" && !DID_WARN_UNCACHED_SNAPSHOT && !Object.is(value, readSnapshot())) {
5498
+ DID_WARN_UNCACHED_SNAPSHOT = true;
5499
+ console.error(
5500
+ "The " + (readSnapshot === getSnapshot ? "getSnapshot" : "getServerSnapshot") + " result must be cached to avoid an infinite update loop."
5501
+ );
5502
+ }
4908
5503
  const scope = CURRENT_SCOPE;
4909
5504
  let inst = scope.hooks?.get(subs.inst);
4910
5505
  if (inst === void 0) {
@@ -4916,11 +5511,11 @@ function useSyncExternalStore(subscribe, getSnapshot, ...rest) {
4916
5511
  subscribe,
4917
5512
  forceUpdate: typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ ? () => {
4918
5513
  if (!block.disposed) (0, import_profiling.__profileSchedule)(block, "external-store", slot);
4919
- scheduleRender(block);
4920
- } : () => scheduleRender(block),
5514
+ scheduleStoreRender(block);
5515
+ } : () => scheduleStoreRender(block),
4921
5516
  onStoreChange: () => {
4922
5517
  if (block.disposed) return;
4923
- if (CURRENT_BLOCK === null && block.pending && block.pendingMode === "urgent" && !block.pendingDeferred && !(typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) && (process.env.NODE_ENV === "production" || !IS_OCTANE_ACT_ENVIRONMENT || actScopeDepth !== 0 || syncFlush)) {
5518
+ if (CURRENT_BLOCK === null && block.pending && block.pendingMode === "urgent" && !block.pendingDeferred && !(typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) && (process.env.NODE_ENV === "production" || !isActEnvironment() || actScopeDepth !== 0 || syncFlush)) {
4924
5519
  return;
4925
5520
  }
4926
5521
  if (checkStoreChanged(created)) created.forceUpdate();
@@ -6084,7 +6679,8 @@ const Suspense = /* @__PURE__ */ (0, import_component_flags.markComponentFlags)(
6084
6679
  );
6085
6680
  },
6086
6681
  import_component_flags.COMPONENT_FLAG_BOUNDARY,
6087
- "Suspense"
6682
+ "Suspense",
6683
+ /* @__PURE__ */ Symbol.for("octane.suspense")
6088
6684
  );
6089
6685
  function initializeViewTransitionComponent() {
6090
6686
  return (0, import_component_flags.markComponentFlags)(
@@ -6131,6 +6727,11 @@ const ErrorBoundary = /* @__PURE__ */ (0, import_component_flags.markComponentFl
6131
6727
  );
6132
6728
  const TsrxErrorBoundary = ErrorBoundary;
6133
6729
  function use(usable) {
6730
+ if (process.env.NODE_ENV !== "production" && devMemoComputeDepth !== 0) {
6731
+ console.error(
6732
+ "Do not call use() inside a useMemo() factory. Cached factories can skip context or promise reads; call use() before useMemo() and memoize the returned value instead."
6733
+ );
6734
+ }
6134
6735
  if (usable && usable.$$kind === CONTEXT_TAG) {
6135
6736
  return useContextInternal(usable);
6136
6737
  }
@@ -6831,6 +7432,15 @@ function warmChild(comp, props) {
6831
7432
  WARM_DEPTH--;
6832
7433
  }
6833
7434
  }
7435
+ function markWarm(component, plan) {
7436
+ Object.defineProperty(component, "__warm", {
7437
+ configurable: true,
7438
+ get() {
7439
+ return this === component ? plan : void 0;
7440
+ }
7441
+ });
7442
+ return component;
7443
+ }
6834
7444
  function adoptWarmEntry(slot, deps, accept) {
6835
7445
  let b = CURRENT_BLOCK;
6836
7446
  while (b !== null) {
@@ -7129,6 +7739,8 @@ function lazy(load) {
7129
7739
  let thenable = null;
7130
7740
  let profiledComponent = null;
7131
7741
  let memoMetadataInstalled = false;
7742
+ let displayName;
7743
+ let resolvedName = "Lazy";
7132
7744
  let lazyWrapper;
7133
7745
  const initializeLazy = () => {
7134
7746
  if (status !== "uninitialized") return;
@@ -7161,16 +7773,23 @@ function lazy(load) {
7161
7773
  };
7162
7774
  const callResolvedComponent = (props, scope, extra) => {
7163
7775
  const comp = resolveLazyModule(result);
7776
+ resolvedName = comp.displayName || comp.name || "Lazy";
7164
7777
  if (comp.__memo === true) {
7165
7778
  if (!memoMetadataInstalled) {
7166
- lazyWrapper.__memo = true;
7167
- lazyWrapper.__compare = (prev, next) => {
7168
- const current = resolveLazyModule(result);
7169
- const compare = current.__compare;
7170
- const previous = (0, import_shared_value_helpers.resolveLazyDefaultProps)(current, prev);
7171
- const incoming = (0, import_shared_value_helpers.resolveLazyDefaultProps)(current, next);
7172
- return compare ? compare(previous, incoming) : shallowEqualProps(previous, incoming);
7173
- };
7779
+ Object.defineProperty(lazyWrapper, "__memo", {
7780
+ get() {
7781
+ return this === lazyWrapper;
7782
+ }
7783
+ });
7784
+ Object.defineProperty(lazyWrapper, "__compare", {
7785
+ value: (prev, next) => {
7786
+ const current = resolveLazyModule(result);
7787
+ const compare = current.__compare;
7788
+ const previous = (0, import_shared_value_helpers.resolveLazyDefaultProps)(current, prev);
7789
+ const incoming = (0, import_shared_value_helpers.resolveLazyDefaultProps)(current, next);
7790
+ return compare ? compare(previous, incoming) : shallowEqualProps(previous, incoming);
7791
+ }
7792
+ });
7174
7793
  memoMetadataInstalled = true;
7175
7794
  }
7176
7795
  scope.block.memoInChain = true;
@@ -7200,10 +7819,22 @@ function lazy(load) {
7200
7819
  }
7201
7820
  if (settledStatus === "rejected") throw result;
7202
7821
  }
7822
+ runActiveWarmPlans();
7203
7823
  throw new SuspenseException(thenable);
7204
7824
  };
7205
- lazyWrapper.__warm = initializeLazy;
7206
- Object.defineProperty(lazyWrapper, LAZY_COMPONENT, { value: true });
7825
+ markWarm(lazyWrapper, initializeLazy);
7826
+ Object.defineProperty(lazyWrapper, LAZY_COMPONENT, {
7827
+ get() {
7828
+ return this === lazyWrapper;
7829
+ }
7830
+ });
7831
+ Object.defineProperty(lazyWrapper, "displayName", {
7832
+ configurable: true,
7833
+ get: () => displayName ?? resolvedName,
7834
+ set: (value) => {
7835
+ displayName = value;
7836
+ }
7837
+ });
7207
7838
  return lazyWrapper;
7208
7839
  }
7209
7840
  function useId(slot) {
@@ -7415,6 +8046,7 @@ class HydrationCapability {
7415
8046
  warnHydrationStructuralMismatch(loc, expected, actual);
7416
8047
  }
7417
8048
  recordTextMismatch(node, loc, server) {
8049
+ if (process.env.NODE_ENV === "production" && ROOT_ERROR_HANDLERS === null) return;
7418
8050
  if (!this.textWarnings.has(node)) this.textWarnings.set(node, { loc, server });
7419
8051
  }
7420
8052
  flushTextWarnings() {
@@ -7422,7 +8054,9 @@ class HydrationCapability {
7422
8054
  if (!this.rootBlock.parentNode.contains(node)) continue;
7423
8055
  const client = node.nodeValue;
7424
8056
  if (pending.server !== client) {
7425
- warnHydrationValueMismatch(pending.loc, "text", pending.server, client);
8057
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(61)), this.rootBlock);
8058
+ if (process.env.NODE_ENV !== "production")
8059
+ warnHydrationValueMismatch(pending.loc, "text", pending.server, client);
7426
8060
  }
7427
8061
  }
7428
8062
  this.textWarnings.clear();
@@ -7681,10 +8315,20 @@ class HydrationCapability {
7681
8315
  if (first !== null && first.nodeType === 3) {
7682
8316
  const server = first.nodeValue;
7683
8317
  if (server !== text && !isTextParserNormalizedMatch(server, text) && !isHydrationSuppressed(el)) {
7684
- if (process.env.NODE_ENV !== "production")
7685
- this.recordTextMismatch(first, loc || el.__oct_loc, server);
8318
+ this.recordTextMismatch(first, loc || el.__oct_loc, server);
7686
8319
  first.nodeValue = text;
7687
8320
  }
8321
+ if (first.nextSibling !== null) {
8322
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(62)), this.rootBlock);
8323
+ if (process.env.NODE_ENV !== "production") {
8324
+ warnHydrationStructuralMismatch(
8325
+ loc || el.__oct_loc,
8326
+ "the end of the text element",
8327
+ describeHydrationNode(first.nextSibling)
8328
+ );
8329
+ }
8330
+ while (first.nextSibling !== null) el.removeChild(first.nextSibling);
8331
+ }
7688
8332
  return first;
7689
8333
  }
7690
8334
  if (this.isOpen(first)) {
@@ -7706,8 +8350,7 @@ class HydrationCapability {
7706
8350
  if (server !== text && !isTextParserNormalizedMatch(server, text)) {
7707
8351
  const host2 = posNode.parentNode;
7708
8352
  if (!isHydrationSuppressed(host2)) {
7709
- if (process.env.NODE_ENV !== "production")
7710
- this.recordTextMismatch(posNode, host2 && host2.__oct_loc, server);
8353
+ this.recordTextMismatch(posNode, host2 && host2.__oct_loc, server);
7711
8354
  posNode.nodeValue = text;
7712
8355
  }
7713
8356
  }
@@ -8894,6 +9537,7 @@ function attrNamespace(name) {
8894
9537
  return null;
8895
9538
  }
8896
9539
  function setAttribute(el, name, value) {
9540
+ if (name === "innerText" || name === "textContent") return;
8897
9541
  if (process.env.NODE_ENV !== "production" && el.__oct_loc !== void 0 && !isHtmlCustomElement(el) && typeof el.__oct_custom_is !== "string") {
8898
9542
  const warning = (0, import_aria_diagnostics.isAriaAttributeName)(name) ? (0, import_aria_diagnostics.ariaAttributeWarning)(name, el.localName) : (0, import_host_property_diagnostics.hostPropertyWarning)(name, value, el.localName, el.namespaceURI === SVG_NS);
8899
9543
  if (warning !== null) devWarnAttributeOnce(el, name, warning);
@@ -8931,6 +9575,10 @@ function setAttribute(el, name, value) {
8931
9575
  break;
8932
9576
  case 8:
8933
9577
  if ((name === "multiple" || name === "selected") && !isHtmlCustomElement(el)) {
9578
+ if (name === "selected") {
9579
+ const hydration2 = activeHydration();
9580
+ if (hydration2 !== null && !hydration2.isFresh(el)) return;
9581
+ }
8934
9582
  el[name] = value && typeof value !== "function" && typeof value !== "symbol";
8935
9583
  return;
8936
9584
  }
@@ -9114,7 +9762,7 @@ function setAriaAttribute(el, name, value) {
9114
9762
  const warning = (0, import_aria_diagnostics.ariaAttributeWarning)(name, el.localName);
9115
9763
  if (warning !== null) devWarnAttributeOnce(el, name, warning);
9116
9764
  }
9117
- const next = value == null ? null : String(value);
9765
+ const next = value == null || typeof value === "function" || typeof value === "symbol" ? null : String(value);
9118
9766
  const hydration = activeHydration();
9119
9767
  if (hydration !== null && !hydration.allowAttribute(el, name, next)) return;
9120
9768
  if (TRANSITION_JOURNAL !== null) journalAttr(el, name);
@@ -9123,7 +9771,7 @@ function setAriaAttribute(el, name, value) {
9123
9771
  }
9124
9772
  function coerceAttrValue(el, name, value) {
9125
9773
  if (name.charCodeAt(0) === 97 && name.startsWith("aria-")) {
9126
- return value == null ? null : String(value);
9774
+ return value == null || typeof value === "function" || typeof value === "symbol" ? null : String(value);
9127
9775
  }
9128
9776
  const t = typeof value;
9129
9777
  if (t === "boolean" && (0, import_constants.isEnumeratedBooleanAttr)(name)) return value ? "true" : "false";
@@ -9171,6 +9819,7 @@ function coerceAttrValue(el, name, value) {
9171
9819
  if (import_constants.POSITIVE_NUMERIC_ATTR_PROPS.has(lower) && !(Number(value) >= 1)) {
9172
9820
  return null;
9173
9821
  }
9822
+ if ((lower === "rowspan" || lower === "start") && Number.isNaN(Number(value))) return null;
9174
9823
  if (name.length > 2 && name.charCodeAt(0) === 111 && name.charCodeAt(1) === 110) {
9175
9824
  return null;
9176
9825
  }
@@ -9263,7 +9912,9 @@ function setStyleProperty(el, name, value, staticCss, previous) {
9263
9912
  }
9264
9913
  function applyStyleValue(el, style, value, prev) {
9265
9914
  if (value == null || value === false || value === "") {
9266
- if (prev != null && prev !== false && prev !== "") style.cssText = "";
9915
+ if (prev && typeof prev === "object") {
9916
+ for (const key in prev) style.removeProperty((0, import_css.styleName)(key));
9917
+ } else if (typeof prev === "string") style.cssText = "";
9267
9918
  return;
9268
9919
  }
9269
9920
  if (typeof value === "string") {
@@ -9320,10 +9971,13 @@ function isEventKey(k) {
9320
9971
  const CAPTURE_PREFIX = "$$capture:";
9321
9972
  function jsxEventName(rest) {
9322
9973
  if (rest === "DoubleClick") return "dblclick";
9974
+ if (rest === "Focus") return "focusin";
9975
+ if (rest === "Blur") return "focusout";
9323
9976
  return rest.toLowerCase();
9324
9977
  }
9325
- function eventSlot(name) {
9326
- if (!isEventKey(name)) return null;
9978
+ function eventSlot(name, el) {
9979
+ if (!isEventKey(name) || el !== void 0 && isHtmlCustomElement(el) && !(0, import_event_names.isDelegatedEventProp)(name))
9980
+ return null;
9327
9981
  let rest = name.slice(2);
9328
9982
  let capture = false;
9329
9983
  if (rest.length > 7 && rest.endsWith("Capture") && name !== "onGotPointerCapture" && name !== "onLostPointerCapture") {
@@ -9360,7 +10014,7 @@ function removeHostProp(el, name, prevValue) {
9360
10014
  );
9361
10015
  return;
9362
10016
  }
9363
- const ev = eventSlot(name);
10017
+ const ev = eventSlot(name, el);
9364
10018
  if (ev) setEventHandler(el, ev.key, null);
9365
10019
  else setAttribute(el, name, null);
9366
10020
  }
@@ -9377,8 +10031,8 @@ function snapshotSpread(value) {
9377
10031
  return snapshot;
9378
10032
  }
9379
10033
  function formActionAttributeName(el, name) {
9380
- if (el.localName === "form" && name === "action") return "action";
9381
- if ((el.localName === "button" || el.localName === "input") && (name === "formAction" || name === "formaction"))
10034
+ if (name === "action" && el.localName === "form") return "action";
10035
+ if ((name === "formAction" || name === "formaction") && (el.localName === "button" || el.localName === "input"))
9382
10036
  return "formaction";
9383
10037
  return null;
9384
10038
  }
@@ -9466,7 +10120,7 @@ function setSpread(el, value, prev, mountScope, skipDangerouslySetInnerHTML = fa
9466
10120
  devValidateHostProps(el, Object(value));
9467
10121
  }
9468
10122
  if (value != null && Object.prototype.propertyIsEnumerable.call(Object(value), "suppressHydrationWarning")) {
9469
- el.__oct_suppress = value.suppressHydrationWarning !== false;
10123
+ el.__oct_suppress = value.suppressHydrationWarning === true;
9470
10124
  }
9471
10125
  if (process.env.NODE_ENV !== "production" && value != null && Object.prototype.propertyIsEnumerable.call(Object(value), "suppressNativeChangeWarning")) {
9472
10126
  el.__oct_native_change_suppressed = value.suppressNativeChangeWarning === true;
@@ -9540,7 +10194,7 @@ function setSpread(el, value, prev, mountScope, skipDangerouslySetInnerHTML = fa
9540
10194
  );
9541
10195
  continue;
9542
10196
  }
9543
- const ev = eventSlot(k);
10197
+ const ev = eventSlot(k, el);
9544
10198
  if (ev) {
9545
10199
  if (v === pv) continue;
9546
10200
  if (ev.capture) {
@@ -9572,9 +10226,9 @@ function removeHeadEventListeners(state, attrs) {
9572
10226
  handlers.delete(name);
9573
10227
  }
9574
10228
  }
9575
- function adoptServerHeadEl(key, tag) {
10229
+ function adoptServerHeadEl(head, key, tag) {
9576
10230
  const closeKey = "/" + key;
9577
- for (let n = document.head.firstChild; n !== null; n = n.nextSibling) {
10231
+ for (let n = head.firstChild; n !== null; n = n.nextSibling) {
9578
10232
  if (n.nodeType === 8 && n.data === key) {
9579
10233
  let candidate = n.nextSibling;
9580
10234
  let match = null;
@@ -9610,10 +10264,13 @@ function headBlock(scope, slot, key, tag, attrs, text) {
9610
10264
  if (typeof document === "undefined") return;
9611
10265
  let state = scope.slots[slot];
9612
10266
  if (state === void 0) {
9613
- let el2 = adoptServerHeadEl((0, import_head_ownership.headOwnershipKey)(key, rootIdentifierPrefix(scope.block)), tag);
10267
+ const parent = scope.block.parentNode;
10268
+ const ownerDocument = parent.nodeType === 9 ? parent : parent.ownerDocument;
10269
+ const head = ownerDocument.head;
10270
+ let el2 = adoptServerHeadEl(head, (0, import_head_ownership.headOwnershipKey)(key, rootIdentifierPrefix(scope.block)), tag);
9614
10271
  if (el2 === null) {
9615
- el2 = document.createElement(tag);
9616
- document.head.appendChild(el2);
10272
+ el2 = ownerDocument.createElement(tag);
10273
+ head.appendChild(el2);
9617
10274
  }
9618
10275
  state = { el: el2 };
9619
10276
  scope.slots[slot] = state;
@@ -9738,6 +10395,7 @@ function evt0(el, key, fn) {
9738
10395
  return d;
9739
10396
  }
9740
10397
  function evt0u(d, fn) {
10398
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9741
10399
  if (TRANSITION_JOURNAL !== null) journalObjectOnce(d);
9742
10400
  d.fn = fn;
9743
10401
  }
@@ -9747,6 +10405,7 @@ function evt1(el, key, fn, a0) {
9747
10405
  return d;
9748
10406
  }
9749
10407
  function evt1u(d, fn, a0) {
10408
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9750
10409
  if (TRANSITION_JOURNAL !== null) {
9751
10410
  journalObjectOnce(d);
9752
10411
  journalObjectOnce(d.args);
@@ -9760,6 +10419,7 @@ function evt2(el, key, fn, a0, a1) {
9760
10419
  return d;
9761
10420
  }
9762
10421
  function evt2u(d, fn, a0, a1) {
10422
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9763
10423
  if (TRANSITION_JOURNAL !== null) {
9764
10424
  journalObjectOnce(d);
9765
10425
  journalObjectOnce(d.args);
@@ -9775,6 +10435,7 @@ function evtN(el, key, fn, args) {
9775
10435
  return d;
9776
10436
  }
9777
10437
  function evtNu(d, fn, args) {
10438
+ if (_dispatchDepth !== 0) preserveDispatchedBundle(d);
9778
10439
  if (TRANSITION_JOURNAL !== null) journalObjectOnce(d);
9779
10440
  d.fn = fn;
9780
10441
  d.args = args;
@@ -10115,6 +10776,28 @@ const CURRENT_TARGET_DESCRIPTOR = {
10115
10776
  }
10116
10777
  };
10117
10778
  const CAPTURE_PATH = [];
10779
+ const CAPTURE_SLOTS = [];
10780
+ function snapshotDelegatedSlots(base, key, event) {
10781
+ const type = event.type;
10782
+ const suppressDisabled = type === "click" || type === "dblclick" || type === "mousedown" || type === "mousemove" || type === "mouseup" || type === "mouseenter" && key[2] !== "c";
10783
+ for (let index = base; index < CAPTURE_PATH.length; index++) {
10784
+ const node = CAPTURE_PATH[index];
10785
+ const slot = node[key];
10786
+ CAPTURE_SLOTS[index] = slot != null && suppressDisabled && node.disabled && (node.localName === "button" || node.localName === "input" || node.localName === "select" || node.localName === "textarea") ? null : slot;
10787
+ }
10788
+ }
10789
+ function preserveDispatchedBundle(bundle) {
10790
+ let snapshot;
10791
+ for (let index = 0; index < CAPTURE_SLOTS.length; index++) {
10792
+ if (CAPTURE_SLOTS[index] === bundle) {
10793
+ CAPTURE_SLOTS[index] = snapshot ??= {
10794
+ [EVENT_SLOT_KIND]: HANDLER_BUNDLE_KIND,
10795
+ fn: bundle.fn,
10796
+ args: bundle.args.slice()
10797
+ };
10798
+ }
10799
+ }
10800
+ }
10118
10801
  function resolvePortalEventOwner(node) {
10119
10802
  if (node.$$portalParent != null || node.parentNode === null) return;
10120
10803
  const target = node.parentNode;
@@ -10332,13 +11015,7 @@ function dispatchDelegated(event) {
10332
11015
  _dispatchDepth++;
10333
11016
  const node = event.target;
10334
11017
  const prevSubmitRec = ACTIVE_SUBMIT_DISPATCH;
10335
- const submitRec = event.type === "submit" && node != null && node.nodeName === "FORM" ? {
10336
- form: node,
10337
- event,
10338
- transitions: 0,
10339
- published: false,
10340
- intercepted: false
10341
- } : null;
11018
+ const submitRec = event.type === "submit" && node != null && node.nodeName === "FORM" ? snapshotSubmitDispatch(node, event) : null;
10342
11019
  if (submitRec !== null) ACTIVE_SUBMIT_DISPATCH = submitRec;
10343
11020
  const nativeBatch = (0, import_native_read_events.beginNativeEventBatch)(event);
10344
11021
  const pathBase = CAPTURE_PATH.length;
@@ -10348,14 +11025,17 @@ function dispatchDelegated(event) {
10348
11025
  if (delegatedCapture(event.type) && _delegatedCapture.has(event.type) && dispatchDelegatedCapture.call(this, event))
10349
11026
  return;
10350
11027
  if (!_delegated.has(event.type)) return;
11028
+ if (node?.nodeType === 1 && isHtmlCustomElement(node) && (event.type === "invalid" || EMULATED_BUBBLING_EVENTS.includes(event.type)))
11029
+ return;
10351
11030
  buildDelegatedPath(event, this);
11031
+ snapshotDelegatedSlots(pathBase, key, event);
10352
11032
  stop = Object.getOwnPropertyDescriptor(event, "stopPropagation");
10353
11033
  propagationStarted = true;
10354
11034
  beginDelegatedPropagation(event, stop, null);
10355
11035
  for (let i = pathBase; i < CAPTURE_PATH.length; i++) {
10356
11036
  const current = CAPTURE_PATH[i];
10357
11037
  if (targetOnly && current !== event.target) break;
10358
- const slot = current[key];
11038
+ const slot = CAPTURE_SLOTS[i];
10359
11039
  if (slot != null) {
10360
11040
  setCurrentTarget(event, current);
10361
11041
  fireEventSlot(slot, event);
@@ -10363,8 +11043,12 @@ function dispatchDelegated(event) {
10363
11043
  }
10364
11044
  if (targetOnly) break;
10365
11045
  }
11046
+ if (submitRec !== null && FORM_SUBMIT_DRIVER !== null && !event.defaultPrevented && CAPTURE_PATH.includes(submitRec.form, pathBase)) {
11047
+ FORM_SUBMIT_DRIVER(submitRec.form, event, submitRec.action, submitRec.submitter);
11048
+ }
10366
11049
  } finally {
10367
11050
  CAPTURE_PATH.length = pathBase;
11051
+ CAPTURE_SLOTS.length = pathBase;
10368
11052
  if (propagationStarted) endDelegatedPropagation(event, stop, null);
10369
11053
  if (submitRec !== null) {
10370
11054
  ACTIVE_SUBMIT_DISPATCH = prevSubmitRec;
@@ -10387,6 +11071,7 @@ function dispatchDelegatedCapture(event) {
10387
11071
  const key = CAPTURE_PREFIX + event.type;
10388
11072
  const pathBase = CAPTURE_PATH.length;
10389
11073
  buildDelegatedPath(event, this, path);
11074
+ snapshotDelegatedSlots(pathBase, key, event);
10390
11075
  const stop = Object.getOwnPropertyDescriptor(event, "stopPropagation");
10391
11076
  const immediate = delegatedCapture(event.type) ? Object.getOwnPropertyDescriptor(event, "stopImmediatePropagation") : null;
10392
11077
  const wasCancelled = event.cancelBubble;
@@ -10396,7 +11081,7 @@ function dispatchDelegatedCapture(event) {
10396
11081
  try {
10397
11082
  beginDelegatedPropagation(event, stop, immediate);
10398
11083
  for (let i = CAPTURE_PATH.length - 1; i >= pathBase; i--) {
10399
- const slot = CAPTURE_PATH[i][key];
11084
+ const slot = CAPTURE_SLOTS[i];
10400
11085
  if (slot != null) {
10401
11086
  setCurrentTarget(event, CAPTURE_PATH[i]);
10402
11087
  fireEventSlot(slot, event);
@@ -10406,6 +11091,7 @@ function dispatchDelegatedCapture(event) {
10406
11091
  } finally {
10407
11092
  stopped = event[PROPAGATION_FLAGS] !== 0 || !wasCancelled && event.cancelBubble;
10408
11093
  CAPTURE_PATH.length = pathBase;
11094
+ CAPTURE_SLOTS.length = pathBase;
10409
11095
  endDelegatedPropagation(event, stop, immediate);
10410
11096
  clearCurrentTarget(event);
10411
11097
  try {
@@ -10433,7 +11119,7 @@ function clearCurrentTarget(event) {
10433
11119
  delete event.currentTarget;
10434
11120
  delete event[CURRENT_TARGET_NODE];
10435
11121
  }
10436
- const IDLE_FORM_STATUS = { pending: false, data: null, method: "get", action: null };
11122
+ const IDLE_FORM_STATUS = { pending: false, data: null, method: null, action: null };
10437
11123
  const FORM_STATUS = /* @__PURE__ */ new WeakMap();
10438
11124
  const FORM_STATUS_LISTENERS = /* @__PURE__ */ new WeakMap();
10439
11125
  function setFormStatus(form, status) {
@@ -10441,7 +11127,28 @@ function setFormStatus(form, status) {
10441
11127
  const ls = FORM_STATUS_LISTENERS.get(form);
10442
11128
  if (ls) for (const l of ls) l();
10443
11129
  }
11130
+ function snapshotSubmitDispatch(form, event) {
11131
+ let submitter = event.submitter;
11132
+ let action = form.$$formAction;
11133
+ if (submitter !== null && submitter !== void 0) {
11134
+ const override = submitter.$$formAction ?? submitter.getAttribute("formaction");
11135
+ if (override != null) {
11136
+ action = override;
11137
+ submitter = null;
11138
+ }
11139
+ }
11140
+ return {
11141
+ form,
11142
+ event,
11143
+ action,
11144
+ submitter: submitter ?? null,
11145
+ transitions: 0,
11146
+ published: false,
11147
+ intercepted: false
11148
+ };
11149
+ }
10444
11150
  let ACTIVE_SUBMIT_DISPATCH = null;
11151
+ let FORM_SUBMIT_DRIVER = null;
10445
11152
  function publishManualFormPending(rec) {
10446
11153
  if (rec.intercepted || rec.transitions === 0 || !rec.event.defaultPrevented) return;
10447
11154
  const form = rec.form;
@@ -10497,30 +11204,22 @@ function flushFormResets() {
10497
11204
  PENDING_FORM_RESETS = null;
10498
11205
  for (const f of forms) resetFormNow(f);
10499
11206
  }
10500
- function setFormAction(el, name, value, prev) {
11207
+ function setFormAction(el, name, value, _prev) {
10501
11208
  if (typeof value === "function") {
10502
11209
  el.$$formAction = value;
10503
11210
  if (process.env.NODE_ENV !== "production") queueFormActionAuthoringDiagnostic(el);
10504
- if (el.nodeName === "FORM") {
10505
- if (!el.$$formSubmitWired) {
10506
- el.$$formSubmitWired = true;
10507
- el.$$submit = (event) => handleFormSubmit(el, event);
10508
- delegateEvents(["submit"]);
10509
- }
11211
+ if (!el.$$formSubmitWired) {
11212
+ el.$$formSubmitWired = true;
11213
+ FORM_SUBMIT_DRIVER = handleFormSubmit;
11214
+ delegateEvents(["submit"]);
10510
11215
  }
10511
11216
  el.removeAttribute(name);
10512
11217
  return;
10513
11218
  }
10514
11219
  el.$$formAction = void 0;
10515
- if (typeof prev === "function" && el.nodeName === "FORM") {
10516
- el.$$submit = void 0;
10517
- el.$$formSubmitWired = false;
10518
- }
10519
11220
  setAttribute(el, name, value);
10520
11221
  }
10521
- function handleFormSubmit(form, event) {
10522
- const submitter = event.submitter;
10523
- const action = submitter && submitter.$$formAction || form.$$formAction;
11222
+ function handleFormSubmit(form, event, action, submitter) {
10524
11223
  if (typeof action !== "function") return;
10525
11224
  event.preventDefault();
10526
11225
  if (ACTIVE_SUBMIT_DISPATCH !== null && ACTIVE_SUBMIT_DISPATCH.form === form)
@@ -10696,7 +11395,7 @@ function armControlled(el) {
10696
11395
  return ctrl;
10697
11396
  }
10698
11397
  function toControlledString(v) {
10699
- return typeof v === "string" ? v : String(v);
11398
+ return typeof v === "string" ? v : typeof v === "function" || typeof v === "symbol" ? "" : String(v);
10700
11399
  }
10701
11400
  function valueNeedsWrite(el, raw) {
10702
11401
  if (el.type === "number") {
@@ -10957,35 +11656,77 @@ function projectSelectValue(sel, sv, setDefaultSelected) {
10957
11656
  }
10958
11657
  if (defaultOption !== null) defaultOption.selected = true;
10959
11658
  }
10960
- function setDefaultValue(el, value) {
11659
+ function setDefaultValue(el, value, initial) {
10961
11660
  const ctrl = armControlled(el);
10962
11661
  const hydration = activeHydration();
10963
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
10964
11662
  if (el.localName === "select") {
10965
- if (!Object.is(ctrl.dvv, value)) {
11663
+ const first2 = ctrl.dvv === UNCONTROLLED;
11664
+ const multiple = el.multiple;
11665
+ const changedMultiple = ctrl.formMultiple !== multiple;
11666
+ if (first2 || changedMultiple) {
10966
11667
  if (TRANSITION_JOURNAL !== null) {
10967
11668
  journalObjectOnce(ctrl);
10968
11669
  journalBag();
10969
11670
  }
10970
11671
  ctrl.dvv = value;
10971
- queueControlledCommit(SELECT_DEFAULT_SYNCS, { el, value });
11672
+ ctrl.formMultiple = multiple;
11673
+ if (hydration !== null && !hydration.isFresh(el)) return;
11674
+ if (value != null)
11675
+ queueControlledCommit(SELECT_DEFAULT_SYNCS, { el, value });
11676
+ else if (changedMultiple)
11677
+ projectSelectValue(el, multiple ? /* @__PURE__ */ new Set() : "", false);
10972
11678
  }
10973
11679
  return;
10974
11680
  }
11681
+ const first = initial ?? !ctrl.sawV;
11682
+ const previousDefault = ctrl.dvv;
11683
+ if (TRANSITION_JOURNAL !== null) journalObjectOnce(ctrl);
11684
+ ctrl.sawV = true;
11685
+ ctrl.dvv = value;
11686
+ const hydrating = hydration !== null && !hydration.isFresh(el);
10975
11687
  if (ctrl.v !== UNCONTROLLED) return;
10976
11688
  const input = el;
11689
+ if (value == null) {
11690
+ if (previousDefault !== UNCONTROLLED && previousDefault != null) {
11691
+ if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
11692
+ if (el.localName === "input") input.removeAttribute("value");
11693
+ else input.defaultValue = "";
11694
+ }
11695
+ return;
11696
+ }
10977
11697
  const s = toControlledString(value);
10978
- if (input.defaultValue !== s) {
11698
+ if (first && !hydrating && input.value !== s) {
11699
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "value", "defaultValue");
11700
+ input.value = s;
11701
+ }
11702
+ if (input.defaultValue !== s || s === "" && el.localName === "input" && !input.hasAttribute("value")) {
10979
11703
  if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
10980
11704
  input.defaultValue = s;
10981
11705
  }
10982
11706
  }
11707
+ const DEFAULT_VALUE_BASELINE = /* @__PURE__ */ Symbol("octane.defaultValue");
10983
11708
  function setDefaultValueUncontrolled(el, value) {
10984
11709
  const hydration = activeHydration();
10985
- if (hydration !== null && !hydration.isFresh(el) || value == null) return;
10986
11710
  const input = el;
10987
- const s = toControlledString(value);
10988
- if (input.defaultValue !== s) {
11711
+ const previous = input[DEFAULT_VALUE_BASELINE];
11712
+ const s = value == null ? null : toControlledString(value);
11713
+ if (TRANSITION_JOURNAL !== null)
11714
+ TRANSITION_JOURNAL.push(JOURNAL_PROP, input, DEFAULT_VALUE_BASELINE, previous);
11715
+ input[DEFAULT_VALUE_BASELINE] = s;
11716
+ const hydrating = hydration !== null && !hydration.isFresh(el);
11717
+ if (s === null) {
11718
+ if (previous != null) {
11719
+ if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
11720
+ if (el.localName === "input") input.removeAttribute("value");
11721
+ else input.defaultValue = "";
11722
+ }
11723
+ return;
11724
+ }
11725
+ if (previous === void 0 && !hydrating && input.value !== s) {
11726
+ if (TRANSITION_JOURNAL !== null) journalControlled(el, "value", "defaultValue");
11727
+ input.value = s;
11728
+ }
11729
+ if (input.defaultValue !== s || s === "" && el.localName === "input" && !input.hasAttribute("value")) {
10989
11730
  if (TRANSITION_JOURNAL !== null) journalDefaultValue(input);
10990
11731
  input.defaultValue = s;
10991
11732
  }
@@ -11054,7 +11795,6 @@ function setFormControlSources(el, sources) {
11054
11795
  }
11055
11796
  const ctrl = armControlled(el);
11056
11797
  const first = !ctrl.formSeen;
11057
- const previousDefaultValue = ctrl.formDefaultValue;
11058
11798
  const previousDefaultChecked = ctrl.formDefaultChecked;
11059
11799
  const previousMultiple = ctrl.formMultiple;
11060
11800
  if (TRANSITION_JOURNAL !== null) {
@@ -11076,9 +11816,7 @@ function setFormControlSources(el, sources) {
11076
11816
  const defaultString = defaultValue == null ? null : toControlledString(defaultValue);
11077
11817
  setValue(input, value);
11078
11818
  if (value == null) {
11079
- if (defaultString !== null) setDefaultValue(input, defaultString);
11080
- else if (!first && previousDefaultValue !== UNCONTROLLED && previousDefaultValue != null)
11081
- input.removeAttribute("value");
11819
+ setDefaultValue(input, defaultString, first);
11082
11820
  }
11083
11821
  setChecked(input, checked);
11084
11822
  if (checked == null && defaultChecked != null) setDefaultChecked(input, defaultChecked);
@@ -11091,7 +11829,7 @@ function setFormControlSources(el, sources) {
11091
11829
  const textarea = el;
11092
11830
  setValue(textarea, value);
11093
11831
  if (value == null) {
11094
- if (defaultValue != null) setDefaultValue(textarea, defaultValue);
11832
+ if (defaultValue != null) setDefaultValue(textarea, defaultValue, first);
11095
11833
  else if (!first && textarea.defaultValue !== "") textarea.defaultValue = "";
11096
11834
  }
11097
11835
  return;
@@ -11114,7 +11852,7 @@ function setFormControlSources(el, sources) {
11114
11852
  }
11115
11853
  setSelectValue(select, value);
11116
11854
  if (defaultValue != null) setDefaultValue(select, defaultValue);
11117
- else ctrl.dvv = UNCONTROLLED;
11855
+ else if (first) ctrl.dvv = void 0;
11118
11856
  }
11119
11857
  function nativeTextChangeMessage(el, hasBubbleChange, controlled) {
11120
11858
  const changeProp = hasBubbleChange ? "onChange" : "onChangeCapture";
@@ -11398,7 +12136,9 @@ function unregisterPortalEventRange(target, portal2) {
11398
12136
  }
11399
12137
  }
11400
12138
  function portal(parentScope, slotKey, target, body, props, host, env, fragmentOwners, fragmentAnchor) {
12139
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
11401
12140
  const prev = parentScope.slots[slotKey];
12141
+ const key = portalKey(props);
11402
12142
  if (fragmentAnchor !== void 0 && fragmentOwners === void 0 && prev !== void 0 && prev.target === target) {
11403
12143
  prepareFragmentPortalInterleaving(prev);
11404
12144
  }
@@ -11407,12 +12147,13 @@ function portal(parentScope, slotKey, target, body, props, host, env, fragmentOw
11407
12147
  parentScope.block,
11408
12148
  target,
11409
12149
  body,
11410
- props,
12150
+ key === null ? props : void 0,
11411
12151
  // `host` (passed by the compiler) is the JSX element that contains the
11412
12152
  // createPortal call — the natural "logical parent" for event bubbling. When
11413
12153
  // the portal is at top level the compiler passes the block's parentNode.
11414
12154
  host || parentScope.block.parentNode,
11415
- env
12155
+ env,
12156
+ key
11416
12157
  );
11417
12158
  if (prev !== state) {
11418
12159
  journalRootProperty(parentScope.slots, String(slotKey));
@@ -11573,16 +12314,16 @@ function registerValuePortalFragmentOwners(portal2, parentBlock, anchor) {
11573
12314
  registerFragmentPortalOwners(portal2, nestedOwners ?? firstOwner, anchor);
11574
12315
  }
11575
12316
  }
11576
- function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env) {
12317
+ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env, key = null) {
11577
12318
  const hydration = activeHydration();
11578
12319
  if (hydration !== null) {
11579
12320
  return hydration.suspend(
11580
- () => renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env)
12321
+ () => renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, env, key)
11581
12322
  );
11582
12323
  }
11583
12324
  const norm = normalizePortalBody(rawBody, rawProps);
11584
12325
  let state = prev;
11585
- if (state === null || state.target !== target) {
12326
+ if (state === null || state.target !== target || state.key !== key) {
11586
12327
  if (state !== null) teardownPortalState(state);
11587
12328
  const start = document.createComment("portal");
11588
12329
  const end = document.createComment("/portal");
@@ -11603,7 +12344,7 @@ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, e
11603
12344
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
11604
12345
  (0, import_profiling.__profileTrackComponent)(block, profilePortalComponent(rawBody));
11605
12346
  }
11606
- state = { __kind: "portalSlotSlot", block, target, host, start, end };
12347
+ state = { __kind: "portalSlotSlot", block, target, key, host, start, end };
11607
12348
  registerPortalEventRange(target, state);
11608
12349
  activityPortalCreated?.(block);
11609
12350
  registerDelegationTarget(target);
@@ -11685,9 +12426,13 @@ function genericPortalBody(value, scope) {
11685
12426
  childSlot(scope, 0, scope.parentNode, value, scope.endMarker);
11686
12427
  }
11687
12428
  const PORTAL_TAG = /* @__PURE__ */ Symbol.for("octane.portal");
12429
+ function portalKey(value) {
12430
+ return typeof value === "string" || typeof value === "number" ? String(value) : null;
12431
+ }
11688
12432
  // @__NO_SIDE_EFFECTS__
11689
12433
  function createPortal(body, target, props = void 0) {
11690
- return { $$kind: PORTAL_TAG, body, target, props };
12434
+ const key = portalKey(props);
12435
+ return { $$kind: PORTAL_TAG, body, target, key, props: key === null ? props : void 0 };
11691
12436
  }
11692
12437
  const ELEMENT_TAG = /* @__PURE__ */ Symbol.for("octane.element");
11693
12438
  const KEYED_ELEMENT_DESCRIPTORS = /* @__PURE__ */ new WeakSet();
@@ -12106,6 +12851,7 @@ function componentSlotVoid(parentScope, slotKey, domParent, comp, props, anchor,
12106
12851
  );
12107
12852
  }
12108
12853
  function componentSlotImpl(outputHandler, parentScope, slotKey, domParent, body, identity, props, renderProps, anchor, key, singleRoot, inherit, hasKey) {
12854
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
12109
12855
  const parentBlock = parentScope.block;
12110
12856
  const hydration = activeHydration();
12111
12857
  if (hydration !== null && (anchor != null && hydration.isFresh(anchor) || hydration.isFresh(domParent))) {
@@ -12215,8 +12961,8 @@ function componentSlotImpl(outputHandler, parentScope, slotKey, domParent, body,
12215
12961
  parentScope.slots[slotKey] = state;
12216
12962
  registerSlot(parentScope, state);
12217
12963
  }
12218
- const nextKey = key === void 0 ? NO_KEY : key;
12219
- const keyChanged = key !== void 0 && state.prevKey !== NO_KEY && !Object.is(key, state.prevKey);
12964
+ const nextKey = key === void 0 ? NO_KEY : "" + key;
12965
+ const keyChanged = key !== void 0 && state.prevKey !== NO_KEY && nextKey !== state.prevKey;
12220
12966
  const replacing = identity !== state.currentComp || keyChanged;
12221
12967
  const journaledSlot = ROOT_RENDER_TRANSACTION !== null && state.block !== null && replacing;
12222
12968
  if (journaledSlot) {
@@ -12671,25 +13417,28 @@ function clearReplacedChildBlock(state, oldBlock) {
12671
13417
  }
12672
13418
  const DEOPT_KEY_WARNED_BLOCKS = /* @__PURE__ */ new WeakSet();
12673
13419
  let DEOPT_KEY_WARNED_WITHOUT_BLOCK = false;
13420
+ function warnMissingListKey(owner) {
13421
+ const warned = owner === null ? DEOPT_KEY_WARNED_WITHOUT_BLOCK : DEOPT_KEY_WARNED_BLOCKS.has(owner);
13422
+ if (!warned) {
13423
+ if (owner === null) DEOPT_KEY_WARNED_WITHOUT_BLOCK = true;
13424
+ else DEOPT_KEY_WARNED_BLOCKS.add(owner);
13425
+ console.warn(
13426
+ 'Octane: each element in an array child should have a unique "key" prop (e.g. `items.map((x) => <li key={x.id}>\u2026</li>)`). Missing keys can reconcile incorrectly on reorder \u2014 for keyed lists prefer `@for (...; key ...)`.'
13427
+ );
13428
+ }
13429
+ }
12674
13430
  function deoptKey(item, index) {
12675
13431
  const element = item != null && item.$$kind === ELEMENT_TAG;
13432
+ if (item?.$$kind === PORTAL_TAG && item.key != null) return item.key;
12676
13433
  if (element && item.key != null && !ELEMENTS_MISSING_LIST_KEY.has(item)) return item.key;
12677
13434
  if (element && process.env.NODE_ENV !== "production" && activeHydration() === null) {
12678
- const owner = CURRENT_BLOCK;
12679
- const warned = owner === null ? DEOPT_KEY_WARNED_WITHOUT_BLOCK : DEOPT_KEY_WARNED_BLOCKS.has(owner);
12680
- if (!warned) {
12681
- if (owner === null) DEOPT_KEY_WARNED_WITHOUT_BLOCK = true;
12682
- else DEOPT_KEY_WARNED_BLOCKS.add(owner);
12683
- console.warn(
12684
- 'Octane: each element in an array child should have a unique "key" prop (e.g. `items.map((x) => <li key={x.id}>\u2026</li>)`). Missing keys can reconcile incorrectly on reorder \u2014 for keyed lists prefer `@for (...; key ...)`.'
12685
- );
12686
- }
13435
+ warnMissingListKey(CURRENT_BLOCK);
12687
13436
  }
12688
13437
  return element && item.key != null ? item.key : index;
12689
13438
  }
12690
13439
  const POSITIONAL_CHILDREN = /* @__PURE__ */ new WeakSet();
12691
13440
  function deoptKeyPositional(item, index) {
12692
- return item != null && item.$$kind === ELEMENT_TAG && item.key != null ? item.key : index;
13441
+ return item != null && (item.$$kind === ELEMENT_TAG || item.$$kind === PORTAL_TAG) && item.key != null ? item.key : index;
12693
13442
  }
12694
13443
  function positionalChildren(children) {
12695
13444
  POSITIONAL_CHILDREN.add(children);
@@ -12705,6 +13454,11 @@ function noteDeoptRef(block) {
12705
13454
  }
12706
13455
  }
12707
13456
  function applyDeoptProp(el, name, v, ownerBlock) {
13457
+ const actionName = formActionAttributeName(el, name);
13458
+ if (actionName !== null) {
13459
+ setFormAction(el, actionName, v, void 0);
13460
+ return;
13461
+ }
12708
13462
  if (name === "ref") {
12709
13463
  if (v != null) {
12710
13464
  noteDeoptRef(ownerBlock);
@@ -12715,7 +13469,7 @@ function applyDeoptProp(el, name, v, ownerBlock) {
12715
13469
  } else if (name === "style") {
12716
13470
  setStyle(el, v, void 0);
12717
13471
  } else {
12718
- const ev = eventSlot(name);
13472
+ const ev = eventSlot(name, el);
12719
13473
  if (ev !== null) {
12720
13474
  setEventHandler(
12721
13475
  el,
@@ -12737,6 +13491,9 @@ function hasDangerHTML(props) {
12737
13491
  }
12738
13492
  return true;
12739
13493
  }
13494
+ function hasHostPropContent(descriptor) {
13495
+ return hasDangerHTML(descriptor.props) || descriptor.type === "textarea" && (descriptor.props?.value != null || descriptor.props?.defaultValue != null);
13496
+ }
12740
13497
  function applyDeoptProps(el, props, ownerBlock) {
12741
13498
  if (props == null) {
12742
13499
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, ownerBlock);
@@ -12745,7 +13502,7 @@ function applyDeoptProps(el, props, ownerBlock) {
12745
13502
  for (const name in props) {
12746
13503
  if (name === "key" || name === "children") continue;
12747
13504
  if (name === "suppressHydrationWarning") {
12748
- el.__oct_suppress = props[name] !== false;
13505
+ el.__oct_suppress = props[name] === true;
12749
13506
  continue;
12750
13507
  }
12751
13508
  applyDeoptProp(el, name, props[name], ownerBlock);
@@ -12766,7 +13523,7 @@ function patchDeoptProps(el, prevProps, nextProps, ownerBlock) {
12766
13523
  for (const name in nextProps) {
12767
13524
  if (name === "key" || name === "children") continue;
12768
13525
  if (name === "suppressHydrationWarning") {
12769
- el.__oct_suppress = nextProps[name] !== false;
13526
+ el.__oct_suppress = nextProps[name] === true;
12770
13527
  continue;
12771
13528
  }
12772
13529
  const nv = nextProps[name];
@@ -12833,8 +13590,13 @@ function applyHostProps(el, props, scope, state) {
12833
13590
  for (const name in props) {
12834
13591
  if (name === "key" || name === "children") continue;
12835
13592
  const v = props[name];
13593
+ const actionName = formActionAttributeName(el, name);
13594
+ if (actionName !== null) {
13595
+ setFormAction(el, actionName, v, prev?.[name]);
13596
+ continue;
13597
+ }
12836
13598
  if (name === "suppressHydrationWarning") {
12837
- el.__oct_suppress = v !== false;
13599
+ el.__oct_suppress = v === true;
12838
13600
  continue;
12839
13601
  }
12840
13602
  if (name === "ref") {
@@ -12848,7 +13610,7 @@ function applyHostProps(el, props, scope, state) {
12848
13610
  } else if (name === "style") {
12849
13611
  setStyle(el, v, prev != null ? prev.style : void 0);
12850
13612
  } else {
12851
- const ev = eventSlot(name);
13613
+ const ev = eventSlot(name, el);
12852
13614
  if (ev) {
12853
13615
  if (ev.capture) {
12854
13616
  if (!_delegatedCapture.has(ev.type)) delegateCaptureEvents([ev.type]);
@@ -12955,7 +13717,7 @@ function deoptWrapperKind(value) {
12955
13717
  return POSITIONAL_CHILDREN.has(value) ? "fragment" : "array";
12956
13718
  }
12957
13719
  function scopedDeoptKey(path, item, index, key) {
12958
- const explicit = isElementDescriptor(item) && item.key != null;
13720
+ const explicit = (isElementDescriptor(item) || item?.$$kind === PORTAL_TAG) && item.key != null;
12959
13721
  if (path.length === 0) return explicit ? "k" + String(key) : "i" + index;
12960
13722
  return JSON.stringify([path, explicit ? "key" : "index", explicit ? String(key) : index]);
12961
13723
  }
@@ -13068,6 +13830,10 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
13068
13830
  if (t === "string" || t === "number" || t === "bigint") {
13069
13831
  const s = String(value);
13070
13832
  if (prev !== null && prev.nodeType === 3) {
13833
+ const hydration = activeHydration();
13834
+ if (hydration !== null && !hydration.isFresh(prev.parentNode)) {
13835
+ return hydration.htextSwap(prev, s);
13836
+ }
13071
13837
  updateTextValue(prev, s);
13072
13838
  return prev;
13073
13839
  }
@@ -13085,7 +13851,7 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
13085
13851
  applyDeoptProps(el, value.props, ownerBlock);
13086
13852
  }
13087
13853
  setDeoptDesc(el, value);
13088
- if (!hasDangerHTML(value.props)) {
13854
+ if (!hasHostPropContent(value)) {
13089
13855
  reconcileDeoptChildren(el, value.children, ownerBlock);
13090
13856
  }
13091
13857
  return el;
@@ -13101,7 +13867,12 @@ function reconcileDeoptChildren(el, children, ownerBlock) {
13101
13867
  if (type === "string" && children !== "" || type === "number" || type === "bigint") {
13102
13868
  const first = getFirstChild(el);
13103
13869
  if (first !== null && first.nodeType === 3 && getNextSibling(first) === null && first.$$deoptKey === 0 && first.$$portalEnd == null) {
13104
- updateTextValue(first, String(children));
13870
+ const hydration = activeHydration();
13871
+ if (hydration !== null && !hydration.isFresh(el)) {
13872
+ hydration.htextSwap(first, String(children));
13873
+ } else {
13874
+ updateTextValue(first, String(children));
13875
+ }
13105
13876
  return;
13106
13877
  }
13107
13878
  }
@@ -13179,6 +13950,10 @@ function reconcileDeoptChildren(el, children, ownerBlock) {
13179
13950
  for (let i = owned.length - 1; i >= 0; i--) {
13180
13951
  const n = owned[i];
13181
13952
  if (keep === null || !keep.has(n)) {
13953
+ const hydration = activeHydration();
13954
+ if (hydration !== null && !hydration.isFresh(el)) {
13955
+ noteRecoverableHydrationError(() => new Error((0, import_error_codes_client_generated.formatClientError)(62)), ownerBlock);
13956
+ }
13182
13957
  if (journal) {
13183
13958
  journalRootChildren(el);
13184
13959
  deferRootRange(el, n, n, () => detachDeoptTreeRefs(n, null));
@@ -13409,6 +14184,7 @@ function mappedDeoptItemBody(item, scope) {
13409
14184
  function descNeedsBlocks(value) {
13410
14185
  if (typeof value === "function") return true;
13411
14186
  if (value == null || typeof value !== "object") return false;
14187
+ if (typeof value.then === "function") return true;
13412
14188
  if (Array.isArray(value)) {
13413
14189
  for (let i = 0; i < value.length; i++) {
13414
14190
  if (descNeedsBlocks(value[i])) return true;
@@ -13434,7 +14210,7 @@ function hostElementBody(d, block) {
13434
14210
  applyDeoptProps(el, d.props, block);
13435
14211
  setDeoptDesc(el, d);
13436
14212
  const savedCursor = hydration.node.nextSibling;
13437
- if (!hasDangerHTML(d.props)) {
14213
+ if (!hasHostPropContent(d)) {
13438
14214
  hydration.node = el.firstChild;
13439
14215
  childSlot(block, 0, el, d.children, null, false, el);
13440
14216
  }
@@ -13462,7 +14238,7 @@ function hostElementBody(d, block) {
13462
14238
  block.parentNode.insertBefore(el, block.endMarker);
13463
14239
  applyDeoptProps(el, d.props, block);
13464
14240
  setDeoptDesc(el, d);
13465
- if (!hasDangerHTML(d.props)) {
14241
+ if (!hasHostPropContent(d)) {
13466
14242
  hydration.suspend(() => childSlot(block, 0, el, d.children, null, false, el));
13467
14243
  }
13468
14244
  return;
@@ -13498,7 +14274,7 @@ function hostElementBody(d, block) {
13498
14274
  patchDeoptProps(el, getDeoptDesc(el)?.props ?? null, d.props, block);
13499
14275
  }
13500
14276
  setDeoptDesc(el, d);
13501
- if (!hasDangerHTML(d.props)) childSlot(block, 0, el, d.children, null, false, el);
14277
+ if (!hasHostPropContent(d)) childSlot(block, 0, el, d.children, null, false, el);
13502
14278
  }
13503
14279
  function hostStringTagBody(d, block) {
13504
14280
  const tag = d.type;
@@ -13512,7 +14288,7 @@ function hostStringTagBody(d, block) {
13512
14288
  applyDeoptProps(el, d.props, block);
13513
14289
  setDeoptDesc(el, d);
13514
14290
  const savedCursor = hydration.node.nextSibling;
13515
- if (!hasDangerHTML(d.props)) {
14291
+ if (!hasHostPropContent(d)) {
13516
14292
  hydration.node = el.firstChild;
13517
14293
  renderHostTagChildren(d, block, el);
13518
14294
  }
@@ -13540,7 +14316,7 @@ function hostStringTagBody(d, block) {
13540
14316
  block.parentNode.insertBefore(el, block.endMarker);
13541
14317
  applyDeoptProps(el, d.props, block);
13542
14318
  setDeoptDesc(el, d);
13543
- if (!hasDangerHTML(d.props)) {
14319
+ if (!hasHostPropContent(d)) {
13544
14320
  hydration.suspend(() => renderHostTagChildren(d, block, el));
13545
14321
  }
13546
14322
  return;
@@ -13554,7 +14330,7 @@ function hostStringTagBody(d, block) {
13554
14330
  patchDeoptProps(el, getDeoptDesc(el)?.props ?? null, d.props, block);
13555
14331
  }
13556
14332
  setDeoptDesc(el, d);
13557
- if (!hasDangerHTML(d.props)) renderHostTagChildren(d, block, el);
14333
+ if (!hasHostPropContent(d)) renderHostTagChildren(d, block, el);
13558
14334
  }
13559
14335
  function renderHostTagChildren(d, block, el) {
13560
14336
  const kids = d.children;
@@ -13732,6 +14508,8 @@ function mapSlot(scopeOrItems, slotOrMethod, domParent, items, method, native, c
13732
14508
  callback = native;
13733
14509
  native = mapSlot(items, method);
13734
14510
  }
14511
+ if (process.env.NODE_ENV !== "production" && ((flags ?? 0) & 64) !== 0 && items?.length > 0)
14512
+ warnMissingListKey(scopeOrItems.block);
13735
14513
  if (ownEnd === 1) ownEnd = true;
13736
14514
  if (native === true) {
13737
14515
  const previous = scopeOrItems.slots[slotOrMethod]?.forSlot;
@@ -14001,6 +14779,7 @@ function renderPreparedChildList(state, parentBlock, domParent, preparedList, hy
14001
14779
  return;
14002
14780
  }
14003
14781
  function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsHost, compactable, includeKeyedSingle = true, compiledMapBody, compiledMapKey, compiledMapFlags, compiledMapDeps, mappedFallback) {
14782
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
14004
14783
  if (value != null && includeKeyedSingle && domParent.nodeType === 1 && import_constants.VOID_ELEMENTS.has(domParent.localName) && !isPortalTarget(parentScope.block, domParent)) {
14005
14784
  throw new Error((0, import_error_codes_client_generated.formatClientError)(26, domParent.localName));
14006
14785
  }
@@ -14075,7 +14854,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
14075
14854
  slotKey,
14076
14855
  domParent,
14077
14856
  value,
14078
- anchor,
14857
+ anchor?.parentNode === domParent ? anchor : null,
14079
14858
  ownEnd,
14080
14859
  ownsHost,
14081
14860
  compactable,
@@ -14196,7 +14975,9 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
14196
14975
  portalDesc.body,
14197
14976
  portalDesc.props,
14198
14977
  // The DOM element containing this hole is the portal's logical parent.
14199
- domParent
14978
+ domParent,
14979
+ void 0,
14980
+ portalDesc.key
14200
14981
  );
14201
14982
  if (activeFragments.size !== 0 && state.end !== null) {
14202
14983
  registerValuePortalFragmentOwners(state.portal, parentBlock, state.end);
@@ -14832,7 +15613,17 @@ function memo(component, arePropsEqual) {
14832
15613
  function memoWrapper(props, scope, extra) {
14833
15614
  return component(props, scope, extra);
14834
15615
  }
14835
- memoWrapper.__memo = true;
15616
+ Object.defineProperty(memoWrapper, "type", { value: component });
15617
+ Object.defineProperty(memoWrapper, "displayName", {
15618
+ configurable: true,
15619
+ writable: true,
15620
+ value: component.displayName || component.name || "Memo"
15621
+ });
15622
+ Object.defineProperty(memoWrapper, "__memo", {
15623
+ get() {
15624
+ return this === memoWrapper;
15625
+ }
15626
+ });
14836
15627
  Object.defineProperty(memoWrapper, "defaultProps", {
14837
15628
  configurable: true,
14838
15629
  get: () => component.defaultProps,
@@ -14842,7 +15633,7 @@ function memo(component, arePropsEqual) {
14842
15633
  });
14843
15634
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14844
15635
  (0, import_profiling.__profileComponentSource)(memoWrapper, component);
14845
- if (arePropsEqual) memoWrapper.__compare = arePropsEqual;
15636
+ if (arePropsEqual) Object.defineProperty(memoWrapper, "__compare", { value: arePropsEqual });
14846
15637
  return memoWrapper;
14847
15638
  }
14848
15639
  const HMR = /* @__PURE__ */ Symbol.for("octane.hmr");
@@ -14867,7 +15658,7 @@ function hmr(fn) {
14867
15658
  meta.fn = nextFn;
14868
15659
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14869
15660
  (0, import_profiling.__profileComponentSource)(wrapper, meta.fn);
14870
- wrapper.__warm = meta.fn.__warm;
15661
+ markWarm(wrapper, meta.fn.__warm);
14871
15662
  const it = meta.liveBlocks.values();
14872
15663
  for (let r = it.next(); !r.done; r = it.next()) {
14873
15664
  const b = r.value;
@@ -14889,10 +15680,14 @@ function hmr(fn) {
14889
15680
  if (scope !== void 0) meta.liveBlocks.add(scope.block);
14890
15681
  return meta.fn(props, scope, extra);
14891
15682
  }
14892
- wrapper[HMR] = meta;
15683
+ Object.defineProperty(wrapper, HMR, {
15684
+ get() {
15685
+ return this === wrapper ? meta : void 0;
15686
+ }
15687
+ });
14893
15688
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
14894
15689
  (0, import_profiling.__profileComponentSource)(wrapper, fn);
14895
- if (fn.__warm !== void 0) wrapper.__warm = fn.__warm;
15690
+ if (fn.__warm !== void 0) markWarm(wrapper, fn.__warm);
14896
15691
  return wrapper;
14897
15692
  }
14898
15693
  let TRANSITION_FALLBACK_TIMEOUT_MS = Infinity;
@@ -15685,7 +16480,7 @@ function renderVisibleTry(state, source) {
15685
16480
  throw renderError;
15686
16481
  if (isSuspenseException(renderError)) {
15687
16482
  if (state.propagateSuspense) throw renderError;
15688
- handleSuspense(state, renderError.thenable, block, journalCheckpoint);
16483
+ handleSuspense(state, renderError.thenable, block, journalCheckpoint, source ?? block);
15689
16484
  } else switchToCatch(state, renderError, true);
15690
16485
  } else {
15691
16486
  if (capture !== null) spliceOffscreenCapture(capture);
@@ -15970,6 +16765,7 @@ function releaseHeldTransition(state) {
15970
16765
  if (state.transitionHeld) {
15971
16766
  state.transitionHeld = false;
15972
16767
  tickTransitionCount(-1);
16768
+ releaseTransitionHookHolder(state);
15973
16769
  }
15974
16770
  abandonHeldTransition(state);
15975
16771
  if (state.transitionTimeoutId !== null) {
@@ -15977,14 +16773,15 @@ function releaseHeldTransition(state) {
15977
16773
  state.transitionTimeoutId = null;
15978
16774
  }
15979
16775
  }
15980
- function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1) {
16776
+ function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1, transitionOrigin = sourceBlock) {
15981
16777
  ensureScheduledVisibilityDriver();
15982
16778
  const isTransition = sourceBlock.currentRenderMode === "transition";
15983
- if ((isTransition || state.transitionHeld) && state.hasResolved && state.branch === 1 && state.hiddenDom === null) {
16779
+ if (isTransition && state.hasResolved && state.branch === 1 && state.hiddenDom === null) {
15984
16780
  rollbackTransitionJournal(journalCheckpoint, state.tryBlock ?? sourceBlock);
15985
16781
  if (ACTIVE_TRANSITION_ATTEMPT !== null) {
15986
16782
  (ACTIVE_TRANSITION_ATTEMPT.heldSlots ??= /* @__PURE__ */ new Set()).add(state);
15987
16783
  }
16784
+ holdTransitionHooksForBlock(state, transitionOrigin);
15988
16785
  if (!state.transitionHeld) {
15989
16786
  state.transitionHeld = true;
15990
16787
  tickTransitionCount(1);
@@ -16005,6 +16802,7 @@ function handleSuspense(state, thenable, sourceBlock, journalCheckpoint = -1) {
16005
16802
  attachResume(state, thenable);
16006
16803
  return;
16007
16804
  }
16805
+ if (!isTransition) releaseHeldTransition(state);
16008
16806
  hideTryContentAndMountPending(state, thenable);
16009
16807
  }
16010
16808
  function invalidatePendingSuspenseEffects(owner) {
@@ -16297,7 +17095,10 @@ function commitResumeInner(state) {
16297
17095
  if (!deferringStagedRevealEffects) commitEffects();
16298
17096
  } finally {
16299
17097
  if (hiddenActivity !== null) rehideActivityAfterDescendantRender(hiddenActivity);
16300
- if (releaseHeld) tickTransitionCount(-1);
17098
+ if (releaseHeld) {
17099
+ tickTransitionCount(-1);
17100
+ releaseTransitionHookHolder(state);
17101
+ }
16301
17102
  }
16302
17103
  }
16303
17104
  function findScheduledVisibilityOwner(block, includeActivity, visibleMode = null) {
@@ -16617,6 +17418,7 @@ function attemptHiddenRevealInner(state, scheduledMode, reason = "update") {
16617
17418
  if (state.transitionHeld) {
16618
17419
  state.transitionHeld = false;
16619
17420
  tickTransitionCount(-1);
17421
+ releaseTransitionHookHolder(state);
16620
17422
  }
16621
17423
  if (HELD_TRANSITIONS.has(state)) {
16622
17424
  HELD_TRANSITIONS.delete(state);
@@ -16671,6 +17473,7 @@ function flushStagedReveals() {
16671
17473
  break;
16672
17474
  }
16673
17475
  }
17476
+ if (allVisible && heldTransitionHasPendingAction(HELD_SYNC_TRANSITION.entries)) return;
16674
17477
  if (allVisible && promoteHeldSyncTransition()) {
16675
17478
  STAGED_REVEALS.clear();
16676
17479
  flush();
@@ -16750,6 +17553,9 @@ function attachResume(state, thenable) {
16750
17553
  thenable.then(retry, retry);
16751
17554
  }
16752
17555
  function startTransition(fn) {
17556
+ runTransition(fn);
17557
+ }
17558
+ function runTransition(fn, hook) {
16753
17559
  ensureTransitionSwapDriver();
16754
17560
  TRANSITION_DEPTH++;
16755
17561
  const parentActionBatch = ACTIVE_TRANSITION_ACTION_BATCH;
@@ -16757,6 +17563,10 @@ function startTransition(fn) {
16757
17563
  const actionBatch = parentActionBatch ?? pendingActionBatch ?? createTransitionActionBatch();
16758
17564
  const ownsActionBatch = parentActionBatch === null && pendingActionBatch === null;
16759
17565
  ACTIVE_TRANSITION_ACTION_BATCH = actionBatch;
17566
+ if (hook !== void 0) {
17567
+ addTransitionHookToBatch(actionBatch, hook);
17568
+ publishTransitionHookBatch(actionBatch);
17569
+ }
16760
17570
  const submitRec = ACTIVE_SUBMIT_DISPATCH;
16761
17571
  if (submitRec !== null) submitRec.transitions++;
16762
17572
  let result;
@@ -16786,7 +17596,10 @@ function startTransition(fn) {
16786
17596
  tickTransitionCount(-1);
16787
17597
  if (submitRec !== null) settleSubmitTransition(submitRec);
16788
17598
  flushFormResets();
16789
- throw err;
17599
+ actionBatch.workComplete = true;
17600
+ finishTransitionHookBatch(actionBatch);
17601
+ reportTransitionError(err, hook);
17602
+ return;
16790
17603
  }
16791
17604
  if (result != null && typeof result.then === "function") {
16792
17605
  ASYNC_TRANSITION_COUNT++;
@@ -16800,16 +17613,31 @@ function startTransition(fn) {
16800
17613
  ASYNC_TRANSITION_COUNT--;
16801
17614
  if (submitRec !== null) settleSubmitTransition(submitRec);
16802
17615
  flushFormResets();
17616
+ queueMicrotask(() => {
17617
+ actionBatch.workComplete = true;
17618
+ finishTransitionHookBatch(actionBatch);
17619
+ });
16803
17620
  };
16804
- result.then(settle, settle);
17621
+ result.then(settle, (error) => {
17622
+ settle();
17623
+ reportTransitionError(error, hook);
17624
+ });
16805
17625
  } else {
16806
17626
  queueMicrotask(() => {
16807
17627
  tickTransitionCount(-1);
16808
17628
  if (submitRec !== null) settleSubmitTransition(submitRec);
16809
17629
  flushFormResets();
17630
+ actionBatch.workComplete = true;
17631
+ finishTransitionHookBatch(actionBatch);
16810
17632
  });
16811
17633
  }
16812
17634
  }
17635
+ function reportTransitionError(error, hook) {
17636
+ if (hook !== void 0 && !hook.block.disposed) {
17637
+ hook.error = { value: error };
17638
+ scheduleRender(hook.block);
17639
+ } else reportListenerError(error);
17640
+ }
16813
17641
  function useTransition(slot) {
16814
17642
  slot = resolveSlot(slot);
16815
17643
  if (slot === void 0) missingSlot("useTransition");
@@ -16817,22 +17645,33 @@ function useTransition(slot) {
16817
17645
  const block = CURRENT_BLOCK;
16818
17646
  let s = scope.hooks?.get(slot);
16819
17647
  if (s === void 0) {
16820
- const slotRef = { isPending: false, start: startTransition };
16821
- s = slotRef;
16822
- ensureHooks(scope).set(slot, slotRef);
16823
- const listener = () => {
16824
- const next = TRANSITION_PENDING_COUNT > 0;
16825
- if (slotRef.isPending !== next) {
16826
- slotRef.isPending = next;
16827
- if (!block.disposed) {
17648
+ const hook = {
17649
+ isPending: false,
17650
+ block,
17651
+ pendingBatches: 0,
17652
+ start: (fn) => {
17653
+ if (!block.disposed) runTransition(fn, hook);
17654
+ },
17655
+ publish: (pending) => {
17656
+ if (hook.isPending === pending || block.disposed) return;
17657
+ hook.isPending = pending;
17658
+ TRANSITION_LISTENER_PUBLISH_DEPTH++;
17659
+ try {
16828
17660
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
16829
17661
  (0, import_profiling.__profileSchedule)(block, "transition-pending", slot);
16830
17662
  scheduleRender(block);
17663
+ } finally {
17664
+ TRANSITION_LISTENER_PUBLISH_DEPTH--;
16831
17665
  }
16832
17666
  }
16833
17667
  };
16834
- TRANSITION_LISTENERS.add(listener);
16835
- registerHookCleanup(scope, () => TRANSITION_LISTENERS.delete(listener));
17668
+ s = hook;
17669
+ ensureHooks(scope).set(slot, hook);
17670
+ }
17671
+ if (s.error !== void 0) {
17672
+ const error = s.error.value;
17673
+ s.error = void 0;
17674
+ throw error;
16836
17675
  }
16837
17676
  return [s.isPending, s.start];
16838
17677
  }
@@ -16863,6 +17702,7 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16863
17702
  }
16864
17703
  };
16865
17704
  const dispatch = ((payload) => {
17705
+ const outsideTransition = process.env.NODE_ENV !== "production" && transitionActionBatchForUpdate() === null && ACTIVE_SUBMIT_DISPATCH?.intercepted !== true;
16866
17706
  slotRef.pendingCount++;
16867
17707
  setPending(true);
16868
17708
  slotRef.chain = slotRef.chain.then(
@@ -16874,7 +17714,13 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16874
17714
  startTransition(() => {
16875
17715
  let p;
16876
17716
  try {
16877
- p = Promise.resolve(slotRef.action(prevState, payload));
17717
+ const result = slotRef.action(prevState, payload);
17718
+ if (process.env.NODE_ENV !== "production" && outsideTransition && result != null && typeof result.then === "function") {
17719
+ console.error(
17720
+ "An async useActionState action was dispatched outside a transition or action. Use an action/formAction prop or wrap the dispatch in startTransition."
17721
+ );
17722
+ }
17723
+ p = Promise.resolve(result);
16878
17724
  } catch (err) {
16879
17725
  finish();
16880
17726
  const handler = findTryHandler(block);
@@ -16902,7 +17748,7 @@ function useActionState(action, initialState, permalinkOrSlot, slot) {
16902
17748
  resolveResult(prevState);
16903
17749
  }
16904
17750
  );
16905
- return p;
17751
+ return p.then(noop, noop);
16906
17752
  });
16907
17753
  })
16908
17754
  );
@@ -16990,6 +17836,11 @@ function useOptimistic(passthrough, updateFnOrSlot, slot) {
16990
17836
  updateFn,
16991
17837
  armed: false,
16992
17838
  add: (value) => {
17839
+ if (process.env.NODE_ENV !== "production" && TRANSITION_DEPTH === 0 && ASYNC_TRANSITION_COUNT === 0) {
17840
+ console.error(
17841
+ "An optimistic update was dispatched outside a transition or action. Wrap it in startTransition or call it from an action."
17842
+ );
17843
+ }
16993
17844
  slotRef.queue.push(value);
16994
17845
  if (TRANSITION_PENDING_COUNT > 0) {
16995
17846
  slotRef.armed = true;
@@ -17023,11 +17874,11 @@ function spawnDeferredSwap(s) {
17023
17874
  queueMicrotask(() => {
17024
17875
  if (!s.scheduled || s.block.disposed) return;
17025
17876
  s.scheduled = false;
17026
- if (Object.is(s.current, s.next)) return;
17027
- s.current = s.next;
17877
+ if (Object.is(s.value, s.next)) return;
17028
17878
  startTransition(() => {
17029
17879
  DEFERRED_SPAWN = true;
17030
17880
  try {
17881
+ stageTransitionValue(s, s.block, s.next, s.next, true);
17031
17882
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
17032
17883
  (0, import_profiling.__profileSchedule)(s.block, "deferred-value", s.profileSlot);
17033
17884
  scheduleRender(s.block);
@@ -17038,6 +17889,14 @@ function spawnDeferredSwap(s) {
17038
17889
  });
17039
17890
  });
17040
17891
  }
17892
+ function hasHeldDeferredSwap(slot) {
17893
+ const entries = HELD_SYNC_TRANSITION?.entries ?? slot.block.idState.renderOwner?.transition?.entries;
17894
+ if (entries === void 0) return false;
17895
+ for (const entry of entries) {
17896
+ if (entry.slot === slot && Object.is(entry.value, slot.next)) return true;
17897
+ }
17898
+ return false;
17899
+ }
17041
17900
  function useDeferredValue(value, ...rest) {
17042
17901
  let slot = rest[rest.length - 1];
17043
17902
  slot = resolveSlot(slot);
@@ -17051,7 +17910,7 @@ function useDeferredValue(value, ...rest) {
17051
17910
  if (s === void 0) {
17052
17911
  if (hasInitial && !block.currentRenderDeferred) {
17053
17912
  s = {
17054
- current: initialValue,
17913
+ value: initialValue,
17055
17914
  next: value,
17056
17915
  scheduled: false,
17057
17916
  block,
@@ -17063,31 +17922,32 @@ function useDeferredValue(value, ...rest) {
17063
17922
  if (!Object.is(initialValue, value)) spawnDeferredSwap(s);
17064
17923
  return initialValue;
17065
17924
  }
17066
- s = { current: value, next: value, scheduled: false, block, wasHidden: hidden };
17925
+ s = { value, next: value, scheduled: false, block, wasHidden: hidden };
17067
17926
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
17068
17927
  s.profileSlot = slot;
17069
17928
  ensureHooks(scope).set(slot, s);
17070
17929
  return value;
17071
17930
  }
17931
+ if (ACTIVE_TRANSITION_ATTEMPT !== null) journalObjectOnce(s);
17072
17932
  s.next = value;
17073
17933
  const wasHidden = s.wasHidden;
17074
17934
  s.wasHidden = hidden;
17075
- if (Object.is(s.current, value)) return s.current;
17935
+ if (Object.is(s.value, value)) return s.value;
17076
17936
  if (hidden || wasHidden) {
17077
17937
  if (hasInitial && !block.currentRenderDeferred && !Object.is(initialValue, value)) {
17078
- s.current = initialValue;
17938
+ s.value = initialValue;
17079
17939
  if (!s.scheduled) spawnDeferredSwap(s);
17080
17940
  return initialValue;
17081
17941
  }
17082
- s.current = value;
17942
+ s.value = value;
17083
17943
  return value;
17084
17944
  }
17085
17945
  if (block.currentRenderMode === "transition") {
17086
- s.current = value;
17946
+ s.value = value;
17087
17947
  return value;
17088
17948
  }
17089
- if (!s.scheduled) spawnDeferredSwap(s);
17090
- return s.current;
17949
+ if (!s.scheduled && !hasHeldDeferredSwap(s)) spawnDeferredSwap(s);
17950
+ return s.value;
17091
17951
  }
17092
17952
  function requestReset(state) {
17093
17953
  if (state.parentBlock.disposed || state.branch !== 0) return;
@@ -17161,6 +18021,7 @@ function switchToCatchInner(state, err, reportInline, adoptedStart, adoptedEnd)
17161
18021
  if (state.transitionHeld) {
17162
18022
  state.transitionHeld = false;
17163
18023
  tickTransitionCount(-1);
18024
+ releaseTransitionHookHolder(state);
17164
18025
  }
17165
18026
  abandonHeldTransition(state);
17166
18027
  if (state.catchBody === null) {
@@ -17322,6 +18183,7 @@ function sharesBlockBoundary(parent, start, end) {
17322
18183
  return parent !== null && start !== null && end !== null && parent.startMarker === start && parent.endMarker === end;
17323
18184
  }
17324
18185
  function renderBranchSlot(parentScope, slotKey, state, domParent, next, body, marker, env) {
18186
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
17325
18187
  const parentBlock = parentScope.block;
17326
18188
  const hydration = activeHydration();
17327
18189
  if (next !== state.branch) {
@@ -17986,6 +18848,7 @@ function queueActivityDeactivation(state, block, commitVersion) {
17986
18848
  });
17987
18849
  }
17988
18850
  function activityBlock(parentScope, slotKey, domParent, mode, body, anchor, env) {
18851
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
17989
18852
  if (mode === "hidden") ensureScheduledVisibilityDriver();
17990
18853
  const parentBlock = parentScope.block;
17991
18854
  const hydration = activeHydration();
@@ -18224,7 +19087,7 @@ function deactivateScope(scope, disconnectPassive = true) {
18224
19087
  const cleanup = e.cleanup;
18225
19088
  e.cleanup = void 0;
18226
19089
  try {
18227
- runEffectCleanupCallback(cleanup);
19090
+ runEffectCleanupCallback(cleanup, e.phase);
18228
19091
  } catch (err) {
18229
19092
  if (err instanceof MaximumUpdateDepthError) throw err;
18230
19093
  const handler = findTryHandler(scope.block);
@@ -18275,6 +19138,7 @@ function switchBlock(parentScope, slotKey, domParent, discriminant, cases, defau
18275
19138
  renderBranchSlot(parentScope, slotKey, state, domParent, nextIdx, body, "switch", env);
18276
19139
  }
18277
19140
  function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd) {
19141
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
18278
19142
  const parentBlock = parentScope.block;
18279
19143
  const hydration = activeHydration();
18280
19144
  let state = parentScope.slots[slotKey];
@@ -18430,6 +19294,7 @@ function forBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flag
18430
19294
  }
18431
19295
  }
18432
19296
  function keyedForBlock(parentScope, slotKey, domParent, items, getKey, itemBody, flags, deps, emptyBody, anchor, ownEnd, selectionBody) {
19297
+ if (CURRENT_BLOCK?.pending && !CURRENT_BLOCK.crossRenderUpdate) return;
18433
19298
  const state = parentScope.slots[slotKey];
18434
19299
  if (TRANSITION_JOURNAL !== null && ROOT_RENDER_TRANSACTION === null) {
18435
19300
  if (state !== void 0) {
@@ -18758,9 +19623,25 @@ function consumeAdoptQueuePrefix(adopt, count) {
18758
19623
  if (count < adopt.length) adopt.copyWithin(0, count);
18759
19624
  adopt.length -= count;
18760
19625
  }
19626
+ function checkedListKey(getKey) {
19627
+ const seen = /* @__PURE__ */ new Map();
19628
+ let warned = false;
19629
+ return (item, index) => {
19630
+ const key = getKey(item, index);
19631
+ if (!warned && seen.has(key) && seen.get(key) !== index) {
19632
+ warned = true;
19633
+ const label = typeof key === "object" || typeof key === "function" ? "[object identity]" : String(key);
19634
+ console.error(
19635
+ `Encountered two children with the same key, ${label}. Keys should be unique so that components maintain their identity across updates.`
19636
+ );
19637
+ } else seen.set(key, index);
19638
+ return key;
19639
+ };
19640
+ }
18761
19641
  function mountItemsLinear(parentBlock, state, items, getKey, itemBody, singleRoot, ssrMarkerless) {
18762
19642
  const newLen = items.length;
18763
19643
  if (newLen === 0) return;
19644
+ if (process.env.NODE_ENV !== "production") getKey = checkedListKey(getKey);
18764
19645
  if (TRANSITION_JOURNAL !== null) journalForSlot(state);
18765
19646
  const oldItems = state.items;
18766
19647
  const parentNode = state.end.parentNode;
@@ -18830,6 +19711,7 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
18830
19711
  mountItemsLinear(parentBlock, state, items, getKey, itemBody, singleRoot, ssrMarkerless);
18831
19712
  return;
18832
19713
  }
19714
+ if (process.env.NODE_ENV !== "production") getKey = checkedListKey(getKey);
18833
19715
  if (newLen === 0) {
18834
19716
  if (journalShape) journalForSlot(state);
18835
19717
  batchClearItems(state, oldItems);
@@ -19088,81 +19970,72 @@ function reconcileKeyed(parentBlock, state, items, getKey, itemBody, pure, singl
19088
19970
  }
19089
19971
  }
19090
19972
  const middleEndAnchor = afterMiddle ? afterMiddle.startMarker : state.end;
19091
- let nextBlock = afterMiddle;
19092
- let lastPlaced = null;
19093
- if (moved) {
19973
+ if (patched === newMidLen) {
19094
19974
  const seq = lis(sources, newMidLen);
19095
19975
  let seqIdx = seq.length - 1;
19976
+ let nextBlock = afterMiddle;
19096
19977
  for (let i = newMidLen - 1; i >= 0; i--) {
19097
- const targetIdx = i + prefixLen;
19098
- const key = newKeys[i];
19099
- const anchor = nextBlock ? nextBlock.startMarker : middleEndAnchor;
19100
- let block;
19101
- if (sources[i] === -1) {
19102
- const item = items[targetIdx];
19103
- block = mountItem(
19104
- parentBlock,
19105
- parentNode,
19106
- anchor,
19107
- item,
19108
- targetIdx,
19109
- itemBody,
19110
- state,
19111
- singleRoot,
19112
- ssrMarkerless
19113
- );
19114
- oldItems.set(key, block);
19115
- block.key = key;
19116
- state.size++;
19117
- } else if (seqIdx < 0 || i !== seq[seqIdx]) {
19118
- block = oldItems.get(key);
19119
- moveBlockBefore(block, anchor);
19120
- } else {
19121
- block = oldItems.get(key);
19122
- seqIdx--;
19123
- }
19978
+ const block = oldItems.get(newKeys[i]);
19979
+ if (seqIdx < 0 || i !== seq[seqIdx]) {
19980
+ moveBlockBefore(block, nextBlock ? nextBlock.startMarker : middleEndAnchor);
19981
+ } else seqIdx--;
19124
19982
  block.nextSibling = nextBlock;
19125
19983
  if (nextBlock) nextBlock.prevSibling = block;
19126
- if (lastPlaced === null) lastPlaced = block;
19984
+ else state.tail = block;
19127
19985
  nextBlock = block;
19128
19986
  }
19129
- } else {
19987
+ nextBlock.prevSibling = beforeMiddle;
19988
+ if (beforeMiddle) beforeMiddle.nextSibling = nextBlock;
19989
+ else state.head = nextBlock;
19990
+ return;
19991
+ }
19992
+ if (moved) {
19993
+ const seq = lis(sources, newMidLen);
19994
+ let seqIdx = seq.length - 1;
19995
+ let anchor = middleEndAnchor;
19130
19996
  for (let i = newMidLen - 1; i >= 0; i--) {
19131
- const targetIdx = i + prefixLen;
19132
- const key = newKeys[i];
19133
- const anchor = nextBlock ? nextBlock.startMarker : middleEndAnchor;
19134
- let block;
19135
- if (sources[i] === -1) {
19136
- const item = items[targetIdx];
19137
- block = mountItem(
19138
- parentBlock,
19139
- parentNode,
19140
- anchor,
19141
- item,
19142
- targetIdx,
19143
- itemBody,
19144
- state,
19145
- singleRoot,
19146
- ssrMarkerless
19147
- );
19148
- oldItems.set(key, block);
19149
- block.key = key;
19150
- state.size++;
19151
- } else {
19152
- block = oldItems.get(key);
19997
+ if (sources[i] === -1) continue;
19998
+ const block = oldItems.get(newKeys[i]);
19999
+ if (seqIdx < 0 || i !== seq[seqIdx]) moveBlockBefore(block, anchor);
20000
+ else seqIdx--;
20001
+ anchor = block.startMarker;
20002
+ }
20003
+ }
20004
+ let previous = beforeMiddle;
20005
+ let nextSurvivor = 0;
20006
+ for (let i = 0; i < newMidLen; i++) {
20007
+ const key = newKeys[i];
20008
+ let block;
20009
+ if (sources[i] === -1) {
20010
+ if (nextSurvivor <= i) {
20011
+ nextSurvivor = i + 1;
20012
+ while (nextSurvivor < newMidLen && sources[nextSurvivor] === -1) nextSurvivor++;
19153
20013
  }
19154
- block.nextSibling = nextBlock;
19155
- if (nextBlock) nextBlock.prevSibling = block;
19156
- if (lastPlaced === null) lastPlaced = block;
19157
- nextBlock = block;
19158
- }
20014
+ const anchor = nextSurvivor < newMidLen ? oldItems.get(newKeys[nextSurvivor]).startMarker : middleEndAnchor;
20015
+ const targetIdx = i + prefixLen;
20016
+ block = mountItem(
20017
+ parentBlock,
20018
+ parentNode,
20019
+ anchor,
20020
+ items[targetIdx],
20021
+ targetIdx,
20022
+ itemBody,
20023
+ state,
20024
+ singleRoot,
20025
+ ssrMarkerless
20026
+ );
20027
+ oldItems.set(key, block);
20028
+ block.key = key;
20029
+ state.size++;
20030
+ } else block = oldItems.get(key);
20031
+ block.prevSibling = previous;
20032
+ if (previous) previous.nextSibling = block;
20033
+ else state.head = block;
20034
+ previous = block;
19159
20035
  }
19160
- const newMiddleHead = nextBlock;
19161
- const newMiddleTail = lastPlaced;
19162
- newMiddleHead.prevSibling = beforeMiddle;
19163
- if (beforeMiddle) beforeMiddle.nextSibling = newMiddleHead;
19164
- else state.head = newMiddleHead;
19165
- if (!afterMiddle) state.tail = newMiddleTail;
20036
+ previous.nextSibling = afterMiddle;
20037
+ if (afterMiddle) afterMiddle.prevSibling = previous;
20038
+ else state.tail = previous;
19166
20039
  } finally {
19167
20040
  if (sources.length <= MAX_KEYED_REORDER_SCRATCH && (keyedReorderSources === null || keyedReorderSources.length < sources.length)) {
19168
20041
  keyedReorderSources = sources;
@@ -19868,8 +20741,19 @@ let ROOT_CONTAINER_OWNERS = null;
19868
20741
  const ROOT_RENDERABLE_BODY = ((value) => value === void 0 ? null : value);
19869
20742
  const EMPTY_ROOT_BODY = (() => void 0);
19870
20743
  function assertValidRootContainer(container) {
19871
- if (container === null || typeof container !== "object" || container.nodeType !== 1) {
19872
- throw new Error((0, import_error_codes_client_generated.formatClientError)(28));
20744
+ if (container === null || typeof container !== "object" || container.nodeType !== 1 && container.nodeType !== 9 && container.nodeType !== 11) {
20745
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(63));
20746
+ }
20747
+ }
20748
+ function clearRootContainer(container) {
20749
+ if (container.nodeType !== 9) {
20750
+ container.textContent = "";
20751
+ return;
20752
+ }
20753
+ for (let child2 = container.firstChild; child2 !== null; ) {
20754
+ const next = child2.nextSibling;
20755
+ if (child2.nodeType !== 10) container.removeChild(child2);
20756
+ child2 = next;
19873
20757
  }
19874
20758
  }
19875
20759
  function claimRootContainer(container) {
@@ -19978,17 +20862,19 @@ function devHtmlNesting(childTag, ancestors, childLocation, ancestorLocation) {
19978
20862
  }
19979
20863
  function validateRootHtmlNesting(container, body) {
19980
20864
  if (process.env.NODE_ENV !== "production") {
19981
- if (componentSourceLoc(body) === void 0 || container.namespaceURI !== "http://www.w3.org/1999/xhtml" || container.localName === "div" || container.localName === "body" || container.localName === "html" || container.localName.includes("-")) {
20865
+ if (container.nodeType !== 1) return;
20866
+ const element = container;
20867
+ if (componentSourceLoc(body) === void 0 || element.namespaceURI !== "http://www.w3.org/1999/xhtml" || element.localName === "div" || element.localName === "body" || element.localName === "html" || element.localName.includes("-")) {
19982
20868
  return;
19983
20869
  }
19984
20870
  const root = container.firstElementChild;
19985
20871
  if (root === null) return;
19986
- if ((0, import_html_tree_validation.invalidHtmlNestingWithParent)(root.localName, container.localName) !== null) {
19987
- devHtmlNesting(root.localName, [container.localName]);
20872
+ if ((0, import_html_tree_validation.invalidHtmlNestingWithParent)(root.localName, element.localName) !== null) {
20873
+ devHtmlNesting(root.localName, [element.localName]);
19988
20874
  return;
19989
20875
  }
19990
20876
  let child2 = root.firstElementChild;
19991
- const ancestors = [root.localName, container.localName];
20877
+ const ancestors = [root.localName, element.localName];
19992
20878
  while (child2 !== null && child2.namespaceURI === "http://www.w3.org/1999/xhtml") {
19993
20879
  if ((0, import_html_tree_validation.invalidHtmlNestingWithAncestor)(child2.localName, ancestors) !== null) {
19994
20880
  devHtmlNesting(child2.localName, ancestors);
@@ -20053,7 +20939,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
20053
20939
  const previousRoot = rootBlock;
20054
20940
  const previousBody = currentBody;
20055
20941
  const previousKey = currentKey;
20056
- const staged = previousRoot !== null && previousRoot.mounted && !previousRoot.disposed && !renderOwner.transaction.created?.has(previousRoot);
20942
+ const staged = container.nodeType !== 9 && previousRoot !== null && previousRoot.mounted && !previousRoot.disposed && !renderOwner.transaction.created?.has(previousRoot);
20057
20943
  const oldFirst = staged ? container.firstChild : null;
20058
20944
  const oldLast = staged ? container.lastChild : null;
20059
20945
  journalUndo(() => {
@@ -20078,7 +20964,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
20078
20964
  end = document.createComment("/root");
20079
20965
  container.append(start, end);
20080
20966
  } else {
20081
- while (container.firstChild) container.removeChild(container.firstChild);
20967
+ clearRootContainer(container);
20082
20968
  }
20083
20969
  rootBlock = createBlock(
20084
20970
  "root",
@@ -20121,6 +21007,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
20121
21007
  mountedRoot.pendingMode = mode ?? null;
20122
21008
  try {
20123
21009
  renderBlock(mountedRoot);
21010
+ if (QUEUE.length > 0) drainHydrationRenderPhaseUpdates(mountedRoot);
20124
21011
  if (process.env.NODE_ENV !== "production") {
20125
21012
  validateRootHtmlNesting(container, body);
20126
21013
  }
@@ -20239,7 +21126,8 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
20239
21126
  false
20240
21127
  );
20241
21128
  drainRefDetaches();
20242
- container.textContent = "";
21129
+ clearRootContainer(container);
21130
+ drainDeferredPassiveUnmounts();
20243
21131
  rootBlock = null;
20244
21132
  currentBody = null;
20245
21133
  currentKey = null;
@@ -20398,7 +21286,7 @@ function hydrateRoot(container, bodyOrElement, propsOrOptions, rootOptions) {
20398
21286
  journalRootProperty(idState, "next");
20399
21287
  idState.next = 0;
20400
21288
  let firstNode = container.firstChild;
20401
- while (firstNode !== null && isRendererHydrationStyle(firstNode))
21289
+ while (firstNode !== null && (firstNode.nodeType === 10 || isRendererHydrationStyle(firstNode)))
20402
21290
  firstNode = firstNode.nextSibling;
20403
21291
  const hydration = new HydrationCapability(rootBlock, firstNode, seeds);
20404
21292
  if (nativeManifest !== void 0)
@@ -20431,7 +21319,7 @@ function hydrateRoot(container, bodyOrElement, propsOrOptions, rootOptions) {
20431
21319
  } catch (unhandled) {
20432
21320
  rollbackRootRender(owner.transaction);
20433
21321
  unmountBlock(rootBlock, false);
20434
- container.textContent = "";
21322
+ clearRootContainer(container);
20435
21323
  if (!reportUncaughtError(rootBlock, unhandled)) throw unhandled;
20436
21324
  return;
20437
21325
  }
@@ -20926,15 +21814,18 @@ function scriptResource(attrs) {
20926
21814
  hydrateRoot,
20927
21815
  ifBlock,
20928
21816
  injectStyle,
21817
+ invokeManualHook,
20929
21818
  isChildrenBlock,
20930
21819
  isValidElement,
20931
21820
  keyedForBlock,
20932
21821
  lazy,
21822
+ manualHook,
20933
21823
  mapSlot,
20934
21824
  markChildrenBlock,
20935
21825
  markDangerouslySetInnerHTMLChildren,
20936
21826
  markNativeChangeDiagnosticStatic,
20937
21827
  markSingleRoot,
21828
+ markWarm,
20938
21829
  memo,
20939
21830
  memoPublish,
20940
21831
  memoPublishAlways,