var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
export class TurnContextBuilder {
    constructor(getAdminforth, userContextProvider) {
        this.getAdminforth = getAdminforth;
        this.userContextProvider = userContextProvider;
    }
    build(input) {
        return __awaiter(this, void 0, void 0, function* () {
            var _a, _b, _c, _d;
            const adminforth = this.getAdminforth();
            return {
                adminUser: input.base.adminUser,
                sessionId: input.base.sessionId,
                turnId: input.turnId,
                abortSignal: input.base.abortSignal,
                currentPage: input.base.currentPage,
                chatSurface: input.base.chatSurface,
                userTimeZone: (_c = (_a = input.base.userTimeZone) !== null && _a !== void 0 ? _a : yield ((_b = this.userContextProvider) === null || _b === void 0 ? void 0 : _b.getUserTimeZone(input.base.adminUser))) !== null && _c !== void 0 ? _c : "UTC",
                adminPublicOrigin: (_d = input.base.adminPublicOrigin) !== null && _d !== void 0 ? _d : adminforth.config.baseUrlSlashed,
            };
        });
    }
}
