'use strict';

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

const index = require('./index-d685a739.js');
const delay = require('./delay-e91dba76.js');
const scheduleArray = require('./scheduleArray-0ba3d6f8.js');

function isNumeric(val) {
    return !scheduleArray.isArray(val) && (val - parseFloat(val) + 1) >= 0;
}

function timer(dueTime = 0, periodOrScheduler, scheduler) {
    let period = -1;
    if (isNumeric(periodOrScheduler)) {
        period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
    }
    else if (delay.isScheduler(periodOrScheduler)) {
        scheduler = periodOrScheduler;
    }
    if (!delay.isScheduler(scheduler)) {
        scheduler = scheduleArray.async;
    }
    return new scheduleArray.Observable(subscriber => {
        const due = isNumeric(dueTime)
            ? dueTime
            : (+dueTime - scheduler.now());
        return scheduler.schedule(dispatch, due, {
            index: 0, period, subscriber
        });
    });
}
function dispatch(state) {
    const { index, period, subscriber } = state;
    subscriber.next(index);
    if (subscriber.closed) {
        return;
    }
    else if (period === -1) {
        return subscriber.complete();
    }
    state.index = index + 1;
    this.schedule(state, period);
}

const getLocalResourceUrl = (relativePath) => {
    const resourcesUrlElement = document.querySelector('script[data-fl-namespace="design-system"][data-fl-resources-url]');
    const resourcesUrl = (resourcesUrlElement && resourcesUrlElement.getAttribute('data-fl-resources-url')) || '';
    try {
        return new URL(relativePath, resourcesUrl).href;
    }
    catch (error) {
        return `${resourcesUrl}/${relativePath}`;
    }
};

const styleGuideCss = "";

const FlareStyleGuide = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.data = [
      'Apple',
      'Application',
      'Appetizer',
      'Anna',
      'Banana',
      'Archery',
      'Apogee'
    ].map((v) => ({
      label: v,
      value: v
    }));
    this.searchFunction = (query) => {
      const results = this.data.filter((item) => item.label.toLowerCase().includes(query.toLowerCase()));
      return delay.of(results).pipe(delay.delay(1000)).toPromise();
    };
  }
  render() {
    return (index.h(index.Host, null, index.h("link", { rel: "stylesheet", href: getLocalResourceUrl('beacon.css'), media: "all" }), this.themeCssUrl && index.h("link", { rel: "stylesheet", href: this.themeCssUrl, media: "all" }), index.h("div", { class: "container m-3 p-5 shadow" }, index.h("h1", null, "Beacon"), index.h("h5", null, "Flare-Apollo Component Library \uD83D\uDE80"), index.h("div", { class: "row" }, index.h("div", { class: "col" }, index.h("ul", { class: "list-group" }, index.h("li", { class: "list-group-item" }, index.h("small", { class: "text-muted" }, "Typography"), index.h("div", { class: "col" }, index.h("h1", null, "h1 Heading"), index.h("h2", null, "h2 Sub-heading"), index.h("h3", null, "h3 Sub-heading"), index.h("h4", null, "h4 Sub-heading"), index.h("p", null, "Paragraph"), index.h("div", { class: "d-flex flex-column" }, index.h("strong", null, "Strong"), index.h("small", null, "small"), index.h("a", { href: "https://www.flarehr.com", target: "_blank" }, "Weblink")))), index.h("li", { class: "list-group-item" }, index.h("small", { class: "text-muted" }, "Buttons"), index.h("div", { class: "col-3 my-2" }, this.renderButtonVariants())), index.h("li", { class: "list-group-item" }, index.h("small", { class: "text-muted" }, "Loading indicator"), index.h("div", { class: "col" }, index.h("fl-loading-indicator", null), index.h("fl-loading-indicator", { theme: "dark" }))), index.h("li", { class: "list-group-item" }, index.h("small", { class: "text-muted" }, "Dropdown"), index.h("div", { class: "col-4" }, index.h("fl-dropdown", { options: this.data }))), index.h("li", { class: "list-group-item" }, index.h("small", { class: "text-muted" }, "Async Dropdown"), index.h("div", { class: "col-4" }, index.h("fl-dropdown-async", { "min-search-string-length": "2", searchFunction: this.searchFunction }))), index.h("li", { class: "list-group-item" }, index.h("small", { class: "text-muted" }, "Promise Button"), index.h("div", { class: "col-3 my-2" }, index.h("fl-promise-button", { isBlockElement: true, promiseFn: () => this.takeTime() }, "Promise Button block")), index.h("div", { class: "col-3 my-2" }, index.h("fl-promise-button", { promiseFn: () => this.takeTime() }, "Promise Button")), index.h("div", { class: "col-3 my-2" }, index.h("fl-promise-button", { variant: "secondary", promiseFn: () => this.takeTime() }, "Secondary Promise Button"))), index.h("li", { class: "list-group-item" }, index.h("small", { class: "text-muted" }, "Radio buttons"), index.h("div", { class: "col my-2" }, index.h("div", { class: "form-check fl-radio-container" }, index.h("input", { class: "form-check-input", type: "radio", name: "flexRadioDefault", id: "flexRadioDefault" }), index.h("label", { class: "form-check-label", htmlFor: "flexRadioDefault" }, "Default radio")))), index.h("li", { class: "list-group-item" }, index.h("small", { class: "text-muted" }, "Checkboxes"), index.h("div", { class: "col my-2" }, index.h("div", { class: "form-check fl-checkbox-container" }, index.h("input", { class: "form-check-input", type: "checkbox", id: "flexCheckDefault" }), index.h("label", { class: "form-check-label", htmlFor: "flexCheckDefault" }, "Default checkbox"))))))))));
  }
  renderButtonVariants() {
    return (index.h("ul", { class: "list-group" }, index.h("li", { class: "list-group-item" }, index.h("i", null, "Primary"), index.h("fl-button", { isBlockElement: true }, "Button")), index.h("li", { class: "list-group-item" }, index.h("i", null, "Primary, disabled"), index.h("fl-button", { isBlockElement: true, disabled: true }, "Button")), index.h("li", { class: "list-group-item" }, index.h("i", null, "Primary Outline"), index.h("fl-button", { isBlockElement: true, outline: true }, "Button")), index.h("li", { class: "list-group-item" }, index.h("i", null, "Primary Outline, disabled"), index.h("fl-button", { isBlockElement: true, disabled: true, outline: true }, "Button")), index.h("li", { class: "list-group-item" }, index.h("i", null, "Secondary"), index.h("fl-button", { isBlockElement: true, variant: "secondary" }, "Button")), index.h("li", { class: "list-group-item" }, index.h("i", null, "Secondary, disabled"), index.h("fl-button", { isBlockElement: true, disabled: true, variant: "secondary" }, "Button")), index.h("li", { class: "list-group-item" }, index.h("i", null, "Secondary Outline"), index.h("fl-button", { isBlockElement: true, variant: "secondary", outline: true }, "Button")), index.h("li", { class: "list-group-item" }, index.h("i", null, "Secondary Outline, disabled"), index.h("fl-button", { isBlockElement: true, disabled: true, variant: "secondary", outline: true }, "Button"))));
  }
  async takeTime() {
    return timer(Math.random() * 2000 + 2000).toPromise();
  }
};
FlareStyleGuide.style = styleGuideCss;

exports.fl_style_guide = FlareStyleGuide;
