import { Component, Input, Output, EventEmitter } from '@angular/core';
import { BaseAngularComponent } from '@memberjunction/ng-base-types';
import { DashboardShareAdapter } from './dashboard-share-adapter';
import * as i0 from "@angular/core";
import * as i1 from "@memberjunction/ng-resource-permissions";
/**
 * Thin wrapper that maps a `MJDashboardEntity` + the Dashboard-specific
 * permission model onto the generic `mj-resource-share-dialog`. Existing call
 * sites (`<mj-dashboard-share-dialog [Dashboard]=... [Visible]=... (Result)=... />`)
 * continue to work unchanged — this component just constructs the context +
 * adapter and delegates.
 */
export class DashboardShareDialogComponent extends BaseAngularComponent {
    Visible = false;
    set Dashboard(value) {
        this._dashboard = value;
        this.context = value
            ? {
                ResourceID: value.ID,
                ResourceName: value.Name ?? 'Untitled',
                OwnerUserID: value.UserID,
                OwnerDisplayName: value.User ?? 'You'
            }
            : null;
    }
    get Dashboard() {
        return this._dashboard;
    }
    Result = new EventEmitter();
    context = null;
    adapter = new DashboardShareAdapter();
    _dashboard = null;
    constructor() {
        super();
        this.adapter.Provider = this.ProviderToUse;
    }
    onResult(result) {
        this.Result.emit({
            Action: result.Action,
            Dashboard: result.Action === 'save' && this._dashboard ? this._dashboard : undefined
        });
    }
    static ɵfac = function DashboardShareDialogComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DashboardShareDialogComponent)(); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DashboardShareDialogComponent, selectors: [["mj-dashboard-share-dialog"]], inputs: { Visible: "Visible", Dashboard: "Dashboard" }, outputs: { Result: "Result" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 3, consts: [[3, "Result", "Visible", "Context", "Adapter"]], template: function DashboardShareDialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "mj-resource-share-dialog", 0);
            i0.ɵɵlistener("Result", function DashboardShareDialogComponent_Template_mj_resource_share_dialog_Result_0_listener($event) { return ctx.onResult($event); });
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵproperty("Visible", ctx.Visible)("Context", ctx.context)("Adapter", ctx.adapter);
        } }, dependencies: [i1.GenericShareDialogComponent], encapsulation: 2 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DashboardShareDialogComponent, [{
        type: Component,
        args: [{
                standalone: false,
                selector: 'mj-dashboard-share-dialog',
                template: `
        <mj-resource-share-dialog
            [Visible]="Visible"
            [Context]="context"
            [Adapter]="adapter"
            (Result)="onResult($event)">
        </mj-resource-share-dialog>
    `
            }]
    }], () => [], { Visible: [{
            type: Input
        }], Dashboard: [{
            type: Input
        }], Result: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(DashboardShareDialogComponent, { className: "DashboardShareDialogComponent", filePath: "src/DashboardBrowser/dashboard-share-dialog.component.ts", lineNumber: 36 }); })();
//# sourceMappingURL=dashboard-share-dialog.component.js.map