import * as i0 from '@angular/core';
import { Component, Input, NgModule } from '@angular/core';
import * as i1 from '@aztrix/helpers';
import { HelperPipesModule } from '@aztrix/helpers';
import * as i2 from '@angular/common';
import { CommonModule } from '@angular/common';

class FontSelectComponent {
    constructor(_fonts) {
        this._fonts = _fonts;
    }
    get fontsGrouped() {
        return this._fonts.fonts.reduce((prev, curr) => {
            const item = prev.find((i) => i.type === curr.type);
            if (item) {
                item.fonts.push(curr);
            }
            else {
                prev.push({ type: curr.type, fonts: [curr] });
            }
            return prev;
        }, []);
    }
    ngOnInit() {
        this._fonts.loadAllFonts().then();
    }
}
FontSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: FontSelectComponent, deps: [{ token: i1.FontsService }], target: i0.ɵɵFactoryTarget.Component });
FontSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: FontSelectComponent, selector: "ax-font-select", inputs: { form: "form" }, ngImport: i0, template: "<div *ngFor=\"let fontGroup of fontsGrouped\">\n  <h3>{{ 'page.edit.appearance.font.type.' + fontGroup.type | translate }}</h3>\n  <div class=\"fonts\">\n    <div class=\"font\" *ngFor=\"let font of fontGroup.fonts\" (click)=\"form.setValue(font.value)\">\n      <input\n        class=\"input\"\n        type=\"radio\"\n        [id]=\"'font-' + font.index\"\n        [value]=\"'font-' + font.index\"\n        [checked]=\"font.value === form?.value\"\n      />\n      <label\n        class=\"font-label\"\n        [for]=\"'font-' + font.index\"\n        [ngStyle]=\"{'font-family': font.value}\"\n      >\n        <span>Aa</span>\n      </label>\n      <span class=\"option-label\">{{ font.label }}</span>\n    </div>\n  </div>\n</div>\n", styles: [":host{display:flex;flex-direction:column;gap:2rem}:host input[type=radio]:checked+label{background-color:var(--primary-color-500)}.fonts{display:grid;grid-gap:1rem;grid-template-columns:repeat(auto-fill,minmax(90px,1fr))}.font{width:100%;min-height:80px;display:flex;flex-direction:column;align-items:center;text-align:center}.input{position:absolute;visibility:hidden;opacity:0}.input+label{position:relative;display:inline-block;width:100%;height:70px;overflow:hidden;background-color:#efefef;border-radius:10px;cursor:pointer;-webkit-user-select:none;user-select:none}.input+label.bg-color-label{background-color:#363f48}.input+label .ax-button{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.font-label span{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:2rem}.option-label{margin-top:.5rem}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: FontSelectComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-font-select', template: "<div *ngFor=\"let fontGroup of fontsGrouped\">\n  <h3>{{ 'page.edit.appearance.font.type.' + fontGroup.type | translate }}</h3>\n  <div class=\"fonts\">\n    <div class=\"font\" *ngFor=\"let font of fontGroup.fonts\" (click)=\"form.setValue(font.value)\">\n      <input\n        class=\"input\"\n        type=\"radio\"\n        [id]=\"'font-' + font.index\"\n        [value]=\"'font-' + font.index\"\n        [checked]=\"font.value === form?.value\"\n      />\n      <label\n        class=\"font-label\"\n        [for]=\"'font-' + font.index\"\n        [ngStyle]=\"{'font-family': font.value}\"\n      >\n        <span>Aa</span>\n      </label>\n      <span class=\"option-label\">{{ font.label }}</span>\n    </div>\n  </div>\n</div>\n", styles: [":host{display:flex;flex-direction:column;gap:2rem}:host input[type=radio]:checked+label{background-color:var(--primary-color-500)}.fonts{display:grid;grid-gap:1rem;grid-template-columns:repeat(auto-fill,minmax(90px,1fr))}.font{width:100%;min-height:80px;display:flex;flex-direction:column;align-items:center;text-align:center}.input{position:absolute;visibility:hidden;opacity:0}.input+label{position:relative;display:inline-block;width:100%;height:70px;overflow:hidden;background-color:#efefef;border-radius:10px;cursor:pointer;-webkit-user-select:none;user-select:none}.input+label.bg-color-label{background-color:#363f48}.input+label .ax-button{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.font-label span{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:2rem}.option-label{margin-top:.5rem}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.FontsService }]; }, propDecorators: { form: [{
                type: Input
            }] } });

class FontSelectModule {
}
FontSelectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: FontSelectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
FontSelectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.5", ngImport: i0, type: FontSelectModule, declarations: [FontSelectComponent], imports: [CommonModule, HelperPipesModule], exports: [FontSelectComponent] });
FontSelectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: FontSelectModule, imports: [CommonModule, HelperPipesModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: FontSelectModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [FontSelectComponent],
                    imports: [CommonModule, HelperPipesModule],
                    exports: [FontSelectComponent],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { FontSelectComponent, FontSelectModule };
//# sourceMappingURL=aztrix-components-font-select.mjs.map
//# sourceMappingURL=aztrix-components-font-select.mjs.map
