File: /home/mciraet/www/wp-content/plugins/woocommerce-payments/dist/chunks/reports-balance.js.map
{"version":3,"file":"chunks/reports-balance.js?ver=78ed68389b1a9b5a6c5c","mappings":"8KAKA,MAOA,GAPgC,SAAK,EAAAA,IAAK,CACxCC,MAAO,6BACPC,QAAS,YACTC,UAAuB,SAAK,EAAAC,KAAM,CAChCC,EAAG,qJ,oFCMP,MAAMC,EAAiBC,GAA2BA,EAAMC,MAAO,EAAG,IAErDC,EACZC,GAEA,iBAAkBJ,EAAcI,EAAOC,UAAaL,EACnDI,EAAOE,WAGIC,EAAgBA,EAC5BC,cACAC,UACAC,gBACAC,eAOA,MAAMC,EAAcZ,EAAcU,EAAcL,OAC1CQ,EAAYb,EAAcU,EAAcJ,KACxCQ,GAAiBC,EAAAA,EAAAA,MAEvB,OAAOC,EAAAA,EAAAA,0BACN,CACC,CAAEC,IAAK,gBAAiBC,MAAO,iBAC/B,CACCD,IAAK,yBACLC,MAAO,0BAER,CAAED,IAAK,UAAWC,MAAO,WACzB,CAAED,IAAK,QAASC,MAAO,SACvB,CAAED,IAAK,SAAUC,MAAO,UACxB,CAAED,IAAK,QAASC,MAAO,SACvB,CAAED,IAAK,WAAYC,MAAO,YAC1B,CAAED,IAAK,eAAgBC,MAAO,gBAC9B,CAAED,IAAK,aAAcC,MAAO,eAE7BV,EAAYW,IAAOC,IAClB,MAAMC,EAAQD,EAAIE,WAAYb,GACxBc,GAAWC,EAAAA,EAAAA,IAAaJ,EAAKV,GAEnC,MAAO,CACN,CACCT,MAAOa,EAAeW,aACtBC,QAASZ,EAAeW,cAEzB,CACCxB,MAAOa,EAAea,UACtBD,QAASZ,EAAea,WAEzB,CAAE1B,MAAOmB,EAAIH,IAAKS,QAASN,EAAIH,KAC/B,CAAEhB,MAAOsB,EAAUG,QAASH,GAC5B,CAAEtB,MAAOmB,EAAIQ,UAAWnB,GAAWiB,QAAS,IAC5C,CAAEzB,MAAOoB,GAAS,GAAIK,QAAS,IAC/B,CAAEzB,MAAO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D,EAAM6F,SAAyB,CACnC,IAAM,MAAMoO,KAAUwK,EAAe,CACpC,MAAM7G,EAAQ2G,EAActK,EAAQ5J,GACpC,GACCuN,EAAO,KAAQ5X,EAAMA,MAAO,IAC5B4X,EAAO,KAAQ5X,EAAMA,MAAO,GAE5B,OAAOiU,CAET,CACA,MAAO,QACR,CAEA,IAAM,MAAMA,KAAUuK,EACrB,GAAKL,EAAyBlK,EAAQ5J,KAAUrK,EAAMA,MACrD,OAAOiU,EAGT,MAAO,S,+DC7MD,MAAMzE,EAAcA,EAC1BC,QACAC,cACA9G,OACA6K,SACApO,YACAqO,gBACAC,YACA7E,aACAC,kBACAzH,WAEAlC,EAAAA,EAAAA,MAAA,OACCC,UAAY,CACX,sBACA,mCACAA,GAECgK,OAAQ/E,SACRgF,KAAM,KACRhI,KAAOA,EACP,kBAAkBqM,EAClB,mBAAmBD,EAAe9T,SAAA,EAElC0F,EAAAA,EAAAA,KAAA,QAAMD,UAAU,4BAA4B,cAAY,OAAMzF,UAC7D0F,EAAAA,EAAAA,KAACsZ,EAAAA,KAAI,CAAChW,KAAOA,EAAO2U,KAAO,QAE5BnY,EAAAA,EAAAA,MAAA,OAAKC,UAAU,4BAA2BzF,SAAA,EACzC0F,EAAAA,EAAAA,KAAA,MACChB,GAAKqP,EACLlN,IAAMqI,EACNvH,SAAWwH,EAAiBnP,SAE1B6P,KAEHnK,EAAAA,EAAAA,KAAA,KAAGhB,GAAKoP,EAAe9T,SAAG8P,OAEzB+D,I","sources":["webpack://woocommerce-payments/./node_modules/@wordpress/icons/build-module/library/close-small.js","webpack://woocommerce-payments/./client/reports/balance/format.ts","webpack://woocommerce-payments/./client/reports/balance/balance-dataview.tsx","webpack://woocommerce-payments/./client/reports/feedback-survey/strings.tsx","webpack://woocommerce-payments/./client/reports/feedback-survey/thumbs.tsx","webpack://woocommerce-payments/./client/reports/feedback-survey/hooks.ts","webpack://woocommerce-payments/./client/reports/feedback-survey/tracks.ts","webpack://woocommerce-payments/./client/reports/feedback-survey/index.tsx","webpack://woocommerce-payments/./client/reports/balance/loading-skeleton.tsx","webpack://woocommerce-payments/./client/reports/balance/index.tsx","webpack://woocommerce-payments/./client/reports/balance/rows.ts","webpack://woocommerce-payments/./client/reports/balance/use-balance-date-filter.ts","webpack://woocommerce-payments/./client/reports/balance/utils.ts","webpack://woocommerce-payments/./client/reports/date-filter/dataviews-date-range-preset-portal.tsx","webpack://woocommerce-payments/./client/reports/date-filter/presets.ts","webpack://woocommerce-payments/./client/reports/report-state.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SVG, Path } from '@wordpress/primitives';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst closeSmall = /*#__PURE__*/_jsx(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 24 24\",\n children: /*#__PURE__*/_jsx(Path, {\n d: \"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z\"\n })\n});\nexport default closeSmall;\n//# sourceMappingURL=close-small.js.map","/** @format */\n\n/**\n * External dependencies\n */\nimport { generateCSVDataFromTable } from '@woocommerce/csv-export';\n\n/**\n * Internal dependencies\n */\nimport { formatExplicitCurrency } from 'multi-currency/interface/functions';\nimport type { ReportsPeriodRange } from 'wcpay/reports/period-selector';\nimport type { BalanceRow } from './rows';\nimport { getBalanceReportIdentity, getRowLabel } from './utils';\n\nconst formatYmdUTC = ( value: string ): string => value.slice( 0, 10 );\n\nexport const getBalanceExportFileName = (\n\tperiod: ReportsPeriodRange\n): string =>\n\t`wcpay-balance-${ formatYmdUTC( period.start ) }_${ formatYmdUTC(\n\t\tperiod.end\n\t) }.csv`;\n\nexport const getBalanceCSV = ( {\n\tvisibleRows,\n\tsummary,\n\tdisplayPeriod,\n\tcurrency,\n}: {\n\tvisibleRows: BalanceRow[];\n\tsummary: Parameters< BalanceRow[ 'getAmount' ] >[ 0 ];\n\tdisplayPeriod: ReportsPeriodRange;\n\tcurrency: string;\n} ): string => {\n\tconst periodStart = formatYmdUTC( displayPeriod.start );\n\tconst periodEnd = formatYmdUTC( displayPeriod.end );\n\tconst reportIdentity = getBalanceReportIdentity();\n\n\treturn generateCSVDataFromTable(\n\t\t[\n\t\t\t{ key: 'business_name', label: 'business_name' },\n\t\t\t{\n\t\t\t\tkey: 'woopayments_account_id',\n\t\t\t\tlabel: 'woopayments_account_id',\n\t\t\t},\n\t\t\t{ key: 'row_key', label: 'row_key' },\n\t\t\t{ key: 'label', label: 'label' },\n\t\t\t{ key: 'amount', label: 'amount' },\n\t\t\t{ key: 'count', label: 'count' },\n\t\t\t{ key: 'currency', label: 'currency' },\n\t\t\t{ key: 'period_start', label: 'period_start' },\n\t\t\t{ key: 'period_end', label: 'period_end' },\n\t\t],\n\t\tvisibleRows.map( ( row ) => {\n\t\t\tconst count = row.getCount?.( summary );\n\t\t\tconst rowLabel = getRowLabel( row, displayPeriod );\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tvalue: reportIdentity.businessName,\n\t\t\t\t\tdisplay: reportIdentity.businessName,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tvalue: reportIdentity.accountId,\n\t\t\t\t\tdisplay: reportIdentity.accountId,\n\t\t\t\t},\n\t\t\t\t{ value: row.key, display: row.key },\n\t\t\t\t{ value: rowLabel, display: rowLabel },\n\t\t\t\t{ value: row.getAmount( summary ), display: '' },\n\t\t\t\t{ value: count ?? '', display: '' },\n\t\t\t\t{ value: currency, display: currency },\n\t\t\t\t{ value: periodStart, display: periodStart },\n\t\t\t\t{ value: periodEnd, display: periodEnd },\n\t\t\t];\n\t\t} )\n\t);\n};\n\n/**\n * Formats a Balance summary amount in the \"code-first with leading sign\" style\n * used by the Balance report Figma design — e.g. `+USD 1,234.00` or `-USD 80.00`.\n *\n * The default `formatExplicitCurrency` output puts the symbol before the amount\n * and the ISO code after it (`$1,234.00 USD`). Balance rows show every amount\n * with an explicit sign and the ISO code in front, with no currency symbol, so\n * that running totals are easy to scan and reconciliation against bank\n * statements doesn't require eyeballing past a `$`.\n */\nexport const formatBalanceAmount = (\n\tamount: number,\n\tcurrencyCode: string\n): string => {\n\tconst upperCode = currencyCode.toUpperCase();\n\tconst isNegative = amount < 0;\n\tconst isZero = amount === 0;\n\tconst absoluteAmount = isNegative ? -amount : amount;\n\n\t// `skipSymbol = true` removes the leading `$` (etc.) while keeping the\n\t// currency utility's locale-aware number formatting. Depending on explicit\n\t// pricing settings, the helper may also append a trailing ISO code.\n\tconst formatted = formatExplicitCurrency( absoluteAmount, upperCode, true );\n\n\t// `formatExplicitCurrency` returns the value in one of two shapes depending\n\t// on whether explicit pricing is enabled in settings:\n\t// • \"1,234.00 USD\" — explicit pricing on (the common case)\n\t// • \"1,234.00\" — explicit pricing off\n\t// Move the ISO code to the front to match the Figma \"code-first\" pattern,\n\t// and drop any stray spaces left behind by the symbol removal.\n\tconst withoutCode = formatted\n\t\t.replace( new RegExp( `\\\\s*${ upperCode }\\\\s*$` ), '' )\n\t\t.trim();\n\n\t// Zero balances render without a sign so reconciliation reports don't pin a\n\t// misleading positive or negative direction onto an empty line.\n\tif ( isZero ) {\n\t\treturn `${ upperCode } ${ withoutCode }`;\n\t}\n\n\tconst sign = isNegative ? '-' : '+';\n\n\treturn `${ sign }${ upperCode } ${ withoutCode }`;\n};\n","/** @format */\n\n/**\n * Renders the Balance summary through DataViews using the composition API —\n * passing children makes DataViews render only the composed pieces (the\n * funnel FiltersToggle, the native date filter chips and the rows Layout)\n * and omit the Search box, View-options gear, Pagination and Footer.\n * Field renders carry className-driven styling so depth colors live in SCSS\n * (overridable in forced-colors mode); a scoped block in style.scss also\n * neutralises the DataViews table chrome (header row, cell padding) so the\n * summary matches the bespoke design it replaced.\n *\n * External dependencies\n */\nimport React, {\n\tuseCallback,\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { DataViews } from '@wordpress/dataviews/wp';\nimport type { View, Field } from '@wordpress/dataviews/wp';\n\n/**\n * Internal dependencies\n */\nimport { BalanceRow, getDisplayedAmount, getRowDepth } from './rows';\nimport { formatBalanceAmount } from './format';\nimport { getRowLabel } from './utils';\nimport type { ReportsBalanceSummary } from 'wcpay/data/reports/hooks';\nimport type { ReportsPeriodRange } from 'wcpay/reports/period-selector';\nimport type { DateFilterValue } from 'wcpay/reports/date-filter';\nimport { DataViewsDateRangePresetPortal } from 'wcpay/reports/date-filter/dataviews-date-range-preset-portal';\n\n// Date-filter operators for the Balance report. `between` leads so a newly\n// added (or re-added) filter defaults to it — DataViews uses operators[0] —\n// surfacing the range presets instead of the confusing single-date\n// \"Past week / Past month\" anchors a `before` default produced (WOOPMNT-6243).\n// Exported so the ordering is guarded by a unit test.\nexport const balanceDateFilterOperators: Array<\n\t'between' | 'before' | 'after' | 'on'\n> = [ 'between', 'before', 'after', 'on' ];\n\n// DataViews keeps the chips row collapsed until the funnel is toggled —\n// `isShowingFilter` starts false for non-primary filters and isn't part of the\n// public API. We open it once by clicking the funnel button so the active Date\n// chip shows by default. The selector is scoped to the funnel-in-toggle-mode\n// form (an active filter exists); the \"Add filter\" menu trigger carries\n// aria-haspopup and is intentionally skipped so a filterless mount never pops\n// the menu.\n//\n// This is a deliberate, product-required divergence from the Fees report —\n// do not reconcile the two: Balance keeps its date filter open by default\n// (it's the report's only control and always has an applied range), while\n// Fees ships with no filters applied and accepts DataViews' collapsed\n// default (chip hidden behind the funnel badge until clicked). The\n// canonical-rows test pins the open-by-default behaviour.\n// TODO: Replace with a public DataViews API (e.g. a `defaultFiltersOpen` prop\n// or an `isShowingFilter` setter) once one ships upstream.\nconst openFiltersRowWorkaround = ( root: HTMLElement | null ): void => {\n\troot?.querySelector< HTMLButtonElement >(\n\t\t'.dataviews-filters__visibility-toggle[aria-pressed=\"false\"]:not([aria-haspopup])'\n\t)?.click();\n};\n\ninterface BalanceItem {\n\tid: string;\n\tlabel: string;\n\tdepth: number;\n\tcount?: number;\n\tamount: number;\n}\n\ninterface BalanceDataViewProps {\n\tvisibleRows: BalanceRow[];\n\tsummary: ReportsBalanceSummary;\n\tdisplayPeriod: ReportsPeriodRange;\n\tcurrency: string;\n\tdateValue: DateFilterValue | undefined;\n\tonDateChange: (\n\t\tnext: DateFilterValue | undefined,\n\t\treferenceDate?: Date\n\t) => void;\n\tfocusTargetRef?: React.RefObject< HTMLDivElement >;\n\tdateFilterNow?: Date;\n\t// Render as a non-interactive preview (the loading skeleton): hide the\n\t// native date Filters and mark the whole view aria-hidden so the blurred\n\t// placeholder is skipped by assistive tech and keyboard navigation.\n\tpreview?: boolean;\n\t// When provided, render this below the date Filters instead of the rows\n\t// card. Keeps the date filter UI (funnel toggle + active chip) mounted\n\t// across the loading / error / empty report states, so a cleared filter\n\t// can always be re-applied.\n\tchildren?: React.ReactNode;\n}\n\nconst buildItems = (\n\tvisibleRows: BalanceRow[],\n\tsummary: ReportsBalanceSummary,\n\tdisplayPeriod: ReportsPeriodRange\n): BalanceItem[] =>\n\tvisibleRows.map( ( row ) => ( {\n\t\tid: row.key,\n\t\tlabel: getRowLabel( row, displayPeriod ),\n\t\tdepth: getRowDepth( row ),\n\t\tcount: row.getCount?.( summary ),\n\t\tamount: getDisplayedAmount( row, row.getAmount( summary ) ),\n\t} ) );\n\nexport const BalanceDataView = ( {\n\tvisibleRows,\n\tsummary,\n\tdisplayPeriod,\n\tcurrency,\n\tdateValue,\n\tonDateChange,\n\tfocusTargetRef,\n\tdateFilterNow,\n\tpreview = false,\n\tchildren,\n}: BalanceDataViewProps ): JSX.Element => {\n\t// A filter entry the user is still editing (added via the funnel menu, or\n\t// an operator switch that reset the value). The chip must stay rendered —\n\t// with its date input — even though there's no applied value yet, and the\n\t// controlled `view` below is otherwise derived solely from `dateValue`.\n\t// Unlike Fees (which stages this in useFeesView next to its URL sync),\n\t// Balance has no view-state URL sync, so component state is the right\n\t// home for it.\n\tconst [ pendingDateOperator, setPendingDateOperator ] = useState<\n\t\tstring | null\n\t>( null );\n\tconst rootRef = useRef< HTMLDivElement >( null );\n\t// DataViews offers no way to name the <table> itself, so the card is a\n\t// labelled group: assistive tech announces \"Balance summary\" on entry,\n\t// standing in for the bespoke table's <caption>.\n\tconst captionId = useId();\n\tconst stableDateFilterNow = useRef( dateFilterNow ?? new Date() ).current;\n\t// Gate the funnel-click workaround to a single run per mount so React\n\t// 18 StrictMode's double-invoke in development doesn't fire it twice.\n\tconst filtersRowOpenedRef = useRef( false );\n\tconst onDatePresetChange = useCallback(\n\t\t( nextValue: DateFilterValue, referenceDate?: Date ) => {\n\t\t\tsetPendingDateOperator( null );\n\t\t\tonDateChange( nextValue, referenceDate );\n\t\t},\n\t\t[ onDateChange ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( preview || filtersRowOpenedRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\topenFiltersRowWorkaround( rootRef.current );\n\t\tfiltersRowOpenedRef.current = true;\n\t}, [ preview ] );\n\n\tconst items = useMemo(\n\t\t() => buildItems( visibleRows, summary, displayPeriod ),\n\t\t[ visibleRows, summary, displayPeriod ]\n\t);\n\n\tconst fields = useMemo< Field< BalanceItem >[] >(\n\t\t() =>\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tid: 'date',\n\t\t\t\t\tlabel: __( 'Date', 'woocommerce-payments' ),\n\t\t\t\t\ttype: 'date',\n\t\t\t\t\tenableHiding: false,\n\t\t\t\t\tenableSorting: false,\n\t\t\t\t\tfilterBy: {\n\t\t\t\t\t\t// Deliberately not primary: a cleared filter removes\n\t\t\t\t\t\t// the chip and leaves only the funnel toggle, which\n\t\t\t\t\t\t// re-adds it (primary filters also hard-disable the\n\t\t\t\t\t\t// funnel in DataViews).\n\t\t\t\t\t\toperators: balanceDateFilterOperators,\n\t\t\t\t\t},\n\t\t\t\t\tgetValue: () => displayPeriod.start,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: 'label',\n\t\t\t\t\tlabel: __( 'Balance row', 'woocommerce-payments' ),\n\t\t\t\t\t// With sorting, hiding and moving all disabled, DataViews\n\t\t\t\t\t// renders the column header as plain text instead of a\n\t\t\t\t\t// menu button — required for the visually-hidden <thead>\n\t\t\t\t\t// to stay free of focusable elements.\n\t\t\t\t\tenableHiding: false,\n\t\t\t\t\tenableSorting: false,\n\t\t\t\t\tgetValue: ( { item }: { item: BalanceItem } ) => item.label,\n\t\t\t\t\trender: ( { item }: { item: BalanceItem } ) => (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName={ `wcpay-reports-balance-dv__label wcpay-reports-balance-dv__label--depth-${ item.depth }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>{ item.label }</span>\n\t\t\t\t\t\t\t{ typeof item.count === 'number' && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ /* The badge is decorative; screen readers\n\t\t\t\t\t\t\t\t\t get the unambiguous \"N items\" text instead. */ }\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"wcpay-reports-balance-dv__count\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ item.count }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t<span className=\"screen-reader-text\">\n\t\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %d: number of ledger entries included in this Balance row. */\n\t\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t\t'%d item',\n\t\t\t\t\t\t\t\t\t\t\t\t'%d items',\n\t\t\t\t\t\t\t\t\t\t\t\titem.count,\n\t\t\t\t\t\t\t\t\t\t\t\t'woocommerce-payments'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\titem.count\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: 'amount',\n\t\t\t\t\tlabel: __( 'Amount', 'woocommerce-payments' ),\n\t\t\t\t\tenableHiding: false,\n\t\t\t\t\tenableSorting: false,\n\t\t\t\t\tgetValue: ( { item }: { item: BalanceItem } ) =>\n\t\t\t\t\t\titem.amount,\n\t\t\t\t\trender: ( { item }: { item: BalanceItem } ) => (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName={ `wcpay-reports-balance-dv__amount wcpay-reports-balance-dv__amount--depth-${ item.depth }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ formatBalanceAmount( item.amount, currency ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] as Field< BalanceItem >[],\n\t\t[ currency, displayPeriod.start ]\n\t);\n\n\tconst view = useMemo< View >( () => {\n\t\t// A pending (valueless) entry wins so the chip reflects the edit in\n\t\t// progress; the previously applied value keeps driving the data below\n\t\t// until a new date is actually picked.\n\t\tlet filters: View[ 'filters' ] = [];\n\t\tif ( pendingDateOperator ) {\n\t\t\tfilters = [\n\t\t\t\t{\n\t\t\t\t\tfield: 'date',\n\t\t\t\t\toperator:\n\t\t\t\t\t\tpendingDateOperator as DateFilterValue[ 'operator' ],\n\t\t\t\t\tvalue: undefined,\n\t\t\t\t},\n\t\t\t];\n\t\t} else if ( dateValue ) {\n\t\t\tfilters = [\n\t\t\t\t{\n\t\t\t\t\tfield: 'date',\n\t\t\t\t\toperator: dateValue.operator,\n\t\t\t\t\tvalue: dateValue.value,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn {\n\t\t\ttype: 'table',\n\t\t\tsearch: '',\n\t\t\tpage: 1,\n\t\t\tperPage: 100,\n\t\t\tfields: [ 'label', 'amount' ],\n\t\t\tfilters,\n\t\t\t// Column moving is part of the header menus — disabling it (with\n\t\t\t// sorting/hiding off on the fields) keeps the visually-hidden\n\t\t\t// column headers as plain, non-focusable text.\n\t\t\tlayout: { enableMoving: false },\n\t\t};\n\t}, [ dateValue, pendingDateOperator ] );\n\n\t// `items`, `fields` and `view` are memoized above; memoizing the handler\n\t// too keeps the DataViews prop set referentially stable between renders.\n\tconst onChangeView = useCallback(\n\t\t( next: View ) => {\n\t\t\tconst dateFilter = next.filters?.find(\n\t\t\t\t( f ) => f.field === 'date'\n\t\t\t);\n\t\t\tif ( dateFilter && dateFilter.value !== undefined ) {\n\t\t\t\tsetPendingDateOperator( null );\n\t\t\t\tonDateChange( {\n\t\t\t\t\toperator: dateFilter.operator,\n\t\t\t\t\tvalue: dateFilter.value,\n\t\t\t\t} as DateFilterValue );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( dateFilter ) {\n\t\t\t\t// Filter added from the funnel menu, or an operator switch\n\t\t\t\t// reset the value — keep the chip mounted while the user\n\t\t\t\t// picks a date.\n\t\t\t\tsetPendingDateOperator( dateFilter.operator );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetPendingDateOperator( null );\n\t\t\tif ( dateValue ) {\n\t\t\t\tonDateChange( undefined );\n\t\t\t}\n\t\t},\n\t\t[ dateValue, onDateChange ]\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wcpay-reports-balance-dv\"\n\t\t\tref={ rootRef }\n\t\t\taria-hidden={ preview || undefined }\n\t\t>\n\t\t\t{ ! preview && (\n\t\t\t\t<DataViewsDateRangePresetPortal\n\t\t\t\t\trootRef={ rootRef }\n\t\t\t\t\tdateValue={ dateValue }\n\t\t\t\t\tdateFilterNow={ stableDateFilterNow }\n\t\t\t\t\tonDateChange={ onDatePresetChange }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<DataViews\n\t\t\t\tdata={ items }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tfields={ fields }\n\t\t\t\tpaginationInfo={ { totalItems: items.length, totalPages: 1 } }\n\t\t\t\tdefaultLayouts={ { table: {} } }\n\t\t\t\tgetItemId={ ( item: BalanceItem ) => item.id }\n\t\t\t>\n\t\t\t\t{ /* Compose only the native date filter + the rows — no\n\t\t\t\t Search, View-options gear, Pagination or Footer. The preview\n\t\t\t\t (loading skeleton) omits the interactive filter entirely.\n\t\t\t\t The funnel toggle is always mounted, positioned next to the\n\t\t\t\t report tabs (see style.scss): with an active filter it shows\n\t\t\t\t a count badge and toggles the chips row; with none, its menu\n\t\t\t\t re-adds the Date filter. */ }\n\t\t\t\t{ ! preview && (\n\t\t\t\t\t<div className=\"wcpay-reports-balance-dv__actions\">\n\t\t\t\t\t\t<DataViews.FiltersToggle />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t{ ! preview && <DataViews.FiltersToggled /> }\n\t\t\t\t{ children ?? (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"wcpay-reports-balance-dv__card\"\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\taria-labelledby={ captionId }\n\t\t\t\t\t\tref={ focusTargetRef }\n\t\t\t\t\t\ttabIndex={ focusTargetRef ? -1 : undefined }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"wcpay-reports-balance-dv__caption\"\n\t\t\t\t\t\t\tid={ captionId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Balance summary', 'woocommerce-payments' ) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<DataViews.Layout />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</DataViews>\n\t\t</div>\n\t);\n};\n\nexport default BalanceDataView;\n","/**\n * External dependencies\n */\nimport React from 'react';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nexport const feedbackQuestion = __(\n\t'Did this report give you the information you needed?',\n\t'woocommerce-payments'\n);\n\nexport const thumbsUpLabel = __(\n\t'What did you use this report for? (optional)',\n\t'woocommerce-payments'\n);\n\nexport const thumbsDownLabel = __(\n\t\"What's missing? (optional)\",\n\t'woocommerce-payments'\n);\n\nexport const thumbsUpAriaLabel = __(\n\t'This report was helpful',\n\t'woocommerce-payments'\n);\n\nexport const thumbsDownAriaLabel = __(\n\t'This report was not helpful',\n\t'woocommerce-payments'\n);\n\nexport const reportFeedbackRatingAriaLabel = __(\n\t'Report feedback rating',\n\t'woocommerce-payments'\n);\n\nexport const closeAriaLabel = __(\n\t'Dismiss feedback survey',\n\t'woocommerce-payments'\n);\nexport const cancelLabel = __( 'Cancel', 'woocommerce-payments' );\nexport const sendLabel = __( 'Send', 'woocommerce-payments' );\nexport const submitErrorMessage = __(\n\t'Your feedback could not be sent. Please try again.',\n\t'woocommerce-payments'\n);\nexport const submitSuccessMessage = __(\n\t'Thanks for your feedback!',\n\t'woocommerce-payments'\n);\n\nexport const privacyDisclaimer = createInterpolateElement(\n\t__(\n\t\t'Your feedback will only be shared with WooCommerce and treated pursuant to our <a>privacy policy</a>.',\n\t\t'woocommerce-payments'\n\t),\n\t{\n\t\ta: (\n\t\t\t// eslint-disable-next-line jsx-a11y/anchor-has-content\n\t\t\t<a\n\t\t\t\thref=\"https://automattic.com/privacy/\"\n\t\t\t\ttarget=\"_blank\"\n\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t/>\n\t\t),\n\t}\n);\n","/**\n * External dependencies\n */\nimport React from 'react';\nimport { Button } from '@wordpress/components';\nimport clsx from 'clsx';\n\n/**\n * Internal dependencies\n */\nimport type { ReportFeedbackRating } from './tracks';\nimport {\n\treportFeedbackRatingAriaLabel,\n\tthumbsDownAriaLabel,\n\tthumbsUpAriaLabel,\n} from './strings';\n\ninterface ThumbsControlProps {\n\tcontrolsId?: string;\n\tdisabled?: boolean;\n\tisExpanded?: boolean;\n\tonSelect: ( rating: ReportFeedbackRating ) => void;\n\tselectedRating: ReportFeedbackRating | null;\n}\n\nconst options: Array< {\n\tariaLabel: string;\n\ticon: string;\n\trating: ReportFeedbackRating;\n} > = [\n\t{\n\t\tariaLabel: thumbsUpAriaLabel,\n\t\ticon: '👍',\n\t\trating: 'thumbs-up',\n\t},\n\t{\n\t\tariaLabel: thumbsDownAriaLabel,\n\t\ticon: '👎',\n\t\trating: 'thumbs-down',\n\t},\n];\n\nexport const ThumbsControl = ( {\n\tcontrolsId,\n\tdisabled = false,\n\tisExpanded = false,\n\tonSelect,\n\tselectedRating,\n}: ThumbsControlProps ) => {\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wcpay-reports-feedback-survey__thumbs\"\n\t\t\trole=\"group\"\n\t\t\taria-label={ reportFeedbackRatingAriaLabel }\n\t\t>\n\t\t\t{ options.map( ( { ariaLabel, icon, rating } ) => {\n\t\t\t\tconst isSelected = rating === selectedRating;\n\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ rating }\n\t\t\t\t\t\taria-controls={ controlsId }\n\t\t\t\t\t\taria-expanded={ isExpanded }\n\t\t\t\t\t\taria-label={ ariaLabel }\n\t\t\t\t\t\taria-pressed={ isSelected }\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'wcpay-reports-feedback-survey__thumb',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'wcpay-reports-feedback-survey__thumb--selected':\n\t\t\t\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tonClick={ () => onSelect( rating ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span aria-hidden=\"true\">{ icon }</span>\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n};\n","/**\n * External dependencies\n */\nimport { useCallback, useState } from 'react';\nimport apiFetch from '@wordpress/api-fetch';\nimport { useUserPreferences } from '@woocommerce/data';\n\n/**\n * Internal dependencies\n */\nimport { NAMESPACE } from 'wcpay/data/constants';\nimport type { ReportFeedbackRating } from './tracks';\n\ninterface SubmitFeedbackParams {\n\tcomments: string;\n\trating: ReportFeedbackRating;\n}\n\ninterface UserPreferences extends ReturnType< typeof useUserPreferences > {\n\twc_payments_reports_feedback_dismissed?: number;\n}\n\nexport const useSubmitReportFeedback = () => {\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\n\tconst submitFeedback = useCallback(\n\t\tasync ( { rating, comments }: SubmitFeedbackParams ) => {\n\t\t\tsetIsSubmitting( true );\n\t\t\ttry {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tpath: `${ NAMESPACE }/survey/reports-feedback`,\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tdata: { rating, comments },\n\t\t\t\t} );\n\t\t\t} finally {\n\t\t\t\tsetIsSubmitting( false );\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\treturn { isSubmitting, submitFeedback };\n};\n\nexport const useReportFeedbackState = () => {\n\tconst {\n\t\tupdateUserPreferences,\n\t\twc_payments_reports_feedback_dismissed: dismissedAt,\n\t} = useUserPreferences() as UserPreferences;\n\n\tconst dismiss = () =>\n\t\tupdateUserPreferences( {\n\t\t\twc_payments_reports_feedback_dismissed: Math.floor(\n\t\t\t\tDate.now() / 1000\n\t\t\t),\n\t\t} );\n\n\treturn {\n\t\tdismiss,\n\t\tisDismissed: Boolean( dismissedAt ),\n\t};\n};\n","/**\n * External dependencies\n */\nimport { recordEvent } from 'tracks';\n\nexport type ReportFeedbackRating = 'thumbs-up' | 'thumbs-down';\n\nconst reportFeedbackReportType = 'balance';\n\nconst getSentiment = ( rating: ReportFeedbackRating ): 'up' | 'down' =>\n\trating === 'thumbs-up' ? 'up' : 'down';\n\nexport const recordReportFeedbackView = () => {\n\trecordEvent( 'wcpay_reports_feedback_view', {\n\t\treport_type: reportFeedbackReportType,\n\t} );\n};\n\nexport const recordReportFeedbackThumbsUp = () => {\n\trecordEvent( 'wcpay_reports_feedback_thumbs_up', {\n\t\treport_type: reportFeedbackReportType,\n\t} );\n};\n\nexport const recordReportFeedbackThumbsDown = () => {\n\trecordEvent( 'wcpay_reports_feedback_thumbs_down', {\n\t\treport_type: reportFeedbackReportType,\n\t} );\n};\n\nexport const recordReportFeedbackSubmit = (\n\trating: ReportFeedbackRating,\n\thasText: boolean\n) => {\n\trecordEvent( 'wcpay_reports_feedback_submit', {\n\t\treport_type: reportFeedbackReportType,\n\t\tsentiment: getSentiment( rating ),\n\t\thas_text: hasText,\n\t} );\n};\n\nexport const recordReportFeedbackSubmitError = (\n\trating: ReportFeedbackRating,\n\thasText: boolean\n) => {\n\trecordEvent( 'wcpay_reports_feedback_submit_error', {\n\t\treport_type: reportFeedbackReportType,\n\t\tsentiment: getSentiment( rating ),\n\t\thas_text: hasText,\n\t} );\n};\n\nexport const recordReportFeedbackCancel = () => {\n\trecordEvent( 'wcpay_reports_feedback_cancel', {\n\t\treport_type: reportFeedbackReportType,\n\t} );\n};\n\nexport const recordReportFeedbackDismiss = () => {\n\trecordEvent( 'wcpay_reports_feedback_dismiss', {\n\t\treport_type: reportFeedbackReportType,\n\t} );\n};\n","/**\n * External dependencies\n */\nimport React, { useEffect, useId, useRef, useState } from 'react';\nimport { Button, Notice, TextareaControl } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport './style.scss';\nimport { ThumbsControl } from './thumbs';\nimport { useReportFeedbackState, useSubmitReportFeedback } from './hooks';\nimport {\n\tcancelLabel,\n\tcloseAriaLabel,\n\tfeedbackQuestion,\n\tprivacyDisclaimer,\n\tsendLabel,\n\tsubmitErrorMessage,\n\tsubmitSuccessMessage,\n\tthumbsDownLabel,\n\tthumbsUpLabel,\n} from './strings';\nimport {\n\trecordReportFeedbackCancel,\n\trecordReportFeedbackDismiss,\n\trecordReportFeedbackSubmit,\n\trecordReportFeedbackSubmitError,\n\trecordReportFeedbackThumbsDown,\n\trecordReportFeedbackThumbsUp,\n\trecordReportFeedbackView,\n\ttype ReportFeedbackRating,\n} from './tracks';\n\nconst isReportsAreaEnabled = () =>\n\ttypeof wcpaySettings !== 'undefined' &&\n\tBoolean( wcpaySettings?.featureFlags?.reportsArea );\n\ninterface ReportFeedbackSurveyProps {\n\tfocusAfterCloseRef?: React.RefObject< HTMLElement >;\n}\n\nconst ReportFeedbackSurveyContent = ( {\n\tfocusAfterCloseRef,\n}: ReportFeedbackSurveyProps ) => {\n\tconst { dismiss, isDismissed } = useReportFeedbackState();\n\tconst { isSubmitting, submitFeedback } = useSubmitReportFeedback();\n\tconst { createSuccessNotice } = useDispatch( 'core/notices' );\n\tconst expandedRegionId = useId();\n\tconst containerRef = useRef< HTMLDivElement >( null );\n\tconst expandedRegionRef = useRef< HTMLDivElement >( null );\n\tconst hasFocusedExpandedForm = useRef( false );\n\tconst [ rating, setRating ] = useState< ReportFeedbackRating | null >(\n\t\tnull\n\t);\n\tconst [ comments, setComments ] = useState( '' );\n\tconst [ isHidden, setIsHidden ] = useState( false );\n\tconst [ hasSubmitError, setHasSubmitError ] = useState( false );\n\tconst hasRecordedView = useRef( false );\n\n\tconst isVisible = ! isHidden && ! isDismissed;\n\tconst isExpanded = rating !== null;\n\n\tuseEffect( () => {\n\t\tif ( ! isVisible || hasRecordedView.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\trecordReportFeedbackView();\n\t\thasRecordedView.current = true;\n\t}, [ isVisible ] );\n\n\tuseEffect( () => {\n\t\tif ( ! isExpanded ) {\n\t\t\thasFocusedExpandedForm.current = false;\n\t\t\treturn;\n\t\t}\n\t\tif ( hasFocusedExpandedForm.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\texpandedRegionRef.current\n\t\t\t?.querySelector< HTMLTextAreaElement >( 'textarea' )\n\t\t\t?.focus();\n\t\thasFocusedExpandedForm.current = true;\n\t}, [ isExpanded ] );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\tconst focusAfterClose = () => {\n\t\tconst activeElement = containerRef.current?.ownerDocument.activeElement;\n\n\t\tif (\n\t\t\t! activeElement ||\n\t\t\t! containerRef.current?.contains( activeElement )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tfocusAfterCloseRef?.current?.focus( { preventScroll: true } );\n\t};\n\n\tconst persistDismissal = () => {\n\t\ttry {\n\t\t\tvoid Promise.resolve( dismiss() ).catch( () => undefined );\n\t\t} catch {\n\t\t\t// Survey submission/dismissal succeeded locally; a preference write failure should not reopen it.\n\t\t}\n\t};\n\n\tconst hideSurvey = () => {\n\t\tfocusAfterClose();\n\t\tsetIsHidden( true );\n\t};\n\n\tconst handleRatingSelect = ( selectedRating: ReportFeedbackRating ) => {\n\t\tsetRating( selectedRating );\n\t\tsetHasSubmitError( false );\n\n\t\tif ( selectedRating === 'thumbs-up' ) {\n\t\t\trecordReportFeedbackThumbsUp();\n\t\t} else {\n\t\t\trecordReportFeedbackThumbsDown();\n\t\t}\n\t};\n\n\tconst handleCancel = () => {\n\t\trecordReportFeedbackCancel();\n\t\tsetRating( null );\n\t\tsetComments( '' );\n\t\tsetHasSubmitError( false );\n\t};\n\n\tconst handleDismiss = () => {\n\t\trecordReportFeedbackDismiss();\n\t\tpersistDismissal();\n\t\thideSurvey();\n\t};\n\n\tconst handleSubmit = async () => {\n\t\tif ( ! rating ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetHasSubmitError( false );\n\t\tconst trimmedComments = comments.trim();\n\t\tconst hasText = trimmedComments.length > 0;\n\t\trecordReportFeedbackSubmit( rating, hasText );\n\n\t\ttry {\n\t\t\tawait submitFeedback( { rating, comments: trimmedComments } );\n\t\t} catch {\n\t\t\trecordReportFeedbackSubmitError( rating, hasText );\n\t\t\tsetHasSubmitError( true );\n\t\t\treturn;\n\t\t}\n\n\t\tpersistDismissal();\n\t\tcreateSuccessNotice( submitSuccessMessage, {\n\t\t\tid: 'wcpay-reports-feedback-submitted',\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t\thideSurvey();\n\t};\n\n\treturn (\n\t\t<div className=\"wcpay-reports-feedback-survey\" ref={ containerRef }>\n\t\t\t<div className=\"wcpay-reports-feedback-survey__header\">\n\t\t\t\t<div className=\"wcpay-reports-feedback-survey__header-content\">\n\t\t\t\t\t<p className=\"wcpay-reports-feedback-survey__question\">\n\t\t\t\t\t\t{ feedbackQuestion }\n\t\t\t\t\t</p>\n\t\t\t\t\t<ThumbsControl\n\t\t\t\t\t\tcontrolsId={ expandedRegionId }\n\t\t\t\t\t\tdisabled={ isSubmitting }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tonSelect={ handleRatingSelect }\n\t\t\t\t\t\tselectedRating={ rating }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"wcpay-reports-feedback-survey__close\"\n\t\t\t\t\tdisabled={ isSubmitting }\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ closeAriaLabel }\n\t\t\t\t\tonClick={ handleDismiss }\n\t\t\t\t/>\n\t\t\t</div>\n\n\t\t\t{ isExpanded && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"wcpay-reports-feedback-survey__divider\"\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t/>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"wcpay-reports-feedback-survey__body\"\n\t\t\t\t\t\tid={ expandedRegionId }\n\t\t\t\t\t\tref={ expandedRegionRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\trating === 'thumbs-up'\n\t\t\t\t\t\t\t\t\t? thumbsUpLabel\n\t\t\t\t\t\t\t\t\t: thumbsDownLabel\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChange={ setComments }\n\t\t\t\t\t\t\treadOnly={ isSubmitting }\n\t\t\t\t\t\t\tvalue={ comments }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<p className=\"wcpay-reports-feedback-survey__disclaimer\">\n\t\t\t\t\t\t\t{ privacyDisclaimer }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{ hasSubmitError && (\n\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\tclassName=\"wcpay-reports-feedback-survey__error\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ submitErrorMessage }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"wcpay-reports-feedback-survey__footer\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdisabled={ isSubmitting }\n\t\t\t\t\t\t\tonClick={ handleCancel }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ cancelLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdisabled={ isSubmitting }\n\t\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sendLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\nconst ReportFeedbackSurvey = ( props: ReportFeedbackSurveyProps ) => {\n\tif ( ! isReportsAreaEnabled() ) {\n\t\treturn null;\n\t}\n\n\treturn <ReportFeedbackSurveyContent { ...props } />;\n};\n\nexport default ReportFeedbackSurvey;\n","/** @format */\n\n/**\n * External dependencies\n */\nimport React, { RefObject } from 'react';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { BalanceDataView } from './balance-dataview';\nimport { getVisibleBalanceRows } from './rows';\nimport type { ReportsBalanceSummary } from 'wcpay/data/reports/hooks';\n\ninterface BalanceLoadingSkeletonProps {\n\theadingRef?: RefObject< HTMLHeadingElement >;\n\theadingTabIndex?: number;\n}\n\n// Static mock summary used only to render plausible amounts behind the blur.\n// Values are illustrative: no PII, no real merchant data.\nconst mockSummaryFixture: ReportsBalanceSummary = {\n\tcurrency: 'usd',\n\tperiod: {\n\t\tstart: '2024-03-01T00:00:00',\n\t\tend: '2024-03-31T23:59:59',\n\t},\n\tstarting_balance: { amount: 120000 },\n\ttotal_charges_captured: { amount: 845000, count: 42 },\n\tfees: { amount: -28400 },\n\tcharge_fees: { amount: -25400 },\n\tdispute_fees: { amount: -3000 },\n\trefunds: { amount: -14500, count: 4 },\n\tdisputes: { amount: -7500, count: 1 },\n\tnet_balance_change_in_the_period: { amount: 794600 },\n\tpayouts: { amount: 800000, count: 2 },\n\tending_balance: { amount: 114600 },\n};\n\nexport const BalanceLoadingSkeleton = ( {\n\theadingRef,\n\theadingTabIndex,\n}: BalanceLoadingSkeletonProps ): JSX.Element => {\n\tconst currency =\n\t\twcpaySettings?.accountDefaultCurrency ||\n\t\tmockSummaryFixture.currency ||\n\t\t'usd';\n\tconst mockSummary: ReportsBalanceSummary = {\n\t\t...mockSummaryFixture,\n\t\tcurrency,\n\t};\n\tconst visibleRows = getVisibleBalanceRows( mockSummary );\n\n\treturn (\n\t\t<div className=\"wcpay-reports-balance__skeleton\">\n\t\t\t<BalanceDataView\n\t\t\t\tvisibleRows={ visibleRows }\n\t\t\t\tsummary={ mockSummary }\n\t\t\t\tdisplayPeriod={ {\n\t\t\t\t\tstart: mockSummary.period?.start ?? '',\n\t\t\t\t\tend: mockSummary.period?.end ?? '',\n\t\t\t\t} }\n\t\t\t\tcurrency={ currency }\n\t\t\t\tdateValue={ undefined }\n\t\t\t\tonDateChange={ () => undefined }\n\t\t\t\tpreview\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tclassName=\"wcpay-reports-balance__skeleton-shimmer\"\n\t\t\t\taria-hidden=\"true\"\n\t\t\t/>\n\t\t\t<div\n\t\t\t\trole=\"status\"\n\t\t\t\tclassName=\"wcpay-reports-balance__skeleton-status\"\n\t\t\t>\n\t\t\t\t<h2 ref={ headingRef } tabIndex={ headingTabIndex }>\n\t\t\t\t\t{ __( 'Loading balance report', 'woocommerce-payments' ) }\n\t\t\t\t</h2>\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n","/** @format */\n\n/**\n * External dependencies\n */\nimport React, { useContext, useEffect, useId, useRef } from 'react';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { calendar } from '@wordpress/icons';\nimport { recordEvent } from 'tracks';\n\n/**\n * Internal dependencies\n */\nimport { useReportsBalanceSummary } from 'wcpay/data/reports';\nimport type { DateFilterValue } from 'wcpay/reports/date-filter';\nimport { matchPreset } from 'wcpay/reports/date-filter/presets';\nimport { ReportState } from '../report-state';\nimport type { ReportsPeriodRange } from 'wcpay/reports/period-selector';\nimport {\n\tBalanceRow,\n\tgetDisplayedAmount,\n\tgetRowDepth,\n\tgetVisibleBalanceRows,\n} from './rows';\nimport {\n\tgetPeriodForDateFilter,\n\tuseBalanceDateFilter,\n} from './use-balance-date-filter';\nimport { BalanceDataView } from './balance-dataview';\nimport ReportFeedbackSurvey from '../feedback-survey';\nimport { BalanceLoadingSkeleton } from './loading-skeleton';\nimport { formatBalanceAmount } from './format';\nimport { BalanceDateFilterNowContext } from './context';\nimport {\n\tgetRangeDays,\n\tgetBalanceReportIdentity,\n\tgetRowLabel,\n\thasBalanceActivity,\n\thasKeys,\n\tisBalanceSummaryMalformed,\n\tprintContextClass,\n} from './utils';\nimport WooPaymentsLogo from 'assets/images/woopayments.svg?asset';\nimport './style.scss';\n\ninterface BalanceReportProps {\n\tonReload?: ( period: ReportsPeriodRange ) => void;\n}\n\nconst woopaymentsBusinessDetails = [\n\t__( 'WooPayments', 'woocommerce-payments' ),\n\t// Postal address lines below are deliberately not wrapped in __():\n\t// localizing a legal entity address would produce non-deliverable text on\n\t// the printed reconciliation report.\n\t'Automattic Inc.',\n\t'60 29th Street #343',\n\t'San Francisco, CA, 94110, US',\n];\n\nconst getPrintRowClassName = ( row: BalanceRow ): string | undefined => {\n\tconst depth = getRowDepth( row );\n\tconst classNames = [\n\t\tdepth === 1 && 'wcpay-reports-balance-print__row--group',\n\t\tdepth === 2 && 'wcpay-reports-balance-print__row--indent',\n\t];\n\n\tconst rowClassName = classNames.filter( Boolean ).join( ' ' );\n\n\treturn rowClassName || undefined;\n};\n\nconst BalanceEmptyState = (): JSX.Element => (\n\t<ReportState\n\t\ttitle={ __( 'No balance activity', 'woocommerce-payments' ) }\n\t\tdescription={ __(\n\t\t\t\"Your Balance summary will appear here once there's enough data to display.\",\n\t\t\t'woocommerce-payments'\n\t\t) }\n\t\ticon={ calendar }\n\t\tclassName=\"wcpay-reports-state--empty\"\n\t\trole=\"status\"\n\t/>\n);\n\nconst BalancePrintReport = ( {\n\tvisibleRows,\n\tsummary,\n\tdisplayPeriod,\n\tcurrency,\n}: {\n\tvisibleRows: BalanceRow[];\n\tsummary: Parameters< BalanceRow[ 'getAmount' ] >[ 0 ];\n\tdisplayPeriod: ReportsPeriodRange;\n\tcurrency: string;\n} ): JSX.Element => {\n\tconst reportIdentity = getBalanceReportIdentity();\n\tconst businessLines = [\n\t\treportIdentity.businessName,\n\t\treportIdentity.accountId,\n\t\t...woopaymentsBusinessDetails,\n\t].filter( ( line ): line is string => line !== '' );\n\n\treturn (\n\t\t<section className=\"wcpay-reports-balance-print\" aria-hidden=\"true\">\n\t\t\t<header className=\"wcpay-reports-balance-print__header\">\n\t\t\t\t<img\n\t\t\t\t\tclassName=\"wcpay-reports-balance-print__logo\"\n\t\t\t\t\tsrc={ WooPaymentsLogo }\n\t\t\t\t\talt={ __( 'WooPayments', 'woocommerce-payments' ) }\n\t\t\t\t/>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"wcpay-reports-balance-print__business\"\n\t\t\t\t\tdata-testid=\"balance-report-business\"\n\t\t\t\t>\n\t\t\t\t\t{ businessLines.map( ( line, index ) => (\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tkey={ `${ line }-${ index }` }\n\t\t\t\t\t\t\tdata-testid=\"balance-report-business-line\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ line }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</header>\n\t\t\t<table className=\"wcpay-reports-balance-print__table\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th scope=\"colgroup\" colSpan={ 2 }>\n\t\t\t\t\t\t\t{ __( 'Balance summary', 'woocommerce-payments' ) }\n\t\t\t\t\t\t</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>\n\t\t\t\t\t{ visibleRows.map( ( row ) => {\n\t\t\t\t\t\tconst amount = getDisplayedAmount(\n\t\t\t\t\t\t\trow,\n\t\t\t\t\t\t\trow.getAmount( summary )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<tr\n\t\t\t\t\t\t\t\tkey={ row.key }\n\t\t\t\t\t\t\t\tclassName={ getPrintRowClassName( row ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<th scope=\"row\">\n\t\t\t\t\t\t\t\t\t{ getRowLabel( row, displayPeriod ) }\n\t\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t{ formatBalanceAmount( amount, currency ) }\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<p className=\"wcpay-reports-balance-print__disclaimer\">\n\t\t\t\t{ __(\n\t\t\t\t\t'This report is provided for informational reconciliation purposes only. It is not an IRS form, tax statement, bank statement, legal document, or formal financial statement.',\n\t\t\t\t\t'woocommerce-payments'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t</section>\n\t);\n};\n\nexport const BalanceReport = ( {\n\tonReload = () => undefined,\n}: BalanceReportProps ): JSX.Element => {\n\tconst contextDateFilterNow = useContext( BalanceDateFilterNowContext );\n\tconst stableDateFilterNow = useRef(\n\t\tcontextDateFilterNow ?? new Date()\n\t).current;\n\tconst { value, period, hasDateFilterValue, setValue } =\n\t\tuseBalanceDateFilter( stableDateFilterNow );\n\tconst requestCurrency = wcpaySettings.accountDefaultCurrency || '';\n\tconst {\n\t\tsummary,\n\t\terror = {},\n\t\tisLoading,\n\t} = useReportsBalanceSummary(\n\t\thasDateFilterValue ? period : undefined,\n\t\trequestCurrency\n\t);\n\tconst hasStoreError = hasKeys( error );\n\tconst hasMalformedSummary = isBalanceSummaryMalformed( {\n\t\tsummary,\n\t\thasDateFilterValue,\n\t\tisLoading,\n\t\thasStoreError,\n\t} );\n\tconst hasError = hasStoreError || hasMalformedSummary;\n\tconst containerRef = useRef< HTMLDivElement >( null );\n\tconst loadingHeadingRef = useRef< HTMLHeadingElement >( null );\n\tconst errorHeadingRef = useRef< HTMLHeadingElement >( null );\n\tconst feedbackFocusTargetRef = useRef< HTMLDivElement >( null );\n\tconst previousLoadingRef = useRef( isLoading );\n\tconst previousErrorRef = useRef( hasError );\n\tconst activeRequestKey = hasDateFilterValue\n\t\t? `${ period.start }:${ period.end }:${ requestCurrency.toLowerCase() }`\n\t\t: null;\n\tconst loadingRequestKeyRef = useRef< string | null >(\n\t\tisLoading ? activeRequestKey : null\n\t);\n\tconst completedActiveRequest =\n\t\tpreviousLoadingRef.current &&\n\t\t! isLoading &&\n\t\t! hasError &&\n\t\tactiveRequestKey !== null &&\n\t\tloadingRequestKeyRef.current === activeRequestKey;\n\t// Marks that the user just pressed Reload, so the next error→loading\n\t// transition should restore focus to the loading heading (the Reload\n\t// button itself unmounts before the useEffect runs).\n\tconst reloadRequestedRef = useRef( false );\n\tconst speakTimerRef = useRef< ReturnType< typeof setTimeout > | null >(\n\t\tnull\n\t);\n\tconst lastSpokenRef = useRef< string | null >( null );\n\tconst errorHeadingId = useId();\n\tconst errorDescriptionId = useId();\n\tconst visibleRows = getVisibleBalanceRows( summary );\n\tconst hasActivity = hasBalanceActivity( visibleRows, summary );\n\tconst hasLoadedReportActivity =\n\t\thasDateFilterValue && ! isLoading && ! hasError && hasActivity;\n\tconst printScopeActive = hasLoadedReportActivity;\n\tconst displayPeriod = {\n\t\tstart: summary.period?.start ?? period.start,\n\t\tend: summary.period?.end ?? period.end,\n\t};\n\tconst currency = summary.currency ?? '';\n\tconst recordDateFilterChange = (\n\t\tnext: DateFilterValue,\n\t\tisInitialApply: boolean,\n\t\treferenceDate = stableDateFilterNow\n\t) => {\n\t\tconst nextPeriod = getPeriodForDateFilter( next, referenceDate );\n\t\trecordEvent( 'wcpay_reports_balance_date_filter_change', {\n\t\t\tpreset: matchPreset( next, referenceDate ),\n\t\t\trange_days: getRangeDays( nextPeriod.start, nextPeriod.end ),\n\t\t\tis_initial_apply: isInitialApply,\n\t\t} );\n\t};\n\tconst onDateFilterChange = (\n\t\tnext: DateFilterValue | undefined,\n\t\treferenceDate?: Date\n\t) => {\n\t\tif ( next ) {\n\t\t\trecordDateFilterChange( next, ! hasDateFilterValue, referenceDate );\n\t\t} else {\n\t\t\t// Clearing the native DataViews date filter is the Reset action.\n\t\t\trecordEvent( 'wcpay_reports_balance_date_filter_change', {\n\t\t\t\tpreset: 'reset',\n\t\t\t\trange_days: null,\n\t\t\t\tis_initial_apply: false,\n\t\t\t} );\n\t\t}\n\t\tsetValue( next );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( isLoading && activeRequestKey ) {\n\t\t\tloadingRequestKeyRef.current = activeRequestKey;\n\t\t} else if ( ! activeRequestKey ) {\n\t\t\tloadingRequestKeyRef.current = null;\n\t\t}\n\n\t\tif ( completedActiveRequest ) {\n\t\t\trecordEvent( 'wcpay_reports_balance_load_success', {\n\t\t\t\tcurrency,\n\t\t\t\thas_activity: hasActivity,\n\t\t\t\tvisible_row_count: visibleRows.length,\n\t\t\t\trange_days: getRangeDays(\n\t\t\t\t\tdisplayPeriod.start,\n\t\t\t\t\tdisplayPeriod.end\n\t\t\t\t),\n\t\t\t} );\n\t\t}\n\n\t\tconst reachedErrorTerminal =\n\t\t\thasError &&\n\t\t\t! isLoading &&\n\t\t\t( ! previousErrorRef.current || previousLoadingRef.current );\n\t\tif ( reachedErrorTerminal ) {\n\t\t\trecordEvent( 'wcpay_reports_balance_load_error', {\n\t\t\t\terror_type: hasStoreError ? 'store' : 'malformed',\n\t\t\t\trange_days: getRangeDays( period.start, period.end ),\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tactiveRequestKey,\n\t\tcompletedActiveRequest,\n\t\tcurrency,\n\t\tdisplayPeriod.end,\n\t\tdisplayPeriod.start,\n\t\thasActivity,\n\t\thasError,\n\t\thasStoreError,\n\t\tisLoading,\n\t\tperiod.end,\n\t\tperiod.start,\n\t\tvisibleRows.length,\n\t] );\n\n\tuseEffect( () => {\n\t\t// Focus the error heading when the failure interrupts the user inside\n\t\t// the report. `reloadRequestedRef` covers the Reload → loading → fail\n\t\t// path: the focused loading heading unmounts with the skeleton, so by\n\t\t// the time this effect runs focus has already fallen back to <body>\n\t\t// and the containment check alone would miss it.\n\t\tif (\n\t\t\thasError &&\n\t\t\t! previousErrorRef.current &&\n\t\t\t( reloadRequestedRef.current ||\n\t\t\t\t( containerRef.current?.contains(\n\t\t\t\t\tcontainerRef.current.ownerDocument.activeElement\n\t\t\t\t) ??\n\t\t\t\t\tfalse ) )\n\t\t) {\n\t\t\terrorHeadingRef.current?.focus();\n\t\t}\n\n\t\t// The Reload button is unmounted by the time this effect runs, so we\n\t\t// can't read its focus state — `reloadRequestedRef` was set during the\n\t\t// click handler instead. The cached error persists alongside\n\t\t// `isLoading=true` after invalidateResolution, but the loading\n\t\t// skeleton still renders because `isLoading` wins in the content\n\t\t// branch — so gate on `isLoading` alone here. The ref is consumed\n\t\t// at the terminal states (success below or the error branch above).\n\t\tif ( reloadRequestedRef.current && isLoading ) {\n\t\t\tloadingHeadingRef.current?.focus();\n\t\t}\n\n\t\t// Each loading cycle is its own announcement context. Resetting the\n\t\t// de-dupe ref on the loading edge keeps duplicate-suppression within\n\t\t// a single cycle while letting subsequent successful loads (date\n\t\t// filter change, Reload from error) announce again.\n\t\tif ( isLoading && ! previousLoadingRef.current ) {\n\t\t\tlastSpokenRef.current = null;\n\t\t}\n\n\t\tif ( completedActiveRequest ) {\n\t\t\treloadRequestedRef.current = false;\n\n\t\t\tconst message = __(\n\t\t\t\t'Balance report loaded.',\n\t\t\t\t'woocommerce-payments'\n\t\t\t);\n\t\t\tif ( speakTimerRef.current ) {\n\t\t\t\tclearTimeout( speakTimerRef.current );\n\t\t\t}\n\t\t\tspeakTimerRef.current = setTimeout( () => {\n\t\t\t\tspeakTimerRef.current = null;\n\t\t\t\tif ( lastSpokenRef.current === message ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlastSpokenRef.current = message;\n\t\t\t\tspeak( message );\n\t\t\t}, 500 );\n\t\t}\n\n\t\tconst reachedErrorTerminal =\n\t\t\thasError &&\n\t\t\t! isLoading &&\n\t\t\t( ! previousErrorRef.current || previousLoadingRef.current );\n\t\t// Consume the ref on the error terminal too, so a subsequent\n\t\t// non-Reload error doesn't inherit the previous click's intent.\n\t\tif ( reachedErrorTerminal ) {\n\t\t\treloadRequestedRef.current = false;\n\t\t}\n\n\t\tif ( ! activeRequestKey && ! isLoading ) {\n\t\t\treloadRequestedRef.current = false;\n\t\t}\n\n\t\tpreviousLoadingRef.current = isLoading;\n\t\tpreviousErrorRef.current = hasError;\n\t}, [ activeRequestKey, completedActiveRequest, hasError, isLoading ] );\n\n\tuseEffect( () => {\n\t\tif ( ! printScopeActive ) {\n\t\t\treturn;\n\t\t}\n\n\t\tdocument.body.classList.add( printContextClass );\n\t\tdocument.documentElement.classList.add( printContextClass );\n\n\t\treturn () => {\n\t\t\tdocument.body.classList.remove( printContextClass );\n\t\t\tdocument.documentElement.classList.remove( printContextClass );\n\t\t};\n\t}, [ printScopeActive ] );\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tif ( speakTimerRef.current ) {\n\t\t\t\tclearTimeout( speakTimerRef.current );\n\t\t\t\tspeakTimerRef.current = null;\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\t// The state content renders inside BalanceDataView, below the always\n\t// mounted native date filter — so a cleared filter leaves an empty Date\n\t// chip that can be re-applied from any state, matching the original\n\t// persistent toolbar. `undefined` means loaded: BalanceDataView renders\n\t// its own rows card.\n\tlet stateContent: JSX.Element | undefined;\n\n\tif ( ! hasDateFilterValue ) {\n\t\tstateContent = <BalanceEmptyState />;\n\t} else if ( isLoading ) {\n\t\tstateContent = (\n\t\t\t<BalanceLoadingSkeleton\n\t\t\t\theadingRef={ loadingHeadingRef }\n\t\t\t\theadingTabIndex={ -1 }\n\t\t\t/>\n\t\t);\n\t} else if ( hasError ) {\n\t\tstateContent = (\n\t\t\t<ReportState\n\t\t\t\ttitle={ __( 'Balance unavailable', 'woocommerce-payments' ) }\n\t\t\t\tdescription={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\"We couldn't load your balance data.\",\n\t\t\t\t\t\t\t\t'woocommerce-payments'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>{ ' ' }\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Try again in a few minutes.',\n\t\t\t\t\t\t\t\t'woocommerce-payments'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\taction={\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\trecordEvent( 'wcpay_reports_balance_reload_click', {\n\t\t\t\t\t\t\t\trange_days: getRangeDays(\n\t\t\t\t\t\t\t\t\tperiod.start,\n\t\t\t\t\t\t\t\t\tperiod.end\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\treloadRequestedRef.current = true;\n\t\t\t\t\t\t\tonReload( period );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reload report', 'woocommerce-payments' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t}\n\t\t\t\ticon={ calendar }\n\t\t\t\tclassName=\"wcpay-reports-state--error wcpay-reports-state--balance-error\"\n\t\t\t\tdescriptionId={ errorDescriptionId }\n\t\t\t\theadingId={ errorHeadingId }\n\t\t\t\theadingRef={ errorHeadingRef }\n\t\t\t\theadingTabIndex={ -1 }\n\t\t\t\trole=\"alert\"\n\t\t\t/>\n\t\t);\n\t} else if ( ! hasActivity ) {\n\t\tstateContent = <BalanceEmptyState />;\n\t}\n\n\treturn (\n\t\t<div className=\"wcpay-reports-balance\" ref={ containerRef }>\n\t\t\t<BalanceDataView\n\t\t\t\tvisibleRows={ visibleRows }\n\t\t\t\tsummary={ summary }\n\t\t\t\tdisplayPeriod={ displayPeriod }\n\t\t\t\tcurrency={ currency }\n\t\t\t\tdateValue={ value }\n\t\t\t\tonDateChange={ onDateFilterChange }\n\t\t\t\tfocusTargetRef={ feedbackFocusTargetRef }\n\t\t\t\tdateFilterNow={ stableDateFilterNow }\n\t\t\t>\n\t\t\t\t{ stateContent }\n\t\t\t</BalanceDataView>\n\t\t\t{ printScopeActive && (\n\t\t\t\t<BalancePrintReport\n\t\t\t\t\tvisibleRows={ visibleRows }\n\t\t\t\t\tsummary={ summary }\n\t\t\t\t\tdisplayPeriod={ displayPeriod }\n\t\t\t\t\tcurrency={ currency }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasLoadedReportActivity && (\n\t\t\t\t<ReportFeedbackSurvey\n\t\t\t\t\tfocusAfterCloseRef={ feedbackFocusTargetRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\nexport default BalanceReport;\n","/** @format */\n\n/**\n * External dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tReportsBalanceSummary,\n\tReportsBalanceSummaryRow,\n} from 'wcpay/data/reports/hooks';\n\nexport type BalanceRowKey =\n\t| 'starting_balance'\n\t| 'total_charges_captured'\n\t| 'fees'\n\t| 'charge_fees'\n\t| 'payout_fees'\n\t| 'reader_fees'\n\t| 'dispute_fees'\n\t| 'fee_refunds'\n\t| 'refunds'\n\t| 'refund_failure'\n\t| 'disputes'\n\t| 'financing_payout'\n\t| 'financing_paydown'\n\t| 'network_costs'\n\t| 'other_adjustments'\n\t| 'net_balance_change_in_the_period'\n\t| 'payouts'\n\t| 'ending_balance';\n\n/**\n * Indent depth for a Balance summary row.\n *\n * `0` — top-level anchors (Starting balance, Total charges captured, Net\n * balance change, Ending balance).\n * `1` — Fees group header and all standalone non-anchor rows (Refunds, Refund\n * failures, Disputes, Financing payout/paydown, Payout fees, Reader costs,\n * Network costs, Other adjustments, Payouts). Only `fees` actually owns\n * depth-2 children; the rest are leaves rendered at the same indent for\n * visual hierarchy.\n * `2` — sub-rows nested inside the Fees group (Charge fees, Dispute fees, Fee\n * refunds).\n */\nexport type BalanceRowDepth = 0 | 1 | 2;\n\nexport interface BalanceRow {\n\tkey: BalanceRowKey;\n\tlabel: string;\n\tdepth?: BalanceRowDepth;\n\talwaysVisible?: boolean;\n\t/**\n\t * Force the displayed amount to render with a leading minus sign even when\n\t * the raw value is positive. Used for rows that always represent an outflow\n\t * (e.g. Payouts), so the visual sign communicates direction-of-flow rather\n\t * than the storage sign of the underlying datum. Zero amounts are still\n\t * rendered without a sign. The CSV export uses the raw value.\n\t */\n\tdisplayNegative?: boolean;\n\tgetAmount: ( summary: ReportsBalanceSummary ) => number;\n\tgetCount?: ( summary: ReportsBalanceSummary ) => number | undefined;\n}\n\nexport const getRowDepth = ( row: BalanceRow ): BalanceRowDepth =>\n\trow.depth ?? 0;\n\n/**\n * Applies the row-level `displayNegative` contract to a raw amount: outflow\n * rows (e.g. Payouts) render with a leading minus even when the underlying\n * datum is stored as a positive magnitude. Zero amounts pass through unchanged\n * so reconciliation reports don't pin a misleading sign onto an empty line.\n * The CSV export uses the raw value — only the on-screen and print tables\n * apply this transform.\n */\nexport const getDisplayedAmount = (\n\trow: BalanceRow,\n\tamount: number\n): number => {\n\tif ( row.displayNegative && amount !== 0 ) {\n\t\treturn -Math.abs( amount );\n\t}\n\n\treturn amount;\n};\n\nconst getRow = (\n\tsummary: ReportsBalanceSummary,\n\tkey: BalanceRowKey\n): ReportsBalanceSummaryRow | undefined =>\n\tsummary[ key ] as ReportsBalanceSummaryRow | undefined;\n\nconst getAmount =\n\t( key: BalanceRowKey ) =>\n\t( summary: ReportsBalanceSummary ): number =>\n\t\tgetRow( summary, key )?.amount ?? 0;\n\nconst getCount =\n\t( key: BalanceRowKey ) =>\n\t( summary: ReportsBalanceSummary ): number | undefined =>\n\t\tgetRow( summary, key )?.count;\n\n// The plan and tests intentionally pin this export name as the row-contract\n// constant used by the Balance UI.\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const BALANCE_ROWS: BalanceRow[] = [\n\t{\n\t\tkey: 'starting_balance',\n\t\tlabel: __( 'Starting balance', 'woocommerce-payments' ),\n\t\talwaysVisible: true,\n\t\tgetAmount: getAmount( 'starting_balance' ),\n\t},\n\t{\n\t\tkey: 'total_charges_captured',\n\t\tlabel: __( 'Total charges captured', 'woocommerce-payments' ),\n\t\talwaysVisible: true,\n\t\tgetAmount: getAmount( 'total_charges_captured' ),\n\t\tgetCount: getCount( 'total_charges_captured' ),\n\t},\n\t{\n\t\tkey: 'fees',\n\t\tlabel: __( 'Fees', 'woocommerce-payments' ),\n\t\talwaysVisible: true,\n\t\tdepth: 1,\n\t\tgetAmount: getAmount( 'fees' ),\n\t},\n\t{\n\t\tkey: 'charge_fees',\n\t\tlabel: __( 'Charge fees', 'woocommerce-payments' ),\n\t\tdepth: 2,\n\t\tgetAmount: getAmount( 'charge_fees' ),\n\t},\n\t{\n\t\tkey: 'dispute_fees',\n\t\tlabel: __( 'Dispute fees', 'woocommerce-payments' ),\n\t\tdepth: 2,\n\t\tgetAmount: getAmount( 'dispute_fees' ),\n\t},\n\t{\n\t\tkey: 'fee_refunds',\n\t\tlabel: __( 'Fee refunds', 'woocommerce-payments' ),\n\t\tdepth: 2,\n\t\tgetAmount: getAmount( 'fee_refunds' ),\n\t},\n\t{\n\t\tkey: 'refunds',\n\t\tlabel: __( 'Refunds', 'woocommerce-payments' ),\n\t\tdepth: 1,\n\t\tgetAmount: getAmount( 'refunds' ),\n\t\tgetCount: getCount( 'refunds' ),\n\t},\n\t{\n\t\tkey: 'refund_failure',\n\t\tlabel: __( 'Refund failures', 'woocommerce-payments' ),\n\t\tdepth: 1,\n\t\tgetAmount: getAmount( 'refund_failure' ),\n\t\tgetCount: getCount( 'refund_failure' ),\n\t},\n\t{\n\t\tkey: 'disputes',\n\t\tlabel: __( 'Disputes', 'woocommerce-payments' ),\n\t\tdepth: 1,\n\t\tgetAmount: getAmount( 'disputes' ),\n\t\tgetCount: getCount( 'disputes' ),\n\t},\n\t{\n\t\tkey: 'financing_payout',\n\t\tlabel: __( 'Financing payout', 'woocommerce-payments' ),\n\t\tdepth: 1,\n\t\tgetAmount: getAmount( 'financing_payout' ),\n\t\tgetCount: getCount( 'financing_payout' ),\n\t},\n\t{\n\t\tkey: 'financing_paydown',\n\t\tlabel: __( 'Financing paydown', 'woocommerce-payments' ),\n\t\tdepth: 1,\n\t\tgetAmount: getAmount( 'financing_paydown' ),\n\t\tgetCount: getCount( 'financing_paydown' ),\n\t},\n\t{\n\t\tkey: 'payout_fees',\n\t\tlabel: __( 'Payout fees', 'woocommerce-payments' ),\n\t\tdepth: 1,\n\t\tgetAmount: getAmount( 'payout_fees' ),\n\t},\n\t{\n\t\tkey: 'reader_fees',\n\t\t// \"Reader costs\" is the intentional UI label; `reader_fees` is the upstream API key.\n\t\tlabel: __( 'Reader costs', 'woocommerce-payments' ),\n\t\tdepth: 1,\n\t\tgetAmount: getAmount( 'reader_fees' ),\n\t},\n\t{\n\t\tkey: 'network_costs',\n\t\tlabel: __( 'Network costs', 'woocommerce-payments' ),\n\t\tdepth: 1,\n\t\tgetAmount: getAmount( 'network_costs' ),\n\t\tgetCount: getCount( 'network_costs' ),\n\t},\n\t{\n\t\tkey: 'other_adjustments',\n\t\tlabel: __( 'Other adjustments', 'woocommerce-payments' ),\n\t\tdepth: 1,\n\t\tgetAmount: getAmount( 'other_adjustments' ),\n\t\tgetCount: getCount( 'other_adjustments' ),\n\t},\n\t{\n\t\tkey: 'net_balance_change_in_the_period',\n\t\tlabel: __( 'Net balance change in the period', 'woocommerce-payments' ),\n\t\talwaysVisible: true,\n\t\tgetAmount: getAmount( 'net_balance_change_in_the_period' ),\n\t},\n\t{\n\t\tkey: 'payouts',\n\t\tlabel: __( 'Payouts', 'woocommerce-payments' ),\n\t\talwaysVisible: true,\n\t\tdepth: 1,\n\t\tdisplayNegative: true,\n\t\tgetAmount: getAmount( 'payouts' ),\n\t\tgetCount: getCount( 'payouts' ),\n\t},\n\t{\n\t\tkey: 'ending_balance',\n\t\tlabel: __( 'Ending balance', 'woocommerce-payments' ),\n\t\talwaysVisible: true,\n\t\tgetAmount: getAmount( 'ending_balance' ),\n\t},\n];\n\nexport const getVisibleBalanceRows = (\n\tsummary: ReportsBalanceSummary\n): BalanceRow[] =>\n\tBALANCE_ROWS.filter(\n\t\t( row ) =>\n\t\t\trow.alwaysVisible ||\n\t\t\trow.getAmount( summary ) !== 0 ||\n\t\t\t( row.getCount?.( summary ) ?? 0 ) !== 0\n\t);\n","/** @format */\n\n/**\n * External dependencies\n */\nimport { useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { getQuery, updateQueryString } from '@woocommerce/navigation';\n\n/**\n * Internal dependencies\n */\nimport {\n\tparseDateFilterFromQuery,\n\tserializeDateFilterToQuery,\n\ttype DateFilterValue,\n} from 'wcpay/reports/date-filter';\nimport {\n\tgetLastFullCalendarMonthUTC,\n\ttype ReportsPeriodRange,\n} from 'wcpay/reports/period-selector';\nimport { BalanceDateFilterNowContext } from './context';\n\nexport { BalanceDateFilterNowContext };\n\nconst reportsPath = '/payments/reports';\nconst balanceDateFilterChangeEvent = 'wcpay-balance-date-filter-change';\n\ninterface UseBalanceDateFilterResult {\n\tvalue: DateFilterValue | undefined;\n\tperiod: ReportsPeriodRange;\n\thasDateFilterValue: boolean;\n\tsetValue: ( next: DateFilterValue | undefined ) => void;\n}\n\ninterface LocalDateFilterValue {\n\tvalue: DateFilterValue | undefined;\n}\n\nconst parseYmd = ( ymd: string ): [ number, number, number ] => {\n\tconst [ year, month, day ] = ymd.split( '-' ).map( Number );\n\treturn [ year, month, day ];\n};\n\nconst toStartOfDayUTC = ( ymd: string ): string => {\n\tconst [ year, month, day ] = parseYmd( ymd );\n\treturn new Date(\n\t\tDate.UTC( year, month - 1, day, 0, 0, 0, 0 )\n\t).toISOString();\n};\n\nconst toEndOfDayUTC = ( ymd: string ): string => {\n\tconst [ year, month, day ] = parseYmd( ymd );\n\treturn new Date(\n\t\tDate.UTC( year, month - 1, day, 23, 59, 59, 999 )\n\t).toISOString();\n};\n\nconst toYmdUTC = ( date: Date ): string =>\n\t[\n\t\tdate.getUTCFullYear(),\n\t\tString( date.getUTCMonth() + 1 ).padStart( 2, '0' ),\n\t\tString( date.getUTCDate() ).padStart( 2, '0' ),\n\t].join( '-' );\n\nconst getMonthStartYmd = ( ymd: string ): string => {\n\tconst [ year, month ] = parseYmd( ymd );\n\treturn toYmdUTC( new Date( Date.UTC( year, month - 1, 1 ) ) );\n};\n\nconst getMonthEndYmd = ( ymd: string ): string => {\n\tconst [ year, month ] = parseYmd( ymd );\n\treturn toYmdUTC( new Date( Date.UTC( year, month, 0 ) ) );\n};\n\nconst getLatestCompleteDayYmd = ( now: Date ): string =>\n\ttoYmdUTC(\n\t\tnew Date(\n\t\t\tDate.UTC(\n\t\t\t\tnow.getUTCFullYear(),\n\t\t\t\tnow.getUTCMonth(),\n\t\t\t\tnow.getUTCDate() - 1\n\t\t\t)\n\t\t)\n\t);\n\nconst minYmd = ( first: string, second: string ): string =>\n\tfirst <= second ? first : second;\n\nconst capYmdAtLatestCompleteDay = ( ymd: string, now: Date ): string =>\n\tminYmd( ymd, getLatestCompleteDayYmd( now ) );\n\nconst sortYmdRange = ( start: string, end: string ): [ string, string ] =>\n\tstart <= end ? [ start, end ] : [ end, start ];\n\nconst normalizeDateFilterValue = (\n\tvalue: DateFilterValue | undefined,\n\tnow: Date\n): DateFilterValue | undefined => {\n\tif ( ! value ) {\n\t\treturn undefined;\n\t}\n\n\tif ( value.operator === 'between' ) {\n\t\tconst [ start, end ] = sortYmdRange(\n\t\t\tcapYmdAtLatestCompleteDay( value.value[ 0 ], now ),\n\t\t\tcapYmdAtLatestCompleteDay( value.value[ 1 ], now )\n\t\t);\n\n\t\treturn {\n\t\t\toperator: 'between',\n\t\t\tvalue: [ start, end ],\n\t\t};\n\t}\n\n\tif ( value.operator === 'on' ) {\n\t\treturn {\n\t\t\toperator: 'on',\n\t\t\tvalue: capYmdAtLatestCompleteDay( value.value, now ),\n\t\t};\n\t}\n\n\tif ( value.operator === 'before' ) {\n\t\treturn {\n\t\t\toperator: 'before',\n\t\t\tvalue: capYmdAtLatestCompleteDay( value.value, now ),\n\t\t};\n\t}\n\n\treturn {\n\t\toperator: 'after',\n\t\tvalue: capYmdAtLatestCompleteDay( value.value, now ),\n\t};\n};\n\nconst getLastFullCalendarMonthDateFilter = ( now: Date ): DateFilterValue => {\n\tconst range = getLastFullCalendarMonthUTC( now );\n\n\treturn {\n\t\toperator: 'between',\n\t\tvalue: [ range.start.slice( 0, 10 ), range.end.slice( 0, 10 ) ],\n\t};\n};\n\nexport const getPeriodForDateFilter = (\n\tvalue: DateFilterValue | undefined,\n\tnow: Date = new Date()\n): ReportsPeriodRange => {\n\tconst normalizedValue = normalizeDateFilterValue( value, now );\n\tif ( ! normalizedValue ) {\n\t\treturn getLastFullCalendarMonthUTC( now );\n\t}\n\n\tif ( normalizedValue.operator === 'on' ) {\n\t\treturn {\n\t\t\tstart: toStartOfDayUTC( normalizedValue.value ),\n\t\t\tend: toEndOfDayUTC( normalizedValue.value ),\n\t\t};\n\t}\n\n\tif ( normalizedValue.operator === 'between' ) {\n\t\treturn {\n\t\t\tstart: toStartOfDayUTC( normalizedValue.value[ 0 ] ),\n\t\t\tend: toEndOfDayUTC( normalizedValue.value[ 1 ] ),\n\t\t};\n\t}\n\n\tif ( normalizedValue.operator === 'before' ) {\n\t\treturn {\n\t\t\tstart: toStartOfDayUTC( getMonthStartYmd( normalizedValue.value ) ),\n\t\t\tend: toEndOfDayUTC( normalizedValue.value ),\n\t\t};\n\t}\n\n\tconst endYmd = minYmd(\n\t\tgetMonthEndYmd( normalizedValue.value ),\n\t\tgetLatestCompleteDayYmd( now )\n\t);\n\treturn {\n\t\tstart: toStartOfDayUTC( normalizedValue.value ),\n\t\tend: toEndOfDayUTC( endYmd ),\n\t};\n};\n\nexport const useBalanceDateFilter = (\n\tnow?: Date\n): UseBalanceDateFilterResult => {\n\tconst contextNow = useContext( BalanceDateFilterNowContext );\n\tconst stableNow = useRef( now ?? contextNow ?? new Date() ).current;\n\tconst isUpdatingUrlRef = useRef( false );\n\tconst [ navTick, setNavTick ] = useState( 0 );\n\tconst [ localValue, setLocalValue ] = useState<\n\t\tLocalDateFilterValue | undefined\n\t>();\n\tconst bumpNavTick = useCallback(\n\t\t() => setNavTick( ( tick ) => tick + 1 ),\n\t\t[]\n\t);\n\tconst readUrlValue = useCallback(\n\t\t() =>\n\t\t\tnormalizeDateFilterValue(\n\t\t\t\tparseDateFilterFromQuery(\n\t\t\t\t\tgetQuery() as Record< string, unknown >\n\t\t\t\t),\n\t\t\t\tstableNow\n\t\t\t),\n\t\t[ stableNow ]\n\t);\n\tconst handleLocalDateFilterChange = useCallback(\n\t\t( event: Event ) => {\n\t\t\tsetLocalValue(\n\t\t\t\t( event as CustomEvent< LocalDateFilterValue > ).detail\n\t\t\t);\n\t\t\tbumpNavTick();\n\t\t},\n\t\t[ bumpNavTick ]\n\t);\n\tconst handleHistoryChange = useCallback( () => {\n\t\tif ( ! isUpdatingUrlRef.current ) {\n\t\t\tsetLocalValue( undefined );\n\t\t}\n\t\tbumpNavTick();\n\t}, [ bumpNavTick ] );\n\n\tuseEffect( () => {\n\t\twindow.addEventListener(\n\t\t\tbalanceDateFilterChangeEvent,\n\t\t\thandleLocalDateFilterChange\n\t\t);\n\t\twindow.addEventListener( 'popstate', handleHistoryChange );\n\t\twindow.addEventListener( 'pushstate', handleHistoryChange );\n\t\twindow.addEventListener( 'replacestate', handleHistoryChange );\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\n\t\t\t\tbalanceDateFilterChangeEvent,\n\t\t\t\thandleLocalDateFilterChange\n\t\t\t);\n\t\t\twindow.removeEventListener( 'popstate', handleHistoryChange );\n\t\t\twindow.removeEventListener( 'pushstate', handleHistoryChange );\n\t\t\twindow.removeEventListener( 'replacestate', handleHistoryChange );\n\t\t};\n\t}, [ handleHistoryChange, handleLocalDateFilterChange ] );\n\n\t// `navTick` deliberately forces this render to read the current URL again\n\t// after browser navigation or after this hook writes a new query string.\n\tvoid navTick;\n\t// Keep local writes authoritative during an open interaction. The URL parser\n\t// collapses same-day `date_between` values to `on`, which would interrupt\n\t// in-progress range selection after the first calendar click.\n\tconst value = localValue\n\t\t? localValue.value\n\t\t: readUrlValue() ?? getLastFullCalendarMonthDateFilter( stableNow );\n\tconst period = getPeriodForDateFilter( value, stableNow );\n\tconst hasDateFilterValue = value !== undefined;\n\n\tconst setValue = useCallback(\n\t\t( next: DateFilterValue | undefined ) => {\n\t\t\tconst normalizedValue = normalizeDateFilterValue( next, stableNow );\n\t\t\tisUpdatingUrlRef.current = true;\n\t\t\ttry {\n\t\t\t\tupdateQueryString(\n\t\t\t\t\tserializeDateFilterToQuery( normalizedValue ),\n\t\t\t\t\treportsPath\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tisUpdatingUrlRef.current = false;\n\t\t\t}\n\t\t\twindow.dispatchEvent(\n\t\t\t\tnew CustomEvent< LocalDateFilterValue >(\n\t\t\t\t\tbalanceDateFilterChangeEvent,\n\t\t\t\t\t{ detail: { value: normalizedValue } }\n\t\t\t\t)\n\t\t\t);\n\t\t\tsetNavTick( ( tick ) => tick + 1 );\n\t\t},\n\t\t[ stableNow ]\n\t);\n\n\treturn {\n\t\tvalue,\n\t\tperiod,\n\t\thasDateFilterValue,\n\t\tsetValue,\n\t};\n};\n","/** @format */\n\n/**\n * External dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { formatDateTimeFromString } from 'wcpay/utils/date-time';\nimport type { ReportsBalanceSummary } from 'wcpay/data/reports/hooks';\nimport type { ReportsPeriodRange } from 'wcpay/reports/period-selector';\nimport type { BalanceRow } from './rows';\n\nexport const printContextClass = 'wcpay-reports-balance-print-context';\n\nexport const getBalanceReportIdentity = () => ( {\n\tbusinessName: (\n\t\twcpaySettings.accountStatus?.businessName ||\n\t\twcpaySettings.storeName ||\n\t\t''\n\t).trim(),\n\taccountId: ( wcpaySettings.accountStatus?.accountId || '' ).trim(),\n} );\n\nexport const getRangeDays = ( start?: string, end?: string ): number | null => {\n\tif ( ! start || ! end ) {\n\t\treturn null;\n\t}\n\n\treturn Math.round(\n\t\t( new Date( end ).getTime() - new Date( start ).getTime() ) / 86400000\n\t);\n};\n\nexport const hasKeys = (\n\tvalue: Record< string, unknown > | undefined\n): boolean => Object.keys( value ?? {} ).length > 0;\n\nexport const isBalanceSummaryValid = (\n\tsummary: ReportsBalanceSummary\n): boolean =>\n\tBoolean( summary.currency && summary.period?.start && summary.period?.end );\n\nexport const isBalanceSummaryMalformed = ( {\n\tsummary,\n\thasDateFilterValue,\n\tisLoading,\n\thasStoreError,\n}: {\n\tsummary: ReportsBalanceSummary;\n\thasDateFilterValue: boolean;\n\tisLoading: boolean;\n\thasStoreError: boolean;\n} ): boolean =>\n\thasDateFilterValue &&\n\t! isLoading &&\n\t! hasStoreError &&\n\t! isBalanceSummaryValid( summary );\n\nexport const hasBalanceActivity = (\n\tvisibleRows: BalanceRow[],\n\tsummary: Parameters< BalanceRow[ 'getAmount' ] >[ 0 ]\n): boolean =>\n\tvisibleRows.some(\n\t\t( row ) =>\n\t\t\trow.getAmount( summary ) !== 0 ||\n\t\t\t( row.getCount?.( summary ) ?? 0 ) !== 0\n\t);\n\nexport const formatUtcDate = ( value: string ): string =>\n\tsprintf(\n\t\t/* translators: %s: date rendered in the site's date format. */\n\t\t__( '%s UTC', 'woocommerce-payments' ),\n\t\tformatDateTimeFromString( value, { timezone: 'UTC' } )\n\t);\n\nexport const getRowLabel = (\n\trow: BalanceRow,\n\tperiod: ReportsPeriodRange\n): string => {\n\tif ( row.key === 'starting_balance' ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: period start date. */\n\t\t\t__( 'Starting balance - %s', 'woocommerce-payments' ),\n\t\t\tformatUtcDate( period.start )\n\t\t);\n\t}\n\n\tif ( row.key === 'ending_balance' ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: period end date. */\n\t\t\t__( 'Ending balance - %s', 'woocommerce-payments' ),\n\t\t\tformatUtcDate( period.end )\n\t\t);\n\t}\n\n\treturn row.label;\n};\n","/** @format */\n\n/**\n * External dependencies\n */\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { DateFilterValue } from './types';\nimport type { RangePreset } from './presets';\nimport { getRangePresetLabel, matchPreset, resolvePreset } from './presets';\n\nconst injectedDateRangePresetClass = 'wcpay-reports-date-range-preset';\nconst injectedDateRangePresetInsertClass =\n\t'wcpay-reports-date-range-preset-insert';\nconst dateRangePresetButtonClass = `components-button is-tertiary is-small dataviews-controls__date-preset ${ injectedDateRangePresetClass }`;\n// DataViews owns this native label and translates it with the default domain.\n// eslint-disable-next-line @wordpress/i18n-text-domain\nconst customDatePresetLabel = __( 'Custom' );\n\ntype ReportDateRangePreset = Extract< RangePreset, 'last_month' | 'last_year' >;\nconst dataViewsDateRangePresetKeys: ReportDateRangePreset[] = [\n\t'last_month',\n\t'last_year',\n];\nconst dataViewsDateRangePresets = dataViewsDateRangePresetKeys.map(\n\t( preset ) => ( {\n\t\tpreset,\n\t\tlabel: getRangePresetLabel( preset ),\n\t} )\n);\n\ntype DateRangePresetInsertionPoint = {\n\tpopover: HTMLElement;\n\tparent: HTMLElement;\n\tbefore: Element;\n};\n\ntype SyncPortalNodeOptions = {\n\tforce?: boolean;\n};\n\n// DataViews does not expose a public preset-extension API. These selectors are\n// private DataViews markup verified against the `@wordpress/dataviews` version\n// bundled with this branch; if upstream renames them, the injected presets will\n// silently stop rendering while the native date filter continues to work.\nconst getDateRangePresetInsertionPoint = (\n\townerDocument: Document\n): DateRangePresetInsertionPoint | null => {\n\tconst popovers = ownerDocument.querySelectorAll< HTMLElement >(\n\t\t'.dataviews-filters__summary-popover'\n\t);\n\n\tfor ( const popover of Array.from( popovers ) ) {\n\t\tconst rangeInputs = popover.querySelector< HTMLElement >(\n\t\t\t'.dataviews-controls__date-range-inputs'\n\t\t);\n\t\tif ( ! rangeInputs ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst firstNativePreset = popover.querySelector< HTMLElement >(\n\t\t\t`.dataviews-controls__date-preset:not(.${ injectedDateRangePresetClass })`\n\t\t);\n\t\tif ( firstNativePreset?.parentElement ) {\n\t\t\treturn {\n\t\t\t\tpopover,\n\t\t\t\tparent: firstNativePreset.parentElement,\n\t\t\t\tbefore: firstNativePreset,\n\t\t\t};\n\t\t}\n\n\t\tif ( rangeInputs?.parentElement ) {\n\t\t\treturn {\n\t\t\t\tpopover,\n\t\t\t\tparent: rangeInputs.parentElement,\n\t\t\t\tbefore: rangeInputs,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn null;\n};\n\nconst getDateRangePresetPopoverFallbackContainer = (\n\townerDocument: Document\n): HTMLElement | null =>\n\townerDocument.querySelector< HTMLElement >(\n\t\t'.components-popover__fallback-container'\n\t);\n\nconst isDataViewsDateRangePreset = (\n\tpreset: string\n): preset is ReportDateRangePreset =>\n\tdataViewsDateRangePresetKeys.includes( preset as ReportDateRangePreset );\n\nconst getSelectedDateRangePreset = (\n\tdateValue: DateFilterValue | undefined,\n\tnow: Date\n): ReportDateRangePreset | null => {\n\tif ( ! dateValue || dateValue.operator !== 'between' ) {\n\t\treturn null;\n\t}\n\n\tconst preset = matchPreset( dateValue, now );\n\treturn isDataViewsDateRangePreset( preset ) ? preset : null;\n};\n\nconst syncNativeDatePresetState = (\n\tpopover: HTMLElement,\n\tselectedPreset: ReportDateRangePreset | null\n): void => {\n\tconst nativePresetButtons = popover.querySelectorAll< HTMLButtonElement >(\n\t\t`.dataviews-controls__date-preset:not(.${ injectedDateRangePresetClass })`\n\t);\n\tconst buttons = Array.from( nativePresetButtons );\n\tconst customPresetButton = buttons.find(\n\t\t( button ) => button.textContent?.trim() === customDatePresetLabel\n\t);\n\n\tfor ( const button of buttons ) {\n\t\tif ( selectedPreset ) {\n\t\t\tif ( button.getAttribute( 'aria-pressed' ) !== 'false' ) {\n\t\t\t\tbutton.setAttribute( 'aria-pressed', 'false' );\n\t\t\t}\n\t\t\tif ( button.classList.contains( 'is-pressed' ) ) {\n\t\t\t\tbutton.classList.remove( 'is-pressed' );\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ! customPresetButton ) {\n\t\treturn;\n\t}\n\n\tcustomPresetButton.removeAttribute( 'aria-disabled' );\n};\n\nconst syncDateRangePresetButtons = (\n\tportalNode: HTMLElement,\n\tselectedPreset: ReportDateRangePreset | null,\n\tonPresetClick: ( preset: ReportDateRangePreset ) => void\n): void => {\n\tfor ( const { preset, label } of dataViewsDateRangePresets ) {\n\t\tconst selector = `[data-wcpay-date-range-preset=\"${ preset }\"]`;\n\t\tlet button = portalNode.querySelector< HTMLButtonElement >( selector );\n\t\tif ( ! button ) {\n\t\t\tbutton = portalNode.ownerDocument.createElement( 'button' );\n\t\t\tbutton.type = 'button';\n\t\t\tbutton.className = dateRangePresetButtonClass;\n\t\t\tbutton.dataset.wcpayDateRangePreset = preset;\n\t\t\tbutton.textContent = label;\n\t\t\tbutton.onclick = () => onPresetClick( preset );\n\t\t\tportalNode.appendChild( button );\n\t\t}\n\n\t\tconst isSelected = selectedPreset === preset;\n\t\tconst ariaPressed = isSelected ? 'true' : 'false';\n\t\tif ( button.textContent !== label ) {\n\t\t\tbutton.textContent = label;\n\t\t}\n\t\tif ( button.getAttribute( 'aria-pressed' ) !== ariaPressed ) {\n\t\t\tbutton.setAttribute( 'aria-pressed', ariaPressed );\n\t\t}\n\t\tif ( button.classList.contains( 'is-pressed' ) !== isSelected ) {\n\t\t\tbutton.classList.toggle( 'is-pressed', isSelected );\n\t\t}\n\t}\n};\n\nexport const DataViewsDateRangePresetPortal = ( {\n\trootRef,\n\tdateValue,\n\tdateFilterNow,\n\tonDateChange,\n}: {\n\trootRef: React.RefObject< HTMLElement | null >;\n\tdateValue: DateFilterValue | undefined;\n\tdateFilterNow?: Date;\n\tonDateChange: ( next: DateFilterValue, referenceDate: Date ) => void;\n} ): null => {\n\tconst portalNodeRef = useRef< HTMLDivElement | null >( null );\n\tconst stableDateFilterNowRef = useRef< Date | null >( null );\n\tif ( ! stableDateFilterNowRef.current ) {\n\t\tstableDateFilterNowRef.current = dateFilterNow ?? new Date();\n\t}\n\tconst [ clickedDateFilterNow, setClickedDateFilterNow ] =\n\t\tuseState< Date | null >( null );\n\tconst selectedPreset =\n\t\t( clickedDateFilterNow &&\n\t\t\tgetSelectedDateRangePreset( dateValue, clickedDateFilterNow ) ) ||\n\t\tgetSelectedDateRangePreset( dateValue, stableDateFilterNowRef.current );\n\tconst applyDatePreset = useCallback(\n\t\t( preset: ReportDateRangePreset ) => {\n\t\t\tconst currentDateFilterNow = new Date();\n\t\t\tconst nextValue = resolvePreset(\n\t\t\t\tpreset,\n\t\t\t\t'between',\n\t\t\t\tcurrentDateFilterNow\n\t\t\t);\n\t\t\tif ( nextValue ) {\n\t\t\t\tsetClickedDateFilterNow( currentDateFilterNow );\n\t\t\t\tonDateChange( nextValue, currentDateFilterNow );\n\t\t\t}\n\t\t},\n\t\t[ onDateChange ]\n\t);\n\tconst applyDatePresetRef = useRef( applyDatePreset );\n\tapplyDatePresetRef.current = applyDatePreset;\n\tconst selectedPresetRef = useRef( selectedPreset );\n\tselectedPresetRef.current = selectedPreset;\n\n\tconst syncPortalNode = useCallback(\n\t\t( { force = false }: SyncPortalNodeOptions = {} ) => {\n\t\t\tconst ownerDocument = rootRef.current?.ownerDocument ?? document;\n\t\t\tconst insertionPoint =\n\t\t\t\tgetDateRangePresetInsertionPoint( ownerDocument );\n\t\t\tconst currentSelectedPreset = selectedPresetRef.current;\n\n\t\t\tif ( ! insertionPoint ) {\n\t\t\t\tportalNodeRef.current?.remove();\n\t\t\t\tportalNodeRef.current = null;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tportalNodeRef.current?.parentElement ===\n\t\t\t\t\tinsertionPoint.parent &&\n\t\t\t\tportalNodeRef.current.nextElementSibling ===\n\t\t\t\t\tinsertionPoint.before\n\t\t\t) {\n\t\t\t\tif ( ! force ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsyncNativeDatePresetState(\n\t\t\t\t\tinsertionPoint.popover,\n\t\t\t\t\tcurrentSelectedPreset\n\t\t\t\t);\n\t\t\t\tsyncDateRangePresetButtons(\n\t\t\t\t\tportalNodeRef.current,\n\t\t\t\t\tcurrentSelectedPreset,\n\t\t\t\t\t( preset ) => applyDatePresetRef.current( preset )\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsyncNativeDatePresetState(\n\t\t\t\tinsertionPoint.popover,\n\t\t\t\tcurrentSelectedPreset\n\t\t\t);\n\t\t\tportalNodeRef.current?.remove();\n\n\t\t\tconst nextPortalNode = ownerDocument.createElement( 'div' );\n\t\t\tnextPortalNode.className = injectedDateRangePresetInsertClass;\n\t\t\tnextPortalNode.style.display = 'contents';\n\t\t\tinsertionPoint.parent.insertBefore(\n\t\t\t\tnextPortalNode,\n\t\t\t\tinsertionPoint.before\n\t\t\t);\n\n\t\t\tportalNodeRef.current = nextPortalNode;\n\t\t\tsyncDateRangePresetButtons(\n\t\t\t\tnextPortalNode,\n\t\t\t\tcurrentSelectedPreset,\n\t\t\t\t( preset ) => applyDatePresetRef.current( preset )\n\t\t\t);\n\t\t},\n\t\t[ rootRef ]\n\t);\n\n\tuseEffect( () => {\n\t\tsyncPortalNode( { force: true } );\n\t}, [ selectedPreset, syncPortalNode ] );\n\n\tuseEffect( () => {\n\t\tconst ownerDocument = rootRef.current?.ownerDocument ?? document;\n\t\tconst ownerWindow = ownerDocument.defaultView ?? window;\n\t\tsyncPortalNode();\n\t\tlet syncAnimationFrame: number | null = null;\n\n\t\tconst observedTargets = new Set< HTMLElement >();\n\n\t\tfunction observeTarget(\n\t\t\tobserver: MutationObserver,\n\t\t\ttarget: HTMLElement | null,\n\t\t\toptions: MutationObserverInit\n\t\t) {\n\t\t\tif ( ! target || observedTargets.has( target ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tobserver.observe( target, options );\n\t\t\tobservedTargets.add( target );\n\t\t}\n\n\t\tfunction observePopoverFallbackContainer( observer: MutationObserver ) {\n\t\t\tobserveTarget(\n\t\t\t\tobserver,\n\t\t\t\tgetDateRangePresetPopoverFallbackContainer( ownerDocument ),\n\t\t\t\t{\n\t\t\t\t\tchildList: true,\n\t\t\t\t\tsubtree: true,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tconst observer = new MutationObserver( () => {\n\t\t\tif ( syncAnimationFrame !== null ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsyncAnimationFrame = ownerWindow.requestAnimationFrame( () => {\n\t\t\t\tsyncAnimationFrame = null;\n\t\t\t\tsyncPortalNode();\n\t\t\t\tobservePopoverFallbackContainer( observer );\n\t\t\t} );\n\t\t} );\n\n\t\tobservePopoverFallbackContainer( observer );\n\t\tobserveTarget(\n\t\t\tobserver,\n\t\t\townerDocument.getElementById( 'wpbody-content' ),\n\t\t\t{\n\t\t\t\tchildList: true,\n\t\t\t\tsubtree: true,\n\t\t\t}\n\t\t);\n\t\tobserveTarget( observer, ownerDocument.body, {\n\t\t\tchildList: true,\n\t\t} );\n\n\t\tif ( ! observedTargets.size ) {\n\t\t\treturn () => {\n\t\t\t\tif ( syncAnimationFrame !== null ) {\n\t\t\t\t\townerWindow.cancelAnimationFrame( syncAnimationFrame );\n\t\t\t\t}\n\t\t\t\tportalNodeRef.current?.remove();\n\t\t\t\tportalNodeRef.current = null;\n\t\t\t};\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( syncAnimationFrame !== null ) {\n\t\t\t\townerWindow.cancelAnimationFrame( syncAnimationFrame );\n\t\t\t}\n\t\t\tobserver.disconnect();\n\t\t\tportalNodeRef.current?.remove();\n\t\t\tportalNodeRef.current = null;\n\t\t};\n\t}, [ rootRef, syncPortalNode ] );\n\n\treturn null;\n};\n","/** @format */\n\n/**\n * External dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tDateFilterPresetElement,\n\tDateFilterValue,\n\tDateOperator,\n} from './types';\n\nexport type SingleDatePreset =\n\t| 'today'\n\t| 'yesterday'\n\t| 'past_week'\n\t| 'past_month';\n\nexport type RangePreset =\n\t| 'last_month'\n\t| 'month_to_date'\n\t| 'last_year'\n\t| 'year_to_date';\n\nexport type CustomPreset = 'custom';\n\nexport type DatePreset = SingleDatePreset | RangePreset | CustomPreset;\n\nconst toYmd = ( d: Date ): string =>\n\t`${ d.getFullYear() }-${ String( d.getMonth() + 1 ).padStart(\n\t\t2,\n\t\t'0'\n\t) }-${ String( d.getDate() ).padStart( 2, '0' ) }`;\n\nconst startOfDay = ( now: Date ): Date =>\n\tnew Date( now.getFullYear(), now.getMonth(), now.getDate() );\n\nconst singleDatePresetLabels = (): Record< SingleDatePreset, string > => ( {\n\ttoday: __( 'Today', 'woocommerce-payments' ),\n\tyesterday: __( 'Yesterday', 'woocommerce-payments' ),\n\tpast_week: __( 'Past week', 'woocommerce-payments' ),\n\tpast_month: __( 'Past month', 'woocommerce-payments' ),\n} );\n\nconst rangePresetLabels = (): Record< RangePreset, string > => ( {\n\tlast_month: __( 'Previous month', 'woocommerce-payments' ),\n\tmonth_to_date: __( 'Month to date', 'woocommerce-payments' ),\n\tlast_year: __( 'Previous year', 'woocommerce-payments' ),\n\tyear_to_date: __( 'Year to date', 'woocommerce-payments' ),\n} );\n\nexport const getRangePresetLabel = ( preset: RangePreset ): string =>\n\trangePresetLabels()[ preset ];\n\n/**\n * Return the preset chip list for the given operator. `between` operates on\n * date ranges; `on`/`before`/`after` operate on a single anchor date.\n */\nexport const getPresetsForOperator = (\n\toperator: DateOperator\n): DateFilterPresetElement[] => {\n\tconst customLabel = __( 'Custom', 'woocommerce-payments' );\n\n\tif ( operator === 'between' ) {\n\t\tconst labels = rangePresetLabels();\n\t\treturn [\n\t\t\t{ value: 'last_month', label: labels.last_month },\n\t\t\t{ value: 'month_to_date', label: labels.month_to_date },\n\t\t\t{ value: 'last_year', label: labels.last_year },\n\t\t\t{ value: 'year_to_date', label: labels.year_to_date },\n\t\t\t{ value: 'custom', label: customLabel },\n\t\t];\n\t}\n\n\tconst labels = singleDatePresetLabels();\n\treturn [\n\t\t{ value: 'today', label: labels.today },\n\t\t{ value: 'yesterday', label: labels.yesterday },\n\t\t{ value: 'past_week', label: labels.past_week },\n\t\t{ value: 'past_month', label: labels.past_month },\n\t\t{ value: 'custom', label: customLabel },\n\t];\n};\n\nconst resolveSingleAnchorDate = (\n\tpreset: SingleDatePreset,\n\tnow: Date\n): string => {\n\tconst today = startOfDay( now );\n\n\tswitch ( preset ) {\n\t\tcase 'today':\n\t\t\treturn toYmd( today );\n\t\tcase 'yesterday': {\n\t\t\tconst d = new Date( today );\n\t\t\td.setDate( d.getDate() - 1 );\n\t\t\treturn toYmd( d );\n\t\t}\n\t\tcase 'past_week': {\n\t\t\tconst d = new Date( today );\n\t\t\td.setDate( d.getDate() - 7 );\n\t\t\treturn toYmd( d );\n\t\t}\n\t\tcase 'past_month': {\n\t\t\tconst d = new Date( today );\n\t\t\td.setMonth( d.getMonth() - 1 );\n\t\t\treturn toYmd( d );\n\t\t}\n\t}\n};\n\nconst resolveRange = ( preset: RangePreset, now: Date ): [ string, string ] => {\n\tconst today = startOfDay( now );\n\tconst year = today.getFullYear();\n\tconst month = today.getMonth();\n\n\tswitch ( preset ) {\n\t\tcase 'last_month': {\n\t\t\tconst start = new Date( year, month - 1, 1 );\n\t\t\tconst end = new Date( year, month, 0 );\n\t\t\treturn [ toYmd( start ), toYmd( end ) ];\n\t\t}\n\t\tcase 'month_to_date': {\n\t\t\tconst start = new Date( year, month, 1 );\n\t\t\treturn [ toYmd( start ), toYmd( today ) ];\n\t\t}\n\t\tcase 'last_year': {\n\t\t\tconst start = new Date( year - 1, 0, 1 );\n\t\t\tconst end = new Date( year - 1, 11, 31 );\n\t\t\treturn [ toYmd( start ), toYmd( end ) ];\n\t\t}\n\t\tcase 'year_to_date': {\n\t\t\tconst start = new Date( year, 0, 1 );\n\t\t\treturn [ toYmd( start ), toYmd( today ) ];\n\t\t}\n\t}\n};\n\nconst singleDatePresets: SingleDatePreset[] = [\n\t'today',\n\t'yesterday',\n\t'past_week',\n\t'past_month',\n];\n\nconst rangePresets: RangePreset[] = [\n\t// Keep these keys stable: they are emitted in analytics even when labels use\n\t// \"Previous month\" / \"Previous year\" for merchant-facing copy.\n\t'last_month',\n\t'month_to_date',\n\t'last_year',\n\t'year_to_date',\n];\n\nconst isSingleDatePreset = ( value: unknown ): value is SingleDatePreset =>\n\ttypeof value === 'string' &&\n\tsingleDatePresets.includes( value as SingleDatePreset );\n\nconst isRangePreset = ( value: unknown ): value is RangePreset =>\n\ttypeof value === 'string' && rangePresets.includes( value as RangePreset );\n\n/**\n * Resolve a preset key + operator into a `DateFilterValue`. Returns `undefined`\n * for unrecognized presets, the `custom` sentinel, or operator/preset\n * mismatches (e.g., a range preset against a single-date operator).\n */\nexport const resolvePreset = (\n\tpreset: string,\n\toperator: DateOperator,\n\tnow: Date = new Date()\n): DateFilterValue | undefined => {\n\tif ( preset === 'custom' ) {\n\t\treturn undefined;\n\t}\n\n\tif ( operator === 'between' ) {\n\t\tif ( ! isRangePreset( preset ) ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn { operator: 'between', value: resolveRange( preset, now ) };\n\t}\n\n\tif ( ! isSingleDatePreset( preset ) ) {\n\t\treturn undefined;\n\t}\n\tconst anchor = resolveSingleAnchorDate( preset, now );\n\tif ( operator === 'on' ) {\n\t\treturn { operator: 'on', value: anchor };\n\t}\n\tif ( operator === 'before' ) {\n\t\treturn { operator: 'before', value: anchor };\n\t}\n\treturn { operator: 'after', value: anchor };\n};\n\n/**\n * Try to recognize a `DateFilterValue` as one of the named presets, given a\n * reference \"now\". Returns the preset key, or `'custom'` if no preset matches.\n * Useful so the popover can highlight the active preset chip on reopen.\n */\nexport const matchPreset = (\n\tvalue: DateFilterValue,\n\tnow: Date = new Date()\n): DatePreset => {\n\tif ( value.operator === 'between' ) {\n\t\tfor ( const preset of rangePresets ) {\n\t\t\tconst range = resolveRange( preset, now );\n\t\t\tif (\n\t\t\t\trange[ 0 ] === value.value[ 0 ] &&\n\t\t\t\trange[ 1 ] === value.value[ 1 ]\n\t\t\t) {\n\t\t\t\treturn preset;\n\t\t\t}\n\t\t}\n\t\treturn 'custom';\n\t}\n\n\tfor ( const preset of singleDatePresets ) {\n\t\tif ( resolveSingleAnchorDate( preset, now ) === value.value ) {\n\t\t\treturn preset;\n\t\t}\n\t}\n\treturn 'custom';\n};\n","/** @format */\n\n/**\n * External dependencies\n */\nimport React from 'react';\nimport { Icon } from '@wordpress/components';\n\ninterface ReportStateProps {\n\ttitle: string;\n\tdescription: React.ReactNode;\n\ticon: React.ComponentProps< typeof Icon >[ 'icon' ];\n\taction?: React.ReactNode;\n\tclassName?: string;\n\tdescriptionId?: string;\n\theadingId?: string;\n\theadingRef?: React.Ref< HTMLHeadingElement >;\n\theadingTabIndex?: number;\n\trole?: string;\n}\n\nexport const ReportState = ( {\n\ttitle,\n\tdescription,\n\ticon,\n\taction,\n\tclassName,\n\tdescriptionId,\n\theadingId,\n\theadingRef,\n\theadingTabIndex,\n\trole,\n}: ReportStateProps ): JSX.Element => (\n\t<div\n\t\tclassName={ [\n\t\t\t'wcpay-reports-state',\n\t\t\t'wcpay-reports-state--illustrated',\n\t\t\tclassName,\n\t\t]\n\t\t\t.filter( Boolean )\n\t\t\t.join( ' ' ) }\n\t\trole={ role }\n\t\taria-labelledby={ headingId }\n\t\taria-describedby={ descriptionId }\n\t>\n\t\t<span className=\"wcpay-reports-state__icon\" aria-hidden=\"true\">\n\t\t\t<Icon icon={ icon } size={ 48 } />\n\t\t</span>\n\t\t<div className=\"wcpay-reports-state__copy\">\n\t\t\t<h2\n\t\t\t\tid={ headingId }\n\t\t\t\tref={ headingRef }\n\t\t\t\ttabIndex={ headingTabIndex }\n\t\t\t>\n\t\t\t\t{ title }\n\t\t\t</h2>\n\t\t\t<p id={ descriptionId }>{ description }</p>\n\t\t</div>\n\t\t{ action }\n\t</div>\n);\n"],"names":["SVG","xmlns","viewBox","children","Path","d","formatYmdUTC","value","slice","getBalanceExportFileName","period","start","end","getBalanceCSV","visibleRows","summary","displayPeriod","currency","periodStart","periodEnd","reportIdentity","getBalanceReportIdentity","generateCSVDataFromTable","key","label","map","row","count","getCount","rowLabel","getRowLabel","businessName","display","accountId","getAmount","formatBalanceAmount","amount","currencyCode","upperCode","toUpperCase","isNegative","isZero","absoluteAmount","withoutCode","formatExplicitCurrency","replace","RegExp","trim","balanceDateFilterOperators","BalanceDataView","dateValue","onDateChange","focusTargetRef","dateFilterNow","preview","pendingDateOperator","setPendingDateOperator","useState","rootRef","useRef","captionId","useId","stableDateFilterNow","Date","current","filtersRowOpenedRef","onDatePresetChange","useCallback","nextValue","referenceDate","useEffect","root","querySelector","click","items","useMemo","buildItems","id","depth","getRowDepth","getDisplayedAmount","fields","__","type","enableHiding","enableSorting","filterBy","operators","getValue","item","render","_jsxs","className","_jsx","_Fragment","sprintf","_n","view","filters","field","operator","undefined","search","page","perPage","layout","enableMoving","onChangeView","next","dateFilter","find","f","ref","DataViewsDateRangePresetPortal","DataViews","data","paginationInfo","totalItems","length","totalPages","defaultLayouts","table","getItemId","FiltersToggle","FiltersToggled","role","tabIndex","Layout","feedbackQuestion","thumbsUpLabel","thumbsDownLabel","thumbsUpAriaLabel","thumbsDownAriaLabel","reportFeedbackRatingAriaLabel","closeAriaLabel","cancelLabel","sendLabel","submitErrorMessage","submitSuccessMessage","privacyDisclaimer","createInterpolateElement","a","href","target","rel","options","ariaLabel","icon","rating","ThumbsControl","controlsId","disabled","isExpanded","onSelect","selectedRating","isSelected","Button","clsx","onClick","reportFeedbackReportType","getSentiment","ReportFeedbackSurveyContent","focusAfterCloseRef","dismiss","isDismissed","useReportFeedbackState","updateUserPreferences","wc_payments_reports_feedback_dismissed","dismissedAt","useUserPreferences","Math","floor","now","Boolean","isSubmitting","submitFeedback","useSubmitReportFeedback","setIsSubmitting","async","comments","apiFetch","path","NAMESPACE","method","createSuccessNotice","useDispatch","expandedRegionId","containerRef","expandedRegionRef","hasFocusedExpandedForm","setRating","setComments","isHidden","setIsHidden","hasSubmitError","setHasSubmitError","hasRecordedView","isVisible","recordEvent","report_type","focus","persistDismissal","Promise","resolve","catch","hideSurvey","focusAfterClose","activeElement","ownerDocument","contains","preventScroll","closeSmall","handleDismiss","TextareaControl","__nextHasNoMarginBottom","onChange","readOnly","Notice","status","isDismissible","handleCancel","variant","isBusy","trimmedComments","hasText","recordReportFeedbackSubmit","sentiment","has_text","recordReportFeedbackSubmitError","props","wcpaySettings","featureFlags","reportsArea","mockSummaryFixture","starting_balance","total_charges_captured","fees","charge_fees","dispute_fees","refunds","disputes","net_balance_change_in_the_period","payouts","ending_balance","BalanceLoadingSkeleton","headingRef","headingTabIndex","accountDefaultCurrency","mockSummary","getVisibleBalanceRows","woopaymentsBusinessDetails","getPrintRowClassName","filter","join","BalanceEmptyState","ReportState","title","description","calendar","BalancePrintReport","businessLines","line","src","WooPaymentsLogo","alt","index","scope","colSpan","BalanceReport","onReload","contextDateFilterNow","useContext","BalanceDateFilterNowContext","hasDateFilterValue","setValue","useBalanceDateFilter","requestCurrency","error","isLoading","useReportsBalanceSummary","hasStoreError","hasKeys","hasMalformedSummary","isBalanceSummaryMalformed","hasError","loadingHeadingRef","errorHeadingRef","feedbackFocusTargetRef","previousLoadingRef","previousErrorRef","activeRequestKey","toLowerCase","loadingRequestKeyRef","completedActiveRequest","reloadRequestedRef","speakTimerRef","lastSpokenRef","errorHeadingId","errorDescriptionId","hasActivity","hasBalanceActivity","hasLoadedReportActivity","printScopeActive","stateContent","has_activity","visible_row_count","range_days","getRangeDays","error_type","message","clearTimeout","setTimeout","speak","document","body","classList","add","printContextClass","documentElement","remove","action","descriptionId","headingId","onDateFilterChange","recordDateFilterChange","isInitialApply","nextPeriod","getPeriodForDateFilter","preset","matchPreset","is_initial_apply","ReportFeedbackSurvey","displayNegative","abs","getRow","BALANCE_ROWS","alwaysVisible","balanceDateFilterChangeEvent","parseYmd","ymd","year","month","day","split","Number","toStartOfDayUTC","UTC","toISOString","toEndOfDayUTC","toYmdUTC","date","getUTCFullYear","String","getUTCMonth","padStart","getUTCDate","getMonthStartYmd","getLatestCompleteDayYmd","minYmd","first","second","capYmdAtLatestCompleteDay","normalizeDateFilterValue","sortYmdRange","normalizedValue","getLastFullCalendarMonthUTC","endYmd","getMonthEndYmd","contextNow","stableNow","isUpdatingUrlRef","navTick","setNavTick","localValue","setLocalValue","bumpNavTick","tick","readUrlValue","parseDateFilterFromQuery","getQuery","handleLocalDateFilterChange","event","detail","handleHistoryChange","window","addEventListener","removeEventListener","range","getLastFullCalendarMonthDateFilter","updateQueryString","serializeDateFilterToQuery","dispatchEvent","CustomEvent","accountStatus","storeName","round","getTime","Object","keys","isBalanceSummaryValid","some","formatUtcDate","formatDateTimeFromString","timezone","injectedDateRangePresetClass","dateRangePresetButtonClass","customDatePresetLabel","dataViewsDateRangePresetKeys","dataViewsDateRangePresets","getRangePresetLabel","getSelectedDateRangePreset","includes","isDataViewsDateRangePreset","syncNativeDatePresetState","popover","selectedPreset","nativePresetButtons","querySelectorAll","buttons","Array","from","customPresetButton","button","textContent","getAttribute","setAttribute","removeAttribute","syncDateRangePresetButtons","portalNode","onPresetClick","selector","createElement","dataset","wcpayDateRangePreset","onclick","appendChild","ariaPressed","toggle","portalNodeRef","stableDateFilterNowRef","clickedDateFilterNow","setClickedDateFilterNow","applyDatePreset","currentDateFilterNow","resolvePreset","applyDatePresetRef","selectedPresetRef","syncPortalNode","force","insertionPoint","popovers","rangeInputs","firstNativePreset","parentElement","parent","before","getDateRangePresetInsertionPoint","currentSelectedPreset","nextElementSibling","nextPortalNode","style","insertBefore","ownerWindow","defaultView","syncAnimationFrame","observedTargets","Set","observeTarget","observer","has","observe","observePopoverFallbackContainer","getDateRangePresetPopoverFallbackContainer","childList","subtree","MutationObserver","requestAnimationFrame","getElementById","size","cancelAnimationFrame","disconnect","toYmd","getFullYear","getMonth","getDate","startOfDay","last_month","month_to_date","last_year","year_to_date","resolveSingleAnchorDate","today","setDate","setMonth","resolveRange","singleDatePresets","rangePresets","isSingleDatePreset","anchor","Icon"],"sourceRoot":""}