import "core-js/modules/es.error.cause.js";
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
import { META_HEAD, ClipboardData } from "./clipboardData.mjs";
import { normalizeRanges } from "../copyableRanges.mjs";
import { getDataByCoords, getHTMLByCoords } from "../../../utils/parseTable.mjs";
/**
 * Creates an object containing information about copy/cut action.
 *
 * @private
 */
export class CopyClipboardData extends ClipboardData {
  /**
   * @param {Core} instance Handsontable instance (used only while copying data).
   * @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} copyableRanges Cell
   * ranges related to instance of Handsontable (used only while copying data).
   */
  constructor(instance, copyableRanges) {
    super();
    /**
     * Sanitized data of "text/html" type inside the clipboard.
     *
     * @private
     * @type {string}
     */
    _defineProperty(this, "html", void 0);
    /**
     * Copied data stored as array of arrays.
     *
     * @private
     * @type {string[][]}
     */
    _defineProperty(this, "data", void 0);
    /**
     * Copied cell ranges related to instance of Handsontable.
     *
     * @private
     * @type {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>}
     */
    _defineProperty(this, "copyableRanges", void 0);
    const {
      rows,
      columns
    } = normalizeRanges(copyableRanges);
    this.html = [META_HEAD, getHTMLByCoords(instance, {
      rows,
      columns
    })].join('');
    this.data = getDataByCoords(instance, {
      rows,
      columns
    });
    this.copyableRanges = copyableRanges;
  }

  /**
   * Gets ranges related to copied part of Handsontable.
   *
   * @returns {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>}
   */
  getRanges() {
    return this.copyableRanges;
  }
}