@seamly/web-ui 25.2.1 → 25.3.0-beta

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.
@@ -239,27 +239,36 @@ function getOrInsertComputed(map, key, compute) {
239
239
  function isImmutableDefault(value) {
240
240
  return typeof value !== "object" || value == null || Object.isFrozen(value);
241
241
  }
242
- function trackForMutations(isImmutable, ignorePaths, obj) {
243
- const trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
242
+ function trackForMutations(isImmutable, ignoredPaths, obj) {
243
+ const trackedProperties = trackProperties(isImmutable, ignoredPaths, obj);
244
244
  return {
245
245
  detectMutations() {
246
- return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
246
+ return detectMutations(isImmutable, ignoredPaths, trackedProperties, obj);
247
247
  }
248
248
  };
249
249
  }
250
- function trackProperties(isImmutable, ignorePaths = [], obj, path = "", checkedObjects = /* @__PURE__ */ new Set()) {
250
+ function trackProperties(isImmutable, ignoredPaths = [], obj, path = "", checkedObjects = /* @__PURE__ */ new Set()) {
251
251
  const tracked = {
252
252
  value: obj
253
253
  };
254
254
  if (!isImmutable(obj) && !checkedObjects.has(obj)) {
255
255
  checkedObjects.add(obj);
256
256
  tracked.children = {};
257
+ const hasIgnoredPaths = ignoredPaths.length > 0;
257
258
  for (const key in obj) {
258
- const childPath = path ? path + "." + key : key;
259
- if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
260
- continue;
259
+ const nestedPath = path ? path + "." + key : key;
260
+ if (hasIgnoredPaths) {
261
+ const hasMatches = ignoredPaths.some((ignored) => {
262
+ if (ignored instanceof RegExp) {
263
+ return ignored.test(nestedPath);
264
+ }
265
+ return nestedPath === ignored;
266
+ });
267
+ if (hasMatches) {
268
+ continue;
269
+ }
261
270
  }
262
- tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
271
+ tracked.children[key] = trackProperties(isImmutable, ignoredPaths, obj[key], nestedPath);
263
272
  }
264
273
  }
265
274
  return tracked;
@@ -736,7 +745,6 @@ function executeReducerBuilderCallback(builderCallback) {
736
745
  }
737
746
 
738
747
  // src/createReducer.ts
739
- (0,immer__WEBPACK_IMPORTED_MODULE_1__.setUseStrictIteration)(false);
740
748
  function isStateFunction(x) {
741
749
  return typeof x === "function";
742
750
  }
@@ -8382,7 +8390,7 @@ var errors = true ? [
8382
8390
  function die(error, ...args) {
8383
8391
  if (true) {
8384
8392
  const e = errors[error];
8385
- const msg = typeof e === "function" ? e.apply(null, args) : e;
8393
+ const msg = isFunction(e) ? e.apply(null, args) : e;
8386
8394
  throw new Error(`[Immer] ${msg}`);
8387
8395
  }
8388
8396
  // removed by dead control flow
@@ -8390,27 +8398,32 @@ function die(error, ...args) {
8390
8398
  }
8391
8399
 
8392
8400
  // src/utils/common.ts
8393
- var getPrototypeOf = Object.getPrototypeOf;
8394
- function isDraft(value) {
8395
- return !!value && !!value[DRAFT_STATE];
8396
- }
8401
+ var O = Object;
8402
+ var getPrototypeOf = O.getPrototypeOf;
8403
+ var CONSTRUCTOR = "constructor";
8404
+ var PROTOTYPE = "prototype";
8405
+ var CONFIGURABLE = "configurable";
8406
+ var ENUMERABLE = "enumerable";
8407
+ var WRITABLE = "writable";
8408
+ var VALUE = "value";
8409
+ var isDraft = (value) => !!value && !!value[DRAFT_STATE];
8397
8410
  function isDraftable(value) {
8398
8411
  if (!value)
8399
8412
  return false;
8400
- return isPlainObject(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!value.constructor?.[DRAFTABLE] || isMap(value) || isSet(value);
8413
+ return isPlainObject(value) || isArray(value) || !!value[DRAFTABLE] || !!value[CONSTRUCTOR]?.[DRAFTABLE] || isMap(value) || isSet(value);
8401
8414
  }
8402
- var objectCtorString = Object.prototype.constructor.toString();
8415
+ var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString();
8403
8416
  var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
8404
8417
  function isPlainObject(value) {
8405
- if (!value || typeof value !== "object")
8418
+ if (!value || !isObjectish(value))
8406
8419
  return false;
8407
- const proto = Object.getPrototypeOf(value);
8408
- if (proto === null || proto === Object.prototype)
8420
+ const proto = getPrototypeOf(value);
8421
+ if (proto === null || proto === O[PROTOTYPE])
8409
8422
  return true;
8410
- const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
8423
+ const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR];
8411
8424
  if (Ctor === Object)
8412
8425
  return true;
8413
- if (typeof Ctor !== "function")
8426
+ if (!isFunction(Ctor))
8414
8427
  return false;
8415
8428
  let ctorString = cachedCtorStrings.get(Ctor);
8416
8429
  if (ctorString === void 0) {
@@ -8426,7 +8439,7 @@ function original(value) {
8426
8439
  }
8427
8440
  function each(obj, iter, strict = true) {
8428
8441
  if (getArchtype(obj) === 0 /* Object */) {
8429
- const keys = strict ? Reflect.ownKeys(obj) : Object.keys(obj);
8442
+ const keys = strict ? Reflect.ownKeys(obj) : O.keys(obj);
8430
8443
  keys.forEach((key) => {
8431
8444
  iter(key, obj[key], obj);
8432
8445
  });
@@ -8436,23 +8449,21 @@ function each(obj, iter, strict = true) {
8436
8449
  }
8437
8450
  function getArchtype(thing) {
8438
8451
  const state = thing[DRAFT_STATE];
8439
- return state ? state.type_ : Array.isArray(thing) ? 1 /* Array */ : isMap(thing) ? 2 /* Map */ : isSet(thing) ? 3 /* Set */ : 0 /* Object */;
8440
- }
8441
- function has(thing, prop) {
8442
- return getArchtype(thing) === 2 /* Map */ ? thing.has(prop) : Object.prototype.hasOwnProperty.call(thing, prop);
8452
+ return state ? state.type_ : isArray(thing) ? 1 /* Array */ : isMap(thing) ? 2 /* Map */ : isSet(thing) ? 3 /* Set */ : 0 /* Object */;
8443
8453
  }
8444
- function get(thing, prop) {
8445
- return getArchtype(thing) === 2 /* Map */ ? thing.get(prop) : thing[prop];
8446
- }
8447
- function set(thing, propOrOldValue, value) {
8448
- const t = getArchtype(thing);
8449
- if (t === 2 /* Map */)
8454
+ var has = (thing, prop, type = getArchtype(thing)) => type === 2 /* Map */ ? thing.has(prop) : O[PROTOTYPE].hasOwnProperty.call(thing, prop);
8455
+ var get = (thing, prop, type = getArchtype(thing)) => (
8456
+ // @ts-ignore
8457
+ type === 2 /* Map */ ? thing.get(prop) : thing[prop]
8458
+ );
8459
+ var set = (thing, propOrOldValue, value, type = getArchtype(thing)) => {
8460
+ if (type === 2 /* Map */)
8450
8461
  thing.set(propOrOldValue, value);
8451
- else if (t === 3 /* Set */) {
8462
+ else if (type === 3 /* Set */) {
8452
8463
  thing.add(value);
8453
8464
  } else
8454
8465
  thing[propOrOldValue] = value;
8455
- }
8466
+ };
8456
8467
  function is(x, y) {
8457
8468
  if (x === y) {
8458
8469
  return x !== 0 || 1 / x === 1 / y;
@@ -8460,15 +8471,23 @@ function is(x, y) {
8460
8471
  return x !== x && y !== y;
8461
8472
  }
8462
8473
  }
8463
- function isMap(target) {
8464
- return target instanceof Map;
8465
- }
8466
- function isSet(target) {
8467
- return target instanceof Set;
8468
- }
8469
- function latest(state) {
8470
- return state.copy_ || state.base_;
8471
- }
8474
+ var isArray = Array.isArray;
8475
+ var isMap = (target) => target instanceof Map;
8476
+ var isSet = (target) => target instanceof Set;
8477
+ var isObjectish = (target) => typeof target === "object";
8478
+ var isFunction = (target) => typeof target === "function";
8479
+ var isBoolean = (target) => typeof target === "boolean";
8480
+ var getProxyDraft = (value) => {
8481
+ if (!isObjectish(value))
8482
+ return null;
8483
+ return value?.[DRAFT_STATE];
8484
+ };
8485
+ var latest = (state) => state.copy_ || state.base_;
8486
+ var getValue = (value) => {
8487
+ const proxyDraft = getProxyDraft(value);
8488
+ return proxyDraft ? proxyDraft.copy_ ?? proxyDraft.base_ : value;
8489
+ };
8490
+ var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
8472
8491
  function shallowCopy(base, strict) {
8473
8492
  if (isMap(base)) {
8474
8493
  return new Map(base);
@@ -8476,68 +8495,76 @@ function shallowCopy(base, strict) {
8476
8495
  if (isSet(base)) {
8477
8496
  return new Set(base);
8478
8497
  }
8479
- if (Array.isArray(base))
8480
- return Array.prototype.slice.call(base);
8498
+ if (isArray(base))
8499
+ return Array[PROTOTYPE].slice.call(base);
8481
8500
  const isPlain = isPlainObject(base);
8482
8501
  if (strict === true || strict === "class_only" && !isPlain) {
8483
- const descriptors = Object.getOwnPropertyDescriptors(base);
8502
+ const descriptors = O.getOwnPropertyDescriptors(base);
8484
8503
  delete descriptors[DRAFT_STATE];
8485
8504
  let keys = Reflect.ownKeys(descriptors);
8486
8505
  for (let i = 0; i < keys.length; i++) {
8487
8506
  const key = keys[i];
8488
8507
  const desc = descriptors[key];
8489
- if (desc.writable === false) {
8490
- desc.writable = true;
8491
- desc.configurable = true;
8508
+ if (desc[WRITABLE] === false) {
8509
+ desc[WRITABLE] = true;
8510
+ desc[CONFIGURABLE] = true;
8492
8511
  }
8493
8512
  if (desc.get || desc.set)
8494
8513
  descriptors[key] = {
8495
- configurable: true,
8496
- writable: true,
8514
+ [CONFIGURABLE]: true,
8515
+ [WRITABLE]: true,
8497
8516
  // could live with !!desc.set as well here...
8498
- enumerable: desc.enumerable,
8499
- value: base[key]
8517
+ [ENUMERABLE]: desc[ENUMERABLE],
8518
+ [VALUE]: base[key]
8500
8519
  };
8501
8520
  }
8502
- return Object.create(getPrototypeOf(base), descriptors);
8521
+ return O.create(getPrototypeOf(base), descriptors);
8503
8522
  } else {
8504
8523
  const proto = getPrototypeOf(base);
8505
8524
  if (proto !== null && isPlain) {
8506
8525
  return { ...base };
8507
8526
  }
8508
- const obj = Object.create(proto);
8509
- return Object.assign(obj, base);
8527
+ const obj = O.create(proto);
8528
+ return O.assign(obj, base);
8510
8529
  }
8511
8530
  }
8512
8531
  function freeze(obj, deep = false) {
8513
8532
  if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
8514
8533
  return obj;
8515
8534
  if (getArchtype(obj) > 1) {
8516
- Object.defineProperties(obj, {
8535
+ O.defineProperties(obj, {
8517
8536
  set: dontMutateMethodOverride,
8518
8537
  add: dontMutateMethodOverride,
8519
8538
  clear: dontMutateMethodOverride,
8520
8539
  delete: dontMutateMethodOverride
8521
8540
  });
8522
8541
  }
8523
- Object.freeze(obj);
8542
+ O.freeze(obj);
8524
8543
  if (deep)
8525
- Object.values(obj).forEach((value) => freeze(value, true));
8544
+ each(
8545
+ obj,
8546
+ (_key, value) => {
8547
+ freeze(value, true);
8548
+ },
8549
+ false
8550
+ );
8526
8551
  return obj;
8527
8552
  }
8528
8553
  function dontMutateFrozenCollections() {
8529
8554
  die(2);
8530
8555
  }
8531
8556
  var dontMutateMethodOverride = {
8532
- value: dontMutateFrozenCollections
8557
+ [VALUE]: dontMutateFrozenCollections
8533
8558
  };
8534
8559
  function isFrozen(obj) {
8535
- if (obj === null || typeof obj !== "object")
8560
+ if (obj === null || !isObjectish(obj))
8536
8561
  return true;
8537
- return Object.isFrozen(obj);
8562
+ return O.isFrozen(obj);
8538
8563
  }
8539
8564
 
8540
8565
  // src/utils/plugins.ts
8566
+ var PluginMapSet = "MapSet";
8567
+ var PluginPatches = "Patches";
8541
8568
  var plugins = {};
8542
8569
  function getPlugin(pluginKey) {
8543
8570
  const plugin = plugins[pluginKey];
@@ -8546,6 +8573,7 @@ function getPlugin(pluginKey) {
8546
8573
  }
8547
8574
  return plugin;
8548
8575
  }
8576
+ var isPluginLoaded = (pluginKey) => !!plugins[pluginKey];
8549
8577
  function loadPlugin(pluginKey, implementation) {
8550
8578
  if (!plugins[pluginKey])
8551
8579
  plugins[pluginKey] = implementation;
@@ -8553,23 +8581,22 @@ function loadPlugin(pluginKey, implementation) {
8553
8581
 
8554
8582
  // src/core/scope.ts
8555
8583
  var currentScope;
8556
- function getCurrentScope() {
8557
- return currentScope;
8558
- }
8559
- function createScope(parent_, immer_) {
8560
- return {
8561
- drafts_: [],
8562
- parent_,
8563
- immer_,
8564
- // Whenever the modified draft contains a draft from another scope, we
8565
- // need to prevent auto-freezing so the unowned draft can be finalized.
8566
- canAutoFreeze_: true,
8567
- unfinalizedDrafts_: 0
8568
- };
8569
- }
8584
+ var getCurrentScope = () => currentScope;
8585
+ var createScope = (parent_, immer_) => ({
8586
+ drafts_: [],
8587
+ parent_,
8588
+ immer_,
8589
+ // Whenever the modified draft contains a draft from another scope, we
8590
+ // need to prevent auto-freezing so the unowned draft can be finalized.
8591
+ canAutoFreeze_: true,
8592
+ unfinalizedDrafts_: 0,
8593
+ handledSet_: /* @__PURE__ */ new Set(),
8594
+ processedForPatches_: /* @__PURE__ */ new Set(),
8595
+ mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0
8596
+ });
8570
8597
  function usePatchesInScope(scope, patchListener) {
8571
8598
  if (patchListener) {
8572
- getPlugin("Patches");
8599
+ scope.patchPlugin_ = getPlugin(PluginPatches);
8573
8600
  scope.patches_ = [];
8574
8601
  scope.inversePatches_ = [];
8575
8602
  scope.patchListener_ = patchListener;
@@ -8585,9 +8612,7 @@ function leaveScope(scope) {
8585
8612
  currentScope = scope.parent_;
8586
8613
  }
8587
8614
  }
8588
- function enterScope(immer2) {
8589
- return currentScope = createScope(currentScope, immer2);
8590
- }
8615
+ var enterScope = (immer2) => currentScope = createScope(currentScope, immer2);
8591
8616
  function revokeDraft(draft) {
8592
8617
  const state = draft[DRAFT_STATE];
8593
8618
  if (state.type_ === 0 /* Object */ || state.type_ === 1 /* Array */)
@@ -8608,129 +8633,166 @@ function processResult(result, scope) {
8608
8633
  }
8609
8634
  if (isDraftable(result)) {
8610
8635
  result = finalize(scope, result);
8611
- if (!scope.parent_)
8612
- maybeFreeze(scope, result);
8613
8636
  }
8614
- if (scope.patches_) {
8615
- getPlugin("Patches").generateReplacementPatches_(
8637
+ const { patchPlugin_ } = scope;
8638
+ if (patchPlugin_) {
8639
+ patchPlugin_.generateReplacementPatches_(
8616
8640
  baseDraft[DRAFT_STATE].base_,
8617
8641
  result,
8618
- scope.patches_,
8619
- scope.inversePatches_
8642
+ scope
8620
8643
  );
8621
8644
  }
8622
8645
  } else {
8623
- result = finalize(scope, baseDraft, []);
8646
+ result = finalize(scope, baseDraft);
8624
8647
  }
8648
+ maybeFreeze(scope, result, true);
8625
8649
  revokeScope(scope);
8626
8650
  if (scope.patches_) {
8627
8651
  scope.patchListener_(scope.patches_, scope.inversePatches_);
8628
8652
  }
8629
8653
  return result !== NOTHING ? result : void 0;
8630
8654
  }
8631
- function finalize(rootScope, value, path) {
8655
+ function finalize(rootScope, value) {
8632
8656
  if (isFrozen(value))
8633
8657
  return value;
8634
- const useStrictIteration = rootScope.immer_.shouldUseStrictIteration();
8635
8658
  const state = value[DRAFT_STATE];
8636
8659
  if (!state) {
8637
- each(
8638
- value,
8639
- (key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path),
8640
- useStrictIteration
8641
- );
8642
- return value;
8660
+ const finalValue = handleValue(value, rootScope.handledSet_, rootScope);
8661
+ return finalValue;
8643
8662
  }
8644
- if (state.scope_ !== rootScope)
8663
+ if (!isSameScope(state, rootScope)) {
8645
8664
  return value;
8665
+ }
8646
8666
  if (!state.modified_) {
8647
- maybeFreeze(rootScope, state.base_, true);
8648
8667
  return state.base_;
8649
8668
  }
8650
8669
  if (!state.finalized_) {
8651
- state.finalized_ = true;
8652
- state.scope_.unfinalizedDrafts_--;
8653
- const result = state.copy_;
8654
- let resultEach = result;
8655
- let isSet2 = false;
8656
- if (state.type_ === 3 /* Set */) {
8657
- resultEach = new Set(result);
8658
- result.clear();
8659
- isSet2 = true;
8660
- }
8661
- each(
8662
- resultEach,
8663
- (key, childValue) => finalizeProperty(
8664
- rootScope,
8665
- state,
8666
- result,
8667
- key,
8668
- childValue,
8669
- path,
8670
- isSet2
8671
- ),
8672
- useStrictIteration
8673
- );
8674
- maybeFreeze(rootScope, result, false);
8675
- if (path && rootScope.patches_) {
8676
- getPlugin("Patches").generatePatches_(
8677
- state,
8678
- path,
8679
- rootScope.patches_,
8680
- rootScope.inversePatches_
8681
- );
8670
+ const { callbacks_ } = state;
8671
+ if (callbacks_) {
8672
+ while (callbacks_.length > 0) {
8673
+ const callback = callbacks_.pop();
8674
+ callback(rootScope);
8675
+ }
8682
8676
  }
8677
+ generatePatchesAndFinalize(state, rootScope);
8683
8678
  }
8684
8679
  return state.copy_;
8685
8680
  }
8686
- function finalizeProperty(rootScope, parentState, targetObject, prop, childValue, rootPath, targetIsSet) {
8687
- if (childValue == null) {
8688
- return;
8681
+ function maybeFreeze(scope, value, deep = false) {
8682
+ if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
8683
+ freeze(value, deep);
8689
8684
  }
8690
- if (typeof childValue !== "object" && !targetIsSet) {
8691
- return;
8685
+ }
8686
+ function markStateFinalized(state) {
8687
+ state.finalized_ = true;
8688
+ state.scope_.unfinalizedDrafts_--;
8689
+ }
8690
+ var isSameScope = (state, rootScope) => state.scope_ === rootScope;
8691
+ var EMPTY_LOCATIONS_RESULT = [];
8692
+ function updateDraftInParent(parent, draftValue, finalizedValue, originalKey) {
8693
+ const parentCopy = latest(parent);
8694
+ const parentType = parent.type_;
8695
+ if (originalKey !== void 0) {
8696
+ const currentValue = get(parentCopy, originalKey, parentType);
8697
+ if (currentValue === draftValue) {
8698
+ set(parentCopy, originalKey, finalizedValue, parentType);
8699
+ return;
8700
+ }
8692
8701
  }
8693
- const childIsFrozen = isFrozen(childValue);
8694
- if (childIsFrozen && !targetIsSet) {
8695
- return;
8702
+ if (!parent.draftLocations_) {
8703
+ const draftLocations = parent.draftLocations_ = /* @__PURE__ */ new Map();
8704
+ each(parentCopy, (key, value) => {
8705
+ if (isDraft(value)) {
8706
+ const keys = draftLocations.get(value) || [];
8707
+ keys.push(key);
8708
+ draftLocations.set(value, keys);
8709
+ }
8710
+ });
8696
8711
  }
8697
- if ( true && childValue === targetObject)
8698
- die(5);
8699
- if (isDraft(childValue)) {
8700
- const path = rootPath && parentState && parentState.type_ !== 3 /* Set */ && // Set objects are atomic since they have no keys.
8701
- !has(parentState.assigned_, prop) ? rootPath.concat(prop) : void 0;
8702
- const res = finalize(rootScope, childValue, path);
8703
- set(targetObject, prop, res);
8704
- if (isDraft(res)) {
8705
- rootScope.canAutoFreeze_ = false;
8706
- } else
8707
- return;
8708
- } else if (targetIsSet) {
8709
- targetObject.add(childValue);
8712
+ const locations = parent.draftLocations_.get(draftValue) ?? EMPTY_LOCATIONS_RESULT;
8713
+ for (const location of locations) {
8714
+ set(parentCopy, location, finalizedValue, parentType);
8710
8715
  }
8711
- if (isDraftable(childValue) && !childIsFrozen) {
8712
- if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
8716
+ }
8717
+ function registerChildFinalizationCallback(parent, child, key) {
8718
+ parent.callbacks_.push(function childCleanup(rootScope) {
8719
+ const state = child;
8720
+ if (!state || !isSameScope(state, rootScope)) {
8713
8721
  return;
8714
8722
  }
8715
- if (parentState && parentState.base_ && parentState.base_[prop] === childValue && childIsFrozen) {
8716
- return;
8723
+ rootScope.mapSetPlugin_?.fixSetContents(state);
8724
+ const finalizedValue = getFinalValue(state);
8725
+ updateDraftInParent(parent, state.draft_ ?? state, finalizedValue, key);
8726
+ generatePatchesAndFinalize(state, rootScope);
8727
+ });
8728
+ }
8729
+ function generatePatchesAndFinalize(state, rootScope) {
8730
+ const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 /* Set */ || (state.assigned_?.size ?? 0) > 0);
8731
+ if (shouldFinalize) {
8732
+ const { patchPlugin_ } = rootScope;
8733
+ if (patchPlugin_) {
8734
+ const basePath = patchPlugin_.getPath(state);
8735
+ if (basePath) {
8736
+ patchPlugin_.generatePatches_(state, basePath, rootScope);
8737
+ }
8717
8738
  }
8718
- finalize(rootScope, childValue);
8719
- if ((!parentState || !parentState.scope_.parent_) && typeof prop !== "symbol" && (isMap(targetObject) ? targetObject.has(prop) : Object.prototype.propertyIsEnumerable.call(targetObject, prop)))
8720
- maybeFreeze(rootScope, childValue);
8739
+ markStateFinalized(state);
8721
8740
  }
8722
8741
  }
8723
- function maybeFreeze(scope, value, deep = false) {
8724
- if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
8725
- freeze(value, deep);
8742
+ function handleCrossReference(target, key, value) {
8743
+ const { scope_ } = target;
8744
+ if (isDraft(value)) {
8745
+ const state = value[DRAFT_STATE];
8746
+ if (isSameScope(state, scope_)) {
8747
+ state.callbacks_.push(function crossReferenceCleanup() {
8748
+ prepareCopy(target);
8749
+ const finalizedValue = getFinalValue(state);
8750
+ updateDraftInParent(target, value, finalizedValue, key);
8751
+ });
8752
+ }
8753
+ } else if (isDraftable(value)) {
8754
+ target.callbacks_.push(function nestedDraftCleanup() {
8755
+ const targetCopy = latest(target);
8756
+ if (get(targetCopy, key, target.type_) === value) {
8757
+ if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
8758
+ handleValue(
8759
+ get(target.copy_, key, target.type_),
8760
+ scope_.handledSet_,
8761
+ scope_
8762
+ );
8763
+ }
8764
+ }
8765
+ });
8766
+ }
8767
+ }
8768
+ function handleValue(target, handledSet, rootScope) {
8769
+ if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
8770
+ return target;
8771
+ }
8772
+ if (isDraft(target) || handledSet.has(target) || !isDraftable(target) || isFrozen(target)) {
8773
+ return target;
8726
8774
  }
8775
+ handledSet.add(target);
8776
+ each(target, (key, value) => {
8777
+ if (isDraft(value)) {
8778
+ const state = value[DRAFT_STATE];
8779
+ if (isSameScope(state, rootScope)) {
8780
+ const updatedValue = getFinalValue(state);
8781
+ set(target, key, updatedValue, target.type_);
8782
+ markStateFinalized(state);
8783
+ }
8784
+ } else if (isDraftable(value)) {
8785
+ handleValue(value, handledSet, rootScope);
8786
+ }
8787
+ });
8788
+ return target;
8727
8789
  }
8728
8790
 
8729
8791
  // src/core/proxy.ts
8730
8792
  function createProxyProxy(base, parent) {
8731
- const isArray = Array.isArray(base);
8793
+ const baseIsArray = isArray(base);
8732
8794
  const state = {
8733
- type_: isArray ? 1 /* Array */ : 0 /* Object */,
8795
+ type_: baseIsArray ? 1 /* Array */ : 0 /* Object */,
8734
8796
  // Track which produce call this is associated with.
8735
8797
  scope_: parent ? parent.scope_ : getCurrentScope(),
8736
8798
  // True for both shallow and deep changes.
@@ -8738,7 +8800,8 @@ function createProxyProxy(base, parent) {
8738
8800
  // Used during finalization.
8739
8801
  finalized_: false,
8740
8802
  // Track which properties have been assigned (true) or deleted (false).
8741
- assigned_: {},
8803
+ // actually instantiated in `prepareCopy()`
8804
+ assigned_: void 0,
8742
8805
  // The parent draft state.
8743
8806
  parent_: parent,
8744
8807
  // The base state.
@@ -8750,25 +8813,27 @@ function createProxyProxy(base, parent) {
8750
8813
  copy_: null,
8751
8814
  // Called by the `produce` function.
8752
8815
  revoke_: null,
8753
- isManual_: false
8816
+ isManual_: false,
8817
+ // `callbacks` actually gets assigned in `createProxy`
8818
+ callbacks_: void 0
8754
8819
  };
8755
8820
  let target = state;
8756
8821
  let traps = objectTraps;
8757
- if (isArray) {
8822
+ if (baseIsArray) {
8758
8823
  target = [state];
8759
8824
  traps = arrayTraps;
8760
8825
  }
8761
8826
  const { revoke, proxy } = Proxy.revocable(target, traps);
8762
8827
  state.draft_ = proxy;
8763
8828
  state.revoke_ = revoke;
8764
- return proxy;
8829
+ return [proxy, state];
8765
8830
  }
8766
8831
  var objectTraps = {
8767
8832
  get(state, prop) {
8768
8833
  if (prop === DRAFT_STATE)
8769
8834
  return state;
8770
8835
  const source = latest(state);
8771
- if (!has(source, prop)) {
8836
+ if (!has(source, prop, state.type_)) {
8772
8837
  return readPropFromProto(state, source, prop);
8773
8838
  }
8774
8839
  const value = source[prop];
@@ -8777,7 +8842,9 @@ var objectTraps = {
8777
8842
  }
8778
8843
  if (value === peek(state.base_, prop)) {
8779
8844
  prepareCopy(state);
8780
- return state.copy_[prop] = createProxy(value, state);
8845
+ const childKey = state.type_ === 1 /* Array */ ? +prop : prop;
8846
+ const childDraft = createProxy(state.scope_, value, state, childKey);
8847
+ return state.copy_[childKey] = childDraft;
8781
8848
  }
8782
8849
  return value;
8783
8850
  },
@@ -8798,10 +8865,10 @@ var objectTraps = {
8798
8865
  const currentState = current2?.[DRAFT_STATE];
8799
8866
  if (currentState && currentState.base_ === value) {
8800
8867
  state.copy_[prop] = value;
8801
- state.assigned_[prop] = false;
8868
+ state.assigned_.set(prop, false);
8802
8869
  return true;
8803
8870
  }
8804
- if (is(value, current2) && (value !== void 0 || has(state.base_, prop)))
8871
+ if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
8805
8872
  return true;
8806
8873
  prepareCopy(state);
8807
8874
  markChanged(state);
@@ -8811,16 +8878,17 @@ var objectTraps = {
8811
8878
  Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
8812
8879
  return true;
8813
8880
  state.copy_[prop] = value;
8814
- state.assigned_[prop] = true;
8881
+ state.assigned_.set(prop, true);
8882
+ handleCrossReference(state, prop, value);
8815
8883
  return true;
8816
8884
  },
8817
8885
  deleteProperty(state, prop) {
8886
+ prepareCopy(state);
8818
8887
  if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
8819
- state.assigned_[prop] = false;
8820
- prepareCopy(state);
8888
+ state.assigned_.set(prop, false);
8821
8889
  markChanged(state);
8822
8890
  } else {
8823
- delete state.assigned_[prop];
8891
+ state.assigned_.delete(prop);
8824
8892
  }
8825
8893
  if (state.copy_) {
8826
8894
  delete state.copy_[prop];
@@ -8835,10 +8903,10 @@ var objectTraps = {
8835
8903
  if (!desc)
8836
8904
  return desc;
8837
8905
  return {
8838
- writable: true,
8839
- configurable: state.type_ !== 1 /* Array */ || prop !== "length",
8840
- enumerable: desc.enumerable,
8841
- value: owner[prop]
8906
+ [WRITABLE]: true,
8907
+ [CONFIGURABLE]: state.type_ !== 1 /* Array */ || prop !== "length",
8908
+ [ENUMERABLE]: desc[ENUMERABLE],
8909
+ [VALUE]: owner[prop]
8842
8910
  };
8843
8911
  },
8844
8912
  defineProperty() {
@@ -8854,8 +8922,9 @@ var objectTraps = {
8854
8922
  var arrayTraps = {};
8855
8923
  each(objectTraps, (key, fn) => {
8856
8924
  arrayTraps[key] = function() {
8857
- arguments[0] = arguments[0][0];
8858
- return fn.apply(this, arguments);
8925
+ const args = arguments;
8926
+ args[0] = args[0][0];
8927
+ return fn.apply(this, args);
8859
8928
  };
8860
8929
  });
8861
8930
  arrayTraps.deleteProperty = function(state, prop) {
@@ -8875,7 +8944,7 @@ function peek(draft, prop) {
8875
8944
  }
8876
8945
  function readPropFromProto(state, source, prop) {
8877
8946
  const desc = getDescriptorFromProto(source, prop);
8878
- return desc ? `value` in desc ? desc.value : (
8947
+ return desc ? VALUE in desc ? desc[VALUE] : (
8879
8948
  // This is a very special case, if the prop is a getter defined by the
8880
8949
  // prototype, we should invoke it with the draft as context!
8881
8950
  desc.get?.call(state.draft_)
@@ -8903,6 +8972,7 @@ function markChanged(state) {
8903
8972
  }
8904
8973
  function prepareCopy(state) {
8905
8974
  if (!state.copy_) {
8975
+ state.assigned_ = /* @__PURE__ */ new Map();
8906
8976
  state.copy_ = shallowCopy(
8907
8977
  state.base_,
8908
8978
  state.scope_.immer_.useStrictShallowCopy_
@@ -8915,7 +8985,7 @@ var Immer2 = class {
8915
8985
  constructor(config) {
8916
8986
  this.autoFreeze_ = true;
8917
8987
  this.useStrictShallowCopy_ = false;
8918
- this.useStrictIteration_ = true;
8988
+ this.useStrictIteration_ = false;
8919
8989
  /**
8920
8990
  * The `produce` function takes a value and a "recipe function" (whose
8921
8991
  * return value often depends on the base state). The recipe function is
@@ -8936,7 +9006,7 @@ var Immer2 = class {
8936
9006
  * @returns {any} a new state, or the initial state if nothing was modified
8937
9007
  */
8938
9008
  this.produce = (base, recipe, patchListener) => {
8939
- if (typeof base === "function" && typeof recipe !== "function") {
9009
+ if (isFunction(base) && !isFunction(recipe)) {
8940
9010
  const defaultBase = recipe;
8941
9011
  recipe = base;
8942
9012
  const self = this;
@@ -8944,14 +9014,14 @@ var Immer2 = class {
8944
9014
  return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
8945
9015
  };
8946
9016
  }
8947
- if (typeof recipe !== "function")
9017
+ if (!isFunction(recipe))
8948
9018
  die(6);
8949
- if (patchListener !== void 0 && typeof patchListener !== "function")
9019
+ if (patchListener !== void 0 && !isFunction(patchListener))
8950
9020
  die(7);
8951
9021
  let result;
8952
9022
  if (isDraftable(base)) {
8953
9023
  const scope = enterScope(this);
8954
- const proxy = createProxy(base, void 0);
9024
+ const proxy = createProxy(scope, base, void 0);
8955
9025
  let hasError = true;
8956
9026
  try {
8957
9027
  result = recipe(proxy);
@@ -8964,7 +9034,7 @@ var Immer2 = class {
8964
9034
  }
8965
9035
  usePatchesInScope(scope, patchListener);
8966
9036
  return processResult(result, scope);
8967
- } else if (!base || typeof base !== "object") {
9037
+ } else if (!base || !isObjectish(base)) {
8968
9038
  result = recipe(base);
8969
9039
  if (result === void 0)
8970
9040
  result = base;
@@ -8975,7 +9045,10 @@ var Immer2 = class {
8975
9045
  if (patchListener) {
8976
9046
  const p = [];
8977
9047
  const ip = [];
8978
- getPlugin("Patches").generateReplacementPatches_(base, result, p, ip);
9048
+ getPlugin(PluginPatches).generateReplacementPatches_(base, result, {
9049
+ patches_: p,
9050
+ inversePatches_: ip
9051
+ });
8979
9052
  patchListener(p, ip);
8980
9053
  }
8981
9054
  return result;
@@ -8983,7 +9056,7 @@ var Immer2 = class {
8983
9056
  die(1, base);
8984
9057
  };
8985
9058
  this.produceWithPatches = (base, recipe) => {
8986
- if (typeof base === "function") {
9059
+ if (isFunction(base)) {
8987
9060
  return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
8988
9061
  }
8989
9062
  let patches, inversePatches;
@@ -8993,11 +9066,11 @@ var Immer2 = class {
8993
9066
  });
8994
9067
  return [result, patches, inversePatches];
8995
9068
  };
8996
- if (typeof config?.autoFreeze === "boolean")
9069
+ if (isBoolean(config?.autoFreeze))
8997
9070
  this.setAutoFreeze(config.autoFreeze);
8998
- if (typeof config?.useStrictShallowCopy === "boolean")
9071
+ if (isBoolean(config?.useStrictShallowCopy))
8999
9072
  this.setUseStrictShallowCopy(config.useStrictShallowCopy);
9000
- if (typeof config?.useStrictIteration === "boolean")
9073
+ if (isBoolean(config?.useStrictIteration))
9001
9074
  this.setUseStrictIteration(config.useStrictIteration);
9002
9075
  }
9003
9076
  createDraft(base) {
@@ -9006,7 +9079,7 @@ var Immer2 = class {
9006
9079
  if (isDraft(base))
9007
9080
  base = current(base);
9008
9081
  const scope = enterScope(this);
9009
- const proxy = createProxy(base, void 0);
9082
+ const proxy = createProxy(scope, base, void 0);
9010
9083
  proxy[DRAFT_STATE].isManual_ = true;
9011
9084
  leaveScope(scope);
9012
9085
  return proxy;
@@ -9059,7 +9132,7 @@ var Immer2 = class {
9059
9132
  if (i > -1) {
9060
9133
  patches = patches.slice(i + 1);
9061
9134
  }
9062
- const applyPatchesImpl = getPlugin("Patches").applyPatches_;
9135
+ const applyPatchesImpl = getPlugin(PluginPatches).applyPatches_;
9063
9136
  if (isDraft(base)) {
9064
9137
  return applyPatchesImpl(base, patches);
9065
9138
  }
@@ -9069,10 +9142,23 @@ var Immer2 = class {
9069
9142
  );
9070
9143
  }
9071
9144
  };
9072
- function createProxy(value, parent) {
9073
- const draft = isMap(value) ? getPlugin("MapSet").proxyMap_(value, parent) : isSet(value) ? getPlugin("MapSet").proxySet_(value, parent) : createProxyProxy(value, parent);
9074
- const scope = parent ? parent.scope_ : getCurrentScope();
9145
+ function createProxy(rootScope, value, parent, key) {
9146
+ const [draft, state] = isMap(value) ? getPlugin(PluginMapSet).proxyMap_(value, parent) : isSet(value) ? getPlugin(PluginMapSet).proxySet_(value, parent) : createProxyProxy(value, parent);
9147
+ const scope = parent?.scope_ ?? getCurrentScope();
9075
9148
  scope.drafts_.push(draft);
9149
+ state.callbacks_ = parent?.callbacks_ ?? [];
9150
+ state.key_ = key;
9151
+ if (parent && key !== void 0) {
9152
+ registerChildFinalizationCallback(parent, state, key);
9153
+ } else {
9154
+ state.callbacks_.push(function rootDraftCleanup(rootScope2) {
9155
+ rootScope2.mapSetPlugin_?.fixSetContents(state);
9156
+ const { patchPlugin_ } = rootScope2;
9157
+ if (state.modified_ && patchPlugin_) {
9158
+ patchPlugin_.generatePatches_(state, [], rootScope2);
9159
+ }
9160
+ });
9161
+ }
9076
9162
  return draft;
9077
9163
  }
9078
9164
 
@@ -9125,27 +9211,86 @@ function enablePatches() {
9125
9211
  "Patching reserved attributes like __proto__, prototype and constructor is not allowed"
9126
9212
  );
9127
9213
  }
9214
+ function getPath(state, path = []) {
9215
+ if ("key_" in state && state.key_ !== void 0) {
9216
+ const parentCopy = state.parent_.copy_ ?? state.parent_.base_;
9217
+ const proxyDraft = getProxyDraft(get(parentCopy, state.key_));
9218
+ const valueAtKey = get(parentCopy, state.key_);
9219
+ if (valueAtKey === void 0) {
9220
+ return null;
9221
+ }
9222
+ if (valueAtKey !== state.draft_ && valueAtKey !== state.base_ && valueAtKey !== state.copy_) {
9223
+ return null;
9224
+ }
9225
+ if (proxyDraft != null && proxyDraft.base_ !== state.base_) {
9226
+ return null;
9227
+ }
9228
+ const isSet2 = state.parent_.type_ === 3 /* Set */;
9229
+ let key;
9230
+ if (isSet2) {
9231
+ const setParent = state.parent_;
9232
+ key = Array.from(setParent.drafts_.keys()).indexOf(state.key_);
9233
+ } else {
9234
+ key = state.key_;
9235
+ }
9236
+ if (!(isSet2 && parentCopy.size > key || has(parentCopy, key))) {
9237
+ return null;
9238
+ }
9239
+ path.push(key);
9240
+ }
9241
+ if (state.parent_) {
9242
+ return getPath(state.parent_, path);
9243
+ }
9244
+ path.reverse();
9245
+ try {
9246
+ resolvePath(state.copy_, path);
9247
+ } catch (e) {
9248
+ return null;
9249
+ }
9250
+ return path;
9251
+ }
9252
+ function resolvePath(base, path) {
9253
+ let current2 = base;
9254
+ for (let i = 0; i < path.length - 1; i++) {
9255
+ const key = path[i];
9256
+ current2 = get(current2, key);
9257
+ if (!isObjectish(current2) || current2 === null) {
9258
+ throw new Error(`Cannot resolve path at '${path.join("/")}'`);
9259
+ }
9260
+ }
9261
+ return current2;
9262
+ }
9128
9263
  const REPLACE = "replace";
9129
9264
  const ADD = "add";
9130
9265
  const REMOVE = "remove";
9131
- function generatePatches_(state, basePath, patches, inversePatches) {
9266
+ function generatePatches_(state, basePath, scope) {
9267
+ if (state.scope_.processedForPatches_.has(state)) {
9268
+ return;
9269
+ }
9270
+ state.scope_.processedForPatches_.add(state);
9271
+ const { patches_, inversePatches_ } = scope;
9132
9272
  switch (state.type_) {
9133
9273
  case 0 /* Object */:
9134
9274
  case 2 /* Map */:
9135
9275
  return generatePatchesFromAssigned(
9136
9276
  state,
9137
9277
  basePath,
9138
- patches,
9139
- inversePatches
9278
+ patches_,
9279
+ inversePatches_
9140
9280
  );
9141
9281
  case 1 /* Array */:
9142
- return generateArrayPatches(state, basePath, patches, inversePatches);
9282
+ return generateArrayPatches(
9283
+ state,
9284
+ basePath,
9285
+ patches_,
9286
+ inversePatches_
9287
+ );
9143
9288
  case 3 /* Set */:
9144
9289
  return generateSetPatches(
9145
9290
  state,
9146
9291
  basePath,
9147
- patches,
9148
- inversePatches
9292
+ patches_,
9293
+ inversePatches_
9149
9294
  );
9150
9295
  }
9151
9296
  }
@@ -9158,19 +9303,25 @@ function enablePatches() {
9158
9303
  [patches, inversePatches] = [inversePatches, patches];
9159
9304
  }
9160
9305
  for (let i = 0; i < base_.length; i++) {
9161
- if (assigned_[i] && copy_[i] !== base_[i]) {
9306
+ const copiedItem = copy_[i];
9307
+ const baseItem = base_[i];
9308
+ if (assigned_?.get(i.toString()) && copiedItem !== baseItem) {
9309
+ const childState = copiedItem?.[DRAFT_STATE];
9310
+ if (childState && childState.modified_) {
9311
+ continue;
9312
+ }
9162
9313
  const path = basePath.concat([i]);
9163
9314
  patches.push({
9164
9315
  op: REPLACE,
9165
9316
  path,
9166
9317
  // Need to maybe clone it, as it can in fact be the original value
9167
9318
  // due to the base/copy inversion at the start of this function
9168
- value: clonePatchValueIfNeeded(copy_[i])
9319
+ value: clonePatchValueIfNeeded(copiedItem)
9169
9320
  });
9170
9321
  inversePatches.push({
9171
9322
  op: REPLACE,
9172
9323
  path,
9173
- value: clonePatchValueIfNeeded(base_[i])
9324
+ value: clonePatchValueIfNeeded(baseItem)
9174
9325
  });
9175
9326
  }
9176
9327
  }
@@ -9193,15 +9344,17 @@ function enablePatches() {
9193
9344
  }
9194
9345
  }
9195
9346
  function generatePatchesFromAssigned(state, basePath, patches, inversePatches) {
9196
- const { base_, copy_ } = state;
9347
+ const { base_, copy_, type_ } = state;
9197
9348
  each(state.assigned_, (key, assignedValue) => {
9198
- const origValue = get(base_, key);
9199
- const value = get(copy_, key);
9349
+ const origValue = get(base_, key, type_);
9350
+ const value = get(copy_, key, type_);
9200
9351
  const op = !assignedValue ? REMOVE : has(base_, key) ? REPLACE : ADD;
9201
9352
  if (origValue === value && op === REPLACE)
9202
9353
  return;
9203
9354
  const path = basePath.concat(key);
9204
- patches.push(op === REMOVE ? { op, path } : { op, path, value });
9355
+ patches.push(
9356
+ op === REMOVE ? { op, path } : { op, path, value: clonePatchValueIfNeeded(value) }
9357
+ );
9205
9358
  inversePatches.push(
9206
9359
  op === ADD ? { op: REMOVE, path } : op === REMOVE ? { op: ADD, path, value: clonePatchValueIfNeeded(origValue) } : { op: REPLACE, path, value: clonePatchValueIfNeeded(origValue) }
9207
9360
  );
@@ -9244,13 +9397,14 @@ function enablePatches() {
9244
9397
  i++;
9245
9398
  });
9246
9399
  }
9247
- function generateReplacementPatches_(baseValue, replacement, patches, inversePatches) {
9248
- patches.push({
9400
+ function generateReplacementPatches_(baseValue, replacement, scope) {
9401
+ const { patches_, inversePatches_ } = scope;
9402
+ patches_.push({
9249
9403
  op: REPLACE,
9250
9404
  path: [],
9251
9405
  value: replacement === NOTHING ? void 0 : replacement
9252
9406
  });
9253
- inversePatches.push({
9407
+ inversePatches_.push({
9254
9408
  op: REPLACE,
9255
9409
  path: [],
9256
9410
  value: baseValue
@@ -9266,12 +9420,12 @@ function enablePatches() {
9266
9420
  if (typeof p !== "string" && typeof p !== "number") {
9267
9421
  p = "" + p;
9268
9422
  }
9269
- if ((parentType === 0 /* Object */ || parentType === 1 /* Array */) && (p === "__proto__" || p === "constructor"))
9423
+ if ((parentType === 0 /* Object */ || parentType === 1 /* Array */) && (p === "__proto__" || p === CONSTRUCTOR))
9270
9424
  die(errorOffset + 3);
9271
- if (typeof base === "function" && p === "prototype")
9425
+ if (isFunction(base) && p === PROTOTYPE)
9272
9426
  die(errorOffset + 3);
9273
9427
  base = get(base, p);
9274
- if (typeof base !== "object")
9428
+ if (!isObjectish(base))
9275
9429
  die(errorOffset + 2, path.join("/"));
9276
9430
  }
9277
9431
  const type = getArchtype(base);
@@ -9318,7 +9472,7 @@ function enablePatches() {
9318
9472
  function deepClonePatchValue(obj) {
9319
9473
  if (!isDraftable(obj))
9320
9474
  return obj;
9321
- if (Array.isArray(obj))
9475
+ if (isArray(obj))
9322
9476
  return obj.map(deepClonePatchValue);
9323
9477
  if (isMap(obj))
9324
9478
  return new Map(
@@ -9339,10 +9493,11 @@ function enablePatches() {
9339
9493
  } else
9340
9494
  return obj;
9341
9495
  }
9342
- loadPlugin("Patches", {
9496
+ loadPlugin(PluginPatches, {
9343
9497
  applyPatches_,
9344
9498
  generatePatches_,
9345
- generateReplacementPatches_
9499
+ generateReplacementPatches_,
9500
+ getPath
9346
9501
  });
9347
9502
  }
9348
9503
 
@@ -9362,7 +9517,8 @@ function enableMapSet() {
9362
9517
  base_: target,
9363
9518
  draft_: this,
9364
9519
  isManual_: false,
9365
- revoked_: false
9520
+ revoked_: false,
9521
+ callbacks_: []
9366
9522
  };
9367
9523
  }
9368
9524
  get size() {
@@ -9428,7 +9584,7 @@ function enableMapSet() {
9428
9584
  if (value !== state.base_.get(key)) {
9429
9585
  return value;
9430
9586
  }
9431
- const draft = createProxy(value, state);
9587
+ const draft = createProxy(state.scope_, value, state, key);
9432
9588
  prepareMapCopy(state);
9433
9589
  state.copy_.set(key, draft);
9434
9590
  return draft;
@@ -9473,7 +9629,8 @@ function enableMapSet() {
9473
9629
  }
9474
9630
  }
9475
9631
  function proxyMap_(target, parent) {
9476
- return new DraftMap(target, parent);
9632
+ const map = new DraftMap(target, parent);
9633
+ return [map, map[DRAFT_STATE]];
9477
9634
  }
9478
9635
  function prepareMapCopy(state) {
9479
9636
  if (!state.copy_) {
@@ -9495,7 +9652,9 @@ function enableMapSet() {
9495
9652
  draft_: this,
9496
9653
  drafts_: /* @__PURE__ */ new Map(),
9497
9654
  revoked_: false,
9498
- isManual_: false
9655
+ isManual_: false,
9656
+ assigned_: void 0,
9657
+ callbacks_: []
9499
9658
  };
9500
9659
  }
9501
9660
  get size() {
@@ -9573,14 +9732,15 @@ function enableMapSet() {
9573
9732
  }
9574
9733
  }
9575
9734
  function proxySet_(target, parent) {
9576
- return new DraftSet(target, parent);
9735
+ const set2 = new DraftSet(target, parent);
9736
+ return [set2, set2[DRAFT_STATE]];
9577
9737
  }
9578
9738
  function prepareSetCopy(state) {
9579
9739
  if (!state.copy_) {
9580
9740
  state.copy_ = /* @__PURE__ */ new Set();
9581
9741
  state.base_.forEach((value) => {
9582
9742
  if (isDraftable(value)) {
9583
- const draft = createProxy(value, state);
9743
+ const draft = createProxy(state.scope_, value, state, value);
9584
9744
  state.drafts_.set(value, draft);
9585
9745
  state.copy_.add(draft);
9586
9746
  } else {
@@ -9593,7 +9753,16 @@ function enableMapSet() {
9593
9753
  if (state.revoked_)
9594
9754
  die(3, JSON.stringify(latest(state)));
9595
9755
  }
9596
- loadPlugin("MapSet", { proxyMap_, proxySet_ });
9756
+ function fixSetContents(target) {
9757
+ if (target.type_ === 3 /* Set */ && target.copy_) {
9758
+ const copy = new Set(target.copy_);
9759
+ target.copy_.clear();
9760
+ copy.forEach((value) => {
9761
+ target.copy_.add(getValue(value));
9762
+ });
9763
+ }
9764
+ }
9765
+ loadPlugin(PluginMapSet, { proxyMap_, proxySet_, fixSetContents });
9597
9766
  }
9598
9767
 
9599
9768
  // src/immer.ts
@@ -9612,12 +9781,8 @@ var setUseStrictIteration = /* @__PURE__ */ immer.setUseStrictIteration.bind(
9612
9781
  var applyPatches = /* @__PURE__ */ immer.applyPatches.bind(immer);
9613
9782
  var createDraft = /* @__PURE__ */ immer.createDraft.bind(immer);
9614
9783
  var finishDraft = /* @__PURE__ */ immer.finishDraft.bind(immer);
9615
- function castDraft(value) {
9616
- return value;
9617
- }
9618
- function castImmutable(value) {
9619
- return value;
9620
- }
9784
+ var castDraft = (value) => value;
9785
+ var castImmutable = (value) => value;
9621
9786
 
9622
9787
  //# sourceMappingURL=immer.mjs.map
9623
9788
 
@@ -9833,7 +9998,7 @@ __webpack_require__.r(__webpack_exports__);
9833
9998
  /* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
9834
9999
  /* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in preact_hooks__WEBPACK_IMPORTED_MODULE_1__) if(["default","Component","Fragment","createContext","createElement","createRef","Children","PureComponent","StrictMode","Suspense","SuspenseList","__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","cloneElement","createFactory","createPortal","findDOMNode","flushSync","forwardRef","hydrate","isElement","isFragment","isMemo","isValidElement","lazy","memo","render","startTransition","unmountComponentAtNode","unstable_batchedUpdates","useDeferredValue","useInsertionEffect","useSyncExternalStore","useTransition","version"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => preact_hooks__WEBPACK_IMPORTED_MODULE_1__[__WEBPACK_IMPORT_KEY__]
9835
10000
  /* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
9836
- function g(n,t){for(var e in t)n[e]=t[e];return n}function E(n,t){for(var e in n)if("__source"!==e&&!(e in t))return!0;for(var r in t)if("__source"!==r&&n[r]!==t[r])return!0;return!1}function C(n,t){var e=t(),r=(0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)({t:{__:e,u:t}}),u=r[0].t,o=r[1];return (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect)(function(){u.__=e,u.u=t,x(u)&&o({t:u})},[n,e,t]),(0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function(){return x(u)&&o({t:u}),n(function(){x(u)&&o({t:u})})},[n]),e}function x(n){var t,e,r=n.u,u=n.__;try{var o=r();return!((t=u)===(e=o)&&(0!==t||1/t==1/e)||t!=t&&e!=e)}catch(n){return!0}}function R(n){n()}function w(n){return n}function k(){return[!1,R]}var I=preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect;function N(n,t){this.props=n,this.context=t}function M(n,e){function r(n){var t=this.props.ref,r=t==n.ref;return!r&&t&&(t.call?t(null):t.current=null),e?!e(this.props,n)||!r:E(this.props,n)}function u(e){return this.shouldComponentUpdate=r,(0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(n,e)}return u.displayName="Memo("+(n.displayName||n.name)+")",u.prototype.isReactComponent=!0,u.__f=!0,u.type=n,u}(N.prototype=new preact__WEBPACK_IMPORTED_MODULE_0__.Component).isPureReactComponent=!0,N.prototype.shouldComponentUpdate=function(n,t){return E(this.props,n)||E(this.state,t)};var T=preact__WEBPACK_IMPORTED_MODULE_0__.options.__b;preact__WEBPACK_IMPORTED_MODULE_0__.options.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),T&&T(n)};var A="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function D(n){function t(t){var e=g({},t);return delete e.ref,n(e,t.ref||null)}return t.$$typeof=A,t.render=n,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(n.displayName||n.name)+")",t}var L=function(n,t){return null==n?null:(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)((0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(n).map(t))},O={map:L,forEach:L,count:function(n){return n?(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(n).length:0},only:function(n){var t=(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(n);if(1!==t.length)throw"Children.only";return t[0]},toArray:preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray},F=preact__WEBPACK_IMPORTED_MODULE_0__.options.__e;preact__WEBPACK_IMPORTED_MODULE_0__.options.__e=function(n,t,e,r){if(n.then)for(var u,o=t;o=o.__;)if((u=o.__c)&&u.__c)return null==t.__e&&(t.__e=e.__e,t.__k=e.__k),u.__c(n,t);F(n,t,e,r)};var U=preact__WEBPACK_IMPORTED_MODULE_0__.options.unmount;function V(n,t,e){return n&&(n.__c&&n.__c.__H&&(n.__c.__H.__.forEach(function(n){"function"==typeof n.__c&&n.__c()}),n.__c.__H=null),null!=(n=g({},n)).__c&&(n.__c.__P===e&&(n.__c.__P=t),n.__c.__e=!0,n.__c=null),n.__k=n.__k&&n.__k.map(function(n){return V(n,t,e)})),n}function W(n,t,e){return n&&e&&(n.__v=null,n.__k=n.__k&&n.__k.map(function(n){return W(n,t,e)}),n.__c&&n.__c.__P===t&&(n.__e&&e.appendChild(n.__e),n.__c.__e=!0,n.__c.__P=e)),n}function P(){this.__u=0,this.o=null,this.__b=null}function j(n){var t=n.__.__c;return t&&t.__a&&t.__a(n)}function z(n){var e,r,u;function o(o){if(e||(e=n()).then(function(n){r=n.default||n},function(n){u=n}),u)throw u;if(!r)throw e;return (0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(r,o)}return o.displayName="Lazy",o.__f=!0,o}function B(){this.i=null,this.l=null}preact__WEBPACK_IMPORTED_MODULE_0__.options.unmount=function(n){var t=n.__c;t&&t.__R&&t.__R(),t&&32&n.__u&&(n.type=null),U&&U(n)},(P.prototype=new preact__WEBPACK_IMPORTED_MODULE_0__.Component).__c=function(n,t){var e=t.__c,r=this;null==r.o&&(r.o=[]),r.o.push(e);var u=j(r.__v),o=!1,i=function(){o||(o=!0,e.__R=null,u?u(l):l())};e.__R=i;var l=function(){if(!--r.__u){if(r.state.__a){var n=r.state.__a;r.__v.__k[0]=W(n,n.__c.__P,n.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),n.then(i,i)},P.prototype.componentWillUnmount=function(){this.o=[]},P.prototype.render=function(n,e){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=V(this.__b,r,o.__O=o.__P)}this.__b=null}var i=e.__a&&(0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,null,n.fallback);return i&&(i.__u&=-33),[(0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,null,e.__a?null:n.children),i]};var H=function(n,t,e){if(++e[1]===e[0]&&n.l.delete(t),n.props.revealOrder&&("t"!==n.props.revealOrder[0]||!n.l.size))for(e=n.i;e;){for(;e.length>3;)e.pop()();if(e[1]<e[0])break;n.i=e=e[2]}};function Z(n){return this.getChildContext=function(){return n.context},n.children}function Y(n){var e=this,r=n.h;if(e.componentWillUnmount=function(){(0,preact__WEBPACK_IMPORTED_MODULE_0__.render)(null,e.v),e.v=null,e.h=null},e.h&&e.h!==r&&e.componentWillUnmount(),!e.v){for(var u=e.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;e.h=r,e.v={nodeType:1,parentNode:r,childNodes:[],__k:{__m:u.__m},contains:function(){return!0},insertBefore:function(n,t){this.childNodes.push(n),e.h.insertBefore(n,t)},removeChild:function(n){this.childNodes.splice(this.childNodes.indexOf(n)>>>1,1),e.h.removeChild(n)}}}(0,preact__WEBPACK_IMPORTED_MODULE_0__.render)((0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(Z,{context:e.context},n.__v),e.v)}function $(n,e){var r=(0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(Y,{__v:n,h:e});return r.containerInfo=e,r}(B.prototype=new preact__WEBPACK_IMPORTED_MODULE_0__.Component).__a=function(n){var t=this,e=j(t.__v),r=t.l.get(n);return r[0]++,function(u){var o=function(){t.props.revealOrder?(r.push(u),H(t,n,r)):u()};e?e(o):o()}},B.prototype.render=function(n){this.i=null,this.l=new Map;var t=(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(n.children);n.revealOrder&&"b"===n.revealOrder[0]&&t.reverse();for(var e=t.length;e--;)this.l.set(t[e],this.i=[1,0,this.i]);return n.children},B.prototype.componentDidUpdate=B.prototype.componentDidMount=function(){var n=this;this.l.forEach(function(t,e){H(n,e,t)})};var q="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,G=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,J=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,K=/[A-Z0-9]/g,Q="undefined"!=typeof document,X=function(n){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(n)};function nn(n,t,e){return null==t.__k&&(t.textContent=""),(0,preact__WEBPACK_IMPORTED_MODULE_0__.render)(n,t),"function"==typeof e&&e(),n?n.__c:null}function tn(n,t,e){return (0,preact__WEBPACK_IMPORTED_MODULE_0__.hydrate)(n,t),"function"==typeof e&&e(),n?n.__c:null}preact__WEBPACK_IMPORTED_MODULE_0__.Component.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(preact__WEBPACK_IMPORTED_MODULE_0__.Component.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})});var en=preact__WEBPACK_IMPORTED_MODULE_0__.options.event;function rn(){}function un(){return this.cancelBubble}function on(){return this.defaultPrevented}preact__WEBPACK_IMPORTED_MODULE_0__.options.event=function(n){return en&&(n=en(n)),n.persist=rn,n.isPropagationStopped=un,n.isDefaultPrevented=on,n.nativeEvent=n};var ln,cn={enumerable:!1,configurable:!0,get:function(){return this.class}},fn=preact__WEBPACK_IMPORTED_MODULE_0__.options.vnode;preact__WEBPACK_IMPORTED_MODULE_0__.options.vnode=function(n){"string"==typeof n.type&&function(n){var t=n.props,e=n.type,u={},o=-1===e.indexOf("-");for(var i in t){var l=t[i];if(!("value"===i&&"defaultValue"in t&&null==l||Q&&"children"===i&&"noscript"===e||"class"===i||"className"===i)){var c=i.toLowerCase();"defaultValue"===i&&"value"in t&&null==t.value?i="value":"download"===i&&!0===l?l="":"translate"===c&&"no"===l?l=!1:"o"===c[0]&&"n"===c[1]?"ondoubleclick"===c?i="ondblclick":"onchange"!==c||"input"!==e&&"textarea"!==e||X(t.type)?"onfocus"===c?i="onfocusin":"onblur"===c?i="onfocusout":J.test(i)&&(i=c):c=i="oninput":o&&G.test(i)?i=i.replace(K,"-$&").toLowerCase():null===l&&(l=void 0),"oninput"===c&&u[i=c]&&(i="oninputCapture"),u[i]=l}}"select"==e&&u.multiple&&Array.isArray(u.value)&&(u.value=(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(t.children).forEach(function(n){n.props.selected=-1!=u.value.indexOf(n.props.value)})),"select"==e&&null!=u.defaultValue&&(u.value=(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(t.children).forEach(function(n){n.props.selected=u.multiple?-1!=u.defaultValue.indexOf(n.props.value):u.defaultValue==n.props.value})),t.class&&!t.className?(u.class=t.class,Object.defineProperty(u,"className",cn)):(t.className&&!t.class||t.class&&t.className)&&(u.class=u.className=t.className),n.props=u}(n),n.$$typeof=q,fn&&fn(n)};var an=preact__WEBPACK_IMPORTED_MODULE_0__.options.__r;preact__WEBPACK_IMPORTED_MODULE_0__.options.__r=function(n){an&&an(n),ln=n.__c};var sn=preact__WEBPACK_IMPORTED_MODULE_0__.options.diffed;preact__WEBPACK_IMPORTED_MODULE_0__.options.diffed=function(n){sn&&sn(n);var t=n.props,e=n.__e;null!=e&&"textarea"===n.type&&"value"in t&&t.value!==e.value&&(e.value=null==t.value?"":t.value),ln=null};var hn={ReactCurrentDispatcher:{current:{readContext:function(n){return ln.__n[n.__c].props.value},useCallback:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useCallback,useContext:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useContext,useDebugValue:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useDebugValue,useDeferredValue:w,useEffect:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect,useId:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useId,useImperativeHandle:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useImperativeHandle,useInsertionEffect:I,useLayoutEffect:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect,useMemo:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useMemo,useReducer:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useReducer,useRef:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useRef,useState:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState,useSyncExternalStore:C,useTransition:k}}},vn="18.3.1";function dn(n){return preact__WEBPACK_IMPORTED_MODULE_0__.createElement.bind(null,n)}function mn(n){return!!n&&n.$$typeof===q}function pn(n){return mn(n)&&n.type===preact__WEBPACK_IMPORTED_MODULE_0__.Fragment}function yn(n){return!!n&&!!n.displayName&&("string"==typeof n.displayName||n.displayName instanceof String)&&n.displayName.startsWith("Memo(")}function _n(n){return mn(n)?preact__WEBPACK_IMPORTED_MODULE_0__.cloneElement.apply(null,arguments):n}function bn(n){return!!n.__k&&((0,preact__WEBPACK_IMPORTED_MODULE_0__.render)(null,n),!0)}function Sn(n){return n&&(n.base||1===n.nodeType&&n)||null}var gn=function(n,t){return n(t)},En=function(n,t){return n(t)},Cn=preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,xn=mn,Rn={useState:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState,useId:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useId,useReducer:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useReducer,useEffect:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect,useLayoutEffect:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect,useInsertionEffect:I,useTransition:k,useDeferredValue:w,useSyncExternalStore:C,startTransition:R,useRef:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useRef,useImperativeHandle:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useImperativeHandle,useMemo:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useMemo,useCallback:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useCallback,useContext:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useContext,useDebugValue:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useDebugValue,version:"18.3.1",Children:O,render:nn,hydrate:tn,unmountComponentAtNode:bn,createPortal:$,createElement:preact__WEBPACK_IMPORTED_MODULE_0__.createElement,createContext:preact__WEBPACK_IMPORTED_MODULE_0__.createContext,createFactory:dn,cloneElement:_n,createRef:preact__WEBPACK_IMPORTED_MODULE_0__.createRef,Fragment:preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,isValidElement:mn,isElement:xn,isFragment:pn,isMemo:yn,findDOMNode:Sn,Component:preact__WEBPACK_IMPORTED_MODULE_0__.Component,PureComponent:N,memo:M,forwardRef:D,flushSync:En,unstable_batchedUpdates:gn,StrictMode:Cn,Suspense:P,SuspenseList:B,lazy:z,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:hn};
10001
+ function g(n,t){for(var e in t)n[e]=t[e];return n}function E(n,t){for(var e in n)if("__source"!==e&&!(e in t))return!0;for(var r in t)if("__source"!==r&&n[r]!==t[r])return!0;return!1}function C(n,t){var e=t(),r=(0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)({t:{__:e,u:t}}),u=r[0].t,o=r[1];return (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect)(function(){u.__=e,u.u=t,x(u)&&o({t:u})},[n,e,t]),(0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function(){return x(u)&&o({t:u}),n(function(){x(u)&&o({t:u})})},[n]),e}function x(n){var t,e,r=n.u,u=n.__;try{var o=r();return!((t=u)===(e=o)&&(0!==t||1/t==1/e)||t!=t&&e!=e)}catch(n){return!0}}function R(n){n()}function w(n){return n}function k(){return[!1,R]}var I=preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect;function N(n,t){this.props=n,this.context=t}function M(n,e){function r(n){var t=this.props.ref,r=t==n.ref;return!r&&t&&(t.call?t(null):t.current=null),e?!e(this.props,n)||!r:E(this.props,n)}function u(e){return this.shouldComponentUpdate=r,(0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(n,e)}return u.displayName="Memo("+(n.displayName||n.name)+")",u.prototype.isReactComponent=!0,u.__f=!0,u.type=n,u}(N.prototype=new preact__WEBPACK_IMPORTED_MODULE_0__.Component).isPureReactComponent=!0,N.prototype.shouldComponentUpdate=function(n,t){return E(this.props,n)||E(this.state,t)};var T=preact__WEBPACK_IMPORTED_MODULE_0__.options.__b;preact__WEBPACK_IMPORTED_MODULE_0__.options.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),T&&T(n)};var A="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function D(n){function t(t){var e=g({},t);return delete e.ref,n(e,t.ref||null)}return t.$$typeof=A,t.render=n,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(n.displayName||n.name)+")",t}var L=function(n,t){return null==n?null:(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)((0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(n).map(t))},O={map:L,forEach:L,count:function(n){return n?(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(n).length:0},only:function(n){var t=(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(n);if(1!==t.length)throw"Children.only";return t[0]},toArray:preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray},F=preact__WEBPACK_IMPORTED_MODULE_0__.options.__e;preact__WEBPACK_IMPORTED_MODULE_0__.options.__e=function(n,t,e,r){if(n.then)for(var u,o=t;o=o.__;)if((u=o.__c)&&u.__c)return null==t.__e&&(t.__e=e.__e,t.__k=e.__k),u.__c(n,t);F(n,t,e,r)};var U=preact__WEBPACK_IMPORTED_MODULE_0__.options.unmount;function V(n,t,e){return n&&(n.__c&&n.__c.__H&&(n.__c.__H.__.forEach(function(n){"function"==typeof n.__c&&n.__c()}),n.__c.__H=null),null!=(n=g({},n)).__c&&(n.__c.__P===e&&(n.__c.__P=t),n.__c.__e=!0,n.__c=null),n.__k=n.__k&&n.__k.map(function(n){return V(n,t,e)})),n}function W(n,t,e){return n&&e&&(n.__v=null,n.__k=n.__k&&n.__k.map(function(n){return W(n,t,e)}),n.__c&&n.__c.__P===t&&(n.__e&&e.appendChild(n.__e),n.__c.__e=!0,n.__c.__P=e)),n}function P(){this.__u=0,this.o=null,this.__b=null}function j(n){var t=n.__.__c;return t&&t.__a&&t.__a(n)}function z(n){var e,r,u,o=null;function i(i){if(e||(e=n()).then(function(n){n&&(o=n.default||n),u=!0},function(n){r=n,u=!0}),r)throw r;if(!u)throw e;return o?(0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(o,i):null}return i.displayName="Lazy",i.__f=!0,i}function B(){this.i=null,this.l=null}preact__WEBPACK_IMPORTED_MODULE_0__.options.unmount=function(n){var t=n.__c;t&&t.__R&&t.__R(),t&&32&n.__u&&(n.type=null),U&&U(n)},(P.prototype=new preact__WEBPACK_IMPORTED_MODULE_0__.Component).__c=function(n,t){var e=t.__c,r=this;null==r.o&&(r.o=[]),r.o.push(e);var u=j(r.__v),o=!1,i=function(){o||(o=!0,e.__R=null,u?u(l):l())};e.__R=i;var l=function(){if(!--r.__u){if(r.state.__a){var n=r.state.__a;r.__v.__k[0]=W(n,n.__c.__P,n.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),n.then(i,i)},P.prototype.componentWillUnmount=function(){this.o=[]},P.prototype.render=function(n,e){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=V(this.__b,r,o.__O=o.__P)}this.__b=null}var i=e.__a&&(0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,null,n.fallback);return i&&(i.__u&=-33),[(0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,null,e.__a?null:n.children),i]};var H=function(n,t,e){if(++e[1]===e[0]&&n.l.delete(t),n.props.revealOrder&&("t"!==n.props.revealOrder[0]||!n.l.size))for(e=n.i;e;){for(;e.length>3;)e.pop()();if(e[1]<e[0])break;n.i=e=e[2]}};function Z(n){return this.getChildContext=function(){return n.context},n.children}function Y(n){var e=this,r=n.h;if(e.componentWillUnmount=function(){(0,preact__WEBPACK_IMPORTED_MODULE_0__.render)(null,e.v),e.v=null,e.h=null},e.h&&e.h!==r&&e.componentWillUnmount(),!e.v){for(var u=e.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;e.h=r,e.v={nodeType:1,parentNode:r,childNodes:[],__k:{__m:u.__m},contains:function(){return!0},insertBefore:function(n,t){this.childNodes.push(n),e.h.insertBefore(n,t)},removeChild:function(n){this.childNodes.splice(this.childNodes.indexOf(n)>>>1,1),e.h.removeChild(n)}}}(0,preact__WEBPACK_IMPORTED_MODULE_0__.render)((0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(Z,{context:e.context},n.__v),e.v)}function $(n,e){var r=(0,preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(Y,{__v:n,h:e});return r.containerInfo=e,r}(B.prototype=new preact__WEBPACK_IMPORTED_MODULE_0__.Component).__a=function(n){var t=this,e=j(t.__v),r=t.l.get(n);return r[0]++,function(u){var o=function(){t.props.revealOrder?(r.push(u),H(t,n,r)):u()};e?e(o):o()}},B.prototype.render=function(n){this.i=null,this.l=new Map;var t=(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(n.children);n.revealOrder&&"b"===n.revealOrder[0]&&t.reverse();for(var e=t.length;e--;)this.l.set(t[e],this.i=[1,0,this.i]);return n.children},B.prototype.componentDidUpdate=B.prototype.componentDidMount=function(){var n=this;this.l.forEach(function(t,e){H(n,e,t)})};var q="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,G=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,J=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,K=/[A-Z0-9]/g,Q="undefined"!=typeof document,X=function(n){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(n)};function nn(n,t,e){return null==t.__k&&(t.textContent=""),(0,preact__WEBPACK_IMPORTED_MODULE_0__.render)(n,t),"function"==typeof e&&e(),n?n.__c:null}function tn(n,t,e){return (0,preact__WEBPACK_IMPORTED_MODULE_0__.hydrate)(n,t),"function"==typeof e&&e(),n?n.__c:null}preact__WEBPACK_IMPORTED_MODULE_0__.Component.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(preact__WEBPACK_IMPORTED_MODULE_0__.Component.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})});var en=preact__WEBPACK_IMPORTED_MODULE_0__.options.event;function rn(){}function un(){return this.cancelBubble}function on(){return this.defaultPrevented}preact__WEBPACK_IMPORTED_MODULE_0__.options.event=function(n){return en&&(n=en(n)),n.persist=rn,n.isPropagationStopped=un,n.isDefaultPrevented=on,n.nativeEvent=n};var ln,cn={enumerable:!1,configurable:!0,get:function(){return this.class}},fn=preact__WEBPACK_IMPORTED_MODULE_0__.options.vnode;preact__WEBPACK_IMPORTED_MODULE_0__.options.vnode=function(n){"string"==typeof n.type&&function(n){var t=n.props,e=n.type,u={},o=-1===e.indexOf("-");for(var i in t){var l=t[i];if(!("value"===i&&"defaultValue"in t&&null==l||Q&&"children"===i&&"noscript"===e||"class"===i||"className"===i)){var c=i.toLowerCase();"defaultValue"===i&&"value"in t&&null==t.value?i="value":"download"===i&&!0===l?l="":"translate"===c&&"no"===l?l=!1:"o"===c[0]&&"n"===c[1]?"ondoubleclick"===c?i="ondblclick":"onchange"!==c||"input"!==e&&"textarea"!==e||X(t.type)?"onfocus"===c?i="onfocusin":"onblur"===c?i="onfocusout":J.test(i)&&(i=c):c=i="oninput":o&&G.test(i)?i=i.replace(K,"-$&").toLowerCase():null===l&&(l=void 0),"oninput"===c&&u[i=c]&&(i="oninputCapture"),u[i]=l}}"select"==e&&u.multiple&&Array.isArray(u.value)&&(u.value=(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(t.children).forEach(function(n){n.props.selected=-1!=u.value.indexOf(n.props.value)})),"select"==e&&null!=u.defaultValue&&(u.value=(0,preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(t.children).forEach(function(n){n.props.selected=u.multiple?-1!=u.defaultValue.indexOf(n.props.value):u.defaultValue==n.props.value})),t.class&&!t.className?(u.class=t.class,Object.defineProperty(u,"className",cn)):(t.className&&!t.class||t.class&&t.className)&&(u.class=u.className=t.className),n.props=u}(n),n.$$typeof=q,fn&&fn(n)};var an=preact__WEBPACK_IMPORTED_MODULE_0__.options.__r;preact__WEBPACK_IMPORTED_MODULE_0__.options.__r=function(n){an&&an(n),ln=n.__c};var sn=preact__WEBPACK_IMPORTED_MODULE_0__.options.diffed;preact__WEBPACK_IMPORTED_MODULE_0__.options.diffed=function(n){sn&&sn(n);var t=n.props,e=n.__e;null!=e&&"textarea"===n.type&&"value"in t&&t.value!==e.value&&(e.value=null==t.value?"":t.value),ln=null};var hn={ReactCurrentDispatcher:{current:{readContext:function(n){return ln.__n[n.__c].props.value},useCallback:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useCallback,useContext:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useContext,useDebugValue:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useDebugValue,useDeferredValue:w,useEffect:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect,useId:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useId,useImperativeHandle:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useImperativeHandle,useInsertionEffect:I,useLayoutEffect:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect,useMemo:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useMemo,useReducer:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useReducer,useRef:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useRef,useState:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState,useSyncExternalStore:C,useTransition:k}}},vn="18.3.1";function dn(n){return preact__WEBPACK_IMPORTED_MODULE_0__.createElement.bind(null,n)}function mn(n){return!!n&&n.$$typeof===q}function pn(n){return mn(n)&&n.type===preact__WEBPACK_IMPORTED_MODULE_0__.Fragment}function yn(n){return!!n&&!!n.displayName&&("string"==typeof n.displayName||n.displayName instanceof String)&&n.displayName.startsWith("Memo(")}function _n(n){return mn(n)?preact__WEBPACK_IMPORTED_MODULE_0__.cloneElement.apply(null,arguments):n}function bn(n){return!!n.__k&&((0,preact__WEBPACK_IMPORTED_MODULE_0__.render)(null,n),!0)}function Sn(n){return n&&(n.base||1===n.nodeType&&n)||null}var gn=function(n,t){return n(t)},En=function(n,t){return n(t)},Cn=preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,xn=mn,Rn={useState:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState,useId:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useId,useReducer:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useReducer,useEffect:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect,useLayoutEffect:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect,useInsertionEffect:I,useTransition:k,useDeferredValue:w,useSyncExternalStore:C,startTransition:R,useRef:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useRef,useImperativeHandle:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useImperativeHandle,useMemo:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useMemo,useCallback:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useCallback,useContext:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useContext,useDebugValue:preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useDebugValue,version:"18.3.1",Children:O,render:nn,hydrate:tn,unmountComponentAtNode:bn,createPortal:$,createElement:preact__WEBPACK_IMPORTED_MODULE_0__.createElement,createContext:preact__WEBPACK_IMPORTED_MODULE_0__.createContext,createFactory:dn,cloneElement:_n,createRef:preact__WEBPACK_IMPORTED_MODULE_0__.createRef,Fragment:preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,isValidElement:mn,isElement:xn,isFragment:pn,isMemo:yn,findDOMNode:Sn,Component:preact__WEBPACK_IMPORTED_MODULE_0__.Component,PureComponent:N,memo:M,forwardRef:D,flushSync:En,unstable_batchedUpdates:gn,StrictMode:Cn,Suspense:P,SuspenseList:B,lazy:z,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:hn};
9837
10002
  //# sourceMappingURL=compat.module.js.map
9838
10003
 
9839
10004
 
@@ -14591,7 +14756,7 @@ class API {
14591
14756
  return {
14592
14757
  clientName: "@seamly/web-ui",
14593
14758
  clientVariant: this.#layoutMode,
14594
- clientVersion: "25.2.1",
14759
+ clientVersion: "25.3.0-beta",
14595
14760
  currentUrl: window.location.toString(),
14596
14761
  screenResolution: `${window.screen.width}x${window.screen.height}`,
14597
14762
  timezone: (0,_utils__WEBPACK_IMPORTED_MODULE_13__.getTimeZone)(),
@@ -15111,6 +15276,7 @@ const initialConfigState = {
15111
15276
  connectWhenInView: true,
15112
15277
  showDisclaimer: false,
15113
15278
  showSuggestions: true,
15279
+ useMultilineUserInput: false,
15114
15280
  preChat: {
15115
15281
  enterDelay: 1000,
15116
15282
  exitAfter: 4000
@@ -15127,7 +15293,7 @@ const initialConfigState = {
15127
15293
  parentElement: undefined,
15128
15294
  layoutMode: 'window'
15129
15295
  };
15130
- const configKeys = ['alwaysShowEntryLabel', 'hideOnNoUserResponse', 'connectWhenInView', 'showDisclaimer', 'showSuggestions', 'continueChat', 'preChat', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback', 'agentParticipant', 'userParticipant', 'startChatIcon', 'notificationAudioURL'];
15296
+ const configKeys = ['alwaysShowEntryLabel', 'hideOnNoUserResponse', 'connectWhenInView', 'showDisclaimer', 'showSuggestions', 'useMultilineUserInput', 'continueChat', 'preChat', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback', 'agentParticipant', 'userParticipant', 'startChatIcon', 'notificationAudioURL'];
15131
15297
  const updateState = (state, config) => {
15132
15298
  const {
15133
15299
  messages,
@@ -23750,19 +23916,23 @@ __webpack_require__.r(__webpack_exports__);
23750
23916
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
23751
23917
  /* harmony export */ "default": () => (/* binding */ TextEntryForm)
23752
23918
  /* harmony export */ });
23753
- /* harmony import */ var domains_forms_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! domains/forms/hooks */ "./src/javascripts/core/domains/forms/hooks.ts");
23754
- /* harmony import */ var domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! domains/i18n/hooks */ "./src/javascripts/core/domains/i18n/hooks.ts");
23755
- /* harmony import */ var domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! domains/visibility/hooks */ "./src/javascripts/core/domains/visibility/hooks.ts");
23756
- /* harmony import */ var lib_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! lib/css */ "./src/javascripts/core/lib/css.ts");
23757
- /* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! preact/hooks */ "preact/hooks");
23758
- /* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(preact_hooks__WEBPACK_IMPORTED_MODULE_4__);
23759
- /* harmony import */ var ui_components_form_controls_form__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ui/components/form-controls/form */ "./src/javascripts/core/ui/components/form-controls/form.tsx");
23760
- /* harmony import */ var ui_components_form_controls_input__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ui/components/form-controls/input */ "./src/javascripts/core/ui/components/form-controls/input.tsx");
23761
- /* harmony import */ var ui_components_layout_icon__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ui/components/layout/icon */ "./src/javascripts/core/ui/components/layout/icon.tsx");
23762
- /* harmony import */ var ui_hooks_seamly_entry_hooks__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ui/hooks/seamly-entry-hooks */ "./src/javascripts/core/ui/hooks/seamly-entry-hooks.ts");
23763
- /* harmony import */ var ui_hooks_seamly_hooks__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ui/hooks/seamly-hooks */ "./src/javascripts/core/ui/hooks/seamly-hooks.ts");
23764
- /* harmony import */ var _hooks__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./hooks */ "./src/javascripts/core/ui/components/entry/text-entry/hooks.ts");
23765
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/preact/compat/jsx-runtime.mjs");
23919
+ /* harmony import */ var domains_config_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! domains/config/hooks */ "./src/javascripts/core/domains/config/hooks.ts");
23920
+ /* harmony import */ var domains_forms_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! domains/forms/hooks */ "./src/javascripts/core/domains/forms/hooks.ts");
23921
+ /* harmony import */ var domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! domains/i18n/hooks */ "./src/javascripts/core/domains/i18n/hooks.ts");
23922
+ /* harmony import */ var domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! domains/visibility/hooks */ "./src/javascripts/core/domains/visibility/hooks.ts");
23923
+ /* harmony import */ var lib_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! lib/css */ "./src/javascripts/core/lib/css.ts");
23924
+ /* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! preact/hooks */ "preact/hooks");
23925
+ /* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(preact_hooks__WEBPACK_IMPORTED_MODULE_5__);
23926
+ /* harmony import */ var ui_components_form_controls_form__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ui/components/form-controls/form */ "./src/javascripts/core/ui/components/form-controls/form.tsx");
23927
+ /* harmony import */ var ui_components_form_controls_input__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ui/components/form-controls/input */ "./src/javascripts/core/ui/components/form-controls/input.tsx");
23928
+ /* harmony import */ var ui_components_form_controls_textarea__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ui/components/form-controls/textarea */ "./src/javascripts/core/ui/components/form-controls/textarea.tsx");
23929
+ /* harmony import */ var ui_components_layout_icon__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ui/components/layout/icon */ "./src/javascripts/core/ui/components/layout/icon.tsx");
23930
+ /* harmony import */ var ui_hooks_seamly_entry_hooks__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ui/hooks/seamly-entry-hooks */ "./src/javascripts/core/ui/hooks/seamly-entry-hooks.ts");
23931
+ /* harmony import */ var ui_hooks_seamly_hooks__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ui/hooks/seamly-hooks */ "./src/javascripts/core/ui/hooks/seamly-hooks.ts");
23932
+ /* harmony import */ var _hooks__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./hooks */ "./src/javascripts/core/ui/components/entry/text-entry/hooks.ts");
23933
+ /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/preact/compat/jsx-runtime.mjs");
23934
+
23935
+
23766
23936
 
23767
23937
 
23768
23938
 
@@ -23781,37 +23951,41 @@ function TextEntryForm({
23781
23951
  }) {
23782
23952
  const {
23783
23953
  t
23784
- } = (0,domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_1__.useI18n)();
23954
+ } = (0,domains_i18n_hooks__WEBPACK_IMPORTED_MODULE_2__.useI18n)();
23785
23955
  const {
23786
23956
  setInputFocus
23787
- } = (0,domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_2__.useVisibility)();
23957
+ } = (0,domains_visibility_hooks__WEBPACK_IMPORTED_MODULE_3__.useVisibility)();
23788
23958
  const {
23789
23959
  sendAssertive
23790
- } = (0,ui_hooks_seamly_hooks__WEBPACK_IMPORTED_MODULE_9__.useLiveRegion)();
23960
+ } = (0,ui_hooks_seamly_hooks__WEBPACK_IMPORTED_MODULE_11__.useLiveRegion)();
23791
23961
  const {
23792
23962
  emitEvent
23793
- } = (0,ui_hooks_seamly_hooks__WEBPACK_IMPORTED_MODULE_9__.useSeamlyCommands)();
23794
- const handleKeyUp = (0,ui_hooks_seamly_entry_hooks__WEBPACK_IMPORTED_MODULE_8__.useSeamlyTyping)();
23963
+ } = (0,ui_hooks_seamly_hooks__WEBPACK_IMPORTED_MODULE_11__.useSeamlyCommands)();
23964
+ const handleKeyUp = (0,ui_hooks_seamly_entry_hooks__WEBPACK_IMPORTED_MODULE_10__.useSeamlyTyping)();
23795
23965
  const {
23796
23966
  setBlockAutoEntrySwitch
23797
- } = (0,ui_hooks_seamly_entry_hooks__WEBPACK_IMPORTED_MODULE_8__.useSeamlyEntry)();
23967
+ } = (0,ui_hooks_seamly_entry_hooks__WEBPACK_IMPORTED_MODULE_10__.useSeamlyEntry)();
23798
23968
  const {
23799
23969
  placeholder,
23800
23970
  label,
23801
23971
  labelClass
23802
- } = (0,_hooks__WEBPACK_IMPORTED_MODULE_10__.useEntryTextTranslation)(controlName);
23972
+ } = (0,_hooks__WEBPACK_IMPORTED_MODULE_12__.useEntryTextTranslation)(controlName);
23803
23973
  // TODO: Standardize the validation on form fields
23804
23974
  const {
23805
23975
  hasCharacterLimit,
23806
23976
  reachedCharacterWarning,
23807
23977
  reachedCharacterLimit,
23808
23978
  remainingChars
23809
- } = (0,_hooks__WEBPACK_IMPORTED_MODULE_10__.useCharacterLimit)(controlName);
23979
+ } = (0,_hooks__WEBPACK_IMPORTED_MODULE_12__.useCharacterLimit)(controlName);
23810
23980
  const [{
23811
23981
  value
23812
- }] = (0,domains_forms_hooks__WEBPACK_IMPORTED_MODULE_0__.useFormControl)(controlName);
23982
+ }] = (0,domains_forms_hooks__WEBPACK_IMPORTED_MODULE_1__.useFormControl)(controlName);
23813
23983
  const hasValue = !!value;
23814
- const handleFocus = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useCallback)(() => {
23984
+ const {
23985
+ useMultilineUserInput
23986
+ } = (0,domains_config_hooks__WEBPACK_IMPORTED_MODULE_0__.useConfig)();
23987
+ const submitButtonRef = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_5__.useRef)(null);
23988
+ const handleFocus = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_5__.useCallback)(() => {
23815
23989
  if (reachedCharacterWarning) {
23816
23990
  sendAssertive(t('input.srCharacterLimitText', {
23817
23991
  limit: remainingChars
@@ -23822,7 +23996,7 @@ function TextEntryForm({
23822
23996
 
23823
23997
  // When the input holds a value, the component should be blocked from switching
23824
23998
  // to file upload form.
23825
- (0,preact_hooks__WEBPACK_IMPORTED_MODULE_4__.useLayoutEffect)(() => {
23999
+ (0,preact_hooks__WEBPACK_IMPORTED_MODULE_5__.useLayoutEffect)(() => {
23826
24000
  setBlockAutoEntrySwitch(hasValue);
23827
24001
  return () => {
23828
24002
  setBlockAutoEntrySwitch(false);
@@ -23832,36 +24006,45 @@ function TextEntryForm({
23832
24006
  // When a message is submitted, the keyboard should be prevented from closing on mobile devices
23833
24007
  event.preventDefault();
23834
24008
  };
23835
- return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(ui_components_form_controls_form__WEBPACK_IMPORTED_MODULE_5__["default"], {
23836
- className: (0,lib_css__WEBPACK_IMPORTED_MODULE_3__.className)('entry-form'),
24009
+ const entryProps = {
24010
+ id: skipLinkId,
24011
+ name: controlName,
24012
+ className: (0,lib_css__WEBPACK_IMPORTED_MODULE_4__.className)('input__text'),
24013
+ autocomplete: 'off',
24014
+ placeholder,
24015
+ labelText: label,
24016
+ labelClass: (0,lib_css__WEBPACK_IMPORTED_MODULE_4__.className)(labelClass),
24017
+ 'aria-invalid': hasCharacterLimit ? reachedCharacterLimit : false,
24018
+ onKeyUp: handleKeyUp,
24019
+ onFocus: handleFocus,
24020
+ focus: setInputFocus
24021
+ };
24022
+ return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_13__.jsxs)(ui_components_form_controls_form__WEBPACK_IMPORTED_MODULE_6__["default"], {
24023
+ className: (0,lib_css__WEBPACK_IMPORTED_MODULE_4__.className)('entry-form'),
23837
24024
  disableValidationClasses: true,
23838
24025
  noValidate: "true",
23839
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)("div", {
23840
- className: (0,lib_css__WEBPACK_IMPORTED_MODULE_3__.className)(['input--text__container', ...(reachedCharacterWarning && !reachedCharacterLimit ? ['character-warning'] : []), ...(reachedCharacterLimit ? ['character-exceeded'] : [])]),
23841
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(ui_components_form_controls_input__WEBPACK_IMPORTED_MODULE_6__["default"], {
23842
- id: skipLinkId,
23843
- type: "text",
23844
- name: controlName,
23845
- className: (0,lib_css__WEBPACK_IMPORTED_MODULE_3__.className)('input__text'),
23846
- autocomplete: "off",
23847
- placeholder: placeholder,
23848
- labelText: label,
23849
- labelClass: (0,lib_css__WEBPACK_IMPORTED_MODULE_3__.className)(labelClass),
23850
- "aria-invalid": hasCharacterLimit ? reachedCharacterLimit : false,
23851
- onKeyUp: handleKeyUp,
23852
- onFocus: handleFocus,
23853
- focus: setInputFocus
23854
- }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("div", {
23855
- className: (0,lib_css__WEBPACK_IMPORTED_MODULE_3__.className)('character-count'),
23856
- children: reachedCharacterWarning && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("span", {
24026
+ children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_13__.jsxs)("div", {
24027
+ className: (0,lib_css__WEBPACK_IMPORTED_MODULE_4__.className)(['input--text__container', ...(reachedCharacterWarning && !reachedCharacterLimit ? ['character-warning'] : []), ...(reachedCharacterLimit ? ['character-exceeded'] : [])]),
24028
+ children: [!useMultilineUserInput ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_13__.jsx)(ui_components_form_controls_input__WEBPACK_IMPORTED_MODULE_7__["default"], {
24029
+ ...entryProps,
24030
+ type: "text"
24031
+ }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_13__.jsx)(ui_components_form_controls_textarea__WEBPACK_IMPORTED_MODULE_8__["default"], {
24032
+ ...entryProps,
24033
+ submitButtonRef: submitButtonRef,
24034
+ wrap: "hard"
24035
+ }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_13__.jsx)("div", {
24036
+ className: (0,lib_css__WEBPACK_IMPORTED_MODULE_4__.className)('character-count'),
24037
+ children: reachedCharacterWarning && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_13__.jsx)("span", {
23857
24038
  children: remainingChars
23858
24039
  })
23859
24040
  })]
23860
- }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("button", {
23861
- className: (0,lib_css__WEBPACK_IMPORTED_MODULE_3__.className)('button', 'input__submit'),
24041
+ }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_13__.jsx)("button", {
24042
+ className: (0,lib_css__WEBPACK_IMPORTED_MODULE_4__.className)('button', 'input__submit'),
23862
24043
  onPointerDown: handlePointerDown,
23863
24044
  "aria-disabled": !hasValue || reachedCharacterLimit,
23864
- children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(ui_components_layout_icon__WEBPACK_IMPORTED_MODULE_7__["default"], {
24045
+ ref: submitButtonRef,
24046
+ type: "submit",
24047
+ children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_13__.jsx)(ui_components_layout_icon__WEBPACK_IMPORTED_MODULE_9__["default"], {
23865
24048
  name: "send",
23866
24049
  size: "32",
23867
24050
  alt: t('input.sendMessage')
@@ -24551,6 +24734,86 @@ function Input({
24551
24734
 
24552
24735
  /***/ }),
24553
24736
 
24737
+ /***/ "./src/javascripts/core/ui/components/form-controls/textarea.tsx":
24738
+ /*!***********************************************************************!*\
24739
+ !*** ./src/javascripts/core/ui/components/form-controls/textarea.tsx ***!
24740
+ \***********************************************************************/
24741
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
24742
+
24743
+ "use strict";
24744
+ __webpack_require__.r(__webpack_exports__);
24745
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
24746
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
24747
+ /* harmony export */ });
24748
+ /* harmony import */ var domains_forms_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! domains/forms/hooks */ "./src/javascripts/core/domains/forms/hooks.ts");
24749
+ /* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/hooks */ "preact/hooks");
24750
+ /* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(preact_hooks__WEBPACK_IMPORTED_MODULE_1__);
24751
+ /* harmony import */ var _wrapper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./wrapper */ "./src/javascripts/core/ui/components/form-controls/wrapper.tsx");
24752
+ /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/preact/compat/jsx-runtime.mjs");
24753
+
24754
+
24755
+
24756
+
24757
+ function Textarea({
24758
+ id,
24759
+ name,
24760
+ labelText,
24761
+ labelClass,
24762
+ contentHint = null,
24763
+ focus,
24764
+ submitButtonRef,
24765
+ 'aria-invalid': ariaInvalid,
24766
+ 'aria-describedby': ariaDescribedBy,
24767
+ ...props
24768
+ }) {
24769
+ const textareaRef = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
24770
+ const {
24771
+ isSubmitted
24772
+ } = (0,domains_forms_hooks__WEBPACK_IMPORTED_MODULE_0__.useFormContext)();
24773
+ const [field, {
24774
+ error
24775
+ }] = (0,domains_forms_hooks__WEBPACK_IMPORTED_MODULE_0__.useFormControl)(name);
24776
+ const hasError = isSubmitted && error;
24777
+ const describedByIds = [ariaDescribedBy && ariaDescribedBy, contentHint && `${id}-content-hint`, hasError && `${id}-error`].filter(Boolean).join(' ');
24778
+ (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect)(() => {
24779
+ if (textareaRef.current && focus) {
24780
+ textareaRef.current.focus();
24781
+ }
24782
+ }, [focus]);
24783
+ const handleKeyDown = e => {
24784
+ if (e.key === 'Enter' && !e.shiftKey) {
24785
+ // Prevent default newline in textarea
24786
+ e.preventDefault();
24787
+
24788
+ // Trigger the submit button
24789
+ if (submitButtonRef.current) {
24790
+ submitButtonRef.current.click();
24791
+ }
24792
+ }
24793
+ };
24794
+ return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_wrapper__WEBPACK_IMPORTED_MODULE_2__["default"], {
24795
+ id: id,
24796
+ contentHint: contentHint,
24797
+ validity: !hasError,
24798
+ errorText: error,
24799
+ labelText: labelText,
24800
+ labelClass: labelClass,
24801
+ children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("textarea", {
24802
+ ...field,
24803
+ ...props,
24804
+ ref: textareaRef,
24805
+ id: id,
24806
+ "aria-invalid": ariaInvalid || hasError ? 'true' : 'false',
24807
+ "aria-describedby": describedByIds || undefined,
24808
+ name: name,
24809
+ onKeyDown: handleKeyDown
24810
+ })
24811
+ });
24812
+ }
24813
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Textarea);
24814
+
24815
+ /***/ }),
24816
+
24554
24817
  /***/ "./src/javascripts/core/ui/components/form-controls/wrapper.tsx":
24555
24818
  /*!**********************************************************************!*\
24556
24819
  !*** ./src/javascripts/core/ui/components/form-controls/wrapper.tsx ***!