'use strict';

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

const index = require('./index-b8c5f2d4.js');
const overlays = require('./overlays-80829bce.js');
require('./ionic-global-f3f011dc.js');
require('./framework-delegate-10468a40.js');
require('./helpers-ab0173af.js');
require('./hardware-back-button-39b3f658.js');
require('./index-b008ec2b.js');

const FormController = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
  }
  /**
   * Display a form in a modal. If the form is canceled, it resolves to
   * `undefined`. If the form is submitted, it resolves to the GeoJSON
   * feature updated by the form.
   * @param feature The GeoJSON feature that the form will edit.
   * @param options Option object used to set the properties of the `gl-form`.
   */
  async create(feature, options) {
    let form = document.createElement("gl-form");
    form.feature = feature;
    for (let optionName in options)
      form[optionName] = options[optionName];
    const modal = await overlays.modalController.create({
      component: form,
    });
    await modal.present();
    return await new Promise((resolve) => {
      form.addEventListener("glFormCancel", () => {
        modal.dismiss();
        resolve(undefined);
      });
      form.addEventListener("glFormSubmit", () => {
        modal.dismiss();
        resolve(feature);
      });
    });
  }
};

exports.gl_form_controller = FormController;

//# sourceMappingURL=gl-form-controller.cjs.entry.js.map