import { defineComponent, computed, resolveComponent, createElementBlock, openBlock, Fragment, createBlock, createVNode, Teleport, createCommentVNode, withModifiers, createElementVNode, normalizeStyle, toDisplayString, renderList, createTextVNode, createSlots, withCtx, renderSlot } from 'vue';
import './calendar-context-menu.vue.mjs';
import './calendar-edit-panel.vue.mjs';
import _sfc_main$1 from './calendar-edit-panel.vue2.mjs';
import _sfc_main$2 from './calendar-context-menu.vue2.mjs';

"use strict";
const _hoisted_1 = { class: "ll-calendar__event-list-header" };
const _hoisted_2 = { class: "ll-calendar__event-list-heading" };
const _hoisted_3 = { class: "ll-calendar__event-list-container" };
const _hoisted_4 = {
  key: 1,
  class: "ll-calendar__event-list"
};
const _hoisted_5 = ["onClick", "onContextmenu"];
const _hoisted_6 = { class: "ll-calendar__event-multiday-single" };
var _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "calendar-event-list-modal",
  props: {
    open: { type: Boolean, required: true },
    title: { type: String, required: true },
    events: { type: Array, required: true },
    getEventIdentifier: { type: Function, required: true },
    getEventTitle: { type: Function, required: true },
    getEventTimeLabel: { type: Function, required: true },
    onSelectEvent: { type: Function, required: true },
    onContextmenuEvent: { type: Function, required: true },
    editPopoverOpen: { type: Boolean, required: true },
    editPresentationMode: { type: String, required: true },
    editPopoverPlacement: { type: String, required: true },
    contextMenuOpen: { type: Boolean, required: true },
    contextMenuEvent: { required: true },
    contextMenuStyle: { type: Object, required: true },
    editPopoverStyle: { type: Object, required: true },
    editBoundaryStyle: { type: Object, required: false },
    editFormData: { type: Object, required: true },
    editFormColumns: { type: Array, required: true },
    isCreatingEvent: { type: Boolean, required: true },
    editingEventTitle: { type: String, required: true },
    currentEditableEvent: { type: Object, required: true },
    closeContextMenu: { type: Function, required: true },
    handleContextMenuEdit: { type: Function, required: true },
    handleContextMenuCopy: { type: Function, required: true },
    handleContextMenuDelete: { type: Function, required: true },
    handleMaskClose: { type: Function, required: true },
    handleSwitchPresentation: { type: Function, required: true },
    handleConfirmEdit: { type: Function, required: true },
    handleConfirmAndAdd: { type: Function, required: true },
    handleDeleteEditEvent: { type: Function, required: true },
    onBindEditPanelRef: { type: Function, required: false },
    onBindContextMenuPanelRef: { type: Function, required: false },
    panelStyle: { type: Object, required: false }
  },
  emits: ["update:open"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const innerOpen = computed({
      get: () => props.open,
      set: (value) => emit("update:open", value)
    });
    const closePanel = () => {
      innerOpen.value = false;
    };
    const bindEditPanelRef = (instance) => {
      props.onBindEditPanelRef?.(instance);
    };
    const bindContextMenuPanelRef = (instance) => {
      props.onBindContextMenuPanelRef?.(instance);
    };
    const handleSelect = (event, nativeEvent) => {
      props.onSelectEvent({ event, nativeEvent });
    };
    const handleContextmenu = (event, nativeEvent) => {
      props.onContextmenuEvent({ event, nativeEvent });
    };
    return (_ctx, _cache) => {
      const _component_ll_empty = resolveComponent("ll-empty");
      return openBlock(), createElementBlock(
        Fragment,
        null,
        [
          (openBlock(), createBlock(Teleport, { to: "body" }, [
            innerOpen.value ? (openBlock(), createElementBlock(
              "div",
              {
                key: 0,
                class: "ll-calendar__event-list-layer",
                onClick: withModifiers(closePanel, ["self"]),
                onContextmenu: _cache[1] || (_cache[1] = withModifiers(() => {
                }, ["prevent"]))
              },
              [
                createElementVNode(
                  "div",
                  {
                    class: "ll-calendar__event-list-panel",
                    style: normalizeStyle(props.panelStyle),
                    onClick: _cache[0] || (_cache[0] = withModifiers(() => {
                    }, ["stop"]))
                  },
                  [
                    createElementVNode("div", _hoisted_1, [
                      createElementVNode(
                        "div",
                        _hoisted_2,
                        toDisplayString(__props.title),
                        1
                        /* TEXT */
                      ),
                      createElementVNode("button", {
                        type: "button",
                        class: "ll-calendar__event-list-close",
                        "aria-label": "\u5173\u95ED",
                        onClick: closePanel
                      }, " \xD7 ")
                    ]),
                    createElementVNode("div", _hoisted_3, [
                      __props.events.length === 0 ? (openBlock(), createBlock(_component_ll_empty, {
                        key: 0,
                        title: "\u65E0\u65E5\u7A0B"
                      })) : (openBlock(), createElementBlock("div", _hoisted_4, [
                        (openBlock(true), createElementBlock(
                          Fragment,
                          null,
                          renderList(__props.events, (event, idx) => {
                            return openBlock(), createElementBlock("div", {
                              key: `${__props.getEventIdentifier(event)}-${idx}`,
                              class: "ll-calendar__event-list-item",
                              onClick: ($event) => handleSelect(event, $event),
                              onContextmenu: withModifiers(($event) => handleContextmenu(event, $event), ["prevent", "stop"])
                            }, [
                              createElementVNode("div", _hoisted_6, [
                                event.tag ? (openBlock(), createElementBlock(
                                  "span",
                                  {
                                    key: 0,
                                    class: "ll-calendar__event-tag",
                                    style: normalizeStyle(
                                      event.tagColor ? { backgroundColor: event.tagColor } : {}
                                    )
                                  },
                                  toDisplayString(event.tag),
                                  5
                                  /* TEXT, STYLE */
                                )) : createCommentVNode("v-if", true),
                                createTextVNode(
                                  toDisplayString(__props.getEventTitle(event) || "\u672A\u547D\u540D\u65E5\u7A0B"),
                                  1
                                  /* TEXT */
                                )
                              ])
                            ], 40, _hoisted_5);
                          }),
                          128
                          /* KEYED_FRAGMENT */
                        ))
                      ]))
                    ])
                  ],
                  4
                  /* STYLE */
                )
              ],
              32
              /* NEED_HYDRATION */
            )) : createCommentVNode("v-if", true)
          ])),
          createVNode(_sfc_main$1, {
            ref: bindEditPanelRef,
            open: __props.editPopoverOpen,
            "presentation-mode": __props.editPresentationMode,
            placement: __props.editPopoverPlacement,
            style: normalizeStyle(__props.editPopoverStyle),
            "boundary-style": __props.editBoundaryStyle,
            title: __props.editingEventTitle,
            "form-data": __props.editFormData,
            "form-columns": __props.editFormColumns,
            "is-creating-event": __props.isCreatingEvent,
            "current-editable-event": __props.currentEditableEvent,
            onMaskClose: __props.handleMaskClose,
            onSwitchPresentation: __props.handleSwitchPresentation,
            onConfirm: __props.handleConfirmEdit,
            onConfirmAndAdd: __props.handleConfirmAndAdd,
            onDeleteEditEvent: __props.handleDeleteEditEvent
          }, createSlots({
            _: 2
            /* DYNAMIC */
          }, [
            _ctx.$slots["edit-form"] ? {
              name: "edit-form",
              fn: withCtx(({ data }) => [
                renderSlot(_ctx.$slots, "edit-form", { data })
              ]),
              key: "0"
            } : void 0
          ]), 1032, ["open", "presentation-mode", "placement", "style", "boundary-style", "title", "form-data", "form-columns", "is-creating-event", "current-editable-event", "onMaskClose", "onSwitchPresentation", "onConfirm", "onConfirmAndAdd", "onDeleteEditEvent"]),
          createVNode(_sfc_main$2, {
            ref: bindContextMenuPanelRef,
            open: __props.contextMenuOpen,
            style: normalizeStyle(__props.contextMenuStyle),
            event: __props.contextMenuEvent,
            "current-editable-event": __props.currentEditableEvent,
            onClose: __props.closeContextMenu,
            onEdit: __props.handleContextMenuEdit,
            onCopy: __props.handleContextMenuCopy,
            onRemove: __props.handleContextMenuDelete
          }, {
            "event-contextmenu": withCtx(({ event, close, edit, copy, remove }) => [
              renderSlot(_ctx.$slots, "event-contextmenu", {
                event,
                close,
                edit,
                copy,
                remove
              })
            ]),
            _: 3
            /* FORWARDED */
          }, 8, ["open", "style", "event", "current-editable-event", "onClose", "onEdit", "onCopy", "onRemove"])
        ],
        64
        /* STABLE_FRAGMENT */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=calendar-event-list-modal.vue2.mjs.map
