{"version":3,"sources":["webpack://web/./node_modules/optimism/node_modules/@wry/context/lib/context.esm.js","webpack://web/./node_modules/optimism/lib/bundle.esm.js"],"names":["currentContext","MISSING_VALUE","idCounter","globalKey","host","Array","Slot","this","id","Date","now","Math","random","toString","slice","join","prototype","hasValue","context_1","parent","slots","value","getValue","withValue","callback","args","thisArg","_a","__proto__","apply","bind","context","saved","arguments","noContext","Object","defineProperty","enumerable","writable","configurable","defaultDispose","Cache","max","dispose","Infinity","map","Map","newest","oldest","has","key","get","node","getNode","older","newer","set","clean","size","delete","parentEntrySlot","hasOwnProperty","toArray","from","collection","array","forEach","item","push","maybeUnsubscribe","entryOrDep","unsubscribe","emptySetPool","assert","condition","optionalMessage","Error","valueGet","length","Entry","fn","parents","Set","childValues","dirtyChildren","dirty","recomputing","deps","count","peek","mightBeDirty","rememberParent","recompute","entry","forgetChildren","recomputeNewValue","subscribe","e","setDirty","maybeSubscribe","reportClean","setClean","reallyRecompute","reportDirty","_this","eachParent","child","forgetChild","forget","dependOn","dep","add","pop","forgetDeps","clear","reportDirtyChild","reportCleanChild","parentCount","i","parentWasClean","a","b","len","childValue","removeDirtyChild","dc","_value","EntryMethods","options","depsByKey","depend","dep_1","entryMethodName","m_1","call","makeDefaultMakeCacheKeyFunction","keyTrie","WeakMap","lookupArray","caches","wrap","originalFunction","create","cache","pow","keyArgs","makeCacheKey","optimistic","dirtyKey","peekKey","forgetKey","getKey","freeze"],"mappings":"2LAGIA,EAAiB,KAGjBC,EAAgB,GAChBC,EAAY,EAiHZC,EAAY,oBACZC,EAAOC,MACPC,EAAOF,EAAKD,IAAc,WAC1B,IAAIG,EAhHgD,WACpD,SAASA,IAILC,KAAKC,GAAK,CACN,OACAN,IACAO,KAAKC,MACLC,KAAKC,SAASC,SAAS,IAAIC,MAAM,IACnCC,KAAK,KAyFX,OAvFAT,EAAKU,UAAUC,SAAW,WACtB,IAAK,IAAIC,EAAYlB,EAAgBkB,EAAWA,EAAYA,EAAUC,OAGlE,GAAI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D,UAAUvF,MAAMW,UAAUF,MAAMwH,KAAKrG,YAYvD,OATA8G,EAAMvF,IAAIN,EAAK2C,GACf8C,EAAO5B,IAAIgC,GAINnF,EAAgB3C,aACjB0H,EAAOzE,SAAQ,SAAU6E,GAAS,OAAOA,EAAMtF,WAC/CkF,EAAOzB,SAEJ7F,GASX,SAAS+H,EAASlG,GACd,IAAI2C,EAAQkD,EAAM5F,IAAID,GAClB2C,GACAA,EAAMK,WAOd,SAASmD,EAAQnG,GACb,IAAI2C,EAAQkD,EAAM5F,IAAID,GACtB,GAAI2C,EACA,OAAOA,EAAMJ,OAOrB,SAAS6D,EAAUpG,GACf,OAAO6F,EAAMpF,OAAOT,GAUxB,OAtCAf,OAAOC,eAAe+G,EAAY,OAAQ,CACtChG,IAAK,WACD,OAAO4F,EAAW,IAAErF,MAExBnB,cAAc,EACdF,YAAY,IAQhB8G,EAAWC,SAAWA,EACtBD,EAAW9D,MAAQ,WACf+D,EAASF,EAAarH,MAAM,KAAMI,aAQtCkH,EAAWE,QAAUA,EACrBF,EAAW1D,KAAO,WACd,OAAO4D,EAAQH,EAAarH,MAAM,KAAMI,aAK5CkH,EAAWG,UAAYA,EACvBH,EAAWvC,OAAS,WAChB,OAAO0C,EAAUJ,EAAarH,MAAM,KAAMI,aAE9CkH,EAAWD,aAAeA,EAC1BC,EAAWI,OAASN,EAAU,WAC1B,OAAOC,EAAarH,MAAM,KAAMoH,EAAQpH,MAAM,KAAMI,aACpDiH,EACG/G,OAAOqH,OAAOL","file":"npm.optimism.35c077533ad01ec0dca6.react.bundle.js","sourcesContent":["// This currentContext variable will only be used if the makeSlotClass\r\n// function is called, which happens only if this is the first copy of the\r\n// @wry/context package to be imported.\r\nvar currentContext = null;\r\n// This unique internal object is used to denote the absence of a value\r\n// for a given Slot, and is never exposed to outside code.\r\nvar MISSING_VALUE = {};\r\nvar idCounter = 1;\r\n// Although we can't do anything about the cost of duplicated code from\r\n// accidentally bundling multiple copies of the @wry/context package, we can\r\n// avoid creating the Slot class more than once using makeSlotClass.\r\nvar makeSlotClass = function () { return /** @class */ (function () {\r\n function Slot() {\r\n // If you have a Slot object, you can find out its slot.id, but you cannot\r\n // guess the slot.id of a Slot you don't have access to, thanks to the\r\n // randomized suffix.\r\n this.id = [\r\n \"slot\",\r\n idCounter++,\r\n Date.now(),\r\n Math.random().toString(36).slice(2),\r\n ].join(\":\");\r\n }\r\n Slot.prototype.hasValue = function () {\r\n for (var context_1 = currentContext; context_1; context_1 = context_1.parent) {\r\n // We use the Slot object iself as a key to its value, which means the\r\n // value cannot be obtained without a reference to the Slot object.\r\n if (this.id in context_1.slots) {\r\n var value = context_1.slots[this.id];\r\n if (value === MISSING_VALUE)\r\n break;\r\n if (context_1 !== currentContext) {\r\n // Cache the value in currentContext.slots so the next lookup will\r\n // be faster. This caching is safe because the tree of contexts and\r\n // the values of the slots are logically immutable.\r\n currentContext.slots[this.id] = value;\r\n }\r\n return true;\r\n }\r\n }\r\n if (currentContext) {\r\n // If a value was not found for this Slot, it's never going to be found\r\n // no matter how many times we look it up, so we might as well cache\r\n // the absence of the value, too.\r\n currentContext.slots[this.id] = MISSING_VALUE;\r\n }\r\n return false;\r\n };\r\n Slot.prototype.getValue = function () {\r\n if (this.hasValue()) {\r\n return currentContext.slots[this.id];\r\n }\r\n };\r\n Slot.prototype.withValue = function (value, callback, \r\n // Given the prevalence of arrow functions, specifying arguments is likely\r\n // to be much more common than specifying `this`, hence this ordering:\r\n args, thisArg) {\r\n var _a;\r\n var slots = (_a = {\r\n __proto__: null\r\n },\r\n _a[this.id] = value,\r\n _a);\r\n var parent = currentContext;\r\n currentContext = { parent: parent, slots: slots };\r\n try {\r\n // Function.prototype.apply allows the arguments array argument to be\r\n // omitted or undefined, so args! is fine here.\r\n return callback.apply(thisArg, args);\r\n }\r\n finally {\r\n currentContext = parent;\r\n }\r\n };\r\n // Capture the current context and wrap a callback function so that it\r\n // reestablishes the captured context when called.\r\n Slot.bind = function (callback) {\r\n var context = currentContext;\r\n return function () {\r\n var saved = currentContext;\r\n try {\r\n currentContext = context;\r\n return callback.apply(this, arguments);\r\n }\r\n finally {\r\n currentContext = saved;\r\n }\r\n };\r\n };\r\n // Immediately run a callback function without any captured context.\r\n Slot.noContext = function (callback, \r\n // Given the prevalence of arrow functions, specifying arguments is likely\r\n // to be much more common than specifying `this`, hence this ordering:\r\n args, thisArg) {\r\n if (currentContext) {\r\n var saved = currentContext;\r\n try {\r\n currentContext = null;\r\n // Function.prototype.apply allows the arguments array argument to be\r\n // omitted or undefined, so args! is fine here.\r\n return callback.apply(thisArg, args);\r\n }\r\n finally {\r\n currentContext = saved;\r\n }\r\n }\r\n else {\r\n return callback.apply(thisArg, args);\r\n }\r\n };\r\n return Slot;\r\n}()); };\r\n// We store a single global implementation of the Slot class as a permanent\r\n// non-enumerable symbol property of the Array constructor. This obfuscation\r\n// does nothing to prevent access to the Slot class, but at least it ensures\r\n// the implementation (i.e. currentContext) cannot be tampered with, and all\r\n// copies of the @wry/context package (hopefully just one) will share the\r\n// same Slot implementation. Since the first copy of the @wry/context package\r\n// to be imported wins, this technique imposes a very high cost for any\r\n// future breaking changes to the Slot class.\r\nvar globalKey = \"@wry/context:Slot\";\r\nvar host = Array;\r\nvar Slot = host[globalKey] || function () {\r\n var Slot = makeSlotClass();\r\n try {\r\n Object.defineProperty(host, globalKey, {\r\n value: host[globalKey] = Slot,\r\n enumerable: false,\r\n writable: false,\r\n configurable: false,\r\n });\r\n }\r\n finally {\r\n return Slot;\r\n }\r\n}();\n\nvar bind = Slot.bind, noContext = Slot.noContext;\r\nfunction setTimeoutWithContext(callback, delay) {\r\n return setTimeout(bind(callback), delay);\r\n}\r\n// Turn any generator function into an async function (using yield instead\r\n// of await), with context automatically preserved across yields.\r\nfunction asyncFromGen(genFn) {\r\n return function () {\r\n var gen = genFn.apply(this, arguments);\r\n var boundNext = bind(gen.next);\r\n var boundThrow = bind(gen.throw);\r\n return new Promise(function (resolve, reject) {\r\n function invoke(method, argument) {\r\n try {\r\n var result = method.call(gen, argument);\r\n }\r\n catch (error) {\r\n return reject(error);\r\n }\r\n var next = result.done ? resolve : invokeNext;\r\n if (isPromiseLike(result.value)) {\r\n result.value.then(next, result.done ? reject : invokeThrow);\r\n }\r\n else {\r\n next(result.value);\r\n }\r\n }\r\n var invokeNext = function (value) { return invoke(boundNext, value); };\r\n var invokeThrow = function (error) { return invoke(boundThrow, error); };\r\n invokeNext();\r\n });\r\n };\r\n}\r\nfunction isPromiseLike(value) {\r\n return value && typeof value.then === \"function\";\r\n}\r\n// If you use the fibers npm package to implement coroutines in Node.js,\r\n// you should call this function at least once to ensure context management\r\n// remains coherent across any yields.\r\nvar wrappedFibers = [];\r\nfunction wrapYieldingFiberMethods(Fiber) {\r\n // There can be only one implementation of Fiber per process, so this array\r\n // should never grow longer than one element.\r\n if (wrappedFibers.indexOf(Fiber) < 0) {\r\n var wrap = function (obj, method) {\r\n var fn = obj[method];\r\n obj[method] = function () {\r\n return noContext(fn, arguments, this);\r\n };\r\n };\r\n // These methods can yield, according to\r\n // https://github.com/laverdet/node-fibers/blob/ddebed9b8ae3883e57f822e2108e6943e5c8d2a8/fibers.js#L97-L100\r\n wrap(Fiber, \"yield\");\r\n wrap(Fiber.prototype, \"run\");\r\n wrap(Fiber.prototype, \"throwInto\");\r\n wrappedFibers.push(Fiber);\r\n }\r\n return Fiber;\r\n}\n\nexport { Slot, asyncFromGen, bind, noContext, setTimeoutWithContext as setTimeout, wrapYieldingFiberMethods };\n//# sourceMappingURL=context.esm.js.map\n","import { Trie } from '@wry/trie';\nexport { Trie as KeyTrie } from '@wry/trie';\nimport { Slot } from '@wry/context';\nexport { asyncFromGen, bind as bindContext, noContext, setTimeout } from '@wry/context';\n\nfunction defaultDispose() { }\r\nvar Cache = /** @class */ (function () {\r\n function Cache(max, dispose) {\r\n if (max === void 0) { max = Infinity; }\r\n if (dispose === void 0) { dispose = defaultDispose; }\r\n this.max = max;\r\n this.dispose = dispose;\r\n this.map = new Map();\r\n this.newest = null;\r\n this.oldest = null;\r\n }\r\n Cache.prototype.has = function (key) {\r\n return this.map.has(key);\r\n };\r\n Cache.prototype.get = function (key) {\r\n var node = this.getNode(key);\r\n return node && node.value;\r\n };\r\n Cache.prototype.getNode = function (key) {\r\n var node = this.map.get(key);\r\n if (node && node !== this.newest) {\r\n var older = node.older, newer = node.newer;\r\n if (newer) {\r\n newer.older = older;\r\n }\r\n if (older) {\r\n older.newer = newer;\r\n }\r\n node.older = this.newest;\r\n node.older.newer = node;\r\n node.newer = null;\r\n this.newest = node;\r\n if (node === this.oldest) {\r\n this.oldest = newer;\r\n }\r\n }\r\n return node;\r\n };\r\n Cache.prototype.set = function (key, value) {\r\n var node = this.getNode(key);\r\n if (node) {\r\n return node.value = value;\r\n }\r\n node = {\r\n key: key,\r\n value: value,\r\n newer: null,\r\n older: this.newest\r\n };\r\n if (this.newest) {\r\n this.newest.newer = node;\r\n }\r\n this.newest = node;\r\n this.oldest = this.oldest || node;\r\n this.map.set(key, node);\r\n return node.value;\r\n };\r\n Cache.prototype.clean = function () {\r\n while (this.oldest && this.map.size > this.max) {\r\n this.delete(this.oldest.key);\r\n }\r\n };\r\n Cache.prototype.delete = function (key) {\r\n var node = this.map.get(key);\r\n if (node) {\r\n if (node === this.newest) {\r\n this.newest = node.older;\r\n }\r\n if (node === this.oldest) {\r\n this.oldest = node.newer;\r\n }\r\n if (node.newer) {\r\n node.newer.older = node.older;\r\n }\r\n if (node.older) {\r\n node.older.newer = node.newer;\r\n }\r\n this.map.delete(key);\r\n this.dispose(node.value, key);\r\n return true;\r\n }\r\n return false;\r\n };\r\n return Cache;\r\n}());\n\nvar parentEntrySlot = new Slot();\n\nvar _a;\r\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\r\nvar \r\n// This Array.from polyfill is restricted to working with Set for now,\r\n// but we can improve the polyfill and add other input types, as needed. Note\r\n// that this fallback implementation will only be used if the host environment\r\n// does not support a native Array.from function. In most modern JS runtimes,\r\n// the toArray function exported here will be === Array.from.\r\ntoArray = (_a = Array.from, _a === void 0 ? function (collection) {\r\n var array = [];\r\n collection.forEach(function (item) { return array.push(item); });\r\n return array;\r\n} : _a);\r\nfunction maybeUnsubscribe(entryOrDep) {\r\n var unsubscribe = entryOrDep.unsubscribe;\r\n if (typeof unsubscribe === \"function\") {\r\n entryOrDep.unsubscribe = void 0;\r\n unsubscribe();\r\n }\r\n}\n\nvar emptySetPool = [];\r\nvar POOL_TARGET_SIZE = 100;\r\n// Since this package might be used browsers, we should avoid using the\r\n// Node built-in assert module.\r\nfunction assert(condition, optionalMessage) {\r\n if (!condition) {\r\n throw new Error(optionalMessage || \"assertion failure\");\r\n }\r\n}\r\nfunction valueIs(a, b) {\r\n var len = a.length;\r\n return (\r\n // Unknown values are not equal to each other.\r\n len > 0 &&\r\n // Both values must be ordinary (or both exceptional) to be equal.\r\n len === b.length &&\r\n // The underlying value or exception must be the same.\r\n a[len - 1] === b[len - 1]);\r\n}\r\nfunction valueGet(value) {\r\n switch (value.length) {\r\n case 0: throw new Error(\"unknown value\");\r\n case 1: return value[0];\r\n case 2: throw value[1];\r\n }\r\n}\r\nfunction valueCopy(value) {\r\n return value.slice(0);\r\n}\r\nvar Entry = /** @class */ (function () {\r\n function Entry(fn) {\r\n this.fn = fn;\r\n this.parents = new Set();\r\n this.childValues = new Map();\r\n // When this Entry has children that are dirty, this property becomes\r\n // a Set containing other Entry objects, borrowed from emptySetPool.\r\n // When the set becomes empty, it gets recycled back to emptySetPool.\r\n this.dirtyChildren = null;\r\n this.dirty = true;\r\n this.recomputing = false;\r\n this.value = [];\r\n this.deps = null;\r\n ++Entry.count;\r\n }\r\n Entry.prototype.peek = function () {\r\n if (this.value.length === 1 && !mightBeDirty(this)) {\r\n rememberParent(this);\r\n return this.value[0];\r\n }\r\n };\r\n // This is the most important method of the Entry API, because it\r\n // determines whether the cached this.value can be returned immediately,\r\n // or must be recomputed. The overall performance of the caching system\r\n // depends on the truth of the following observations: (1) this.dirty is\r\n // usually false, (2) this.dirtyChildren is usually null/empty, and thus\r\n // (3) valueGet(this.value) is usually returned without recomputation.\r\n Entry.prototype.recompute = function (args) {\r\n assert(!this.recomputing, \"already recomputing\");\r\n rememberParent(this);\r\n return mightBeDirty(this)\r\n ? reallyRecompute(this, args)\r\n : valueGet(this.value);\r\n };\r\n Entry.prototype.setDirty = function () {\r\n if (this.dirty)\r\n return;\r\n this.dirty = true;\r\n this.value.length = 0;\r\n reportDirty(this);\r\n // We can go ahead and unsubscribe here, since any further dirty\r\n // notifications we receive will be redundant, and unsubscribing may\r\n // free up some resources, e.g. file watchers.\r\n maybeUnsubscribe(this);\r\n };\r\n Entry.prototype.dispose = function () {\r\n var _this = this;\r\n this.setDirty();\r\n // Sever any dependency relationships with our own children, so those\r\n // children don't retain this parent Entry in their child.parents sets,\r\n // thereby preventing it from being fully garbage collected.\r\n forgetChildren(this);\r\n // Because this entry has been kicked out of the cache (in index.js),\r\n // we've lost the ability to find out if/when this entry becomes dirty,\r\n // whether that happens through a subscription, because of a direct call\r\n // to entry.setDirty(), or because one of its children becomes dirty.\r\n // Because of this loss of future information, we have to assume the\r\n // worst (that this entry might have become dirty very soon), so we must\r\n // immediately mark this entry's parents as dirty. Normally we could\r\n // just call entry.setDirty() rather than calling parent.setDirty() for\r\n // each parent, but that would leave this entry in parent.childValues\r\n // and parent.dirtyChildren, which would prevent the child from being\r\n // truly forgotten.\r\n eachParent(this, function (parent, child) {\r\n parent.setDirty();\r\n forgetChild(parent, _this);\r\n });\r\n };\r\n Entry.prototype.forget = function () {\r\n // The code that creates Entry objects in index.ts will replace this method\r\n // with one that actually removes the Entry from the cache, which will also\r\n // trigger the entry.dispose method.\r\n this.dispose();\r\n };\r\n Entry.prototype.dependOn = function (dep) {\r\n dep.add(this);\r\n if (!this.deps) {\r\n this.deps = emptySetPool.pop() || new Set();\r\n }\r\n this.deps.add(dep);\r\n };\r\n Entry.prototype.forgetDeps = function () {\r\n var _this = this;\r\n if (this.deps) {\r\n toArray(this.deps).forEach(function (dep) { return dep.delete(_this); });\r\n this.deps.clear();\r\n emptySetPool.push(this.deps);\r\n this.deps = null;\r\n }\r\n };\r\n Entry.count = 0;\r\n return Entry;\r\n}());\r\nfunction rememberParent(child) {\r\n var parent = parentEntrySlot.getValue();\r\n if (parent) {\r\n child.parents.add(parent);\r\n if (!parent.childValues.has(child)) {\r\n parent.childValues.set(child, []);\r\n }\r\n if (mightBeDirty(child)) {\r\n reportDirtyChild(parent, child);\r\n }\r\n else {\r\n reportCleanChild(parent, child);\r\n }\r\n return parent;\r\n }\r\n}\r\nfunction reallyRecompute(entry, args) {\r\n forgetChildren(entry);\r\n // Set entry as the parent entry while calling recomputeNewValue(entry).\r\n parentEntrySlot.withValue(entry, recomputeNewValue, [entry, args]);\r\n if (maybeSubscribe(entry, args)) {\r\n // If we successfully recomputed entry.value and did not fail to\r\n // (re)subscribe, then this Entry is no longer explicitly dirty.\r\n setClean(entry);\r\n }\r\n return valueGet(entry.value);\r\n}\r\nfunction recomputeNewValue(entry, args) {\r\n entry.recomputing = true;\r\n // Set entry.value as unknown.\r\n entry.value.length = 0;\r\n try {\r\n // If entry.fn succeeds, entry.value will become a normal Value.\r\n entry.value[0] = entry.fn.apply(null, args);\r\n }\r\n catch (e) {\r\n // If entry.fn throws, entry.value will become exceptional.\r\n entry.value[1] = e;\r\n }\r\n // Either way, this line is always reached.\r\n entry.recomputing = false;\r\n}\r\nfunction mightBeDirty(entry) {\r\n return entry.dirty || !!(entry.dirtyChildren && entry.dirtyChildren.size);\r\n}\r\nfunction setClean(entry) {\r\n entry.dirty = false;\r\n if (mightBeDirty(entry)) {\r\n // This Entry may still have dirty children, in which case we can't\r\n // let our parents know we're clean just yet.\r\n return;\r\n }\r\n reportClean(entry);\r\n}\r\nfunction reportDirty(child) {\r\n eachParent(child, reportDirtyChild);\r\n}\r\nfunction reportClean(child) {\r\n eachParent(child, reportCleanChild);\r\n}\r\nfunction eachParent(child, callback) {\r\n var parentCount = child.parents.size;\r\n if (parentCount) {\r\n var parents = toArray(child.parents);\r\n for (var i = 0; i < parentCount; ++i) {\r\n callback(parents[i], child);\r\n }\r\n }\r\n}\r\n// Let a parent Entry know that one of its children may be dirty.\r\nfunction reportDirtyChild(parent, child) {\r\n // Must have called rememberParent(child) before calling\r\n // reportDirtyChild(parent, child).\r\n assert(parent.childValues.has(child));\r\n assert(mightBeDirty(child));\r\n var parentWasClean = !mightBeDirty(parent);\r\n if (!parent.dirtyChildren) {\r\n parent.dirtyChildren = emptySetPool.pop() || new Set;\r\n }\r\n else if (parent.dirtyChildren.has(child)) {\r\n // If we already know this child is dirty, then we must have already\r\n // informed our own parents that we are dirty, so we can terminate\r\n // the recursion early.\r\n return;\r\n }\r\n parent.dirtyChildren.add(child);\r\n // If parent was clean before, it just became (possibly) dirty (according to\r\n // mightBeDirty), since we just added child to parent.dirtyChildren.\r\n if (parentWasClean) {\r\n reportDirty(parent);\r\n }\r\n}\r\n// Let a parent Entry know that one of its children is no longer dirty.\r\nfunction reportCleanChild(parent, child) {\r\n // Must have called rememberChild(child) before calling\r\n // reportCleanChild(parent, child).\r\n assert(parent.childValues.has(child));\r\n assert(!mightBeDirty(child));\r\n var childValue = parent.childValues.get(child);\r\n if (childValue.length === 0) {\r\n parent.childValues.set(child, valueCopy(child.value));\r\n }\r\n else if (!valueIs(childValue, child.value)) {\r\n parent.setDirty();\r\n }\r\n removeDirtyChild(parent, child);\r\n if (mightBeDirty(parent)) {\r\n return;\r\n }\r\n reportClean(parent);\r\n}\r\nfunction removeDirtyChild(parent, child) {\r\n var dc = parent.dirtyChildren;\r\n if (dc) {\r\n dc.delete(child);\r\n if (dc.size === 0) {\r\n if (emptySetPool.length < POOL_TARGET_SIZE) {\r\n emptySetPool.push(dc);\r\n }\r\n parent.dirtyChildren = null;\r\n }\r\n }\r\n}\r\n// Removes all children from this entry and returns an array of the\r\n// removed children.\r\nfunction forgetChildren(parent) {\r\n if (parent.childValues.size > 0) {\r\n parent.childValues.forEach(function (_value, child) {\r\n forgetChild(parent, child);\r\n });\r\n }\r\n // Remove this parent Entry from any sets to which it was added by the\r\n // addToSet method.\r\n parent.forgetDeps();\r\n // After we forget all our children, this.dirtyChildren must be empty\r\n // and therefore must have been reset to null.\r\n assert(parent.dirtyChildren === null);\r\n}\r\nfunction forgetChild(parent, child) {\r\n child.parents.delete(parent);\r\n parent.childValues.delete(child);\r\n removeDirtyChild(parent, child);\r\n}\r\nfunction maybeSubscribe(entry, args) {\r\n if (typeof entry.subscribe === \"function\") {\r\n try {\r\n maybeUnsubscribe(entry); // Prevent double subscriptions.\r\n entry.unsubscribe = entry.subscribe.apply(null, args);\r\n }\r\n catch (e) {\r\n // If this Entry has a subscribe function and it threw an exception\r\n // (or an unsubscribe function it previously returned now throws),\r\n // return false to indicate that we were not able to subscribe (or\r\n // unsubscribe), and this Entry should remain dirty.\r\n entry.setDirty();\r\n return false;\r\n }\r\n }\r\n // Returning true indicates either that there was no entry.subscribe\r\n // function or that it succeeded.\r\n return true;\r\n}\n\nvar EntryMethods = {\r\n setDirty: true,\r\n dispose: true,\r\n forget: true,\r\n};\r\nfunction dep(options) {\r\n var depsByKey = new Map();\r\n var subscribe = options && options.subscribe;\r\n function depend(key) {\r\n var parent = parentEntrySlot.getValue();\r\n if (parent) {\r\n var dep_1 = depsByKey.get(key);\r\n if (!dep_1) {\r\n depsByKey.set(key, dep_1 = new Set);\r\n }\r\n parent.dependOn(dep_1);\r\n if (typeof subscribe === \"function\") {\r\n maybeUnsubscribe(dep_1);\r\n dep_1.unsubscribe = subscribe(key);\r\n }\r\n }\r\n }\r\n depend.dirty = function dirty(key, entryMethodName) {\r\n var dep = depsByKey.get(key);\r\n if (dep) {\r\n var m_1 = (entryMethodName &&\r\n hasOwnProperty.call(EntryMethods, entryMethodName)) ? entryMethodName : \"setDirty\";\r\n // We have to use toArray(dep).forEach instead of dep.forEach, because\r\n // modifying a Set while iterating over it can cause elements in the Set\r\n // to be removed from the Set before they've been iterated over.\r\n toArray(dep).forEach(function (entry) { return entry[m_1](); });\r\n depsByKey.delete(key);\r\n maybeUnsubscribe(dep);\r\n }\r\n };\r\n return depend;\r\n}\n\nfunction makeDefaultMakeCacheKeyFunction() {\r\n var keyTrie = new Trie(typeof WeakMap === \"function\");\r\n return function () {\r\n return keyTrie.lookupArray(arguments);\r\n };\r\n}\r\n// The defaultMakeCacheKey function is remarkably powerful, because it gives\r\n// a unique object for any shallow-identical list of arguments. If you need\r\n// to implement a custom makeCacheKey function, you may find it helpful to\r\n// delegate the final work to defaultMakeCacheKey, which is why we export it\r\n// here. However, you may want to avoid defaultMakeCacheKey if your runtime\r\n// does not support WeakMap, or you have the ability to return a string key.\r\n// In those cases, just write your own custom makeCacheKey functions.\r\nvar defaultMakeCacheKey = makeDefaultMakeCacheKeyFunction();\r\nvar caches = new Set();\r\nfunction wrap(originalFunction, options) {\r\n if (options === void 0) { options = Object.create(null); }\r\n var cache = new Cache(options.max || Math.pow(2, 16), function (entry) { return entry.dispose(); });\r\n var keyArgs = options.keyArgs;\r\n var makeCacheKey = options.makeCacheKey ||\r\n makeDefaultMakeCacheKeyFunction();\r\n var optimistic = function () {\r\n var key = makeCacheKey.apply(null, keyArgs ? keyArgs.apply(null, arguments) : arguments);\r\n if (key === void 0) {\r\n return originalFunction.apply(null, arguments);\r\n }\r\n var entry = cache.get(key);\r\n if (!entry) {\r\n cache.set(key, entry = new Entry(originalFunction));\r\n entry.subscribe = options.subscribe;\r\n // Give the Entry the ability to trigger cache.delete(key), even though\r\n // the Entry itself does not know about key or cache.\r\n entry.forget = function () { return cache.delete(key); };\r\n }\r\n var value = entry.recompute(Array.prototype.slice.call(arguments));\r\n // Move this entry to the front of the least-recently used queue,\r\n // since we just finished computing its value.\r\n cache.set(key, entry);\r\n caches.add(cache);\r\n // Clean up any excess entries in the cache, but only if there is no\r\n // active parent entry, meaning we're not in the middle of a larger\r\n // computation that might be flummoxed by the cleaning.\r\n if (!parentEntrySlot.hasValue()) {\r\n caches.forEach(function (cache) { return cache.clean(); });\r\n caches.clear();\r\n }\r\n return value;\r\n };\r\n Object.defineProperty(optimistic, \"size\", {\r\n get: function () {\r\n return cache[\"map\"].size;\r\n },\r\n configurable: false,\r\n enumerable: false,\r\n });\r\n function dirtyKey(key) {\r\n var entry = cache.get(key);\r\n if (entry) {\r\n entry.setDirty();\r\n }\r\n }\r\n optimistic.dirtyKey = dirtyKey;\r\n optimistic.dirty = function dirty() {\r\n dirtyKey(makeCacheKey.apply(null, arguments));\r\n };\r\n function peekKey(key) {\r\n var entry = cache.get(key);\r\n if (entry) {\r\n return entry.peek();\r\n }\r\n }\r\n optimistic.peekKey = peekKey;\r\n optimistic.peek = function peek() {\r\n return peekKey(makeCacheKey.apply(null, arguments));\r\n };\r\n function forgetKey(key) {\r\n return cache.delete(key);\r\n }\r\n optimistic.forgetKey = forgetKey;\r\n optimistic.forget = function forget() {\r\n return forgetKey(makeCacheKey.apply(null, arguments));\r\n };\r\n optimistic.makeCacheKey = makeCacheKey;\r\n optimistic.getKey = keyArgs ? function getKey() {\r\n return makeCacheKey.apply(null, keyArgs.apply(null, arguments));\r\n } : makeCacheKey;\r\n return Object.freeze(optimistic);\r\n}\n\nexport { defaultMakeCacheKey, dep, wrap };\n//# sourceMappingURL=bundle.esm.js.map\n"],"sourceRoot":""}