import { r as registerInstance, d as createEvent, B as Build, h } from './index-33e43734.js';
import { t as toastController } from './overlays-0a1b9fc7.js';
import './ionic-global-bd76bde2.js';
import './helpers-7e937ffa.js';

const modalScannerCss = "modal-scanner .banner{background-color:var(--ion-color-secondary)}modal-scanner h1{color:#fff}modal-scanner p{margin:0 0 15px 0;color:rgba(255, 255, 255, 0.8);font-weight:normal}.modal-scanner{--width:700px;--max-width:700px}@media only screen and (max-width: 800px){.modal-scanner{--width:100%;--max-width:auto}}";

let ModalScanner = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.floodteamCloseModal = createEvent(this, "floodteamCloseModal", 7);
  }
  onReset(event) {
    var _a;
    if (((_a = event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "bulkUpdateUsers") {
      const sendEmailModalEl = document.querySelector("ion-modal.modal-scanner");
      if (sendEmailModalEl === null || sendEmailModalEl === void 0 ? void 0 : sendEmailModalEl.dismiss) {
        sendEmailModalEl.dismiss();
      }
    }
  }
  async onSuccess(event) {
    var _a;
    if (((_a = event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "bulkUpdateUsers") {
      const sendEmailModalEl = document.querySelector("ion-modal.modal-scanner");
      if (sendEmailModalEl === null || sendEmailModalEl === void 0 ? void 0 : sendEmailModalEl.dismiss) {
        await sendEmailModalEl.dismiss();
        this.presentToast();
      }
    }
  }
  async presentToast() {
    const toast = await toastController.create({
      message: `Scanning...`,
      duration: 2000,
    });
    toast.present();
  }
  onScanSuccess(decodedText, decodedResult) {
    // Handle on success condition with the decoded text or result.
    console.log(`Scan result: ${decodedText}`, decodedResult);
    // ...
    this.qrCodeScanner.clear();
    // ^ this will stop the scanner (video feed) and clear the scan area.
  }
  componentDidLoad() {
    if (!(Build === null || Build === void 0 ? void 0 : Build.isBrowser))
      return;
    setTimeout(() => {
      this.qrCodeScanner = new window.Html5QrcodeScanner("reader", {
        fps: 10,
        qrbox: 250,
      });
      this.qrCodeScanner.render(this.onScanSuccess.bind(this));
    }, 100);
  }
  render() {
    return [
      h("ion-header", null, h("ion-toolbar", null, h("ion-title", null, "Scan QR Code"), h("ion-buttons", { slot: "end" }, h("ion-button", { onClick: () => this.floodteamCloseModal.emit(), style: {
          "--color": "var(--ion-text-color)",
          "--color-hover": "var(--ion-color-danger",
        } }, h("ion-icon", { slot: "icon-only", name: "close-circle-outline" }))))),
      h("ion-content", null, h("div", { id: "reader" })),
    ];
  }
};
ModalScanner.style = modalScannerCss;

export { ModalScanner as modal_scanner };

//# sourceMappingURL=modal-scanner.entry.js.map