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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { LitElement, html, css, property, } from 'lit-element';
import { classMap } from 'lit-html/directives/class-map';
// This decorator defines the element.
export class Collapse extends LitElement {
    constructor() {
        super(...arguments);
        // This decorator creates a property accessor that triggers rendering and
        // an observed attribute.
        this.mood = 'great';
        this.open = true;
    }
    handleClick() {
        this.open = !this.open;
        this.requestUpdate();
    }
    // Render element DOM by returning a `lit-html` template.
    render() {
        return html `
      <div class="stk-snippet stk-snippet-wrapper stk-container incut no-ad vrez-margins" data-ce-tag="container" data-container-name="Incut">
        <div class="stk-container my-outer-block incut_header" data-ce-tag="container">
          <slot name="title" class="stk-reset wp-exclude-emoji stk-theme_37074__style_medium_header incut_title">Заголовок</slot>
          <div @click="${this.handleClick} class="stk-container my-outer-block incut_svg" data-ce-tag="container">
            <svg
              class=${classMap({ incut_arrow: true, open: this.open })}
              width="18" height="9" viewbox="0 0 18 9" fill="none" xmlns="http://www.w3.org/2000/svg"
            >
              <path d="M17 1.5L9 7.5L1 1.5" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
            </svg>
          </div>
        </div>
        <slot name='body'
          class=${classMap({ body: true, open: this.open })}
        ></slot>
      </div>
    `;
    }
}
Collapse.styles = css `
    :host {
      display: block;
      padding: 1.25rem;
      background: #f5f5f5!important;
      overflow: hidden;
      border: .5px solid #e6e6e6;
      box-sizing: border-box;
      border-radius: 8px;
      margin-bottom: 20px;
    }
    .incut_arrow {
      transition: .4s;
    }
    .incut_arrow.open {
      transform: rotate(-180deg);
    }
    .body {
      display: none;
    }
    .body.open {
      display: block;
    }
    `;
__decorate([
    property(),
    __metadata("design:type", Object)
], Collapse.prototype, "mood", void 0);
const defaultOptions = {
    name: 'collapse',
    title: 'Collapse',
    tag: 'ARENA-COLLAPSE',
    attributes: [],
    shortcut: 'Alt + KeyC',
    hint: 'c',
    command: 'add-collapse',
    component: 'arena-collapse',
    marks: [
        {
            tag: 'ARENA-COLLAPSE',
            attributes: [],
        },
    ],
};
const collapsePlugin = (opts) => ({
    register(textarena) {
        const { name, icon, title, tag, attributes, shortcut, hint, command, component, marks, } = Object.assign(Object.assign({}, defaultOptions), (opts || {}));
        if (!customElements.get(component)) {
            customElements.define(component, Collapse);
        }
        const paragraph = textarena.getDefaultTextArena();
        if (!paragraph) {
            throw new Error('Default Arena for text not found');
        }
        const allowedArenas = textarena.getSimpleArenas();
        const collapseBodyContainer = textarena.registerArena({
            name: 'collapse-body-container',
            tag: 'COLLAPSE-BODY',
            attributes: [
                'slot=body',
            ],
            hasChildren: true,
            allowedArenas,
            arenaForText: paragraph,
        }, [
            {
                tag: 'COLLAPSE-BODY',
                attributes: [
                    'slot=body',
                ],
            },
        ], []);
        const collapseTitleParagraph = textarena.registerArena({
            name: 'collapse-title-paragraph',
            tag: 'H3',
            attributes: [
                'slot=title',
            ],
            hasText: true,
            nextArena: paragraph,
        }, [
            {
                tag: 'H3',
                attributes: [
                    'slot=title',
                ],
            },
        ], []);
        const arena = textarena.registerArena({
            name,
            tag,
            attributes,
            protectedChildren: [
                [collapseTitleParagraph, {}, 'Заголовок'],
                [collapseBodyContainer, {}, 'Контент'],
            ],
            arenaForText: collapseBodyContainer,
        }, marks, [textarena.getRootArenaName()]);
        textarena.registerCommand(command, (ta, selection) => {
            const sel = ta.insertBeforeSelected(selection, arena);
            return sel;
        });
        textarena.registerShortcut(shortcut, command);
        textarena.registerCreator({
            name,
            icon,
            title,
            shortcut,
            hint,
            command,
            canShow: (node) => node.parent.isAllowedNode(arena),
        });
    },
});
export default collapsePlugin;
//# sourceMappingURL=collapse-plugin.js.map