import { r as t, c as i, h as e, H as s, a } from "./p-9b9ccd0c.js";

import { c as n } from "./p-c5196b3b.js";

import { L as o } from "./p-311eedf3.js";

import { r } from "./p-7d0f58d6.js";

const filesToListItemsData = t => {
  const i = [];
  t.forEach((t => {
    const e = typeof t === "string" ? t : t.name;
    const s = typeof t === "string" ? t : t.name;
    const a = undefined;
    const n = false;
    i.push({
      itemId: e,
      itemValue: s,
      itemIcon: a,
      itemChecked: n
    });
  }));
  return i;
};

const l = ":host{display:grid;block-size:100%}.opacity-0{opacity:0}.gxi-hidden{display:none !important}.align-center{display:flex;align-items:center}.align-end{display:flex;align-items:end}.overflow-auto{overflow:auto}:host(.gx-ide-component){height:100% !important;display:flex !important;flex-direction:column !important}.gx-ide-main-wrapper{color:var(--gx-ide-component-text-color);font-weight:var(--font-style-regular);font-size:var(--font-size-body-m);font-family:var(--font-family-body);height:100%;display:flex;flex-direction:column;flex-grow:1;box-sizing:border-box}.buttons-container{display:flex;gap:var(--spacing-gap-m)}.giu-static-pill-icon-and-text,.giu-static-pill{background-color:var(--elevation-background-color, var(--color-accent-surface-elevation-1));padding-inline:var(--spacing-padding-m);color:var(--color-text-neutral-default);font-size:var(--font-size-body-s);line-height:var(--line-height-relaxed);font-weight:var(--font-style-regular);border-radius:4px;min-block-size:25px;display:inline-grid;align-items:center;pointer-events:none;inline-size:max-content}.giu-static-pill-icon-and-text{display:inline-grid;grid-auto-flow:column;grid-auto-columns:max-content;gap:var(--spacing-gap-m)}.tab-full-width-buttons::part(tab-list block-start),.tab-full-width-buttons::part(tab-list block-end){grid-auto-columns:1fr}.tab-full-width-buttons::part(tab block-start){justify-content:center}.tree-view::part(item__header){--icon__system_warning_warning--disabled:var(\n    --icon__system_warning_warning--enabled\n  )}.tabular-grid{--focus-outline-width:1px}.control-wrapper{display:flex;gap:var(--spacing-gap-m);align-items:center}.control-wrapper--vertical{flex-direction:column;align-items:start}.controls-wrapper{display:flex;gap:var(--spacing-gap-m)}.controls-wrapper--vertical{flex-direction:column;align-items:start}.input-text{box-sizing:border-box;background-color:transparent;border:1px solid var(--color-border-neutral-default);border-radius:4px;height:26px;color:var(--color-text-neutral-default);font-size:var(--font-size-body-xs)}.input-text--full-width{align-self:stretch}:host{display:block}.main{display:grid;grid-template-rows:1fr auto;block-size:100%;gap:var(--spacing-gap-l)}.path-list{inline-size:100%;block-size:100%}gx-ide-list-selector::part(list){block-size:100%}.hidden-input{display:none}.checkbox-container{display:flex;gap:var(--spacing-gap-m)}.footer{display:flex;flex-direction:column;gap:var(--spacing-gap-l)}";

const c = class {
  constructor(e) {
    t(this, e);
    this.componentDidRenderFirstTime = i(this, "componentDidRenderFirstTime", 7);
    this.selectionChanged = i(this, "selectionChanged", 7);
    this.renderedFirstTime = false;
    // 7.LISTENERS //
    // 8.PUBLIC METHODS API //
    // 9.LOCAL METHODS //
        this.fileSelectionChangedHandler = t => {
      this.selectionChanged.emit();
      const i = Array.isArray(t.detail) ? t.detail : [ t.detail ];
      this.selectedFiles = i.map((t => t.itemValue));
    };
    this.loadFileHandle = async () => {
      this.fileInput.click();
    };
    this.handleFileInputChange = t => {
      const i = t.target;
      if (i.files && i.files.length > 0) {
        const t = Array.from(i.files);
        const e = t.filter((t => !this.files.some((i => i.name === t.name))));
        this.files = [ ...this.files, ...e ];
      }
      this.fileInput.value = null;
    };
    this.confirmCallbackHandle = async () => {
      if (this.confirmCallback && this.files.length > 0) {
        const t = {
          automaticBackup: this.automaticBackupEl.value === "true",
          files: this.files
        };
        await this.confirmCallback(t);
      }
    };
    this.removeFiles = t => {
      this.files = this.files.filter((i => !t.includes(i.name)));
      this.selectedFiles = [];
      this.fileInput.value = null;
    };
    this.handleRemoveButtonClick = () => {
      this.removeFiles(this.selectedFiles);
    };
    this.files = [];
    this.selectedFiles = [];
    this.displayTitle = false;
    this.allowedExtensions = undefined;
    this.confirmCallback = undefined;
    this.cancelCallback = undefined;
  }
  // 6.COMPONENT LIFECYCLE METHODS //
  async componentWillLoad() {
    this._componentLocale = await o.getComponentStrings(this.el);
  }
  componentDidRender() {
    if (!this.renderedFirstTime) {
      this.componentDidRenderFirstTime.emit(this._componentLocale.componentName);
      this.renderedFirstTime = true;
    }
  }
  // 10.RENDER() FUNCTION //
  render() {
    var t;
    return e(s, {
      class: "gx-ide-component"
    }, e("div", {
      class: "gx-ide-main-wrapper"
    }, e("gx-ide-container", {
      slimmerFooter: n.gxIdeContainer.slimmerFooter
    }, e("div", {
      class: "main"
    }, e("div", {
      class: "controls-wrapper controls-wrapper--vertical"
    }, e("label", {
      htmlFor: "path-list"
    }, this._componentLocale.main.listLabel), e("gx-ide-list-selector", {
      id: "path-list",
      type: "multi-selection",
      listName: "path-list",
      ordered: true,
      onSelectionChanged: this.fileSelectionChangedHandler,
      class: "path-list"
    }, r(filesToListItemsData(this.files)))), e("div", {
      class: "footer"
    }, e("div", {
      class: "checkbox-container"
    }, e("ch-checkbox", {
      id: "automatic-backup",
      accessibleName: this._componentLocale.main.automaticBackupLabel,
      checkedValue: "true",
      unCheckedValue: "false",
      value: "checked",
      ref: t => this.automaticBackupEl = t
    }), e("label", {
      htmlFor: "automatic-backup"
    }, this._componentLocale.main.automaticBackupLabel)), e("div", {
      class: "controls-wrapper"
    }, e("input", {
      type: "file",
      id: "input_file",
      accept: (t = this.allowedExtensions) === null || t === void 0 ? void 0 : t.join(", "),
      ref: t => this.fileInput = t,
      onChange: this.handleFileInputChange,
      class: "hidden-input",
      multiple: true
    }), e("button", {
      onClick: this.loadFileHandle
    }, this._componentLocale.main.addFilesButton), e("button", {
      onClick: this.handleRemoveButtonClick,
      disabled: this.selectedFiles.length === 0
    }, this._componentLocale.main.removeFilesButton, " (", this.selectedFiles.length, ")")))), e("button", {
      slot: "footer-end",
      onClick: this.confirmCallbackHandle
    }, this._componentLocale.footer.confirmButton), e("button", {
      slot: "footer-end",
      onClick: this.cancelCallback
    }, this._componentLocale.footer.cancelButton))));
  }
  static get assetsDirs() {
    return [ "gx-ide-assets/bpm-import-files" ];
  }
  get el() {
    return a(this);
  }
};

c.style = l;

export { c as gx_ide_bpm_import_files };
//# sourceMappingURL=p-d68412ac.entry.js.map