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,GACvB,KAAK,eAAe,EAAS,EAC/B,CAEJ,GACC,CACD,IAAK,eACL,MAAO,SAAsB,EAAU,GACrC,IAAI,EAAY,EAAK,GACrB,GAAK,EAAS,eAAe,GAC7B,GAAI,EAAK,OAAS,EAChB,KAAK,eAAe,EAAS,GAAY,EAAK,MAAM,QADtD,CAIA,IAAI,EAAS,EAAS,GACtB,IAAI,QAAQ,GACZ,GAAI,MAAM,QAAQ,GAChB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,OAAQ,IAC5B,QAAQ,EAAO,MAClB,EAAO,GAAK,KAAK,UAAU,EAAO,UAItC,EAAS,GAAa,KAAK,UAAU,EAVvC,CAYF,GACC,CACD,IAAK,iBACL,MAAO,SAAwB,EAAU,GACnC,MAAM,QAAQ,GAChB,KAAK,YAAY,EAAU,GAClB,GACT,KAAK,aAAa,EAAU,EAEhC,GACC,CACD,IAAK,WACL,MAAO,SAAkB,EAAU,GACjC,IACI,GADU,UAAU,OAAS,QAAsB,IAAjB,UAAU,GAAmB,UAAU,GAAK,CAAC,GAC5D,SAEvB,KAAK,UAAY,EACjB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAU,OAAQ,IAAK,CACzC,IACI,EADM,EAAU,GACL,MAAM,KACrB,KAAK,eAAe,EAAU,EAChC,CAEA,OADA,KAAK,WAAY,EACV,CACT,KAGK,CACT,CApFwB,GAsFxB,QAAQ,QAAU","file":"/npm/dynamic-serializer@0.2.1/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/dynamic-serializer@0.2.1/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar isEmpty = function isEmpty(val) {\n  return val === undefined || val === null || val === '';\n};\n\nvar DynamicSerializer = function () {\n  function DynamicSerializer() {\n    _classCallCheck(this, DynamicSerializer);\n\n    this._counter = 0;\n    this._cache = {};\n    this._constant = false;\n  }\n\n  _createClass(DynamicSerializer, [{\n    key: '_cacheVal',\n    value: function _cacheVal(arrVal) {\n      if (this._constant) return '<<constant>>';\n      if (this._cache.hasOwnProperty(arrVal)) {\n        return this._cache[arrVal];\n      }\n      return this._cache[arrVal] = this._counter++;\n    }\n  }, {\n    key: '_visitArray',\n    value: function _visitArray(snapshot, path) {\n      var nextProp = path[0];\n      var arrVal = snapshot[nextProp];\n      if (isFinite(nextProp)) {\n        if (path.length > 1) {\n          this._visitSnapshot(arrVal, path.slice(1));\n        } else if (!isEmpty(arrVal)) {\n          snapshot[nextProp] = this._cacheVal(arrVal);\n        }\n      } else {\n        for (var i = 0; i < snapshot.length; i++) {\n          var _arrVal = snapshot[i];\n          this._visitSnapshot(_arrVal, path);\n        }\n      }\n    }\n  }, {\n    key: '_visitObject',\n    value: function _visitObject(snapshot, path) {\n      var nextLayer = path[0];\n      if (!snapshot.hasOwnProperty(nextLayer)) return;\n      if (path.length > 1) {\n        this._visitSnapshot(snapshot[nextLayer], path.slice(1));\n        return;\n      }\n      var oldVal = snapshot[nextLayer];\n      if (isEmpty(oldVal)) return;\n      if (Array.isArray(oldVal)) {\n        for (var i = 0; i < oldVal.length; i++) {\n          if (!isEmpty(oldVal[i])) {\n            oldVal[i] = this._cacheVal(oldVal[i]);\n          }\n        }\n      } else {\n        snapshot[nextLayer] = this._cacheVal(oldVal);\n      }\n    }\n  }, {\n    key: '_visitSnapshot',\n    value: function _visitSnapshot(snapshot, path) {\n      if (Array.isArray(snapshot)) {\n        this._visitArray(snapshot, path);\n      } else if (snapshot) {\n        this._visitObject(snapshot, path);\n      }\n    }\n  }, {\n    key: 'toStatic',\n    value: function toStatic(snapshot, fullPaths) {\n      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n      var constant = options.constant;\n\n      this._constant = constant;\n      for (var i = 0; i < fullPaths.length; i++) {\n        var uid = fullPaths[i];\n        var path = uid.split('.');\n        this._visitSnapshot(snapshot, path);\n      }\n      this._constant = false;\n      return snapshot;\n    }\n  }]);\n\n  return DynamicSerializer;\n}();\n\nexports.default = DynamicSerializer;"]}