/**
 *
 * @ai-apps/angular v2.147.1-next.0 | card.component.js
 *
 * Copyright 2014, 2022 IBM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import { Component, ElementRef, HostBinding, Input, Optional, SkipSelf, } from '@angular/core';
import { CardService } from './card.service';
import * as i0 from "@angular/core";
import * as i1 from "./card.service";
import * as i2 from "@angular/common";
function CardComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵprojection(0);
} }
function CardComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0, 3);
} if (rf & 2) {
    i0.ɵɵnextContext();
    const _r0 = i0.ɵɵreference(1);
    i0.ɵɵproperty("ngTemplateOutlet", _r0);
} }
function CardComponent_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 4);
    i0.ɵɵelementStart(1, "div", 5);
    i0.ɵɵelementContainer(2, 3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵnextContext();
    const _r0 = i0.ɵɵreference(1);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngTemplateOutlet", _r0);
} }
const _c0 = ["*"];
/**
 * Provider for `CardService` that lets us either use a service provided to us
 * by the parent injector, or fall back to a new instance for this component tree.
 */
const CARD_SERVICE_PROVIDER = {
    provide: CardService,
    deps: [[new Optional(), new SkipSelf(), CardService]],
    useFactory: (parentCardService) => {
        return parentCardService || new CardService();
    },
};
export class CardComponent {
    constructor(cardService, elementRef) {
        this.cardService = cardService;
        this.elementRef = elementRef;
        this.defaultHeight = null;
        this.expanded = false;
        this.cardClass = true;
        this.wrapperClass = true;
        this.selected = false;
        this.role = 'presentation';
    }
    ngOnChanges(changes) {
        if (changes.expanded) {
            this.cardService.setExpanded(changes.expanded.currentValue);
        }
    }
    ngOnInit() {
        if (this.defaultHeight) {
            this.cardService.setCardHeight(this.defaultHeight);
        }
    }
    ngAfterViewInit() {
        const hostElement = this.elementRef.nativeElement;
        hostElement.style.setProperty('--card-default-height', this.cardService.getCardHeight());
    }
}
CardComponent.ɵfac = function CardComponent_Factory(t) { return new (t || CardComponent)(i0.ɵɵdirectiveInject(i1.CardService), i0.ɵɵdirectiveInject(i0.ElementRef)); };
CardComponent.ɵcmp = i0.ɵɵdefineComponent({ type: CardComponent, selectors: [["ai-card"]], hostVars: 7, hostBindings: function CardComponent_HostBindings(rf, ctx) { if (rf & 2) {
        i0.ɵɵattribute("role", ctx.role);
        i0.ɵɵclassProp("iot--card", ctx.cardClass)("iot--card--wrapper", ctx.wrapperClass)("iot--card--wrapper__selected", ctx.selected);
    } }, inputs: { defaultHeight: "defaultHeight", expanded: "expanded", selected: "selected" }, features: [i0.ɵɵProvidersFeature([CARD_SERVICE_PROVIDER]), i0.ɵɵNgOnChangesFeature], ngContentSelectors: _c0, decls: 4, vars: 2, consts: [["content", ""], [3, "ngTemplateOutlet", 4, "ngIf"], ["class", "bx--modal is-visible", 4, "ngIf"], [3, "ngTemplateOutlet"], [1, "bx--modal", "is-visible"], [1, "iot--card", "iot--card--wrapper", "expanded"]], template: function CardComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵprojectionDef();
        i0.ɵɵtemplate(0, CardComponent_ng_template_0_Template, 1, 0, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
        i0.ɵɵtemplate(2, CardComponent_ng_container_2_Template, 1, 1, "ng-container", 1);
        i0.ɵɵtemplate(3, CardComponent_div_3_Template, 3, 1, "div", 2);
    } if (rf & 2) {
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", !ctx.expanded);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.expanded);
    } }, directives: [i2.NgIf, i2.NgTemplateOutlet], styles: [".expanded[_ngcontent-%COMP%] {\n        height: calc(100% - 50px);\n        width: calc(100% - 50px);\n      }"] });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CardComponent, [{
        type: Component,
        args: [{
                selector: 'ai-card',
                template: `
    <ng-template #content>
      <ng-content></ng-content>
    </ng-template>
    <ng-container *ngIf="!expanded" [ngTemplateOutlet]="content"></ng-container>
    <div *ngIf="expanded" class="bx--modal is-visible">
      <div class="iot--card iot--card--wrapper expanded">
        <ng-container [ngTemplateOutlet]="content"></ng-container>
      </div>
    </div>
  `,
                providers: [CARD_SERVICE_PROVIDER],
                styles: [
                    `
      .expanded {
        height: calc(100% - 50px);
        width: calc(100% - 50px);
      }
    `,
                ],
            }]
    }], function () { return [{ type: i1.CardService }, { type: i0.ElementRef }]; }, { defaultHeight: [{
            type: Input
        }], expanded: [{
            type: Input
        }], cardClass: [{
            type: HostBinding,
            args: ['class.iot--card']
        }], wrapperClass: [{
            type: HostBinding,
            args: ['class.iot--card--wrapper']
        }], selected: [{
            type: HostBinding,
            args: ['class.iot--card--wrapper__selected']
        }, {
            type: Input
        }], role: [{
            type: HostBinding,
            args: ['attr.role']
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 