import { Component, Event, h, Host, Listen, Prop, State } from '@stencil/core';
import { takvimDailyCalendarI18nDefault } from "@dvn/takvim/components/takvim-daily-calendar/i18n";
import { InvalidationAction, NotificationAction } from "@dvn/core/models/actions";
import { generateActionEmitData } from "@dvn/core/components/views/dvn-card-view/action-util";
export class DvnAppViewTakvimDailyCalendarView {
  async componentWillLoad() {
    this.strings = await this.apiSozluk.getContent(this.view.i18nEntryId, takvimDailyCalendarI18nDefault);
  }
  // TODO this event should be defined in config or the meeting detail should be shown in this view
  // @Listen('viewMeeting')
  // onViewMeeting(event: CustomEvent) {
  //   console.log('onViewMeeting');
  //   console.log(event.detail);
  // }
  onAction(event) {
    var _a, _b;
    const { view } = this;
    if (view.availableTimePickerConfig.successNavigationAction) {
      // show go to meeting page action confirmation dialog
      this.createdMeeting = event.detail;
    }
    (_b = (_a = view.availableTimePickerConfig.events) === null || _a === void 0 ? void 0 : _a.success) === null || _b === void 0 ? void 0 : _b.forEach(eventToEmit => {
      if (eventToEmit instanceof InvalidationAction) {
        this.invalidation.emit(eventToEmit);
      }
      if (eventToEmit instanceof NotificationAction) {
        this.notification.emit(eventToEmit);
      }
    });
  }
  render() {
    const { strings } = this;
    return (h(Host, { class: "d-flex flex-grow-1", style: { overflow: 'hidden' } },
      h("takvim-daily-calendar", { apiData: this.apiData, apiTakvim: this.apiTakvim, strings: this.strings, user: this.user, userSettings: this.userSettings, membershipConfigId: this.membership.config._id, calendarConfigId: this.view.table._id, membershipConfigIdToGroupMeetings: this.view.membershipConfigIdToGroupMeetings, membershipConfigIdToViewOnMeetings: this.view.membershipConfigIdToViewOnMeetings }),
      h("dvn-dialog", { title: strings.meetingIsScheduled, shown: !!this.createdMeeting, onDismiss: () => this.createdMeeting = undefined },
        h("div", { slot: "actions" },
          h("dvn-button", { view: "flat", onClick: () => this.createdMeeting = undefined }, strings.stayOnPage),
          h("dvn-button", { tint: "primary", view: "flat", onClick: () => {
              this.action.emit(generateActionEmitData({}, this.createdMeeting, this.view.availableTimePickerConfig.successNavigationAction));
              this.createdMeeting = undefined;
            } }, strings.goToMeetingPage)))));
  }
  static get is() { return "dvn-app-view-takvim-daily-calendar-view"; }
  static get properties() { return {
    "view": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "TakvimDailyCalendarViewConfig",
        "resolved": "TakvimDailyCalendarViewConfig",
        "references": {
          "TakvimDailyCalendarViewConfig": {
            "location": "import",
            "path": "@dvn/takvim/views/dvn-app-view-takvim-daily-calendar-view/takvim-daily-calendar-view-config"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "params": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "TakvimDailyCalendarViewParams",
        "resolved": "TakvimDailyCalendarViewParams",
        "references": {
          "TakvimDailyCalendarViewParams": {
            "location": "import",
            "path": "@dvn/takvim/views/dvn-app-view-takvim-daily-calendar-view/params"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "user": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "User",
        "resolved": "User",
        "references": {
          "User": {
            "location": "import",
            "path": "@dvn/kimlik/api/models"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "userSettings": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "UserSettings",
        "resolved": "UserSettings",
        "references": {
          "UserSettings": {
            "location": "import",
            "path": "@dvn/kimlik/api/models/UserSettings"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "membership": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Membership",
        "resolved": "Membership",
        "references": {
          "Membership": {
            "location": "import",
            "path": "@dvn/core/models/membership"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiData": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "DataApi",
        "resolved": "DataApi",
        "references": {
          "DataApi": {
            "location": "import",
            "path": "@dvn/core/api"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiSozluk": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "SozlukApi",
        "resolved": "SozlukApi",
        "references": {
          "SozlukApi": {
            "location": "import",
            "path": "@dvn/sozluk/api"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiTakvim": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "TakvimApi",
        "resolved": "TakvimApi",
        "references": {
          "TakvimApi": {
            "location": "import",
            "path": "@dvn/takvim/api/takvimApi"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiUye": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "UyeApi",
        "resolved": "UyeApi",
        "references": {
          "UyeApi": {
            "location": "import",
            "path": "@dvn/uye/api"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "createdMeeting": {},
    "strings": {}
  }; }
  static get events() { return [{
      "method": "invalidation",
      "name": "invalidation",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }, {
      "method": "notification",
      "name": "notification",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }, {
      "method": "action",
      "name": "action",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }]; }
  static get listeners() { return [{
      "name": "createMeeting",
      "method": "onAction",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
