import { __awaiter } from "tslib";
import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { Subject } from 'rxjs';
import { MEDIA_PRIVACY_STYLE_CLASS, MEDIA_PRIVACY_OPTIONS, MAX_JOURNAL_POST_IMAGES, ADD_MEDIA_LABEL, MAX_JOURNAL_POST_VIDEO } from '../inspire-library.const';
import { AddMediaOptions, FileType, ImageMirrorOption, RTCState } from '../inspire-library.enum';
import * as RecordRTC from 'recordrtc';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "ngx-webcam";
import * as i3 from "@angular/forms";
import * as i4 from "../click-outside.directive";
const _c0 = ["browseMedia"];
const _c1 = ["mobileNativeCamera"];
const _c2 = ["videoCapture"];
const _c3 = ["videoPlay"];
function AddMediaComponent_div_0_div_5_figure_1_Template(rf, ctx) { if (rf & 1) {
    const _r12 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "figure", 18);
    i0.ɵɵelement(1, "img", 19);
    i0.ɵɵelementStart(2, "a", 20);
    i0.ɵɵlistener("click", function AddMediaComponent_div_0_div_5_figure_1_Template_a_click_2_listener() { i0.ɵɵrestoreView(_r12); const photo_r10 = ctx.$implicit; const ctx_r11 = i0.ɵɵnextContext(3); return ctx_r11.onRemoveAttachedMedia(photo_r10); });
    i0.ɵɵtext(3, "\u00D7");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "a", 21);
    i0.ɵɵlistener("click", function AddMediaComponent_div_0_div_5_figure_1_Template_a_click_4_listener() { i0.ɵɵrestoreView(_r12); const ctx_r13 = i0.ɵɵnextContext(3); return ctx_r13.onEditAttachedMedia(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const photo_r10 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("src", photo_r10 == null ? null : photo_r10.thumbnail_URL, i0.ɵɵsanitizeUrl);
} }
function AddMediaComponent_div_0_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 16);
    i0.ɵɵtemplate(1, AddMediaComponent_div_0_div_5_figure_1_Template, 5, 1, "figure", 17);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r8 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r8.attachedMedia);
} }
function AddMediaComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    const _r15 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵelementStart(1, "a", 12);
    i0.ɵɵlistener("click", function AddMediaComponent_div_0_Template_a_click_1_listener() { i0.ɵɵrestoreView(_r15); const ctx_r14 = i0.ɵɵnextContext(); return ctx_r14.setMediaOptions(ctx_r14.addMediaOptions == null ? null : ctx_r14.addMediaOptions.mediaTypes); });
    i0.ɵɵelement(2, "i", 13);
    i0.ɵɵelementStart(3, "span", 14);
    i0.ɵɵtext(4, "Add Media");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(5, AddMediaComponent_div_0_div_5_Template, 2, 1, "div", 15);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("ngIf", ctx_r0.attachedMedia == null ? null : ctx_r0.attachedMedia.length);
} }
function AddMediaComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    const _r17 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 22);
    i0.ɵɵelementStart(2, "button", 23);
    i0.ɵɵlistener("click", function AddMediaComponent_ng_container_1_Template_button_click_2_listener() { i0.ɵɵrestoreView(_r17); const ctx_r16 = i0.ɵɵnextContext(); return ctx_r16.setMediaOptions(ctx_r16.addMediaOptions == null ? null : ctx_r16.addMediaOptions.mediaOptions, ctx_r16.fileType.image); });
    i0.ɵɵtext(3, "Photo");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "button", 24);
    i0.ɵɵlistener("click", function AddMediaComponent_ng_container_1_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r17); const ctx_r18 = i0.ɵɵnextContext(); return ctx_r18.setMediaOptions(ctx_r18.addMediaOptions == null ? null : ctx_r18.addMediaOptions.mediaOptions, ctx_r18.fileType.video); });
    i0.ɵɵtext(5, "Video");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "a", 25);
    i0.ɵɵlistener("click", function AddMediaComponent_ng_container_1_Template_a_click_6_listener() { i0.ɵɵrestoreView(_r17); const ctx_r19 = i0.ɵɵnextContext(); return ctx_r19.setMediaOptions(ctx_r19.addMediaOptions == null ? null : ctx_r19.addMediaOptions.normal); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} }
function AddMediaComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    const _r21 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 26);
    i0.ɵɵelementStart(1, "div", 27);
    i0.ɵɵtext(2, " Add Media ");
    i0.ɵɵelementStart(3, "a", 28);
    i0.ɵɵlistener("click", function AddMediaComponent_div_2_Template_a_click_3_listener() { i0.ɵɵrestoreView(_r21); const ctx_r20 = i0.ɵɵnextContext(); return ctx_r20.onCloseAddMedia(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "div", 29);
    i0.ɵɵelementStart(5, "button", 30);
    i0.ɵɵlistener("click", function AddMediaComponent_div_2_Template_button_click_5_listener() { i0.ɵɵrestoreView(_r21); const ctx_r22 = i0.ɵɵnextContext(); return ctx_r22.setMediaOptions(ctx_r22.addMediaOptions == null ? null : ctx_r22.addMediaOptions.fromInspireLibrary); });
    i0.ɵɵtext(6, "Select From Inspire Library");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "button", 31);
    i0.ɵɵlistener("click", function AddMediaComponent_div_2_Template_button_click_7_listener() { i0.ɵɵrestoreView(_r21); const ctx_r23 = i0.ɵɵnextContext(); return ctx_r23.setMediaOptions(ctx_r23.addMediaOptions == null ? null : ctx_r23.addMediaOptions.takePhoto); });
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "button", 32);
    i0.ɵɵlistener("click", function AddMediaComponent_div_2_Template_button_click_9_listener() { i0.ɵɵrestoreView(_r21); const ctx_r24 = i0.ɵɵnextContext(); return ctx_r24.openMediaExplorer(); });
    i0.ɵɵtext(10);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("disabled", !(ctx_r2.inspireLibraryMedia == null ? null : ctx_r2.inspireLibraryMedia.length));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1("Take ", ctx_r2.mediaTypeLabel[ctx_r2.mediaType], "");
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1("Upload ", ctx_r2.mediaTypeLabel[ctx_r2.mediaType], "");
} }
function AddMediaComponent_div_3_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    const _r28 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "figure", 37);
    i0.ɵɵlistener("click", function AddMediaComponent_div_3_ng_container_6_Template_figure_click_1_listener() { i0.ɵɵrestoreView(_r28); const media_r26 = ctx.$implicit; const ctx_r27 = i0.ɵɵnextContext(2); return ctx_r27.onToggleMediaSelection(media_r26); });
    i0.ɵɵelement(2, "img", 19);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const media_r26 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("selected", media_r26 == null ? null : media_r26.isSelected);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("src", media_r26 == null ? null : media_r26.thumbnail_URL, i0.ɵɵsanitizeUrl);
} }
function AddMediaComponent_div_3_Template(rf, ctx) { if (rf & 1) {
    const _r30 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 33);
    i0.ɵɵelementStart(1, "div", 27);
    i0.ɵɵtext(2, " Select From Inspire Library ");
    i0.ɵɵelementStart(3, "a", 28);
    i0.ɵɵlistener("click", function AddMediaComponent_div_3_Template_a_click_3_listener() { i0.ɵɵrestoreView(_r30); const ctx_r29 = i0.ɵɵnextContext(); return ctx_r29.onRemoveAllSelectedMedia(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "div", 29);
    i0.ɵɵelementStart(5, "div", 34);
    i0.ɵɵtemplate(6, AddMediaComponent_div_3_ng_container_6_Template, 3, 3, "ng-container", 35);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "button", 36);
    i0.ɵɵlistener("click", function AddMediaComponent_div_3_Template_button_click_7_listener() { i0.ɵɵrestoreView(_r30); const ctx_r31 = i0.ɵɵnextContext(); return ctx_r31.onNext(); });
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(6);
    i0.ɵɵproperty("ngForOf", ctx_r3.inspireLibraryMedia);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("disabled", ctx_r3.isNoMediaSelected);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r3.nextButtonText, " ");
} }
function AddMediaComponent_div_9_webcam_4_Template(rf, ctx) { if (rf & 1) {
    const _r39 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "webcam", 46);
    i0.ɵɵlistener("imageCapture", function AddMediaComponent_div_9_webcam_4_Template_webcam_imageCapture_0_listener($event) { i0.ɵɵrestoreView(_r39); const ctx_r38 = i0.ɵɵnextContext(2); return ctx_r38.onImageCapture($event); })("initError", function AddMediaComponent_div_9_webcam_4_Template_webcam_initError_0_listener($event) { i0.ɵɵrestoreView(_r39); const ctx_r40 = i0.ɵɵnextContext(2); return ctx_r40.onInitError($event); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r32 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("height", 400)("width", 500)("trigger", ctx_r32.triggerObservable)("imageQuality", 1)("mirrorImage", ctx_r32.imageMirrorOption.never);
} }
function AddMediaComponent_div_9_video_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "video", 47, 48);
} }
function AddMediaComponent_div_9_ng_container_6_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelement(1, "img", 49);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const image_r43 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("src", image_r43, i0.ɵɵsanitizeUrl);
} }
function AddMediaComponent_div_9_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, AddMediaComponent_div_9_ng_container_6_div_1_Template, 2, 1, "div", 35);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r34 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r34.webcamPhotos);
} }
function AddMediaComponent_div_9_div_9_div_1_Template(rf, ctx) { if (rf & 1) {
    const _r47 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 52);
    i0.ɵɵtext(1, " Photo ");
    i0.ɵɵelementStart(2, "button", 53);
    i0.ɵɵlistener("click", function AddMediaComponent_div_9_div_9_div_1_Template_button_click_2_listener() { i0.ɵɵrestoreView(_r47); const ctx_r46 = i0.ɵɵnextContext(3); return ctx_r46.triggerWebcamSnapshot(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} }
function AddMediaComponent_div_9_div_9_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    const _r49 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 54);
    i0.ɵɵtext(2);
    i0.ɵɵelementStart(3, "button", 53);
    i0.ɵɵlistener("click", function AddMediaComponent_div_9_div_9_ng_container_2_Template_button_click_3_listener() { i0.ɵɵrestoreView(_r49); const ctx_r48 = i0.ɵɵnextContext(3); return ctx_r48.onToggleVideoCapture(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r45 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", !!ctx_r45.recordRtc && (ctx_r45.recordRtc == null ? null : ctx_r45.recordRtc.getState()) === "recording" ? "Stop" : "Video", " ");
} }
function AddMediaComponent_div_9_div_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 50);
    i0.ɵɵtemplate(1, AddMediaComponent_div_9_div_9_div_1_Template, 3, 0, "div", 51);
    i0.ɵɵtemplate(2, AddMediaComponent_div_9_div_9_ng_container_2_Template, 4, 1, "ng-container", 1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r36 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r36.mediaType === ctx_r36.fileType.image);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r36.mediaType === ctx_r36.fileType.video);
} }
function AddMediaComponent_div_9_div_10_Template(rf, ctx) { if (rf & 1) {
    const _r51 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 50);
    i0.ɵɵelementStart(1, "button", 55);
    i0.ɵɵlistener("click", function AddMediaComponent_div_9_div_10_Template_button_click_1_listener() { i0.ɵɵrestoreView(_r51); const ctx_r50 = i0.ɵɵnextContext(2); return ctx_r50.onRetakeMedia(); });
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "button", 56);
    i0.ɵɵlistener("click", function AddMediaComponent_div_9_div_10_Template_button_click_3_listener() { i0.ɵɵrestoreView(_r51); const ctx_r52 = i0.ɵɵnextContext(2); return ctx_r52.onUpload(); });
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r37 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1("Retake ", ctx_r37.mediaTypeLabel[ctx_r37.mediaType], "");
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1("Use ", ctx_r37.mediaTypeLabel[ctx_r37.mediaType], "");
} }
function AddMediaComponent_div_9_Template(rf, ctx) { if (rf & 1) {
    const _r54 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 38);
    i0.ɵɵelementStart(1, "a", 39);
    i0.ɵɵlistener("click", function AddMediaComponent_div_9_Template_a_click_1_listener() { i0.ɵɵrestoreView(_r54); const ctx_r53 = i0.ɵɵnextContext(); return ctx_r53.onCloseWebcam(); });
    i0.ɵɵtext(2, "\u00D7");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 40);
    i0.ɵɵtemplate(4, AddMediaComponent_div_9_webcam_4_Template, 1, 5, "webcam", 41);
    i0.ɵɵtemplate(5, AddMediaComponent_div_9_video_5_Template, 2, 0, "video", 42);
    i0.ɵɵtemplate(6, AddMediaComponent_div_9_ng_container_6_Template, 2, 1, "ng-container", 1);
    i0.ɵɵelement(7, "video", 43, 44);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(9, AddMediaComponent_div_9_div_9_Template, 3, 2, "div", 45);
    i0.ɵɵtemplate(10, AddMediaComponent_div_9_div_10_Template, 5, 2, "div", 45);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext();
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("ngIf", ctx_r6.showWebcam && ctx_r6.mediaType === ctx_r6.fileType.image);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r6.showWebcam && ctx_r6.mediaType === ctx_r6.fileType.video);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", (ctx_r6.webcamPhotos == null ? null : ctx_r6.webcamPhotos.length) && !ctx_r6.showWebcam);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("hidden", ctx_r6.showWebcam || ctx_r6.mediaType !== ctx_r6.fileType.video);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r6.showWebcam);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r6.showWebcam);
} }
function AddMediaComponent_div_10_div_6_div_12_div_1_Template(rf, ctx) { if (rf & 1) {
    const _r63 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 75);
    i0.ɵɵlistener("click", function AddMediaComponent_div_10_div_6_div_12_div_1_Template_div_click_0_listener() { i0.ɵɵrestoreView(_r63); const privacyOption_r60 = ctx.$implicit; const ctx_r62 = i0.ɵɵnextContext(2); const photo_r56 = ctx_r62.$implicit; const photoIndex_r57 = ctx_r62.index; const ctx_r61 = i0.ɵɵnextContext(2); return ctx_r61.onSelectPrivacyOption(privacyOption_r60, photo_r56, photoIndex_r57); });
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const privacyOption_r60 = ctx.$implicit;
    const ctx_r59 = i0.ɵɵnextContext(4);
    i0.ɵɵclassMap(ctx_r59.privacyStyle[privacyOption_r60 == null ? null : privacyOption_r60.value]);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", privacyOption_r60 == null ? null : privacyOption_r60.label, " ");
} }
function AddMediaComponent_div_10_div_6_div_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 73);
    i0.ɵɵtemplate(1, AddMediaComponent_div_10_div_6_div_12_div_1_Template, 2, 3, "div", 74);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r58 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r58.privacyOptions);
} }
function AddMediaComponent_div_10_div_6_Template(rf, ctx) { if (rf & 1) {
    const _r65 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 61);
    i0.ɵɵelementStart(1, "figure", 62);
    i0.ɵɵelement(2, "img", 19);
    i0.ɵɵelementStart(3, "a", 63);
    i0.ɵɵlistener("click", function AddMediaComponent_div_10_div_6_Template_a_click_3_listener() { i0.ɵɵrestoreView(_r65); const photo_r56 = ctx.$implicit; const ctx_r64 = i0.ɵɵnextContext(2); return ctx_r64.onRemoveSelectedMedia(photo_r56); });
    i0.ɵɵtext(4, "\u00D7");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "div", 64);
    i0.ɵɵelementStart(6, "input", 65);
    i0.ɵɵlistener("ngModelChange", function AddMediaComponent_div_10_div_6_Template_input_ngModelChange_6_listener($event) { i0.ɵɵrestoreView(_r65); const photo_r56 = ctx.$implicit; return photo_r56.caption = $event; });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "div", 66);
    i0.ɵɵlistener("clickOutside", function AddMediaComponent_div_10_div_6_Template_div_clickOutside_7_listener() { i0.ɵɵrestoreView(_r65); const photoIndex_r57 = ctx.index; const ctx_r67 = i0.ɵɵnextContext(2); return ctx_r67.onTogglePrivacyOption(photoIndex_r57, false); })("click", function AddMediaComponent_div_10_div_6_Template_div_click_7_listener() { i0.ɵɵrestoreView(_r65); const photoIndex_r57 = ctx.index; const ctx_r68 = i0.ɵɵnextContext(2); return ctx_r68.onTogglePrivacyOption(photoIndex_r57); });
    i0.ɵɵelementStart(8, "div", 67);
    i0.ɵɵtext(9, " Privacy: ");
    i0.ɵɵelementStart(10, "span", 68);
    i0.ɵɵtext(11);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(12, AddMediaComponent_div_10_div_6_div_12_Template, 2, 1, "div", 69);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(13, "div", 70);
    i0.ɵɵelementStart(14, "input", 71);
    i0.ɵɵlistener("ngModelChange", function AddMediaComponent_div_10_div_6_Template_input_ngModelChange_14_listener($event) { i0.ɵɵrestoreView(_r65); const photo_r56 = ctx.$implicit; return photo_r56.sensitive = $event; });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(15, "div", 72);
    i0.ɵɵtext(16, " Mark as sensitive ");
    i0.ɵɵelementStart(17, "small");
    i0.ɵɵtext(18, "(tap to see)");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const photo_r56 = ctx.$implicit;
    const photoIndex_r57 = ctx.index;
    const ctx_r55 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("src", photo_r56.thumbnail_URL, i0.ɵɵsanitizeUrl);
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("ngModel", photo_r56.caption);
    i0.ɵɵadvance(4);
    i0.ɵɵclassMap(ctx_r55.privacyStyle[photo_r56 == null ? null : photo_r56.privacy]);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r55.getSelectedPrivacyLabel(photo_r56));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r55.showPrivacyOption[photoIndex_r57]);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngModel", photo_r56.sensitive);
} }
function AddMediaComponent_div_10_Template(rf, ctx) { if (rf & 1) {
    const _r71 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 57);
    i0.ɵɵelementStart(1, "div", 27);
    i0.ɵɵtext(2, " Media Details ");
    i0.ɵɵelementStart(3, "a", 28);
    i0.ɵɵlistener("click", function AddMediaComponent_div_10_Template_a_click_3_listener() { i0.ɵɵrestoreView(_r71); const ctx_r70 = i0.ɵɵnextContext(); return ctx_r70.onRemoveAllSelectedMedia(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "div", 29);
    i0.ɵɵelementStart(5, "div", 58);
    i0.ɵɵtemplate(6, AddMediaComponent_div_10_div_6_Template, 19, 7, "div", 59);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "button", 60);
    i0.ɵɵlistener("click", function AddMediaComponent_div_10_Template_button_click_7_listener($event) { i0.ɵɵrestoreView(_r71); const ctx_r72 = i0.ɵɵnextContext(); return ctx_r72.onAttachMediaToPost($event); });
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r7 = i0.ɵɵnextContext();
    i0.ɵɵadvance(6);
    i0.ɵɵproperty("ngForOf", ctx_r7.selectedMedia);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r7.attachToPostButtonText, " ");
} }
export class AddMediaComponent {
    constructor() {
        this.media = [];
        this.attachedMedia = [];
        this.customMediaOption = null;
        this.nextButtonText = 'Next';
        this.attachToPostButtonText = 'Attach to post';
        this.mediaType = FileType.image;
        this.isMobile = false;
        this.setAttachedMedia = new EventEmitter();
        this.updateMediaMetaData = new EventEmitter();
        this.uploadFile = new EventEmitter();
        this.closeAddMedia = new EventEmitter();
        this.addMediaOptions = AddMediaOptions;
        this.currentMediaOption = AddMediaOptions.normal;
        this.showPrivacyOption = new Array(this.media.length).fill(false);
        this.webcamPhotos = [];
        this.filesToUpload = [];
        this.showWebcam = true;
        this.errors = [];
        this.triggerWebCam$ = new Subject();
        this.isNoMediaSelected = false;
        this.inspireLibraryMedia = [];
        this.selectedMedia = [];
        this.selectedMediaCopy = [];
        this.imageMirrorOption = ImageMirrorOption;
        this.privacyOptions = MEDIA_PRIVACY_OPTIONS;
        this.privacyStyle = MEDIA_PRIVACY_STYLE_CLASS;
        this.fileType = FileType;
        this.mediaTypeLabel = ADD_MEDIA_LABEL;
        // video
        this.videoStream = null;
        this.recordRtc = null;
    }
    ngOnInit() {
        if (this.customMediaOption) {
            this.currentMediaOption = this.customMediaOption;
        }
        this.media = this.media.map(photo => {
            photo.isSelected = !!photo.isAttached;
            return photo;
        });
    }
    ngOnChanges(changes) {
        for (const propName in changes) {
            if (changes.hasOwnProperty(propName) && !changes[propName].firstChange) {
                switch (propName) {
                    case 'media': {
                        this.onMediaUpdate();
                    }
                }
            }
        }
        this.updateIsNoMediaSelected();
    }
    onMediaUpdate() {
        var _a;
        let attachedPhotosCount = 0;
        let attachedVideoCount = 0;
        this.media = this.media.map(photo => {
            if (photo.filetype === this.fileType.image) {
                attachedPhotosCount += +(!!(photo === null || photo === void 0 ? void 0 : photo.isSelected));
                if (attachedPhotosCount > MAX_JOURNAL_POST_IMAGES && (photo === null || photo === void 0 ? void 0 : photo.isSelected)) {
                    photo.isAttached = false;
                    photo.isSelected = false;
                }
            }
            else if (photo.filetype === this.fileType.video) {
                attachedVideoCount += +(!!(photo === null || photo === void 0 ? void 0 : photo.isSelected));
                if (attachedVideoCount > MAX_JOURNAL_POST_VIDEO && (photo === null || photo === void 0 ? void 0 : photo.isSelected)) {
                    photo.isAttached = false;
                    photo.isSelected = false;
                }
            }
            return photo;
        });
        this.selectedMedia = this.media.filter(photo => photo.isSelected);
        this.selectedMediaCopy = JSON.parse(JSON.stringify(this.selectedMedia));
        this.webcamPhotos = [];
        this.toggleWebcam(true);
        this.setMediaOptions((_a = this.addMediaOptions) === null || _a === void 0 ? void 0 : _a.addPhotos);
    }
    updateIsNoMediaSelected() {
        this.isNoMediaSelected = this.media.filter(photo => photo.filetype.includes(this.mediaType)).every(photo => !photo.isSelected);
    }
    onEditAttachedMedia() {
        var _a;
        this.selectedMedia = this.attachedMedia.map(attachedMedia => {
            attachedMedia.isSelected = true;
            return attachedMedia;
        });
        this.selectedMediaCopy = JSON.parse(JSON.stringify(this.selectedMedia));
        this.setMediaOptions((_a = this.addMediaOptions) === null || _a === void 0 ? void 0 : _a.addPhotos);
    }
    onCloseAddMedia() {
        this.setMediaOptions(this.addMediaOptions.normal);
        this.closeAddMedia.emit();
    }
    setMediaOptions(option, mediaType) {
        if (this.isMobile && option === AddMediaOptions.takePhoto) {
            this.openMobileNativeCameraApp();
            return;
        }
        else {
            this.currentMediaOption = option;
            if (this.mediaType === this.fileType.video && option === AddMediaOptions.takePhoto) {
                this.initVideoStream();
            }
        }
        if (mediaType) {
            this.mediaType = mediaType;
            this.inspireLibraryMedia = this.media.filter(media => media.filetype.includes(mediaType));
        }
        this.updateIsNoMediaSelected();
    }
    initVideoStream() {
        navigator.mediaDevices.getUserMedia({ audio: true, video: true })
            .then((stream) => {
            this.videoStream = stream;
            this.videoCapture.nativeElement.srcObject = this.videoStream;
        })
            .catch(error => {
            // video not supported
        });
    }
    closeVideoStream() {
        if (this.videoStream) {
            const stream = this.videoStream;
            stream.getAudioTracks().forEach(track => track.stop());
            stream.getVideoTracks().forEach(track => track.stop());
        }
    }
    onToggleVideoCapture() {
        var _a, _b, _c;
        if (!this.recordRtc || ((_a = this.recordRtc) === null || _a === void 0 ? void 0 : _a.getState()) !== RTCState.recording) {
            this.recordRtc = null;
            const options = {
                mimeType: 'video/webm\;codecs=h264',
                bitsPerSecond: 128000
            };
            this.recordRtc = new RecordRTC(this.videoStream, options);
            this.recordRtc.startRecording();
            (_c = (_b = this.videoCapture) === null || _b === void 0 ? void 0 : _b.nativeElement) === null || _c === void 0 ? void 0 : _c.load();
        }
        else {
            this.recordRtc.stopRecording(this.processVideo.bind(this));
        }
    }
    processVideo(audioVideoWebMURL) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            this.toggleWebcam(false);
            this.videoPlay.nativeElement.src = audioVideoWebMURL;
            const blob = yield this.recordRtc.getBlob();
            this.filesToUpload = [new File([blob], 'webcamVideo.webm', { type: 'video/webm' })];
            (_a = this.recordRtc) === null || _a === void 0 ? void 0 : _a.destroy();
            this.recordRtc = null;
            this.closeVideoStream();
        });
    }
    onCloseWebcam() {
        var _a, _b;
        // making this true, so when next camera is open it shows the camera not the previously taken picture
        this.toggleWebcam(true);
        // this method is responsible for rendering parent div or camera
        this.setMediaOptions((_a = this.addMediaOptions) === null || _a === void 0 ? void 0 : _a.mediaOptions);
        this.webcamPhotos = [];
        this.filesToUpload = [];
        (_b = this.recordRtc) === null || _b === void 0 ? void 0 : _b.destroy();
        this.recordRtc = null;
        this.closeVideoStream();
    }
    onRetakeMedia() {
        this.toggleWebcam(true);
        if (this.mediaType === this.fileType.video) {
            this.videoPlay.nativeElement.src = '';
            this.initVideoStream();
        }
    }
    onToggleMediaSelection(selectedPhoto) {
        const mediaLimit = {
            [FileType.image]: MAX_JOURNAL_POST_IMAGES,
            [FileType.video]: MAX_JOURNAL_POST_VIDEO
        };
        const selectedMedia = this.media.filter(photo => photo.isSelected && photo.filetype == this.mediaType).length;
        if (selectedMedia < mediaLimit[this.mediaType] || selectedPhoto.isSelected) {
            selectedPhoto.isSelected = !selectedPhoto.isSelected;
        }
        this.updateIsNoMediaSelected();
    }
    onNext() {
        var _a;
        this.selectedMedia = this.media.filter(photo => photo.isSelected);
        this.selectedMediaCopy = JSON.parse(JSON.stringify(this.selectedMedia));
        this.setMediaOptions((_a = this.addMediaOptions) === null || _a === void 0 ? void 0 : _a.addPhotos);
    }
    onRemoveSelectedMedia(photo) {
        var _a, _b;
        photo.isSelected = false;
        this.selectedMedia = this.media.filter(photo => photo.isSelected);
        if (!((_a = this.selectedMedia) === null || _a === void 0 ? void 0 : _a.length)) {
            this.setMediaOptions(this.customMediaOption ? this.customMediaOption : (_b = this.addMediaOptions) === null || _b === void 0 ? void 0 : _b.normal);
        }
    }
    onRemoveAttachedMedia(photo) {
        photo.isSelected = false;
        photo.isAttached = false;
        this.updateAttachedMedia(this.media);
        this.setAttachedMedia.emit(this.attachedMedia);
    }
    onRemoveAllSelectedMedia() {
        var _a;
        this.removeUnsavedChanges();
        this.updateAttachedMedia(this.media);
        this.setMediaOptions((_a = this.addMediaOptions) === null || _a === void 0 ? void 0 : _a.mediaOptions);
    }
    removeUnsavedChanges() {
        const selectedPhotosCopyDict = this.selectedMediaCopy.reduce((acc, cur) => {
            acc[cur.uuid] = cur;
            return acc;
        }, {});
        this.media = this.media.map(photo => {
            if (!!selectedPhotosCopyDict[photo.uuid]) {
                const { caption, privacy, sensitive } = selectedPhotosCopyDict[photo.uuid];
                photo.caption = caption;
                photo.privacy = privacy;
                photo.sensitive = sensitive;
            }
            if (photo.isAttached) {
                photo.isSelected = true;
            }
            else {
                photo.isSelected = false;
            }
            return photo;
        });
    }
    onSelectPrivacyOption(privacyOption, photo, photoIndex) {
        photo.privacy = privacyOption.value;
        this.showPrivacyOption[photoIndex] = false;
    }
    onTogglePrivacyOption(photoIndex, value) {
        if (value === true || value === false) {
            this.showPrivacyOption[photoIndex] = value;
        }
        else {
            this.showPrivacyOption[photoIndex] = !this.showPrivacyOption[photoIndex];
        }
    }
    getSelectedPrivacyLabel(photo) {
        const privacy = this.privacyOptions.find(privacy => privacy.value === photo.privacy);
        if (privacy) {
            return privacy.label;
        }
        return '';
    }
    onUpdateAttachedPhotosMetaData(attachedMedia) {
        this.updateMediaMetaData.emit(attachedMedia);
    }
    onAttachMediaToPost(event) {
        var _a;
        this.selectedMedia = this.selectedMedia.map(selectedPhoto => {
            selectedPhoto.isAttached = true;
            return selectedPhoto;
        });
        this.selectedMediaCopy = JSON.parse(JSON.stringify(this.selectedMedia));
        this.updateAttachedMedia(this.selectedMedia);
        this.onUpdateAttachedPhotosMetaData(this.attachedMedia);
        this.setMediaOptions((_a = this.addMediaOptions) === null || _a === void 0 ? void 0 : _a.normal);
        this.selectedMedia = [];
        this.setAttachedMedia.emit(this.attachedMedia);
        this.closeAddMedia.emit();
        event.stopPropagation();
    }
    updateAttachedMedia(selectedMedia) {
        this.attachedMedia = selectedMedia.filter(selectedPhoto => selectedPhoto.isAttached && selectedPhoto.isSelected);
    }
    onSelectMedia(event) {
        var _a;
        const files = Array.from(((_a = event.target) === null || _a === void 0 ? void 0 : _a.files) || []);
        this.filesToUpload = [...files];
        this.onUpload();
    }
    onCaptureMediaFromMobile(event) {
        this.onSelectMedia(event);
    }
    onUpload() {
        this.uploadFile.emit(this.filesToUpload);
    }
    openMediaExplorer() {
        this.browseMedia.nativeElement.click();
    }
    openMobileNativeCameraApp() {
        this.mobileNativeCamera.nativeElement.click();
    }
    onImageCapture(webcamImage) {
        return __awaiter(this, void 0, void 0, function* () {
            try {
                const file = yield this.convertBase64ToImage('webcamimage.jpeg', 'image/jpeg', webcamImage.imageAsDataUrl);
                this.filesToUpload = [file];
                this.webcamPhotos = [webcamImage.imageAsDataUrl];
            }
            catch (err) { }
        });
    }
    triggerWebcamSnapshot() {
        this.triggerWebCam$.next();
        this.toggleWebcam(false);
    }
    get triggerObservable() {
        return this.triggerWebCam$.asObservable();
    }
    toggleWebcam(value) {
        if (value == false || value == true) {
            this.showWebcam = value;
        }
        else {
            this.showWebcam = !this.showWebcam;
        }
    }
    onInitError(error) {
        this.errors.push(error);
    }
    convertBase64ToImage(imageName, type, base64) {
        return __awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
                const response = yield fetch(base64);
                const blob = yield response.blob();
                resolve(new File([blob], imageName, { type }));
            }));
        });
    }
}
AddMediaComponent.ɵfac = function AddMediaComponent_Factory(t) { return new (t || AddMediaComponent)(); };
AddMediaComponent.ɵcmp = i0.ɵɵdefineComponent({ type: AddMediaComponent, selectors: [["ins-add-media"]], viewQuery: function AddMediaComponent_Query(rf, ctx) { if (rf & 1) {
        i0.ɵɵviewQuery(_c0, true);
        i0.ɵɵviewQuery(_c1, true);
        i0.ɵɵviewQuery(_c2, true);
        i0.ɵɵviewQuery(_c3, true);
    } if (rf & 2) {
        var _t;
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.browseMedia = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.mobileNativeCamera = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.videoCapture = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.videoPlay = _t.first);
    } }, inputs: { media: "media", attachedMedia: "attachedMedia", customMediaOption: "customMediaOption", nextButtonText: "nextButtonText", attachToPostButtonText: "attachToPostButtonText", mediaType: "mediaType", isMobile: "isMobile" }, outputs: { setAttachedMedia: "setAttachedMedia", updateMediaMetaData: "updateMediaMetaData", uploadFile: "uploadFile", closeAddMedia: "closeAddMedia" }, features: [i0.ɵɵNgOnChangesFeature], decls: 11, vars: 8, consts: [["class", "media-control", 4, "ngIf"], [4, "ngIf"], ["class", "media-popup-box add-media-box", "id", "media_select", 4, "ngIf"], ["class", "media-popup-box add-media-box", "id", "media_upload_inspire_library", 4, "ngIf"], ["hidden", ""], ["hidden", "", "type", "file", 3, "accept", "change"], ["browseMedia", ""], ["hidden", "", "type", "file", "capture", "", 3, "accept", "change"], ["mobileNativeCamera", ""], ["class", "capture-photo-wrap", 4, "ngIf"], ["class", "media-popup-box add-media-box", "id", "media_photo_summary", 4, "ngIf"], [1, "media-control"], ["id", "add_media_btn", 1, "cjp-action", 3, "click"], [1, "icn-plus-o"], [1, "cjp-a-label"], ["class", "media-listing", 4, "ngIf"], [1, "media-listing"], ["class", "media-thumbnail", "id", "attached_photo", 4, "ngFor", "ngForOf"], ["id", "attached_photo", 1, "media-thumbnail"], ["alt", "Image Title", 3, "src"], ["id", "attached_photo_remove", 1, "media-remove", 3, "click"], ["id", "attached_photo_edit", 1, "media-edit", "icn-edit", 3, "click"], ["id", "media_type", 1, "upload-btn-group"], ["type", "button", "id", "media_type_photo", 1, "bttn", 3, "click"], ["type", "button", "id", "media_type_video", 1, "bttn", 3, "click"], [1, "ubg-close", "icn-cross-o", 3, "click"], ["id", "media_select", 1, "media-popup-box", "add-media-box"], [1, "mpb-head"], [1, "icn-cross-o", "mpb-close", "media-close", 3, "click"], [1, "mpb-body"], ["type", "button", "id", "media_select_inspire_library", 1, "btn-inspire-lib", 3, "disabled", "click"], ["type", "button", "id", "media_select_take_photo", 1, "btn-take-photo", 3, "click"], ["type", "button", "id", "media_select_browse_photo", 1, "btn-upload-photo", 3, "click"], ["id", "media_upload_inspire_library", 1, "media-popup-box", "add-media-box"], [1, "media-library"], [4, "ngFor", "ngForOf"], ["type", "button", "id", "media_attach", 1, "btn-next", 3, "disabled", "click"], ["id", "media_library_photo", 1, "media-thumbnail", 3, "click"], [1, "capture-photo-wrap"], [1, "cpw-close", 3, "click"], [1, "cpw-webcam"], [3, "height", "width", "trigger", "imageQuality", "mirrorImage", "imageCapture", "initError", 4, "ngIf"], ["autoplay", "", "playsinline", "", "controls", "", "controlsList", "nofullscreen nodownload", "disablepictureinpicture", "", 4, "ngIf"], ["controls", "", "controlsList", "nofullscreen nodownload", "disablepictureinpicture", "", 3, "hidden"], ["videoPlay", ""], ["class", "cpw-actions", 4, "ngIf"], [3, "height", "width", "trigger", "imageQuality", "mirrorImage", "imageCapture", "initError"], ["autoplay", "", "playsinline", "", "controls", "", "controlsList", "nofullscreen nodownload", "disablepictureinpicture", ""], ["videoCapture", ""], ["alt", "image", 3, "src"], [1, "cpw-actions"], ["class", "cpw-take-photo", 4, "ngIf"], [1, "cpw-take-photo"], ["type", "button", 1, "cpw-photo-btn", 3, "click"], [1, "cpw-take-photo", "mr-2"], ["type", "button", "id", "retake_photo_btn", 1, "cpw-btn", 3, "click"], ["type", "button", "id", "upload_photo_btn", 1, "cpw-btn", 3, "click"], ["id", "media_photo_summary", 1, "media-popup-box", "add-media-box"], [1, "media-details"], ["class", "md-item", 4, "ngFor", "ngForOf"], ["type", "button", "id", "post_btn", 1, "btn-next", 3, "click"], [1, "md-item"], [1, "media-thumbnail"], ["id", "media_photo_summary_remove", 1, "media-remove", 3, "click"], [1, "md-meta"], ["placeholder", "Your caption", "type", "text", 1, "md-input", 3, "ngModel", "ngModelChange"], ["id", "toggle_privacy", 1, "md-privacy", 3, "clickOutside", "click"], [1, "md-p-btn"], [1, "md-p-selected"], ["class", "md-p-menu", "id", "privacy_option_menu", 4, "ngIf"], [1, "md-sensitive"], ["placeholder", "Your caption", "type", "checkbox", 1, "md-s-checkbox", 3, "ngModel", "ngModelChange"], [1, "md-s-content"], ["id", "privacy_option_menu", 1, "md-p-menu"], ["class", "md-p-item", "id", "privacy_option", 3, "class", "click", 4, "ngFor", "ngForOf"], ["id", "privacy_option", 1, "md-p-item", 3, "click"]], template: function AddMediaComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵtemplate(0, AddMediaComponent_div_0_Template, 6, 1, "div", 0);
        i0.ɵɵtemplate(1, AddMediaComponent_ng_container_1_Template, 7, 0, "ng-container", 1);
        i0.ɵɵtemplate(2, AddMediaComponent_div_2_Template, 11, 3, "div", 2);
        i0.ɵɵtemplate(3, AddMediaComponent_div_3_Template, 9, 3, "div", 3);
        i0.ɵɵelementStart(4, "div", 4);
        i0.ɵɵelementStart(5, "input", 5, 6);
        i0.ɵɵlistener("change", function AddMediaComponent_Template_input_change_5_listener($event) { return ctx.onSelectMedia($event); });
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(7, "input", 7, 8);
        i0.ɵɵlistener("change", function AddMediaComponent_Template_input_change_7_listener($event) { return ctx.onCaptureMediaFromMobile($event); });
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵtemplate(9, AddMediaComponent_div_9_Template, 11, 6, "div", 9);
        i0.ɵɵtemplate(10, AddMediaComponent_div_10_Template, 9, 2, "div", 10);
    } if (rf & 2) {
        i0.ɵɵproperty("ngIf", ctx.currentMediaOption == (ctx.addMediaOptions == null ? null : ctx.addMediaOptions.normal));
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.currentMediaOption == (ctx.addMediaOptions == null ? null : ctx.addMediaOptions.mediaTypes));
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.currentMediaOption == (ctx.addMediaOptions == null ? null : ctx.addMediaOptions.mediaOptions));
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.currentMediaOption == (ctx.addMediaOptions == null ? null : ctx.addMediaOptions.fromInspireLibrary));
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("accept", ctx.mediaType + "/*");
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("accept", ctx.mediaType + "/*");
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.currentMediaOption == (ctx.addMediaOptions == null ? null : ctx.addMediaOptions.takePhoto));
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.currentMediaOption == (ctx.addMediaOptions == null ? null : ctx.addMediaOptions.addPhotos));
    } }, directives: [i1.NgIf, i1.NgForOf, i2.WebcamComponent, i3.DefaultValueAccessor, i3.NgControlStatus, i3.NgModel, i4.ClickOutsideDirective, i3.CheckboxControlValueAccessor], styles: ["@font-face{font-family:ins-icons;src:url(/assets/fonts/icons/ins-icons.ttf?nf14g1) format(\"truetype\"),url(/assets/fonts/icons/ins-icons.woff?nf14g1) format(\"woff\"),url(/assets/fonts/icons/ins-icons.svg?nf14g1#ins-icons) format(\"svg\");font-weight:400;font-style:normal;font-display:block}.ins-icon[_ngcontent-%COMP%], .media-thumbnail.selected[_ngcontent-%COMP%]:after, [class*=\" icn-\"][_ngcontent-%COMP%], [class^=icn-][_ngcontent-%COMP%]{font-family:ins-icons!important;speak:never;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icn-minus-o[_ngcontent-%COMP%]:before{content:\"\\e93a\"}.icn-disclaimer[_ngcontent-%COMP%]:before{content:\"\\e934\"}.icn-leave-community[_ngcontent-%COMP%]:before{content:\"\\e935\"}.icn-stethoscope[_ngcontent-%COMP%]:before{content:\"\\e936\"}.icn-join-community[_ngcontent-%COMP%]:before{content:\"\\e937\"}.icn-resources[_ngcontent-%COMP%]:before{content:\"\\e938\"}.icn-help[_ngcontent-%COMP%]:before{content:\"\\e939\"}.icn-checked[_ngcontent-%COMP%]:before{content:\"\\e933\"}.icn-plus[_ngcontent-%COMP%]:before{content:\"\\e932\"}.icn-expand[_ngcontent-%COMP%]:before{content:\"\\e931\"}.icn-Invite[_ngcontent-%COMP%]:before{content:\"\\e930\"}.icn-report[_ngcontent-%COMP%]:before{content:\"\\e92f\"}.icn-unfollow[_ngcontent-%COMP%]:before{content:\"\\e92e\"}.icn-block[_ngcontent-%COMP%]:before{content:\"\\e92d\"}.icn-trash[_ngcontent-%COMP%]:before{content:\"\\e92b\"}.icn-follow[_ngcontent-%COMP%]:before{content:\"\\e92c\"}.icn-lock[_ngcontent-%COMP%]:before{content:\"\\e92a\"}.icn-bolt-left[_ngcontent-%COMP%]:before{content:\"\\e925\"}.icn-bolt-right[_ngcontent-%COMP%]:before{content:\"\\e926\"}.icn-bolt-down[_ngcontent-%COMP%]:before{content:\"\\e927\"}.icn-bolt-up[_ngcontent-%COMP%]:before{content:\"\\e928\"}.icn-img-o[_ngcontent-%COMP%]:before{content:\"\\e929\"}.icn-tick[_ngcontent-%COMP%]:before{content:\"\\e924\"}.icn-tick-o[_ngcontent-%COMP%]:before{content:\"\\e923\"}.icn-cross-o[_ngcontent-%COMP%]:before{content:\"\\e922\"}.icn-plus-o[_ngcontent-%COMP%]:before{content:\"\\e921\"}.icn-hide[_ngcontent-%COMP%]:before{content:\"\\e920\"}.icn-menu[_ngcontent-%COMP%]:before{content:\"\\e900\"}.icn-more[_ngcontent-%COMP%]:before{content:\"\\e901\"}.icn-msgs[_ngcontent-%COMP%]:before{content:\"\\e902\"}.icn-pin[_ngcontent-%COMP%]:before{content:\"\\e903\"}.icn-reply[_ngcontent-%COMP%]:before{content:\"\\e904\"}.icn-search[_ngcontent-%COMP%]:before{content:\"\\e905\"}.icn-settings[_ngcontent-%COMP%]:before{content:\"\\e906\"}.icn-treatment[_ngcontent-%COMP%]:before{content:\"\\e907\"}.icn-aid[_ngcontent-%COMP%]:before{content:\"\\e908\"}.icn-apple[_ngcontent-%COMP%]:before{content:\"\\e909\"}.icn-arrow-down[_ngcontent-%COMP%]:before{content:\"\\e90a\"}.icn-arrow-up[_ngcontent-%COMP%]:before{content:\"\\e91d\"}.icn-arrow-left[_ngcontent-%COMP%]:before{content:\"\\e91e\"}.icn-arrow-right[_ngcontent-%COMP%]:before{content:\"\\e91f\"}.icn-bell[_ngcontent-%COMP%]:before{content:\"\\e90b\"}.icn-bookmark-o[_ngcontent-%COMP%]:before{content:\"\\e90c\"}.icn-calendar[_ngcontent-%COMP%]:before{content:\"\\e90d\"}.icn-check[_ngcontent-%COMP%]:before{content:\"\\e90e\"}.icn-community[_ngcontent-%COMP%]:before{content:\"\\e90f\"}.icn-d-arrow-up[_ngcontent-%COMP%]:before{content:\"\\e910\"}.icn-discussion[_ngcontent-%COMP%]:before{content:\"\\e911\"}.icn-edit[_ngcontent-%COMP%]:before{content:\"\\e912\"}.icn-facebook[_ngcontent-%COMP%]:before{content:\"\\e913\"}.icn-filters[_ngcontent-%COMP%]:before{content:\"\\e914\"}.icn-friends[_ngcontent-%COMP%]:before{content:\"\\e915\"}.icn-google[_ngcontent-%COMP%]:before{content:\"\\e916\"}.icn-heart[_ngcontent-%COMP%]:before{content:\"\\e917\"}.icn-home[_ngcontent-%COMP%]:before{content:\"\\e918\"}.icn-img[_ngcontent-%COMP%]:before{content:\"\\e919\"}.icn-inspire[_ngcontent-%COMP%]:before{content:\"\\e91a\"}.icn-journal[_ngcontent-%COMP%]:before{content:\"\\e91b\"}.icn-like[_ngcontent-%COMP%]:before{content:\"\\e91c\"}.btn-inspire-lib[_ngcontent-%COMP%], .btn-next[_ngcontent-%COMP%], .btn-take-photo[_ngcontent-%COMP%], .btn-upload-photo[_ngcontent-%COMP%], .upload-btn-group[_ngcontent-%COMP%]   .bttn[_ngcontent-%COMP%]{border:none;border-radius:.5rem;font-size:1rem;line-height:1;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;padding:0 1rem;height:2.25rem;transition:.3s ease-in-out}.btn-inspire-lib[_ngcontent-%COMP%]:hover, .btn-next[_ngcontent-%COMP%]:hover, .btn-take-photo[_ngcontent-%COMP%]:hover, .btn-upload-photo[_ngcontent-%COMP%]:hover, .upload-btn-group[_ngcontent-%COMP%]   .bttn[_ngcontent-%COMP%]:hover{background:#f8f9fb}.btn-inspire-lib[disabled][_ngcontent-%COMP%], .btn-next[disabled][_ngcontent-%COMP%], .btn-take-photo[disabled][_ngcontent-%COMP%], .btn-upload-photo[disabled][_ngcontent-%COMP%], .upload-btn-group[_ngcontent-%COMP%]   .bttn[disabled][_ngcontent-%COMP%]{background:#c6cbc9;color:#6e6f70;cursor:default}.btn-inspire-lib[_ngcontent-%COMP%]{background:#009dfc;color:#fff}.btn-inspire-lib[_ngcontent-%COMP%]:not([disabled]):hover{background:#008de3}.btn-next[_ngcontent-%COMP%], .btn-take-photo[_ngcontent-%COMP%], .upload-btn-group[_ngcontent-%COMP%]   .bttn[_ngcontent-%COMP%]{background:#005cc9;color:#fff}.btn-next[_ngcontent-%COMP%]:not([disabled]):hover, .btn-take-photo[_ngcontent-%COMP%]:not([disabled]):hover, .upload-btn-group[_ngcontent-%COMP%]   .bttn[_ngcontent-%COMP%]:not([disabled]):hover{background:#0050b0}.btn-upload-photo[_ngcontent-%COMP%]{background:#943585;color:#fff}.btn-upload-photo[_ngcontent-%COMP%]:not([disabled]):hover{background:#812e74}.upload-btn-group[_ngcontent-%COMP%]{display:flex;align-items:center;margin-bottom:1.25rem}.upload-btn-group[_ngcontent-%COMP%]   .bttn[_ngcontent-%COMP%]{margin-right:.3125rem;width:6.875rem}.ubg-close[_ngcontent-%COMP%]{margin-left:1.25rem}.media-close[_ngcontent-%COMP%], .mpb-close[_ngcontent-%COMP%], .ubg-close[_ngcontent-%COMP%]{font-size:.875rem;color:#c6cbc9;cursor:pointer}.media-close[_ngcontent-%COMP%]:hover, .mpb-close[_ngcontent-%COMP%]:hover, .ubg-close[_ngcontent-%COMP%]:hover{color:#000}.add-media-box[_ngcontent-%COMP%]{border:1px solid #e2e5e4;box-shadow:0 .125rem .3125rem 0 rgba(208,208,208,.5)}.add-media-box[_ngcontent-%COMP%]   .bttn[_ngcontent-%COMP%]{margin-left:auto;margin-right:auto;display:flex;width:350px}.mpb-head[_ngcontent-%COMP%]{border-bottom:1px solid #e2e5e4;text-align:center;padding:.625rem;position:relative}.mpb-close[_ngcontent-%COMP%]{position:absolute;right:.625rem;top:50%;transform:translateY(-50%)}.mpb-body[_ngcontent-%COMP%]{padding:1.5rem}@media (max-width:575px){.mpb-body[_ngcontent-%COMP%]{padding:1rem}}.btn-inspire-lib[_ngcontent-%COMP%], .btn-next[_ngcontent-%COMP%], .btn-take-photo[_ngcontent-%COMP%], .btn-upload-photo[_ngcontent-%COMP%]{margin-left:auto;margin-right:auto;display:flex;max-width:350px;width:100%}.btn-inspire-lib[_ngcontent-%COMP%], .btn-next[_ngcontent-%COMP%], .btn-take-photo[_ngcontent-%COMP%]{margin-bottom:1rem}.media-thumbnail[_ngcontent-%COMP%]{width:5.625rem;height:5.625rem;border-radius:.3125rem;overflow:hidden;position:relative;margin:6px;background:#f8f9fb;cursor:pointer}.media-thumbnail[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;-o-object-fit:cover;object-fit:cover}.media-thumbnail.selected[_ngcontent-%COMP%]:before{content:\"\";border:.3125rem solid #005cc9;position:absolute;z-index:1;width:100%;height:100%}.media-thumbnail.selected[_ngcontent-%COMP%]:after{content:\"\\e924\";position:absolute;z-index:1;font-size:.9375rem;background:#005cc9;width:1.875rem;height:1.875rem;border-radius:50%;color:#fff;display:flex;align-items:center;justify-content:center;top:0;left:0}.media-library[_ngcontent-%COMP%]{display:flex;align-items:center;max-width:31.875rem;flex-wrap:wrap;margin:0 auto 1.25rem}.media-details[_ngcontent-%COMP%]{margin-bottom:1.25rem}.media-details[_ngcontent-%COMP%]   .media-thumbnail[_ngcontent-%COMP%]{margin-right:.9375rem}.md-input[_ngcontent-%COMP%]{border:none;background:0 0;font-size:1rem;color:#000;margin-bottom:.5rem}.media-remove[_ngcontent-%COMP%]{position:absolute;right:.3125rem;top:.3125rem;background:#fff;color:#6e6f70;width:1.25rem;height:1.25rem;border-radius:.3125rem;display:flex;align-items:center;justify-content:center;font-size:1.1875rem;font-weight:700}.media-edit[_ngcontent-%COMP%]{position:absolute;left:.3125rem;top:.3125rem;background:#fff;color:#6e6f70;width:1.25rem;height:1.25rem;border-radius:.3125rem;display:flex;align-items:center;justify-content:center;font-size:.625rem}.md-item[_ngcontent-%COMP%]{display:flex;padding:10px 0}.md-item[_ngcontent-%COMP%]:not(:last-child){border-bottom:1px solid #e2e5e4}.md-item[_ngcontent-%COMP%]:first-child{padding-top:0}.md-item[_ngcontent-%COMP%]:last-child{padding-bottom:0}.md-meta[_ngcontent-%COMP%]{flex:1 1 auto}.md-p-item[_ngcontent-%COMP%], .md-p-selected[_ngcontent-%COMP%]{font-weight:700}.md-privacy[_ngcontent-%COMP%]{font-size:.875rem;position:relative;max-width:15.625rem;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.md-p-btn[_ngcontent-%COMP%]{font-size:1rem;margin-bottom:.5rem;cursor:pointer}.md-p-menu[_ngcontent-%COMP%]{border:1px solid #e2e5e4;border-bottom:none;top:100%;left:0;width:100%;z-index:1;position:absolute;background:#fff;padding:5px 0;box-shadow:0 .125rem .3125rem 0 rgba(208,208,208,.5)}.md-p-item[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:.3125rem .625rem;cursor:pointer;font-size:.875rem}.md-p-item[_ngcontent-%COMP%]:hover{background:#f8f9fb}.md-p-member[_ngcontent-%COMP%]{color:#007a48}.md-p-friends[_ngcontent-%COMP%]{color:#943585}.md-p-public[_ngcontent-%COMP%]{color:#005cc9}.md-sensitive[_ngcontent-%COMP%]{color:#000;display:flex}.md-s-checkbox[_ngcontent-%COMP%]{width:1.125rem;height:1.125rem;flex:0 0 auto}.md-s-content[_ngcontent-%COMP%]{margin-left:.3125rem}.md-s-content[_ngcontent-%COMP%]   small[_ngcontent-%COMP%]{display:block}.media-control[_ngcontent-%COMP%], .media-listing[_ngcontent-%COMP%]{display:flex;align-items:center}.media-listing[_ngcontent-%COMP%]{display:flex;align-items:center;margin-left:2.5rem}@media (max-width:575px){.media-listing[_ngcontent-%COMP%]{margin-left:1rem}}.media-listing[_ngcontent-%COMP%]   .media-thumbnail[_ngcontent-%COMP%]{width:3.75rem;height:3.75rem}.capture-photo-wrap[_ngcontent-%COMP%]{position:fixed;background:rgba(0,0,0,.9);padding-top:3.125rem;z-index:9999;left:0;top:0;bottom:0;right:0}.cpw-close[_ngcontent-%COMP%]{font-size:1.5625rem;color:#fff;position:absolute;right:.625rem;top:.625rem;line-height:.6;padding:.4375rem;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:.8}.cpw-close[_ngcontent-%COMP%]:hover{opacity:1}.cpw-webcam[_ngcontent-%COMP%]{display:flex;justify-content:center}.cpw-actions[_ngcontent-%COMP%]{padding:0 .9375rem;display:flex;align-items:center;justify-content:center;margin-top:1.25rem}.cpw-btn[_ngcontent-%COMP%]{border:none;background:0 0;color:#fff;font-size:1.25rem;padding:.3125rem;margin:0 .9375rem;cursor:pointer}.cpw-btn[_ngcontent-%COMP%]:hover{text-decoration:underline}.cpw-take-photo[_ngcontent-%COMP%]{text-align:center;text-transform:uppercase;color:#fff}.cpw-photo-btn[_ngcontent-%COMP%]{width:5rem;height:5rem;border-radius:100%;background:#fff;cursor:pointer;padding:.625rem;display:block;border:none;margin-top:.625rem}.cpw-photo-btn[_ngcontent-%COMP%]:before{content:\"\";width:3.75rem;height:3.75rem;border-radius:100%;border:1px solid #000;background:#fff;display:block;box-sizing:border-box}[_nghost-%COMP%]     .cpw-webcam video{max-width:31.25rem;width:100%;height:auto}"] });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(AddMediaComponent, [{
        type: Component,
        args: [{
                selector: 'ins-add-media',
                templateUrl: './add-media.component.html',
                styleUrls: ['./add-media.component.scss']
            }]
    }], function () { return []; }, { browseMedia: [{
            type: ViewChild,
            args: ['browseMedia']
        }], mobileNativeCamera: [{
            type: ViewChild,
            args: ['mobileNativeCamera']
        }], videoCapture: [{
            type: ViewChild,
            args: ['videoCapture']
        }], videoPlay: [{
            type: ViewChild,
            args: ['videoPlay']
        }], media: [{
            type: Input
        }], attachedMedia: [{
            type: Input
        }], customMediaOption: [{
            type: Input
        }], nextButtonText: [{
            type: Input
        }], attachToPostButtonText: [{
            type: Input
        }], mediaType: [{
            type: Input
        }], isMobile: [{
            type: Input
        }], setAttachedMedia: [{
            type: Output
        }], updateMediaMetaData: [{
            type: Output
        }], uploadFile: [{
            type: Output
        }], closeAddMedia: [{
            type: Output
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 