@bluecopa/core 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/config.ts","../src/api/client.ts","../src/api/user/getLoggedInUserDetails.ts","../src/api/workflow/triggerHttpWorkflow.ts","../src/api/workflow/triggerWorkflow.ts","../src/api/file/getFileUrlByFileId.ts","../src/api/definition/runPublishedDefinition.ts","../src/api/definition/runSampleDefinition.ts","../src/api/definition/runDefinition.ts","../src/api/worksheet/getWorksheets.ts","../src/utils/date.ts","../../models/src/lib/ui-models/workbookModel.ts","../src/utils/metric/filterUtils.ts","../../models/src/lib/ui-models/definitionModel.ts","../src/utils/metric/analysisMethods.ts","../src/utils/metric/mergeFilterService.ts","../src/utils/metric/getMetricDefinition.ts","../src/utils/inputTable/inputTableDefinition.ts","../src/utils/file/downloadFile.ts","../src/utils/metric/hydrateWorksheet.ts","../src/api/metric/getData.ts","../../models/src/lib/builders/definitionBuilder.ts","../src/api/dataset/getData.ts","../src/api/dataset/getSampleData.ts","../src/api/workbook/getPublishedWorkbookById.ts","../src/types/workbook.ts","../src/api/inputTable/getTableById.ts","../src/api/inputTable/getData.ts","../src/tailwind/bluecopa.config.ts"],"sourcesContent":["export interface Config {\n\tapiBaseUrl: string;\n\taccessToken: string;\n\tworkspaceId: string;\n}\n\nclass ConfigSingleton {\n\tprivate static instance: ConfigSingleton;\n\tprivate config: Config;\n\n\tprivate constructor() {\n\t\tthis.config = {\n\t\t\tapiBaseUrl: '',\n\t\t\taccessToken: '',\n\t\t\tworkspaceId: '',\n\t\t};\n\t}\n\n\tpublic static getInstance(): ConfigSingleton {\n\t\tif (!ConfigSingleton.instance) {\n\t\t\tConfigSingleton.instance = new ConfigSingleton();\n\t\t}\n\t\treturn ConfigSingleton.instance;\n\t}\n\n\tpublic setConfig(newConfig: Partial<Config>): void {\n\t\tthis.config = { ...this.config, ...newConfig };\n\t}\n\n\tpublic getConfig(): Config {\n\t\treturn { ...this.config }; // Return a copy to prevent external mutations\n\t}\n\n\tpublic resetConfig(): void {\n\t\tthis.config = {\n\t\t\tapiBaseUrl: '',\n\t\t\taccessToken: '',\n\t\t\tworkspaceId: '',\n\t\t};\n\t}\n}\n\n// Export convenience functions that use the singleton instance\nconst configInstance = ConfigSingleton.getInstance();\n\nexport function setConfig(newConfig: Partial<Config>): void {\n\tconfigInstance.setConfig(newConfig);\n}\n\nexport function getConfig(): Config {\n\treturn configInstance.getConfig();\n}\n\nexport function resetConfig(): void {\n\tconfigInstance.resetConfig();\n}\n\n// Export the singleton class for advanced usage if needed\nexport { ConfigSingleton };\n\n\n","import axios, {\n AxiosInstance,\n AxiosResponse,\n InternalAxiosRequestConfig,\n} from \"axios\";\nimport { getConfig, setConfig } from \"../config\";\n\n// Create axios instance with default configuration\nconst createApiClient = (): AxiosInstance => {\n const client = axios.create({\n timeout: 10000,\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n // Request interceptor to add auth token and dynamic baseURL\n client.interceptors.request.use(\n (config: InternalAxiosRequestConfig) => {\n const copaConfig = getConfig();\n \n // Always update baseURL from current config\n if (copaConfig.apiBaseUrl) {\n config.baseURL = copaConfig.apiBaseUrl;\n }\n \n // Add auth headers if available\n if (copaConfig.accessToken && config.headers) {\n config.headers[\"X-COPA-TOKEN\"] = `Bearer ${copaConfig.accessToken}`;\n }\n \n if (copaConfig.workspaceId && config.headers) {\n config.headers[\"X-COPA-WORKSPACE-ID\"] = copaConfig.workspaceId;\n }\n \n console.log('API Request Config:', {\n baseURL: config.baseURL,\n hasToken: !!copaConfig.accessToken,\n hasWorkspaceId: !!copaConfig.workspaceId\n });\n \n return config;\n },\n (error) => {\n return Promise.reject(error);\n }\n );\n\n // Response interceptor for error handling\n client.interceptors.response.use(\n (response: AxiosResponse) => {\n return response;\n },\n (error) => {\n // Handle common errors\n if (error.response?.status === 401) {\n setConfig({ accessToken: \"\", workspaceId: \"\" });\n // You might want to redirect to login page here\n }\n return Promise.reject(error);\n }\n );\n\n return client;\n};\n\n// Export the configured client instance\nexport const apiClient = createApiClient();\n","import { apiClient } from \"../client\";\n\nexport interface UserDetails {\n id: string;\n email: string;\n name: string;\n role: string;\n workspaceId: string;\n avatar?: string;\n preferences?: Record<string, any>;\n lastLoginAt?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ApiResponse<T> {\n success: boolean;\n data: T;\n message?: string;\n}\n\n/**\n * Fetches the logged-in user's details from the API\n * @returns Promise<{ user: UserDetails }> The user's details\n * @throws Error if the request fails or user is not authenticated\n */\nexport async function getLoggedInUserDetails(): Promise<{ user: UserDetails }> {\n try {\n const response = await apiClient.get(\"/user/current\");\n\n if (!response.data) {\n throw { message: \"Failed to fetch user details\", status: 500 };\n }\n return response.data as { user: UserDetails };\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching user details\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n}\n","import { apiClient } from \"../client\";\n\nexport interface TriggerHttpWorkflowRequest {\n data: Record<string, any>;\n triggerId: string;\n}\n\nexport interface TriggeredWorkflow {\n workflowId: string;\n triggerId: string;\n}\n\nexport interface TriggerHttpWorkflowResponse {\n triggeredWorkflows: TriggeredWorkflow[];\n}\n\n/**\n * Triggers an HTTP workflow with the provided data\n * @param params - The trigger parameters\n * @param params.triggerId - The ID of the HTTP trigger\n * @param params.data - The data payload to send to the workflow\n * @returns Promise<TriggerHttpWorkflowResponse> The triggered workflow details\n * @throws Error if the request fails\n */\nexport async function triggerHttpWorkflow({\n data,\n triggerId,\n}: TriggerHttpWorkflowRequest): Promise<TriggerHttpWorkflowResponse> {\n try {\n const response = await apiClient.post(`/http-trigger/${triggerId}`, data);\n if (!response.data) {\n throw { message: \"Failed to trigger HTTP workflow\", status: 500 };\n }\n\n return response.data;\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while triggering the HTTP workflow\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n}\n","import { apiClient } from \"../client\";\n\nexport interface TriggerWorkflowRequest {\n parentId: string;\n triggerBy: string;\n}\n\nexport interface TriggerWorkflowResponse {\n workbookId: string;\n triggerBy: string;\n instanceId: string;\n triggerId: string;\n workflowId: string;\n status: string;\n triggeredAt: string;\n message: string;\n}\n\n/**\n * Triggers workflow\n * @param params - The trigger parameters\n * @param params.parentId - The ID of the workflow to be triggered\n * @param params.triggerBy - The user who triggered the workflow\n * @returns Promise<TriggerWorkflowResponse> The triggered workflow details\n * @throws Error if the request fails\n */\nexport async function triggerWorkflow({\n parentId, triggerBy,\n}: TriggerWorkflowRequest): Promise<TriggerWorkflowResponse> {\n try {\n const response = await apiClient.post('/workflow/trigger', { parentId, triggerBy });\n if (!response.data) {\n throw { message: \"Failed to trigger workflow\", status: 500 };\n }\n\n return response.data;\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while triggering the workflow\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n}\n","import { apiClient } from \"../client\";\n\nexport interface GetFileUrlRequest {\n key: string;\n contentType: string;\n method: 'GET' | 'PUT' | 'POST';\n}\n\nexport interface GetFileUrlResponse {\n url: string;\n}\n\n/**\n * Gets a signed URL for a file by its key\n * @param params - The file request parameters\n * @param params.key - The file key/path in storage\n * @param params.contentType - The content type of the file\n * @param params.method - The HTTP method (GET, PUT, POST)\n * @returns Promise<GetFileUrlResponse> The signed URL for the file\n * @throws Error if the request fails\n */\nexport async function getFileUrlByFileId({\n key, contentType, method,\n}: GetFileUrlRequest): Promise<GetFileUrlResponse> {\n try {\n\tconst response = await apiClient.post('/file/url', { key, contentType, method });\n\tif (!response.data) {\n\t throw { message: \"Failed to get file URL\", status: 500 };\n\t}\n\n\treturn { url: response.data };\n } catch (error: any) {\n\tconst message =\n\t error.response?.data?.message ||\n\t error.message ||\n\t \"An unexpected error occurred while getting file URL\";\n\tconst status = error.response?.status || 500;\n\tthrow { message, status };\n }\n}\n","import { CancelTokenSource } from \"axios\";\nimport { apiClient } from \"../client\";\n\nexport const runPublishedDefinition = async (props: {\n describe: string;\n sheet: { id: string; lastModifiedDate: string };\n variable: string;\n inputs: object;\n source?: CancelTokenSource;\n}) => {\n const { sheet, variable, inputs, describe, source } = props;\n\n if (!sheet) {\n throw new Error(`Definition is null`);\n }\n if (!variable) {\n throw new Error(`Variable is null`);\n }\n\n return apiClient.post(\n \"/definition/run-published\",\n {\n sheet: sheet,\n variable: variable,\n inputs: inputs,\n describe,\n },\n { cancelToken: source?.token }\n );\n};\n","import { apiClient } from \"../client\";\n\nexport const runSampleDefinition = async (props: {\n datasetId: string;\n dataFilter: \"valid_data\" | \"invalid_data\" | \"all_data\";\n duplicateColGroups?: string[];\n datasetType?: string;\n}) => {\n const { datasetId, dataFilter, duplicateColGroups, datasetType } = props;\n\n if (!datasetId) {\n throw new Error(`Dataset ID is null`);\n }\n if (!dataFilter) {\n throw new Error(`Data filter is null`);\n }\n\n return apiClient.post(\n \"/definition/run-sample\",\n { datasetId, dataFilter, duplicateColGroups, datasetType }\n );\n};\n","import { CancelTokenSource } from \"axios\";\nimport { apiClient } from \"../client\";\nimport { Definition, Inputs, Variable } from \"$models/ui-models/definitionModel\";\n\nexport const runDefinition = async (props: {\n inputs: Inputs;\n definition: Definition;\n variable: string;\n source?: CancelTokenSource;\n limit?: number;\n}) => {\n const { definition, variable, inputs, limit, source } = props;\n\n if (!definition) {\n throw new Error(`Definition is null`);\n }\n if (!variable) {\n throw new Error(`Variable is null`);\n }\n if (!inputs) {\n throw new Error(`Inputs is null`);\n }\n\n return apiClient.post(\n \"/definition/run\",\n { inputs, definition, variable, limit },\n { cancelToken: source?.token }\n );\n};\n","import { Worksheet } from \"$models/gen/Api\";\nimport { apiClient } from \"../client\";\n\nexport const getWorksheets = async (worksheetIds: string[]) => {\n try {\n const response = await apiClient.post(\"/worksheet/get-worksheets\", {\n ids: worksheetIds,\n });\n\n if (!response.data) {\n throw { message: \"Failed to fetch worksheets details\", status: 500 };\n }\n return response.data as Worksheet[];\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching worksheets details\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","export function formatDate(date: Date): string {\n return date.toISOString().split('T')[0];\n}\n","import type { CompactNotation, Currency } from '$models/common/localeUtils';\nimport type { HierarchyProperties, Workbook, Worksheet } from '$models/gen/Api';\nimport type { SelectOptionType } from '$models/types/selectType';\nimport type { DateRange } from '$models/ui-models/dateRangeModel';\nimport type {\n\tDefinition,\n\tFormatRule,\n\tGroupByHierarchyType,\n\tInputs,\n\tTimeBin\n} from '$models/ui-models/definitionModel';\nimport type { FilterRule } from '$models/ui-models/filterModel';\nimport { F } from 'vite/dist/node/types.d-aGj9QkWt';\nimport { YAxisCountEnum } from './chartModels';\nimport type { CrossFiltersModalDataType, DashboardBlockProperties } from './dashboardModel';\nimport { InputTableDefinitionModel } from './inputTableModel';\nimport type { MapFxModel } from './mapFxModel';\nimport { PortalDefinition } from './portalWidgetDefinition';\nimport { ProcessDefinition } from './processDefinitionTypes';\nimport type { Report, StatementPlan } from './reportModel';\nimport { DocumentTypeEnum } from './workspaceTreeModel';\n\nexport const DASHBOARD_TYPE = 'DASHBOARD';\nexport const STATEMENT_TYPE = 'STATEMENT';\nexport const PLAN_TYPE = 'PLAN';\n\nexport type BoardTypes = 'DASHBOARD' | 'STATEMENT' | 'PLAN';\nexport type WorkbookSheetTypes = 'WORKSHEET' | 'PIVOT' | 'METRIC' | 'STATEMENT';\n\nexport type ModelUpdateType = 'DEFINITION' | 'MODEL' | 'THUMBNAIL' | 'FAVORITE';\n\nexport type PivotProperties = {\n\trowGroup: any;\n\tcolGroup: any;\n};\n\nexport type TableMaps = Record<string, any[]>;\n\nexport type SheetCreationOptions = 'newSheet' | 'existingSheet';\nexport type LineType = 'PIVOT' | 'FORMULA';\n\nexport type MetricSeriesAdditional = {\n\tchartSettings: {\n\t\tdisplayMode: 'chart' | 'table';\n\t};\n\n\tconfiguration: {\n\t\tbinValue: string;\n\t\tdataField: string;\n\t\trowgroup: string[];\n\t\tvalues: string[];\n\t\tfilters: unknown;\n\t};\n};\n\nexport type ColumnSetting = {\n\tcurrency?: Currency;\n\tdateFormat?: string;\n\tfield: string; // data is reflected in the grid based on fields\n\theaderName: string; // header name is reflected in the grid\n\tprecision?: number; // set precision value\n\ttype?: 'str' | 'f64' | 'i64' | 'date' | \"datetime(time_unit='us', time_zone=None)\"; // ex -> ['dateColumn', 'nonEditableColumn'], 'nonEditableColumn'\n\tclearFormatting?: boolean; // clear all formatting, including defaults\n\tvalueFormatter?: (params: any) => any; // formate the value\n\tvalueGetter?: (params: any) => any; // will have access to other params and can do calculations\n\theaderTooltip?: string; // tooltip for the header\n\theaderClass?: string | string[] | ((params: any) => string | string[] | undefined);\n\theaderComponent?: any; // custom header component\n\tcolId?: string; // unique id for the column - optional\n\tcheckboxSelection?: boolean; // if true, will have a checkbox in the column\n\tshowDisabledCheckboxes?: boolean; // if true, will show disabled checkbox, default -> false\n\ticons?: { [key: string]: Function | string };\n\tsuppressNavigable?: boolean; // et to true if this column is not navigable (i.e. cannot be tabbed into), otherwise false. Can also be a callback function to have different rows navigable.\n\tsuppressKeyboardEvent?: Function; //Allows the user to suppress certain keyboard events in the grid cell. See Suppress Keyboard Events.\n\thide?: boolean; // show hide the columns\n\tlockVisible?: boolean; //Set to true to block making column visible / hidden via the UI (API will still work).\n\tlockPosition?: boolean | 'left' | 'right'; //Lock a column to position to 'left' or'right' to always have this column displayed in that position. true is treated as 'left'\n\tsuppressMovable?: boolean; //Set to true to block moving this column via dragging\n\tmenuTabs?: string[]; // Set to an array containing zero, one or many of the following options: 'filterMenuTab' | 'generalMenuTab' | 'columnsMenuTab'. This is used to figure out which menu tabs are present and in which order the tabs are shown.\n\tsuppressMenu?: boolean; //Set to true to not show the column menu when the column header is right clicked.\n\tpinned?: boolean | 'left' | 'right' | null;\n\teditable?: boolean;\n\tcellClassRule?: {\n\t\t[key: string]: (params: any) => boolean;\n\t};\n\tenableRowGroup?: boolean;\n\tenablePivot?: boolean;\n\tenableValue?: boolean;\n\tunique_count?: number;\n\tcellRendererParams?: any;\n\tcellRenderer?: string | Function;\n\twidth?: number;\n\taggFunc?: string;\n\tisCurrency?: boolean;\n\tisPercentage?: boolean;\n\tisNumber?: boolean;\n\tshowAs?: ShowAsType | CustomCalculationsShowAsType;\n\tminWidth?: number;\n\tcellClass?: string | string[] | ((params: any) => string | string[] | undefined);\n\tcellDataType?: boolean;\n\tsheetName?: string;\n\tisFormulaColumn?: boolean;\n\tisLookupColumn?: boolean;\n\tisJoinColumn?: boolean;\n\tcompactNotation?: CompactNotation;\n\tdatasetId?: string;\n\tdatasetName?: string;\n\tcolumnGroup?: string;\n\tcolumnGroupShow?: 'open' | 'closed';\n\tmarryChildren?: boolean;\n\tchildren?: ColumnSetting[];\n\tgroupId?: string;\n};\n\nexport enum ShowAsEnum {\n\tDEFAULT = 'default',\n\tROW = 'row',\n\tCOLUMN = 'column',\n\tGRAND_TOTAL = 'grandTotal'\n}\n\nexport enum CustomCalculationShowAsEnum {\n\tNONE = 'none',\n\tFORMULA = 'formula',\n\tAGGREGATE = 'aggregate'\n}\n\nexport type UiSettings = {\n\tfontSize?: number;\n\tdecimalPlaces?: {\n\t\t[colId: string]: number;\n\t};\n\tcolumnSettings?: ColumnSetting[];\n};\n\nexport type CustomModel = {};\nexport type LookupSetting = {\n\tleftCol: string;\n\trightCol: string;\n\trightSheetId: string;\n\tselectedColumns: { col: string; alias: string }[];\n};\n\nexport type XLookupSetting = {\n\tlookup_sheet_id: string;\n\tlookup_col: string;\n\tlookup_sheet: string;\n\twith_col: string;\n\treturn_col: string; // this is the id of the column in the lookup sheet\n\tsort_col?: string;\n\tsort_order?: string;\n\tselection_mode?: boolean;\n\treturn_col_id?: string; // this is the id of the column in the current sheet\n};\n\nexport type WorkbookCustomModel = {\n\tinputs?: Inputs;\n\tvariable?: string;\n\tfilterColumnsBy?: FilterColumnsBy;\n\tdateRange?: DateRange;\n\tuiSettings?: UiSettings;\n\tworksheetType?: 'TableSheet';\n\tdatasetId?: string;\n\tdatasetName?: string;\n\tparentTableColumnSettings?: ColumnSetting[];\n\tcurrency?: string;\n\tlookupSettings?: LookupSetting[];\n\tformatSettings?: FormatRule[];\n\txLookupSettings?: XLookupSetting[];\n\tsortOptions?: SortOptionsForWorkbook;\n};\n\nexport type ReconWorkbookCustomModel = WorkbookCustomModel & {\n\tdateColumn?: string;\n};\n\nexport type RowGroupsType = Array<string | string[]>;\n\nexport type GridColumnState = {\n\tvalueCols: ValueColsType[];\n\tfilterModel: any;\n\trowGroupCols: RowGroupsType;\n\tpivotCols: string[];\n};\n\nexport type SortOptions = {\n\tsortByField: SelectOptionType | undefined;\n\tsortByOrder: 'asc' | 'desc';\n\t/** Intervals to sort data based on (for trends) */\n\tpivotFilters?: string[];\n};\nexport type SortOptionsForWorkbook = {\n\tsortByField: SelectOptionType | undefined | SelectOptionType[];\n\tsortByOrder: 'asc' | 'desc' | undefined | ('asc' | 'desc')[];\n};\n\nexport type LimitOptions = {\n\tlimit: number;\n\tlimitFrom: 'top' | 'bottom';\n};\n\nexport type PivotCustomModel = WorkbookCustomModel & {\n\tchartType?: string;\n\tparentTableId: string;\n\tgridColumnState?: GridColumnState;\n\tparentTableVariable: string;\n\ttimeBin?: TimeBin | '';\n\tcompareTrends?: Array<{ id: string; name: string; dateRange: DateRange }>;\n\tdateColumn?: string;\n\tdatasetId: string;\n\tdatasetName: string;\n\thierarchy?: HierarchyProperties;\n\tcurrency?: string;\n\tsortOptions?: SortOptions;\n\tlimitOptions?: LimitOptions;\n\tcolorPalette?: string;\n\tsettings?: any;\n\tcolumnWidth?: any;\n\tshowDimensionMappingValues?: boolean;\n\tshowBinSortOrderValues?: boolean;\n\tplotAsTrendsOrder?: 'asc' | 'desc' | 'none';\n\tpivotColumnFormatMap?: Record<string, ColumnSetting>;\n};\n\nexport type MetricViewMode = 'grid' | 'chart' | 'geomap';\n\nexport type TableCustomModel = WorkbookCustomModel & {\n\tcolumns?: string[];\n};\n\nexport type LineCustomModel = WorkbookCustomModel & {\n\tparentTableVariable?: string;\n\tparentTableId?: string;\n\tvalueCols?: ValueColsType[];\n\tallValueCols?: ValueColsType[];\n\tfilterModel?: any;\n\ttimeBin?: TimeBin;\n\tdateColumn?: string;\n\tgroupBy?: string[];\n\tpivotCols?: string[];\n};\n\nexport type Line = {\n\tid: string;\n\ttype: LineType;\n\tsheetId?: string;\n\tvariable?: string;\n\tinputs?: any;\n\tcustomModel?: LineCustomModel;\n\tdefinitionModel?: Definition;\n\tdisplayName?: string;\n\tformula?: string;\n\tlastModifiedDate?: string;\n\tpublishedVersion?: number;\n\tcurrency?: Currency;\n\tprecision?: number;\n\tdateFormat?: string;\n\tclearFormatting?: boolean;\n};\nexport type ShowAsType = 'default' | 'row' | 'column' | 'grandTotal';\nexport type CustomCalculationsShowAsType = 'none' | 'formula' | 'aggregate';\nexport type PivotGridDisplayType = { gridData: any[]; gridColumns: any[] };\nexport type ValueColsType = {\n\tlabel?: string;\n\tcol: string;\n\taggFun?: string;\n\tformula?: string;\n\tcurrency?: Currency;\n\tprecision?: number;\n\tnumberFormat?: string;\n\tdateFormat?: string;\n\tclearFormatting?: boolean;\n\timpact?: 'positive' | 'negative';\n\tchartColorBasedOnImpact?: boolean;\n\ttype?: 'value' | 'formula' | 'column';\n\tisCurrency?: boolean;\n\tisPercentage?: boolean;\n\tisNumber?: boolean;\n\tshowAs?: ShowAsType | CustomCalculationsShowAsType;\n\tisAmortize?: boolean;\n\thide?: boolean;\n\tcompactNotation?: CompactNotation;\n\thideGrandTotal?: boolean;\n\tsourceLabel?: string; // Label of the valueCol this is based/derived from\n\tcompareTrendId?: string;\n\tshowRowTotal?: boolean;\n};\nexport type Section = {\n\tid: string;\n\theader: string;\n\tlines: Line[];\n};\n\nexport type Statement = {\n\tsections: Section[];\n\tformulaColumns?: string[];\n\ttimeBinOption: { label: string; value: TimeBin };\n\tinputs?: Inputs;\n};\n\nexport type DashboardDateRangeModel = {\n\tdateRange: DateRange;\n\tappliedOnBlocks: { blockId: string; blockName: string; applied: boolean }[];\n};\n\nexport type BoardCurrencyModel = {\n\tcurrency: string;\n\tappliedOnBlocks: { blockId: string; blockName: string; applied: boolean }[];\n};\n\nexport type Sheet<\n\tT extends CustomModel = any,\n\tD extends\n\t\t| Definition\n\t\t| MapFxModel\n\t\t| Report\n\t\t| ProcessDefinition\n\t\t| PortalDefinition\n\t\t| StatementPlan\n\t\t| InputTableDefinitionModel = Definition\n> = Worksheet & {\n\tcustomModel?: T;\n\tdefinitionModel?: D;\n};\n\n//Same model for Board and Workbook\nexport type WorkbookModel<T extends CustomModel = any> = Omit<Workbook, 'sheets'> & {\n\tsheets: Sheet<T>[];\n};\n\nexport type FilterBy = 'value' | 'condition';\n\nexport type FilterColumnsBy = { [column: string]: FilterBy };\n\nexport type WeakLinkType = {\n\tdocumentId: string;\n\tsheetId: string;\n\ttype: DocumentTypeEnum.WORKBOOK | DocumentTypeEnum.STATEMENT;\n};\n\nexport type MetricMetadataType = {\n\tparentTableVariable?: string;\n\tvariable: string;\n\tdatasetId?: string;\n\tdatasetName?: string;\n\tcolumnSettings: ColumnSetting[];\n\tdateColumn?: string;\n\tdateRange?: DateRange;\n\tfilterColumnsBy?: FilterColumnsBy;\n\tinputs: Inputs;\n\taliases?: { [key: string]: string };\n\tvalueCols?: ValueColsType[];\n\tfilterModel?: FilterRule | [];\n\trowGroupCols?: RowGroupsType;\n\tpivotCols?: string[];\n\ttimeBin?: TimeBin | '';\n\thierarchy?: HierarchyProperties;\n\tcurrency?: string;\n\tsortOptions?: SortOptions;\n\tlimitOptions?: LimitOptions;\n\tlastModifiedDate?: string;\n\tdescription?: string;\n\tscore?: string;\n\tisKPI?: boolean;\n\tcrossFilterModel?: CrossFiltersModalDataType;\n\tviewFilterModel?: any;\n\thierarchyCol?: GroupByHierarchyType;\n\tweakLink?: WeakLinkType;\n\tstringValue?: boolean;\n\tcompareTrends?: Array<{ id: string; name: string; dateRange: DateRange }>;\n\tshowDimensionMappingValues?: boolean;\n\tshowBinSortOrderValues?: boolean;\n\tplotAsTrendsOrder?: 'asc' | 'desc' | 'none';\n\tpivotColumnFormatMap?: Record<string, ColumnSetting>;\n\tcolumnWidth?: Record<string, number>;\n};\n\n/**\n * Settings for configuring geographical map visualizations.\n * @property {string} country - The country for which the map is displayed (currently supports 'India').\n * @property {string} cityColumn - The column containing city names.\n * @property {string} aggregateByCol - The column to aggregate data by.\n * @property {string[]} showInTooltip - Fields to display in the tooltip.\n * @property {string[]} fieldToIndicateZeroValues - Fields that should be highlighted when zero.\n * @property {string} fillColor - The color used to fill the markers.\n * @property {string} borderColor - The color used for marker borders.\n */\nexport type GeomapSettings = {\n\tcountry: string;\n\tcityColumn: string;\n\taggregateByCol: string;\n\tshowInTooltip: string[];\n\tfieldToIndicateZeroValues: string[];\n\tfillColor: string;\n\tborderColor: string;\n};\n\ntype FunnelChartSortOrder = 'descending' | 'ascending' | 'none';\n\nexport type FunnelChartSettings = {\n\thideLabels: boolean;\n\tselectedValueColumn: string;\n\tsortOrder: FunnelChartSortOrder;\n\tmin: number;\n\tmax: number;\n};\n\nexport type MetricSettingsType = {\n\tchartType?: string;\n\thideTooltipHeader?: boolean;\n\tchartTypeBeforeDrilldown?: string;\n\tviewMode: MetricViewMode;\n\tcolorPalette?: string;\n\taxisDistributionType?: 'value' | 'log';\n\tyAxisCount?: YAxisCountEnum;\n\tlabelPosition?: string;\n\tlabelRotation?: string;\n\twaterfallParentMapping?: Record<string, string>;\n\tgeomapSettings?: GeomapSettings;\n\tfunnelChartSettings?: FunnelChartSettings;\n\tchartSettings?: Record<string, any>;\n};\n\nexport type DashboardProperties = { [cols in number]?: DashboardBlockProperties };\n\nexport type MetricCustomModel = DashboardProperties & {\n\tmetadata: MetricMetadataType;\n\tsettings: MetricSettingsType;\n\taddedMode?: 'imported' | 'created';\n};\n","import type { SelectOptionType } from '$models/types/selectType';\nimport {\n\toperatorsWithIsNotTrue,\n\ttype FilterRule,\n\ttype FilterSelectOptionsType,\n\ttype FilterUniqueValueSelectOptionsType,\n\ttype RuleType\n} from '$models/ui-models/filterModel';\nimport { FilterColumnsBy, ValueColsType } from '$models/ui-models/workbookModel';\nimport { Operator } from '$models/ui-models/filterModel';\nimport _ from 'lodash';\n\nexport type FilterPanelStoreType = {\n\tdefaultType: Omit<RuleType, 'cond'>;\n\trules: FilterSelectOptionsType[];\n};\n\nconst defaultFilterPanel: FilterRule = {\n\tis_not: false,\n\trule_type: 'and_cond',\n\trules: []\n};\n\nexport const filterToSelectOptionType = (\n\tfilter: FilterRule,\n\tcolumns: SelectOptionType[]\n): FilterPanelStoreType => {\n\tconst rules: FilterRule[] = filter?.rules as FilterRule[] || [];\n\n\tif (!rules || rules.length === 0) {\n\t\treturn {\n\t\t\tdefaultType: 'and_cond',\n\t\t\trules: []\n\t\t};\n\t}\n\n\tconst selectOptionsForRules: FilterSelectOptionsType[] = rules.map((rule) =>\n\t\tgetSelectionOptionsFromFilter(rule, columns)\n\t);\n\treturn {\n\t\tdefaultType: (filter?.rule_type as Omit<RuleType, 'cond'>) || 'and_cond',\n\t\trules: selectOptionsForRules\n\t};\n};\n\nexport const getSelectionOptionsFromFilter = (\n\trule: FilterRule,\n\tcolumns: SelectOptionType[]\n): FilterSelectOptionsType => {\n\tif (_.isEmpty(rule?.rules)) {\n\t\tconst col = columns.find((column) => column.label === rule.col || column.value === rule.col);\n\n\t\treturn {\n\t\t\tlabel: col?.label || '',\n\t\t\tvalue: col?.value || '',\n\t\t\toption: {\n\t\t\t\taggFun: col?.option?.aggFun,\n\t\t\t\tuniqueValues: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: col?.label || '',\n\t\t\t\t\t\tvalue: col?.value || '',\n\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\tuniqueValue: rule?.value as string | number | boolean,\n\t\t\t\t\t\t\toperator: rule?.operator,\n\t\t\t\t\t\t\truleType: rule?.rule_type || 'cond',\n\t\t\t\t\t\t\tisNot: rule?.is_not || false,\n\t\t\t\t\t\t\tcaseSensitive: rule?.is_case_sensitive ?? true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tuniqueValueCount: col?.option?.uniqueCount,\n\t\t\t\ttype: col?.option?.type,\n\t\t\t\truleType: rule?.rule_type || 'cond'\n\t\t\t}\n\t\t};\n\t}\n\tconst col = columns?.find(\n\t\t(column) => column.label === rule?.rules?.[0]?.col || column.value === rule?.rules?.[0]?.col\n\t);\n\tconst isValueFilter = _.get(rule, 'rules.0.operator', null) === 'in_op' && _.get(rule, 'rules.0.value', null);\n\tif (isValueFilter) {\n\t\treturn {\n\t\t\tlabel: col?.label || '',\n\t\t\tvalue: col?.value || '',\n\t\t\toption: {\n\t\t\t\taggFun: col?.option?.aggFun,\n\t\t\t\tuniqueValues: rule?.rules?.[0]?.value?.map((r: string) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tlabel: col?.label || '',\n\t\t\t\t\t\tvalue: col?.value || '',\n\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\taggFun: col?.option?.aggFun,\n\t\t\t\t\t\t\tuniqueValue: r,\n\t\t\t\t\t\t\toperator: 'equal',\n\t\t\t\t\t\t\truleType: 'cond',\n\t\t\t\t\t\t\tisNot: false,\n\t\t\t\t\t\t\tcaseSensitive: true\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}) || [],\n\t\t\t\tuniqueValueCount: col?.option?.uniqueCount,\n\t\t\t\ttype: col?.option?.type,\n\t\t\t\truleType: rule?.rule_type || 'cond'\n\t\t\t}\n\t\t};\n\t}\n\treturn {\n\t\tlabel: col?.label || '',\n\t\tvalue: col?.value || '',\n\t\toption: {\n\t\t\taggFun: col?.option?.aggFun,\n\t\t\tuniqueValues: rule?.rules?.map((r: FilterRule) => {\n\t\t\t\tconst childCol = columns?.find((column) => column.value === r.col);\n\t\t\t\treturn {\n\t\t\t\t\tlabel: childCol?.label || '',\n\t\t\t\t\tvalue: childCol?.value || '',\n\t\t\t\t\toption: {\n\t\t\t\t\t\taggFun: childCol?.option?.aggFun,\n\t\t\t\t\t\tuniqueValue: r?.value as string | number | boolean,\n\t\t\t\t\t\toperator: r?.operator,\n\t\t\t\t\t\truleType: r?.rule_type || 'cond',\n\t\t\t\t\t\tisNot: r?.is_not || false,\n\t\t\t\t\t\tcaseSensitive: r?.is_case_sensitive ?? true\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}) || [],\n\t\t\tuniqueValueCount: col?.option?.uniqueCount,\n\t\t\ttype: col?.option?.type,\n\t\t\truleType: rule?.rule_type || 'cond'\n\t\t}\n\t};\n};\n\nexport const getSelectOptionTypeToFilter = (\n\tfilter: FilterPanelStoreType,\n\tfilterColumnsBy?: FilterColumnsBy\n): FilterRule => {\n\tconst rules: FilterSelectOptionsType[] = filter?.rules;\n\tconst defaultRuleType = filter?.defaultType;\n\n\tif (!rules || rules.length === 0) {\n\t\treturn defaultFilterPanel;\n\t}\n\n\tlet filterRules: FilterRule[] = rules?.map((rule) =>\n\t\tgetFilterRuleFromSelectionOptions(rule, filterColumnsBy)\n\t);\n\n\tif (filterRules.length === 1 && filterRules[0].rules && filterRules[0].rules.length < 1) {\n\t\tfilterRules = [];\n\t}\n\n\treturn {\n\t\tis_not: false,\n\t\trule_type: defaultRuleType as RuleType,\n\t\trules: filterRules\n\t};\n};\n\nexport const getFilterRuleFromSelectionOptions = (\n\trule: FilterSelectOptionsType,\n\tfilterColumnsBy?: FilterColumnsBy\n): FilterRule => {\n\tif (filterColumnsBy?.[rule.value] === 'value' || rule?.option?.uniqueValues?.length > 2) {\n\t\treturn {\n\t\t\trule_type: 'or_cond',\n\t\t\trules: [\n\t\t\t\t{\n\t\t\t\t\tcol: rule.value,\n\t\t\t\t\tvalue: _.map(rule?.option?.uniqueValues || [], (r) => r.option.uniqueValue),\n\t\t\t\t\toperator: 'in_op',\n\t\t\t\t\trule_type: 'cond',\n\t\t\t\t\tis_not: false,\n\t\t\t\t\tis_case_sensitive: true\n\t\t\t\t}\n\t\t\t],\n\t\t\tis_not: false\n\t\t};\n\t}\n\tif (rule?.option?.uniqueValues?.length === 1) {\n\t\tconst uniqueValue = rule?.option?.uniqueValues?.[0];\n\t\treturn {\n\t\t\tcol: rule.value,\n\t\t\tvalue: uniqueValue?.option?.uniqueValue,\n\t\t\toperator: uniqueValue?.option?.operator,\n\t\t\trule_type: uniqueValue?.option?.ruleType ?? 'cond',\n\t\t\tis_not: uniqueValue?.option?.isNot ?? false,\n\t\t\tis_case_sensitive: uniqueValue?.option?.caseSensitive ?? true\n\t\t};\n\t}\n\treturn {\n\t\trule_type: rule?.option?.ruleType,\n\t\trules: (rule?.option?.uniqueValues || []).map((r: FilterUniqueValueSelectOptionsType) => {\n\t\t\treturn {\n\t\t\t\tcol: r.value,\n\t\t\t\tvalue: r.option?.uniqueValue,\n\t\t\t\toperator: r.option?.operator,\n\t\t\t\trule_type: r.option?.ruleType ?? 'cond',\n\t\t\t\tis_not: r.option?.isNot ?? false,\n\t\t\t\tis_case_sensitive: r.option?.caseSensitive ?? true\n\t\t\t};\n\t\t}),\n\t\tis_not: false\n\t};\n};\n\nexport const getFilterRulesFromFilterSelectOptionsMap = (\n\tfilterSelectOptionsMap: {\n\t\t[filterId: string]: FilterSelectOptionsType;\n\t},\n\tfilterColumnsBy: FilterColumnsBy\n): { combinedFilterRule: FilterRule; columnFilterRule: FilterRule; aggFilterRule: FilterRule } => {\n\tconst filterSelectOptionsMapForAgg = _.pickBy(\n\t\tfilterSelectOptionsMap,\n\t\t(o) => !_.isEmpty(o.option.aggFun)\n\t);\n\tconst filterSelectOptionsMapForFilters = _.pickBy(filterSelectOptionsMap, (o) =>\n\t\t_.isEmpty(o.option.aggFun)\n\t);\n\n\tconst filterSelectOption: FilterPanelStoreType = {\n\t\tdefaultType: 'and_cond' as RuleType,\n\t\trules: Object.values(filterSelectOptionsMap)\n\t};\n\n\tconst filterSelectOptionWithoutAgg: FilterPanelStoreType = {\n\t\tdefaultType: 'and_cond' as RuleType,\n\t\trules: Object.values(filterSelectOptionsMapForFilters)\n\t};\n\tconst filterSelectOptionForAgg: FilterPanelStoreType = {\n\t\tdefaultType: 'and_cond' as RuleType,\n\t\trules: Object.values(filterSelectOptionsMapForAgg)\n\t};\n\n\tconst columnFilterRule = getSelectOptionTypeToFilter(\n\t\tfilterSelectOptionWithoutAgg,\n\t\tfilterColumnsBy\n\t);\n\tconst combinedFilterRule = getSelectOptionTypeToFilter(filterSelectOption, filterColumnsBy);\n\tconst aggFilterRule = getSelectOptionTypeToFilter(filterSelectOptionForAgg, filterColumnsBy);\n\n\treturn {\n\t\tcombinedFilterRule,\n\t\tcolumnFilterRule,\n\t\taggFilterRule\n\t};\n};\n\nexport const getColumnFilterRuleFromCombinedFilterRule = (\n\tcombinedFilterRule: FilterRule,\n\tvalueCols: ValueColsType[]\n): FilterRule => {\n\tconst filterRules: FilterRule[] = combinedFilterRule?.rules ?? [];\n\tconst columnFilterRules: FilterRule[] = [];\n\n\t_.forEach(filterRules, (rule) => {\n\t\tconst valueCol = valueCols?.find((valueCol) => rule?.col === valueCol?.label);\n\t\tif (!valueCol) {\n\t\t\tcolumnFilterRules.push(rule);\n\t\t}\n\t});\n\n\treturn {\n\t\t...combinedFilterRule,\n\t\trules: columnFilterRules\n\t};\n};\n\nexport const getAggregateFilterRuleFromCombinedFilterRule = (\n\tcombinedFilterRule: FilterRule,\n\tvalueCols: ValueColsType[]\n): FilterRule => {\n\tconst filterRules: FilterRule[] = combinedFilterRule?.rules ?? [];\n\tconst aggFilterRules: FilterRule[] = [];\n\n\t_.forEach(filterRules, (rule) => {\n\t\tconst valueCol = valueCols?.find((valueCol) => rule?.col === valueCol?.label);\n\t\tif (valueCol) {\n\t\t\taggFilterRules.push(rule);\n\t\t}\n\t});\n\n\treturn {\n\t\t...combinedFilterRule,\n\t\trules: aggFilterRules\n\t};\n};\n\nexport const getIsNotValueForPredicateType = (predicateType: Operator) => {\n\treturn _.includes(operatorsWithIsNotTrue, predicateType);\n};\n","import _ from 'lodash';\nimport { Section } from './reportModel';\nimport { ColumnFilterRule } from '$models/gen/Api';\n\nexport type BaseTransform = {\n\ttype: string;\n};\n\nexport type Pivot = BaseTransform & {\n\ttable: string;\n\tvalues: string | string[];\n\tcol_groups: string | string[];\n\trow_groups: string | string[];\n\taggregate_fn: string;\n};\n\nexport type TimeBin = 'per_day' | 'per_week' | 'per_month' | 'per_quarter' | 'per_year';\n\nexport type DateRange =\n\t| 'current_week'\n\t| 'current_month'\n\t| 'current_quarter'\n\t| 'current_year'\n\t| 'previous_week'\n\t| 'previous_month'\n\t| 'previous_quarter'\n\t| 'previous_year'\n\t| 'past_week'\n\t| 'past_month'\n\t| 'past_quarter'\n\t| 'past_year'\n\t| 'custom_period'\n\t| 'all';\n\nexport type MetricAggregateType =\n\t| [alias: string, formula: string]\n\t| [alias: string, col: string, func: string];\n\nexport type InputTableMetricAggregateType = Record<string, [string, string]>;\n\nexport type ProjectFractionType =\n\t| 'FRACTION_OF_COL_TOTAL'\n\t| 'FRACTION_OF_ROW_TOTAL'\n\t| 'FRACTION_OF_GRAND_TOTAL';\n\nexport enum ProjectFractionEnum {\n\tFRACTION_OF_COL_TOTAL = 'FRACTION_OF_COL_TOTAL',\n\tFRACTION_OF_ROW_TOTAL = 'FRACTION_OF_ROW_TOTAL',\n\tFRACTION_OF_GRAND_TOTAL = 'FRACTION_OF_GRAND_TOTAL',\n\tNONE = 'null',\n\tTOTAL_OF_FORMULA = 'TOTAL_OF_FORMULA',\n\tTOTAL_OF_AGGREGATE = 'TOTAL_OF_AGGREGATE'\n}\n\nexport type ProjectAsType = {\n\t[valueColName: string]: ProjectFractionType;\n};\n\nexport type MetricSeries = BaseTransform & {\n\ttable: string;\n\tdate_column: string;\n\taggregates: MetricAggregateType[];\n\tformula_on_aggregates: [alias: string, formula: string][];\n\tfilter_on_aggregates?: FilterRule;\n\tbin_by: string; // because we are passing it as variable now\n\tgroup_by: string[] | string;\n\trow_group_by?: string[] | string;\n\tcol_group_by?: string[] | string;\n\trequire_totals?: boolean;\n\tproject_as?: string | ProjectAsType; // because we are passing it as variable now\n\tshow_dimension_mapping_values?: boolean;\n\tbin_order_by_desc?: boolean; // because we are passing it as variable now\n};\n\nexport type Load = {\n\tloc: string;\n\tto: string;\n\tfs_options: any;\n};\n\nexport type Import = {\n\tloc: string;\n\tto: string;\n\timport_type: 'dataset' | 'definition';\n\tfrom_var?: string;\n\tdate_column_filter?:\n\t\t| {\n\t\t\t\ttime_period: DateRange;\n\t\t\t\tstart_date?: string;\n\t\t\t\tend_date?: string;\n\t\t }\n\t\t| string;\n\tto_currency?: string;\n};\n\nexport type AddColumn = BaseTransform & {\n\ttype: 'AddColumn';\n\ttable: string;\n\n\tcol: string;\n\n\texpr: string;\n};\nexport type ManageColumns = BaseTransform & {\n\ttype: 'ManageColumns';\n\ttable: string;\n\tcols: string[];\n};\n\nexport type RenameColumn = BaseTransform & {\n\ttype: 'RenameColumn';\n\ttable: string;\n\n\t//TODO : Check fxRuntime Types\n\tcol: string;\n\n\tbefore: string;\n\n\tafter: string;\n};\n\nexport type SourceDataset = BaseTransform & {\n\ttype: 'SourceDataset';\n\ttable: string;\n\tcols: string[];\n};\n\nexport type View = BaseTransform & {\n\ttype: 'View';\n\ttable: string;\n\tcols: string[] | string;\n};\n\ntype RuleType = 'or_cond' | 'and_cond' | 'cond';\n\nexport type RuleOp =\n\t| 'starts_with'\n\t| 'ends_with'\n\t| 'like'\n\t| 'contains'\n\t| 'equal'\n\t| 'greater'\n\t| 'greater_equal'\n\t| 'less'\n\t| 'less_equal'\n\t| 'in_op';\n\nexport type FilterRule = {\n\trule_type: RuleType;\n\tcol?: string;\n\toperator?: RuleOp;\n\tvalue?: string | number | boolean | string[];\n\trules?: FilterRule[];\n\tis_not: boolean;\n\tis_case_sensitive: boolean;\n\tignore_if_col_not_exists?: boolean;\n};\n\nexport type Filter = BaseTransform & {\n\ttable: string;\n\texpr: string;\n};\n\nexport type RuleFilter = BaseTransform & {\n\ttable: string;\n\trule: ColumnFilterRule | string;\n};\n\nexport type Sort = BaseTransform & {\n\ttable: string;\n\n\tcol: string[];\n\n\tasc: boolean[];\n\n\tpivot_inputs: {\n\t\tpivot_filters: FilterRule[];\n\t\tpivot_columns: string[];\n\t\tpivot_groups: { [key: string]: 'ASC' | 'DESC' };\n\t};\n};\n\nexport type Metric = BaseTransform & {\n\ttable: string;\n\n\taggregates: Aggregates;\n\n\tgroup_by: string | string[];\n};\n\nexport type Merge = BaseTransform & {\n\ttables: string[];\n};\n\nexport type JoinTransformHow = 'left' | 'right';\n\nexport type Join = BaseTransform & {\n\tleft: string;\n\n\tright: string;\n\n\tleft_on: string;\n\n\tright_on: string;\n\n\thow: JoinTransformHow;\n\n\tallow_duplication: boolean;\n\n\tright_cols?: string[];\n\n\tright_aliases?: string[];\n};\n\nexport type Transform<T extends BaseTransform> = T;\nexport type TransformStrings =\n\t| 'addColumn'\n\t| 'renameColumn'\n\t| 'view'\n\t| 'join'\n\t| 'metric'\n\t| 'filter'\n\t| 'sort'\n\t| 'merge'\n\t| 'pivot'\n\t| 'metric'\n\t| 'metricseries';\nexport type AvailableTransform =\n\t| AddColumn\n\t| RenameColumn\n\t| View\n\t| Filter\n\t| Sort\n\t| Metric\n\t| Merge\n\t| Join\n\t| Pivot\n\t| MetricSeries\n\t| RuleFilter;\n\nexport type Variable = {\n\tname: string;\n\ttransforms: AvailableTransform[];\n};\n\nexport type Aggregates = Record<string, string[]>;\n\nexport type Permission = any;\n\ntype Principal = {\n\tname: string;\n\n\tptype: string;\n};\n\nexport type Export = {\n\ttable: string;\n\n\tassignments?: (Principal | Permission[])[];\n\n\tentry_key: string;\n\n\ttags?: string[];\n};\n\nexport type TableColMap = {\n\ttables: any[];\n\tcolumns: Record<string, string[]>;\n};\n\ntype ColId = string;\nexport type Inputs = {\n\t[key: string]: any;\n};\n\nexport type Table = { data: any[]; to: string };\nexport type Definition = {\n\tinputs?: {\n\t\t[key: string]: any;\n\t};\n\taliases?: {\n\t\t[tableName: string]: { [alias: string]: ColId };\n\t};\n\timports?: Import[];\n\n\tloads?: Load[];\n\n\tvariables?: Variable[];\n\n\tpermissions?: Permission[];\n\n\texports?: Export[];\n\n\ttables?: Table[];\n\n\tsections?: Section[];\n};\n\nexport type DescriptionResultWithUniqueCount = {\n\tname: string;\n\tdata_type: 'str' | 'f64' | 'i64' | 'date';\n\tcount: number;\n\tunique_count: number;\n\tis_currency_column: boolean;\n\tdatasetId: string;\n\tdatasetName: string;\n};\n\nexport type DescriptionResultWithoutUniqueCount = {\n\tname: string;\n\tdata_type: string;\n\tis_currency_column: boolean;\n\tdatasetId: string;\n\tdatasetName: string;\n};\n\nexport type DescriptionResult =\n\t| DescriptionResultWithoutUniqueCount\n\t| DescriptionResultWithUniqueCount;\n\nconst CURRENT_WEEK = 'current_week';\nconst CURRENT_MONTH = 'current_month';\nconst CURRENT_QUARTER = 'current_quarter';\nconst CURRENT_YEAR = 'current_year';\nconst PREV_WEEK = 'previous_week';\nconst PREV_MONTH = 'previous_month';\nconst PREV_QUARTER = 'previous_quarter';\nconst PREV_YEAR = 'previous_year';\nconst PAST_WEEK = 'past_week';\nconst PAST_MONTH = 'past_month';\nconst PAST_QUARTER = 'past_quarter';\nconst PAST_YEAR = 'past_year';\nconst CUSTOM = 'custom_period';\n\nexport type FormatRule = {\n\tid: string;\n\trule_type: RuleType;\n\tcol: string;\n\toperator: RuleOp;\n\tvalue: string | number | Date;\n\t// rules?: FilterRule[];\n\tis_not: boolean;\n\tcolor_hex: [string, string];\n\tcase_sensitive: boolean;\n};\n\nexport type GroupByHierarchyType = {\n\talias: string;\n\ttype: string;\n\tlookup_col: string;\n\ttable: string;\n\tlevel?: number;\n\tparent?: string;\n\tfilter: FilterRule;\n\tinclude_parents: boolean;\n\tuse_as: string;\n};\n","import { generatePushID } from '$models/common/pushId';\nimport {\n\tgetFxUdescribeApi,\n\tgetFxUniqueColumnValuesApi,\n\trunDefinitionApi,\n\trunPublishedDefinitionApi\n} from '$models/fx/fxApi';\nimport type { DatasetImportMetadata } from '$models/gen/Api';\nimport type { SelectOptionType } from '$models/types/selectType';\nimport type { BlockSheetCustomModel } from '$models/ui-models/dashboardModel';\nimport type { DateRange } from '$models/ui-models/dateRangeModel';\nimport {\n\tProjectFractionEnum,\n\tTransform,\n\tSort,\n\ttype Definition,\n\ttype DescriptionResult,\n\ttype DescriptionResultWithUniqueCount,\n\ttype Import,\n\ttype Inputs,\n\ttype RuleFilter,\n\ttype TimeBin,\n\ttype Variable,\n\ttype View,\n\tMetricSeries\n} from '$models/ui-models/definitionModel';\nimport type {\n\tCommonFilter,\n\tFilterPanelStoreType,\n\tFilterRule,\n\tFilterSelectOptionsType,\n\tFilterUniqueValueSelectOptionsType,\n\tRuleType\n} from '$models/ui-models/filterModel';\nimport {\n\tCustomCalculationShowAsEnum,\n\tShowAsEnum,\n\tWorkbookCustomModel,\n\ttype ColumnSetting,\n\ttype FilterColumnsBy,\n\ttype GridColumnState,\n\ttype MetricCustomModel,\n\ttype MetricMetadataType,\n\ttype PivotCustomModel,\n\ttype Sheet,\n\ttype SortOptions,\n\ttype ValueColsType\n} from '$models/ui-models/workbookModel';\n\nimport _ from 'lodash';\nimport { findVariable } from './variableUtils';\nimport { buildVariable } from './buildVariable';\nimport { filterToSelectOptionType, getAggregateFilterRuleFromCombinedFilterRule, getColumnFilterRuleFromCombinedFilterRule, getSelectOptionTypeToFilter } from './filterUtils';\nimport { getInputName } from './inputNameUtil';\nimport { getDisplayName } from './displayNamesUtil';\nimport type {\n\tLimitOptions,\n\tRowGroupsType,\n} from '$models/ui-models/workbookModel';\n\nexport type MetricToolPanelType = {\n\tpivotCols: string[];\n\trowGroupCols: RowGroupsType;\n\tvalueCols: ValueColsType[];\n\tsortOptions: SortOptions;\n\tlimitOptions: LimitOptions;\n\tfilterModel: FilterRule | [];\n\tdateRange?: DateRange;\n\ttimeBin: TimeBin | '';\n\tcurrency?: string;\n\tcompareTrends?: Array<{\n\t\tid: string;\n\t\tname: string;\n\t\tdateRange: DateRange;\n\t}>;\n\tshowDimensionMappingValues?: boolean;\n\tplotAsTrendsOrder?: 'asc' | 'desc' | 'none';\n\tshowBinSortOrderValues?: boolean;\n};\n\n\nconst getValuesForSpecialOperators = (op: string) => {\n\tswitch (op) {\n\t\tcase 'not_equal':\n\t\t\treturn { operator: 'equal', isNot: true };\n\t\tcase 'not_contains':\n\t\t\treturn { operator: 'contains', isNot: true };\n\t\tcase 'is_empty':\n\t\t\treturn { value: '', operator: 'equal', isNot: false };\n\t\tcase 'is_not_empty':\n\t\t\treturn { value: '', operator: 'equal', isNot: true };\n\t\tcase 'is_null':\n\t\t\treturn { value: null, operator: 'equal', isNot: false };\n\t\tcase 'is_not_null':\n\t\t\treturn { value: null, operator: 'equal', isNot: true };\n\t\tdefault:\n\t\t\treturn {};\n\t}\n};\n\nexport const getPivotGridData = async (props: {\n\tinputs: Inputs;\n\tdefinitionModel: Definition;\n\tvariableName: string;\n\tvalueCols?: ValueColsType[];\n}) => {\n\tconst { inputs, definitionModel, variableName, valueCols } = props;\n\n\treturn runDefinitionApi(inputs, definitionModel, variableName);\n};\n\nexport const replaceFilterColumn = (props: {\n\tfr: FilterSelectOptionsType[];\n\tcolumn: SelectOptionType<ColumnSetting>;\n}) => {\n\tconst { fr, column } = props;\n\n\tconst updatedFr = _.map(fr, (f) => {\n\t\tlet newFr = { ...f, label: column?.label, value: column?.value };\n\t\tif (newFr.option.uniqueValues) {\n\t\t\t_.map(newFr.option.uniqueValues, (u) => {\n\t\t\t\tu.label = column?.label;\n\t\t\t\tu.value = column?.value;\n\t\t\t});\n\t\t}\n\t\treturn newFr;\n\t});\n\n\treturn updatedFr;\n};\n\nexport const mergeCommonFilters = (props: {\n\tcommonFilters: CommonFilter[];\n\trule: FilterSelectOptionsType[];\n\tcondition: RuleType;\n\tlineId: string;\n}) => {\n\tconst { commonFilters, rule, lineId, condition } = props;\n\tlet replacedFr: FilterSelectOptionsType[][] = [];\n\tif (_.isEmpty(commonFilters)) return { defaultType: condition, rules: rule };\n\t_.forEach(commonFilters, (f: CommonFilter) => {\n\t\tconst columnSettingsSelectOption = [\n\t\t\t{\n\t\t\t\tlabel: f.name,\n\t\t\t\tvalue: f.column.name,\n\t\t\t\toption: {\n\t\t\t\t\theaderName: f.name,\n\t\t\t\t\tfield: f.column.name,\n\t\t\t\t\ttype: f.column.data_type,\n\t\t\t\t\tdatasetName: f.datasetName,\n\t\t\t\t\tdatasetId: f.datasetId\n\t\t\t\t}\n\t\t\t}\n\t\t];\n\n\t\t// check if applied on the line\n\t\tconst appliedOnLine = _.find(f?.appliedOnBlocks, (l) => l.blockId === lineId) as {\n\t\t\tblockId: string;\n\t\t\tapplied: boolean;\n\t\t\tblockName: string;\n\t\t\tcolumn: string;\n\t\t\tcolumnSettings: SelectOptionType<ColumnSetting>[];\n\t\t};\n\t\tif (appliedOnLine && appliedOnLine.applied) {\n\t\t\tconst commonRule = f.rule;\n\t\t\tconst fr = filterToSelectOptionType(commonRule, columnSettingsSelectOption);\n\t\t\tconst columnSetting = _.find(\n\t\t\t\tappliedOnLine.columnSettings,\n\t\t\t\t(c) => c.value === appliedOnLine.column\n\t\t\t);\n\t\t\tif (columnSetting) {\n\t\t\t\treplacedFr.push(replaceFilterColumn({ fr: fr.rules, column: columnSetting }));\n\t\t\t}\n\t\t}\n\t});\n\n\tconst mergedFr = _.unionBy(replacedFr.flat(), rule, 'value');\n\n\treturn { defaultType: condition, rules: mergedFr };\n};\n\nexport const getUniqueValues = async (\n\tcolumn: string[],\n\tsheetDetails?: {\n\t\tsheetId: string;\n\t\tinputs: Inputs;\n\t\tdefinitionModel: Definition;\n\t\tparentTableVariable: string;\n\t},\n\tuniqueValues?: any,\n\tuniqueValueStore?: any,\n\tstoreSelectOptions?: boolean\n): Promise<string[]> => {\n\tconst uValStr = uniqueValues ?? { uniqueValues: {} };\n\n\tif (column && column[0] && sheetDetails) {\n\t\tif (\n\t\t\tsheetDetails.sheetId in uValStr?.uniqueValues &&\n\t\t\tcolumn[0] in uValStr?.uniqueValues?.[sheetDetails.sheetId]\n\t\t) {\n\t\t\treturn uValStr?.uniqueValues[sheetDetails.sheetId][column[0]];\n\t\t}\n\n\t\t/**\n\t\t * removing filters to get all unique values. also make sure the variable being called is not a view variable.\n\t\t * This is because user might have hidden the column in the view variable, but added it as a filter.\n\t\t */\n\t\tlet inputs = _.reduce(\n\t\t\tObject.entries(sheetDetails?.inputs || {}),\n\t\t\t(acc, [key, value]) => {\n\t\t\t\tif (_.includes(key, 'rule_')) {\n\t\t\t\t\tacc[key] = defaultFilterRule;\n\t\t\t\t} else {\n\t\t\t\t\tacc[key] = value;\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record<string, any>\n\t\t);\n\n\t\tinputs = {\n\t\t\t...inputs,\n\t\t\tprojectAsInput: {},\n\t\t\trowGroupByInput: [],\n\t\t\tcolumnGroupByInput: [],\n\t\t\tgroupByInput: [],\n\t\t\tfilterOnAggregates: [],\n\t\t\tshowDimensionMappingValues: inputs.showDimensionMappingValues ?? false,\n\t\t\tshowBinSortOrderValues: inputs.showBinSortOrderValues ?? false\n\t\t};\n\n\t\tlet variableName = sheetDetails?.parentTableVariable;\n\t\tconst variables = sheetDetails?.definitionModel?.variables;\n\n\t\tconst calledVariable = _.find(variables, (v) => v.name === variableName);\n\t\tif (calledVariable?.transforms[0]?.type === 'View') {\n\t\t\tvariableName = (calledVariable?.transforms[0] as View)?.table;\n\t\t}\n\n\t\tconst uniqueValues = (\n\t\t\tawait getFxUniqueColumnValuesApi(inputs, sheetDetails.definitionModel, variableName, column)\n\t\t)?.data;\n\n\t\tif (storeSelectOptions) {\n\t\t\tconst selectOptions = _.map(uniqueValues[column[0]], (uv) => ({ label: uv, value: uv }));\n\t\t\tuniqueValueStore.updateUniqueValues(sheetDetails.sheetId, { [column[0]]: selectOptions });\n\t\t} else {\n\t\t\tuniqueValueStore.updateUniqueValues(sheetDetails.sheetId, uniqueValues);\n\t\t}\n\t\treturn uniqueValues[column[0]];\n\t}\n\t\n\treturn [];\n};\n\nexport const _getAggregates = (valueCols: ValueColsType[]) => {\n\treturn valueCols.map((vc: ValueColsType) => {\n\t\tif (vc.formula) {\n\t\t\t//first param should be the label\n\t\t\treturn [vc.label ?? vc.col, vc.formula];\n\t\t}\n\t\t//first param should be the label, second param should be the column id\n\t\treturn [vc.label ?? vc.col, vc.col, vc.aggFun];\n\t});\n};\n\nconst getParentTableVariableType = (childId: string, variables: Variable[]): Variable | undefined => {\n\tconst parentTableVariable = _.find(variables, (v) => v.name === childId);\n\treturn parentTableVariable;\n};\n\nexport const findParentIsMetricSeries = (childId: string, variables: Variable[]): boolean => {\n\tconst parentTableVariable = getParentTableVariableType(childId, variables);\n\tif (parentTableVariable?.transforms[0]?.type === 'MetricSeries') {\n\t\treturn true;\n\t} else if (parentTableVariable?.transforms[0]) {\n\t\t//@ts-ignore\n\t\treturn findParentIsMetricSeries(parentTableVariable?.transforms[0]?.table, variables);\n\t}\n\treturn false;\n};\n\nexport const ShowAsToProjectFractionMapper: Partial<\n\tRecord<ShowAsEnum | CustomCalculationShowAsEnum, ProjectFractionEnum>\n> = {\n\t[ShowAsEnum.ROW]: ProjectFractionEnum.FRACTION_OF_ROW_TOTAL,\n\t[ShowAsEnum.COLUMN]: ProjectFractionEnum.FRACTION_OF_COL_TOTAL,\n\t[ShowAsEnum.GRAND_TOTAL]: ProjectFractionEnum.FRACTION_OF_GRAND_TOTAL,\n\t[CustomCalculationShowAsEnum.NONE]: ProjectFractionEnum.FRACTION_OF_ROW_TOTAL,\n\t[CustomCalculationShowAsEnum.FORMULA]: ProjectFractionEnum.TOTAL_OF_FORMULA,\n\t[CustomCalculationShowAsEnum.AGGREGATE]: ProjectFractionEnum.TOTAL_OF_AGGREGATE\n};\n\nexport const getDefinitionModelAndVariableNameForPivot = (props: {\n\tpivotSheet: Sheet<PivotCustomModel>;\n\trowsToGroupBy: string[];\n\tvalueCols: ValueColsType[];\n\tsortOptions: SortOptions;\n\ttimeBin?: TimeBin | '';\n\tdateRange: DateRange;\n\tdateColumn?: string;\n\tpivotCols: string[];\n\tcurrency?: string;\n\tcompareTrends?: Array<{\n\t\tid: string;\n\t\tname: string;\n\t\tdateRange: DateRange;\n\t}>;\n\tshowDimensionMappingValues?: boolean;\n\tshowBinSortOrderValues?: boolean;\n}) => {\n\tconst {\n\t\tpivotSheet,\n\t\trowsToGroupBy,\n\t\ttimeBin,\n\t\tdateColumn,\n\t\tdateRange,\n\t\tpivotCols,\n\t\tcurrency,\n\t\tsortOptions,\n\t\tcompareTrends,\n\t\tshowDimensionMappingValues,\n\t\tshowBinSortOrderValues\n\t} = props;\n\tconst valueCols = props.valueCols.filter((vc) => vc.type !== 'column') ?? [];\n\tconst newCols = props.valueCols.filter((vc) => vc.type === 'column') ?? [];\n\tlet variableName = generatePushID();\n\tconst pivotDefinitionModel = pivotSheet.definitionModel as Definition;\n\tlet variables: Variable[] = pivotDefinitionModel.variables || [];\n\tconst pivotVariable: Variable | undefined = variables.find((v) => v.transforms[0].type === 'MetricSeries');\n\tconst filterVariable: Variable | undefined = variables.find(\n\t\t(v) =>\n\t\t\tv.transforms[0].type === 'RuleFilter' && (v.transforms[0] as RuleFilter).rule === '${' + `rule_pivot` + '}'\n\t);\n\n\tif (pivotVariable) {\n\t\tvariableName = pivotVariable.name;\n\t}\n\tconst parentTableVariable = pivotSheet.customModel?.variable;\n\n\tif (!_.isEmpty(valueCols)) {\n\t\tconst rowGroups = _.filter(rowsToGroupBy[0], (r) => !pivotCols.includes(r));\n\t\tconst variableObject = buildVariable('metric', {\n\t\t\tname: variableName,\n\t\t\ttable: filterVariable?.name,\n\t\t\tproperties: {\n\t\t\t\tvalueCols,\n\t\t\t\trowGroups,\n\t\t\t\tcustomCalculation: newCols\n\t\t\t}\n\t\t});\n\n\t\tif (pivotVariable) {\n\t\t\tvariables = variables.map((v) => {\n\t\t\t\tif (v.transforms[0].type === 'MetricSeries') {\n\t\t\t\t\treturn variableObject;\n\t\t\t\t}\n\t\t\t\treturn v;\n\t\t\t});\n\t\t} else {\n\t\t\tvariables = [\n\t\t\t\t...variables.filter((vr: Variable) => vr.transforms[0].type !== 'Metric'),\n\t\t\t\tvariableObject\n\t\t\t];\n\t\t}\n\n\t\tconst ruleFilterVariable = _.find(variables, (v) => v.name.startsWith('rule_filter_'));\n\t\t// Search for Workbook Sort Variable\n\t\tlet { variable: workbookSortVariable, index: workbookSortVariableIndex } = findVariable(\n\t\t\tvariables,\n\t\t\truleFilterVariable?.name || '',\n\t\t\t'Sort'\n\t\t);\n\n\t\tif (workbookSortVariable) {\n\t\t\tif (workbookSortVariableIndex !== -1) {\n\t\t\t\tconst sortTransformTable = (workbookSortVariable.transforms[0] as Sort).table;\n\t\t\t\tvariables = variables.map((v) => {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tif (v.transforms[0]?.table === workbookSortVariable.name) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...v,\n\t\t\t\t\t\t\ttransforms: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...v.transforms[0],\n\t\t\t\t\t\t\t\t\ttable: sortTransformTable\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn v;\n\t\t\t\t});\n\t\t\t\tvariables.splice(workbookSortVariableIndex, 1);\n\t\t\t}\n\t\t}\n\t\t// Search for Metric Sort Variable\n\t\tlet { variable: sortVariable, index: sortVariableIndex } = findVariable(\n\t\t\tvariables,\n\t\t\tpivotSheet.customModel?.variable || '',\n\t\t\t'Sort',\n\t\t\t(variable) => variable.name.startsWith('rule_filter_') // Terminate search when rule_filter variable is reached to prevent matching the Workbook Sort variable\n\t\t);\n\n\t\tlet inputsArray: any[] = [];\n\t\tlet inputsCompareTrendsIndices: Array<{ id: string; index: number }> = [];\n\t\tconst projectAsInput = _.reduce(\n\t\t\tprops.valueCols,\n\t\t\t(acc, curr) => {\n\t\t\t\tif (curr.showAs && curr.showAs !== ShowAsEnum.DEFAULT && curr.label) {\n\t\t\t\t\tconst mappedValue = ShowAsToProjectFractionMapper[curr.showAs];\n\t\t\t\t\tif (mappedValue) {\n\t\t\t\t\t\tacc[curr.label] = mappedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record<string, ProjectFractionEnum>\n\t\t);\n\n\t\tif (!_.isEmpty(pivotCols)) {\n\t\t\tconst pc = timeBin ? [dateColumn, ...pivotCols] : pivotCols;\n\n\t\t\tpc?.forEach((col, index) => {\n\t\t\t\tconst groupByInput = rowsToGroupBy[index];\n\t\t\t\tconst columnGroupByInput = _.filter(groupByInput, (r) => pc.includes(r));\n\t\t\t\tconst rowGroupByInput = _.filter(groupByInput, (r) => !pc.includes(r));\n\n\t\t\t\tinputsArray.push({\n\t\t\t\t\t...pivotSheet.customModel?.inputs,\n\t\t\t\t\t// valueColsInput: aggregates,\n\t\t\t\t\tdate_range: { ...dateRange },\n\t\t\t\t\tgroupByInput: rowsToGroupBy[index],\n\t\t\t\t\tcolumnGroupByInput,\n\t\t\t\t\trowGroupByInput,\n\t\t\t\t\tdateColumnInput: dateColumn,\n\t\t\t\t\tbinByInput: timeBin,\n\t\t\t\t\tto_currency: currency,\n\t\t\t\t\tprojectAsInput,\n\t\t\t\t\tshowDimensionMappingValues,\n\t\t\t\t\tshowBinSortOrderValues\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\tif (compareTrends && compareTrends.length > 0) {\n\t\t\t\tinputsArray = _.map(compareTrends, (ct, index) => {\n\t\t\t\t\tinputsCompareTrendsIndices.push({ id: ct.id, index });\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...pivotSheet.customModel?.inputs,\n\t\t\t\t\t\t// valueColsInput: aggregates,\n\t\t\t\t\t\tdate_range: { ...ct.dateRange },\n\t\t\t\t\t\tgroupByInput: rowsToGroupBy[0],\n\t\t\t\t\t\trowGroupByInput: rowsToGroupBy[0],\n\t\t\t\t\t\tcolumnGroupByInput: [],\n\t\t\t\t\t\tdateColumnInput: dateColumn,\n\t\t\t\t\t\tbinByInput: timeBin,\n\t\t\t\t\t\tto_currency: currency,\n\t\t\t\t\t\tprojectAsInput,\n\t\t\t\t\t\tshowDimensionMappingValues,\n\t\t\t\t\t\tshowBinSortOrderValues\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tinputsArray = [\n\t\t\t\t\t{\n\t\t\t\t\t\t...pivotSheet.customModel?.inputs,\n\t\t\t\t\t\t// valueColsInput: aggregates,\n\t\t\t\t\t\tdate_range: { ...dateRange },\n\t\t\t\t\t\tgroupByInput: rowsToGroupBy[0],\n\t\t\t\t\t\trowGroupByInput: rowsToGroupBy[0],\n\t\t\t\t\t\tcolumnGroupByInput: [],\n\t\t\t\t\t\tdateColumnInput: dateColumn,\n\t\t\t\t\t\tbinByInput: timeBin,\n\t\t\t\t\t\tto_currency: currency,\n\t\t\t\t\t\tprojectAsInput,\n\t\t\t\t\t\tshowDimensionMappingValues,\n\t\t\t\t\t\tshowBinSortOrderValues\n\t\t\t\t\t}\n\t\t\t\t];\n\t\t\t}\n\t\t}\n\t\tconst newColAliases = _.reduce(\n\t\t\tnewCols,\n\t\t\t(acc, curr) => {\n\t\t\t\tif (curr.label) {\n\t\t\t\t\tacc[curr.label] = curr.col;\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record<string, string>\n\t\t);\n\n\t\tif (sortOptions?.sortByField) {\n\t\t\tconst allSortVariables = _.filter(variables, (v) => v.transforms[0].type === 'Sort');\n\t\t\tconst metricSortVariables = _.filter(allSortVariables, (v) => {\n\t\t\t\t//@ts-ignore\n\t\t\t\treturn findParentIsMetricSeries(v.transforms[0].table, variables);\n\t\t\t});\n\t\t\t// remove the metricSortVariables from variables\n\t\t\tvariables = _.filter(variables, (v) => !metricSortVariables.includes(v));\n\n\t\t\tconst sortVariableName = generatePushID();\n\t\t\tconst sortPivotFilterRule = {\n\t\t\t\trule_type: 'or_cond',\n\t\t\t\trules: [\n\t\t\t\t\t{\n\t\t\t\t\t\trule_type: 'or_cond',\n\t\t\t\t\t\trules: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcol: dateColumn,\n\t\t\t\t\t\t\t\tvalue: sortOptions.pivotFilters ?? [],\n\t\t\t\t\t\t\t\toperator: 'in_op',\n\t\t\t\t\t\t\t\trule_type: 'cond',\n\t\t\t\t\t\t\t\tis_not: false,\n\t\t\t\t\t\t\t\tis_case_sensitive: true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\tis_not: false\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t};\n\t\t\tconst sortPivotInputs = _.isEmpty(timeBin)\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tpivot_filters: [sortPivotFilterRule as FilterRule],\n\t\t\t\t\t\tpivot_columns: [...rowGroups, ...pivotCols],\n\t\t\t\t\t\tpivot_groups: { [`${dateColumn}_group`]: showBinSortOrderValues ? 'DESC' : 'ASC' }\n\t\t\t\t\t};\n\n\t\t\tinputsArray = inputsArray.map((i) => {\n\t\t\t\tconst newInputs = { ...i };\n\t\t\t\tObject.keys(newInputs).forEach((key) => {\n\t\t\t\t\tif (key.startsWith('sortPivotInputs_')) {\n\t\t\t\t\t\tdelete newInputs[key];\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn newInputs;\n\t\t\t});\n\n\t\t\tsortVariable = buildVariable('sort', {\n\t\t\t\tname: sortVariableName,\n\t\t\t\ttable: variableName,\n\t\t\t\tproperties: {\n\t\t\t\t\tcol: [sortOptions.sortByField.label],\n\t\t\t\t\tasc: [sortOptions.sortByOrder === 'asc'],\n\t\t\t\t\tpivot_inputs: sortPivotInputs ? `\\${sortPivotInputs_${sortVariableName}}` : undefined\n\t\t\t\t}\n\t\t\t});\n\t\t\tvariableName = sortVariableName;\n\t\t\tvariables = [...variables, sortVariable];\n\n\t\t\tif (inputsArray?.length > 0) {\n\t\t\t\tinputsArray = inputsArray.map((i) => ({\n\t\t\t\t\t...i,\n\t\t\t\t\t[`sortPivotInputs_${sortVariableName}`]: sortPivotInputs\n\t\t\t\t}));\n\t\t\t}\n\t\t} else if (sortOptions?.sortByField === undefined && sortVariable) {\n\t\t\tconst sortVariableIndex = variables.findIndex((v) => v === sortVariable);\n\t\t\tif (sortVariableIndex !== -1) {\n\t\t\t\tconst sortTransformTable = (sortVariable.transforms[0] as Sort).table;\n\t\t\t\tvariables = variables.map((v) => {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tif (v.transforms[0]?.table === sortVariable.name) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...v,\n\t\t\t\t\t\t\ttransforms: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...v.transforms[0],\n\t\t\t\t\t\t\t\t\ttable: sortTransformTable\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn v;\n\t\t\t\t});\n\t\t\t\tvariables.splice(sortVariableIndex, 1);\n\t\t\t}\n\n\t\t\tif (inputsArray?.length > 0) {\n\t\t\t\tinputsArray = inputsArray.map((i) => {\n\t\t\t\t\tconst newInputs = { ...i };\n\t\t\t\t\tObject.keys(newInputs).forEach((key) => {\n\t\t\t\t\t\tif (key.startsWith('sortPivotInputs_')) {\n\t\t\t\t\t\t\tdelete newInputs[key];\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\treturn newInputs;\n\t\t\t\t});\n\t\t\t}\n\t\t\tvariables = variables.filter((v) => v.transforms[0]?.type !== 'Sort');\n\t\t}\n\n\t\tconst definitionModel = {\n\t\t\t...pivotDefinitionModel,\n\t\t\taliases: {\n\t\t\t\t...pivotDefinitionModel.aliases,\n\t\t\t\t[variableName]: { \n\t\t\t\t\t...(pivotDefinitionModel.aliases && parentTableVariable ? pivotDefinitionModel.aliases[parentTableVariable] : {}), \n\t\t\t\t\t...newColAliases \n\t\t\t\t}\n\t\t\t},\n\t\t\tvariables: [...variables]\n\t\t} as Definition;\n\n\t\treturn { inputs: inputsArray, definitionModel, variableName, inputsCompareTrendsIndices };\n\t}\n\treturn {\n\t\tinputs: pivotSheet.customModel?.inputs || [],\n\t\tdefinitionModel: pivotDefinitionModel,\n\t\tvariableName\n\t};\n};\n\nexport const getFilterSelectOptionsMap = (fSO: FilterSelectOptionsType[]) =>\n\tfSO.reduce(\n\t\t(acc, curr) => {\n\t\t\tif (curr.value) {\n\t\t\t\tacc[curr.value] = curr;\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as { [filterId: string]: FilterSelectOptionsType }\n\t);\n\nexport const getDrilldownFiltersMap = (props: {\n\tfiltersToBeApplied: Array<{field: string; key: string | number; type?: string; startDate?: string; endDate?: string; operator?: string}>;\n\tcolumnSelectOptions: SelectOptionType[];\n}) => {\n\tconst { filtersToBeApplied, columnSelectOptions } = props;\n\n\tlet filterMap: { [id: string]: FilterSelectOptionsType } = {};\n\n\tconst filterGroup = _.groupBy(filtersToBeApplied, 'field');\n\n\t_.forEach(filterGroup, (fg) => {\n\t\tlet uniqueValues: FilterUniqueValueSelectOptionsType[] = [];\n\t\tconst col = columnSelectOptions?.find(\n\t\t\t(c: SelectOptionType) =>\n\t\t\t\tc.value === fg[0].field || c.value === `${fg[0].field}_group` || c.label === fg[0].field\n\t\t);\n\t\tlet ruleType: RuleType = 'cond';\n\t\t_.forEach(\n\t\t\tfg,\n\t\t\t(ftba: {\n\t\t\t\tfield: string;\n\t\t\t\tkey: string | number;\n\t\t\t\ttype?: string;\n\t\t\t\tstartDate?: string;\n\t\t\t\tendDate?: string;\n\t\t\t\toperator?: string;\n\t\t\t}) => {\n\t\t\t\tif (ftba.operator) {\n\t\t\t\t\tlet uniqueValuesForNegationOperator, uniqueValuesForOperator;\n\t\t\t\t\tif (ftba.operator.includes('not')) {\n\t\t\t\t\t\tuniqueValuesForNegationOperator = getValuesForSpecialOperators(ftba.operator);\n\t\t\t\t\t\tuniqueValuesForOperator = [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: col?.label,\n\t\t\t\t\t\t\t\tvalue: col?.value,\n\t\t\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\t\t\tuniqueValue: ftba.key,\n\t\t\t\t\t\t\t\t\truleType: 'cond',\n\t\t\t\t\t\t\t\t\toperator: uniqueValuesForNegationOperator.operator,\n\t\t\t\t\t\t\t\t\tisNot: uniqueValuesForNegationOperator.isNot\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t] as FilterUniqueValueSelectOptionsType[];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tuniqueValuesForOperator = [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: col?.label,\n\t\t\t\t\t\t\t\tvalue: col?.value,\n\t\t\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\t\t\tuniqueValue: ftba.key,\n\t\t\t\t\t\t\t\t\truleType: 'cond',\n\t\t\t\t\t\t\t\t\toperator: ftba.operator\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t] as FilterUniqueValueSelectOptionsType[];\n\t\t\t\t\t}\n\t\t\t\t\tuniqueValues.push(...uniqueValuesForOperator);\n\t\t\t\t\truleType = 'and_cond';\n\t\t\t\t} else if (ftba.type === 'date') {\n\t\t\t\t\tconst uniqueValuesForDate = [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: col?.label,\n\t\t\t\t\t\t\tvalue: col?.value?.replace('_group', ''),\n\t\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\t\tuniqueValue: ftba.startDate,\n\t\t\t\t\t\t\t\truleType: 'cond',\n\t\t\t\t\t\t\t\toperator: 'greater_equal'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: col?.label,\n\t\t\t\t\t\t\tvalue: col?.value?.replace('_group', ''),\n\t\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\t\tuniqueValue: ftba.endDate,\n\t\t\t\t\t\t\t\truleType: 'cond',\n\t\t\t\t\t\t\t\toperator: 'less_equal'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t] as FilterUniqueValueSelectOptionsType[];\n\t\t\t\t\tuniqueValues.push(...uniqueValuesForDate);\n\t\t\t\t\truleType = 'or_cond';\n\t\t\t\t} else {\n\t\t\t\t\t// build uniquevalues for filter variable\n\t\t\t\t\tconst uniqueValuesForSelection = [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: col?.label || '',\n\t\t\t\t\t\t\tvalue: col?.value,\n\t\t\t\t\t\t\toption: { uniqueValue: ftba.key, ruleType: 'cond', operator: 'equal' }\n\t\t\t\t\t\t}\n\t\t\t\t\t] as FilterUniqueValueSelectOptionsType[];\n\n\t\t\t\t\tuniqueValues.push(...uniqueValuesForSelection);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\tconst fiterSelectOption: FilterSelectOptionsType = {\n\t\t\tlabel: col?.label || '',\n\t\t\tvalue: col?.value,\n\t\t\toption: {\n\t\t\t\tuniqueValues,\n\t\t\t\truleType: ruleType,\n\t\t\t\tuniqueValueCount: col?.option.uniqueCount,\n\t\t\t\ttype: col?.option.type\n\t\t\t}\n\t\t};\n\n\t\tfilterMap = {\n\t\t\t...filterMap,\n\t\t\t[col?.value]: fiterSelectOption\n\t\t};\n\t});\n\n\treturn filterMap;\n};\n\nexport const getFilterRulesFromMap = (filterMap: {\n\t[filterId: string]: FilterSelectOptionsType;\n}) => {\n\tlet filterSelectOption = [];\n\n\tfor (const pf of Object.values(filterMap)) {\n\t\tfilterSelectOption.push(pf);\n\t}\n\n\treturn getSelectOptionTypeToFilter({\n\t\tdefaultType: 'and_cond',\n\t\trules: filterSelectOption\n\t});\n};\n\nexport const getFiltersToBeAppliedOnDrilldown = (props: {\n\trowGroups: string[];\n\tgroupKeys: string[];\n}) => {\n\tconst { rowGroups, groupKeys } = props;\n\tconst filtersToBeApplied: { field: string; key: string }[] = [];\n\tgroupKeys?.forEach((key, index) => filtersToBeApplied.push({ field: rowGroups[index], key }));\n\treturn filtersToBeApplied;\n};\n\nexport const getMetricFilterRule = (inputs: Inputs | Inputs[]) => {\n\tconst isInputsArray = Array.isArray(inputs);\n\tconst input = isInputsArray ? inputs[0] : inputs;\n\treturn input?.['rule_pivot'] ?? defaultFilterRule;\n};\n\nexport const getDrilldownModels = (props: {\n\tfiltersToBeApplied: { field: string; key: string }[];\n\tsheetDefinitionModel: Definition;\n\tsheetInputs: Inputs;\n\tsheetVariableName: string;\n\tcolumnSelectOptions: SelectOptionType[];\n}) => {\n\tconst {\n\t\tfiltersToBeApplied,\n\t\tsheetDefinitionModel,\n\t\tsheetInputs,\n\t\tsheetVariableName,\n\t\tcolumnSelectOptions\n\t} = props;\n\tlet variables = sheetDefinitionModel.variables;\n\n\tconst metricFilterRule: FilterRule = getMetricFilterRule(sheetInputs);\n\tconst metricFilterRuleSelectOptions = filterToSelectOptionType(\n\t\tmetricFilterRule,\n\t\tcolumnSelectOptions\n\t);\n\n\tconst drilldownFilterMap = getDrilldownFiltersMap({ filtersToBeApplied, columnSelectOptions });\n\n\tconst mergedRule = _.unionBy(\n\t\tObject.values(drilldownFilterMap),\n\t\tmetricFilterRuleSelectOptions.rules,\n\t\t'value'\n\t);\n\n\tconst filterRule: FilterRule = getSelectOptionTypeToFilter({\n\t\tdefaultType: 'and_cond',\n\t\trules: mergedRule\n\t});\n\n\t// current sheet inputs\n\n\tlet inputs = sheetInputs.map((sI: Inputs) => {\n\t\tconst rowGroupByInput = _.filter(sI.rowGroupByInput, (r) => sI.groupByInput.includes(r));\n\t\tconst columnGroupByInput = _.filter(sI.columnGroupByInput, (r) => sI.groupByInput.includes(r));\n\t\treturn { ...sI, ['rule_pivot']: filterRule, rowGroupByInput, columnGroupByInput };\n\t});\n\n\tconst definitionModel = { ...sheetDefinitionModel, variables };\n\n\treturn {\n\t\tdrilldownTableDefinitionModel: definitionModel,\n\t\tdrilldownTableVariableName: sheetVariableName,\n\t\tdrilldownTableInputs: inputs\n\t};\n};\n\nexport const getAmChartGroup = (props: { drilldownLevel: string[]; clickedColumn: string }) => {\n\tconst { clickedColumn, drilldownLevel } = props;\n\tlet group: string[] = [];\n\n\tconst clickedColumnIndex = drilldownLevel.indexOf(clickedColumn);\n\tgroup = drilldownLevel.slice(clickedColumnIndex + 1);\n\n\treturn group;\n};\n\nexport const getDataForDrilldown = async (props: {\n\tdrilldownFiltersToBeAppliedOnChart: { field: string; key: string }[];\n\tsheetDefinitionModel: Definition;\n\tsheetInputs: Inputs;\n\tsheetVariableName: string;\n\tcolumnSelectOptions: SelectOptionType[];\n}) => {\n\tconst {\n\t\tdrilldownFiltersToBeAppliedOnChart,\n\t\tsheetDefinitionModel,\n\t\tsheetInputs,\n\t\tsheetVariableName,\n\t\tcolumnSelectOptions\n\t} = props;\n\tlet { drilldownTableDefinitionModel, drilldownTableVariableName, drilldownTableInputs } =\n\t\tgetDrilldownModels({\n\t\t\tfiltersToBeApplied: drilldownFiltersToBeAppliedOnChart,\n\t\t\tsheetDefinitionModel: sheetDefinitionModel,\n\t\t\tsheetInputs: sheetInputs,\n\t\t\tsheetVariableName: sheetVariableName,\n\t\t\tcolumnSelectOptions: columnSelectOptions\n\t\t});\n\n\tdrilldownTableInputs = Array.isArray(drilldownTableInputs)\n\t\t? drilldownTableInputs[0]\n\t\t: drilldownTableInputs;\n\n\ttry {\n\t\tconst data = (\n\t\t\tawait runDefinitionApi(\n\t\t\t\tdrilldownTableInputs,\n\t\t\t\tdrilldownTableDefinitionModel,\n\t\t\t\tdrilldownTableVariableName\n\t\t\t)\n\t\t).data;\n\n\t\treturn data;\n\t} catch (error) {\n\t\tthrow error;\n\t}\n};\n\nexport const updateWorksheetAndMetricFilterMapForDrilldown = (props: {\n\tsheetInputs: Inputs;\n\tfilterVariable: Variable[];\n\tcolumnSelectOptions: SelectOptionType[];\n}) => {\n\tconst { sheetInputs, filterVariable, columnSelectOptions } = props;\n\n\tlet worksheetFilterMap = {};\n\tlet metricFilterMap = {};\n\n\tfilterVariable.forEach((fv: Variable) => {\n\t\tconst transform = fv.transforms[0] as RuleFilter;\n\t\tconst tRule = getInputName(transform.rule as string);\n\t\tconst sheetFilterRule: FilterRule = sheetInputs[tRule];\n\t\tconst sheetFilterSelectOption = filterToSelectOptionType(sheetFilterRule, columnSelectOptions);\n\t\tif (tRule.includes('worksheet')) {\n\t\t\tworksheetFilterMap = getFilterSelectOptionsMap(sheetFilterSelectOption?.rules);\n\t\t} else {\n\t\t\tmetricFilterMap = getFilterSelectOptionsMap(sheetFilterSelectOption?.rules);\n\t\t}\n\t});\n\n\treturn { ...worksheetFilterMap, ...metricFilterMap };\n};\n\nexport const getTableDrilldownModels = (props: {\n\tfiltersToBeApplied: { field: string; key: string | number }[];\n\tsheetDefinitionModel: Definition;\n\tsheetInputs: Inputs;\n\tcolumnSelectOptions: SelectOptionType[];\n\tincludesValueCols?: boolean;\n}) => {\n\tconst { filtersToBeApplied, sheetDefinitionModel, sheetInputs, columnSelectOptions } = props;\n\n\t// remove metric series variable from from definition model\n\tlet variables = [...(sheetDefinitionModel.variables || [])];\n\tvariables = variables.filter((variable: Variable) => {\n\t\treturn variable?.transforms?.[0]?.type !== 'MetricSeries';\n\t});\n\n\t// update parent table name in filter variable if exists\n\t// create a drill down filter variable\n\n\tlet filterVariable = variables.filter((variable: Variable) => {\n\t\treturn variable?.transforms?.[0]?.type === 'RuleFilter';\n\t});\n\n\tconst drilldownVariable = variables.find((v: Variable) => {\n\t\tconst transform = v.transforms?.[0];\n\t\tif (\n\t\t\ttransform?.type === 'RuleFilter' &&\n\t\t\ttypeof (transform as RuleFilter)?.rule === 'string' &&\n\t\t\t((transform as RuleFilter)?.rule as string)?.includes('rule_drillDown')\n\t\t) {\n\t\t\treturn v;\n\t\t}\n\t});\n\n\t// updateWorksheetAndMetricFilterMapForDrilldown(currentSheetInputs, filterVariable);\n\tconst variableName = drilldownVariable ? drilldownVariable.name : generatePushID();\n\tconst tTableName = filterVariable[filterVariable.length - 1]?.name;\n\tconst inputRuleVariable = `rule_drillDown`;\n\n\tconst drilldownFiltersMap = getDrilldownFiltersMap({ filtersToBeApplied, columnSelectOptions });\n\n\tconst drillDownFilterRule = getFilterRulesFromMap(drilldownFiltersMap);\n\n\t// current sheet inputs\n\tlet inputs = { ...sheetInputs, [inputRuleVariable]: drillDownFilterRule };\n\n\tif (!drilldownVariable) {\n\t\tconst drillDownFilterVariableObject = {\n\t\t\tname: variableName,\n\t\t\ttransforms: [\n\t\t\t\t{\n\t\t\t\t\ttable: tTableName,\n\t\t\t\t\ttype: 'RuleFilter',\n\t\t\t\t\trule: '${' + inputRuleVariable + '}'\n\t\t\t\t}\n\t\t\t]\n\t\t};\n\t\tvariables = [...variables, drillDownFilterVariableObject];\n\t}\n\tconst definitionModel = { ...sheetDefinitionModel, variables };\n\n\treturn {\n\t\tdrilldownTableDefinitionModel: definitionModel,\n\t\tdrilldownTableVariableName: variableName,\n\t\tdrilldownTableInputs: inputs\n\t};\n};\n\nexport const getValueGroupsSelectOptions = (props: {\n\tvalueCols: ValueColsType[];\n\taliases: { [key: string]: string };\n}) => {\n\tconst { valueCols, aliases } = props;\n\tconst getLabel = (name: string) => _.findKey(aliases, (o: string) => o === name);\n\tconst getFormulaAggregateFn = (formula: string) => {\n\t\treturn formula.substring(0, formula.indexOf('('));\n\t};\n\n\tconst getFormulaValue = (formula: string) =>\n\t\tformula.substring(formula.indexOf('(') + 1, formula.lastIndexOf(')'));\n\n\tconst valGroups =\n\t\tvalueCols?.map((valueCol) => {\n\t\t\tif (valueCol?.formula) {\n\t\t\t\tconst aggFun =\n\t\t\t\t\tvalueCol?.type && valueCol.type !== 'formula'\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: getFormulaAggregateFn(valueCol.formula);\n\t\t\t\treturn {\n\t\t\t\t\tlabel: valueCol.col,\n\t\t\t\t\tvalue: valueCol.col,\n\t\t\t\t\toption: {\n\t\t\t\t\t\tformulaMode: true,\n\t\t\t\t\t\taggFun,\n\t\t\t\t\t\tformula: getFormulaValue(valueCol.formula),\n\t\t\t\t\t\tfieldLabel: valueCol.col,\n\t\t\t\t\t\timpact: valueCol?.impact ?? 'positive',\n\t\t\t\t\t\ttype: valueCol?.type ?? 'formula',\n\t\t\t\t\t\tcurrency: valueCol?.currency,\n\t\t\t\t\t\tprecision: valueCol?.precision,\n\t\t\t\t\t\tisCurrency: valueCol?.isCurrency,\n\t\t\t\t\t\tisPercentage: valueCol?.isPercentage,\n\t\t\t\t\t\tisNumber: valueCol?.isNumber,\n\t\t\t\t\t\tshowAs: valueCol?.showAs ?? 'default',\n\t\t\t\t\t\tisAmortize: valueCol?.isAmortize ?? false,\n\t\t\t\t\t\tisHidden: valueCol?.hide ?? false,\n\t\t\t\t\t\thideGrandTotal: valueCol?.hideGrandTotal ?? false,\n\t\t\t\t\t\tshowRowTotal: valueCol?.showRowTotal ?? false,\n\t\t\t\t\t\tchartColorBasedOnImpact: valueCol?.chartColorBasedOnImpact ?? false,\n\t\t\t\t\t\tcompactNotation: valueCol?.compactNotation\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tlabel: valueCol.label,\n\t\t\t\tvalue: valueCol.col,\n\t\t\t\toption: {\n\t\t\t\t\tformulaMode: false,\n\t\t\t\t\taggFun: valueCol.aggFun,\n\t\t\t\t\tfieldLabel: getLabel(valueCol.col) ?? valueCol.col,\n\t\t\t\t\timpact: valueCol?.impact ?? 'positive',\n\t\t\t\t\ttype: 'value' as ValueColsType['type'],\n\t\t\t\t\tcurrency: valueCol?.currency,\n\t\t\t\t\tprecision: valueCol?.precision,\n\t\t\t\t\tisCurrency: valueCol?.isCurrency,\n\t\t\t\t\tisPercentage: valueCol?.isPercentage,\n\t\t\t\t\tisNumber: valueCol?.isNumber,\n\t\t\t\t\tshowAs: valueCol?.showAs ?? 'default',\n\t\t\t\t\tisHidden: valueCol?.hide ?? false,\n\t\t\t\t\thideGrandTotal: valueCol?.hideGrandTotal ?? false,\n\t\t\t\t\tshowRowTotal: valueCol?.showRowTotal ?? false,\n\t\t\t\t\tchartColorBasedOnImpact: valueCol?.chartColorBasedOnImpact ?? false,\n\t\t\t\t\tcompactNotation: valueCol?.compactNotation\n\t\t\t\t}\n\t\t\t};\n\t\t}) ?? [];\n\treturn valGroups;\n};\n\nexport const getRowGroupsSelectOptions = (props: {\n\trowGroups: Array<string | string[]>;\n\tcolumns: SelectOptionType[];\n}) => {\n\tconst { rowGroups, columns } = props;\n\tlet rowGroupsSelectOptions: any[] = [];\n\trowGroups?.forEach((rgc: string | string[]) => {\n\t\tif (typeof rgc === 'string') {\n\t\t\tconst col = columns?.find((col) => col.value === rgc);\n\t\t\trowGroupsSelectOptions = [...rowGroupsSelectOptions, col];\n\t\t} else {\n\t\t\tconst rowLabel = rgc?.[0];\n\t\t\tconst rowField = rgc?.[1]?.split('(')?.[1]?.split(',')?.[0]?.replace(/'/g, '');\n\t\t\tconst col = columns?.find((col) => col.value === rowField);\n\t\t\tconst updatedCol = {\n\t\t\t\t...col,\n\t\t\t\tlabel: rowLabel,\n\t\t\t\toption: { ...col?.option, rowType: 'hierarchy' }\n\t\t\t};\n\n\t\t\trowGroupsSelectOptions = [...rowGroupsSelectOptions, { ...updatedCol }];\n\t\t}\n\t});\n\treturn rowGroupsSelectOptions;\n};\n\nexport const getColumnGroupsSelectOptions = (props: {\n\tcolumnGroups: string[];\n\tcolumns: SelectOptionType[];\n}) => {\n\tconst { columnGroups, columns } = props;\n\tlet columnGroupsSelectOptions: any[] = [];\n\tcolumnGroups?.forEach((rgc: string) => {\n\t\tconst col = columns?.find((col) => col.value === rgc);\n\t\tcolumnGroupsSelectOptions = [...columnGroupsSelectOptions, col];\n\t});\n\treturn columnGroupsSelectOptions;\n};\n\nexport const removeDateColumnFromColRowGroupIfTrend = (props: {\n\ttimeBin: TimeBin | '';\n\tpivotCols: string[];\n\trowGroupCols: string[];\n\tdateColumn: string;\n}) => {\n\tconst { timeBin, pivotCols, rowGroupCols, dateColumn } = props;\n\tif (timeBin) {\n\t\tconst dateColumnIndex = pivotCols.indexOf(dateColumn);\n\t\tif (dateColumnIndex > -1) {\n\t\t\tpivotCols.splice(dateColumnIndex, 1);\n\t\t}\n\t\tconst dateColumnIndex2 = rowGroupCols.indexOf(dateColumn);\n\t\tif (dateColumnIndex2 > -1) {\n\t\t\trowGroupCols.splice(dateColumnIndex2, 1);\n\t\t}\n\t}\n\treturn { pivotCols, rowGroupCols };\n};\n\nexport const getNewMetricSheet = async (props: {\n\tdatasetList: DatasetImportMetadata[];\n\tsheetName: string;\n\tobjectId: string;\n\timportType: any;\n\tdateRange?: any;\n\tparentId?: string;\n}) => {\n\tconst { objectId, sheetName, datasetList, dateRange } = props;\n\t//get dataset from store\n\tconst dataset = datasetList.find(\n\t\t(ds: DatasetImportMetadata) => ds.id === objectId\n\t);\n\n\tif (!dataset) {\n\t\tthrow new Error(`Dataset with id ${objectId} not found`);\n\t}\n\n\tconst datasetName: string = dataset.name || '';\n\tconst datasetId: string = dataset.id || '';\n\n\tconst datasetDateColumn: string = dataset?.dateColumn ?? '';\n\tconst importModel: Import[] = [\n\t\t{\n\t\t\tloc: objectId,\n\t\t\tto: datasetName,\n\t\t\timport_type: 'dataset'\n\t\t}\n\t];\n\n\tif (dataset.datasetType === 'TRANSACTION') {\n\t\timportModel[0].date_column_filter = '${date_range}';\n\t}\n\n\tconst sheetId = generatePushID();\n\tconst inputRuleVariable = `rule_worksheet_${sheetId}`;\n\tconst metricFilterVariableName = generatePushID();\n\tconst metricVariableName = generatePushID();\n\n\tconst variableModel: Variable[] = [\n\t\t{\n\t\t\tname: sheetId,\n\t\t\ttransforms: [\n\t\t\t\t{\n\t\t\t\t\ttable: dataset.name,\n\t\t\t\t\ttype: 'RuleFilter',\n\t\t\t\t\trule: '${' + inputRuleVariable + '}'\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\tname: metricFilterVariableName,\n\t\t\ttransforms: [\n\t\t\t\t{\n\t\t\t\t\ttable: sheetId,\n\t\t\t\t\ttype: 'RuleFilter',\n\t\t\t\t\trule: '${rule_pivot}'\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\tname: metricVariableName,\n\t\t\ttransforms: [\n\t\t\t\t//@ts-ignore\n\t\t\t\t{\n\t\t\t\t\ttable: metricFilterVariableName,\n\t\t\t\t\taggregates: [],\n\t\t\t\t\tgroup_by: '${groupByInput}',\n\t\t\t\t\ttype: 'MetricSeries',\n\t\t\t\t\tbin_by: '${binByInput}'\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t];\n\n\t//create the definition model for the sheet in the workbook WITHOUT aliases\n\n\tconst defaultDefinition: Definition = {\n\t\timports: [],\n\t\tvariables: [],\n\t\taliases: {},\n\t\tinputs: {}\n\t};\n\n\tlet definitionModel: Definition = {\n\t\t...defaultDefinition,\n\t\timports: importModel,\n\t\tvariables: variableModel,\n\t\taliases: {}\n\t};\n\n\t//run describe(definition, variable)\n\tconst inputs: Inputs = {\n\t\t...defaultDefinition.inputs,\n\t\t[inputRuleVariable]: {\n\t\t\tis_not: false,\n\t\t\trule_type: 'and_cond',\n\t\t\trules: []\n\t\t},\n\t\trule_pivot: {\n\t\t\tis_not: false,\n\t\t\trule_type: 'and_cond',\n\t\t\trules: []\n\t\t},\n\t\tgroupByInput: [],\n\t\tbinByInput: ''\n\t};\n\n\tif (dataset.datasetType === 'TRANSACTION') {\n\t\tinputs.date_range = dateRange;\n\t}\n\n\tconst results = await Promise.all([getFxUdescribeApi(inputs, definitionModel, datasetName)]);\n\tconst tableDescription: DescriptionResult[] = (results[0] as any).data;\n\n\tconst alias = tableDescription.reduce(\n\t\t(acc: { [id: string]: string }, curr: DescriptionResult) => {\n\t\t\tacc[getDisplayName(curr.name)] = curr.name;\n\t\t\treturn acc;\n\t\t},\n\t\t{}\n\t);\n\n\t//update the definition model to have the alises\n\tdefinitionModel = {\n\t\t...definitionModel,\n\t\taliases: {\n\t\t\t[sheetId]: alias,\n\t\t\t[metricFilterVariableName]: alias,\n\t\t\t[metricVariableName]: alias\n\t\t}\n\t};\n\n\tconst columnSettings: ColumnSetting[] = tableDescription.map(\n\t\t(description: DescriptionResult): ColumnSetting => {\n\t\t\tconst descWithCount = description as DescriptionResultWithUniqueCount;\n\t\t\treturn {\n\t\t\t\thide: false,\n\t\t\t\theaderName: getDisplayName(description.name),\n\t\t\t\ttype: description.data_type as \"str\" | \"f64\" | \"i64\" | \"date\" | \"datetime(time_unit='us', time_zone=None)\" | undefined,\n\t\t\t\tfield: description.name,\n\t\t\t\tunique_count: descWithCount.unique_count,\n\t\t\t\tdatasetId: descWithCount.datasetId,\n\t\t\t\tdatasetName: descWithCount.datasetName\n\t\t\t};\n\t\t}\n\t);\n\n\t//then create sheet\n\tconst sheet: Sheet<BlockSheetCustomModel> = {\n\t\tname: sheetName,\n\t\tdefinitionModel,\n\t\tcustomModel: {\n\t\t\tmetadata: {\n\t\t\t\tparentTableVariable: sheetId,\n\t\t\t\tdateRange: dateRange,\n\t\t\t\tinputs: inputs,\n\t\t\t\tcolumnSettings,\n\t\t\t\tdatasetId: datasetId,\n\t\t\t\tdatasetName: datasetName,\n\t\t\t\tvariable: metricVariableName,\n\t\t\t\tdateColumn: datasetDateColumn,\n\t\t\t\tvalueCols: [],\n\t\t\t\trowGroupCols: [],\n\t\t\t\tfilterColumnsBy: {},\n\t\t\t\tfilterModel: [],\n\t\t\t\tpivotCols: [],\n\t\t\t\taliases: definitionModel.aliases ? definitionModel.aliases[metricVariableName] : undefined\n\t\t\t},\n\t\t\tsettings: {\n\t\t\t\tchartType: 'table',\n\t\t\t\tviewMode: 'grid'\n\t\t\t},\n\t\t\t[8]: { x: 0, y: 0, w: 4, h: 6 } // pivotBlockProperties placeholder\n\t\t},\n\t\tcustomFields: {\n\t\t\tvariable: sheetId as any,\n\t\t\tdateColumn: datasetDateColumn as unknown as Object,\n\t\t\tdatasetNames: [datasetName]\n\t\t},\n\t\ttype: 'PIVOT',\n\t\tparentId: props.parentId,\n\t\tparentType: 'DASHBOARD',\n\t\tid: sheetId,\n\t\tworkspaceId: undefined,\n\t\tsources: [{ id: datasetId, componentType: 'DATASET' }]\n\t};\n\n\treturn sheet;\n};\n\nexport const getColumnSettingsToSelectOptions = (columnSettings: ColumnSetting[]) => {\n\treturn _.chain(columnSettings)\n\t\t.filter((c) => !c.field.includes('__bc_') && !c.aggFunc)\n\t\t.map((c: ColumnSetting) => {\n\t\t\treturn {\n\t\t\t\tlabel: c.headerName,\n\t\t\t\tvalue: c.field,\n\t\t\t\toption: {\n\t\t\t\t\ttype: c.type,\n\t\t\t\t\tuniqueCount: c.unique_count,\n\t\t\t\t\tfieldLabel: c.headerName,\n\t\t\t\t\tcurrency: c?.currency,\n\t\t\t\t\tprecision: c?.precision,\n\t\t\t\t\tdateFormat: c?.dateFormat,\n\t\t\t\t\tisCurrency: c?.isCurrency\n\t\t\t\t}\n\t\t\t};\n\t\t})\n\t\t.value();\n};\n\nexport const getDefinitionModelWithUpdatedValueCols = (props: {\n\tdefinition: Definition;\n\tvalueCols: ValueColsType[];\n}) => {\n\tconst { definition } = props;\n\tlet shDef = definition;\n\tlet variableName = shDef?.variables?.[shDef?.variables?.length - 1]?.name;\n\n\tlet variables = shDef?.variables ?? [];\n\tconst tableName = variables?.[variables.length - 1]?.name;\n\tconst id = generatePushID();\n\n\tconst viewVariable: Variable = {\n\t\tname: id,\n\t\ttransforms: [\n\t\t\t{\n\t\t\t\ttype: 'View',\n\t\t\t\ttable: tableName,\n\t\t\t\tcols: '${viewInputs}'\n\t\t\t}\n\t\t]\n\t};\n\n\tvariables = [...variables, viewVariable];\n\tvariableName = id;\n\n\tconst updatedDefinition = { ...shDef, variables };\n\n\treturn { updatedDefinition, variableName };\n};\n\nexport const applyFilter = async (props: {\n\tsheetId: string;\n\tmetadata: MetricMetadataType;\n\tlastModifiedDate: string;\n}) => {\n\tconst { metadata, sheetId, lastModifiedDate } = props;\n\n\tconst parentTableVariable: string = metadata?.parentTableVariable || '';\n\n\tconst inputs = metadata?.inputs;\n\n\tconst variable = metadata?.variable;\n\n\ttry {\n\t\tconst serverResponse = await runPublishedDefinitionApi({\n\t\t\tinputs: { ...inputs },\n\t\t\tsheet: {\n\t\t\t\tid: sheetId,\n\t\t\t\tlastModifiedDate\n\t\t\t},\n\t\t\tvariable,\n\t\t\tdescribe: parentTableVariable\n\t\t});\n\n\t\tconst result: { data: any[]; description: DescriptionResultWithUniqueCount[] } =\n\t\t\tserverResponse.data;\n\n\t\tconst gridData = result.data;\n\n\t\treturn gridData;\n\t} catch (error) {\n\t\tconsole.error(error);\n\t}\n};\n\nexport const defaultFilterRule: FilterRule = {\n\tis_not: false,\n\trule_type: 'and_cond',\n\trules: []\n};\n\nexport const getPromotedFiltersSelectOptionsForLine = (\n\tmetricSheet: Sheet<MetricCustomModel>\n): SelectOptionType[] => {\n\tlet promotedFiltersSelectOptions: any[] = [];\n\n\tconst sheetId = metricSheet?.id;\n\tconst sheetDefinitionModel = metricSheet?.definitionModel;\n\n\tconst metadata = metricSheet?.customModel?.metadata as MetricMetadataType;\n\tif (!_.isEmpty(metadata)) {\n\t\tconst blockColumnSettings = metadata?.columnSettings as ColumnSetting[];\n\n\t\tconst blockSheetDetails: {\n\t\t\tsheetId: string | undefined;\n\t\t\tdefinitionModel: Definition;\n\t\t\tparentTableVariable: string | undefined;\n\t\t\tinputs: Inputs | undefined;\n\t\t} = {\n\t\t\tsheetId,\n\t\t\tdefinitionModel: sheetDefinitionModel as Definition,\n\t\t\tparentTableVariable: metadata?.parentTableVariable,\n\t\t\tinputs: metadata?.inputs\n\t\t};\n\t\tconst blockFilterColumnsBy: FilterColumnsBy = metadata?.filterColumnsBy || {};\n\n\t\t// create promoted fiters select options\n\t\t_.chain(blockColumnSettings)\n\t\t\t.filter((c) => !c.aggFunc && !c.field.includes('__bc_'))\n\t\t\t.forEach((cso: ColumnSetting) => {\n\t\t\t\tpromotedFiltersSelectOptions = [\n\t\t\t\t\t...promotedFiltersSelectOptions,\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: cso.headerName,\n\t\t\t\t\t\tvalue: cso.field,\n\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\tname: cso.headerName,\n\t\t\t\t\t\t\trule: defaultFilterRule,\n\t\t\t\t\t\t\tsheetDetails: blockSheetDetails,\n\t\t\t\t\t\t\tlineId: sheetId,\n\t\t\t\t\t\t\tfilterColumnsBy: blockFilterColumnsBy,\n\t\t\t\t\t\t\tid: cso.field,\n\t\t\t\t\t\t\tdatasetId: cso?.datasetId ?? metadata?.datasetId,\n\t\t\t\t\t\t\tblockColumnSettings: blockColumnSettings,\n\t\t\t\t\t\t\tdatasetName: cso?.datasetName ?? metadata?.datasetName,\n\t\t\t\t\t\t\tuniqueValueCount: cso?.unique_count ?? 1000\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t];\n\t\t\t})\n\t\t\t.value();\n\n\t\treturn promotedFiltersSelectOptions;\n\t} else {\n\t\treturn [];\n\t}\n};\n\nexport const getAllLinesFilterSelectOptions = (metricSheets: Sheet<MetricCustomModel>[]) => {\n\tlet allLinesFilterSelectOptions: SelectOptionType[] = [];\n\tmetricSheets?.forEach((bs: Sheet<MetricCustomModel>) => {\n\t\tconst so: SelectOptionType[] = getPromotedFiltersSelectOptionsForLine(bs);\n\t\tallLinesFilterSelectOptions = _.uniqBy(\n\t\t\t[...allLinesFilterSelectOptions, ...so],\n\t\t\t(v) => `${v.option?.datasetId}_${v.option?.id}`\n\t\t);\n\t});\n\n\treturn _.uniqWith(\n\t\tallLinesFilterSelectOptions,\n\t\t(a, b) => a.option.datasetId === b.option.datasetId && a.value === b.value\n\t);\n};\n\nexport function formatDate(date: any) {\n\tlet month = '' + (date.getMonth() + 1),\n\t\tday = '' + date.getDate(),\n\t\tyear = date.getFullYear();\n\n\tif (month.length < 2) month = '0' + month;\n\tif (day.length < 2) day = '0' + day;\n\n\treturn [year, month, day].join('-');\n}\n\nexport const getQuarterDates = (props: { month: number; year: number }) => {\n\tlet startDate;\n\tlet endDate;\n\n\tlet { month, year } = props;\n\tmonth = month + 1;\n\n\tif (month >= 4 && month <= 6) {\n\t\tstartDate = formatDate(new Date(year, 3, 1));\n\t\tendDate = formatDate(new Date(year, 5, 30));\n\t} else if (month >= 7 && month <= 9) {\n\t\tstartDate = formatDate(new Date(year, 6, 1));\n\t\tendDate = formatDate(new Date(year, 8, 30));\n\t} else if (month >= 10 && month <= 12) {\n\t\tstartDate = formatDate(new Date(year, 9, 1));\n\t\tendDate = formatDate(new Date(year, 11, 31));\n\t} else if (month >= 1 && month <= 3) {\n\t\tstartDate = formatDate(new Date(year - 1, 9, 1));\n\t\tendDate = formatDate(new Date(year, 2, 31));\n\t}\n\n\treturn { startDate, endDate };\n};\n\nexport const getMonthDates = (props: { month: number; year: number }) => {\n\tconst { month, year } = props;\n\tconst startDate = formatDate(new Date(year, month, 1));\n\tconst endDate = formatDate(new Date(year, month + 1, 0));\n\treturn { startDate, endDate };\n};\n\nexport const getYearDates = (props: { year: number }) => {\n\tconst { year } = props;\n\n\tconst startDate = formatDate(new Date(year, 0, 1));\n\tconst endDate = formatDate(new Date(year, 11, 31));\n\treturn { startDate, endDate };\n};\n\nexport const getStartEndDates = (props: { timeBin: TimeBin; date: Date }) => {\n\tconst { timeBin, date } = props;\n\n\tconst month = date.getMonth();\n\tconst year = date.getFullYear();\n\n\tif (timeBin === 'per_month') return getMonthDates({ month, year });\n\tif (timeBin === 'per_quarter') return getQuarterDates({ month, year });\n\tif (timeBin === 'per_year') return getYearDates({ year });\n};\n\nexport const getSheetProperties = (props: {\n\tsheet: Sheet<PivotCustomModel>;\n\tgroupKeys?: string[];\n\ttoolPanelValues?: MetricToolPanelType;\n\tinitialLoad: boolean;\n\tcurrencyValue: string;\n}) => {\n\tconst { sheet, toolPanelValues, groupKeys, initialLoad, currencyValue } = props;\n\tlet pivotCols: string[] = [],\n\t\trowGroupCols: Array<string | string[]> = [],\n\t\tfilterModel: FilterRule | [] = [],\n\t\tvalueCols: ValueColsType[] = [],\n\t\ttimeBin: TimeBin | '' = '',\n\t\tdateRange: DateRange,\n\t\tcurrency: string,\n\t\tshowBinSortOrderValues: boolean,\n\t\tcompareTrends: Array<{\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\tdateRange: DateRange;\n\t\t}>,\n\t\tshowDimensionMappingValues: boolean;\n\tlet gridColumnState: GridColumnState;\n\tlet dateColumn = sheet?.customModel?.dateColumn;\n\tlet sortOptions: SortOptions;\n\n\tif (!initialLoad && toolPanelValues) {\n\t\tpivotCols = toolPanelValues.pivotCols;\n\t\trowGroupCols = toolPanelValues.rowGroupCols;\n\t\tfilterModel = toolPanelValues.filterModel;\n\t\tvalueCols = toolPanelValues.valueCols;\n\t\tsortOptions = toolPanelValues.sortOptions;\n\t\ttimeBin = toolPanelValues.timeBin;\n\t\tdateRange = toolPanelValues.dateRange || { time_period: 'past_quarter' };\n\t\tcurrency = toolPanelValues.currency || currencyValue;\n\t\tcompareTrends = toolPanelValues.compareTrends || [];\n\t\tshowDimensionMappingValues = toolPanelValues.showDimensionMappingValues || false;\n\t\tshowBinSortOrderValues = toolPanelValues.showBinSortOrderValues || false;\n\t\t// get rowGroupCols till index clicked row level\n\t\tgridColumnState = { pivotCols, rowGroupCols, filterModel, valueCols };\n\t\trowGroupCols = rowGroupCols.slice(0, (groupKeys?.length || 0) + 1);\n\t} else {\n\t\tconst cModel = sheet?.customModel;\n\t\tgridColumnState = cModel?.gridColumnState || { pivotCols: [], rowGroupCols: [], filterModel: [], valueCols: [] };\n\t\ttimeBin = cModel?.timeBin ?? '';\n\t\tdateRange = cModel?.dateRange ?? { time_period: 'past_quarter' };\n\t\tcurrency = cModel?.currency ?? currencyValue;\n\t\tif (gridColumnState) {\n\t\t\t({ pivotCols, rowGroupCols, valueCols, filterModel } = gridColumnState);\n\t\t\trowGroupCols = rowGroupCols.slice(0, (groupKeys?.length || 0) + 1);\n\t\t}\n\t\tsortOptions = cModel?.sortOptions || { sortByField: undefined, sortByOrder: 'asc' };\n\t\tcompareTrends = cModel?.compareTrends || [];\n\t\tshowDimensionMappingValues = cModel?.showDimensionMappingValues ?? false;\n\t\tshowBinSortOrderValues = cModel?.showBinSortOrderValues ?? false;\n\t}\n\n\t({ pivotCols, rowGroupCols } = removeDateColumnFromColRowGroupIfTrend({\n\t\ttimeBin,\n\t\tpivotCols,\n\t\trowGroupCols: rowGroupCols as string[],\n\t\tdateColumn: dateColumn || ''\n\t}));\n\n\tpivotCols = pivotCols ?? [];\n\trowGroupCols = rowGroupCols ?? [];\n\tvalueCols = valueCols ?? [];\n\ttimeBin = timeBin ?? '';\n\n\tlet rowsToGroupBy = [];\n\tif (!_.isEmpty(pivotCols)) {\n\t\tif (timeBin) {\n\t\t\trowsToGroupBy.push([...rowGroupCols]);\n\t\t\tfor (let i = 0; i < pivotCols.length; i++) {\n\t\t\t\tconst pcols = pivotCols;\n\t\t\t\trowsToGroupBy.push([...pcols.slice(0, i + 1), ...rowGroupCols]);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (let i = 0; i < pivotCols.length; i++) {\n\t\t\t\tconst pcols = pivotCols;\n\t\t\t\trowsToGroupBy.push([...pcols.slice(0, i + 1), ...rowGroupCols]);\n\t\t\t}\n\t\t}\n\t} else {\n\t\trowsToGroupBy.push([...pivotCols, ...rowGroupCols]);\n\t}\n\n\t// create definition Model for pivot\n\tconst definitionModelAndVariable = getDefinitionModelAndVariableNameForPivot({\n\t\tpivotSheet: sheet,\n\t\trowsToGroupBy: rowsToGroupBy as any, // Type assertion to handle 2D array\n\t\tvalueCols,\n\t\tsortOptions,\n\t\ttimeBin,\n\t\tdateRange,\n\t\tdateColumn: sheet?.customModel?.dateColumn ?? '',\n\t\tpivotCols,\n\t\tcurrency,\n\t\tcompareTrends,\n\t\tshowDimensionMappingValues,\n\t\tshowBinSortOrderValues\n\t});\n\n\tlet definitionModel = definitionModelAndVariable.definitionModel;\n\n\tlet variableName = definitionModelAndVariable.variableName;\n\tlet inputs: Inputs = definitionModelAndVariable.inputs;\n\tconst inputsCompareTrendsIndices = definitionModelAndVariable.inputsCompareTrendsIndices;\n\tif (!initialLoad && _.isEmpty(filterModel)) {\n\t\tinputs = _.map(inputs, (input) => {\n\t\t\treturn {\n\t\t\t\t...input,\n\t\t\t\trule_pivot: defaultFilterRule,\n\t\t\t\tfilterOnAggregates: defaultFilterRule\n\t\t\t};\n\t\t});\n\t}\n\n\tif (!_.isEmpty(filterModel)) {\n\t\tconst aggFilterRule = getAggregateFilterRuleFromCombinedFilterRule(\n\t\t\tfilterModel as FilterRule,\n\t\t\tvalueCols\n\t\t);\n\t\tconst columnFilterRule = getColumnFilterRuleFromCombinedFilterRule(\n\t\t\tfilterModel as FilterRule,\n\t\t\tvalueCols\n\t\t);\n\t\tinputs = _.map(inputs, (input) => {\n\t\t\treturn {\n\t\t\t\t...input,\n\t\t\t\trule_pivot: columnFilterRule,\n\t\t\t\tfilterOnAggregates: aggFilterRule\n\t\t\t};\n\t\t});\n\t}\n\n\treturn { inputs, definitionModel, variableName, gridColumnState, inputsCompareTrendsIndices };\n};\n\nexport const getValueColumnsFromSelectOptions = (selectOptions: SelectOptionType[]) => {\n\treturn selectOptions?.map((col: SelectOptionType) => {\n\t\tlet valueCol = {\n\t\t\tlabel: col.label,\n\t\t\tcol: col.option.formulaMode ? col.label : col.value,\n\t\t\taggFun: col.option.formulaMode ? undefined : col.option.aggFun,\n\t\t\timpact: col.option.impact,\n\t\t\ttype: col.option.type,\n\t\t\tisCurrency: col.option.isCurrency ?? false,\n\t\t\tisPercentage: col?.option?.isPercentage ?? false,\n\t\t\tisNumber: col?.option?.isNumber ?? false,\n\t\t\tshowAs: col?.option?.showAs ?? 'default',\n\t\t\tisAmortize: col?.option?.isAmortize ?? false,\n\t\t\thide: col?.option?.isHidden ?? false,\n\t\t\thideGrandTotal: col?.option?.hideGrandTotal ?? false,\n\t\t\tshowRowTotal: col?.option?.showRowTotal ?? false,\n\t\t\tchartColorBasedOnImpact: col?.option?.chartColorBasedOnImpact,\n\t\t\tcompactNotation: col?.option?.compactNotation,\n\t\t\tprecision: col?.option?.precision\n\t\t};\n\n\t\tif (!col.option.formulaMode) return valueCol;\n\t\tif (!col.option.aggFun) return { ...valueCol, formula: `(${col.option.formula})` };\n\t\treturn { ...valueCol, formula: `${col.option.aggFun}(${col.option.formula})` };\n\t});\n};\n\nexport const defaultDateRange: DateRange = {\n\ttime_period: 'past_quarter'\n};\n\nexport const getPromotedFilterRulesSelectOptions = (promotedFiltersStoreValue: {\n\t[datasetId: string]: { [id: string]: FilterPanelStoreType };\n}) => {\n\tlet promotedFiltersSelectOptions = [];\n\n\tfor (const [datasetId, pf] of Object.entries(promotedFiltersStoreValue ?? {})) {\n\t\tfor (const rule of Object.values(pf)) {\n\t\t\tif (rule.rules[0]) {\n\t\t\t\tconst rules = { ...rule.rules[0], option: { ...rule.rules[0].option, datasetId } };\n\t\t\t\tpromotedFiltersSelectOptions.push(rules);\n\t\t\t}\n\t\t}\n\t}\n\treturn promotedFiltersSelectOptions;\n};\n\nexport const checkIfCurrencyFormula = (props: { formula: string; columns: any }) => {\n\tconst { formula, columns } = props;\n\tconst notAllowedFunctions = ['COUNT', 'COUNTDIST', 'CONCAT'];\n\tconst extractColumnValues = (str: string) => {\n\t\tconst regex = /'(.*?)'/g;\n\t\tconst matches = [];\n\t\tlet match;\n\n\t\twhile ((match = regex.exec(str))) {\n\t\t\tmatches.push(match[1]);\n\t\t}\n\n\t\treturn matches;\n\t};\n\n\t//check if formula includes any of the not allowed functions\n\tconst hasNotAllowedFunctions = notAllowedFunctions.some((func) => _.includes([formula], func));\n\n\tif (hasNotAllowedFunctions) {\n\t\treturn false;\n\t} else {\n\t\tconst columnValues = extractColumnValues(formula);\n\t\tconst currencyColumn = _.chain(columns)\n\t\t\t.filter((col: ColumnSetting) => col.isCurrency)\n\t\t\t.map((col: ColumnSetting) => col.headerName || col.field)\n\t\t\t.compact()\n\t\t\t.value();\n\n\t\t// check if anyone of columnValues is in columns array\n\t\tconst hasCurrencyColumn = columnValues.some((col: string) => (currencyColumn as any).includes(col));\n\t\treturn hasCurrencyColumn;\n\t}\n};\n\nexport const getProjectAsInput = (valueCols: ValueColsType[]) => {\n\t\tconst projectAsInput = _.reduce(\n\t\t\tvalueCols,\n\t\t\t(acc, curr) => {\n\t\t\t\tif (curr.showAs && curr.showAs !== ShowAsEnum.DEFAULT && curr.label) {\n\t\t\t\t\tconst mappedValue = ShowAsToProjectFractionMapper[curr.showAs];\n\t\t\t\t\tif (mappedValue) {\n\t\t\t\t\t\tacc[curr.label] = mappedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record<string, ProjectFractionEnum>\n\t\t);\treturn projectAsInput;\n};\n\nexport const getUpdatedDefinitionCustomModel = (props: {\n\tmetricDefinitionModel: Definition;\n\tparentDefinitionModel: Definition;\n\tparentCustomModel: WorkbookCustomModel;\n\tmetricCustomModel: PivotCustomModel;\n\tremoveSort?: boolean;\n}) => {\n\tconst {\n\t\tmetricDefinitionModel,\n\t\tparentDefinitionModel,\n\t\tmetricCustomModel,\n\t\tparentCustomModel,\n\t\tremoveSort\n\t} = props;\n\n\tconst parentTableVariable = parentCustomModel.variable;\n\tconst metricNewColumns = _.filter(metricDefinitionModel.variables ?? [], (v) => {\n\t\tif (!v.transforms || !v.transforms[0]) {\n\t\t\treturn false;\n\t\t}\n\t\tif (removeSort) {\n\t\t\treturn (\n\t\t\t\tfindParentIsMetricSeries(\n\t\t\t\t\t(v.transforms[0] as Sort).table,\n\t\t\t\t\tmetricDefinitionModel.variables ?? []\n\t\t\t\t) && v.transforms[0].type !== 'Sort'\n\t\t\t);\n\t\t}\n\t\treturn findParentIsMetricSeries(\n\t\t\t(v.transforms[0] as Sort).table,\n\t\t\tmetricDefinitionModel.variables ?? []\n\t\t);\n\t});\n\n\tconst definitionVariables = metricDefinitionModel.variables ?? [];\n\tconst analysisVariable: Variable | undefined = _.find<Variable>(definitionVariables, (v: Variable) =>\n\t\t!!_.find(v.transforms, (t: Transform<any>) => t.type === 'MetricSeries')\n\t);\n\n\tmetricDefinitionModel.imports = _.uniqBy(\n\t\t[...(parentDefinitionModel.imports ?? []), ...(metricDefinitionModel.imports ?? [])],\n\t\t'to'\n\t);\n\n\tconst parentDefinitionAliases = parentDefinitionModel.aliases ?? {};\n\n\tconst parentTableVariableAlias = parentTableVariable ? parentDefinitionAliases[parentTableVariable] as {\n\t\t[columnName: string]: string;\n\t} : {};\n\n\tconst metricDefinitionAliases = {\n\t\t...metricDefinitionModel.aliases,\n\t\t...parentDefinitionAliases\n\t} as { [tableId: string]: { [columnName: string]: string } };\n\n\t//foreach table in metricDefinitionAliases replace the values with parentTableVariableAlias\n\tfor (const [tableId] of Object.entries(metricDefinitionAliases)) {\n\t\tif (!parentDefinitionAliases[tableId]) {\n\t\t\t//if the table id does not belong to the data sheet\n\n\t\t\tconst metricTableAlias = metricDefinitionAliases[tableId] as {\n\t\t\t\t[columnName: string]: string;\n\t\t\t};\n\n\t\t\t//foreach each value in the metricTableAlias replace the value with the value of the parentTableVariableAlias\n\n\t\t\tfor (const [columnName, columnId] of Object.entries(metricTableAlias)) {\n\t\t\t\t//find the value of the parentTableVariableAlias where the key is the columnId\n\n\t\t\t\tconst pColName = _.findKey(parentTableVariableAlias, (pColId) => pColId === columnId);\n\n\t\t\t\tif (pColName && pColName !== columnName) {\n\t\t\t\t\tdelete metricTableAlias[columnName];\n\t\t\t\t\tmetricTableAlias[pColName] = parentTableVariableAlias[pColName];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tmetricDefinitionModel.aliases = metricDefinitionAliases;\n\n\tconst variables = _.cloneDeep(parentDefinitionModel.variables ?? []);\n\tmetricDefinitionModel.variables = definitionVariables.filter(\n\t\t(v: Variable) => v.name === analysisVariable?.name\n\t);\n\n\tconst previousVariables = metricDefinitionModel.variables;\n\tmetricDefinitionModel.variables = [...variables];\n\tconst variableNames = metricDefinitionModel.variables?.map((v: Variable) => v?.name);\n\tmetricDefinitionModel.variables.push(\n\t\t..._.filter(previousVariables, (v: Variable) => variableNames?.includes(v.name))\n\t);\n\tconst filterVariable = _.find(definitionVariables, (v: Variable) =>\n\t\tv.transforms?.some((t: Transform<any>) => t.type === 'RuleFilter' && t.rule === '${rule_pivot}')\n\t);\n\tif (filterVariable && parentTableVariable) {\n\t\t(filterVariable.transforms![0] as RuleFilter).table = parentTableVariable;\n\t\tmetricDefinitionModel.variables.push(filterVariable);\n\t}\n\tif (analysisVariable && parentTableVariable) {\n\t\t//@ts-ignore\n\t\tanalysisVariable.transforms![0].table = parentTableVariable;\n\t\t(analysisVariable.transforms![0] as MetricSeries).row_group_by = '${rowGroupByInput}';\n\t\t(analysisVariable.transforms![0] as MetricSeries).col_group_by = '${columnGroupByInput}';\n\n\t\tconst rowGroups = metricCustomModel?.gridColumnState?.rowGroupCols ?? [];\n\t\tconst valueCols = metricCustomModel?.gridColumnState?.valueCols ?? [];\n\t\tconst showAsList = _.chain(valueCols)\n\t\t\t.filter((vc) => !!vc.showAs)\n\t\t\t.map((vc) => vc?.showAs)\n\t\t\t.value();\n\n\t\t(analysisVariable.transforms![0] as MetricSeries).require_totals =\n\t\t\t!_.isEmpty(rowGroups) ||\n\t\t\t(!_.isEmpty(showAsList) && _.some(showAsList, (showAs) => showAs !== 'default'));\n\n\t\t//find the variable where the type of the 0 element of the transforms is 'FilterRule' and the table is the same as the variable of the analysisVariable\n\n\t\tif (filterVariable) {\n\t\t\t//@ts-ignore\n\t\t\tanalysisVariable.transforms![0].table = filterVariable.name;\n\t\t\t//@ts-ignore\n\n\t\t\t//update aliases and variables of updatedDefinitionModel with the filterVariable aliases and variables\n\t\t\tif (metricDefinitionModel.aliases && parentTableVariable) {\n\t\t\t\tmetricDefinitionModel.aliases[parentTableVariable] = {\n\t\t\t\t\t...metricDefinitionModel.aliases[parentTableVariable]\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tmetricDefinitionModel.variables.push(analysisVariable);\n\t\tmetricCustomModel.variable = analysisVariable.name;\n\n\t\t// update the sheet inputs in customModel\n\t}\n\n\tmetricCustomModel.inputs = { ...parentCustomModel.inputs, ...metricCustomModel.inputs };\n\n\tif (!_.isEmpty(metricNewColumns)) {\n\t\tmetricDefinitionModel.variables.push(...metricNewColumns);\n\t\tmetricCustomModel.variable = metricNewColumns[metricNewColumns.length - 1].name;\n\t}\n\n\tif (metricCustomModel.parentTableColumnSettings && parentCustomModel.uiSettings?.columnSettings) {\n\t\tmetricCustomModel.parentTableColumnSettings.splice(\n\t\t\t0,\n\t\t\tmetricCustomModel.parentTableColumnSettings.length,\n\t\t\t...parentCustomModel.uiSettings.columnSettings\n\t\t);\n\t}\n\n\tif (metricCustomModel.inputs?.['view_worksheet'] && metricCustomModel.parentTableColumnSettings) {\n\t\t_.forEach(metricCustomModel.parentTableColumnSettings, (c) => {\n\t\t\tif (metricCustomModel.inputs?.view_worksheet) {\n\t\t\t\tmetricCustomModel.inputs.view_worksheet = _.uniq([\n\t\t\t\t\t...metricCustomModel.inputs.view_worksheet,\n\t\t\t\t\tc.field\n\t\t\t\t]);\n\t\t\t}\n\t\t});\n\t}\n\n\tif (parentTableVariable) {\n\t\tmetricCustomModel.parentTableVariable = parentTableVariable;\n\t}\n\treturn { definitionModel: metricDefinitionModel, customModel: metricCustomModel };\n};\n\nexport const getUpdatedWorksheetDefinitionCustomModels = (props: {\n\tparentSheet: Sheet<WorkbookCustomModel>;\n\tmetricSheet: Sheet<PivotCustomModel>;\n}) => {\n\tconst { parentSheet, metricSheet } = props;\n\tconst parentDefinitionModel = parentSheet?.definitionModel as Definition;\n\tconst parentCustomModel = parentSheet?.customModel;\n\tconst metricDefinitionModel = metricSheet?.definitionModel as Definition;\n\tconst metricCustomModel = metricSheet?.customModel;\n\n\tif (!parentCustomModel || !metricCustomModel) {\n\t\tthrow new Error('Parent or metric custom model is missing');\n\t}\n\n\treturn {\n\t\t...getUpdatedDefinitionCustomModel({\n\t\t\tmetricDefinitionModel,\n\t\t\tparentDefinitionModel,\n\t\t\tmetricCustomModel,\n\t\t\tparentCustomModel\n\t\t})\n\t};\n};\n\nexport const timeBinToIntervalMapper = {\n\tper_month: 'Month',\n\tper_quarter: 'Quarter',\n\tper_week: 'Week',\n\tper_day: 'Day',\n\tper_year: 'Year'\n};\n\nexport const mapValueColsWithTrends = (props: {\n\tvalueCols: ValueColsType[];\n\tcompareTrends: PivotCustomModel['compareTrends'];\n}) => {\n\tconst { valueCols, compareTrends } = props;\n\treturn _.chain(valueCols)\n\t\t.filter((vc) => !vc.hide)\n\t\t.flatMap((vc) => {\n\t\t\tif (_.isEmpty(compareTrends)) {\n\t\t\t\treturn [vc];\n\t\t\t}\n\t\t\tconst trends = _.map(compareTrends, (ct) => {\n\t\t\t\treturn {\n\t\t\t\t\t...vc,\n\t\t\t\t\tlabel: `${vc.label}__${ct.name}`,\n\t\t\t\t\tcol: `${vc.col}__${ct.name}`,\n\t\t\t\t\tsourceLabel: vc.sourceLabel ?? vc.label,\n\t\t\t\t\tcompareTrendId: ct.id\n\t\t\t\t};\n\t\t\t});\n\t\t\treturn trends;\n\t\t})\n\t\t.value();\n};\n","import type { SelectOptionType } from '$models/types/selectType';\nimport {\n\tCommonFilter,\n\tFilterPanelStoreType,\n\tFilterRule,\n\tFilterSelectOptionsType,\n\tPromotedFiltersType,\n\tRuleType\n} from '$models/ui-models/filterModel';\nimport { ColumnSetting } from '$models/ui-models/workbookModel';\nimport {\n\tgetColumnSettingsToSelectOptions,\n\treplaceFilterColumn\n} from './analysisMethods';\nimport { filterToSelectOptionType, getSelectOptionTypeToFilter } from './filterUtils';\nimport _ from 'lodash';\n\nexport type MergeCommonFilterType = {\n\tcommonFilters: CommonFilter[];\n\trule: FilterSelectOptionsType[];\n\tcondition: RuleType;\n\tid: string; // id of the block/line/kpi\n};\n\nexport type MergeFilterType = {\n\tid: string; // id of the block/line/kpi -> metric\n\tmetricFilters: FilterRule;\n\tcolumnSettings: ColumnSetting[]; // metric column settings\n\tcommonFilters: CommonFilter[];\n\tpromotedFilters: PromotedFiltersType[];\n\tdatasetIds: string[];\n};\n\nexport type ApplicablePromotedFiltersType = {\n\tid: string; // id of the block/line/kpi -> metric\n\tdatasetIds: string[];\n\tpromotedFilters: PromotedFiltersType[];\n};\n\nexport interface IMergeFilterService {\n\tmergeCommonFilters(props: MergeCommonFilterType): FilterPanelStoreType;\n\tmergeFilters(props: MergeFilterType): FilterRule; // merge all filters -> metric, promoted, common\n}\n\nexport class MergeFilterService implements IMergeFilterService {\n\tprivate getColumnSettingsForCommonFilters(cf: CommonFilter): SelectOptionType<ColumnSetting>[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: cf.name,\n\t\t\t\tvalue: cf.column.name,\n\t\t\t\toption: {\n\t\t\t\t\theaderName: cf.name,\n\t\t\t\t\tfield: cf.column.name, //@ts-ignore\n\t\t\t\t\ttype: cf.column.data_type,\n\t\t\t\t\tdatasetName: cf.datasetName,\n\t\t\t\t\tdatasetId: cf.datasetId\n\t\t\t\t}\n\t\t\t}\n\t\t];\n\t}\n\n\tmergeCommonFilters(props: MergeCommonFilterType): FilterPanelStoreType {\n\t\tconst { commonFilters, rule, id, condition } = props;\n\t\tlet replacedFr: FilterSelectOptionsType[][] = [];\n\t\tif (_.isEmpty(commonFilters)) return { defaultType: condition, rules: rule };\n\t\t_.forEach(commonFilters, (f: CommonFilter) => {\n\t\t\tconst columnSettingsSelectOption = this.getColumnSettingsForCommonFilters(f);\n\n\t\t\t// check if applied on the line\n\t\t\tconst appliedOnLine = _.find(f?.appliedOnBlocks, (l) => l.blockId === id) as {\n\t\t\t\tblockId: string;\n\t\t\t\tapplied: boolean;\n\t\t\t\tblockName: string;\n\t\t\t\tcolumn: string;\n\t\t\t\tcolumnSettings: SelectOptionType<ColumnSetting>[];\n\t\t\t};\n\t\t\tif (appliedOnLine && appliedOnLine.applied) {\n\t\t\t\tconst commonRule = f.rule;\n\t\t\t\tconst fr = filterToSelectOptionType(commonRule, columnSettingsSelectOption);\n\t\t\t\tconst columnSetting = _.find(\n\t\t\t\t\tappliedOnLine.columnSettings,\n\t\t\t\t\t(c) => c.value === appliedOnLine.column\n\t\t\t\t);\n\t\t\t\tif (columnSetting) {\n\t\t\t\t\treplacedFr.push(replaceFilterColumn({ fr: fr.rules, column: columnSetting }));\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tconst mergedFr = _.unionBy(replacedFr.flat(), rule, 'value');\n\n\t\treturn { defaultType: condition, rules: mergedFr };\n\t}\n\n\tprivate getApplicablePromotedFilters(props: ApplicablePromotedFiltersType) {\n\t\tconst { id, datasetIds, promotedFilters } = props;\n\t\treturn _.filter(promotedFilters, (pf) => {\n\t\t\tconst appliedBlock = _.find(pf.appliedOnBlocks, (aob) => aob.blockId === id);\n\t\t\tconst isApplied = appliedBlock?.applied ?? false;\n\t\t\treturn isApplied && _.includes(datasetIds, pf.datasetId);\n\t\t});\n\t}\n\n\tprivate getUnion(\n\t\tpromotedFilters: PromotedFiltersType[],\n\t\tmetricFilters: FilterRule,\n\t\tcolumnSettings: ColumnSetting[]\n\t): FilterPanelStoreType {\n\t\t/** get select options for promoted filters */\n\t\tconst pfSelectOptions = _.map(promotedFilters, (pf) => {\n\t\t\treturn (\n\t\t\t\tfilterToSelectOptionType(pf.rule, getColumnSettingsToSelectOptions(pf.blockColumnSettings))\n\t\t\t\t\t?.rules ?? []\n\t\t\t);\n\t\t}).flat();\n\n\t\tconst mFilterModel = filterToSelectOptionType(\n\t\t\tmetricFilters,\n\t\t\tgetColumnSettingsToSelectOptions(columnSettings)\n\t\t);\n\n\t\tif (_.isEmpty(mFilterModel)) {\n\t\t\treturn { defaultType: 'and_cond', rules: pfSelectOptions };\n\t\t}\n\n\t\tconst ruleType = mFilterModel?.defaultType ?? 'and_cond';\n\t\tconst mSelectOptions = mFilterModel?.rules ?? [];\n\n\t\tconst union = _.unionBy(pfSelectOptions, mSelectOptions, 'value');\n\t\treturn { defaultType: ruleType, rules: union };\n\t}\n\n\t/** merges promoted filter to metric filter */\n\tprivate mergePromotedFilters(props: MergeFilterType): FilterPanelStoreType {\n\t\tconst { metricFilters, columnSettings, promotedFilters } = props;\n\n\t\tconst applicablePromotedFilters = this.getApplicablePromotedFilters({\n\t\t\tid: props.id,\n\t\t\tdatasetIds: props.datasetIds,\n\t\t\tpromotedFilters\n\t\t});\n\n\t\treturn this.getUnion(applicablePromotedFilters, metricFilters, columnSettings);\n\t}\n\n\tmergeFilters(props: MergeFilterType): FilterRule {\n\t\tconst { commonFilters } = props;\n\n\t\tconst filtersWithPromoted = this.mergePromotedFilters(props);\n\t\tconst filtersWithCommon = this.mergeCommonFilters({\n\t\t\tcommonFilters,\n\t\t\trule: filtersWithPromoted.rules,\n\t\t\tid: props.id,\n\t\t\tcondition: (filtersWithPromoted?.defaultType ?? 'and_cond') as RuleType\n\t\t});\n\n\t\treturn getSelectOptionTypeToFilter(filtersWithCommon);\n\t}\n}\n","import { HierarchyProperties, Worksheet } from \"$models/gen/Api\";\nimport { DashboardDateRangeModel } from \"$models/ui-models/dashboardModel\";\nimport {\n Inputs,\n TimeBin,\n} from \"$models/ui-models/definitionModel\";\nimport {\n CommonFilter,\n FilterPanelStoreType,\n FilterRule,\n PromotedFiltersType,\n} from \"$models/ui-models/filterModel\";\nimport {\n ShowAsEnum,\n type BoardCurrencyModel,\n type ColumnSetting,\n type MetricMetadataType,\n type RowGroupsType,\n type ValueColsType,\n} from \"$models/ui-models/workbookModel\";\nimport _ from \"lodash\";\nimport {\n filterToSelectOptionType,\n getColumnFilterRuleFromCombinedFilterRule,\n getSelectOptionTypeToFilter,\n} from \"./filterUtils\";\nimport { MergeFilterService } from \"./mergeFilterService\";\nimport {\n defaultFilterRule,\n getColumnSettingsToSelectOptions,\n getDrilldownFiltersMap,\n getFiltersToBeAppliedOnDrilldown,\n getMetricFilterRule,\n ShowAsToProjectFractionMapper,\n} from \"./analysisMethods\";\nimport { DateRange } from \"$models/ui-models/dateRangeModel\";\n\nconst updatePromotedFiltersAndDateRangeToMetadataAndInputs = (props: {\n blockId: string;\n metadata: MetricMetadataType;\n promotedFiltersStoreValue: {\n [datasetId: string]: { [id: string]: FilterPanelStoreType };\n };\n promotedFilters: PromotedFiltersType[];\n inputs: Inputs;\n dateRangeModel: DashboardDateRangeModel;\n currencyModel: BoardCurrencyModel;\n commonFilters?: CommonFilter[];\n}) => {\n const { blockId, metadata, promotedFilters, inputs, commonFilters } = props;\n\n const updateDateRange = (updateProps: {\n blockId: string;\n blockDateRange: DateRange;\n dateRangeModel: DashboardDateRangeModel;\n }) => {\n const { blockId, blockDateRange, dateRangeModel } = updateProps;\n const { dateRange, appliedOnBlocks } = dateRangeModel;\n\n const dateRangeApplicableOnBlockIds = appliedOnBlocks\n ?.filter((apb: { applied: boolean }) => apb.applied)\n ?.map((apb: { blockId: string }) => apb.blockId);\n\n if (dateRangeApplicableOnBlockIds?.includes(blockId)) {\n return dateRange;\n } else {\n return blockDateRange;\n }\n };\n\n const updateCurrencyFilter = (updateProps: {\n blockId: string;\n blockCurrencyFilter: string;\n currencyModel: BoardCurrencyModel;\n }) => {\n const { blockId, blockCurrencyFilter, currencyModel } = updateProps;\n const { currency, appliedOnBlocks } = currencyModel;\n\n const currencyFilterApplicableOnBlockIds = _.chain(appliedOnBlocks)\n .filter((apb: { applied: boolean }) => apb.applied)\n .map((apb: { blockId: string }) => apb.blockId)\n .value();\n\n if (currencyFilterApplicableOnBlockIds?.includes(blockId)) {\n return currency;\n } else {\n return blockCurrencyFilter;\n }\n };\n\n const metricColumnFilter = getColumnFilterRuleFromCombinedFilterRule(\n metadata.filterModel as FilterRule,\n metadata.valueCols || []\n );\n\n const updatedFilterRule = new MergeFilterService().mergeFilters({\n id: blockId,\n metricFilters: metricColumnFilter as FilterRule,\n columnSettings: metadata.columnSettings,\n promotedFilters,\n commonFilters: commonFilters || [],\n datasetIds: [metadata.datasetId || \"\"],\n });\n\n const updatedDateRange = updateDateRange({\n blockId,\n blockDateRange: metadata.dateRange || { time_period: \"past_quarter\" },\n dateRangeModel: props.dateRangeModel,\n });\n\n const updateCurrencyFilterValue = updateCurrencyFilter({\n blockId,\n blockCurrencyFilter: metadata.currency || \"\",\n currencyModel: props.currencyModel,\n });\n\n const updatedInputs = {\n ...inputs,\n [\"filterOnAggregates\"]: _.get(\n inputs,\n \"filterOnAggregates\",\n defaultFilterRule\n ),\n [\"rule_pivot\"]: updatedFilterRule,\n date_range: updatedDateRange,\n to_currency: updateCurrencyFilterValue,\n showDimensionMappingValues: metadata.showDimensionMappingValues ?? false,\n showBinSortOrderValues: metadata?.inputs?.showBinSortOrderValues ?? false,\n };\n const updatedMetadata = {\n ...metadata,\n filterModel: updatedFilterRule,\n dateRange: updatedDateRange,\n inputs: updatedInputs,\n };\n\n return { updatedInputs, updatedMetadata };\n};\n\nconst getRowsToGroupBy = (props: {\n pivotColumns: string[];\n timeBin: TimeBin | \"\";\n rowGroupColumns: RowGroupsType;\n}) => {\n const { pivotColumns, timeBin, rowGroupColumns } = props;\n const rowsToGroupBy = [];\n if (!_.isEmpty(pivotColumns)) {\n if (timeBin) {\n rowsToGroupBy.push([...rowGroupColumns]);\n for (let i = 0; i < pivotColumns.length; i++) {\n const pcols = pivotColumns;\n rowsToGroupBy.push([...pcols.slice(0, i + 1), ...rowGroupColumns]);\n }\n } else {\n for (let i = 0; i < pivotColumns.length; i++) {\n const pcols = pivotColumns;\n rowsToGroupBy.push([...pcols.slice(0, i + 1), ...rowGroupColumns]);\n }\n }\n } else {\n rowsToGroupBy.push([...pivotColumns, ...rowGroupColumns]);\n }\n\n return rowsToGroupBy;\n};\n\nconst getInputsArray = (props: {\n pivotColumns: string[];\n timeBin: TimeBin | \"\";\n rowsToGroupBy: string[][];\n inputs: Inputs;\n dateColumn: string;\n valueCols: ValueColsType[];\n hierarchy?: HierarchyProperties;\n rowGroupCols?: RowGroupsType;\n compareTrends?: MetricMetadataType[\"compareTrends\"];\n showDimensionMappingValues?: boolean;\n showBinSortOrderValues: boolean;\n}) => {\n const {\n pivotColumns,\n timeBin,\n rowsToGroupBy,\n inputs,\n dateColumn,\n valueCols,\n hierarchy,\n rowGroupCols,\n compareTrends,\n showDimensionMappingValues = false,\n showBinSortOrderValues = false,\n } = props;\n let inputsArray: Inputs[] = [];\n const inputsCompareTrendsIndices: Array<{ id: string; index: number }> = [];\n\n const getViewsInput = (index?: number) => {\n let viewInputs = inputs?.viewInputs;\n if (!viewInputs) return undefined;\n\n const valueColsLabel = _.map(valueCols, (vc) => vc.label);\n viewInputs = _.filter(\n viewInputs,\n (vi) => valueColsLabel.includes(vi) || vi.includes(\"__bc_\")\n );\n\n if (_.isEmpty(rowGroupCols)) {\n viewInputs = _.filter(viewInputs, (vi) => !vi.includes(\"__bc_\"));\n }\n if (timeBin) {\n viewInputs = _.uniq([...viewInputs, dateColumn, `${dateColumn}_group`]);\n }\n if (index !== undefined) {\n viewInputs = _.uniq([...viewInputs, ...rowsToGroupBy[index]]);\n } else {\n if (!_.isEmpty(rowGroupCols)) {\n let row = rowsToGroupBy[0];\n if (!_.isEmpty(hierarchy) && hierarchy) {\n const rowLabelName = _.get(rowsToGroupBy, \"0.0.0\");\n row = [\n rowLabelName,\n `${rowLabelName}_level_number`,\n `${rowLabelName}_${hierarchy.parentColId}`,\n `${rowLabelName}_${hierarchy.nodeColName}`,\n ];\n }\n\n viewInputs = _.uniq([...viewInputs, ...row]);\n }\n }\n return viewInputs;\n };\n\n const projectAsInput = _.reduce(\n valueCols,\n (acc: Record<string, any>, curr) => {\n if (curr.showAs && curr.showAs !== ShowAsEnum.DEFAULT && curr.label) {\n acc[curr.label] = ShowAsToProjectFractionMapper[curr.showAs];\n }\n return acc;\n },\n {} as Record<string, any>\n );\n\n const sortPivotInputsKey = Object.keys(inputs).find((key) =>\n key.startsWith(\"sortPivotInputs\")\n );\n const sortPivotInputsValue = sortPivotInputsKey\n ? { ...inputs[sortPivotInputsKey] }\n : undefined;\n\n if (!_.isEmpty(pivotColumns)) {\n const pc = timeBin ? [dateColumn, ...pivotColumns] : pivotColumns;\n\n pc?.forEach((col, index) => {\n const groupByInput = rowsToGroupBy[index];\n const columnGroupByInput = _.filter(groupByInput, (r) => pc.includes(r));\n const rowGroupByInput = _.filter(groupByInput, (r) => !pc.includes(r));\n if (sortPivotInputsValue) {\n sortPivotInputsValue.pivotColumns = rowsToGroupBy[index];\n }\n\n inputsArray.push({\n ...inputs,\n groupByInput: rowsToGroupBy[index],\n dateColumnInput: dateColumn,\n binByInput: timeBin,\n viewInputs: getViewsInput(index),\n columnGroupByInput,\n rowGroupByInput,\n projectAsInput,\n showDimensionMappingValues,\n showBinSortOrderValues,\n ...(sortPivotInputsKey\n ? { [sortPivotInputsKey]: sortPivotInputsValue }\n : {}),\n });\n });\n } else {\n if (compareTrends && compareTrends.length > 0) {\n if (sortPivotInputsValue) {\n sortPivotInputsValue.pivotColumns = rowsToGroupBy[0];\n }\n inputsArray = _.map(compareTrends, (ct, index) => {\n inputsCompareTrendsIndices.push({ id: ct.id, index });\n return {\n ...inputs,\n date_range: { ...ct.dateRange },\n groupByInput: rowsToGroupBy[0],\n dateColumnInput: dateColumn,\n binByInput: timeBin,\n viewInputs: getViewsInput(),\n rowGroupByInput: rowsToGroupBy[0],\n columnGroupByInput: [],\n projectAsInput,\n showDimensionMappingValues,\n showBinSortOrderValues,\n ...(sortPivotInputsKey\n ? { [sortPivotInputsKey]: sortPivotInputsValue }\n : {}),\n };\n });\n } else {\n if (sortPivotInputsValue) {\n sortPivotInputsValue.pivotColumns = rowsToGroupBy[0];\n }\n inputsArray = [\n {\n ...inputs,\n groupByInput: rowsToGroupBy[0],\n dateColumnInput: dateColumn,\n binByInput: timeBin,\n viewInputs: getViewsInput(),\n rowGroupByInput: rowsToGroupBy[0],\n columnGroupByInput: [],\n projectAsInput,\n showDimensionMappingValues,\n showBinSortOrderValues,\n ...(sortPivotInputsKey\n ? { [sortPivotInputsKey]: sortPivotInputsValue }\n : {}),\n },\n ];\n }\n }\n\n return { inputs: inputsArray, inputsCompareTrendsIndices };\n};\n\nconst mergeDrilldownFiltersToMetricFilters = (props: {\n metricFilterRule: FilterRule;\n filtersToBeApplied: { field: string; key: string }[];\n columnSettings: ColumnSetting[];\n}) => {\n const { metricFilterRule, filtersToBeApplied, columnSettings } = props;\n const columnSelectOptions = getColumnSettingsToSelectOptions(columnSettings);\n const metricFilterRuleSelectOptions = filterToSelectOptionType(\n metricFilterRule,\n columnSelectOptions\n );\n const drilldownFilterMap = getDrilldownFiltersMap({\n filtersToBeApplied,\n columnSelectOptions,\n });\n\n const mergedRule = _.unionBy(\n Object.values(drilldownFilterMap),\n metricFilterRuleSelectOptions.rules,\n \"value\"\n );\n const filterRule: FilterRule = getSelectOptionTypeToFilter({\n defaultType: \"and_cond\",\n rules: mergedRule,\n });\n\n return filterRule;\n};\n\nexport const getMetricDefinition = (props: {\n sheetId: string;\n metadata: MetricMetadataType;\n groupKeys: string[];\n lastModifiedDate: string;\n promotedFiltersStoreValue: {\n [datasetId: string]: { [id: string]: FilterPanelStoreType };\n };\n promotedFilters: PromotedFiltersType[];\n dateRangeModel: DashboardDateRangeModel;\n currencyModel: BoardCurrencyModel;\n commonFilters: CommonFilter[];\n}) => {\n const {\n sheetId,\n metadata,\n groupKeys,\n promotedFiltersStoreValue,\n promotedFilters,\n dateRangeModel,\n currencyModel,\n commonFilters,\n } = props;\n const {\n parentTableVariable,\n valueCols,\n rowGroupCols,\n pivotCols,\n timeBin,\n dateColumn,\n columnSettings,\n } = metadata;\n let inputs = metadata?.inputs;\n\n //if (isHierarchyMetric({ rowGroups: metadata?.rowGroupCols })) {\n //gridApi.setPivotResultColumns([]);\n // return await this.runHierarchyMetricsForDashboards(props);\n //}\n\n const { updatedInputs } =\n updatePromotedFiltersAndDateRangeToMetadataAndInputs({\n blockId: sheetId,\n metadata,\n promotedFiltersStoreValue,\n promotedFilters,\n inputs,\n dateRangeModel,\n currencyModel,\n commonFilters,\n });\n\n let rowsToGroupBy = getRowsToGroupBy({\n pivotColumns: pivotCols || [],\n rowGroupColumns: (rowGroupCols || []).slice(0, groupKeys.length + 1),\n timeBin: timeBin || \"\",\n });\n\n let { inputs: inputsArray } = getInputsArray({\n inputs: updatedInputs,\n dateColumn: dateColumn || \"\",\n timeBin: timeBin || \"\",\n rowsToGroupBy: rowsToGroupBy as string[][],\n pivotColumns: pivotCols || [],\n valueCols: valueCols || [],\n rowGroupCols: rowGroupCols,\n compareTrends: metadata.compareTrends,\n showDimensionMappingValues:\n metadata?.inputs?.showDimensionMappingValues ?? false,\n showBinSortOrderValues: metadata?.inputs?.showBinSortOrderValues ?? false,\n });\n\n if (!_.isEmpty(groupKeys)) {\n const mergedFilterRule = mergeDrilldownFiltersToMetricFilters({\n metricFilterRule: getMetricFilterRule(inputsArray),\n filtersToBeApplied: getFiltersToBeAppliedOnDrilldown({\n rowGroups: metadata?.rowGroupCols as string[],\n groupKeys,\n }),\n columnSettings,\n });\n\n inputsArray = inputsArray?.map((ia) => {\n return { ...ia, [\"rule_pivot\"]: mergedFilterRule };\n });\n }\n\n return {\n inputs: inputsArray,\n describe: parentTableVariable,\n };\n};\n\nexport const getSelectedMetricsParentIds = (selectedItems: { sheet: Worksheet }[]) => {\n return _.chain(selectedItems)\n .map((s) => s?.sheet?.customFields?.parentTableId as unknown as string)\n .uniq()\n .value();\n};\n\n\nexport const defaultDashboardDateRangeModel: DashboardDateRangeModel = {\n\t//@ts-ignore\n\tdateRange: {},\n\tappliedOnBlocks: []\n};\n\nexport const defaultCurrencyModel: BoardCurrencyModel = {\n\tcurrency: 'USD',\n\tappliedOnBlocks: []\n};","// REMOVE THIS FILE AFTER REFACTORING INPUT TABLES\nimport { ColumnFilterRule } from '$models/gen/Api';\nimport {\n\tMetricAggregateType,\n\tMetricSeries,\n} from '$models/ui-models/definitionModel';\nimport {\n\tInputTableDefinitionModel,\n\tInputTableFilterTransform,\n\tInputTableSortTransform,\n\tInputTableTransformation\n} from '$models/ui-models/inputTableModel';\nimport {\n\tSortOptions,\n\tValueColsType\n} from '$models/ui-models/workbookModel';\nimport _ from 'lodash';\nimport { getColumnSettingsToSelectOptions, getDrilldownFiltersMap, getFiltersToBeAppliedOnDrilldown } from '../metric/analysisMethods';\nimport { filterToSelectOptionType, getSelectOptionTypeToFilter } from '../metric/filterUtils';\n\nexport const getGroupByDefinition = ({\n\ttableId,\n\ttableName,\n\tgroupKeys,\n\trowGroupCols,\n\tcolumnSettings,\n\tfilterRules,\n\tsortValue,\n\tmetricSeries\n}) => {\n\tlet filtersToBeApplied = getFiltersToBeAppliedOnDrilldown({\n\t\tgroupKeys,\n\t\trowGroups: rowGroupCols as string[]\n\t});\n\tconst columnSelectOptions = getColumnSettingsToSelectOptions(columnSettings);\n\n\tconst metricFilterRuleSelectOptions = filterToSelectOptionType(filterRules, columnSelectOptions);\n\tconst crossFilterMap = getDrilldownFiltersMap({\n\t\tfiltersToBeApplied,\n\t\tcolumnSelectOptions\n\t});\n\n\tconst mergedRule = _.unionBy(\n\t\tObject.values(crossFilterMap),\n\t\tmetricFilterRuleSelectOptions.rules,\n\t\t'value'\n\t);\n\n\tconst filterRule = getSelectOptionTypeToFilter({\n\t\tdefaultType: 'and_cond',\n\t\trules: mergedRule\n\t});\n\treturn generateDefinitionModel({\n\t\tfilters: filterRule as any,\n\t\tsort: sortValue,\n\t\tmetricSeries,\n\t\ttableId,\n\t\ttableName\n\t});\n};\n\nexport const generateDefinitionModel = ({\n\tfilters,\n\tsort,\n\tmetricSeries,\n\ttableId,\n\ttableName\n}: {\n\tfilters?: ColumnFilterRule;\n\tsort?: Record<string, any>;\n\tmetricSeries?: Partial<MetricSeries>;\n\ttableId: string;\n\ttableName: string;\n}): { targetName: string; definition: InputTableDefinitionModel } => {\n\tconst { transformations, targetName } = generateTransformations(\n\t\ttableName,\n\t\tfilters,\n\t\tsort,\n\t\tmetricSeries\n\t);\n\n\tconst importConfig: any = getImportConfig(tableId, tableName);\n\treturn {\n\t\ttargetName,\n\t\tdefinition: {\n\t\t\timports: [importConfig],\n\t\t\ttransformations\n\t\t}\n\t};\n};\n\nexport const sortConfigFromValue = (sortBy: SortOptions) => {\n\tconst sortValueObj = !_.isNil(sortBy?.sortByField)\n\t\t? { [sortBy.sortByField.value]: _.get(sortBy, 'sortByOrder', 'asc').toUpperCase() }\n\t\t: undefined;\n\treturn sortValueObj;\n};\n\nexport const getMetricSeries = (props: {\n\tpivotCols: string[];\n\trowGroupCols: string[];\n\tvalueCols: ValueColsType[];\n}) => {\n\tconst { pivotCols, rowGroupCols, valueCols } = props;\n\tconst group_by = [...pivotCols, ...rowGroupCols];\n\n\tconst aggregates: MetricAggregateType[] = _.map<\n\t\tValueColsType,\n\t\t[alias: string, formula: string] | [alias: string, col: string, func: string]\n\t>(valueCols, (valueCol) => {\n\t\tif (valueCol.type === 'formula') {\n\t\t\tconst formula = valueCol.formula;\n\t\t\treturn [valueCol.label, formula];\n\t\t} else if (valueCol.type === 'column') {\n\t\t\tconst formula = valueCol.formula;\n\t\t\treturn [valueCol.label, formula];\n\t\t}\n\t\treturn [valueCol.label, valueCol.col, valueCol.aggFun];\n\t});\n\n\tconst metricSeries: Partial<MetricSeries> = {\n\t\taggregates,\n\t\tgroup_by,\n\t\trow_group_by: rowGroupCols,\n\t\tcol_group_by: pivotCols,\n\t\ttype: 'TableAggregate',\n\t\tformula_on_aggregates: []\n\t};\n\treturn metricSeries;\n};\n\nconst getFilterConfig = (\n\tfilters: ColumnFilterRule,\n\tprevName: string\n): InputTableFilterTransform => ({\n\tname: 'table_filter',\n\ttable_name: prevName,\n\tfilter: filters,\n\ttype: 'CollectionFilter'\n});\n\nconst getSortConfig = (sort: Record<string, any>, prevName: string): InputTableSortTransform => ({\n\tname: 'table_sort',\n\ttable_name: prevName,\n\tsort_columns: sort,\n\ttype: 'CollectionSort'\n});\n\nconst generateTransformations = (\n\ttableName: string,\n\tfilters?: ColumnFilterRule,\n\tsort?: Record<string, any>,\n\tmetricSeries?: Partial<MetricSeries>\n): { transformations: InputTableTransformation[]; targetName: string } => {\n\tconst transformations = [];\n\tlet prevName = tableName;\n\tlet targetName = tableName;\n\n\tif (!_.isEmpty(filters)) {\n\t\tconst filterConfig = getFilterConfig(filters, prevName);\n\t\ttransformations.push(filterConfig);\n\t\tprevName = filterConfig.name;\n\t\ttargetName = 'table_filter';\n\t}\n\n\tif (metricSeries) {\n\t\tconst aggregateConfig = {\n\t\t\tname: 'table_aggregate',\n\t\t\ttable_name: prevName,\n\t\t\taggregates: metricSeries.aggregates,\n\t\t\tgroup_by: metricSeries.group_by,\n\t\t\ttype: 'CollectionAggregate'\n\t\t};\n\t\ttransformations.push(aggregateConfig);\n\t\tprevName = aggregateConfig.name;\n\t\ttargetName = 'table_aggregate';\n\t}\n\n\tif (metricSeries?.aggregates) {\n\t\tif (sort !== undefined) {\n\t\t\tconst sortEntries = Object.entries(sort);\n\t\t\tif (sortEntries.length > 0) {\n\t\t\t\tconst newSort = {};\n\t\t\t\tfor (const [sortKey, sortOrder] of sortEntries) {\n\t\t\t\t\tconst matchingAggregate = metricSeries.aggregates.find((agg) => agg[1] === sortKey);\n\t\t\t\t\tif (matchingAggregate) {\n\t\t\t\t\t\tnewSort[matchingAggregate[0]] = sortOrder;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsort = _.isEmpty(newSort) ? {} : newSort;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!_.isEmpty(sort)) {\n\t\tconst sortConfig = getSortConfig(sort, prevName);\n\t\ttransformations.push(sortConfig);\n\t\tprevName = sortConfig.name;\n\t\ttargetName = 'table_sort';\n\t}\n\n\treturn { transformations, targetName };\n};\n\nconst getImportConfig = (id: string, name: string) => ({\n\tname: name,\n\ttable_id: id,\n\ttype: 'TableImport'\n});\n\n\n","import axios, { AxiosRequestConfig } from \"axios\";\nimport { getFileUrlByFileId, GetFileUrlRequest } from \"../../api/file\";\n\nexport async function downloadFile(\n loc: string,\n contentType: string\n): Promise<object | null> {\n if (!loc) return null;\n\n const requestData: GetFileUrlRequest = {\n key: loc,\n contentType: contentType,\n method: \"GET\" as unknown as \"GET\" | \"PUT\" | \"POST\", // Type assertion to match the expected type\n };\n\n try {\n const response = await getFileUrlByFileId(requestData);\n // Get the PresignedUrl\n const presignedUrl = response.url;\n\n const config: AxiosRequestConfig = {\n method: \"GET\",\n url: presignedUrl,\n headers: {\n \"Content-Type\": \"application/octet-stream\",\n },\n };\n const axiosInstance = axios.create();\n const result = await axiosInstance(config);\n\n const fileRead = result.data;\n return fileRead;\n } catch (error) {\n console.error(\"Error downloading file:\", error);\n throw error;\n }\n}\n","import { Sheet } from \"$models/ui-models/workbookModel\";\nimport { downloadFile } from \"../file/downloadFile\";\n\nexport const hydrateWorksheet = async (sheet: Sheet): Promise<Sheet | null> => {\n try {\n if (!sheet) return sheet;\n\n const isHydrated = sheet.definitionModel && sheet.customModel;\n\n if (isHydrated) {\n return sheet;\n }\n\n const definitionModelId = sheet.externalDataId;\n const customModelId = sheet.modelId;\n\n let definitionModel = {} as Record<string, unknown>;\n let customModel = {} as Record<string, unknown>;\n const sheetId = sheet.id as string;\n if (definitionModelId && customModelId) {\n definitionModel = (await downloadFile(definitionModelId, \"application/json\")) as Record<\n string,\n unknown\n >;\n customModel = (await downloadFile(customModelId, \"application/json\")) as Record<\n string,\n unknown\n >;\n }\n if (!definitionModel || !definitionModel[sheetId]) {\n return sheet;\n }\n sheet.definitionModel = definitionModel[sheetId];\n sheet.customModel = customModel[sheetId];\n return sheet;\n } catch (error) {\n console.error(\"Error hydrating portal page:\", error);\n throw error;\n }\n};\n","import _ from \"lodash\";\nimport { getWorksheets } from \"../worksheet\";\nimport { getMetricDefinition } from \"../../utils\";\nimport {\n defaultCurrencyModel,\n defaultDashboardDateRangeModel,\n getSelectedMetricsParentIds,\n} from \"../../utils/metric/getMetricDefinition\";\nimport { hydrateWorksheet } from \"../../utils/metric/hydrateWorksheet\";\nimport { getUpdatedDefinitionCustomModel } from \"../../utils/metric/analysisMethods\";\nimport { Definition, Inputs, TimeBin } from \"$models/ui-models/definitionModel\";\nimport {\n GridColumnState,\n MetricMetadataType,\n PivotCustomModel,\n} from \"$models/ui-models/workbookModel\";\nimport { runPublishedDefinition } from \"../definition\";\n\nexport const getData = async (\n metricSheetId: string,\n options?: {\n groupKeys?: string[];\n isKPI?: boolean;\n plotAsTrend?: boolean;\n stringValue?: boolean;\n }\n) => {\n const worksheets = await getWorksheets([metricSheetId]);\n if (_.isEmpty(worksheets)) return {};\n\n const selectedWorksheet = worksheets[0];\n const hydratedSheet = await hydrateWorksheet(selectedWorksheet);\n if (!hydratedSheet) return {};\n\n const selectedMetricsParentIds = getSelectedMetricsParentIds([\n { sheet: selectedWorksheet },\n ]);\n const parentWorksheets = await getWorksheets(selectedMetricsParentIds);\n const parentSheet = _.find(\n parentWorksheets,\n (ps) =>\n ps.id === (hydratedSheet?.customFields.parentTableId as unknown as string)\n );\n let definitionModel;\n let customModel;\n\n if (parentSheet) {\n const hydratedParentSheet = await hydrateWorksheet(parentSheet);\n if (hydratedParentSheet?.definitionModel) {\n const {\n definitionModel: parentDefinitionModel,\n customModel: parentCustomModel,\n } = getUpdatedDefinitionCustomModel({\n metricDefinitionModel: hydratedSheet.definitionModel as Definition,\n parentDefinitionModel:\n hydratedParentSheet?.definitionModel as Definition,\n parentCustomModel: hydratedParentSheet?.customModel as PivotCustomModel,\n metricCustomModel: hydratedSheet.customModel as PivotCustomModel,\n });\n definitionModel = parentDefinitionModel;\n customModel = parentCustomModel;\n }\n } else {\n definitionModel = hydratedSheet.definitionModel as Definition;\n customModel = hydratedSheet.customModel as PivotCustomModel;\n }\n\n const cModel = customModel;\n const dModel = definitionModel as Definition;\n const gridColumnState: GridColumnState =\n cModel?.gridColumnState as GridColumnState;\n\n const { variable, parentTableVariable, inputs } = cModel as {\n variable: string;\n parentTableVariable: string;\n inputs: Inputs;\n };\n\n const aliases = dModel?.aliases?.[parentTableVariable];\n\n let timeBin = \"\";\n if (options?.isKPI) {\n timeBin = (\n options?.plotAsTrend\n ? !_.isEmpty(cModel?.timeBin)\n ? cModel?.timeBin\n : \"per_month\"\n : \"\"\n ) as TimeBin;\n } else {\n timeBin = cModel?.timeBin ?? \"\";\n }\n\n const valueCols = _.map(gridColumnState?.valueCols, (vc) => ({\n ...vc,\n hide: false,\n }));\n\n const columnSettings = _.map(cModel?.parentTableColumnSettings, (cs) => ({\n ...cs,\n hide: false,\n }));\n const metadata: MetricMetadataType = {\n variable,\n parentTableVariable,\n inputs,\n datasetId: cModel?.datasetId ?? \"\",\n datasetName: cModel?.datasetName ?? \"\",\n columnSettings: columnSettings ?? [],\n filterColumnsBy: cModel?.filterColumnsBy ?? {},\n filterModel: hydratedSheet?.customModel?.gridColumnState?.filterModel ?? {},\n valueCols: valueCols ?? [],\n rowGroupCols: gridColumnState?.rowGroupCols ?? [],\n pivotCols: gridColumnState?.pivotCols ?? [],\n dateColumn: cModel?.dateColumn,\n timeBin: timeBin as TimeBin,\n dateRange: cModel?.inputs?.date_range,\n aliases,\n lastModifiedDate: hydratedSheet?.lastModifiedDate,\n hierarchy: cModel?.hierarchy,\n description: \"\",\n isKPI: options?.isKPI ?? false,\n currency: cModel?.currency,\n sortOptions: cModel?.sortOptions,\n limitOptions: cModel?.limitOptions,\n stringValue: options?.stringValue ?? false,\n };\n\n const { inputs: definitionInputs, describe } = getMetricDefinition({\n sheetId: hydratedSheet.id as string,\n metadata,\n groupKeys: options?.groupKeys ?? [],\n lastModifiedDate: hydratedSheet.lastModifiedDate as string,\n promotedFiltersStoreValue: {},\n promotedFilters: [],\n dateRangeModel:\n hydratedSheet?.customModel?.dateRangeModel ??\n defaultDashboardDateRangeModel,\n currencyModel:\n hydratedSheet?.customModel?.currencyModel ?? defaultCurrencyModel,\n commonFilters: [],\n });\n\n let resultData = [] as object[];\n if (\n !_.isEmpty(valueCols) ||\n !_.isEmpty(metadata.rowGroupCols) ||\n !_.isEmpty(metadata.pivotCols)\n ) {\n if (!_.isEmpty(definitionInputs)) {\n let promises = [] as Promise<any>[];\n definitionInputs.forEach((input) => {\n promises.push(\n runPublishedDefinition({\n inputs: { ...input },\n sheet: {\n id: hydratedSheet.id as string,\n lastModifiedDate: hydratedSheet.lastModifiedDate as string,\n },\n variable,\n describe: parentTableVariable,\n })\n );\n });\n const data = await Promise.all(promises);\n resultData = _.map(data, (d) => d.data.data);\n } else {\n const result = (\n await runPublishedDefinition({\n inputs: { ...inputs },\n sheet: {\n id: hydratedSheet.id as string,\n lastModifiedDate: hydratedSheet.lastModifiedDate as string,\n },\n variable,\n describe: parentTableVariable,\n })\n ).data;\n resultData = result.data;\n }\n }\n resultData = _.flatten(resultData);\n\n return { data: resultData };\n};\n","import {\n\tDefinition,\n\tImport,\n\tLoad,\n\tVariable,\n\tExport,\n\tPermission,\n\tTable,\n\tInputs,\n\tAvailableTransform\n} from '$models/ui-models/definitionModel';\nimport { Section } from '$models/ui-models/reportModel';\n\nexport class DefinitionBuilder {\n\tprivate definition: Definition;\n\n\tprivate constructor(def?: Definition) {\n\t\tthis.definition = {\n\t\t\tinputs: {},\n\t\t\taliases: {},\n\t\t\timports: [],\n\t\t\tloads: [],\n\t\t\tvariables: [],\n\t\t\tpermissions: [],\n\t\t\texports: [],\n\t\t\ttables: [],\n\t\t\tsections: []\n\t\t};\n\n\t\tif (def) {\n\t\t\tthis.definition = {\n\t\t\t\t...this.definition,\n\t\t\t\t...def\n\t\t\t};\n\t\t}\n\t}\n\n\tstatic builder(def?: Definition): DefinitionBuilder {\n\t\treturn new DefinitionBuilder(def);\n\t}\n\n\t// Input methods\n\twithInputs(inputs: Inputs): DefinitionBuilder {\n\t\tthis.definition.inputs = { ...this.definition.inputs, ...inputs };\n\t\treturn this;\n\t}\n\n\t// Alias methods\n\twithAlias(tableName: string, columnAliases: Record<string, string>): DefinitionBuilder {\n\t\tif (!this.definition.aliases) {\n\t\t\tthis.definition.aliases = {};\n\t\t}\n\t\tthis.definition.aliases[tableName] = columnAliases;\n\t\treturn this;\n\t}\n\n\t// Import methods\n\taddImport(imprt: Import): DefinitionBuilder {\n\t\tthis.definition.imports?.push(imprt);\n\t\treturn this;\n\t}\n\n\taddDatasetImport(\n\t\tdatasetId: string,\n\t\toptions?: Partial<Omit<Import, 'loc' | 'to' | 'import_type'>>\n\t): DefinitionBuilder {\n\t\tconst imprt: Import = {\n\t\t\tloc: datasetId,\n\t\t\tto: datasetId,\n\t\t\timport_type: 'dataset',\n\t\t\t...options\n\t\t};\n\t\treturn this.addImport(imprt);\n\t}\n\n\t// Load methods\n\taddLoad(load: Load): DefinitionBuilder {\n\t\tthis.definition.loads?.push(load);\n\t\treturn this;\n\t}\n\n\taddFileLoad(\n\t\tfrom: string,\n\t\tto: string,\n\t\tfsOptions: Record<string, unknown> = {}\n\t): DefinitionBuilder {\n\t\tconst load: Load = {\n\t\t\tloc: from,\n\t\t\tto,\n\t\t\tfs_options: fsOptions\n\t\t};\n\t\treturn this.addLoad(load);\n\t}\n\n\t// Variable methods\n\taddVariable(name: string, transforms: AvailableTransform[]): DefinitionBuilder {\n\t\tconst variable: Variable = {\n\t\t\tname,\n\t\t\ttransforms\n\t\t};\n\t\tthis.definition.variables?.push(variable);\n\t\treturn this;\n\t}\n\n\t// Permission methods\n\taddPermission(permission: Permission): DefinitionBuilder {\n\t\tthis.definition.permissions?.push(permission);\n\t\treturn this;\n\t}\n\n\t// Export methods\n\taddExport(exprt: Export): DefinitionBuilder {\n\t\tthis.definition.exports?.push(exprt);\n\t\treturn this;\n\t}\n\n\t// Table methods\n\taddTable(table: Table): DefinitionBuilder {\n\t\tthis.definition.tables?.push(table);\n\t\treturn this;\n\t}\n\n\t// Section methods\n\taddSection(section: Section): DefinitionBuilder {\n\t\tthis.definition.sections?.push(section);\n\t\treturn this;\n\t}\n\n\t// Build method with basic validation\n\tbuild(): Definition {\n\t\tthis.validateDefinition();\n\t\treturn this.definition;\n\t}\n\n\tprivate validateDefinition(): void {\n\t\t// Ensure all referenced tables in aliases exist in imports or loads\n\t\tconst definedTables = new Set([\n\t\t\t...(this.definition.imports?.map((i) => i.to) || []),\n\t\t\t...(this.definition.loads?.map((l) => l.to) || [])\n\t\t]);\n\n\t\tconst aliasedTables = Object.keys(this.definition.aliases || {});\n\t\tfor (const table of aliasedTables) {\n\t\t\tif (!definedTables.has(table)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Table \"${table}\" referenced in aliases but not defined in imports or loads`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Ensure all variables have valid names and transforms\n\t\tthis.definition.variables?.forEach((variable) => {\n\t\t\tif (!variable.name) {\n\t\t\t\tthrow new Error('Variable must have a name');\n\t\t\t}\n\t\t\tif (!Array.isArray(variable.transforms) || variable.transforms.length === 0) {\n\t\t\t\tthrow new Error(`Variable \"${variable.name}\" must have at least one transform`);\n\t\t\t}\n\t\t});\n\t}\n}\n","import { DefinitionBuilder } from \"$models/builders/definitionBuilder\";\nimport { Inputs } from \"$models/ui-models/definitionModel\";\nimport { runDefinition } from \"../definition\";\n\nexport const getData = async (\n datasetId: string,\n options?: { limit?: number }\n) => {\n try {\n if (!datasetId) {\n throw new Error(\"Dataset ID is required\");\n }\n\n // Build the definition model with the dataset import\n const definitionModel = DefinitionBuilder.builder()\n .addDatasetImport(datasetId)\n .build();\n\n const response = await runDefinition({\n definition: definitionModel,\n inputs: definitionModel.inputs as Inputs,\n variable: datasetId,\n limit: options?.limit || 1000,\n });\n\n if (!response?.data) {\n throw new Error(\"No data returned from API\");\n }\n\n return { data: response.data };\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching data for the dataset\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","import { runSampleDefinition } from \"../definition\";\n\nexport const getSampleData = async ({\n datasetId,\n dataFilter,\n duplicateColGroups,\n datasetType,\n}: {\n datasetId: string,\n dataFilter: \"valid_data\" | \"invalid_data\" | \"all_data\",\n duplicateColGroups?: string[],\n datasetType?: string\n}) => {\n try {\n if (!datasetId) {\n throw new Error(\"Dataset ID is required\");\n }\n\n const response = await runSampleDefinition({\n datasetId,\n dataFilter,\n duplicateColGroups,\n datasetType,\n });\n\n if (!response?.data) {\n throw new Error(\"No data returned from API\");\n }\n\n return { data: response.data };\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching sample data\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","import { Workbook } from \"$models/gen/Api\";\nimport { apiClient } from \"../client\";\n\nexport const getPublishedWorkbookById = async ({\n type,\n id,\n}: {\n type: string;\n id: string;\n}) => {\n try {\n const response = await apiClient.post(\"/workbook/published\", {\n type,\n id,\n });\n\n if (!response.data) {\n throw { message: \"Failed to fetch workbook details\", status: 500 };\n }\n return response.data as Workbook;\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching workbook details\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","export enum WorkbookTypeEnum {\n WORKBOOK = \"WORKBOOK\",\n TRANSFORMATION = \"TRANSFORMATION\",\n STATEMENT = \"STATEMENT\",\n DASHBOARD = \"DASHBOARD\",\n PORTAL = \"PORTAL\",\n PROCESS = \"PROCESS\",\n COLLECTION = \"COLLECTION\",\n COST_ALLOCATION_GROUP = \"ALLOCATION_GROUP\",\n ALLOCATION_BLUEPRINT = \"ALLOCATION_BLUEPRINT\",\n FIN_CLOSE = \"FIN_CLOSE\",\n PAGE_TEMPLATE = \"PAGE_TEMPLATE\",\n}\n","import { Workbook } from \"$models/gen/Api\";\nimport { apiClient } from \"../client\";\n\nexport const getTableById = async (tableId: string) => {\n try {\n const response = await apiClient.get(\n `/input-table/get-table/${tableId}`\n );\n\n if (!response.data) {\n throw { message: \"Failed to fetch table details\", status: 500 };\n }\n return response.data as Workbook;\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching table details\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","import _ from \"lodash\";\nimport { LimitOptions, SortOptions } from \"$models/ui-models/workbookModel\";\nimport {\n generateDefinitionModel,\n getGroupByDefinition,\n getMetricSeries,\n sortConfigFromValue,\n} from \"../../utils/inputTable\";\nimport { getPublishedWorkbookById } from \"../workbook/getPublishedWorkbookById\";\nimport { WorkbookTypeEnum } from \"../../types/workbook\";\nimport { getTableById } from \"./getTableById\";\nimport { hydrateWorksheet } from \"../../utils/metric/hydrateWorksheet\";\nimport { apiClient } from \"../client\";\n\nexport const getData = async ({\n inputTableId: inputTableWorkbookId,\n inputTableViewId,\n pageParams = {},\n limitParams,\n sortParams,\n offsetParam,\n}: {\n inputTableId: string;\n inputTableViewId: string;\n pageParams?: any;\n limitParams?: LimitOptions;\n sortParams?: SortOptions;\n offsetParam?: number;\n}) => {\n try {\n if (!inputTableWorkbookId || !inputTableViewId) {\n return [];\n }\n const inputTableWorkbook = await getPublishedWorkbookById({\n id: inputTableWorkbookId,\n type: WorkbookTypeEnum.COLLECTION\n });\n const inputTableId = _.get(\n inputTableWorkbook,\n \"customFields.metadata.inputTableId\"\n );\n\n const inputTable = await getTableById(inputTableId);\n if (!inputTable) {\n throw new Error(\"Input table not found\");\n }\n\n const inputTableView = inputTableWorkbook?.sheets?.find(\n (sheet) => sheet.id === inputTableViewId\n );\n\n if (!inputTableView) {\n throw new Error(\"Input table view not found\");\n }\n\n const hydratedView = await hydrateWorksheet(inputTableView);\n\n if (!hydratedView) {\n throw new Error(\"Failed to hydrate input table view\");\n }\n\n const filters = _.get(hydratedView, \"customModel.filters\");\n const sort = _.get(hydratedView, \"customModel.sort\");\n const limit = _.get(hydratedView, \"customModel.limit\", {}) as LimitOptions;\n const metadata = _.get(hydratedView, \"customModel.metadata\");\n let { targetName, definition } = {\n targetName: \"\",\n definition: {},\n };\n if (hydratedView.type === \"PIVOT\") {\n const gridColumnState = {\n valueCols: _.get(metadata, \"valueCols\", []),\n rowGroupCols: _.get(metadata, \"rowGroupCols\", []),\n filterModel: _.get(metadata, \"filterModel\", {}),\n pivotCols: _.get(metadata, \"pivotCols\", []),\n };\n const metricSeries = getMetricSeries({\n pivotCols: _.get(metadata, \"pivotCols\", []),\n rowGroupCols: _.get(metadata, \"rowGroupCols\", []),\n valueCols: _.get(metadata, \"valueCols\", []),\n });\n\n const columnSettings = _.get(\n hydratedView,\n \"customModel.metadata.columnSettings\"\n );\n const groupByDefinition = getGroupByDefinition({\n tableId: inputTable.id,\n tableName: inputTable.name,\n groupKeys: [],\n rowGroupCols: gridColumnState.rowGroupCols,\n columnSettings,\n filterRules: filters,\n sortValue: sort,\n metricSeries,\n });\n targetName = groupByDefinition.targetName;\n definition = groupByDefinition.definition;\n } else {\n const definitionModel = generateDefinitionModel({\n tableId: inputTable.id as string,\n tableName: inputTable.name,\n filters: filters,\n sort: sortParams?.sortByOrder\n ? sortConfigFromValue(sortParams)\n : sortConfigFromValue(sort),\n });\n targetName = definitionModel.targetName;\n definition = definitionModel.definition;\n }\n\n let stringifiedDefinition = JSON.stringify(definition);\n try {\n const matches = stringifiedDefinition?.match(/{{\\s*([\\w.]+)\\s*}}/g);\n if (matches) {\n matches.forEach((match) => {\n const key = match.replace(/{{\\s*|\\s*}}/g, \"\");\n const value = _.get(pageParams, key, \"\");\n if (value) {\n stringifiedDefinition =\n stringifiedDefinition?.replace(match, value) || \"\";\n }\n });\n }\n } catch (error) {\n console.warn(\"Error evaluating input\", error);\n }\n\n const inputTableResponse = await apiClient.post(\n \"/input-table/get-table-data\",\n {\n targetName,\n definition: JSON.parse(stringifiedDefinition),\n },\n {\n params: {\n limit: limitParams?.limit || limit.limit || 1000,\n offset: offsetParam || 0,\n },\n }\n );\n const data = _.get(inputTableResponse, \"data.result\");\n\n return { data };\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching table details\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","const bluecopaTailwindConfig = {\n darkMode: \"class\",\n important: true,\n theme: {\n fontFamily: {\n para: [\"Bogle\"],\n display: [\"Bogle\"],\n table: [\"Bogle\"],\n },\n fontWeight: {\n normal: \"300\",\n semibold: \"500\",\n bold: \"700\",\n black: \"800\",\n },\n keyframes: {\n \"fadeIn-top-to-bottom\": {\n \"0%\": { transform: \"translateY(-3%)\", opacity: 0 },\n \"100%\": { transform: \"translateY(0)\", opacity: 1 },\n },\n },\n animation: {\n \"fadeIn-t-b\": \"fadeIn-top-to-bottom 0.8s ease-out forwards\",\n \"fadeOut-b-t\": \"fadeIn-top-to-bottom 0.8s ease-out backwards\",\n },\n extend: {\n boxShadow: {\n md: \"2px 2px 10px 0px rgba(0,0,0,0.3)\",\n lg: \"4px 4px 10px 0px rgba(0,0,0,0.3)\",\n xl: \"6px 6px 10px 0px rgba(0,0,0,0.3)\",\n DEFAULT: \"2px 2px 10px 0px rgba(0,0,0,0.3)\",\n },\n colors: {\n primary: {\n 50: \"#ebf4ff\",\n 100: \"#dbe9ff\",\n 200: \"#bed7ff\",\n 300: \"#97bbff\",\n 400: \"#6e92ff\",\n 500: \"#0071dc\",\n 600: \"#3548ff\",\n 700: \"#202ee2\",\n 800: \"#1d2bb6\",\n 900: \"#202d8f\",\n 950: \"#131953\",\n DEFAULT: \"#0071dc\",\n },\n secondary: {\n 50: \"#F9FAFB\",\n 100: \"#F3F4F6\",\n 200: \"#E5E7EB\",\n 300: \"#D1D5DB\",\n 400: \"#9CA3AF\",\n 500: \"#041e42\",\n 600: \"#4B5563\",\n 700: \"#374151\",\n 800: \"#1F2937\",\n 900: \"#111827\",\n DEFAULT: \"#041e42\",\n },\n danger: {\n 50: \"#FEF2F2\",\n 100: \"#FEE2E2\",\n 200: \"#FECACA\",\n 300: \"#FCA5A5\",\n 400: \"#F87171\",\n 500: \"#EF4444\",\n 600: \"#DC2626\",\n 700: \"#B91C1C\",\n 800: \"#991B1B\",\n 900: \"#7F1D1D\",\n DEFAULT: \"#DE1C24\",\n },\n success: {\n 50: \"#EEFFDD\",\n 100: \"#ddedce\",\n 200: \"#bcdb9d\",\n 300: \"#9ac96c\",\n 400: \"#79b73b\",\n 500: \"#89E32F\",\n 600: \"#468408\",\n 700: \"#346306\",\n 800: \"#234204\",\n 900: \"#112102\",\n DEFAULT: \"#53a10f\",\n },\n warning: {\n DEFAULT: \"#fff200\",\n 100: \"#fef3c7\",\n },\n menuBtnBg: \"#ffffff\",\n menuBtnText: \"#041e42\",\n navbarBg: \"#041e42\",\n navbarBlue: \"#041e42\",\n navbarText: \"#fff\",\n headerBg: \"#fff\",\n headerText: \"#041e42\",\n homeHeaderBg: \"#f5f5f4\",\n homeHeaderText: \"#041e42\",\n\n coralRed: \"#ef4444\",\n dartMouthGreen: \"#059669\",\n chestnut: \"#c2410c\",\n softPink: \"#fecaca\",\n darkPurple: \"#6b21a8\",\n darkPastelGreen: \"#4d7c0f\",\n sandyBrown: \"#fb923c\",\n cinnabar: \"#ef4444\",\n tyrianPurple: \"#701a75\",\n ruddyBlue: \"#0891b2\",\n viridian: \"#0f766e\",\n cobaltBlue: \"#1d4ed8\",\n dukeBlue: \"#1e3a8a\",\n jasmine: \"#fde68a\",\n },\n spacing: {\n none: \"0rem\",\n sm: \"0.3025rem\",\n md: \"0.605rem\",\n lg: \"0.9075rem\",\n xl: \"1.21rem\",\n \"2xl\": \"2.42rem\",\n \"3xl\": \"4.84rem\",\n },\n borderRadius: {\n sm: \"1.3rem\",\n md: \"1.3rem\",\n lg: \"1.3rem\",\n DEFAULT: \"1.3rem\",\n },\n fontSize: {\n \"preset-0\": [\"3.013rem\", \"4.513rem\"],\n \"preset-1\": [\"2.505rem\", \"3.763rem\"],\n \"preset-2\": [\"2.093rem\", \"3.146rem\"],\n \"preset-3\": [\"1.742rem\", \"2.626rem\"],\n \"preset-4\": [\"1.452rem\", \"2.190rem\"],\n \"preset-5\": [\"1.21rem\", \"1.815rem\"],\n \"preset-6\": [\"1.004rem\", \"1.513rem\"],\n \"preset-7\": [\"0.835rem\", \"1.258rem\"],\n \"preset-8\": [\"0.702rem\", \"1.053rem\"],\n },\n zIndex: {\n 1: \"1\",\n 2: \"2\",\n 3: \"3\",\n 4: \"4\",\n 5: \"5\",\n 6: \"6\",\n 7: \"7\",\n 8: \"8\",\n 9: \"9\",\n 10: \"10\",\n 1001: \"1001\",\n 1002: \"1002\",\n },\n },\n },\n};\n\nexport default bluecopaTailwindConfig;\n"],"names":["ShowAsEnum","CustomCalculationShowAsEnum","col","_b","_a","_d","_c","_e","valueCol","ProjectFractionEnum","index","blockId","getData","WorkbookTypeEnum"],"mappings":";;;;;AAMA,MAAM,gBAAgB;AAAA,EAIb,cAAc;AACrB,SAAK,SAAS;AAAA,MACb,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,aAAa;AAAA,IAAA;AAAA,EAEf;AAAA,EAEA,OAAc,cAA+B;AAC5C,QAAI,CAAC,gBAAgB,UAAU;AAC9B,sBAAgB,WAAW,IAAI,gBAAA;AAAA,IAChC;AACA,WAAO,gBAAgB;AAAA,EACxB;AAAA,EAEO,UAAU,WAAkC;AAClD,SAAK,SAAS,EAAE,GAAG,KAAK,QAAQ,GAAG,UAAA;AAAA,EACpC;AAAA,EAEO,YAAoB;AAC1B,WAAO,EAAE,GAAG,KAAK,OAAA;AAAA,EAClB;AAAA,EAEO,cAAoB;AAC1B,SAAK,SAAS;AAAA,MACb,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,aAAa;AAAA,IAAA;AAAA,EAEf;AACD;AAGA,MAAM,iBAAiB,gBAAgB,YAAA;AAEhC,SAAS,UAAU,WAAkC;AAC3D,iBAAe,UAAU,SAA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QACV,SAAS;AAAA,MAAA;AAAA,MAEX,SAAS;AAAA,QACP,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,OAAO;AAAA,QACP,OAAO;AAAA,MAAA;AAAA,MAET,cAAc;AAAA,QACZ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,SAAS;AAAA,MAAA;AAAA,MAEX,UAAU;AAAA,QACR,YAAY,CAAC,YAAY,UAAU;AAAA,QACnC,YAAY,CAAC,YAAY,UAAU;AAAA,QACnC,YAAY,CAAC,YAAY,UAAU;AAAA,QACnC,YAAY,CAAC,YAAY,UAAU;AAAA,QACnC,YAAY,CAAC,YAAY,UAAU;AAAA,QACnC,YAAY,CAAC,WAAW,UAAU;AAAA,QAClC,YAAY,CAAC,YAAY,UAAU;AAAA,QACnC,YAAY,CAAC,YAAY,UAAU;AAAA,QACnC,YAAY,CAAC,YAAY,UAAU;AAAA,MAAA;AAAA,MAErC,QAAQ;AAAA,QACN,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,QACH,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,MAAA;AAAA,IACR;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"index.es.js","sources":["../src/config.ts","../src/api/client.ts","../src/api/user/getLoggedInUserDetails.ts","../src/api/workflow/triggerHttpWorkflowById.ts","../src/api/workflow/triggerWorkflowById.ts","../src/api/workflow/getWorkflowInstanceStatusById.ts","../src/api/file/getFileUrlByFileId.ts","../src/api/definition/runPublishedDefinition.ts","../src/api/definition/runSampleDefinition.ts","../src/api/definition/runDefinition.ts","../src/api/worksheet/getWorksheets.ts","../src/api/worksheet/getWorksheetsByType.ts","../src/utils/date.ts","../../models/src/lib/ui-models/workbookModel.ts","../src/utils/metric/filterUtils.ts","../../models/src/lib/ui-models/definitionModel.ts","../src/utils/metric/analysisMethods.ts","../src/utils/metric/mergeFilterService.ts","../src/utils/metric/getMetricDefinition.ts","../src/utils/inputTable/inputTableDefinition.ts","../src/utils/file/downloadFile.ts","../src/utils/metric/hydrateWorksheet.ts","../src/api/metric/getData.ts","../../models/src/lib/builders/definitionBuilder.ts","../src/api/dataset/getData.ts","../src/api/dataset/getSampleData.ts","../src/api/dataset/getDatasets.ts","../src/api/workbook/getPublishedWorkbookById.ts","../src/types/workbook.ts","../src/api/inputTable/getTableById.ts","../src/api/inputTable/getData.ts","../src/api/inputTable/getInputTables.ts","../src/api/workbook/getWorkbooksByType.ts","../src/tailwind/bluecopa.config.ts"],"sourcesContent":["export interface Config {\n\tapiBaseUrl: string;\n\taccessToken: string;\n\tworkspaceId: string;\n}\n\nclass ConfigSingleton {\n\tprivate static instance: ConfigSingleton;\n\tprivate config: Config;\n\n\tprivate constructor() {\n\t\tthis.config = {\n\t\t\tapiBaseUrl: '',\n\t\t\taccessToken: '',\n\t\t\tworkspaceId: '',\n\t\t};\n\t}\n\n\tpublic static getInstance(): ConfigSingleton {\n\t\tif (!ConfigSingleton.instance) {\n\t\t\tConfigSingleton.instance = new ConfigSingleton();\n\t\t}\n\t\treturn ConfigSingleton.instance;\n\t}\n\n\tpublic setConfig(newConfig: Partial<Config>): void {\n\t\tthis.config = { ...this.config, ...newConfig };\n\t}\n\n\tpublic getConfig(): Config {\n\t\treturn { ...this.config }; // Return a copy to prevent external mutations\n\t}\n\n\tpublic resetConfig(): void {\n\t\tthis.config = {\n\t\t\tapiBaseUrl: '',\n\t\t\taccessToken: '',\n\t\t\tworkspaceId: '',\n\t\t};\n\t}\n}\n\n// Export convenience functions that use the singleton instance\nconst configInstance = ConfigSingleton.getInstance();\n\nexport function setConfig(newConfig: Partial<Config>): void {\n\tconfigInstance.setConfig(newConfig);\n}\n\nexport function getConfig(): Config {\n\treturn configInstance.getConfig();\n}\n\nexport function resetConfig(): void {\n\tconfigInstance.resetConfig();\n}\n\n// Export the singleton class for advanced usage if needed\nexport { ConfigSingleton };\n\n\n","import axios, {\n AxiosInstance,\n AxiosResponse,\n InternalAxiosRequestConfig,\n} from \"axios\";\nimport { getConfig, setConfig } from \"../config\";\n\n// Create axios instance with default configuration\nconst createApiClient = (): AxiosInstance => {\n const client = axios.create({\n timeout: 10000,\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n // Request interceptor to add auth token and dynamic baseURL\n client.interceptors.request.use(\n (config: InternalAxiosRequestConfig) => {\n const copaConfig = getConfig();\n \n // Always update baseURL from current config\n if (copaConfig.apiBaseUrl) {\n config.baseURL = copaConfig.apiBaseUrl;\n }\n \n // Add auth headers if available\n if (copaConfig.accessToken && config.headers) {\n config.headers[\"X-COPA-TOKEN\"] = `Bearer ${copaConfig.accessToken}`;\n }\n \n if (copaConfig.workspaceId && config.headers) {\n config.headers[\"X-COPA-WORKSPACE-ID\"] = copaConfig.workspaceId;\n }\n \n console.log('API Request Config:', {\n baseURL: config.baseURL,\n hasToken: !!copaConfig.accessToken,\n hasWorkspaceId: !!copaConfig.workspaceId\n });\n \n return config;\n },\n (error) => {\n return Promise.reject(error);\n }\n );\n\n // Response interceptor for error handling\n client.interceptors.response.use(\n (response: AxiosResponse) => {\n return response;\n },\n (error) => {\n // Handle common errors\n if (error.response?.status === 401) {\n setConfig({ accessToken: \"\", workspaceId: \"\" });\n // You might want to redirect to login page here\n }\n return Promise.reject(error);\n }\n );\n\n return client;\n};\n\n// Export the configured client instance\nexport const apiClient = createApiClient();\n","import { apiClient } from \"../client\";\n\nexport interface UserDetails {\n id: string;\n email: string;\n name: string;\n role: string;\n workspaceId: string;\n avatar?: string;\n preferences?: Record<string, any>;\n lastLoginAt?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ApiResponse<T> {\n success: boolean;\n data: T;\n message?: string;\n}\n\n/**\n * Fetches the logged-in user's details from the API\n * @returns Promise<{ user: UserDetails }> The user's details\n * @throws Error if the request fails or user is not authenticated\n */\nexport async function getLoggedInUserDetails(): Promise<{ user: UserDetails }> {\n try {\n const response = await apiClient.get(\"/user/current\");\n\n if (!response.data) {\n throw { message: \"Failed to fetch user details\", status: 500 };\n }\n return response.data as { user: UserDetails };\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching user details\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n}\n","import { apiClient } from \"../client\";\n\nexport interface TriggerHttpWorkflowRequest {\n data: Record<string, any>;\n triggerId: string;\n}\n\nexport interface TriggeredWorkflow {\n workflowId: string;\n triggerId: string;\n}\n\nexport interface TriggerHttpWorkflowResponse {\n triggeredWorkflows: TriggeredWorkflow[];\n}\n\n/**\n * Triggers an HTTP workflow with the provided data\n * @param params - The trigger parameters\n * @param params.triggerId - The ID of the HTTP trigger\n * @param params.data - The data payload to send to the workflow\n * @returns Promise<TriggerHttpWorkflowResponse> The triggered workflow details\n * @throws Error if the request fails\n */\nexport async function triggerHttpWorkflowById({\n data,\n triggerId,\n}: TriggerHttpWorkflowRequest): Promise<TriggerHttpWorkflowResponse> {\n try {\n const response = await apiClient.post(`/http-trigger/${triggerId}`, data);\n if (!response.data) {\n throw { message: \"Failed to trigger HTTP workflow\", status: 500 };\n }\n\n return response.data;\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while triggering the HTTP workflow\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n}\n","import { apiClient } from \"../client\";\n\nexport interface TriggerWorkflowRequest {\n parentId: string;\n triggerBy: string;\n}\n\nexport interface TriggerWorkflowResponse {\n workbookId: string;\n triggerBy: string;\n instanceId: string;\n triggerId: string;\n workflowId: string;\n status: string;\n triggeredAt: string;\n message: string;\n}\n\n/**\n * Triggers workflow\n * @param params - The trigger parameters\n * @param params.parentId - The ID of the workflow to be triggered\n * @param params.triggerBy - The user who triggered the workflow\n * @returns Promise<TriggerWorkflowResponse> The triggered workflow details\n * @throws Error if the request fails\n */\nexport async function triggerWorkflowById({\n parentId, triggerBy,\n}: TriggerWorkflowRequest): Promise<TriggerWorkflowResponse> {\n try {\n const response = await apiClient.post('/workflow/trigger', { parentId, triggerBy });\n if (!response.data) {\n throw { message: \"Failed to trigger workflow\", status: 500 };\n }\n\n return response.data;\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while triggering the workflow\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n}\n","import { apiClient } from '../client';\n\nexport type WorkflowStatusRequest = ReadonlyArray<{\n instanceId: string;\n parentId: string;\n}>;\n\nexport enum WorkflowStatus {\n Succeeded = 'Succeeded',\n Failed = 'Failed',\n Running = 'Running',\n NotFound = 'NotFound'\n}\n\nexport type StepInfo = { stepId: string; name: string; stepOutput: Record<string, any> };\n\nexport type WorkflowStatusResponse = {\n instanceId: string;\n processName: string;\n parentId: string;\n status: WorkflowStatus;\n message: string;\n data: {\n completed: StepInfo[];\n running: StepInfo[];\n failed?: StepInfo[];\n };\n completedAt: string;\n error?: string;\n};\n\nexport type WorkflowStatusResponses = ReadonlyArray<WorkflowStatusResponse>;\n\nexport const getWorkflowInstanceStatusById = async (request: WorkflowStatusRequest): Promise<WorkflowStatusResponses> => {\n try {\n const response = await apiClient.post('/workflow/instances/status', request);\n\n if (!response.data) {\n throw { message: 'Failed to fetch workflow statuses', status: 500 };\n }\n return response.data as WorkflowStatusResponses;\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n 'An unexpected error occurred while fetching workflow statuses';\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};","import { apiClient } from \"../client\";\n\nexport interface GetFileUrlRequest {\n key: string;\n contentType: string;\n method: 'GET' | 'PUT' | 'POST';\n}\n\nexport interface GetFileUrlResponse {\n url: string;\n}\n\n/**\n * Gets a signed URL for a file by its key\n * @param params - The file request parameters\n * @param params.key - The file key/path in storage\n * @param params.contentType - The content type of the file\n * @param params.method - The HTTP method (GET, PUT, POST)\n * @returns Promise<GetFileUrlResponse> The signed URL for the file\n * @throws Error if the request fails\n */\nexport async function getFileUrlByFileId({\n key, contentType, method,\n}: GetFileUrlRequest): Promise<GetFileUrlResponse> {\n try {\n\tconst response = await apiClient.post('/file/url', { key, contentType, method });\n\tif (!response.data) {\n\t throw { message: \"Failed to get file URL\", status: 500 };\n\t}\n\n\treturn { url: response.data };\n } catch (error: any) {\n\tconst message =\n\t error.response?.data?.message ||\n\t error.message ||\n\t \"An unexpected error occurred while getting file URL\";\n\tconst status = error.response?.status || 500;\n\tthrow { message, status };\n }\n}\n","import { CancelTokenSource } from \"axios\";\nimport { apiClient } from \"../client\";\n\nexport const runPublishedDefinition = async (props: {\n describe: string;\n sheet: { id: string; lastModifiedDate: string };\n variable: string;\n inputs: object;\n source?: CancelTokenSource;\n}) => {\n const { sheet, variable, inputs, describe, source } = props;\n\n if (!sheet) {\n throw new Error(`Definition is null`);\n }\n if (!variable) {\n throw new Error(`Variable is null`);\n }\n\n return apiClient.post(\n \"/definition/run-published\",\n {\n sheet: sheet,\n variable: variable,\n inputs: inputs,\n describe,\n },\n { cancelToken: source?.token }\n );\n};\n","import { apiClient } from \"../client\";\n\nexport const runSampleDefinition = async (props: {\n datasetId: string;\n dataFilter: \"valid_data\" | \"invalid_data\" | \"all_data\";\n duplicateColGroups?: string[];\n datasetType?: string;\n}) => {\n const { datasetId, dataFilter, duplicateColGroups, datasetType } = props;\n\n if (!datasetId) {\n throw new Error(`Dataset ID is null`);\n }\n if (!dataFilter) {\n throw new Error(`Data filter is null`);\n }\n\n return apiClient.post(\n \"/definition/run-sample\",\n { datasetId, dataFilter, duplicateColGroups, datasetType }\n );\n};\n","import { CancelTokenSource } from \"axios\";\nimport { apiClient } from \"../client\";\nimport { Definition, Inputs, Variable } from \"$models/ui-models/definitionModel\";\n\nexport const runDefinition = async (props: {\n inputs: Inputs;\n definition: Definition;\n variable: string;\n source?: CancelTokenSource;\n limit?: number;\n}) => {\n const { definition, variable, inputs, limit, source } = props;\n\n if (!definition) {\n throw new Error(`Definition is null`);\n }\n if (!variable) {\n throw new Error(`Variable is null`);\n }\n if (!inputs) {\n throw new Error(`Inputs is null`);\n }\n\n return apiClient.post(\n \"/definition/run\",\n { inputs, definition, variable, limit },\n { cancelToken: source?.token }\n );\n};\n","import { Worksheet } from \"$models/gen/Api\";\nimport { apiClient } from \"../client\";\n\nexport const getWorksheets = async (worksheetIds: string[]) => {\n try {\n const response = await apiClient.post(\"/worksheet/get-worksheets\", {\n ids: worksheetIds,\n });\n\n if (!response.data) {\n throw { message: \"Failed to fetch worksheets details\", status: 500 };\n }\n return response.data as Worksheet[];\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching worksheets details\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","import { Worksheet } from \"$models/gen/Api\";\nimport { apiClient } from \"../client\";\n\nexport const getWorksheetsByType = async (type: Worksheet[\"type\"]) => {\n try {\n const response = await apiClient.post(\"/worksheet/get-worksheets-by-type\", {\n type,\n });\n\n if (!response.data) {\n throw { message: \"Failed to fetch worksheets\", status: 500 };\n }\n return response.data as Worksheet[];\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching worksheets\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","export function formatDate(date: Date): string {\n return date.toISOString().split('T')[0];\n}\n","import type { CompactNotation, Currency } from '$models/common/localeUtils';\nimport type { HierarchyProperties, Workbook, Worksheet } from '$models/gen/Api';\nimport type { SelectOptionType } from '$models/types/selectType';\nimport type { DateRange } from '$models/ui-models/dateRangeModel';\nimport type {\n\tDefinition,\n\tFormatRule,\n\tGroupByHierarchyType,\n\tInputs,\n\tTimeBin\n} from '$models/ui-models/definitionModel';\nimport type { FilterRule } from '$models/ui-models/filterModel';\nimport { F } from 'vite/dist/node/types.d-aGj9QkWt';\nimport { YAxisCountEnum } from './chartModels';\nimport type { CrossFiltersModalDataType, DashboardBlockProperties } from './dashboardModel';\nimport { InputTableDefinitionModel } from './inputTableModel';\nimport type { MapFxModel } from './mapFxModel';\nimport { PortalDefinition } from './portalWidgetDefinition';\nimport { ProcessDefinition } from './processDefinitionTypes';\nimport type { Report, StatementPlan } from './reportModel';\nimport { DocumentTypeEnum } from './workspaceTreeModel';\n\nexport const DASHBOARD_TYPE = 'DASHBOARD';\nexport const STATEMENT_TYPE = 'STATEMENT';\nexport const PLAN_TYPE = 'PLAN';\n\nexport type BoardTypes = 'DASHBOARD' | 'STATEMENT' | 'PLAN';\nexport type WorkbookSheetTypes = 'WORKSHEET' | 'PIVOT' | 'METRIC' | 'STATEMENT';\n\nexport type ModelUpdateType = 'DEFINITION' | 'MODEL' | 'THUMBNAIL' | 'FAVORITE';\n\nexport type PivotProperties = {\n\trowGroup: any;\n\tcolGroup: any;\n};\n\nexport type TableMaps = Record<string, any[]>;\n\nexport type SheetCreationOptions = 'newSheet' | 'existingSheet';\nexport type LineType = 'PIVOT' | 'FORMULA';\n\nexport type MetricSeriesAdditional = {\n\tchartSettings: {\n\t\tdisplayMode: 'chart' | 'table';\n\t};\n\n\tconfiguration: {\n\t\tbinValue: string;\n\t\tdataField: string;\n\t\trowgroup: string[];\n\t\tvalues: string[];\n\t\tfilters: unknown;\n\t};\n};\n\nexport type ColumnSetting = {\n\tcurrency?: Currency;\n\tdateFormat?: string;\n\tfield: string; // data is reflected in the grid based on fields\n\theaderName: string; // header name is reflected in the grid\n\tprecision?: number; // set precision value\n\ttype?: 'str' | 'f64' | 'i64' | 'date' | \"datetime(time_unit='us', time_zone=None)\"; // ex -> ['dateColumn', 'nonEditableColumn'], 'nonEditableColumn'\n\tclearFormatting?: boolean; // clear all formatting, including defaults\n\tvalueFormatter?: (params: any) => any; // formate the value\n\tvalueGetter?: (params: any) => any; // will have access to other params and can do calculations\n\theaderTooltip?: string; // tooltip for the header\n\theaderClass?: string | string[] | ((params: any) => string | string[] | undefined);\n\theaderComponent?: any; // custom header component\n\tcolId?: string; // unique id for the column - optional\n\tcheckboxSelection?: boolean; // if true, will have a checkbox in the column\n\tshowDisabledCheckboxes?: boolean; // if true, will show disabled checkbox, default -> false\n\ticons?: { [key: string]: Function | string };\n\tsuppressNavigable?: boolean; // et to true if this column is not navigable (i.e. cannot be tabbed into), otherwise false. Can also be a callback function to have different rows navigable.\n\tsuppressKeyboardEvent?: Function; //Allows the user to suppress certain keyboard events in the grid cell. See Suppress Keyboard Events.\n\thide?: boolean; // show hide the columns\n\tlockVisible?: boolean; //Set to true to block making column visible / hidden via the UI (API will still work).\n\tlockPosition?: boolean | 'left' | 'right'; //Lock a column to position to 'left' or'right' to always have this column displayed in that position. true is treated as 'left'\n\tsuppressMovable?: boolean; //Set to true to block moving this column via dragging\n\tmenuTabs?: string[]; // Set to an array containing zero, one or many of the following options: 'filterMenuTab' | 'generalMenuTab' | 'columnsMenuTab'. This is used to figure out which menu tabs are present and in which order the tabs are shown.\n\tsuppressMenu?: boolean; //Set to true to not show the column menu when the column header is right clicked.\n\tpinned?: boolean | 'left' | 'right' | null;\n\teditable?: boolean;\n\tcellClassRule?: {\n\t\t[key: string]: (params: any) => boolean;\n\t};\n\tenableRowGroup?: boolean;\n\tenablePivot?: boolean;\n\tenableValue?: boolean;\n\tunique_count?: number;\n\tcellRendererParams?: any;\n\tcellRenderer?: string | Function;\n\twidth?: number;\n\taggFunc?: string;\n\tisCurrency?: boolean;\n\tisPercentage?: boolean;\n\tisNumber?: boolean;\n\tshowAs?: ShowAsType | CustomCalculationsShowAsType;\n\tminWidth?: number;\n\tcellClass?: string | string[] | ((params: any) => string | string[] | undefined);\n\tcellDataType?: boolean;\n\tsheetName?: string;\n\tisFormulaColumn?: boolean;\n\tisLookupColumn?: boolean;\n\tisJoinColumn?: boolean;\n\tcompactNotation?: CompactNotation;\n\tdatasetId?: string;\n\tdatasetName?: string;\n\tcolumnGroup?: string;\n\tcolumnGroupShow?: 'open' | 'closed';\n\tmarryChildren?: boolean;\n\tchildren?: ColumnSetting[];\n\tgroupId?: string;\n};\n\nexport enum ShowAsEnum {\n\tDEFAULT = 'default',\n\tROW = 'row',\n\tCOLUMN = 'column',\n\tGRAND_TOTAL = 'grandTotal'\n}\n\nexport enum CustomCalculationShowAsEnum {\n\tNONE = 'none',\n\tFORMULA = 'formula',\n\tAGGREGATE = 'aggregate'\n}\n\nexport type UiSettings = {\n\tfontSize?: number;\n\tdecimalPlaces?: {\n\t\t[colId: string]: number;\n\t};\n\tcolumnSettings?: ColumnSetting[];\n};\n\nexport type CustomModel = {};\nexport type LookupSetting = {\n\tleftCol: string;\n\trightCol: string;\n\trightSheetId: string;\n\tselectedColumns: { col: string; alias: string }[];\n};\n\nexport type XLookupSetting = {\n\tlookup_sheet_id: string;\n\tlookup_col: string;\n\tlookup_sheet: string;\n\twith_col: string;\n\treturn_col: string; // this is the id of the column in the lookup sheet\n\tsort_col?: string;\n\tsort_order?: string;\n\tselection_mode?: boolean;\n\treturn_col_id?: string; // this is the id of the column in the current sheet\n};\n\nexport type WorkbookCustomModel = {\n\tinputs?: Inputs;\n\tvariable?: string;\n\tfilterColumnsBy?: FilterColumnsBy;\n\tdateRange?: DateRange;\n\tuiSettings?: UiSettings;\n\tworksheetType?: 'TableSheet';\n\tdatasetId?: string;\n\tdatasetName?: string;\n\tparentTableColumnSettings?: ColumnSetting[];\n\tcurrency?: string;\n\tlookupSettings?: LookupSetting[];\n\tformatSettings?: FormatRule[];\n\txLookupSettings?: XLookupSetting[];\n\tsortOptions?: SortOptionsForWorkbook;\n};\n\nexport type ReconWorkbookCustomModel = WorkbookCustomModel & {\n\tdateColumn?: string;\n};\n\nexport type RowGroupsType = Array<string | string[]>;\n\nexport type GridColumnState = {\n\tvalueCols: ValueColsType[];\n\tfilterModel: any;\n\trowGroupCols: RowGroupsType;\n\tpivotCols: string[];\n};\n\nexport type SortOptions = {\n\tsortByField: SelectOptionType | undefined;\n\tsortByOrder: 'asc' | 'desc';\n\t/** Intervals to sort data based on (for trends) */\n\tpivotFilters?: string[];\n};\nexport type SortOptionsForWorkbook = {\n\tsortByField: SelectOptionType | undefined | SelectOptionType[];\n\tsortByOrder: 'asc' | 'desc' | undefined | ('asc' | 'desc')[];\n};\n\nexport type LimitOptions = {\n\tlimit: number;\n\tlimitFrom: 'top' | 'bottom';\n};\n\nexport type PivotCustomModel = WorkbookCustomModel & {\n\tchartType?: string;\n\tparentTableId: string;\n\tgridColumnState?: GridColumnState;\n\tparentTableVariable: string;\n\ttimeBin?: TimeBin | '';\n\tcompareTrends?: Array<{ id: string; name: string; dateRange: DateRange }>;\n\tdateColumn?: string;\n\tdatasetId: string;\n\tdatasetName: string;\n\thierarchy?: HierarchyProperties;\n\tcurrency?: string;\n\tsortOptions?: SortOptions;\n\tlimitOptions?: LimitOptions;\n\tcolorPalette?: string;\n\tsettings?: any;\n\tcolumnWidth?: any;\n\tshowDimensionMappingValues?: boolean;\n\tshowBinSortOrderValues?: boolean;\n\tplotAsTrendsOrder?: 'asc' | 'desc' | 'none';\n\tpivotColumnFormatMap?: Record<string, ColumnSetting>;\n};\n\nexport type MetricViewMode = 'grid' | 'chart' | 'geomap';\n\nexport type TableCustomModel = WorkbookCustomModel & {\n\tcolumns?: string[];\n};\n\nexport type LineCustomModel = WorkbookCustomModel & {\n\tparentTableVariable?: string;\n\tparentTableId?: string;\n\tvalueCols?: ValueColsType[];\n\tallValueCols?: ValueColsType[];\n\tfilterModel?: any;\n\ttimeBin?: TimeBin;\n\tdateColumn?: string;\n\tgroupBy?: string[];\n\tpivotCols?: string[];\n};\n\nexport type Line = {\n\tid: string;\n\ttype: LineType;\n\tsheetId?: string;\n\tvariable?: string;\n\tinputs?: any;\n\tcustomModel?: LineCustomModel;\n\tdefinitionModel?: Definition;\n\tdisplayName?: string;\n\tformula?: string;\n\tlastModifiedDate?: string;\n\tpublishedVersion?: number;\n\tcurrency?: Currency;\n\tprecision?: number;\n\tdateFormat?: string;\n\tclearFormatting?: boolean;\n};\nexport type ShowAsType = 'default' | 'row' | 'column' | 'grandTotal';\nexport type CustomCalculationsShowAsType = 'none' | 'formula' | 'aggregate';\nexport type PivotGridDisplayType = { gridData: any[]; gridColumns: any[] };\nexport type ValueColsType = {\n\tlabel?: string;\n\tcol: string;\n\taggFun?: string;\n\tformula?: string;\n\tcurrency?: Currency;\n\tprecision?: number;\n\tnumberFormat?: string;\n\tdateFormat?: string;\n\tclearFormatting?: boolean;\n\timpact?: 'positive' | 'negative';\n\tchartColorBasedOnImpact?: boolean;\n\ttype?: 'value' | 'formula' | 'column';\n\tisCurrency?: boolean;\n\tisPercentage?: boolean;\n\tisNumber?: boolean;\n\tshowAs?: ShowAsType | CustomCalculationsShowAsType;\n\tisAmortize?: boolean;\n\thide?: boolean;\n\tcompactNotation?: CompactNotation;\n\thideGrandTotal?: boolean;\n\tsourceLabel?: string; // Label of the valueCol this is based/derived from\n\tcompareTrendId?: string;\n\tshowRowTotal?: boolean;\n};\nexport type Section = {\n\tid: string;\n\theader: string;\n\tlines: Line[];\n};\n\nexport type Statement = {\n\tsections: Section[];\n\tformulaColumns?: string[];\n\ttimeBinOption: { label: string; value: TimeBin };\n\tinputs?: Inputs;\n};\n\nexport type DashboardDateRangeModel = {\n\tdateRange: DateRange;\n\tappliedOnBlocks: { blockId: string; blockName: string; applied: boolean }[];\n};\n\nexport type BoardCurrencyModel = {\n\tcurrency: string;\n\tappliedOnBlocks: { blockId: string; blockName: string; applied: boolean }[];\n};\n\nexport type Sheet<\n\tT extends CustomModel = any,\n\tD extends\n\t\t| Definition\n\t\t| MapFxModel\n\t\t| Report\n\t\t| ProcessDefinition\n\t\t| PortalDefinition\n\t\t| StatementPlan\n\t\t| InputTableDefinitionModel = Definition\n> = Worksheet & {\n\tcustomModel?: T;\n\tdefinitionModel?: D;\n};\n\n//Same model for Board and Workbook\nexport type WorkbookModel<T extends CustomModel = any> = Omit<Workbook, 'sheets'> & {\n\tsheets: Sheet<T>[];\n};\n\nexport type FilterBy = 'value' | 'condition';\n\nexport type FilterColumnsBy = { [column: string]: FilterBy };\n\nexport type WeakLinkType = {\n\tdocumentId: string;\n\tsheetId: string;\n\ttype: DocumentTypeEnum.WORKBOOK | DocumentTypeEnum.STATEMENT;\n};\n\nexport type MetricMetadataType = {\n\tparentTableVariable?: string;\n\tvariable: string;\n\tdatasetId?: string;\n\tdatasetName?: string;\n\tcolumnSettings: ColumnSetting[];\n\tdateColumn?: string;\n\tdateRange?: DateRange;\n\tfilterColumnsBy?: FilterColumnsBy;\n\tinputs: Inputs;\n\taliases?: { [key: string]: string };\n\tvalueCols?: ValueColsType[];\n\tfilterModel?: FilterRule | [];\n\trowGroupCols?: RowGroupsType;\n\tpivotCols?: string[];\n\ttimeBin?: TimeBin | '';\n\thierarchy?: HierarchyProperties;\n\tcurrency?: string;\n\tsortOptions?: SortOptions;\n\tlimitOptions?: LimitOptions;\n\tlastModifiedDate?: string;\n\tdescription?: string;\n\tscore?: string;\n\tisKPI?: boolean;\n\tcrossFilterModel?: CrossFiltersModalDataType;\n\tviewFilterModel?: any;\n\thierarchyCol?: GroupByHierarchyType;\n\tweakLink?: WeakLinkType;\n\tstringValue?: boolean;\n\tcompareTrends?: Array<{ id: string; name: string; dateRange: DateRange }>;\n\tshowDimensionMappingValues?: boolean;\n\tshowBinSortOrderValues?: boolean;\n\tplotAsTrendsOrder?: 'asc' | 'desc' | 'none';\n\tpivotColumnFormatMap?: Record<string, ColumnSetting>;\n\tcolumnWidth?: Record<string, number>;\n};\n\n/**\n * Settings for configuring geographical map visualizations.\n * @property {string} country - The country for which the map is displayed (currently supports 'India').\n * @property {string} cityColumn - The column containing city names.\n * @property {string} aggregateByCol - The column to aggregate data by.\n * @property {string[]} showInTooltip - Fields to display in the tooltip.\n * @property {string[]} fieldToIndicateZeroValues - Fields that should be highlighted when zero.\n * @property {string} fillColor - The color used to fill the markers.\n * @property {string} borderColor - The color used for marker borders.\n */\nexport type GeomapSettings = {\n\tcountry: string;\n\tcityColumn: string;\n\taggregateByCol: string;\n\tshowInTooltip: string[];\n\tfieldToIndicateZeroValues: string[];\n\tfillColor: string;\n\tborderColor: string;\n};\n\ntype FunnelChartSortOrder = 'descending' | 'ascending' | 'none';\n\nexport type FunnelChartSettings = {\n\thideLabels: boolean;\n\tselectedValueColumn: string;\n\tsortOrder: FunnelChartSortOrder;\n\tmin: number;\n\tmax: number;\n};\n\nexport type MetricSettingsType = {\n\tchartType?: string;\n\thideTooltipHeader?: boolean;\n\tchartTypeBeforeDrilldown?: string;\n\tviewMode: MetricViewMode;\n\tcolorPalette?: string;\n\taxisDistributionType?: 'value' | 'log';\n\tyAxisCount?: YAxisCountEnum;\n\tlabelPosition?: string;\n\tlabelRotation?: string;\n\twaterfallParentMapping?: Record<string, string>;\n\tgeomapSettings?: GeomapSettings;\n\tfunnelChartSettings?: FunnelChartSettings;\n\tchartSettings?: Record<string, any>;\n};\n\nexport type DashboardProperties = { [cols in number]?: DashboardBlockProperties };\n\nexport type MetricCustomModel = DashboardProperties & {\n\tmetadata: MetricMetadataType;\n\tsettings: MetricSettingsType;\n\taddedMode?: 'imported' | 'created';\n};\n","import type { SelectOptionType } from '$models/types/selectType';\nimport {\n\toperatorsWithIsNotTrue,\n\ttype FilterRule,\n\ttype FilterSelectOptionsType,\n\ttype FilterUniqueValueSelectOptionsType,\n\ttype RuleType\n} from '$models/ui-models/filterModel';\nimport { FilterColumnsBy, ValueColsType } from '$models/ui-models/workbookModel';\nimport { Operator } from '$models/ui-models/filterModel';\nimport _ from 'lodash';\n\nexport type FilterPanelStoreType = {\n\tdefaultType: Omit<RuleType, 'cond'>;\n\trules: FilterSelectOptionsType[];\n};\n\nconst defaultFilterPanel: FilterRule = {\n\tis_not: false,\n\trule_type: 'and_cond',\n\trules: []\n};\n\nexport const filterToSelectOptionType = (\n\tfilter: FilterRule,\n\tcolumns: SelectOptionType[]\n): FilterPanelStoreType => {\n\tconst rules: FilterRule[] = filter?.rules as FilterRule[] || [];\n\n\tif (!rules || rules.length === 0) {\n\t\treturn {\n\t\t\tdefaultType: 'and_cond',\n\t\t\trules: []\n\t\t};\n\t}\n\n\tconst selectOptionsForRules: FilterSelectOptionsType[] = rules.map((rule) =>\n\t\tgetSelectionOptionsFromFilter(rule, columns)\n\t);\n\treturn {\n\t\tdefaultType: (filter?.rule_type as Omit<RuleType, 'cond'>) || 'and_cond',\n\t\trules: selectOptionsForRules\n\t};\n};\n\nexport const getSelectionOptionsFromFilter = (\n\trule: FilterRule,\n\tcolumns: SelectOptionType[]\n): FilterSelectOptionsType => {\n\tif (_.isEmpty(rule?.rules)) {\n\t\tconst col = columns.find((column) => column.label === rule.col || column.value === rule.col);\n\n\t\treturn {\n\t\t\tlabel: col?.label || '',\n\t\t\tvalue: col?.value || '',\n\t\t\toption: {\n\t\t\t\taggFun: col?.option?.aggFun,\n\t\t\t\tuniqueValues: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: col?.label || '',\n\t\t\t\t\t\tvalue: col?.value || '',\n\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\tuniqueValue: rule?.value as string | number | boolean,\n\t\t\t\t\t\t\toperator: rule?.operator,\n\t\t\t\t\t\t\truleType: rule?.rule_type || 'cond',\n\t\t\t\t\t\t\tisNot: rule?.is_not || false,\n\t\t\t\t\t\t\tcaseSensitive: rule?.is_case_sensitive ?? true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tuniqueValueCount: col?.option?.uniqueCount,\n\t\t\t\ttype: col?.option?.type,\n\t\t\t\truleType: rule?.rule_type || 'cond'\n\t\t\t}\n\t\t};\n\t}\n\tconst col = columns?.find(\n\t\t(column) => column.label === rule?.rules?.[0]?.col || column.value === rule?.rules?.[0]?.col\n\t);\n\tconst isValueFilter = _.get(rule, 'rules.0.operator', null) === 'in_op' && _.get(rule, 'rules.0.value', null);\n\tif (isValueFilter) {\n\t\treturn {\n\t\t\tlabel: col?.label || '',\n\t\t\tvalue: col?.value || '',\n\t\t\toption: {\n\t\t\t\taggFun: col?.option?.aggFun,\n\t\t\t\tuniqueValues: rule?.rules?.[0]?.value?.map((r: string) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tlabel: col?.label || '',\n\t\t\t\t\t\tvalue: col?.value || '',\n\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\taggFun: col?.option?.aggFun,\n\t\t\t\t\t\t\tuniqueValue: r,\n\t\t\t\t\t\t\toperator: 'equal',\n\t\t\t\t\t\t\truleType: 'cond',\n\t\t\t\t\t\t\tisNot: false,\n\t\t\t\t\t\t\tcaseSensitive: true\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}) || [],\n\t\t\t\tuniqueValueCount: col?.option?.uniqueCount,\n\t\t\t\ttype: col?.option?.type,\n\t\t\t\truleType: rule?.rule_type || 'cond'\n\t\t\t}\n\t\t};\n\t}\n\treturn {\n\t\tlabel: col?.label || '',\n\t\tvalue: col?.value || '',\n\t\toption: {\n\t\t\taggFun: col?.option?.aggFun,\n\t\t\tuniqueValues: rule?.rules?.map((r: FilterRule) => {\n\t\t\t\tconst childCol = columns?.find((column) => column.value === r.col);\n\t\t\t\treturn {\n\t\t\t\t\tlabel: childCol?.label || '',\n\t\t\t\t\tvalue: childCol?.value || '',\n\t\t\t\t\toption: {\n\t\t\t\t\t\taggFun: childCol?.option?.aggFun,\n\t\t\t\t\t\tuniqueValue: r?.value as string | number | boolean,\n\t\t\t\t\t\toperator: r?.operator,\n\t\t\t\t\t\truleType: r?.rule_type || 'cond',\n\t\t\t\t\t\tisNot: r?.is_not || false,\n\t\t\t\t\t\tcaseSensitive: r?.is_case_sensitive ?? true\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}) || [],\n\t\t\tuniqueValueCount: col?.option?.uniqueCount,\n\t\t\ttype: col?.option?.type,\n\t\t\truleType: rule?.rule_type || 'cond'\n\t\t}\n\t};\n};\n\nexport const getSelectOptionTypeToFilter = (\n\tfilter: FilterPanelStoreType,\n\tfilterColumnsBy?: FilterColumnsBy\n): FilterRule => {\n\tconst rules: FilterSelectOptionsType[] = filter?.rules;\n\tconst defaultRuleType = filter?.defaultType;\n\n\tif (!rules || rules.length === 0) {\n\t\treturn defaultFilterPanel;\n\t}\n\n\tlet filterRules: FilterRule[] = rules?.map((rule) =>\n\t\tgetFilterRuleFromSelectionOptions(rule, filterColumnsBy)\n\t);\n\n\tif (filterRules.length === 1 && filterRules[0].rules && filterRules[0].rules.length < 1) {\n\t\tfilterRules = [];\n\t}\n\n\treturn {\n\t\tis_not: false,\n\t\trule_type: defaultRuleType as RuleType,\n\t\trules: filterRules\n\t};\n};\n\nexport const getFilterRuleFromSelectionOptions = (\n\trule: FilterSelectOptionsType,\n\tfilterColumnsBy?: FilterColumnsBy\n): FilterRule => {\n\tif (filterColumnsBy?.[rule.value] === 'value' || rule?.option?.uniqueValues?.length > 2) {\n\t\treturn {\n\t\t\trule_type: 'or_cond',\n\t\t\trules: [\n\t\t\t\t{\n\t\t\t\t\tcol: rule.value,\n\t\t\t\t\tvalue: _.map(rule?.option?.uniqueValues || [], (r) => r.option.uniqueValue),\n\t\t\t\t\toperator: 'in_op',\n\t\t\t\t\trule_type: 'cond',\n\t\t\t\t\tis_not: false,\n\t\t\t\t\tis_case_sensitive: true\n\t\t\t\t}\n\t\t\t],\n\t\t\tis_not: false\n\t\t};\n\t}\n\tif (rule?.option?.uniqueValues?.length === 1) {\n\t\tconst uniqueValue = rule?.option?.uniqueValues?.[0];\n\t\treturn {\n\t\t\tcol: rule.value,\n\t\t\tvalue: uniqueValue?.option?.uniqueValue,\n\t\t\toperator: uniqueValue?.option?.operator,\n\t\t\trule_type: uniqueValue?.option?.ruleType ?? 'cond',\n\t\t\tis_not: uniqueValue?.option?.isNot ?? false,\n\t\t\tis_case_sensitive: uniqueValue?.option?.caseSensitive ?? true\n\t\t};\n\t}\n\treturn {\n\t\trule_type: rule?.option?.ruleType,\n\t\trules: (rule?.option?.uniqueValues || []).map((r: FilterUniqueValueSelectOptionsType) => {\n\t\t\treturn {\n\t\t\t\tcol: r.value,\n\t\t\t\tvalue: r.option?.uniqueValue,\n\t\t\t\toperator: r.option?.operator,\n\t\t\t\trule_type: r.option?.ruleType ?? 'cond',\n\t\t\t\tis_not: r.option?.isNot ?? false,\n\t\t\t\tis_case_sensitive: r.option?.caseSensitive ?? true\n\t\t\t};\n\t\t}),\n\t\tis_not: false\n\t};\n};\n\nexport const getFilterRulesFromFilterSelectOptionsMap = (\n\tfilterSelectOptionsMap: {\n\t\t[filterId: string]: FilterSelectOptionsType;\n\t},\n\tfilterColumnsBy: FilterColumnsBy\n): { combinedFilterRule: FilterRule; columnFilterRule: FilterRule; aggFilterRule: FilterRule } => {\n\tconst filterSelectOptionsMapForAgg = _.pickBy(\n\t\tfilterSelectOptionsMap,\n\t\t(o) => !_.isEmpty(o.option.aggFun)\n\t);\n\tconst filterSelectOptionsMapForFilters = _.pickBy(filterSelectOptionsMap, (o) =>\n\t\t_.isEmpty(o.option.aggFun)\n\t);\n\n\tconst filterSelectOption: FilterPanelStoreType = {\n\t\tdefaultType: 'and_cond' as RuleType,\n\t\trules: Object.values(filterSelectOptionsMap)\n\t};\n\n\tconst filterSelectOptionWithoutAgg: FilterPanelStoreType = {\n\t\tdefaultType: 'and_cond' as RuleType,\n\t\trules: Object.values(filterSelectOptionsMapForFilters)\n\t};\n\tconst filterSelectOptionForAgg: FilterPanelStoreType = {\n\t\tdefaultType: 'and_cond' as RuleType,\n\t\trules: Object.values(filterSelectOptionsMapForAgg)\n\t};\n\n\tconst columnFilterRule = getSelectOptionTypeToFilter(\n\t\tfilterSelectOptionWithoutAgg,\n\t\tfilterColumnsBy\n\t);\n\tconst combinedFilterRule = getSelectOptionTypeToFilter(filterSelectOption, filterColumnsBy);\n\tconst aggFilterRule = getSelectOptionTypeToFilter(filterSelectOptionForAgg, filterColumnsBy);\n\n\treturn {\n\t\tcombinedFilterRule,\n\t\tcolumnFilterRule,\n\t\taggFilterRule\n\t};\n};\n\nexport const getColumnFilterRuleFromCombinedFilterRule = (\n\tcombinedFilterRule: FilterRule,\n\tvalueCols: ValueColsType[]\n): FilterRule => {\n\tconst filterRules: FilterRule[] = combinedFilterRule?.rules ?? [];\n\tconst columnFilterRules: FilterRule[] = [];\n\n\t_.forEach(filterRules, (rule) => {\n\t\tconst valueCol = valueCols?.find((valueCol) => rule?.col === valueCol?.label);\n\t\tif (!valueCol) {\n\t\t\tcolumnFilterRules.push(rule);\n\t\t}\n\t});\n\n\treturn {\n\t\t...combinedFilterRule,\n\t\trules: columnFilterRules\n\t};\n};\n\nexport const getAggregateFilterRuleFromCombinedFilterRule = (\n\tcombinedFilterRule: FilterRule,\n\tvalueCols: ValueColsType[]\n): FilterRule => {\n\tconst filterRules: FilterRule[] = combinedFilterRule?.rules ?? [];\n\tconst aggFilterRules: FilterRule[] = [];\n\n\t_.forEach(filterRules, (rule) => {\n\t\tconst valueCol = valueCols?.find((valueCol) => rule?.col === valueCol?.label);\n\t\tif (valueCol) {\n\t\t\taggFilterRules.push(rule);\n\t\t}\n\t});\n\n\treturn {\n\t\t...combinedFilterRule,\n\t\trules: aggFilterRules\n\t};\n};\n\nexport const getIsNotValueForPredicateType = (predicateType: Operator) => {\n\treturn _.includes(operatorsWithIsNotTrue, predicateType);\n};\n","import _ from 'lodash';\nimport { Section } from './reportModel';\nimport { ColumnFilterRule } from '$models/gen/Api';\n\nexport type BaseTransform = {\n\ttype: string;\n};\n\nexport type Pivot = BaseTransform & {\n\ttable: string;\n\tvalues: string | string[];\n\tcol_groups: string | string[];\n\trow_groups: string | string[];\n\taggregate_fn: string;\n};\n\nexport type TimeBin = 'per_day' | 'per_week' | 'per_month' | 'per_quarter' | 'per_year';\n\nexport type DateRange =\n\t| 'current_week'\n\t| 'current_month'\n\t| 'current_quarter'\n\t| 'current_year'\n\t| 'previous_week'\n\t| 'previous_month'\n\t| 'previous_quarter'\n\t| 'previous_year'\n\t| 'past_week'\n\t| 'past_month'\n\t| 'past_quarter'\n\t| 'past_year'\n\t| 'custom_period'\n\t| 'all';\n\nexport type MetricAggregateType =\n\t| [alias: string, formula: string]\n\t| [alias: string, col: string, func: string];\n\nexport type InputTableMetricAggregateType = Record<string, [string, string]>;\n\nexport type ProjectFractionType =\n\t| 'FRACTION_OF_COL_TOTAL'\n\t| 'FRACTION_OF_ROW_TOTAL'\n\t| 'FRACTION_OF_GRAND_TOTAL';\n\nexport enum ProjectFractionEnum {\n\tFRACTION_OF_COL_TOTAL = 'FRACTION_OF_COL_TOTAL',\n\tFRACTION_OF_ROW_TOTAL = 'FRACTION_OF_ROW_TOTAL',\n\tFRACTION_OF_GRAND_TOTAL = 'FRACTION_OF_GRAND_TOTAL',\n\tNONE = 'null',\n\tTOTAL_OF_FORMULA = 'TOTAL_OF_FORMULA',\n\tTOTAL_OF_AGGREGATE = 'TOTAL_OF_AGGREGATE'\n}\n\nexport type ProjectAsType = {\n\t[valueColName: string]: ProjectFractionType;\n};\n\nexport type MetricSeries = BaseTransform & {\n\ttable: string;\n\tdate_column: string;\n\taggregates: MetricAggregateType[];\n\tformula_on_aggregates: [alias: string, formula: string][];\n\tfilter_on_aggregates?: FilterRule;\n\tbin_by: string; // because we are passing it as variable now\n\tgroup_by: string[] | string;\n\trow_group_by?: string[] | string;\n\tcol_group_by?: string[] | string;\n\trequire_totals?: boolean;\n\tproject_as?: string | ProjectAsType; // because we are passing it as variable now\n\tshow_dimension_mapping_values?: boolean;\n\tbin_order_by_desc?: boolean; // because we are passing it as variable now\n};\n\nexport type Load = {\n\tloc: string;\n\tto: string;\n\tfs_options: any;\n};\n\nexport type Import = {\n\tloc: string;\n\tto: string;\n\timport_type: 'dataset' | 'definition';\n\tfrom_var?: string;\n\tdate_column_filter?:\n\t\t| {\n\t\t\t\ttime_period: DateRange;\n\t\t\t\tstart_date?: string;\n\t\t\t\tend_date?: string;\n\t\t }\n\t\t| string;\n\tto_currency?: string;\n};\n\nexport type AddColumn = BaseTransform & {\n\ttype: 'AddColumn';\n\ttable: string;\n\n\tcol: string;\n\n\texpr: string;\n};\nexport type ManageColumns = BaseTransform & {\n\ttype: 'ManageColumns';\n\ttable: string;\n\tcols: string[];\n};\n\nexport type RenameColumn = BaseTransform & {\n\ttype: 'RenameColumn';\n\ttable: string;\n\n\t//TODO : Check fxRuntime Types\n\tcol: string;\n\n\tbefore: string;\n\n\tafter: string;\n};\n\nexport type SourceDataset = BaseTransform & {\n\ttype: 'SourceDataset';\n\ttable: string;\n\tcols: string[];\n};\n\nexport type View = BaseTransform & {\n\ttype: 'View';\n\ttable: string;\n\tcols: string[] | string;\n};\n\ntype RuleType = 'or_cond' | 'and_cond' | 'cond';\n\nexport type RuleOp =\n\t| 'starts_with'\n\t| 'ends_with'\n\t| 'like'\n\t| 'contains'\n\t| 'equal'\n\t| 'greater'\n\t| 'greater_equal'\n\t| 'less'\n\t| 'less_equal'\n\t| 'in_op';\n\nexport type FilterRule = {\n\trule_type: RuleType;\n\tcol?: string;\n\toperator?: RuleOp;\n\tvalue?: string | number | boolean | string[];\n\trules?: FilterRule[];\n\tis_not: boolean;\n\tis_case_sensitive: boolean;\n\tignore_if_col_not_exists?: boolean;\n};\n\nexport type Filter = BaseTransform & {\n\ttable: string;\n\texpr: string;\n};\n\nexport type RuleFilter = BaseTransform & {\n\ttable: string;\n\trule: ColumnFilterRule | string;\n};\n\nexport type Sort = BaseTransform & {\n\ttable: string;\n\n\tcol: string[];\n\n\tasc: boolean[];\n\n\tpivot_inputs: {\n\t\tpivot_filters: FilterRule[];\n\t\tpivot_columns: string[];\n\t\tpivot_groups: { [key: string]: 'ASC' | 'DESC' };\n\t};\n};\n\nexport type Metric = BaseTransform & {\n\ttable: string;\n\n\taggregates: Aggregates;\n\n\tgroup_by: string | string[];\n};\n\nexport type Merge = BaseTransform & {\n\ttables: string[];\n};\n\nexport type JoinTransformHow = 'left' | 'right';\n\nexport type Join = BaseTransform & {\n\tleft: string;\n\n\tright: string;\n\n\tleft_on: string;\n\n\tright_on: string;\n\n\thow: JoinTransformHow;\n\n\tallow_duplication: boolean;\n\n\tright_cols?: string[];\n\n\tright_aliases?: string[];\n};\n\nexport type Transform<T extends BaseTransform> = T;\nexport type TransformStrings =\n\t| 'addColumn'\n\t| 'renameColumn'\n\t| 'view'\n\t| 'join'\n\t| 'metric'\n\t| 'filter'\n\t| 'sort'\n\t| 'merge'\n\t| 'pivot'\n\t| 'metric'\n\t| 'metricseries';\nexport type AvailableTransform =\n\t| AddColumn\n\t| RenameColumn\n\t| View\n\t| Filter\n\t| Sort\n\t| Metric\n\t| Merge\n\t| Join\n\t| Pivot\n\t| MetricSeries\n\t| RuleFilter;\n\nexport type Variable = {\n\tname: string;\n\ttransforms: AvailableTransform[];\n};\n\nexport type Aggregates = Record<string, string[]>;\n\nexport type Permission = any;\n\ntype Principal = {\n\tname: string;\n\n\tptype: string;\n};\n\nexport type Export = {\n\ttable: string;\n\n\tassignments?: (Principal | Permission[])[];\n\n\tentry_key: string;\n\n\ttags?: string[];\n};\n\nexport type TableColMap = {\n\ttables: any[];\n\tcolumns: Record<string, string[]>;\n};\n\ntype ColId = string;\nexport type Inputs = {\n\t[key: string]: any;\n};\n\nexport type Table = { data: any[]; to: string };\nexport type Definition = {\n\tinputs?: {\n\t\t[key: string]: any;\n\t};\n\taliases?: {\n\t\t[tableName: string]: { [alias: string]: ColId };\n\t};\n\timports?: Import[];\n\n\tloads?: Load[];\n\n\tvariables?: Variable[];\n\n\tpermissions?: Permission[];\n\n\texports?: Export[];\n\n\ttables?: Table[];\n\n\tsections?: Section[];\n};\n\nexport type DescriptionResultWithUniqueCount = {\n\tname: string;\n\tdata_type: 'str' | 'f64' | 'i64' | 'date';\n\tcount: number;\n\tunique_count: number;\n\tis_currency_column: boolean;\n\tdatasetId: string;\n\tdatasetName: string;\n};\n\nexport type DescriptionResultWithoutUniqueCount = {\n\tname: string;\n\tdata_type: string;\n\tis_currency_column: boolean;\n\tdatasetId: string;\n\tdatasetName: string;\n};\n\nexport type DescriptionResult =\n\t| DescriptionResultWithoutUniqueCount\n\t| DescriptionResultWithUniqueCount;\n\nconst CURRENT_WEEK = 'current_week';\nconst CURRENT_MONTH = 'current_month';\nconst CURRENT_QUARTER = 'current_quarter';\nconst CURRENT_YEAR = 'current_year';\nconst PREV_WEEK = 'previous_week';\nconst PREV_MONTH = 'previous_month';\nconst PREV_QUARTER = 'previous_quarter';\nconst PREV_YEAR = 'previous_year';\nconst PAST_WEEK = 'past_week';\nconst PAST_MONTH = 'past_month';\nconst PAST_QUARTER = 'past_quarter';\nconst PAST_YEAR = 'past_year';\nconst CUSTOM = 'custom_period';\n\nexport type FormatRule = {\n\tid: string;\n\trule_type: RuleType;\n\tcol: string;\n\toperator: RuleOp;\n\tvalue: string | number | Date;\n\t// rules?: FilterRule[];\n\tis_not: boolean;\n\tcolor_hex: [string, string];\n\tcase_sensitive: boolean;\n};\n\nexport type GroupByHierarchyType = {\n\talias: string;\n\ttype: string;\n\tlookup_col: string;\n\ttable: string;\n\tlevel?: number;\n\tparent?: string;\n\tfilter: FilterRule;\n\tinclude_parents: boolean;\n\tuse_as: string;\n};\n","import { generatePushID } from '$models/common/pushId';\nimport {\n\tgetFxUdescribeApi,\n\tgetFxUniqueColumnValuesApi,\n\trunDefinitionApi,\n\trunPublishedDefinitionApi\n} from '$models/fx/fxApi';\nimport type { DatasetImportMetadata } from '$models/gen/Api';\nimport type { SelectOptionType } from '$models/types/selectType';\nimport type { BlockSheetCustomModel } from '$models/ui-models/dashboardModel';\nimport type { DateRange } from '$models/ui-models/dateRangeModel';\nimport {\n\tProjectFractionEnum,\n\tTransform,\n\tSort,\n\ttype Definition,\n\ttype DescriptionResult,\n\ttype DescriptionResultWithUniqueCount,\n\ttype Import,\n\ttype Inputs,\n\ttype RuleFilter,\n\ttype TimeBin,\n\ttype Variable,\n\ttype View,\n\tMetricSeries\n} from '$models/ui-models/definitionModel';\nimport type {\n\tCommonFilter,\n\tFilterPanelStoreType,\n\tFilterRule,\n\tFilterSelectOptionsType,\n\tFilterUniqueValueSelectOptionsType,\n\tRuleType\n} from '$models/ui-models/filterModel';\nimport {\n\tCustomCalculationShowAsEnum,\n\tShowAsEnum,\n\tWorkbookCustomModel,\n\ttype ColumnSetting,\n\ttype FilterColumnsBy,\n\ttype GridColumnState,\n\ttype MetricCustomModel,\n\ttype MetricMetadataType,\n\ttype PivotCustomModel,\n\ttype Sheet,\n\ttype SortOptions,\n\ttype ValueColsType\n} from '$models/ui-models/workbookModel';\n\nimport _ from 'lodash';\nimport { findVariable } from './variableUtils';\nimport { buildVariable } from './buildVariable';\nimport { filterToSelectOptionType, getAggregateFilterRuleFromCombinedFilterRule, getColumnFilterRuleFromCombinedFilterRule, getSelectOptionTypeToFilter } from './filterUtils';\nimport { getInputName } from './inputNameUtil';\nimport { getDisplayName } from './displayNamesUtil';\nimport type {\n\tLimitOptions,\n\tRowGroupsType,\n} from '$models/ui-models/workbookModel';\n\nexport type MetricToolPanelType = {\n\tpivotCols: string[];\n\trowGroupCols: RowGroupsType;\n\tvalueCols: ValueColsType[];\n\tsortOptions: SortOptions;\n\tlimitOptions: LimitOptions;\n\tfilterModel: FilterRule | [];\n\tdateRange?: DateRange;\n\ttimeBin: TimeBin | '';\n\tcurrency?: string;\n\tcompareTrends?: Array<{\n\t\tid: string;\n\t\tname: string;\n\t\tdateRange: DateRange;\n\t}>;\n\tshowDimensionMappingValues?: boolean;\n\tplotAsTrendsOrder?: 'asc' | 'desc' | 'none';\n\tshowBinSortOrderValues?: boolean;\n};\n\n\nconst getValuesForSpecialOperators = (op: string) => {\n\tswitch (op) {\n\t\tcase 'not_equal':\n\t\t\treturn { operator: 'equal', isNot: true };\n\t\tcase 'not_contains':\n\t\t\treturn { operator: 'contains', isNot: true };\n\t\tcase 'is_empty':\n\t\t\treturn { value: '', operator: 'equal', isNot: false };\n\t\tcase 'is_not_empty':\n\t\t\treturn { value: '', operator: 'equal', isNot: true };\n\t\tcase 'is_null':\n\t\t\treturn { value: null, operator: 'equal', isNot: false };\n\t\tcase 'is_not_null':\n\t\t\treturn { value: null, operator: 'equal', isNot: true };\n\t\tdefault:\n\t\t\treturn {};\n\t}\n};\n\nexport const getPivotGridData = async (props: {\n\tinputs: Inputs;\n\tdefinitionModel: Definition;\n\tvariableName: string;\n\tvalueCols?: ValueColsType[];\n}) => {\n\tconst { inputs, definitionModel, variableName, valueCols } = props;\n\n\treturn runDefinitionApi(inputs, definitionModel, variableName);\n};\n\nexport const replaceFilterColumn = (props: {\n\tfr: FilterSelectOptionsType[];\n\tcolumn: SelectOptionType<ColumnSetting>;\n}) => {\n\tconst { fr, column } = props;\n\n\tconst updatedFr = _.map(fr, (f) => {\n\t\tlet newFr = { ...f, label: column?.label, value: column?.value };\n\t\tif (newFr.option.uniqueValues) {\n\t\t\t_.map(newFr.option.uniqueValues, (u) => {\n\t\t\t\tu.label = column?.label;\n\t\t\t\tu.value = column?.value;\n\t\t\t});\n\t\t}\n\t\treturn newFr;\n\t});\n\n\treturn updatedFr;\n};\n\nexport const mergeCommonFilters = (props: {\n\tcommonFilters: CommonFilter[];\n\trule: FilterSelectOptionsType[];\n\tcondition: RuleType;\n\tlineId: string;\n}) => {\n\tconst { commonFilters, rule, lineId, condition } = props;\n\tlet replacedFr: FilterSelectOptionsType[][] = [];\n\tif (_.isEmpty(commonFilters)) return { defaultType: condition, rules: rule };\n\t_.forEach(commonFilters, (f: CommonFilter) => {\n\t\tconst columnSettingsSelectOption = [\n\t\t\t{\n\t\t\t\tlabel: f.name,\n\t\t\t\tvalue: f.column.name,\n\t\t\t\toption: {\n\t\t\t\t\theaderName: f.name,\n\t\t\t\t\tfield: f.column.name,\n\t\t\t\t\ttype: f.column.data_type,\n\t\t\t\t\tdatasetName: f.datasetName,\n\t\t\t\t\tdatasetId: f.datasetId\n\t\t\t\t}\n\t\t\t}\n\t\t];\n\n\t\t// check if applied on the line\n\t\tconst appliedOnLine = _.find(f?.appliedOnBlocks, (l) => l.blockId === lineId) as {\n\t\t\tblockId: string;\n\t\t\tapplied: boolean;\n\t\t\tblockName: string;\n\t\t\tcolumn: string;\n\t\t\tcolumnSettings: SelectOptionType<ColumnSetting>[];\n\t\t};\n\t\tif (appliedOnLine && appliedOnLine.applied) {\n\t\t\tconst commonRule = f.rule;\n\t\t\tconst fr = filterToSelectOptionType(commonRule, columnSettingsSelectOption);\n\t\t\tconst columnSetting = _.find(\n\t\t\t\tappliedOnLine.columnSettings,\n\t\t\t\t(c) => c.value === appliedOnLine.column\n\t\t\t);\n\t\t\tif (columnSetting) {\n\t\t\t\treplacedFr.push(replaceFilterColumn({ fr: fr.rules, column: columnSetting }));\n\t\t\t}\n\t\t}\n\t});\n\n\tconst mergedFr = _.unionBy(replacedFr.flat(), rule, 'value');\n\n\treturn { defaultType: condition, rules: mergedFr };\n};\n\nexport const getUniqueValues = async (\n\tcolumn: string[],\n\tsheetDetails?: {\n\t\tsheetId: string;\n\t\tinputs: Inputs;\n\t\tdefinitionModel: Definition;\n\t\tparentTableVariable: string;\n\t},\n\tuniqueValues?: any,\n\tuniqueValueStore?: any,\n\tstoreSelectOptions?: boolean\n): Promise<string[]> => {\n\tconst uValStr = uniqueValues ?? { uniqueValues: {} };\n\n\tif (column && column[0] && sheetDetails) {\n\t\tif (\n\t\t\tsheetDetails.sheetId in uValStr?.uniqueValues &&\n\t\t\tcolumn[0] in uValStr?.uniqueValues?.[sheetDetails.sheetId]\n\t\t) {\n\t\t\treturn uValStr?.uniqueValues[sheetDetails.sheetId][column[0]];\n\t\t}\n\n\t\t/**\n\t\t * removing filters to get all unique values. also make sure the variable being called is not a view variable.\n\t\t * This is because user might have hidden the column in the view variable, but added it as a filter.\n\t\t */\n\t\tlet inputs = _.reduce(\n\t\t\tObject.entries(sheetDetails?.inputs || {}),\n\t\t\t(acc, [key, value]) => {\n\t\t\t\tif (_.includes(key, 'rule_')) {\n\t\t\t\t\tacc[key] = defaultFilterRule;\n\t\t\t\t} else {\n\t\t\t\t\tacc[key] = value;\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record<string, any>\n\t\t);\n\n\t\tinputs = {\n\t\t\t...inputs,\n\t\t\tprojectAsInput: {},\n\t\t\trowGroupByInput: [],\n\t\t\tcolumnGroupByInput: [],\n\t\t\tgroupByInput: [],\n\t\t\tfilterOnAggregates: [],\n\t\t\tshowDimensionMappingValues: inputs.showDimensionMappingValues ?? false,\n\t\t\tshowBinSortOrderValues: inputs.showBinSortOrderValues ?? false\n\t\t};\n\n\t\tlet variableName = sheetDetails?.parentTableVariable;\n\t\tconst variables = sheetDetails?.definitionModel?.variables;\n\n\t\tconst calledVariable = _.find(variables, (v) => v.name === variableName);\n\t\tif (calledVariable?.transforms[0]?.type === 'View') {\n\t\t\tvariableName = (calledVariable?.transforms[0] as View)?.table;\n\t\t}\n\n\t\tconst uniqueValues = (\n\t\t\tawait getFxUniqueColumnValuesApi(inputs, sheetDetails.definitionModel, variableName, column)\n\t\t)?.data;\n\n\t\tif (storeSelectOptions) {\n\t\t\tconst selectOptions = _.map(uniqueValues[column[0]], (uv) => ({ label: uv, value: uv }));\n\t\t\tuniqueValueStore.updateUniqueValues(sheetDetails.sheetId, { [column[0]]: selectOptions });\n\t\t} else {\n\t\t\tuniqueValueStore.updateUniqueValues(sheetDetails.sheetId, uniqueValues);\n\t\t}\n\t\treturn uniqueValues[column[0]];\n\t}\n\t\n\treturn [];\n};\n\nexport const _getAggregates = (valueCols: ValueColsType[]) => {\n\treturn valueCols.map((vc: ValueColsType) => {\n\t\tif (vc.formula) {\n\t\t\t//first param should be the label\n\t\t\treturn [vc.label ?? vc.col, vc.formula];\n\t\t}\n\t\t//first param should be the label, second param should be the column id\n\t\treturn [vc.label ?? vc.col, vc.col, vc.aggFun];\n\t});\n};\n\nconst getParentTableVariableType = (childId: string, variables: Variable[]): Variable | undefined => {\n\tconst parentTableVariable = _.find(variables, (v) => v.name === childId);\n\treturn parentTableVariable;\n};\n\nexport const findParentIsMetricSeries = (childId: string, variables: Variable[]): boolean => {\n\tconst parentTableVariable = getParentTableVariableType(childId, variables);\n\tif (parentTableVariable?.transforms[0]?.type === 'MetricSeries') {\n\t\treturn true;\n\t} else if (parentTableVariable?.transforms[0]) {\n\t\t//@ts-ignore\n\t\treturn findParentIsMetricSeries(parentTableVariable?.transforms[0]?.table, variables);\n\t}\n\treturn false;\n};\n\nexport const ShowAsToProjectFractionMapper: Partial<\n\tRecord<ShowAsEnum | CustomCalculationShowAsEnum, ProjectFractionEnum>\n> = {\n\t[ShowAsEnum.ROW]: ProjectFractionEnum.FRACTION_OF_ROW_TOTAL,\n\t[ShowAsEnum.COLUMN]: ProjectFractionEnum.FRACTION_OF_COL_TOTAL,\n\t[ShowAsEnum.GRAND_TOTAL]: ProjectFractionEnum.FRACTION_OF_GRAND_TOTAL,\n\t[CustomCalculationShowAsEnum.NONE]: ProjectFractionEnum.FRACTION_OF_ROW_TOTAL,\n\t[CustomCalculationShowAsEnum.FORMULA]: ProjectFractionEnum.TOTAL_OF_FORMULA,\n\t[CustomCalculationShowAsEnum.AGGREGATE]: ProjectFractionEnum.TOTAL_OF_AGGREGATE\n};\n\nexport const getDefinitionModelAndVariableNameForPivot = (props: {\n\tpivotSheet: Sheet<PivotCustomModel>;\n\trowsToGroupBy: string[];\n\tvalueCols: ValueColsType[];\n\tsortOptions: SortOptions;\n\ttimeBin?: TimeBin | '';\n\tdateRange: DateRange;\n\tdateColumn?: string;\n\tpivotCols: string[];\n\tcurrency?: string;\n\tcompareTrends?: Array<{\n\t\tid: string;\n\t\tname: string;\n\t\tdateRange: DateRange;\n\t}>;\n\tshowDimensionMappingValues?: boolean;\n\tshowBinSortOrderValues?: boolean;\n}) => {\n\tconst {\n\t\tpivotSheet,\n\t\trowsToGroupBy,\n\t\ttimeBin,\n\t\tdateColumn,\n\t\tdateRange,\n\t\tpivotCols,\n\t\tcurrency,\n\t\tsortOptions,\n\t\tcompareTrends,\n\t\tshowDimensionMappingValues,\n\t\tshowBinSortOrderValues\n\t} = props;\n\tconst valueCols = props.valueCols.filter((vc) => vc.type !== 'column') ?? [];\n\tconst newCols = props.valueCols.filter((vc) => vc.type === 'column') ?? [];\n\tlet variableName = generatePushID();\n\tconst pivotDefinitionModel = pivotSheet.definitionModel as Definition;\n\tlet variables: Variable[] = pivotDefinitionModel.variables || [];\n\tconst pivotVariable: Variable | undefined = variables.find((v) => v.transforms[0].type === 'MetricSeries');\n\tconst filterVariable: Variable | undefined = variables.find(\n\t\t(v) =>\n\t\t\tv.transforms[0].type === 'RuleFilter' && (v.transforms[0] as RuleFilter).rule === '${' + `rule_pivot` + '}'\n\t);\n\n\tif (pivotVariable) {\n\t\tvariableName = pivotVariable.name;\n\t}\n\tconst parentTableVariable = pivotSheet.customModel?.variable;\n\n\tif (!_.isEmpty(valueCols)) {\n\t\tconst rowGroups = _.filter(rowsToGroupBy[0], (r) => !pivotCols.includes(r));\n\t\tconst variableObject = buildVariable('metric', {\n\t\t\tname: variableName,\n\t\t\ttable: filterVariable?.name,\n\t\t\tproperties: {\n\t\t\t\tvalueCols,\n\t\t\t\trowGroups,\n\t\t\t\tcustomCalculation: newCols\n\t\t\t}\n\t\t});\n\n\t\tif (pivotVariable) {\n\t\t\tvariables = variables.map((v) => {\n\t\t\t\tif (v.transforms[0].type === 'MetricSeries') {\n\t\t\t\t\treturn variableObject;\n\t\t\t\t}\n\t\t\t\treturn v;\n\t\t\t});\n\t\t} else {\n\t\t\tvariables = [\n\t\t\t\t...variables.filter((vr: Variable) => vr.transforms[0].type !== 'Metric'),\n\t\t\t\tvariableObject\n\t\t\t];\n\t\t}\n\n\t\tconst ruleFilterVariable = _.find(variables, (v) => v.name.startsWith('rule_filter_'));\n\t\t// Search for Workbook Sort Variable\n\t\tlet { variable: workbookSortVariable, index: workbookSortVariableIndex } = findVariable(\n\t\t\tvariables,\n\t\t\truleFilterVariable?.name || '',\n\t\t\t'Sort'\n\t\t);\n\n\t\tif (workbookSortVariable) {\n\t\t\tif (workbookSortVariableIndex !== -1) {\n\t\t\t\tconst sortTransformTable = (workbookSortVariable.transforms[0] as Sort).table;\n\t\t\t\tvariables = variables.map((v) => {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tif (v.transforms[0]?.table === workbookSortVariable.name) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...v,\n\t\t\t\t\t\t\ttransforms: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...v.transforms[0],\n\t\t\t\t\t\t\t\t\ttable: sortTransformTable\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn v;\n\t\t\t\t});\n\t\t\t\tvariables.splice(workbookSortVariableIndex, 1);\n\t\t\t}\n\t\t}\n\t\t// Search for Metric Sort Variable\n\t\tlet { variable: sortVariable, index: sortVariableIndex } = findVariable(\n\t\t\tvariables,\n\t\t\tpivotSheet.customModel?.variable || '',\n\t\t\t'Sort',\n\t\t\t(variable) => variable.name.startsWith('rule_filter_') // Terminate search when rule_filter variable is reached to prevent matching the Workbook Sort variable\n\t\t);\n\n\t\tlet inputsArray: any[] = [];\n\t\tlet inputsCompareTrendsIndices: Array<{ id: string; index: number }> = [];\n\t\tconst projectAsInput = _.reduce(\n\t\t\tprops.valueCols,\n\t\t\t(acc, curr) => {\n\t\t\t\tif (curr.showAs && curr.showAs !== ShowAsEnum.DEFAULT && curr.label) {\n\t\t\t\t\tconst mappedValue = ShowAsToProjectFractionMapper[curr.showAs];\n\t\t\t\t\tif (mappedValue) {\n\t\t\t\t\t\tacc[curr.label] = mappedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record<string, ProjectFractionEnum>\n\t\t);\n\n\t\tif (!_.isEmpty(pivotCols)) {\n\t\t\tconst pc = timeBin ? [dateColumn, ...pivotCols] : pivotCols;\n\n\t\t\tpc?.forEach((col, index) => {\n\t\t\t\tconst groupByInput = rowsToGroupBy[index];\n\t\t\t\tconst columnGroupByInput = _.filter(groupByInput, (r) => pc.includes(r));\n\t\t\t\tconst rowGroupByInput = _.filter(groupByInput, (r) => !pc.includes(r));\n\n\t\t\t\tinputsArray.push({\n\t\t\t\t\t...pivotSheet.customModel?.inputs,\n\t\t\t\t\t// valueColsInput: aggregates,\n\t\t\t\t\tdate_range: { ...dateRange },\n\t\t\t\t\tgroupByInput: rowsToGroupBy[index],\n\t\t\t\t\tcolumnGroupByInput,\n\t\t\t\t\trowGroupByInput,\n\t\t\t\t\tdateColumnInput: dateColumn,\n\t\t\t\t\tbinByInput: timeBin,\n\t\t\t\t\tto_currency: currency,\n\t\t\t\t\tprojectAsInput,\n\t\t\t\t\tshowDimensionMappingValues,\n\t\t\t\t\tshowBinSortOrderValues\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\tif (compareTrends && compareTrends.length > 0) {\n\t\t\t\tinputsArray = _.map(compareTrends, (ct, index) => {\n\t\t\t\t\tinputsCompareTrendsIndices.push({ id: ct.id, index });\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...pivotSheet.customModel?.inputs,\n\t\t\t\t\t\t// valueColsInput: aggregates,\n\t\t\t\t\t\tdate_range: { ...ct.dateRange },\n\t\t\t\t\t\tgroupByInput: rowsToGroupBy[0],\n\t\t\t\t\t\trowGroupByInput: rowsToGroupBy[0],\n\t\t\t\t\t\tcolumnGroupByInput: [],\n\t\t\t\t\t\tdateColumnInput: dateColumn,\n\t\t\t\t\t\tbinByInput: timeBin,\n\t\t\t\t\t\tto_currency: currency,\n\t\t\t\t\t\tprojectAsInput,\n\t\t\t\t\t\tshowDimensionMappingValues,\n\t\t\t\t\t\tshowBinSortOrderValues\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tinputsArray = [\n\t\t\t\t\t{\n\t\t\t\t\t\t...pivotSheet.customModel?.inputs,\n\t\t\t\t\t\t// valueColsInput: aggregates,\n\t\t\t\t\t\tdate_range: { ...dateRange },\n\t\t\t\t\t\tgroupByInput: rowsToGroupBy[0],\n\t\t\t\t\t\trowGroupByInput: rowsToGroupBy[0],\n\t\t\t\t\t\tcolumnGroupByInput: [],\n\t\t\t\t\t\tdateColumnInput: dateColumn,\n\t\t\t\t\t\tbinByInput: timeBin,\n\t\t\t\t\t\tto_currency: currency,\n\t\t\t\t\t\tprojectAsInput,\n\t\t\t\t\t\tshowDimensionMappingValues,\n\t\t\t\t\t\tshowBinSortOrderValues\n\t\t\t\t\t}\n\t\t\t\t];\n\t\t\t}\n\t\t}\n\t\tconst newColAliases = _.reduce(\n\t\t\tnewCols,\n\t\t\t(acc, curr) => {\n\t\t\t\tif (curr.label) {\n\t\t\t\t\tacc[curr.label] = curr.col;\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record<string, string>\n\t\t);\n\n\t\tif (sortOptions?.sortByField) {\n\t\t\tconst allSortVariables = _.filter(variables, (v) => v.transforms[0].type === 'Sort');\n\t\t\tconst metricSortVariables = _.filter(allSortVariables, (v) => {\n\t\t\t\t//@ts-ignore\n\t\t\t\treturn findParentIsMetricSeries(v.transforms[0].table, variables);\n\t\t\t});\n\t\t\t// remove the metricSortVariables from variables\n\t\t\tvariables = _.filter(variables, (v) => !metricSortVariables.includes(v));\n\n\t\t\tconst sortVariableName = generatePushID();\n\t\t\tconst sortPivotFilterRule = {\n\t\t\t\trule_type: 'or_cond',\n\t\t\t\trules: [\n\t\t\t\t\t{\n\t\t\t\t\t\trule_type: 'or_cond',\n\t\t\t\t\t\trules: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcol: dateColumn,\n\t\t\t\t\t\t\t\tvalue: sortOptions.pivotFilters ?? [],\n\t\t\t\t\t\t\t\toperator: 'in_op',\n\t\t\t\t\t\t\t\trule_type: 'cond',\n\t\t\t\t\t\t\t\tis_not: false,\n\t\t\t\t\t\t\t\tis_case_sensitive: true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\tis_not: false\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t};\n\t\t\tconst sortPivotInputs = _.isEmpty(timeBin)\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tpivot_filters: [sortPivotFilterRule as FilterRule],\n\t\t\t\t\t\tpivot_columns: [...rowGroups, ...pivotCols],\n\t\t\t\t\t\tpivot_groups: { [`${dateColumn}_group`]: showBinSortOrderValues ? 'DESC' : 'ASC' }\n\t\t\t\t\t};\n\n\t\t\tinputsArray = inputsArray.map((i) => {\n\t\t\t\tconst newInputs = { ...i };\n\t\t\t\tObject.keys(newInputs).forEach((key) => {\n\t\t\t\t\tif (key.startsWith('sortPivotInputs_')) {\n\t\t\t\t\t\tdelete newInputs[key];\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn newInputs;\n\t\t\t});\n\n\t\t\tsortVariable = buildVariable('sort', {\n\t\t\t\tname: sortVariableName,\n\t\t\t\ttable: variableName,\n\t\t\t\tproperties: {\n\t\t\t\t\tcol: [sortOptions.sortByField.label],\n\t\t\t\t\tasc: [sortOptions.sortByOrder === 'asc'],\n\t\t\t\t\tpivot_inputs: sortPivotInputs ? `\\${sortPivotInputs_${sortVariableName}}` : undefined\n\t\t\t\t}\n\t\t\t});\n\t\t\tvariableName = sortVariableName;\n\t\t\tvariables = [...variables, sortVariable];\n\n\t\t\tif (inputsArray?.length > 0) {\n\t\t\t\tinputsArray = inputsArray.map((i) => ({\n\t\t\t\t\t...i,\n\t\t\t\t\t[`sortPivotInputs_${sortVariableName}`]: sortPivotInputs\n\t\t\t\t}));\n\t\t\t}\n\t\t} else if (sortOptions?.sortByField === undefined && sortVariable) {\n\t\t\tconst sortVariableIndex = variables.findIndex((v) => v === sortVariable);\n\t\t\tif (sortVariableIndex !== -1) {\n\t\t\t\tconst sortTransformTable = (sortVariable.transforms[0] as Sort).table;\n\t\t\t\tvariables = variables.map((v) => {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tif (v.transforms[0]?.table === sortVariable.name) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...v,\n\t\t\t\t\t\t\ttransforms: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...v.transforms[0],\n\t\t\t\t\t\t\t\t\ttable: sortTransformTable\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn v;\n\t\t\t\t});\n\t\t\t\tvariables.splice(sortVariableIndex, 1);\n\t\t\t}\n\n\t\t\tif (inputsArray?.length > 0) {\n\t\t\t\tinputsArray = inputsArray.map((i) => {\n\t\t\t\t\tconst newInputs = { ...i };\n\t\t\t\t\tObject.keys(newInputs).forEach((key) => {\n\t\t\t\t\t\tif (key.startsWith('sortPivotInputs_')) {\n\t\t\t\t\t\t\tdelete newInputs[key];\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\treturn newInputs;\n\t\t\t\t});\n\t\t\t}\n\t\t\tvariables = variables.filter((v) => v.transforms[0]?.type !== 'Sort');\n\t\t}\n\n\t\tconst definitionModel = {\n\t\t\t...pivotDefinitionModel,\n\t\t\taliases: {\n\t\t\t\t...pivotDefinitionModel.aliases,\n\t\t\t\t[variableName]: { \n\t\t\t\t\t...(pivotDefinitionModel.aliases && parentTableVariable ? pivotDefinitionModel.aliases[parentTableVariable] : {}), \n\t\t\t\t\t...newColAliases \n\t\t\t\t}\n\t\t\t},\n\t\t\tvariables: [...variables]\n\t\t} as Definition;\n\n\t\treturn { inputs: inputsArray, definitionModel, variableName, inputsCompareTrendsIndices };\n\t}\n\treturn {\n\t\tinputs: pivotSheet.customModel?.inputs || [],\n\t\tdefinitionModel: pivotDefinitionModel,\n\t\tvariableName\n\t};\n};\n\nexport const getFilterSelectOptionsMap = (fSO: FilterSelectOptionsType[]) =>\n\tfSO.reduce(\n\t\t(acc, curr) => {\n\t\t\tif (curr.value) {\n\t\t\t\tacc[curr.value] = curr;\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as { [filterId: string]: FilterSelectOptionsType }\n\t);\n\nexport const getDrilldownFiltersMap = (props: {\n\tfiltersToBeApplied: Array<{field: string; key: string | number; type?: string; startDate?: string; endDate?: string; operator?: string}>;\n\tcolumnSelectOptions: SelectOptionType[];\n}) => {\n\tconst { filtersToBeApplied, columnSelectOptions } = props;\n\n\tlet filterMap: { [id: string]: FilterSelectOptionsType } = {};\n\n\tconst filterGroup = _.groupBy(filtersToBeApplied, 'field');\n\n\t_.forEach(filterGroup, (fg) => {\n\t\tlet uniqueValues: FilterUniqueValueSelectOptionsType[] = [];\n\t\tconst col = columnSelectOptions?.find(\n\t\t\t(c: SelectOptionType) =>\n\t\t\t\tc.value === fg[0].field || c.value === `${fg[0].field}_group` || c.label === fg[0].field\n\t\t);\n\t\tlet ruleType: RuleType = 'cond';\n\t\t_.forEach(\n\t\t\tfg,\n\t\t\t(ftba: {\n\t\t\t\tfield: string;\n\t\t\t\tkey: string | number;\n\t\t\t\ttype?: string;\n\t\t\t\tstartDate?: string;\n\t\t\t\tendDate?: string;\n\t\t\t\toperator?: string;\n\t\t\t}) => {\n\t\t\t\tif (ftba.operator) {\n\t\t\t\t\tlet uniqueValuesForNegationOperator, uniqueValuesForOperator;\n\t\t\t\t\tif (ftba.operator.includes('not')) {\n\t\t\t\t\t\tuniqueValuesForNegationOperator = getValuesForSpecialOperators(ftba.operator);\n\t\t\t\t\t\tuniqueValuesForOperator = [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: col?.label,\n\t\t\t\t\t\t\t\tvalue: col?.value,\n\t\t\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\t\t\tuniqueValue: ftba.key,\n\t\t\t\t\t\t\t\t\truleType: 'cond',\n\t\t\t\t\t\t\t\t\toperator: uniqueValuesForNegationOperator.operator,\n\t\t\t\t\t\t\t\t\tisNot: uniqueValuesForNegationOperator.isNot\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t] as FilterUniqueValueSelectOptionsType[];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tuniqueValuesForOperator = [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: col?.label,\n\t\t\t\t\t\t\t\tvalue: col?.value,\n\t\t\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\t\t\tuniqueValue: ftba.key,\n\t\t\t\t\t\t\t\t\truleType: 'cond',\n\t\t\t\t\t\t\t\t\toperator: ftba.operator\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t] as FilterUniqueValueSelectOptionsType[];\n\t\t\t\t\t}\n\t\t\t\t\tuniqueValues.push(...uniqueValuesForOperator);\n\t\t\t\t\truleType = 'and_cond';\n\t\t\t\t} else if (ftba.type === 'date') {\n\t\t\t\t\tconst uniqueValuesForDate = [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: col?.label,\n\t\t\t\t\t\t\tvalue: col?.value?.replace('_group', ''),\n\t\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\t\tuniqueValue: ftba.startDate,\n\t\t\t\t\t\t\t\truleType: 'cond',\n\t\t\t\t\t\t\t\toperator: 'greater_equal'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: col?.label,\n\t\t\t\t\t\t\tvalue: col?.value?.replace('_group', ''),\n\t\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\t\tuniqueValue: ftba.endDate,\n\t\t\t\t\t\t\t\truleType: 'cond',\n\t\t\t\t\t\t\t\toperator: 'less_equal'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t] as FilterUniqueValueSelectOptionsType[];\n\t\t\t\t\tuniqueValues.push(...uniqueValuesForDate);\n\t\t\t\t\truleType = 'or_cond';\n\t\t\t\t} else {\n\t\t\t\t\t// build uniquevalues for filter variable\n\t\t\t\t\tconst uniqueValuesForSelection = [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: col?.label || '',\n\t\t\t\t\t\t\tvalue: col?.value,\n\t\t\t\t\t\t\toption: { uniqueValue: ftba.key, ruleType: 'cond', operator: 'equal' }\n\t\t\t\t\t\t}\n\t\t\t\t\t] as FilterUniqueValueSelectOptionsType[];\n\n\t\t\t\t\tuniqueValues.push(...uniqueValuesForSelection);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\tconst fiterSelectOption: FilterSelectOptionsType = {\n\t\t\tlabel: col?.label || '',\n\t\t\tvalue: col?.value,\n\t\t\toption: {\n\t\t\t\tuniqueValues,\n\t\t\t\truleType: ruleType,\n\t\t\t\tuniqueValueCount: col?.option.uniqueCount,\n\t\t\t\ttype: col?.option.type\n\t\t\t}\n\t\t};\n\n\t\tfilterMap = {\n\t\t\t...filterMap,\n\t\t\t[col?.value]: fiterSelectOption\n\t\t};\n\t});\n\n\treturn filterMap;\n};\n\nexport const getFilterRulesFromMap = (filterMap: {\n\t[filterId: string]: FilterSelectOptionsType;\n}) => {\n\tlet filterSelectOption = [];\n\n\tfor (const pf of Object.values(filterMap)) {\n\t\tfilterSelectOption.push(pf);\n\t}\n\n\treturn getSelectOptionTypeToFilter({\n\t\tdefaultType: 'and_cond',\n\t\trules: filterSelectOption\n\t});\n};\n\nexport const getFiltersToBeAppliedOnDrilldown = (props: {\n\trowGroups: string[];\n\tgroupKeys: string[];\n}) => {\n\tconst { rowGroups, groupKeys } = props;\n\tconst filtersToBeApplied: { field: string; key: string }[] = [];\n\tgroupKeys?.forEach((key, index) => filtersToBeApplied.push({ field: rowGroups[index], key }));\n\treturn filtersToBeApplied;\n};\n\nexport const getMetricFilterRule = (inputs: Inputs | Inputs[]) => {\n\tconst isInputsArray = Array.isArray(inputs);\n\tconst input = isInputsArray ? inputs[0] : inputs;\n\treturn input?.['rule_pivot'] ?? defaultFilterRule;\n};\n\nexport const getDrilldownModels = (props: {\n\tfiltersToBeApplied: { field: string; key: string }[];\n\tsheetDefinitionModel: Definition;\n\tsheetInputs: Inputs;\n\tsheetVariableName: string;\n\tcolumnSelectOptions: SelectOptionType[];\n}) => {\n\tconst {\n\t\tfiltersToBeApplied,\n\t\tsheetDefinitionModel,\n\t\tsheetInputs,\n\t\tsheetVariableName,\n\t\tcolumnSelectOptions\n\t} = props;\n\tlet variables = sheetDefinitionModel.variables;\n\n\tconst metricFilterRule: FilterRule = getMetricFilterRule(sheetInputs);\n\tconst metricFilterRuleSelectOptions = filterToSelectOptionType(\n\t\tmetricFilterRule,\n\t\tcolumnSelectOptions\n\t);\n\n\tconst drilldownFilterMap = getDrilldownFiltersMap({ filtersToBeApplied, columnSelectOptions });\n\n\tconst mergedRule = _.unionBy(\n\t\tObject.values(drilldownFilterMap),\n\t\tmetricFilterRuleSelectOptions.rules,\n\t\t'value'\n\t);\n\n\tconst filterRule: FilterRule = getSelectOptionTypeToFilter({\n\t\tdefaultType: 'and_cond',\n\t\trules: mergedRule\n\t});\n\n\t// current sheet inputs\n\n\tlet inputs = sheetInputs.map((sI: Inputs) => {\n\t\tconst rowGroupByInput = _.filter(sI.rowGroupByInput, (r) => sI.groupByInput.includes(r));\n\t\tconst columnGroupByInput = _.filter(sI.columnGroupByInput, (r) => sI.groupByInput.includes(r));\n\t\treturn { ...sI, ['rule_pivot']: filterRule, rowGroupByInput, columnGroupByInput };\n\t});\n\n\tconst definitionModel = { ...sheetDefinitionModel, variables };\n\n\treturn {\n\t\tdrilldownTableDefinitionModel: definitionModel,\n\t\tdrilldownTableVariableName: sheetVariableName,\n\t\tdrilldownTableInputs: inputs\n\t};\n};\n\nexport const getAmChartGroup = (props: { drilldownLevel: string[]; clickedColumn: string }) => {\n\tconst { clickedColumn, drilldownLevel } = props;\n\tlet group: string[] = [];\n\n\tconst clickedColumnIndex = drilldownLevel.indexOf(clickedColumn);\n\tgroup = drilldownLevel.slice(clickedColumnIndex + 1);\n\n\treturn group;\n};\n\nexport const getDataForDrilldown = async (props: {\n\tdrilldownFiltersToBeAppliedOnChart: { field: string; key: string }[];\n\tsheetDefinitionModel: Definition;\n\tsheetInputs: Inputs;\n\tsheetVariableName: string;\n\tcolumnSelectOptions: SelectOptionType[];\n}) => {\n\tconst {\n\t\tdrilldownFiltersToBeAppliedOnChart,\n\t\tsheetDefinitionModel,\n\t\tsheetInputs,\n\t\tsheetVariableName,\n\t\tcolumnSelectOptions\n\t} = props;\n\tlet { drilldownTableDefinitionModel, drilldownTableVariableName, drilldownTableInputs } =\n\t\tgetDrilldownModels({\n\t\t\tfiltersToBeApplied: drilldownFiltersToBeAppliedOnChart,\n\t\t\tsheetDefinitionModel: sheetDefinitionModel,\n\t\t\tsheetInputs: sheetInputs,\n\t\t\tsheetVariableName: sheetVariableName,\n\t\t\tcolumnSelectOptions: columnSelectOptions\n\t\t});\n\n\tdrilldownTableInputs = Array.isArray(drilldownTableInputs)\n\t\t? drilldownTableInputs[0]\n\t\t: drilldownTableInputs;\n\n\ttry {\n\t\tconst data = (\n\t\t\tawait runDefinitionApi(\n\t\t\t\tdrilldownTableInputs,\n\t\t\t\tdrilldownTableDefinitionModel,\n\t\t\t\tdrilldownTableVariableName\n\t\t\t)\n\t\t).data;\n\n\t\treturn data;\n\t} catch (error) {\n\t\tthrow error;\n\t}\n};\n\nexport const updateWorksheetAndMetricFilterMapForDrilldown = (props: {\n\tsheetInputs: Inputs;\n\tfilterVariable: Variable[];\n\tcolumnSelectOptions: SelectOptionType[];\n}) => {\n\tconst { sheetInputs, filterVariable, columnSelectOptions } = props;\n\n\tlet worksheetFilterMap = {};\n\tlet metricFilterMap = {};\n\n\tfilterVariable.forEach((fv: Variable) => {\n\t\tconst transform = fv.transforms[0] as RuleFilter;\n\t\tconst tRule = getInputName(transform.rule as string);\n\t\tconst sheetFilterRule: FilterRule = sheetInputs[tRule];\n\t\tconst sheetFilterSelectOption = filterToSelectOptionType(sheetFilterRule, columnSelectOptions);\n\t\tif (tRule.includes('worksheet')) {\n\t\t\tworksheetFilterMap = getFilterSelectOptionsMap(sheetFilterSelectOption?.rules);\n\t\t} else {\n\t\t\tmetricFilterMap = getFilterSelectOptionsMap(sheetFilterSelectOption?.rules);\n\t\t}\n\t});\n\n\treturn { ...worksheetFilterMap, ...metricFilterMap };\n};\n\nexport const getTableDrilldownModels = (props: {\n\tfiltersToBeApplied: { field: string; key: string | number }[];\n\tsheetDefinitionModel: Definition;\n\tsheetInputs: Inputs;\n\tcolumnSelectOptions: SelectOptionType[];\n\tincludesValueCols?: boolean;\n}) => {\n\tconst { filtersToBeApplied, sheetDefinitionModel, sheetInputs, columnSelectOptions } = props;\n\n\t// remove metric series variable from from definition model\n\tlet variables = [...(sheetDefinitionModel.variables || [])];\n\tvariables = variables.filter((variable: Variable) => {\n\t\treturn variable?.transforms?.[0]?.type !== 'MetricSeries';\n\t});\n\n\t// update parent table name in filter variable if exists\n\t// create a drill down filter variable\n\n\tlet filterVariable = variables.filter((variable: Variable) => {\n\t\treturn variable?.transforms?.[0]?.type === 'RuleFilter';\n\t});\n\n\tconst drilldownVariable = variables.find((v: Variable) => {\n\t\tconst transform = v.transforms?.[0];\n\t\tif (\n\t\t\ttransform?.type === 'RuleFilter' &&\n\t\t\ttypeof (transform as RuleFilter)?.rule === 'string' &&\n\t\t\t((transform as RuleFilter)?.rule as string)?.includes('rule_drillDown')\n\t\t) {\n\t\t\treturn v;\n\t\t}\n\t});\n\n\t// updateWorksheetAndMetricFilterMapForDrilldown(currentSheetInputs, filterVariable);\n\tconst variableName = drilldownVariable ? drilldownVariable.name : generatePushID();\n\tconst tTableName = filterVariable[filterVariable.length - 1]?.name;\n\tconst inputRuleVariable = `rule_drillDown`;\n\n\tconst drilldownFiltersMap = getDrilldownFiltersMap({ filtersToBeApplied, columnSelectOptions });\n\n\tconst drillDownFilterRule = getFilterRulesFromMap(drilldownFiltersMap);\n\n\t// current sheet inputs\n\tlet inputs = { ...sheetInputs, [inputRuleVariable]: drillDownFilterRule };\n\n\tif (!drilldownVariable) {\n\t\tconst drillDownFilterVariableObject = {\n\t\t\tname: variableName,\n\t\t\ttransforms: [\n\t\t\t\t{\n\t\t\t\t\ttable: tTableName,\n\t\t\t\t\ttype: 'RuleFilter',\n\t\t\t\t\trule: '${' + inputRuleVariable + '}'\n\t\t\t\t}\n\t\t\t]\n\t\t};\n\t\tvariables = [...variables, drillDownFilterVariableObject];\n\t}\n\tconst definitionModel = { ...sheetDefinitionModel, variables };\n\n\treturn {\n\t\tdrilldownTableDefinitionModel: definitionModel,\n\t\tdrilldownTableVariableName: variableName,\n\t\tdrilldownTableInputs: inputs\n\t};\n};\n\nexport const getValueGroupsSelectOptions = (props: {\n\tvalueCols: ValueColsType[];\n\taliases: { [key: string]: string };\n}) => {\n\tconst { valueCols, aliases } = props;\n\tconst getLabel = (name: string) => _.findKey(aliases, (o: string) => o === name);\n\tconst getFormulaAggregateFn = (formula: string) => {\n\t\treturn formula.substring(0, formula.indexOf('('));\n\t};\n\n\tconst getFormulaValue = (formula: string) =>\n\t\tformula.substring(formula.indexOf('(') + 1, formula.lastIndexOf(')'));\n\n\tconst valGroups =\n\t\tvalueCols?.map((valueCol) => {\n\t\t\tif (valueCol?.formula) {\n\t\t\t\tconst aggFun =\n\t\t\t\t\tvalueCol?.type && valueCol.type !== 'formula'\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: getFormulaAggregateFn(valueCol.formula);\n\t\t\t\treturn {\n\t\t\t\t\tlabel: valueCol.col,\n\t\t\t\t\tvalue: valueCol.col,\n\t\t\t\t\toption: {\n\t\t\t\t\t\tformulaMode: true,\n\t\t\t\t\t\taggFun,\n\t\t\t\t\t\tformula: getFormulaValue(valueCol.formula),\n\t\t\t\t\t\tfieldLabel: valueCol.col,\n\t\t\t\t\t\timpact: valueCol?.impact ?? 'positive',\n\t\t\t\t\t\ttype: valueCol?.type ?? 'formula',\n\t\t\t\t\t\tcurrency: valueCol?.currency,\n\t\t\t\t\t\tprecision: valueCol?.precision,\n\t\t\t\t\t\tisCurrency: valueCol?.isCurrency,\n\t\t\t\t\t\tisPercentage: valueCol?.isPercentage,\n\t\t\t\t\t\tisNumber: valueCol?.isNumber,\n\t\t\t\t\t\tshowAs: valueCol?.showAs ?? 'default',\n\t\t\t\t\t\tisAmortize: valueCol?.isAmortize ?? false,\n\t\t\t\t\t\tisHidden: valueCol?.hide ?? false,\n\t\t\t\t\t\thideGrandTotal: valueCol?.hideGrandTotal ?? false,\n\t\t\t\t\t\tshowRowTotal: valueCol?.showRowTotal ?? false,\n\t\t\t\t\t\tchartColorBasedOnImpact: valueCol?.chartColorBasedOnImpact ?? false,\n\t\t\t\t\t\tcompactNotation: valueCol?.compactNotation\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tlabel: valueCol.label,\n\t\t\t\tvalue: valueCol.col,\n\t\t\t\toption: {\n\t\t\t\t\tformulaMode: false,\n\t\t\t\t\taggFun: valueCol.aggFun,\n\t\t\t\t\tfieldLabel: getLabel(valueCol.col) ?? valueCol.col,\n\t\t\t\t\timpact: valueCol?.impact ?? 'positive',\n\t\t\t\t\ttype: 'value' as ValueColsType['type'],\n\t\t\t\t\tcurrency: valueCol?.currency,\n\t\t\t\t\tprecision: valueCol?.precision,\n\t\t\t\t\tisCurrency: valueCol?.isCurrency,\n\t\t\t\t\tisPercentage: valueCol?.isPercentage,\n\t\t\t\t\tisNumber: valueCol?.isNumber,\n\t\t\t\t\tshowAs: valueCol?.showAs ?? 'default',\n\t\t\t\t\tisHidden: valueCol?.hide ?? false,\n\t\t\t\t\thideGrandTotal: valueCol?.hideGrandTotal ?? false,\n\t\t\t\t\tshowRowTotal: valueCol?.showRowTotal ?? false,\n\t\t\t\t\tchartColorBasedOnImpact: valueCol?.chartColorBasedOnImpact ?? false,\n\t\t\t\t\tcompactNotation: valueCol?.compactNotation\n\t\t\t\t}\n\t\t\t};\n\t\t}) ?? [];\n\treturn valGroups;\n};\n\nexport const getRowGroupsSelectOptions = (props: {\n\trowGroups: Array<string | string[]>;\n\tcolumns: SelectOptionType[];\n}) => {\n\tconst { rowGroups, columns } = props;\n\tlet rowGroupsSelectOptions: any[] = [];\n\trowGroups?.forEach((rgc: string | string[]) => {\n\t\tif (typeof rgc === 'string') {\n\t\t\tconst col = columns?.find((col) => col.value === rgc);\n\t\t\trowGroupsSelectOptions = [...rowGroupsSelectOptions, col];\n\t\t} else {\n\t\t\tconst rowLabel = rgc?.[0];\n\t\t\tconst rowField = rgc?.[1]?.split('(')?.[1]?.split(',')?.[0]?.replace(/'/g, '');\n\t\t\tconst col = columns?.find((col) => col.value === rowField);\n\t\t\tconst updatedCol = {\n\t\t\t\t...col,\n\t\t\t\tlabel: rowLabel,\n\t\t\t\toption: { ...col?.option, rowType: 'hierarchy' }\n\t\t\t};\n\n\t\t\trowGroupsSelectOptions = [...rowGroupsSelectOptions, { ...updatedCol }];\n\t\t}\n\t});\n\treturn rowGroupsSelectOptions;\n};\n\nexport const getColumnGroupsSelectOptions = (props: {\n\tcolumnGroups: string[];\n\tcolumns: SelectOptionType[];\n}) => {\n\tconst { columnGroups, columns } = props;\n\tlet columnGroupsSelectOptions: any[] = [];\n\tcolumnGroups?.forEach((rgc: string) => {\n\t\tconst col = columns?.find((col) => col.value === rgc);\n\t\tcolumnGroupsSelectOptions = [...columnGroupsSelectOptions, col];\n\t});\n\treturn columnGroupsSelectOptions;\n};\n\nexport const removeDateColumnFromColRowGroupIfTrend = (props: {\n\ttimeBin: TimeBin | '';\n\tpivotCols: string[];\n\trowGroupCols: string[];\n\tdateColumn: string;\n}) => {\n\tconst { timeBin, pivotCols, rowGroupCols, dateColumn } = props;\n\tif (timeBin) {\n\t\tconst dateColumnIndex = pivotCols.indexOf(dateColumn);\n\t\tif (dateColumnIndex > -1) {\n\t\t\tpivotCols.splice(dateColumnIndex, 1);\n\t\t}\n\t\tconst dateColumnIndex2 = rowGroupCols.indexOf(dateColumn);\n\t\tif (dateColumnIndex2 > -1) {\n\t\t\trowGroupCols.splice(dateColumnIndex2, 1);\n\t\t}\n\t}\n\treturn { pivotCols, rowGroupCols };\n};\n\nexport const getNewMetricSheet = async (props: {\n\tdatasetList: DatasetImportMetadata[];\n\tsheetName: string;\n\tobjectId: string;\n\timportType: any;\n\tdateRange?: any;\n\tparentId?: string;\n}) => {\n\tconst { objectId, sheetName, datasetList, dateRange } = props;\n\t//get dataset from store\n\tconst dataset = datasetList.find(\n\t\t(ds: DatasetImportMetadata) => ds.id === objectId\n\t);\n\n\tif (!dataset) {\n\t\tthrow new Error(`Dataset with id ${objectId} not found`);\n\t}\n\n\tconst datasetName: string = dataset.name || '';\n\tconst datasetId: string = dataset.id || '';\n\n\tconst datasetDateColumn: string = dataset?.dateColumn ?? '';\n\tconst importModel: Import[] = [\n\t\t{\n\t\t\tloc: objectId,\n\t\t\tto: datasetName,\n\t\t\timport_type: 'dataset'\n\t\t}\n\t];\n\n\tif (dataset.datasetType === 'TRANSACTION') {\n\t\timportModel[0].date_column_filter = '${date_range}';\n\t}\n\n\tconst sheetId = generatePushID();\n\tconst inputRuleVariable = `rule_worksheet_${sheetId}`;\n\tconst metricFilterVariableName = generatePushID();\n\tconst metricVariableName = generatePushID();\n\n\tconst variableModel: Variable[] = [\n\t\t{\n\t\t\tname: sheetId,\n\t\t\ttransforms: [\n\t\t\t\t{\n\t\t\t\t\ttable: dataset.name,\n\t\t\t\t\ttype: 'RuleFilter',\n\t\t\t\t\trule: '${' + inputRuleVariable + '}'\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\tname: metricFilterVariableName,\n\t\t\ttransforms: [\n\t\t\t\t{\n\t\t\t\t\ttable: sheetId,\n\t\t\t\t\ttype: 'RuleFilter',\n\t\t\t\t\trule: '${rule_pivot}'\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\tname: metricVariableName,\n\t\t\ttransforms: [\n\t\t\t\t//@ts-ignore\n\t\t\t\t{\n\t\t\t\t\ttable: metricFilterVariableName,\n\t\t\t\t\taggregates: [],\n\t\t\t\t\tgroup_by: '${groupByInput}',\n\t\t\t\t\ttype: 'MetricSeries',\n\t\t\t\t\tbin_by: '${binByInput}'\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t];\n\n\t//create the definition model for the sheet in the workbook WITHOUT aliases\n\n\tconst defaultDefinition: Definition = {\n\t\timports: [],\n\t\tvariables: [],\n\t\taliases: {},\n\t\tinputs: {}\n\t};\n\n\tlet definitionModel: Definition = {\n\t\t...defaultDefinition,\n\t\timports: importModel,\n\t\tvariables: variableModel,\n\t\taliases: {}\n\t};\n\n\t//run describe(definition, variable)\n\tconst inputs: Inputs = {\n\t\t...defaultDefinition.inputs,\n\t\t[inputRuleVariable]: {\n\t\t\tis_not: false,\n\t\t\trule_type: 'and_cond',\n\t\t\trules: []\n\t\t},\n\t\trule_pivot: {\n\t\t\tis_not: false,\n\t\t\trule_type: 'and_cond',\n\t\t\trules: []\n\t\t},\n\t\tgroupByInput: [],\n\t\tbinByInput: ''\n\t};\n\n\tif (dataset.datasetType === 'TRANSACTION') {\n\t\tinputs.date_range = dateRange;\n\t}\n\n\tconst results = await Promise.all([getFxUdescribeApi(inputs, definitionModel, datasetName)]);\n\tconst tableDescription: DescriptionResult[] = (results[0] as any).data;\n\n\tconst alias = tableDescription.reduce(\n\t\t(acc: { [id: string]: string }, curr: DescriptionResult) => {\n\t\t\tacc[getDisplayName(curr.name)] = curr.name;\n\t\t\treturn acc;\n\t\t},\n\t\t{}\n\t);\n\n\t//update the definition model to have the alises\n\tdefinitionModel = {\n\t\t...definitionModel,\n\t\taliases: {\n\t\t\t[sheetId]: alias,\n\t\t\t[metricFilterVariableName]: alias,\n\t\t\t[metricVariableName]: alias\n\t\t}\n\t};\n\n\tconst columnSettings: ColumnSetting[] = tableDescription.map(\n\t\t(description: DescriptionResult): ColumnSetting => {\n\t\t\tconst descWithCount = description as DescriptionResultWithUniqueCount;\n\t\t\treturn {\n\t\t\t\thide: false,\n\t\t\t\theaderName: getDisplayName(description.name),\n\t\t\t\ttype: description.data_type as \"str\" | \"f64\" | \"i64\" | \"date\" | \"datetime(time_unit='us', time_zone=None)\" | undefined,\n\t\t\t\tfield: description.name,\n\t\t\t\tunique_count: descWithCount.unique_count,\n\t\t\t\tdatasetId: descWithCount.datasetId,\n\t\t\t\tdatasetName: descWithCount.datasetName\n\t\t\t};\n\t\t}\n\t);\n\n\t//then create sheet\n\tconst sheet: Sheet<BlockSheetCustomModel> = {\n\t\tname: sheetName,\n\t\tdefinitionModel,\n\t\tcustomModel: {\n\t\t\tmetadata: {\n\t\t\t\tparentTableVariable: sheetId,\n\t\t\t\tdateRange: dateRange,\n\t\t\t\tinputs: inputs,\n\t\t\t\tcolumnSettings,\n\t\t\t\tdatasetId: datasetId,\n\t\t\t\tdatasetName: datasetName,\n\t\t\t\tvariable: metricVariableName,\n\t\t\t\tdateColumn: datasetDateColumn,\n\t\t\t\tvalueCols: [],\n\t\t\t\trowGroupCols: [],\n\t\t\t\tfilterColumnsBy: {},\n\t\t\t\tfilterModel: [],\n\t\t\t\tpivotCols: [],\n\t\t\t\taliases: definitionModel.aliases ? definitionModel.aliases[metricVariableName] : undefined\n\t\t\t},\n\t\t\tsettings: {\n\t\t\t\tchartType: 'table',\n\t\t\t\tviewMode: 'grid'\n\t\t\t},\n\t\t\t[8]: { x: 0, y: 0, w: 4, h: 6 } // pivotBlockProperties placeholder\n\t\t},\n\t\tcustomFields: {\n\t\t\tvariable: sheetId as any,\n\t\t\tdateColumn: datasetDateColumn as unknown as Object,\n\t\t\tdatasetNames: [datasetName]\n\t\t},\n\t\ttype: 'PIVOT',\n\t\tparentId: props.parentId,\n\t\tparentType: 'DASHBOARD',\n\t\tid: sheetId,\n\t\tworkspaceId: undefined,\n\t\tsources: [{ id: datasetId, componentType: 'DATASET' }]\n\t};\n\n\treturn sheet;\n};\n\nexport const getColumnSettingsToSelectOptions = (columnSettings: ColumnSetting[]) => {\n\treturn _.chain(columnSettings)\n\t\t.filter((c) => !c.field.includes('__bc_') && !c.aggFunc)\n\t\t.map((c: ColumnSetting) => {\n\t\t\treturn {\n\t\t\t\tlabel: c.headerName,\n\t\t\t\tvalue: c.field,\n\t\t\t\toption: {\n\t\t\t\t\ttype: c.type,\n\t\t\t\t\tuniqueCount: c.unique_count,\n\t\t\t\t\tfieldLabel: c.headerName,\n\t\t\t\t\tcurrency: c?.currency,\n\t\t\t\t\tprecision: c?.precision,\n\t\t\t\t\tdateFormat: c?.dateFormat,\n\t\t\t\t\tisCurrency: c?.isCurrency\n\t\t\t\t}\n\t\t\t};\n\t\t})\n\t\t.value();\n};\n\nexport const getDefinitionModelWithUpdatedValueCols = (props: {\n\tdefinition: Definition;\n\tvalueCols: ValueColsType[];\n}) => {\n\tconst { definition } = props;\n\tlet shDef = definition;\n\tlet variableName = shDef?.variables?.[shDef?.variables?.length - 1]?.name;\n\n\tlet variables = shDef?.variables ?? [];\n\tconst tableName = variables?.[variables.length - 1]?.name;\n\tconst id = generatePushID();\n\n\tconst viewVariable: Variable = {\n\t\tname: id,\n\t\ttransforms: [\n\t\t\t{\n\t\t\t\ttype: 'View',\n\t\t\t\ttable: tableName,\n\t\t\t\tcols: '${viewInputs}'\n\t\t\t}\n\t\t]\n\t};\n\n\tvariables = [...variables, viewVariable];\n\tvariableName = id;\n\n\tconst updatedDefinition = { ...shDef, variables };\n\n\treturn { updatedDefinition, variableName };\n};\n\nexport const applyFilter = async (props: {\n\tsheetId: string;\n\tmetadata: MetricMetadataType;\n\tlastModifiedDate: string;\n}) => {\n\tconst { metadata, sheetId, lastModifiedDate } = props;\n\n\tconst parentTableVariable: string = metadata?.parentTableVariable || '';\n\n\tconst inputs = metadata?.inputs;\n\n\tconst variable = metadata?.variable;\n\n\ttry {\n\t\tconst serverResponse = await runPublishedDefinitionApi({\n\t\t\tinputs: { ...inputs },\n\t\t\tsheet: {\n\t\t\t\tid: sheetId,\n\t\t\t\tlastModifiedDate\n\t\t\t},\n\t\t\tvariable,\n\t\t\tdescribe: parentTableVariable\n\t\t});\n\n\t\tconst result: { data: any[]; description: DescriptionResultWithUniqueCount[] } =\n\t\t\tserverResponse.data;\n\n\t\tconst gridData = result.data;\n\n\t\treturn gridData;\n\t} catch (error) {\n\t\tconsole.error(error);\n\t}\n};\n\nexport const defaultFilterRule: FilterRule = {\n\tis_not: false,\n\trule_type: 'and_cond',\n\trules: []\n};\n\nexport const getPromotedFiltersSelectOptionsForLine = (\n\tmetricSheet: Sheet<MetricCustomModel>\n): SelectOptionType[] => {\n\tlet promotedFiltersSelectOptions: any[] = [];\n\n\tconst sheetId = metricSheet?.id;\n\tconst sheetDefinitionModel = metricSheet?.definitionModel;\n\n\tconst metadata = metricSheet?.customModel?.metadata as MetricMetadataType;\n\tif (!_.isEmpty(metadata)) {\n\t\tconst blockColumnSettings = metadata?.columnSettings as ColumnSetting[];\n\n\t\tconst blockSheetDetails: {\n\t\t\tsheetId: string | undefined;\n\t\t\tdefinitionModel: Definition;\n\t\t\tparentTableVariable: string | undefined;\n\t\t\tinputs: Inputs | undefined;\n\t\t} = {\n\t\t\tsheetId,\n\t\t\tdefinitionModel: sheetDefinitionModel as Definition,\n\t\t\tparentTableVariable: metadata?.parentTableVariable,\n\t\t\tinputs: metadata?.inputs\n\t\t};\n\t\tconst blockFilterColumnsBy: FilterColumnsBy = metadata?.filterColumnsBy || {};\n\n\t\t// create promoted fiters select options\n\t\t_.chain(blockColumnSettings)\n\t\t\t.filter((c) => !c.aggFunc && !c.field.includes('__bc_'))\n\t\t\t.forEach((cso: ColumnSetting) => {\n\t\t\t\tpromotedFiltersSelectOptions = [\n\t\t\t\t\t...promotedFiltersSelectOptions,\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: cso.headerName,\n\t\t\t\t\t\tvalue: cso.field,\n\t\t\t\t\t\toption: {\n\t\t\t\t\t\t\tname: cso.headerName,\n\t\t\t\t\t\t\trule: defaultFilterRule,\n\t\t\t\t\t\t\tsheetDetails: blockSheetDetails,\n\t\t\t\t\t\t\tlineId: sheetId,\n\t\t\t\t\t\t\tfilterColumnsBy: blockFilterColumnsBy,\n\t\t\t\t\t\t\tid: cso.field,\n\t\t\t\t\t\t\tdatasetId: cso?.datasetId ?? metadata?.datasetId,\n\t\t\t\t\t\t\tblockColumnSettings: blockColumnSettings,\n\t\t\t\t\t\t\tdatasetName: cso?.datasetName ?? metadata?.datasetName,\n\t\t\t\t\t\t\tuniqueValueCount: cso?.unique_count ?? 1000\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t];\n\t\t\t})\n\t\t\t.value();\n\n\t\treturn promotedFiltersSelectOptions;\n\t} else {\n\t\treturn [];\n\t}\n};\n\nexport const getAllLinesFilterSelectOptions = (metricSheets: Sheet<MetricCustomModel>[]) => {\n\tlet allLinesFilterSelectOptions: SelectOptionType[] = [];\n\tmetricSheets?.forEach((bs: Sheet<MetricCustomModel>) => {\n\t\tconst so: SelectOptionType[] = getPromotedFiltersSelectOptionsForLine(bs);\n\t\tallLinesFilterSelectOptions = _.uniqBy(\n\t\t\t[...allLinesFilterSelectOptions, ...so],\n\t\t\t(v) => `${v.option?.datasetId}_${v.option?.id}`\n\t\t);\n\t});\n\n\treturn _.uniqWith(\n\t\tallLinesFilterSelectOptions,\n\t\t(a, b) => a.option.datasetId === b.option.datasetId && a.value === b.value\n\t);\n};\n\nexport function formatDate(date: any) {\n\tlet month = '' + (date.getMonth() + 1),\n\t\tday = '' + date.getDate(),\n\t\tyear = date.getFullYear();\n\n\tif (month.length < 2) month = '0' + month;\n\tif (day.length < 2) day = '0' + day;\n\n\treturn [year, month, day].join('-');\n}\n\nexport const getQuarterDates = (props: { month: number; year: number }) => {\n\tlet startDate;\n\tlet endDate;\n\n\tlet { month, year } = props;\n\tmonth = month + 1;\n\n\tif (month >= 4 && month <= 6) {\n\t\tstartDate = formatDate(new Date(year, 3, 1));\n\t\tendDate = formatDate(new Date(year, 5, 30));\n\t} else if (month >= 7 && month <= 9) {\n\t\tstartDate = formatDate(new Date(year, 6, 1));\n\t\tendDate = formatDate(new Date(year, 8, 30));\n\t} else if (month >= 10 && month <= 12) {\n\t\tstartDate = formatDate(new Date(year, 9, 1));\n\t\tendDate = formatDate(new Date(year, 11, 31));\n\t} else if (month >= 1 && month <= 3) {\n\t\tstartDate = formatDate(new Date(year - 1, 9, 1));\n\t\tendDate = formatDate(new Date(year, 2, 31));\n\t}\n\n\treturn { startDate, endDate };\n};\n\nexport const getMonthDates = (props: { month: number; year: number }) => {\n\tconst { month, year } = props;\n\tconst startDate = formatDate(new Date(year, month, 1));\n\tconst endDate = formatDate(new Date(year, month + 1, 0));\n\treturn { startDate, endDate };\n};\n\nexport const getYearDates = (props: { year: number }) => {\n\tconst { year } = props;\n\n\tconst startDate = formatDate(new Date(year, 0, 1));\n\tconst endDate = formatDate(new Date(year, 11, 31));\n\treturn { startDate, endDate };\n};\n\nexport const getStartEndDates = (props: { timeBin: TimeBin; date: Date }) => {\n\tconst { timeBin, date } = props;\n\n\tconst month = date.getMonth();\n\tconst year = date.getFullYear();\n\n\tif (timeBin === 'per_month') return getMonthDates({ month, year });\n\tif (timeBin === 'per_quarter') return getQuarterDates({ month, year });\n\tif (timeBin === 'per_year') return getYearDates({ year });\n};\n\nexport const getSheetProperties = (props: {\n\tsheet: Sheet<PivotCustomModel>;\n\tgroupKeys?: string[];\n\ttoolPanelValues?: MetricToolPanelType;\n\tinitialLoad: boolean;\n\tcurrencyValue: string;\n}) => {\n\tconst { sheet, toolPanelValues, groupKeys, initialLoad, currencyValue } = props;\n\tlet pivotCols: string[] = [],\n\t\trowGroupCols: Array<string | string[]> = [],\n\t\tfilterModel: FilterRule | [] = [],\n\t\tvalueCols: ValueColsType[] = [],\n\t\ttimeBin: TimeBin | '' = '',\n\t\tdateRange: DateRange,\n\t\tcurrency: string,\n\t\tshowBinSortOrderValues: boolean,\n\t\tcompareTrends: Array<{\n\t\t\tid: string;\n\t\t\tname: string;\n\t\t\tdateRange: DateRange;\n\t\t}>,\n\t\tshowDimensionMappingValues: boolean;\n\tlet gridColumnState: GridColumnState;\n\tlet dateColumn = sheet?.customModel?.dateColumn;\n\tlet sortOptions: SortOptions;\n\n\tif (!initialLoad && toolPanelValues) {\n\t\tpivotCols = toolPanelValues.pivotCols;\n\t\trowGroupCols = toolPanelValues.rowGroupCols;\n\t\tfilterModel = toolPanelValues.filterModel;\n\t\tvalueCols = toolPanelValues.valueCols;\n\t\tsortOptions = toolPanelValues.sortOptions;\n\t\ttimeBin = toolPanelValues.timeBin;\n\t\tdateRange = toolPanelValues.dateRange || { time_period: 'past_quarter' };\n\t\tcurrency = toolPanelValues.currency || currencyValue;\n\t\tcompareTrends = toolPanelValues.compareTrends || [];\n\t\tshowDimensionMappingValues = toolPanelValues.showDimensionMappingValues || false;\n\t\tshowBinSortOrderValues = toolPanelValues.showBinSortOrderValues || false;\n\t\t// get rowGroupCols till index clicked row level\n\t\tgridColumnState = { pivotCols, rowGroupCols, filterModel, valueCols };\n\t\trowGroupCols = rowGroupCols.slice(0, (groupKeys?.length || 0) + 1);\n\t} else {\n\t\tconst cModel = sheet?.customModel;\n\t\tgridColumnState = cModel?.gridColumnState || { pivotCols: [], rowGroupCols: [], filterModel: [], valueCols: [] };\n\t\ttimeBin = cModel?.timeBin ?? '';\n\t\tdateRange = cModel?.dateRange ?? { time_period: 'past_quarter' };\n\t\tcurrency = cModel?.currency ?? currencyValue;\n\t\tif (gridColumnState) {\n\t\t\t({ pivotCols, rowGroupCols, valueCols, filterModel } = gridColumnState);\n\t\t\trowGroupCols = rowGroupCols.slice(0, (groupKeys?.length || 0) + 1);\n\t\t}\n\t\tsortOptions = cModel?.sortOptions || { sortByField: undefined, sortByOrder: 'asc' };\n\t\tcompareTrends = cModel?.compareTrends || [];\n\t\tshowDimensionMappingValues = cModel?.showDimensionMappingValues ?? false;\n\t\tshowBinSortOrderValues = cModel?.showBinSortOrderValues ?? false;\n\t}\n\n\t({ pivotCols, rowGroupCols } = removeDateColumnFromColRowGroupIfTrend({\n\t\ttimeBin,\n\t\tpivotCols,\n\t\trowGroupCols: rowGroupCols as string[],\n\t\tdateColumn: dateColumn || ''\n\t}));\n\n\tpivotCols = pivotCols ?? [];\n\trowGroupCols = rowGroupCols ?? [];\n\tvalueCols = valueCols ?? [];\n\ttimeBin = timeBin ?? '';\n\n\tlet rowsToGroupBy = [];\n\tif (!_.isEmpty(pivotCols)) {\n\t\tif (timeBin) {\n\t\t\trowsToGroupBy.push([...rowGroupCols]);\n\t\t\tfor (let i = 0; i < pivotCols.length; i++) {\n\t\t\t\tconst pcols = pivotCols;\n\t\t\t\trowsToGroupBy.push([...pcols.slice(0, i + 1), ...rowGroupCols]);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (let i = 0; i < pivotCols.length; i++) {\n\t\t\t\tconst pcols = pivotCols;\n\t\t\t\trowsToGroupBy.push([...pcols.slice(0, i + 1), ...rowGroupCols]);\n\t\t\t}\n\t\t}\n\t} else {\n\t\trowsToGroupBy.push([...pivotCols, ...rowGroupCols]);\n\t}\n\n\t// create definition Model for pivot\n\tconst definitionModelAndVariable = getDefinitionModelAndVariableNameForPivot({\n\t\tpivotSheet: sheet,\n\t\trowsToGroupBy: rowsToGroupBy as any, // Type assertion to handle 2D array\n\t\tvalueCols,\n\t\tsortOptions,\n\t\ttimeBin,\n\t\tdateRange,\n\t\tdateColumn: sheet?.customModel?.dateColumn ?? '',\n\t\tpivotCols,\n\t\tcurrency,\n\t\tcompareTrends,\n\t\tshowDimensionMappingValues,\n\t\tshowBinSortOrderValues\n\t});\n\n\tlet definitionModel = definitionModelAndVariable.definitionModel;\n\n\tlet variableName = definitionModelAndVariable.variableName;\n\tlet inputs: Inputs = definitionModelAndVariable.inputs;\n\tconst inputsCompareTrendsIndices = definitionModelAndVariable.inputsCompareTrendsIndices;\n\tif (!initialLoad && _.isEmpty(filterModel)) {\n\t\tinputs = _.map(inputs, (input) => {\n\t\t\treturn {\n\t\t\t\t...input,\n\t\t\t\trule_pivot: defaultFilterRule,\n\t\t\t\tfilterOnAggregates: defaultFilterRule\n\t\t\t};\n\t\t});\n\t}\n\n\tif (!_.isEmpty(filterModel)) {\n\t\tconst aggFilterRule = getAggregateFilterRuleFromCombinedFilterRule(\n\t\t\tfilterModel as FilterRule,\n\t\t\tvalueCols\n\t\t);\n\t\tconst columnFilterRule = getColumnFilterRuleFromCombinedFilterRule(\n\t\t\tfilterModel as FilterRule,\n\t\t\tvalueCols\n\t\t);\n\t\tinputs = _.map(inputs, (input) => {\n\t\t\treturn {\n\t\t\t\t...input,\n\t\t\t\trule_pivot: columnFilterRule,\n\t\t\t\tfilterOnAggregates: aggFilterRule\n\t\t\t};\n\t\t});\n\t}\n\n\treturn { inputs, definitionModel, variableName, gridColumnState, inputsCompareTrendsIndices };\n};\n\nexport const getValueColumnsFromSelectOptions = (selectOptions: SelectOptionType[]) => {\n\treturn selectOptions?.map((col: SelectOptionType) => {\n\t\tlet valueCol = {\n\t\t\tlabel: col.label,\n\t\t\tcol: col.option.formulaMode ? col.label : col.value,\n\t\t\taggFun: col.option.formulaMode ? undefined : col.option.aggFun,\n\t\t\timpact: col.option.impact,\n\t\t\ttype: col.option.type,\n\t\t\tisCurrency: col.option.isCurrency ?? false,\n\t\t\tisPercentage: col?.option?.isPercentage ?? false,\n\t\t\tisNumber: col?.option?.isNumber ?? false,\n\t\t\tshowAs: col?.option?.showAs ?? 'default',\n\t\t\tisAmortize: col?.option?.isAmortize ?? false,\n\t\t\thide: col?.option?.isHidden ?? false,\n\t\t\thideGrandTotal: col?.option?.hideGrandTotal ?? false,\n\t\t\tshowRowTotal: col?.option?.showRowTotal ?? false,\n\t\t\tchartColorBasedOnImpact: col?.option?.chartColorBasedOnImpact,\n\t\t\tcompactNotation: col?.option?.compactNotation,\n\t\t\tprecision: col?.option?.precision\n\t\t};\n\n\t\tif (!col.option.formulaMode) return valueCol;\n\t\tif (!col.option.aggFun) return { ...valueCol, formula: `(${col.option.formula})` };\n\t\treturn { ...valueCol, formula: `${col.option.aggFun}(${col.option.formula})` };\n\t});\n};\n\nexport const defaultDateRange: DateRange = {\n\ttime_period: 'past_quarter'\n};\n\nexport const getPromotedFilterRulesSelectOptions = (promotedFiltersStoreValue: {\n\t[datasetId: string]: { [id: string]: FilterPanelStoreType };\n}) => {\n\tlet promotedFiltersSelectOptions = [];\n\n\tfor (const [datasetId, pf] of Object.entries(promotedFiltersStoreValue ?? {})) {\n\t\tfor (const rule of Object.values(pf)) {\n\t\t\tif (rule.rules[0]) {\n\t\t\t\tconst rules = { ...rule.rules[0], option: { ...rule.rules[0].option, datasetId } };\n\t\t\t\tpromotedFiltersSelectOptions.push(rules);\n\t\t\t}\n\t\t}\n\t}\n\treturn promotedFiltersSelectOptions;\n};\n\nexport const checkIfCurrencyFormula = (props: { formula: string; columns: any }) => {\n\tconst { formula, columns } = props;\n\tconst notAllowedFunctions = ['COUNT', 'COUNTDIST', 'CONCAT'];\n\tconst extractColumnValues = (str: string) => {\n\t\tconst regex = /'(.*?)'/g;\n\t\tconst matches = [];\n\t\tlet match;\n\n\t\twhile ((match = regex.exec(str))) {\n\t\t\tmatches.push(match[1]);\n\t\t}\n\n\t\treturn matches;\n\t};\n\n\t//check if formula includes any of the not allowed functions\n\tconst hasNotAllowedFunctions = notAllowedFunctions.some((func) => _.includes([formula], func));\n\n\tif (hasNotAllowedFunctions) {\n\t\treturn false;\n\t} else {\n\t\tconst columnValues = extractColumnValues(formula);\n\t\tconst currencyColumn = _.chain(columns)\n\t\t\t.filter((col: ColumnSetting) => col.isCurrency)\n\t\t\t.map((col: ColumnSetting) => col.headerName || col.field)\n\t\t\t.compact()\n\t\t\t.value();\n\n\t\t// check if anyone of columnValues is in columns array\n\t\tconst hasCurrencyColumn = columnValues.some((col: string) => (currencyColumn as any).includes(col));\n\t\treturn hasCurrencyColumn;\n\t}\n};\n\nexport const getProjectAsInput = (valueCols: ValueColsType[]) => {\n\t\tconst projectAsInput = _.reduce(\n\t\t\tvalueCols,\n\t\t\t(acc, curr) => {\n\t\t\t\tif (curr.showAs && curr.showAs !== ShowAsEnum.DEFAULT && curr.label) {\n\t\t\t\t\tconst mappedValue = ShowAsToProjectFractionMapper[curr.showAs];\n\t\t\t\t\tif (mappedValue) {\n\t\t\t\t\t\tacc[curr.label] = mappedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record<string, ProjectFractionEnum>\n\t\t);\treturn projectAsInput;\n};\n\nexport const getUpdatedDefinitionCustomModel = (props: {\n\tmetricDefinitionModel: Definition;\n\tparentDefinitionModel: Definition;\n\tparentCustomModel: WorkbookCustomModel;\n\tmetricCustomModel: PivotCustomModel;\n\tremoveSort?: boolean;\n}) => {\n\tconst {\n\t\tmetricDefinitionModel,\n\t\tparentDefinitionModel,\n\t\tmetricCustomModel,\n\t\tparentCustomModel,\n\t\tremoveSort\n\t} = props;\n\n\tconst parentTableVariable = parentCustomModel.variable;\n\tconst metricNewColumns = _.filter(metricDefinitionModel.variables ?? [], (v) => {\n\t\tif (!v.transforms || !v.transforms[0]) {\n\t\t\treturn false;\n\t\t}\n\t\tif (removeSort) {\n\t\t\treturn (\n\t\t\t\tfindParentIsMetricSeries(\n\t\t\t\t\t(v.transforms[0] as Sort).table,\n\t\t\t\t\tmetricDefinitionModel.variables ?? []\n\t\t\t\t) && v.transforms[0].type !== 'Sort'\n\t\t\t);\n\t\t}\n\t\treturn findParentIsMetricSeries(\n\t\t\t(v.transforms[0] as Sort).table,\n\t\t\tmetricDefinitionModel.variables ?? []\n\t\t);\n\t});\n\n\tconst definitionVariables = metricDefinitionModel.variables ?? [];\n\tconst analysisVariable: Variable | undefined = _.find<Variable>(definitionVariables, (v: Variable) =>\n\t\t!!_.find(v.transforms, (t: Transform<any>) => t.type === 'MetricSeries')\n\t);\n\n\tmetricDefinitionModel.imports = _.uniqBy(\n\t\t[...(parentDefinitionModel.imports ?? []), ...(metricDefinitionModel.imports ?? [])],\n\t\t'to'\n\t);\n\n\tconst parentDefinitionAliases = parentDefinitionModel.aliases ?? {};\n\n\tconst parentTableVariableAlias = parentTableVariable ? parentDefinitionAliases[parentTableVariable] as {\n\t\t[columnName: string]: string;\n\t} : {};\n\n\tconst metricDefinitionAliases = {\n\t\t...metricDefinitionModel.aliases,\n\t\t...parentDefinitionAliases\n\t} as { [tableId: string]: { [columnName: string]: string } };\n\n\t//foreach table in metricDefinitionAliases replace the values with parentTableVariableAlias\n\tfor (const [tableId] of Object.entries(metricDefinitionAliases)) {\n\t\tif (!parentDefinitionAliases[tableId]) {\n\t\t\t//if the table id does not belong to the data sheet\n\n\t\t\tconst metricTableAlias = metricDefinitionAliases[tableId] as {\n\t\t\t\t[columnName: string]: string;\n\t\t\t};\n\n\t\t\t//foreach each value in the metricTableAlias replace the value with the value of the parentTableVariableAlias\n\n\t\t\tfor (const [columnName, columnId] of Object.entries(metricTableAlias)) {\n\t\t\t\t//find the value of the parentTableVariableAlias where the key is the columnId\n\n\t\t\t\tconst pColName = _.findKey(parentTableVariableAlias, (pColId) => pColId === columnId);\n\n\t\t\t\tif (pColName && pColName !== columnName) {\n\t\t\t\t\tdelete metricTableAlias[columnName];\n\t\t\t\t\tmetricTableAlias[pColName] = parentTableVariableAlias[pColName];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tmetricDefinitionModel.aliases = metricDefinitionAliases;\n\n\tconst variables = _.cloneDeep(parentDefinitionModel.variables ?? []);\n\tmetricDefinitionModel.variables = definitionVariables.filter(\n\t\t(v: Variable) => v.name === analysisVariable?.name\n\t);\n\n\tconst previousVariables = metricDefinitionModel.variables;\n\tmetricDefinitionModel.variables = [...variables];\n\tconst variableNames = metricDefinitionModel.variables?.map((v: Variable) => v?.name);\n\tmetricDefinitionModel.variables.push(\n\t\t..._.filter(previousVariables, (v: Variable) => variableNames?.includes(v.name))\n\t);\n\tconst filterVariable = _.find(definitionVariables, (v: Variable) =>\n\t\tv.transforms?.some((t: Transform<any>) => t.type === 'RuleFilter' && t.rule === '${rule_pivot}')\n\t);\n\tif (filterVariable && parentTableVariable) {\n\t\t(filterVariable.transforms![0] as RuleFilter).table = parentTableVariable;\n\t\tmetricDefinitionModel.variables.push(filterVariable);\n\t}\n\tif (analysisVariable && parentTableVariable) {\n\t\t//@ts-ignore\n\t\tanalysisVariable.transforms![0].table = parentTableVariable;\n\t\t(analysisVariable.transforms![0] as MetricSeries).row_group_by = '${rowGroupByInput}';\n\t\t(analysisVariable.transforms![0] as MetricSeries).col_group_by = '${columnGroupByInput}';\n\n\t\tconst rowGroups = metricCustomModel?.gridColumnState?.rowGroupCols ?? [];\n\t\tconst valueCols = metricCustomModel?.gridColumnState?.valueCols ?? [];\n\t\tconst showAsList = _.chain(valueCols)\n\t\t\t.filter((vc) => !!vc.showAs)\n\t\t\t.map((vc) => vc?.showAs)\n\t\t\t.value();\n\n\t\t(analysisVariable.transforms![0] as MetricSeries).require_totals =\n\t\t\t!_.isEmpty(rowGroups) ||\n\t\t\t(!_.isEmpty(showAsList) && _.some(showAsList, (showAs) => showAs !== 'default'));\n\n\t\t//find the variable where the type of the 0 element of the transforms is 'FilterRule' and the table is the same as the variable of the analysisVariable\n\n\t\tif (filterVariable) {\n\t\t\t//@ts-ignore\n\t\t\tanalysisVariable.transforms![0].table = filterVariable.name;\n\t\t\t//@ts-ignore\n\n\t\t\t//update aliases and variables of updatedDefinitionModel with the filterVariable aliases and variables\n\t\t\tif (metricDefinitionModel.aliases && parentTableVariable) {\n\t\t\t\tmetricDefinitionModel.aliases[parentTableVariable] = {\n\t\t\t\t\t...metricDefinitionModel.aliases[parentTableVariable]\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tmetricDefinitionModel.variables.push(analysisVariable);\n\t\tmetricCustomModel.variable = analysisVariable.name;\n\n\t\t// update the sheet inputs in customModel\n\t}\n\n\tmetricCustomModel.inputs = { ...parentCustomModel.inputs, ...metricCustomModel.inputs };\n\n\tif (!_.isEmpty(metricNewColumns)) {\n\t\tmetricDefinitionModel.variables.push(...metricNewColumns);\n\t\tmetricCustomModel.variable = metricNewColumns[metricNewColumns.length - 1].name;\n\t}\n\n\tif (metricCustomModel.parentTableColumnSettings && parentCustomModel.uiSettings?.columnSettings) {\n\t\tmetricCustomModel.parentTableColumnSettings.splice(\n\t\t\t0,\n\t\t\tmetricCustomModel.parentTableColumnSettings.length,\n\t\t\t...parentCustomModel.uiSettings.columnSettings\n\t\t);\n\t}\n\n\tif (metricCustomModel.inputs?.['view_worksheet'] && metricCustomModel.parentTableColumnSettings) {\n\t\t_.forEach(metricCustomModel.parentTableColumnSettings, (c) => {\n\t\t\tif (metricCustomModel.inputs?.view_worksheet) {\n\t\t\t\tmetricCustomModel.inputs.view_worksheet = _.uniq([\n\t\t\t\t\t...metricCustomModel.inputs.view_worksheet,\n\t\t\t\t\tc.field\n\t\t\t\t]);\n\t\t\t}\n\t\t});\n\t}\n\n\tif (parentTableVariable) {\n\t\tmetricCustomModel.parentTableVariable = parentTableVariable;\n\t}\n\treturn { definitionModel: metricDefinitionModel, customModel: metricCustomModel };\n};\n\nexport const getUpdatedWorksheetDefinitionCustomModels = (props: {\n\tparentSheet: Sheet<WorkbookCustomModel>;\n\tmetricSheet: Sheet<PivotCustomModel>;\n}) => {\n\tconst { parentSheet, metricSheet } = props;\n\tconst parentDefinitionModel = parentSheet?.definitionModel as Definition;\n\tconst parentCustomModel = parentSheet?.customModel;\n\tconst metricDefinitionModel = metricSheet?.definitionModel as Definition;\n\tconst metricCustomModel = metricSheet?.customModel;\n\n\tif (!parentCustomModel || !metricCustomModel) {\n\t\tthrow new Error('Parent or metric custom model is missing');\n\t}\n\n\treturn {\n\t\t...getUpdatedDefinitionCustomModel({\n\t\t\tmetricDefinitionModel,\n\t\t\tparentDefinitionModel,\n\t\t\tmetricCustomModel,\n\t\t\tparentCustomModel\n\t\t})\n\t};\n};\n\nexport const timeBinToIntervalMapper = {\n\tper_month: 'Month',\n\tper_quarter: 'Quarter',\n\tper_week: 'Week',\n\tper_day: 'Day',\n\tper_year: 'Year'\n};\n\nexport const mapValueColsWithTrends = (props: {\n\tvalueCols: ValueColsType[];\n\tcompareTrends: PivotCustomModel['compareTrends'];\n}) => {\n\tconst { valueCols, compareTrends } = props;\n\treturn _.chain(valueCols)\n\t\t.filter((vc) => !vc.hide)\n\t\t.flatMap((vc) => {\n\t\t\tif (_.isEmpty(compareTrends)) {\n\t\t\t\treturn [vc];\n\t\t\t}\n\t\t\tconst trends = _.map(compareTrends, (ct) => {\n\t\t\t\treturn {\n\t\t\t\t\t...vc,\n\t\t\t\t\tlabel: `${vc.label}__${ct.name}`,\n\t\t\t\t\tcol: `${vc.col}__${ct.name}`,\n\t\t\t\t\tsourceLabel: vc.sourceLabel ?? vc.label,\n\t\t\t\t\tcompareTrendId: ct.id\n\t\t\t\t};\n\t\t\t});\n\t\t\treturn trends;\n\t\t})\n\t\t.value();\n};\n","import type { SelectOptionType } from '$models/types/selectType';\nimport {\n\tCommonFilter,\n\tFilterPanelStoreType,\n\tFilterRule,\n\tFilterSelectOptionsType,\n\tPromotedFiltersType,\n\tRuleType\n} from '$models/ui-models/filterModel';\nimport { ColumnSetting } from '$models/ui-models/workbookModel';\nimport {\n\tgetColumnSettingsToSelectOptions,\n\treplaceFilterColumn\n} from './analysisMethods';\nimport { filterToSelectOptionType, getSelectOptionTypeToFilter } from './filterUtils';\nimport _ from 'lodash';\n\nexport type MergeCommonFilterType = {\n\tcommonFilters: CommonFilter[];\n\trule: FilterSelectOptionsType[];\n\tcondition: RuleType;\n\tid: string; // id of the block/line/kpi\n};\n\nexport type MergeFilterType = {\n\tid: string; // id of the block/line/kpi -> metric\n\tmetricFilters: FilterRule;\n\tcolumnSettings: ColumnSetting[]; // metric column settings\n\tcommonFilters: CommonFilter[];\n\tpromotedFilters: PromotedFiltersType[];\n\tdatasetIds: string[];\n};\n\nexport type ApplicablePromotedFiltersType = {\n\tid: string; // id of the block/line/kpi -> metric\n\tdatasetIds: string[];\n\tpromotedFilters: PromotedFiltersType[];\n};\n\nexport interface IMergeFilterService {\n\tmergeCommonFilters(props: MergeCommonFilterType): FilterPanelStoreType;\n\tmergeFilters(props: MergeFilterType): FilterRule; // merge all filters -> metric, promoted, common\n}\n\nexport class MergeFilterService implements IMergeFilterService {\n\tprivate getColumnSettingsForCommonFilters(cf: CommonFilter): SelectOptionType<ColumnSetting>[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: cf.name,\n\t\t\t\tvalue: cf.column.name,\n\t\t\t\toption: {\n\t\t\t\t\theaderName: cf.name,\n\t\t\t\t\tfield: cf.column.name, //@ts-ignore\n\t\t\t\t\ttype: cf.column.data_type,\n\t\t\t\t\tdatasetName: cf.datasetName,\n\t\t\t\t\tdatasetId: cf.datasetId\n\t\t\t\t}\n\t\t\t}\n\t\t];\n\t}\n\n\tmergeCommonFilters(props: MergeCommonFilterType): FilterPanelStoreType {\n\t\tconst { commonFilters, rule, id, condition } = props;\n\t\tlet replacedFr: FilterSelectOptionsType[][] = [];\n\t\tif (_.isEmpty(commonFilters)) return { defaultType: condition, rules: rule };\n\t\t_.forEach(commonFilters, (f: CommonFilter) => {\n\t\t\tconst columnSettingsSelectOption = this.getColumnSettingsForCommonFilters(f);\n\n\t\t\t// check if applied on the line\n\t\t\tconst appliedOnLine = _.find(f?.appliedOnBlocks, (l) => l.blockId === id) as {\n\t\t\t\tblockId: string;\n\t\t\t\tapplied: boolean;\n\t\t\t\tblockName: string;\n\t\t\t\tcolumn: string;\n\t\t\t\tcolumnSettings: SelectOptionType<ColumnSetting>[];\n\t\t\t};\n\t\t\tif (appliedOnLine && appliedOnLine.applied) {\n\t\t\t\tconst commonRule = f.rule;\n\t\t\t\tconst fr = filterToSelectOptionType(commonRule, columnSettingsSelectOption);\n\t\t\t\tconst columnSetting = _.find(\n\t\t\t\t\tappliedOnLine.columnSettings,\n\t\t\t\t\t(c) => c.value === appliedOnLine.column\n\t\t\t\t);\n\t\t\t\tif (columnSetting) {\n\t\t\t\t\treplacedFr.push(replaceFilterColumn({ fr: fr.rules, column: columnSetting }));\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tconst mergedFr = _.unionBy(replacedFr.flat(), rule, 'value');\n\n\t\treturn { defaultType: condition, rules: mergedFr };\n\t}\n\n\tprivate getApplicablePromotedFilters(props: ApplicablePromotedFiltersType) {\n\t\tconst { id, datasetIds, promotedFilters } = props;\n\t\treturn _.filter(promotedFilters, (pf) => {\n\t\t\tconst appliedBlock = _.find(pf.appliedOnBlocks, (aob) => aob.blockId === id);\n\t\t\tconst isApplied = appliedBlock?.applied ?? false;\n\t\t\treturn isApplied && _.includes(datasetIds, pf.datasetId);\n\t\t});\n\t}\n\n\tprivate getUnion(\n\t\tpromotedFilters: PromotedFiltersType[],\n\t\tmetricFilters: FilterRule,\n\t\tcolumnSettings: ColumnSetting[]\n\t): FilterPanelStoreType {\n\t\t/** get select options for promoted filters */\n\t\tconst pfSelectOptions = _.map(promotedFilters, (pf) => {\n\t\t\treturn (\n\t\t\t\tfilterToSelectOptionType(pf.rule, getColumnSettingsToSelectOptions(pf.blockColumnSettings))\n\t\t\t\t\t?.rules ?? []\n\t\t\t);\n\t\t}).flat();\n\n\t\tconst mFilterModel = filterToSelectOptionType(\n\t\t\tmetricFilters,\n\t\t\tgetColumnSettingsToSelectOptions(columnSettings)\n\t\t);\n\n\t\tif (_.isEmpty(mFilterModel)) {\n\t\t\treturn { defaultType: 'and_cond', rules: pfSelectOptions };\n\t\t}\n\n\t\tconst ruleType = mFilterModel?.defaultType ?? 'and_cond';\n\t\tconst mSelectOptions = mFilterModel?.rules ?? [];\n\n\t\tconst union = _.unionBy(pfSelectOptions, mSelectOptions, 'value');\n\t\treturn { defaultType: ruleType, rules: union };\n\t}\n\n\t/** merges promoted filter to metric filter */\n\tprivate mergePromotedFilters(props: MergeFilterType): FilterPanelStoreType {\n\t\tconst { metricFilters, columnSettings, promotedFilters } = props;\n\n\t\tconst applicablePromotedFilters = this.getApplicablePromotedFilters({\n\t\t\tid: props.id,\n\t\t\tdatasetIds: props.datasetIds,\n\t\t\tpromotedFilters\n\t\t});\n\n\t\treturn this.getUnion(applicablePromotedFilters, metricFilters, columnSettings);\n\t}\n\n\tmergeFilters(props: MergeFilterType): FilterRule {\n\t\tconst { commonFilters } = props;\n\n\t\tconst filtersWithPromoted = this.mergePromotedFilters(props);\n\t\tconst filtersWithCommon = this.mergeCommonFilters({\n\t\t\tcommonFilters,\n\t\t\trule: filtersWithPromoted.rules,\n\t\t\tid: props.id,\n\t\t\tcondition: (filtersWithPromoted?.defaultType ?? 'and_cond') as RuleType\n\t\t});\n\n\t\treturn getSelectOptionTypeToFilter(filtersWithCommon);\n\t}\n}\n","import { HierarchyProperties, Worksheet } from \"$models/gen/Api\";\nimport { DashboardDateRangeModel } from \"$models/ui-models/dashboardModel\";\nimport {\n Inputs,\n TimeBin,\n} from \"$models/ui-models/definitionModel\";\nimport {\n CommonFilter,\n FilterPanelStoreType,\n FilterRule,\n PromotedFiltersType,\n} from \"$models/ui-models/filterModel\";\nimport {\n ShowAsEnum,\n type BoardCurrencyModel,\n type ColumnSetting,\n type MetricMetadataType,\n type RowGroupsType,\n type ValueColsType,\n} from \"$models/ui-models/workbookModel\";\nimport _ from \"lodash\";\nimport {\n filterToSelectOptionType,\n getColumnFilterRuleFromCombinedFilterRule,\n getSelectOptionTypeToFilter,\n} from \"./filterUtils\";\nimport { MergeFilterService } from \"./mergeFilterService\";\nimport {\n defaultFilterRule,\n getColumnSettingsToSelectOptions,\n getDrilldownFiltersMap,\n getFiltersToBeAppliedOnDrilldown,\n getMetricFilterRule,\n ShowAsToProjectFractionMapper,\n} from \"./analysisMethods\";\nimport { DateRange } from \"$models/ui-models/dateRangeModel\";\n\nconst updatePromotedFiltersAndDateRangeToMetadataAndInputs = (props: {\n blockId: string;\n metadata: MetricMetadataType;\n promotedFiltersStoreValue: {\n [datasetId: string]: { [id: string]: FilterPanelStoreType };\n };\n promotedFilters: PromotedFiltersType[];\n inputs: Inputs;\n dateRangeModel: DashboardDateRangeModel;\n currencyModel: BoardCurrencyModel;\n commonFilters?: CommonFilter[];\n}) => {\n const { blockId, metadata, promotedFilters, inputs, commonFilters } = props;\n\n const updateDateRange = (updateProps: {\n blockId: string;\n blockDateRange: DateRange;\n dateRangeModel: DashboardDateRangeModel;\n }) => {\n const { blockId, blockDateRange, dateRangeModel } = updateProps;\n const { dateRange, appliedOnBlocks } = dateRangeModel;\n\n const dateRangeApplicableOnBlockIds = appliedOnBlocks\n ?.filter((apb: { applied: boolean }) => apb.applied)\n ?.map((apb: { blockId: string }) => apb.blockId);\n\n if (dateRangeApplicableOnBlockIds?.includes(blockId)) {\n return dateRange;\n } else {\n return blockDateRange;\n }\n };\n\n const updateCurrencyFilter = (updateProps: {\n blockId: string;\n blockCurrencyFilter: string;\n currencyModel: BoardCurrencyModel;\n }) => {\n const { blockId, blockCurrencyFilter, currencyModel } = updateProps;\n const { currency, appliedOnBlocks } = currencyModel;\n\n const currencyFilterApplicableOnBlockIds = _.chain(appliedOnBlocks)\n .filter((apb: { applied: boolean }) => apb.applied)\n .map((apb: { blockId: string }) => apb.blockId)\n .value();\n\n if (currencyFilterApplicableOnBlockIds?.includes(blockId)) {\n return currency;\n } else {\n return blockCurrencyFilter;\n }\n };\n\n const metricColumnFilter = getColumnFilterRuleFromCombinedFilterRule(\n metadata.filterModel as FilterRule,\n metadata.valueCols || []\n );\n\n const updatedFilterRule = new MergeFilterService().mergeFilters({\n id: blockId,\n metricFilters: metricColumnFilter as FilterRule,\n columnSettings: metadata.columnSettings,\n promotedFilters,\n commonFilters: commonFilters || [],\n datasetIds: [metadata.datasetId || \"\"],\n });\n\n const updatedDateRange = updateDateRange({\n blockId,\n blockDateRange: metadata.dateRange || { time_period: \"past_quarter\" },\n dateRangeModel: props.dateRangeModel,\n });\n\n const updateCurrencyFilterValue = updateCurrencyFilter({\n blockId,\n blockCurrencyFilter: metadata.currency || \"\",\n currencyModel: props.currencyModel,\n });\n\n const updatedInputs = {\n ...inputs,\n [\"filterOnAggregates\"]: _.get(\n inputs,\n \"filterOnAggregates\",\n defaultFilterRule\n ),\n [\"rule_pivot\"]: updatedFilterRule,\n date_range: updatedDateRange,\n to_currency: updateCurrencyFilterValue,\n showDimensionMappingValues: metadata.showDimensionMappingValues ?? false,\n showBinSortOrderValues: metadata?.inputs?.showBinSortOrderValues ?? false,\n };\n const updatedMetadata = {\n ...metadata,\n filterModel: updatedFilterRule,\n dateRange: updatedDateRange,\n inputs: updatedInputs,\n };\n\n return { updatedInputs, updatedMetadata };\n};\n\nconst getRowsToGroupBy = (props: {\n pivotColumns: string[];\n timeBin: TimeBin | \"\";\n rowGroupColumns: RowGroupsType;\n}) => {\n const { pivotColumns, timeBin, rowGroupColumns } = props;\n const rowsToGroupBy = [];\n if (!_.isEmpty(pivotColumns)) {\n if (timeBin) {\n rowsToGroupBy.push([...rowGroupColumns]);\n for (let i = 0; i < pivotColumns.length; i++) {\n const pcols = pivotColumns;\n rowsToGroupBy.push([...pcols.slice(0, i + 1), ...rowGroupColumns]);\n }\n } else {\n for (let i = 0; i < pivotColumns.length; i++) {\n const pcols = pivotColumns;\n rowsToGroupBy.push([...pcols.slice(0, i + 1), ...rowGroupColumns]);\n }\n }\n } else {\n rowsToGroupBy.push([...pivotColumns, ...rowGroupColumns]);\n }\n\n return rowsToGroupBy;\n};\n\nconst getInputsArray = (props: {\n pivotColumns: string[];\n timeBin: TimeBin | \"\";\n rowsToGroupBy: string[][];\n inputs: Inputs;\n dateColumn: string;\n valueCols: ValueColsType[];\n hierarchy?: HierarchyProperties;\n rowGroupCols?: RowGroupsType;\n compareTrends?: MetricMetadataType[\"compareTrends\"];\n showDimensionMappingValues?: boolean;\n showBinSortOrderValues: boolean;\n}) => {\n const {\n pivotColumns,\n timeBin,\n rowsToGroupBy,\n inputs,\n dateColumn,\n valueCols,\n hierarchy,\n rowGroupCols,\n compareTrends,\n showDimensionMappingValues = false,\n showBinSortOrderValues = false,\n } = props;\n let inputsArray: Inputs[] = [];\n const inputsCompareTrendsIndices: Array<{ id: string; index: number }> = [];\n\n const getViewsInput = (index?: number) => {\n let viewInputs = inputs?.viewInputs;\n if (!viewInputs) return undefined;\n\n const valueColsLabel = _.map(valueCols, (vc) => vc.label);\n viewInputs = _.filter(\n viewInputs,\n (vi) => valueColsLabel.includes(vi) || vi.includes(\"__bc_\")\n );\n\n if (_.isEmpty(rowGroupCols)) {\n viewInputs = _.filter(viewInputs, (vi) => !vi.includes(\"__bc_\"));\n }\n if (timeBin) {\n viewInputs = _.uniq([...viewInputs, dateColumn, `${dateColumn}_group`]);\n }\n if (index !== undefined) {\n viewInputs = _.uniq([...viewInputs, ...rowsToGroupBy[index]]);\n } else {\n if (!_.isEmpty(rowGroupCols)) {\n let row = rowsToGroupBy[0];\n if (!_.isEmpty(hierarchy) && hierarchy) {\n const rowLabelName = _.get(rowsToGroupBy, \"0.0.0\");\n row = [\n rowLabelName,\n `${rowLabelName}_level_number`,\n `${rowLabelName}_${hierarchy.parentColId}`,\n `${rowLabelName}_${hierarchy.nodeColName}`,\n ];\n }\n\n viewInputs = _.uniq([...viewInputs, ...row]);\n }\n }\n return viewInputs;\n };\n\n const projectAsInput = _.reduce(\n valueCols,\n (acc: Record<string, any>, curr) => {\n if (curr.showAs && curr.showAs !== ShowAsEnum.DEFAULT && curr.label) {\n acc[curr.label] = ShowAsToProjectFractionMapper[curr.showAs];\n }\n return acc;\n },\n {} as Record<string, any>\n );\n\n const sortPivotInputsKey = Object.keys(inputs).find((key) =>\n key.startsWith(\"sortPivotInputs\")\n );\n const sortPivotInputsValue = sortPivotInputsKey\n ? { ...inputs[sortPivotInputsKey] }\n : undefined;\n\n if (!_.isEmpty(pivotColumns)) {\n const pc = timeBin ? [dateColumn, ...pivotColumns] : pivotColumns;\n\n pc?.forEach((col, index) => {\n const groupByInput = rowsToGroupBy[index];\n const columnGroupByInput = _.filter(groupByInput, (r) => pc.includes(r));\n const rowGroupByInput = _.filter(groupByInput, (r) => !pc.includes(r));\n if (sortPivotInputsValue) {\n sortPivotInputsValue.pivotColumns = rowsToGroupBy[index];\n }\n\n inputsArray.push({\n ...inputs,\n groupByInput: rowsToGroupBy[index],\n dateColumnInput: dateColumn,\n binByInput: timeBin,\n viewInputs: getViewsInput(index),\n columnGroupByInput,\n rowGroupByInput,\n projectAsInput,\n showDimensionMappingValues,\n showBinSortOrderValues,\n ...(sortPivotInputsKey\n ? { [sortPivotInputsKey]: sortPivotInputsValue }\n : {}),\n });\n });\n } else {\n if (compareTrends && compareTrends.length > 0) {\n if (sortPivotInputsValue) {\n sortPivotInputsValue.pivotColumns = rowsToGroupBy[0];\n }\n inputsArray = _.map(compareTrends, (ct, index) => {\n inputsCompareTrendsIndices.push({ id: ct.id, index });\n return {\n ...inputs,\n date_range: { ...ct.dateRange },\n groupByInput: rowsToGroupBy[0],\n dateColumnInput: dateColumn,\n binByInput: timeBin,\n viewInputs: getViewsInput(),\n rowGroupByInput: rowsToGroupBy[0],\n columnGroupByInput: [],\n projectAsInput,\n showDimensionMappingValues,\n showBinSortOrderValues,\n ...(sortPivotInputsKey\n ? { [sortPivotInputsKey]: sortPivotInputsValue }\n : {}),\n };\n });\n } else {\n if (sortPivotInputsValue) {\n sortPivotInputsValue.pivotColumns = rowsToGroupBy[0];\n }\n inputsArray = [\n {\n ...inputs,\n groupByInput: rowsToGroupBy[0],\n dateColumnInput: dateColumn,\n binByInput: timeBin,\n viewInputs: getViewsInput(),\n rowGroupByInput: rowsToGroupBy[0],\n columnGroupByInput: [],\n projectAsInput,\n showDimensionMappingValues,\n showBinSortOrderValues,\n ...(sortPivotInputsKey\n ? { [sortPivotInputsKey]: sortPivotInputsValue }\n : {}),\n },\n ];\n }\n }\n\n return { inputs: inputsArray, inputsCompareTrendsIndices };\n};\n\nconst mergeDrilldownFiltersToMetricFilters = (props: {\n metricFilterRule: FilterRule;\n filtersToBeApplied: { field: string; key: string }[];\n columnSettings: ColumnSetting[];\n}) => {\n const { metricFilterRule, filtersToBeApplied, columnSettings } = props;\n const columnSelectOptions = getColumnSettingsToSelectOptions(columnSettings);\n const metricFilterRuleSelectOptions = filterToSelectOptionType(\n metricFilterRule,\n columnSelectOptions\n );\n const drilldownFilterMap = getDrilldownFiltersMap({\n filtersToBeApplied,\n columnSelectOptions,\n });\n\n const mergedRule = _.unionBy(\n Object.values(drilldownFilterMap),\n metricFilterRuleSelectOptions.rules,\n \"value\"\n );\n const filterRule: FilterRule = getSelectOptionTypeToFilter({\n defaultType: \"and_cond\",\n rules: mergedRule,\n });\n\n return filterRule;\n};\n\nexport const getMetricDefinition = (props: {\n sheetId: string;\n metadata: MetricMetadataType;\n groupKeys: string[];\n lastModifiedDate: string;\n promotedFiltersStoreValue: {\n [datasetId: string]: { [id: string]: FilterPanelStoreType };\n };\n promotedFilters: PromotedFiltersType[];\n dateRangeModel: DashboardDateRangeModel;\n currencyModel: BoardCurrencyModel;\n commonFilters: CommonFilter[];\n}) => {\n const {\n sheetId,\n metadata,\n groupKeys,\n promotedFiltersStoreValue,\n promotedFilters,\n dateRangeModel,\n currencyModel,\n commonFilters,\n } = props;\n const {\n parentTableVariable,\n valueCols,\n rowGroupCols,\n pivotCols,\n timeBin,\n dateColumn,\n columnSettings,\n } = metadata;\n let inputs = metadata?.inputs;\n\n //if (isHierarchyMetric({ rowGroups: metadata?.rowGroupCols })) {\n //gridApi.setPivotResultColumns([]);\n // return await this.runHierarchyMetricsForDashboards(props);\n //}\n\n const { updatedInputs } =\n updatePromotedFiltersAndDateRangeToMetadataAndInputs({\n blockId: sheetId,\n metadata,\n promotedFiltersStoreValue,\n promotedFilters,\n inputs,\n dateRangeModel,\n currencyModel,\n commonFilters,\n });\n\n let rowsToGroupBy = getRowsToGroupBy({\n pivotColumns: pivotCols || [],\n rowGroupColumns: (rowGroupCols || []).slice(0, groupKeys.length + 1),\n timeBin: timeBin || \"\",\n });\n\n let { inputs: inputsArray } = getInputsArray({\n inputs: updatedInputs,\n dateColumn: dateColumn || \"\",\n timeBin: timeBin || \"\",\n rowsToGroupBy: rowsToGroupBy as string[][],\n pivotColumns: pivotCols || [],\n valueCols: valueCols || [],\n rowGroupCols: rowGroupCols,\n compareTrends: metadata.compareTrends,\n showDimensionMappingValues:\n metadata?.inputs?.showDimensionMappingValues ?? false,\n showBinSortOrderValues: metadata?.inputs?.showBinSortOrderValues ?? false,\n });\n\n if (!_.isEmpty(groupKeys)) {\n const mergedFilterRule = mergeDrilldownFiltersToMetricFilters({\n metricFilterRule: getMetricFilterRule(inputsArray),\n filtersToBeApplied: getFiltersToBeAppliedOnDrilldown({\n rowGroups: metadata?.rowGroupCols as string[],\n groupKeys,\n }),\n columnSettings,\n });\n\n inputsArray = inputsArray?.map((ia) => {\n return { ...ia, [\"rule_pivot\"]: mergedFilterRule };\n });\n }\n\n return {\n inputs: inputsArray,\n describe: parentTableVariable,\n };\n};\n\nexport const getSelectedMetricsParentIds = (selectedItems: { sheet: Worksheet }[]) => {\n return _.chain(selectedItems)\n .map((s) => s?.sheet?.customFields?.parentTableId as unknown as string)\n .uniq()\n .value();\n};\n\n\nexport const defaultDashboardDateRangeModel: DashboardDateRangeModel = {\n\t//@ts-ignore\n\tdateRange: {},\n\tappliedOnBlocks: []\n};\n\nexport const defaultCurrencyModel: BoardCurrencyModel = {\n\tcurrency: 'USD',\n\tappliedOnBlocks: []\n};","// REMOVE THIS FILE AFTER REFACTORING INPUT TABLES\nimport { ColumnFilterRule } from '$models/gen/Api';\nimport {\n\tMetricAggregateType,\n\tMetricSeries,\n} from '$models/ui-models/definitionModel';\nimport {\n\tInputTableDefinitionModel,\n\tInputTableFilterTransform,\n\tInputTableSortTransform,\n\tInputTableTransformation\n} from '$models/ui-models/inputTableModel';\nimport {\n\tSortOptions,\n\tValueColsType\n} from '$models/ui-models/workbookModel';\nimport _ from 'lodash';\nimport { getColumnSettingsToSelectOptions, getDrilldownFiltersMap, getFiltersToBeAppliedOnDrilldown } from '../metric/analysisMethods';\nimport { filterToSelectOptionType, getSelectOptionTypeToFilter } from '../metric/filterUtils';\n\nexport const getGroupByDefinition = ({\n\ttableId,\n\ttableName,\n\tgroupKeys,\n\trowGroupCols,\n\tcolumnSettings,\n\tfilterRules,\n\tsortValue,\n\tmetricSeries\n}) => {\n\tlet filtersToBeApplied = getFiltersToBeAppliedOnDrilldown({\n\t\tgroupKeys,\n\t\trowGroups: rowGroupCols as string[]\n\t});\n\tconst columnSelectOptions = getColumnSettingsToSelectOptions(columnSettings);\n\n\tconst metricFilterRuleSelectOptions = filterToSelectOptionType(filterRules, columnSelectOptions);\n\tconst crossFilterMap = getDrilldownFiltersMap({\n\t\tfiltersToBeApplied,\n\t\tcolumnSelectOptions\n\t});\n\n\tconst mergedRule = _.unionBy(\n\t\tObject.values(crossFilterMap),\n\t\tmetricFilterRuleSelectOptions.rules,\n\t\t'value'\n\t);\n\n\tconst filterRule = getSelectOptionTypeToFilter({\n\t\tdefaultType: 'and_cond',\n\t\trules: mergedRule\n\t});\n\treturn generateDefinitionModel({\n\t\tfilters: filterRule as any,\n\t\tsort: sortValue,\n\t\tmetricSeries,\n\t\ttableId,\n\t\ttableName\n\t});\n};\n\nexport const generateDefinitionModel = ({\n\tfilters,\n\tsort,\n\tmetricSeries,\n\ttableId,\n\ttableName\n}: {\n\tfilters?: ColumnFilterRule;\n\tsort?: Record<string, any>;\n\tmetricSeries?: Partial<MetricSeries>;\n\ttableId: string;\n\ttableName: string;\n}): { targetName: string; definition: InputTableDefinitionModel } => {\n\tconst { transformations, targetName } = generateTransformations(\n\t\ttableName,\n\t\tfilters,\n\t\tsort,\n\t\tmetricSeries\n\t);\n\n\tconst importConfig: any = getImportConfig(tableId, tableName);\n\treturn {\n\t\ttargetName,\n\t\tdefinition: {\n\t\t\timports: [importConfig],\n\t\t\ttransformations\n\t\t}\n\t};\n};\n\nexport const sortConfigFromValue = (sortBy: SortOptions) => {\n\tconst sortValueObj = !_.isNil(sortBy?.sortByField)\n\t\t? { [sortBy.sortByField.value]: _.get(sortBy, 'sortByOrder', 'asc').toUpperCase() }\n\t\t: undefined;\n\treturn sortValueObj;\n};\n\nexport const getMetricSeries = (props: {\n\tpivotCols: string[];\n\trowGroupCols: string[];\n\tvalueCols: ValueColsType[];\n}) => {\n\tconst { pivotCols, rowGroupCols, valueCols } = props;\n\tconst group_by = [...pivotCols, ...rowGroupCols];\n\n\tconst aggregates: MetricAggregateType[] = _.map<\n\t\tValueColsType,\n\t\t[alias: string, formula: string] | [alias: string, col: string, func: string]\n\t>(valueCols, (valueCol) => {\n\t\tif (valueCol.type === 'formula') {\n\t\t\tconst formula = valueCol.formula;\n\t\t\treturn [valueCol.label, formula];\n\t\t} else if (valueCol.type === 'column') {\n\t\t\tconst formula = valueCol.formula;\n\t\t\treturn [valueCol.label, formula];\n\t\t}\n\t\treturn [valueCol.label, valueCol.col, valueCol.aggFun];\n\t});\n\n\tconst metricSeries: Partial<MetricSeries> = {\n\t\taggregates,\n\t\tgroup_by,\n\t\trow_group_by: rowGroupCols,\n\t\tcol_group_by: pivotCols,\n\t\ttype: 'TableAggregate',\n\t\tformula_on_aggregates: []\n\t};\n\treturn metricSeries;\n};\n\nconst getFilterConfig = (\n\tfilters: ColumnFilterRule,\n\tprevName: string\n): InputTableFilterTransform => ({\n\tname: 'table_filter',\n\ttable_name: prevName,\n\tfilter: filters,\n\ttype: 'CollectionFilter'\n});\n\nconst getSortConfig = (sort: Record<string, any>, prevName: string): InputTableSortTransform => ({\n\tname: 'table_sort',\n\ttable_name: prevName,\n\tsort_columns: sort,\n\ttype: 'CollectionSort'\n});\n\nconst generateTransformations = (\n\ttableName: string,\n\tfilters?: ColumnFilterRule,\n\tsort?: Record<string, any>,\n\tmetricSeries?: Partial<MetricSeries>\n): { transformations: InputTableTransformation[]; targetName: string } => {\n\tconst transformations = [];\n\tlet prevName = tableName;\n\tlet targetName = tableName;\n\n\tif (!_.isEmpty(filters)) {\n\t\tconst filterConfig = getFilterConfig(filters, prevName);\n\t\ttransformations.push(filterConfig);\n\t\tprevName = filterConfig.name;\n\t\ttargetName = 'table_filter';\n\t}\n\n\tif (metricSeries) {\n\t\tconst aggregateConfig = {\n\t\t\tname: 'table_aggregate',\n\t\t\ttable_name: prevName,\n\t\t\taggregates: metricSeries.aggregates,\n\t\t\tgroup_by: metricSeries.group_by,\n\t\t\ttype: 'CollectionAggregate'\n\t\t};\n\t\ttransformations.push(aggregateConfig);\n\t\tprevName = aggregateConfig.name;\n\t\ttargetName = 'table_aggregate';\n\t}\n\n\tif (metricSeries?.aggregates) {\n\t\tif (sort !== undefined) {\n\t\t\tconst sortEntries = Object.entries(sort);\n\t\t\tif (sortEntries.length > 0) {\n\t\t\t\tconst newSort = {};\n\t\t\t\tfor (const [sortKey, sortOrder] of sortEntries) {\n\t\t\t\t\tconst matchingAggregate = metricSeries.aggregates.find((agg) => agg[1] === sortKey);\n\t\t\t\t\tif (matchingAggregate) {\n\t\t\t\t\t\tnewSort[matchingAggregate[0]] = sortOrder;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsort = _.isEmpty(newSort) ? {} : newSort;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!_.isEmpty(sort)) {\n\t\tconst sortConfig = getSortConfig(sort, prevName);\n\t\ttransformations.push(sortConfig);\n\t\tprevName = sortConfig.name;\n\t\ttargetName = 'table_sort';\n\t}\n\n\treturn { transformations, targetName };\n};\n\nconst getImportConfig = (id: string, name: string) => ({\n\tname: name,\n\ttable_id: id,\n\ttype: 'TableImport'\n});\n\n\n","import axios, { AxiosRequestConfig } from \"axios\";\nimport { getFileUrlByFileId, GetFileUrlRequest } from \"../../api/file\";\n\nexport async function downloadFile(\n loc: string,\n contentType: string\n): Promise<object | null> {\n if (!loc) return null;\n\n const requestData: GetFileUrlRequest = {\n key: loc,\n contentType: contentType,\n method: \"GET\" as unknown as \"GET\" | \"PUT\" | \"POST\", // Type assertion to match the expected type\n };\n\n try {\n const response = await getFileUrlByFileId(requestData);\n // Get the PresignedUrl\n const presignedUrl = response.url;\n\n const config: AxiosRequestConfig = {\n method: \"GET\",\n url: presignedUrl,\n headers: {\n \"Content-Type\": \"application/octet-stream\",\n },\n };\n const axiosInstance = axios.create();\n const result = await axiosInstance(config);\n\n const fileRead = result.data;\n return fileRead;\n } catch (error) {\n console.error(\"Error downloading file:\", error);\n throw error;\n }\n}\n","import { Sheet } from \"$models/ui-models/workbookModel\";\nimport { downloadFile } from \"../file/downloadFile\";\n\nexport const hydrateWorksheet = async (sheet: Sheet): Promise<Sheet | null> => {\n try {\n if (!sheet) return sheet;\n\n const isHydrated = sheet.definitionModel && sheet.customModel;\n\n if (isHydrated) {\n return sheet;\n }\n\n const definitionModelId = sheet.externalDataId;\n const customModelId = sheet.modelId;\n\n let definitionModel = {} as Record<string, unknown>;\n let customModel = {} as Record<string, unknown>;\n const sheetId = sheet.id as string;\n if (definitionModelId && customModelId) {\n definitionModel = (await downloadFile(definitionModelId, \"application/json\")) as Record<\n string,\n unknown\n >;\n customModel = (await downloadFile(customModelId, \"application/json\")) as Record<\n string,\n unknown\n >;\n }\n if (!definitionModel || !definitionModel[sheetId]) {\n return sheet;\n }\n sheet.definitionModel = definitionModel[sheetId];\n sheet.customModel = customModel[sheetId];\n return sheet;\n } catch (error) {\n console.error(\"Error hydrating portal page:\", error);\n throw error;\n }\n};\n","import _ from \"lodash\";\nimport { getWorksheets } from \"../worksheet\";\nimport { getMetricDefinition } from \"../../utils\";\nimport {\n defaultCurrencyModel,\n defaultDashboardDateRangeModel,\n getSelectedMetricsParentIds,\n} from \"../../utils/metric/getMetricDefinition\";\nimport { hydrateWorksheet } from \"../../utils/metric/hydrateWorksheet\";\nimport { getUpdatedDefinitionCustomModel } from \"../../utils/metric/analysisMethods\";\nimport { Definition, Inputs, TimeBin } from \"$models/ui-models/definitionModel\";\nimport {\n GridColumnState,\n MetricMetadataType,\n PivotCustomModel,\n} from \"$models/ui-models/workbookModel\";\nimport { runPublishedDefinition } from \"../definition\";\n\nexport const getData = async (\n metricSheetId: string,\n options?: {\n groupKeys?: string[];\n isKPI?: boolean;\n plotAsTrend?: boolean;\n stringValue?: boolean;\n }\n) => {\n const worksheets = await getWorksheets([metricSheetId]);\n if (_.isEmpty(worksheets)) return {};\n\n const selectedWorksheet = worksheets[0];\n const hydratedSheet = await hydrateWorksheet(selectedWorksheet);\n if (!hydratedSheet) return {};\n\n const selectedMetricsParentIds = getSelectedMetricsParentIds([\n { sheet: selectedWorksheet },\n ]);\n const parentWorksheets = await getWorksheets(selectedMetricsParentIds);\n const parentSheet = _.find(\n parentWorksheets,\n (ps) =>\n ps.id === (hydratedSheet?.customFields.parentTableId as unknown as string)\n );\n let definitionModel;\n let customModel;\n\n if (parentSheet) {\n const hydratedParentSheet = await hydrateWorksheet(parentSheet);\n if (hydratedParentSheet?.definitionModel) {\n const {\n definitionModel: parentDefinitionModel,\n customModel: parentCustomModel,\n } = getUpdatedDefinitionCustomModel({\n metricDefinitionModel: hydratedSheet.definitionModel as Definition,\n parentDefinitionModel:\n hydratedParentSheet?.definitionModel as Definition,\n parentCustomModel: hydratedParentSheet?.customModel as PivotCustomModel,\n metricCustomModel: hydratedSheet.customModel as PivotCustomModel,\n });\n definitionModel = parentDefinitionModel;\n customModel = parentCustomModel;\n }\n } else {\n definitionModel = hydratedSheet.definitionModel as Definition;\n customModel = hydratedSheet.customModel as PivotCustomModel;\n }\n\n const cModel = customModel;\n const dModel = definitionModel as Definition;\n const gridColumnState: GridColumnState =\n cModel?.gridColumnState as GridColumnState;\n\n const { variable, parentTableVariable, inputs } = cModel as {\n variable: string;\n parentTableVariable: string;\n inputs: Inputs;\n };\n\n const aliases = dModel?.aliases?.[parentTableVariable];\n\n let timeBin = \"\";\n if (options?.isKPI) {\n timeBin = (\n options?.plotAsTrend\n ? !_.isEmpty(cModel?.timeBin)\n ? cModel?.timeBin\n : \"per_month\"\n : \"\"\n ) as TimeBin;\n } else {\n timeBin = cModel?.timeBin ?? \"\";\n }\n\n const valueCols = _.map(gridColumnState?.valueCols, (vc) => ({\n ...vc,\n hide: false,\n }));\n\n const columnSettings = _.map(cModel?.parentTableColumnSettings, (cs) => ({\n ...cs,\n hide: false,\n }));\n const metadata: MetricMetadataType = {\n variable,\n parentTableVariable,\n inputs,\n datasetId: cModel?.datasetId ?? \"\",\n datasetName: cModel?.datasetName ?? \"\",\n columnSettings: columnSettings ?? [],\n filterColumnsBy: cModel?.filterColumnsBy ?? {},\n filterModel: hydratedSheet?.customModel?.gridColumnState?.filterModel ?? {},\n valueCols: valueCols ?? [],\n rowGroupCols: gridColumnState?.rowGroupCols ?? [],\n pivotCols: gridColumnState?.pivotCols ?? [],\n dateColumn: cModel?.dateColumn,\n timeBin: timeBin as TimeBin,\n dateRange: cModel?.inputs?.date_range,\n aliases,\n lastModifiedDate: hydratedSheet?.lastModifiedDate,\n hierarchy: cModel?.hierarchy,\n description: \"\",\n isKPI: options?.isKPI ?? false,\n currency: cModel?.currency,\n sortOptions: cModel?.sortOptions,\n limitOptions: cModel?.limitOptions,\n stringValue: options?.stringValue ?? false,\n };\n\n const { inputs: definitionInputs, describe } = getMetricDefinition({\n sheetId: hydratedSheet.id as string,\n metadata,\n groupKeys: options?.groupKeys ?? [],\n lastModifiedDate: hydratedSheet.lastModifiedDate as string,\n promotedFiltersStoreValue: {},\n promotedFilters: [],\n dateRangeModel:\n hydratedSheet?.customModel?.dateRangeModel ??\n defaultDashboardDateRangeModel,\n currencyModel:\n hydratedSheet?.customModel?.currencyModel ?? defaultCurrencyModel,\n commonFilters: [],\n });\n\n let resultData = [] as object[];\n if (\n !_.isEmpty(valueCols) ||\n !_.isEmpty(metadata.rowGroupCols) ||\n !_.isEmpty(metadata.pivotCols)\n ) {\n if (!_.isEmpty(definitionInputs)) {\n let promises = [] as Promise<any>[];\n definitionInputs.forEach((input) => {\n promises.push(\n runPublishedDefinition({\n inputs: { ...input },\n sheet: {\n id: hydratedSheet.id as string,\n lastModifiedDate: hydratedSheet.lastModifiedDate as string,\n },\n variable,\n describe: parentTableVariable,\n })\n );\n });\n const data = await Promise.all(promises);\n resultData = _.map(data, (d) => d.data.data);\n } else {\n const result = (\n await runPublishedDefinition({\n inputs: { ...inputs },\n sheet: {\n id: hydratedSheet.id as string,\n lastModifiedDate: hydratedSheet.lastModifiedDate as string,\n },\n variable,\n describe: parentTableVariable,\n })\n ).data;\n resultData = result.data;\n }\n }\n resultData = _.flatten(resultData);\n\n return { data: resultData };\n};\n","import {\n\tDefinition,\n\tImport,\n\tLoad,\n\tVariable,\n\tExport,\n\tPermission,\n\tTable,\n\tInputs,\n\tAvailableTransform\n} from '$models/ui-models/definitionModel';\nimport { Section } from '$models/ui-models/reportModel';\n\nexport class DefinitionBuilder {\n\tprivate definition: Definition;\n\n\tprivate constructor(def?: Definition) {\n\t\tthis.definition = {\n\t\t\tinputs: {},\n\t\t\taliases: {},\n\t\t\timports: [],\n\t\t\tloads: [],\n\t\t\tvariables: [],\n\t\t\tpermissions: [],\n\t\t\texports: [],\n\t\t\ttables: [],\n\t\t\tsections: []\n\t\t};\n\n\t\tif (def) {\n\t\t\tthis.definition = {\n\t\t\t\t...this.definition,\n\t\t\t\t...def\n\t\t\t};\n\t\t}\n\t}\n\n\tstatic builder(def?: Definition): DefinitionBuilder {\n\t\treturn new DefinitionBuilder(def);\n\t}\n\n\t// Input methods\n\twithInputs(inputs: Inputs): DefinitionBuilder {\n\t\tthis.definition.inputs = { ...this.definition.inputs, ...inputs };\n\t\treturn this;\n\t}\n\n\t// Alias methods\n\twithAlias(tableName: string, columnAliases: Record<string, string>): DefinitionBuilder {\n\t\tif (!this.definition.aliases) {\n\t\t\tthis.definition.aliases = {};\n\t\t}\n\t\tthis.definition.aliases[tableName] = columnAliases;\n\t\treturn this;\n\t}\n\n\t// Import methods\n\taddImport(imprt: Import): DefinitionBuilder {\n\t\tthis.definition.imports?.push(imprt);\n\t\treturn this;\n\t}\n\n\taddDatasetImport(\n\t\tdatasetId: string,\n\t\toptions?: Partial<Omit<Import, 'loc' | 'to' | 'import_type'>>\n\t): DefinitionBuilder {\n\t\tconst imprt: Import = {\n\t\t\tloc: datasetId,\n\t\t\tto: datasetId,\n\t\t\timport_type: 'dataset',\n\t\t\t...options\n\t\t};\n\t\treturn this.addImport(imprt);\n\t}\n\n\t// Load methods\n\taddLoad(load: Load): DefinitionBuilder {\n\t\tthis.definition.loads?.push(load);\n\t\treturn this;\n\t}\n\n\taddFileLoad(\n\t\tfrom: string,\n\t\tto: string,\n\t\tfsOptions: Record<string, unknown> = {}\n\t): DefinitionBuilder {\n\t\tconst load: Load = {\n\t\t\tloc: from,\n\t\t\tto,\n\t\t\tfs_options: fsOptions\n\t\t};\n\t\treturn this.addLoad(load);\n\t}\n\n\t// Variable methods\n\taddVariable(name: string, transforms: AvailableTransform[]): DefinitionBuilder {\n\t\tconst variable: Variable = {\n\t\t\tname,\n\t\t\ttransforms\n\t\t};\n\t\tthis.definition.variables?.push(variable);\n\t\treturn this;\n\t}\n\n\t// Permission methods\n\taddPermission(permission: Permission): DefinitionBuilder {\n\t\tthis.definition.permissions?.push(permission);\n\t\treturn this;\n\t}\n\n\t// Export methods\n\taddExport(exprt: Export): DefinitionBuilder {\n\t\tthis.definition.exports?.push(exprt);\n\t\treturn this;\n\t}\n\n\t// Table methods\n\taddTable(table: Table): DefinitionBuilder {\n\t\tthis.definition.tables?.push(table);\n\t\treturn this;\n\t}\n\n\t// Section methods\n\taddSection(section: Section): DefinitionBuilder {\n\t\tthis.definition.sections?.push(section);\n\t\treturn this;\n\t}\n\n\t// Build method with basic validation\n\tbuild(): Definition {\n\t\tthis.validateDefinition();\n\t\treturn this.definition;\n\t}\n\n\tprivate validateDefinition(): void {\n\t\t// Ensure all referenced tables in aliases exist in imports or loads\n\t\tconst definedTables = new Set([\n\t\t\t...(this.definition.imports?.map((i) => i.to) || []),\n\t\t\t...(this.definition.loads?.map((l) => l.to) || [])\n\t\t]);\n\n\t\tconst aliasedTables = Object.keys(this.definition.aliases || {});\n\t\tfor (const table of aliasedTables) {\n\t\t\tif (!definedTables.has(table)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Table \"${table}\" referenced in aliases but not defined in imports or loads`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Ensure all variables have valid names and transforms\n\t\tthis.definition.variables?.forEach((variable) => {\n\t\t\tif (!variable.name) {\n\t\t\t\tthrow new Error('Variable must have a name');\n\t\t\t}\n\t\t\tif (!Array.isArray(variable.transforms) || variable.transforms.length === 0) {\n\t\t\t\tthrow new Error(`Variable \"${variable.name}\" must have at least one transform`);\n\t\t\t}\n\t\t});\n\t}\n}\n","import { DefinitionBuilder } from \"$models/builders/definitionBuilder\";\nimport { Inputs } from \"$models/ui-models/definitionModel\";\nimport { runDefinition } from \"../definition\";\n\nexport const getData = async (\n datasetId: string,\n options?: { limit?: number }\n) => {\n try {\n if (!datasetId) {\n throw new Error(\"Dataset ID is required\");\n }\n\n // Build the definition model with the dataset import\n const definitionModel = DefinitionBuilder.builder()\n .addDatasetImport(datasetId)\n .build();\n\n const response = await runDefinition({\n definition: definitionModel,\n inputs: definitionModel.inputs as Inputs,\n variable: datasetId,\n limit: options?.limit || 1000,\n });\n\n if (!response?.data) {\n throw new Error(\"No data returned from API\");\n }\n\n return { data: response.data };\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching data for the dataset\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","import { runSampleDefinition } from \"../definition\";\n\nexport const getSampleData = async ({\n datasetId,\n dataFilter,\n duplicateColGroups,\n datasetType,\n}: {\n datasetId: string,\n dataFilter: \"valid_data\" | \"invalid_data\" | \"all_data\",\n duplicateColGroups?: string[],\n datasetType?: string\n}) => {\n try {\n if (!datasetId) {\n throw new Error(\"Dataset ID is required\");\n }\n\n const response = await runSampleDefinition({\n datasetId,\n dataFilter,\n duplicateColGroups,\n datasetType,\n });\n\n if (!response?.data) {\n throw new Error(\"No data returned from API\");\n }\n\n return { data: response.data };\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching sample data\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","import { Worksheet } from \"$models/gen/Api\";\nimport { apiClient } from \"../client\";\n\nexport const getAllDatasets = async () => {\n try {\n\tconst response = await apiClient.post(\"/datasets/get-datasets\");\n\n\tif (!response.data) {\n\t throw { message: \"Failed to fetch datasets\", status: 500 };\n\t}\n\treturn response.data as Worksheet[];\n } catch (error: any) {\n\tconst message =\n\t error.response?.data?.message ||\n\t error.message ||\n\t \"An unexpected error occurred while fetching datasets\";\n\tconst status = error.response?.status || 500;\n\tthrow { message, status };\n }\n};\n","import { Workbook } from \"$models/gen/Api\";\nimport { apiClient } from \"../client\";\n\nexport const getPublishedWorkbookById = async ({\n type,\n id,\n}: {\n type: string;\n id: string;\n}) => {\n try {\n const response = await apiClient.post(\"/workbook/get-published-workbook-by-id\", {\n type,\n id,\n });\n\n if (!response.data) {\n throw { message: \"Failed to fetch workbook details\", status: 500 };\n }\n return response.data as Workbook;\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching workbook details\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","export enum WorkbookTypeEnum {\n WORKBOOK = \"WORKBOOK\",\n TRANSFORMATION = \"TRANSFORMATION\",\n STATEMENT = \"STATEMENT\",\n DASHBOARD = \"DASHBOARD\",\n PORTAL = \"PORTAL\",\n PROCESS = \"PROCESS\",\n COLLECTION = \"COLLECTION\",\n COST_ALLOCATION_GROUP = \"ALLOCATION_GROUP\",\n ALLOCATION_BLUEPRINT = \"ALLOCATION_BLUEPRINT\",\n FIN_CLOSE = \"FIN_CLOSE\",\n PAGE_TEMPLATE = \"PAGE_TEMPLATE\",\n}\n","import { Workbook } from \"$models/gen/Api\";\nimport { apiClient } from \"../client\";\n\nexport const getTableById = async (tableId: string) => {\n try {\n const response = await apiClient.get(\n `/input-table/get-table/${tableId}`\n );\n\n if (!response.data) {\n throw { message: \"Failed to fetch table details\", status: 500 };\n }\n return response.data as Workbook;\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching table details\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","import _ from \"lodash\";\nimport { LimitOptions, SortOptions } from \"$models/ui-models/workbookModel\";\nimport {\n generateDefinitionModel,\n getGroupByDefinition,\n getMetricSeries,\n sortConfigFromValue,\n} from \"../../utils/inputTable\";\nimport { getPublishedWorkbookById } from \"../workbook/getPublishedWorkbookById\";\nimport { WorkbookTypeEnum } from \"../../types/workbook\";\nimport { getTableById } from \"./getTableById\";\nimport { hydrateWorksheet } from \"../../utils/metric/hydrateWorksheet\";\nimport { apiClient } from \"../client\";\n\nexport const getData = async ({\n inputTableId: inputTableWorkbookId,\n inputTableViewId,\n pageParams = {},\n limitParams,\n sortParams,\n offsetParam,\n}: {\n inputTableId: string;\n inputTableViewId: string;\n pageParams?: any;\n limitParams?: LimitOptions;\n sortParams?: SortOptions;\n offsetParam?: number;\n}) => {\n try {\n if (!inputTableWorkbookId || !inputTableViewId) {\n return [];\n }\n const inputTableWorkbook = await getPublishedWorkbookById({\n id: inputTableWorkbookId,\n type: WorkbookTypeEnum.COLLECTION\n });\n const inputTableId = _.get(\n inputTableWorkbook,\n \"customFields.metadata.inputTableId\"\n );\n\n const inputTable = await getTableById(inputTableId);\n if (!inputTable) {\n throw new Error(\"Input table not found\");\n }\n\n const inputTableView = inputTableWorkbook?.sheets?.find(\n (sheet) => sheet.id === inputTableViewId\n );\n\n if (!inputTableView) {\n throw new Error(\"Input table view not found\");\n }\n\n const hydratedView = await hydrateWorksheet(inputTableView);\n\n if (!hydratedView) {\n throw new Error(\"Failed to hydrate input table view\");\n }\n\n const filters = _.get(hydratedView, \"customModel.filters\");\n const sort = _.get(hydratedView, \"customModel.sort\");\n const limit = _.get(hydratedView, \"customModel.limit\", {}) as LimitOptions;\n const metadata = _.get(hydratedView, \"customModel.metadata\");\n let { targetName, definition } = {\n targetName: \"\",\n definition: {},\n };\n if (hydratedView.type === \"PIVOT\") {\n const gridColumnState = {\n valueCols: _.get(metadata, \"valueCols\", []),\n rowGroupCols: _.get(metadata, \"rowGroupCols\", []),\n filterModel: _.get(metadata, \"filterModel\", {}),\n pivotCols: _.get(metadata, \"pivotCols\", []),\n };\n const metricSeries = getMetricSeries({\n pivotCols: _.get(metadata, \"pivotCols\", []),\n rowGroupCols: _.get(metadata, \"rowGroupCols\", []),\n valueCols: _.get(metadata, \"valueCols\", []),\n });\n\n const columnSettings = _.get(\n hydratedView,\n \"customModel.metadata.columnSettings\"\n );\n const groupByDefinition = getGroupByDefinition({\n tableId: inputTable.id,\n tableName: inputTable.name,\n groupKeys: [],\n rowGroupCols: gridColumnState.rowGroupCols,\n columnSettings,\n filterRules: filters,\n sortValue: sort,\n metricSeries,\n });\n targetName = groupByDefinition.targetName;\n definition = groupByDefinition.definition;\n } else {\n const definitionModel = generateDefinitionModel({\n tableId: inputTable.id as string,\n tableName: inputTable.name,\n filters: filters,\n sort: sortParams?.sortByOrder\n ? sortConfigFromValue(sortParams)\n : sortConfigFromValue(sort),\n });\n targetName = definitionModel.targetName;\n definition = definitionModel.definition;\n }\n\n let stringifiedDefinition = JSON.stringify(definition);\n try {\n const matches = stringifiedDefinition?.match(/{{\\s*([\\w.]+)\\s*}}/g);\n if (matches) {\n matches.forEach((match) => {\n const key = match.replace(/{{\\s*|\\s*}}/g, \"\");\n const value = _.get(pageParams, key, \"\");\n if (value) {\n stringifiedDefinition =\n stringifiedDefinition?.replace(match, value) || \"\";\n }\n });\n }\n } catch (error) {\n console.warn(\"Error evaluating input\", error);\n }\n\n const inputTableResponse = await apiClient.post(\n \"/input-table/get-table-data\",\n {\n targetName,\n definition: JSON.parse(stringifiedDefinition),\n },\n {\n params: {\n limit: limitParams?.limit || limit.limit || 1000,\n offset: offsetParam || 0,\n },\n }\n );\n const data = _.get(inputTableResponse, \"data.result\");\n\n return { data };\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching table details\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","import { InputTable, Workbook } from \"$models/gen/Api\";\nimport { apiClient } from \"../client\";\n\nexport const getInputTables = async () => {\n try {\n const response = await apiClient.get(\"/input-table/get-input-tables\");\n\n if (!response.data) {\n throw { message: \"Failed to fetch tables\", status: 500 };\n }\n return response.data as InputTable[];\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching tables\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","import { Worksheet } from \"$models/gen/Api\";\nimport { apiClient } from \"../client\";\n\nexport const getWorkbooksByType = async (type: Worksheet[\"type\"]) => {\n try {\n const response = await apiClient.post(\"/workbook/get-workbooks-by-type\", {\n type,\n });\n\n if (!response.data) {\n throw { message: \"Failed to fetch workbooks\", status: 500 };\n }\n return response.data as Worksheet[];\n } catch (error: any) {\n const message =\n error.response?.data?.message ||\n error.message ||\n \"An unexpected error occurred while fetching workbooks by type\";\n const status = error.response?.status || 500;\n throw { message, status };\n }\n};\n","const bluecopaTailwindConfig = {\n darkMode: \"class\",\n important: true,\n theme: {\n fontFamily: {\n para: [\"Bogle\"],\n display: [\"Bogle\"],\n table: [\"Bogle\"],\n },\n fontWeight: {\n normal: \"300\",\n semibold: \"500\",\n bold: \"700\",\n black: \"800\",\n },\n keyframes: {\n \"fadeIn-top-to-bottom\": {\n \"0%\": { transform: \"translateY(-3%)\", opacity: 0 },\n \"100%\": { transform: \"translateY(0)\", opacity: 1 },\n },\n },\n animation: {\n \"fadeIn-t-b\": \"fadeIn-top-to-bottom 0.8s ease-out forwards\",\n \"fadeOut-b-t\": \"fadeIn-top-to-bottom 0.8s ease-out backwards\",\n },\n extend: {\n boxShadow: {\n md: \"2px 2px 10px 0px rgba(0,0,0,0.3)\",\n lg: \"4px 4px 10px 0px rgba(0,0,0,0.3)\",\n xl: \"6px 6px 10px 0px rgba(0,0,0,0.3)\",\n DEFAULT: \"2px 2px 10px 0px rgba(0,0,0,0.3)\",\n },\n colors: {\n primary: {\n 50: \"#ebf4ff\",\n 100: \"#dbe9ff\",\n 200: \"#bed7ff\",\n 300: \"#97bbff\",\n 400: \"#6e92ff\",\n 500: \"#0071dc\",\n 600: \"#3548ff\",\n 700: \"#202ee2\",\n 800: \"#1d2bb6\",\n 900: \"#202d8f\",\n 950: \"#131953\",\n DEFAULT: \"#0071dc\",\n },\n secondary: {\n 50: \"#F9FAFB\",\n 100: \"#F3F4F6\",\n 200: \"#E5E7EB\",\n 300: \"#D1D5DB\",\n 400: \"#9CA3AF\",\n 500: \"#041e42\",\n 600: \"#4B5563\",\n 700: \"#374151\",\n 800: \"#1F2937\",\n 900: \"#111827\",\n DEFAULT: \"#041e42\",\n },\n danger: {\n 50: \"#FEF2F2\",\n 100: \"#FEE2E2\",\n 200: \"#FECACA\",\n 300: \"#FCA5A5\",\n 400: \"#F87171\",\n 500: \"#EF4444\",\n 600: \"#DC2626\",\n 700: \"#B91C1C\",\n 800: \"#991B1B\",\n 900: \"#7F1D1D\",\n DEFAULT: \"#DE1C24\",\n },\n success: {\n 50: \"#EEFFDD\",\n 100: \"#ddedce\",\n 200: \"#bcdb9d\",\n 300: \"#9ac96c\",\n 400: \"#79b73b\",\n 500: \"#89E32F\",\n 600: \"#468408\",\n 700: \"#346306\",\n 800: \"#234204\",\n 900: \"#112102\",\n DEFAULT: \"#53a10f\",\n },\n warning: {\n DEFAULT: \"#fff200\",\n 100: \"#fef3c7\",\n },\n menuBtnBg: \"#ffffff\",\n menuBtnText: \"#041e42\",\n navbarBg: \"#041e42\",\n navbarBlue: \"#041e42\",\n navbarText: \"#fff\",\n headerBg: \"#fff\",\n headerText: \"#041e42\",\n homeHeaderBg: \"#f5f5f4\",\n homeHeaderText: \"#041e42\",\n\n coralRed: \"#ef4444\",\n dartMouthGreen: \"#059669\",\n chestnut: \"#c2410c\",\n softPink: \"#fecaca\",\n darkPurple: \"#6b21a8\",\n darkPastelGreen: \"#4d7c0f\",\n sandyBrown: \"#fb923c\",\n cinnabar: \"#ef4444\",\n tyrianPurple: \"#701a75\",\n ruddyBlue: \"#0891b2\",\n viridian: \"#0f766e\",\n cobaltBlue: \"#1d4ed8\",\n dukeBlue: \"#1e3a8a\",\n jasmine: \"#fde68a\",\n },\n spacing: {\n none: \"0rem\",\n sm: \"0.3025rem\",\n md: \"0.605rem\",\n lg: \"0.9075rem\",\n xl: \"1.21rem\",\n \"2xl\": \"2.42rem\",\n \"3xl\": \"4.84rem\",\n },\n borderRadius: {\n sm: \"1.3rem\",\n md: \"1.3rem\",\n lg: \"1.3rem\",\n DEFAULT: \"1.3rem\",\n },\n fontSize: {\n \"preset-0\": [\"3.013rem\", \"4.513rem\"],\n \"preset-1\": [\"2.505rem\", \"3.763rem\"],\n \"preset-2\": [\"2.093rem\", \"3.146rem\"],\n \"preset-3\": [\"1.742rem\", \"2.626rem\"],\n \"preset-4\": [\"1.452rem\", \"2.190rem\"],\n \"preset-5\": [\"1.21rem\", \"1.815rem\"],\n \"preset-6\": [\"1.004rem\", \"1.513rem\"],\n \"preset-7\": [\"0.835rem\", \"1.258rem\"],\n \"preset-8\": [\"0.702rem\", \"1.053rem\"],\n },\n zIndex: {\n 1: \"1\",\n 2: \"2\",\n 3: \"3\",\n 4: \"4\",\n 5: \"5\",\n 6: \"6\",\n 7: \"7\",\n 8: \"8\",\n 9: \"9\",\n 10: \"10\",\n 1001: \"1001\",\n 1002: \"1002\",\n },\n },\n },\n};\n\nexport default bluecopaTailwindConfig;\n"],"names":["WorkflowStatus","ShowAsEnum","CustomCalculationShowAsEnum","col","_b","_a","_d","_c","_e","valueCol","ProjectFractionEnum","index","blockId","getData","WorkbookTypeEnum"],"mappings":";;;;;AAMA,MAAM,gBAAgB;AAAA,EAIb,cAAc;AACrB,SAAK,SAAS;AAAA,MACb,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,aAAa;AAAA,IAAA;AAAA,EAEf;AAAA,EAEA,OAAc,cAA+B;AAC5C,QAAI,CAAC,gBAAgB,UAAU;AAC9B,sBAAgB,WAAW,IAAI,gBAAA;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