(function (global) {
  global.ARQ = global.ARQ || {};
  /**
   * Registro append-only de acciones (no sustituye undo por snapshots).
   */
  ARQ.actionLog = {
    append: function (sheet, accion, capaId, parametros) {
      if (!sheet) return;
      sheet.editor_acciones = sheet.editor_acciones || [];
      sheet.editor_acciones.push({
        accion: accion,
        capa_id: capaId != null ? capaId : null,
        parametros: parametros || {},
        t: Date.now(),
      });
      while (sheet.editor_acciones.length > 500) {
        sheet.editor_acciones.shift();
      }
    },
  };
})(typeof window !== 'undefined' ? window : this);
