@es-joy/jsoe 0.13.8 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/.eslintrc.cjs +7 -0
  2. package/.nyc_output/out.json +20068 -11970
  3. package/CHANGES.md +10 -0
  4. package/README.md +10 -21
  5. package/demo/index.js +79 -2
  6. package/dist/formats/indexedDBKey.d.ts.map +1 -1
  7. package/dist/formats/structuredCloning.d.ts.map +1 -1
  8. package/dist/fundamentalTypes/BooleanObjectType.d.ts.map +1 -1
  9. package/dist/fundamentalTypes/NumberObjectType.d.ts.map +1 -1
  10. package/dist/fundamentalTypes/StringObjectType.d.ts.map +1 -1
  11. package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
  12. package/dist/fundamentalTypes/blobType.d.ts.map +1 -1
  13. package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
  14. package/dist/fundamentalTypes/fileType.d.ts.map +1 -1
  15. package/dist/fundamentalTypes/filelistType.d.ts.map +1 -1
  16. package/dist/fundamentalTypes/mapType.d.ts.map +1 -1
  17. package/dist/fundamentalTypes/noneditableType.d.ts +6 -0
  18. package/dist/fundamentalTypes/noneditableType.d.ts.map +1 -0
  19. package/dist/fundamentalTypes/objectReferenceType.d.ts.map +1 -1
  20. package/dist/fundamentalTypes/objectType.d.ts.map +1 -1
  21. package/dist/fundamentalTypes/setType.d.ts.map +1 -1
  22. package/dist/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -1
  23. package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
  24. package/dist/index.js +1980 -237
  25. package/dist/superTypes/SpecialNumberType.d.ts +2 -10
  26. package/dist/superTypes/SpecialNumberType.d.ts.map +1 -1
  27. package/dist/superTypes/SpecialRealNumberType.d.ts +2 -2
  28. package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -1
  29. package/dist/superTypes/buffersourceType.d.ts +8 -0
  30. package/dist/superTypes/buffersourceType.d.ts.map +1 -0
  31. package/dist/superTypes/dommatrixType.d.ts +6 -0
  32. package/dist/superTypes/dommatrixType.d.ts.map +1 -0
  33. package/dist/superTypes/dompointType.d.ts +6 -0
  34. package/dist/superTypes/dompointType.d.ts.map +1 -0
  35. package/dist/superTypes/domrectType.d.ts +6 -0
  36. package/dist/superTypes/domrectType.d.ts.map +1 -0
  37. package/dist/superTypes/errorsSpecialType.d.ts +2 -2
  38. package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
  39. package/dist/types.d.ts +29 -17
  40. package/dist/types.d.ts.map +1 -1
  41. package/dist/utils/media.d.ts.map +1 -1
  42. package/dist/vendor-imports.d.ts +1 -1
  43. package/package.json +13 -13
  44. package/src/formats/indexedDBKey.js +2 -3
  45. package/src/formats/structuredCloning.js +37 -20
  46. package/src/fundamentalTypes/BooleanObjectType.js +3 -1
  47. package/src/fundamentalTypes/NumberObjectType.js +3 -1
  48. package/src/fundamentalTypes/StringObjectType.js +3 -1
  49. package/src/fundamentalTypes/arrayType.js +4 -2
  50. package/src/fundamentalTypes/blobType.js +17 -13
  51. package/src/fundamentalTypes/dateType.js +6 -2
  52. package/src/fundamentalTypes/fileType.js +14 -12
  53. package/src/fundamentalTypes/filelistType.js +3 -1
  54. package/src/fundamentalTypes/mapType.js +3 -1
  55. package/src/fundamentalTypes/noneditableType.js +87 -0
  56. package/src/fundamentalTypes/objectReferenceType.js +3 -1
  57. package/src/fundamentalTypes/objectType.js +3 -1
  58. package/src/fundamentalTypes/setType.js +3 -1
  59. package/src/fundamentalTypes/sparseUndefinedType.js +3 -1
  60. package/src/fundamentalTypes/undefinedType.js +3 -1
  61. package/src/jsoe.css +64 -0
  62. package/src/subTypes/blobHTMLType.js +1 -1
  63. package/src/superTypes/SpecialNumberType.js +2 -8
  64. package/src/superTypes/SpecialRealNumberType.js +2 -2
  65. package/src/superTypes/buffersourceType.js +1455 -0
  66. package/src/{fundamentalTypes → superTypes}/dommatrixType.js +63 -10
  67. package/src/{fundamentalTypes → superTypes}/dompointType.js +60 -7
  68. package/src/{fundamentalTypes → superTypes}/domrectType.js +59 -7
  69. package/src/superTypes/errorsSpecialType.js +1 -1
  70. package/src/types.js +39 -22
  71. package/src/utils/media.js +3 -2
  72. package/src/vendor-imports.js +2 -1
  73. package/vendor/typeson-registry/dist/index.js +90 -28
package/dist/index.js CHANGED
@@ -122,7 +122,7 @@ const NULLABLES = ['autocomplete', 'dir',
122
122
  * @param {string} sel
123
123
  * @returns {HTMLElement|null}
124
124
  */
125
- const $$1 = sel => {
125
+ const $$2 = sel => {
126
126
  if (!doc) {
127
127
  throw new Error('No document object');
128
128
  }
@@ -850,7 +850,7 @@ const jml = function jml(...args) {
850
850
  */
851
851
  template, doc.body);
852
852
  } else if (typeof template === 'string') {
853
- template = /** @type {HTMLTemplateElement} */$$1(template);
853
+ template = /** @type {HTMLTemplateElement} */$$2(template);
854
854
  }
855
855
  jml( /** @type {HTMLTemplateElement} */
856
856
  /** @type {HTMLTemplateElement} */template.content.cloneNode(true), shadowRoot);
@@ -2129,7 +2129,7 @@ class JamilihMap extends Map {
2129
2129
  * @returns {ArbitraryValue}
2130
2130
  */
2131
2131
  get(element) {
2132
- const elem = typeof element === 'string' ? $$1(element) : element;
2132
+ const elem = typeof element === 'string' ? $$2(element) : element;
2133
2133
  return super.get.call(this, elem);
2134
2134
  }
2135
2135
  /**
@@ -2138,7 +2138,7 @@ class JamilihMap extends Map {
2138
2138
  * @returns {ArbitraryValue}
2139
2139
  */
2140
2140
  set(element, value) {
2141
- const elem = typeof element === 'string' ? $$1(element) : element;
2141
+ const elem = typeof element === 'string' ? $$2(element) : element;
2142
2142
  return super.set.call(this, elem, value);
2143
2143
  }
2144
2144
  /**
@@ -2148,7 +2148,7 @@ class JamilihMap extends Map {
2148
2148
  * @returns {ArbitraryValue}
2149
2149
  */
2150
2150
  invoke(element, methodName, ...args) {
2151
- const elem = typeof element === 'string' ? $$1(element) : element;
2151
+ const elem = typeof element === 'string' ? $$2(element) : element;
2152
2152
  return this.get(elem)[methodName](elem, ...args);
2153
2153
  }
2154
2154
  }
@@ -2163,7 +2163,7 @@ class JamilihWeakMap extends WeakMap {
2163
2163
  * @returns {ArbitraryValue}
2164
2164
  */
2165
2165
  get(element) {
2166
- const elem = typeof element === 'string' ? $$1(element) : element;
2166
+ const elem = typeof element === 'string' ? $$2(element) : element;
2167
2167
  if (!elem) {
2168
2168
  throw new Error("Can't find the element");
2169
2169
  }
@@ -2175,7 +2175,7 @@ class JamilihWeakMap extends WeakMap {
2175
2175
  * @returns {ArbitraryValue}
2176
2176
  */
2177
2177
  set(element, value) {
2178
- const elem = typeof element === 'string' ? $$1(element) : element;
2178
+ const elem = typeof element === 'string' ? $$2(element) : element;
2179
2179
  if (!elem) {
2180
2180
  throw new Error("Can't find the element");
2181
2181
  }
@@ -2188,7 +2188,7 @@ class JamilihWeakMap extends WeakMap {
2188
2188
  * @returns {ArbitraryValue}
2189
2189
  */
2190
2190
  invoke(element, methodName, ...args) {
2191
- const elem = typeof element === 'string' ? $$1(element) : element;
2191
+ const elem = typeof element === 'string' ? $$2(element) : element;
2192
2192
  if (!elem) {
2193
2193
  throw new Error("Can't find the element");
2194
2194
  }
@@ -2234,7 +2234,7 @@ jml.strong = function (obj, ...args) {
2234
2234
  * @returns {ArbitraryValue} The value associated with the symbol
2235
2235
  */
2236
2236
  jml.symbol = jml.sym = jml.for = function (element, sym) {
2237
- const elem = typeof element === 'string' ? $$1(element) : element;
2237
+ const elem = typeof element === 'string' ? $$2(element) : element;
2238
2238
 
2239
2239
  // @ts-expect-error Should be ok
2240
2240
  return elem[typeof sym === 'symbol' ? sym : Symbol.for(sym)];
@@ -2253,7 +2253,7 @@ jml.symbol = jml.sym = jml.for = function (element, sym) {
2253
2253
  * @returns {ArbitraryValue}
2254
2254
  */
2255
2255
  jml.command = function (elem, symOrMap, methodName, ...args) {
2256
- elem = typeof elem === 'string' ? $$1(elem) : elem;
2256
+ elem = typeof elem === 'string' ? $$2(elem) : elem;
2257
2257
  if (!elem) {
2258
2258
  throw new Error('No element found');
2259
2259
  }
@@ -2315,7 +2315,7 @@ if (doc && doc.body) {
2315
2315
  }
2316
2316
  const nbsp$1 = '\u00A0'; // Very commonly needed in templates
2317
2317
 
2318
- function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n);}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return (t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _slicedToArray(e,t){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],s=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1;}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){u=!0,o=e;}finally{try{if(!s&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||_unsupportedIterableToArray(e,t)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return "Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:String(t)}var e=_createClass((function TypesonPromise(e){_classCallCheck(this,TypesonPromise),this.p=new Promise(e);}));e.__typeson__type__="TypesonPromise","undefined"!=typeof Symbol&&Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function get(){return "TypesonPromise"}}),e.prototype.then=function(t,r){var n=this;return new e((function(e,o){n.p.then((function(r){e(t?t(r):r);})).catch((function(e){return r?r(e):Promise.reject(e)})).then(e,o);}))},e.prototype.catch=function(e){return this.then((function(){}),e)},e.resolve=function(t){return new e((function(e){e(t);}))},e.reject=function(t){return new e((function(e,r){r(t);}))},e.all=function(t){return new e((function(e,r){Promise.all(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))},e.race=function(t){return new e((function(e,r){Promise.race(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))},e.allSettled=function(t){return new e((function(e,r){Promise.allSettled(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))};var t=Object.hasOwn,r=Object.getPrototypeOf;function isThenable(e,t){return isObject(e)&&"function"==typeof e.then&&(!t||"function"==typeof e.catch)}function toStringTag(e){return Object.prototype.toString.call(e).slice(8,-1)}function hasConstructorOf(e,n){if(!e||"object"!==_typeof(e))return !1;var o=r(e);if(!o)return null===n;var a=t(o,"constructor")&&o.constructor;return "function"!=typeof a?null===n:n===a||null!==n&&Function.prototype.toString.call(a)===Function.prototype.toString.call(n)||"function"==typeof n&&"string"==typeof a.__typeson__type__&&a.__typeson__type__===n.__typeson__type__}function isPlainObject(e){return !(!e||"Object"!==toStringTag(e))&&(!r(e)||hasConstructorOf(e,Object))}function isUserObject(e){if(!e||"Object"!==toStringTag(e))return !1;var t=r(e);return !t||hasConstructorOf(e,Object)||isUserObject(t)}function isObject(e){return null!==e&&"object"===_typeof(e)}function escapeKeyPathComponent(e){return e.replaceAll("''","''''").replace(/^$/,"''").replaceAll("~","~0").replaceAll(".","~1")}function unescapeKeyPathComponent(e){return e.replaceAll("~1",".").replaceAll("~0","~").replace(/^''$/,"").replaceAll("''''","''")}function getByKeyPath(e,t){if(""===t)return e;if(null===e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");var r=t.indexOf(".");if(r>-1){var n=e[unescapeKeyPathComponent(t.slice(0,r))];return void 0===n?void 0:getByKeyPath(n,t.slice(r+1))}return e[unescapeKeyPathComponent(t)]}function setAtKeyPath(e,t,r){if(""===t)return r;if(!e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");var n=t.indexOf(".");return n>-1?setAtKeyPath(e[unescapeKeyPathComponent(t.slice(0,n))],t.slice(n+1),r):(e[unescapeKeyPathComponent(t)]=r,e)}function getJSONType(e){return null===e?"null":Array.isArray(e)?"array":_typeof(e)}function _await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}var n=Object.keys,o=Object.hasOwn,a=Array.isArray,i=["type","replaced","iterateIn","iterateUnsetNumeric","addLength"];function _async(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function nestedPathsFirst(e,t){var r,n;if(""===e.keypath)return -1;var o=null!==(r=e.keypath.match(/\./g))&&void 0!==r?r:0,a=null!==(n=t.keypath.match(/\./g))&&void 0!==n?n:0;return o&&(o=o.length),a&&(a=a.length),o>a?-1:o<a?1:e.keypath<t.keypath?-1:e.keypath>t.keypath?1:0}var c=function(){function Typeson(e){_classCallCheck(this,Typeson),this.options=e,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={};}return _createClass(Typeson,[{key:"stringify",value:function stringify(e,t,r,n){n=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),n),{},{stringification:!0});var o=this.encapsulate(e,null,n);return a(o)?JSON.stringify(o[0],t,r):o.then((function(e){return JSON.stringify(e,t,r)}))}},{key:"stringifySync",value:function stringifySync(e,t,r,n){return this.stringify(e,t,r,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},n),{},{sync:!0}))}},{key:"stringifyAsync",value:function stringifyAsync(e,t,r,n){return this.stringify(e,t,r,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},n),{},{sync:!1}))}},{key:"parse",value:function parse(e,t,r){return r=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),r),{},{parse:!0}),this.revive(JSON.parse(e,t),r)}},{key:"parseSync",value:function parseSync(e,t,r){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!0}))}},{key:"parseAsync",value:function parseAsync(e,t,r){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!1}))}},{key:"specialTypeNames",value:function specialTypeNames(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.returnTypeNames=!0,this.encapsulate(e,t,r)}},{key:"rootTypeName",value:function rootTypeName(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.iterateNone=!0,this.encapsulate(e,t,r)}},{key:"encapsulate",value:function encapsulate(t,r,c){var s=this,u=_objectSpread2(_objectSpread2({sync:!0},this.options),c),l=u.sync,f={},y=[],p=[],d=[],v=!("cyclic"in u)||u.cyclic,b=u.encapsulateObserver,m=function finish(e){var t=Object.values(f);if(u.iterateNone)return t.length?t[0]:getJSONType(e);if(t.length){if(u.returnTypeNames)return function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}(e)||function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||_unsupportedIterableToArray(e)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(new Set(t));e&&isPlainObject(e)&&!o(e,"$types")?e.$types=f:e={$:e,$types:{$:f}};}else isObject(e)&&o(e,"$types")&&(e={$:e,$types:!0});return !u.returnTypeNames&&e},h=_async((function(t,r){return _await(Promise.all(r.map((function(e){return e[1].p}))),(function(n){return _await(Promise.all(n.map(_async((function(n){var o=!1,a=[],i=_slicedToArray(r.splice(0,1),1),c=_slicedToArray(i[0],7),s=c[0],u=c[2],l=c[3],f=c[4],y=c[5],p=c[6],d=O(s,n,u,l,a,!0,p),v=hasConstructorOf(d,e);return function _invoke(e,t){var r=e();return r&&r.then?r.then(t):t(r)}((function(){if(s&&v)return _await(d.p,(function(e){f[y]=e;var r=h(t,a);return o=!0,r}))}),(function(e){return o?e:(s?f[y]=d:t=v?d.p:d,h(t,a))}))})))),(function(){return t}))}))})),g=function _adaptBuiltinStateObjectProperties(e,t,r){Object.assign(e,t);var n=i.map((function(t){var r=e[t];return delete e[t],r}));r(),i.forEach((function(t,r){e[t]=n[r];}));},O=function _encapsulate(t,r,i,c,l,d,v){var m,h={},O=_typeof(r),w=b?function(n){var o,a=null!==(o=null!=v?v:c.type)&&void 0!==o?o:getJSONType(r);b(Object.assign(null!=n?n:h,{keypath:t,value:r,cyclic:i,stateObj:c,promisesData:l,resolvingTypesonPromise:d,awaitingTypesonPromise:hasConstructorOf(r,e)},{type:a}));}:null;if(["string","boolean","number","undefined"].includes(O))return void 0===r||Number.isNaN(r)||r===Number.NEGATIVE_INFINITY||r===Number.POSITIVE_INFINITY||0===r?(m=c.replaced?r:_(t,r,c,l,!1,d,w))!==r&&(h={replaced:m}):m=r,w&&w(),m;if(null===r)return w&&w(),r;if(i&&!c.iterateIn&&!c.iterateUnsetNumeric&&r&&"object"===_typeof(r)){var A=y.indexOf(r);if(!(A<0))return f[t]="#",w&&w({cyclicKeypath:p[A]}),"#"+p[A];!0===i&&(y.push(r),p.push(t));}var S,j,T=isPlainObject(r),N=a(r),I=(T||N)&&(!s.plainObjectReplacers.length||c.replaced)||c.iterateIn?r:_(t,r,c,l,T||N,null,w);if(I!==r?(m=I,h={replaced:I}):""===t&&hasConstructorOf(r,e)?(l.push([t,r,i,c,void 0,void 0,c.type]),m=r):N&&"object"!==c.iterateIn||"array"===c.iterateIn?(S=new Array(r.length),h={clone:S}):(["function","symbol"].includes(_typeof(r))||"toJSON"in r||hasConstructorOf(r,e)||hasConstructorOf(r,Promise)||hasConstructorOf(r,ArrayBuffer))&&!T&&"object"!==c.iterateIn?m=r:(S={},c.addLength&&(S.length=r.length),h={clone:S}),w&&w(),u.iterateNone)return null!==(j=S)&&void 0!==j?j:m;if(!S)return m;if(c.iterateIn){var P=function _loop(n){var a={ownKeys:o(r,n)};g(c,a,(function(){var o=t+(t?".":"")+escapeKeyPathComponent(n),a=_encapsulate(o,r[n],Boolean(i),c,l,d);hasConstructorOf(a,e)?l.push([o,a,Boolean(i),c,S,n,c.type]):void 0!==a&&(S[n]=a);}));};for(var E in r)P(E);w&&w({endIterateIn:!0,end:!0});}else n(r).forEach((function(n){var o=t+(t?".":"")+escapeKeyPathComponent(n);g(c,{ownKeys:!0},(function(){var t=_encapsulate(o,r[n],Boolean(i),c,l,d);hasConstructorOf(t,e)?l.push([o,t,Boolean(i),c,S,n,c.type]):void 0!==t&&(S[n]=t);}));})),w&&w({endIterateOwn:!0,end:!0});if(c.iterateUnsetNumeric){for(var x=r.length,C=function _loop2(n){if(!(n in r)){var o="".concat(t).concat(t?".":"").concat(n);g(c,{ownKeys:!1},(function(){var t=_encapsulate(o,void 0,Boolean(i),c,l,d);hasConstructorOf(t,e)?l.push([o,t,Boolean(i),c,S,n,c.type]):void 0!==t&&(S[n]=t);}));}},k=0;k<x;k++)C(k);w&&w({endIterateUnsetNumeric:!0,end:!0});}return S},_=function replace(e,t,r,n,o,a,i){for(var c=o?s.plainObjectReplacers:s.nonplainObjectReplacers,u=c.length;u--;){var y=c[u];if(y.test(t,r)){var p=y.type;if(s.revivers[p]){var d=f[e];f[e]=d?[p].concat(d):p;}if(Object.assign(r,{type:p,replaced:!0}),(l||!y.replaceAsync)&&!y.replace)return i&&i({typeDetected:!0}),O(e,t,v&&"readonly",r,n,a,p);i&&i({replacing:!0});var b=void 0;if(l||!y.replaceAsync){if(void 0===y.replace)throw new TypeError("Missing replacer");b=y.replace(t,r);}else b=y.replaceAsync(t,r);return O(e,b,v&&"readonly",r,n,a,p)}}return t},w=O("",t,v,null!=r?r:{},d);if(d.length)return l&&u.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(h(w,d)).then(m);if(!l&&u.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return u.stringification&&l?[m(w)]:l?m(w):Promise.resolve(m(w))}},{key:"encapsulateSync",value:function encapsulateSync(e,t,r){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!0}))}},{key:"encapsulateAsync",value:function encapsulateAsync(e,t,r){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!1}))}},{key:"revive",value:function revive(t,r){var o=this,i=_objectSpread2(_objectSpread2({sync:!0},this.options),r),c=i.sync;function finishRevival(e){if(c)return e;if(i.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return Promise.resolve(e)}if(!t||"object"!==_typeof(t)||Array.isArray(t))return finishRevival(t);var u=t.$types;if(!0===u)return finishRevival(t.$);if(!u||"object"!==_typeof(u)||Array.isArray(u))return finishRevival(t);var l=[],f={},y=!0;u.$&&isPlainObject(u.$)&&(t=t.$,u=u.$,y=!1);var p=function executeReviver(e,t){var r,n=_slicedToArray(null!==(r=o.revivers[e])&&void 0!==r?r:[],1)[0];if(!n)throw new Error("Unregistered type: "+e);if(c&&!("revive"in n))return t;if(!c&&n.reviveAsync)return n.reviveAsync(t,f);if(n.revive)return n.revive(t,f);throw new Error("Missing reviver")},d=[];function checkUndefined(e){return hasConstructorOf(e,s)?void 0:e}var v,b=function revivePlainObjects(){var r=[];if(!u)throw new Error("Found bad `types`");if(Object.entries(u).forEach((function(e){var t=_slicedToArray(e,2),n=t[0],a=t[1];"#"!==a&&[].concat(a).forEach((function(e){var t;_slicedToArray(null!==(t=o.revivers[e])&&void 0!==t?t:[null,{}],2)[1].plain&&(r.push({keypath:n,type:e}),delete u[n]);}));})),r.length)return r.sort(nestedPathsFirst).reduce((function reducer(r,n){var o=n.keypath,a=n.type;if(isThenable(r))return r.then((function(e){return reducer(e,{keypath:o,type:a})}));var i=getByKeyPath(t,o);if(hasConstructorOf(i=p(a,i),e))return i.then((function(e){var r=setAtKeyPath(t,o,e);r===e&&(t=r);}));var c=setAtKeyPath(t,o,i);c===i&&(t=c);}),void 0)}();return hasConstructorOf(b,e)?v=b.then((function(){return t})):(v=function _revive(t,r,o,i,c){if(!y||"$types"!==t){var f=u[t],v=a(r);if(v||isPlainObject(r)){var b=v?new Array(r.length):{};for(n(r).forEach((function(n){var a=_revive(t+(t?".":"")+escapeKeyPathComponent(n),r[n],null!=o?o:b,b,n),i=function set(e){return hasConstructorOf(e,s)?b[n]=void 0:void 0!==e&&(b[n]=e),e};hasConstructorOf(a,e)?d.push(a.then((function(e){return i(e)}))):i(a);})),r=b;l.length;){var m=_slicedToArray(l[0],4),h=m[0],g=m[1],O=m[2],_=m[3],w=getByKeyPath(h,g);if(void 0===w)break;O[_]=w,l.splice(0,1);}}if(!f)return r;if("#"===f){var A=getByKeyPath(o,r.slice(1));return void 0===A&&l.push([o,r.slice(1),i,c]),A}return [].concat(f).reduce((function reducer(t,r){if(hasConstructorOf(t,e))return t.then((function(e){return reducer(e,r)}));if("string"!=typeof r)throw new TypeError("Bad type JSON");return p(r,t)}),r)}}("",t,null),d.length&&(v=e.resolve(v).then((function(t){return e.all([t].concat(d))})).then((function(e){return _slicedToArray(e,1)[0]})))),isThenable(v)?c&&i.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():hasConstructorOf(v,e)?v.p.then(checkUndefined):v:!c&&i.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():c?checkUndefined(v):Promise.resolve(checkUndefined(v))}},{key:"reviveSync",value:function reviveSync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!0}))}},{key:"reviveAsync",value:function reviveAsync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!1}))}},{key:"register",value:function register(e,t){var r=this,o=null!=t?t:{},i=function R(e){a(e)?e.forEach((function(e){return R(e)})):n(e).forEach((function(t){var n;if("#"===t)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(u.includes(t))throw new TypeError("Plain JSON object types are reserved as type names");var i=e[t],c=i&&"function"!=typeof i&&!Array.isArray(i)&&i.testPlainObjects?r.plainObjectReplacers:r.nonplainObjectReplacers,s=c.filter((function(e){return e.type===t}));if(s.length&&(c.splice(c.indexOf(s[0]),1),delete r.revivers[t],delete r.types[t]),"function"==typeof i){var l=i;i={test:function test(e){return e&&e.constructor===l},replace:function replace(e){return _objectSpread2({},e)},revive:function revive(e){return Object.assign(Object.create(l.prototype),e)}};}else if(a(i)){var f=_slicedToArray(i,3);i={test:f[0],replace:f[1],revive:f[2]};}if(null!==(n=i)&&void 0!==n&&n.test){var y={type:t,test:i.test.bind(i)};i.replace&&(y.replace=i.replace.bind(i)),i.replaceAsync&&(y.replaceAsync=i.replaceAsync.bind(i));var p="number"==typeof o.fallback?o.fallback:o.fallback?0:Number.POSITIVE_INFINITY;if(i.testPlainObjects?r.plainObjectReplacers.splice(p,0,y):r.nonplainObjectReplacers.splice(p,0,y),i.revive||i.reviveAsync){var d={};i.revive&&(d.revive=i.revive.bind(i)),i.reviveAsync&&(d.reviveAsync=i.reviveAsync.bind(i)),r.revivers[t]=[d,{plain:i.testPlainObjects}];}r.types[t]=i;}}));};return [].concat(e).forEach((function(e){return i(e)})),this}}]),Typeson}(),s=_createClass((function Undefined(){_classCallCheck(this,Undefined);}));s.__typeson__type__="TypesonUndefined";for(var u=["null","boolean","number","string","array","object"],l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=new Uint8Array(256),y=0;y<64;y++)f[l.codePointAt(y)]=y;var p=function encode(e,t,r){null==r&&(r=e.byteLength);for(var n=new Uint8Array(e,t||0,r),o=n.length,a="",i=0;i<o;i+=3)a+=l[n[i]>>2],a+=l[(3&n[i])<<4|n[i+1]>>4],a+=l[(15&n[i+1])<<2|n[i+2]>>6],a+=l[63&n[i+2]];return o%3==2?a=a.slice(0,-1)+"=":o%3==1&&(a=a.slice(0,-2)+"=="),a},d=function decode(e){var t=e.length;if(t%4)throw new Error("Bad base64 length: not divisible by four");var r,n,o,a,i=.75*e.length,c=0;"="===e[e.length-1]&&(i--,"="===e[e.length-2]&&i--);for(var s=new ArrayBuffer(i),u=new Uint8Array(s),l=0;l<t;l+=4)r=f[e.codePointAt(l)],n=f[e.codePointAt(l+1)],o=f[e.codePointAt(l+2)],a=f[e.codePointAt(l+3)],u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|o>>2,u[c++]=(3&o)<<6|63&a;return s};const v={arraybuffer:{test:e=>"ArrayBuffer"===toStringTag(e),replace(e,t){t.buffers||(t.buffers=[]);const r=t.buffers.indexOf(e);return r>-1?{index:r}:(t.buffers.push(e),p(e))},revive(e,t){if(t.buffers||(t.buffers=[]),"object"==typeof e)return t.buffers[e.index];const r=d(e);return t.buffers.push(r),r}}},b={bigintObject:{test:e=>"object"==typeof e&&hasConstructorOf(e,BigInt),replace:String,revive:e=>new Object(BigInt(e))}},m={bigint:{test:e=>"bigint"==typeof e,replace:String,revive:e=>BigInt(e)}};function string2arraybuffer(e){const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t.buffer}const h={blob:{test:e=>"Blob"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad Blob access: "+t.status);return {type:e.type,stringContents:t.responseText}},revive(e){const{type:t,stringContents:r}=e;return new Blob([string2arraybuffer(r)],{type:t})},replaceAsync:t=>new e(((e,r)=>{const n=new FileReader;n.addEventListener("load",(()=>{e({type:t.type,stringContents:n.result});})),n.addEventListener("error",(()=>{r(n.error);})),n.readAsBinaryString(t);}))}};const _={cryptokey:{test:e=>"CryptoKey"===toStringTag(e)&&e.extractable,replaceAsync:t=>new e((async(e,r)=>{let n;try{n=await crypto.subtle.exportKey("jwk",t);}catch(e){return void r(e)}e({jwk:n,algorithm:t.algorithm,usages:t.usages});})),revive(e){const{jwk:t,algorithm:r,usages:n}=e;return crypto.subtle.importKey("jwk",t,r,!0,n)}}},w={dataview:{test:e=>"DataView"===toStringTag(e),replace({buffer:e,byteOffset:t,byteLength:r},n){n.buffers||(n.buffers=[]);const o=n.buffers.indexOf(e);return o>-1?{index:o,byteOffset:t,byteLength:r}:(n.buffers.push(e),{encoded:p(e),byteOffset:t,byteLength:r})},revive(e,t){t.buffers||(t.buffers=[]);const{byteOffset:r,byteLength:n,encoded:o,index:a}=e;let i;return "index"in e?i=t.buffers[a]:(i=d(o),t.buffers.push(i)),new DataView(i,r,n)}}},A={date:{test:e=>"Date"===toStringTag(e),replace(e){const t=e.getTime();return Number.isNaN(t)?"NaN":t},revive:e=>"NaN"===e?new Date(Number.NaN):new Date(e)}},S={domexception:{test:e=>"DOMException"===toStringTag(e),replace:e=>({name:e.name,message:e.message}),revive:({message:e,name:t})=>new DOMException(e,t)}},j={dommatrix:{test:e=>"DOMMatrix"===toStringTag(e),replace:e=>e.is2D?{a:e.a,b:e.b,c:e.c,d:e.d,e:e.e,f:e.f}:{m11:e.m11,m12:e.m12,m13:e.m13,m14:e.m14,m21:e.m21,m22:e.m22,m23:e.m23,m24:e.m24,m31:e.m31,m32:e.m32,m33:e.m33,m34:e.m34,m41:e.m41,m42:e.m42,m43:e.m43,m44:e.m44},revive:e=>Object.hasOwn(e,"a")?new DOMMatrix([e.a,e.b,e.c,e.d,e.e,e.f]):new DOMMatrix([e.m11,e.m12,e.m13,e.m14,e.m21,e.m22,e.m23,e.m24,e.m31,e.m32,e.m33,e.m34,e.m41,e.m42,e.m43,e.m44])}},T={dompoint:{test:e=>"DOMPoint"===toStringTag(e),replace:e=>({x:e.x,y:e.y,z:e.z,w:e.w}),revive:({x:e,y:t,z:r,w:n})=>new DOMPoint(e,t,r,n)}},N={domrect:{test:e=>"DOMRect"===toStringTag(e),replace:e=>({x:e.x,y:e.y,width:e.width,height:e.height}),revive:({x:e,y:t,width:r,height:n})=>new DOMRect(e,t,r,n)}},I={error:{test:e=>"Error"===toStringTag(e),replace:({name:e,message:t,cause:r,stack:n,fileName:o,lineNumber:a,columnNumber:i})=>({name:e,message:t,cause:r,stack:n,fileName:o,lineNumber:a,columnNumber:i}),revive(e){const t=new Error(e.message);return t.name=e.name,t.cause=e.cause,t.stack=e.stack,t.fileName=e.fileName,t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}}},P={};function create$2(e){P[e.name.toLowerCase()]={test:t=>hasConstructorOf(t,e),replace:({name:e,message:t,cause:r,stack:n,fileName:o,lineNumber:a,columnNumber:i,errors:c})=>({name:e,message:t,cause:r,stack:n,fileName:o,lineNumber:a,columnNumber:i,errors:c}),revive(t){const r="undefined"!=typeof AggregateError&&e===AggregateError,n=r?new e(t.errors,t.message):new e(t.message);return n.name=t.name,n.cause=t.cause,n.stack=t.stack,n.fileName=t.fileName,n.lineNumber=t.lineNumber,n.columnNumber=t.columnNumber,r&&(n.errors=t.errors),n}};}[TypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError].forEach((e=>create$2(e))),"undefined"!=typeof AggregateError&&create$2(AggregateError),"function"==typeof InternalError&&create$2(InternalError);const E={file:{test:e=>"File"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad File access: "+t.status);return {type:e.type,stringContents:t.responseText,name:e.name,lastModified:e.lastModified}},revive:({name:e,type:t,stringContents:r,lastModified:n})=>new File([string2arraybuffer(r)],e,{type:t,lastModified:n}),replaceAsync:t=>new e((function(e,r){const n=new FileReader;n.addEventListener("load",(function(){e({type:t.type,stringContents:n.result,name:t.name,lastModified:t.lastModified});})),n.addEventListener("error",(function(){r(n.error);})),n.readAsBinaryString(t);}))}},x={file:E.file,filelist:{test:e=>"FileList"===toStringTag(e),replace(e){const t=[];for(let r=0;r<e.length;r++)t[r]=e.item(r);return t},revive(e){class FileList{constructor(){this._files=arguments[0],this.length=this._files.length;}item(e){return this._files[e]}get[Symbol.toStringTag](){return "FileList"}}return new FileList(e)}}},C={imagebitmap:{test:e=>"ImageBitmap"===toStringTag(e)||e&&e.dataset&&"ImageBitmap"===e.dataset.toStringTag,replace(e){const t=document.createElement("canvas");return t.getContext("2d").drawImage(e,0,0),t.toDataURL()},revive(e){const t=document.createElement("canvas"),r=t.getContext("2d"),n=document.createElement("img");return n.addEventListener("load",(function(){r.drawImage(n,0,0);})),n.src=e,t},reviveAsync(t){const r=document.createElement("canvas"),n=r.getContext("2d"),o=document.createElement("img");return o.addEventListener("load",(function(){n.drawImage(o,0,0);})),o.src=t,new e((async(e,t)=>{try{e(await createImageBitmap(r));}catch(e){t(e);}}))}}},k={imagedata:{test:e=>"ImageData"===toStringTag(e),replace:e=>({array:[...e.data],width:e.width,height:e.height}),revive:e=>new ImageData(new Uint8ClampedArray(e.array),e.width,e.height)}},B={infinity:{test:e=>e===Number.POSITIVE_INFINITY,replace:()=>"Infinity",revive:()=>Number.POSITIVE_INFINITY}},D={map:{test:e=>"Map"===toStringTag(e),replace:e=>[...e.entries()],revive:e=>new Map(e)}},K={nan:{test:e=>Number.isNaN(e),replace:()=>"NaN",revive:()=>Number.NaN}},L={negativeInfinity:{test:e=>e===Number.NEGATIVE_INFINITY,replace:()=>"-Infinity",revive:()=>Number.NEGATIVE_INFINITY}},F={negativeZero:{test:e=>Object.is(e,-0),replace:()=>0,revive:()=>-0}},J={StringObject:{test:e=>"String"===toStringTag(e)&&"object"==typeof e,replace:String,revive:e=>new String(e)},BooleanObject:{test:e=>"Boolean"===toStringTag(e)&&"object"==typeof e,replace:Boolean,revive:e=>new Boolean(e)},NumberObject:{test:e=>"Number"===toStringTag(e)&&"object"==typeof e,replace:Number,revive:e=>new Number(e)}},V={regexp:{test:e=>"RegExp"===toStringTag(e),replace:e=>({source:e.source,flags:(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":"")}),revive:({source:e,flags:t})=>new RegExp(e,t)}},W={set:{test:e=>"Set"===toStringTag(e),replace:e=>[...e.values()],revive:e=>new Set(e)}},G={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[]].forEach((e=>function create$1(e){const t=e.name;G[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace:e=>(0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e:e.slice(0)).buffer,revive:t=>"ArrayBuffer"===toStringTag(t)?new e(t):t};}(e)));const H={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[]].forEach((e=>function create(e){const t=e.name;H[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace({buffer:e,byteOffset:t,length:r},n){n.buffers||(n.buffers=[]);const o=n.buffers.indexOf(e);return o>-1?{index:o,byteOffset:t,length:r}:(n.buffers.push(e),{encoded:p(e),byteOffset:t,length:r})},revive(t,r){r.buffers||(r.buffers=[]);const{byteOffset:n,length:o,encoded:a,index:i}=t;let c;return "index"in t?c=r.buffers[i]:(c=d(a),r.buffers.push(c)),new e(c,n,o)}};}(e)));const z={undef:{test:(e,t)=>void 0===e&&(t.ownKeys||!("ownKeys"in t)),replace:()=>0,revive:()=>new s}},X={userObject:{test:e=>isUserObject(e),replace:e=>({...e}),revive:e=>e}},Z=[{arrayNonindexKeys:{testPlainObjects:!0,test:(e,t)=>!!Array.isArray(e)&&(Object.keys(e).some((e=>String(Number.parseInt(e))!==e))&&(t.iterateIn="object",t.addLength=!0),!0),replace:(e,t)=>(t.iterateUnsetNumeric=!0,e),revive(e){if(Array.isArray(e))return e;const t=[];return Object.entries(e).forEach((([e,r])=>{t[e]=r;})),t}}},{sparseUndefined:{test:(e,t)=>void 0===e&&!1===t.ownKeys,replace:()=>0,revive(){}}}],Q=[K,B,L,F],oe=[X,z,Z,J,Q,A,V,k,C,E,x,h,I,P].concat("function"==typeof Map?D:[],"function"==typeof Set?W:[],"function"==typeof ArrayBuffer?v:[],"function"==typeof Uint8Array?H:[],"function"==typeof DataView?w:[],"undefined"!=typeof crypto?_:[],"undefined"!=typeof BigInt?[m,b]:[],"undefined"!=typeof DOMException?S:[],"undefined"!=typeof DOMRect?N:[],"undefined"!=typeof DOMPoint?T:[],"undefined"!=typeof DOMMatrix?j:[]),ae=oe.concat({checkDataCloneException:{test(e){const t={}.toString.call(e).slice(8,-1);if(["symbol","function"].includes(typeof e)||["Arguments","Module","Promise","WeakMap","WeakSet","Event","MessageChannel"].includes(t)||e&&"object"==typeof e&&"number"==typeof e.nodeType&&"function"==typeof e.insertBefore)throw new DOMException("The object cannot be cloned.","DataCloneError");return !1}}});
2318
+ function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n);}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return (t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _slicedToArray(e,t){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o,i,c=[],s=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1;}else for(;!(s=(n=o.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){u=!0,a=e;}finally{try{if(!s&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||_unsupportedIterableToArray(e,t)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return "Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:String(t)}var e=_createClass((function TypesonPromise(e){_classCallCheck(this,TypesonPromise),this.p=new Promise(e);}));e.__typeson__type__="TypesonPromise","undefined"!=typeof Symbol&&Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function get(){return "TypesonPromise"}}),e.prototype.then=function(t,r){var n=this;return new e((function(e,a){n.p.then((function(r){e(t?t(r):r);})).catch((function(e){return r?r(e):Promise.reject(e)})).then(e,a);}))},e.prototype.catch=function(e){return this.then((function(){}),e)},e.resolve=function(t){return new e((function(e){e(t);}))},e.reject=function(t){return new e((function(e,r){r(t);}))},e.all=function(t){return new e((function(e,r){Promise.all(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))},e.race=function(t){return new e((function(e,r){Promise.race(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))},e.allSettled=function(t){return new e((function(e,r){Promise.allSettled(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))};var t=Object.hasOwn,r=Object.getPrototypeOf;function isThenable(e,t){return isObject(e)&&"function"==typeof e.then&&(!t||"function"==typeof e.catch)}function toStringTag(e){return Object.prototype.toString.call(e).slice(8,-1)}function hasConstructorOf(e,n){if(!e||"object"!==_typeof(e))return !1;var a=r(e);if(!a)return null===n;var o=t(a,"constructor")&&a.constructor;return "function"!=typeof o?null===n:n===o||null!==n&&Function.prototype.toString.call(o)===Function.prototype.toString.call(n)||"function"==typeof n&&"string"==typeof o.__typeson__type__&&o.__typeson__type__===n.__typeson__type__}function isPlainObject(e){return !(!e||"Object"!==toStringTag(e))&&(!r(e)||hasConstructorOf(e,Object))}function isUserObject(e){if(!e||"Object"!==toStringTag(e))return !1;var t=r(e);return !t||hasConstructorOf(e,Object)||isUserObject(t)}function isObject(e){return null!==e&&"object"===_typeof(e)}function escapeKeyPathComponent(e){return e.replaceAll("''","''''").replace(/^$/,"''").replaceAll("~","~0").replaceAll(".","~1")}function unescapeKeyPathComponent(e){return e.replaceAll("~1",".").replaceAll("~0","~").replace(/^''$/,"").replaceAll("''''","''")}function getByKeyPath(e,t){if(""===t)return e;if(null===e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");var r=t.indexOf(".");if(r>-1){var n=e[unescapeKeyPathComponent(t.slice(0,r))];return void 0===n?void 0:getByKeyPath(n,t.slice(r+1))}return e[unescapeKeyPathComponent(t)]}function setAtKeyPath(e,t,r){if(""===t)return r;if(!e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");var n=t.indexOf(".");return n>-1?setAtKeyPath(e[unescapeKeyPathComponent(t.slice(0,n))],t.slice(n+1),r):(e[unescapeKeyPathComponent(t)]=r,e)}function getJSONType(e){return null===e?"null":Array.isArray(e)?"array":_typeof(e)}function _await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}var n=Object.keys,a=Object.hasOwn,o=Array.isArray,i=["type","replaced","iterateIn","iterateUnsetNumeric","addLength"];function _async(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function nestedPathsFirst(e,t){var r,n;if(""===e.keypath)return -1;var a=null!==(r=e.keypath.match(/\./g))&&void 0!==r?r:0,o=null!==(n=t.keypath.match(/\./g))&&void 0!==n?n:0;return a&&(a=a.length),o&&(o=o.length),a>o?-1:a<o?1:e.keypath<t.keypath?-1:e.keypath>t.keypath?1:0}var c=function(){function Typeson(e){_classCallCheck(this,Typeson),this.options=e,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={};}return _createClass(Typeson,[{key:"stringify",value:function stringify(e,t,r,n){n=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),n),{},{stringification:!0});var a=this.encapsulate(e,null,n);return o(a)?JSON.stringify(a[0],t,r):a.then((function(e){return JSON.stringify(e,t,r)}))}},{key:"stringifySync",value:function stringifySync(e,t,r,n){return this.stringify(e,t,r,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},n),{},{sync:!0}))}},{key:"stringifyAsync",value:function stringifyAsync(e,t,r,n){return this.stringify(e,t,r,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},n),{},{sync:!1}))}},{key:"parse",value:function parse(e,t,r){return r=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),r),{},{parse:!0}),this.revive(JSON.parse(e,t),r)}},{key:"parseSync",value:function parseSync(e,t,r){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!0}))}},{key:"parseAsync",value:function parseAsync(e,t,r){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!1}))}},{key:"specialTypeNames",value:function specialTypeNames(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.returnTypeNames=!0,this.encapsulate(e,t,r)}},{key:"rootTypeName",value:function rootTypeName(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.iterateNone=!0,this.encapsulate(e,t,r)}},{key:"encapsulate",value:function encapsulate(t,r,c){var s=this,u=_objectSpread2(_objectSpread2({sync:!0},this.options),c),l=u.sync,f={},y=[],p=[],d=[],v=!("cyclic"in u)||u.cyclic,b=u.encapsulateObserver,m=function finish(e){var t=Object.values(f);if(u.iterateNone)return t.length?t[0]:getJSONType(e);if(t.length){if(u.returnTypeNames)return function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}(e)||function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||_unsupportedIterableToArray(e)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(new Set(t));e&&isPlainObject(e)&&!a(e,"$types")?e.$types=f:e={$:e,$types:{$:f}};}else isObject(e)&&a(e,"$types")&&(e={$:e,$types:!0});return !u.returnTypeNames&&e},h=_async((function(t,r){return _await(Promise.all(r.map((function(e){return e[1].p}))),(function(n){return _await(Promise.all(n.map(_async((function(n){var a=!1,o=[],i=_slicedToArray(r.splice(0,1),1),c=_slicedToArray(i[0],7),s=c[0],u=c[2],l=c[3],f=c[4],y=c[5],p=c[6],d=O(s,n,u,l,o,!0,p),v=hasConstructorOf(d,e);return function _invoke(e,t){var r=e();return r&&r.then?r.then(t):t(r)}((function(){if(s&&v)return _await(d.p,(function(e){f[y]=e;var r=h(t,o);return a=!0,r}))}),(function(e){return a?e:(s?f[y]=d:t=v?d.p:d,h(t,o))}))})))),(function(){return t}))}))})),g=function _adaptBuiltinStateObjectProperties(e,t,r){Object.assign(e,t);var n=i.map((function(t){var r=e[t];return delete e[t],r}));r(),i.forEach((function(t,r){e[t]=n[r];}));},O=function _encapsulate(t,r,i,c,l,d,v){var m,h={},O=_typeof(r),w=b?function(n){var a,o=null!==(a=null!=v?v:c.type)&&void 0!==a?a:getJSONType(r);b(Object.assign(null!=n?n:h,{keypath:t,value:r,cyclic:i,stateObj:c,promisesData:l,resolvingTypesonPromise:d,awaitingTypesonPromise:hasConstructorOf(r,e)},{type:o}));}:null;if(["string","boolean","number","undefined"].includes(O))return void 0===r||Number.isNaN(r)||r===Number.NEGATIVE_INFINITY||r===Number.POSITIVE_INFINITY||0===r?(m=c.replaced?r:_(t,r,c,l,!1,d,w))!==r&&(h={replaced:m}):m=r,w&&w(),m;if(null===r)return w&&w(),r;if(i&&!c.iterateIn&&!c.iterateUnsetNumeric&&r&&"object"===_typeof(r)){var A=y.indexOf(r);if(!(A<0))return f[t]="#",w&&w({cyclicKeypath:p[A]}),"#"+p[A];!0===i&&(y.push(r),p.push(t));}var S,j,T=isPlainObject(r),N=o(r),I=(T||N)&&(!s.plainObjectReplacers.length||c.replaced)||c.iterateIn?r:_(t,r,c,l,T||N,null,w);if(I!==r?(m=I,h={replaced:I}):""===t&&hasConstructorOf(r,e)?(l.push([t,r,i,c,void 0,void 0,c.type]),m=r):N&&"object"!==c.iterateIn||"array"===c.iterateIn?(S=new Array(r.length),h={clone:S}):(["function","symbol"].includes(_typeof(r))||"toJSON"in r||hasConstructorOf(r,e)||hasConstructorOf(r,Promise)||hasConstructorOf(r,ArrayBuffer))&&!T&&"object"!==c.iterateIn?m=r:(S={},c.addLength&&(S.length=r.length),h={clone:S}),w&&w(),u.iterateNone)return null!==(j=S)&&void 0!==j?j:m;if(!S)return m;if(c.iterateIn){var P=function _loop(n){var o={ownKeys:a(r,n)};g(c,o,(function(){var a=t+(t?".":"")+escapeKeyPathComponent(n),o=_encapsulate(a,r[n],Boolean(i),c,l,d);hasConstructorOf(o,e)?l.push([a,o,Boolean(i),c,S,n,c.type]):void 0!==o&&(S[n]=o);}));};for(var E in r)P(E);w&&w({endIterateIn:!0,end:!0});}else n(r).forEach((function(n){var a=t+(t?".":"")+escapeKeyPathComponent(n);g(c,{ownKeys:!0},(function(){var t=_encapsulate(a,r[n],Boolean(i),c,l,d);hasConstructorOf(t,e)?l.push([a,t,Boolean(i),c,S,n,c.type]):void 0!==t&&(S[n]=t);}));})),w&&w({endIterateOwn:!0,end:!0});if(c.iterateUnsetNumeric){for(var x=r.length,C=function _loop2(n){if(!(n in r)){var a="".concat(t).concat(t?".":"").concat(n);g(c,{ownKeys:!1},(function(){var t=_encapsulate(a,void 0,Boolean(i),c,l,d);hasConstructorOf(t,e)?l.push([a,t,Boolean(i),c,S,n,c.type]):void 0!==t&&(S[n]=t);}));}},k=0;k<x;k++)C(k);w&&w({endIterateUnsetNumeric:!0,end:!0});}return S},_=function replace(e,t,r,n,a,o,i){for(var c=a?s.plainObjectReplacers:s.nonplainObjectReplacers,u=c.length;u--;){var y=c[u];if(y.test(t,r)){var p=y.type;if(s.revivers[p]){var d=f[e];f[e]=d?[p].concat(d):p;}if(Object.assign(r,{type:p,replaced:!0}),(l||!y.replaceAsync)&&!y.replace)return i&&i({typeDetected:!0}),O(e,t,v&&"readonly",r,n,o,p);i&&i({replacing:!0});var b=void 0;if(l||!y.replaceAsync){if(void 0===y.replace)throw new TypeError("Missing replacer");b=y.replace(t,r);}else b=y.replaceAsync(t,r);return O(e,b,v&&"readonly",r,n,o,p)}}return t},w=O("",t,v,null!=r?r:{},d);if(d.length)return l&&u.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(h(w,d)).then(m);if(!l&&u.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return u.stringification&&l?[m(w)]:l?m(w):Promise.resolve(m(w))}},{key:"encapsulateSync",value:function encapsulateSync(e,t,r){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!0}))}},{key:"encapsulateAsync",value:function encapsulateAsync(e,t,r){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!1}))}},{key:"revive",value:function revive(t,r){var a=this,i=_objectSpread2(_objectSpread2({sync:!0},this.options),r),c=i.sync;function finishRevival(e){if(c)return e;if(i.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return Promise.resolve(e)}if(!t||"object"!==_typeof(t)||Array.isArray(t))return finishRevival(t);var u=t.$types;if(!0===u)return finishRevival(t.$);if(!u||"object"!==_typeof(u)||Array.isArray(u))return finishRevival(t);var l=[],f={},y=!0;u.$&&isPlainObject(u.$)&&(t=t.$,u=u.$,y=!1);var p=function executeReviver(e,t){var r,n=_slicedToArray(null!==(r=a.revivers[e])&&void 0!==r?r:[],1)[0];if(!n)throw new Error("Unregistered type: "+e);if(c&&!("revive"in n))return t;if(!c&&n.reviveAsync)return n.reviveAsync(t,f);if(n.revive)return n.revive(t,f);throw new Error("Missing reviver")},d=[];function checkUndefined(e){return hasConstructorOf(e,s)?void 0:e}var v,b=function revivePlainObjects(){var r=[];if(!u)throw new Error("Found bad `types`");if(Object.entries(u).forEach((function(e){var t=_slicedToArray(e,2),n=t[0],o=t[1];"#"!==o&&[].concat(o).forEach((function(e){var t;_slicedToArray(null!==(t=a.revivers[e])&&void 0!==t?t:[null,{}],2)[1].plain&&(r.push({keypath:n,type:e}),delete u[n]);}));})),r.length)return r.sort(nestedPathsFirst).reduce((function reducer(r,n){var a=n.keypath,o=n.type;if(isThenable(r))return r.then((function(e){return reducer(e,{keypath:a,type:o})}));var i=getByKeyPath(t,a);if(hasConstructorOf(i=p(o,i),e))return i.then((function(e){var r=setAtKeyPath(t,a,e);r===e&&(t=r);}));var c=setAtKeyPath(t,a,i);c===i&&(t=c);}),void 0)}();return hasConstructorOf(b,e)?v=b.then((function(){return t})):(v=function _revive(t,r,a,i,c){if(!y||"$types"!==t){var f=u[t],v=o(r);if(v||isPlainObject(r)){var b=v?new Array(r.length):{};for(n(r).forEach((function(n){var o=_revive(t+(t?".":"")+escapeKeyPathComponent(n),r[n],null!=a?a:b,b,n),i=function set(e){return hasConstructorOf(e,s)?b[n]=void 0:void 0!==e&&(b[n]=e),e};hasConstructorOf(o,e)?d.push(o.then((function(e){return i(e)}))):i(o);})),r=b;l.length;){var m=_slicedToArray(l[0],4),h=m[0],g=m[1],O=m[2],_=m[3],w=getByKeyPath(h,g);if(void 0===w)break;O[_]=w,l.splice(0,1);}}if(!f)return r;if("#"===f){var A=getByKeyPath(a,r.slice(1));return void 0===A&&l.push([a,r.slice(1),i,c]),A}return [].concat(f).reduce((function reducer(t,r){if(hasConstructorOf(t,e))return t.then((function(e){return reducer(e,r)}));if("string"!=typeof r)throw new TypeError("Bad type JSON");return p(r,t)}),r)}}("",t,null),d.length&&(v=e.resolve(v).then((function(t){return e.all([t].concat(d))})).then((function(e){return _slicedToArray(e,1)[0]})))),isThenable(v)?c&&i.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():hasConstructorOf(v,e)?v.p.then(checkUndefined):v:!c&&i.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():c?checkUndefined(v):Promise.resolve(checkUndefined(v))}},{key:"reviveSync",value:function reviveSync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!0}))}},{key:"reviveAsync",value:function reviveAsync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!1}))}},{key:"register",value:function register(e,t){var r=this,a=null!=t?t:{},i=function R(e){o(e)?e.forEach((function(e){return R(e)})):n(e).forEach((function(t){var n;if("#"===t)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(u.includes(t))throw new TypeError("Plain JSON object types are reserved as type names");var i=e[t],c=i&&"function"!=typeof i&&!Array.isArray(i)&&i.testPlainObjects?r.plainObjectReplacers:r.nonplainObjectReplacers,s=c.filter((function(e){return e.type===t}));if(s.length&&(c.splice(c.indexOf(s[0]),1),delete r.revivers[t],delete r.types[t]),"function"==typeof i){var l=i;i={test:function test(e){return e&&e.constructor===l},replace:function replace(e){return _objectSpread2({},e)},revive:function revive(e){return Object.assign(Object.create(l.prototype),e)}};}else if(o(i)){var f=_slicedToArray(i,3);i={test:f[0],replace:f[1],revive:f[2]};}if(null!==(n=i)&&void 0!==n&&n.test){var y={type:t,test:i.test.bind(i)};i.replace&&(y.replace=i.replace.bind(i)),i.replaceAsync&&(y.replaceAsync=i.replaceAsync.bind(i));var p="number"==typeof a.fallback?a.fallback:a.fallback?0:Number.POSITIVE_INFINITY;if(i.testPlainObjects?r.plainObjectReplacers.splice(p,0,y):r.nonplainObjectReplacers.splice(p,0,y),i.revive||i.reviveAsync){var d={};i.revive&&(d.revive=i.revive.bind(i)),i.reviveAsync&&(d.reviveAsync=i.reviveAsync.bind(i)),r.revivers[t]=[d,{plain:i.testPlainObjects}];}r.types[t]=i;}}));};return [].concat(e).forEach((function(e){return i(e)})),this}}]),Typeson}(),s=_createClass((function Undefined(){_classCallCheck(this,Undefined);}));s.__typeson__type__="TypesonUndefined";for(var u=["null","boolean","number","string","array","object"],l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=new Uint8Array(256),y=0;y<64;y++)f[l.codePointAt(y)]=y;var p=function encode(e,t,r){null==r&&(r=e.byteLength);for(var n=new Uint8Array(e,t||0,r),a=n.length,o="",i=0;i<a;i+=3)o+=l[n[i]>>2],o+=l[(3&n[i])<<4|n[i+1]>>4],o+=l[(15&n[i+1])<<2|n[i+2]>>6],o+=l[63&n[i+2]];return a%3==2?o=o.slice(0,-1)+"=":a%3==1&&(o=o.slice(0,-2)+"=="),o},d=function decode(e){var t=e.length;if(t%4)throw new Error("Bad base64 length: not divisible by four");var r,n,a,o,i=.75*e.length,c=0;"="===e[e.length-1]&&(i--,"="===e[e.length-2]&&i--);for(var s=new ArrayBuffer(i),u=new Uint8Array(s),l=0;l<t;l+=4)r=f[e.codePointAt(l)],n=f[e.codePointAt(l+1)],a=f[e.codePointAt(l+2)],o=f[e.codePointAt(l+3)],u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|a>>2,u[c++]=(3&a)<<6|63&o;return s};const v={arraybuffer:{test:e=>"ArrayBuffer"===toStringTag(e),replace(e,t){t.buffers||(t.buffers=[]);const r=t.buffers.indexOf(e);return r>-1?{index:r}:(t.buffers.push(e),p(e))},revive(e,t){if(t.buffers||(t.buffers=[]),"object"==typeof e)return t.buffers[e.index];const r=d(e);return t.buffers.push(r),r}}},b={bigintObject:{test:e=>"object"==typeof e&&hasConstructorOf(e,BigInt),replace:String,revive:e=>new Object(BigInt(e))}},m={bigint:{test:e=>"bigint"==typeof e,replace:String,revive:e=>BigInt(e)}};function string2arraybuffer(e){const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t.buffer}const h={blob:{test:e=>"Blob"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad Blob access: "+t.status);return {type:e.type,stringContents:t.responseText}},revive(e){const{type:t,stringContents:r}=e;return new Blob([string2arraybuffer(r)],{type:t})},replaceAsync:t=>new e(((e,r)=>{const n=new FileReader;n.addEventListener("load",(()=>{e({type:t.type,stringContents:n.result});})),n.addEventListener("error",(()=>{r(n.error);})),n.readAsBinaryString(t);}))}};function generateUUID(){let e=Date.now()+("undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():0);return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/gu,(function(t){const r=Math.trunc((e+16*Math.random())%16);return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)}))}const _={cryptokey:{test:e=>"CryptoKey"===toStringTag(e)&&e.extractable,replaceAsync:t=>new e((async(e,r)=>{let n;try{n=await crypto.subtle.exportKey("jwk",t);}catch(e){return void r(e)}e({jwk:n,algorithm:t.algorithm,usages:t.usages});})),revive(e){const{jwk:t,algorithm:r,usages:n}=e;return crypto.subtle.importKey("jwk",t,r,!0,n)}}},w={dataview:{test:e=>"DataView"===toStringTag(e),replace({buffer:e,byteOffset:t,byteLength:r},n){n.buffers||(n.buffers=[]);const a=n.buffers.indexOf(e);return a>-1?{index:a,byteOffset:t,byteLength:r}:(n.buffers.push(e),{encoded:p(e),byteOffset:t,byteLength:r})},revive(e,t){t.buffers||(t.buffers=[]);const{byteOffset:r,byteLength:n,encoded:a,index:o}=e;let i;return "index"in e?i=t.buffers[o]:(i=d(a),t.buffers.push(i)),new DataView(i,r,n)}}},A={date:{test:e=>"Date"===toStringTag(e),replace(e){const t=e.getTime();return Number.isNaN(t)?"NaN":t},revive:e=>"NaN"===e?new Date(Number.NaN):new Date(e)}},S={domexception:{test:e=>"DOMException"===toStringTag(e),replace:e=>({name:e.name,message:e.message}),revive:({message:e,name:t})=>new DOMException(e,t)}},j={};function create$5(e){j[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>e.is2D?{a:e.a,b:e.b,c:e.c,d:e.d,e:e.e,f:e.f}:{m11:e.m11,m12:e.m12,m13:e.m13,m14:e.m14,m21:e.m21,m22:e.m22,m23:e.m23,m24:e.m24,m31:e.m31,m32:e.m32,m33:e.m33,m34:e.m34,m41:e.m41,m42:e.m42,m43:e.m43,m44:e.m44},revive:t=>Object.hasOwn(t,"a")?new e([t.a,t.b,t.c,t.d,t.e,t.f]):new e([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44])};}"undefined"!=typeof DOMMatrix&&create$5(DOMMatrix),"undefined"!=typeof DOMMatrixReadOnly&&create$5(DOMMatrixReadOnly);const T={};function create$4(e){T[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>({x:e.x,y:e.y,z:e.z,w:e.w}),revive:({x:t,y:r,z:n,w:a})=>new e(t,r,n,a)};}"undefined"!=typeof DOMPoint&&create$4(DOMPoint),"undefined"!=typeof DOMPointReadOnly&&create$4(DOMPointReadOnly);const N={domquad:{test:e=>"DOMQuad"===toStringTag(e),replace:e=>({p1:e.p1,p2:e.p2,p3:e.p3,p4:e.p4}),revive:({p1:e,p2:t,p3:r,p4:n})=>new DOMQuad(e,t,r,n)}},I={};function create$3(e){I[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>({x:e.x,y:e.y,width:e.width,height:e.height}),revive:({x:t,y:r,width:n,height:a})=>new e(t,r,n,a)};}"undefined"!=typeof DOMRect&&create$3(DOMRect),"undefined"!=typeof DOMRectReadOnly&&create$3(DOMRectReadOnly);const P={error:{test:e=>"Error"===toStringTag(e),replace:({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:i})=>({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:i}),revive(e){const t=new Error(e.message);return t.name=e.name,t.cause=e.cause,t.stack=e.stack,t.fileName=e.fileName,t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}}},E={};function create$2(e){E[e.name.toLowerCase()]={test:t=>hasConstructorOf(t,e),replace:({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:i,errors:c})=>({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:i,errors:c}),revive(t){const r="undefined"!=typeof AggregateError&&e===AggregateError?new e(t.errors,t.message):new e(t.message);return r.name=t.name,r.cause=t.cause,r.stack=t.stack,r.fileName=t.fileName,r.lineNumber=t.lineNumber,r.columnNumber=t.columnNumber,r}};}[TypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError].forEach((e=>create$2(e))),"undefined"!=typeof AggregateError&&create$2(AggregateError),"function"==typeof InternalError&&create$2(InternalError);const x={file:{test:e=>"File"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad File access: "+t.status);return {type:e.type,stringContents:t.responseText,name:e.name,lastModified:e.lastModified}},revive:({name:e,type:t,stringContents:r,lastModified:n})=>new File([string2arraybuffer(r)],e,{type:t,lastModified:n}),replaceAsync:t=>new e((function(e,r){const n=new FileReader;n.addEventListener("load",(function(){e({type:t.type,stringContents:n.result,name:t.name,lastModified:t.lastModified});})),n.addEventListener("error",(function(){r(n.error);})),n.readAsBinaryString(t);}))}},C={file:x.file,filelist:{test:e=>"FileList"===toStringTag(e),replace(e){const t=[];for(let r=0;r<e.length;r++)t[r]=e.item(r);return t},revive(e){class FileList{constructor(){this._files=arguments[0],this.length=this._files.length;}item(e){return this._files[e]}get[Symbol.toStringTag](){return "FileList"}}return new FileList(e)}}},k={imagebitmap:{test:e=>"ImageBitmap"===toStringTag(e)||e&&e.dataset&&"ImageBitmap"===e.dataset.toStringTag,replace(e){const t=document.createElement("canvas");return t.getContext("2d").drawImage(e,0,0),t.toDataURL()},revive(e){const t=document.createElement("canvas"),r=t.getContext("2d"),n=document.createElement("img");return n.addEventListener("load",(function(){r.drawImage(n,0,0);})),n.src=e,t},reviveAsync(t){const r=document.createElement("canvas"),n=r.getContext("2d"),a=document.createElement("img");return a.addEventListener("load",(function(){n.drawImage(a,0,0);})),a.src=t,new e((async(e,t)=>{try{e(await createImageBitmap(r));}catch(e){t(e);}}))}}},B={imagedata:{test:e=>"ImageData"===toStringTag(e),replace:e=>({array:[...e.data],width:e.width,height:e.height}),revive:e=>new ImageData(new Uint8ClampedArray(e.array),e.width,e.height)}},U$1={infinity:{test:e=>e===Number.POSITIVE_INFINITY,replace:()=>"Infinity",revive:()=>Number.POSITIVE_INFINITY}},K={map:{test:e=>"Map"===toStringTag(e),replace:e=>[...e.entries()],revive:e=>new Map(e)}},L={nan:{test:e=>Number.isNaN(e),replace:()=>"NaN",revive:()=>Number.NaN}},F={negativeInfinity:{test:e=>e===Number.NEGATIVE_INFINITY,replace:()=>"-Infinity",revive:()=>Number.NEGATIVE_INFINITY}},$$1={negativeZero:{test:e=>Object.is(e,-0),replace:()=>0,revive:()=>-0}},V={StringObject:{test:e=>"String"===toStringTag(e)&&"object"==typeof e,replace:String,revive:e=>new String(e)},BooleanObject:{test:e=>"Boolean"===toStringTag(e)&&"object"==typeof e,replace:Boolean,revive:e=>new Boolean(e)},NumberObject:{test:e=>"Number"===toStringTag(e)&&"object"==typeof e,replace:Number,revive:e=>new Number(e)}},q={regexp:{test:e=>"RegExp"===toStringTag(e),replace:e=>({source:e.source,flags:(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":"")}),revive:({source:e,flags:t})=>new RegExp(e,t)}},Y={},W={resurrectable:{test:e=>e&&!Array.isArray(e)&&["object","function","symbol"].includes(typeof e),replace(e){const t=generateUUID();return Y[t]=e,t},revive:e=>Y[e]}},G={set:{test:e=>"Set"===toStringTag(e),replace:e=>[...e.values()],revive:e=>new Set(e)}},H={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[]].forEach((e=>function create$1(e){const t=e.name;H[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace:e=>(0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e:e.slice(0)).buffer,revive:t=>"ArrayBuffer"===toStringTag(t)?new e(t):t};}(e)));const z={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[]].forEach((e=>function create(e){const t=e.name;z[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace({buffer:e,byteOffset:t,length:r},n){n.buffers||(n.buffers=[]);const a=n.buffers.indexOf(e);return a>-1?{index:a,byteOffset:t,length:r}:(n.buffers.push(e),{encoded:p(e),byteOffset:t,length:r})},revive(t,r){r.buffers||(r.buffers=[]);const{byteOffset:n,length:a,encoded:o,index:i}=t;let c;return "index"in t?c=r.buffers[i]:(c=d(o),r.buffers.push(c)),new e(c,n,a)}};}(e)));const Q={undef:{test:(e,t)=>void 0===e&&(t.ownKeys||!("ownKeys"in t)),replace:()=>0,revive:()=>new s}},X={userObject:{test:e=>isUserObject(e),replace:e=>({...e}),revive:e=>e}},Z=[{arrayNonindexKeys:{testPlainObjects:!0,test:(e,t)=>!!Array.isArray(e)&&(Object.keys(e).some((e=>String(Number.parseInt(e))!==e))&&(t.iterateIn="object",t.addLength=!0),!0),replace:(e,t)=>(t.iterateUnsetNumeric=!0,e),revive(e){if(Array.isArray(e))return e;const t=[];return Object.entries(e).forEach((([e,r])=>{t[e]=r;})),t}}},{sparseUndefined:{test:(e,t)=>void 0===e&&!1===t.ownKeys,replace:()=>0,revive(){}}}],ee=[L,U$1,F,$$1],oe=[X,Q,Z,V,ee,A,q,B,k,x,C,h,P,E].concat("function"==typeof Map?K:[],"function"==typeof Set?G:[],"function"==typeof ArrayBuffer?v:[],"function"==typeof Uint8Array?z:[],"function"==typeof DataView?w:[],"undefined"!=typeof crypto?_:[],"undefined"!=typeof BigInt?[m,b]:[],"undefined"!=typeof DOMException?S:[],"undefined"!=typeof DOMRect?I:[],"undefined"!=typeof DOMPoint?T:[],"undefined"!=typeof DOMQuad?N:[],"undefined"!=typeof DOMMatrix?j:[]),ie=oe.concat({checkDataCloneException:{test(e){const t={}.toString.call(e).slice(8,-1);if(["symbol","function"].includes(typeof e)||["Arguments","Module","Promise","WeakMap","WeakSet","Event","MessageChannel"].includes(t)||e&&"object"==typeof e&&"number"==typeof e.nodeType&&"function"==typeof e.insertBefore)throw new DOMException("The object cannot be cloned.","DataCloneError");return !1}}});
2319
2319
 
2320
2320
  const nbsp = '\u00A0';
2321
2321
  const upArrow = '\u2191';
@@ -3082,6 +3082,15 @@ const json = {
3082
3082
  }
3083
3083
  };
3084
3084
 
3085
+ // We modify resurrectable in hopes an including application doesn't need it
3086
+ /** @type {import('typeson').TypeSpecSet} */ (
3087
+ W.resurrectable
3088
+ ).test = /** @type {import('typeson').Tester} */ (x) => {
3089
+ return x && typeof x === 'object' && !Array.isArray(x) &&
3090
+ // Could be a user object with a string tag, but we can't tell
3091
+ toStringTag(x) !== 'Object';
3092
+ };
3093
+
3085
3094
  /**
3086
3095
  * @typedef {(info: {
3087
3096
  * propName: string,
@@ -3164,8 +3173,6 @@ const encapsulateObserver = (stateObj) => {
3164
3173
  return;
3165
3174
  }
3166
3175
 
3167
- // console.log('observerObj', observerObj);
3168
-
3169
3176
  /** @type {import('../types.js').AvailableType} */
3170
3177
  let newType;
3171
3178
  let newValue = value;
@@ -3469,15 +3476,35 @@ const canonicalToAvailableType = (
3469
3476
  const structuredCloning = {
3470
3477
  iterate (records, stateObj) {
3471
3478
  // console.log('records', records);
3479
+ /* istanbul ignore if -- Just a guard */
3472
3480
  if (!stateObj.format) {
3473
3481
  stateObj.format = 'structuredCloning';
3474
3482
  }
3475
3483
  // Todo: Replace this with async typeson?
3476
3484
  // eslint-disable-next-line promise/avoid-new
3477
3485
  return new Promise((resolve, reject) => {
3486
+ const structuredCloningFixed = ie.filter(
3487
+ (typeSpecSet) => {
3488
+ return ![
3489
+ // Not yet supported within JSOE
3490
+ 'imagedata',
3491
+ 'imagebitmap',
3492
+ 'cryptokey',
3493
+ 'domquad'
3494
+ ].some((prop) => {
3495
+ return Object.hasOwn(typeSpecSet, prop);
3496
+ });
3497
+ }
3498
+ );
3499
+ structuredCloningFixed.splice(
3500
+ // Add after userObjects
3501
+ 1,
3502
+ 0,
3503
+ W
3504
+ );
3478
3505
  const typeson = new c({
3479
3506
  encapsulateObserver: encapsulateObserver(stateObj)
3480
- }).register(ae);
3507
+ }).register(structuredCloningFixed);
3481
3508
  typeson.encapsulate(records);
3482
3509
  // Todo (low): We might want to run async encapsulate for
3483
3510
  // async types (and put this after Promise resolves)
@@ -3555,25 +3582,14 @@ const structuredCloning = {
3555
3582
  'domexception',
3556
3583
  'domrect',
3557
3584
  'dompoint',
3558
- 'dommatrix'
3585
+ 'dommatrix',
3586
+ 'buffersource',
3587
+ 'resurrectable'
3559
3588
 
3560
3589
  // Ok, but will need some work and/or decisions on how to present:
3561
3590
  // 'cryptokey',
3562
-
3563
- // 'arraybuffer',
3564
- // 'dataview', 'imagedata', 'imagebitmap',
3565
- /*
3566
- // Typed Arrays
3567
- 'int8array',
3568
- 'uint8array',
3569
- 'uint8clampedarray',
3570
- 'int16array',
3571
- 'uint16array',
3572
- 'int32array',
3573
- 'uint32array',
3574
- 'float32array',
3575
- 'float64array',
3576
- */
3591
+ // 'domquad',
3592
+ // 'imagedata', 'imagebitmap',
3577
3593
  ];
3578
3594
  }
3579
3595
  };
@@ -3581,7 +3597,8 @@ const structuredCloning = {
3581
3597
  /** @type {import('../formats.js').Format} */
3582
3598
  const indexedDBKey = {
3583
3599
  types: () => [
3584
- 'number', 'SpecialRealNumber', 'string', 'ValidDate', 'array'
3600
+ 'number', 'SpecialRealNumber', 'string', 'ValidDate', 'array',
3601
+ 'buffersource'
3585
3602
  ],
3586
3603
  // A hack until we simply pass in our own types or do own parsing
3587
3604
  testInvalid (newType, value) {
@@ -3619,8 +3636,6 @@ const indexedDBKey = {
3619
3636
  }
3620
3637
  };
3621
3638
 
3622
- // Todo (low): Support ArrayBuffer
3623
-
3624
3639
  /**
3625
3640
  * @type {Map<import('../types.js').AvailableType,
3626
3641
  * import('../types.js').AvailableType>
@@ -3927,7 +3942,7 @@ const blobHTMLType = {
3927
3942
  );
3928
3943
  },
3929
3944
  getValue ({root}) {
3930
- return this.toValue(
3945
+ return /** @type {import('../types.js').ToValue} */ (this.toValue)(
3931
3946
  'data:text/html,' + /** @type {SCEditorTextarea} */ (
3932
3947
  this.getInput({root})
3933
3948
  ).sceditorInstance.val()
@@ -4400,7 +4415,9 @@ const objectReferenceType = {
4400
4415
  type: 'object',
4401
4416
  stringRegex: /^objectRef\((?:|\/[^)]*)\)$/u,
4402
4417
  toValue (...args) {
4403
- return arrayReferenceType.toValue.apply(this, args);
4418
+ return /** @type {import('../types.js').ToValue} */ (
4419
+ arrayReferenceType.toValue
4420
+ ).apply(this, args);
4404
4421
  },
4405
4422
  resolveReference (...args) {
4406
4423
  return arrayReferenceType.resolveReference?.apply(
@@ -6190,7 +6207,9 @@ const arrayType = {
6190
6207
  // and object reference checking?
6191
6208
  if (![
6192
6209
  'checkbox', 'radio', 'file',
6193
- 'datetime-local'
6210
+ 'datetime-local',
6211
+ // For label radio clicks
6212
+ undefined
6194
6213
  ].includes(target.type)) {
6195
6214
  e.preventDefault();
6196
6215
  }
@@ -6211,7 +6230,7 @@ const arrayType = {
6211
6230
  * @this {HTMLInputElement}
6212
6231
  */
6213
6232
  change () {
6214
- /* c8 ignore next 3 */
6233
+ /* istanbul ignore if */
6215
6234
  if (!this.files) {
6216
6235
  return;
6217
6236
  }
@@ -6248,7 +6267,9 @@ const objectType = {
6248
6267
  stringRegexBegin: /^\{/u,
6249
6268
  stringRegexEnd: /^\}/u,
6250
6269
  toValue (...args) {
6251
- return arrayType.toValue.apply(this, args);
6270
+ return /** @type {import('../types.js').ToValue} */ (
6271
+ arrayType.toValue
6272
+ ).apply(this, args);
6252
6273
  },
6253
6274
  getValue (...args) {
6254
6275
  return arrayType.getValue.apply(this, args);
@@ -6340,9 +6361,13 @@ const dateType = {
6340
6361
  },
6341
6362
  getValue ({root}) {
6342
6363
  if (this.isInvalid({root})) {
6343
- return this.toValue('NaN').value;
6364
+ return /** @type {import('../types.js').ToValue} */ (
6365
+ this.toValue
6366
+ )('NaN').value;
6344
6367
  }
6345
- return this.toValue(this.getInput({root}).value).value;
6368
+ return /** @type {import('../types.js').ToValue} */ (
6369
+ this.toValue
6370
+ )(this.getInput({root}).value).value;
6346
6371
  },
6347
6372
  isValueInvalid (value) {
6348
6373
  return value && Number.isNaN(value.getTime());
@@ -6429,7 +6454,9 @@ const setType = {
6429
6454
  stringRegexBegin: /^Set\(/u,
6430
6455
  stringRegexEnd: /^\)/u,
6431
6456
  toValue (...args) {
6432
- return arrayType.toValue.apply(this, args);
6457
+ return /** @type {import('../types.js').ToValue} */ (
6458
+ arrayType.toValue
6459
+ ).apply(this, args);
6433
6460
  },
6434
6461
  getValue (...args) {
6435
6462
  return arrayType.getValue.apply(this, args);
@@ -6460,7 +6487,9 @@ const mapType = {
6460
6487
  stringRegexBegin: /^Map\(/u,
6461
6488
  stringRegexEnd: /^\)/u,
6462
6489
  toValue (...args) {
6463
- return arrayType.toValue.apply(this, args);
6490
+ return /** @type {import('../types.js').ToValue} */ (
6491
+ arrayType.toValue
6492
+ ).apply(this, args);
6464
6493
  },
6465
6494
  getValue (...args) {
6466
6495
  return arrayType.getValue.apply(this, args);
@@ -6490,7 +6519,9 @@ const undefinedType = {
6490
6519
  return {value: undefined};
6491
6520
  },
6492
6521
  getValue () {
6493
- return this.toValue('').value;
6522
+ return /** @type {import('../types.js').ToValue} */ (
6523
+ this.toValue
6524
+ )('').value;
6494
6525
  },
6495
6526
  viewUI (/* {value} */) {
6496
6527
  return ['i', {dataset: {type: 'undef'}}, ['undefined']];
@@ -6640,7 +6671,9 @@ const BooleanObjectType = {
6640
6671
  return /** @type {HTMLInputElement} */ ($e(root, 'input'));
6641
6672
  },
6642
6673
  getValue ({root}) {
6643
- return this.toValue(String(/** @type {HTMLInputElement} */ (
6674
+ return /** @type {import('../types.js').ToValue} */ (
6675
+ this.toValue
6676
+ )(String(/** @type {HTMLInputElement} */ (
6644
6677
  this.getInput({root})
6645
6678
  ).checked)).value;
6646
6679
  },
@@ -6697,7 +6730,9 @@ const NumberObjectType = {
6697
6730
  return /** @type {HTMLInputElement} */ ($e(root, 'input'));
6698
6731
  },
6699
6732
  getValue ({root}) {
6700
- return this.toValue(this.getInput({root}).value).value;
6733
+ return /** @type {import('../types.js').ToValue} */ (
6734
+ this.toValue
6735
+ )(this.getInput({root}).value).value;
6701
6736
  },
6702
6737
  setValue ({root, value}) {
6703
6738
  this.getInput({root}).value = String(value);
@@ -6732,7 +6767,9 @@ const StringObjectType = {
6732
6767
  return /** @type {HTMLTextAreaElement} */ ($e(root, 'textarea'));
6733
6768
  },
6734
6769
  getValue ({root}) {
6735
- return this.toValue(this.getInput({root}).value).value;
6770
+ return /** @type {import('../types.js').ToValue} */ (
6771
+ this.toValue
6772
+ )(this.getInput({root}).value).value;
6736
6773
  },
6737
6774
  setValue ({root, value}) {
6738
6775
  this.getInput({root}).value = value;
@@ -6752,7 +6789,7 @@ const StringObjectType = {
6752
6789
  };
6753
6790
 
6754
6791
  /**
6755
- * @type {import('./SpecialNumberType.js').SuperTypeObject}
6792
+ * @type {import('../types.js').SuperTypeObject}
6756
6793
  */
6757
6794
  const SpecialRealNumberSuperType = {
6758
6795
  option: ['Special Real Number', {title: '`Infinity`, `-Infinity`, `-0`'}],
@@ -6771,7 +6808,7 @@ const SpecialRealNumberSuperType = {
6771
6808
  return /** @type {HTMLSelectElement} */ ($e(root, 'select'));
6772
6809
  },
6773
6810
  getValue ({root}) {
6774
- return this.toValue(
6811
+ return /** @type {import('../types.js').ToValue} */ (this.toValue)(
6775
6812
  /** @type {Required<import('../types.js').TypeObject>} */ (
6776
6813
  this
6777
6814
  ).getSelect({root}).value
@@ -6812,13 +6849,7 @@ const SpecialRealNumberSuperType = {
6812
6849
  };
6813
6850
 
6814
6851
  /**
6815
- * @typedef {import('../types.js').TypeObject & {
6816
- * childTypes: string[]
6817
- * }} SuperTypeObject
6818
- */
6819
-
6820
- /**
6821
- * @type {SuperTypeObject}
6852
+ * @type {import('../types.js').SuperTypeObject}
6822
6853
  */
6823
6854
  const SpecialNumberSuperType = {
6824
6855
  option: ['Special Number', {title: '`NaN`, `Infinity`, `-Infinity`, `-0`'}],
@@ -6843,7 +6874,7 @@ const SpecialNumberSuperType = {
6843
6874
  return /** @type {HTMLSelectElement} */ ($e(root, 'select'));
6844
6875
  },
6845
6876
  getValue ({root}) {
6846
- return this.toValue(
6877
+ return /** @type {import('../types.js').ToValue} */ (this.toValue)(
6847
6878
  /** @type {Required<import('../types.js').TypeObject>} */ (
6848
6879
  this
6849
6880
  ).getSelect({root}).value
@@ -6893,7 +6924,7 @@ const errorType = {
6893
6924
  toValue (s) {
6894
6925
  const obj = JSON.parse(s);
6895
6926
  const errObj = /** @type {{revive: import('typeson-registry').Reviver}} */ (
6896
- I.error
6927
+ P.error
6897
6928
  ).revive(obj, {});
6898
6929
  return {value: errObj};
6899
6930
  },
@@ -7340,7 +7371,7 @@ if (typeof InternalError !== 'undefined') {
7340
7371
  const specialErrors = [...specialErrorsMap.keys()];
7341
7372
 
7342
7373
  /**
7343
- * @type {import('./SpecialNumberType.js').SuperTypeObject}
7374
+ * @type {import('../types.js').SuperTypeObject}
7344
7375
  */
7345
7376
  const errorsSpecialType = {
7346
7377
  option: ['Special errors'],
@@ -7361,7 +7392,7 @@ const errorsSpecialType = {
7361
7392
 
7362
7393
  const obj = JSON.parse(s);
7363
7394
  const errObj = /** @type {{revive: import('typeson-registry').Reviver}} */ (
7364
- P[errorClass.toLowerCase()]
7395
+ E[errorClass.toLowerCase()]
7365
7396
  ).revive(obj, {});
7366
7397
  return {value: errObj};
7367
7398
  },
@@ -8145,9 +8176,10 @@ async function getUserMedia (constraints) {
8145
8176
  let stream = null;
8146
8177
  try {
8147
8178
  stream = await navigator.mediaDevices.getUserMedia(constraints);
8148
- /* c8 ignore next 4 */
8149
8179
  } catch (err) {
8180
+ /* istanbul ignore next */
8150
8181
  console.error('err', err);
8182
+ /* istanbul ignore next */
8151
8183
  return null;
8152
8184
  }
8153
8185
  return stream;
@@ -8163,8 +8195,8 @@ async function startScreenCapture (displayMediaOptions) {
8163
8195
  try {
8164
8196
  captureStream =
8165
8197
  await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
8166
- /* c8 ignore next 3 */
8167
8198
  } catch (err) {
8199
+ /* istanbul ignore next */
8168
8200
  console.error(`Error: ${err}`);
8169
8201
  }
8170
8202
  return captureStream;
@@ -8299,7 +8331,7 @@ function binaryButton$1 (value, editable) {
8299
8331
  ['textarea', {
8300
8332
  class: 'view-binary'
8301
8333
  }, [
8302
- /* c8 ignore next */
8334
+ /* istanbul ignore next */
8303
8335
  /** @type {string|null} */ (reader.result) ?? ''
8304
8336
  ]]
8305
8337
  ])]
@@ -8307,12 +8339,13 @@ function binaryButton$1 (value, editable) {
8307
8339
  });
8308
8340
  });
8309
8341
  // Seems not feasible to accurately simulate
8310
- /* c8 ignore next 10 */
8311
8342
  reader.addEventListener(
8312
8343
  'error',
8313
- /* c8 ignore next 6 */
8344
+ /* istanbul ignore next */
8314
8345
  async function () {
8346
+ /* istanbul ignore next */
8315
8347
  console.error(reader.error);
8348
+ /* istanbul ignore next */
8316
8349
  await dialogs.alert(/** @type {string} */ (
8317
8350
  /** @type {DOMException} */ (reader.error).message
8318
8351
  ));
@@ -8391,18 +8424,19 @@ const fileType = {
8391
8424
  'Text source',
8392
8425
  ['br'],
8393
8426
  ['textarea', {class: 'view-text'}, [
8394
- /* c8 ignore next */
8427
+ /* istanbul ignore next */
8395
8428
  /** @type {string|null} */ (reader.result) ?? ''
8396
8429
  ]]
8397
8430
  ]));
8398
8431
  });
8399
8432
  // Seems not feasible to accurately simulate
8400
- /* c8 ignore next 10 */
8401
8433
  reader.addEventListener(
8402
8434
  'error',
8403
- /* c8 ignore next 6 */
8435
+ /* istanbul ignore next */
8404
8436
  function () {
8437
+ /* istanbul ignore next */
8405
8438
  console.error(reader.error);
8439
+ /* istanbul ignore next */
8406
8440
  div.append(
8407
8441
  /** @type {DOMException} */ (reader.error).message
8408
8442
  );
@@ -8715,7 +8749,7 @@ const fileType = {
8715
8749
  * @this {HTMLInputElement}
8716
8750
  */
8717
8751
  change () {
8718
- /* c8 ignore next 3 -- TS */
8752
+ /* istanbul ignore if -- TS */
8719
8753
  if (!this.files) {
8720
8754
  return;
8721
8755
  }
@@ -8863,7 +8897,7 @@ const fileType = {
8863
8897
 
8864
8898
  if (constraints) {
8865
8899
  const mediaStream = await getUserMedia(constraints);
8866
- /* c8 ignore next 4 */
8900
+ /* istanbul ignore if */
8867
8901
  if (!mediaStream) {
8868
8902
  await dialogs.alert('Error getting user media');
8869
8903
  return;
@@ -8911,7 +8945,7 @@ const fileType = {
8911
8945
  const mediaStream = await startScreenCapture(
8912
8946
  screenShareConstraints
8913
8947
  );
8914
- /* c8 ignore next 4 */
8948
+ /* istanbul ignore if */
8915
8949
  if (!mediaStream) {
8916
8950
  await dialogs.alert('Error getting user media');
8917
8951
  return;
@@ -8994,7 +9028,7 @@ const fileType = {
8994
9028
  'video.previewMedia'
8995
9029
  ));
8996
9030
 
8997
- /* c8 ignore next 4 */
9031
+ /* istanbul ignore if */
8998
9032
  if (!previewMedia.srcObject) {
8999
9033
  dialogs.alert('No stream found to record');
9000
9034
  return;
@@ -9027,7 +9061,7 @@ const fileType = {
9027
9061
 
9028
9062
  try {
9029
9063
  mediaRecorder.start();
9030
- /* c8 ignore next 4 */
9064
+ /* istanbul ignore if */
9031
9065
  } catch (err) {
9032
9066
  dialogs.alert('Error starting media recorder');
9033
9067
  return;
@@ -9167,7 +9201,7 @@ const fileType = {
9167
9201
  ($e(videoContainer, 'img.photo'));
9168
9202
 
9169
9203
  canvas.toBlob((blob) => {
9170
- /* c8 ignore next 4 */
9204
+ /* istanbul ignore if */
9171
9205
  if (!blob) {
9172
9206
  dialogs.alert('Error converting canvas to Blob');
9173
9207
  return;
@@ -9284,7 +9318,9 @@ const filelistType = {
9284
9318
  stringRegexEnd: /^\)/u,
9285
9319
 
9286
9320
  toValue (...args) {
9287
- return arrayType.toValue.apply(this, args);
9321
+ return /** @type {import('../types.js').ToValue} */ (
9322
+ arrayType.toValue
9323
+ ).apply(this, args);
9288
9324
  },
9289
9325
  getValue (...args) {
9290
9326
  return arrayType.getValue.apply(this, args);
@@ -9411,7 +9447,7 @@ function binaryButton (value, editable) {
9411
9447
  ['textarea', {
9412
9448
  class: 'view-binary'
9413
9449
  }, [
9414
- /* c8 ignore next */
9450
+ /* istanbul ignore next */
9415
9451
  /** @type {string|null} */ (reader.result) ?? ''
9416
9452
  ]]
9417
9453
  ])]
@@ -9419,12 +9455,13 @@ function binaryButton (value, editable) {
9419
9455
  });
9420
9456
  });
9421
9457
  // Seems not feasible to accurately simulate
9422
- /* c8 ignore next 10 */
9423
9458
  reader.addEventListener(
9424
9459
  'error',
9425
- /* c8 ignore next 6 */
9460
+ /* istanbul ignore next */
9426
9461
  async function () {
9462
+ /* istanbul ignore next */
9427
9463
  console.error(reader.error);
9464
+ /* istanbul ignore next */
9428
9465
  await dialogs.alert(/** @type {string} */ (
9429
9466
  /** @type {DOMException} */ (reader.error).message
9430
9467
  ));
@@ -9492,18 +9529,19 @@ const blobType = {
9492
9529
  'Text source',
9493
9530
  ['br'],
9494
9531
  ['textarea', {class: 'view-text'}, [
9495
- /* c8 ignore next */
9532
+ /* istanbul ignore next */
9496
9533
  /** @type {string|null} */ (reader.result) ?? ''
9497
9534
  ]]
9498
9535
  ]));
9499
9536
  });
9500
9537
  // Seems not feasible to accurately simulate
9501
- /* c8 ignore next 10 */
9502
9538
  reader.addEventListener(
9503
9539
  'error',
9504
- /* c8 ignore next 6 */
9540
+ /* istanbul ignore next */
9505
9541
  function () {
9542
+ /* istanbul ignore next */
9506
9543
  console.error(reader.error);
9544
+ /* istanbul ignore next */
9507
9545
  div.append(
9508
9546
  /** @type {DOMException} */ (reader.error).message
9509
9547
  );
@@ -9680,7 +9718,7 @@ const blobType = {
9680
9718
  blob
9681
9719
  ).slice(8, -1) === 'Blob'
9682
9720
  ? /** @type {Blob} */ (blob)
9683
- /* c8 ignore next */
9721
+ /* istanbul ignore next */
9684
9722
  : undefined;
9685
9723
  }
9686
9724
  }
@@ -9750,7 +9788,7 @@ const blobType = {
9750
9788
  * @this {HTMLInputElement}
9751
9789
  */
9752
9790
  change () {
9753
- /* c8 ignore next 3 -- TS */
9791
+ /* istanbul ignore if -- TS */
9754
9792
  if (!this.files) {
9755
9793
  return;
9756
9794
  }
@@ -9902,7 +9940,7 @@ const blobType = {
9902
9940
 
9903
9941
  if (constraints) {
9904
9942
  const mediaStream = await getUserMedia(constraints);
9905
- /* c8 ignore next 4 */
9943
+ /* istanbul ignore if */
9906
9944
  if (!mediaStream) {
9907
9945
  await dialogs.alert('Error getting user media');
9908
9946
  return;
@@ -9950,7 +9988,7 @@ const blobType = {
9950
9988
  const mediaStream = await startScreenCapture(
9951
9989
  screenShareConstraints
9952
9990
  );
9953
- /* c8 ignore next 4 */
9991
+ /* istanbul ignore if */
9954
9992
  if (!mediaStream) {
9955
9993
  await dialogs.alert('Error getting user media');
9956
9994
  return;
@@ -10033,7 +10071,7 @@ const blobType = {
10033
10071
  'video.previewMedia'
10034
10072
  ));
10035
10073
 
10036
- /* c8 ignore next 4 */
10074
+ /* istanbul ignore if */
10037
10075
  if (!previewMedia.srcObject) {
10038
10076
  dialogs.alert('No stream found to record');
10039
10077
  return;
@@ -10066,9 +10104,11 @@ const blobType = {
10066
10104
 
10067
10105
  try {
10068
10106
  mediaRecorder.start();
10069
- /* c8 ignore next 4 */
10107
+ /* istanbul ignore next */
10070
10108
  } catch (err) {
10109
+ /* istanbul ignore next */
10071
10110
  dialogs.alert('Error starting media recorder');
10111
+ /* istanbul ignore next */
10072
10112
  return;
10073
10113
  }
10074
10114
  mediaRecorder.addEventListener('stop', () => {
@@ -10199,7 +10239,7 @@ const blobType = {
10199
10239
  ($e(videoContainer, 'img.photo'));
10200
10240
 
10201
10241
  canvas.toBlob((blob) => {
10202
- /* c8 ignore next 4 */
10242
+ /* istanbul ignore if */
10203
10243
  if (!blob) {
10204
10244
  dialogs.alert('Error converting canvas to Blob');
10205
10245
  return;
@@ -10418,18 +10458,30 @@ const domexceptionType = {
10418
10458
  }
10419
10459
  };
10420
10460
 
10461
+ let idx$3 = 0;
10462
+
10421
10463
  /**
10422
- * @type {import('../types.js').TypeObject}
10464
+ * @type {import('../types.js').SuperTypeObject}
10423
10465
  */
10424
10466
  const domrectType = {
10425
10467
  option: ['DOMRect'],
10426
- stringRegex: /^DOMRect\((.*)\)$/u,
10427
- toValue (s) {
10468
+ childTypes: ['domrectreadonly'],
10469
+ stringRegex: /^(?<domRectClass>DOMRect|DOMRectReadOnly)\((?<innerContent>.*)\)$/u,
10470
+ toValue (s, rootInfo) {
10471
+ const {groups: {
10472
+ domRectClass
10473
+ /* istanbul ignore next -- Should always be found */
10474
+ } = {}} = /** @type {RegExpMatchArray} */ (
10475
+ /** @type {import('../types.js').RootInfo} */ (rootInfo).match
10476
+ );
10428
10477
  const {x, y, width, height} = JSON.parse(s);
10429
- return {value: new DOMRect(x, y, width, height)};
10478
+ return {
10479
+ value: new (
10480
+ domRectClass === 'DOMRect' ? DOMRect : DOMRectReadOnly
10481
+ )(x, y, width, height)};
10430
10482
  },
10431
10483
  getInput ({root}) {
10432
- return /** @type {HTMLInputElement} */ ($e(root, 'input'));
10484
+ return /** @type {HTMLInputElement} */ ($e(root, 'input:not([type])'));
10433
10485
  },
10434
10486
  setValue ({root, value}) {
10435
10487
  /** @type {HTMLInputElement} */ (
@@ -10444,6 +10496,16 @@ const domrectType = {
10444
10496
  /** @type {HTMLInputElement} */ (
10445
10497
  $e(root, '.height')
10446
10498
  ).value = String(value.height);
10499
+
10500
+ if (toStringTag(value) === 'DOMRect') {
10501
+ /** @type {HTMLInputElement} */ (
10502
+ $e(root, '.domrect-readonly-readwrite')
10503
+ ).checked = true;
10504
+ } else {
10505
+ /** @type {HTMLInputElement} */ (
10506
+ $e(root, '.domrect-readonly-readonly')
10507
+ ).checked = true;
10508
+ }
10447
10509
  },
10448
10510
  getValue ({root}) {
10449
10511
  const x = Number(/** @type {HTMLInputElement} */ (
@@ -10458,11 +10520,16 @@ const domrectType = {
10458
10520
  const height = Number(/** @type {HTMLInputElement} */ (
10459
10521
  $e(root, '.height')
10460
10522
  ).value);
10461
- return new DOMRect(x, y, width, height);
10523
+
10524
+ const isReadWrite = /** @type {HTMLInputElement} */ (
10525
+ $e(root, '.domrect-readonly-readwrite')
10526
+ ).checked;
10527
+ return new (isReadWrite ? DOMRect : DOMRectReadOnly)(x, y, width, height);
10462
10528
  },
10463
10529
  viewUI ({value}) {
10530
+ const isReadWrite = toStringTag(value) === 'DOMRect';
10464
10531
  return ['div', {dataset: {type: 'domrect'}}, [
10465
- ['b', {class: 'emphasis'}, ['DOMRect']],
10532
+ ['b', {class: 'emphasis'}, [isReadWrite ? 'DOMRect' : 'DOMRectReadOnly']],
10466
10533
  ['br'],
10467
10534
  ['b', ['x ']],
10468
10535
  value.x,
@@ -10483,8 +10550,32 @@ const domrectType = {
10483
10550
  width: '',
10484
10551
  height: ''
10485
10552
  }}) {
10553
+ idx$3++;
10486
10554
  // eslint-disable-next-line @stylistic/max-len -- Long
10487
10555
  return ['div', {dataset: {type: 'domrect'}}, /** @type {import('jamilih').JamilihChildren} */ ([
10556
+ ['div', [
10557
+ ['label', [
10558
+ ['input', {
10559
+ type: 'radio',
10560
+ class: 'domrect-readonly-readwrite',
10561
+ name: `${typeNamespace}-domrect-readonly-${idx$3}`,
10562
+ value: 'readwrite',
10563
+ checked: toStringTag(value) !== 'DOMRectReadOnly'
10564
+ }],
10565
+ 'Readwrite'
10566
+ ]],
10567
+ ' ',
10568
+ ['label', [
10569
+ ['input', {
10570
+ type: 'radio',
10571
+ class: 'domrect-readonly-readonly',
10572
+ name: `${typeNamespace}-domrect-readonly-${idx$3}`,
10573
+ value: 'readonly',
10574
+ checked: toStringTag(value) === 'DOMRectReadOnly'
10575
+ }],
10576
+ 'Read-only'
10577
+ ]]
10578
+ ]],
10488
10579
  ['label', [
10489
10580
  'x: ',
10490
10581
  ['input', {
@@ -10520,18 +10611,29 @@ const domrectType = {
10520
10611
  }
10521
10612
  };
10522
10613
 
10614
+ let idx$2 = 0;
10615
+
10523
10616
  /**
10524
- * @type {import('../types.js').TypeObject}
10617
+ * @type {import('../types.js').SuperTypeObject}
10525
10618
  */
10526
10619
  const dompointType = {
10527
10620
  option: ['DOMPoint'],
10528
- stringRegex: /^DOMPoint\((.*)\)$/u,
10529
- toValue (s) {
10621
+ childTypes: ['dompointreadonly'],
10622
+ stringRegex: /^(?<domPointClass>DOMPoint|DOMPointReadOnly)\((?<innerContent>.*)\)$/u,
10623
+ toValue (s, rootInfo) {
10624
+ const {groups: {
10625
+ domPointClass
10626
+ /* istanbul ignore next -- Should always be found */
10627
+ } = {}} = /** @type {RegExpMatchArray} */ (
10628
+ /** @type {import('../types.js').RootInfo} */ (rootInfo).match
10629
+ );
10530
10630
  const {x, y, z, w} = JSON.parse(s);
10531
- return {value: new DOMPoint(x, y, z, w)};
10631
+ return {value: new (
10632
+ domPointClass === 'DOMPoint' ? DOMPoint : DOMPointReadOnly
10633
+ )(x, y, z, w)};
10532
10634
  },
10533
10635
  getInput ({root}) {
10534
- return /** @type {HTMLInputElement} */ ($e(root, 'input'));
10636
+ return /** @type {HTMLInputElement} */ ($e(root, 'input:not([type])'));
10535
10637
  },
10536
10638
  setValue ({root, value}) {
10537
10639
  /** @type {HTMLInputElement} */ (
@@ -10546,6 +10648,16 @@ const dompointType = {
10546
10648
  /** @type {HTMLInputElement} */ (
10547
10649
  $e(root, '.w')
10548
10650
  ).value = String(value.w);
10651
+
10652
+ if (toStringTag(value) === 'DOMPoint') {
10653
+ /** @type {HTMLInputElement} */ (
10654
+ $e(root, '.dompoint-readonly-readwrite')
10655
+ ).checked = true;
10656
+ } else {
10657
+ /** @type {HTMLInputElement} */ (
10658
+ $e(root, '.dompoint-readonly-readonly')
10659
+ ).checked = true;
10660
+ }
10549
10661
  },
10550
10662
  getValue ({root}) {
10551
10663
  const x = Number(/** @type {HTMLInputElement} */ (
@@ -10560,11 +10672,18 @@ const dompointType = {
10560
10672
  const w = Number(/** @type {HTMLInputElement} */ (
10561
10673
  $e(root, '.w')
10562
10674
  ).value);
10563
- return new DOMPoint(x, y, z, w);
10675
+
10676
+ const isReadWrite = /** @type {HTMLInputElement} */ (
10677
+ $e(root, '.dompoint-readonly-readwrite')
10678
+ ).checked;
10679
+ return new (isReadWrite ? DOMPoint : DOMPointReadOnly)(x, y, z, w);
10564
10680
  },
10565
10681
  viewUI ({value}) {
10682
+ const isReadWrite = toStringTag(value) === 'DOMPoint';
10566
10683
  return ['div', {dataset: {type: 'dompoint'}}, [
10567
- ['b', {class: 'emphasis'}, ['DOMPoint']],
10684
+ ['b', {class: 'emphasis'}, [
10685
+ isReadWrite ? 'DOMPoint' : 'DOMPointReadOnly'
10686
+ ]],
10568
10687
  ['br'],
10569
10688
  ['b', ['x ']],
10570
10689
  value.x,
@@ -10585,8 +10704,32 @@ const dompointType = {
10585
10704
  z: '',
10586
10705
  w: ''
10587
10706
  }}) {
10707
+ idx$2++;
10588
10708
  // eslint-disable-next-line @stylistic/max-len -- Long
10589
10709
  return ['div', {dataset: {type: 'dompoint'}}, /** @type {import('jamilih').JamilihChildren} */ ([
10710
+ ['div', [
10711
+ ['label', [
10712
+ ['input', {
10713
+ type: 'radio',
10714
+ class: 'dompoint-readonly-readwrite',
10715
+ name: `${typeNamespace}-dompoint-readonly-${idx$2}`,
10716
+ value: 'readwrite',
10717
+ checked: toStringTag(value) !== 'DOMPointReadOnly'
10718
+ }],
10719
+ 'Readwrite'
10720
+ ]],
10721
+ ' ',
10722
+ ['label', [
10723
+ ['input', {
10724
+ type: 'radio',
10725
+ class: 'dompoint-readonly-readonly',
10726
+ name: `${typeNamespace}-dompoint-readonly-${idx$2}`,
10727
+ value: 'readonly',
10728
+ checked: toStringTag(value) === 'DOMPointReadOnly'
10729
+ }],
10730
+ 'Read-only'
10731
+ ]]
10732
+ ]],
10590
10733
  ['label', [
10591
10734
  'x: ',
10592
10735
  ['input', {
@@ -10622,20 +10765,31 @@ const dompointType = {
10622
10765
  }
10623
10766
  };
10624
10767
 
10625
- let idx = 0;
10768
+ let idx$1 = 0;
10626
10769
 
10627
10770
  /**
10628
- * @type {import('../types.js').TypeObject}
10771
+ * @type {import('../types.js').SuperTypeObject}
10629
10772
  */
10630
10773
  const dommatrixType = {
10631
10774
  option: ['DOMMatrix'],
10632
- stringRegex: /^DOMMatrix\((.*)\)$/u,
10633
- toValue (s) {
10775
+ childTypes: ['dommatrixreadonly'],
10776
+ stringRegex: /^(?<domMatrixClass>DOMMatrix|DOMMatrixReadOnly)\((?<innerContent>.*)\)$/u,
10777
+ toValue (s, rootInfo) {
10778
+ const {groups: {
10779
+ domMatrixClass
10780
+ /* istanbul ignore next -- Should always be found */
10781
+ } = {}} = /** @type {RegExpMatchArray} */ (
10782
+ /** @type {import('../types.js').RootInfo} */ (rootInfo).match
10783
+ );
10634
10784
  const o = JSON.parse(s);
10635
10785
 
10786
+ const DOMMatrixClass = domMatrixClass === 'DOMMatrix'
10787
+ ? DOMMatrix
10788
+ : DOMMatrixReadOnly;
10789
+
10636
10790
  const dommatrix = Object.hasOwn(o, 'a')
10637
- ? new DOMMatrix([o.a, o.b, o.c, o.d, o.e, o.f])
10638
- : new DOMMatrix([
10791
+ ? new DOMMatrixClass([o.a, o.b, o.c, o.d, o.e, o.f])
10792
+ : new DOMMatrixClass([
10639
10793
  o.m11, o.m12, o.m13, o.m14,
10640
10794
  o.m21, o.m22, o.m23, o.m24,
10641
10795
  o.m31, o.m32, o.m33, o.m34,
@@ -10645,7 +10799,7 @@ const dommatrixType = {
10645
10799
  return {value: dommatrix};
10646
10800
  },
10647
10801
  getInput ({root}) {
10648
- return /** @type {HTMLInputElement} */ ($e(root, 'input'));
10802
+ return /** @type {HTMLInputElement} */ ($e(root, 'input:not([type])'));
10649
10803
  },
10650
10804
  setValue ({root, value: o}) {
10651
10805
  const {is2D} = o;
@@ -10731,8 +10885,23 @@ const dommatrixType = {
10731
10885
  $e(root, '.m44')
10732
10886
  ).value = o.m44;
10733
10887
  }
10888
+
10889
+ if (toStringTag(o) === 'DOMMatrix') {
10890
+ /** @type {HTMLInputElement} */ (
10891
+ $e(root, '.dommatrix-readonly-readwrite')
10892
+ ).checked = true;
10893
+ } else {
10894
+ /** @type {HTMLInputElement} */ (
10895
+ $e(root, '.dommatrix-readonly-readonly')
10896
+ ).checked = true;
10897
+ }
10734
10898
  },
10735
10899
  getValue ({root}) {
10900
+ const isReadWrite = /** @type {HTMLInputElement} */ (
10901
+ $e(root, '.dommatrix-readonly-readwrite')
10902
+ ).checked;
10903
+ const DOMMatrixClass = isReadWrite ? DOMMatrix : DOMMatrixReadOnly;
10904
+
10736
10905
  const aType = /** @type {HTMLInputElement} */ (
10737
10906
  $e(root, '.a')
10738
10907
  ).value;
@@ -10754,7 +10923,7 @@ const dommatrixType = {
10754
10923
  const f = Number(/** @type {HTMLInputElement} */ (
10755
10924
  $e(root, '.f')
10756
10925
  ).value);
10757
- return new DOMMatrix([a, b, c, d, e, f]);
10926
+ return new DOMMatrixClass([a, b, c, d, e, f]);
10758
10927
  }
10759
10928
 
10760
10929
  const m11 = Number(/** @type {HTMLInputElement} */ (
@@ -10809,7 +10978,7 @@ const dommatrixType = {
10809
10978
  $e(root, '.m44')
10810
10979
  ).value);
10811
10980
 
10812
- return new DOMMatrix([
10981
+ return new DOMMatrixClass([
10813
10982
  m11, m12, m13, m14,
10814
10983
  m21, m22, m23, m24,
10815
10984
  m31, m32, m33, m34,
@@ -10817,8 +10986,11 @@ const dommatrixType = {
10817
10986
  ]);
10818
10987
  },
10819
10988
  viewUI ({value}) {
10989
+ const isReadWrite = toStringTag(value) === 'DOMMatrix';
10820
10990
  return ['div', {dataset: {type: 'dommatrix'}}, [
10821
- ['b', {class: 'emphasis'}, ['DOMMatrix']],
10991
+ ['b', {class: 'emphasis'}, [
10992
+ isReadWrite ? 'DOMMatrix' : 'DOMMatrixReadOnly'
10993
+ ]],
10822
10994
  value.is2D
10823
10995
  ? ['div', [
10824
10996
  ['b', ['a ']],
@@ -10894,15 +11066,38 @@ const dommatrixType = {
10894
11066
  ]];
10895
11067
  },
10896
11068
  editUI ({typeNamespace, value = {}}) {
10897
- idx++;
11069
+ idx$1++;
10898
11070
  const {is2D} = value;
10899
11071
  // eslint-disable-next-line @stylistic/max-len -- Long
10900
11072
  return ['div', {dataset: {type: 'dommatrix'}}, /** @type {import('jamilih').JamilihChildren} */ ([
11073
+ ['div', [
11074
+ ['label', [
11075
+ ['input', {
11076
+ type: 'radio',
11077
+ class: 'dommatrix-readonly-readwrite',
11078
+ name: `${typeNamespace}-dommatrix-readonly-${idx$1}`,
11079
+ value: 'readwrite',
11080
+ checked: toStringTag(value) !== 'DOMMatrixReadOnly'
11081
+ }],
11082
+ 'Readwrite'
11083
+ ]],
11084
+ ' ',
11085
+ ['label', [
11086
+ ['input', {
11087
+ type: 'radio',
11088
+ class: 'dommatrix-readonly-readonly',
11089
+ name: `${typeNamespace}-dommatrix-readonly-${idx$1}`,
11090
+ value: 'readonly',
11091
+ checked: toStringTag(value) === 'DOMMatrixReadOnly'
11092
+ }],
11093
+ 'Read-only'
11094
+ ]]
11095
+ ]],
10901
11096
  ['div', {
10902
11097
  $on: {
10903
11098
  click (e) {
10904
11099
  const {target} = e;
10905
- /* c8 ignore next 3 */
11100
+ /* istanbul ignore if */
10906
11101
  if (/** @type {HTMLInputElement} */ (target).type !== 'radio') {
10907
11102
  return;
10908
11103
  }
@@ -10920,7 +11115,7 @@ const dommatrixType = {
10920
11115
  '2d',
10921
11116
  ['input', {
10922
11117
  class: 'd2',
10923
- type: 'radio', name: `${typeNamespace}-dommatrix-dimension-${idx}`,
11118
+ type: 'radio', name: `${typeNamespace}-dommatrix-dimension-${idx$1}`,
10924
11119
  value: '2d',
10925
11120
  checked: Boolean(is2D)
10926
11121
  }]
@@ -10930,7 +11125,7 @@ const dommatrixType = {
10930
11125
  '3d',
10931
11126
  ['input', {
10932
11127
  class: 'd3',
10933
- type: 'radio', name: `${typeNamespace}-dommatrix-dimension-${idx}`,
11128
+ type: 'radio', name: `${typeNamespace}-dommatrix-dimension-${idx$1}`,
10934
11129
  value: '3d',
10935
11130
  checked: !is2D
10936
11131
  }]
@@ -10977,125 +11172,1658 @@ const dommatrixType = {
10977
11172
  }
10978
11173
  };
10979
11174
 
11175
+ const dataViewMethods = /** @type {const} */ ([
11176
+ 'setInt8',
11177
+ 'setUint8',
11178
+ 'setInt16',
11179
+ 'setUint16',
11180
+ 'setInt32',
11181
+ 'setUint32',
11182
+ 'setFloat32',
11183
+ 'setFloat64',
11184
+ 'setBigInt64',
11185
+ 'setBigUint64'
11186
+ ]);
11187
+
11188
+ const typedArrays = /** @type {const} */ ([
11189
+ 'Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array',
11190
+ 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array',
11191
+ 'Float64Array', 'BigInt64Array', 'BigUint64Array'
11192
+ ]);
11193
+
10980
11194
  /**
10981
- * Utility to retrieve the property value given a legend element.
10982
- * @param {HTMLLegendElement} legend
10983
- * @returns {string}
10984
- */
10985
- const getPropertyValueFromLegend = (legend) => {
10986
- const propElem = $e(legend, '*[data-prop="true"]');
10987
- if (!propElem) {
10988
- throw new Error(
10989
- 'No property on the supplied legend element'
10990
- );
10991
- }
10992
- if (propElem.nodeName.toLowerCase() === 'input') {
10993
- return /** @type {HTMLInputElement} */ (propElem).value;
10994
- }
10995
- if (!propElem.textContent) {
10996
- throw new Error(
10997
- 'No property with text present on the supplied legend element'
10998
- );
11195
+ * @param {TypedArray} typedArray
11196
+ * @returns {{min: number, max: number}}
11197
+ */
11198
+ const getMinMaxForTypedArray = (typedArray) => {
11199
+ switch (typedArray) {
11200
+ case 'Int8Array':
11201
+ return {min: -128, max: 127};
11202
+ case 'Uint8Array':
11203
+ return {min: 0, max: 255};
11204
+ case 'Uint8ClampedArray':
11205
+ return {min: 0, max: 255};
11206
+ case 'Int16Array':
11207
+ return {min: -32768, max: 32767};
11208
+ case 'Uint16Array':
11209
+ return {min: 0, max: 65535};
11210
+ case 'Int32Array':
11211
+ return {min: -2147483648, max: 2147483647};
11212
+ case 'Uint32Array':
11213
+ return {min: 0, max: 4294967295};
11214
+ case 'Float32Array':
11215
+ return {min: -3.4e38, max: 3.4e38};
11216
+ case 'Float64Array':
11217
+ // eslint-disable-next-line no-loss-of-precision -- Inevitable?
11218
+ return {min: -1.8e308, max: 1.8e308};
11219
+ case 'BigInt64Array':
11220
+ return {min: -(2 ** 63), max: (2 ** 63) - 1};
11221
+ case 'BigUint64Array':
11222
+ return {min: 0, max: (2 ** 64) - 1};
11223
+ /* istanbul ignore next -- Guard */
11224
+ default:
11225
+ /* istanbul ignore next -- Guard */
11226
+ throw new Error('Unexpected typed array type');
10999
11227
  }
11000
- // 1-based to 0-based
11001
- return String(Number.parseInt(propElem.textContent) - 1);
11002
11228
  };
11003
11229
 
11004
11230
  /**
11005
- * Any other possibilities than `div`?
11006
- * @typedef {HTMLDivElement} RootElement
11007
- */
11231
+ * @typedef {"Int8Array"|"Uint8Array"|"Uint8ClampedArray"|
11232
+ * "Int16Array"|"Uint16Array"|"Int32Array"|"Uint32Array"|
11233
+ * "Float32Array"|"Float64Array"|"BigInt64Array"|
11234
+ * "BigUint64Array"} TypedArray
11235
+ */
11236
+
11237
+ /**
11238
+ * @typedef {Int8Array|Uint8Array|Uint8ClampedArray|
11239
+ * Int16Array|Uint16Array|Int32Array|Uint32Array|
11240
+ * Float32Array|Float64Array|BigInt64Array|
11241
+ * BigUint64Array} TypedArrayInstance
11242
+ */
11243
+
11244
+ /**
11245
+ * @param {TypedArray} prop
11246
+ * @returns {Int8ArrayConstructor|Uint8ArrayConstructor|
11247
+ * Uint8ClampedArrayConstructor|Int16ArrayConstructor|
11248
+ * Uint16ArrayConstructor|Int32ArrayConstructor|Uint32ArrayConstructor|
11249
+ * Float32ArrayConstructor|Float64ArrayConstructor|
11250
+ * BigInt64ArrayConstructor|BigUint64ArrayConstructor}
11251
+ */
11252
+ const getTypedArray = (prop) => {
11253
+ switch (prop) {
11254
+ case 'Int8Array':
11255
+ return Int8Array;
11256
+ case 'Uint8Array':
11257
+ return Uint8Array;
11258
+ case 'Uint8ClampedArray':
11259
+ return Uint8ClampedArray;
11260
+ case 'Int16Array':
11261
+ return Int16Array;
11262
+ case 'Uint16Array':
11263
+ return Uint16Array;
11264
+ case 'Int32Array':
11265
+ return Int32Array;
11266
+ case 'Uint32Array':
11267
+ return Uint32Array;
11268
+ case 'Float32Array':
11269
+ return Float32Array;
11270
+ case 'Float64Array':
11271
+ return Float64Array;
11272
+ case 'BigInt64Array':
11273
+ return BigInt64Array;
11274
+ case 'BigUint64Array':
11275
+ return BigUint64Array;
11276
+ /* istanbul ignore next -- Guard */
11277
+ default:
11278
+ /* istanbul ignore next -- Guard */
11279
+ throw new Error('Unexpected type');
11280
+ }
11281
+ };
11008
11282
 
11009
- /**
11010
- * Utility to retrieve the type out of a type root element.
11011
- * @callback GetTypeForRoot
11012
- * @param {?RootElement} root
11013
- * @returns {string} Why would it not exist?
11014
- */
11283
+ let idx = 0;
11015
11284
 
11016
11285
  /**
11017
- * Utility to get the value out of a type root element with a given
11018
- * state and path.
11019
- * @callback GetValueForRoot
11020
- * @param {RootElement} root
11021
- * @param {StateObject} [stateObj]
11022
- * @param {string} [currentPath]
11023
- * @returns {StructuredCloneValue}
11286
+ * @type {import('../types.js').SuperTypeObject}
11024
11287
  */
11288
+ const buffersourceType = {
11289
+ option: ['Buffer source (ArrayBuffer, DataView, TypedArrays)'],
11290
+ childTypes: [
11291
+ 'arraybuffer',
11292
+ 'dataview',
11293
+ 'int8array', 'uint8array', 'uint8clampedarray', 'int16array',
11294
+ 'uint16array', 'int32array', 'uint32array', 'float32array',
11295
+ 'float64array', 'bigint64array', 'biguint64array'
11296
+ ],
11297
+ stringRegex: /^(?<bufferSourceClass>ArrayBuffer|DataView|(?:Int8|Uint8|Uint8Clamped|Int16|Uint16|Int32|Uint32|Float32|Float64|BigInt64|BigUint64)Array)\((?<innerContent>.*)\)$/u,
11298
+ toValue (s, rootInfo) {
11299
+ const {groups: {
11300
+ bufferSourceClass
11301
+ /* istanbul ignore next -- Should always be found */
11302
+ } = {}} = /** @type {RegExpMatchArray} */ (
11303
+ /** @type {import('../types.js').RootInfo} */ (rootInfo).match
11304
+ );
11025
11305
 
11026
- /**
11027
- * Utility to get the form control (e.g., input element) for a root.
11028
- * @callback GetFormControlForRoot
11029
- * @param {RootElement} root
11030
- * @returns {null|
11031
- * HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|HTMLButtonElement}
11032
- */
11306
+ const o = JSON.parse(s);
11307
+ const {
11308
+ byteLength, maxByteLength, byteOffset,
11309
+ dataViewByteOffset,
11310
+ dataViewByteLength, length
11311
+ } = o;
11312
+ // @ts-expect-error Ok
11313
+ const buffer = new ArrayBuffer(byteLength, {maxByteLength});
11314
+
11315
+ let typedArray, TypedArray;
11316
+ if (bufferSourceClass.endsWith('Array') || 'typedArray' in o) {
11317
+ TypedArray = getTypedArray(
11318
+ /** @type {TypedArray} */ (o.typedArray ?? bufferSourceClass)
11319
+ );
11033
11320
 
11034
- /**
11035
- * Utility to get the value for a root using its ancestor and state.
11036
- * @callback GetValueFromRootAncestor
11037
- * @param {string|HTMLElement} selOrEl
11038
- * @param {StateObject} [stateObj]
11039
- * @returns {StructuredCloneValue}
11040
- */
11321
+ typedArray = new TypedArray(buffer, byteOffset, length);
11041
11322
 
11042
- /**
11043
- * @callback GetFormControlFromRootAncestor
11044
- * @param {string|HTMLElement} selOrEl
11045
- * @returns {null|HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|
11046
- * HTMLButtonElement}
11047
- */
11323
+ if ('set' in o) {
11324
+ o.set[0].forEach(
11325
+ /**
11326
+ * @param {string} s
11327
+ * @param {number} i
11328
+ * @returns {void}
11329
+ */
11330
+ (s, i) => {
11331
+ if (typeof s === 'string') {
11332
+ o.set[0][i] = BigInt(s);
11333
+ }
11334
+ }
11335
+ );
11336
+ typedArray.set(...(
11337
+ /**
11338
+ * @type {[
11339
+ * array: Array<bigint> & Array<number>,
11340
+ * offset?: number | undefined
11341
+ * ]}
11342
+ */ (o.set)));
11343
+ }
11344
+ }
11048
11345
 
11049
- /**
11050
- * @callback GetOptionForType
11051
- * @param {AvailableType} type
11052
- * @returns {[string, {value: AvailableType, title?: string}]}
11053
- */
11346
+ /** @type {DataView|undefined} */
11347
+ let view;
11348
+ if (bufferSourceClass === 'DataView' || dataViewMethods.some((method) => {
11349
+ return method in o;
11350
+ })) {
11351
+ view = new DataView(buffer, dataViewByteOffset, dataViewByteLength);
11352
+ dataViewMethods.forEach((prop) => {
11353
+ o[prop]?.forEach(
11354
+ /**
11355
+ * @type {(info: [
11356
+ * byteOffset: number,
11357
+ * value: bigint|number,
11358
+ * littleEndian?: boolean|undefined
11359
+ * ]) => void}
11360
+ */
11361
+ (vals) => {
11362
+ if (typeof vals[1] === 'string') {
11363
+ vals[1] = BigInt(vals[1]);
11364
+ }
11365
+ // @ts-expect-error It's ok
11366
+ view[prop](...vals);
11367
+ }
11368
+ );
11369
+ });
11370
+ }
11371
+ return {
11372
+ value: bufferSourceClass === 'ArrayBuffer'
11373
+ ? buffer
11374
+ : bufferSourceClass === 'DataView'
11375
+ ? view
11376
+ : typedArray
11377
+ };
11378
+ },
11379
+ getInput ({root}) {
11380
+ const byteLength =
11381
+ /**
11382
+ * @type {HTMLInputElement & {
11383
+ * $value: BufferSource
11384
+ * }}
11385
+ */ ($e(root, '.byteLength'));
11386
+ return byteLength;
11387
+ },
11388
+ setValue ({root, value}) {
11389
+ const stringTag = toStringTag(value);
11390
+ if (stringTag === 'ArrayBuffer' || stringTag === 'DataView') {
11391
+ $e(root, `[value=${stringTag}].buffersource-returnType`)?.click();
11392
+ } else {
11393
+ $e(root, `[value=TypedArray].buffersource-returnType`)?.click();
11394
+ const typedArrays = /** @type {HTMLSelectElement} */ (
11395
+ $e(root, '.buffersource-typedArrays')
11396
+ );
11397
+ typedArrays.value = stringTag;
11398
+ typedArrays.dispatchEvent(new Event('change'));
11399
+ }
11054
11400
 
11055
- /**
11056
- * @callback GetTypeOptionsForFormatAndState
11057
- * @param {import('./formats.js').AvailableFormat} format
11058
- * @param {string} [parserState]
11059
- * @returns {[string, {value: AvailableType, title?: string}][]}
11060
- */
11401
+ const byteLength =
11402
+ /**
11403
+ * @type {HTMLInputElement & {
11404
+ * $value: BufferSource
11405
+ * }}
11406
+ */ ($e(root, '.byteLength'));
11061
11407
 
11062
- /**
11063
- * @typedef {(
11064
- * keypath: string,
11065
- * parentPath: string,
11066
- * arrayOrObjectPropertyName: string,
11067
- * valueType: string
11068
- * ) => StateObject} GetPossibleSchemasForPathAndType
11069
- */
11408
+ byteLength.$value = value;
11070
11409
 
11071
- /**
11072
- * @typedef {{
11073
- * typeNamespace?: string,
11074
- * "readonly"?: boolean,
11075
- * format?: import('./formats.js').AvailableFormat,
11076
- * formats?: import('./formats.js').default,
11077
- * types?: Types,
11078
- * error?: Error,
11079
- * rootUI?: Element,
11080
- * schema?: string,
11081
- * schemaContent?: object,
11082
- * getPossibleSchemasForPathAndType?: GetPossibleSchemasForPathAndType,
11083
- * paths?: {[currentPath: string]: {
11084
- * referentPath: string,
11085
- * expectArrayReferent: boolean
11086
- * }},
11087
- * handlingReference?: boolean
11088
- * }} StateObject
11089
- */
11410
+ const buffer = stringTag === 'ArrayBuffer' ? value : value.buffer;
11411
+ byteLength.value = buffer.byteLength;
11412
+ byteLength.dispatchEvent(new Event('change'));
11090
11413
 
11091
- /* eslint-disable jsdoc/valid-types -- readonly reserved */
11092
- /**
11093
- * @typedef {(cfg: {
11094
- * readonly?: boolean,
11095
- * resultType?: "both"|"keys"|"values",
11096
- * typeNamespace?: string,
11097
- * type: AvailableType,
11098
- * topRoot?: RootElement,
11414
+ const maxByteLength = /** @type {HTMLInputElement} */ (
11415
+ $e(root, '.maxByteLength')
11416
+ );
11417
+ maxByteLength.value = buffer.maxByteLength;
11418
+ maxByteLength.dispatchEvent(new Event('change'));
11419
+
11420
+ if (stringTag === 'DataView') {
11421
+ const dataViewByteLength = /** @type {HTMLInputElement} */ (
11422
+ $e(root, '.dataViewByteLength')
11423
+ );
11424
+ dataViewByteLength.value = value.byteLength;
11425
+ dataViewByteLength.dispatchEvent(new Event('change'));
11426
+
11427
+ const dataViewByteOffset = /** @type {HTMLInputElement} */ (
11428
+ $e(root, '.dataViewByteOffset')
11429
+ );
11430
+ dataViewByteOffset.value = value.byteOffset;
11431
+ dataViewByteOffset.dispatchEvent(new Event('change'));
11432
+ } else if (stringTag !== 'ArrayBuffer') { // TypedArray
11433
+ const typedArrayByteOffset = /** @type {HTMLInputElement} */ (
11434
+ $e(root, '.typedArrayByteOffset')
11435
+ );
11436
+ typedArrayByteOffset.value = value.byteOffset;
11437
+ typedArrayByteOffset.dispatchEvent(new Event('change'));
11438
+
11439
+ const typedArrayLength = /** @type {HTMLInputElement} */ (
11440
+ $e(root, '.typedArrayLength')
11441
+ );
11442
+ typedArrayLength.value = value.length;
11443
+ typedArrayLength.dispatchEvent(new Event('change'));
11444
+ }
11445
+ },
11446
+ getValue ({root}) {
11447
+ return /** @type {HTMLInputElement & {$value: BufferSource}} */ (
11448
+ this.getInput({root})
11449
+ ).$value;
11450
+ },
11451
+ viewUI ({value}) {
11452
+ const stringTag = toStringTag(value);
11453
+ const buffer = stringTag === 'ArrayBuffer' ? value : value.buffer;
11454
+
11455
+ return ['div', {dataset: {type: 'buffersource'}}, [
11456
+ ['b', {class: 'emphasis'}, [stringTag]],
11457
+ ['br'],
11458
+ ['b', ['Buffer byte length: ']],
11459
+ buffer.byteLength,
11460
+ ['br'],
11461
+ ['b', ['Buffer max byte length: ']],
11462
+ buffer.maxByteLength,
11463
+
11464
+ ...stringTag === 'DataView'
11465
+ ? [
11466
+ ['br'],
11467
+ ['b', ['Data View byte length: ']],
11468
+ value.byteLength,
11469
+ ['br'],
11470
+ ['b', ['Data View byte offset: ']],
11471
+ value.byteOffset
11472
+ ]
11473
+ : [''],
11474
+ ...(stringTag !== 'DataView' && stringTag !== 'ArrayBuffer') // TypedArray
11475
+ ? [
11476
+ ['br'],
11477
+ ['b', ['Typed Array byte offset: ']],
11478
+ value.byteOffset,
11479
+ ['br'],
11480
+ ['b', ['Typed Array length: ']],
11481
+ value.length
11482
+ ]
11483
+ : [''],
11484
+ ['br'],
11485
+ ['button', {
11486
+ class: 'buffersource-viewData',
11487
+ $on: {
11488
+ async click (e) {
11489
+ e.preventDefault();
11490
+ const dialog = await dialogs.makeCancelDialog({
11491
+ // @ts-expect-error TS bug
11492
+ children: /** @type {import('jamilih').JamilihChildren} */ ([
11493
+ ['select', {
11494
+ class: 'buffersource-typedArrays-view',
11495
+ 'aria-label': 'Typed Arrays',
11496
+ $on: {
11497
+ change () {
11498
+ const typedArrayVal = /** @type {HTMLSelectElement} */ (
11499
+ this
11500
+ ).value;
11501
+ const TypedArray = getTypedArray(
11502
+ /** @type {TypedArray} */ (typedArrayVal)
11503
+ );
11504
+ const typedArray = new TypedArray(buffer);
11505
+ const typedArrayArea = /** @type {HTMLElement} */ ($e(
11506
+ /** @type {HTMLElement} */
11507
+ (this.parentElement),
11508
+ '.typedArrayArea'
11509
+ ));
11510
+ typedArrayArea.textContent = '';
11511
+ typedArrayArea.append(
11512
+ ...Array.from({
11513
+ length: typedArray.length
11514
+ }, (_v, key) => {
11515
+ return jml('span', [
11516
+ ['b', [key]],
11517
+ ' ',
11518
+ ['span', [
11519
+ typedArray[key]
11520
+ ? String(typedArray[key])
11521
+ : '0'
11522
+ ]],
11523
+ ' '
11524
+ ]);
11525
+ })
11526
+ );
11527
+ }
11528
+ }
11529
+ }, typedArrays.map((typedArray) => {
11530
+ return ['option', {
11531
+ selected: stringTag === typedArray
11532
+ ? true
11533
+ : undefined
11534
+ }, [typedArray]];
11535
+ })],
11536
+ ['div', {
11537
+ class: 'typedArrayArea'
11538
+ }]
11539
+ ])
11540
+ });
11541
+
11542
+ /** @type {HTMLSelectElement} */ (
11543
+ $e(dialog, '.buffersource-typedArrays-view')
11544
+ ).dispatchEvent(
11545
+ new Event('change')
11546
+ );
11547
+ // Todo: We could also add `DataView` get methods here
11548
+ // (and length/byte offset for the typed array) if
11549
+ // there is a demand
11550
+ }
11551
+ }
11552
+ }, ['View data']]
11553
+ ]];
11554
+ },
11555
+ editUI ({typeNamespace, value}) {
11556
+ idx++;
11557
+
11558
+ /**
11559
+ * @typedef {() => void} BuildInstances
11560
+ */
11561
+
11562
+ const div = /** @type {HTMLDivElement} */ (jml('div', {
11563
+ dataset: {type: 'buffersource'}
11564
+ }, [
11565
+ ['fieldset', {
11566
+ class: 'returnType',
11567
+ $on: {
11568
+ change () {
11569
+ /**
11570
+ * @type {HTMLFieldSetElement & {
11571
+ * $buildInstances: BuildInstances
11572
+ * }}
11573
+ */ (this).$buildInstances();
11574
+ }
11575
+ },
11576
+ $custom: {
11577
+ /** @type {BuildInstances} */
11578
+ $buildInstances () {
11579
+ const that = /** @type {HTMLFieldSetElement} */ (this);
11580
+ const ancestor = /** @type {HTMLDivElement} */ (that.parentElement);
11581
+ const {value} = /** @type {HTMLInputElement} */ ($e(
11582
+ that, `[name=${typeNamespace}-buffersource-returnType-${idx}]` +
11583
+ `:checked`
11584
+ ));
11585
+
11586
+ const byteLength =
11587
+ /**
11588
+ * @type {HTMLInputElement & {
11589
+ * $value: BufferSource,
11590
+ * $dataView: DataView,
11591
+ * $typedArray: TypedArrayInstance
11592
+ * }}
11593
+ */ (
11594
+ $e(ancestor, '.byteLength')
11595
+ );
11596
+ const byteLengthVal = Number.parseInt(byteLength.value);
11597
+ const maxByteLength = Number.parseInt(
11598
+ /** @type {HTMLInputElement} */ (
11599
+ $e(ancestor, '.maxByteLength')
11600
+ ).value
11601
+ );
11602
+
11603
+ const buffer = new ArrayBuffer(
11604
+ // @ts-expect-error New ArrayBuffer argument
11605
+ byteLengthVal, maxByteLength ? {maxByteLength} : undefined
11606
+ );
11607
+
11608
+ const dataViewByteOffsetVal = /** @type {HTMLInputElement} */ ($e(
11609
+ ancestor,
11610
+ '.dataViewByteOffset'
11611
+ )).value;
11612
+ const dataViewByteOffset = dataViewByteOffsetVal
11613
+ ? Number.parseInt(dataViewByteOffsetVal)
11614
+ : 0;
11615
+
11616
+ const dataViewByteLengthVal = /** @type {HTMLInputElement} */ ($e(
11617
+ ancestor,
11618
+ '.dataViewByteLength'
11619
+ )).value;
11620
+ const dataViewByteLength = dataViewByteLengthVal
11621
+ ? Number.parseInt(dataViewByteLengthVal)
11622
+ : undefined;
11623
+
11624
+ const dataView = new DataView(
11625
+ buffer, dataViewByteOffset, dataViewByteLength
11626
+ );
11627
+
11628
+ const {value: typedArrayValue} = /** @type {HTMLSelectElement} */ (
11629
+ $e(ancestor, '.buffersource-typedArrays-init')
11630
+ );
11631
+
11632
+ const TypedArray = getTypedArray(
11633
+ /** @type {TypedArray} */ (typedArrayValue)
11634
+ );
11635
+ const typedArrayByteOffsetVal =
11636
+ /** @type {HTMLInputElement} */ ($e(
11637
+ ancestor,
11638
+ '.typedArrayByteOffset'
11639
+ )).value;
11640
+ const typedArrayByteOffset = typedArrayByteOffsetVal
11641
+ ? Number.parseInt(typedArrayByteOffsetVal)
11642
+ : 0;
11643
+
11644
+ const typedArrayLengthVal =
11645
+ /** @type {HTMLInputElement} */ ($e(
11646
+ ancestor,
11647
+ '.typedArrayLength'
11648
+ )).value;
11649
+ const typedArrayLength = typedArrayLengthVal
11650
+ ? Number.parseInt(typedArrayLengthVal)
11651
+ : byteLengthVal;
11652
+
11653
+ const typedArray = new TypedArray(
11654
+ buffer, typedArrayByteOffset, typedArrayLength
11655
+ );
11656
+
11657
+ byteLength.$dataView = dataView;
11658
+ byteLength.$typedArray = typedArray;
11659
+
11660
+ const typedArrayValues = $$e(
11661
+ ancestor, '.typedArrayArea .typedArrayValue'
11662
+ ).map((input) => {
11663
+ // Don't check dataset, as may be changing to BigInt now
11664
+ return TypedArray.name.startsWith('Big')
11665
+ ? BigInt(
11666
+ /** @type {HTMLInputElement} */ (input).value
11667
+ )
11668
+ : Number(
11669
+ /** @type {HTMLInputElement} */ (input).value
11670
+ );
11671
+ });
11672
+
11673
+ // @ts-expect-error Ok
11674
+ byteLength.$typedArray.set(typedArrayValues, 0);
11675
+
11676
+ switch (value) {
11677
+ case 'ArrayBuffer':
11678
+ byteLength.$value = buffer;
11679
+ break;
11680
+ case 'DataView': {
11681
+ byteLength.$value = dataView;
11682
+ break;
11683
+ } default: // 'TypedArray'
11684
+ byteLength.$value = typedArray;
11685
+ break;
11686
+ }
11687
+ }
11688
+ }
11689
+ }, [
11690
+ ['legend', ['Return type']],
11691
+ ['label', {
11692
+ $on: {
11693
+ click () {
11694
+ /** @type {HTMLElement} */ ($e(
11695
+ /** @type {HTMLElement} */ (this.parentElement),
11696
+ '.buffersource-typedArrays'
11697
+ )).hidden = true;
11698
+ /** @type {HTMLElement} */ ($e(
11699
+ /** @type {HTMLElement} */ (this?.parentElement?.parentElement),
11700
+ '.buffersource-typedArrays-init'
11701
+ )).hidden = false;
11702
+ }
11703
+ }
11704
+ }, [
11705
+ ['input', {
11706
+ type: 'radio',
11707
+ class: 'buffersource-returnType ' +
11708
+ 'buffersource-returnType-arraybuffer',
11709
+ name: `${typeNamespace}-buffersource-returnType-${idx}`,
11710
+ checked: true,
11711
+ value: 'ArrayBuffer'
11712
+ // checked: toStringTag(value) !== ''
11713
+ }],
11714
+ 'ArrayBuffer'
11715
+ ]],
11716
+ ' ',
11717
+ ['label', {
11718
+ $on: {
11719
+ click () {
11720
+ /** @type {HTMLElement} */ ($e(
11721
+ /** @type {HTMLElement} */ (this.parentElement),
11722
+ '.buffersource-typedArrays'
11723
+ )).hidden = true;
11724
+ /** @type {HTMLElement} */ ($e(
11725
+ /** @type {HTMLElement} */ (this?.parentElement?.parentElement),
11726
+ '.buffersource-typedArrays-init'
11727
+ )).hidden = false;
11728
+ }
11729
+ }
11730
+ }, [
11731
+ ['input', {
11732
+ type: 'radio',
11733
+ class: 'buffersource-returnType buffersource-returnType-dataview',
11734
+ name: `${typeNamespace}-buffersource-returnType-${idx}`,
11735
+ value: 'DataView'
11736
+ // checked: toStringTag(value) !== ''
11737
+ }],
11738
+ 'DataView'
11739
+ ]],
11740
+ ' ',
11741
+ ['label', {
11742
+ $on: {
11743
+ click () {
11744
+ /** @type {HTMLElement} */ ($e(
11745
+ /** @type {HTMLElement} */ (this.parentElement),
11746
+ '.buffersource-typedArrays'
11747
+ )).hidden = false;
11748
+ /** @type {HTMLElement} */ ($e(
11749
+ /** @type {HTMLElement} */ (this?.parentElement?.parentElement),
11750
+ '.buffersource-typedArrays-init'
11751
+ )).hidden = true;
11752
+ }
11753
+ }
11754
+ }, [
11755
+ ['input', {
11756
+ type: 'radio',
11757
+ class: 'buffersource-returnType buffersource-returnType-typedarray',
11758
+ name: `${typeNamespace}-buffersource-returnType-${idx}`,
11759
+ value: 'TypedArray'
11760
+ // checked: toStringTag(value) !== ''
11761
+ }],
11762
+ 'Typed Array'
11763
+ ]],
11764
+ ' ',
11765
+ ['select', {
11766
+ hidden: true, class: 'buffersource-typedArrays',
11767
+ 'aria-label': 'Typed Arrays',
11768
+ $on: {
11769
+ change (e) {
11770
+ const that = /** @type {HTMLSelectElement} */ (this);
11771
+ const ancestor = /** @type {HTMLElement} */ (
11772
+ that.parentElement?.parentElement
11773
+ );
11774
+
11775
+ const select =
11776
+ /**
11777
+ * @type {HTMLSelectElement & {
11778
+ * $setMinsAndMaxes: SetMinsAndMaxes,
11779
+ * $checkTypedArrayByteLength: CheckTypedArrayByteLength
11780
+ * }}
11781
+ */
11782
+ ($e(
11783
+ ancestor,
11784
+ '.buffersource-typedArrays-init'
11785
+ ));
11786
+
11787
+ // Update to reflect current state changes if later revealing
11788
+ select.value = /** @type {HTMLSelectElement} */ (this).value;
11789
+
11790
+ const typedArrayLength =
11791
+ /**
11792
+ * @type {HTMLInputElement & {
11793
+ * $checkBufferBounds: CheckBufferBounds
11794
+ * }}
11795
+ */ (
11796
+ $e(ancestor, '.typedArrayLength')
11797
+ );
11798
+ if (!typedArrayLength.$checkBufferBounds(e)) {
11799
+ return;
11800
+ }
11801
+
11802
+ select.$setMinsAndMaxes(
11803
+ /** @type {TypedArray} */
11804
+ (/** @type {HTMLSelectElement} */ (this).value)
11805
+ );
11806
+
11807
+ select.$checkTypedArrayByteLength(e);
11808
+
11809
+ const typedArrayByteOffset = $e(
11810
+ /** @type {HTMLElement} */
11811
+ (this?.parentElement?.parentElement),
11812
+ '.typedArrayByteOffset'
11813
+ );
11814
+ /**
11815
+ * @type {HTMLInputElement & {
11816
+ * $checkByteOffsetMultiple: CheckByteOffsetMultiple
11817
+ * }}
11818
+ */ (typedArrayByteOffset).$checkByteOffsetMultiple(e);
11819
+ }
11820
+ }
11821
+ }, typedArrays.map((typedArray) => {
11822
+ return ['option', [typedArray]];
11823
+ })]
11824
+ ]],
11825
+ ['fieldset', {
11826
+ $on: {
11827
+ change () {
11828
+ /**
11829
+ * @type {HTMLFieldSetElement & {
11830
+ * $buildInstances: BuildInstances
11831
+ * }}
11832
+ */ (this.previousElementSibling).$buildInstances();
11833
+ }
11834
+ }
11835
+ }, [
11836
+ ['legend', ['Construction options']],
11837
+ ['fieldset', [
11838
+ ['legend', ['ArrayBuffer']],
11839
+ ['label', [
11840
+ 'Byte length ',
11841
+ ['input', {
11842
+ class: 'byteLength',
11843
+ type: 'number', step: '1', size: '4', pattern: '\\d+',
11844
+ min: 0,
11845
+ $custom: {
11846
+ $value: value ?? new ArrayBuffer(0)
11847
+ },
11848
+ $on: {
11849
+ change (e) {
11850
+ const that = /** @type {HTMLInputElement} */ (
11851
+ this
11852
+ );
11853
+
11854
+ const ancestor = /** @type {HTMLElement} */ (
11855
+ that.
11856
+ parentElement?.parentElement?.parentElement?.parentElement
11857
+ );
11858
+ const typedArrayLength =
11859
+ /**
11860
+ * @type {HTMLInputElement & {
11861
+ * $checkBufferBounds: CheckBufferBounds
11862
+ * }}
11863
+ */ (
11864
+ $e(ancestor, '.typedArrayLength')
11865
+ );
11866
+ if (!typedArrayLength.$checkBufferBounds(e)) {
11867
+ return;
11868
+ }
11869
+
11870
+ const maxByteLength = /** @type {HTMLInputElement} */ ($e(
11871
+ /** @type {HTMLElement} */ (
11872
+ that.parentElement?.parentElement
11873
+ ), '.maxByteLength'
11874
+ ));
11875
+ const val = that.value;
11876
+
11877
+ if (Number.parseInt(val) > Number.MAX_SAFE_INTEGER) {
11878
+ that.setCustomValidity(
11879
+ 'The ArrayBuffer length exceeds the maximum ' +
11880
+ 'allowable size'
11881
+ );
11882
+ e.stopPropagation();
11883
+ that.reportValidity();
11884
+ return;
11885
+ }
11886
+ that.setCustomValidity('');
11887
+ that.reportValidity();
11888
+
11889
+ if (
11890
+ Number.parseInt(val) > Number.parseInt(maxByteLength.value)
11891
+ ) {
11892
+ maxByteLength.value = val;
11893
+ }
11894
+
11895
+ const greatGrandparent = /** @type {HTMLElement} */
11896
+ (that.parentElement?.parentElement?.parentElement);
11897
+
11898
+ /**
11899
+ * @type {HTMLInputElement & {
11900
+ * $checkDataViewByteLength: CheckDataViewByteLength
11901
+ * }}
11902
+ */ ($e(
11903
+ greatGrandparent,
11904
+ '.dataViewByteLength'
11905
+ )).$checkDataViewByteLength(e);
11906
+
11907
+ /**
11908
+ * @type {HTMLSelectElement & {
11909
+ * $checkTypedArrayByteLength: CheckTypedArrayByteLength
11910
+ * }}
11911
+ */ ($e(
11912
+ /** @type {HTMLElement} */
11913
+ (greatGrandparent.parentElement),
11914
+ '.buffersource-typedArrays-init'
11915
+ )).$checkTypedArrayByteLength(e);
11916
+ }
11917
+ }
11918
+ }]
11919
+ ]],
11920
+ ' ',
11921
+ ['label', [
11922
+ 'Max byte length ',
11923
+ ['input', {
11924
+ class: 'maxByteLength',
11925
+ type: 'number', step: '1', size: '4', pattern: '\\d+',
11926
+ min: 0,
11927
+ $on: {
11928
+ change (e) {
11929
+ const that = /** @type {HTMLInputElement} */ (this);
11930
+ const byteLength = /** @type {HTMLInputElement} */ ($e(
11931
+ /** @type {HTMLElement} */ (
11932
+ that.parentElement?.parentElement
11933
+ ), '.byteLength'
11934
+ ));
11935
+ const val = that.value;
11936
+ if (
11937
+ Number.parseInt(val) < Number.parseInt(byteLength.value)
11938
+ ) {
11939
+ // byteLength.value = val;
11940
+ that.setCustomValidity(
11941
+ 'The max value cannot be less than the byte length'
11942
+ );
11943
+ e.stopPropagation();
11944
+ } else {
11945
+ that.setCustomValidity('');
11946
+ }
11947
+ that.reportValidity();
11948
+ }
11949
+ }
11950
+ }]
11951
+ ]]
11952
+ ]],
11953
+ ['fieldset', [
11954
+ ['legend', ['DataView']],
11955
+ ['label', [
11956
+ 'Byte length ',
11957
+ ['input', {
11958
+ class: 'dataViewByteLength',
11959
+ type: 'number', step: '1', size: '4', pattern: '\\d+',
11960
+ min: 0,
11961
+ $custom: {
11962
+ /**
11963
+ * @typedef {(e: Event) => void} CheckDataViewByteLength
11964
+ */
11965
+
11966
+ /** @type {CheckDataViewByteLength} */
11967
+ $checkDataViewByteLength (e) {
11968
+ const that = /** @type {HTMLInputElement} */ (
11969
+ this
11970
+ );
11971
+ const greatGrandparent = /** @type {HTMLElement} */
11972
+ (that.parentElement?.parentElement?.parentElement);
11973
+
11974
+ const byteOffset = Number.parseInt(
11975
+ /** @type {HTMLInputElement} */ ($e(
11976
+ greatGrandparent,
11977
+ '.dataViewByteOffset'
11978
+ )).value
11979
+ ) || 0;
11980
+
11981
+ const bufferByteLengthVal = /** @type {HTMLInputElement} */ (
11982
+ $e(
11983
+ greatGrandparent,
11984
+ '.byteLength'
11985
+ )).value;
11986
+ const bufferByteLength = bufferByteLengthVal
11987
+ ? Number.parseInt(
11988
+ bufferByteLengthVal
11989
+ )
11990
+ : 0;
11991
+
11992
+ const byteLength = that.value
11993
+ ? Number.parseInt(
11994
+ that.value
11995
+ )
11996
+ : bufferByteLength;
11997
+
11998
+ if (byteOffset + byteLength > bufferByteLength) {
11999
+ that.setCustomValidity(
12000
+ 'The DataView byte length and offset exceed ' +
12001
+ 'the buffer\'s byte length'
12002
+ );
12003
+ e.stopPropagation();
12004
+ } else {
12005
+ that.setCustomValidity('');
12006
+ }
12007
+ that.reportValidity();
12008
+ }
12009
+ },
12010
+ $on: {
12011
+ change (e) {
12012
+ /**
12013
+ * @type {HTMLInputElement & {
12014
+ * $checkDataViewByteLength: CheckDataViewByteLength
12015
+ * }}
12016
+ */ (
12017
+ this
12018
+ ).$checkDataViewByteLength(e);
12019
+ }
12020
+ }
12021
+ }]
12022
+ ]],
12023
+ ' ',
12024
+ ['label', [
12025
+ 'Byte offset ',
12026
+ ['input', {
12027
+ class: 'dataViewByteOffset',
12028
+ type: 'number', step: '1', size: '4', pattern: '\\d+',
12029
+ min: 0,
12030
+ $on: {
12031
+ change (e) {
12032
+ const that = /** @type {HTMLInputElement} */ (
12033
+ this
12034
+ );
12035
+ const greatGrandparent = /** @type {HTMLElement} */
12036
+ (that.parentElement?.parentElement?.parentElement);
12037
+
12038
+ /**
12039
+ * @type {HTMLInputElement & {
12040
+ * $checkDataViewByteLength: CheckDataViewByteLength
12041
+ * }}
12042
+ */ ($e(
12043
+ greatGrandparent,
12044
+ '.dataViewByteLength'
12045
+ )).$checkDataViewByteLength(e);
12046
+ }
12047
+ }
12048
+ }]
12049
+ ]]
12050
+ ]],
12051
+ ['fieldset', [
12052
+ ['legend', ['Typed array']],
12053
+ ['label', [
12054
+ 'Byte offset ',
12055
+ ['input', {
12056
+ class: 'typedArrayByteOffset',
12057
+ type: 'number', step: '1', size: '4', pattern: '\\d+',
12058
+ min: 0,
12059
+ max: (2 ** 53) - 1,
12060
+ $custom: {
12061
+ /**
12062
+ * @typedef {(e: Event) => void} CheckByteOffsetMultiple
12063
+ */
12064
+
12065
+ /** @type {CheckByteOffsetMultiple} */
12066
+ $checkByteOffsetMultiple (e) {
12067
+ const that = /** @type {HTMLInputElement} */ (this);
12068
+ const ancestor = /** @type {HTMLElement} */ (
12069
+ that.
12070
+ parentElement?.parentElement?.parentElement?.parentElement
12071
+ );
12072
+
12073
+ const {value} = /** @type {HTMLSelectElement} */ (
12074
+ $e(ancestor, '.buffersource-typedArrays-init')
12075
+ );
12076
+
12077
+ const TypedArray = getTypedArray(
12078
+ /** @type {TypedArray} */ (value)
12079
+ );
12080
+ if (
12081
+ Number.parseInt(that.value) % TypedArray.BYTES_PER_ELEMENT
12082
+ ) {
12083
+ that.setCustomValidity(
12084
+ 'Byte offset must be a multiple of the typed ' +
12085
+ `array's bytes-per-element size (${
12086
+ TypedArray.BYTES_PER_ELEMENT
12087
+ })`
12088
+ );
12089
+ e.stopPropagation();
12090
+ } else {
12091
+ that.setCustomValidity('');
12092
+ }
12093
+ that.reportValidity();
12094
+ }
12095
+ },
12096
+ $on: {
12097
+ change (e) {
12098
+ const that = /** @type {HTMLInputElement} */ (this);
12099
+ const ancestor = /** @type {HTMLElement} */ (
12100
+ that.
12101
+ parentElement?.parentElement?.parentElement?.parentElement
12102
+ );
12103
+ const typedArrayLength =
12104
+ /**
12105
+ * @type {HTMLInputElement & {
12106
+ * $checkBufferBounds: CheckBufferBounds
12107
+ * }}
12108
+ */ (
12109
+ $e(ancestor, '.typedArrayLength')
12110
+ );
12111
+ if (!typedArrayLength.$checkBufferBounds(e)) {
12112
+ return;
12113
+ }
12114
+ /**
12115
+ * @type {HTMLInputElement & {
12116
+ * $checkByteOffsetMultiple: CheckByteOffsetMultiple
12117
+ * }}
12118
+ */ (this).$checkByteOffsetMultiple(e);
12119
+ }
12120
+ }
12121
+ }]
12122
+ ]]
12123
+ // ' ',
12124
+ // ['label', [
12125
+ // 'Length ',
12126
+ // ['input', {
12127
+ // class: 'typedArrayLength',
12128
+ // type: 'number', step: '1', size: '4', pattern: '\\d+',
12129
+ // min: 0
12130
+ // }]
12131
+ // ]]
12132
+ ]]
12133
+ ]],
12134
+ ['fieldset', [
12135
+ ['legend', ['Typed Array initialization (optional)']],
12136
+ ['select', {
12137
+ class: 'buffersource-typedArrays-init',
12138
+ 'aria-label': 'Typed Arrays',
12139
+ $custom: {
12140
+ /**
12141
+ * @callback SetMinsAndMaxes
12142
+ * @param {TypedArray} typedArray
12143
+ * @returns {void}
12144
+ */
12145
+
12146
+ /** @type {SetMinsAndMaxes} */
12147
+ $setMinsAndMaxes (typedArray) {
12148
+ const {min, max} = getMinMaxForTypedArray(typedArray);
12149
+
12150
+ /** @type {HTMLInputElement[]} */ (
12151
+ $$e(/** @type {HTMLElement} */ (
12152
+ /** @type {HTMLSelectElement} */ (this).parentElement
12153
+ ), '.typedArrayValue')
12154
+ ).forEach((typedArrayValue) => {
12155
+ typedArrayValue.className =
12156
+ 'typedArrayValue typedArray-' + typedArray;
12157
+ typedArrayValue.min = String(min);
12158
+ typedArrayValue.max = String(max);
12159
+ });
12160
+ },
12161
+
12162
+ /**
12163
+ * @typedef {(e: Event) => void} CheckTypedArrayByteLength
12164
+ */
12165
+
12166
+ /** @type {CheckTypedArrayByteLength} */
12167
+ $checkTypedArrayByteLength (e) {
12168
+ const that = /** @type {HTMLSelectElement} */ (this);
12169
+ const TypedArray = getTypedArray(
12170
+ /** @type {TypedArray} */ (that.value)
12171
+ );
12172
+
12173
+ const byteLength = /** @type {HTMLInputElement} */ ($e(
12174
+ /** @type {HTMLElement} */
12175
+ (that.parentElement?.parentElement),
12176
+ '.byteLength'
12177
+ ));
12178
+ const arrayBufferLength = byteLength.value
12179
+ ? Number.parseInt(
12180
+ byteLength.value
12181
+ )
12182
+ : 0;
12183
+ if (arrayBufferLength % TypedArray.BYTES_PER_ELEMENT) {
12184
+ byteLength.setCustomValidity(
12185
+ 'Array buffer must be a multiple of the typed array\'s ' +
12186
+ `bytes-per-element size (${TypedArray.BYTES_PER_ELEMENT})`
12187
+ );
12188
+ e.stopPropagation();
12189
+ } else {
12190
+ byteLength.setCustomValidity('');
12191
+ }
12192
+ byteLength.reportValidity();
12193
+ }
12194
+ },
12195
+ $on: {
12196
+ change (e) {
12197
+ const that =
12198
+ /**
12199
+ * @type {HTMLSelectElement & {
12200
+ * $setMinsAndMaxes: SetMinsAndMaxes,
12201
+ * $checkTypedArrayByteLength: CheckTypedArrayByteLength
12202
+ * }}
12203
+ */ (
12204
+ this
12205
+ );
12206
+
12207
+ const ancestor = /** @type {HTMLElement} */ (
12208
+ that.
12209
+ parentElement?.parentElement?.parentElement
12210
+ );
12211
+
12212
+ // Update to reflect current state changes if later revealing
12213
+ /** @type {HTMLSelectElement} */ ($e(
12214
+ /** @type {HTMLElement} */
12215
+ (this.parentElement?.parentElement),
12216
+ '.buffersource-typedArrays'
12217
+ )).value = that.value;
12218
+
12219
+ const typedArrayLength =
12220
+ /**
12221
+ * @type {HTMLInputElement & {
12222
+ * $checkBufferBounds: CheckBufferBounds
12223
+ * }}
12224
+ */ (
12225
+ $e(ancestor, '.typedArrayLength')
12226
+ );
12227
+ if (!typedArrayLength.$checkBufferBounds(e)) {
12228
+ return;
12229
+ }
12230
+
12231
+ that.$checkTypedArrayByteLength(e);
12232
+
12233
+ that.$setMinsAndMaxes(/** @type {TypedArray} */ (that.value));
12234
+
12235
+ const typedArrayByteOffset = $e(
12236
+ /** @type {HTMLElement} */
12237
+ (that?.parentElement?.parentElement),
12238
+ '.typedArrayByteOffset'
12239
+ );
12240
+ /**
12241
+ * @type {HTMLInputElement & {
12242
+ * $checkByteOffsetMultiple: CheckByteOffsetMultiple
12243
+ * }}
12244
+ */ (typedArrayByteOffset).$checkByteOffsetMultiple(e);
12245
+
12246
+ /**
12247
+ * @type {HTMLFieldSetElement & {
12248
+ * $buildInstances: BuildInstances
12249
+ * }}
12250
+ */ ($e(
12251
+ /** @type {HTMLElement} */
12252
+ (this.parentElement?.parentElement),
12253
+ '.returnType'
12254
+ )).$buildInstances();
12255
+ }
12256
+ }
12257
+ }, typedArrays.map((typedArray) => {
12258
+ return ['option', [typedArray]];
12259
+ })],
12260
+ ' ',
12261
+ ['label', [
12262
+ 'Array length: ',
12263
+ ['input', {
12264
+ class: 'typedArrayLength',
12265
+ type: 'number', step: '1', size: '4', pattern: '\\d+',
12266
+ min: 0,
12267
+ $custom: {
12268
+ /**
12269
+ * When creating a view from a buffer, the bounds are outside
12270
+ * the buffer. In other words, `byteOffset + length *
12271
+ * TypedArray.BYTES_PER_ELEMENT > buffer.byteLength`.
12272
+ * @typedef {(e: Event) => boolean} CheckBufferBounds
12273
+ */
12274
+
12275
+ /** @type {CheckBufferBounds} */
12276
+ $checkBufferBounds (e) {
12277
+ const that = /** @type {HTMLInputElement} */ (this);
12278
+
12279
+ const ancestor = /** @type {HTMLElement} */ (
12280
+ that.parentElement?.parentElement?.parentElement
12281
+ );
12282
+ const bufferByteLengthVal = /** @type {HTMLInputElement} */ (
12283
+ $e(
12284
+ ancestor,
12285
+ '.byteLength'
12286
+ )).value;
12287
+ const bufferByteLength = bufferByteLengthVal
12288
+ ? Number.parseInt(
12289
+ bufferByteLengthVal
12290
+ )
12291
+ : 0;
12292
+
12293
+ const length = that.value
12294
+ ? Number.parseInt(that.value)
12295
+ : bufferByteLength;
12296
+
12297
+ const {value} = /** @type {HTMLSelectElement} */ (
12298
+ $e(ancestor, '.buffersource-typedArrays-init')
12299
+ );
12300
+
12301
+ const TypedArray = getTypedArray(
12302
+ /** @type {TypedArray} */ (value)
12303
+ );
12304
+
12305
+ const typedArrayByteOffsetVal =
12306
+ /** @type {HTMLInputElement} */ ($e(
12307
+ ancestor,
12308
+ '.typedArrayByteOffset'
12309
+ )).value;
12310
+ const typedArrayByteOffset = typedArrayByteOffsetVal
12311
+ ? Number.parseInt(typedArrayByteOffsetVal)
12312
+ : 0;
12313
+
12314
+ console.log('1111', typedArrayByteOffset,
12315
+ length, TypedArray.BYTES_PER_ELEMENT,
12316
+ bufferByteLength);
12317
+
12318
+ if (
12319
+ (typedArrayByteOffset +
12320
+ (length * TypedArray.BYTES_PER_ELEMENT)) >
12321
+ bufferByteLength
12322
+ ) {
12323
+ that.setCustomValidity(
12324
+ 'The byte offset and the length times bytes per element ' +
12325
+ 'is greater than the buffer length'
12326
+ );
12327
+ e.stopPropagation();
12328
+ that.reportValidity();
12329
+ return false;
12330
+ }
12331
+
12332
+ that.setCustomValidity('');
12333
+ that.reportValidity();
12334
+ return true;
12335
+ },
12336
+
12337
+ /**
12338
+ * @typedef {() => void} BuildTypedArray
12339
+ */
12340
+
12341
+ /** @type {BuildTypedArray} */
12342
+ $buildTypedArray () {
12343
+ const that = /** @type {HTMLInputElement} */ (this);
12344
+ const length = Number.parseInt(that.value);
12345
+ const grandparent = /** @type {HTMLElement} */ (
12346
+ that.parentElement?.parentElement
12347
+ );
12348
+
12349
+ const ancestor = /** @type {HTMLElement} */ (
12350
+ that.parentElement?.parentElement?.parentElement
12351
+ );
12352
+ const bufferByteLength =
12353
+ /**
12354
+ * @type {HTMLInputElement & {
12355
+ * $typedArray: TypedArrayInstance
12356
+ * }}
12357
+ */ ($e(
12358
+ ancestor,
12359
+ '.byteLength'
12360
+ ));
12361
+
12362
+ const typedArrayArea = /** @type {HTMLElement} */ ($e(
12363
+ grandparent, '.typedArrayArea'
12364
+ ));
12365
+
12366
+ typedArrayArea.addEventListener('change', (e) => {
12367
+ const input = /** @type {HTMLInputElement} */ (e.target);
12368
+ bufferByteLength.$typedArray.set([
12369
+ // @ts-expect-error Ok
12370
+ input.dataset.bigint === 'true'
12371
+ ? BigInt(input.value)
12372
+ : Number(input.value)
12373
+ ], Number.parseInt(
12374
+ /** @type {string} */ (input.dataset.key)
12375
+ ));
12376
+ });
12377
+ const {value} = /** @type {HTMLSelectElement} */ (
12378
+ $e(grandparent, '.buffersource-typedArrays-init')
12379
+ );
12380
+ const {min, max} = getMinMaxForTypedArray(
12381
+ /** @type {TypedArray} */ (value)
12382
+ );
12383
+
12384
+ typedArrayArea.textContent = '';
12385
+ typedArrayArea.append(
12386
+ ...Array.from({length}, (_v, key) => {
12387
+ return jml('label', [
12388
+ key,
12389
+ ' ',
12390
+ ['input', {
12391
+ class: 'typedArrayValue typedArray-' + value,
12392
+ dataset: {
12393
+ key, bigint: String(value.startsWith('BigInt'))
12394
+ },
12395
+ type: 'number', step: '1',
12396
+ pattern: value.startsWith('Float')
12397
+ ? '\\d+(?:\\.\\d+)?'
12398
+ : '\\d+',
12399
+ value: bufferByteLength.$typedArray[key]
12400
+ ? String(bufferByteLength.$typedArray[key])
12401
+ : '0',
12402
+ min, max
12403
+ }],
12404
+ ' '
12405
+ // !key || key % 9 ? ' ' : ['br']
12406
+ ]);
12407
+ })
12408
+ );
12409
+ }
12410
+ },
12411
+ $on: {
12412
+ change (e) {
12413
+ const that =
12414
+ /**
12415
+ * @type {HTMLInputElement & {
12416
+ * $checkBufferBounds: CheckBufferBounds,
12417
+ * $buildTypedArray: BuildTypedArray
12418
+ * }}
12419
+ */ (
12420
+ this
12421
+ );
12422
+ const grandparent = /** @type {HTMLElement} */ (
12423
+ this.parentElement?.parentElement
12424
+ );
12425
+
12426
+ if (!that.$checkBufferBounds(e)) {
12427
+ return;
12428
+ }
12429
+
12430
+ const {value} = /** @type {HTMLSelectElement} */ (
12431
+ $e(grandparent, '.buffersource-typedArrays-init')
12432
+ );
12433
+
12434
+ const length = Number.parseInt(that.value);
12435
+ try {
12436
+ const TypedArray = getTypedArray(
12437
+ /** @type {TypedArray} */ (value)
12438
+ );
12439
+ // eslint-disable-next-line no-new -- Testing
12440
+ new TypedArray(length);
12441
+ } catch (err) {
12442
+ that.setCustomValidity('Typed Array length is too long');
12443
+ e.stopPropagation();
12444
+ that.reportValidity();
12445
+ return;
12446
+ }
12447
+ that.setCustomValidity('');
12448
+ that.reportValidity();
12449
+
12450
+ /**
12451
+ * @type {HTMLFieldSetElement & {
12452
+ * $buildInstances: BuildInstances
12453
+ * }}
12454
+ */ ($e(
12455
+ /** @type {HTMLElement} */
12456
+ (this.parentElement?.parentElement?.parentElement),
12457
+ '.returnType'
12458
+ )).$buildInstances();
12459
+
12460
+ that.$buildTypedArray();
12461
+ }
12462
+ }
12463
+ }],
12464
+ ['div', {
12465
+ class: 'typedArrayArea'
12466
+ }]
12467
+ ]]
12468
+ ]],
12469
+ ['fieldset', [
12470
+ ['legend', ['DataView initialization (optional)']],
12471
+ ['select', {
12472
+ class: 'dataViewMethod',
12473
+ 'aria-label': 'Data View methods',
12474
+ $on: {
12475
+ change () {
12476
+ const dataViewArea = /** @type {HTMLDivElement} */ ($e(
12477
+ /** @type {HTMLElement} */ (this.parentElement), '.dataViewArea'
12478
+ ));
12479
+
12480
+ const val = /** @type {HTMLSelectElement} */ (this).value;
12481
+ const typedArray = /** @type {TypedArray} */ (
12482
+ val.slice(3) + 'Array'
12483
+ );
12484
+
12485
+ dataViewArea.textContent = '';
12486
+ dataViewArea.append(
12487
+ jml(
12488
+ 'label', [
12489
+ 'Byte offset ',
12490
+ ['input', {
12491
+ type: 'number',
12492
+ class: 'dataViewSetByteOffset',
12493
+ step: '1', size: '4', pattern: '\\d+'
12494
+ }]
12495
+ ]
12496
+ ),
12497
+ ' ',
12498
+ jml(
12499
+ 'label', [
12500
+ 'Value ',
12501
+ ['input', {
12502
+ type: 'number',
12503
+ step: '1', size: '4', pattern: '\\d+',
12504
+ class: 'typedArrayValue typedArray-' + typedArray,
12505
+ ...getMinMaxForTypedArray(typedArray)
12506
+ }]
12507
+ ]
12508
+ ),
12509
+ val === 'setInt8' || val === 'setUint8'
12510
+ ? ''
12511
+ : jml('label', [
12512
+ ['input', {
12513
+ class: 'littleEndian',
12514
+ type: 'checkbox'
12515
+ }],
12516
+ 'Little endian'
12517
+ ]),
12518
+ ' ',
12519
+ jml('button', {
12520
+ $on: {
12521
+ click (e) {
12522
+ e.preventDefault();
12523
+ const ancestor = /** @type {HTMLElement} */ (
12524
+ this.parentElement
12525
+ );
12526
+ const dataViewMethod =
12527
+ /** @type {dataViewMethods[number]} */ (
12528
+ /** @type {HTMLSelectElement} */ (
12529
+ ancestor.previousElementSibling
12530
+ )?.value
12531
+ );
12532
+
12533
+ const dataViewSetByteOffset =
12534
+ Number.parseInt(/** @type {HTMLInputElement} */ ($e(
12535
+ ancestor,
12536
+ '.dataViewSetByteOffset'
12537
+ )).value);
12538
+ const typedArrayValue =
12539
+ /** @type {HTMLInputElement} */ ($e(
12540
+ ancestor,
12541
+ '.typedArrayValue'
12542
+ )).value;
12543
+ const littleEndian =
12544
+ /** @type {HTMLInputElement|null} */ ($e(
12545
+ ancestor,
12546
+ '.littleEndian'
12547
+ ))?.checked;
12548
+
12549
+ const byteLength =
12550
+ /**
12551
+ * @type {HTMLInputElement & {
12552
+ * $dataView: DataView,
12553
+ * }}
12554
+ */ (
12555
+ $e(
12556
+ /** @type {HTMLElement} */
12557
+ (ancestor?.parentElement?.parentElement),
12558
+ '.byteLength'
12559
+ )
12560
+ );
12561
+
12562
+ if (
12563
+ dataViewMethod === 'setBigInt64' ||
12564
+ dataViewMethod === 'setBigUint64'
12565
+ ) {
12566
+ byteLength.$dataView[dataViewMethod](
12567
+ dataViewSetByteOffset,
12568
+ BigInt(typedArrayValue),
12569
+ littleEndian
12570
+ );
12571
+ } else {
12572
+ byteLength.$dataView[dataViewMethod](
12573
+ dataViewSetByteOffset,
12574
+ Number(typedArrayValue),
12575
+ littleEndian
12576
+ );
12577
+ }
12578
+
12579
+ const typedArrayLength =
12580
+ /**
12581
+ * @type {HTMLInputElement & {
12582
+ * $buildTypedArray: BuildTypedArray
12583
+ * }}
12584
+ */ ($e(
12585
+ /** @type {HTMLElement} */
12586
+ (ancestor.parentElement?.parentElement),
12587
+ '.typedArrayLength'
12588
+ ));
12589
+ typedArrayLength.$buildTypedArray();
12590
+ }
12591
+ }
12592
+ }, ['Set'])
12593
+ );
12594
+ }
12595
+ }
12596
+ }, [
12597
+ ['option', {value: ''}, ['(Select a data view method)']],
12598
+ ...dataViewMethods.map((dataViewMethod) => {
12599
+ return /** @type {import('jamilih').JamilihArray} */ (
12600
+ ['option', [dataViewMethod]]
12601
+ );
12602
+ })
12603
+ ]],
12604
+ ' ',
12605
+ ['div', {class: 'dataViewArea'}]
12606
+ ]]
12607
+ ]));
12608
+
12609
+ if (this.setValue && value) {
12610
+ this.setValue({root: div, value});
12611
+ } else {
12612
+ const byteLength =
12613
+ /**
12614
+ * @type {HTMLInputElement & {
12615
+ * $value: BufferSource
12616
+ * }}
12617
+ */ ($e(div, '.byteLength'));
12618
+ byteLength.$value = new ArrayBuffer(0);
12619
+ }
12620
+
12621
+ return [div];
12622
+ }
12623
+ };
12624
+
12625
+ /**
12626
+ * @type {import('../types.js').TypeObject}
12627
+ */
12628
+ const noneditableType = {
12629
+ // Ideally, we would remove the option,
12630
+ // but edit forms currently need a pull-down option
12631
+ option: ['Non-editable'],
12632
+ getInput ({root}) {
12633
+ return /** @type {HTMLButtonElement} */ ($e(root, 'button'));
12634
+ },
12635
+ setValue ({root, value}) {
12636
+ /** @type {HTMLButtonElement & {$value: any}} */ (
12637
+ this.getInput({root})
12638
+ ).$value = value;
12639
+ /** @type {HTMLSpanElement} */ (
12640
+ $e(root, '.stringTag')
12641
+ ).textContent = value === undefined
12642
+ ? '(None)'
12643
+ : toStringTag(value);
12644
+ },
12645
+ getValue ({root}) {
12646
+ return /** @type {HTMLButtonElement & {$value: any}} */ (
12647
+ this.getInput({root})
12648
+ ).$value;
12649
+ },
12650
+ validate ({root}) {
12651
+ const val = /** @type {HTMLButtonElement & {$value: any}} */ (
12652
+ this.getInput({root})
12653
+ ).$value;
12654
+ return {
12655
+ message: 'The non-editable type is only for passing on ' +
12656
+ 'pre-existing content that is unknown or currently unsupported',
12657
+ valid: val !== undefined
12658
+ };
12659
+ },
12660
+ viewUI ({value}) {
12661
+ return ['div', {dataset: {type: 'resurrectable'}}, [
12662
+ ['b', {class: 'emphasis'}, ['Non-editable']],
12663
+ ['span', {
12664
+ title: 'There is no current support for editing this element\'s ' +
12665
+ 'type, but its contents will be passed on transparently.'
12666
+ }, ['?']],
12667
+ ['b', ['String tag: ']],
12668
+ toStringTag(value)
12669
+ ]];
12670
+ },
12671
+ editUI ({typeNamespace, value}) {
12672
+ return ['div', {dataset: {type: 'resurrectable'}}, [
12673
+ ['a', {
12674
+ // eslint-disable-next-line no-script-url -- Safe
12675
+ href: 'javascript:void(0)',
12676
+ $on: {
12677
+ click (e) {
12678
+ e.preventDefault();
12679
+ }
12680
+ },
12681
+ title: 'There is no current support for editing this element\'s ' +
12682
+ 'type, but its contents will be passed on transparently.'
12683
+ }, ['?']],
12684
+ ' ',
12685
+ ['button', {
12686
+ $on: {
12687
+ click (e) {
12688
+ e.preventDefault();
12689
+ console.log(/** @type {HTMLButtonElement & {$value: any}} */ (
12690
+ this
12691
+ ).$value);
12692
+ }
12693
+ },
12694
+ name: `${typeNamespace}-resurrectable`,
12695
+ $custom: {
12696
+ $value: value
12697
+ }
12698
+ }, [
12699
+ 'Non-editable'
12700
+ ]],
12701
+ ['br'],
12702
+ ['b', ['String tag: ']],
12703
+ ['span', {class: 'stringTag'}, [value ? toStringTag(value) : '(None)']]
12704
+ ]];
12705
+ }
12706
+ };
12707
+
12708
+ /**
12709
+ * Utility to retrieve the property value given a legend element.
12710
+ * @param {HTMLLegendElement} legend
12711
+ * @returns {string}
12712
+ */
12713
+ const getPropertyValueFromLegend = (legend) => {
12714
+ const propElem = $e(legend, '*[data-prop="true"]');
12715
+ if (!propElem) {
12716
+ throw new Error(
12717
+ 'No property on the supplied legend element'
12718
+ );
12719
+ }
12720
+ if (propElem.nodeName.toLowerCase() === 'input') {
12721
+ return /** @type {HTMLInputElement} */ (propElem).value;
12722
+ }
12723
+ if (!propElem.textContent) {
12724
+ throw new Error(
12725
+ 'No property with text present on the supplied legend element'
12726
+ );
12727
+ }
12728
+ // 1-based to 0-based
12729
+ return String(Number.parseInt(propElem.textContent) - 1);
12730
+ };
12731
+
12732
+ /**
12733
+ * Any other possibilities than `div`?
12734
+ * @typedef {HTMLDivElement} RootElement
12735
+ */
12736
+
12737
+ /**
12738
+ * Utility to retrieve the type out of a type root element.
12739
+ * @callback GetTypeForRoot
12740
+ * @param {?RootElement} root
12741
+ * @returns {string} Why would it not exist?
12742
+ */
12743
+
12744
+ /**
12745
+ * Utility to get the value out of a type root element with a given
12746
+ * state and path.
12747
+ * @callback GetValueForRoot
12748
+ * @param {RootElement} root
12749
+ * @param {StateObject} [stateObj]
12750
+ * @param {string} [currentPath]
12751
+ * @returns {StructuredCloneValue}
12752
+ */
12753
+
12754
+ /**
12755
+ * Utility to get the form control (e.g., input element) for a root.
12756
+ * @callback GetFormControlForRoot
12757
+ * @param {RootElement} root
12758
+ * @returns {null|
12759
+ * HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|HTMLButtonElement}
12760
+ */
12761
+
12762
+ /**
12763
+ * Utility to get the value for a root using its ancestor and state.
12764
+ * @callback GetValueFromRootAncestor
12765
+ * @param {string|HTMLElement} selOrEl
12766
+ * @param {StateObject} [stateObj]
12767
+ * @returns {StructuredCloneValue}
12768
+ */
12769
+
12770
+ /**
12771
+ * @callback GetFormControlFromRootAncestor
12772
+ * @param {string|HTMLElement} selOrEl
12773
+ * @returns {null|HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement|
12774
+ * HTMLButtonElement}
12775
+ */
12776
+
12777
+ /**
12778
+ * @callback GetOptionForType
12779
+ * @param {AvailableType} type
12780
+ * @returns {[string, {value: AvailableType, title?: string}]}
12781
+ */
12782
+
12783
+ /**
12784
+ * @callback GetTypeOptionsForFormatAndState
12785
+ * @param {import('./formats.js').AvailableFormat} format
12786
+ * @param {string} [parserState]
12787
+ * @returns {[string, {value: AvailableType, title?: string}][]}
12788
+ */
12789
+
12790
+ /**
12791
+ * @typedef {(
12792
+ * keypath: string,
12793
+ * parentPath: string,
12794
+ * arrayOrObjectPropertyName: string,
12795
+ * valueType: string
12796
+ * ) => StateObject} GetPossibleSchemasForPathAndType
12797
+ */
12798
+
12799
+ /**
12800
+ * @typedef {{
12801
+ * typeNamespace?: string,
12802
+ * "readonly"?: boolean,
12803
+ * format?: import('./formats.js').AvailableFormat,
12804
+ * formats?: import('./formats.js').default,
12805
+ * types?: Types,
12806
+ * error?: Error,
12807
+ * rootUI?: Element,
12808
+ * schema?: string,
12809
+ * schemaContent?: object,
12810
+ * getPossibleSchemasForPathAndType?: GetPossibleSchemasForPathAndType,
12811
+ * paths?: {[currentPath: string]: {
12812
+ * referentPath: string,
12813
+ * expectArrayReferent: boolean
12814
+ * }},
12815
+ * handlingReference?: boolean
12816
+ * }} StateObject
12817
+ */
12818
+
12819
+ /* eslint-disable jsdoc/valid-types -- readonly reserved */
12820
+ /**
12821
+ * @typedef {(cfg: {
12822
+ * readonly?: boolean,
12823
+ * resultType?: "both"|"keys"|"values",
12824
+ * typeNamespace?: string,
12825
+ * type: AvailableType,
12826
+ * topRoot?: RootElement,
11099
12827
  * bringIntoFocus?: boolean|undefined,
11100
12828
  * buildTypeChoices?: import('./typeChoices.js').BuildTypeChoices,
11101
12829
  * format: import('./formats.js').AvailableFormat,
@@ -11201,6 +12929,16 @@ const getPropertyValueFromLegend = (legend) => {
11201
12929
  * ) => void} TypeObjectSetValue
11202
12930
  */
11203
12931
 
12932
+ /**
12933
+ * @typedef {(
12934
+ * s: string, info?: RootInfo
12935
+ * ) => {
12936
+ * value?: StructuredCloneValue,
12937
+ * remnant?: string,
12938
+ * assign?: false
12939
+ * }} ToValue
12940
+ */
12941
+
11204
12942
  /**
11205
12943
  * @typedef {object} TypeObject
11206
12944
  * @property {[
@@ -11230,13 +12968,7 @@ const getPropertyValueFromLegend = (legend) => {
11230
12968
  * check whether this subtype matches
11231
12969
  * @property {string} [superType] The greater fundamental type to which
11232
12970
  * the type belongs
11233
- * @property {(
11234
- * s: string, info?: RootInfo
11235
- * ) => {
11236
- * value?: StructuredCloneValue,
11237
- * remnant?: string,
11238
- * assign?: false
11239
- * }} toValue Converts from string to value. May use
12971
+ * @property {ToValue} [toValue] Converts from string to value. May use
11240
12972
  * `stringRegex` to find components.
11241
12973
  * @property {(info: {
11242
12974
  * root: HTMLDivElement,
@@ -11301,13 +13033,19 @@ const getPropertyValueFromLegend = (legend) => {
11301
13033
  * "objectReference"|"array"|"object"|"date"|"userObject"|"undef"|
11302
13034
  * "SpecialRealNumber"|"SpecialNumber"|"regexp"|"BooleanObject"|
11303
13035
  * "NumberObject"|"StringObject"|"map"|"set"|"file"|"filelist"|"blobHTML"|
11304
- * "arraybuffer"|"arraybufferview"|"dataview"|"imagedata"|"imagebitmap"|
13036
+ * "buffersource"|"dataview"|"imagedata"|"imagebitmap"|
11305
13037
  * "int8array"|"uint8array"|"uint8clampedarray"|"int16array"|"uint16array"|
11306
13038
  * "int32array"|"uint32array"|"float32array"|"float64array"|"ValidDate"|
11307
13039
  * "arrayNonindexKeys"|"error"|"errors"|"blob"|"domexception"|"domrect"|
11308
- * "dompoint"|"dommatrix"} AvailableType
13040
+ * "dompoint"|"dommatrix"|"resurrectable"} AvailableType
11309
13041
  */
11310
13042
 
13043
+ /**
13044
+ * @typedef {TypeObject & {
13045
+ * childTypes: string[]
13046
+ * }} SuperTypeObject
13047
+ */
13048
+
11311
13049
  /**
11312
13050
  *
11313
13051
  */
@@ -11371,12 +13109,9 @@ class Types {
11371
13109
  dompoint: dompointType,
11372
13110
  dommatrix: dommatrixType,
11373
13111
 
11374
- arraybuffer: {
11375
- option: ['ArrayBuffer']
11376
- },
11377
- arraybufferview: {
11378
- option: ['ArrayBufferView']
11379
- },
13112
+ resurrectable: noneditableType,
13113
+
13114
+ buffersource: buffersourceType,
11380
13115
  dataview: {
11381
13116
  option: ['DataView']
11382
13117
  },
@@ -11529,6 +13264,7 @@ class Types {
11529
13264
  // Ensure `stateObj` remains a reference if present
11530
13265
  return typeObject.getValue({
11531
13266
  root,
13267
+ /* istanbul ignore next -- Guard */
11532
13268
  stateObj: stateObj ?? {
11533
13269
  types: this
11534
13270
  },
@@ -11573,11 +13309,12 @@ class Types {
11573
13309
 
11574
13310
  /** @type {GetOptionForType} */
11575
13311
  getOptionForType (type) {
13312
+ const availableType = /** @type {TypeObject} */ (
13313
+ this.availableTypes[type]
13314
+ );
11576
13315
  /** @type {[string, {value?: AvailableType, title?: string}?]} */
11577
13316
  const optInfo = [
11578
- ...(/** @type {TypeObject} */ (
11579
- this.availableTypes[type]
11580
- )).option
13317
+ ...availableType.option
11581
13318
  ];
11582
13319
  optInfo[1] = {value: type, ...(optInfo[1])};
11583
13320
  return /** @type {[string, {value: AvailableType, title?: string}]} */ (
@@ -11593,6 +13330,7 @@ class Types {
11593
13330
  if (!typesForFormatAndState) {
11594
13331
  throw new Error('Unexpected type for format and state');
11595
13332
  }
13333
+
11596
13334
  return typesForFormatAndState.map((type) => {
11597
13335
  return this.getOptionForType(type);
11598
13336
  });
@@ -11775,7 +13513,12 @@ class Types {
11775
13513
  // console.log('s0', s, '::', remnant, match);
11776
13514
  let valObj;
11777
13515
  try {
11778
- valObj = /** @type {TypeObject} */ (found[1]).toValue(
13516
+ const typeObj = /** @type {TypeObject} */ (found[1]);
13517
+ /* istanbul ignore if -- TS guard */
13518
+ if (!typeObj.toValue) {
13519
+ throw new Error('Type has no `toValue` method');
13520
+ }
13521
+ valObj = typeObj.toValue(
11779
13522
  mtch.groups?.innerContent || innerContent || s, {
11780
13523
  types: this,
11781
13524
  format,
@@ -11815,7 +13558,7 @@ class Types {
11815
13558
  }
11816
13559
  if (firstRun) {
11817
13560
  const typeson = new c().register(
11818
- ae
13561
+ ie
11819
13562
  );
11820
13563
  try {
11821
13564
  const topRoot = typeson.revive(value);