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 { ShadowlessElement, WithDisposable } from '@blockeditor/lit';
import {} from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js';
import { html } from 'lit/static-html.js';
import { EDGELESS_BLOCK_CHILD_BORDER_WIDTH, EDGELESS_BLOCK_CHILD_PADDING, } from '../../_common/consts.js';
import { DEFAULT_NOTE_COLOR } from '../../_common/edgeless/note/consts.js';
import {} from '../../note-block/index.js';
import { deserializeXYWH } from '../../surface-block/index.js';
let SurfaceRefNotePortal = class SurfaceRefNotePortal extends WithDisposable(ShadowlessElement) {
    connectedCallback() {
        super.connectedCallback();
    }
    firstUpdated() {
        this.disposables.add(this.model.propsUpdated.on(() => this.requestUpdate()));
    }
    updated() {
        setTimeout(() => {
            const editiableElements = Array.from(this.querySelectorAll('[contenteditable]'));
            const blockElements = Array.from(this.querySelectorAll(`[data-block-id]`));
            editiableElements.forEach(element => {
                if (element.contentEditable === 'true')
                    element.contentEditable = 'false';
            });
            blockElements.forEach(element => {
                element.setAttribute('data-queryable', 'false');
            });
        }, 500);
    }
    render() {
        const { model, index } = this;
        const { xywh, background } = model;
        const [modelX, modelY, modelW, modelH] = deserializeXYWH(xywh);
        const isHiddenNote = model.hidden;
        const style = {
            zIndex: `${index}`,
            width: modelW + 'px',
            height: modelH + 'px',
            transform: `translate(${modelX}px, ${modelY}px)`,
            padding: `${EDGELESS_BLOCK_CHILD_PADDING}px`,
            border: `${EDGELESS_BLOCK_CHILD_BORDER_WIDTH}px ${isHiddenNote ? 'dashed' : 'solid'} var(--affine-black-10)`,
            background: isHiddenNote
                ? 'transparent'
                : `var(${background ?? DEFAULT_NOTE_COLOR})`,
            boxShadow: isHiddenNote ? undefined : 'var(--affine-shadow-3)',
            position: 'absolute',
            borderRadius: '8px',
            boxSizing: 'border-box',
            pointerEvents: 'none',
            overflow: 'hidden',
            transformOrigin: '0 0',
            userSelect: 'none',
        };
        return html `
      <div
        class="surface-ref-note-portal"
        style=${styleMap(style)}
        data-model-height="${modelH}"
        data-portal-reference-block-id="${model.id}"
      >
        ${this.renderModel(model)}
      </div>
    `;
    }
};
__decorate([
    property({ attribute: false })
], SurfaceRefNotePortal.prototype, "index", void 0);
__decorate([
    property({ attribute: false })
], SurfaceRefNotePortal.prototype, "model", void 0);
__decorate([
    property({ attribute: false })
], SurfaceRefNotePortal.prototype, "renderModel", void 0);
SurfaceRefNotePortal = __decorate([
    customElement('surface-ref-note-portal')
], SurfaceRefNotePortal);
export { SurfaceRefNotePortal };
//# sourceMappingURL=note.js.map