import { Component, Input, ViewChild } from "@angular/core";
import StiRectangleGeometryLayout from "../computed/StiRectangleGeometryLayout";
import { StiDragPreviewElement } from "../elements/StiDragPreviewElement";
import { StiBorderArea } from "../properties/StiBorderArea";
import { StiLabelAlignment } from "../system/enums";
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "./sti-text-box/sti-text-box.component";
import * as i3 from "./sti-number-box/sti-number-box.component";
import * as i4 from "./sti-combo-box/sti-combo-box.component";
import * as i5 from "./sti-list-box/sti-list-box.component";
import * as i6 from "./sti-single-selection/sti-single-selection.component";
import * as i7 from "./sti-multiple-selection/sti-multiple-selection.component";
import * as i8 from "./sti-check-box/sti-check-box.component";
import * as i9 from "./sti-line/sti-line.component";
import * as i10 from "./sti-signature/sti-signature.component";
import * as i11 from "./sti-date-time-box/sti-date-time-box.component";
import * as i12 from "./sti-table/sti-table.component";
import * as i13 from "./sti-image/sti-image.component";
import * as i14 from "./sti-button/sti-button.component";
import * as i15 from "./sti-barcode/sti-barcode.component";
import * as i16 from "./sti-text/sti-text.component";
import * as i17 from "./sti-drag-preview-adorner/sti-drag-preview-adorner.component";
import * as i18 from "./sti-label/sti-label.component";
import * as i19 from "./sti-address/sti-address.component";
import * as i20 from "./sti-pdf-signature/sti-pdf-signature.component";
import * as i21 from "../services/model.service";
import * as i22 from "./sti-component";
import * as i23 from "./sti-editable-content.component";
export class StiComponentHolderComponent {
    constructor() {
        this.isClone = false;
    }
    ngOnInit() { }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StiComponentHolderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: StiComponentHolderComponent, selector: "sti-component-holder", inputs: { element: "element", isClone: "isClone" }, ngImport: i0, template: `
    <ng-container *ngIf="element != null">
      <sti-address-component
        [element]="element"
        *ngIf="element.type === 'AddressElement'"
        [isClone]="isClone"
      ></sti-address-component>
      <sti-textbox-component
        [element]="element"
        *ngIf="element.type === 'Text_BoxElement'"
        [isClone]="isClone"
      ></sti-textbox-component>
      <sti-text-component
        [element]="element"
        *ngIf="element.type === 'TextElement'"
        [isClone]="isClone"
      ></sti-text-component>
      <sti-table-component
        [element]="element"
        *ngIf="element.type === 'TableElement'"
        [isClone]="isClone"
      ></sti-table-component>
      <sti-singleselection-component
        [element]="element"
        *ngIf="element.type === 'Single_SelectionElement'"
        [isClone]="isClone"
      ></sti-singleselection-component>
      <sti-signature-component [element]="element" *ngIf="element.type === 'SignatureElement'" [isClone]="isClone">
      </sti-signature-component>
      <sti-pdf-signature-component
        [element]="element"
        *ngIf="element.type === 'PDFSignatureElement'"
        [isClone]="isClone"
      ></sti-pdf-signature-component>
      <sti-panel-component
        [element]="element"
        *ngIf="element.type === 'PanelElement'"
        [isClone]="isClone"
      ></sti-panel-component>
      <sti-numberbox-component
        [element]="element"
        *ngIf="element.type === 'Number_BoxElement'"
        [isClone]="isClone"
      ></sti-numberbox-component>
      <sti-multipleselection-component
        [element]="element"
        *ngIf="element.type === 'Multiple_SelectionElement'"
        [isClone]="isClone"
      ></sti-multipleselection-component>
      <sti-listbox-component
        [element]="element"
        *ngIf="element.type === 'List_BoxElement'"
        [isClone]="isClone"
      ></sti-listbox-component>
      <sti-label-component
        [element]="element"
        *ngIf="element.type === 'LabelElement'"
        [isClone]="isClone"
      ></sti-label-component>
      <sti-image-component
        [element]="element"
        *ngIf="element.type === 'ImageElement'"
        [isClone]="isClone"
      ></sti-image-component>
      <sti-drag-preview-adorner [element]="element" *ngIf="element.type === 'Drag_Preview'"></sti-drag-preview-adorner>
      <sti-line-component
        [element]="element"
        *ngIf="element.type === 'LineElement'"
        [isClone]="isClone"
      ></sti-line-component>
      <sti-datetimebox-component
        [element]="element"
        *ngIf="element.type === 'DateTime_BoxElement'"
        [isClone]="isClone"
      ></sti-datetimebox-component>
      <sti-combobox-component
        [element]="element"
        *ngIf="element.type === 'Combo_BoxElement'"
        [isClone]="isClone"
      ></sti-combobox-component>
      <sti-checkbox-component
        [element]="element"
        *ngIf="element.type === 'Check_BoxElement'"
        [isClone]="isClone"
      ></sti-checkbox-component>
      <sti-button-component
        [element]="element"
        *ngIf="element.type === 'ButtonElement'"
        [isClone]="isClone"
      ></sti-button-component>
      <sti-barcode-component
        [element]="element"
        *ngIf="element.type === 'BarCodeElement'"
        [isClone]="isClone"
      ></sti-barcode-component>
    </ng-container>
  `, isInline: true, dependencies: [{ kind: "directive", type: i0.forwardRef(() => i1.NgIf), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i0.forwardRef(() => i2.StiTextBoxComponent), selector: "sti-textbox-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i3.StiNumberBoxComponent), selector: "sti-numberbox-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i4.StiComboBoxComponent), selector: "sti-combobox-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i5.StiListBoxComponent), selector: "sti-listbox-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i6.StiSingleSelectionComponent), selector: "sti-singleselection-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i7.StiMultipleSelectionComponent), selector: "sti-multipleselection-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i8.StiCheckBoxComponent), selector: "sti-checkbox-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i9.StiLineComponent), selector: "sti-line-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i10.StiSignatureComponent), selector: "sti-signature-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => StiPanelComponent), selector: "sti-panel-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i11.StiDateTimeBoxComponent), selector: "sti-datetimebox-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i12.StiTableComponent), selector: "sti-table-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i13.StiImageComponent), selector: "sti-image-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i14.StiButtonComponent), selector: "sti-button-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i15.StiBarcodeComponent), selector: "sti-barcode-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i16.StiTextComponent), selector: "sti-text-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i17.StiDragPreviewAdornerComponent), selector: "sti-drag-preview-adorner", inputs: ["element"] }, { kind: "component", type: i0.forwardRef(() => i18.StiLabelComponent), selector: "sti-label-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i19.StiAddressComponent), selector: "sti-address-component", inputs: ["element", "isClone"] }, { kind: "component", type: i0.forwardRef(() => i20.StiPDFSignatureComponent), selector: "sti-pdf-signature-component", inputs: ["element", "isClone"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StiComponentHolderComponent, decorators: [{
            type: Component,
            args: [{
                    selector: "sti-component-holder",
                    template: `
    <ng-container *ngIf="element != null">
      <sti-address-component
        [element]="element"
        *ngIf="element.type === 'AddressElement'"
        [isClone]="isClone"
      ></sti-address-component>
      <sti-textbox-component
        [element]="element"
        *ngIf="element.type === 'Text_BoxElement'"
        [isClone]="isClone"
      ></sti-textbox-component>
      <sti-text-component
        [element]="element"
        *ngIf="element.type === 'TextElement'"
        [isClone]="isClone"
      ></sti-text-component>
      <sti-table-component
        [element]="element"
        *ngIf="element.type === 'TableElement'"
        [isClone]="isClone"
      ></sti-table-component>
      <sti-singleselection-component
        [element]="element"
        *ngIf="element.type === 'Single_SelectionElement'"
        [isClone]="isClone"
      ></sti-singleselection-component>
      <sti-signature-component [element]="element" *ngIf="element.type === 'SignatureElement'" [isClone]="isClone">
      </sti-signature-component>
      <sti-pdf-signature-component
        [element]="element"
        *ngIf="element.type === 'PDFSignatureElement'"
        [isClone]="isClone"
      ></sti-pdf-signature-component>
      <sti-panel-component
        [element]="element"
        *ngIf="element.type === 'PanelElement'"
        [isClone]="isClone"
      ></sti-panel-component>
      <sti-numberbox-component
        [element]="element"
        *ngIf="element.type === 'Number_BoxElement'"
        [isClone]="isClone"
      ></sti-numberbox-component>
      <sti-multipleselection-component
        [element]="element"
        *ngIf="element.type === 'Multiple_SelectionElement'"
        [isClone]="isClone"
      ></sti-multipleselection-component>
      <sti-listbox-component
        [element]="element"
        *ngIf="element.type === 'List_BoxElement'"
        [isClone]="isClone"
      ></sti-listbox-component>
      <sti-label-component
        [element]="element"
        *ngIf="element.type === 'LabelElement'"
        [isClone]="isClone"
      ></sti-label-component>
      <sti-image-component
        [element]="element"
        *ngIf="element.type === 'ImageElement'"
        [isClone]="isClone"
      ></sti-image-component>
      <sti-drag-preview-adorner [element]="element" *ngIf="element.type === 'Drag_Preview'"></sti-drag-preview-adorner>
      <sti-line-component
        [element]="element"
        *ngIf="element.type === 'LineElement'"
        [isClone]="isClone"
      ></sti-line-component>
      <sti-datetimebox-component
        [element]="element"
        *ngIf="element.type === 'DateTime_BoxElement'"
        [isClone]="isClone"
      ></sti-datetimebox-component>
      <sti-combobox-component
        [element]="element"
        *ngIf="element.type === 'Combo_BoxElement'"
        [isClone]="isClone"
      ></sti-combobox-component>
      <sti-checkbox-component
        [element]="element"
        *ngIf="element.type === 'Check_BoxElement'"
        [isClone]="isClone"
      ></sti-checkbox-component>
      <sti-button-component
        [element]="element"
        *ngIf="element.type === 'ButtonElement'"
        [isClone]="isClone"
      ></sti-button-component>
      <sti-barcode-component
        [element]="element"
        *ngIf="element.type === 'BarCodeElement'"
        [isClone]="isClone"
      ></sti-barcode-component>
    </ng-container>
  `,
                }]
        }], ctorParameters: () => [], propDecorators: { element: [{
                type: Input
            }], isClone: [{
                type: Input
            }] } });
//==========================================================
export class StiPanelComponent {
    get elements() {
        return this.element?.elements;
    }
    get borderArea() {
        if (!this.isClone) {
            let borderArea = new StiBorderArea();
            borderArea.top =
                this.ref?.nativeElement?.offsetTop -
                    (this.element.label.alignment != StiLabelAlignment.Top ? this.element.padding.top : 0);
            borderArea.left = this.ref?.nativeElement?.offsetLeft;
            borderArea.width = this.ref?.nativeElement?.offsetWidth - this.element.padding.left - this.element.padding.right;
            borderArea.height = this.ref?.nativeElement?.offsetHeight;
            borderArea.border = this.element.border;
            return borderArea;
        }
    }
    get align() {
        return "start";
    }
    get minWidth() {
        if (this.elements?.length > 0) {
            let minWidth = this.elements[0]?.x + this.elements[0]?.width;
            this.elements.forEach((element) => {
                if (minWidth < element.x + element.width) {
                    minWidth = element.x + element.width;
                }
            });
            return minWidth;
        }
        return "min-content";
    }
    get minHeight() {
        if (!this.model.draggingElement) {
            if (this.elements?.length > 0) {
                let maxBottomPoint = 0;
                this.elements?.forEach((element) => {
                    if (!(element instanceof StiDragPreviewElement) && element.geometry.bottom > maxBottomPoint) {
                        maxBottomPoint = element.geometry.bottom;
                    }
                });
                if (this.currentBottomPoint != maxBottomPoint) {
                    this.render.insertElement(this.element);
                    this.render.checkOutputs(this.model.getElementPage(this.element));
                    this.currentBottomPoint = maxBottomPoint;
                }
                return maxBottomPoint > 0 ? maxBottomPoint : 5;
            }
            else {
                return 5;
            }
        }
    }
    constructor(model, render) {
        this.model = model;
        this.render = render;
        this.isClone = false;
    }
    ngAfterViewInit() {
        if (!this.isClone) {
            this.element.element = this.ref;
        }
    }
    ngOnInit() { }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StiPanelComponent, deps: [{ token: i21.StiModelService }, { token: StiRectangleGeometryLayout }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: StiPanelComponent, selector: "sti-panel-component", inputs: { element: "element", isClone: "isClone" }, viewQueries: [{ propertyName: "ref", first: true, predicate: ["ref"], descendants: true }], ngImport: i0, template: ` <sti-component [element]="element" [borderArea]="borderArea" [isClone]="isClone" class="sti-panel">
    <sti-editable-content-component
      *ngIf="element?.label.value?.length > 0 && element?.isLabelTopAlignment()"
      [editableContent]="element.label"
      [style.text-align]="element?.getContentAlign()"
      [style.align-self]="align"
      [hideEmpty]="element.showLabelPlaceholder(model?.selectedComponent?.element == element)"
      [style.width]="element?.getLabelWidth()"
    ></sti-editable-content-component>
    <table [style.width]="'100%'" [style.height]="'100%'" [style.margin-top.px]="element?.getTopMargin()">
      <tr>
        <td
          *ngIf="element?.label.value?.length > 0 && !element?.isLabelTopAlignment()"
          [style.display]="'flex'"
          [style.height]="'100%'"
          [style.width]="element?.getLabelWidth()"
          [style.align-items]="element?.getVerticalAlignment()"
        >
          <sti-editable-content-component
            *ngIf="element?.label.value?.length > 0"
            [editableContent]="element?.label"
            [required]="element.required"
            [style.text-align]="element?.getContentAlign()"
            [style.width]="element?.getLabelWidth()"
            [hideEmpty]="element?.showLabelPlaceholder(model?.selectedComponent?.element == element)"
          ></sti-editable-content-component>
        </td>
        <td [style.width]="'100%'" [style.height]="'100%'">
          <div
            #ref
            class="sti-panel-container"
            [style.height]="'100%'"
            [style.min-width.px]="minWidth"
            [style.min-height.px]="minHeight"
            [style.align-self]="'center'"
            [style.overflow]="'hidden'"
            [style.background-color]="
              (!element.isAdded &&
                element.backgroundColor.r == 255 &&
                element.backgroundColor.g == 255 &&
                element.backgroundColor.b == 255) ||
              element.backgroundColor.a == 0
                ? 'transparent'
                : element?.backgroundColor.toHtmlColor()
            "
          >
            <div *ngFor="let element of elements" [disabled]="element?.readOnly ? true : false">
              <sti-component-holder [element]="element"></sti-component-holder>
            </div>
          </div>
        </td>
      </tr>
      <tr *ngIf="element?.description.value?.length > 0">
        <td *ngIf="element?.label.value?.length > 0 && !element?.isLabelTopAlignment()"></td>
        <td [style.maxWidth.px]="element.maxWidth + 1">
          <sti-editable-content-component
            *ngIf="element?.description.value?.length > 0"
            [editableContent]="element.description"
          >
          </sti-editable-content-component>
        </td>
      </tr>
    </table>
  </sti-component>`, isInline: true, styles: ["table{border-spacing:0}tr{height:max-content;padding:0;margin:0}td{height:100%;padding:0;margin:0}.sti-panel-container{min-height:5px;position:relative}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i22.StiComponent, selector: "sti-component", inputs: ["element", "class", "isClone", "borderArea"] }, { kind: "component", type: StiComponentHolderComponent, selector: "sti-component-holder", inputs: ["element", "isClone"] }, { kind: "component", type: i23.StiEditableContentComponent, selector: "sti-editable-content-component", inputs: ["editableContent", "displayContent", "required", "eParent", "hideEmpty", "active", "alignment", "isTableTotalHeader", "disablePadding", "fromButton", "parentCursor", "isTableHeader"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StiPanelComponent, decorators: [{
            type: Component,
            args: [{ selector: "sti-panel-component", template: ` <sti-component [element]="element" [borderArea]="borderArea" [isClone]="isClone" class="sti-panel">
    <sti-editable-content-component
      *ngIf="element?.label.value?.length > 0 && element?.isLabelTopAlignment()"
      [editableContent]="element.label"
      [style.text-align]="element?.getContentAlign()"
      [style.align-self]="align"
      [hideEmpty]="element.showLabelPlaceholder(model?.selectedComponent?.element == element)"
      [style.width]="element?.getLabelWidth()"
    ></sti-editable-content-component>
    <table [style.width]="'100%'" [style.height]="'100%'" [style.margin-top.px]="element?.getTopMargin()">
      <tr>
        <td
          *ngIf="element?.label.value?.length > 0 && !element?.isLabelTopAlignment()"
          [style.display]="'flex'"
          [style.height]="'100%'"
          [style.width]="element?.getLabelWidth()"
          [style.align-items]="element?.getVerticalAlignment()"
        >
          <sti-editable-content-component
            *ngIf="element?.label.value?.length > 0"
            [editableContent]="element?.label"
            [required]="element.required"
            [style.text-align]="element?.getContentAlign()"
            [style.width]="element?.getLabelWidth()"
            [hideEmpty]="element?.showLabelPlaceholder(model?.selectedComponent?.element == element)"
          ></sti-editable-content-component>
        </td>
        <td [style.width]="'100%'" [style.height]="'100%'">
          <div
            #ref
            class="sti-panel-container"
            [style.height]="'100%'"
            [style.min-width.px]="minWidth"
            [style.min-height.px]="minHeight"
            [style.align-self]="'center'"
            [style.overflow]="'hidden'"
            [style.background-color]="
              (!element.isAdded &&
                element.backgroundColor.r == 255 &&
                element.backgroundColor.g == 255 &&
                element.backgroundColor.b == 255) ||
              element.backgroundColor.a == 0
                ? 'transparent'
                : element?.backgroundColor.toHtmlColor()
            "
          >
            <div *ngFor="let element of elements" [disabled]="element?.readOnly ? true : false">
              <sti-component-holder [element]="element"></sti-component-holder>
            </div>
          </div>
        </td>
      </tr>
      <tr *ngIf="element?.description.value?.length > 0">
        <td *ngIf="element?.label.value?.length > 0 && !element?.isLabelTopAlignment()"></td>
        <td [style.maxWidth.px]="element.maxWidth + 1">
          <sti-editable-content-component
            *ngIf="element?.description.value?.length > 0"
            [editableContent]="element.description"
          >
          </sti-editable-content-component>
        </td>
      </tr>
    </table>
  </sti-component>`, styles: ["table{border-spacing:0}tr{height:max-content;padding:0;margin:0}td{height:100%;padding:0;margin:0}.sti-panel-container{min-height:5px;position:relative}\n"] }]
        }], ctorParameters: () => [{ type: i21.StiModelService }, { type: StiRectangleGeometryLayout }], propDecorators: { ref: [{
                type: ViewChild,
                args: ["ref"]
            }], element: [{
                type: Input
            }], isClone: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 