import { AppObjectUC, getSingletonComponent, } from "@vived/core";
import { AppDispatcher } from "../Entities/AppDispatcher";
export class ShowConfirmUC extends AppObjectUC {
    constructor() {
        super(...arguments);
        this.requestType = "SHOW_CONFIRM";
    }
}
ShowConfirmUC.type = "ShowConfirmUC";
ShowConfirmUC.get = (appObjects) => getSingletonComponent(ShowConfirmUC.type, appObjects);
export function makeShowConfirmUC(appObject) {
    return new ShowAlertUCImp(appObject);
}
class ShowAlertUCImp extends ShowConfirmUC {
    constructor(appObject) {
        super(appObject, ShowConfirmUC.type);
        this.requestVersion = 1;
        this.showConfirm = (data) => {
            if (!this.appDispatcher)
                return;
            const payload = {
                title: data.title,
                message: data.message,
                confirmCallback: data.confirmCallback,
                cancelButtonLabel: data.cancelButtonLabel,
                cancelCallback: data.cancelCallback,
                confirmButtonLabel: data.confirmButtonLabel,
            };
            this.appDispatcher.formRequestAndDispatch(this.requestType, this.requestVersion, payload);
        };
        this.appDispatcher = appObject.getComponent(AppDispatcher.type);
        if (!this.appDispatcher) {
            this.warn(`${ShowConfirmUC.type} has been added to an App Object that does not have a AppDispatcher. Add a dispatcher first`);
            this.dispose();
        }
    }
}
//# sourceMappingURL=ShowConfirmUC.js.map