import { ChangeDetectionStrategy, Component, EventEmitter, Input, Optional, Output, forwardRef, } from '@angular/core';
import { provideControlContainer, provideValueAccessor } from '../utils/form.util';
import { FormGenericComponent } from '../../services/form-generic.abstract';
import { ButtonComponent } from '../../components/atoms/button/button.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
export class RadioButtonComponent extends FormGenericComponent {
    constructor(destroyRef, formGroupDirective) {
        super(formGroupDirective);
        this.destroyRef = destroyRef;
        this.formGroupDirective = formGroupDirective;
        this.key = '';
        this.label = '';
        this.checked = false;
        this.formControlName = '';
        this.valueChange = new EventEmitter();
    }
    writeValue(value) {
        this.checked = value;
        this.triggerMarkCheck();
    }
    onValueChange() {
        // this.checked = true;
        this.setValue(this.value);
        this.valueChange.emit(this.value);
    }
    setValue(value) {
        this.triggerChange(value);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: RadioButtonComponent, deps: [{ token: i0.DestroyRef }, { token: i1.FormGroupDirective, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.5", type: RadioButtonComponent, isStandalone: true, selector: "ct-radio-button", inputs: { key: "key", label: "label", value: "value", checked: "checked", formControlName: "formControlName" }, outputs: { valueChange: "valueChange" }, providers: [provideValueAccessor(forwardRef(() => RadioButtonComponent))], usesInheritance: true, ngImport: i0, template: "<input\n  [id]=\"value\"\n  class=\"hidden\"\n  type=\"radio\"\n  [name]=\"key\"\n  [value]=\"value\"\n  [checked]=\"checked\"\n  (change)=\"onValueChange()\" />\n<label class=\"w-full grow cursor-pointer\" [for]=\"value\">\n  <ct-button [text]=\"label\" [type]=\"checked ? 'secondary' : 'primary'\" [fullSize]=\"true\" (click)=\"onValueChange()\" />\n</label>\n", dependencies: [{ kind: "component", type: ButtonComponent, selector: "ct-button", inputs: ["text", "icon", "iconPosition", "role", "disabled", "fullSize", "size", "type", "variant"] }], viewProviders: [provideControlContainer()], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: RadioButtonComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ct-radio-button', standalone: true, imports: [ButtonComponent], providers: [provideValueAccessor(forwardRef(() => RadioButtonComponent))], viewProviders: [provideControlContainer()], changeDetection: ChangeDetectionStrategy.OnPush, template: "<input\n  [id]=\"value\"\n  class=\"hidden\"\n  type=\"radio\"\n  [name]=\"key\"\n  [value]=\"value\"\n  [checked]=\"checked\"\n  (change)=\"onValueChange()\" />\n<label class=\"w-full grow cursor-pointer\" [for]=\"value\">\n  <ct-button [text]=\"label\" [type]=\"checked ? 'secondary' : 'primary'\" [fullSize]=\"true\" (click)=\"onValueChange()\" />\n</label>\n" }]
        }], ctorParameters: () => [{ type: i0.DestroyRef }, { type: i1.FormGroupDirective, decorators: [{
                    type: Optional
                }] }], propDecorators: { key: [{
                type: Input
            }], label: [{
                type: Input
            }], value: [{
                type: Input
            }], checked: [{
                type: Input
            }], formControlName: [{
                type: Input
            }], valueChange: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64,[encoded data, 4772 characters]