// (C) 2021-2026 GoodData Corporation
import { isObjRef, } from "@gooddata/sdk-model";
/**
 * Creates the ChangeInsightWidgetHeader command. Dispatching this command will result in change of the Insight widget's
 * header which (now) includes title.
 *
 * @param ref - reference of the insight widget to modify
 * @param header - new header to use
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function changeInsightWidgetHeader(ref, header, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_HEADER",
        correlationId,
        payload: {
            ref,
            header,
        },
    };
}
/**
 * Creates the ChangeInsightWidgetFilterSettings command for {@link IFilterOpReplaceAll} operation.
 *
 * Dispatching this command will result in replacement of Insight widget's filter settings; this includes change of
 * data set used for common date filter, disabling common date filtering, ignoring attribute/date filters that are defined on the dashboard for the widget.
 *
 * @param ref - reference of the insight widget to modify
 * @param settings - new filter settings to apply
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function replaceInsightWidgetFilterSettings(ref, settings, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_FILTER_SETTINGS",
        correlationId,
        payload: {
            ref,
            operation: {
                type: "replace",
                ...settings,
            },
        },
    };
}
/**
 * Creates the ChangeInsightWidgetFilterSettings command for {@link IFilterOpEnableDateFilter} operation.
 *
 * Dispatching this command will result in change of Insight widget's date filter setting. The date filtering will
 * be enabled and the provided date data set will be used for date-filtering widget's insight.
 *
 * @param ref - reference of the insight widget to modify
 * @param dateDataset - date data set to use for filtering the insight, if "default" is provided, the default date dataset will be resolved and used
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function enableInsightWidgetDateFilter(ref, dateDataset, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_FILTER_SETTINGS",
        correlationId,
        payload: {
            ref,
            operation: {
                type: "enableDateFilter",
                dateDataset,
            },
        },
    };
}
/**
 * Creates the ChangeInsightWidgetFilterSettings command for {@link IFilterOpDisableDateFilter} operation.
 *
 * Dispatching this command will result in change of Insight widget's date filter setting. The date filtering will
 * be disabled.
 *
 * @param ref - reference of the insight widget to modify
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function disableInsightWidgetDateFilter(ref, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_FILTER_SETTINGS",
        correlationId,
        payload: {
            ref,
            operation: {
                type: "disableDateFilter",
            },
        },
    };
}
/**
 * Creates the ChangeInsightWidgetFilterSettings command for {@link IFilterOpReplaceAttributeIgnores} operation.
 *
 * Dispatching this command will result in replacement of Insight widget's attribute filter ignore-list. Those attribute filters
 * that use the provided displayForms for filtering will be ignored by the widget.
 *
 * @param ref - reference of the insight widget to modify
 * @param displayForms - refs of display forms used by attribute filters that should be ignored
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function replaceInsightWidgetIgnoredFilters(ref, displayForms, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_FILTER_SETTINGS",
        correlationId,
        payload: {
            ref,
            operation: {
                type: "replaceAttributeIgnores",
                displayFormRefs: displayForms ?? [],
            },
        },
    };
}
/**
 * Creates the ChangeInsightWidgetFilterSettings command for {@link IFilterOpIgnoreAttributeFilter} operation.
 *
 * Dispatching this command will result in addition of one or more filters into Insight widget's attribute filter ignore-list.
 * Those attribute filters that use the provided displayForms for filtering will be ignored by the widget on top of any
 * other filters that are already ignored.
 *
 * Ignored attribute filters are not passed down to the insight and will not be used to filter that insight.
 *
 * The operation is idempotent - trying to ignore an attribute filter multiple times will have no effect.
 *
 * @param ref - reference of the insight widget to modify
 * @param oneOrMoreDisplayForms - one or more refs of display forms used by attribute filters that should be added to the ignore-list
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @public
 */
export function ignoreFilterOnInsightWidget(ref, oneOrMoreDisplayForms, correlationId) {
    const displayFormRefs = isObjRef(oneOrMoreDisplayForms) ? [oneOrMoreDisplayForms] : oneOrMoreDisplayForms;
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_FILTER_SETTINGS",
        correlationId,
        payload: {
            ref,
            operation: {
                type: "ignoreAttributeFilter",
                displayFormRefs,
            },
        },
    };
}
/**
 * Creates the ChangeInsightWidgetFilterSettings command for {@link IFilterOpUnignoreAttributeFilter} operation.
 *
 * Dispatching this command will result in removal of one or more filters from Insight widget's attribute filter ignore-list.
 * Ignored attribute filters are not passed down to the insight and will not be used to filter that insight.
 *
 * The operation is idempotent - trying to unignore an attribute filter multiple times will have no effect.
 *
 * @param ref - reference of the insight widget to modify
 * @param oneOrMoreDisplayForms - one or more refs of display forms used by attribute filters that should be removed from the ignore-list
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function unignoreFilterOnInsightWidget(ref, oneOrMoreDisplayForms, correlationId) {
    const displayFormRefs = isObjRef(oneOrMoreDisplayForms) ? [oneOrMoreDisplayForms] : oneOrMoreDisplayForms;
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_FILTER_SETTINGS",
        correlationId,
        payload: {
            ref,
            operation: {
                type: "unignoreAttributeFilter",
                displayFormRefs,
            },
        },
    };
}
/**
 * Creates the ChangeInsightWidgetFilterSettings command for {@link IFilterOpIgnoreMeasureValueFilter} operation.
 *
 * @alpha
 */
export function ignoreMeasureValueFilterOnInsightWidget(ref, oneOrMoreMeasures, correlationId) {
    const measureRefs = isObjRef(oneOrMoreMeasures) ? [oneOrMoreMeasures] : oneOrMoreMeasures;
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_FILTER_SETTINGS",
        correlationId,
        payload: {
            ref,
            operation: {
                type: "ignoreMeasureValueFilter",
                measureRefs,
            },
        },
    };
}
/**
 * Creates the ChangeInsightWidgetFilterSettings command for {@link IFilterOpUnignoreMeasureValueFilter} operation.
 *
 * @alpha
 */
export function unignoreMeasureValueFilterOnInsightWidget(ref, oneOrMoreMeasures, correlationId) {
    const measureRefs = isObjRef(oneOrMoreMeasures) ? [oneOrMoreMeasures] : oneOrMoreMeasures;
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_FILTER_SETTINGS",
        correlationId,
        payload: {
            ref,
            operation: {
                type: "unignoreMeasureValueFilter",
                measureRefs,
            },
        },
    };
}
/**
 * Creates the ChangeInsightWidgetVisProperties command. Dispatching this command will result is modification
 * of the visualization properties that are effective for the particular insight widget.
 *
 * Through visualization properties, you can modify how particular visualization looks and behaves (enable/disable
 * tooltips, legend, change axes, enable zooming).
 *
 * If you want to clear any widget-level properties, set properties to `undefined`.
 *
 * @param ref - reference of the insight widget to modify
 * @param properties - new properties to set, undefined to clear any widget level visualization properties
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function changeInsightWidgetVisProperties(ref, properties, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_PROPERTIES",
        correlationId,
        payload: {
            ref,
            properties,
        },
    };
}
/**
 *
 * Creates the ChangeInsightWidgetVisConfiguration command. Dispatching this command will result is modification
 * of the visualization configuration that are effective for the particular insight widget.
 *
 * Through visualization configuration, you can modify how particular visualization behaves
 *
 * If you want to clear any widget-level configuration, set config to `undefined`.
 *
 * @param ref - reference of the insight widget to modify
 * @param config - new configuration to set, undefined to clear any widget level visualization config
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @public
 */
export function changeInsightWidgetVisConfiguration(ref, config, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_CONFIGURATION",
        correlationId,
        payload: {
            ref,
            config,
        },
    };
}
/**
 * Creates the ChangeInsightWidgetInsight command. Dispatching this command will result in change of what
 * insight is rendered inside particular insight widget - while keeping all the other setup the same (filtering,
 * drilling).
 *
 * @param ref - reference to insight widget whose insight should be changed
 * @param insightRef - reference to the new insight to use in the widget
 * @param visualizationProperties - specify visualization properties to use. Undefined value means keeping the existing properties on record in the widget
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function changeInsightWidgetInsight(ref, insightRef, visualizationProperties, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_INSIGHT",
        correlationId,
        payload: {
            ref,
            insightRef,
            visualizationProperties,
        },
    };
}
/**
 * Creates the ModifyDrillsForInsightWidget command. Dispatching the created command will add or modify a new drill for
 * the insight widget.
 *
 * Drill can be setup for particular measure - meaning elements in the insight will be clickable. Exactly one drill
 * can be specified for a measure.
 *
 * What happens on click depends on the context in which the dashboard lives:
 *
 * -  When in KPI Dashboard (embedded or not) the defined action is actually triggered and done - it may open a new tab,
 *    open overlay with insight, navigate to a new dashboard and carry over the filters.
 * -  When the dashboard is embedded using Dashboard component, an event will be emitted describing the defined
 *    drill action.
 *
 * @param ref - reference to insight widget whose drills should be modified
 * @param drills - drills to add or modify.
 * @param blacklistHierarchiesToUpdate -
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function modifyDrillsForInsightWidget(ref, drills, blacklistHierarchiesToUpdate, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.MODIFY_DRILLS",
        correlationId,
        payload: {
            ref,
            drills,
            blacklistHierarchiesToUpdate,
        },
    };
}
/**
 * Creates the AttributeHierarchyModified command , dispatching this command will result on reset of catalog.
 *
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function attributeHierarchyModified(correlationId) {
    return {
        type: "GDC.DASH/CMD.ATTRIBUTE_HIERARCHY_MODIFIED",
        correlationId,
    };
}
/**
 * Type guard resolved all drill selector
 *
 * @beta
 */
export function isAllDrillSelector(obj) {
    return obj === "*";
}
/**
 * Creates the RemoveDrillsForInsightWidget command. Dispatching the created command will remove insight widget's
 * drill definition for the provided measure.
 *
 * @param ref - reference of insight widget whose drill should be removed
 * @param localIdentifiers - drill localIdentifiers whose drill definitions should be removed
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function removeDrillsForInsightWidget(ref, localIdentifiers, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.REMOVE_DRILLS",
        correlationId,
        payload: {
            ref,
            localIdentifiers,
        },
    };
}
/**
 * Creates the RemoveDrillDownForInsightWidget command. Dispatching the created command will remove insight widget's
 * drill definition for the provided measure.
 *
 * @param ref - reference of insight widget whose drill should be removed
 * @param blacklistHierarchies - drill localIdentifiers and its hierarchy should be removed
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @alpha
 */
export function removeDrillDownForInsightWidget(ref, blacklistHierarchies, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.REMOVE_DRILL_DOWN",
        correlationId,
        payload: {
            ref,
            blacklistHierarchies,
        },
    };
}
/**
 * Creates the RemoveDrillToUrlForInsightWidget command. Dispatching the created command will remove insight widget's
 * drill definition for the provided attribute.
 *
 * @param ref - reference of insight widget whose drill should be removed
 * @param blacklistAttributes - displayForm refs of drill to url attributes which should be removed.
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @alpha
 */
export function removeDrillToUrlForInsightWidget(ref, blacklistAttributes, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.REMOVE_DRILL_TO_URL",
        correlationId,
        payload: { ref, blacklistAttributes },
    };
}
/**
 * Creates the AddDrillDownForInsightWidget command. Dispatching the created command will create insight widget's
 * drill definition for the provided measure.
 *
 * @param ref - reference of insight widget whose drill should be created
 * @param attributeIdentifier - drill localIdentifier that should be added.
 * @param drillDownIdentifier - drill down hierarchy localIdentifier that should be added.
 * @param drillDownAttributeHierarchyRef - drill down hierarchy reference that should be added.
 * @param intersectionIgnoredAttributes - specify local identifiers of attributes that should be ignored in drill intersection during drill down.
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @alpha
 */
export function addDrillDownForInsightWidget(ref, attributeIdentifier, drillDownIdentifier, drillDownAttributeHierarchyRef, intersectionIgnoredAttributes = [], correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.ADD_DRILL_DOWN",
        correlationId,
        payload: {
            ref,
            attributeIdentifier,
            drillDownIdentifier,
            drillDownAttributeHierarchyRef,
            intersectionIgnoredAttributes,
        },
    };
}
/**
 * Creates the ModifyDrillDownForInsightWidget command. Dispatching the created command will update insight widget's
 * drill definition for the provided measure.
 *
 * @param ref - reference of insight widget whose drill should be modified
 * @param attributeIdentifier - drill localIdentifier and its hierarchy should be modified.
 * @param attributeHierarchyRef - drill attribute hierarchy ref to be modified.
 * @param blacklistHierarchies - drill localIdentifiers and its hierarchy should be modified
 * @param intersectionIgnoredAttributes - specify local identifiers of attributes that should be ignored in drill intersection during drill down.
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @alpha
 */
export function modifyDrillDownForInsightWidget(ref, attributeIdentifier, attributeHierarchyRef, blacklistHierarchies, intersectionIgnoredAttributes, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.MODIFY_DRILL_DOWN",
        correlationId,
        payload: {
            ref,
            attributeIdentifier,
            attributeHierarchyRef,
            blacklistHierarchies,
            intersectionIgnoredAttributes,
        },
    };
}
/**
 * Creates the RefreshInsightWidget command. Dispatching this command will result in re-calculation of the widget's
 * insight and re-render.
 *
 * @param ref - reference to the Insight widget to refresh
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function refreshInsightWidget(ref, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.REFRESH",
        correlationId,
        payload: {
            ref,
        },
    };
}
/**
 * Creates the ExportInsightWidget command. Dispatching this command will result in exporting of the widget to a CSV of XLSX file.
 *
 * @param ref - reference to the Insight widget to refresh
 * @param config - configuration of the export operation
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function exportInsightWidget(ref, config, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.EXPORT",
        correlationId,
        payload: {
            config,
            ref,
        },
    };
}
/**
 * Creates the ExportInlineInsightWidget command. Dispatching this command will result in exporting of the inline insight to a CSV of XLSX file.
 *
 * @param ref - reference to the Insight widget to export
 * @param config - configuration of the export operation
 * @param insight - transient insight definition to export
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function exportInlineInsightWidget(ref, config, insight, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.EXPORT",
        correlationId,
        payload: {
            config,
            ref,
            insight,
        },
    };
}
export function exportRawInsightWidget(ref, widget, insight, filename, optionsOrCorrelationId, correlationId) {
    const options = typeof optionsOrCorrelationId === "string" ? undefined : optionsOrCorrelationId;
    const effectiveCorrelationId = typeof optionsOrCorrelationId === "string" ? optionsOrCorrelationId : correlationId;
    return exportRawInsightWidgetWithOptions(ref, widget, insight, filename, options, effectiveCorrelationId);
}
function exportRawInsightWidgetWithOptions(ref, widget, insight, filename, options, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.EXPORT_RAW",
        correlationId,
        payload: {
            ref,
            widget,
            insight,
            filename,
            options,
        },
    };
}
/**
 * Creates the ExportSlidesInsightWidget command. Dispatching this command will result in exporting of the widget to a slides type (pdf, pptx).
 *
 * @param ref - reference to the Insight to export
 * @param filename - filename of the exported file
 * @param exportType - type of export to perform
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 * @param templateId - identifier of the export template to use
 *
 * @alpha
 */
export function exportSlidesInsightWidget(ref, filename, exportType, correlationId, templateId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.EXPORT_SLIDES",
        correlationId,
        payload: {
            ref,
            filename,
            exportType,
            templateId,
        },
    };
}
/**
 * Creates the ExportImageInsightWidget command. Dispatching this command will result in exporting of the widget to an image.
 *
 * @param ref - reference to the Insight to export
 * @param filename - filename of the exported file
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @alpha
 */
export function exportImageInsightWidget(ref, filename, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.EXPORT_IMAGE",
        correlationId,
        payload: {
            ref,
            filename,
        },
    };
}
/**
 * Creates the ChangeInsightWidgetDescription command. Dispatching this command will result in change of the Insight widget's
 * description.
 *
 * @param ref - reference of the insight widget to modify
 * @param description - new description to use
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function changeInsightWidgetDescription(ref, description, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_DESCRIPTION",
        correlationId,
        payload: {
            ref,
            description,
        },
    };
}
//
//
//
/**
 * Creates the ChangeInsightWidgetFilterSettings command for {@link IFilterOpIgnoreDateFilter} operation.
 *
 * Dispatching this command will result in addition of one or more filters into Insight widget's date filter ignore-list.
 * Those date filters that use the provided date data sets for filtering will be ignored by the widget on top of any
 * other filters that are already ignored.
 *
 * Ignored date filters are not passed down to the insight and will not be used to filter that insight.
 *
 * The operation is idempotent - trying to ignore a date filter multiple times will have no effect.
 *
 * @param ref - reference of the insight widget to modify
 * @param oneOrMoreDataSets - one or more refs of date dataSets used by date filters that should be added to the ignore-list
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @public
 */
export function ignoreDateFilterOnInsightWidget(ref, oneOrMoreDataSets, correlationId) {
    const dateDataSetRefs = isObjRef(oneOrMoreDataSets) ? [oneOrMoreDataSets] : oneOrMoreDataSets;
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_FILTER_SETTINGS",
        correlationId,
        payload: {
            ref,
            operation: {
                type: "ignoreDateFilter",
                dateDataSetRefs,
            },
        },
    };
}
/**
 * Creates the ChangeInsightWidgetFilterSettings command for {@link IFilterOpUnignoreDateFilter} operation.
 *
 * Dispatching this command will result in removal of one or more filters from Insight widget's date filter ignore-list.
 * Ignored date filters are not passed down to the insight and will not be used to filter that insight.
 *
 * The operation is idempotent - trying to unignore a date filter multiple times will have no effect.
 *
 * @param ref - reference of the insight widget to modify
 * @param oneOrMoreDataSets - one or more refs of date data sets used by date filters that should be removed from the ignore-list
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @beta
 */
export function unignoreDateFilterOnInsightWidget(ref, oneOrMoreDataSets, correlationId) {
    const dateDataSetRefs = isObjRef(oneOrMoreDataSets) ? [oneOrMoreDataSets] : oneOrMoreDataSets;
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_FILTER_SETTINGS",
        correlationId,
        payload: {
            ref,
            operation: {
                type: "unignoreDateFilter",
                dateDataSetRefs,
            },
        },
    };
}
/**
 * Creates the ChangeInsightWidgetCrossFiltering command. Dispatching this command will result in change of the Insight widget's
 * cross-filtering setting.
 *
 * @param ref - reference of the insight widget to modify
 * @param ignoreCrossFiltering -
 * @param correlationId - specify correlation id to use for this command. this will be included in all
 *  events that will be emitted during the command processing
 *
 * @alpha
 */
export function changeInsightWidgetIgnoreCrossFiltering(ref, ignoreCrossFiltering, correlationId) {
    return {
        type: "GDC.DASH/CMD.INSIGHT_WIDGET.CHANGE_IGNORE_CROSS_FILTERING",
        correlationId,
        payload: {
            ref,
            ignoreCrossFiltering,
        },
    };
}
