import { Component, Event, h, Listen, Prop, State } from '@stencil/core';
import { StateOfReminder } from '../../utils/utils';
import '@maggioli-design-system/mds-avatar/dist/mds-avatar/mds-avatar';
import '@maggioli-design-system/mds-img/dist/mds-img/mds-img';
import '@maggioli-design-system/mds-text/dist/mds-text/mds-text';
export class SwAddonReminderFooter {
  constructor() {
    this.imgBaseUrl = '/services/eolo-api-documentsmanaging/api/profile-image/get/';
    this.reminderDoneProp = false;
    this.reminderDone = false;
    this.controlParam = false;
    this.submitValidation = false;
    this.reminderAddonInfo = null;
  }
  switchReminderDone() {
    if (this.status === StateOfReminder.view) {
      this.reminderDone = !this.reminderDone;
      this.reminderDoneProp = this.reminderDone;
      this.reminderDoneEmitter.emit(this.reminderDone);
    }
  }
  connectedCallback() {
    this.reminderDone = this.reminderDoneProp;
  }
  componentWillRender() {
    this.reminderDone = this.reminderDoneProp;
    this.status = this.state;
  }
  componentWillUpdate() {
    if (this.reminderAddonInfo.hour && this.reminderAddonInfo.minute && this.reminderAddonInfo.duration && this.reminderAddonInfo.description && this.reminderAddonInfo.date && this.reminderAddonInfo.name) {
      this.errorEmitter.emit(false);
      this.controlParam = true;
    }
    else {
      this.controlParam = false;
    }
  }
  componentShouldUpdate() {
    this.status = this.state;
  }
  undoReminder() {
    this.undoReminderEmitter.emit(true);
  }
  editReminder() {
    let output = Object.assign({}, this.reminderAddonInfo);
    output.author = this.author;
    this.editReminderEmitterFromSubmit.emit(output);
    this.createReminderEmitter.emit('view');
  }
  createReminder() {
    if (this.submitValidation) {
      this.errorEmitter.emit(false);
      let output = Object.assign({}, this.reminderAddonInfo);
      output.author = this.author;
      this.createReminderEmitterFromSubmit.emit(output);
      this.createReminderEmitter.emit('view');
    }
    else {
      this.errorEmitter.emit(true);
    }
  }
  render() {
    if (this.status === StateOfReminder.create) {
      return (h("div", { class: "reminder-footer" },
        h("div", { class: "items-container" },
          "Azioni",
          h("div", { class: "buttons-container" },
            h("sw-input-button", { onClick: () => this.undoReminder(), icon: false, text: "Annulla" }),
            h("sw-input-button", { onClick: () => this.createReminder(), icon: true, dark: true, text: "Crea" })))));
    }
    else if (this.status === StateOfReminder.view) {
      return (h("div", { class: "reminder-footer" },
        h("div", { class: "author-container" },
          "Utenti",
          h("div", { class: "info-author" },
            h("div", { class: "avatar" },
              h("mds-avatar", { class: "avatar-maggioli", initials: "https://www.boorp.com/avatars_100x100_for_myspace/25.png", src: this.imgBaseUrl + this.author.image })),
            h("div", { class: "text-info" },
              h("div", null,
                "Modificato da ",
                h("b", null,
                  this.author.name,
                  " ",
                  this.author.surname)),
              h("div", null, this.author.date)))),
        h("div", { class: "items-container-view" },
          "Azioni",
          h("div", { class: "buttons-container-view" },
            h("sw-input-button", { size: "200px", class: { 'generic': true, 'hidden': this.reminderDone === true }, icon: false, dark: true, text: "Segna come completato" }),
            h("sw-input-button", { size: "200px", class: { 'generic': true, 'hidden': this.reminderDone === false }, icon: false, text: "Non completato" })))));
    }
    else {
      return (h("div", { class: "reminder-footer" },
        h("div", { class: "items-container" },
          "Azioni",
          h("div", { class: "buttons-container" },
            h("sw-input-button", { onClick: () => this.undoReminder(), icon: false, text: "Annulla" }),
            h("sw-input-button", { onClick: () => this.editReminder(), icon: true, dark: true, text: "Modifica" })))));
    }
  }
  static get is() { return "sw-addon-reminder-footer"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["sw-addon-reminder-footer.css"]
  }; }
  static get styleUrls() { return {
    "$": ["sw-addon-reminder-footer.css"]
  }; }
  static get properties() { return {
    "state": {
      "type": "number",
      "mutable": false,
      "complexType": {
        "original": "StateOfReminder",
        "resolved": "StateOfReminder.create | StateOfReminder.edit | StateOfReminder.view",
        "references": {
          "StateOfReminder": {
            "location": "import",
            "path": "../../utils/utils"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "state",
      "reflect": false
    },
    "reminderDoneProp": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "reminder-done-prop",
      "reflect": false,
      "defaultValue": "false"
    },
    "submitValidation": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "submit-validation",
      "reflect": false,
      "defaultValue": "false"
    },
    "author": {
      "type": "unknown",
      "mutable": true,
      "complexType": {
        "original": "AuthorStencilDTO",
        "resolved": "AuthorStencilDTO",
        "references": {
          "AuthorStencilDTO": {
            "location": "import",
            "path": "../../interfaces"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "reminderAddonInfo": {
      "type": "unknown",
      "mutable": true,
      "complexType": {
        "original": "{name?: string, description?: string, hour?:string, minute?:string, duration?:string, date?: string}",
        "resolved": "{ name?: string; description?: string; hour?: string; minute?: string; duration?: string; date?: string; }",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "defaultValue": "null"
    }
  }; }
  static get states() { return {
    "reminderDone": {},
    "reminderAddonInfoState": {}
  }; }
  static get events() { return [{
      "method": "createReminderEmitter",
      "name": "createReminderEmitter",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }, {
      "method": "createReminderEmitterFromSubmit",
      "name": "createReminderEmitterFromSubmit",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "AddonReminderStencilDTO",
        "resolved": "AddonReminderStencilDTO",
        "references": {
          "AddonReminderStencilDTO": {
            "location": "import",
            "path": "../../interfaces"
          }
        }
      }
    }, {
      "method": "undoReminderEmitter",
      "name": "undoReminderEmitter",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      }
    }, {
      "method": "reminderDoneEmitter",
      "name": "reminderDoneEmitter",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      }
    }, {
      "method": "errorEmitter",
      "name": "errorEmitter",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      }
    }, {
      "method": "editReminderEmitterFromSubmit",
      "name": "editReminderEmitterFromSubmit",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "AddonReminderStencilDTO",
        "resolved": "AddonReminderStencilDTO",
        "references": {
          "AddonReminderStencilDTO": {
            "location": "import",
            "path": "../../interfaces"
          }
        }
      }
    }]; }
  static get listeners() { return [{
      "name": "toggleReminderEmitter",
      "method": "switchReminderDone",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
