unpoly-rails 3.10.2 → 3.11.0.rc12

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.
@@ -5,7 +5,7 @@
5
5
  /***/ (() => {
6
6
 
7
7
  window.up = {
8
- version: '3.10.2'
8
+ version: '3.11.0-rc12'
9
9
  };
10
10
 
11
11
 
@@ -116,7 +116,7 @@ up.util = (function () {
116
116
  }
117
117
  function iteratee(block) {
118
118
  if (isString(block)) {
119
- return item => item[block];
119
+ return (item) => item[block];
120
120
  }
121
121
  else {
122
122
  return block;
@@ -135,11 +135,7 @@ up.util = (function () {
135
135
  return mapped;
136
136
  }
137
137
  function mapObject(array, pairer) {
138
- const merger = function (object, pair) {
139
- object[pair[0]] = pair[1];
140
- return object;
141
- };
142
- return map(array, pairer).reduce(merger, {});
138
+ return Object.fromEntries(array.map(pairer));
143
139
  }
144
140
  function each(array, block) {
145
141
  let i = 0;
@@ -147,15 +143,18 @@ up.util = (function () {
147
143
  block(item, i++);
148
144
  }
149
145
  }
150
- function isNull(object) {
151
- return object === null;
146
+ function isNull(value) {
147
+ return value === null;
148
+ }
149
+ function isTruthy(value) {
150
+ return !!value;
152
151
  }
153
- function isUndefined(object) {
154
- return object === undefined;
152
+ function isUndefined(value) {
153
+ return value === undefined;
155
154
  }
156
155
  const isDefined = negate(isUndefined);
157
- function isMissing(object) {
158
- return isUndefined(object) || isNull(object);
156
+ function isMissing(value) {
157
+ return isUndefined(value) || isNull(value);
159
158
  }
160
159
  const isGiven = negate(isMissing);
161
160
  function isBlank(value) {
@@ -180,50 +179,50 @@ up.util = (function () {
180
179
  }
181
180
  }
182
181
  const isPresent = negate(isBlank);
183
- function isFunction(object) {
184
- return typeof (object) === 'function';
182
+ function isFunction(value) {
183
+ return typeof (value) === 'function';
185
184
  }
186
- function isString(object) {
187
- return (typeof (object) === 'string') || object instanceof String;
185
+ function isString(value) {
186
+ return (typeof (value) === 'string') || value instanceof String;
188
187
  }
189
- function isBoolean(object) {
190
- return (typeof (object) === 'boolean') || object instanceof Boolean;
188
+ function isBoolean(value) {
189
+ return (typeof (value) === 'boolean') || value instanceof Boolean;
191
190
  }
192
- function isNumber(object) {
193
- return (typeof (object) === 'number') || object instanceof Number;
191
+ function isNumber(value) {
192
+ return (typeof (value) === 'number') || value instanceof Number;
194
193
  }
195
- function isOptions(object) {
196
- return (typeof (object) === 'object') && !isNull(object) && (isUndefined(object.constructor) || (object.constructor === Object));
194
+ function isOptions(value) {
195
+ return (typeof (value) === 'object') && !isNull(value) && (isUndefined(value.constructor) || (value.constructor === Object));
197
196
  }
198
- function isObject(object) {
199
- const typeOfResult = typeof (object);
200
- return ((typeOfResult === 'object') && !isNull(object)) || (typeOfResult === 'function');
197
+ function isObject(value) {
198
+ const typeOfResult = typeof (value);
199
+ return ((typeOfResult === 'object') && !isNull(value)) || (typeOfResult === 'function');
201
200
  }
202
- function isElement(object) {
203
- return object instanceof Element;
201
+ function isElement(value) {
202
+ return value instanceof Element;
204
203
  }
205
- function isTextNode(object) {
206
- return object instanceof Text;
204
+ function isTextNode(value) {
205
+ return value instanceof Text;
207
206
  }
208
- function isRegExp(object) {
209
- return object instanceof RegExp;
207
+ function isRegExp(value) {
208
+ return value instanceof RegExp;
210
209
  }
211
- function isError(object) {
212
- return object instanceof Error;
210
+ function isError(value) {
211
+ return value instanceof Error;
213
212
  }
214
- function isJQuery(object) {
215
- return up.browser.canJQuery() && object instanceof jQuery;
213
+ function isJQuery(value) {
214
+ return up.browser.canJQuery() && value instanceof jQuery;
216
215
  }
217
- function isElementLike(object) {
216
+ function isElementLike(value) {
218
217
  var _a;
219
- return !!(object && (object.addEventListener || (isJQuery(object) && ((_a = object[0]) === null || _a === void 0 ? void 0 : _a.addEventListener))));
218
+ return !!(value && (value.addEventListener || (isJQuery(value) && ((_a = value[0]) === null || _a === void 0 ? void 0 : _a.addEventListener))));
220
219
  }
221
- function isPromise(object) {
222
- return isObject(object) && isFunction(object.then);
220
+ function isPromise(value) {
221
+ return isObject(value) && isFunction(value.then);
223
222
  }
224
223
  const { isArray } = Array;
225
- function isFormData(object) {
226
- return object instanceof FormData;
224
+ function isFormData(value) {
225
+ return value instanceof FormData;
227
226
  }
228
227
  function toArray(value) {
229
228
  return isArray(value) ? value : copyArrayLike(value);
@@ -390,13 +389,15 @@ up.util = (function () {
390
389
  return filterList(list, tester);
391
390
  }
392
391
  function intersect(array1, array2) {
393
- return filterList(array1, element => contains(array2, element));
392
+ return filterList(array1, (element) => contains(array2, element));
394
393
  }
395
394
  function scheduleTimer(millis, callback) {
396
395
  return setTimeout(callback, millis);
397
396
  }
398
397
  function queueTask(task) {
399
- return setTimeout(task);
398
+ const channel = new MessageChannel();
399
+ channel.port1.onmessage = () => task();
400
+ channel.port2.postMessage(0);
400
401
  }
401
402
  function last(value) {
402
403
  return value[value.length - 1];
@@ -426,7 +427,7 @@ up.util = (function () {
426
427
  const filtered = {};
427
428
  for (let key in object) {
428
429
  const value = object[key];
429
- if (tester(value, key, object)) {
430
+ if (tester(value, key)) {
430
431
  filtered[key] = object[key];
431
432
  }
432
433
  }
@@ -463,7 +464,7 @@ up.util = (function () {
463
464
  "'": '''
464
465
  };
465
466
  function escapeHTML(string) {
466
- return string.replace(/[&<>"']/g, char => ESCAPE_HTML_ENTITY_MAP[char]);
467
+ return string.replace(/[&<>"']/g, (char) => ESCAPE_HTML_ENTITY_MAP[char]);
467
468
  }
468
469
  function escapeRegExp(string) {
469
470
  return string.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
@@ -492,9 +493,9 @@ up.util = (function () {
492
493
  function identity(arg) {
493
494
  return arg;
494
495
  }
495
- function sequence(functions) {
496
- functions = compact(functions);
497
- return (...args) => map(functions, fn => fn(...args));
496
+ function sequence(...args) {
497
+ let functions = scanFunctions(...args);
498
+ return (...args) => map(functions, (fn) => fn(...args));
498
499
  }
499
500
  function flatten(array) {
500
501
  const flattened = [];
@@ -529,34 +530,36 @@ up.util = (function () {
529
530
  return Object.prototype.hasOwnProperty(k);
530
531
  }
531
532
  function isEqual(a, b) {
533
+ if (a === b) {
534
+ return true;
535
+ }
532
536
  if (a === null || a === void 0 ? void 0 : a.valueOf) {
533
537
  a = a.valueOf();
534
538
  }
535
539
  if (b === null || b === void 0 ? void 0 : b.valueOf) {
536
540
  b = b.valueOf();
537
541
  }
542
+ if (a === b) {
543
+ return true;
544
+ }
538
545
  if (typeof (a) !== typeof (b)) {
539
546
  return false;
540
547
  }
541
- else if (isList(a) && isList(b)) {
548
+ if (isList(a) && isList(b)) {
542
549
  return isEqualList(a, b);
543
550
  }
544
- else if (isObject(a) && a[isEqual.key]) {
551
+ if (isObject(a) && a[isEqual.key]) {
545
552
  return a[isEqual.key](b);
546
553
  }
547
- else if (isOptions(a) && isOptions(b)) {
548
- const aKeys = Object.keys(a);
549
- const bKeys = Object.keys(b);
550
- if (isEqualList(aKeys, bKeys)) {
551
- return every(aKeys, aKey => isEqual(a[aKey], b[aKey]));
552
- }
553
- else {
554
- return false;
555
- }
556
- }
557
- else {
558
- return a === b;
554
+ if (isOptions(a) && isOptions(b)) {
555
+ return isEqualOptions(a, b);
559
556
  }
557
+ return false;
558
+ }
559
+ function isEqualOptions(a, b) {
560
+ const aKeys = Object.keys(a);
561
+ const bKeys = Object.keys(b);
562
+ return isEqualList(aKeys, bKeys) && every(aKeys, (key) => isEqual(a[key], b[key]));
560
563
  }
561
564
  isEqual.key = 'up.util.isEqual';
562
565
  function isEqualList(a, b) {
@@ -613,7 +616,7 @@ up.util = (function () {
613
616
  return renamed;
614
617
  }
615
618
  function camelToKebabCase(str) {
616
- return str.replace(/[A-Z]/g, char => '-' + char.toLowerCase());
619
+ return str.replace(/[A-Z]/g, (char) => '-' + char.toLowerCase());
617
620
  }
618
621
  function lowerCaseFirst(str) {
619
622
  return str[0].toLowerCase() + str.slice(1);
@@ -797,36 +800,39 @@ up.util = (function () {
797
800
  }
798
801
  function maskPattern(str, patterns, { keepDelimiters = false } = {}) {
799
802
  let maskCount = 0;
800
- let maskPattern = /§(\d+)/g;
801
- let matches = [];
802
- let replaceLayers = 0;
803
- let replace = (replacePattern) => {
803
+ let maskPattern = /§\d+/g;
804
+ let maskings = {};
805
+ let replaceLayers = [];
806
+ let replace = (replacePattern, allowRestoreTransform) => {
804
807
  let didReplace = false;
805
808
  str = str.replaceAll(replacePattern, function (match) {
806
809
  didReplace = true;
807
- let glyph = '§' + (maskCount++);
808
- let mask;
810
+ let mask = '§' + (maskCount++);
811
+ let remain;
809
812
  let masked;
810
813
  if (keepDelimiters) {
811
814
  let startDelimiter = match[0];
812
815
  let endDelimiter = match.slice(-1);
813
816
  masked = match.slice(1, -1);
814
- mask = startDelimiter + glyph + endDelimiter;
817
+ remain = startDelimiter + mask + endDelimiter;
815
818
  }
816
819
  else {
817
820
  masked = match;
818
- mask = glyph;
821
+ remain = mask;
819
822
  }
820
- matches.push(masked);
821
- return mask;
823
+ maskings[mask] = masked;
824
+ return remain;
822
825
  });
823
826
  if (didReplace)
824
- replaceLayers++;
827
+ replaceLayers.unshift({ allowRestoreTransform });
825
828
  };
826
- [maskPattern, ...patterns].forEach(replace);
829
+ replace(maskPattern, false);
830
+ for (let pattern of patterns)
831
+ replace(pattern, true);
827
832
  let restore = (s, transform = identity) => {
828
- for (let i = 0; i < replaceLayers; i++) {
829
- s = s.replace(maskPattern, (match, placeholderIndex) => transform(matches[placeholderIndex]));
833
+ for (let { allowRestoreTransform } of replaceLayers) {
834
+ let iterationTransform = allowRestoreTransform ? transform : identity;
835
+ s = s.replace(maskPattern, (match) => iterationTransform(assert(maskings[match], isString)));
830
836
  }
831
837
  return s;
832
838
  };
@@ -840,6 +846,7 @@ up.util = (function () {
840
846
  function ensureDoubleQuotes(str) {
841
847
  if (str[0] === '"')
842
848
  return str;
849
+ assert(str[0] === "'");
843
850
  str = str.slice(1, -1);
844
851
  let transformed = str.replace(/(\\\\)|(\\')|(\\")|(")/g, function (_match, escapedBackslash, escapedSingleQuote, _doubleQuote) {
845
852
  return escapedBackslash
@@ -868,6 +875,17 @@ up.util = (function () {
868
875
  ];
869
876
  });
870
877
  }
878
+ function spanObject(keys, value) {
879
+ return mapObject(keys, (key) => [key, value]);
880
+ }
881
+ function assert(value, testFn = isTruthy) {
882
+ if (testFn(value)) {
883
+ return value;
884
+ }
885
+ else {
886
+ throw "assert failed";
887
+ }
888
+ }
871
889
  return {
872
890
  parseURL,
873
891
  normalizeURL,
@@ -885,6 +903,7 @@ up.util = (function () {
885
903
  map,
886
904
  flatMap,
887
905
  mapObject,
906
+ spanObject,
888
907
  findResult,
889
908
  some,
890
909
  every,
@@ -975,6 +994,7 @@ up.util = (function () {
975
994
  maskPattern,
976
995
  expressionOutline,
977
996
  parseString,
997
+ assert,
978
998
  };
979
999
  })();
980
1000
 
@@ -1089,12 +1109,13 @@ up.element = (function () {
1089
1109
  return root.querySelector(selector);
1090
1110
  }
1091
1111
  function subtree(root, selector) {
1092
- const results = [];
1112
+ const descendantMatches = root.querySelectorAll(selector);
1093
1113
  if (elementLikeMatches(root, selector)) {
1094
- results.push(root);
1114
+ return [root, ...descendantMatches];
1115
+ }
1116
+ else {
1117
+ return descendantMatches;
1095
1118
  }
1096
- results.push(...root.querySelectorAll(selector));
1097
- return results;
1098
1119
  }
1099
1120
  function subtreeFirst(root, selector) {
1100
1121
  return elementLikeMatches(root, selector) ? root : root.querySelector(selector);
@@ -1202,7 +1223,7 @@ up.element = (function () {
1202
1223
  function metaContent(name) {
1203
1224
  var _a;
1204
1225
  const selector = "meta" + attrSelector('name', name);
1205
- return (_a = first(selector)) === null || _a === void 0 ? void 0 : _a.getAttribute('content');
1226
+ return (_a = document.head.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.getAttribute('content');
1206
1227
  }
1207
1228
  function insertBefore(existingNode, newNode) {
1208
1229
  existingNode.parentNode.insertBefore(newNode, existingNode);
@@ -1312,7 +1333,7 @@ up.element = (function () {
1312
1333
  return element;
1313
1334
  }
1314
1335
  const SINGLETON_TAG_NAMES = ['HTML', 'BODY', 'HEAD', 'TITLE'];
1315
- const isSingleton = up.mockable(element => element.matches(SINGLETON_TAG_NAMES.join()));
1336
+ const isSingleton = up.mockable((element) => element.matches(SINGLETON_TAG_NAMES.join()));
1316
1337
  function elementTagName(element) {
1317
1338
  return element.tagName.toLowerCase();
1318
1339
  }
@@ -1340,9 +1361,11 @@ up.element = (function () {
1340
1361
  function createBrokenDocumentFromHTML(html) {
1341
1362
  return new DOMParser().parseFromString(html, 'text/html');
1342
1363
  }
1343
- function fixParserDamage(scriptish) {
1344
- let clone = createFromHTML(scriptish.outerHTML);
1345
- scriptish.replaceWith(clone);
1364
+ function revivedClone(element) {
1365
+ let clone = createFromHTML(element.outerHTML);
1366
+ if ('nonce' in element)
1367
+ clone.nonce = element.nonce;
1368
+ return clone;
1346
1369
  }
1347
1370
  function createFromHTML(html) {
1348
1371
  return extractSingular(createNodesFromHTML(html));
@@ -1539,7 +1562,7 @@ up.element = (function () {
1539
1562
  }
1540
1563
  function extractFromStyleObject(style, keyOrKeys) {
1541
1564
  if (up.migrate.loaded)
1542
- keyOrKeys = up.migrate.fixStyleProps(keyOrKeys);
1565
+ keyOrKeys = up.migrate.fixGetStyleProps(keyOrKeys);
1543
1566
  if (u.isString(keyOrKeys)) {
1544
1567
  return style.getPropertyValue(keyOrKeys);
1545
1568
  }
@@ -1549,7 +1572,7 @@ up.element = (function () {
1549
1572
  }
1550
1573
  function setInlineStyle(element, props, unit = '') {
1551
1574
  if (up.migrate.loaded)
1552
- props = up.migrate.fixStyleProps(props, unit);
1575
+ props = up.migrate.fixSetStyleProps(props, unit);
1553
1576
  if (u.isString(props)) {
1554
1577
  element.setAttribute('style', props);
1555
1578
  }
@@ -1651,7 +1674,7 @@ up.element = (function () {
1651
1674
  attrSelector,
1652
1675
  tagName: elementTagName,
1653
1676
  createBrokenDocumentFromHTML,
1654
- fixParserDamage,
1677
+ revivedClone,
1655
1678
  createNodesFromHTML,
1656
1679
  createFromHTML,
1657
1680
  extractSingular,
@@ -1783,7 +1806,7 @@ up.Record = class Record {
1783
1806
  return {};
1784
1807
  }
1785
1808
  constructor(options) {
1786
- Object.assign(this, this.defaults(options), this.attributes(options));
1809
+ Object.assign(this, u.mergeDefined(this.defaults(options), this.attributes(options)));
1787
1810
  }
1788
1811
  attributes(source = this) {
1789
1812
  return u.pick(source, this.keys());
@@ -1862,13 +1885,39 @@ up.LogConfig = class LogConfig extends up.Config {
1862
1885
  /* 19 */
1863
1886
  /***/ (() => {
1864
1887
 
1888
+ const u = up.util;
1889
+ up.Registry = class Registry {
1890
+ constructor(valueDescription, normalize = u.identity) {
1891
+ this._data = {};
1892
+ this._normalize = normalize;
1893
+ this._valueDescription = valueDescription;
1894
+ this.put = this.put.bind(this);
1895
+ document.addEventListener('up:framework:reset', () => this.reset());
1896
+ }
1897
+ put(key, object) {
1898
+ object = this._normalize(object);
1899
+ object.isDefault = up.framework.evaling;
1900
+ this._data[key] = object;
1901
+ }
1902
+ get(name) {
1903
+ return this._data[name] || up.fail("Unknown %s %o", this._valueDescription, name);
1904
+ }
1905
+ reset() {
1906
+ this._data = u.pickBy(this._data, 'isDefault');
1907
+ }
1908
+ };
1909
+
1910
+
1911
+ /***/ }),
1912
+ /* 20 */
1913
+ /***/ (() => {
1914
+
1865
1915
  const u = up.util;
1866
1916
  const e = up.element;
1867
1917
  up.OptionsParser = class OptionsParser {
1868
1918
  constructor(element, options, parserOptions = {}) {
1869
1919
  this._options = options;
1870
1920
  this._element = element;
1871
- this._parserOptions = parserOptions;
1872
1921
  this._fail = parserOptions.fail;
1873
1922
  this._closest = parserOptions.closest;
1874
1923
  this._attrPrefix = parserOptions.attrPrefix || 'up-';
@@ -1904,11 +1953,11 @@ up.OptionsParser = class OptionsParser {
1904
1953
  value !== null && value !== void 0 ? value : (value = this._parseFromAttr(attrValueFn, this._element, attrName));
1905
1954
  }
1906
1955
  value !== null && value !== void 0 ? value : (value = (_b = keyOptions.default) !== null && _b !== void 0 ? _b : this._defaults[key]);
1907
- let normalizeFn = keyOptions.normalize;
1908
- if (normalizeFn) {
1909
- value = normalizeFn(value);
1910
- }
1911
1956
  if (u.isDefined(value)) {
1957
+ let normalizeFn = keyOptions.normalize;
1958
+ if (normalizeFn) {
1959
+ value = normalizeFn(value);
1960
+ }
1912
1961
  this._options[key] = value;
1913
1962
  }
1914
1963
  let failKey;
@@ -1917,8 +1966,8 @@ up.OptionsParser = class OptionsParser {
1917
1966
  this.parse(attrValueFn, failKey, Object.assign(Object.assign({}, keyOptions), { attr: failAttrNames }));
1918
1967
  }
1919
1968
  }
1920
- include(optionsFn) {
1921
- let fnResult = optionsFn(this._element, this._options, this._parserOptions);
1969
+ include(optionsFn, parserOptions) {
1970
+ let fnResult = optionsFn(this._element, this._options, Object.assign({ defaults: this._defaults }, parserOptions));
1922
1971
  Object.assign(this._options, fnResult);
1923
1972
  }
1924
1973
  _parseFromAttr(attrValueFn, element, attrName) {
@@ -1945,7 +1994,7 @@ up.OptionsParser = class OptionsParser {
1945
1994
 
1946
1995
 
1947
1996
  /***/ }),
1948
- /* 20 */
1997
+ /* 21 */
1949
1998
  /***/ (() => {
1950
1999
 
1951
2000
  const u = up.util;
@@ -1974,7 +2023,7 @@ up.FIFOCache = class FIFOCache {
1974
2023
 
1975
2024
 
1976
2025
  /***/ }),
1977
- /* 21 */
2026
+ /* 22 */
1978
2027
  /***/ (() => {
1979
2028
 
1980
2029
  up.Rect = class Rect extends up.Record {
@@ -2005,7 +2054,7 @@ up.Rect = class Rect extends up.Record {
2005
2054
 
2006
2055
 
2007
2056
  /***/ }),
2008
- /* 22 */
2057
+ /* 23 */
2009
2058
  /***/ (() => {
2010
2059
 
2011
2060
  const e = up.element;
@@ -2053,7 +2102,7 @@ up.BodyShifter = class BodyShifter {
2053
2102
 
2054
2103
 
2055
2104
  /***/ }),
2056
- /* 23 */
2105
+ /* 24 */
2057
2106
  /***/ (() => {
2058
2107
 
2059
2108
  const u = up.util;
@@ -2079,7 +2128,7 @@ up.Change = class Change {
2079
2128
 
2080
2129
 
2081
2130
  /***/ }),
2082
- /* 24 */
2131
+ /* 25 */
2083
2132
  /***/ (() => {
2084
2133
 
2085
2134
  const u = up.util;
@@ -2147,14 +2196,14 @@ up.Change.Addition = class Addition extends up.Change {
2147
2196
  _responseOptions() {
2148
2197
  return { response: this._response };
2149
2198
  }
2150
- executeSteps(steps, responseDoc, noneOptions) {
2151
- return new up.Change.UpdateSteps({ steps, noneOptions }).execute(responseDoc);
2199
+ executeSteps({ steps, responseDoc, noneOptions, passRenderOptions = this.options }) {
2200
+ return new up.Change.UpdateSteps({ steps, noneOptions, passRenderOptions }).execute(responseDoc);
2152
2201
  }
2153
2202
  };
2154
2203
 
2155
2204
 
2156
2205
  /***/ }),
2157
- /* 25 */
2206
+ /* 26 */
2158
2207
  /***/ (function() {
2159
2208
 
2160
2209
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -2169,8 +2218,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
2169
2218
  var _a;
2170
2219
  const u = up.util;
2171
2220
  up.RenderJob = (_a = class RenderJob {
2172
- constructor(options) {
2173
- this.options = options;
2221
+ constructor(renderOptions) {
2222
+ this.renderOptions = renderOptions;
2174
2223
  }
2175
2224
  execute() {
2176
2225
  this._rendered = this._executePromise();
@@ -2180,9 +2229,9 @@ up.RenderJob = (_a = class RenderJob {
2180
2229
  return __awaiter(this, void 0, void 0, function* () {
2181
2230
  try {
2182
2231
  this._emitGuardEvent();
2183
- this.options = up.RenderOptions.preprocess(this.options);
2184
- up.browser.assertConfirmed(this.options);
2185
- up.RenderOptions.assertContentGiven(this.options);
2232
+ this.renderOptions = up.RenderOptions.preprocess(this.renderOptions);
2233
+ up.browser.assertConfirmed(this.renderOptions);
2234
+ up.RenderOptions.assertContentGiven(this.renderOptions);
2186
2235
  let result = yield this._getChange().execute();
2187
2236
  this._handleResult(result);
2188
2237
  return result;
@@ -2195,7 +2244,7 @@ up.RenderJob = (_a = class RenderJob {
2195
2244
  }
2196
2245
  _handleResult(result) {
2197
2246
  if (result instanceof up.RenderResult) {
2198
- let { onRendered, onFinished } = result.options;
2247
+ let { onRendered, onFinished } = result.renderOptions;
2199
2248
  if (!result.none)
2200
2249
  up.error.guard(() => onRendered === null || onRendered === void 0 ? void 0 : onRendered(result));
2201
2250
  let guardedOnFinished = function (result) {
@@ -2208,7 +2257,7 @@ up.RenderJob = (_a = class RenderJob {
2208
2257
  _handleError(error) {
2209
2258
  let prefix = error instanceof up.Aborted ? 'Rendering was aborted' : 'Error while rendering';
2210
2259
  up.puts('up.render()', `${prefix}: ${error.name}: ${error.message}`);
2211
- up.error.guard(() => { var _b, _c; return (_c = (_b = this.options).onError) === null || _c === void 0 ? void 0 : _c.call(_b, error); });
2260
+ up.error.guard(() => { var _b, _c; return (_c = (_b = this.renderOptions).onError) === null || _c === void 0 ? void 0 : _c.call(_b, error); });
2212
2261
  }
2213
2262
  get finished() {
2214
2263
  return this._awaitFinished();
@@ -2231,7 +2280,7 @@ up.RenderJob = (_a = class RenderJob {
2231
2280
  }
2232
2281
  _getChange() {
2233
2282
  let handleAbort = u.memoize((request) => this._handleAbortOption(request));
2234
- let renderOptions = Object.assign(Object.assign({}, this.options), { handleAbort });
2283
+ let renderOptions = Object.assign(Object.assign({}, this.renderOptions), { handleAbort });
2235
2284
  if (renderOptions.url) {
2236
2285
  return new up.Change.FromURL(renderOptions);
2237
2286
  }
@@ -2243,16 +2292,16 @@ up.RenderJob = (_a = class RenderJob {
2243
2292
  }
2244
2293
  }
2245
2294
  _emitGuardEvent() {
2246
- let guardEvent = u.pluckKey(this.options, 'guardEvent');
2295
+ let guardEvent = u.pluckKey(this.renderOptions, 'guardEvent');
2247
2296
  if (guardEvent) {
2248
- guardEvent.renderOptions = this.options;
2249
- if (up.emit(guardEvent, { target: this.options.origin }).defaultPrevented) {
2297
+ guardEvent.renderOptions = this.renderOptions;
2298
+ if (up.emit(guardEvent, { target: this.renderOptions.origin }).defaultPrevented) {
2250
2299
  throw new up.Aborted(`Rendering was prevented by ${guardEvent.type} listener`);
2251
2300
  }
2252
2301
  }
2253
2302
  }
2254
2303
  _handleAbortOption(request) {
2255
- let { abort } = this.options;
2304
+ let { abort } = this.renderOptions;
2256
2305
  if (!abort || !up.network.isBusy())
2257
2306
  return;
2258
2307
  let { bindFragments, bindLayer, origin, layer } = this._getChange().getPreflightProps();
@@ -2290,7 +2339,7 @@ up.RenderJob = (_a = class RenderJob {
2290
2339
 
2291
2340
 
2292
2341
  /***/ }),
2293
- /* 26 */
2342
+ /* 27 */
2294
2343
  /***/ (function() {
2295
2344
 
2296
2345
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -2326,20 +2375,20 @@ up.Change.DestroyFragment = class DestroyFragment extends up.Change {
2326
2375
  return __awaiter(this, void 0, void 0, function* () {
2327
2376
  this._emitDestroyed();
2328
2377
  yield this._animate();
2329
- this._wipe();
2378
+ this._erase();
2330
2379
  (_a = this._onFinished) === null || _a === void 0 ? void 0 : _a.call(this);
2331
2380
  });
2332
2381
  }
2333
2382
  _destroyNow() {
2334
2383
  var _a;
2335
- this._wipe();
2384
+ this._erase();
2336
2385
  this._emitDestroyed();
2337
2386
  (_a = this._onFinished) === null || _a === void 0 ? void 0 : _a.call(this);
2338
2387
  }
2339
2388
  _animate() {
2340
2389
  return up.motion.animate(this._element, this._animation, this.options);
2341
2390
  }
2342
- _wipe() {
2391
+ _erase() {
2343
2392
  this._layer.asCurrent(() => {
2344
2393
  up.fragment.abort(this._element);
2345
2394
  up.script.clean(this._element, { layer: this._layer });
@@ -2354,7 +2403,7 @@ up.Change.DestroyFragment = class DestroyFragment extends up.Change {
2354
2403
 
2355
2404
 
2356
2405
  /***/ }),
2357
- /* 27 */
2406
+ /* 28 */
2358
2407
  /***/ (function() {
2359
2408
 
2360
2409
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -2417,6 +2466,7 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
2417
2466
  this._assertOpenEventEmitted();
2418
2467
  this.layer = this._buildLayer();
2419
2468
  this._baseLayer.peel({ history: !this.layer.history });
2469
+ this._baseLayer.saveHistory();
2420
2470
  up.layer.stack.push(this.layer);
2421
2471
  this.layer.createElements();
2422
2472
  this.layer.setupHandlers();
@@ -2426,14 +2476,15 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
2426
2476
  this.handleLayerChangeRequests();
2427
2477
  this.responseDoc.commitElement(this._content);
2428
2478
  this.layer.setContent(this._content);
2429
- this.setReloadAttrs({ newElement: this._content, source: this.options.source });
2430
2479
  this.responseDoc.finalizeElement(this._content);
2480
+ this.setReloadAttrs({ newElement: this._content, source: this.options.source });
2481
+ up.hello(this.layer.element, Object.assign(Object.assign({}, this.options), { layer: this.layer, dataRoot: this._content }));
2431
2482
  this._newOverlayResult = new up.RenderResult({
2432
2483
  layer: this.layer,
2433
2484
  fragments: [this._content],
2434
2485
  target: this.target,
2486
+ renderOptions: this.options,
2435
2487
  });
2436
- up.hello(this.layer.element, Object.assign(Object.assign({}, this.options), { layer: this.layer, dataRoot: this._content }));
2437
2488
  this._handleScroll();
2438
2489
  this._newOverlayResult.finished = this._finish();
2439
2490
  this.layer.opening = false;
@@ -2444,7 +2495,10 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
2444
2495
  if (this._otherLayersResult)
2445
2496
  return;
2446
2497
  let otherLayerSteps = this._getHungrySteps().other;
2447
- this._otherLayersResult = this.executeSteps(otherLayerSteps, this.responseDoc);
2498
+ this._otherLayersResult = this.executeSteps({
2499
+ steps: otherLayerSteps,
2500
+ responseDoc: this.responseDoc,
2501
+ });
2448
2502
  }
2449
2503
  _finish() {
2450
2504
  return __awaiter(this, void 0, void 0, function* () {
@@ -2456,7 +2510,7 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
2456
2510
  }
2457
2511
  _buildLayer() {
2458
2512
  const buildOptions = Object.assign(Object.assign({}, this.options), { opening: true });
2459
- const beforeNew = optionsWithLayerDefaults => {
2513
+ const beforeNew = (optionsWithLayerDefaults) => {
2460
2514
  return this.options = up.RenderOptions.finalize(optionsWithLayerDefaults);
2461
2515
  };
2462
2516
  return up.layer.build(buildOptions, beforeNew);
@@ -2466,9 +2520,7 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
2466
2520
  if (this.layer.history === 'auto') {
2467
2521
  this.layer.history = up.fragment.hasAutoHistory([this._content], this.layer);
2468
2522
  }
2469
- let { parent } = this.layer;
2470
- (_a = this.layer).history && (_a.history = parent.history);
2471
- parent.saveHistory();
2523
+ (_a = this.layer).history && (_a.history = this._baseLayer.history);
2472
2524
  this.layer.updateHistory(this.options);
2473
2525
  }
2474
2526
  _handleFocus() {
@@ -2513,7 +2565,7 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
2513
2565
 
2514
2566
 
2515
2567
  /***/ }),
2516
- /* 28 */
2568
+ /* 29 */
2517
2569
  /***/ (() => {
2518
2570
 
2519
2571
  var _a;
@@ -2585,13 +2637,20 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
2585
2637
  this.layer.updateHistory(this.options);
2586
2638
  }
2587
2639
  this.handleLayerChangeRequests();
2588
- this._currentLayerResult = this.executeSteps(this._steps, this.responseDoc, this.options);
2640
+ this._currentLayerResult = this.executeSteps({
2641
+ steps: this._steps,
2642
+ responseDoc: this.responseDoc,
2643
+ noneOptions: this.options,
2644
+ });
2589
2645
  }
2590
2646
  _renderOtherLayers() {
2591
2647
  if (this._otherLayersResult)
2592
2648
  return;
2593
2649
  let otherLayerSteps = this._getHungrySteps().other;
2594
- this._otherLayersResult = this.executeSteps(otherLayerSteps, this.responseDoc);
2650
+ this._otherLayersResult = this.executeSteps({
2651
+ steps: otherLayerSteps,
2652
+ responseDoc: this.responseDoc,
2653
+ });
2595
2654
  }
2596
2655
  _matchPreflight() {
2597
2656
  this._matchOldElements();
@@ -2660,7 +2719,7 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
2660
2719
 
2661
2720
 
2662
2721
  /***/ }),
2663
- /* 29 */
2722
+ /* 30 */
2664
2723
  /***/ (function() {
2665
2724
 
2666
2725
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -2677,31 +2736,30 @@ const e = up.element;
2677
2736
  up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
2678
2737
  constructor(options) {
2679
2738
  super(options);
2739
+ this._steps = u.copy(u.assert(options.steps));
2740
+ this._passRenderOptions = u.assert(options.passRenderOptions);
2680
2741
  this._noneOptions = options.noneOptions || {};
2681
- this._steps = u.copy(options.steps);
2682
2742
  }
2683
2743
  execute(responseDoc) {
2684
- var _a;
2685
2744
  this.responseDoc = responseDoc;
2686
2745
  this._steps = responseDoc.selectSteps(this._steps);
2687
2746
  this._steps = responseDoc.commitSteps(this._steps);
2688
- if (!this._steps.length) {
2689
- return this._executeNone();
2690
- }
2691
2747
  this.renderResult = new up.RenderResult({
2692
- layer: (_a = this._steps[0]) === null || _a === void 0 ? void 0 : _a.layer,
2748
+ layer: this._passRenderOptions.layer,
2693
2749
  target: up.fragment.targetForSteps(this._steps),
2750
+ renderOptions: this._passRenderOptions,
2694
2751
  });
2695
- this._steps.reverse();
2696
- const motionEndPromises = this._steps.map(step => this._executeStep(step));
2697
- this.renderResult.finished = this._finish(motionEndPromises);
2752
+ if (!this._steps.length) {
2753
+ this._handleFocus(null, this._noneOptions);
2754
+ this._handleScroll(null, this._noneOptions);
2755
+ }
2756
+ else {
2757
+ this._steps.reverse();
2758
+ const motionEndPromises = this._steps.map((step) => this._executeStep(step));
2759
+ this.renderResult.finished = this._finish(motionEndPromises);
2760
+ }
2698
2761
  return this.renderResult;
2699
2762
  }
2700
- _executeNone() {
2701
- this._handleFocus(null, this._noneOptions);
2702
- this._handleScroll(null, this._noneOptions);
2703
- return up.RenderResult.buildNone();
2704
- }
2705
2763
  _finish(motionEndPromises) {
2706
2764
  return __awaiter(this, void 0, void 0, function* () {
2707
2765
  yield Promise.all(motionEndPromises);
@@ -2716,26 +2774,23 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
2716
2774
  this.renderResult.fragments.unshift(...newFragments);
2717
2775
  }
2718
2776
  _executeStep(step) {
2719
- this.setReloadAttrs(step);
2720
2777
  switch (step.placement) {
2721
2778
  case 'swap': {
2722
- let keepPlan = this._findKeepPlan(step);
2779
+ let keepPlan = up.fragment.keepPlan(step);
2723
2780
  if (keepPlan) {
2724
2781
  this._handleFocus(step.oldElement, step);
2725
2782
  this._handleScroll(step.oldElement, step);
2726
2783
  return Promise.resolve();
2727
2784
  }
2728
2785
  else {
2729
- this._preserveKeepables(step);
2786
+ this._preserveDescendantKeepables(step);
2730
2787
  const parent = step.oldElement.parentNode;
2731
2788
  const morphOptions = Object.assign(Object.assign({}, step), { beforeStart() {
2732
2789
  up.fragment.markAsDestroying(step.oldElement);
2733
2790
  }, afterInsert: () => {
2734
- this._restoreKeepables(step);
2735
- this.responseDoc.finalizeElement(step.newElement);
2736
- this._unmarkKeepables(step);
2737
- up.hello(step.newElement, step);
2738
- this._addToResult(step.newElement);
2791
+ this._restoreDescendantKeepables(step);
2792
+ this._welcomeElement(step.newElement, step);
2793
+ this._finalizeDescendantKeepables(step);
2739
2794
  }, beforeDetach: () => {
2740
2795
  up.script.clean(step.oldElement, { layer: step.layer });
2741
2796
  }, afterDetach() {
@@ -2762,90 +2817,64 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
2762
2817
  let wrapper = e.wrapChildren(step.newElement);
2763
2818
  let position = step.placement === 'before' ? 'afterbegin' : 'beforeend';
2764
2819
  step.oldElement.insertAdjacentElement(position, wrapper);
2765
- this.responseDoc.finalizeElement(wrapper);
2766
- up.hello(wrapper, step);
2767
- this._addToResult(wrapper);
2820
+ this._welcomeElement(wrapper, step);
2768
2821
  this._handleFocus(wrapper, step);
2769
2822
  this._handleScroll(wrapper, step);
2770
- return up.animate(wrapper, step.transition, step).then(() => e.unwrap(wrapper));
2823
+ return up.animate(wrapper, step.animation, step).then(() => e.unwrap(wrapper));
2771
2824
  }
2772
2825
  default: {
2773
2826
  up.fail('Unknown placement: %o', step.placement);
2774
2827
  }
2775
2828
  }
2776
2829
  }
2777
- _findKeepPlan(options) {
2778
- if (!options.keep) {
2779
- return;
2780
- }
2781
- const { oldElement, newElement } = options;
2782
- let doKeep = e.booleanAttr(oldElement, 'up-keep');
2783
- if (!doKeep) {
2784
- return;
2785
- }
2786
- let partner;
2787
- let partnerSelector = up.fragment.toTarget(oldElement);
2788
- const lookupOpts = { layer: options.layer };
2789
- if (options.descendantsOnly) {
2790
- partner = up.fragment.get(newElement, partnerSelector, lookupOpts);
2791
- }
2792
- else {
2793
- partner = e.subtreeFirst(newElement, partnerSelector, lookupOpts);
2794
- }
2795
- if (partner && e.booleanAttr(partner, 'up-keep') !== false) {
2796
- const plan = {
2797
- oldElement,
2798
- newElement: partner,
2799
- newData: up.script.data(partner),
2800
- renderOptions: options,
2801
- };
2802
- if (!up.fragment.emitKeep(plan).defaultPrevented) {
2803
- return plan;
2804
- }
2805
- }
2830
+ _welcomeElement(element, step) {
2831
+ this.responseDoc.finalizeElement(element);
2832
+ this.setReloadAttrs(step);
2833
+ up.hello(element, step);
2834
+ this._addToResult(element);
2806
2835
  }
2807
- _preserveKeepables(step) {
2808
- const keepPlans = [];
2836
+ _preserveDescendantKeepables(step) {
2837
+ const descendantKeepPlans = [];
2809
2838
  if (step.keep) {
2810
2839
  for (let keepable of step.oldElement.querySelectorAll('[up-keep]')) {
2811
- let keepPlan = this._findKeepPlan(Object.assign(Object.assign({}, step), { oldElement: keepable, descendantsOnly: true }));
2840
+ let keepPlan = up.fragment.keepPlan(Object.assign(Object.assign({}, step), { oldElement: keepable, descendantsOnly: true }));
2812
2841
  if (keepPlan) {
2813
2842
  const keepableClone = keepable.cloneNode(true);
2814
2843
  keepable.insertAdjacentElement('beforebegin', keepableClone);
2815
2844
  keepable.classList.add('up-keeping');
2816
2845
  up.script.disableSubtree(keepPlan.newElement);
2817
2846
  let viewports = up.viewport.subtree(keepPlan.oldElement);
2818
- keepPlan.revivers = viewports.map(function (viewport) {
2847
+ keepPlan.revivers = u.map(viewports, function (viewport) {
2819
2848
  let cursorProps = up.viewport.copyCursorProps(viewport);
2820
2849
  return () => up.viewport.copyCursorProps(cursorProps, viewport);
2821
2850
  });
2822
- if (this._willChangeElement(document.body)) {
2851
+ if (this._willChangeBody()) {
2823
2852
  keepPlan.newElement.replaceWith(keepable);
2824
2853
  }
2825
2854
  else {
2826
2855
  document.body.append(keepable);
2827
2856
  }
2828
- keepPlans.push(keepPlan);
2857
+ descendantKeepPlans.push(keepPlan);
2829
2858
  }
2830
2859
  }
2831
2860
  }
2832
- step.keepPlans = keepPlans;
2861
+ step.descendantKeepPlans = descendantKeepPlans;
2833
2862
  }
2834
- _restoreKeepables(step) {
2835
- for (let keepPlan of step.keepPlans) {
2863
+ _restoreDescendantKeepables(step) {
2864
+ for (let keepPlan of step.descendantKeepPlans) {
2836
2865
  keepPlan.newElement.replaceWith(keepPlan.oldElement);
2837
2866
  for (let reviver of keepPlan.revivers) {
2838
2867
  reviver();
2839
2868
  }
2840
2869
  }
2841
2870
  }
2842
- _unmarkKeepables(step) {
2843
- for (let keepPlan of step.keepPlans) {
2871
+ _finalizeDescendantKeepables(step) {
2872
+ for (let keepPlan of step.descendantKeepPlans) {
2844
2873
  keepPlan.oldElement.classList.remove('up-keeping');
2845
2874
  }
2846
2875
  }
2847
- _willChangeElement(element) {
2848
- return u.some(this._steps, (step) => step.oldElement.contains(element));
2876
+ _willChangeBody() {
2877
+ return u.some(this._steps, (step) => step.oldElement.matches('body'));
2849
2878
  }
2850
2879
  _handleFocus(fragment, options) {
2851
2880
  const fragmentFocus = new up.FragmentFocus(Object.assign(Object.assign({}, options), { fragment, autoMeans: up.fragment.config.autoFocus }));
@@ -2859,7 +2888,7 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
2859
2888
 
2860
2889
 
2861
2890
  /***/ }),
2862
- /* 30 */
2891
+ /* 31 */
2863
2892
  /***/ (() => {
2864
2893
 
2865
2894
  const u = up.util;
@@ -2939,7 +2968,7 @@ up.Change.CloseLayer = class CloseLayer extends up.Change {
2939
2968
 
2940
2969
 
2941
2970
  /***/ }),
2942
- /* 31 */
2971
+ /* 32 */
2943
2972
  /***/ (function() {
2944
2973
 
2945
2974
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -2969,7 +2998,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2969
2998
  return request;
2970
2999
  (_e = (_d = this.options).handleAbort) === null || _e === void 0 ? void 0 : _e.call(_d, request);
2971
3000
  request.runPreviews(this.options);
2972
- return yield u.always(request, responseOrError => this._onRequestSettled(responseOrError));
3001
+ return yield u.always(request, (responseOrError) => this._onRequestSettled(responseOrError));
2973
3002
  });
2974
3003
  }
2975
3004
  _newPageReason() {
@@ -3024,7 +3053,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
3024
3053
 
3025
3054
 
3026
3055
  /***/ }),
3027
- /* 32 */
3056
+ /* 33 */
3028
3057
  /***/ (function() {
3029
3058
 
3030
3059
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -3064,7 +3093,7 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
3064
3093
  this.options.failTarget = ':none';
3065
3094
  }
3066
3095
  _updateContentFromResponse(finalRenderOptions) {
3067
- if (finalRenderOptions.failPrefixForced) {
3096
+ if (finalRenderOptions.didForceFailOptions) {
3068
3097
  up.puts('up.render()', 'Rendering failed response using fail-prefixed options (https://unpoly.com/failed-responses)');
3069
3098
  }
3070
3099
  this._augmentOptionsFromResponse(finalRenderOptions);
@@ -3140,6 +3169,11 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
3140
3169
  renderOptions.source = this.improveHistoryValue(renderOptions.source, 'keep');
3141
3170
  renderOptions.history = !!renderOptions.location;
3142
3171
  }
3172
+ let openLayerOptions = this._response.openLayer;
3173
+ if (openLayerOptions) {
3174
+ Object.assign(renderOptions, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, up.Layer.Overlay.UNSET_VISUALS), { target: undefined }), up.fragment.config.navigateOptions), openLayerOptions), { layer: 'new' }));
3175
+ Object.assign(renderOptions, openLayerOptions);
3176
+ }
3143
3177
  renderOptions.location = this.improveHistoryValue(renderOptions.location, serverLocation);
3144
3178
  renderOptions.title = this.improveHistoryValue(renderOptions.title, this._response.title);
3145
3179
  renderOptions.eventPlans = this._response.eventPlans;
@@ -3154,7 +3188,7 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
3154
3188
  renderOptions.target = ':none';
3155
3189
  }
3156
3190
  renderOptions.context = u.merge(renderOptions.context, this._response.context);
3157
- renderOptions.cspNonces = this._response.cspNonces;
3191
+ renderOptions.cspInfo = this._response.cspInfo;
3158
3192
  (_b = renderOptions.time) !== null && _b !== void 0 ? _b : (renderOptions.time = this._response.lastModified);
3159
3193
  (_c = renderOptions.etag) !== null && _c !== void 0 ? _c : (renderOptions.etag = this._response.etag);
3160
3194
  }
@@ -3168,7 +3202,7 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
3168
3202
 
3169
3203
 
3170
3204
  /***/ }),
3171
- /* 33 */
3205
+ /* 34 */
3172
3206
  /***/ (() => {
3173
3207
 
3174
3208
  var _a;
@@ -3213,9 +3247,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3213
3247
  return this._seekPlan(this._executePlan.bind(this)) || this._cannotMatchPostflightTarget();
3214
3248
  }
3215
3249
  _executePlan(matchedPlan) {
3216
- let result = matchedPlan.execute(this._getResponseDoc(), this._onPlanApplicable.bind(this, matchedPlan));
3217
- result.options = this.options;
3218
- return result;
3250
+ return matchedPlan.execute(this._getResponseDoc(), this._onPlanApplicable.bind(this, matchedPlan));
3219
3251
  }
3220
3252
  _isApplicablePlanError(error) {
3221
3253
  return !(error instanceof up.CannotMatch);
@@ -3242,7 +3274,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3242
3274
  'fragment',
3243
3275
  'document',
3244
3276
  'html',
3245
- 'cspNonces',
3277
+ 'cspInfo',
3246
3278
  'origin',
3247
3279
  'data',
3248
3280
  ]);
@@ -3274,7 +3306,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3274
3306
  return this._expandTargets(target || ':main', layer)[0];
3275
3307
  }
3276
3308
  getPreflightProps(opts = {}) {
3277
- const getPlanProps = plan => plan.getPreflightProps();
3309
+ const getPlanProps = (plan) => plan.getPreflightProps();
3278
3310
  return this._seekPlan(getPlanProps) || opts.optional || this._cannotMatchPreflightTarget();
3279
3311
  }
3280
3312
  _cannotMatchPreflightTarget() {
@@ -3292,7 +3324,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3292
3324
  else if (this._layers.length === 0) {
3293
3325
  this._cannotMatchLayer();
3294
3326
  }
3295
- else if (this.options.failPrefixForced) {
3327
+ else if (this.options.didForceFailOptions) {
3296
3328
  throw new up.CannotMatch('No target selector given for failed responses (https://unpoly.com/failed-responses)');
3297
3329
  }
3298
3330
  else {
@@ -3326,7 +3358,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3326
3358
 
3327
3359
 
3328
3360
  /***/ }),
3329
- /* 34 */
3361
+ /* 35 */
3330
3362
  /***/ (() => {
3331
3363
 
3332
3364
  const u = up.util;
@@ -3422,7 +3454,7 @@ up.CompilerPass = class CompilerPass {
3422
3454
 
3423
3455
 
3424
3456
  /***/ }),
3425
- /* 35 */
3457
+ /* 36 */
3426
3458
  /***/ (() => {
3427
3459
 
3428
3460
  const u = up.util;
@@ -3529,7 +3561,7 @@ up.CSSTransition = class CSSTransition {
3529
3561
 
3530
3562
 
3531
3563
  /***/ }),
3532
- /* 36 */
3564
+ /* 37 */
3533
3565
  /***/ (() => {
3534
3566
 
3535
3567
  const u = up.util;
@@ -3552,7 +3584,7 @@ up.DestructorPass = class DestructorPass {
3552
3584
 
3553
3585
 
3554
3586
  /***/ }),
3555
- /* 37 */
3587
+ /* 38 */
3556
3588
  /***/ (() => {
3557
3589
 
3558
3590
  const u = up.util;
@@ -3652,7 +3684,7 @@ up.EventEmitter = class EventEmitter extends up.Record {
3652
3684
 
3653
3685
 
3654
3686
  /***/ }),
3655
- /* 38 */
3687
+ /* 39 */
3656
3688
  /***/ (() => {
3657
3689
 
3658
3690
  const u = up.util;
@@ -3705,7 +3737,8 @@ up.EventListener = class EventListener extends up.Record {
3705
3737
  }
3706
3738
  let element = event.target;
3707
3739
  if (this.selector) {
3708
- element = element.closest(u.evalOption(this.selector));
3740
+ let selector = u.evalOption(this.selector);
3741
+ element = element.closest(selector);
3709
3742
  }
3710
3743
  if (this.guard && !this.guard(event)) {
3711
3744
  return;
@@ -3759,7 +3792,7 @@ up.EventListener = class EventListener extends up.Record {
3759
3792
 
3760
3793
 
3761
3794
  /***/ }),
3762
- /* 39 */
3795
+ /* 40 */
3763
3796
  /***/ (() => {
3764
3797
 
3765
3798
  const u = up.util;
@@ -3805,7 +3838,7 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
3805
3838
  }
3806
3839
  });
3807
3840
  }
3808
- static fromBindArgs(args, defaults) {
3841
+ static fromBindArgs(args, overrides) {
3809
3842
  args = u.copy(args);
3810
3843
  const callback = args.pop();
3811
3844
  let elements;
@@ -3825,14 +3858,64 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
3825
3858
  }
3826
3859
  const options = u.extractOptions(args);
3827
3860
  const selector = args[0];
3828
- const attributes = Object.assign(Object.assign({ elements, eventTypes, selector, callback }, options), defaults);
3861
+ const attributes = Object.assign(Object.assign({ elements, eventTypes, selector, callback }, options), overrides);
3829
3862
  return new (this)(attributes);
3830
3863
  }
3831
3864
  };
3832
3865
 
3833
3866
 
3834
3867
  /***/ }),
3835
- /* 40 */
3868
+ /* 41 */
3869
+ /***/ (() => {
3870
+
3871
+ const u = up.util;
3872
+ up.SelectorTracker = class SelectorTracker {
3873
+ constructor(selector, options, addCallback) {
3874
+ var _a;
3875
+ this._selector = selector;
3876
+ this._addCallback = addCallback;
3877
+ this._layer = options.layer || 'any';
3878
+ this._filter = options.filter || u.identity;
3879
+ this._live = (_a = options.live) !== null && _a !== void 0 ? _a : true;
3880
+ this._knownMatches = new Map();
3881
+ }
3882
+ start() {
3883
+ this._sync();
3884
+ return u.sequence(this._trackFragments(), () => this._removeAllMatches());
3885
+ }
3886
+ _trackFragments() {
3887
+ if (this._live) {
3888
+ return up.on('up:fragment:inserted up:fragment:destroyed', () => this._sync());
3889
+ }
3890
+ }
3891
+ _sync() {
3892
+ let removeMap = new Map(this._knownMatches);
3893
+ this._knownMatches.clear();
3894
+ for (let newMatch of this._currentMatches) {
3895
+ let knownRemoveCallback = removeMap.get(newMatch);
3896
+ removeMap.delete(newMatch);
3897
+ let removeCallback = knownRemoveCallback || this._addCallback(newMatch) || u.noop;
3898
+ this._knownMatches.set(newMatch, removeCallback);
3899
+ }
3900
+ this._runRemoveCallbacks(removeMap);
3901
+ }
3902
+ get _currentMatches() {
3903
+ let allMatches = up.fragment.all(this._selector, { layer: this._layer });
3904
+ return this._filter(allMatches);
3905
+ }
3906
+ _removeAllMatches() {
3907
+ this._runRemoveCallbacks(this._knownMatches);
3908
+ }
3909
+ _runRemoveCallbacks(map) {
3910
+ for (let [element, removeCallback] of map) {
3911
+ removeCallback(element);
3912
+ }
3913
+ }
3914
+ };
3915
+
3916
+
3917
+ /***/ }),
3918
+ /* 42 */
3836
3919
  /***/ (function() {
3837
3920
 
3838
3921
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -3847,42 +3930,52 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
3847
3930
  const u = up.util;
3848
3931
  up.FieldWatcher = class FieldWatcher {
3849
3932
  constructor(root, options, callback) {
3933
+ var _a;
3850
3934
  this._options = options;
3851
3935
  this._root = root;
3852
- this._scope = up.form.getScope(root);
3853
3936
  this._callback = callback;
3854
3937
  this._batch = options.batch;
3938
+ this._logPrefix = (_a = options.logPrefix) !== null && _a !== void 0 ? _a : 'up.watch()';
3939
+ this._ensureWatchable();
3855
3940
  }
3856
3941
  start() {
3857
3942
  this._scheduledValues = null;
3858
3943
  this._processedValues = this._readFieldValues();
3859
3944
  this._currentTimer = null;
3860
3945
  this._callbackRunning = false;
3861
- this._cleaner = u.cleaner();
3862
- this._watchFieldsWithin(this._root);
3863
- this._root.addEventListener('up:fragment:inserted', ({ target }) => {
3864
- if (target !== this._root)
3865
- this._watchFieldsWithin(target);
3866
- });
3867
- this._cleaner(up.fragment.onAborted(this._scope, () => this._abort()));
3868
- this._cleaner(up.on(this._scope, 'reset', () => this._onFormReset()));
3946
+ return u.sequence(up.form.trackFields(this._root, (field) => this._watchField(field)), this._trackAbort(), this._trackReset(), () => this._abort());
3869
3947
  }
3870
- stop() {
3871
- this._abort();
3872
- this._cleaner.clean();
3948
+ _ensureWatchable() {
3949
+ const fail = (message) => up.fail(message, this._logPrefix, this._root);
3950
+ if (!this._callback) {
3951
+ fail('No callback provided for %s (%o)');
3952
+ }
3953
+ if (this._root.matches('input[type=radio]')) {
3954
+ fail('Use %s with the container of a radio group, not with an individual radio button (%o)');
3955
+ }
3956
+ if (up.form.isField(this._root) && !this._root.name) {
3957
+ fail('%s can only watch fields with a name (%o)');
3958
+ }
3959
+ }
3960
+ _trackAbort() {
3961
+ let guard = ({ target }) => target.contains(this._region);
3962
+ return up.on('up:fragment:aborted', { guard }, () => this._abort());
3963
+ }
3964
+ _trackReset() {
3965
+ let guard = ({ target }) => target === this._region;
3966
+ return up.on('reset', { guard }, (event) => this._onFormReset(event));
3967
+ }
3968
+ get _region() {
3969
+ return up.form.getRegion(this._root);
3873
3970
  }
3874
3971
  _fieldOptions(field) {
3875
3972
  let rootOptions = u.copy(this._options);
3876
3973
  return up.form.watchOptions(field, rootOptions, { defaults: { event: 'input' } });
3877
3974
  }
3878
- _watchFieldsWithin(container) {
3879
- for (let field of up.form.fields(container)) {
3880
- this._watchField(field);
3881
- }
3882
- }
3883
3975
  _watchField(field) {
3884
3976
  let fieldOptions = this._fieldOptions(field);
3885
- this._cleaner(up.on(field, fieldOptions.event, () => this._check(fieldOptions)));
3977
+ let eventType = fieldOptions.event;
3978
+ return up.on(field, eventType, (event) => this._check(event, fieldOptions));
3886
3979
  }
3887
3980
  _abort() {
3888
3981
  this._scheduledValues = null;
@@ -3908,7 +4001,7 @@ up.FieldWatcher = class FieldWatcher {
3908
4001
  return;
3909
4002
  if (this._currentTimer)
3910
4003
  return;
3911
- if (!this._scope.isConnected)
4004
+ if (!up.fragment.isAlive(this._region))
3912
4005
  return;
3913
4006
  let callbackOptions = u.omit(this._scheduledFieldOptions, ['event', 'delay']);
3914
4007
  const diff = this._changedValues(this._processedValues, this._scheduledValues);
@@ -3954,20 +4047,116 @@ up.FieldWatcher = class FieldWatcher {
3954
4047
  _readFieldValues() {
3955
4048
  return up.Params.fromContainer(this._root).toObject();
3956
4049
  }
3957
- _check(fieldOptions = {}) {
4050
+ _check(event, fieldOptions = {}) {
3958
4051
  const values = this._readFieldValues();
3959
4052
  if (this._isNewValues(values)) {
4053
+ up.log.putsEvent(event);
3960
4054
  this._scheduleValues(values, fieldOptions);
3961
4055
  }
3962
4056
  }
3963
- _onFormReset() {
3964
- u.task(() => this._check());
4057
+ _onFormReset(event) {
4058
+ u.task(() => this._check(event));
3965
4059
  }
3966
4060
  };
3967
4061
 
3968
4062
 
3969
4063
  /***/ }),
3970
- /* 41 */
4064
+ /* 43 */
4065
+ /***/ (() => {
4066
+
4067
+ const u = up.util;
4068
+ const e = up.element;
4069
+ const BUILTIN_SWITCH_EFFECTS = [
4070
+ { attr: 'up-hide-for', toggle(target, active) { e.toggle(target, !active); } },
4071
+ { attr: 'up-show-for', toggle(target, active) { e.toggle(target, active); } },
4072
+ { attr: 'up-disable-for', toggle(target, active) { up.form.setDisabled(target, active); } },
4073
+ { attr: 'up-enable-for', toggle(target, active) { up.form.setDisabled(target, !active); } },
4074
+ ];
4075
+ up.Switcher = class Switcher {
4076
+ constructor(root) {
4077
+ this._root = root;
4078
+ this._switcheeSelector = root.getAttribute('up-switch') || up.fail("No switch target given for %o", root);
4079
+ this._regionSelector = root.getAttribute('up-switch-region');
4080
+ }
4081
+ start() {
4082
+ this._switchRegion();
4083
+ return u.sequence(this._trackFieldChanges(), this._trackNewSwitchees());
4084
+ }
4085
+ _trackFieldChanges() {
4086
+ var _a, _b;
4087
+ let callback = () => this._onFieldChanged();
4088
+ return ((_b = (_a = up.migrate).watchForSwitch) === null || _b === void 0 ? void 0 : _b.call(_a, this._root, callback))
4089
+ || up.watch(this._root, { logPrefix: '[up-switch]' }, callback);
4090
+ }
4091
+ _trackNewSwitchees() {
4092
+ let filter = (matches) => {
4093
+ let scope = this._scope;
4094
+ return u.filter(matches, (match) => scope === null || scope === void 0 ? void 0 : scope.contains(match));
4095
+ };
4096
+ let onSwitcheeAdded = (switchee) => this._switchSwitchee(switchee);
4097
+ return up.fragment.trackSelector(this._switcheeSelector, { filter }, onSwitcheeAdded);
4098
+ }
4099
+ _onFieldChanged() {
4100
+ this._switchRegion();
4101
+ }
4102
+ _switchRegion() {
4103
+ const fieldTokens = this._buildFieldTokens();
4104
+ for (let switchee of this._findSwitchees()) {
4105
+ this._switchSwitchee(switchee, fieldTokens);
4106
+ }
4107
+ }
4108
+ _switchSwitchee(switchee, fieldTokens = this._buildFieldTokens()) {
4109
+ let previousValues = switchee.upSwitchValues;
4110
+ if (!u.isEqual(previousValues, fieldTokens)) {
4111
+ switchee.upSwitchValues = fieldTokens;
4112
+ this._switchSwitcheeNow(switchee, fieldTokens);
4113
+ }
4114
+ }
4115
+ _switchSwitcheeNow(switchee, fieldTokens) {
4116
+ for (let { attr, toggle } of BUILTIN_SWITCH_EFFECTS) {
4117
+ let attrValue = switchee.getAttribute(attr);
4118
+ if (attrValue) {
4119
+ let activeTokens = this._parseSwitcheeTokens(attrValue);
4120
+ let isActive = u.intersect(fieldTokens, activeTokens).length > 0;
4121
+ toggle(switchee, isActive);
4122
+ }
4123
+ }
4124
+ let log = ['Switching %o', switchee];
4125
+ up.emit(switchee, 'up:form:switch', { field: this._root, fieldTokens, log });
4126
+ }
4127
+ _findSwitchees() {
4128
+ let scope = this._scope;
4129
+ return scope ? up.fragment.subtree(scope, this._switcheeSelector) : [];
4130
+ }
4131
+ get _scope() {
4132
+ if (this._regionSelector) {
4133
+ return up.fragment.get(this._regionSelector, { origin: this._root });
4134
+ }
4135
+ else {
4136
+ return up.form.getRegion(this._root);
4137
+ }
4138
+ }
4139
+ _parseSwitcheeTokens(str) {
4140
+ return u.getSimpleTokens(str, { json: true });
4141
+ }
4142
+ _buildFieldTokens() {
4143
+ var _a;
4144
+ let values = up.Params.fromContainer(this._root).values();
4145
+ let tokens = [...values];
4146
+ let anyPresent = u.some(values, u.isPresent);
4147
+ tokens.push(anyPresent ? ':present' : ':blank');
4148
+ let fields = up.form.fields(this._root);
4149
+ if ((_a = fields[0]) === null || _a === void 0 ? void 0 : _a.matches('[type=radio], [type=checkbox]')) {
4150
+ let anyChecked = u.some(fields, 'checked');
4151
+ tokens.push(anyChecked ? ':checked' : ':unchecked');
4152
+ }
4153
+ return tokens;
4154
+ }
4155
+ };
4156
+
4157
+
4158
+ /***/ }),
4159
+ /* 44 */
3971
4160
  /***/ (function() {
3972
4161
 
3973
4162
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -3998,41 +4187,52 @@ up.FormValidator = class FormValidator {
3998
4187
  this._dirtySolutions = [];
3999
4188
  this._nextRenderTimer = null;
4000
4189
  this._rendering = false;
4001
- this._resetNextRenderPromise();
4002
4190
  this._honorAbort();
4003
4191
  }
4192
+ start() {
4193
+ let guard = (field) => this._isValidatingField(field);
4194
+ let callback = (field) => this._onFieldAdded(field);
4195
+ return up.form.trackFields(this._form, { guard }, callback);
4196
+ }
4197
+ _isValidatingField(field) {
4198
+ return field.closest('[up-validate]:not([up-validate=false])');
4199
+ }
4200
+ _onFieldAdded(field) {
4201
+ let eventType = up.form.validateOptions(field).event;
4202
+ return up.on(field, eventType, (event) => {
4203
+ up.log.putsEvent(event);
4204
+ up.error.muteUncriticalRejection(this.validate({ origin: field }));
4205
+ });
4206
+ }
4004
4207
  _honorAbort() {
4005
4208
  up.fragment.onAborted(this._form, (event) => this._onAborted(event));
4006
4209
  }
4007
4210
  _onAborted(event) {
4008
- if (this._dirtySolutions.length) {
4009
- this._dirtySolutions = [];
4010
- this._nextRenderPromise.reject(new up.Aborted(event.reason));
4011
- this._resetNextRenderPromise();
4211
+ let abortedError = new up.Aborted(event.reason);
4212
+ let solution;
4213
+ while (solution = this._dirtySolutions.shift()) {
4214
+ solution.deferred.reject(abortedError);
4012
4215
  }
4013
4216
  }
4014
- _resetNextRenderPromise() {
4015
- this._nextRenderPromise = u.newDeferred();
4016
- }
4017
- watchContainer(fieldOrForm) {
4018
- let { event } = this._originOptions(fieldOrForm);
4019
- let guard = () => up.fragment.isAlive(fieldOrForm);
4020
- let callback = () => up.error.muteUncriticalRejection(this.validate({ origin: fieldOrForm }));
4021
- up.on(fieldOrForm, event, { guard }, callback);
4022
- }
4023
4217
  validate(options = {}) {
4024
- let solutions = this._getSolutions(options);
4025
- this._dirtySolutions.push(...solutions);
4218
+ var _a;
4219
+ let newSolutions = this._getSolutions(options);
4220
+ this._dirtySolutions.push(...newSolutions);
4026
4221
  this._scheduleNextRender();
4027
- return this._nextRenderPromise;
4222
+ return (_a = newSolutions[0]) === null || _a === void 0 ? void 0 : _a.deferred;
4028
4223
  }
4029
4224
  _getSolutions(options) {
4030
4225
  let solutions = this._getTargetSelectorSolutions(options)
4031
4226
  || this._getFieldSolutions(options)
4032
4227
  || this._getElementSolutions(options.origin);
4228
+ let deferred = u.newDeferred();
4033
4229
  for (let solution of solutions) {
4034
- solution.renderOptions = this._originOptions(solution.origin, options);
4230
+ let renderOptions = up.form.validateOptions(solution.origin, options);
4231
+ solution.batch = u.pluckKey(renderOptions, 'batch');
4232
+ solution.renderOptions = renderOptions;
4233
+ solution.destination = `${renderOptions.method} ${renderOptions.url}`;
4035
4234
  solution.target = up.fragment.resolveOrigin(solution.target, solution);
4235
+ solution.deferred = deferred;
4036
4236
  }
4037
4237
  return solutions;
4038
4238
  }
@@ -4085,9 +4285,6 @@ up.FormValidator = class FormValidator {
4085
4285
  return this._getTargetSelectorSolutions({ target, origin: field });
4086
4286
  }
4087
4287
  }
4088
- _originOptions(element, overrideOptions) {
4089
- return up.form.watchOptions(element, overrideOptions, { defaults: { event: 'change' } });
4090
- }
4091
4288
  _scheduleNextRender() {
4092
4289
  let solutionDelays = this._dirtySolutions.map((solution) => solution.renderOptions.delay);
4093
4290
  let shortestDelay = Math.min(...solutionDelays) || 0;
@@ -4108,14 +4305,15 @@ up.FormValidator = class FormValidator {
4108
4305
  return;
4109
4306
  if (this._nextRenderTimer)
4110
4307
  return;
4111
- let options = this._mergeRenderOptions(this._dirtySolutions);
4112
- this._dirtySolutions = [];
4308
+ let solutionsBatch = this._selectDirtySolutionsBatch();
4309
+ let renderOptions = this._mergeRenderOptions(solutionsBatch);
4113
4310
  this._rendering = true;
4114
- let renderingPromise = this._nextRenderPromise;
4115
- this._resetNextRenderPromise();
4116
4311
  try {
4117
- renderingPromise.resolve(up.render(options));
4118
- yield renderingPromise;
4312
+ let renderPromise = up.render(renderOptions);
4313
+ for (let solution of solutionsBatch) {
4314
+ solution.deferred.resolve(renderPromise);
4315
+ }
4316
+ yield renderPromise;
4119
4317
  }
4120
4318
  finally {
4121
4319
  this._rendering = false;
@@ -4123,20 +4321,39 @@ up.FormValidator = class FormValidator {
4123
4321
  }
4124
4322
  });
4125
4323
  }
4324
+ _selectDirtySolutionsBatch() {
4325
+ let batch = [];
4326
+ let i = 0;
4327
+ while (i < this._dirtySolutions.length) {
4328
+ let solution = this._dirtySolutions[i];
4329
+ if (batch.length === 0 || this._canBatchSolutions(batch[0], solution)) {
4330
+ batch.push(solution);
4331
+ this._dirtySolutions.splice(i, 1);
4332
+ }
4333
+ else {
4334
+ i++;
4335
+ }
4336
+ }
4337
+ return batch;
4338
+ }
4339
+ _canBatchSolutions(s1, s2) {
4340
+ return s1.destination === s2.destination && s1.batch && s2.batch;
4341
+ }
4126
4342
  _mergeRenderOptions(dirtySolutions) {
4127
4343
  var _a;
4128
4344
  let dirtyOrigins = u.map(dirtySolutions, 'origin');
4129
4345
  let dirtyFields = u.flatMap(dirtyOrigins, up.form.fields);
4130
4346
  let dirtyNames = u.uniq(u.map(dirtyFields, 'name'));
4131
4347
  let dirtyRenderOptionsList = u.map(dirtySolutions, 'renderOptions');
4132
- let options = u.mergeDefined(...dirtyRenderOptionsList, up.form.destinationOptions(this._form));
4348
+ let formDestinationOptions = up.form.destinationOptions(this._form);
4349
+ let options = u.mergeDefined(formDestinationOptions, ...dirtyRenderOptionsList);
4133
4350
  options.target = u.map(dirtySolutions, 'target').join(', ');
4134
4351
  options.origin = this._form;
4135
4352
  (_a = options.focus) !== null && _a !== void 0 ? _a : (options.focus = 'keep');
4136
4353
  options.failOptions = false;
4137
4354
  options.defaultMaybe = true;
4138
- options.params = up.Params.merge(options.params, ...u.map(dirtyRenderOptionsList, 'params'));
4139
- options.headers = u.merge(options.headers, ...u.map(dirtyRenderOptionsList, 'headers'));
4355
+ options.params = up.Params.merge(formDestinationOptions.params, ...u.map(dirtyRenderOptionsList, 'params'));
4356
+ options.headers = u.merge(formDestinationOptions.headers, ...u.map(dirtyRenderOptionsList, 'headers'));
4140
4357
  this._addValidateHeader(options.headers, dirtyNames);
4141
4358
  options.feedback = u.some(dirtyRenderOptionsList, 'feedback');
4142
4359
  options.data = undefined;
@@ -4164,15 +4381,11 @@ up.FormValidator = class FormValidator {
4164
4381
  value = ':unknown';
4165
4382
  headers[key] = value;
4166
4383
  }
4167
- static forElement(element) {
4168
- let form = up.form.get(element);
4169
- return form.upFormValidator || (form.upFormValidator = new this(form));
4170
- }
4171
4384
  };
4172
4385
 
4173
4386
 
4174
4387
  /***/ }),
4175
- /* 42 */
4388
+ /* 45 */
4176
4389
  /***/ (() => {
4177
4390
 
4178
4391
  up.FocusCapsule = class FocusCapsule {
@@ -4211,7 +4424,7 @@ up.FocusCapsule = class FocusCapsule {
4211
4424
 
4212
4425
 
4213
4426
  /***/ }),
4214
- /* 43 */
4427
+ /* 46 */
4215
4428
  /***/ (() => {
4216
4429
 
4217
4430
  const u = up.util;
@@ -4254,7 +4467,7 @@ up.FragmentProcessor = class FragmentProcessor extends up.Record {
4254
4467
  return this.processPrimitive(opt);
4255
4468
  }
4256
4469
  processArray(array) {
4257
- return u.find(array, opt => this.tryProcess(opt));
4470
+ return u.find(array, (opt) => this.tryProcess(opt));
4258
4471
  }
4259
4472
  resolveCondition(condition) {
4260
4473
  if (condition === 'main') {
@@ -4276,7 +4489,7 @@ up.FragmentProcessor = class FragmentProcessor extends up.Record {
4276
4489
 
4277
4490
 
4278
4491
  /***/ }),
4279
- /* 44 */
4492
+ /* 47 */
4280
4493
  /***/ (() => {
4281
4494
 
4282
4495
  const u = up.util;
@@ -4327,7 +4540,7 @@ up.FragmentFinder = class FragmentFinder {
4327
4540
 
4328
4541
 
4329
4542
  /***/ }),
4330
- /* 45 */
4543
+ /* 48 */
4331
4544
  /***/ (() => {
4332
4545
 
4333
4546
  const u = up.util;
@@ -4337,6 +4550,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
4337
4550
  keys() {
4338
4551
  return super.keys().concat([
4339
4552
  'hash',
4553
+ 'focusVisible',
4340
4554
  'focusCapsule',
4341
4555
  'inputDevice',
4342
4556
  ]);
@@ -4394,7 +4608,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
4394
4608
  }
4395
4609
  _focusElement(element) {
4396
4610
  if (element) {
4397
- up.focus(element, Object.assign(Object.assign({ force: true }, PREVENT_SCROLL_OPTIONS), { inputDevice: this.inputDevice }));
4611
+ up.focus(element, Object.assign(Object.assign({ force: true }, PREVENT_SCROLL_OPTIONS), { inputDevice: this.inputDevice, focusVisible: this.focusVisible }));
4398
4612
  return true;
4399
4613
  }
4400
4614
  }
@@ -4412,7 +4626,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
4412
4626
 
4413
4627
 
4414
4628
  /***/ }),
4415
- /* 46 */
4629
+ /* 49 */
4416
4630
  /***/ (() => {
4417
4631
 
4418
4632
  const e = up.element;
@@ -4453,7 +4667,7 @@ up.FragmentPolling = class FragmentPolling {
4453
4667
  if (this._state === 'started') {
4454
4668
  this._clearReloadTimer();
4455
4669
  this._state = 'stopped';
4456
- (_a = this.unbindEvents) === null || _a === void 0 ? void 0 : _a.call(this);
4670
+ (_a = this._unbindEvents) === null || _a === void 0 ? void 0 : _a.call(this);
4457
4671
  }
4458
4672
  }
4459
4673
  forceStart(options) {
@@ -4466,8 +4680,8 @@ up.FragmentPolling = class FragmentPolling {
4466
4680
  this.forceStarted = false;
4467
4681
  }
4468
4682
  _ensureEventsBound() {
4469
- if (!this.unbindEvents) {
4470
- this.unbindEvents = up.on('visibilitychange up:layer:opened up:layer:dismissed up:layer:accepted', this._onVisibilityChange.bind(this));
4683
+ if (!this._unbindEvents) {
4684
+ this._unbindEvents = up.on('visibilitychange up:layer:opened up:layer:dismissed up:layer:accepted', this._onVisibilityChange.bind(this));
4471
4685
  }
4472
4686
  }
4473
4687
  _onVisibilityChange() {
@@ -4499,6 +4713,11 @@ up.FragmentPolling = class FragmentPolling {
4499
4713
  if (this._state !== 'started') {
4500
4714
  return;
4501
4715
  }
4716
+ if (!up.fragment.isAlive(this._fragment)) {
4717
+ this._stop();
4718
+ up.puts('[up-poll]', 'Stopped polling a detached fragment');
4719
+ return;
4720
+ }
4502
4721
  if (!this._isFragmentVisible()) {
4503
4722
  up.puts('[up-poll]', 'Will not poll hidden fragment');
4504
4723
  return;
@@ -4570,7 +4789,7 @@ up.FragmentPolling = class FragmentPolling {
4570
4789
 
4571
4790
 
4572
4791
  /***/ }),
4573
- /* 47 */
4792
+ /* 50 */
4574
4793
  /***/ (() => {
4575
4794
 
4576
4795
  const u = up.util;
@@ -4587,8 +4806,10 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
4587
4806
  }
4588
4807
  processPrimitive(opt) {
4589
4808
  switch (opt) {
4590
- case 'reset':
4591
- return this._reset();
4809
+ case 'top':
4810
+ return this._scrollTo(0);
4811
+ case 'bottom':
4812
+ return this._scrollTo(99999999);
4592
4813
  case 'layer':
4593
4814
  return this._revealLayer();
4594
4815
  case 'main':
@@ -4623,9 +4844,8 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
4623
4844
  _revealLayer() {
4624
4845
  return this._revealElement(this.layer.getBoxElement());
4625
4846
  }
4626
- _reset() {
4627
- up.viewport.resetScroll(Object.assign(Object.assign({}, this.attributes()), { around: this.fragment }));
4628
- return true;
4847
+ _scrollTo(position) {
4848
+ return up.viewport.scrollTo(position, Object.assign(Object.assign({}, this.attributes()), { around: this.fragment }));
4629
4849
  }
4630
4850
  _restore() {
4631
4851
  return up.viewport.restoreScroll(Object.assign(Object.assign({}, this.attributes()), { around: this.fragment }));
@@ -4634,7 +4854,7 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
4634
4854
 
4635
4855
 
4636
4856
  /***/ }),
4637
- /* 48 */
4857
+ /* 51 */
4638
4858
  /***/ (() => {
4639
4859
 
4640
4860
  const e = up.element;
@@ -4660,14 +4880,16 @@ up.Layer = class Layer extends up.Record {
4660
4880
  }
4661
4881
  constructor(options = {}) {
4662
4882
  super(options);
4663
- if (!this.mode) {
4664
- throw "missing { mode } option";
4665
- }
4883
+ u.assert(this.mode);
4666
4884
  }
4667
4885
  setupHandlers() {
4668
4886
  up.link.convertClicks(this);
4887
+ this._unbindLocationChanged = up.on('up:location:changed', (event) => this._onBrowserLocationChanged(event));
4888
+ }
4889
+ teardownHandlers() {
4890
+ var _a;
4891
+ (_a = this._unbindLocationChanged) === null || _a === void 0 ? void 0 : _a.call(this);
4669
4892
  }
4670
- teardownHandlers() { }
4671
4893
  mainTargets() {
4672
4894
  return up.layer.mainTargets(this.mode);
4673
4895
  }
@@ -4767,28 +4989,28 @@ up.Layer = class Layer extends up.Record {
4767
4989
  return !this.element.isConnected;
4768
4990
  }
4769
4991
  saveHistory() {
4770
- if (this.history) {
4771
- this.savedTitle = document.title;
4772
- this.savedMetaTags = up.history.findMetaTags();
4773
- this.savedLocation = up.history.location;
4774
- this.savedLang = up.history.getLang();
4775
- }
4992
+ u.assert(this.isFront());
4993
+ if (!this.showsLiveHistory())
4994
+ return;
4995
+ this._savedTitle = this.title;
4996
+ this._savedMetaTags = this.metaTags;
4997
+ this._savedLocation = this.location;
4998
+ this._savedLang = this.lang;
4776
4999
  }
4777
5000
  restoreHistory() {
4778
- if (!this.showsLiveHistory()) {
5001
+ if (!this.showsLiveHistory())
4779
5002
  return;
5003
+ if (this._savedLocation) {
5004
+ up.history.push(this._savedLocation);
4780
5005
  }
4781
- if (this.savedLocation) {
4782
- up.history.push(this.savedLocation);
5006
+ if (this._savedTitle) {
5007
+ document.title = this._savedTitle;
4783
5008
  }
4784
- if (this.savedTitle) {
4785
- document.title = this.savedTitle;
5009
+ if (this._savedMetaTags) {
5010
+ up.history.updateMetaTags(this._savedMetaTags);
4786
5011
  }
4787
- if (this.savedMetaTags) {
4788
- up.history.updateMetaTags(this.savedMetaTags);
4789
- }
4790
- if (u.isString(this.savedLang)) {
4791
- up.history.updateLang(this.savedLang);
5012
+ if (u.isString(this._savedLang)) {
5013
+ up.history.updateLang(this._savedLang);
4792
5014
  }
4793
5015
  }
4794
5016
  asCurrent(fn) {
@@ -4797,32 +5019,37 @@ up.Layer = class Layer extends up.Record {
4797
5019
  updateHistory(options) {
4798
5020
  var _a, _b;
4799
5021
  if (u.isString(options.location)) {
4800
- this.location = options.location;
5022
+ this._updateLocation(options.location, { push: true });
4801
5023
  }
4802
5024
  if (up.history.config.updateMetaTags && u.isList(options.metaTags)) {
4803
5025
  (_b = (_a = up.migrate) === null || _a === void 0 ? void 0 : _a.warnOfHungryMetaTags) === null || _b === void 0 ? void 0 : _b.call(_a, options.metaTags);
4804
- this.metaTags = options.metaTags;
5026
+ this._updateMetaTags(options.metaTags);
4805
5027
  }
4806
5028
  if (u.isString(options.title)) {
4807
- this.title = options.title;
5029
+ this._updateTitle(options.title);
4808
5030
  }
4809
5031
  if (u.isString(options.lang)) {
4810
- this.lang = options.lang;
5032
+ this._updateLang(options.lang);
4811
5033
  }
4812
5034
  }
4813
5035
  showsLiveHistory() {
4814
5036
  return this.history && this.isFront();
4815
5037
  }
5038
+ _onBrowserLocationChanged({ location }) {
5039
+ if (this.showsLiveHistory()) {
5040
+ this._updateLocation(location, { push: false });
5041
+ }
5042
+ }
4816
5043
  get title() {
4817
5044
  if (this.showsLiveHistory()) {
4818
5045
  return document.title;
4819
5046
  }
4820
5047
  else {
4821
- return this.savedTitle;
5048
+ return this._savedTitle;
4822
5049
  }
4823
5050
  }
4824
- set title(title) {
4825
- this.savedTitle = title;
5051
+ _updateTitle(title) {
5052
+ this._savedTitle = title;
4826
5053
  if (this.showsLiveHistory()) {
4827
5054
  document.title = title;
4828
5055
  }
@@ -4832,11 +5059,11 @@ up.Layer = class Layer extends up.Record {
4832
5059
  return up.history.findMetaTags();
4833
5060
  }
4834
5061
  else {
4835
- return this.savedMetaTags;
5062
+ return this._savedMetaTags;
4836
5063
  }
4837
5064
  }
4838
- set metaTags(metaTags) {
4839
- this.savedMetaTags = metaTags;
5065
+ _updateMetaTags(metaTags) {
5066
+ this._savedMetaTags = metaTags;
4840
5067
  if (this.showsLiveHistory()) {
4841
5068
  up.history.updateMetaTags(metaTags);
4842
5069
  }
@@ -4846,11 +5073,11 @@ up.Layer = class Layer extends up.Record {
4846
5073
  return up.history.getLang();
4847
5074
  }
4848
5075
  else {
4849
- return this.savedLang;
5076
+ return this._savedLang;
4850
5077
  }
4851
5078
  }
4852
- set lang(lang) {
4853
- this.savedLang = lang;
5079
+ _updateLang(lang) {
5080
+ this._savedLang = lang;
4854
5081
  if (this.showsLiveHistory()) {
4855
5082
  up.history.updateLang(lang);
4856
5083
  }
@@ -4860,20 +5087,18 @@ up.Layer = class Layer extends up.Record {
4860
5087
  return up.history.location;
4861
5088
  }
4862
5089
  else {
4863
- return this.savedLocation;
5090
+ return this._savedLocation;
4864
5091
  }
4865
5092
  }
4866
- set location(location) {
4867
- const previousLocation = this.location;
4868
- location = u.normalizeURL(location);
4869
- if (previousLocation !== location || this.opening) {
4870
- this.savedLocation = location;
4871
- if (this.showsLiveHistory()) {
4872
- up.history.push(location);
4873
- }
4874
- if (!this.opening) {
4875
- this.emit('up:layer:location:changed', { location });
4876
- }
5093
+ _updateLocation(newLocation, { push }) {
5094
+ let prevSavedLocation = this._savedLocation;
5095
+ let liveLocation = up.history.location;
5096
+ this._savedLocation = newLocation;
5097
+ if (newLocation !== liveLocation && this.showsLiveHistory() && push) {
5098
+ up.history.push(newLocation);
5099
+ }
5100
+ if (newLocation !== prevSavedLocation && !this.opening) {
5101
+ this.emit('up:layer:location:changed', { location: newLocation, previousLocation: prevSavedLocation, log: false });
4877
5102
  }
4878
5103
  }
4879
5104
  selector(part) {
@@ -4902,7 +5127,7 @@ up.Layer = class Layer extends up.Record {
4902
5127
 
4903
5128
 
4904
5129
  /***/ }),
4905
- /* 49 */
5130
+ /* 52 */
4906
5131
  /***/ (function() {
4907
5132
 
4908
5133
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -5012,14 +5237,14 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
5012
5237
  }
5013
5238
  if (this._supportsDismissMethod('outside')) {
5014
5239
  if (this.viewportElement) {
5015
- up.on(this.viewportElement, 'up:click', event => {
5240
+ up.on(this.viewportElement, 'up:click', (event) => {
5016
5241
  if (event.target === this.viewportElement) {
5017
5242
  this._onOutsideClicked(event, true);
5018
5243
  }
5019
5244
  });
5020
5245
  }
5021
5246
  else {
5022
- this.unbindParentClicked = this.parent.on('up:click', (event, element) => {
5247
+ this._unbindParentClicked = this.parent.on('up:click', (event, element) => {
5023
5248
  if (!up.layer.isWithinForeignOverlay(element)) {
5024
5249
  const originClicked = this.origin && this.origin.contains(element);
5025
5250
  this._onOutsideClicked(event, originClicked);
@@ -5028,17 +5253,17 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
5028
5253
  }
5029
5254
  }
5030
5255
  if (this._supportsDismissMethod('key')) {
5031
- this.unbindEscapePressed = up.event.onEscape(event => this.onEscapePressed(event));
5256
+ this._unbindEscapePressed = up.event.onEscape((event) => this.onEscapePressed(event));
5032
5257
  }
5033
- this.registerClickCloser('up-accept', (value, closeOptions) => {
5258
+ this.registerAttrCloser('up-accept', (value, closeOptions) => {
5034
5259
  this.accept(value, closeOptions);
5035
5260
  });
5036
- this.registerClickCloser('up-dismiss', (value, closeOptions) => {
5261
+ this.registerAttrCloser('up-dismiss', (value, closeOptions) => {
5037
5262
  this.dismiss(value, closeOptions);
5038
5263
  });
5039
5264
  (_c = (_b = up.migrate).registerLayerCloser) === null || _c === void 0 ? void 0 : _c.call(_b, this);
5040
- this._registerEventCloser(this.acceptEvent, this.accept);
5041
- this._registerEventCloser(this.dismissEvent, this.dismiss);
5265
+ this._registerExternalEventCloser(this.acceptEvent, this.accept);
5266
+ this._registerExternalEventCloser(this.dismissEvent, this.dismiss);
5042
5267
  this.on('up:click', 'label[for]', (event, label) => this._onLabelClicked(event, label));
5043
5268
  }
5044
5269
  _onLabelClicked(event, label) {
@@ -5073,26 +5298,38 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
5073
5298
  }
5074
5299
  }
5075
5300
  }
5076
- registerClickCloser(attribute, closeFn) {
5077
- let selector = `[${attribute}]`;
5078
- this.on('up:click', selector, function (event) {
5301
+ registerAttrCloser(attribute, closeFn) {
5302
+ this._registerClickCloser(attribute, closeFn);
5303
+ this._registerSubmitCloser(attribute, closeFn);
5304
+ }
5305
+ _registerClickCloser(attribute, closeFn) {
5306
+ this.on('up:click', `[${attribute}]:not(form)`, (event, link) => {
5307
+ up.event.halt(event, { log: true });
5308
+ const value = e.jsonAttr(link, attribute);
5309
+ this._onAttrCloserActivated(link, value, closeFn);
5310
+ });
5311
+ }
5312
+ _registerSubmitCloser(attribute, closeFn) {
5313
+ this.on('submit', `[${attribute}]`, (event, form) => {
5079
5314
  up.event.halt(event, { log: true });
5080
- const origin = event.target.closest(selector);
5081
- const value = e.jsonAttr(origin, attribute);
5082
- const closeOptions = { origin };
5083
- const parser = new up.OptionsParser(origin, closeOptions);
5084
- parser.booleanOrString('animation');
5085
- parser.string('easing');
5086
- parser.number('duration');
5087
- parser.string('confirm');
5088
- up.error.muteUncriticalSync(() => closeFn(value, closeOptions));
5315
+ const value = up.Params.fromForm(form);
5316
+ this._onAttrCloserActivated(form, value, closeFn);
5089
5317
  });
5090
5318
  }
5091
- _registerEventCloser(eventTypes, closeFn) {
5319
+ _onAttrCloserActivated(origin, value, closeFn) {
5320
+ const closeOptions = { origin };
5321
+ const parser = new up.OptionsParser(origin, closeOptions);
5322
+ parser.booleanOrString('animation');
5323
+ parser.string('easing');
5324
+ parser.number('duration');
5325
+ parser.string('confirm');
5326
+ up.error.muteUncriticalSync(() => closeFn(value, closeOptions));
5327
+ }
5328
+ _registerExternalEventCloser(eventTypes, closeFn) {
5092
5329
  if (!eventTypes) {
5093
5330
  return;
5094
5331
  }
5095
- return this.on(eventTypes, event => {
5332
+ return this.on(eventTypes, (event) => {
5096
5333
  event.preventDefault();
5097
5334
  up.error.muteUncriticalSync(() => closeFn.call(this, event, { response: event.response }));
5098
5335
  });
@@ -5113,8 +5350,8 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
5113
5350
  teardownHandlers() {
5114
5351
  var _b, _c;
5115
5352
  super.teardownHandlers();
5116
- (_b = this.unbindParentClicked) === null || _b === void 0 ? void 0 : _b.call(this);
5117
- (_c = this.unbindEscapePressed) === null || _c === void 0 ? void 0 : _c.call(this);
5353
+ (_b = this._unbindParentClicked) === null || _b === void 0 ? void 0 : _b.call(this);
5354
+ (_c = this._unbindEscapePressed) === null || _c === void 0 ? void 0 : _c.call(this);
5118
5355
  this.overlayFocus.teardown();
5119
5356
  }
5120
5357
  destroyElements(options) {
@@ -5201,11 +5438,12 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
5201
5438
  'closeEasing',
5202
5439
  'trapFocus',
5203
5440
  ],
5441
+ _a.UNSET_VISUALS = u.spanObject(_a.VISUAL_KEYS, undefined),
5204
5442
  _a);
5205
5443
 
5206
5444
 
5207
5445
  /***/ }),
5208
- /* 50 */
5446
+ /* 53 */
5209
5447
  /***/ (() => {
5210
5448
 
5211
5449
  up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
@@ -5244,7 +5482,7 @@ up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
5244
5482
 
5245
5483
 
5246
5484
  /***/ }),
5247
- /* 51 */
5485
+ /* 54 */
5248
5486
  /***/ (() => {
5249
5487
 
5250
5488
  up.Layer.OverlayWithViewport = class OverlayWithViewport extends up.Layer.Overlay {
@@ -5273,7 +5511,7 @@ up.Layer.OverlayWithViewport = class OverlayWithViewport extends up.Layer.Overla
5273
5511
 
5274
5512
 
5275
5513
  /***/ }),
5276
- /* 52 */
5514
+ /* 55 */
5277
5515
  /***/ (() => {
5278
5516
 
5279
5517
  var _a;
@@ -5319,7 +5557,7 @@ up.Layer.Root = (_a = class Root extends up.Layer {
5319
5557
 
5320
5558
 
5321
5559
  /***/ }),
5322
- /* 53 */
5560
+ /* 56 */
5323
5561
  /***/ (() => {
5324
5562
 
5325
5563
  var _a;
@@ -5330,7 +5568,7 @@ up.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {
5330
5568
 
5331
5569
 
5332
5570
  /***/ }),
5333
- /* 54 */
5571
+ /* 57 */
5334
5572
  /***/ (() => {
5335
5573
 
5336
5574
  var _a;
@@ -5341,7 +5579,7 @@ up.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {
5341
5579
 
5342
5580
 
5343
5581
  /***/ }),
5344
- /* 55 */
5582
+ /* 58 */
5345
5583
  /***/ (() => {
5346
5584
 
5347
5585
  var _a;
@@ -5352,7 +5590,7 @@ up.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {
5352
5590
 
5353
5591
 
5354
5592
  /***/ }),
5355
- /* 56 */
5593
+ /* 59 */
5356
5594
  /***/ (() => {
5357
5595
 
5358
5596
  var _a;
@@ -5363,7 +5601,7 @@ up.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {
5363
5601
 
5364
5602
 
5365
5603
  /***/ }),
5366
- /* 57 */
5604
+ /* 60 */
5367
5605
  /***/ (() => {
5368
5606
 
5369
5607
  var _a;
@@ -5379,7 +5617,7 @@ up.LayerLookup = (_a = class LayerLookup {
5379
5617
  this._values = u.getSimpleTokens(options.layer);
5380
5618
  }
5381
5619
  all() {
5382
- let results = u.flatMap(this._values, value => this._resolveValue(value));
5620
+ let results = u.flatMap(this._values, (value) => this._resolveValue(value));
5383
5621
  results = u.compact(results);
5384
5622
  results = u.uniq(results);
5385
5623
  return results;
@@ -5394,7 +5632,7 @@ up.LayerLookup = (_a = class LayerLookup {
5394
5632
  }
5395
5633
  _forElement(element) {
5396
5634
  element = e.get(element);
5397
- return u.find(this._stack.reversed(), layer => layer.contains(element));
5635
+ return u.find(this._stack.reversed(), (layer) => layer.contains(element));
5398
5636
  }
5399
5637
  _forIndex(value) {
5400
5638
  return this._stack.at(value);
@@ -5476,7 +5714,7 @@ up.LayerLookup = (_a = class LayerLookup {
5476
5714
 
5477
5715
 
5478
5716
  /***/ }),
5479
- /* 58 */
5717
+ /* 61 */
5480
5718
  /***/ (() => {
5481
5719
 
5482
5720
  const u = up.util;
@@ -5590,7 +5828,7 @@ up.LayerStack = class LayerStack {
5590
5828
 
5591
5829
 
5592
5830
  /***/ }),
5593
- /* 59 */
5831
+ /* 62 */
5594
5832
  /***/ (() => {
5595
5833
 
5596
5834
  const u = up.util;
@@ -5621,11 +5859,19 @@ up.LinkCurrentURLs = class LinkCurrentURLs {
5621
5859
  this._upHREF === normalizedLocation ||
5622
5860
  ((_b = (_a = this._aliasPattern) === null || _a === void 0 ? void 0 : _a.test) === null || _b === void 0 ? void 0 : _b.call(_a, normalizedLocation, false)));
5623
5861
  }
5862
+ isAnyCurrent(normalizedLocations) {
5863
+ return normalizedLocations.some((normalizedLocation) => {
5864
+ var _a, _b;
5865
+ return (this._href === normalizedLocation ||
5866
+ this._upHREF === normalizedLocation ||
5867
+ ((_b = (_a = this._aliasPattern) === null || _a === void 0 ? void 0 : _a.test) === null || _b === void 0 ? void 0 : _b.call(_a, normalizedLocation, false)));
5868
+ });
5869
+ }
5624
5870
  };
5625
5871
 
5626
5872
 
5627
5873
  /***/ }),
5628
- /* 60 */
5874
+ /* 63 */
5629
5875
  /***/ (() => {
5630
5876
 
5631
5877
  const u = up.util;
@@ -5668,13 +5914,15 @@ up.LinkFollowIntent = class LinkFollowIntent {
5668
5914
  }
5669
5915
  _runCallback(event) {
5670
5916
  up.log.putsEvent(event);
5917
+ if (!up.fragment.isAlive(this._link))
5918
+ return;
5671
5919
  this._callback({ onRequestKnown: (request) => this._lastRequest = request });
5672
5920
  }
5673
5921
  };
5674
5922
 
5675
5923
 
5676
5924
  /***/ }),
5677
- /* 61 */
5925
+ /* 64 */
5678
5926
  /***/ (function() {
5679
5927
 
5680
5928
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -5727,7 +5975,7 @@ up.MotionController = class MotionController {
5727
5975
  }
5728
5976
  _expandFinishRequest(elements) {
5729
5977
  if (elements) {
5730
- return u.flatMap(elements, el => e.list(el.closest(this._selector), el.querySelectorAll(this._selector)));
5978
+ return u.flatMap(elements, (el) => e.list(el.closest(this._selector), el.querySelectorAll(this._selector)));
5731
5979
  }
5732
5980
  else {
5733
5981
  return document.querySelectorAll(this._selector);
@@ -5783,10 +6031,9 @@ up.MotionController = class MotionController {
5783
6031
 
5784
6032
 
5785
6033
  /***/ }),
5786
- /* 62 */
6034
+ /* 65 */
5787
6035
  /***/ (() => {
5788
6036
 
5789
- const u = up.util;
5790
6037
  const e = up.element;
5791
6038
  up.NonceableCallback = class NonceableCallback {
5792
6039
  constructor(script, nonce) {
@@ -5840,37 +6087,11 @@ up.NonceableCallback = class NonceableCallback {
5840
6087
  }
5841
6088
  }
5842
6089
  }
5843
- _allowedBy(allowedNonces) {
5844
- return this.nonce && u.contains(allowedNonces, this.nonce);
5845
- }
5846
- static adoptNonces(element, allowedNonces) {
5847
- if (!(allowedNonces === null || allowedNonces === void 0 ? void 0 : allowedNonces.length)) {
5848
- return;
5849
- }
5850
- const getPageNonce = u.memoize(up.protocol.cspNonce);
5851
- u.each(up.script.config.nonceableAttributes, (attribute) => {
5852
- let matches = e.subtree(element, `[${attribute}^="nonce-"]`);
5853
- u.each(matches, (match) => {
5854
- let attributeValue = match.getAttribute(attribute);
5855
- let callback = this.fromString(attributeValue);
5856
- let warn = (message, ...args) => up.log.warn('up.render()', `Cannot use callback [${attribute}="${attributeValue}"]: ${message}`, ...args);
5857
- if (!callback._allowedBy(allowedNonces)) {
5858
- return warn("Callback's CSP nonce (%o) does not match response header (%o)", callback.nonce, allowedNonces);
5859
- }
5860
- let pageNonce = getPageNonce();
5861
- if (!pageNonce) {
5862
- return warn("Current page's CSP nonce is unknown");
5863
- }
5864
- callback.nonce = pageNonce;
5865
- match.setAttribute(attribute, callback.toString());
5866
- });
5867
- });
5868
- }
5869
6090
  };
5870
6091
 
5871
6092
 
5872
6093
  /***/ }),
5873
- /* 63 */
6094
+ /* 66 */
5874
6095
  /***/ (() => {
5875
6096
 
5876
6097
  const e = up.element;
@@ -5892,7 +6113,7 @@ up.OverlayFocus = class OverlayFocus {
5892
6113
  'aria-modal': this._trapFocus.toString()
5893
6114
  });
5894
6115
  if (this._trapFocus) {
5895
- this._untrapFocus = up.on('focusin', event => this._onFocus(event));
6116
+ this._untrapFocus = up.on('focusin', (event) => this._onFocus(event));
5896
6117
  this._focusTrapBefore = e.affix(this._focusElement, 'beforebegin', 'up-focus-trap[tabindex=0]');
5897
6118
  this._focusTrapAfter = e.affix(this._focusElement, 'afterend', 'up-focus-trap[tabindex=0]');
5898
6119
  }
@@ -5943,7 +6164,7 @@ up.OverlayFocus = class OverlayFocus {
5943
6164
 
5944
6165
 
5945
6166
  /***/ }),
5946
- /* 64 */
6167
+ /* 67 */
5947
6168
  /***/ (() => {
5948
6169
 
5949
6170
  const u = up.util;
@@ -5989,15 +6210,12 @@ up.Params = class Params {
5989
6210
  return formData;
5990
6211
  }
5991
6212
  toQuery() {
5992
- let parts = u.map(this.entries, this._arrayEntryToQuery.bind(this));
5993
- parts = u.compact(parts);
6213
+ let simpleEntries = this.withoutBinaryEntries().entries;
6214
+ let parts = simpleEntries.map(this._arrayEntryToQuery);
5994
6215
  return parts.join('&');
5995
6216
  }
5996
6217
  _arrayEntryToQuery(entry) {
5997
6218
  const { value } = entry;
5998
- if (this._isBinaryValue(value)) {
5999
- return;
6000
- }
6001
6219
  let query = encodeURIComponent(entry.name);
6002
6220
  if (u.isGiven(value)) {
6003
6221
  query += "=";
@@ -6005,12 +6223,15 @@ up.Params = class Params {
6005
6223
  }
6006
6224
  return query;
6007
6225
  }
6008
- _isBinaryValue(value) {
6226
+ _isBinaryEntry({ value }) {
6009
6227
  return value instanceof Blob;
6010
6228
  }
6011
- hasBinaryValues() {
6012
- const values = u.map(this.entries, 'value');
6013
- return u.some(values, this._isBinaryValue);
6229
+ hasBinaryEntries() {
6230
+ return u.some(this.entries, this._isBinaryEntry);
6231
+ }
6232
+ withoutBinaryEntries() {
6233
+ let simpleEntries = u.reject(this.entries, this._isBinaryEntry);
6234
+ return new this.constructor(simpleEntries);
6014
6235
  }
6015
6236
  toURL(base) {
6016
6237
  let parts = [base, this.toQuery()];
@@ -6040,9 +6261,15 @@ up.Params = class Params {
6040
6261
  this._addAllFromObject(raw);
6041
6262
  }
6042
6263
  else {
6043
- up.fail("Unsupport params type: %o", raw);
6264
+ up.fail("Unsupported params type: %o", raw);
6044
6265
  }
6045
6266
  }
6267
+ keys() {
6268
+ return u.map(this.entries, 'name');
6269
+ }
6270
+ values() {
6271
+ return u.map(this.entries, 'value');
6272
+ }
6046
6273
  _addAllFromObject(object) {
6047
6274
  for (let key in object) {
6048
6275
  const value = object[key];
@@ -6080,7 +6307,7 @@ up.Params = class Params {
6080
6307
  this.entries = u.reject(this.entries, this._matchEntryFn(name));
6081
6308
  }
6082
6309
  _matchEntryFn(name) {
6083
- return entry => entry.name === name;
6310
+ return (entry) => entry.name === name;
6084
6311
  }
6085
6312
  get(name) {
6086
6313
  if (this._isArrayKey(name)) {
@@ -6095,16 +6322,11 @@ up.Params = class Params {
6095
6322
  return entry === null || entry === void 0 ? void 0 : entry.value;
6096
6323
  }
6097
6324
  getAll(name) {
6098
- if (this._isArrayKey(name)) {
6099
- return this.getAll(name);
6100
- }
6101
- else {
6102
- const entries = u.map(this.entries, this._matchEntryFn(name));
6103
- return u.map(entries, 'value');
6104
- }
6325
+ const entries = u.filter(this.entries, this._matchEntryFn(name));
6326
+ return u.map(entries, 'value');
6105
6327
  }
6106
6328
  _isArrayKey(key) {
6107
- return key.endsWith('[]');
6329
+ return u.evalOption(up.form.config.arrayParam, key);
6108
6330
  }
6109
6331
  [u.isBlank.key]() {
6110
6332
  return this.entries.length === 0;
@@ -6167,17 +6389,21 @@ up.Params = class Params {
6167
6389
  static stripURL(url) {
6168
6390
  return u.normalizeURL(url, { search: false });
6169
6391
  }
6170
- static merge(...objects) {
6171
- return objects.reduce(function (allParams, params) {
6172
- allParams.addAll(params);
6173
- return allParams;
6174
- }, new up.Params());
6392
+ static merge(start, ...objects) {
6393
+ let merged = u.copy(start);
6394
+ for (let object of objects) {
6395
+ let other = u.wrapValue(this, object);
6396
+ for (let key of other.keys())
6397
+ merged.delete(key);
6398
+ merged.addAll(other);
6399
+ }
6400
+ return merged;
6175
6401
  }
6176
6402
  };
6177
6403
 
6178
6404
 
6179
6405
  /***/ }),
6180
- /* 65 */
6406
+ /* 68 */
6181
6407
  /***/ (() => {
6182
6408
 
6183
6409
  const u = up.util;
@@ -6248,7 +6474,7 @@ up.Preview = class Preview {
6248
6474
  }
6249
6475
  disable(...args) {
6250
6476
  let [element] = this._parseMutatorArgs(args, 'val');
6251
- this.undo(up.form.disable(element));
6477
+ this.undo(up.form.disableTemp(element));
6252
6478
  }
6253
6479
  insert(...args) {
6254
6480
  let [reference, position = 'beforeend', tempValue] = this._parseMutatorArgs(args, 'val', u.isAdjacentPosition, 'val');
@@ -6305,7 +6531,7 @@ up.Preview = class Preview {
6305
6531
 
6306
6532
 
6307
6533
  /***/ }),
6308
- /* 66 */
6534
+ /* 69 */
6309
6535
  /***/ (() => {
6310
6536
 
6311
6537
  const e = up.element;
@@ -6355,7 +6581,7 @@ up.ProgressBar = class ProgressBar {
6355
6581
 
6356
6582
 
6357
6583
  /***/ }),
6358
- /* 67 */
6584
+ /* 70 */
6359
6585
  /***/ (() => {
6360
6586
 
6361
6587
  const u = up.util;
@@ -6452,7 +6678,7 @@ up.RenderOptions = (function () {
6452
6678
  return u.merge(preprocessedOptions.defaults, lateDefaults, preprocessedOptions);
6453
6679
  }
6454
6680
  function assertContentGiven(options) {
6455
- if (!u.some(CONTENT_KEYS, contentKey => u.isGiven(options[contentKey]))) {
6681
+ if (!u.some(CONTENT_KEYS, (contentKey) => u.isGiven(options[contentKey]))) {
6456
6682
  if (options.defaultToEmptyContent) {
6457
6683
  options.content = '';
6458
6684
  }
@@ -6473,12 +6699,13 @@ up.RenderOptions = (function () {
6473
6699
  return overrides;
6474
6700
  }
6475
6701
  function deriveFailOptions(preprocessedOptions) {
6702
+ let markFailure = { didFail: true };
6476
6703
  let overrides = failOverrides(preprocessedOptions);
6477
6704
  if (preprocessedOptions.failOptions) {
6478
- return Object.assign(Object.assign(Object.assign(Object.assign({}, preprocessedOptions.defaults), u.pick(preprocessedOptions, SHARED_KEYS)), overrides), { failPrefixForced: true });
6705
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, preprocessedOptions.defaults), u.pick(preprocessedOptions, SHARED_KEYS)), overrides), { didForceFailOptions: true }), markFailure);
6479
6706
  }
6480
6707
  else {
6481
- return Object.assign(Object.assign({}, preprocessedOptions), overrides);
6708
+ return Object.assign(Object.assign(Object.assign({}, preprocessedOptions), overrides), markFailure);
6482
6709
  }
6483
6710
  }
6484
6711
  return {
@@ -6494,7 +6721,7 @@ up.RenderOptions = (function () {
6494
6721
 
6495
6722
 
6496
6723
  /***/ }),
6497
- /* 68 */
6724
+ /* 71 */
6498
6725
  /***/ (function() {
6499
6726
 
6500
6727
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -6512,13 +6739,14 @@ up.RenderResult = class RenderResult extends up.Record {
6512
6739
  'fragments',
6513
6740
  'layer',
6514
6741
  'target',
6515
- 'options',
6742
+ 'renderOptions',
6516
6743
  'finished',
6517
6744
  ];
6518
6745
  }
6519
6746
  defaults() {
6520
6747
  return {
6521
6748
  fragments: [],
6749
+ finished: Promise.resolve(),
6522
6750
  };
6523
6751
  }
6524
6752
  get none() {
@@ -6527,33 +6755,25 @@ up.RenderResult = class RenderResult extends up.Record {
6527
6755
  get fragment() {
6528
6756
  return this.fragments[0];
6529
6757
  }
6758
+ get ok() {
6759
+ return !this.renderOptions.didFail;
6760
+ }
6530
6761
  static both(main, extension, mergeFinished = true) {
6531
- if (!extension)
6762
+ if (!extension) {
6532
6763
  return main;
6533
- return new this({
6534
- target: main.target,
6535
- layer: main.layer,
6536
- options: main.options,
6537
- fragments: main.fragments.concat(extension.fragments),
6538
- finished: (mergeFinished && this.mergeFinished(main, extension))
6539
- });
6764
+ }
6765
+ return new this(Object.assign(Object.assign({}, main), { fragments: main.fragments.concat(extension.fragments), finished: (mergeFinished && this.mergeFinished(main, extension)) }));
6540
6766
  }
6541
6767
  static mergeFinished(main, extension) {
6542
6768
  return __awaiter(this, void 0, void 0, function* () {
6543
6769
  return this.both(yield main.finished, yield extension.finished, false);
6544
6770
  });
6545
6771
  }
6546
- static buildNone() {
6547
- return new this({
6548
- target: ':none',
6549
- finished: Promise.resolve(),
6550
- });
6551
- }
6552
6772
  };
6553
6773
 
6554
6774
 
6555
6775
  /***/ }),
6556
- /* 69 */
6776
+ /* 72 */
6557
6777
  /***/ (() => {
6558
6778
 
6559
6779
  var _a;
@@ -6580,6 +6800,8 @@ up.Request = (_a = class Request extends up.Record {
6580
6800
  'failMode',
6581
6801
  'failContext',
6582
6802
  'origin',
6803
+ 'originLayer',
6804
+ 'originMode',
6583
6805
  'builtAt',
6584
6806
  'wrapMethod',
6585
6807
  'contentType',
@@ -6592,31 +6814,32 @@ up.Request = (_a = class Request extends up.Record {
6592
6814
  ];
6593
6815
  }
6594
6816
  defaults() {
6817
+ let config = up.network.config;
6595
6818
  return {
6596
6819
  state: 'new',
6597
6820
  abortable: true,
6598
6821
  headers: {},
6599
- timeout: up.network.config.timeout,
6822
+ timeout: config.timeout,
6600
6823
  builtAt: new Date(),
6601
6824
  previews: [],
6825
+ wrapMethod: config.wrapMethod,
6602
6826
  };
6603
6827
  }
6604
6828
  constructor(options) {
6605
- var _b, _c;
6829
+ var _b, _c, _d;
6606
6830
  super(options);
6607
6831
  this.params = new up.Params(this.params);
6608
- if (this.wrapMethod == null) {
6609
- this.wrapMethod = up.network.config.wrapMethod;
6610
- }
6611
6832
  this._normalize();
6612
6833
  if ((this.target || this.layer || this.origin) && !options.basic) {
6613
6834
  const layerLookupOptions = { origin: this.origin };
6614
6835
  this.layer = up.layer.get(this.layer, layerLookupOptions);
6615
- this.failLayer = up.layer.get(this.failLayer, layerLookupOptions);
6616
6836
  this.context || (this.context = this.layer.context || {});
6617
- this.failContext || (this.failContext = ((_b = this.failLayer) === null || _b === void 0 ? void 0 : _b.context) || {});
6618
6837
  this.mode || (this.mode = this.layer.mode);
6838
+ this.failLayer = up.layer.get(this.failLayer, layerLookupOptions);
6839
+ this.failContext || (this.failContext = ((_b = this.failLayer) === null || _b === void 0 ? void 0 : _b.context) || {});
6619
6840
  this.failMode || (this.failMode = (_c = this.failLayer) === null || _c === void 0 ? void 0 : _c.mode);
6841
+ this.originLayer || (this.originLayer = up.layer.get(this.origin) || up.layer.current);
6842
+ this.originMode || (this.originMode = (_d = this.originLayer) === null || _d === void 0 ? void 0 : _d.mode);
6620
6843
  }
6621
6844
  this.bindLayer = options.bindLayer || this.layer;
6622
6845
  this._fragments = options.fragments;
@@ -6666,8 +6889,9 @@ up.Request = (_a = class Request extends up.Record {
6666
6889
  u.task(() => {
6667
6890
  this.layer = undefined;
6668
6891
  this.failLayer = undefined;
6669
- this._bindLayer = undefined;
6892
+ this.bindLayer = undefined;
6670
6893
  this.origin = undefined;
6894
+ this.originLayer = undefined;
6671
6895
  this._fragments = undefined;
6672
6896
  this._bindFragments = undefined;
6673
6897
  });
@@ -6824,6 +7048,7 @@ up.Request = (_a = class Request extends up.Record {
6824
7048
  status: this.xhr.status,
6825
7049
  title: up.protocol.titleFromXHR(this.xhr),
6826
7050
  target: up.protocol.targetFromXHR(this.xhr),
7051
+ openLayer: up.protocol.openLayerFromXHR(this.xhr),
6827
7052
  acceptLayer: up.protocol.acceptLayerFromXHR(this.xhr),
6828
7053
  dismissLayer: up.protocol.dismissLayerFromXHR(this.xhr),
6829
7054
  eventPlans: up.protocol.eventPlansFromXHR(this.xhr),
@@ -6877,7 +7102,7 @@ up.Request = (_a = class Request extends up.Record {
6877
7102
  return this.headers[name];
6878
7103
  }
6879
7104
  _setAutoHeaders() {
6880
- for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext']) {
7105
+ for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext', 'originMode']) {
6881
7106
  this._setPropertyHeader(key);
6882
7107
  }
6883
7108
  let csrfHeader, csrfToken;
@@ -6938,7 +7163,7 @@ up.Request = (_a = class Request extends up.Record {
6938
7163
 
6939
7164
 
6940
7165
  /***/ }),
6941
- /* 70 */
7166
+ /* 73 */
6942
7167
  /***/ (function() {
6943
7168
 
6944
7169
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -7030,15 +7255,6 @@ up.Request.Cache = class Cache {
7030
7255
  this._limitSize();
7031
7256
  });
7032
7257
  }
7033
- alias(existingCachedRequest, newRequest) {
7034
- existingCachedRequest = this.get(existingCachedRequest);
7035
- if (!existingCachedRequest)
7036
- return;
7037
- newRequest = this._wrap(newRequest);
7038
- this.track(existingCachedRequest, newRequest, { force: true });
7039
- this.put(newRequest);
7040
- return newRequest;
7041
- }
7042
7258
  track(existingRequest, newRequest, options = {}) {
7043
7259
  var _a;
7044
7260
  return __awaiter(this, void 0, void 0, function* () {
@@ -7119,7 +7335,7 @@ up.Request.Cache = class Cache {
7119
7335
 
7120
7336
 
7121
7337
  /***/ }),
7122
- /* 71 */
7338
+ /* 74 */
7123
7339
  /***/ (() => {
7124
7340
 
7125
7341
  const u = up.util;
@@ -7137,7 +7353,7 @@ up.Request.Queue = class Queue {
7137
7353
  }
7138
7354
  asap(request) {
7139
7355
  request.runQueuedCallbacks();
7140
- u.always(request, responseOrError => this._onRequestSettled(request, responseOrError));
7356
+ u.always(request, () => this._onRequestSettled(request));
7141
7357
  this._scheduleSlowTimer(request);
7142
7358
  this._queueRequest(request);
7143
7359
  queueMicrotask(() => this._poke());
@@ -7168,7 +7384,7 @@ up.Request.Queue = class Queue {
7168
7384
  this._queuedRequests.push(request);
7169
7385
  }
7170
7386
  _pluckNextRequest() {
7171
- let request = u.find(this._queuedRequests, request => !request.background);
7387
+ let request = u.find(this._queuedRequests, (request) => !request.background);
7172
7388
  request || (request = this._queuedRequests[0]);
7173
7389
  return u.remove(this._queuedRequests, request);
7174
7390
  }
@@ -7177,11 +7393,8 @@ up.Request.Queue = class Queue {
7177
7393
  this._currentRequests.push(request);
7178
7394
  }
7179
7395
  }
7180
- _onRequestSettled(request, responseOrError) {
7396
+ _onRequestSettled(request) {
7181
7397
  u.remove(this._currentRequests, request) || u.remove(this._queuedRequests, request);
7182
- if ((responseOrError instanceof up.Response) && responseOrError.ok) {
7183
- up.network.registerAliasForRedirect(request, responseOrError);
7184
- }
7185
7398
  queueMicrotask(() => this._poke());
7186
7399
  u.task(() => this._checkForRecover());
7187
7400
  }
@@ -7230,7 +7443,7 @@ up.Request.Queue = class Queue {
7230
7443
 
7231
7444
 
7232
7445
  /***/ }),
7233
- /* 72 */
7446
+ /* 75 */
7234
7447
  /***/ (() => {
7235
7448
 
7236
7449
  const u = up.util;
@@ -7241,7 +7454,7 @@ up.Request.FormRenderer = class FormRenderer {
7241
7454
  this._request = request;
7242
7455
  }
7243
7456
  buildAndSubmit() {
7244
- this.params = u.copy(this._request.params);
7457
+ this.params = this._request.params.withoutBinaryEntries();
7245
7458
  let action = this._request.url;
7246
7459
  let { method } = this._request;
7247
7460
  const paramsFromQuery = up.Params.fromURL(action);
@@ -7269,7 +7482,7 @@ up.Request.FormRenderer = class FormRenderer {
7269
7482
 
7270
7483
 
7271
7484
  /***/ }),
7272
- /* 73 */
7485
+ /* 76 */
7273
7486
  /***/ (() => {
7274
7487
 
7275
7488
  var _a;
@@ -7318,7 +7531,7 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
7318
7531
  this._contentType = this._request.contentType;
7319
7532
  if (!this._payload && this._request.allowsPayload()) {
7320
7533
  if (!this._contentType) {
7321
- this._contentType = this._params.hasBinaryValues() ? CONTENT_TYPE_FORM_DATA : CONTENT_TYPE_URL_ENCODED;
7534
+ this._contentType = this._params.hasBinaryEntries() ? CONTENT_TYPE_FORM_DATA : CONTENT_TYPE_URL_ENCODED;
7322
7535
  }
7323
7536
  if (this._contentType === CONTENT_TYPE_FORM_DATA) {
7324
7537
  this._contentType = null;
@@ -7340,7 +7553,7 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
7340
7553
 
7341
7554
 
7342
7555
  /***/ }),
7343
- /* 74 */
7556
+ /* 77 */
7344
7557
  /***/ (() => {
7345
7558
 
7346
7559
  const u = up.util;
@@ -7355,6 +7568,7 @@ up.Response = class Response extends up.Record {
7355
7568
  'xhr',
7356
7569
  'target',
7357
7570
  'title',
7571
+ 'openLayer',
7358
7572
  'acceptLayer',
7359
7573
  'dismissLayer',
7360
7574
  'eventPlans',
@@ -7369,7 +7583,7 @@ up.Response = class Response extends up.Record {
7369
7583
  defaults() {
7370
7584
  return {
7371
7585
  headers: {},
7372
- loadedAt: new Date()
7586
+ loadedAt: new Date(),
7373
7587
  };
7374
7588
  }
7375
7589
  get ok() {
@@ -7390,8 +7604,9 @@ up.Response = class Response extends up.Record {
7390
7604
  get contentType() {
7391
7605
  return this.header('Content-Type');
7392
7606
  }
7393
- get cspNonces() {
7394
- return up.protocol.cspNoncesFromHeader(this.header('Content-Security-Policy') || this.header('Content-Security-Policy-Report-Only'));
7607
+ get cspInfo() {
7608
+ let policy = this.header('Content-Security-Policy') || this.header('Content-Security-Policy-Report-Only');
7609
+ return up.protocol.cspInfoFromHeader(policy);
7395
7610
  }
7396
7611
  get lastModified() {
7397
7612
  let header = this.header('Last-Modified');
@@ -7416,19 +7631,33 @@ up.Response = class Response extends up.Record {
7416
7631
  get description() {
7417
7632
  return `HTTP ${this.status} response to ${this.request.description}`;
7418
7633
  }
7634
+ get redirect() {
7635
+ return (this.url !== this.request.url) || (this.method !== this.request.method);
7636
+ }
7637
+ get redirectRequest() {
7638
+ if (!this.redirect)
7639
+ return;
7640
+ let finalRequest = u.variant(this.request, {
7641
+ method: this.method,
7642
+ url: this.url,
7643
+ cacheRoute: null,
7644
+ });
7645
+ up.cache.track(this.request, finalRequest, { force: true });
7646
+ return finalRequest;
7647
+ }
7419
7648
  };
7420
7649
 
7421
7650
 
7422
7651
  /***/ }),
7423
- /* 75 */
7652
+ /* 78 */
7424
7653
  /***/ (() => {
7425
7654
 
7426
7655
  var _a;
7427
7656
  const u = up.util;
7428
7657
  const e = up.element;
7429
- const FULL_DOCUMENT_PATTERN = /^\s*<(html|!DOCTYPE)\b/i;
7658
+ const FULL_DOCUMENT_PATTERN = /^\s*(<!--[^-]*.*?-->\s*)*<(html|!DOCTYPE)\b/i;
7430
7659
  up.ResponseDoc = (_a = class ResponseDoc {
7431
- constructor({ document, fragment, content, target, origin, data, cspNonces, match }) {
7660
+ constructor({ document, fragment, content, target, origin, data, cspInfo, match }) {
7432
7661
  if (document) {
7433
7662
  this._parseDocument(document, origin, data);
7434
7663
  }
@@ -7438,7 +7667,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
7438
7667
  else {
7439
7668
  this._parseContent(content || '', origin, target, data);
7440
7669
  }
7441
- this._cspNonces = cspNonces;
7670
+ this._cspInfo = cspInfo || {};
7442
7671
  if (origin) {
7443
7672
  let originSelector = up.fragment.tryToTarget(origin);
7444
7673
  if (originSelector) {
@@ -7467,9 +7696,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
7467
7696
  this._document = this._buildFauxDocument(value);
7468
7697
  }
7469
7698
  }
7470
- _parseDocumentFromHTML(html) {
7471
- return e.createBrokenDocumentFromHTML(html);
7472
- }
7473
7699
  _parseFragment(value, origin, data) {
7474
7700
  let element = e.extractSingular(up.fragment.provideNodes(value, { origin, data }));
7475
7701
  this._document = this._buildFauxDocument(element);
@@ -7507,7 +7733,14 @@ up.ResponseDoc = (_a = class ResponseDoc {
7507
7733
  return this._fromHead(up.history.findMetaTags);
7508
7734
  }
7509
7735
  get assets() {
7510
- return this._fromHead(up.script.findAssets);
7736
+ return this._fromHead((head) => {
7737
+ let assets = up.script.findAssets(head);
7738
+ return u.map(assets, (asset) => {
7739
+ this._adoptNoncesInSubtree(asset);
7740
+ let clone = this._reviveElementAsClone(asset);
7741
+ return clone;
7742
+ });
7743
+ });
7511
7744
  }
7512
7745
  get lang() {
7513
7746
  if (this._isFullDocument) {
@@ -7560,21 +7793,44 @@ up.ResponseDoc = (_a = class ResponseDoc {
7560
7793
  throw new up.CannotMatch();
7561
7794
  }
7562
7795
  }
7796
+ _disableScriptsInSubtree(element) {
7797
+ let pageNonce = up.protocol.cspNonce();
7798
+ up.script.disableSubtree(element, (script) => !this._isScriptAllowed(script, pageNonce));
7799
+ }
7800
+ _isScriptAllowed(scriptElement, pageNonce) {
7801
+ var _b;
7802
+ let strategy = up.fragment.config.runScripts;
7803
+ if (strategy === true && ((_b = this._cspInfo.declaration) === null || _b === void 0 ? void 0 : _b.includes("'strict-dynamic'"))) {
7804
+ return pageNonce && (pageNonce === scriptElement.nonce);
7805
+ }
7806
+ else {
7807
+ return u.evalOption(strategy, scriptElement);
7808
+ }
7809
+ }
7810
+ _reviveElementAsClone(element) {
7811
+ return e.revivedClone(element);
7812
+ }
7813
+ _reviveSubtreeInPlace(element) {
7814
+ if (this._document instanceof Document) {
7815
+ for (let brokenElement of e.subtree(element, ':is(noscript, script, audio, video):not(.up-keeping, .up-keeping *)')) {
7816
+ let clone = this._reviveElementAsClone(brokenElement);
7817
+ brokenElement.replaceWith(clone);
7818
+ }
7819
+ }
7820
+ }
7821
+ _adoptNoncesInSubtree(element) {
7822
+ up.script.adoptNoncesInSubtree(element, this._cspInfo.nonces);
7823
+ }
7563
7824
  commitElement(element) {
7564
7825
  if (this._document.contains(element)) {
7565
- if (!up.fragment.config.runScripts) {
7566
- up.script.disableSubtree(element);
7567
- }
7826
+ this._adoptNoncesInSubtree(element);
7827
+ this._disableScriptsInSubtree(element);
7568
7828
  element.remove();
7569
7829
  return true;
7570
7830
  }
7571
7831
  }
7572
7832
  finalizeElement(element) {
7573
- up.NonceableCallback.adoptNonces(element, this._cspNonces);
7574
- if (this._document instanceof Document) {
7575
- let brokenElements = e.subtree(element, ':is(noscript,script,audio,video):not(.up-keeping, .up-keeping *)');
7576
- u.each(brokenElements, e.fixParserDamage);
7577
- }
7833
+ this._reviveSubtreeInPlace(element);
7578
7834
  }
7579
7835
  },
7580
7836
  (() => {
@@ -7586,7 +7842,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
7586
7842
 
7587
7843
 
7588
7844
  /***/ }),
7589
- /* 76 */
7845
+ /* 79 */
7590
7846
  /***/ (() => {
7591
7847
 
7592
7848
  const e = up.element;
@@ -7677,7 +7933,7 @@ up.RevealMotion = class RevealMotion {
7677
7933
 
7678
7934
 
7679
7935
  /***/ }),
7680
- /* 77 */
7936
+ /* 80 */
7681
7937
  /***/ (() => {
7682
7938
 
7683
7939
  const u = up.util;
@@ -7700,7 +7956,7 @@ up.Selector = class Selector {
7700
7956
  this._layers = up.layer.getAll(options);
7701
7957
  if (!this._layers.length)
7702
7958
  throw new up.CannotMatch(["Unknown layer: %o", options.layer]);
7703
- this._filters.push(match => u.some(this._layers, layer => layer.contains(match)));
7959
+ this._filters.push((match) => u.some(this._layers, (layer) => layer.contains(match)));
7704
7960
  expandTargetLayer = this._layers[0];
7705
7961
  }
7706
7962
  this._selectors = up.fragment.expandTargets(selector, Object.assign(Object.assign({}, options), { layer: expandTargetLayer }));
@@ -7735,7 +7991,7 @@ up.Selector = class Selector {
7735
7991
  });
7736
7992
  }
7737
7993
  _passesFilter(element) {
7738
- return element && u.every(this._filters, filter => filter(element));
7994
+ return element && u.every(this._filters, (filter) => filter(element));
7739
7995
  }
7740
7996
  _filterOne(element) {
7741
7997
  return u.presence(element, this._passesFilter.bind(this));
@@ -7747,7 +8003,7 @@ up.Selector = class Selector {
7747
8003
 
7748
8004
 
7749
8005
  /***/ }),
7750
- /* 78 */
8006
+ /* 81 */
7751
8007
  /***/ (() => {
7752
8008
 
7753
8009
  const u = up.util;
@@ -7868,7 +8124,7 @@ up.Tether = class Tether {
7868
8124
 
7869
8125
 
7870
8126
  /***/ }),
7871
- /* 79 */
8127
+ /* 82 */
7872
8128
  /***/ (() => {
7873
8129
 
7874
8130
  const u = up.util;
@@ -7942,7 +8198,7 @@ up.URLPattern = class URLPattern {
7942
8198
 
7943
8199
 
7944
8200
  /***/ }),
7945
- /* 80 */
8201
+ /* 83 */
7946
8202
  /***/ (() => {
7947
8203
 
7948
8204
  up.framework = (function () {
@@ -7950,7 +8206,7 @@ up.framework = (function () {
7950
8206
  function emitReset() {
7951
8207
  up.emit('up:framework:reset', { log: false });
7952
8208
  }
7953
- function boot() {
8209
+ function boot({ mode = 'manual' } = {}) {
7954
8210
  if (readyState !== 'configuring') {
7955
8211
  console.error('Unpoly has already booted');
7956
8212
  return;
@@ -7958,9 +8214,9 @@ up.framework = (function () {
7958
8214
  let issue = supportIssue();
7959
8215
  if (!issue) {
7960
8216
  readyState = 'booting';
7961
- up.emit('up:framework:boot', { log: false });
8217
+ up.emit('up:framework:boot', { mode, log: false });
7962
8218
  readyState = 'booted';
7963
- up.emit('up:framework:booted', { log: false });
8219
+ up.emit('up:framework:booted', { mode, log: false });
7964
8220
  }
7965
8221
  else {
7966
8222
  console.error("Unpoly cannot boot: %s", issue);
@@ -7984,7 +8240,7 @@ up.framework = (function () {
7984
8240
  console.debug('Call up.boot() after you have configured Unpoly');
7985
8241
  }
7986
8242
  else {
7987
- document.addEventListener('DOMContentLoaded', boot);
8243
+ document.addEventListener('DOMContentLoaded', () => boot({ mode: 'auto' }));
7988
8244
  }
7989
8245
  readyState = 'configuring';
7990
8246
  }
@@ -8031,7 +8287,7 @@ up.boot = up.framework.boot;
8031
8287
 
8032
8288
 
8033
8289
  /***/ }),
8034
- /* 81 */
8290
+ /* 84 */
8035
8291
  /***/ (() => {
8036
8292
 
8037
8293
  up.event = (function () {
@@ -8083,9 +8339,8 @@ up.event = (function () {
8083
8339
  event.preventDefault();
8084
8340
  }
8085
8341
  const keyModifiers = ['metaKey', 'shiftKey', 'ctrlKey', 'altKey'];
8086
- function isUnmodified(event) {
8087
- return (u.isUndefined(event.button) || (event.button === 0)) &&
8088
- !u.some(keyModifiers, modifier => event[modifier]);
8342
+ function isModified(event) {
8343
+ return (event.button > 0) || u.some(keyModifiers, (modifier) => event[modifier]);
8089
8344
  }
8090
8345
  function isSyntheticClick(event) {
8091
8346
  return u.isMissing(event.clientX);
@@ -8106,7 +8361,7 @@ up.event = (function () {
8106
8361
  return newEvent;
8107
8362
  }
8108
8363
  function executeEmitAttr(event, element) {
8109
- if (!isUnmodified(event)) {
8364
+ if (isModified(event)) {
8110
8365
  return;
8111
8366
  }
8112
8367
  const eventType = e.attr(element, 'up-emit');
@@ -8135,7 +8390,7 @@ up.event = (function () {
8135
8390
  assertEmitted,
8136
8391
  onEscape,
8137
8392
  halt,
8138
- isUnmodified,
8393
+ isModified,
8139
8394
  isSyntheticClick,
8140
8395
  fork,
8141
8396
  keyModifiers,
@@ -8148,14 +8403,14 @@ up.emit = up.event.emit;
8148
8403
 
8149
8404
 
8150
8405
  /***/ }),
8151
- /* 82 */
8406
+ /* 85 */
8152
8407
  /***/ (() => {
8153
8408
 
8154
8409
  up.protocol = (function () {
8155
8410
  const u = up.util;
8156
8411
  const e = up.element;
8157
8412
  const headerize = function (camel) {
8158
- const header = camel.replace(/(^.|[A-Z])/g, char => '-' + char.toUpperCase());
8413
+ const header = camel.replace(/(^.|[A-Z])/g, (char) => '-' + char.toUpperCase());
8159
8414
  return 'X-Up' + header;
8160
8415
  };
8161
8416
  const extractHeader = function (xhr, shortHeader, parseFn = u.identity) {
@@ -8195,6 +8450,9 @@ up.protocol = (function () {
8195
8450
  function eventPlansFromXHR(xhr) {
8196
8451
  return extractHeader(xhr, 'events', u.parseRelaxedJSON);
8197
8452
  }
8453
+ function openLayerFromXHR(xhr) {
8454
+ return extractHeader(xhr, 'openLayer', u.parseRelaxedJSON);
8455
+ }
8198
8456
  function acceptLayerFromXHR(xhr) {
8199
8457
  return extractHeader(xhr, 'acceptLayer', u.parseRelaxedJSON);
8200
8458
  }
@@ -8230,21 +8488,27 @@ up.protocol = (function () {
8230
8488
  function cspNonce() {
8231
8489
  return u.evalOption(config.cspNonce);
8232
8490
  }
8233
- function cspNoncesFromHeader(cspHeader) {
8234
- let nonces = [];
8491
+ const NONCE_PATTERN = /'nonce-([^']+)'/g;
8492
+ function findNonces(cspPart) {
8493
+ let matches = cspPart.matchAll(NONCE_PATTERN);
8494
+ return u.map(matches, '1');
8495
+ }
8496
+ function cspInfoFromHeader(cspHeader) {
8497
+ var _a;
8498
+ let results = {};
8235
8499
  if (cspHeader) {
8236
- let parts = cspHeader.split(/\s*;\s*/);
8237
- for (let part of parts) {
8238
- if (part.indexOf('script-src') === 0) {
8239
- let noncePattern = /'nonce-([^']+)'/g;
8240
- let match;
8241
- while (match = noncePattern.exec(part)) {
8242
- nonces.push(match[1]);
8243
- }
8500
+ let declarations = cspHeader.split(/\s*;\s*/);
8501
+ for (let declaration of declarations) {
8502
+ let directive = (_a = declaration.match(/^(script|default)-src:/)) === null || _a === void 0 ? void 0 : _a[1];
8503
+ if (directive) {
8504
+ results[directive] = {
8505
+ declaration: declaration,
8506
+ nonces: findNonces(declaration)
8507
+ };
8244
8508
  }
8245
8509
  }
8246
8510
  }
8247
- return nonces;
8511
+ return results.script || results.default || {};
8248
8512
  }
8249
8513
  function wrapMethod(method, params) {
8250
8514
  params.add(config.methodParam, method);
@@ -8256,6 +8520,7 @@ up.protocol = (function () {
8256
8520
  titleFromXHR,
8257
8521
  targetFromXHR,
8258
8522
  methodFromXHR,
8523
+ openLayerFromXHR,
8259
8524
  acceptLayerFromXHR,
8260
8525
  contextFromXHR,
8261
8526
  dismissLayerFromXHR,
@@ -8269,13 +8534,13 @@ up.protocol = (function () {
8269
8534
  initialRequestMethod,
8270
8535
  headerize,
8271
8536
  wrapMethod,
8272
- cspNoncesFromHeader,
8537
+ cspInfoFromHeader,
8273
8538
  };
8274
8539
  })();
8275
8540
 
8276
8541
 
8277
8542
  /***/ }),
8278
- /* 83 */
8543
+ /* 86 */
8279
8544
  /***/ (() => {
8280
8545
 
8281
8546
  up.log = (function () {
@@ -8288,24 +8553,26 @@ up.log = (function () {
8288
8553
  }
8289
8554
  const printToWarn = (...args) => printToStream('warn', ...args);
8290
8555
  const printToError = (...args) => printToStream('error', ...args);
8291
- function printToStream(stream, trace, message, ...args) {
8292
- printToStreamStyled(stream, trace, '', message, ...args);
8556
+ function printToStream(stream, prefix, message, ...args) {
8557
+ printToStreamStyled(stream, prefix, '', message, ...args);
8293
8558
  }
8294
- function printToStreamStyled(stream, trace, customStyles, message, ...args) {
8559
+ function printToStreamStyled(stream, prefix, customStyles, message, ...args) {
8295
8560
  if (message) {
8296
8561
  if (config.format) {
8297
- console[stream](`%c${trace}%c ${message}`, 'color: #666666; padding: 1px 3px; border: 1px solid #bbbbbb; border-radius: 2px; font-size: 90%; display: inline-block;' + customStyles, '', ...args);
8562
+ console[stream](`%c${prefix}%c ${message}`, 'color: #666666; padding: 1px 3px; border: 1px solid #bbbbbb; border-radius: 2px; font-size: 90%; display: inline-block;' + customStyles, '', ...args);
8298
8563
  }
8299
8564
  else {
8300
- console[stream](`[${trace}] ${u.sprintf(message, ...args)}`);
8565
+ console[stream](`[${prefix}] ${u.sprintf(message, ...args)}`);
8301
8566
  }
8302
8567
  }
8303
8568
  }
8569
+ let lastPrintedUserEvent;
8304
8570
  function printUserEvent(event) {
8305
- if (config.enabled) {
8306
- event = event.originalEvent || event;
8571
+ if (config.enabled && lastPrintedUserEvent !== event) {
8572
+ lastPrintedUserEvent = event;
8573
+ let originalEvent = event.originalEvent || event;
8307
8574
  let color = '#5566cc';
8308
- printToStreamStyled('log', event.type, `color: white; border-color: ${color}; background-color: ${color}`, 'Interaction on %o', event.target);
8575
+ printToStreamStyled('log', originalEvent.type, `color: white; border-color: ${color}; background-color: ${color}`, 'Interaction on %o', originalEvent.target);
8309
8576
  }
8310
8577
  }
8311
8578
  function printBanner() {
@@ -8356,7 +8623,7 @@ up.warn = up.log.warn;
8356
8623
 
8357
8624
 
8358
8625
  /***/ }),
8359
- /* 84 */
8626
+ /* 87 */
8360
8627
  /***/ (() => {
8361
8628
 
8362
8629
  up.script = (function () {
@@ -8407,6 +8674,7 @@ up.script = (function () {
8407
8674
  '[up-expand]': -300,
8408
8675
  '[data-method]': -400,
8409
8676
  '[data-confirm]': -400,
8677
+ '[up-keep]': 9999999999,
8410
8678
  };
8411
8679
  let registeredCompilers = [];
8412
8680
  let registeredMacros = [];
@@ -8534,16 +8802,41 @@ up.script = (function () {
8534
8802
  up.event.assertEmitted('up:assets:changed', { oldAssets, newAssets, renderOptions });
8535
8803
  }
8536
8804
  }
8537
- function disableScript(scriptElement) {
8538
- scriptElement.type = 'up-disabled-script';
8805
+ function disableScriptsInSubtree(root, guard = () => true) {
8806
+ for (let script of findScripts(root)) {
8807
+ if (guard(script)) {
8808
+ script.type = 'up-disabled-script';
8809
+ }
8810
+ }
8539
8811
  }
8540
- function disableScriptsInSubtree(root) {
8541
- let selector = config.selector('scriptSelectors');
8542
- u.each(e.subtree(root, selector), disableScript);
8812
+ function findScripts(root, selectorSuffix = '') {
8813
+ let selector = config.selector('scriptSelectors') + selectorSuffix;
8814
+ return e.subtree(root, selector);
8543
8815
  }
8544
8816
  function isScript(value) {
8545
8817
  return config.matches(value, 'scriptSelectors');
8546
8818
  }
8819
+ function adoptNoncesInSubtree(root, responseNonces) {
8820
+ let pageNonce = up.protocol.cspNonce();
8821
+ if (!(responseNonces === null || responseNonces === void 0 ? void 0 : responseNonces.length) || !pageNonce)
8822
+ return;
8823
+ for (let script of findScripts(root, '[nonce]')) {
8824
+ if (responseNonces.includes(script.nonce)) {
8825
+ script.nonce = pageNonce;
8826
+ }
8827
+ }
8828
+ for (let attribute of config.nonceableAttributes) {
8829
+ let matches = e.subtree(root, `[${attribute}^="nonce-"]`);
8830
+ for (let match of matches) {
8831
+ let attributeValue = match.getAttribute(attribute);
8832
+ let callback = up.NonceableCallback.fromString(attributeValue);
8833
+ if (responseNonces.includes(callback.nonce)) {
8834
+ callback.nonce = pageNonce;
8835
+ match.setAttribute(attribute, callback.toString());
8836
+ }
8837
+ }
8838
+ }
8839
+ }
8547
8840
  function reset() {
8548
8841
  registeredCompilers = u.filter(registeredCompilers, 'isDefault');
8549
8842
  registeredMacros = u.filter(registeredMacros, 'isDefault');
@@ -8561,6 +8854,7 @@ up.script = (function () {
8561
8854
  findAssets,
8562
8855
  assertAssetsOK,
8563
8856
  disableSubtree: disableScriptsInSubtree,
8857
+ adoptNoncesInSubtree,
8564
8858
  isScript,
8565
8859
  };
8566
8860
  })();
@@ -8573,7 +8867,7 @@ up.attribute = up.script.attrCompiler;
8573
8867
 
8574
8868
 
8575
8869
  /***/ }),
8576
- /* 85 */
8870
+ /* 88 */
8577
8871
  /***/ (() => {
8578
8872
 
8579
8873
  up.history = (function () {
@@ -8599,60 +8893,78 @@ up.history = (function () {
8599
8893
  }));
8600
8894
  let previousLocation;
8601
8895
  let nextPreviousLocation;
8896
+ let nextTrackOptions;
8897
+ let adoptedBases = new up.FIFOCache({ capacity: 100, normalizeKey: getBase });
8898
+ function isAdopted(location) {
8899
+ return !!adoptedBases.get(location);
8900
+ }
8602
8901
  function reset() {
8603
8902
  previousLocation = undefined;
8604
8903
  nextPreviousLocation = undefined;
8605
- trackCurrentLocation();
8904
+ nextTrackOptions = undefined;
8905
+ adoptedBases.clear();
8906
+ trackCurrentLocation({ reason: null, alreadyHandled: true });
8907
+ adopt();
8606
8908
  }
8607
8909
  function currentLocation() {
8608
8910
  return u.normalizeURL(location.href);
8609
8911
  }
8610
- function trackCurrentLocation() {
8611
- const url = currentLocation();
8612
- if (nextPreviousLocation !== url) {
8912
+ function trackCurrentLocation(trackOptions) {
8913
+ var _a, _b;
8914
+ let { reason, alreadyHandled } = nextTrackOptions || trackOptions;
8915
+ let location = currentLocation();
8916
+ if (nextPreviousLocation !== location) {
8613
8917
  previousLocation = nextPreviousLocation;
8614
- nextPreviousLocation = url;
8918
+ nextPreviousLocation = location;
8919
+ if (reason === 'detect') {
8920
+ reason = (getBase(location) === getBase(previousLocation)) ? 'hash' : 'pop';
8921
+ }
8922
+ let willHandle = !alreadyHandled && isAdopted(location);
8923
+ let locationChangedEvent = up.event.build('up:location:changed', {
8924
+ reason,
8925
+ location,
8926
+ previousLocation,
8927
+ alreadyHandled,
8928
+ willHandle,
8929
+ log: `New location is ${location}`
8930
+ });
8931
+ (_b = (_a = up.migrate).prepareLocationChangedEvent) === null || _b === void 0 ? void 0 : _b.call(_a, locationChangedEvent);
8932
+ if (reason) {
8933
+ up.emit(locationChangedEvent);
8934
+ reactToChange(locationChangedEvent);
8935
+ }
8615
8936
  }
8616
8937
  }
8617
- trackCurrentLocation();
8938
+ function splitLocation(location) {
8939
+ return (location === null || location === void 0 ? void 0 : location.split(/(?=#)/)) || [];
8940
+ }
8941
+ function getBase(location) {
8942
+ return splitLocation(location)[0];
8943
+ }
8618
8944
  function isLocation(url, options) {
8619
8945
  return u.matchURLs(url, location.href, Object.assign({ hash: true }, options));
8620
8946
  }
8621
- function replace(location, options = {}) {
8622
- location = u.normalizeURL(location);
8623
- if (manipulate('replaceState', location) && (options.event !== false)) {
8624
- emitLocationChanged({ location, reason: 'replace', log: `Replaced state for ${location}` });
8625
- }
8626
- }
8627
- function push(location) {
8628
- location = u.normalizeURL(location);
8629
- if (!isLocation(location) && manipulate('pushState', location)) {
8630
- emitLocationChanged({ location, reason: 'push', log: `Advanced to location ${location}` });
8631
- }
8947
+ function replace(location, trackOptions) {
8948
+ placeAdoptedHistoryEntry('replaceState', location, trackOptions);
8632
8949
  }
8633
- function emitLocationChanged(props) {
8634
- var _a, _b;
8635
- let event = up.event.build('up:location:changed', props);
8636
- (_b = (_a = up.migrate) === null || _a === void 0 ? void 0 : _a.renamedProperty) === null || _b === void 0 ? void 0 : _b.call(_a, event, 'url', 'location');
8637
- up.emit(event);
8950
+ function push(location, trackOptions) {
8951
+ if (isLocation(location))
8952
+ return;
8953
+ placeAdoptedHistoryEntry('pushState', location, trackOptions);
8638
8954
  }
8639
- function manipulate(method, url) {
8955
+ function placeAdoptedHistoryEntry(method, location, trackOptions) {
8956
+ adopt(location);
8640
8957
  if (config.enabled) {
8641
- const state = buildState();
8642
- window.history[method](state, '', url);
8643
- trackCurrentLocation();
8644
- return true;
8958
+ nextTrackOptions = trackOptions;
8959
+ history[method](null, '', location);
8960
+ nextTrackOptions = undefined;
8645
8961
  }
8646
8962
  }
8647
- function buildState() {
8648
- return { up: {} };
8963
+ function adopt(location = currentLocation()) {
8964
+ location = u.normalizeURL(location);
8965
+ adoptedBases.set(location, true);
8649
8966
  }
8650
- function restoreStateOnPop(state) {
8651
- if (!(state === null || state === void 0 ? void 0 : state.up)) {
8652
- up.puts('popstate', 'Ignoring a history state not owned by Unpoly');
8653
- return;
8654
- }
8655
- let location = currentLocation();
8967
+ function restoreLocation(location) {
8656
8968
  up.error.muteUncriticalRejection(up.render({
8657
8969
  guardEvent: up.event.build('up:location:restore', { location, log: `Restoring location ${location}` }),
8658
8970
  url: location,
@@ -8670,28 +8982,23 @@ up.history = (function () {
8670
8982
  focus: ['restore', 'auto'],
8671
8983
  }));
8672
8984
  }
8673
- function onPop(event) {
8674
- trackCurrentLocation();
8675
- let location = currentLocation();
8676
- emitLocationChanged({ location, reason: 'pop', log: `Navigated to history entry ${location}` });
8677
- up.viewport.saveFocus({ location: previousLocation });
8678
- up.viewport.saveScroll({ location: previousLocation });
8679
- restoreStateOnPop(event.state);
8680
- }
8681
- function register() {
8682
- window.addEventListener('popstate', onPop);
8683
- if (up.protocol.initialRequestMethod() === 'GET') {
8684
- replace(currentLocation(), { event: false });
8985
+ function reactToChange(event) {
8986
+ if (event.alreadyHandled) {
8987
+ return;
8685
8988
  }
8686
- }
8687
- up.on('up:framework:boot', function () {
8688
- if ('jasmine' in window) {
8689
- register();
8989
+ if (!event.willHandle) {
8990
+ up.puts('up.history', 'Ignoring history entry owned by foreign script');
8991
+ return;
8690
8992
  }
8691
- else {
8692
- setTimeout(register, 100);
8993
+ if (event.reason === 'pop') {
8994
+ up.viewport.saveFocus({ location: event.previousLocation });
8995
+ up.viewport.saveScroll({ location: event.previousLocation });
8996
+ restoreLocation(event.location);
8693
8997
  }
8694
- });
8998
+ else if (event.reason === 'hash') {
8999
+ up.viewport.revealHash(location.hash, { strong: true });
9000
+ }
9001
+ }
8695
9002
  function findMetaTags(head = document.head) {
8696
9003
  return head.querySelectorAll(config.selector('metaTagSelectors'));
8697
9004
  }
@@ -8713,6 +9020,62 @@ up.history = (function () {
8713
9020
  function updateLang(newLang) {
8714
9021
  e.setAttrPresence(e.root, 'lang', newLang, !!newLang);
8715
9022
  }
9023
+ function patchHistoryAPI() {
9024
+ const originalPushState = history.pushState;
9025
+ history.pushState = function (...args) {
9026
+ originalPushState.apply(this, args);
9027
+ trackCurrentLocation({ reason: 'push', alreadyHandled: true });
9028
+ };
9029
+ const originalReplaceState = history.replaceState;
9030
+ history.replaceState = function (...args) {
9031
+ originalReplaceState.apply(this, args);
9032
+ trackCurrentLocation({ reason: 'replace', alreadyHandled: true });
9033
+ };
9034
+ }
9035
+ function adoptInitialHistoryEntry() {
9036
+ if (up.protocol.initialRequestMethod() === 'GET') {
9037
+ adopt();
9038
+ }
9039
+ }
9040
+ up.on('up:framework:boot', function ({ mode }) {
9041
+ trackCurrentLocation({ reason: null, alreadyHandled: true });
9042
+ patchHistoryAPI();
9043
+ adoptInitialHistoryEntry();
9044
+ if (mode === 'auto') {
9045
+ up.viewport.revealHash(location.hash, { strong: true });
9046
+ }
9047
+ });
9048
+ up.on(window, 'hashchange, popstate', () => {
9049
+ trackCurrentLocation({ reason: 'detect', alreadyHandled: false });
9050
+ });
9051
+ function onJumpLinkClicked(event, link) {
9052
+ var _a;
9053
+ if (event.defaultPrevented)
9054
+ return;
9055
+ if (up.event.isModified(event))
9056
+ return;
9057
+ let [currentBase, currentHash] = splitLocation(up.layer.current.location);
9058
+ let [linkBase, linkHash] = splitLocation(u.normalizeURL(link));
9059
+ let verbatimHREF = link.getAttribute('href');
9060
+ let isJumpLink = (currentBase === linkBase) || verbatimHREF.startsWith('#');
9061
+ if (!isJumpLink)
9062
+ return;
9063
+ let behavior = (_a = link.getAttribute('up-scroll-behavior')) !== null && _a !== void 0 ? _a : 'auto';
9064
+ let layer = up.layer.get(link);
9065
+ let revealFn = up.viewport.revealHashFn(linkHash, { layer, behavior });
9066
+ if (revealFn) {
9067
+ up.event.halt(event);
9068
+ up.log.putsEvent(event);
9069
+ if (linkHash !== currentHash && layer.showsLiveHistory()) {
9070
+ let newHREF = currentBase + linkHash;
9071
+ push(newHREF, { reason: 'hash', alreadyHandled: true });
9072
+ }
9073
+ revealFn();
9074
+ }
9075
+ else {
9076
+ }
9077
+ }
9078
+ up.on('up:click', 'a[href*="#"]', onJumpLinkClicked);
8716
9079
  up.macro('[up-back]', function (link) {
8717
9080
  if (previousLocation) {
8718
9081
  e.setMissingAttrs(link, {
@@ -8740,10 +9103,10 @@ up.history = (function () {
8740
9103
 
8741
9104
 
8742
9105
  /***/ }),
8743
- /* 86 */
9106
+ /* 89 */
8744
9107
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8745
9108
 
8746
- __webpack_require__(87);
9109
+ __webpack_require__(90);
8747
9110
  const u = up.util;
8748
9111
  const e = up.element;
8749
9112
  up.fragment = (function () {
@@ -8788,6 +9151,7 @@ up.fragment = (function () {
8788
9151
  saveScroll: true,
8789
9152
  saveFocus: true,
8790
9153
  focus: 'keep',
9154
+ focusVisible: 'auto',
8791
9155
  abort: 'target',
8792
9156
  failOptions: true,
8793
9157
  feedback: true,
@@ -8802,12 +9166,13 @@ up.fragment = (function () {
8802
9166
  peel: true,
8803
9167
  },
8804
9168
  match: 'region',
8805
- runScripts: true,
9169
+ runScripts: false,
8806
9170
  autoHistoryTargets: [':main'],
8807
9171
  autoFocus: ['hash', 'autofocus', 'main-if-main', 'keep', 'target-if-lost'],
8808
9172
  autoScroll: ['hash', 'layer-if-main'],
8809
9173
  autoRevalidate: (response) => response.expired,
8810
9174
  skipResponse: defaultSkipResponse,
9175
+ normalizeKeepHTML: defaultNormalizeKeepHTML
8811
9176
  }));
8812
9177
  u.delegate(config, ['mainTargets'], () => up.layer.config.any);
8813
9178
  function defaultSkipResponse({ response, expiredResponse }) {
@@ -8843,17 +9208,85 @@ up.fragment = (function () {
8843
9208
  const options = parseTargetAndOptions(args);
8844
9209
  return render(Object.assign(Object.assign({}, options), { navigate: true }));
8845
9210
  });
9211
+ function emitFragmentKeep(keepPlan) {
9212
+ let { oldElement, newElement: newFragment, newData, renderOptions } = keepPlan;
9213
+ const log = ['Keeping fragment %o', oldElement];
9214
+ const callback = e.callbackAttr(keepPlan.oldElement, 'up-on-keep', { exposedKeys: ['newFragment', 'newData'] });
9215
+ const event = up.event.build('up:fragment:keep', { newFragment, newData, renderOptions });
9216
+ return up.emit(oldElement, event, { log, callback });
9217
+ }
9218
+ function findKeepPlan(options) {
9219
+ if (options.keep === false)
9220
+ return;
9221
+ const { oldElement, newElement } = options;
9222
+ let oldElementMode = keepMode(oldElement);
9223
+ if (!oldElementMode) {
9224
+ return;
9225
+ }
9226
+ let partner;
9227
+ let partnerSelector = up.fragment.toTarget(oldElement);
9228
+ const lookupOpts = { layer: options.layer };
9229
+ if (options.descendantsOnly) {
9230
+ partner = up.fragment.get(newElement, partnerSelector, lookupOpts);
9231
+ }
9232
+ else {
9233
+ partner = e.subtreeFirst(newElement, partnerSelector, lookupOpts);
9234
+ }
9235
+ if (!partner)
9236
+ return;
9237
+ let partnerMode = keepMode(partner);
9238
+ if (partnerMode === false)
9239
+ return;
9240
+ let oldIdentity = keepIdentity(oldElement, oldElementMode);
9241
+ let partnerIdentity = keepIdentity(partner, oldElementMode);
9242
+ if (!u.isEqual(oldIdentity, partnerIdentity))
9243
+ return;
9244
+ const plan = {
9245
+ oldElement,
9246
+ newElement: partner,
9247
+ newData: up.script.data(partner),
9248
+ renderOptions: options,
9249
+ };
9250
+ if (emitFragmentKeep(plan).defaultPrevented)
9251
+ return;
9252
+ return plan;
9253
+ }
9254
+ function keepIdentity(element, mode = keepMode(element)) {
9255
+ var _a;
9256
+ return (_a = element.upKeepIdentity) !== null && _a !== void 0 ? _a : (element.upKeepIdentity = u.copy(buildKeepIdentity(element, mode)));
9257
+ }
9258
+ function defaultNormalizeKeepHTML(html) {
9259
+ let tagPattern = /<[^<]+>/g;
9260
+ let attrs = ['up-etag', 'up-source', 'up-time', 'nonce', ...up.script.config.nonceableAttributes];
9261
+ let attrPattern = new RegExp(`\\s+(${attrs.join('|')})="[^"]*"`, 'g');
9262
+ let cleanTag = (match) => match.replace(attrPattern, '');
9263
+ html = html.replace(tagPattern, cleanTag);
9264
+ html = html.replace(/^[ \t]+/mg, '');
9265
+ return html;
9266
+ }
9267
+ function buildKeepIdentity(element, mode) {
9268
+ if (mode === 'same-html') {
9269
+ return config.normalizeKeepHTML(element.outerHTML);
9270
+ }
9271
+ else if (mode === 'same-data') {
9272
+ return up.data(element);
9273
+ }
9274
+ else {
9275
+ return true;
9276
+ }
9277
+ }
9278
+ up.macro('[up-keep]', (element) => keepIdentity(element));
9279
+ function keepMode(element) {
9280
+ return e.booleanOrStringAttr(element, 'up-keep');
9281
+ }
8846
9282
  function emitFragmentInserted(element) {
9283
+ if (element.upInserted)
9284
+ return;
9285
+ element.upInserted = true;
8847
9286
  return up.emit(element, 'up:fragment:inserted', {
8848
9287
  log: ['Inserted fragment %o', element],
8849
9288
  });
8850
9289
  }
8851
- function emitFragmentKeep(keepPlan) {
8852
- let { oldElement, newElement: newFragment, newData, renderOptions } = keepPlan;
8853
- const log = ['Keeping fragment %o', oldElement];
8854
- const callback = e.callbackAttr(oldElement, 'up-on-keep', { exposedKeys: ['newFragment', 'newData'] });
8855
- return up.emit(oldElement, 'up:fragment:keep', { newFragment, newData, renderOptions, log, callback });
8856
- }
8857
9290
  function emitFragmentDestroyed(fragment, options) {
8858
9291
  var _a;
8859
9292
  const log = (_a = options.log) !== null && _a !== void 0 ? _a : ['Destroyed fragment %o', fragment];
@@ -8931,7 +9364,7 @@ up.fragment = (function () {
8931
9364
  }
8932
9365
  function markFragmentAsDestroying(element) {
8933
9366
  element.classList.add('up-destroying');
8934
- element.setAttribute('aria-hidden', 'true');
9367
+ element.setAttribute('inert', '');
8935
9368
  }
8936
9369
  function reload(...args) {
8937
9370
  var _a, _b;
@@ -8989,8 +9422,8 @@ up.fragment = (function () {
8989
9422
  function toTarget(element, options) {
8990
9423
  return u.presence(element, u.isString) || tryToTarget(element, options) || cannotTarget(element);
8991
9424
  }
8992
- function isTargetable(element) {
8993
- return !!tryToTarget(element);
9425
+ function isTargetable(element, options) {
9426
+ return !!tryToTarget(element, options);
8994
9427
  }
8995
9428
  function untargetableMessage(element) {
8996
9429
  return `Cannot derive good target selector from a <${e.tagName(element)}> element without identifying attributes. Try setting an [id] or configure up.fragment.config.targetDerivers.`;
@@ -9208,7 +9641,7 @@ up.fragment = (function () {
9208
9641
  if (steps.length < 2)
9209
9642
  return steps;
9210
9643
  let compressed = u.uniqBy(steps, 'oldElement');
9211
- compressed = u.reject(compressed, step => isContainedByRivalStep(compressed, step));
9644
+ compressed = u.reject(compressed, (step) => isContainedByRivalStep(compressed, step));
9212
9645
  return compressed;
9213
9646
  }
9214
9647
  function abort(...args) {
@@ -9306,10 +9739,15 @@ up.fragment = (function () {
9306
9739
  return () => up.destroy(tempElement);
9307
9740
  }
9308
9741
  }
9742
+ function trackSelector(...args) {
9743
+ let parsedArgs = u.args(args, 'val', 'options', 'callback');
9744
+ let tracker = new up.SelectorTracker(...parsedArgs);
9745
+ return tracker.start();
9746
+ }
9309
9747
  up.on('up:framework:boot', function () {
9310
9748
  const { documentElement } = document;
9311
- documentElement.setAttribute('up-source', normalizeSource(location.href));
9312
9749
  up.hello(documentElement);
9750
+ documentElement.setAttribute('up-source', normalizeSource(location.href));
9313
9751
  if (!up.browser.canPushState()) {
9314
9752
  return up.warn('Cannot push history changes. Next render pass with history will load a full page.');
9315
9753
  }
@@ -9333,6 +9771,8 @@ up.fragment = (function () {
9333
9771
  emitInserted: emitFragmentInserted,
9334
9772
  emitDestroyed: emitFragmentDestroyed,
9335
9773
  emitKeep: emitFragmentKeep,
9774
+ keepPlan: findKeepPlan,
9775
+ defaultNormalizeKeepHTML,
9336
9776
  successKey,
9337
9777
  failKey,
9338
9778
  expandTargets,
@@ -9358,6 +9798,7 @@ up.fragment = (function () {
9358
9798
  insertTemp,
9359
9799
  provideNodes,
9360
9800
  cloneTemplate,
9801
+ trackSelector,
9361
9802
  };
9362
9803
  })();
9363
9804
  up.reload = up.fragment.reload;
@@ -9370,16 +9811,16 @@ u.delegate(up, ['context'], () => up.layer.current);
9370
9811
 
9371
9812
 
9372
9813
  /***/ }),
9373
- /* 87 */
9814
+ /* 90 */
9374
9815
  /***/ (() => {
9375
9816
 
9376
9817
 
9377
9818
 
9378
9819
  /***/ }),
9379
- /* 88 */
9820
+ /* 91 */
9380
9821
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9381
9822
 
9382
- __webpack_require__(89);
9823
+ __webpack_require__(92);
9383
9824
  up.viewport = (function () {
9384
9825
  const u = up.util;
9385
9826
  const e = up.element;
@@ -9442,10 +9883,26 @@ up.viewport = (function () {
9442
9883
  doFocus(element, options);
9443
9884
  return element === document.activeElement;
9444
9885
  }
9445
- function revealHash(hash = location.hash, options) {
9446
- let match = firstHashTarget(hash, options);
9886
+ function revealHash(...args) {
9887
+ var _a;
9888
+ return (_a = revealHashFn(...args)) === null || _a === void 0 ? void 0 : _a();
9889
+ }
9890
+ function revealHashFn(hash, { strong, layer, origin, behavior = 'instant' } = {}) {
9891
+ if (!hash)
9892
+ return;
9893
+ let match = firstHashTarget(hash, { layer, origin });
9447
9894
  if (match) {
9448
- return reveal(match, { top: true });
9895
+ return () => {
9896
+ let doReveal = () => reveal(match, { top: true, behavior });
9897
+ if (strong)
9898
+ u.task(doReveal);
9899
+ return doReveal();
9900
+ };
9901
+ }
9902
+ else if (hash === '#top') {
9903
+ return () => {
9904
+ return scrollTo(0, { behavior });
9905
+ };
9449
9906
  }
9450
9907
  }
9451
9908
  function allSelector() {
@@ -9517,7 +9974,7 @@ up.viewport = (function () {
9517
9974
  const { location } = options.layer;
9518
9975
  const locationScrollTops = options.layer.lastScrollTops.get(location);
9519
9976
  if (locationScrollTops) {
9520
- setScrollTops(viewports, locationScrollTops);
9977
+ setScrollPositions(viewports, locationScrollTops, 0);
9521
9978
  up.puts('up.viewport.restoreScroll()', 'Restored scroll positions to %o', locationScrollTops);
9522
9979
  return true;
9523
9980
  }
@@ -9563,14 +10020,16 @@ up.viewport = (function () {
9563
10020
  }
9564
10021
  return [viewports, options];
9565
10022
  }
9566
- function resetScroll(...args) {
9567
- const [viewports, _options] = parseOptions(args);
9568
- setScrollTops(viewports, {});
10023
+ function scrollTo(position, ...args) {
10024
+ const [viewports, options] = parseOptions(args);
10025
+ setScrollPositions(viewports, {}, position, options.behavior);
10026
+ return true;
9569
10027
  }
9570
- function setScrollTops(viewports, tops) {
10028
+ function setScrollPositions(viewports, tops, defaultTop, behavior = 'instant') {
9571
10029
  for (let viewport of viewports) {
9572
10030
  const key = scrollTopKey(viewport);
9573
- viewport.scrollTop = tops[key] || 0;
10031
+ const top = tops[key] || defaultTop;
10032
+ viewport.scrollTo({ top, behavior });
9574
10033
  }
9575
10034
  }
9576
10035
  function absolutize(element, options = {}) {
@@ -9612,7 +10071,8 @@ up.viewport = (function () {
9612
10071
  };
9613
10072
  }
9614
10073
  function firstHashTarget(hash, options = {}) {
9615
- if (hash = pureHash(hash)) {
10074
+ hash = pureHash(hash);
10075
+ if (hash) {
9616
10076
  const selector = [
9617
10077
  e.idSelector(hash),
9618
10078
  'a' + e.attrSelector('name', hash)
@@ -9640,22 +10100,10 @@ up.viewport = (function () {
9640
10100
  }
9641
10101
  return to;
9642
10102
  }
9643
- document.addEventListener('DOMContentLoaded', function () {
9644
- revealHash();
9645
- u.task(revealHash);
9646
- });
9647
- up.on(window, 'hashchange', () => revealHash());
9648
- up.on('up:click', 'a[href^="#"]', function (event, link) {
9649
- if (link.hash !== location.hash)
9650
- return;
9651
- if (up.link.isFollowable(link))
9652
- return;
9653
- if (revealHash(link.hash))
9654
- up.event.halt(event);
9655
- });
9656
10103
  return {
9657
10104
  reveal,
9658
10105
  revealHash,
10106
+ revealHashFn,
9659
10107
  firstHashTarget,
9660
10108
  config,
9661
10109
  get: closest,
@@ -9668,7 +10116,7 @@ up.viewport = (function () {
9668
10116
  rootScrollbarWidth,
9669
10117
  saveScroll,
9670
10118
  restoreScroll,
9671
- resetScroll,
10119
+ scrollTo,
9672
10120
  saveFocus,
9673
10121
  restoreFocus,
9674
10122
  absolutize,
@@ -9685,13 +10133,13 @@ up.reveal = up.viewport.reveal;
9685
10133
 
9686
10134
 
9687
10135
  /***/ }),
9688
- /* 89 */
10136
+ /* 92 */
9689
10137
  /***/ (() => {
9690
10138
 
9691
10139
 
9692
10140
 
9693
10141
  /***/ }),
9694
- /* 90 */
10142
+ /* 93 */
9695
10143
  /***/ (function() {
9696
10144
 
9697
10145
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -9706,21 +10154,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9706
10154
  up.motion = (function () {
9707
10155
  const u = up.util;
9708
10156
  const e = up.element;
9709
- let namedAnimations = {};
9710
- let namedTransitions = {};
9711
10157
  const motionController = new up.MotionController('motion');
9712
10158
  const config = new up.Config(() => ({
9713
10159
  duration: 175,
9714
10160
  easing: 'ease',
9715
10161
  enabled: !matchMedia('(prefers-reduced-motion: reduce)').matches
9716
10162
  }));
9717
- function pickDefault(registry) {
9718
- return u.pickBy(registry, 'isDefault');
9719
- }
10163
+ let namedAnimations = new up.Registry('animation', findAnimationFn);
10164
+ let namedTransitions = new up.Registry('transition', findTransitionFn);
9720
10165
  function reset() {
9721
10166
  motionController.reset();
9722
- namedAnimations = pickDefault(namedAnimations);
9723
- namedTransitions = pickDefault(namedTransitions);
9724
10167
  }
9725
10168
  function isEnabled() {
9726
10169
  return config.enabled;
@@ -9751,7 +10194,7 @@ up.motion = (function () {
9751
10194
  }
9752
10195
  function animateNow(element, lastFrame, options) {
9753
10196
  if (up.migrate.loaded)
9754
- lastFrame = up.migrate.fixStyleProps(lastFrame);
10197
+ lastFrame = up.migrate.fixSetStyleProps(lastFrame);
9755
10198
  options = Object.assign(Object.assign({}, options), { finishEvent: motionController.finishEvent });
9756
10199
  const cssTransition = new up.CSSTransition(element, lastFrame, options);
9757
10200
  return cssTransition.start();
@@ -9761,9 +10204,6 @@ up.motion = (function () {
9761
10204
  (_a = options.easing) !== null && _a !== void 0 ? _a : (options.easing = config.easing);
9762
10205
  (_b = options.duration) !== null && _b !== void 0 ? _b : (options.duration = config.duration);
9763
10206
  }
9764
- function findNamedAnimation(name) {
9765
- return namedAnimations[name] || up.fail("Unknown animation %o", name);
9766
- }
9767
10207
  function finish(element) {
9768
10208
  return motionController.finish(element);
9769
10209
  }
@@ -9816,27 +10256,21 @@ up.motion = (function () {
9816
10256
  return Promise.resolve();
9817
10257
  }
9818
10258
  }
9819
- function findTransitionFn(object) {
9820
- if (isNone(object)) {
10259
+ function findTransitionFn(value) {
10260
+ if (isNone(value)) {
9821
10261
  return undefined;
9822
10262
  }
9823
- else if (u.isFunction(object)) {
9824
- return object;
10263
+ else if (u.isFunction(value)) {
10264
+ return value;
9825
10265
  }
9826
- else if (u.isArray(object)) {
9827
- return composeTransitionFn(...object);
10266
+ else if (u.isArray(value)) {
10267
+ return composeTransitionFn(...value);
9828
10268
  }
9829
- else if (u.isString(object)) {
9830
- let namedTransition;
9831
- if (object.indexOf('/') >= 0) {
9832
- return composeTransitionFn(...object.split('/'));
9833
- }
9834
- else if (namedTransition = namedTransitions[object]) {
9835
- return findTransitionFn(namedTransition);
9836
- }
10269
+ else if (u.isString(value) && value.includes('/')) {
10270
+ return composeTransitionFn(...value.split('/'));
9837
10271
  }
9838
10272
  else {
9839
- up.fail("Unknown transition %o", object);
10273
+ return namedTransitions.get(value);
9840
10274
  }
9841
10275
  }
9842
10276
  function composeTransitionFn(oldAnimation, newAnimation) {
@@ -9849,21 +10283,18 @@ up.motion = (function () {
9849
10283
  ]);
9850
10284
  }
9851
10285
  }
9852
- function findAnimationFn(object) {
9853
- if (isNone(object)) {
10286
+ function findAnimationFn(value) {
10287
+ if (isNone(value)) {
9854
10288
  return undefined;
9855
10289
  }
9856
- else if (u.isFunction(object)) {
9857
- return object;
9858
- }
9859
- else if (u.isString(object)) {
9860
- return findNamedAnimation(object);
10290
+ else if (u.isFunction(value)) {
10291
+ return value;
9861
10292
  }
9862
- else if (u.isOptions(object)) {
9863
- return (element, options) => animateNow(element, object, options);
10293
+ else if (u.isOptions(value)) {
10294
+ return (element, options) => animateNow(element, value, options);
9864
10295
  }
9865
10296
  else {
9866
- up.fail('Unknown animation %o', object);
10297
+ return namedAnimations.get(value);
9867
10298
  }
9868
10299
  }
9869
10300
  const swapElementsDirectly = up.mockable(function (oldElement, newElement) {
@@ -9878,16 +10309,6 @@ up.motion = (function () {
9878
10309
  parser.number('duration');
9879
10310
  return options;
9880
10311
  }
9881
- function registerTransition(name, transition) {
9882
- const fn = findTransitionFn(transition);
9883
- fn.isDefault = up.framework.evaling;
9884
- namedTransitions[name] = fn;
9885
- }
9886
- function registerAnimation(name, animation) {
9887
- const fn = findAnimationFn(animation);
9888
- fn.isDefault = up.framework.evaling;
9889
- namedAnimations[name] = fn;
9890
- }
9891
10312
  up.on('up:framework:boot', function () {
9892
10313
  if (!isEnabled()) {
9893
10314
  up.puts('up.motion', 'Animations are disabled');
@@ -9897,9 +10318,8 @@ up.motion = (function () {
9897
10318
  return !animationOrTransition || animationOrTransition === 'none';
9898
10319
  }
9899
10320
  function registerOpacityAnimation(name, from, to) {
9900
- registerAnimation(name, function (element, options) {
9901
- element.style.opacity = 0;
9902
- e.setStyle(element, { opacity: from });
10321
+ namedAnimations.put(name, function (element, options) {
10322
+ element.style.opacity = from;
9903
10323
  return animateNow(element, { opacity: to }, options);
9904
10324
  });
9905
10325
  }
@@ -9918,12 +10338,12 @@ up.motion = (function () {
9918
10338
  function registerMoveAnimations(direction, boxToTransform) {
9919
10339
  const animationToName = `move-to-${direction}`;
9920
10340
  const animationFromName = `move-from-${direction}`;
9921
- registerAnimation(animationToName, function (element, options) {
10341
+ namedAnimations.put(animationToName, function (element, options) {
9922
10342
  const box = untranslatedBox(element);
9923
10343
  const transform = boxToTransform(box);
9924
10344
  return animateNow(element, transform, options);
9925
10345
  });
9926
- registerAnimation(animationFromName, function (element, options) {
10346
+ namedAnimations.put(animationFromName, function (element, options) {
9927
10347
  const box = untranslatedBox(element);
9928
10348
  const transform = boxToTransform(box);
9929
10349
  e.setStyle(element, transform);
@@ -9946,19 +10366,19 @@ up.motion = (function () {
9946
10366
  const travelDistance = up.viewport.rootWidth() - box.left;
9947
10367
  return translateCSS(travelDistance, 0);
9948
10368
  });
9949
- registerTransition('cross-fade', ['fade-out', 'fade-in']);
9950
- registerTransition('move-left', ['move-to-left', 'move-from-right']);
9951
- registerTransition('move-right', ['move-to-right', 'move-from-left']);
9952
- registerTransition('move-up', ['move-to-top', 'move-from-bottom']);
9953
- registerTransition('move-down', ['move-to-bottom', 'move-from-top']);
10369
+ namedTransitions.put('cross-fade', ['fade-out', 'fade-in']);
10370
+ namedTransitions.put('move-left', ['move-to-left', 'move-from-right']);
10371
+ namedTransitions.put('move-right', ['move-to-right', 'move-from-left']);
10372
+ namedTransitions.put('move-up', ['move-to-top', 'move-from-bottom']);
10373
+ namedTransitions.put('move-down', ['move-to-bottom', 'move-from-top']);
9954
10374
  up.on('up:framework:reset', reset);
9955
10375
  return {
9956
10376
  morph,
9957
10377
  animate,
9958
10378
  finish,
9959
10379
  finishCount() { return motionController.finishCount; },
9960
- transition: registerTransition,
9961
- animation: registerAnimation,
10380
+ transition: namedTransitions.put,
10381
+ animation: namedAnimations.put,
9962
10382
  config,
9963
10383
  isEnabled,
9964
10384
  isNone,
@@ -9974,10 +10394,10 @@ up.animate = up.motion.animate;
9974
10394
 
9975
10395
 
9976
10396
  /***/ }),
9977
- /* 91 */
10397
+ /* 94 */
9978
10398
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9979
10399
 
9980
- __webpack_require__(92);
10400
+ __webpack_require__(95);
9981
10401
  const u = up.util;
9982
10402
  up.network = (function () {
9983
10403
  const config = new up.Config(() => ({
@@ -9989,7 +10409,7 @@ up.network = (function () {
9989
10409
  lateDelay: 400,
9990
10410
  fail(response) { return (response.status < 200 || response.status > 299) && response.status !== 304; },
9991
10411
  autoCache(request) { return request.isSafe(); },
9992
- expireCache(request, _response) { return !request.isSafe(); },
10412
+ expireCache(request) { return !request.isSafe(); },
9993
10413
  evictCache: false,
9994
10414
  progressBar: true,
9995
10415
  timeout: 90000,
@@ -10017,6 +10437,9 @@ up.network = (function () {
10017
10437
  return options;
10018
10438
  }
10019
10439
  function processRequest(request) {
10440
+ var _a, _b, _c, _d;
10441
+ cache.expire((_b = (_a = request.expireCache) !== null && _a !== void 0 ? _a : u.evalOption(config.expireCache, request)) !== null && _b !== void 0 ? _b : false);
10442
+ cache.evict((_d = (_c = request.evictCache) !== null && _c !== void 0 ? _c : u.evalOption(config.evictCache, request)) !== null && _d !== void 0 ? _d : false);
10020
10443
  useCachedRequest(request) || queueRequest(request);
10021
10444
  }
10022
10445
  function useCachedRequest(newRequest) {
@@ -10042,29 +10465,28 @@ up.network = (function () {
10042
10465
  request.onLoading = () => cache.reindex(request);
10043
10466
  }
10044
10467
  u.always(request, function (responseOrError) {
10045
- var _a, _b, _c, _d;
10046
- let expireCache = (_b = (_a = responseOrError.expireCache) !== null && _a !== void 0 ? _a : request.expireCache) !== null && _b !== void 0 ? _b : u.evalOption(config.expireCache, request, responseOrError);
10047
- if (expireCache) {
10048
- cache.expire(expireCache, { except: request });
10049
- }
10050
- let evictCache = (_d = (_c = responseOrError.evictCache) !== null && _c !== void 0 ? _c : request.evictCache) !== null && _d !== void 0 ? _d : u.evalOption(config.evictCache, request, responseOrError);
10051
- if (evictCache) {
10052
- cache.evict(evictCache, { except: request });
10053
- }
10054
- let hasCacheEntry = cache.get(request);
10468
+ var _a, _b;
10469
+ cache.expire((_a = responseOrError.expireCache) !== null && _a !== void 0 ? _a : false, { except: request });
10470
+ cache.evict((_b = responseOrError.evictCache) !== null && _b !== void 0 ? _b : false, { except: request });
10055
10471
  let isResponse = responseOrError instanceof up.Response;
10056
10472
  let isNetworkError = !isResponse;
10057
10473
  let isSuccessResponse = isResponse && responseOrError.ok;
10058
10474
  let isErrorResponse = isResponse && !responseOrError.ok;
10059
10475
  let isEmptyResponse = isResponse && responseOrError.none;
10476
+ let redirectRequest = isResponse && responseOrError.redirectRequest;
10060
10477
  if (isErrorResponse) {
10061
10478
  cache.evict(request.url);
10062
10479
  }
10063
10480
  else if (isNetworkError || isEmptyResponse) {
10064
10481
  cache.evict(request);
10065
10482
  }
10066
- else if (isSuccessResponse && hasCacheEntry) {
10067
- cache.put(request);
10483
+ else if (isSuccessResponse) {
10484
+ if (cache.get(request)) {
10485
+ cache.put(request);
10486
+ }
10487
+ if (redirectRequest && (redirectRequest.willCache() || cache.get(redirectRequest))) {
10488
+ cache.put(redirectRequest);
10489
+ }
10068
10490
  }
10069
10491
  });
10070
10492
  }
@@ -10079,16 +10501,6 @@ up.network = (function () {
10079
10501
  (_b = (_a = up.migrate).preprocessAbortArgs) === null || _b === void 0 ? void 0 : _b.call(_a, args);
10080
10502
  queue.abort(...args);
10081
10503
  }
10082
- function registerAliasForRedirect(request, response) {
10083
- if (request.cache && response.url && request.url !== response.url) {
10084
- const newRequest = u.variant(request, {
10085
- method: response.method,
10086
- url: response.url,
10087
- cacheRoute: null,
10088
- });
10089
- cache.alias(request, newRequest);
10090
- }
10091
- }
10092
10504
  function isSafeMethod(method) {
10093
10505
  return u.contains(['GET', 'OPTIONS', 'HEAD'], u.normalizeMethod(method));
10094
10506
  }
@@ -10110,7 +10522,6 @@ up.network = (function () {
10110
10522
  isSafeMethod,
10111
10523
  config,
10112
10524
  abort: abortRequests,
10113
- registerAliasForRedirect,
10114
10525
  queue,
10115
10526
  loadPage,
10116
10527
  };
@@ -10120,13 +10531,13 @@ up.cache = up.network.cache;
10120
10531
 
10121
10532
 
10122
10533
  /***/ }),
10123
- /* 92 */
10534
+ /* 95 */
10124
10535
  /***/ (() => {
10125
10536
 
10126
10537
 
10127
10538
 
10128
10539
  /***/ }),
10129
- /* 93 */
10540
+ /* 96 */
10130
10541
  /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
10131
10542
 
10132
10543
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -10138,7 +10549,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10138
10549
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10139
10550
  });
10140
10551
  };
10141
- __webpack_require__(94);
10552
+ __webpack_require__(97);
10142
10553
  const u = up.util;
10143
10554
  const e = up.element;
10144
10555
  up.layer = (function () {
@@ -10314,7 +10725,7 @@ up.layer = (function () {
10314
10725
  });
10315
10726
  }
10316
10727
  function anySelector() {
10317
- return u.map(LAYER_CLASSES, Class => Class.selector()).join();
10728
+ return u.map(LAYER_CLASSES, (Class) => Class.selector()).join();
10318
10729
  }
10319
10730
  function optionToString(option) {
10320
10731
  if (u.isString(option)) {
@@ -10384,20 +10795,22 @@ up.layer = (function () {
10384
10795
 
10385
10796
 
10386
10797
  /***/ }),
10387
- /* 94 */
10798
+ /* 97 */
10388
10799
  /***/ (() => {
10389
10800
 
10390
10801
 
10391
10802
 
10392
10803
  /***/ }),
10393
- /* 95 */
10804
+ /* 98 */
10394
10805
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10395
10806
 
10396
- __webpack_require__(96);
10807
+ __webpack_require__(99);
10397
10808
  up.link = (function () {
10398
10809
  const u = up.util;
10399
10810
  const e = up.element;
10811
+ let lastTouchstartTarget = null;
10400
10812
  let lastMousedownTarget = null;
10813
+ let lastInstantTarget = null;
10401
10814
  const ATTRS_WITH_LOCAL_HTML = '[up-content], [up-fragment], [up-document]';
10402
10815
  const ATTRS_SUGGESTING_FOLLOW = `${ATTRS_WITH_LOCAL_HTML}, [up-target], [up-layer], [up-transition], [up-preload]`;
10403
10816
  const DEFAULT_INTERACTIVE_ELEMENT = 'a[href], button';
@@ -10427,7 +10840,9 @@ up.link = (function () {
10427
10840
  }
10428
10841
  }
10429
10842
  function reset() {
10843
+ lastTouchstartTarget = null;
10430
10844
  lastMousedownTarget = null;
10845
+ lastInstantTarget = null;
10431
10846
  }
10432
10847
  const follow = up.mockable(function (link, options, parserOptions) {
10433
10848
  return up.render(followOptions(link, options, parserOptions));
@@ -10449,6 +10864,7 @@ up.link = (function () {
10449
10864
  parser.string('contentType');
10450
10865
  parser.booleanOrNumber('lateDelay');
10451
10866
  parser.number('timeout');
10867
+ parser.booleanOrString('fail');
10452
10868
  return options;
10453
10869
  }
10454
10870
  function followOptions(link, options, parserOptions) {
@@ -10458,7 +10874,6 @@ up.link = (function () {
10458
10874
  const parser = new up.OptionsParser(link, options, Object.assign({ fail: true }, parserOptions));
10459
10875
  parser.include(parseRequestOptions);
10460
10876
  options.origin || (options.origin = link);
10461
- parser.boolean('fail');
10462
10877
  parser.boolean('navigate', { default: true });
10463
10878
  parser.string('confirm', { attr: ['up-confirm', 'data-confirm'] });
10464
10879
  parser.string('target');
@@ -10492,9 +10907,12 @@ up.link = (function () {
10492
10907
  parser.string('dismissEvent');
10493
10908
  parser.string('acceptLocation');
10494
10909
  parser.string('dismissLocation');
10495
- parser.booleanOrString('history');
10910
+ parser.booleanOrString('closeAnimation');
10911
+ parser.string('closeEasing');
10912
+ parser.number('closeDuration');
10496
10913
  parser.include(up.status.statusOptions);
10497
10914
  parser.booleanOrString('focus');
10915
+ parser.booleanOrString('focusVisible');
10498
10916
  parser.boolean('saveScroll');
10499
10917
  parser.boolean('saveFocus');
10500
10918
  parser.booleanOrString('scroll');
@@ -10519,7 +10937,7 @@ up.link = (function () {
10519
10937
  return Promise.reject(new up.Error(issue));
10520
10938
  }
10521
10939
  const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });
10522
- return follow(link, Object.assign(Object.assign(Object.assign(Object.assign({ abort: false, abortable: false, background: true, cache: true }, up.RenderOptions.NO_INPUT_INTERFERENCE), up.RenderOptions.NO_PREVIEWS), options), { guardEvent, preload: true }));
10940
+ return follow(link, Object.assign(Object.assign(Object.assign(Object.assign({ abort: false, abortable: false, background: true, cache: true }, options), up.RenderOptions.NO_INPUT_INTERFERENCE), up.RenderOptions.NO_PREVIEWS), { guardEvent, preload: true }));
10523
10941
  }
10524
10942
  function preloadIssue(link) {
10525
10943
  if (!isSafe(link)) {
@@ -10575,27 +10993,37 @@ up.link = (function () {
10575
10993
  }
10576
10994
  function convertClicks(layer) {
10577
10995
  layer.on('click', function (event, element) {
10578
- if (!up.event.isUnmodified(event)) {
10996
+ if (up.event.isModified(event)) {
10579
10997
  return;
10580
10998
  }
10581
- if (isInstant(element) && lastMousedownTarget) {
10999
+ if (isInstant(element) && lastInstantTarget === element) {
10582
11000
  up.event.halt(event);
10583
11001
  }
10584
11002
  else if (up.event.inputDevice === 'key' || up.event.isSyntheticClick(event) || (layer.wasHitByMouseEvent(event) && !didUserDragAway(event))) {
10585
11003
  forkEventAsUpClick(event);
10586
11004
  }
10587
- return lastMousedownTarget = null;
11005
+ lastMousedownTarget = null;
11006
+ lastInstantTarget = null;
11007
+ });
11008
+ layer.on('touchstart', { passive: true }, function (event, element) {
11009
+ lastTouchstartTarget = element;
10588
11010
  });
10589
11011
  layer.on('mousedown', function (event, element) {
10590
- if (!up.event.isUnmodified(event)) {
11012
+ if (up.event.isModified(event)) {
10591
11013
  return;
10592
11014
  }
10593
- lastMousedownTarget = event.target;
10594
- if (isInstant(element)) {
11015
+ lastMousedownTarget = element;
11016
+ if (isInstant(element) && !isLongPressPossible(event)) {
11017
+ lastInstantTarget = element;
10595
11018
  forkEventAsUpClick(event);
10596
11019
  }
11020
+ lastTouchstartTarget = null;
10597
11021
  });
10598
11022
  }
11023
+ function isLongPressPossible(mousedownEvent) {
11024
+ let mousedownTarget = mousedownEvent.target;
11025
+ return (lastTouchstartTarget === mousedownTarget) && mousedownTarget.closest('[href]');
11026
+ }
10599
11027
  function didUserDragAway(clickEvent) {
10600
11028
  return lastMousedownTarget && (lastMousedownTarget !== clickEvent.target);
10601
11029
  }
@@ -10684,13 +11112,13 @@ up.deferred = { load: up.link.loadDeferred };
10684
11112
 
10685
11113
 
10686
11114
  /***/ }),
10687
- /* 96 */
11115
+ /* 99 */
10688
11116
  /***/ (() => {
10689
11117
 
10690
11118
 
10691
11119
 
10692
11120
  /***/ }),
10693
- /* 97 */
11121
+ /* 100 */
10694
11122
  /***/ (() => {
10695
11123
 
10696
11124
  up.form = (function () {
@@ -10703,12 +11131,15 @@ up.form = (function () {
10703
11131
  noSubmitSelectors: ['[up-submit=false]', '[target]', e.crossOriginSelector('action')],
10704
11132
  submitButtonSelectors: ['input[type=submit]', 'input[type=image]', 'button[type=submit]', 'button:not([type])'],
10705
11133
  genericButtonSelectors: ['input[type=button]', 'button[type=button]'],
11134
+ validateBatch: true,
10706
11135
  watchInputEvents: ['input', 'change'],
10707
11136
  watchInputDelay: 0,
10708
11137
  watchChangeEvents: ['change'],
11138
+ watchableEvents: ['input', 'change'],
11139
+ arrayParam: (name) => name.endsWith('[]'),
10709
11140
  }));
10710
11141
  function fieldSelector(suffix = '') {
10711
- return config.fieldSelectors.map(field => field + suffix).join();
11142
+ return config.fieldSelectors.map((field) => field + suffix).join();
10712
11143
  }
10713
11144
  function isField(element) {
10714
11145
  return element.matches(fieldSelector());
@@ -10719,11 +11150,17 @@ up.form = (function () {
10719
11150
  if (root.matches('form[id]')) {
10720
11151
  const outsideFieldSelector = fieldSelector(e.attrSelector('form', root.getAttribute('id')));
10721
11152
  const outsideFields = up.fragment.all(outsideFieldSelector, { layer: root });
10722
- fields.push(...outsideFields);
10723
- fields = u.uniq(fields);
11153
+ fields = u.uniq([...fields, ...outsideFields]);
10724
11154
  }
10725
11155
  return fields;
10726
11156
  }
11157
+ function findFieldsAndButtons(container) {
11158
+ return [
11159
+ ...findFields(container),
11160
+ ...findSubmitButtons(container),
11161
+ ...findGenericButtons(container),
11162
+ ];
11163
+ }
10727
11164
  function findSubmitButtons(root) {
10728
11165
  return e.subtree(root, submitButtonSelector());
10729
11166
  }
@@ -10757,16 +11194,18 @@ up.form = (function () {
10757
11194
  return options;
10758
11195
  }
10759
11196
  function watchOptions(field, options, parserOptions = {}) {
10760
- var _a;
11197
+ var _a, _b, _c;
10761
11198
  options = u.options(options);
10762
- let parser = new up.OptionsParser(field, options, Object.assign(Object.assign({}, parserOptions), { closest: true, attrPrefix: 'up-watch-' }));
10763
- parser.include(up.status.statusOptions);
11199
+ (_a = parserOptions.closest) !== null && _a !== void 0 ? _a : (parserOptions.closest = true);
11200
+ (_b = parserOptions.attrPrefix) !== null && _b !== void 0 ? _b : (parserOptions.attrPrefix = 'up-watch-');
11201
+ let parser = new up.OptionsParser(field, options, parserOptions);
11202
+ parser.include(up.status.statusOptions, parserOptions);
10764
11203
  parser.string('event');
10765
11204
  parser.number('delay');
10766
11205
  let config = up.form.config;
10767
11206
  if (options.event === 'input') {
10768
11207
  options.event = u.evalOption(config.watchInputEvents, field);
10769
- (_a = options.delay) !== null && _a !== void 0 ? _a : (options.delay = config.watchInputDelay);
11208
+ (_c = options.delay) !== null && _c !== void 0 ? _c : (options.delay = config.watchInputDelay);
10770
11209
  }
10771
11210
  else if (options.event === 'change') {
10772
11211
  options.event = u.evalOption(config.watchChangeEvents, field);
@@ -10774,15 +11213,22 @@ up.form = (function () {
10774
11213
  options.origin || (options.origin = field);
10775
11214
  return options;
10776
11215
  }
10777
- function disableContainer(container) {
10778
- let controls = [
10779
- ...findFields(container),
10780
- ...findSubmitButtons(container),
10781
- ...findGenericButtons(container),
10782
- ];
10783
- return u.sequence(u.map(controls, disableControl));
11216
+ function validateOptions(field, options, parserOptions = {}) {
11217
+ options = u.options(options);
11218
+ let parser = new up.OptionsParser(field, options, Object.assign(Object.assign({}, parserOptions), { closest: true, attrPrefix: 'up-validate-' }));
11219
+ parser.string('url');
11220
+ parser.string('method', { normalize: u.normalizeMethod });
11221
+ parser.boolean('batch', { default: config.validateBatch });
11222
+ parser.json('params');
11223
+ parser.json('headers');
11224
+ parser.include(watchOptions, { defaults: { event: 'change' } });
11225
+ return options;
11226
+ }
11227
+ function disableContainerTemp(container) {
11228
+ let controls = findFieldsAndButtons(container);
11229
+ return u.sequence(u.map(controls, disableControlTemp));
10784
11230
  }
10785
- function disableControl(control) {
11231
+ function disableControlTemp(control) {
10786
11232
  if (control.disabled)
10787
11233
  return;
10788
11234
  let focusFallback;
@@ -10797,7 +11243,7 @@ up.form = (function () {
10797
11243
  return () => { control.disabled = false; };
10798
11244
  }
10799
11245
  function getDisableContainers(disable, origin) {
10800
- let originScope = () => getScope(origin);
11246
+ let originScope = () => getRegion(origin);
10801
11247
  if (disable === true) {
10802
11248
  return [originScope()];
10803
11249
  }
@@ -10822,6 +11268,11 @@ up.form = (function () {
10822
11268
  }
10823
11269
  };
10824
11270
  }
11271
+ function setContainerDisabled(container, disabled) {
11272
+ for (let control of findFieldsAndButtons(container)) {
11273
+ control.disabled = disabled;
11274
+ }
11275
+ }
10825
11276
  function destinationOptions(form, options, parserOptions) {
10826
11277
  var _a;
10827
11278
  options = u.options(options);
@@ -10836,8 +11287,7 @@ up.form = (function () {
10836
11287
  options.method || (options.method = submitButton.getAttribute('formmethod'));
10837
11288
  options.url || (options.url = submitButton.getAttribute('formaction'));
10838
11289
  }
10839
- params.addAll(options.params);
10840
- options.params = params;
11290
+ options.params = up.Params.merge(params, options.params);
10841
11291
  parser.string('url', { attr: 'action', default: up.fragment.source(form) });
10842
11292
  parser.string('method', {
10843
11293
  attr: ['up-method', 'data-method', 'method'],
@@ -10854,8 +11304,7 @@ up.form = (function () {
10854
11304
  root = up.element.get(root);
10855
11305
  callback || (callback = watchCallbackFromElement(root) || up.fail('No callback given for up.watch()'));
10856
11306
  const watcher = new up.FieldWatcher(root, options, callback);
10857
- watcher.start();
10858
- return () => watcher.stop();
11307
+ return watcher.start();
10859
11308
  }
10860
11309
  function watchCallbackFromElement(element) {
10861
11310
  let rawCallback = element.getAttribute('up-watch');
@@ -10865,7 +11314,7 @@ up.form = (function () {
10865
11314
  }
10866
11315
  function autosubmit(target, options = {}) {
10867
11316
  const onChange = (_diff, renderOptions) => submit(target, renderOptions);
10868
- return watch(target, Object.assign(Object.assign({}, options), { batch: true }), onChange);
11317
+ return watch(target, Object.assign(Object.assign({ logPrefix: 'up.autosubmit()' }, options), { batch: true }), onChange);
10869
11318
  }
10870
11319
  function getGroupSelectors() {
10871
11320
  var _a, _b;
@@ -10894,7 +11343,8 @@ up.form = (function () {
10894
11343
  }
10895
11344
  function validate(...args) {
10896
11345
  let options = parseValidateArgs(...args);
10897
- let validator = up.FormValidator.forElement(options.origin);
11346
+ let form = getForm(options.origin);
11347
+ let validator = getFormValidator(form);
10898
11348
  return validator.validate(options);
10899
11349
  }
10900
11350
  function parseValidateArgs(originOrTarget, ...args) {
@@ -10907,88 +11357,20 @@ up.form = (function () {
10907
11357
  }
10908
11358
  return options;
10909
11359
  }
10910
- function switcherValues(field) {
10911
- let value;
10912
- let meta;
10913
- if (field.matches('input[type=checkbox]')) {
10914
- if (field.checked) {
10915
- value = field.value;
10916
- meta = ':checked';
10917
- }
10918
- else {
10919
- meta = ':unchecked';
10920
- }
10921
- }
10922
- else if (field.matches('input[type=radio]')) {
10923
- const form = getScope(field);
10924
- const groupName = field.getAttribute('name');
10925
- const checkedButton = form.querySelector(`input[type=radio]${e.attrSelector('name', groupName)}:checked`);
10926
- if (checkedButton) {
10927
- meta = ':checked';
10928
- value = checkedButton.value;
10929
- }
10930
- else {
10931
- meta = ':unchecked';
10932
- }
10933
- }
10934
- else {
10935
- value = field.value;
10936
- }
10937
- const values = [];
10938
- if (u.isPresent(value)) {
10939
- values.push(value);
10940
- values.push(':present');
10941
- }
10942
- else {
10943
- values.push(':blank');
10944
- }
10945
- if (u.isPresent(meta)) {
10946
- values.push(meta);
10947
- }
10948
- return values;
10949
- }
10950
- function switchTargets(switcher, options = {}) {
10951
- const targetSelector = options.target || options.target || switcher.getAttribute('up-switch');
10952
- const form = getScope(switcher);
10953
- targetSelector || up.fail("No switch target given for %o", switcher);
10954
- const fieldValues = switcherValues(switcher);
10955
- for (let target of up.fragment.all(form, targetSelector)) {
10956
- switchTarget(target, fieldValues);
10957
- }
10958
- }
10959
- const switchTarget = up.mockable(function (target, fieldValues) {
10960
- let show;
10961
- fieldValues || (fieldValues = switcherValues(findSwitcherForTarget(target)));
10962
- let hideValues = target.getAttribute('up-hide-for');
10963
- if (hideValues) {
10964
- hideValues = parseSwitchTokens(hideValues);
10965
- show = u.intersect(fieldValues, hideValues).length === 0;
10966
- }
10967
- else {
10968
- let showValues = target.getAttribute('up-show-for');
10969
- showValues = showValues ? parseSwitchTokens(showValues) : [':present', ':checked'];
10970
- show = u.intersect(fieldValues, showValues).length > 0;
10971
- }
10972
- e.toggle(target, show);
10973
- target.classList.add('up-switched');
10974
- });
10975
- function parseSwitchTokens(str) {
10976
- return u.getSimpleTokens(str, { json: true });
10977
- }
10978
- function findSwitcherForTarget(target) {
10979
- const form = getScope(target);
10980
- const switchers = form.querySelectorAll('[up-switch]');
10981
- const switcher = u.find(switchers, function (switcher) {
10982
- const targetSelector = switcher.getAttribute('up-switch');
10983
- return target.matches(targetSelector);
10984
- });
10985
- return switcher || up.fail('Could not find [up-switch] field for %o', target);
10986
- }
10987
11360
  function getForm(elementOrSelector, options = {}) {
10988
11361
  const element = up.fragment.get(elementOrSelector, options);
10989
11362
  return element.form || element.closest('form');
10990
11363
  }
10991
- function getScope(origin, options) {
11364
+ function getFormValidator(form) {
11365
+ return form.upFormValidator || (form.upFormValidator = setupFormValidator(form));
11366
+ }
11367
+ function setupFormValidator(form) {
11368
+ const validator = new up.FormValidator(form);
11369
+ const stop = validator.start();
11370
+ up.destructor(form, stop);
11371
+ return validator;
11372
+ }
11373
+ function getRegion(origin, options) {
10992
11374
  if (origin) {
10993
11375
  return getForm(origin, options) || up.layer.get(origin).element;
10994
11376
  }
@@ -10996,6 +11378,19 @@ up.form = (function () {
10996
11378
  return up.layer.current.element;
10997
11379
  }
10998
11380
  }
11381
+ function trackFields(...args) {
11382
+ let [root, { guard }, callback] = u.args(args, 'val', 'options', 'callback');
11383
+ let filter = function (fields) {
11384
+ let region = getRegion(root);
11385
+ return u.filter(fields, function (field) {
11386
+ return (root === region || root.contains(field))
11387
+ && (getRegion(field) === region)
11388
+ && (!guard || guard(field));
11389
+ });
11390
+ };
11391
+ const live = true;
11392
+ return up.fragment.trackSelector(fieldSelector(), { filter, live }, callback);
11393
+ }
10999
11394
  function focusedField() {
11000
11395
  return u.presence(document.activeElement, isField);
11001
11396
  }
@@ -11010,49 +11405,39 @@ up.form = (function () {
11010
11405
  up.event.halt(event, { log: true });
11011
11406
  up.error.muteUncriticalRejection(submit(form, { submitButton }));
11012
11407
  });
11013
- up.compiler(validatingFieldSelector, function (fieldOrForm) {
11014
- let validator = up.FormValidator.forElement(fieldOrForm);
11015
- validator.watchContainer(fieldOrForm);
11408
+ up.compiler('form', function (form) {
11409
+ getFormValidator(form);
11016
11410
  });
11017
- function validatingFieldSelector() {
11018
- let includes = config.fieldSelectors.map((selector) => `${selector}[up-validate], [up-validate] ${selector}`);
11019
- let excludes = ['[up-validate=false]'];
11020
- return e.unionSelector(includes, excludes);
11021
- }
11022
11411
  up.compiler('[up-switch]', (switcher) => {
11023
- switchTargets(switcher);
11024
- });
11025
- up.on('change', '[up-switch]', (_event, switcher) => {
11026
- switchTargets(switcher);
11027
- });
11028
- up.compiler('[up-show-for]:not(.up-switched), [up-hide-for]:not(.up-switched)', (element) => {
11029
- switchTarget(element);
11412
+ return new up.Switcher(switcher).start();
11030
11413
  });
11031
11414
  up.attribute('up-watch', (formOrField) => watch(formOrField));
11032
- up.attribute('up-autosubmit', (formOrField) => autosubmit(formOrField));
11415
+ up.attribute('up-autosubmit', (formOrField) => autosubmit(formOrField, { logPrefix: '[up-autosubmit]' }));
11033
11416
  return {
11034
11417
  config,
11035
11418
  submit,
11036
11419
  submitOptions,
11037
11420
  destinationOptions,
11038
11421
  watchOptions,
11422
+ validateOptions,
11039
11423
  isSubmittable,
11040
11424
  watch,
11041
11425
  validate,
11042
11426
  autosubmit,
11043
11427
  fieldSelector,
11044
11428
  fields: findFields,
11429
+ trackFields,
11045
11430
  isField,
11046
11431
  submitButtons: findSubmitButtons,
11047
11432
  focusedField,
11048
- switchTarget,
11049
- disable: disableContainer,
11433
+ disableTemp: disableContainerTemp,
11434
+ setDisabled: setContainerDisabled,
11050
11435
  getDisablePreviewFn,
11051
11436
  group: findGroup,
11052
11437
  groupSolution: findGroupSolution,
11053
11438
  groupSelectors: getGroupSelectors,
11054
11439
  get: getForm,
11055
- getScope,
11440
+ getRegion,
11056
11441
  };
11057
11442
  })();
11058
11443
  up.submit = up.form.submit;
@@ -11062,13 +11447,12 @@ up.validate = up.form.validate;
11062
11447
 
11063
11448
 
11064
11449
  /***/ }),
11065
- /* 98 */
11450
+ /* 101 */
11066
11451
  /***/ (() => {
11067
11452
 
11068
11453
  up.status = (function () {
11069
11454
  const u = up.util;
11070
11455
  const e = up.element;
11071
- let namedPreviewFns = {};
11072
11456
  const config = new up.Config(() => ({
11073
11457
  currentClasses: ['up-current'],
11074
11458
  activeClasses: ['up-active'],
@@ -11076,30 +11460,39 @@ up.status = (function () {
11076
11460
  navSelectors: ['[up-nav]', 'nav'],
11077
11461
  noNavSelectors: ['[up-nav=false]'],
11078
11462
  }));
11079
- function reset() {
11080
- up.layer.root.feedbackLocation = null;
11081
- namedPreviewFns = u.pickBy(namedPreviewFns, 'isDefault');
11082
- }
11463
+ let namedPreviewFns = new up.Registry('preview');
11083
11464
  const SELECTOR_LINK = 'a, [up-href]';
11084
11465
  function linkCurrentURLs(link) {
11085
11466
  return link.upCurrentURLs || (link.upCurrentURLs = new up.LinkCurrentURLs(link));
11086
11467
  }
11087
- function updateFragment(fragment, { layer } = {}) {
11088
- layer || (layer = up.layer.get(fragment));
11089
- let layerLocation = getMatchableLayerLocation(layer);
11090
- const navSelector = config.selector('navSelectors');
11091
- const navLinkSelector = `${navSelector} :is(${SELECTOR_LINK}), ${navSelector}:is(${SELECTOR_LINK})`;
11092
- const links = up.fragment.all(navLinkSelector, { layer });
11093
- for (let link of links) {
11094
- const isCurrent = linkCurrentURLs(link).isCurrent(layerLocation);
11095
- for (let currentClass of config.currentClasses) {
11096
- link.classList.toggle(currentClass, isCurrent);
11468
+ function getNavLocations(nav) {
11469
+ let layerRef = e.attr(nav, 'up-layer') || 'origin';
11470
+ let layers = up.layer.getAll(layerRef, { origin: nav });
11471
+ return u.compact(layers.map(getMatchableLayerLocation));
11472
+ }
11473
+ function updateNav(nav, links, { newLinks, anyLocationChanged }) {
11474
+ let currentLocations = (!anyLocationChanged && nav.upNavLocations) || getNavLocations(nav);
11475
+ if (newLinks || !u.isEqual(nav.upNavLocations, currentLocations)) {
11476
+ for (let link of links) {
11477
+ const isCurrent = linkCurrentURLs(link).isAnyCurrent(currentLocations);
11478
+ for (let currentClass of config.currentClasses) {
11479
+ link.classList.toggle(currentClass, isCurrent);
11480
+ }
11481
+ e.setAttrPresence(link, 'aria-current', 'page', isCurrent);
11097
11482
  }
11098
- e.setAttrPresence(link, 'aria-current', 'page', isCurrent);
11483
+ nav.upNavLocations = currentLocations;
11484
+ }
11485
+ }
11486
+ function updateNavsAround(root, opts) {
11487
+ const navSelector = config.selector('navSelectors');
11488
+ const fullNavs = e.around(root, navSelector);
11489
+ for (let fullNav of fullNavs) {
11490
+ let links = e.subtree(fullNav, SELECTOR_LINK);
11491
+ updateNav(fullNav, links, opts);
11099
11492
  }
11100
11493
  }
11101
11494
  function getMatchableLayerLocation(layer) {
11102
- return layer.feedbackLocation || u.matchableURL(layer.location);
11495
+ return u.matchableURL(layer.location);
11103
11496
  }
11104
11497
  function findActivatableArea(element) {
11105
11498
  return e.ancestor(element, SELECTOR_LINK) || element;
@@ -11154,7 +11547,7 @@ up.status = (function () {
11154
11547
  }
11155
11548
  function resolvePreviewString(str) {
11156
11549
  return u.map(u.parseScalarJSONPairs(str), ([name, parsedOptions]) => {
11157
- let previewFn = namedPreviewFns[name] || up.fail('Unknown preview "%s"', name);
11550
+ let previewFn = namedPreviewFns.get(name);
11158
11551
  return function (preview, runOptions) {
11159
11552
  up.puts('[up-preview]', 'Showing preview %o', name);
11160
11553
  return previewFn(preview, parsedOptions || runOptions);
@@ -11165,10 +11558,6 @@ up.status = (function () {
11165
11558
  activeElements || (activeElements = u.wrapList(origin));
11166
11559
  return activeElements.map(findActivatableArea);
11167
11560
  }
11168
- function registerPreview(name, previewFn) {
11169
- previewFn.isDefault = up.framework.evaling;
11170
- namedPreviewFns[name] = previewFn;
11171
- }
11172
11561
  function getFeedbackClassesPreviewFn(feedbackOption, fragments) {
11173
11562
  if (!feedbackOption)
11174
11563
  return;
@@ -11187,33 +11576,15 @@ up.status = (function () {
11187
11576
  parser.string('placeholder');
11188
11577
  return options;
11189
11578
  }
11190
- function updateLayerIfLocationChanged(layer) {
11191
- const processedLocation = layer.feedbackLocation;
11192
- const layerLocation = getMatchableLayerLocation(layer.location);
11193
- if (!processedLocation || (processedLocation !== layerLocation)) {
11194
- layer.feedbackLocation = layerLocation;
11195
- updateFragment(layer.element, { layer });
11196
- }
11197
- }
11198
- function onBrowserLocationChanged() {
11199
- const frontLayer = up.layer.front;
11200
- if (frontLayer.showsLiveHistory()) {
11201
- updateLayerIfLocationChanged(frontLayer);
11202
- }
11203
- }
11204
- up.on('up:location:changed', (_event) => {
11205
- onBrowserLocationChanged();
11206
- });
11207
11579
  up.on('up:fragment:compile', (_event, newFragment) => {
11208
- updateFragment(newFragment);
11580
+ updateNavsAround(newFragment, { newLinks: true, anyLocationChanged: false });
11209
11581
  });
11210
- up.on('up:layer:location:changed', (event) => {
11211
- updateLayerIfLocationChanged(event.layer);
11582
+ up.on('up:layer:location:changed up:layer:opened up:layer:dismissed up:layer:accepted', () => {
11583
+ updateNavsAround(document.body, { newLinks: false, anyLocationChanged: true });
11212
11584
  });
11213
- up.on('up:framework:reset', reset);
11214
11585
  return {
11215
11586
  config,
11216
- preview: registerPreview,
11587
+ preview: namedPreviewFns.put,
11217
11588
  resolvePreviewFns,
11218
11589
  runPreviews,
11219
11590
  statusOptions,
@@ -11223,7 +11594,7 @@ up.preview = up.status.preview;
11223
11594
 
11224
11595
 
11225
11596
  /***/ }),
11226
- /* 99 */
11597
+ /* 102 */
11227
11598
  /***/ (() => {
11228
11599
 
11229
11600
  up.radio = (function () {
@@ -11306,7 +11677,7 @@ up.radio = (function () {
11306
11677
 
11307
11678
 
11308
11679
  /***/ }),
11309
- /* 100 */
11680
+ /* 103 */
11310
11681
  /***/ (() => {
11311
11682
 
11312
11683
  (function () {
@@ -11357,8 +11728,7 @@ up.radio = (function () {
11357
11728
  /******/ }
11358
11729
  /******/
11359
11730
  /************************************************************************/
11360
- var __webpack_exports__ = {};
11361
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
11731
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
11362
11732
  (() => {
11363
11733
  __webpack_require__(1);
11364
11734
  __webpack_require__(2);
@@ -11445,15 +11815,18 @@ __webpack_require__(83);
11445
11815
  __webpack_require__(84);
11446
11816
  __webpack_require__(85);
11447
11817
  __webpack_require__(86);
11818
+ __webpack_require__(87);
11448
11819
  __webpack_require__(88);
11449
- __webpack_require__(90);
11820
+ __webpack_require__(89);
11450
11821
  __webpack_require__(91);
11451
11822
  __webpack_require__(93);
11452
- __webpack_require__(95);
11453
- __webpack_require__(97);
11823
+ __webpack_require__(94);
11824
+ __webpack_require__(96);
11454
11825
  __webpack_require__(98);
11455
- __webpack_require__(99);
11456
11826
  __webpack_require__(100);
11827
+ __webpack_require__(101);
11828
+ __webpack_require__(102);
11829
+ __webpack_require__(103);
11457
11830
  up.framework.onEvaled();
11458
11831
 
11459
11832
  })();