'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-1141a245.js');
const mentorintyBridgeApi = require('./mentorinty-bridge-api-0534712d.js');
const wrapperUtil = require('./wrapper-util-fc8865e9.js');
require('./apiBase-e4ebaf8b.js');
require('./data-transfer-field-e8417d5f.js');
require('./BaseField-381327a9.js');
require('./filter-d5040f65.js');
require('./FieldModelGenerator-1900d81a.js');
require('./reference-field-1239b0c3.js');
require('./index-2eea69a0.js');
require('./FieldGenerator-279a646b.js');
require('./date-a24d7714.js');
require('./index-0783d14f.js');
require('./index-e8e4d80b.js');
require('./index-9d3d3d15.js');
require('./index-9fd84b93.js');
require('./index-61f9621a.js');
require('./index-e751cab0.js');
require('./attachment-b0acc4c1.js');
require('./data-model-9afb7f54.js');
require('./membership-ed8d3277.js');
require('./table-config-8b14c7d3.js');
require('./string-de672b69.js');
require('./User-e889279b.js');
require('./CalendarConfig-ee7bb722.js');
require('./card-list-view-config-61d6ecea.js');
require('./view-config-7972654b.js');
require('./detail-view-config-4fe32db3.js');
require('./takvim-available-time-picker-view-config-816b6faf.js');
require('./common-wrapper-util-a539b2ff.js');
require('./models-8b357ee7.js');

const mentornityScheduleMeetingButtonOnCardCss = "mentornity-schedule-meeting-button-on-card{height:326px;background:var(--color-background-secondary);padding:calc(2 * var(--spacing-unit)) 0 0 calc(3 * var(--spacing-unit));border-bottom-left-radius:var(--card-corner-radius);border-bottom-right-radius:var(--card-corner-radius)}mentornity-schedule-meeting-button-on-card .title{font-size:var(--font-size-small);margin-left:calc(1 * var(--spacing-unit));color:var(--color-text-secondary)}mentornity-schedule-meeting-button-on-card takvim-available-time-picker>dvn-card{--color-elevated-item-background:var(--color-background-secondary)}mentornity-schedule-meeting-button-on-card takvim-available-time-picker>dvn-date-picker>.calendar-container{--color-elevated-item-background:var(--color-background-secondary)}mentornity-schedule-meeting-button-on-card takvim-available-time-picker-selected-day>dvn-card{--color-elevated-item-background:var(--color-background-secondary)}";

const MentornityScheduleMeetingButtonOnCard = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.action = index.createEvent(this, "action", 7);
    this.shouldShow = false;
  }
  componentWillLoad() {
    this.shouldShow = isInViewport(this.el);
    // check if the component is visible periodically
    this.currentTimePositionUpdater = setInterval(() => {
      if (this.shouldShow) {
        // no need to hide already loaded component
        return;
      }
      this.shouldShow = isInViewport(this.el);
    }, 1000);
  }
  disconnectedCallback() {
    clearInterval(this.currentTimePositionUpdater);
  }
  render() {
    var _a;
    if (!this.shouldShow) {
      return (index.h(index.Host, { class: "d-flex flex-grow-1 align-items-center justify-content-center" }, index.h("dvn-progress", { indefinite: true, tint: "primary" })));
    }
    const { item } = this;
    const language = ((_a = this.meta) === null || _a === void 0 ? void 0 : _a.language) || 'en';
    const { mentornityBridgeApi, apiSozluk, guestToPassToAvailableTimePickerAsCurrentUser, userSettings, membership, } = this.meta || {};
    return (index.h(index.Host, { class: "d-flex flex-column flex-grow-1" }, index.h("div", { class: "title" }, mentorintyBridgeApi.getEmbeddedTranslation(language, 'getMeeting').toLocaleUpperCase()), index.h("dvn-app-view-takvim-available-time-picker-view", { apiData: mentornityBridgeApi, apiSozluk: apiSozluk, apiTakvim: mentornityBridgeApi, apiUye: mentornityBridgeApi, user: guestToPassToAvailableTimePickerAsCurrentUser, userSettings: userSettings, membership: membership, params: {
        viewedUserMembership: item,
      }, view: wrapperUtil.getAvailableTimePickerViewConfig(mentornityBridgeApi.organisationConfig) })));
  }
  get el() { return index.getElement(this); }
};
function isInViewport(element) {
  const rect = element.getBoundingClientRect();
  return (rect.top >= 0 &&
    rect.left >= 0 &&
    rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
    rect.right <= (window.innerWidth || document.documentElement.clientWidth));
}
MentornityScheduleMeetingButtonOnCard.style = mentornityScheduleMeetingButtonOnCardCss;

exports.mentornity_schedule_meeting_button_on_card = MentornityScheduleMeetingButtonOnCard;
