import { createBaseState, defaultBaseState } from "document-model";
import { utils } from "./utils.js";
export function defaultGlobalState() {
    return {
        label: null,
        genericSubdomain: null,
        genericBaseDomain: null,
        customDomain: {
            enabled: false,
            domain: null,
            dnsRecords: [],
        },
        defaultPackageRegistry: null,
        services: [],
        packages: [],
        status: "DRAFT",
    };
}
export function defaultLocalState() {
    return {};
}
export function defaultPHState() {
    return {
        ...defaultBaseState(),
        global: defaultGlobalState(),
        local: defaultLocalState(),
    };
}
export function createGlobalState(state) {
    return {
        ...defaultGlobalState(),
        ...(state || {}),
    };
}
export function createLocalState(state) {
    return {
        ...defaultLocalState(),
        ...(state || {}),
    };
}
export function createState(baseState, globalState, localState) {
    return {
        ...createBaseState(baseState?.auth, baseState?.document),
        global: createGlobalState(globalState),
        local: createLocalState(localState),
    };
}
/**
 * Creates a VetraCloudEnvironmentDocument with custom global and local state
 * This properly handles the PHBaseState requirements while allowing
 * document-specific state to be set.
 */
export function createVetraCloudEnvironmentDocument(state) {
    const document = utils.createDocument(state
        ? createState(createBaseState(state.auth, state.document), state.global, state.local)
        : undefined);
    return document;
}
