import { h, F as Fragment, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-090d31ca.js';
import { c as MapToComponentField, M as MapToComponentMethod, V as VegaSlimmer, I as InjectVegaSlimmer } from './global-slimmer-registry-17c4efd4.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-46020a03.js';
import { T as TranslationSlimmer } from './translation-slimmer-32353a1c.js';
import { s as sanitizeVegaComponent } from './component-7d906393.js';
import { V as VegaInternalIconManager } from './internal-icon-manager-bd80b3bb.js';
import { A as AlignCenter, a as AlignJustify, b as AlignLeft, c as AlignRight } from './align-left-7f959adf.js';
import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-2fcba81b.js';
import { i as VegaChange, H as VegaFocus, a as VegaClick, c as VegaPopoverShow, V as VegaDropdownClick, v as VegaDropdownShow, w as VegaDropdownHide } from './vega-event-id-578c6c6d.js';
import { D as DomNodeSubjectObserverFactory } from './dom-node-subject-observer-factory-3897e95b.js';
import { c as createEnterKeyHandlerToTriggerClick } from './accessibility-524cabd2.js';
import { Z as RTE_TABLE_BORDER_STYLES, T as TableSettingType, _ as ColumnOperationType, O as ToggleHeaderTableColumnStrategy, $ as getSelectedCellsBoundary, v as getTableColumnCount, m as getParentBlockByType, h as RTETableBlock, a0 as RowOperationType, k as RTETableHeadBlock, l as RTETableBodyBlock, a1 as SplitCellOperationType, a2 as isRectangularSelection, z as MergeCellsOperationType, a3 as getAdjacentCell } from './split-cell-operation-ecede668.js';
import { V as VegaInternalThemeManager } from './dark-mode-style-controller-e9a6b097.js';
import { D as DarkModeStateControllerSlimmer } from './dark-mode-state-controller-slimmer-f2b4f8ed.js';
import { f as findParent, a as arrayToClassString } from './ui-64815a12.js';
import { K as KeyboardManagerSlimmer } from './keyboard-manager-slimmer-012a9a9b.js';
import { c as chevronDown } from './chevron-down-4a75d28e.js';
import { b as VegaInternalRTEExtensionTableCellSelectionChange } from './vega-internal-event-id-913e8be6.js';
import { i as isArrayEqual } from './array-7888f339.js';
import './internal-translation-controller-d8217d93.js';
import './change-manager-6a7eb88c.js';
import './static-subject-title-52f93124.js';
import './icon-manager-539d7cf7.js';
import './create-public-api-runtime-metrics-slimmer-aaadaa08.js';
import './dynamic-slimmer-90b8af32.js';
import './misc-9fdbcfbb.js';
import './internal-vega-event-manager-1ac5ee9a.js';
import './vega-env-manager-8f8dc473.js';
import './feature-flag-controller-30f7b625.js';
import './index-bfc6dfa2.js';
import './observer-3959f9dd.js';
import './code-block-7e9b404c.js';
import './string-a953eafc.js';
import './type-guard-ed1004cc.js';
import './breakpoints-d9faf11c.js';
import './ui-93922c59.js';
import './typography-396de03f.js';
import './object-0c277f57.js';
import './content-state-2f432ada.js';
import './tinycolor-polyfill-7be0eb93.js';
import './vega-nonce-manager-497e5eb5.js';
import './try-get-document-bef0f526.js';
import './index-3b327f29.js';
import './keyboard-manager-26e2fc32.js';
import './number-4398f2e1.js';

const AlignTop = {
  icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M24 0H488c13.3 0 24 10.7 24 24s-10.7 24-24 24H24C10.7 48 0 37.3 0 24S10.7 0 24 0zM64 176c0-26.5 21.5-48 48-48h64c26.5 0 48 21.5 48 48V464c0 26.5-21.5 48-48 48H112c-26.5 0-48-21.5-48-48V176zm224 0c0-26.5 21.5-48 48-48h64c26.5 0 48 21.5 48 48V336c0 26.5-21.5 48-48 48H336c-26.5 0-48-21.5-48-48V176z"/></svg>`,
};

const AlignBottom = {
  icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M24 512l464 0c13.3 0 24-10.7 24-24s-10.7-24-24-24L24 464c-13.3 0-24 10.7-24 24s10.7 24 24 24zM64 336c0 26.5 21.5 48 48 48h64c26.5 0 48-21.5 48-48l0-288c0-26.5-21.5-48-48-48H112C85.5 0 64 21.5 64 48l0 288zm224 0c0 26.5 21.5 48 48 48l64 0c26.5 0 48-21.5 48-48l0-160c0-26.5-21.5-48-48-48H336c-26.5 0-48 21.5-48 48l0 160z"/></svg>`,
};

const AlignMiddle = {
  icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M64 80c0-26.5 21.5-48 48-48h64c26.5 0 48 21.5 48 48V232h64V144c0-26.5 21.5-48 48-48h64c26.5 0 48 21.5 48 48v88h40c13.3 0 24 10.7 24 24s-10.7 24-24 24H448v88c0 26.5-21.5 48-48 48H336c-26.5 0-48-21.5-48-48V280H224V432c0 26.5-21.5 48-48 48H112c-26.5 0-48-21.5-48-48V280H24c-13.3 0-24-10.7-24-24s10.7-24 24-24H64V80z"/></svg>`,
};

const ObjectsAlignCenterHorizontal = {
  icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill='currentColor' d="M400 176L48 176l0-64 352 0 0 64zm48-64c0-26.5-21.5-48-48-48L248 64l0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40L48 64C21.5 64 0 85.5 0 112l0 64c0 26.5 21.5 48 48 48l152 0 0 64-88 0c-26.5 0-48 21.5-48 48l0 64c0 26.5 21.5 48 48 48l88 0 0 40c0 13.3 10.7 24 24 24s24-10.7 24-24l0-40 88 0c26.5 0 48-21.5 48-48l0-64c0-26.5-21.5-48-48-48l-88 0 0-64 152 0c26.5 0 48-21.5 48-48l0-64zM336 400l-224 0 0-64 224 0 0 64z"/></svg>`,
};

const ObjectsAlignLeft = {
  icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill='currentColor' d="M0 24C0 10.7 10.7 0 24 0S48 10.7 48 24l0 464c0 13.3-10.7 24-24 24s-24-10.7-24-24L0 24zM176 176l288 0 0-64-288 0 0 64zm-48-64c0-26.5 21.5-48 48-48l288 0c26.5 0 48 21.5 48 48l0 64c0 26.5-21.5 48-48 48l-288 0c-26.5 0-48-21.5-48-48l0-64zm48 288l160 0 0-64-160 0 0 64zm-48-64c0-26.5 21.5-48 48-48l160 0c26.5 0 48 21.5 48 48l0 64c0 26.5-21.5 48-48 48l-160 0c-26.5 0-48-21.5-48-48l0-64z"/></svg>`,
};

const ObjectsAlignRight = {
  icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill='currentColor' d="M512 24c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 464c0 13.3 10.7 24 24 24s24-10.7 24-24l0-464zM336 176L48 176l0-64 288 0 0 64zm48-64c0-26.5-21.5-48-48-48L48 64C21.5 64 0 85.5 0 112l0 64c0 26.5 21.5 48 48 48l288 0c26.5 0 48-21.5 48-48l0-64zM336 400l-160 0 0-64 160 0 0 64zm48-64c0-26.5-21.5-48-48-48l-160 0c-26.5 0-48 21.5-48 48l0 64c0 26.5 21.5 48 48 48l160 0c26.5 0 48-21.5 48-48l0-64z"/></svg>`,
};

var __decorate$c = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaRichTextTablePropertiesRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.formTouched = false;
    /**
     * Mark the form as touched.
     */
    this.markFormTouched = () => {
      this.formTouched = true;
    };
    /**
     * Reset the touch state.
     */
    this.resetTouchedState = () => {
      this.formTouched = false;
    };
  }
  initialFormState(newValue) {
    this.resetTouchedState();
    this.resetColorRelatedFields(newValue);
    this.setFormFieldValues(newValue);
  }
  getFormRef() {
    return this.formRef;
  }
  /**
   * Indicates whether the form has been interacted with.
   *
   * @returns {boolean} True if the form has been touched; otherwise, false.
   */
  isFormTouched() {
    return this.formTouched;
  }
  render() {
    return (h("vega-form", { class: "table-properties-form", ref: (el) => (this.formRef = el), onMouseDown: this.markFormTouched }, this.type === 'TABLE'
      ? this.tableFormRenderer.renderPropertiesFields()
      : this.cellFormRenderer.renderPropertiesFields()));
  }
  /**
   * Set form field values if the form is not touched.
   *
   * @param formValues
   */
  setFormFieldValues(formValues) {
    if (this.formRef) {
      void this.formRef.reset(formValues);
    }
  }
  /**
   * Handle color related fields before setting form value to ensure change event is triggered.
   *
   * @param {RTETablePropertiesType} formValue - The form value to be set.
   */
  resetColorRelatedFields(formValue) {
    if (this.formRef) {
      if (formValue.borderColor) {
        const borderColorInput = this.formRef.querySelector('[data-vega-form="borderColor"]');
        borderColorInput && (borderColorInput.value = '');
      }
      if (formValue.backgroundColor) {
        const backgroundColorInput = this.formRef.querySelector('[data-vega-form="backgroundColor"]');
        backgroundColorInput && (backgroundColorInput.value = '');
      }
    }
  }
}
(() => {
  VegaInternalIconManager.register({
    'align-center': AlignCenter,
    'align-justify': AlignJustify,
    'align-left': AlignLeft,
    'align-right': AlignRight,
    'align-top': AlignTop,
    'align-bottom': AlignBottom,
    'align-middle': AlignMiddle,
    'objects-align-left': ObjectsAlignLeft,
    'objects-align-center': ObjectsAlignCenterHorizontal,
    'objects-align-right': ObjectsAlignRight,
  });
})();
__decorate$c([
  MapToComponentField()
], VegaRichTextTablePropertiesRenderer.prototype, "type", void 0);
__decorate$c([
  MapToComponentField()
], VegaRichTextTablePropertiesRenderer.prototype, "tableFormRenderer", void 0);
__decorate$c([
  MapToComponentField()
], VegaRichTextTablePropertiesRenderer.prototype, "cellFormRenderer", void 0);
__decorate$c([
  MapToComponentMethod('watchDefaultValueChange')
], VegaRichTextTablePropertiesRenderer.prototype, "initialFormState", null);

var __decorate$b = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
 * Handles the color related properties for the table properties component.`
 */
class TableColorController extends VegaSlimmer {
  /**
   * Returns an array of light color values from the color schema.
   *
   * @returns {string[]} An array of light color strings.
   */
  getColors() {
    let result = [];
    if (this.colors) {
      result = this.colors.map((colorSchema) => this.isInDarkMode ? colorSchema.dark : colorSchema.light);
    }
    return result;
  }
  /**
   * Returns the color key corresponding to the provided color value.
   *
   * @param {string} color - The color value to find the key for.
   * @returns {string} The key of the color schema that matches the provided color value.
   */
  getColorKey(color) {
    let result = '';
    if (this.colors) {
      const colorSchema = this.colors.find((item) => this.isInDarkMode ? item.dark === color : item.light === color);
      result = colorSchema ? colorSchema.key : '';
    }
    return result;
  }
  /**
   * Returns the color value corresponding to the provided color key.
   *
   * @param {string} colorKey - The color key to find the value for.
   * @returns {string} The value of the color schema that matches the provided color key.
   */
  getColorByKey(colorKey) {
    let result = '';
    if (this.colors) {
      const colorSchema = this.colors.find((item) => item.key === colorKey);
      result = colorSchema ? (this.isInDarkMode ? colorSchema.dark : colorSchema.light) : '';
    }
    return result;
  }
}
__decorate$b([
  MapToComponentField()
], TableColorController.prototype, "colors", void 0);
__decorate$b([
  MapToComponentField({ writable: true })
], TableColorController.prototype, "isInDarkMode", void 0);

var __decorate$a = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaRichTextTablePropertiesBaseFormFieldRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.dimensionFieldValidationRule = [
      {
        canEvaluate: (input) => {
          return !!input;
        },
        shouldShowError: () => {
          return true;
        },
        evaluate: (input) => {
          const dimensionRegex = /^[0-9]*\.?[0-9]+(px|em|rem|%)?$/;
          return {
            isValid: dimensionRegex.test(input),
            message: '',
          };
        },
      },
    ];
    /**
     * Emit a change event on each form field value change.
     *
     * @param {HTMLElement} el - The form field element.
     */
    this.handleFormChange = (el) => {
      DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaChange, async (input) => {
        if (this.formRef) {
          const validateResult = await this.formRef.valid();
          if (validateResult.isValid) {
            if (this.renderer.isFormTouched()) {
              const formData = (await this.formRef.getValue());
              const fieldName = el.dataset.vegaForm;
              this.emitFormDataChange(fieldName, formData);
            }
          }
          this.updateBorderDisplayColor(input.host);
          this.updateBackgroundDisplayColor(input.host);
        }
      });
      if (el && el.tagName === 'VEGA-INPUT') {
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaFocus, this.markFormTouched);
      }
    };
    /**
     * Emit a change event on each form field value change.
     *
     * @param {string} fieldName - The name of the changed field.
     * @param {RTETablePropertiesType} formData - The current form data.
     */
    this.emitFormDataChange = (_fieldName, formData) => {
      this.vegaChange.emit(formData);
    };
    /**
     * Handle text alignment button click event.
     *
     * @param {MouseEvent} e - The click event.
     */
    this.handleAlignmentButtonClick = async (e) => {
      const button = e.currentTarget;
      const formFieldName = button.dataset.formFieldName;
      if (this.formRef) {
        await this.formRef.setValue({ [formFieldName]: button.dataset.id }, { skipInvisible: false });
      }
    };
    /**
     * Clear border color value and hide the color picker popover.
     *
     * @param {HTMLElement} btn - The clear button element.
     */
    this.clearBorderColor = (btn) => {
      DomNodeSubjectObserverFactory.addUniqueObserverToNode(btn, VegaClick, () => {
        if (this.borderColorPickerRef) {
          this.borderColorPickerRef.value = '';
          if (this.formRef) {
            void this.formRef.setValue({ borderColor: '' });
          }
        }
        if (this.colorPickerPopoverRef) {
          void this.colorPickerPopoverRef.hide();
        }
      });
    };
    /**
     * Apply border color value and hide the color picker popover.
     *
     * @param {HTMLElement} btn - The apply button element.
     */
    this.applyBorderColor = (btn) => {
      DomNodeSubjectObserverFactory.addUniqueObserverToNode(btn, VegaClick, () => {
        if (this.borderColorPickerRef && this.formRef) {
          void this.formRef.setValue({
            borderColor: this.controller.getColorKey(this.borderColorPickerRef.value),
          });
        }
        if (this.colorPickerPopoverRef) {
          void this.colorPickerPopoverRef.hide();
        }
      });
    };
    /**
     * Handle background color picker change event.
     *
     * @param {HTMLElement} el - The background color picker element.
     */
    this.handleBackgroundColorPickerChange = (el) => {
      DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaChange, (input) => {
        const colorValue = input.detail;
        const colorKey = this.controller.getColorKey(colorValue) || colorValue;
        if (this.formRef) {
          void this.formRef.setValue({ backgroundColor: colorKey });
        }
      });
    };
    /**
     * Clear background color value.
     *
     * @param {MouseEvent} event - The mouse event.
     */
    this.clearBackgroundColor = (event) => {
      event.stopPropagation();
      if (this.formRef) {
        void this.formRef.setValue({ backgroundColor: null });
      }
    };
    /**
     * Mark the form as touched.
     */
    this.markFormTouched = () => {
      this.renderer.markFormTouched();
    };
  }
  get formRef() {
    return this.renderer.getFormRef();
  }
  /**
   * Render style border fields.
   *
   * @returns { HTMLElement } The border fields element.
   */
  renderBorderFields() {
    return (h("vega-flex", { gap: "size-16", direction: "row", alignItems: "center" },
      h("vega-input-select", { "data-vega-form": "borderStyle", label: "Border Style", placeholder: "Select style", vegaDropdownProps: { searchable: false, matchTargetWidth: false }, source: VegaRichTextTablePropertiesBaseFormFieldRenderer.TABLE_BORDER_STYLES, ref: this.handleFormChange }),
      h("vega-input", { ref: this.handleFormChange, "data-vega-form": "borderWidth", label: "Weight", validationRules: this.dimensionFieldValidationRule }),
      this.renderBorderColorPicker()));
  }
  /**
   * Render background color picker.
   *
   * @returns {HTMLElement} The background color picker element.
   */
  renderBackgroundColorPicker() {
    return (h("div", { class: "background-color-group" },
      h("vega-font", { class: "field-label", variant: "font-field-label", color: "text-primary" }, "Background Color"),
      h("div", { class: "color-picker-container" },
        h("span", { role: "button", tabIndex: 0, "aria-label": "Clear background color", onClick: this.clearBackgroundColor, onKeyDown: createEnterKeyHandlerToTriggerClick(), class: "color-none" }),
        h("vega-divider", { direction: "vertical" }),
        h("vega-color-picker", { isInline: true, ref: this.handleBackgroundColorPickerChange, colors: this.controller.getColors() }),
        h("vega-input", { ref: this.handleFormChange, type: "hidden", "data-vega-form": "backgroundColor" }))));
  }
  /**
   * Render style dimension fields.
   *
   * @returns { HTMLElement } The dimension fields element.
   */
  renderDimensionFields(withPadding = false) {
    return (h("vega-flex", { gap: "size-16", direction: "row", alignItems: "end" },
      h("vega-input", { ref: this.handleFormChange, "data-vega-form": "width", label: "Width", validationRules: this.dimensionFieldValidationRule }),
      h("vega-input", { ref: this.handleFormChange, "data-vega-form": "height", label: "Height", validationRules: this.dimensionFieldValidationRule }),
      withPadding && (h("vega-input", { ref: this.handleFormChange, "data-vega-form": "padding", label: "Padding", validationRules: this.dimensionFieldValidationRule }))));
  }
  renderAlignmentField(alignmentList, iconPrefix, formFieldName) {
    return (h("vega-flex", { direction: "row", gap: "0", class: "text-alignment-button-group" },
      h("vega-input", { ref: this.handleFormChange, "data-vega-form": formFieldName, type: "hidden" }),
      alignmentList.map((key) => {
        return (h("button", { "data-id": key, "data-form-field-name": formFieldName, class: `text-alignment-${key}`, onClick: this.handleAlignmentButtonClick },
          h("vega-icon", { icon: VegaInternalIconManager.getIconKey(`${iconPrefix}${key}`) })));
      })));
  }
  /**
   * Render save and cancel action buttons.
   *
   * @returns {HTMLElement} The action buttons element.
   */
  renderActionButtons() {
    return (h("div", { class: "action-buttons" },
      h("vega-button-link", { ref: this.handleSave }, "Save"),
      h("vega-button-link", { ref: this.handleCancel }, "Cancel")));
  }
  /**
   * Render border color field color picker.
   *
   * @returns {HTMLElement} The border color picker element.
   */
  renderBorderColorPicker() {
    return (h("div", { class: "color-picker-group" },
      h("vega-font", { class: "field-label", variant: "font-field-label", color: "text-primary" }, "Color"),
      h("vega-popover", { ref: (el) => {
          this.colorPickerPopoverRef = el;
          DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaPopoverShow, async () => {
            if (this.formRef && this.borderColorPickerRef) {
              const formValue = await this.formRef.getValue();
              this.borderColorPickerRef.value = this.controller.getColorByKey(formValue['borderColor']);
            }
          });
        }, trigger: "click" },
        h("div", { slot: "popover-content", class: "color-picker-container" },
          h("vega-input", { ref: this.handleFormChange, "data-vega-form": "borderColor", type: "hidden" }),
          h("span", { role: "button", tabIndex: 0, "aria-label": "Clear border color", onKeyDown: createEnterKeyHandlerToTriggerClick(), class: "display-color-placeholder color-none" })),
        h("vega-box", { slot: "popover" },
          h("vega-color-picker", { ref: (el) => {
              this.borderColorPickerRef = el;
            }, isInline: true, colors: this.controller.getColors() }),
          h("vega-flex", { margin: { top: 'size-16' }, justifyContent: "end", gap: "size-16" },
            h("vega-button-link", { ref: this.clearBorderColor }, "Clear"),
            h("vega-button-link", { ref: this.applyBorderColor }, "Apply"))))));
  }
  /**
   * Update the color display span background color when border color changes.
   *
   * @param {HTMLElement} colorPickerRef - The border color field element.
   */
  updateBorderDisplayColor(colorPickerRef) {
    if (colorPickerRef && colorPickerRef.dataset.vegaForm === 'borderColor') {
      const selectedColorKey = colorPickerRef.value;
      const selectedColor = this.controller.getColorByKey(selectedColorKey);
      const displayColorDiv = colorPickerRef.nextElementSibling;
      displayColorDiv.style.backgroundColor = selectedColor;
      if (selectedColor) {
        displayColorDiv.classList.remove('color-none');
      }
      else {
        displayColorDiv.classList.add('color-none');
      }
      if (this.borderColorPickerRef && selectedColor !== this.borderColorPickerRef.value) {
        this.borderColorPickerRef.value = selectedColor;
      }
    }
  }
  /**
   * Update the background color display when background color changes.
   *
   * @param {HTMLElement} colorInput - The background color field element.
   */
  updateBackgroundDisplayColor(colorInput) {
    if (colorInput && colorInput.dataset.vegaForm === 'backgroundColor') {
      const colorKey = colorInput.value;
      const colorValue = this.controller.getColorByKey(colorKey);
      const colorPicker = colorInput.previousElementSibling;
      colorPicker.value = colorValue;
    }
  }
}
VegaRichTextTablePropertiesBaseFormFieldRenderer.TABLE_BORDER_STYLES = RTE_TABLE_BORDER_STYLES.map((style) => ({
  id: style,
  displayName: style.charAt(0).toUpperCase() + style.slice(1),
}));
__decorate$a([
  MapToComponentField()
], VegaRichTextTablePropertiesBaseFormFieldRenderer.prototype, "controller", void 0);
__decorate$a([
  MapToComponentField()
], VegaRichTextTablePropertiesBaseFormFieldRenderer.prototype, "defaultValue", void 0);
__decorate$a([
  MapToComponentField()
], VegaRichTextTablePropertiesBaseFormFieldRenderer.prototype, "renderer", void 0);
__decorate$a([
  MapToComponentField()
], VegaRichTextTablePropertiesBaseFormFieldRenderer.prototype, "styleMap", void 0);
__decorate$a([
  MapToComponentField()
], VegaRichTextTablePropertiesBaseFormFieldRenderer.prototype, "vegaChange", void 0);
__decorate$a([
  MapToComponentField()
], VegaRichTextTablePropertiesBaseFormFieldRenderer.prototype, "vegaCancel", void 0);
__decorate$a([
  MapToComponentField()
], VegaRichTextTablePropertiesBaseFormFieldRenderer.prototype, "vegaSave", void 0);

class VegaRichTextTablePropertiesFormFieldRenderer extends VegaRichTextTablePropertiesBaseFormFieldRenderer {
  constructor() {
    super(...arguments);
    /**
     * Emit save event on save button click.
     *
     * @param {HTMLVegaButtonLinkElement} btn - The save button element.
     */
    this.handleSave = (btn) => {
      DomNodeSubjectObserverFactory.addUniqueObserverToNode(btn, VegaClick, () => {
        this.vegaSave.emit();
      });
    };
    /**
     * Emit cancel event on cancel button click.
     *
     * @param {HTMLVegaButtonLinkElement} btn - The cancel button element.
     */
    this.handleCancel = (btn) => {
      DomNodeSubjectObserverFactory.addUniqueObserverToNode(btn, VegaClick, () => {
        this.vegaCancel.emit(this.defaultValue);
      });
    };
  }
  /**
   * Render table properties fields.
   *
   * @returns {HTMLElement} The table properties fields element.
   */
  renderPropertiesFields() {
    return (h(Fragment, null,
      h("vega-font", { variant: "font-h6", color: "text-primary" }, "Table properties"),
      h("vega-divider", { direction: "horizontal" }),
      this.renderBorderFields(),
      h("vega-divider", { direction: "horizontal" }),
      this.renderBackgroundColorPicker(),
      h("vega-divider", { direction: "horizontal" }),
      this.renderDimensionFields(),
      h("vega-divider", { direction: "horizontal" }),
      this.renderTextAlignmentField(),
      h("vega-divider", { direction: "horizontal" }),
      this.renderActionButtons()));
  }
  /**
   * Render style text alignment field.
   *
   * @returns { HTMLElement } The text alignment field element.
   */
  renderTextAlignmentField() {
    return (h("div", { class: "text-alignment-container" },
      h("vega-font", { variant: "font-field-label", color: "text-primary" }, "Alignment"),
      h("vega-flex", { direction: "row", gap: "size-16" }, this.renderAlignmentField(['left', 'center', 'right'], 'objects-align-', 'textAlign'))));
  }
}

var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaRichTextCellPropertiesFormFieldRenderer extends VegaRichTextTablePropertiesBaseFormFieldRenderer {
  constructor() {
    super(...arguments);
    this.changesNeedApply = {};
    /**
     * Emit a change event on each form field value change.
     *
     * @param {string} fieldName - The name of the changed field.
     * @param {RTETablePropertiesType} formData - The current form data.
     */
    this.emitFormDataChange = (fieldName, formData) => {
      this.vegaChange.emit(this.mergeFormDataWithStyleMap({
        [fieldName]: formData[fieldName],
      }));
    };
    /**
     * Emit save event on save button click.
     *
     * @param {HTMLVegaButtonLinkElement} btn - The save button element.
     */
    this.handleSave = (btn) => {
      DomNodeSubjectObserverFactory.addUniqueObserverToNode(btn, VegaClick, () => {
        this.vegaSave.emit();
      });
    };
    /**
     * Emit cancel event on cancel button click.
     *
     * @param {HTMLVegaButtonLinkElement} btn - The cancel button element.
     */
    this.handleCancel = (btn) => {
      DomNodeSubjectObserverFactory.addUniqueObserverToNode(btn, VegaClick, () => {
        this.vegaCancel.emit(this.styleMap);
      });
    };
  }
  onDefaultValueChange() {
    this.resetChangesNeedApply();
  }
  /**
   * Render cell properties fields.
   *
   * @returns {HTMLElement} The cell properties fields element.
   */
  renderPropertiesFields() {
    return (h(Fragment, null,
      h("vega-font", { variant: "font-h6", color: "text-primary" }, "Cell properties"),
      h("vega-divider", { direction: "horizontal" }),
      super.renderBorderFields(),
      h("vega-divider", { direction: "horizontal" }),
      super.renderBackgroundColorPicker(),
      h("vega-divider", { direction: "horizontal" }),
      this.renderDimensionFields(true),
      h("vega-divider", { direction: "horizontal" }),
      this.renderTextAlignmentField(),
      h("vega-divider", { direction: "horizontal" }),
      this.renderActionButtons()));
  }
  /**
   * Render style text alignment field.
   *
   * @returns { HTMLElement } The text alignment field element.
   */
  renderTextAlignmentField() {
    return (h("div", { class: "text-alignment-container" },
      h("vega-font", { variant: "font-field-label", color: "text-primary" }, "Text Alignment"),
      h("vega-flex", { direction: "row", gap: "size-16" },
        this.renderAlignmentField(['left', 'center', 'right', 'justify'], 'align-', 'textAlign'),
        this.renderAlignmentField(['top', 'middle', 'bottom'], 'align-', 'verticalAlign'))));
  }
  /**
   * Merge form data with style map for all selected cell blocks.
   *
   * @param {RTETablePropertiesType} formData - The form data.
   * @returns {Record<string, RTETablePropertiesType>} The merged data.
   */
  mergeFormDataWithStyleMap(formData) {
    this.changesNeedApply = Object.assign(Object.assign({}, this.changesNeedApply), formData);
    const mergedData = {};
    for (const id in this.styleMap) {
      mergedData[id] = Object.assign(Object.assign({}, this.styleMap[id]), this.changesNeedApply);
    }
    return mergedData;
  }
  /**
   * Reset the changesNeedApply object.
   *
   */
  resetChangesNeedApply() {
    this.changesNeedApply = {};
  }
}
__decorate$9([
  MapToComponentMethod('watchDefaultValueChange')
], VegaRichTextCellPropertiesFormFieldRenderer.prototype, "onDefaultValueChange", null);

const vegaRichTextTablePropertiesCss = ":host{display:block;max-width:420px}:host .table-properties-form{display:flex;flex-direction:column;gap:16px}:host .color-picker-group{display:flex;gap:8px;flex-direction:column}:host .color-picker-group .color-picker-container{flex-shrink:0}:host .color-picker-group .display-color-placeholder{display:block;box-sizing:border-box;border-radius:4px;border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));width:24px;height:24px}:host .color-picker-group .display-color-placeholder.color-none{box-sizing:content-box}:host .text-alignment-container>vega-font{display:block;margin-bottom:8px}:host .text-alignment-button-group button{display:flex;justify-content:center;align-items:center;border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));padding-top:16px;padding-bottom:16px;padding-left:16px;padding-right:16px;position:relative;cursor:pointer;background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1));color:rgba(var(--v-text-primary, 32, 54, 69, 1))}:host .text-alignment-button-group button:not(:first-of-type){margin-left:-1px}:host .text-alignment-button-group button:first-of-type{border-top-left-radius:4px;border-bottom-left-radius:4px}:host .text-alignment-button-group button:last-of-type{border-top-right-radius:4px;border-bottom-right-radius:4px}:host .text-alignment-button-group button:hover{background-color:rgba(var(--v-bg-quaternary, 241, 248, 251, 1));border:1px solid rgba(var(--v-border-input-field-hover, 115, 160, 190, 1));z-index:1}:host .text-alignment-button-group button:active{border:1px solid rgba(var(--v-border-input-field-focus, 19, 98, 226, 1));background-color:rgba(var(--v-bg-quaternary, 241, 248, 251, 1));z-index:1}:host .text-alignment-button-group vega-input[value=left]~.text-alignment-left,:host .text-alignment-button-group vega-input[value=center]~.text-alignment-center,:host .text-alignment-button-group vega-input[value=right]~.text-alignment-right,:host .text-alignment-button-group vega-input[value=justify]~.text-alignment-justify,:host .text-alignment-button-group vega-input[value=top]~.text-alignment-top,:host .text-alignment-button-group vega-input[value=middle]~.text-alignment-middle,:host .text-alignment-button-group vega-input[value=bottom]~.text-alignment-bottom{border:1px solid rgba(var(--v-border-input-field-focus, 19, 98, 226, 1));background-color:rgba(var(--v-bg-quaternary, 241, 248, 251, 1));z-index:1}:host .action-buttons{text-align:right}:host .action-buttons vega-button-link{margin-left:24px}:host .background-color-group{display:flex;gap:8px;flex-direction:column}:host .color-picker-container{box-sizing:border-box;border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));border-radius:8px;padding-left:12px;padding-right:12px;display:flex;gap:8px;align-items:center;padding-top:11px;padding-bottom:11px}:host .color-picker-container:hover{border:1px solid rgba(var(--v-border-input-field-hover, 115, 160, 190, 1))}:host .color-picker-container:focus-within{outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:3px;border:1px solid rgba(var(--v-border-color-input-field-focus, 19, 98, 226, 1))}:host .color-picker-container vega-divider{height:24px !important}:host .color-picker-container .color-none{display:block;box-sizing:border-box;border-radius:4px;width:24px;height:24px;border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1));overflow:hidden;cursor:pointer;position:relative}:host .color-picker-container .color-none:hover{box-shadow:0 0 0 4px rgba(230, 50, 87, 0.25)}:host .color-picker-container .color-none:before{content:\"\";position:absolute;border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1));border-left-width:0px;border-right-width:0px;border-bottom-width:0px;top:0;left:-10px;width:32px;height:0;transform-origin:top right;transform:rotate(-45deg)}:host(.vega-hidden){display:none}";

var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1; i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const VegaRichTextTableProperties = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaChange = createEvent(this, "vegaChange", 1);
    this.vegaCancel = createEvent(this, "vegaCancel", 1);
    this.vegaSave = createEvent(this, "vegaSave", 1);
    this.globalSlimmers = {};
    this.translationSlimmer = new TranslationSlimmer();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.renderer = new VegaRichTextTablePropertiesRenderer();
    this.tableFormRenderer = new VegaRichTextTablePropertiesFormFieldRenderer();
    this.cellFormRenderer = new VegaRichTextCellPropertiesFormFieldRenderer();
    this.controller = new TableColorController();
    this.darkModeStateSlimmer = new DarkModeStateControllerSlimmer();
    this.changeEventPreventSlimmer = new ChildNodesEventPreventSlimmer([VegaChange], () => this.renderer.getFormRef());
    this.isInDarkMode = VegaInternalThemeManager.isDarkMode();
    /**
     * @vegaVersion 2.79.0
     */
    this.type = 'TABLE';
    /**
     * @vegaVersion 2.79.0
     */
    this.colors = [];
  }
  watchDefaultValueChange(newValue) {
  }
  render() {
    return sanitizeVegaComponent(h(Host, null, this.renderer.render()), this.host);
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "defaultValue": ["watchDefaultValueChange"]
  }; }
};
__decorate$8([
  InjectVegaGlobalSlimmer()
], VegaRichTextTableProperties.prototype, "globalSlimmers", void 0);
__decorate$8([
  InjectVegaSlimmer()
], VegaRichTextTableProperties.prototype, "translationSlimmer", void 0);
__decorate$8([
  InjectVegaSlimmer()
], VegaRichTextTableProperties.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate$8([
  InjectVegaSlimmer()
], VegaRichTextTableProperties.prototype, "renderer", void 0);
__decorate$8([
  InjectVegaSlimmer()
], VegaRichTextTableProperties.prototype, "tableFormRenderer", void 0);
__decorate$8([
  InjectVegaSlimmer()
], VegaRichTextTableProperties.prototype, "cellFormRenderer", void 0);
__decorate$8([
  InjectVegaSlimmer()
], VegaRichTextTableProperties.prototype, "controller", void 0);
__decorate$8([
  InjectVegaSlimmer()
], VegaRichTextTableProperties.prototype, "darkModeStateSlimmer", void 0);
__decorate$8([
  InjectVegaSlimmer()
], VegaRichTextTableProperties.prototype, "changeEventPreventSlimmer", void 0);
VegaRichTextTableProperties.style = vegaRichTextTablePropertiesCss;

var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class SelectionWidgetRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    /**
     * Handles the selection of the widget.
     *
     * @param {MouseEvent} e - The mouse event.
     */
    this.handleWidgetSelection = (e) => {
      e.stopPropagation();
      this.isSelected = true;
    };
    /**
     * Handles clicks outside the widget to deselect it.
     */
    this.handleEditorContentClick = () => {
      this.isSelected = false;
    };
    /**
     * Registers the editor content click listener.
     */
    this.registerEditorContentClickListener = () => {
      if (this.editorContentContainerRef) {
        this.editorContentContainerRef.addEventListener('mousedown', this.handleEditorContentClick);
      }
    };
    /**
     * Un-registers the editor content click listener.
     */
    this.unRegisterEditorContentClickListener = () => {
      if (this.editorContentContainerRef) {
        this.editorContentContainerRef.removeEventListener('mousedown', this.handleEditorContentClick);
      }
    };
  }
  connectedCallback() {
    this.editorContentContainerRef = findParent(this.host, '.rich-text-editor-container');
  }
  disconnectedCallback() {
    this.unRegisterEditorContentClickListener();
  }
  watchIsSelected(newValue) {
    if (newValue) {
      this.registerEditorContentClickListener();
    }
    else {
      this.unRegisterEditorContentClickListener();
    }
  }
  getWidgetHandleRef() {
    return this.widgetHandleRef;
  }
  render() {
    return (h("div", { class: arrayToClassString(['v-rte-widget__selection', this.isSelected ? 'selected' : '']), contentEditable: false },
      h("button", { tabIndex: 0, class: "v-rte-widget__selection-handle", ref: (el) => (this.widgetHandleRef = el), onClick: this.handleWidgetSelection }),
      h("div", { class: "v-rte-widget__selection-content" },
        h("slot", null))));
  }
}
__decorate$7([
  MapToComponentField()
], SelectionWidgetRenderer.prototype, "host", void 0);
__decorate$7([
  MapToComponentField({ writable: true })
], SelectionWidgetRenderer.prototype, "isSelected", void 0);
__decorate$7([
  MapToComponentMethod('connectedCallback')
], SelectionWidgetRenderer.prototype, "connectedCallback", null);
__decorate$7([
  MapToComponentMethod('disconnectedCallback')
], SelectionWidgetRenderer.prototype, "disconnectedCallback", null);
__decorate$7([
  MapToComponentMethod('watchIsSelected')
], SelectionWidgetRenderer.prototype, "watchIsSelected", null);

var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
 * Keyboard controller for table selection widget
 */
class SelectionWidgetKeyboardController extends KeyboardManagerSlimmer {
  constructor() {
    super(() => [
      {
        keyCode: 'Backspace',
        eventName: 'keydown',
        activeElementInScope: [this.selectionWidgetRenderer.getWidgetHandleRef()],
        callback: this.handleDeleteKeyDown,
      },
    ]);
    /**
     * Handles the delete key down event.
     *
     */
    this.handleDeleteKeyDown = () => {
      this.vegaRemove.emit();
    };
  }
}
__decorate$6([
  MapToComponentField()
], SelectionWidgetKeyboardController.prototype, "vegaRemove", void 0);
__decorate$6([
  MapToComponentField()
], SelectionWidgetKeyboardController.prototype, "selectionWidgetRenderer", void 0);

const vegaRichTextTableSelectionWidgetCss = ":host{display:block;position:relative;padding-top:19px}:host(:hover) .v-rte-widget__selection-content{outline:2px solid rgb(255, 200, 61)}:host(:hover) .v-rte-widget__selection-handle{display:revert;background:rgb(255, 200, 61)}.v-rte-widget__selection.selected .v-rte-widget__selection-content{outline:2px solid rgb(38, 42, 255)}.v-rte-widget__selection.selected .v-rte-widget__selection-handle{display:revert;background:rgb(38, 42, 255)}.v-rte-widget__selection-handle{border:none;outline:none;width:15px;height:15px;position:absolute;top:2px;left:-2px;padding:2px;box-sizing:border-box;display:none}.v-rte-widget__selection-handle:after{content:\"\";border:1px dashed rgb(255, 255, 255);width:auto;height:100%;display:block}";

var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1; i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const VegaRichTextTableSelectionWidget = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaRemove = createEvent(this, "vegaRemove", 7);
    this.globalSlimmers = {};
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.selectionWidgetRenderer = new SelectionWidgetRenderer();
    this.keyboardController = new SelectionWidgetKeyboardController();
    this.isSelected = false;
  }
  watchIsSelected(newValue) {
  }
  render() {
    return sanitizeVegaComponent(h(Host, null, this.selectionWidgetRenderer.render()), this.host);
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "isSelected": ["watchIsSelected"]
  }; }
};
__decorate$5([
  InjectVegaGlobalSlimmer()
], VegaRichTextTableSelectionWidget.prototype, "globalSlimmers", void 0);
__decorate$5([
  InjectVegaSlimmer()
], VegaRichTextTableSelectionWidget.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate$5([
  InjectVegaSlimmer()
], VegaRichTextTableSelectionWidget.prototype, "selectionWidgetRenderer", void 0);
__decorate$5([
  InjectVegaSlimmer()
], VegaRichTextTableSelectionWidget.prototype, "keyboardController", void 0);
VegaRichTextTableSelectionWidget.style = vegaRichTextTableSelectionWidgetCss;

var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const buttonList = [
  'rte-table-column',
  'rte-table-row',
  'rte-table-merge-cells',
  'rte-table-properties',
  'rte-table-cell-properties',
  'rte-table-caption',
];
class VegaRichTextTableSettingRenderer extends VegaSlimmer {
  render() {
    return (h("vega-flex", { gap: "size-8", class: "rte-table-setting-content" }, buttonList.map((item) => this.renderButton(item))));
  }
  renderButton(item) {
    switch (item) {
      case 'rte-table-column':
        return this.columnButtonSlimmer.render();
      case 'rte-table-row':
        return this.rowButtonSlimmer.render();
      case 'rte-table-merge-cells':
        return this.mergeCellsButtonSlimmer.render();
      case 'rte-table-properties':
        return this.tablePropertiesButtonSlimmer.render();
      case 'rte-table-cell-properties':
        return this.cellPropertiesButtonSlimmer.render();
      default:
        return this.captionButtonSlimmer.render();
    }
  }
}
__decorate$4([
  MapToComponentField()
], VegaRichTextTableSettingRenderer.prototype, "captionButtonSlimmer", void 0);
__decorate$4([
  MapToComponentField()
], VegaRichTextTableSettingRenderer.prototype, "columnButtonSlimmer", void 0);
__decorate$4([
  MapToComponentField()
], VegaRichTextTableSettingRenderer.prototype, "rowButtonSlimmer", void 0);
__decorate$4([
  MapToComponentField()
], VegaRichTextTableSettingRenderer.prototype, "tablePropertiesButtonSlimmer", void 0);
__decorate$4([
  MapToComponentField()
], VegaRichTextTableSettingRenderer.prototype, "cellPropertiesButtonSlimmer", void 0);
__decorate$4([
  MapToComponentField()
], VegaRichTextTableSettingRenderer.prototype, "mergeCellsButtonSlimmer", void 0);

const Icons = {
  'rte-table-column': {
    icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M48 416V160H232V432H64c-8.8 0-16-7.2-16-16zm232 16V160H464V416c0 8.8-7.2 16-16 16H280zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64z"/></svg>`,
  },
  'rte-table-row': {
    icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M448 432l-320 0 0-152 336 0 0 136c0 8.8-7.2 16-16 16zm16-200l-336 0 0-152 320 0c8.8 0 16 7.2 16 16l0 136zM0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32C28.7 32 0 60.7 0 96L0 416z"/></svg>`,
  },
  'rte-table-merge-cells': {
    icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M464 416c0 8.8-7.2 16-16 16H128V192H0V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H160V160H464V416zM64 32C28.7 32 0 60.7 0 96v64H128V32H64zM414.8 246.1c2.5-6 1.1-12.9-3.5-17.4l-32-32c-6.2-6.2-16.4-6.2-22.6 0l-32 32c-4.6 4.6-5.9 11.5-3.5 17.4s8.3 9.9 14.8 9.9h16v48c0 8.8-7.2 16-16 16H288V304c0-6.5-3.9-12.3-9.9-14.8s-12.9-1.1-17.4 3.5l-32 32c-6.2 6.2-6.2 16.4 0 22.6l32 32c4.6 4.6 11.5 5.9 17.4 3.5s9.9-8.3 9.9-14.8V352h48c26.5 0 48-21.5 48-48V256h16c6.5 0 12.3-3.9 14.8-9.9z"/></svg>`,
  },
  'rte-table-properties': {
    icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M48 160V416c0 8.8 7.2 16 16 16H448c8.8 0 16-7.2 16-16V160H128v64c0 8.8 7.2 16 16 16h32c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-5.6 0-11-1-16-2.7V320c0 8.8 7.2 16 16 16h96c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-26.5 0-48-21.5-48-48V224 160H48zM0 96C0 60.7 28.7 32 64 32H448c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM224 240c0-8.8 7.2-16 16-16H400c8.8 0 16 7.2 16 16v32c0 8.8-7.2 16-16 16H240c-8.8 0-16-7.2-16-16V240zm80 80h96c8.8 0 16 7.2 16 16v32c0 8.8-7.2 16-16 16H304c-8.8 0-16-7.2-16-16V336c0-8.8 7.2-16 16-16z"/></svg>`,
  },
  'rte-table-cell-properties': {
    icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M360 80v88H464V96c0-8.8-7.2-16-16-16H360zm-48 0H200v88H312V80zM152 80H64c-8.8 0-16 7.2-16 16v72H152V80zM48 216v80H152V216H48zm0 128v72c0 8.8 7.2 16 16 16h88V344H48zm152 88H312V344H200v88zm160 0h88c8.8 0 16-7.2 16-16V344H360v88zM464 296V216H360v80H464zM0 96C0 60.7 28.7 32 64 32H448c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM200 296H312V216H200v80z"/></svg>`,
  },
  'rte-table-caption': {
    icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M464 224c0-8.8-7.2-16-16-16L64 208c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16l384 0c8.8 0 16-7.2 16-16l0-224zm-16-64c35.3 0 64 28.7 64 64l0 224c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 224c0-35.3 28.7-64 64-64l384 0zm-8-80c13.3 0 24 10.7 24 24s-10.7 24-24 24L72 128c-13.3 0-24-10.7-24-24s10.7-24 24-24l368 0zM392 0c13.3 0 24 10.7 24 24s-10.7 24-24 24L120 48c-13.3 0-24-10.7-24-24s10.7-24 24-24L392 0z"/></svg>`,
  },
};

var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class TableSettingButtonSlimmer extends VegaSlimmer {
  constructor({ icon, title, showArrowIcon }) {
    super();
    this.renderBtn = () => {
      const selected = this.isSelected();
      const disable = this.isDisabled();
      return (h("vega-tooltip", { key: `table-setting-${this.icon}`, text: this.getTitle(), placement: ['bottom', 'top'], trigger: "hover" },
        h("button", { type: "button", class: {
            'rte-table-setting-item': true,
            'rte-table-setting-item-disabled': disable,
            'rte-table-setting-item-selected': selected,
          }, disabled: disable, 
          /* eslint-disable-next-line react/jsx-no-bind */
          onClick: (event) => {
            if (disable) {
              return;
            }
            this.handleClick(event);
          }, onKeyDown: this.preventDefaultEvent, onMouseDown: this.preventDefaultEvent },
          h("vega-flex", { alignItems: "center", justifyContent: "center" },
            h("vega-icon", { icon: VegaInternalIconManager.getIconKey(this.icon), size: "size-16", color: this.getIconColor() }),
            this.showArrowIcon ? (h("vega-icon", { size: "size-8", style: { marginLeft: '8px' }, icon: VegaInternalIconManager.getIconKey('chevron-down'), color: this.getIconColor() })) : null))));
    };
    this.icon = icon;
    this.title = title;
    this.showArrowIcon = showArrowIcon;
  }
  render() {
    return typeof this.renderBtnWrapper === 'function'
      ? this.renderBtnWrapper(this.renderBtn)
      : this.renderBtn();
  }
  emitClickEvent(setting) {
    this.vegaClick.emit(setting);
  }
  /**
   * Prevent the default behavior to keep the cursor position.
   *
   * @param {Event} e - The event object.
   */
  preventDefaultEvent(e) {
    e.preventDefault();
  }
  getTitle() {
    return this.title;
  }
  getIconColor() {
    const selected = this.isSelected();
    const disable = this.isDisabled();
    if (selected) {
      return 'text-link-active';
    }
    else if (disable) {
      return 'text-disabled';
    }
    return 'text-primary';
  }
}
__decorate$3([
  MapToComponentField()
], TableSettingButtonSlimmer.prototype, "hasCaption", void 0);
__decorate$3([
  MapToComponentField()
], TableSettingButtonSlimmer.prototype, "vegaClick", void 0);
__decorate$3([
  MapToComponentField()
], TableSettingButtonSlimmer.prototype, "selectedCells", void 0);

/**
 * Slimmer dedicated to building the caption button.
 */
class CaptionButtonSlimmer extends TableSettingButtonSlimmer {
  constructor() {
    super({
      icon: 'rte-table-caption',
      title: 'caption off',
      showArrowIcon: false,
    });
  }
  isSelected() {
    return this.hasCaption;
  }
  isDisabled() {
    return false;
  }
  handleClick() {
    const caption = !this.hasCaption ? 'rte-table-caption' : '';
    this.emitClickEvent([TableSettingType.CAPTION, caption]);
  }
  getTitle() {
    return this.hasCaption ? 'caption on' : 'caption off';
  }
}

var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
 * Slimmer dedicated to building the column button.
 */
class ColumnButtonSlimmer extends TableSettingButtonSlimmer {
  constructor() {
    super({
      icon: 'rte-table-column',
      title: 'Column',
      showArrowIcon: true,
    });
    this.handleDropdownItemClick = (input) => {
      this.emitClickEvent([TableSettingType.COLUMN, input.detail]);
    };
    this.handleDropdownVisibilityChange = ({ eventName }) => {
      this.isColumnDropdownOpen = eventName.toLocaleLowerCase().indexOf('show') >= 0;
    };
  }
  renderBtnWrapper(renderBtn) {
    return (h("vega-dropdown", { isScreenPosition: true, minWidth: 210, trigger: "click", ref: (el) => {
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaDropdownClick, this.handleDropdownItemClick);
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaDropdownShow, this.handleDropdownVisibilityChange);
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaDropdownHide, this.handleDropdownVisibilityChange);
      } },
      renderBtn(),
      this.renderActionList()));
  }
  isSelected() {
    return this.isColumnDropdownOpen;
  }
  isDisabled() {
    return this.selectedCells.length === 0;
  }
  /* istanbul ignore next */
  // eslint-disable-next-line @typescript-eslint/no-empty-function
  handleClick() { }
  /**
   * Render the action list.
   *
   * @returns {HTMLElement} The action list element.
   */
  renderActionList() {
    return (h("div", { tabIndex: 0, role: "menu", slot: "items", onMouseDown: this.preventDefaultEvent, onKeyDown: this.preventDefaultEvent },
      h("vega-dropdown-item", { itemKey: ColumnOperationType.HEADER_COLUMN },
        h("vega-flex", { alignItems: "center", gap: "size-8" },
          h("vega-toggle-switch", { checked: ToggleHeaderTableColumnStrategy.isFullHeaderSelection(this.selectedCells), size: "small" }),
          "Header Column")),
      h("vega-dropdown-item", { itemKey: ColumnOperationType.ADD_COLUMN_LEFT }, "Insert column left"),
      h("vega-dropdown-item", { itemKey: ColumnOperationType.ADD_COLUMN_RIGHT }, "Insert column right"),
      h("vega-dropdown-item", { itemKey: ColumnOperationType.DELETE_COLUMN, disabled: this.allColumnSelected(this.selectedCells) }, "Delete column"),
      h("vega-dropdown-item", { itemKey: ColumnOperationType.SELECT_COLUMN }, "Select column")));
  }
  /**
   * Determine if all columns are selected based on the selected cell range.
   *
   * @param selectedCellRange
   * @returns {boolean} true if all columns are selected
   */
  allColumnSelected(selectedCellRange) {
    if (selectedCellRange.length === 0) {
      return false;
    }
    const firstSelectedCell = selectedCellRange[0];
    const table = getParentBlockByType(firstSelectedCell, RTETableBlock);
    if (!table) {
      return false;
    }
    const [minCol, maxCol] = getSelectedCellsBoundary(selectedCellRange, table);
    const tableCount = getTableColumnCount(table);
    return maxCol - minCol + 1 === tableCount;
  }
}
__decorate$2([
  MapToComponentField({ writable: true })
], ColumnButtonSlimmer.prototype, "isColumnDropdownOpen", void 0);

/**
 * Slimmer dedicated to building the column button.
 */
class TablePropertiesButtonSlimmer extends TableSettingButtonSlimmer {
  constructor() {
    super({
      icon: 'rte-table-properties',
      title: 'table properties',
      showArrowIcon: false,
    });
  }
  renderBtnWrapper(renderBtn) {
    return renderBtn();
  }
  isSelected() {
    return false;
  }
  isDisabled() {
    return false;
  }
  handleClick() {
    this.emitClickEvent([TableSettingType.TABLE]);
  }
}

/**
 * Slimmer dedicated to building the row button.
 */
class RowButtonSlimmer extends TableSettingButtonSlimmer {
  constructor() {
    super({
      icon: 'rte-table-row',
      title: 'Row',
      showArrowIcon: true,
    });
    this.handleDropdownItemClick = (input) => {
      this.emitClickEvent([TableSettingType.ROW, input.detail]);
    };
  }
  renderBtnWrapper(renderBtn) {
    return (h("vega-dropdown", { isScreenPosition: true, minWidth: 180, trigger: "click", ref: (el) => {
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaDropdownClick, this.handleDropdownItemClick);
      } },
      renderBtn(),
      this.renderActionList()));
  }
  isDisabled() {
    return this.selectedCells.length === 0;
  }
  isSelected() {
    return false;
  }
  /* istanbul ignore next */
  // eslint-disable-next-line @typescript-eslint/no-empty-function
  handleClick() { }
  /**
   * Render the action list.
   *
   * @returns {HTMLElement} The action list element.
   */
  renderActionList() {
    const shouldChecked = this.areSelectedRowsHeaderRows();
    return (h("div", { tabIndex: 0, role: "menu", slot: "items", onMouseDown: this.preventDefaultEvent, onKeyDown: this.preventDefaultEvent },
      h("vega-dropdown-item", { itemKey: RowOperationType.HEADER_ROW },
        h("vega-flex", { alignItems: "center", direction: "row", gap: "size-8" },
          h("vega-toggle-switch", { key: shouldChecked.toString(), size: "small", checked: shouldChecked }),
          h("span", null, "Header row"))),
      h("vega-dropdown-item", { itemKey: RowOperationType.ADD_ROW_ABOVE }, "Insert row above"),
      h("vega-dropdown-item", { itemKey: RowOperationType.ADD_ROW_BELOW }, "Insert row below"),
      h("vega-dropdown-item", { disabled: this.areAllRowsSelected(), itemKey: RowOperationType.DELETE_ROW }, "Delete row"),
      h("vega-dropdown-item", { itemKey: RowOperationType.SELECT_ROW }, "Select row")));
  }
  /**
   * Check if all selected rows are header rows.
   *
   * @returns {boolean} - true if all selected rows are header rows, false otherwise.
   */
  areSelectedRowsHeaderRows() {
    const selectedRows = this.getSelectedRows();
    return (selectedRows.length > 0 &&
      selectedRows.every((row) => row.parent instanceof RTETableHeadBlock));
  }
  /**
   * Check if all rows are selected. Should disable some row operations if true.
   *
   * @returns {boolean} - true if all rows are selected, false otherwise.
   */
  areAllRowsSelected() {
    let flag = false;
    const selectedRows = this.getSelectedRows();
    if (selectedRows.length) {
      const table = getParentBlockByType(selectedRows[0], RTETableBlock);
      if (table) {
        const allRows = table.children
          .filter((block) => block instanceof RTETableHeadBlock || block instanceof RTETableBodyBlock)
          .flatMap((item) => item.children);
        flag = selectedRows.length === allRows.length;
      }
    }
    return flag;
  }
  /**
   * Get all selected rows from selected cells.
   *
   * @returns {RTETableRowBlock[]} - Array of selected table row blocks.
   */
  getSelectedRows() {
    const selectedRows = new Set();
    if (this.selectedCells && this.selectedCells.length) {
      this.selectedCells.forEach((cell) => {
        if (cell.parent) {
          selectedRows.add(cell.parent);
        }
      });
    }
    return Array.from(selectedRows);
  }
}

/**
 * Slimmer dedicated to building the merge cells button.
 */
class CellPropertiesButtonSlimmer extends TableSettingButtonSlimmer {
  constructor() {
    super({
      icon: 'rte-table-cell-properties',
      title: 'cell properties',
      showArrowIcon: false,
    });
  }
  renderBtnWrapper(renderBtn) {
    return renderBtn();
  }
  isSelected() {
    return false;
  }
  isDisabled() {
    return this.selectedCells.length === 0;
  }
  handleClick() {
    this.emitClickEvent([TableSettingType.CELL]);
  }
}

var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
 * Slimmer dedicated to building the merge cells button.
 */
class MergeCellsButtonSlimmer extends TableSettingButtonSlimmer {
  constructor() {
    super({
      icon: 'rte-table-merge-cells',
      title: 'Merge cells',
      showArrowIcon: true,
    });
    this.handleDropdownItemClick = (input) => {
      if (Object.values(SplitCellOperationType).includes(input.detail)) {
        this.emitClickEvent([TableSettingType.SPLIT_CELL, input.detail]);
        return;
      }
      this.emitClickEvent([TableSettingType.MERGE_CELLS, input.detail]);
    };
    this.handleDropdownVisibilityChange = ({ eventName }) => {
      this.isMergeCellsDropdownOpen = eventName.toLocaleLowerCase().indexOf('show') >= 0;
    };
  }
  renderBtnWrapper(renderBtn) {
    return (h("vega-dropdown", { isScreenPosition: true, minWidth: 150, trigger: "click", ref: (el) => {
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaDropdownClick, this.handleDropdownItemClick);
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaDropdownShow, this.handleDropdownVisibilityChange);
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(el, VegaDropdownHide, this.handleDropdownVisibilityChange);
      } },
      renderBtn(),
      this.renderActionList()));
  }
  isSelected() {
    return this.isMergeCellsDropdownOpen;
  }
  isDisabled() {
    if (this.selectedCells.length === 0) {
      return true;
    }
    const hasTableCell = this.selectedCells.some((item) => item.type === 'table-cell');
    const hasTableHeadCell = this.selectedCells.some((item) => item.type === 'table-head-cell');
    if (hasTableCell && hasTableHeadCell) {
      return true;
    }
    return !isRectangularSelection(this.selectedCells);
  }
  handleClick() {
    this.isMergeCellsDropdownOpen = true;
  }
  /**
   * Render the action list.
   *
   * @returns {HTMLElement} The action list element.
   */
  renderActionList() {
    const disabledMap = this.getMergeDirectionDisabledMap();
    return (h("div", { tabIndex: 0, role: "menu", slot: "items", onMouseDown: this.preventDefaultEvent, onKeyDown: this.preventDefaultEvent },
      h("vega-dropdown-item", { itemKey: MergeCellsOperationType.MERGE_CELLS }, "Merge cells"),
      h("vega-dropdown-item", { itemKey: MergeCellsOperationType.MERGE_CELL_UP, disabled: disabledMap[MergeCellsOperationType.MERGE_CELL_UP] }, "Merge cell up"),
      h("vega-dropdown-item", { itemKey: MergeCellsOperationType.MERGE_CELL_RIGHT, disabled: disabledMap[MergeCellsOperationType.MERGE_CELL_RIGHT] }, "Merge cell right"),
      h("vega-dropdown-item", { itemKey: MergeCellsOperationType.MERGE_CELL_DOWN, disabled: disabledMap[MergeCellsOperationType.MERGE_CELL_DOWN] }, "Merge cell down"),
      h("vega-dropdown-item", { itemKey: MergeCellsOperationType.MERGE_CELL_LEFT, disabled: disabledMap[MergeCellsOperationType.MERGE_CELL_LEFT] }, "Merge cell left"),
      h("vega-dropdown-item", { itemKey: SplitCellOperationType.SPLIT_CELL_VERTICALLY, disabled: !this.selectSingleCell() }, "Split cell vertically"),
      h("vega-dropdown-item", { itemKey: SplitCellOperationType.SPLIT_CELL_HORIZONTALLY, disabled: !this.selectSingleCell() }, "Split cell horizontally")));
  }
  selectSingleCell() {
    return this.selectedCells.length === 1;
  }
  getMergeDirectionDisabledMap() {
    if (this.selectedCells.length !== 1) {
      return {
        [MergeCellsOperationType.MERGE_CELL_UP]: true,
        [MergeCellsOperationType.MERGE_CELL_RIGHT]: true,
        [MergeCellsOperationType.MERGE_CELL_DOWN]: true,
        [MergeCellsOperationType.MERGE_CELL_LEFT]: true,
      };
    }
    const cell = this.selectedCells[0];
    const row = cell.parent;
    const table = row.parent;
    const rowIndex = table.children.indexOf(row);
    const cellIndex = row.children.indexOf(cell);
    const isFirstRow = rowIndex === 0;
    const isLastRow = rowIndex === table.children.length - 1;
    const isFirstCol = cellIndex === 0;
    const isLastCol = cellIndex === row.children.length - 1;
    const getDisabledForDirection = (direction, isOnEdge) => {
      if (isOnEdge) {
        return true;
      }
      const adjacentCell = getAdjacentCell(cell, direction);
      return !adjacentCell || !isRectangularSelection([cell, adjacentCell]);
    };
    return {
      [MergeCellsOperationType.MERGE_CELL_UP]: getDisabledForDirection(MergeCellsOperationType.MERGE_CELL_UP, isFirstRow),
      [MergeCellsOperationType.MERGE_CELL_RIGHT]: getDisabledForDirection(MergeCellsOperationType.MERGE_CELL_RIGHT, isLastCol),
      [MergeCellsOperationType.MERGE_CELL_DOWN]: getDisabledForDirection(MergeCellsOperationType.MERGE_CELL_DOWN, isLastRow),
      [MergeCellsOperationType.MERGE_CELL_LEFT]: getDisabledForDirection(MergeCellsOperationType.MERGE_CELL_LEFT, isFirstCol),
    };
  }
}
__decorate$1([
  MapToComponentField({ writable: true })
], MergeCellsButtonSlimmer.prototype, "isMergeCellsDropdownOpen", void 0);

const vegaRichTextTableSettingCss = ":host .rte-table-setting-item{border:none;padding-top:4px;padding-bottom:4px;padding-left:4px;padding-right:4px;cursor:pointer;background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1))}:host .rte-table-setting-item:not(.rte-table-setting-item-disabled,.rte-table-setting-item-selected):hover{background-color:rgba(var(--v-bg-quaternary, 241, 248, 251, 1))}:host .rte-table-setting-item-disabled{cursor:default}:host .rte-table-setting-item-selected{background-color:rgba(var(--v-bg-quaternary, 241, 248, 251, 1))}";

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1; i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const VegaRichTextTableSetting = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaClick = createEvent(this, "vegaClick", 7);
    this.globalSlimmers = {};
    this.translationSlimmer = new TranslationSlimmer();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.renderer = new VegaRichTextTableSettingRenderer();
    this.captionButtonSlimmer = new CaptionButtonSlimmer();
    this.columnButtonSlimmer = new ColumnButtonSlimmer();
    this.tablePropertiesButtonSlimmer = new TablePropertiesButtonSlimmer();
    this.rowButtonSlimmer = new RowButtonSlimmer();
    this.cellPropertiesButtonSlimmer = new CellPropertiesButtonSlimmer();
    this.mergeCellsButtonSlimmer = new MergeCellsButtonSlimmer();
    this.isColumnDropdownOpen = false;
    this.isMergeCellsDropdownOpen = false;
    /**
     * Indicates whether the current table already has a caption.
     *
     * @vegaVersion 2.79.0
     */
    this.hasCaption = false;
    /**
     * The selected cells in the table.
     *
     * @vegaVersion 2.79.0
     */
    this.selectedCells = [];
  }
  connectedCallback() {
    this.registerTableCellSelectionChangeObserver();
  }
  disconnectedCallback() {
    if (this.target) {
      DomNodeSubjectObserverFactory.removeUniqueObserverFromNode(this.target, VegaInternalRTEExtensionTableCellSelectionChange);
    }
  }
  render() {
    return sanitizeVegaComponent(h(Host, null, this.renderer.render()), this.host);
  }
  registerTableCellSelectionChangeObserver() {
    // the target may be null when the table ref becomes ready after rendering vega-rich-text-table-setting.
    if (this.target) {
      DomNodeSubjectObserverFactory.addUniqueObserverToNode(this.target, VegaInternalRTEExtensionTableCellSelectionChange, (input) => {
        if (!isArrayEqual(this.selectedCells, input.detail)) {
          this.selectedCells = input.detail;
        }
      });
    }
  }
  get host() { return getElement(this); }
};
(() => {
  VegaInternalIconManager.register(Object.assign(Object.assign({}, Icons), { 'chevron-down': chevronDown }));
})();
__decorate([
  InjectVegaGlobalSlimmer()
], VegaRichTextTableSetting.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextTableSetting.prototype, "translationSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextTableSetting.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextTableSetting.prototype, "renderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextTableSetting.prototype, "captionButtonSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextTableSetting.prototype, "columnButtonSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextTableSetting.prototype, "tablePropertiesButtonSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextTableSetting.prototype, "rowButtonSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextTableSetting.prototype, "cellPropertiesButtonSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRichTextTableSetting.prototype, "mergeCellsButtonSlimmer", void 0);
__decorate([
  MapToComponentMethod('connectedCallback')
], VegaRichTextTableSetting.prototype, "connectedCallback", null);
__decorate([
  MapToComponentMethod('disconnectedCallback')
], VegaRichTextTableSetting.prototype, "disconnectedCallback", null);
VegaRichTextTableSetting.style = vegaRichTextTableSettingCss;

export { VegaRichTextTableProperties as vega_rich_text_table_properties, VegaRichTextTableSelectionWidget as vega_rich_text_table_selection_widget, VegaRichTextTableSetting as vega_rich_text_table_setting };
