import { getSingletonComponent } from "@vived/core";
import { AppObjectUC } from "@vived/core";
import { AppDispatcher } from "../Entities/AppDispatcher";
export class StateIsCompleteUC extends AppObjectUC {
    constructor() {
        super(...arguments);
        this.requestType = "ON_STATE_COMPLETED";
    }
}
StateIsCompleteUC.type = "StateIsCompleteUC";
StateIsCompleteUC.get = (appObjects) => getSingletonComponent(StateIsCompleteUC.type, appObjects);
export function makeStateIsCompleteUC(appObject) {
    return new StateIsCompleteUCImp(appObject);
}
export function stateIsComplete(appObjects) {
    const uc = StateIsCompleteUC.get(appObjects);
    if (uc) {
        uc.doDispatch();
    }
    else {
        appObjects.submitWarning("stateIsComplete", "Can't find StateIsCompleteUC");
    }
}
class StateIsCompleteUCImp extends StateIsCompleteUC {
    constructor(appObject) {
        super(appObject, StateIsCompleteUC.type);
        this.requestVersion = 1;
        this.doDispatch = () => {
            if (!this.appDispatcher)
                return;
            this.appDispatcher.formRequestAndDispatch(this.requestType, this.requestVersion);
        };
        this.appDispatcher = appObject.getComponent(AppDispatcher.type);
        if (!this.appDispatcher) {
            this.warn("GoToNextStateUC has been added to an App Object that does not have a AppDispatcher. Add a dispatcher first");
            this.dispose();
        }
    }
}
//# sourceMappingURL=StateIsCompleteUC.js.map