'use strict';

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

const index = require('./index-8277cbb3.js');
require('./global-b7b1b8fe.js');
const domContextHooks_module = require('./dom-context-hooks.module-e7b6727c.js');
const index_module = require('./index.module-f8c8495f.js');
const cjs = require('./cjs-1066ec21.js');
const utils = require('./utils-6847bc06.js');
require('./JSS-8503a151.js');
const useLeadFormState = require('./useLeadFormState-b4c2ab5b.js');
const sqmLeadCheckboxFieldView = require('./sqm-lead-checkbox-field-view-0af2a157.js');

function useLeadCheckboxField() {
  const leadFormState = domContextHooks_module.d(useLeadFormState.LEAD_FORM_STATE_CONTEXT);
  return {
    states: {
      leadFormState,
    },
  };
}

const LeadCheckboxField = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.ignored = true;
    /**
     * @uiName Checkbox label
     * @uiWidget textArea
     */
    this.checkboxLabel = "By signing up you agree to the {labelLink}";
    /**
     * Used with link text if the checkbox label contains {labelLink}
     *
     * @uiName Checkbox label link
     */
    this.checkboxLabelLink = "https://example.com";
    /**
     * @uiName Checkbox label link lext
     */
    this.checkboxLabelLinkText = "Terms and Conditions";
    /**
     * @uiName Unchecked error message
     */
    this.errorMessage = "Must be checked";
    /**
     * @uiName Optional
     */
    this.checkboxOptional = false;
    domContextHooks_module.h$1(this);
  }
  disconnectedCallback() { }
  render() {
    const missingProps = utils.getMissingProps([
      {
        attribute: "checkbox-name",
        value: this.checkboxName,
      },
    ]);
    if (!index_module.isDemo() && missingProps) {
      return (index.h(useLeadFormState.RequiredPropsError, { missingProps: missingProps, heading: "An error occured while loading this form", subheading: "A technical problem prevented this checkbox field from loading. Please contact us with the link to this page.", description: "Values for the following attributes are missing:" }));
    }
    const content = {
      ...utils.getProps(this),
    };
    const { states } = index_module.isDemo()
      ? useLeadCheckboxFieldDemo(this)
      : useLeadCheckboxField();
    return (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, { states: states, content: content }));
  }
};
function useLeadCheckboxFieldDemo(props) {
  return cjs.cjs({
    states: {
      leadFormState: {},
    },
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
}

exports.sqm_lead_checkbox_field = LeadCheckboxField;
