'use strict';

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

const index = require('./index-fd2bbf0b.js');
const clipboard = require('./clipboard-b6de46b2.js');
require('./_commonjsHelpers-a5111d61.js');

const shareCss = "fireenjin-share ion-item:hover{cursor:pointer}fireenjin-share .share-twitter ion-icon{color:#1da1f3}fireenjin-share .share-twitter ion-icon svg{fill:#1da1f3}fireenjin-share .share-twitter:hover .item{color:#1da1f3}fireenjin-share .share-facebook ion-icon{color:#3b5998}fireenjin-share .share-facebook ion-icon svg{fill:#3b5998}fireenjin-share .share-facebook:hover .item{color:#3b5998}fireenjin-share .share-google ion-icon{color:#dd4b38}fireenjin-share .share-google ion-icon svg{fill:#dd4b38}fireenjin-share .share-google:hover .item{color:#dd4b38}";

let Share = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinShareClose = index.createEvent(this, "fireenjinShareClose", 7);
  }
  // Implementation Example
  // import { SocialSharing } from "@ionic-native/social-sharing";
  //
  // @Listen("fireenjinShare")
  // async share(event) {
  //   try {
  //     if (navigator?.share) {
  //       await navigator.share(event.detail.data);
  //       return;
  //     }
  //     if (!navigator?.share) {
  //       this.sharePopover = await popoverController.create({
  //         event: event.detail.event,
  //         component: "fireenjin-share",
  //         componentProps: event.detail.data,
  //       });
  //       this.sharePopover.present();
  //       return;
  //     }
  //     await SocialSharing.share(
  //       event.detail.data.message,
  //       event.detail.data.subject,
  //       event.detail.data.file,
  //       event.detail.data.url
  //     );
  //   } catch (e) {
  //     console.log("Error using share functionality...", e);
  //   }
  // }
  openPopup(event, type) {
    event.preventDefault();
    let popupUrl;
    if (type === "facebook") {
      popupUrl = `https://www.facebook.com/dialog/share?app_id=${this.facebookAppId}&display=popup&href=${this.url}`;
    }
    else if (type === "google") {
      popupUrl = `https://plus.google.com/share?url=${this.url}`;
    }
    else if (type === "twitter") {
      popupUrl = `https://twitter.com/intent/tweet?url=${this.url}&text=${this.text}`;
    }
    else {
      return false;
    }
    this.fireenjinShareClose.emit({ event, type });
    window.open(popupUrl, "Share", type === "google" ? "height=600,width=400" : "height=400,width=600");
  }
  componentDidLoad() {
    if (!(index.Build === null || index.Build === void 0 ? void 0 : index.Build.isBrowser))
      return;
    {
      new clipboard.ClipboardJS(this.copyItemEl);
    }
  }
  render() {
    return (index.h("ion-list", null, index.h("ion-item", { lines: this.lines, class: "share-twitter", onClick: (event) => this.openPopup(event, "twitter") }, index.h("ion-icon", { slot: "end", name: "logo-twitter" }), "Share on Twitter"), index.h("ion-item", { lines: this.lines, class: "share-facebook", onClick: (event) => this.openPopup(event, "facebook") }, index.h("ion-icon", { slot: "end", name: "logo-facebook" }), "Share on Facebook"), index.h("ion-item", { lines: this.lines, ref: (el) => (this.copyItemEl = el), class: "share-clipboard", "data-clipboard-text": this.url }, index.h("ion-icon", { slot: "end", name: "clipboard" }), "Copy to Clipboard")));
  }
};
Share.style = shareCss;

exports.fireenjin_share = Share;

//# sourceMappingURL=fireenjin-share.cjs.entry.js.map