{"version":3,"file":"dom-watcher.cjs","names":["MC","_interopRequireWildcard","require","MH","_dom","_domAlter","_domEvents","_log","_misc","_text","_validation","_callback","_xMap","_debug","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","DOMWatcher","create","config","getConfig","CONSTRUCTOR_KEY","reuse","_instances$get","myConfig","configStrKey","objToStrKey","omitKeys","_root","root","getBody","instance","instances","sGet","constructor","key","illegalConstructorError","logger","debug","Logger","name","logAtCreation","buffer","newXMap","_target","_categoryBitmask","_attributes","newSet","_addedTo","_removedFrom","allCallbacks","newMap","timer","mutationHandler","records","debug9","length","record","target","targetOf","recType","type","isElement","S_CHILD_LIST","child","addedNodes","operation","ADDED_BIT","removedNodes","REMOVED_BIT","S_ATTRIBUTES","attributeName","add","ATTRIBUTE_BIT","sizeOf","setTimer","size","values","shouldSkipOperation","debug10","processOperation","clear","observers","_observer","newMutationObserver","_isActive","createCallback","handler","options","_allCallbacks$get","remove","debug5","callback","wrapCallback","onRemove","deleteHandler","_options","setupOnMutation","userOptions","_config$_root","getOptions","waitForElement","isRemoved","activateObserver","skipInitial","_selector","childQueue","takeRecords","element","querySelectorAll","matches","initOperation","parentOf","bufferedOperation","diffOperation","getDiffOperation","invokeCallback","deleteKey","activeCategories","entry","deactivateObserver","categoryBitmask","selector","currentTargets","contains","push","lengthOf","mutationType","debug3","observe","subtree","_subtree","disconnect","_config$_root2","requestToSkip","getIgnoreMove","removedFrom","addedTo","requestFrom","from","requestTo","to","clearIgnoreMove","ignoreMove","onMutation","offMutation","_allCallbacks$get2","exports","SYMBOL","_config$root","_config$subtree","CATEGORIES_BITS","DOM_CATEGORIES_SPACE","bit","S_ADDED","S_REMOVED","S_ATTRIBUTE","_options$selector","_options$target","categories","validateStrList","cat","bitmask","isString","usageError","operationA","operationB","attributes","attr","currentTarget","invoke","catch","logError"],"sources":["../../../src/ts/watchers/dom-watcher.ts"],"sourcesContent":["/**\n * @module Watchers/DOMWatcher\n */\n\nimport * as MC from \"@lisn/globals/minification-constants\";\nimport * as MH from \"@lisn/globals/minification-helpers\";\n\nimport {\n  MutationCategory,\n  CommaSeparatedStr,\n  AtLeastOne,\n} from \"@lisn/globals/types\";\n\nimport { DOM_CATEGORIES_SPACE } from \"@lisn/utils/dom\";\nimport {\n  getIgnoreMove,\n  clearIgnoreMove,\n  ignoreMove,\n} from \"@lisn/utils/dom-alter\";\nimport { waitForElement } from \"@lisn/utils/dom-events\";\nimport { logError } from \"@lisn/utils/log\";\nimport { omitKeys } from \"@lisn/utils/misc\";\nimport { objToStrKey } from \"@lisn/utils/text\";\nimport { validateStrList } from \"@lisn/utils/validation\";\n\nimport {\n  CallbackHandler,\n  Callback,\n  wrapCallback,\n} from \"@lisn/modules/callback\";\nimport { newXMap } from \"@lisn/modules/x-map\";\n\nimport debug from \"@lisn/debug/debug\";\n\n/**\n * {@link DOMWatcher} listens for changes do the DOM tree. It's built on top of\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver | MutationObserver}.\n *\n * It manages registered callbacks globally and reuses MutationObservers for\n * more efficient performance.\n *\n * Each instance of DOMWatcher manages up to two MutationObservers: one\n * for `childList` changes and one for attribute changes, and it disconnects\n * them when there are no active callbacks for the relevant type.\n *\n * `characterData` and changes to base\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | Node}s\n * (non-{@link https://developer.mozilla.org/en-US/docs/Web/API/Element | Element})\n * are not supported.\n */\nexport class DOMWatcher {\n  /**\n   * Call the given handler whenever there's a matching mutation within this\n   * DOMWatcher's {@link DOMWatcherConfig.root | root}.\n   *\n   * If {@link OnMutationOptions.skipInitial | options.skipInitial} is `false`\n   * (default), _and_ {@link OnMutationOptions.selector | options.selector} is\n   * given, _and_ {@link OnMutationOptions.categories | options.categories}\n   * includes \"added\", the handler is also called (almost) immediately with all\n   * existing elements matching the selector under this DOMWatcher's\n   * {@link DOMWatcherConfig.root | root}.\n   *\n   * **IMPORTANT:** The same handler can _not_ be added multiple times, even if\n   * the options differ. If the handler has already been added, it is removed\n   * and re-added with the current options.\n   *\n   * @throws {@link Errors.LisnUsageError | LisnUsageError}\n   *                If the options are not valid.\n   */\n  readonly onMutation: (\n    handler: OnMutationHandler,\n    options?: OnMutationOptions,\n  ) => Promise<void>;\n\n  /**\n   * Removes a previously added handler.\n   */\n  readonly offMutation: (handler: OnMutationHandler) => void;\n\n  /**\n   * Ignore an upcoming moving/adding/removing of an element.\n   *\n   * The operation must complete within the next cycle, by the time\n   * MutationObserver calls us.\n   *\n   * Use this to prevent this instance of DOMWatcher from calling any callbacks\n   * that listen for relevant changes as a result of this operation, to prevent\n   * loops for example.\n   *\n   * **IMPORTANT:**\n   *\n   * Ignoring moving of an element from a parent _inside_ this DOMWatcher's\n   * root to another parent that's _outside_ the root, will work as expected,\n   * even though the \"adding to the new parent\" mutation will not be observed.\n   * This is because the element's current parent at the time of the mutation\n   * callback can be examined.\n   *\n   * However if you want to ignore moving of an element _from a parent outside\n   * this DOMWatcher's root_ you need to specify from: null since the \"removal\n   * from the old parent\" mutation would not be observed and there's no way to\n   * examine it's previous parent at the time the \"adding to the new parent\"\n   * mutation is observed.\n   *\n   * For this reason, setting `options.from` to be an element that's not under\n   * the root is internally treated the same as `options.from: null`.\n   */\n  readonly ignoreMove: (target: Element, options: MoveOptions) => void;\n\n  /**\n   * Creates a new instance of DOMWatcher with the given\n   * {@link DOMWatcherConfig}. It does not save it for future reuse.\n   */\n  static create(config?: DOMWatcherConfig) {\n    return new DOMWatcher(getConfig(config), CONSTRUCTOR_KEY);\n  }\n\n  /**\n   * Returns an existing instance of DOMWatcher with the given\n   * {@link DOMWatcherConfig}, or creates a new one.\n   *\n   * **NOTE:** It saves it for future reuse, so don't use this for temporary\n   * short-lived watchers.\n   */\n  static reuse(config?: DOMWatcherConfig) {\n    const myConfig = getConfig(config);\n    const configStrKey = objToStrKey(omitKeys(myConfig, { _root: null }));\n\n    const root = myConfig._root === MH.getBody() ? null : myConfig._root;\n    let instance = instances.get(root)?.get(configStrKey);\n    if (!instance) {\n      instance = new DOMWatcher(myConfig, CONSTRUCTOR_KEY);\n      instances.sGet(root).set(configStrKey, instance);\n    }\n\n    return instance;\n  }\n\n  private constructor(\n    config: DOMWatcherConfigInternal,\n    key: typeof CONSTRUCTOR_KEY,\n  ) {\n    if (key !== CONSTRUCTOR_KEY) {\n      throw MH.illegalConstructorError(\"DOMWatcher.create\");\n    }\n\n    const logger = debug\n      ? new debug.Logger({ name: \"DOMWatcher\", logAtCreation: config })\n      : null;\n\n    const buffer = newXMap<Element, MutationOperationInternal>((t) => ({\n      _target: t,\n      _categoryBitmask: 0,\n      _attributes: MH.newSet(),\n      _addedTo: null,\n      _removedFrom: null,\n    }));\n\n    const allCallbacks = MH.newMap<\n      OnMutationHandler,\n      {\n        _callback: OnMutationCallback;\n        _options: OnMutationOptionsInternal;\n      }\n    >();\n\n    // ----------\n\n    let timer: ReturnType<typeof setTimeout> | null = null;\n    const mutationHandler = (records: MutationRecord[]) => {\n      debug: logger?.debug9(`Got ${records.length} new records`, records);\n\n      for (const record of records) {\n        const target = MH.targetOf(record);\n        const recType = record.type;\n\n        /* istanbul ignore next */\n        if (!MH.isElement(target)) {\n          continue;\n        }\n\n        if (recType === MC.S_CHILD_LIST) {\n          for (const child of record.addedNodes) {\n            if (MH.isElement(child)) {\n              const operation = buffer.sGet(child);\n              operation._addedTo = target;\n              operation._categoryBitmask |= ADDED_BIT;\n            }\n          }\n\n          for (const child of record.removedNodes) {\n            if (MH.isElement(child)) {\n              const operation = buffer.sGet(child);\n              operation._removedFrom = target;\n              operation._categoryBitmask |= REMOVED_BIT;\n            }\n          }\n\n          //\n        } else if (recType === MC.S_ATTRIBUTES && record.attributeName) {\n          const operation = buffer.sGet(target);\n          operation._attributes.add(record.attributeName);\n          operation._categoryBitmask |= ATTRIBUTE_BIT;\n        }\n      }\n\n      // Schedule flushing of the buffer asynchronously so that we can combine\n      // the records from the two MutationObservers.\n      if (!timer && MH.sizeOf(buffer)) {\n        timer = MH.setTimer(() => {\n          debug: logger?.debug9(`Processing ${buffer.size} operations`);\n          for (const operation of buffer.values()) {\n            if (shouldSkipOperation(operation)) {\n              debug: logger?.debug10(\"Skipping operation\", operation);\n            } else {\n              processOperation(operation);\n            }\n          }\n\n          buffer.clear();\n          timer = null;\n        }, 0);\n      }\n    };\n\n    const observers: Record<MutationType, MyObserver> = {\n      [MC.S_CHILD_LIST]: {\n        _observer: MH.newMutationObserver(mutationHandler),\n        _isActive: false,\n      },\n      [MC.S_ATTRIBUTES]: {\n        _observer: MH.newMutationObserver(mutationHandler),\n        _isActive: false,\n      },\n    };\n\n    // ----------\n\n    const createCallback = (\n      handler: OnMutationHandler,\n      options: OnMutationOptionsInternal,\n    ): OnMutationCallback => {\n      MH.remove(allCallbacks.get(handler)?._callback);\n\n      debug: logger?.debug5(\"Adding/updating handler\", options);\n      const callback = wrapCallback(handler);\n      callback.onRemove(() => deleteHandler(handler));\n\n      allCallbacks.set(handler, { _callback: callback, _options: options });\n      return callback;\n    };\n\n    // ----------\n\n    const setupOnMutation = async (\n      handler: OnMutationHandler,\n      userOptions: OnMutationOptions | undefined,\n    ) => {\n      const options = getOptions(userOptions ?? {});\n      const callback = createCallback(handler, options);\n\n      let root = config._root ?? MH.getBody();\n      if (!root) {\n        root = await waitForElement(MH.getBody);\n      } else {\n        // So that the call is always async\n        await null;\n      }\n\n      if (callback.isRemoved()) {\n        return;\n      }\n\n      if (options._categoryBitmask & (ADDED_BIT | REMOVED_BIT)) {\n        activateObserver(root, MC.S_CHILD_LIST);\n      }\n\n      if (options._categoryBitmask & ATTRIBUTE_BIT) {\n        activateObserver(root, MC.S_ATTRIBUTES);\n      }\n\n      if (\n        userOptions?.skipInitial ||\n        !options._selector ||\n        !(options._categoryBitmask & ADDED_BIT)\n      ) {\n        return;\n      }\n\n      // As some of the matching elements that currently exist in the root may\n      // have just been added and therefore in the MutationObserver's queue, to\n      // avoid calling the handler with those entries twice, we empty its queue\n      // now and process it (which would also invoke the newly added callback).\n      // Then we skip any elements returned in querySelectorAll that were in\n      // the queue.\n\n      const childQueue = observers[MC.S_CHILD_LIST]._observer.takeRecords();\n      mutationHandler(childQueue);\n\n      for (const element of [\n        ...MH.querySelectorAll(root, options._selector),\n        ...(root.matches(options._selector) ? [root] : []),\n      ]) {\n        const initOperation: MutationOperationInternal = {\n          _target: element,\n          _categoryBitmask: ADDED_BIT,\n          _attributes: MH.newSet(),\n          _addedTo: MH.parentOf(element),\n          _removedFrom: null,\n        };\n\n        const bufferedOperation = buffer.get(element);\n        const diffOperation = getDiffOperation(\n          initOperation,\n          bufferedOperation,\n        );\n\n        if (diffOperation) {\n          if (shouldSkipOperation(diffOperation)) {\n            debug: logger?.debug10(\"Skipping operation\", diffOperation);\n          } else {\n            debug: logger?.debug5(\"Calling initially with\", diffOperation);\n            await invokeCallback(callback, diffOperation);\n          }\n        }\n      }\n    };\n\n    // ----------\n\n    const deleteHandler = (handler: OnMutationHandler) => {\n      MH.deleteKey(allCallbacks, handler);\n\n      let activeCategories = 0;\n      for (const entry of allCallbacks.values()) {\n        activeCategories |= entry._options._categoryBitmask;\n      }\n\n      if (!(activeCategories & (ADDED_BIT | REMOVED_BIT))) {\n        deactivateObserver(MC.S_CHILD_LIST);\n      }\n\n      if (!(activeCategories & ATTRIBUTE_BIT)) {\n        deactivateObserver(MC.S_ATTRIBUTES);\n      }\n    };\n\n    // ----------\n\n    const processOperation = (operation: MutationOperationInternal) => {\n      debug: logger?.debug10(\"Processing operation\", operation);\n\n      for (const entry of allCallbacks.values()) {\n        const categoryBitmask = entry._options._categoryBitmask;\n        const target = entry._options._target;\n        const selector = entry._options._selector;\n\n        if (!(operation._categoryBitmask & categoryBitmask)) {\n          debug: logger?.debug10(`Category does not match: ${categoryBitmask}`);\n          continue;\n        }\n\n        const currentTargets = [];\n        if (target) {\n          if (!operation._target.contains(target)) {\n            debug: logger?.debug10(\"Target does not match\", target);\n            continue;\n          }\n\n          currentTargets.push(target);\n        }\n\n        if (selector) {\n          const matches = [...MH.querySelectorAll(operation._target, selector)];\n\n          if (operation._target.matches(selector)) {\n            matches.push(operation._target);\n          }\n\n          if (!MH.lengthOf(matches)) {\n            debug: logger?.debug10(`Selector does not match: ${selector}`);\n            continue;\n          }\n\n          currentTargets.push(...matches);\n        }\n\n        invokeCallback(entry._callback, operation, currentTargets);\n      }\n    };\n\n    // ----------\n\n    const activateObserver = (root: Element, mutationType: MutationType) => {\n      if (!observers[mutationType]._isActive) {\n        debug: logger?.debug3(\n          `Activating mutation observer for '${mutationType}'`,\n        );\n        observers[mutationType]._observer.observe(root, {\n          [mutationType]: true,\n          subtree: config._subtree,\n        });\n        observers[mutationType]._isActive = true;\n      }\n    };\n\n    // ----------\n\n    const deactivateObserver = (mutationType: MutationType) => {\n      if (observers[mutationType]._isActive) {\n        debug: logger?.debug3(\n          `Disconnecting mutation observer for '${mutationType}'`,\n        );\n        observers[mutationType]._observer.disconnect();\n        observers[mutationType]._isActive = false;\n      }\n    };\n\n    // ----------\n\n    const shouldSkipOperation = (\n      operation: MutationOperationInternal,\n    ): boolean => {\n      const target = operation._target;\n      const requestToSkip = getIgnoreMove(target);\n      if (!requestToSkip) {\n        return false;\n      }\n\n      const removedFrom = operation._removedFrom;\n      const addedTo = MH.parentOf(target);\n      const requestFrom = requestToSkip.from;\n      const requestTo = requestToSkip.to;\n\n      const root = config._root ?? MH.getBody();\n      // If \"from\" is currently outside our root, we may not have seen a\n      // removal operation.\n      if (\n        (removedFrom === requestFrom || !root.contains(requestFrom)) &&\n        addedTo === requestTo\n      ) {\n        clearIgnoreMove(target);\n        return true;\n      }\n\n      return false;\n    };\n\n    // ----------\n\n    this.ignoreMove = ignoreMove;\n\n    // ----------\n\n    this.onMutation = setupOnMutation;\n\n    // ----------\n\n    this.offMutation = (handler) => {\n      debug: logger?.debug5(\"Removing handler\");\n      MH.remove(allCallbacks.get(handler)?._callback);\n    };\n  }\n}\n\n/**\n * @interface\n */\nexport type DOMWatcherConfig = {\n  /**\n   * The root element to observe for changes.\n   *\n   * It cannot be overridden on a per-callback basis.\n   *\n   * @defaultValue document.body\n   */\n  root?: Element | null;\n\n  /**\n   * Whether to observe root's subtree for changes or just direct descendants.\n   *\n   * It cannot be overridden on a per-callback basis.\n   *\n   * @defaultValue true\n   */\n  subtree?: boolean;\n};\n\n/**\n * @interface\n */\nexport type OnMutationOptions = {\n  /**\n   * If this is given, then the handler would only be called for operations\n   * where the target is _either_ the given element or an ancestor of it, i.e.\n   * it {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/contains | Node:contains} it.\n   *\n   * @defaultValue undefined\n   */\n  target?: Element;\n\n  /**\n   * If this is given, then the handler would only be called for operations\n   * where the target matches the given selector _or contains an element\n   * matching the given selector_.\n   *\n   * @defaultValue undefined\n   */\n  selector?: string;\n\n  /**\n   * Specifies a list of {@link MutationCategory}s to target for.\n   *\n   * If not given, then the handler is called for any of the supported\n   * mutations.\n   *\n   * It can be a comma-separated list of category names or an array of such\n   * names.\n   *\n   * @defaultValue undefined\n   */\n  categories?: CommaSeparatedStr<MutationCategory> | MutationCategory[];\n\n  /**\n   * Do not call the handler until there's a future matching mutation.\n   *\n   * By default, if `selector` is given, and `categories` includes `added`, we\n   * call the handler (almost) immediately with all elements matching selector\n   * relative to this DOMWatcher's root.\n   *\n   * The initial operation will contain just the element and\n   * `addedTo: <current parent>`.\n   *\n   * @defaultValue false\n   */\n  skipInitial?: boolean;\n};\n\nexport type MoveOptions = AtLeastOne<{\n  /**\n   * If to is missing or null, it's a removal operation.\n   */\n  to: Element | null;\n\n  /**\n   * If from is missing or null, it's an insertion operation.\n   */\n  from: Element | null;\n}>;\n\nexport type MutationOperation = {\n  /**\n   * The target that was changed.\n   */\n  target: Element;\n\n  /**\n   * The target that the callback was interested in.\n   *\n   * If `selector` is given as part of {@link OnMutationOptions}, then\n   * `currentTarget` will point to the target that matched the selector\n   * starting at the operation's `target` as the root. If the operation's\n   * `target` contains more than one element matching selector, the callback\n   * will be called once for _each_ matching child.\n   *\n   * If `target` is given as part of {@link OnMutationOptions}, then\n   * `currentTarget` will be that element.\n   */\n  currentTarget: Element;\n\n  /**\n   * The list of attributes that were changed in this round.\n   */\n  attributes: Set<string>;\n\n  /**\n   * The element that the target was added to, i.e. it's new parent. It is null\n   * if the target was not moved to a new element _during this round_. It does\n   * not mean that this is its current parent.\n   */\n  addedTo: Element | null;\n\n  /**\n   * The element that the target was removed from, i.e. it's old parent. It is\n   * null if the target was not removed from a previous element _during this\n   * round_. It does not mean it did not previously have a parent, but that its\n   * removal was not observed.\n   */\n  removedFrom: Element | null;\n};\n\n/**\n * The handler is invoked with one argument:\n *\n * - a {@link MutationOperation} for a set of mutations related to a particular\n *   element\n *\n * The handler could be invoked multiple times in each \"round\" (cycle of event\n * loop) if there are mutation operations for more than one element that match\n * the supplied {@link OnMutationOptions}.\n */\nexport type OnMutationHandlerArgs = [MutationOperation];\nexport type OnMutationCallback = Callback<OnMutationHandlerArgs>;\nexport type OnMutationHandler =\n  | CallbackHandler<OnMutationHandlerArgs>\n  | OnMutationCallback;\n\n// ----------------------------------------\n\ntype DOMWatcherConfigInternal = {\n  _root: Element | null;\n  _subtree: boolean;\n};\n\ntype OnMutationOptionsInternal = {\n  _target: Element | null;\n  _selector: string;\n  _categoryBitmask: number;\n};\n\ntype MyObserver = {\n  _observer: MutationObserver;\n  _isActive: boolean;\n};\n\ntype MutationType = \"childList\" | \"attributes\";\n\ntype MutationOperationInternal = {\n  _target: Element;\n  _attributes: Set<string>;\n  _addedTo: Element | null;\n  _removedFrom: Element | null;\n  _categoryBitmask: number;\n};\n\nconst CONSTRUCTOR_KEY: unique symbol = MC.SYMBOL() as typeof CONSTRUCTOR_KEY;\nconst instances = newXMap<Element | null, Map<string, DOMWatcher>>(() =>\n  MH.newMap(),\n);\n\nconst getConfig = (\n  config: DOMWatcherConfig | undefined,\n): DOMWatcherConfigInternal => {\n  return {\n    _root: config?.root ?? null,\n    _subtree: config?.subtree ?? true,\n  };\n};\n\nconst CATEGORIES_BITS = DOM_CATEGORIES_SPACE.bit;\nconst ADDED_BIT = CATEGORIES_BITS[MC.S_ADDED];\nconst REMOVED_BIT = CATEGORIES_BITS[MC.S_REMOVED];\nconst ATTRIBUTE_BIT = CATEGORIES_BITS[MC.S_ATTRIBUTE];\n\n// ----------------------------------------\n\nconst getOptions = (options: OnMutationOptions): OnMutationOptionsInternal => {\n  let categoryBitmask = 0;\n  const categories = validateStrList(\n    \"categories\",\n    options.categories,\n    DOM_CATEGORIES_SPACE.has,\n  );\n\n  if (categories) {\n    for (const cat of categories) {\n      categoryBitmask |= CATEGORIES_BITS[cat];\n    }\n  } else {\n    categoryBitmask = DOM_CATEGORIES_SPACE.bitmask; // default: all\n  }\n\n  const selector = options.selector ?? \"\";\n  if (!MH.isString(selector)) {\n    throw MH.usageError(\"'selector' must be a string\");\n  }\n\n  return {\n    _categoryBitmask: categoryBitmask,\n    _target: options.target ?? null,\n    _selector: selector,\n  };\n};\n\nconst getDiffOperation = (\n  operationA: MutationOperationInternal,\n  operationB: MutationOperationInternal | undefined,\n): MutationOperationInternal | null => {\n  if (!operationB || operationA._target !== operationB._target) {\n    return operationA;\n  }\n\n  const attributes = MH.newSet<string>();\n  for (const attr of operationA._attributes) {\n    if (!operationB._attributes.has(attr)) {\n      attributes.add(attr);\n    }\n  }\n\n  const categoryBitmask =\n    operationA._categoryBitmask ^ operationB._categoryBitmask;\n\n  const addedTo =\n    operationA._addedTo === operationB._addedTo ? null : operationA._addedTo;\n\n  const removedFrom =\n    operationA._removedFrom === operationB._removedFrom\n      ? null\n      : operationA._removedFrom;\n\n  if (!MH.sizeOf(attributes) && !categoryBitmask && !addedTo && !removedFrom) {\n    return null;\n  }\n\n  return {\n    _target: operationA._target,\n    _categoryBitmask: categoryBitmask,\n    _attributes: attributes,\n    _addedTo: addedTo,\n    _removedFrom: removedFrom,\n  };\n};\n\nconst invokeCallback = (\n  callback: OnMutationCallback,\n  operation: MutationOperationInternal,\n  currentTargets: Element[] = [],\n) => {\n  if (!MH.lengthOf(currentTargets)) {\n    currentTargets = [operation._target];\n  }\n\n  for (const currentTarget of currentTargets) {\n    callback\n      .invoke({\n        target: operation._target,\n        currentTarget,\n        attributes: operation._attributes,\n        addedTo: operation._addedTo,\n        removedFrom: operation._removedFrom,\n      })\n      .catch(logError);\n  }\n};\n"],"mappings":";;;;;;AAIA,IAAAA,EAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,EAAA,GAAAF,uBAAA,CAAAC,OAAA;AAQA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAKA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAEA,IAAAS,SAAA,GAAAT,OAAA;AAKA,IAAAU,KAAA,GAAAV,OAAA;AAEA,IAAAW,MAAA,GAAAC,sBAAA,CAAAZ,OAAA;AAAsC,SAAAY,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAd,wBAAAc,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAlB,uBAAA,YAAAA,CAAAc,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,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