// packages/block-editor/src/utils/object.ts
function setImmutably(object, path, value) {
  const pathArray = Array.isArray(path) ? [...path] : [path];
  const result = Array.isArray(object) ? [...object] : { ...object };
  const leaf = pathArray.pop();
  let prev = result;
  for (const key of pathArray) {
    const lvl = prev[key];
    prev[key] = prev = Array.isArray(lvl) ? [...lvl] : { ...lvl };
  }
  prev[leaf] = value;
  return result;
}
var getValueFromObjectPath = (object, path, defaultValue) => {
  const arrayPath = Array.isArray(path) ? path : path.split(".");
  let value = object;
  arrayPath.forEach((fieldName) => {
    value = value?.[fieldName];
  });
  return value ?? defaultValue;
};
function uniqByProperty(array, property) {
  const seen = /* @__PURE__ */ new Set();
  return array.filter((item) => {
    const value = item[property];
    return seen.has(value) ? false : seen.add(value);
  });
}
export {
  getValueFromObjectPath,
  setImmutably,
  uniqByProperty
};
//# sourceMappingURL=object.mjs.map
