@tko/computed
Version:
TKO Computed Observables
4 lines • 123 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../index.ts", "../../utils/dist/array.js", "../../utils/dist/options.js", "../../utils/dist/error.js", "../../utils/dist/async.js", "../../utils/dist/ie.js", "../../utils/dist/object.js", "../../utils/dist/function.js", "../../utils/dist/symbol.js", "../../utils/dist/jquery.js", "../../utils/dist/dom/info.js", "../../utils/dist/dom/data.js", "../../utils/dist/dom/disposal.js", "../../utils/dist/dom/event.js", "../../utils/dist/dom/virtualElements.js", "../../utils/dist/dom/html.js", "../../utils/dist/dom/selectExtensions.js", "../../utils/dist/tasks.js", "../../observable/dist/dependencyDetection.js", "../../observable/dist/subscribableSymbol.js", "../../observable/dist/defer.js", "../../observable/dist/Subscription.js", "../../observable/dist/extenders.js", "../../observable/dist/subscribable.js", "../../observable/dist/observable.js", "../../observable/dist/observableArray.changeTracking.js", "../../observable/dist/observableArray.js", "../src/computed.ts", "../src/throttleExtender.ts", "../src/proxy.ts", "../src/when.ts"],
"sourcesContent": ["export * from './src'\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nconst { isArray } = Array;\nexport function arrayForEach(array, action, thisArg) {\n if (arguments.length > 2) {\n action = action.bind(thisArg);\n }\n for (let i = 0, j = array.length; i < j; ++i) {\n action(array[i], i, array);\n }\n}\nexport function arrayIndexOf(array, item) {\n return (isArray(array) ? array : [...array]).indexOf(item);\n}\nexport function arrayFirst(array, predicate, predicateOwner) {\n return (isArray(array) ? array : [...array]).find(predicate, predicateOwner);\n}\nexport function arrayMap(array = [], mapping, thisArg) {\n if (arguments.length > 2) {\n mapping = mapping.bind(thisArg);\n }\n return array === null ? [] : Array.from(array, mapping);\n}\nexport function arrayRemoveItem(array, itemToRemove) {\n var index = arrayIndexOf(array, itemToRemove);\n if (index > 0) {\n array.splice(index, 1);\n } else if (index === 0) {\n array.shift();\n }\n}\nexport function arrayGetDistinctValues(array = []) {\n const seen = /* @__PURE__ */ new Set();\n if (array === null) {\n return [];\n }\n return (isArray(array) ? array : [...array]).filter((item) => seen.has(item) ? false : seen.add(item));\n}\nexport function arrayFilter(array, predicate, thisArg) {\n if (arguments.length > 2) {\n predicate = predicate.bind(thisArg);\n }\n return array === null ? [] : (isArray(array) ? array : [...array]).filter(predicate);\n}\nexport function arrayPushAll(array, valuesToPush) {\n if (isArray(valuesToPush)) {\n array.push.apply(array, valuesToPush);\n } else {\n for (var i = 0, j = valuesToPush.length; i < j; i++) {\n array.push(valuesToPush[i]);\n }\n }\n return array;\n}\nexport function addOrRemoveItem(array, value, included) {\n var existingEntryIndex = arrayIndexOf(typeof array.peek === \"function\" ? array.peek() : array, value);\n if (existingEntryIndex < 0) {\n if (included) {\n array.push(value);\n }\n } else {\n if (!included) {\n array.splice(existingEntryIndex, 1);\n }\n }\n}\nexport function makeArray(arrayLikeObject) {\n return Array.from(arrayLikeObject);\n}\nexport function range(min, max) {\n min = typeof min === \"function\" ? min() : min;\n max = typeof max === \"function\" ? max() : max;\n var result = [];\n for (var i = min; i <= max; i++) {\n result.push(i);\n }\n return result;\n}\nexport function findMovesInArrayComparison(left, right, limitFailedCompares) {\n if (left.length && right.length) {\n var failedCompares, l, r, leftItem, rightItem;\n for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {\n for (r = 0; rightItem = right[r]; ++r) {\n if (leftItem.value === rightItem.value) {\n leftItem.moved = rightItem.index;\n rightItem.moved = leftItem.index;\n right.splice(r, 1);\n failedCompares = r = 0;\n break;\n }\n }\n failedCompares += r;\n }\n }\n}\nconst statusNotInOld = \"added\";\nconst statusNotInNew = \"deleted\";\nexport function compareArrays(oldArray, newArray, options) {\n options = typeof options === \"boolean\" ? { dontLimitMoves: options } : options || {};\n oldArray = oldArray || [];\n newArray = newArray || [];\n if (oldArray.length < newArray.length) {\n return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options);\n } else {\n return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options);\n }\n}\nfunction compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options) {\n var myMin = Math.min, myMax = Math.max, editDistanceMatrix = [], smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = bigIndexMax - smlIndexMax || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow;\n for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {\n lastRow = thisRow;\n editDistanceMatrix.push(thisRow = []);\n bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);\n bigIndexMinForRow = myMax(0, smlIndex - 1);\n for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {\n if (!bigIndex) {\n thisRow[bigIndex] = smlIndex + 1;\n } else if (!smlIndex) {\n thisRow[bigIndex] = bigIndex + 1;\n } else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {\n thisRow[bigIndex] = lastRow[bigIndex - 1];\n } else {\n var northDistance = lastRow[bigIndex] || maxDistance;\n var westDistance = thisRow[bigIndex - 1] || maxDistance;\n thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;\n }\n }\n }\n var editScript = [], meMinusOne, notInSml = [], notInBig = [];\n for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {\n meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;\n if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {\n notInSml.push(editScript[editScript.length] = {\n \"status\": statusNotInSml,\n \"value\": bigArray[--bigIndex],\n \"index\": bigIndex\n });\n } else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {\n notInBig.push(editScript[editScript.length] = {\n \"status\": statusNotInBig,\n \"value\": smlArray[--smlIndex],\n \"index\": smlIndex\n });\n } else {\n --bigIndex;\n --smlIndex;\n if (!options.sparse) {\n editScript.push({\n \"status\": \"retained\",\n \"value\": bigArray[bigIndex]\n });\n }\n }\n }\n findMovesInArrayComparison(notInBig, notInSml, !options.dontLimitMoves && smlIndexMax * 10);\n return editScript.reverse();\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nconst options = {\n deferUpdates: false,\n useOnlyNativeEvents: false,\n protoProperty: \"__ko_proto__\",\n defaultBindingAttribute: \"data-bind\",\n allowVirtualElements: true,\n bindingGlobals: /* @__PURE__ */ Object.create(null),\n bindingProviderInstance: null,\n createChildContextWithAs: false,\n jQuery: globalThis.jQuery,\n Promise: globalThis.Promise,\n taskScheduler: null,\n debug: false,\n global: globalThis,\n document: globalThis.document,\n filters: {},\n includeDestroyed: false,\n foreachHidesDestroyed: false,\n onError: function(e) {\n throw e;\n },\n set: function(name, value) {\n options[name] = value;\n },\n getBindingHandler() {\n },\n cleanExternalData() {\n }\n};\nObject.defineProperty(options, \"$\", {\n get: function() {\n return options.jQuery;\n }\n});\nexport default options;\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport options from \"./options\";\nexport function catchFunctionErrors(delegate) {\n if (!options.onError) {\n return delegate;\n }\n return (...args) => {\n try {\n return delegate(...args);\n } catch (err) {\n options.onError(err);\n }\n };\n}\nexport function deferError(error) {\n safeSetTimeout(function() {\n throw error;\n }, 0);\n}\nexport function safeSetTimeout(handler, timeout) {\n return setTimeout(catchFunctionErrors(handler), timeout);\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport { safeSetTimeout } from \"./error\";\nexport function throttle(callback, timeout) {\n var timeoutInstance;\n return function(...args) {\n if (!timeoutInstance) {\n timeoutInstance = safeSetTimeout(function() {\n timeoutInstance = void 0;\n callback(...args);\n }, timeout);\n }\n };\n}\nexport function debounce(callback, timeout) {\n var timeoutInstance;\n return function(...args) {\n clearTimeout(timeoutInstance);\n timeoutInstance = safeSetTimeout(() => callback(...args), timeout);\n };\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport options from \"./options\";\nconst ieVersion = options.document && function() {\n var version = 3, div = options.document.createElement(\"div\"), iElems = div.getElementsByTagName(\"i\");\n while (div.innerHTML = \"<!--[if gt IE \" + ++version + \"]><i></i><![endif]-->\", iElems[0]) {\n }\n if (!version) {\n const userAgent = window.navigator.userAgent;\n return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);\n }\n return version > 4 ? version : void 0;\n}();\nconst isIe6 = ieVersion === 6;\nconst isIe7 = ieVersion === 7;\nexport { ieVersion, isIe6, isIe7 };\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nexport function hasOwnProperty(obj, propName) {\n return Object.prototype.hasOwnProperty.call(obj, propName);\n}\nexport function isObjectLike(obj) {\n if (obj === null) {\n return false;\n }\n return typeof obj === \"object\" || typeof obj === \"function\";\n}\nexport function extend(target, source) {\n if (source) {\n for (var prop in source) {\n if (hasOwnProperty(source, prop)) {\n target[prop] = source[prop];\n }\n }\n }\n return target;\n}\nexport function objectForEach(obj, action) {\n for (var prop in obj) {\n if (hasOwnProperty(obj, prop)) {\n action(prop, obj[prop]);\n }\n }\n}\nexport function objectMap(source, mapping, thisArg) {\n if (!source) {\n return source;\n }\n if (arguments.length > 2) {\n mapping = mapping.bind(thisArg);\n }\n var target = {};\n for (var prop in source) {\n if (hasOwnProperty(source, prop)) {\n target[prop] = mapping(source[prop], prop, source);\n }\n }\n return target;\n}\nexport function getObjectOwnProperty(obj, propName) {\n return hasOwnProperty(obj, propName) ? obj[propName] : void 0;\n}\nexport function clonePlainObjectDeep(obj, seen) {\n if (!seen) {\n seen = [];\n }\n if (!obj || typeof obj !== \"object\" || obj.constructor !== Object || seen.indexOf(obj) !== -1) {\n return obj;\n }\n seen.push(obj);\n var result = {};\n for (var prop in obj) {\n if (hasOwnProperty(obj, prop)) {\n result[prop] = clonePlainObjectDeep(obj[prop], seen);\n }\n }\n return result;\n}\nexport function safeStringify(value) {\n const seen = /* @__PURE__ */ new Set();\n return JSON.stringify(value, (k, v) => {\n if (seen.has(v)) {\n return \"...\";\n }\n if (typeof v === \"object\") {\n seen.add(v);\n }\n return v;\n });\n}\nexport function isThenable(object) {\n return isObjectLike(object) && typeof object.then === \"function\";\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nfunction testOverwrite() {\n try {\n Object.defineProperty(function x() {\n }, \"length\", {});\n return true;\n } catch (e) {\n return false;\n }\n}\nexport const functionSupportsLengthOverwrite = testOverwrite();\nexport function overwriteLengthPropertyIfSupported(fn, descriptor) {\n if (functionSupportsLengthOverwrite) {\n Object.defineProperty(fn, \"length\", descriptor);\n }\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nexport var useSymbols = typeof Symbol === \"function\";\nexport function createSymbolOrString(identifier) {\n return useSymbols ? Symbol(identifier) : identifier;\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport options from \"./options\";\nexport var jQueryInstance = options.global && options.global.jQuery;\nexport function jQuerySetInstance(jquery) {\n options.jQuery = jQueryInstance = jquery;\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport { arrayFirst } from \"../array\";\nexport function domNodeIsContainedBy(node, containedByNode) {\n if (node === containedByNode) {\n return true;\n }\n if (node.nodeType === 11) {\n return false;\n }\n if (containedByNode.contains) {\n return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);\n }\n if (containedByNode.compareDocumentPosition) {\n return (containedByNode.compareDocumentPosition(node) & 16) == 16;\n }\n while (node && node != containedByNode) {\n node = node.parentNode;\n }\n return !!node;\n}\nexport function domNodeIsAttachedToDocument(node) {\n return domNodeIsContainedBy(node, node.ownerDocument.documentElement);\n}\nexport function anyDomNodeIsAttachedToDocument(nodes) {\n return !!arrayFirst(nodes, domNodeIsAttachedToDocument);\n}\nexport function tagNameLower(element) {\n return element && element.tagName && element.tagName.toLowerCase();\n}\nexport function isDomElement(obj) {\n if (window.HTMLElement) {\n return obj instanceof HTMLElement;\n } else {\n return obj && obj.tagName && obj.nodeType === 1;\n }\n}\nexport function isDocumentFragment(obj) {\n if (window.DocumentFragment) {\n return obj instanceof DocumentFragment;\n } else {\n return obj && obj.nodeType === 11;\n }\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport { ieVersion } from \"../ie\";\nconst datastoreTime = new Date().getTime();\nconst dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;\nconst dataStoreSymbol = Symbol(\"Knockout data\");\nvar dataStore;\nlet uniqueId = 0;\nconst modern = {\n getDataForNode(node, createIfNotFound) {\n let dataForNode = node[dataStoreSymbol];\n if (!dataForNode && createIfNotFound) {\n dataForNode = node[dataStoreSymbol] = {};\n }\n return dataForNode;\n },\n clear(node) {\n if (node[dataStoreSymbol]) {\n delete node[dataStoreSymbol];\n return true;\n }\n return false;\n }\n};\nconst IE = {\n getDataforNode(node, createIfNotFound) {\n let dataStoreKey = node[dataStoreKeyExpandoPropertyName];\n const hasExistingDataStore = dataStoreKey && dataStoreKey !== \"null\" && dataStore[dataStoreKey];\n if (!hasExistingDataStore) {\n if (!createIfNotFound) {\n return void 0;\n }\n dataStoreKey = node[dataStoreKeyExpandoPropertyName] = \"ko\" + uniqueId++;\n dataStore[dataStoreKey] = {};\n }\n return dataStore[dataStoreKey];\n },\n clear(node) {\n const dataStoreKey = node[dataStoreKeyExpandoPropertyName];\n if (dataStoreKey) {\n delete dataStore[dataStoreKey];\n node[dataStoreKeyExpandoPropertyName] = null;\n return true;\n }\n return false;\n }\n};\nconst { getDataForNode, clear } = ieVersion ? IE : modern;\nexport function nextKey() {\n return uniqueId++ + dataStoreKeyExpandoPropertyName;\n}\nfunction get(node, key) {\n const dataForNode = getDataForNode(node, false);\n return dataForNode && dataForNode[key];\n}\nfunction set(node, key, value) {\n var dataForNode = getDataForNode(node, value !== void 0);\n dataForNode && (dataForNode[key] = value);\n}\nfunction getOrSet(node, key, value) {\n const dataForNode = getDataForNode(node, true);\n return dataForNode[key] || (dataForNode[key] = value);\n}\nexport { get, set, getOrSet, clear };\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport * as domData from \"./data\";\nimport { default as options } from \"../options\";\nimport { arrayRemoveItem, arrayIndexOf } from \"../array\";\nimport { jQueryInstance } from \"../jquery\";\nvar domDataKey = domData.nextKey();\nvar cleanableNodeTypes = { 1: true, 8: true, 9: true };\nvar cleanableNodeTypesWithDescendants = { 1: true, 9: true };\nfunction getDisposeCallbacksCollection(node, createIfNotFound) {\n var allDisposeCallbacks = domData.get(node, domDataKey);\n if (allDisposeCallbacks === void 0 && createIfNotFound) {\n allDisposeCallbacks = [];\n domData.set(node, domDataKey, allDisposeCallbacks);\n }\n return allDisposeCallbacks;\n}\nfunction destroyCallbacksCollection(node) {\n domData.set(node, domDataKey, void 0);\n}\nfunction cleanSingleNode(node) {\n var callbacks = getDisposeCallbacksCollection(node, false);\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (let i = 0; i < callbacks.length; i++) {\n callbacks[i](node);\n }\n }\n domData.clear(node);\n for (let i = 0, j = otherNodeCleanerFunctions.length; i < j; ++i) {\n otherNodeCleanerFunctions[i](node);\n }\n if (options.cleanExternalData) {\n options.cleanExternalData(node);\n }\n if (cleanableNodeTypesWithDescendants[node.nodeType]) {\n cleanNodesInList(node.childNodes, true);\n }\n}\nfunction cleanNodesInList(nodeList, onlyComments) {\n const cleanedNodes = [];\n let lastCleanedNode;\n for (var i = 0; i < nodeList.length; i++) {\n if (!onlyComments || nodeList[i].nodeType === 8) {\n cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);\n if (nodeList[i] !== lastCleanedNode) {\n while (i-- && arrayIndexOf(cleanedNodes, nodeList[i]) === -1) {\n }\n }\n }\n }\n}\nexport function addDisposeCallback(node, callback) {\n if (typeof callback !== \"function\") {\n throw new Error(\"Callback must be a function\");\n }\n getDisposeCallbacksCollection(node, true).push(callback);\n}\nexport function removeDisposeCallback(node, callback) {\n var callbacksCollection = getDisposeCallbacksCollection(node, false);\n if (callbacksCollection) {\n arrayRemoveItem(callbacksCollection, callback);\n if (callbacksCollection.length === 0) {\n destroyCallbacksCollection(node);\n }\n }\n}\nexport function cleanNode(node) {\n if (cleanableNodeTypes[node.nodeType]) {\n cleanSingleNode(node);\n if (cleanableNodeTypesWithDescendants[node.nodeType]) {\n cleanNodesInList(node.getElementsByTagName(\"*\"));\n }\n }\n return node;\n}\nexport function removeNode(node) {\n cleanNode(node);\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n}\nexport const otherNodeCleanerFunctions = [];\nexport function addCleaner(fn) {\n otherNodeCleanerFunctions.push(fn);\n}\nexport function removeCleaner(fn) {\n const fnIndex = otherNodeCleanerFunctions.indexOf(fn);\n if (fnIndex >= 0) {\n otherNodeCleanerFunctions.splice(fnIndex, 1);\n }\n}\nexport function cleanjQueryData(node) {\n var jQueryCleanNodeFn = jQueryInstance ? jQueryInstance.cleanData : null;\n if (jQueryCleanNodeFn) {\n jQueryCleanNodeFn([node]);\n }\n}\notherNodeCleanerFunctions.push(cleanjQueryData);\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport { objectForEach } from \"../object\";\nimport { jQueryInstance } from \"../jquery\";\nimport { ieVersion } from \"../ie\";\nimport { catchFunctionErrors } from \"../error\";\nimport { tagNameLower } from \"./info\";\nimport { addDisposeCallback } from \"./disposal\";\nimport options from \"../options\";\nvar knownEvents = {}, knownEventTypesByEventName = {};\nvar keyEventTypeName = options.global.navigator && /Firefox\\/2/i.test(options.global.navigator.userAgent) ? \"KeyboardEvent\" : \"UIEvents\";\nknownEvents[keyEventTypeName] = [\"keyup\", \"keydown\", \"keypress\"];\nknownEvents[\"MouseEvents\"] = [\n \"click\",\n \"dblclick\",\n \"mousedown\",\n \"mouseup\",\n \"mousemove\",\n \"mouseover\",\n \"mouseout\",\n \"mouseenter\",\n \"mouseleave\"\n];\nobjectForEach(knownEvents, function(eventType, knownEventsForType) {\n if (knownEventsForType.length) {\n for (var i = 0, j = knownEventsForType.length; i < j; i++) {\n knownEventTypesByEventName[knownEventsForType[i]] = eventType;\n }\n }\n});\nfunction isClickOnCheckableElement(element, eventType) {\n if (tagNameLower(element) !== \"input\" || !element.type)\n return false;\n if (eventType.toLowerCase() != \"click\")\n return false;\n var inputType = element.type;\n return inputType == \"checkbox\" || inputType == \"radio\";\n}\nvar eventsThatMustBeRegisteredUsingAttachEvent = { \"propertychange\": true };\nlet jQueryEventAttachName;\nexport function registerEventHandler(element, eventType, handler, eventOptions = false) {\n const wrappedHandler = catchFunctionErrors(handler);\n const mustUseAttachEvent = ieVersion && eventsThatMustBeRegisteredUsingAttachEvent[eventType];\n const mustUseNative = Boolean(eventOptions);\n if (!options.useOnlyNativeEvents && !mustUseAttachEvent && !mustUseNative && jQueryInstance) {\n if (!jQueryEventAttachName) {\n jQueryEventAttachName = typeof jQueryInstance(element).on === \"function\" ? \"on\" : \"bind\";\n }\n jQueryInstance(element)[jQueryEventAttachName](eventType, wrappedHandler);\n } else if (!mustUseAttachEvent && typeof element.addEventListener === \"function\") {\n element.addEventListener(eventType, wrappedHandler, eventOptions);\n } else if (typeof element.attachEvent !== \"undefined\") {\n const attachEventHandler = function(event) {\n wrappedHandler.call(element, event);\n };\n const attachEventName = \"on\" + eventType;\n element.attachEvent(attachEventName, attachEventHandler);\n addDisposeCallback(element, function() {\n element.detachEvent(attachEventName, attachEventHandler);\n });\n } else {\n throw new Error(\"Browser doesn't support addEventListener or attachEvent\");\n }\n}\nexport function triggerEvent(element, eventType) {\n if (!(element && element.nodeType)) {\n throw new Error(\"element must be a DOM node when calling triggerEvent\");\n }\n var useClickWorkaround = isClickOnCheckableElement(element, eventType);\n if (!options.useOnlyNativeEvents && jQueryInstance && !useClickWorkaround) {\n jQueryInstance(element).trigger(eventType);\n } else if (typeof document.createEvent === \"function\") {\n if (typeof element.dispatchEvent === \"function\") {\n var eventCategory = knownEventTypesByEventName[eventType] || \"HTMLEvents\";\n var event = document.createEvent(eventCategory);\n event.initEvent(eventType, true, true, options.global, 0, 0, 0, 0, 0, false, false, false, false, 0, element);\n element.dispatchEvent(event);\n } else {\n throw new Error(\"The supplied element doesn't support dispatchEvent\");\n }\n } else if (useClickWorkaround && element.click) {\n element.click();\n } else if (typeof element.fireEvent !== \"undefined\") {\n element.fireEvent(\"on\" + eventType);\n } else {\n throw new Error(\"Browser doesn't support triggering events\");\n }\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport { emptyDomNode, setDomNodeChildren as setRegularDomNodeChildren } from \"./manipulation\";\nimport { removeNode } from \"./disposal\";\nimport { tagNameLower } from \"./info\";\nimport * as domData from \"./data\";\nimport options from \"../options\";\nvar commentNodesHaveTextProperty = options.document && options.document.createComment(\"test\").text === \"<!--test-->\";\nexport var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\\s*ko(?:\\s+([\\s\\S]+))?\\s*-->$/ : /^\\s*ko(?:\\s+([\\s\\S]+))?\\s*$/;\nexport var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\\s*\\/ko\\s*-->$/ : /^\\s*\\/ko\\s*$/;\nvar htmlTagsWithOptionallyClosingChildren = { \"ul\": true, \"ol\": true };\nexport function isStartComment(node) {\n return node.nodeType == 8 && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);\n}\nexport function isEndComment(node) {\n return node.nodeType == 8 && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);\n}\nfunction isUnmatchedEndComment(node) {\n return isEndComment(node) && !domData.get(node, matchedEndCommentDataKey);\n}\nconst matchedEndCommentDataKey = \"__ko_matchedEndComment__\";\nexport function getVirtualChildren(startComment, allowUnbalanced) {\n var currentNode = startComment;\n var depth = 1;\n var children = [];\n while (currentNode = currentNode.nextSibling) {\n if (isEndComment(currentNode)) {\n domData.set(currentNode, matchedEndCommentDataKey, true);\n depth--;\n if (depth === 0) {\n return children;\n }\n }\n children.push(currentNode);\n if (isStartComment(currentNode)) {\n depth++;\n }\n }\n if (!allowUnbalanced) {\n throw new Error(\"Cannot find closing comment tag to match: \" + startComment.nodeValue);\n }\n return null;\n}\nfunction getMatchingEndComment(startComment, allowUnbalanced) {\n var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);\n if (allVirtualChildren) {\n if (allVirtualChildren.length > 0) {\n return allVirtualChildren[allVirtualChildren.length - 1].nextSibling;\n }\n return startComment.nextSibling;\n } else {\n return null;\n }\n}\nfunction getUnbalancedChildTags(node) {\n var childNode = node.firstChild, captureRemaining = null;\n if (childNode) {\n do {\n if (captureRemaining) {\n captureRemaining.push(childNode);\n } else if (isStartComment(childNode)) {\n var matchingEndComment = getMatchingEndComment(childNode, true);\n if (matchingEndComment) {\n childNode = matchingEndComment;\n } else {\n captureRemaining = [childNode];\n }\n } else if (isEndComment(childNode)) {\n captureRemaining = [childNode];\n }\n } while (childNode = childNode.nextSibling);\n }\n return captureRemaining;\n}\nexport var allowedBindings = {};\nexport var hasBindingValue = isStartComment;\nexport function childNodes(node) {\n return isStartComment(node) ? getVirtualChildren(node) : node.childNodes;\n}\nexport function emptyNode(node) {\n if (!isStartComment(node)) {\n emptyDomNode(node);\n } else {\n var virtualChildren = childNodes(node);\n for (var i = 0, j = virtualChildren.length; i < j; i++) {\n removeNode(virtualChildren[i]);\n }\n }\n}\nexport function setDomNodeChildren(node, childNodes2) {\n if (!isStartComment(node)) {\n setRegularDomNodeChildren(node, childNodes2);\n } else {\n emptyNode(node);\n const endCommentNode = node.nextSibling;\n const parentNode = endCommentNode.parentNode;\n for (var i = 0, j = childNodes2.length; i < j; ++i) {\n parentNode.insertBefore(childNodes2[i], endCommentNode);\n }\n }\n}\nexport function prepend(containerNode, nodeToPrepend) {\n if (!isStartComment(containerNode)) {\n if (containerNode.firstChild) {\n containerNode.insertBefore(nodeToPrepend, containerNode.firstChild);\n } else {\n containerNode.appendChild(nodeToPrepend);\n }\n } else {\n containerNode.parentNode.insertBefore(nodeToPrepend, containerNode.nextSibling);\n }\n}\nexport function insertAfter(containerNode, nodeToInsert, insertAfterNode) {\n if (!insertAfterNode) {\n prepend(containerNode, nodeToInsert);\n } else if (!isStartComment(containerNode)) {\n if (insertAfterNode.nextSibling) {\n containerNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);\n } else {\n containerNode.appendChild(nodeToInsert);\n }\n } else {\n containerNode.parentNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);\n }\n}\nexport function firstChild(node) {\n if (!isStartComment(node)) {\n if (node.firstChild && isEndComment(node.firstChild)) {\n throw new Error(\"Found invalid end comment, as the first child of \" + node.outerHTML);\n }\n return node.firstChild;\n }\n if (!node.nextSibling || isEndComment(node.nextSibling)) {\n return null;\n }\n return node.nextSibling;\n}\nexport function lastChild(node) {\n let nextChild = firstChild(node);\n let lastChildNode;\n do {\n lastChildNode = nextChild;\n } while (nextChild = nextSibling(nextChild));\n return lastChildNode;\n}\nexport function nextSibling(node) {\n if (isStartComment(node)) {\n node = getMatchingEndComment(node);\n }\n if (node.nextSibling && isEndComment(node.nextSibling)) {\n if (isUnmatchedEndComment(node.nextSibling)) {\n throw Error(\"Found end comment without a matching opening comment, as next sibling of \" + node.outerHTML);\n }\n return null;\n } else {\n return node.nextSibling;\n }\n}\nexport function previousSibling(node) {\n var depth = 0;\n do {\n if (node.nodeType === 8) {\n if (isStartComment(node)) {\n if (--depth === 0) {\n return node;\n }\n } else if (isEndComment(node)) {\n depth++;\n }\n } else {\n if (depth === 0) {\n return node;\n }\n }\n } while (node = node.previousSibling);\n}\nexport function virtualNodeBindingValue(node) {\n var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex);\n return regexMatch ? regexMatch[1] : null;\n}\nexport function normaliseVirtualElementDomStructure(elementVerified) {\n if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {\n return;\n }\n var childNode = elementVerified.firstChild;\n if (childNode) {\n do {\n if (childNode.nodeType === 1) {\n var unbalancedTags = getUnbalancedChildTags(childNode);\n if (unbalancedTags) {\n var nodeToInsertBefore = childNode.nextSibling;\n for (var i = 0; i < unbalancedTags.length; i++) {\n if (nodeToInsertBefore) {\n elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore);\n } else {\n elementVerified.appendChild(unbalancedTags[i]);\n }\n }\n }\n }\n } while (childNode = childNode.nextSibling);\n }\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport { stringTrim } from \"../string\";\nimport { makeArray } from \"../array\";\nimport { emptyDomNode, moveCleanedNodesToContainerElement } from \"./manipulation\";\nimport { jQueryInstance } from \"../jquery\";\nimport { forceRefresh } from \"./fixes\";\nimport * as virtualElements from \"./virtualElements\";\nimport options from \"../options\";\nvar none = [0, \"\", \"\"], table = [1, \"<table>\", \"</table>\"], tbody = [2, \"<table><tbody>\", \"</tbody></table>\"], colgroup = [2, \"<table><tbody></tbody><colgroup>\", \"</colgroup></table>\"], tr = [3, \"<table><tbody><tr>\", \"</tr></tbody></table>\"], select = [1, \"<select multiple='multiple'>\", \"</select>\"], fieldset = [1, \"<fieldset>\", \"</fieldset>\"], map = [1, \"<map>\", \"</map>\"], object = [1, \"<object>\", \"</object>\"], lookup = {\n \"area\": map,\n \"col\": colgroup,\n \"colgroup\": table,\n \"caption\": table,\n \"legend\": fieldset,\n \"thead\": table,\n \"tbody\": table,\n \"tfoot\": table,\n \"tr\": tbody,\n \"td\": tr,\n \"th\": tr,\n \"option\": select,\n \"optgroup\": select,\n \"param\": object\n}, supportsTemplateTag = options.document && \"content\" in options.document.createElement(\"template\");\nfunction getWrap(tags) {\n const m = tags.match(/^(?:<!--.*?-->\\s*?)*?<([a-z]+)[\\s>]/);\n return m && lookup[m[1]] || none;\n}\nfunction simpleHtmlParse(html, documentContext) {\n documentContext || (documentContext = document);\n var windowContext = documentContext[\"parentWindow\"] || documentContext[\"defaultView\"] || window;\n var tags = stringTrim(html).toLowerCase(), div = documentContext.createElement(\"div\"), wrap = getWrap(tags), depth = wrap[0];\n var markup = \"ignored<div>\" + wrap[1] + html + wrap[2] + \"</div>\";\n if (typeof windowContext[\"innerShiv\"] === \"function\") {\n div.appendChild(windowContext[\"innerShiv\"](markup));\n } else {\n div.innerHTML = markup;\n }\n while (depth--) {\n div = div.lastChild;\n }\n return makeArray(div.lastChild.childNodes);\n}\nfunction templateHtmlParse(html, documentContext) {\n if (!documentContext) {\n documentContext = document;\n }\n var template = documentContext.createElement(\"template\");\n template.innerHTML = html;\n return makeArray(template.content.childNodes);\n}\nfunction jQueryHtmlParse(html, documentContext) {\n if (jQueryInstance.parseHTML) {\n return jQueryInstance.parseHTML(html, documentContext) || [];\n } else {\n var elems = jQueryInstance.clean([html], documentContext);\n if (elems && elems[0]) {\n var elem = elems[0];\n while (elem.parentNode && elem.parentNode.nodeType !== 11) {\n elem = elem.parentNode;\n }\n if (elem.parentNode) {\n elem.parentNode.removeChild(elem);\n }\n }\n return elems;\n }\n}\nexport function parseHtmlFragment(html, documentContext) {\n return supportsTemplateTag ? templateHtmlParse(html, documentContext) : jQueryInstance ? jQueryHtmlParse(html, documentContext) : simpleHtmlParse(html, documentContext);\n}\nexport function parseHtmlForTemplateNodes(html, documentContext) {\n const nodes = parseHtmlFragment(html, documentContext);\n return nodes.length && nodes[0].parentElement || moveCleanedNodesToContainerElement(nodes);\n}\nexport function setHtml(node, html) {\n emptyDomNode(node);\n if (typeof html === \"function\") {\n html = html();\n }\n if (html !== null && html !== void 0) {\n if (typeof html !== \"string\") {\n html = html.toString();\n }\n if (jQueryInstance && !supportsTemplateTag) {\n jQueryInstance(node).html(html);\n } else {\n var parsedNodes = parseHtmlFragment(html, node.ownerDocument);\n if (node.nodeType === 8) {\n if (html === null) {\n virtualElements.emptyNode(node);\n } else {\n virtualElements.setDomNodeChildren(node, parsedNodes);\n }\n } else {\n for (var i = 0; i < parsedNodes.length; i++) {\n node.appendChild(parsedNodes[i]);\n }\n }\n }\n }\n}\nexport function setTextContent(element, textContent) {\n var value = typeof textContent === \"function\" ? textContent() : textContent;\n if (value === null || value === void 0) {\n value = \"\";\n }\n var innerTextNode = virtualElements.firstChild(element);\n if (!innerTextNode || innerTextNode.nodeType != 3 || virtualElements.nextSibling(innerTextNode)) {\n virtualElements.setDomNodeChildren(element, [element.ownerDocument.createTextNode(value)]);\n } else {\n innerTextNode.data = value;\n }\n forceRefresh(element);\n}\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport { tagNameLower } from \"./info\";\nimport * as domData from \"./data\";\nvar hasDomDataExpandoProperty = Symbol(\"Knockout selectExtensions hasDomDataProperty\");\nexport var selectExtensions = {\n optionValueDomDataKey: domData.nextKey(),\n readValue: function(element) {\n switch (tagNameLower(element)) {\n case \"option\":\n if (element[hasDomDataExpandoProperty] === true) {\n return domData.get(element, selectExtensions.optionValueDomDataKey);\n }\n return element.value;\n case \"select\":\n return element.selectedIndex >= 0 ? selectExtensions.readValue(element.options[element.selectedIndex]) : void 0;\n default:\n return element.value;\n }\n },\n writeValue: function(element, value, allowUnset) {\n switch (tagNameLower(element)) {\n case \"option\":\n if (typeof value === \"string\") {\n domData.set(element, selectExtensions.optionValueDomDataKey, void 0);\n if (hasDomDataExpandoProperty in element) {\n delete element[hasDomDataExpandoProperty];\n }\n element.value = value;\n } else {\n domData.set(element, selectExtensions.optionValueDomDataKey, value);\n element[hasDomDataExpandoProperty] = true;\n element.value = typeof value === \"number\" ? value : \"\";\n }\n break;\n case \"select\":\n if (value === \"\" || value === null) {\n value = void 0;\n }\n var selection = -1;\n for (let i = 0, n = element.options.length, optionValue; i < n; ++i) {\n optionValue = selectExtensions.readValue(element.options[i]);\n const strictEqual = optionValue === value;\n const blankEqual = optionValue === \"\" && value === void 0;\n const numericEqual = typeof value === \"number\" && Number(optionValue) === value;\n if (strictEqual || blankEqual || numericEqual) {\n selection = i;\n break;\n }\n }\n if (allowUnset || selection >= 0 || value === void 0 && element.size > 1) {\n element.selectedIndex = selection;\n }\n break;\n default:\n if (value === null || value === void 0) {\n value = \"\";\n }\n element.value = value;\n break;\n }\n }\n};\n", "// @tko/utils \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport options from \"./options\";\nimport { deferError } from \"./error\";\nvar taskQueue = [], taskQueueLength = 0, nextHandle = 1, nextIndexToProcess = 0, w = options.global;\nif (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {\n options.taskScheduler = function(callback) {\n var div = w.document.createElement(\"div\");\n new w.MutationObserver(callback).observe(div, { attributes: true });\n return function() {\n div.classList.toggle(\"foo\");\n };\n }(scheduledProcess);\n} else if (w && w.document && \"onreadystatechange\" in w.document.createElement(\"script\")) {\n options.taskScheduler = function(callback) {\n var script = document.createElement(\"script\");\n script.onreadystatechange = function() {\n script.onreadystatechange = null;\n document.documentElement.removeChild(script);\n script = null;\n callback();\n };\n document.documentElement.appendChild(script);\n };\n} else {\n options.taskScheduler = function(callback) {\n setTimeout(callback, 0);\n };\n}\nfunction processTasks() {\n if (taskQueueLength) {\n var mark = taskQueueLength, countMarks = 0;\n for (var task; nextIndexToProcess < taskQueueLength; ) {\n if (task = taskQueue[nextIndexToProcess++]) {\n if (nextIndexToProcess > mark) {\n if (++countMarks >= 5e3) {\n nextIndexToProcess = taskQueueLength;\n deferError(Error(\"'Too much recursion' after processing \" + countMarks + \" task groups.\"));\n break;\n }\n mark = taskQueueLength;\n }\n try {\n task();\n } catch (ex) {\n deferError(ex);\n }\n }\n }\n }\n}\nfunction scheduledProcess() {\n processTasks();\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0;\n}\nfunction scheduleTaskProcessing() {\n options.taskScheduler(scheduledProcess);\n}\nexport function schedule(func) {\n if (!taskQueueLength) {\n scheduleTaskProcessing();\n }\n taskQueue[taskQueueLength++] = func;\n return nextHandle++;\n}\nexport function cancel(handle) {\n var index = handle - (nextHandle - taskQueueLength);\n if (index >= nextIndexToProcess && index < taskQueueLength) {\n taskQueue[index] = null;\n }\n}\nexport function resetForTesting() {\n var length = taskQueueLength - nextIndexToProcess;\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0;\n return length;\n}\nexport { processTasks as runEarly };\n", "// @tko/observable \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport { isSubscribable } from \"./subscribableSymbol\";\nconst outerFrames = [];\nlet currentFrame;\nlet lastId = 0;\nfunction getId() {\n return ++lastId;\n}\nexport function begin(options) {\n outerFrames.push(currentFrame);\n currentFrame = options;\n}\nexport function end() {\n currentFrame = outerFrames.pop();\n}\nexport function registerDependency(subscribable) {\n if (currentFrame) {\n if (!isSubscribable(subscribable)) {\n throw new Error(\"Only subscribable things can act as dependencies\");\n }\n currentFrame.callback.call(currentFrame.callbackTarget, subscribable, subscribable._id || (subscribable._id = getId()));\n }\n}\nexport function ignore(callback, callbackTarget, callbackArgs) {\n try {\n begin();\n return callback.apply(callbackTarget, callbackArgs || []);\n } finally {\n end();\n }\n}\nexport function getDependenciesCount() {\n if (currentFrame) {\n return currentFrame.computed.getDependenciesCount();\n }\n}\nexport function getDependencies() {\n if (currentFrame) {\n return currentFrame.computed.getDependencies();\n }\n}\nexport function isInitial() {\n if (currentFrame) {\n return currentFrame.isInitial;\n }\n}\nexport { ignore as ignoreDependencies };\n", "// @tko/observable \uD83E\uDD4A 4.0.0-beta1.3 ESM\nexport const SUBSCRIBABLE_SYM = Symbol(\"Knockout Subscribable\");\nexport function isSubscribable(instance) {\n return instance && instance[SUBSCRIBABLE_SYM] || false;\n}\n", "// @tko/observable \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport { tasks } from \"@tko/utils\";\nexport function deferUpdates(target) {\n if (target._deferUpdates) {\n return;\n }\n target._deferUpdates = true;\n target.limit(function(callback) {\n let handle;\n let ignoreUpdates = false;\n return function() {\n if (!ignoreUpdates) {\n tasks.cancel(handle);\n handle = tasks.schedule(callback);\n try {\n ignoreUpdates = true;\n target.notifySubscribers(void 0, \"dirty\");\n } finally {\n ignoreUpdates = false;\n }\n }\n };\n });\n}\n", "// @tko/observable \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport {\n removeDisposeCallback,\n addDisposeCallback\n} from \"@tko/utils\";\nexport default class Subscription {\n constructor(target, observer, disposeCallback) {\n this._target = target;\n this._callback = observer.next;\n this._disposeCallback = disposeCallback;\n this._isDisposed = false;\n this._domNodeDisposalCallback = null;\n }\n dispose() {\n if (this._domNodeDisposalCallback) {\n removeDisposeCallback(this._node, this._domNodeDisposalCallback);\n }\n this._isDisposed = true;\n this._disposeCallback();\n }\n disposeWhenNodeIsRemoved(node) {\n this._node = node;\n addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));\n }\n unsubscribe() {\n this.dispose();\n }\n get closed() {\n return this._isDisposed;\n }\n}\n", "// @tko/observable \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport {\n options,\n objectForEach,\n throttle as throttleFn,\n debounce as debounceFn\n} from \"@tko/utils\";\nimport { deferUpdates } from \"./defer\";\nvar primitiveTypes = {\n \"undefined\": 1,\n \"boolean\": 1,\n \"number\": 1,\n \"string\": 1\n};\nexport function valuesArePrimitiveAndEqual(a, b) {\n var oldValueIsPrimitive = a === null || typeof a in primitiveTypes;\n return oldValueIsPrimitive ? a === b : false;\n}\nexport function applyExtenders(requestedExtenders) {\n var target = this;\n if (requestedExtenders) {\n objectForEach(requestedExtenders, function(key, value) {\n var extenderHandler = extenders[key];\n if (typeof extenderHandler === \"function\") {\n target = extenderHandler(target, value) || target;\n } else {\n options.onError(new Error(\"Extender not found: \" + key));\n }\n });\n }\n return target;\n}\nexport function notify(target, notifyWhen) {\n target.equalityComparer = notifyWhen == \"always\" ? null : valuesArePrimitiveAndEqual;\n}\nexport function deferred(target, option) {\n if (option !== true) {\n throw new Error(\"The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled.\");\n }\n deferUpdates(target);\n}\nexport function rateLimit(target, options2) {\n var timeout, method, limitFunction;\n if (typeof options2 === \"number\") {\n timeout = options2;\n } else {\n timeout = options2.timeout;\n method = options2.method;\n }\n target._deferUpdates = false;\n limitFunction = method === \"notifyWhenChangesStop\" ? debounceFn : throttleFn;\n target.limit(function(callback) {\n return limitFunction(callback, timeout);\n });\n}\nexport var extenders = {\n notify,\n deferred,\n rateLimit\n};\n", "// @tko/observable \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport {\n arrayRemoveItem,\n objectForEach,\n options\n} from \"@tko/utils\";\nimport Subscription from \"./Subscription\";\nimport { SUBSCRIBABLE_SYM } from \"./subscribableSymbol\";\nimport { applyExtenders } from \"./extenders\";\nimport * as dependencyDetection from \"./dependencyDetection\";\nexport { isSubscribable } from \"./subscribableSymbol\";\nexport const LATEST_VALUE = Symbol(\"Knockout latest value\");\nif (!Symbol.observable) {\n Symbol.observable = Symbol.for(\"@tko/Symbol.observable\");\n}\nexport function subscribable() {\n Object.setPrototypeOf(this, ko_subscribable_fn);\n ko_subscribable_fn.init(this);\n}\nexport var defaultEvent = \"change\";\nvar ko_subscribable_fn = {\n [SUBSCRIBABLE_SYM]: true,\n [Symbol.observable]() {\n return this;\n },\n init(instance) {\n instance._subscriptions = { change: [] };\n instance._versionNumber = 1;\n },\n subscribe(callback, callbackTarget, event) {\n const isTC39Callback = typeof callback === \"object\" && callback.next;\n event = event || defaultEvent;\n const observer = isTC39Callback ? callback : {\n next: callbackTarget ? callback.bind(callbackTarget) : callback\n };\n const subscriptionInstance = new Subscription(this, observer, () => {\n arrayRemoveItem(this._subscriptions[event], subscriptionInstance);\n if (this.afterSubscriptionRemove) {\n this.afterSubscriptionRemove(event);\n }\n });\n if (this.beforeSubscriptionAdd) {\n this.beforeSubscriptionAdd(event);\n }\n if (!this._subscriptions[event]) {\n this._subscriptions[event] = [];\n }\n this._subscriptions[event].push(subscriptionInstance);\n if (isTC39Callback && LATEST_VALUE in this) {\n observer.next(this[LATEST_VALUE]);\n }\n return subscriptionInstance;\n },\n notifySubscribers(valueToNotify, event) {\n event = event || defaultEvent;\n if (event === defaultEvent) {\n this.updateVersion();\n }\n if (this.hasSubscriptionsForEvent(event)) {\n const subs = event === defaultEvent && this._changeSubscriptions || [...this._subscriptions[event]];\n try {\n dependencyDetection.begin();\n for (let i = 0, subscriptionInstance; subscriptionInstance = subs[i]; ++i) {\n if (!subscriptionInstance._isDisposed) {\n subscriptionInstance._callback(valueToNotify);\n }\n }\n } finally {\n dependencyDetection.end();\n }\n }\n },\n getVersion() {\n return this._versionNumber;\n },\n hasChanged(versionToCheck) {\n return this.getVersion() !== versionToCheck;\n },\n updateVersion() {\n ++this._versionNumber;\n },\n hasSubscriptionsForEvent(event) {\n return this._subscriptions[event] && this._subscriptions[event].length;\n },\n getSubscriptionsCount(event) {\n if (event) {\n return this._subscriptions[event] && this._subscriptions[event].length || 0;\n } else {\n var total = 0;\n objectForEach(this._subscriptions, function(eventName, subscriptions) {\n if (eventName !== \"dirty\") {\n total += subscriptions.length;\n }\n });\n return total;\n }\n },\n isDifferent(oldValue, newValue) {\n return !this.equalityComparer || !this.equalityComparer(oldValue, newValue);\n },\n once(cb) {\n const subs = this.subscribe((nv) => {\n subs.dispose();\n cb(nv);\n });\n },\n when(test, returnValue) {\n const current = this.peek();\n const givenRv = arguments.length > 1;\n const testFn = typeof test === \"function\" ? test : (v) => v === test;\n if (testFn(current)) {\n return options.Promise.resolve(givenRv ? returnValue : current);\n }\n return new options.Promise((resolve, reject) => {\n const subs = this.subscribe((newValue) => {\n if (testFn(newValue)) {\n subs.dispose();\n resolve(givenRv ? returnValue : newValue);\n }\n });\n });\n },\n yet(test, ...args) {\n const testFn = typeof test === \"function\" ? test : (v) => v === test;\n const negated = (v) => !testFn(v);\n return this.when(negated, ...args);\n },\n next() {\n return new Promise((resolve) => this.once(resolve));\n },\n toString() {\n return \"[object Object]\";\n },\n extend: applyExtenders\n};\nObject.setPrototypeOf(ko_subscribable_fn, Function.prototype);\nsubscribable.fn = ko_subscribable_fn;\n", "// @tko/observable \uD83E\uDD4A 4.0.0-beta1.3 ESM\nimport {\n options,\n overwriteLengthPropertyIfSupported\n} from \"@tko/utils\";\nimport * as dependencyDetection from \"./dependencyDetection\";\nimport { deferUpdates } from \"./defer\";\nimport { subscribable, defaultEvent, LATEST_VALUE } from \"./subscribable\";\nimport { valuesArePrimitiveAndEqual } from \"./extenders\";\nexport function observable(initialValue) {\n function Observable() {\n if (arguments.length > 0) {\n if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {\n Observable.valueWillMutate();\n Observable[LATEST_VALUE] = arguments[0];\n Observable.valueHasMutated();\n }\n return this;\n } else {\n dependencyDetection.registerDependency(Observable);\n re