: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ createUndoManager: () => (/* binding */ createUndoManager)
/* harmony import */ var _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(923);
/* harmony import */ var _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0__);
/** @typedef {import('./types').HistoryRecord} HistoryRecord */
/** @typedef {import('./types').HistoryChange} HistoryChange */
/** @typedef {import('./types').HistoryChanges} HistoryChanges */
/** @typedef {import('./types').UndoManager} UndoManager */
* Merge changes for a single item into a record of changes.
* @param {Record< string, HistoryChange >} changes1 Previous changes
* @param {Record< string, HistoryChange >} changes2 NextChanges
* @return {Record< string, HistoryChange >} Merged changes
function mergeHistoryChanges(changes1, changes2) {
* @type {Record< string, HistoryChange >}
Object.entries(changes2).forEach(([key, value]) => {
* Adds history changes for a single item into a record of changes.
* @param {HistoryRecord} record The record to merge into.
* @param {HistoryChanges} changes The changes to merge.
const addHistoryChangesIntoRecord = (record, changes) => {
const existingChangesIndex = record?.findIndex(({
return typeof recordIdentifier === 'string' ? recordIdentifier === changes.id : _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default()(recordIdentifier, changes.id);
const nextRecord = [...record];
if (existingChangesIndex !== -1) {
// If the edit is already in the stack leave the initial "from" value.
nextRecord[existingChangesIndex] = {
changes: mergeHistoryChanges(nextRecord[existingChangesIndex].changes, changes.changes)
nextRecord.push(changes);
* Creates an undo manager.
* @return {UndoManager} Undo manager.
function createUndoManager() {
* @type {HistoryRecord[]}
const dropPendingRedos = () => {
history = history.slice(0, offset || undefined);
const appendStagedRecordToLatestHistoryRecord = () => {
const index = history.length === 0 ? 0 : history.length - 1;
let latestRecord = (_history$index = history[index]) !== null && _history$index !== void 0 ? _history$index : [];
stagedRecord.forEach(changes => {
latestRecord = addHistoryChangesIntoRecord(latestRecord, changes);
history[index] = latestRecord;
* Checks whether a record is empty.
* A record is considered empty if it the changes keep the same values.
* Also updates to function values are ignored.
* @param {HistoryRecord} record
* @return {boolean} Whether the record is empty.
const isRecordEmpty = record => {
const filteredRecord = record.filter(({
return Object.values(changes).some(({
}) => typeof from !== 'function' && typeof to !== 'function' && !_wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default()(from, to));
return !filteredRecord.length;
* Record changes into the history.
* @param {HistoryRecord=} record A record of changes to record.
* @param {boolean} isStaged Whether to immediately create an undo point or not.
addRecord(record, isStaged = false) {
const isEmpty = !record || isRecordEmpty(record);
record.forEach(changes => {
stagedRecord = addHistoryChangesIntoRecord(stagedRecord, changes);
if (stagedRecord.length) {
appendStagedRecordToLatestHistoryRecord();
if (stagedRecord.length) {
appendStagedRecordToLatestHistoryRecord();
const undoRecord = history[history.length - 1 + offset];
const redoRecord = history[history.length + offset];
return !!history[history.length - 1 + offset];
return !!history[history.length + offset];
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
* Given an instance of EquivalentKeyMap, returns its internal value pair tuple
* for a key, if one exists. The tuple members consist of the last reference
* value for the key (used in efficient subsequent lookups) and the value
* assigned for the key at the leaf node.
* @param {EquivalentKeyMap} instance EquivalentKeyMap instance.
* @param {*} key The key for which to return value pair.
* @return {?Array} Value pair, if exists.
function getValuePair(instance, key) {
var _map = instance._map,
_arrayTreeMap = instance._arrayTreeMap,
_objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the
// value, which can be used to shortcut immediately to the value.
} // Sort keys to ensure stable retrieval from tree.
var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value.
var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap;
for (var i = 0; i < properties.length; i++) {
var property = properties[i];
var propertyValue = key[property];
map = map.get(propertyValue);
var valuePair = map.get('_ekm_value');
} // If reached, it implies that an object-like key was set with another
// reference, so delete the reference and replace with the current.
_map.delete(valuePair[0]);
map.set('_ekm_value', valuePair);
_map.set(key, valuePair);
* Variant of a Map object which enables lookup by equivalent (deeply equal)
* Constructs a new instance of EquivalentKeyMap.
* @param {Iterable.<*>} iterable Initial pair of key, value for map.
function EquivalentKeyMap(iterable) {
_classCallCheck(this, EquivalentKeyMap);
if (iterable instanceof EquivalentKeyMap) {
// Map#forEach is only means of iterating with support for IE11.
iterable.forEach(function (value, key) {
iterablePairs.push([key, value]);
iterable = iterablePairs;
for (var i = 0; i < iterable.length; i++) {
this.set(iterable[i][0], iterable[i][1]);
* Accessor property returning the number of elements.
* @return {number} Number of elements.
_createClass(EquivalentKeyMap, [{
* Add or update an element with a specified key and value.
* @param {*} key The key of the element to add.
* @param {*} value The value of the element to add.
* @return {EquivalentKeyMap} Map instance.
value: function set(key, value) {
// Shortcut non-object-like to set on internal Map.
if (key === null || _typeof(key) !== 'object') {
this._map.set(key, value);
} // Sort keys to ensure stable assignment into tree.
var properties = Object.keys(key).sort();
var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value.
var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap;
for (var i = 0; i < properties.length; i++) {
var property = properties[i];
if (!map.has(property)) {
map.set(property, new EquivalentKeyMap());
var propertyValue = key[property];
if (!map.has(propertyValue)) {
map.set(propertyValue, new EquivalentKeyMap());
map = map.get(propertyValue);
} // If an _ekm_value exists, there was already an equivalent key. Before
// overriding, ensure that the old key reference is removed from map to
// avoid memory leak of accumulating equivalent keys. This is, in a
// sense, a poor man's WeakMap, while still enabling iterability.
var previousValuePair = map.get('_ekm_value');
this._map.delete(previousValuePair[0]);
map.set('_ekm_value', valuePair);
this._map.set(key, valuePair);
* Returns a specified element.
* @param {*} key The key of the element to return.
* @return {?*} The element associated with the specified key or undefined
* if the key can't be found.
value: function get(key) {
// Shortcut non-object-like to get from internal Map.
if (key === null || _typeof(key) !== 'object') {
return this._map.get(key);
var valuePair = getValuePair(this, key);
* Returns a boolean indicating whether an element with the specified key
* @param {*} key The key of the element to test for presence.
* @return {boolean} Whether an element with the specified key exists.
value: function has(key) {
if (key === null || _typeof(key) !== 'object') {
return this._map.has(key);
} // Test on the _presence_ of the pair, not its value, as even undefined
// can be a valid member value for a key.
return getValuePair(this, key) !== undefined;
* Removes the specified element.
* @param {*} key The key of the element to remove.
* @return {boolean} Returns true if an element existed and has been
* removed, or false if the element does not exist.
value: function _delete(key) {
} // This naive implementation will leave orphaned child trees. A better
// implementation should traverse and remove orphans.
this.set(key, undefined);
* Executes a provided function once per each key/value pair, in insertion
* @param {Function} callback Function to execute for each element.
* @param {*} thisArg Value to use as `this` when executing
value: function forEach(callback) {
var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
this._map.forEach(function (value, key) {
// Unwrap value from object-like value pair.
if (key !== null && _typeof(key) === 'object') {
callback.call(thisArg, value, key, _this);
value: function clear() {
this._arrayTreeMap = new Map();
this._objectTreeMap = new Map();
module.exports = EquivalentKeyMap;