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