import { z } from 'zod';
import { cli } from '../../../../cli/cli.js';
import { globalOptionsZod } from '../../../../Command.js';
import request from '../../../../request.js';
import GraphCommand from '../../../base/GraphCommand.js';
import commands from '../../commands.js';
export const options = z.strictObject({
    ...globalOptionsZod.shape,
    force: z.boolean().optional().alias('f')
});
class EntraSiteClassificationDisableCommand extends GraphCommand {
    get name() {
        return commands.SITECLASSIFICATION_DISABLE;
    }
    get description() {
        return 'Disables site classification';
    }
    get schema() {
        return options;
    }
    async commandAction(logger, args) {
        const disableSiteClassification = async () => {
            try {
                let requestOptions = {
                    url: `${this.resource}/v1.0/groupSettings`,
                    headers: {
                        accept: 'application/json;odata.metadata=none'
                    },
                    responseType: 'json'
                };
                const res = await request.get(requestOptions);
                if (res.value.length === 0) {
                    throw 'Site classification is not enabled.';
                }
                const unifiedGroupSetting = res.value.filter((directorySetting) => {
                    return directorySetting.displayName === 'Group.Unified';
                });
                if (!unifiedGroupSetting || unifiedGroupSetting.length === 0) {
                    throw 'Missing DirectorySettingTemplate for "Group.Unified"';
                }
                if (!unifiedGroupSetting[0] ||
                    !unifiedGroupSetting[0].id || unifiedGroupSetting[0].id.length === 0) {
                    throw 'Missing UnifiedGroupSettting id';
                }
                requestOptions = {
                    url: `${this.resource}/v1.0/groupSettings/` + unifiedGroupSetting[0].id,
                    headers: {
                        accept: 'application/json;odata.metadata=none',
                        'content-type': 'application/json'
                    },
                    responseType: 'json'
                };
                await request.delete(requestOptions);
            }
            catch (err) {
                this.handleRejectedODataJsonPromise(err);
            }
        };
        if (args.options.force) {
            await disableSiteClassification();
        }
        else {
            const result = await cli.promptForConfirmation({ message: `Are you sure you want to disable site classification?` });
            if (result) {
                await disableSiteClassification();
            }
        }
    }
}
export default new EntraSiteClassificationDisableCommand();
//# sourceMappingURL=siteclassification-disable.js.map