var __decorate = (this && this.__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;
};
import { css, html } from 'lit';
import { customElement, query } from 'lit/decorators.js';
import { createIcon } from '../../../../_common/components/icon/uni-icon.js';
import { checkboxChecked, checkboxUnchecked, playCheckAnimation, } from '../../../../list-block/utils/icons.js';
import { BaseCellRenderer } from '../base-cell.js';
import { columnRenderer, createFromBaseCellRenderer } from '../renderer.js';
import { checkboxPureColumnConfig } from './define.js';
let CheckboxCell = class CheckboxCell extends BaseCellRenderer {
    beforeEnterEditMode() {
        const checked = !this.value;
        this.onChange(checked);
        if (checked) {
            playCheckAnimation(this._checkbox, { left: -2 }).catch(console.error);
        }
        return false;
    }
    onCopy(_e) {
        _e.preventDefault();
    }
    onPaste(_e) {
        _e.preventDefault();
    }
    onCut(_e) {
        _e.preventDefault();
    }
    render() {
        const checked = this.value ?? false;
        const icon = checked ? checkboxChecked() : checkboxUnchecked();
        return html ` <div class="affine-database-checkbox-container">
      <div
        class="affine-database-checkbox checkbox ${checked ? 'checked' : ''}"
      >
        ${icon}
      </div>
    </div>`;
    }
};
CheckboxCell.styles = css `
    affine-database-checkbox-cell {
      display: block;
      width: 100%;
      cursor: pointer;
    }

    .affine-database-checkbox-container {
      height: 100%;
    }

    .affine-database-checkbox {
      display: flex;
      align-items: center;
      height: var(--data-view-cell-text-line-height);
      width: 100%;
      position: relative;
    }
    .affine-database-checkbox svg {
      width: 16px;
      height: 16px;
    }
  `;
__decorate([
    query('.affine-database-checkbox')
], CheckboxCell.prototype, "_checkbox", void 0);
CheckboxCell = __decorate([
    customElement('affine-database-checkbox-cell')
], CheckboxCell);
export { CheckboxCell };
columnRenderer.register({
    type: checkboxPureColumnConfig.type,
    icon: createIcon('CheckBoxIcon'),
    cellRenderer: {
        view: createFromBaseCellRenderer(CheckboxCell),
    },
});
export const checkboxColumnConfig = checkboxPureColumnConfig;
//# sourceMappingURL=cell-renderer.js.map