import { NgTemplateOutlet } from '@angular/common';
import * as i0 from '@angular/core';
import { input, contentChild, computed, ChangeDetectionStrategy, Component } from '@angular/core';
import { SdHrefDirective } from '@sd-angular/core/directives';
import { SdEmptyPipe } from '@sd-angular/core/pipes';

class SdView {
    // ==========================================
    // 1. SIGNAL INPUTS
    // ==========================================
    label = input();
    value = input();
    // input.required() sẽ ép dev bắt buộc phải truyền [display] vào, y hệt @Input({ required: true })
    display = input.required();
    hyperlink = input();
    // Input để hứng template từ component cha (như sd-input, sd-select) truyền xuống
    labelTemplate = input();
    valueTemplate = input();
    // ==========================================
    // 2. SIGNAL QUERIES (Thay thế @ContentChild)
    // ==========================================
    // Trả về Signal chứa TemplateRef nếu Dev dùng thẻ <sd-view> và truyền #sdLabel, #sdValue
    contentLabelTemplate = contentChild('sdLabel');
    contentValueTemplate = contentChild('sdValue');
    // ==========================================
    // 3. COMPUTED SIGNALS (Thay thế Getters)
    // ==========================================
    // Ưu tiên Input từ cha truyền xuống, không có thì lấy ContentChild
    // Lợi ích: Cache giá trị, không bị chạy lại vô tội vạ như Getter cũ!
    activeLabelTemplate = computed(() => this.labelTemplate() ?? this.contentLabelTemplate());
    activeValueTemplate = computed(() => this.valueTemplate() ?? this.contentValueTemplate());
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdView, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: SdView, isStandalone: true, selector: "sd-view", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, display: { classPropertyName: "display", publicName: "display", isSignal: true, isRequired: true, transformFunction: null }, hyperlink: { classPropertyName: "hyperlink", publicName: "hyperlink", isSignal: true, isRequired: false, transformFunction: null }, labelTemplate: { classPropertyName: "labelTemplate", publicName: "labelTemplate", isSignal: true, isRequired: false, transformFunction: null }, valueTemplate: { classPropertyName: "valueTemplate", publicName: "valueTemplate", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "contentLabelTemplate", first: true, predicate: ["sdLabel"], descendants: true, isSignal: true }, { propertyName: "contentValueTemplate", first: true, predicate: ["sdValue"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (activeLabelTemplate()) {\r\n  <ng-container *ngTemplateOutlet=\"activeLabelTemplate()!\"></ng-container>\r\n} @else {\r\n  @if (label()) {\r\n    <div class=\"T14R text-black400\">{{ label() }}</div>\r\n  }\r\n}\r\n\r\n@if (activeValueTemplate()) {\r\n  <ng-container \r\n    *ngTemplateOutlet=\"\r\n      activeValueTemplate()!; \r\n      context: { $implicit: display(), value: value() }\r\n    \"> \r\n  </ng-container>\r\n} @else {\r\n  @if (hyperlink(); as link) {\r\n    <a [sdHref]=\"link\">{{ display() }}</a>\r\n  } @else {\r\n    <div class=\"T14M\">{{ display() | sdEmpty }}</div>\r\n  }\r\n}", dependencies: [{ kind: "pipe", type: SdEmptyPipe, name: "sdEmpty" }, { kind: "directive", type: SdHrefDirective, selector: "a[sdHref]", inputs: ["sdHref"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdView, decorators: [{
            type: Component,
            args: [{ selector: 'sd-view', standalone: true, imports: [SdEmptyPipe, SdHrefDirective, NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (activeLabelTemplate()) {\r\n  <ng-container *ngTemplateOutlet=\"activeLabelTemplate()!\"></ng-container>\r\n} @else {\r\n  @if (label()) {\r\n    <div class=\"T14R text-black400\">{{ label() }}</div>\r\n  }\r\n}\r\n\r\n@if (activeValueTemplate()) {\r\n  <ng-container \r\n    *ngTemplateOutlet=\"\r\n      activeValueTemplate()!; \r\n      context: { $implicit: display(), value: value() }\r\n    \"> \r\n  </ng-container>\r\n} @else {\r\n  @if (hyperlink(); as link) {\r\n    <a [sdHref]=\"link\">{{ display() }}</a>\r\n  } @else {\r\n    <div class=\"T14M\">{{ display() | sdEmpty }}</div>\r\n  }\r\n}" }]
        }] });

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

export { SdView };
//# sourceMappingURL=sd-angular-core-components-view.mjs.map
