react-semaphor 0.1.428 → 0.1.430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +72 -71
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +5 -4
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +1031 -622
  7. package/dist/chunks/analyze-result-contract-BswhsmWT.js +1 -0
  8. package/dist/chunks/{analyze-result-contract-DnfF8kBb.js → analyze-result-contract-CfOBEwaC.js} +681 -759
  9. package/dist/chunks/{code-editor-CojfM3qp.js → code-editor-C65eEYyU.js} +2980 -2960
  10. package/dist/chunks/code-editor-DOh3aYEh.js +138 -0
  11. package/dist/chunks/{comparison-document-migration-b6c3xiWh.js → comparison-document-migration-DbU_BTxR.js} +1 -1
  12. package/dist/chunks/{comparison-document-migration-BJH1idOd.js → comparison-document-migration-Dj6xZMCb.js} +2 -2
  13. package/dist/chunks/csv-utils-Co0WxHke.js +4 -0
  14. package/dist/chunks/csv-utils-suxSkJGj.js +376 -0
  15. package/dist/chunks/{dashboard-509sbC4_.js → dashboard-0Tpj3XFq.js} +49934 -47167
  16. package/dist/chunks/dashboard-CVDy3fbO.js +1402 -0
  17. package/dist/chunks/{dashboard-briefing-launcher-B-ZTWJwo.js → dashboard-briefing-launcher-DLQqwXMF.js} +1 -1
  18. package/dist/chunks/{dashboard-briefing-launcher-DIdYHNTq.js → dashboard-briefing-launcher-pkNPk_4j.js} +100 -99
  19. package/dist/chunks/{dashboard-controls-CbRzWo1N.js → dashboard-controls-CIN4biYx.js} +114 -113
  20. package/dist/chunks/{dashboard-controls-CWprw-Pb.js → dashboard-controls-DbW9Jt_P.js} +2 -2
  21. package/dist/chunks/dashboard-json-BDKT0Z-m.js +1 -0
  22. package/dist/chunks/{dashboard-json-jO4GQfZk.js → dashboard-json-DBfR770k.js} +18 -17
  23. package/dist/chunks/edit-dashboard-visual-BjAp_UpK.js +182 -0
  24. package/dist/chunks/{edit-dashboard-visual-KgQTjqWp.js → edit-dashboard-visual-qkvRHS8Q.js} +8721 -8481
  25. package/dist/chunks/{metric-comparison-CWweq9RG.js → metric-comparison-CPoDx56y.js} +1 -1
  26. package/dist/chunks/{metric-comparison-BKgkMy9r.js → metric-comparison-DVy3fll_.js} +1 -1
  27. package/dist/chunks/numeric-presentation-CGTcqocU.js +517 -0
  28. package/dist/chunks/numeric-presentation-Dlb-Dk4c.js +1 -0
  29. package/dist/chunks/report-preferences-dialog-Bx8uzG8K.js +690 -0
  30. package/dist/chunks/report-preferences-dialog-LCHeqh7t.js +1 -0
  31. package/dist/chunks/source-identity-5OPV4gvg.js +92 -0
  32. package/dist/chunks/source-identity-Cbo2LOHQ.js +1 -0
  33. package/dist/chunks/{update-policy-CY2k-pJP.js → update-policy-De2NswtM.js} +1 -1
  34. package/dist/chunks/{update-policy-BgONreNd.js → update-policy-DnF_74zC.js} +1 -1
  35. package/dist/chunks/{use-create-flow-overlay-state-BiMYdjZP.js → use-create-flow-overlay-state-C-CxrQ48.js} +1 -1
  36. package/dist/chunks/{use-create-flow-overlay-state-CGsLzp9A.js → use-create-flow-overlay-state-C-j8E5IZ.js} +97 -96
  37. package/dist/chunks/validators-B2vUAqTf.js +1 -0
  38. package/dist/chunks/{validators-Cz-XuORM.js → validators-Bce_J7Vd.js} +19 -13
  39. package/dist/dashboard/index.cjs +1 -1
  40. package/dist/dashboard/index.js +1 -1
  41. package/dist/dashboard-authoring/index.cjs +3 -3
  42. package/dist/dashboard-authoring/index.js +20 -19
  43. package/dist/data-app-builder/index.cjs +1 -1
  44. package/dist/data-app-builder/index.js +50 -50
  45. package/dist/data-app-codegen/index.cjs +1 -1
  46. package/dist/data-app-codegen/index.js +2 -2
  47. package/dist/data-app-codegen-node/index.cjs +1 -1
  48. package/dist/data-app-codegen-node/index.js +3 -3
  49. package/dist/data-app-sdk/index.cjs +2 -2
  50. package/dist/data-app-sdk/index.js +27 -26
  51. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  52. package/dist/data-app-sdk-adapters/index.js +25 -24
  53. package/dist/data-app-sdk-validation/index.cjs +1 -1
  54. package/dist/data-app-sdk-validation/index.js +57 -55
  55. package/dist/format-utils/index.cjs +2 -5
  56. package/dist/format-utils/index.js +136 -161
  57. package/dist/index.cjs +1 -1
  58. package/dist/index.js +158 -155
  59. package/dist/report-runtime-context/index.cjs +1 -0
  60. package/dist/report-runtime-context/index.js +394 -0
  61. package/dist/style.css +1 -1
  62. package/dist/surfboard/index.cjs +1 -1
  63. package/dist/surfboard/index.js +7 -6
  64. package/dist/types/analytics-protocol.d.ts +0 -4
  65. package/dist/types/briefings.d.ts +216 -19
  66. package/dist/types/dashboard-assistant.d.ts +0 -2
  67. package/dist/types/dashboard-authoring.d.ts +34 -9
  68. package/dist/types/dashboard.d.ts +93 -9
  69. package/dist/types/data-app-builder.d.ts +0 -1
  70. package/dist/types/data-app-codegen-node.d.ts +6 -28
  71. package/dist/types/data-app-codegen.d.ts +6 -28
  72. package/dist/types/data-app-sdk-adapters.d.ts +6 -28
  73. package/dist/types/data-app-sdk-validation.d.ts +6 -29
  74. package/dist/types/data-app-sdk.d.ts +6 -31
  75. package/dist/types/format-utils.d.ts +128 -4
  76. package/dist/types/index.cjs +1 -1
  77. package/dist/types/index.js +10 -13
  78. package/dist/types/main.d.ts +249 -89
  79. package/dist/types/report-runtime-context.d.ts +99 -0
  80. package/dist/types/shared.d.ts +34 -9
  81. package/dist/types/surfboard.d.ts +119 -16
  82. package/dist/types/types.d.ts +156 -73
  83. package/dist/types/value-format-preferences.d.ts +126 -0
  84. package/dist/value-format-preferences/index.cjs +1 -0
  85. package/dist/value-format-preferences/index.js +635 -0
  86. package/package.json +11 -1
  87. package/dist/chunks/analyze-result-contract-ege_u6Nl.js +0 -1
  88. package/dist/chunks/calendar-preferences-dialog-BF9bNAF_.js +0 -457
  89. package/dist/chunks/calendar-preferences-dialog-_L9eBQfj.js +0 -1
  90. package/dist/chunks/code-editor-BoowcKU0.js +0 -138
  91. package/dist/chunks/dashboard-CMDXBLnG.js +0 -1402
  92. package/dist/chunks/dashboard-json-BEZrxx_k.js +0 -1
  93. package/dist/chunks/date-formatter-BTTYdAik.js +0 -1
  94. package/dist/chunks/date-formatter-D-89jTjG.js +0 -514
  95. package/dist/chunks/edit-dashboard-visual-D3uhqgm3.js +0 -182
  96. package/dist/chunks/validators-B4VMLX3_.js +0 -1
@@ -1 +1 @@
1
- "use strict";require("./analyze-result-contract-ege_u6Nl.js");const L=require("./metric-comparison-BKgkMy9r.js"),I=["lg","md","sm","xs","xxs"],V=15,_=new Set(["previous_period","same_period_last_year","start_vs_end","target"]),k=new Set([..._,"none",""]);function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function E(e){const r=l(e.preferences)?e.preferences:void 0,o=r&&l(r.kpiVisualOptions)?r.kpiVisualOptions:void 0,s=r&&l(r.tableVisualOptions)?r.tableVisualOptions:void 0;return{preferences:r,kpiOptions:o,kpiComparison:o&&l(o.metricComparison)?o.metricComparison:void 0,kpiComparisonPresent:!!o&&"metricComparison"in o,tableOptions:s,tableComparison:s&&l(s.metricComparison)?s.metricComparison:void 0,tableComparisonPresent:!!s&&"metricComparison"in s}}function O(e){const r=[],o=(s,p)=>{if(Array.isArray(s)){s.forEach((n,c)=>o(n,`${p}[${c}]`));return}if(!l(s))return;const m=s.config;if(l(m)){const n=E(s),c=!!(n.kpiComparisonPresent||n.tableComparisonPresent),d=m.metricColumns,a=Array.isArray(d)?d.flatMap((t,i)=>l(t)?[{index:i,metric:t}]:[]):[];if((a.some(({metric:t})=>"comparisonType"in t)||c)&&r.push({path:p,card:s,metrics:a,malformedMetricIndexes:Array.isArray(d)?d.flatMap((t,i)=>l(t)?[]:[i]):[],malformedMetricColumns:"metricColumns"in m&&!Array.isArray(d),hasLegacyPresentation:c}),"metricColumns"in m||c)return}Object.entries(s).forEach(([n,c])=>o(c,p?`${p}.${n}`:n))};return o(e,"$"),r}const T={difference:"difference",change:"percent_change",change_difference:"both",ratio:"ratio"};function $(e,r){if(!e)return;const o=Object.fromEntries(r.flatMap(s=>typeof e[s]=="string"?[[s,e[s]]]:[]));return Object.keys(o).length?o:void 0}function N(e,r,o){if(e!==void 0){if(!l(e)){o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:r,message:"Legacy comparison formatOptions must be an object."});return}Object.entries(e).forEach(([s,p])=>{if(s==="decimalPlaces"){(typeof p!="number"||!Number.isInteger(p)||p<0||p>6)&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${r}.decimalPlaces`,message:"Legacy comparison decimalPlaces must be an integer from 0 through 6."});return}s==="type"&&(p===void 0||p==="auto")||p!==void 0&&o.push({severity:"error",code:"unsupported_comparison_format",path:`${r}.${s}`,message:`Legacy comparison format option "${s}" has no canonical presentation mapping.`})})}}function C(e,r){const o=r==="kpi"?e.calculationType:e.calculatedAs,s=r==="table"&&o===void 0?"both":T[String(o)],p=l(e.formatOptions)?e.formatOptions:void 0,m=l(e.conditionalLabels)?e.conditionalLabels:void 0,n=l(r==="kpi"?e.colorConfig:e.colors)?r==="kpi"?e.colorConfig:e.colors:void 0,c={};if(s&&(c.displayMode=s),typeof(p==null?void 0:p.decimalPlaces)=="number"&&(c.precision=p.decimalPlaces),r==="kpi"){const t=e.showArrow!==!1,i=e.showColor!==!1;c.indicatorStyle=t?i?"arrow_badge":"arrow":i?"badge":"none",c.showColor=i,(e.position==="left"||e.position==="right"||e.position==="top")&&(c.position=e.position),typeof e.conditionalLabel=="boolean"&&(c.conditionalLabel=e.conditionalLabel),typeof e.labelName=="string"&&(c.labelName=e.labelName)}else(e.indicatorStyle==="arrow_badge"||e.indicatorStyle==="arrow"||e.indicatorStyle==="badge"||e.indicatorStyle==="none")&&(c.indicatorStyle=e.indicatorStyle);const d=m?{...$(m,["increase","decrease"]),...typeof m.noChange=="string"?{neutral:m.noChange}:typeof m.neutral=="string"?{neutral:m.neutral}:{}}:void 0;d&&Object.keys(d).length&&(c.conditionalLabels=d);const a=n?{...$(n,["increase","decrease"]),...typeof n.noChange=="string"?{neutral:n.noChange}:typeof n.neutral=="string"?{neutral:n.neutral}:{}}:void 0;return a&&Object.keys(a).length&&(c.colors=a),c}function w(e){return{...L.COMPARISON_PRESENTATION_DEFAULTS,...e}}function A(e){return e.some(({metric:r})=>r.comparisonType==="previous_period"||r.comparisonType==="same_period_last_year"||r.comparisonType==="target"?!0:l(r.comparison)&&r.comparison.mode==="explicit")}function v(e){const r=e.card.config;return e.metrics.length===2&&(r.groupByColumns===void 0||Array.isArray(r.groupByColumns)&&r.groupByColumns.length===0)}function P(e,r,o,s){const p=r==="kpi"?["enabled","calculationType","formatOptions","showArrow","showColor","conditionalLabel","labelName","position","conditionalLabels","colorConfig","lowerIsBetter"]:["calculatedAs","indicatorStyle","formatOptions","colors","lowerIsBetter"];Object.keys(e).forEach(t=>{p.includes(t)||s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}`,message:`Unknown legacy comparison presentation field "${t}" cannot be dropped automatically.`})});const m=r==="kpi"?"calculationType":"calculatedAs";e[m]!==void 0&&!T[String(e[m])]&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${m}`,message:`Legacy comparison ${m} is unsupported.`}),r==="kpi"&&e.position!==void 0&&!["left","right","top"].includes(String(e.position))&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.position`,message:"Legacy comparison position is unsupported."}),r==="kpi"&&e.labelName!==void 0&&typeof e.labelName!="string"&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.labelName`,message:"Legacy comparison labelName must be a string."}),(r==="kpi"?[["conditionalLabels",["increase","decrease","noChange"]],["colorConfig",["increase","decrease","noChange"]]]:[["colors",["increase","decrease","neutral"]]]).forEach(([t,i])=>{if(e[t]!==void 0){if(!l(e[t])){s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}`,message:`Legacy comparison ${t} must be an object.`});return}Object.entries(e[t]).forEach(([u,f])=>{i.includes(u)?typeof f!="string"&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}.${u}`,message:`Legacy comparison ${t}.${u} must be a string.`}):s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}.${u}`,message:`Unknown legacy comparison ${t} field "${u}" cannot be dropped automatically.`})})}}),(r==="kpi"?["enabled","showArrow","showColor","conditionalLabel","lowerIsBetter"]:["lowerIsBetter"]).forEach(t=>{e[t]!==void 0&&typeof e[t]!="boolean"&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}`,message:`Legacy comparison ${t} must be a boolean.`})}),r==="table"&&e.indicatorStyle!==void 0&&!["arrow_badge","arrow","badge","none"].includes(String(e.indicatorStyle))&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.indicatorStyle`,message:"Legacy comparison indicatorStyle is unsupported."}),N(e.formatOptions,`${o}.formatOptions`,s);const d=C(e,r);L.validateComparisonPresentationSpec(d,o).errors.forEach(t=>{s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:t.path||o,message:t.message})})}function S(e){const r=E(e.card),o=r.kpiComparison?C(r.kpiComparison,"kpi"):void 0,s=r.tableComparison?C(r.tableComparison,"table"):void 0;return{namespaces:r,kpi:o,table:s,presentation:o||s}}function B(e){const r=l(e.preferences)?e.preferences:{},o=l(r.kpiVisualOptions)?r.kpiVisualOptions:{},s=l(o.metricComparison)?o.metricComparison:{},p=l(r.tableVisualOptions)?r.tableVisualOptions:{},m=l(p.metricComparison)?p.metricComparison:{};return o.lowerIsBetter===!0||s.lowerIsBetter===!0||m.lowerIsBetter===!0?"lower_is_better":"higher_is_better"}function D(e){switch(e.comparisonType){case"previous_period":return{mode:"explicit",spec:{kind:"previous_period"}};case"same_period_last_year":return{mode:"explicit",spec:{kind:"previous_year"}};case"target":return{mode:"explicit",spec:{kind:"target",targetValue:e.targetValue}};default:return}}function M(e){const r=l(e.preferences)?e.preferences:void 0;if(!r)return;const o=l(r.kpiVisualOptions)?r.kpiVisualOptions:void 0;o&&delete o.lowerIsBetter;const s=l(r.tableVisualOptions)?r.tableVisualOptions:void 0,p=s&&l(s.metricComparison)?s.metricComparison:void 0;p&&delete p.lowerIsBetter}function R(e){const r=O(e);if(!r.length)return{document:e,changed:!1,changes:[],diagnostics:[]};const o=[];if(r.forEach(n=>{var c,d,a,t;if(n.malformedMetricColumns&&o.push({severity:"error",code:"malformed_metric_columns",path:`${n.path}.config.metricColumns`,message:"Metric columns must be an array before comparison migration."}),n.malformedMetricIndexes.forEach(i=>{o.push({severity:"error",code:"malformed_metric_columns",path:`${n.path}.config.metricColumns[${i}]`,message:"Metric columns must contain objects before comparison migration."})}),n.metrics.forEach(({metric:i,index:u})=>{if(!("comparisonType"in i))return;const f=`${n.path}.config.metricColumns[${u}]`,g=String(i.comparisonType||"");"comparison"in i&&o.push({severity:"error",code:"conflicting_comparison_contracts",path:f,message:"Metric contains both legacy and canonical comparison configuration; resolve the conflict before migration."});const h=l(i.parameters)?i.parameters:void 0,b=h&&l(h.windowTransform)?h.windowTransform:void 0;_.has(g)&&(b==null?void 0:b.function)==="previous_period_delta"&&o.push({severity:"error",code:"conflicting_comparison_window_transform",path:f,message:"A metric cannot combine baseline comparison with previous_period_delta; resolve the authoring intent before migration."}),k.has(g)||o.push({severity:"error",code:"unsupported_comparison_type",path:`${f}.comparisonType`,message:`Unsupported legacy metric comparison type "${g}".`}),i.comparisonType==="target"&&(typeof i.targetValue!="number"||!Number.isFinite(i.targetValue))&&o.push({severity:"error",code:"invalid_target_value",path:`${f}.targetValue`,message:"Legacy target comparison requires a finite metric targetValue."}),i.comparisonType==="start_vs_end"&&o.push({severity:"error",code:"unsupported_start_vs_end",path:`${f}.comparisonType`,message:"start_vs_end is retired and cannot be migrated automatically."}),i.targetValue!==void 0&&i.comparisonType!=="target"&&o.push({severity:"warning",code:"stray_target_value",path:`${f}.targetValue`,message:"Dead non-target targetValue will be removed without changing the baseline."})}),n.hasLegacyPresentation){const{namespaces:i,kpi:u,table:f}=S(n),g=[(c=i.kpiOptions)==null?void 0:c.lowerIsBetter,(d=i.kpiComparison)==null?void 0:d.lowerIsBetter,(a=i.tableComparison)==null?void 0:a.lowerIsBetter].filter(h=>typeof h=="boolean");new Set(g).size>1&&o.push({severity:"error",code:"conflicting_legacy_polarity",path:`${n.path}.preferences`,message:"Legacy comparison polarity values disagree; resolve the conflict before migration."}),((t=i.kpiOptions)==null?void 0:t.lowerIsBetter)!==void 0&&typeof i.kpiOptions.lowerIsBetter!="boolean"&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${n.path}.preferences.kpiVisualOptions.lowerIsBetter`,message:"Legacy comparison lowerIsBetter must be a boolean."}),i.kpiComparisonPresent&&!i.kpiComparison&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${n.path}.preferences.kpiVisualOptions.metricComparison`,message:"Legacy KPI comparison presentation must be an object."}),i.tableComparisonPresent&&!i.tableComparison&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${n.path}.preferences.tableVisualOptions.metricComparison`,message:"Legacy table comparison presentation must be an object."}),"comparisonPresentation"in(i.preferences||{})&&o.push({severity:"error",code:"conflicting_comparison_presentation_contracts",path:`${n.path}.preferences.comparisonPresentation`,message:"Card contains both legacy and canonical comparison presentation; resolve the conflict before migration."}),i.kpiComparison&&typeof i.kpiComparison.enabled=="boolean"&&"metricPairComparisonEnabled"in(i.preferences||{})&&v(n)&&o.push({severity:"error",code:"conflicting_comparison_presentation_contracts",path:`${n.path}.preferences.metricPairComparisonEnabled`,message:"Card contains both legacy and canonical metric-pair enablement; resolve the conflict before migration."}),i.kpiComparison&&P(i.kpiComparison,"kpi",`${n.path}.preferences.kpiVisualOptions.metricComparison`,o),i.tableComparison&&P(i.tableComparison,"table",`${n.path}.preferences.tableVisualOptions.metricComparison`,o),u&&f&&JSON.stringify(w(u))!==JSON.stringify(w(f))&&o.push({severity:"error",code:"conflicting_legacy_presentation_namespaces",path:`${n.path}.preferences`,message:"KPI and table comparison presentation values disagree; resolve the conflict before migration."})}}),o.some(n=>n.severity==="error"))return{document:e,changed:!1,changes:[],diagnostics:o};const s=JSON.parse(JSON.stringify(e)),p=O(s),m=[];return p.forEach(n=>{var d;const c=B(n.card);if(n.metrics.forEach(({metric:a,index:t})=>{if(!("comparisonType"in a))return;const i=String(a.comparisonType||""),u=`${n.path}.config.metricColumns[${t}]`,f=D(a),g=["comparisonType"];delete a.comparisonType,"targetValue"in a&&(delete a.targetValue,g.push("targetValue")),"comparisonDisplay"in a&&(delete a.comparisonDisplay,g.push("comparisonDisplay")),f?a.comparison=f:delete a.comparison,_.has(i)&&(a.comparisonPolarity=c),m.push({kind:"metric",path:u,metricId:typeof a.id=="string"?a.id:void 0,legacyType:i,comparison:f,comparisonPolarity:_.has(i)?c:void 0,removedFields:g})}),M(n.card),n.hasLegacyPresentation){const{namespaces:a,presentation:t}=S(n),i=(d=a.kpiComparison)==null?void 0:d.enabled,u={...t};typeof i=="boolean"&&A(n.metrics)&&(u.showComparison=i);const f=typeof i=="boolean"&&v(n)?i:void 0,g=typeof i=="boolean"&&!A(n.metrics)&&!v(n)?["kpiVisualOptions.metricComparison.enabled"]:void 0,h=a.preferences,b=[];n.metrics.forEach(({metric:y})=>{"comparisonPolarity"in y||(y.comparisonPolarity=c,typeof y.id=="string"&&b.push(y.id))}),Object.keys(u).length&&(h.comparisonPresentation=u),f!==void 0&&(h.metricPairComparisonEnabled=f),a.kpiOptions&&delete a.kpiOptions.metricComparison,a.tableOptions&&delete a.tableOptions.metricComparison,m.push({kind:"presentation",path:`${n.path}.preferences`,comparisonPresentation:Object.keys(u).length?u:void 0,metricPairComparisonEnabled:f,comparisonPolarityMetricIds:b,intentionallyDiscardedFields:g,removedFields:[...a.kpiComparison?["kpiVisualOptions.metricComparison"]:[],...a.tableComparison?["tableVisualOptions.metricComparison"]:[]]})}}),{document:s,changed:!0,changes:m,diagnostics:o}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=I;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=V;exports.transformComparisonDocument=R;
1
+ "use strict";require("./analyze-result-contract-BswhsmWT.js");const L=require("./metric-comparison-DVy3fll_.js"),I=["lg","md","sm","xs","xxs"],V=15,_=new Set(["previous_period","same_period_last_year","start_vs_end","target"]),k=new Set([..._,"none",""]);function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function E(e){const r=l(e.preferences)?e.preferences:void 0,o=r&&l(r.kpiVisualOptions)?r.kpiVisualOptions:void 0,s=r&&l(r.tableVisualOptions)?r.tableVisualOptions:void 0;return{preferences:r,kpiOptions:o,kpiComparison:o&&l(o.metricComparison)?o.metricComparison:void 0,kpiComparisonPresent:!!o&&"metricComparison"in o,tableOptions:s,tableComparison:s&&l(s.metricComparison)?s.metricComparison:void 0,tableComparisonPresent:!!s&&"metricComparison"in s}}function O(e){const r=[],o=(s,p)=>{if(Array.isArray(s)){s.forEach((n,c)=>o(n,`${p}[${c}]`));return}if(!l(s))return;const m=s.config;if(l(m)){const n=E(s),c=!!(n.kpiComparisonPresent||n.tableComparisonPresent),d=m.metricColumns,a=Array.isArray(d)?d.flatMap((t,i)=>l(t)?[{index:i,metric:t}]:[]):[];if((a.some(({metric:t})=>"comparisonType"in t)||c)&&r.push({path:p,card:s,metrics:a,malformedMetricIndexes:Array.isArray(d)?d.flatMap((t,i)=>l(t)?[]:[i]):[],malformedMetricColumns:"metricColumns"in m&&!Array.isArray(d),hasLegacyPresentation:c}),"metricColumns"in m||c)return}Object.entries(s).forEach(([n,c])=>o(c,p?`${p}.${n}`:n))};return o(e,"$"),r}const T={difference:"difference",change:"percent_change",change_difference:"both",ratio:"ratio"};function $(e,r){if(!e)return;const o=Object.fromEntries(r.flatMap(s=>typeof e[s]=="string"?[[s,e[s]]]:[]));return Object.keys(o).length?o:void 0}function N(e,r,o){if(e!==void 0){if(!l(e)){o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:r,message:"Legacy comparison formatOptions must be an object."});return}Object.entries(e).forEach(([s,p])=>{if(s==="decimalPlaces"){(typeof p!="number"||!Number.isInteger(p)||p<0||p>6)&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${r}.decimalPlaces`,message:"Legacy comparison decimalPlaces must be an integer from 0 through 6."});return}s==="type"&&(p===void 0||p==="auto")||p!==void 0&&o.push({severity:"error",code:"unsupported_comparison_format",path:`${r}.${s}`,message:`Legacy comparison format option "${s}" has no canonical presentation mapping.`})})}}function C(e,r){const o=r==="kpi"?e.calculationType:e.calculatedAs,s=r==="table"&&o===void 0?"both":T[String(o)],p=l(e.formatOptions)?e.formatOptions:void 0,m=l(e.conditionalLabels)?e.conditionalLabels:void 0,n=l(r==="kpi"?e.colorConfig:e.colors)?r==="kpi"?e.colorConfig:e.colors:void 0,c={};if(s&&(c.displayMode=s),typeof(p==null?void 0:p.decimalPlaces)=="number"&&(c.precision=p.decimalPlaces),r==="kpi"){const t=e.showArrow!==!1,i=e.showColor!==!1;c.indicatorStyle=t?i?"arrow_badge":"arrow":i?"badge":"none",c.showColor=i,(e.position==="left"||e.position==="right"||e.position==="top")&&(c.position=e.position),typeof e.conditionalLabel=="boolean"&&(c.conditionalLabel=e.conditionalLabel),typeof e.labelName=="string"&&(c.labelName=e.labelName)}else(e.indicatorStyle==="arrow_badge"||e.indicatorStyle==="arrow"||e.indicatorStyle==="badge"||e.indicatorStyle==="none")&&(c.indicatorStyle=e.indicatorStyle);const d=m?{...$(m,["increase","decrease"]),...typeof m.noChange=="string"?{neutral:m.noChange}:typeof m.neutral=="string"?{neutral:m.neutral}:{}}:void 0;d&&Object.keys(d).length&&(c.conditionalLabels=d);const a=n?{...$(n,["increase","decrease"]),...typeof n.noChange=="string"?{neutral:n.noChange}:typeof n.neutral=="string"?{neutral:n.neutral}:{}}:void 0;return a&&Object.keys(a).length&&(c.colors=a),c}function w(e){return{...L.COMPARISON_PRESENTATION_DEFAULTS,...e}}function A(e){return e.some(({metric:r})=>r.comparisonType==="previous_period"||r.comparisonType==="same_period_last_year"||r.comparisonType==="target"?!0:l(r.comparison)&&r.comparison.mode==="explicit")}function v(e){const r=e.card.config;return e.metrics.length===2&&(r.groupByColumns===void 0||Array.isArray(r.groupByColumns)&&r.groupByColumns.length===0)}function P(e,r,o,s){const p=r==="kpi"?["enabled","calculationType","formatOptions","showArrow","showColor","conditionalLabel","labelName","position","conditionalLabels","colorConfig","lowerIsBetter"]:["calculatedAs","indicatorStyle","formatOptions","colors","lowerIsBetter"];Object.keys(e).forEach(t=>{p.includes(t)||s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}`,message:`Unknown legacy comparison presentation field "${t}" cannot be dropped automatically.`})});const m=r==="kpi"?"calculationType":"calculatedAs";e[m]!==void 0&&!T[String(e[m])]&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${m}`,message:`Legacy comparison ${m} is unsupported.`}),r==="kpi"&&e.position!==void 0&&!["left","right","top"].includes(String(e.position))&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.position`,message:"Legacy comparison position is unsupported."}),r==="kpi"&&e.labelName!==void 0&&typeof e.labelName!="string"&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.labelName`,message:"Legacy comparison labelName must be a string."}),(r==="kpi"?[["conditionalLabels",["increase","decrease","noChange"]],["colorConfig",["increase","decrease","noChange"]]]:[["colors",["increase","decrease","neutral"]]]).forEach(([t,i])=>{if(e[t]!==void 0){if(!l(e[t])){s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}`,message:`Legacy comparison ${t} must be an object.`});return}Object.entries(e[t]).forEach(([u,f])=>{i.includes(u)?typeof f!="string"&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}.${u}`,message:`Legacy comparison ${t}.${u} must be a string.`}):s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}.${u}`,message:`Unknown legacy comparison ${t} field "${u}" cannot be dropped automatically.`})})}}),(r==="kpi"?["enabled","showArrow","showColor","conditionalLabel","lowerIsBetter"]:["lowerIsBetter"]).forEach(t=>{e[t]!==void 0&&typeof e[t]!="boolean"&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}`,message:`Legacy comparison ${t} must be a boolean.`})}),r==="table"&&e.indicatorStyle!==void 0&&!["arrow_badge","arrow","badge","none"].includes(String(e.indicatorStyle))&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.indicatorStyle`,message:"Legacy comparison indicatorStyle is unsupported."}),N(e.formatOptions,`${o}.formatOptions`,s);const d=C(e,r);L.validateComparisonPresentationSpec(d,o).errors.forEach(t=>{s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:t.path||o,message:t.message})})}function S(e){const r=E(e.card),o=r.kpiComparison?C(r.kpiComparison,"kpi"):void 0,s=r.tableComparison?C(r.tableComparison,"table"):void 0;return{namespaces:r,kpi:o,table:s,presentation:o||s}}function B(e){const r=l(e.preferences)?e.preferences:{},o=l(r.kpiVisualOptions)?r.kpiVisualOptions:{},s=l(o.metricComparison)?o.metricComparison:{},p=l(r.tableVisualOptions)?r.tableVisualOptions:{},m=l(p.metricComparison)?p.metricComparison:{};return o.lowerIsBetter===!0||s.lowerIsBetter===!0||m.lowerIsBetter===!0?"lower_is_better":"higher_is_better"}function D(e){switch(e.comparisonType){case"previous_period":return{mode:"explicit",spec:{kind:"previous_period"}};case"same_period_last_year":return{mode:"explicit",spec:{kind:"previous_year"}};case"target":return{mode:"explicit",spec:{kind:"target",targetValue:e.targetValue}};default:return}}function M(e){const r=l(e.preferences)?e.preferences:void 0;if(!r)return;const o=l(r.kpiVisualOptions)?r.kpiVisualOptions:void 0;o&&delete o.lowerIsBetter;const s=l(r.tableVisualOptions)?r.tableVisualOptions:void 0,p=s&&l(s.metricComparison)?s.metricComparison:void 0;p&&delete p.lowerIsBetter}function R(e){const r=O(e);if(!r.length)return{document:e,changed:!1,changes:[],diagnostics:[]};const o=[];if(r.forEach(n=>{var c,d,a,t;if(n.malformedMetricColumns&&o.push({severity:"error",code:"malformed_metric_columns",path:`${n.path}.config.metricColumns`,message:"Metric columns must be an array before comparison migration."}),n.malformedMetricIndexes.forEach(i=>{o.push({severity:"error",code:"malformed_metric_columns",path:`${n.path}.config.metricColumns[${i}]`,message:"Metric columns must contain objects before comparison migration."})}),n.metrics.forEach(({metric:i,index:u})=>{if(!("comparisonType"in i))return;const f=`${n.path}.config.metricColumns[${u}]`,g=String(i.comparisonType||"");"comparison"in i&&o.push({severity:"error",code:"conflicting_comparison_contracts",path:f,message:"Metric contains both legacy and canonical comparison configuration; resolve the conflict before migration."});const h=l(i.parameters)?i.parameters:void 0,b=h&&l(h.windowTransform)?h.windowTransform:void 0;_.has(g)&&(b==null?void 0:b.function)==="previous_period_delta"&&o.push({severity:"error",code:"conflicting_comparison_window_transform",path:f,message:"A metric cannot combine baseline comparison with previous_period_delta; resolve the authoring intent before migration."}),k.has(g)||o.push({severity:"error",code:"unsupported_comparison_type",path:`${f}.comparisonType`,message:`Unsupported legacy metric comparison type "${g}".`}),i.comparisonType==="target"&&(typeof i.targetValue!="number"||!Number.isFinite(i.targetValue))&&o.push({severity:"error",code:"invalid_target_value",path:`${f}.targetValue`,message:"Legacy target comparison requires a finite metric targetValue."}),i.comparisonType==="start_vs_end"&&o.push({severity:"error",code:"unsupported_start_vs_end",path:`${f}.comparisonType`,message:"start_vs_end is retired and cannot be migrated automatically."}),i.targetValue!==void 0&&i.comparisonType!=="target"&&o.push({severity:"warning",code:"stray_target_value",path:`${f}.targetValue`,message:"Dead non-target targetValue will be removed without changing the baseline."})}),n.hasLegacyPresentation){const{namespaces:i,kpi:u,table:f}=S(n),g=[(c=i.kpiOptions)==null?void 0:c.lowerIsBetter,(d=i.kpiComparison)==null?void 0:d.lowerIsBetter,(a=i.tableComparison)==null?void 0:a.lowerIsBetter].filter(h=>typeof h=="boolean");new Set(g).size>1&&o.push({severity:"error",code:"conflicting_legacy_polarity",path:`${n.path}.preferences`,message:"Legacy comparison polarity values disagree; resolve the conflict before migration."}),((t=i.kpiOptions)==null?void 0:t.lowerIsBetter)!==void 0&&typeof i.kpiOptions.lowerIsBetter!="boolean"&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${n.path}.preferences.kpiVisualOptions.lowerIsBetter`,message:"Legacy comparison lowerIsBetter must be a boolean."}),i.kpiComparisonPresent&&!i.kpiComparison&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${n.path}.preferences.kpiVisualOptions.metricComparison`,message:"Legacy KPI comparison presentation must be an object."}),i.tableComparisonPresent&&!i.tableComparison&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${n.path}.preferences.tableVisualOptions.metricComparison`,message:"Legacy table comparison presentation must be an object."}),"comparisonPresentation"in(i.preferences||{})&&o.push({severity:"error",code:"conflicting_comparison_presentation_contracts",path:`${n.path}.preferences.comparisonPresentation`,message:"Card contains both legacy and canonical comparison presentation; resolve the conflict before migration."}),i.kpiComparison&&typeof i.kpiComparison.enabled=="boolean"&&"metricPairComparisonEnabled"in(i.preferences||{})&&v(n)&&o.push({severity:"error",code:"conflicting_comparison_presentation_contracts",path:`${n.path}.preferences.metricPairComparisonEnabled`,message:"Card contains both legacy and canonical metric-pair enablement; resolve the conflict before migration."}),i.kpiComparison&&P(i.kpiComparison,"kpi",`${n.path}.preferences.kpiVisualOptions.metricComparison`,o),i.tableComparison&&P(i.tableComparison,"table",`${n.path}.preferences.tableVisualOptions.metricComparison`,o),u&&f&&JSON.stringify(w(u))!==JSON.stringify(w(f))&&o.push({severity:"error",code:"conflicting_legacy_presentation_namespaces",path:`${n.path}.preferences`,message:"KPI and table comparison presentation values disagree; resolve the conflict before migration."})}}),o.some(n=>n.severity==="error"))return{document:e,changed:!1,changes:[],diagnostics:o};const s=JSON.parse(JSON.stringify(e)),p=O(s),m=[];return p.forEach(n=>{var d;const c=B(n.card);if(n.metrics.forEach(({metric:a,index:t})=>{if(!("comparisonType"in a))return;const i=String(a.comparisonType||""),u=`${n.path}.config.metricColumns[${t}]`,f=D(a),g=["comparisonType"];delete a.comparisonType,"targetValue"in a&&(delete a.targetValue,g.push("targetValue")),"comparisonDisplay"in a&&(delete a.comparisonDisplay,g.push("comparisonDisplay")),f?a.comparison=f:delete a.comparison,_.has(i)&&(a.comparisonPolarity=c),m.push({kind:"metric",path:u,metricId:typeof a.id=="string"?a.id:void 0,legacyType:i,comparison:f,comparisonPolarity:_.has(i)?c:void 0,removedFields:g})}),M(n.card),n.hasLegacyPresentation){const{namespaces:a,presentation:t}=S(n),i=(d=a.kpiComparison)==null?void 0:d.enabled,u={...t};typeof i=="boolean"&&A(n.metrics)&&(u.showComparison=i);const f=typeof i=="boolean"&&v(n)?i:void 0,g=typeof i=="boolean"&&!A(n.metrics)&&!v(n)?["kpiVisualOptions.metricComparison.enabled"]:void 0,h=a.preferences,b=[];n.metrics.forEach(({metric:y})=>{"comparisonPolarity"in y||(y.comparisonPolarity=c,typeof y.id=="string"&&b.push(y.id))}),Object.keys(u).length&&(h.comparisonPresentation=u),f!==void 0&&(h.metricPairComparisonEnabled=f),a.kpiOptions&&delete a.kpiOptions.metricComparison,a.tableOptions&&delete a.tableOptions.metricComparison,m.push({kind:"presentation",path:`${n.path}.preferences`,comparisonPresentation:Object.keys(u).length?u:void 0,metricPairComparisonEnabled:f,comparisonPolarityMetricIds:b,intentionallyDiscardedFields:g,removedFields:[...a.kpiComparison?["kpiVisualOptions.metricComparison"]:[],...a.tableComparison?["tableVisualOptions.metricComparison"]:[]]})}}),{document:s,changed:!0,changes:m,diagnostics:o}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=I;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=V;exports.transformComparisonDocument=R;
@@ -1,5 +1,5 @@
1
- import "./analyze-result-contract-DnfF8kBb.js";
2
- import { v as V, C as T } from "./metric-comparison-CWweq9RG.js";
1
+ import "./analyze-result-contract-CfOBEwaC.js";
2
+ import { v as V, C as T } from "./metric-comparison-CPoDx56y.js";
3
3
  const x = [
4
4
  "lg",
5
5
  "md",
@@ -0,0 +1,4 @@
1
+ "use strict";const M=require("./numeric-presentation-Dlb-Dk4c.js"),a=require("./index-D7KJindZ.js");function g(e,t){const n=a.toDate(e),i=a.toDate(t),r=n.getTime()-i.getTime();return r<0?-1:r>0?1:r}function L(e){return a.constructFrom(e,Date.now())}function V(e,t){const n=a.toDate(e),i=a.toDate(t),r=n.getFullYear()-i.getFullYear(),o=n.getMonth()-i.getMonth();return r*12+o}function Z(e){return t=>{const i=(e?Math[e]:Math.trunc)(t);return i===0?0:i}}function P(e,t){return+a.toDate(e)-+a.toDate(t)}function _(e){const t=a.toDate(e);return t.setHours(23,59,59,999),t}function R(e){const t=a.toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function A(e){const t=a.toDate(e);return+_(t)==+R(t)}function E(e,t){const n=a.toDate(e),i=a.toDate(t),r=g(n,i),o=Math.abs(V(n,i));let c;if(o<1)c=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*o);let s=g(n,i)===-r;A(a.toDate(e))&&o===1&&g(e,i)===1&&(s=!1),c=r*(o-Number(s))}return c===0?0:c}function X(e,t,n){const i=P(e,t)/1e3;return Z(n==null?void 0:n.roundingMethod)(i)}function j(e,t,n){const i=a.getDefaultOptions(),r=(n==null?void 0:n.locale)??i.locale??a.enUS,o=2520,c=g(e,t);if(isNaN(c))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:c});let u,f;c>0?(u=a.toDate(t),f=a.toDate(e)):(u=a.toDate(e),f=a.toDate(t));const m=X(f,u),D=(a.getTimezoneOffsetInMilliseconds(f)-a.getTimezoneOffsetInMilliseconds(u))/1e3,l=Math.round((m-D)/60);let h;if(l<2)return n!=null&&n.includeSeconds?m<5?r.formatDistance("lessThanXSeconds",5,s):m<10?r.formatDistance("lessThanXSeconds",10,s):m<20?r.formatDistance("lessThanXSeconds",20,s):m<40?r.formatDistance("halfAMinute",0,s):m<60?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",1,s):l===0?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",l,s);if(l<45)return r.formatDistance("xMinutes",l,s);if(l<90)return r.formatDistance("aboutXHours",1,s);if(l<a.minutesInDay){const d=Math.round(l/60);return r.formatDistance("aboutXHours",d,s)}else{if(l<o)return r.formatDistance("xDays",1,s);if(l<a.minutesInMonth){const d=Math.round(l/a.minutesInDay);return r.formatDistance("xDays",d,s)}else if(l<a.minutesInMonth*2)return h=Math.round(l/a.minutesInMonth),r.formatDistance("aboutXMonths",h,s)}if(h=E(f,u),h<12){const d=Math.round(l/a.minutesInMonth);return r.formatDistance("xMonths",d,s)}else{const d=h%12,y=Math.trunc(h/12);return d<3?r.formatDistance("aboutXYears",y,s):d<9?r.formatDistance("overXYears",y,s):r.formatDistance("almostXYears",y+1,s)}}function w(e,t){return j(e,L(e),t)}const S=["day","hour","minute","second","millisecond"],N={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},v={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},Y={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function H(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond"}function C(e,t){return H(e)?e:t}function I(e,t){return S.indexOf(C(e,t))}function W(e,t){const n=I(e,"day"),i=I(t,"second"),r=Math.min(n,i),o=Math.max(n,i);return S.slice(r,o+1)}function k(e,t){return e*N[C(t,"second")]}function q(e,t){const n=W(t.largestUnit,t.smallestUnit),i=n[n.length-1],r=N[i];let o=Math.round(e/r)*r;return n.map(c=>{const s=N[c],u=Math.floor(o/s);return o-=u*s,{unit:c,value:u}})}function B(e,t){const n=e.filter(o=>o.value!==0),i=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):i.length;return i.slice(0,r).map(o=>`${o.value}${v[o.unit]}`).join(" ")}function G(e,t){const n=e.filter(o=>o.value!==0),i=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):i.length;return i.slice(0,r).map(o=>{const[c,s]=Y[o.unit];return`${o.value} ${o.value===1?c:s}`}).join(" ")}function J(e){const t=e.some(u=>u.unit==="day"&&u.value!==0),n=e.some(u=>u.unit==="millisecond"),i=e.findIndex(u=>u.value!==0),r=Math.max(0,e.length-2),o=t?0:i===-1?r:Math.min(i,r),c=i===-1?e.slice(r):e.slice(o);if(c.length===0)return"0";const s=c.map((u,f)=>u.unit==="millisecond"?String(u.value).padStart(3,"0"):f===0?String(u.value):String(u.value).padStart(2,"0")).join(":");return n?s.replace(/:(\d{3})$/,".$1"):s}function K(e,t,n){const i=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${i})`:`-${i}`:i}function F(e,t={}){if(e==null)return"";const n=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):NaN;if(!Number.isFinite(n))return"";const i=t.inputUnit||"second",r=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",o=n<0,c=Math.abs(k(n,i)),s=q(c,t),u=r==="digital"?J(s):r==="long"?G(s,t.maxUnits):B(s,t.maxUnits);return K(u,o,t)}function Q(e,t,n){const i={...t,locale:t.locale??n};if(i.type==="number")return M.formatNumericCanonical(e,i);const{prefix:r,suffix:o,...c}=i;return`${r??""}${M.formatNumericCanonical(e,{...c,negativeStyle:i.type==="currency"?i.negativeStyle:"minus"})}${o??""}`}function x(e,t,n){return e===null?{value:e,text:null}:!t||t.type==="date"||t.type==="string"?{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n})}:t.type==="duration"?{value:e,text:F(e,{inputUnit:t.inputUnit,outputStyle:t.outputStyle,largestUnit:t.largestUnit,smallestUnit:t.smallestUnit,maxUnits:t.maxUnits,prefix:t.prefix,suffix:t.suffix,negativeInParentheses:t.negativeStyle==="parentheses"})}:{value:e,text:Q(e,t,n)}}function b(e,t,n,i){return e===null?{value:e,text:null}:i==="percent"?{value:e,text:M.formatNumericCanonical(e,{type:"percent",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,percentValueMode:"fraction"})}:{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,suffix:"×"})}}function p(e,t){if(e===void 0)return t;if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("Comparison precision must be an integer from 0 to 6.");return e}function z(e,t){const n={mode:t.displayMode,current:x(e.currentValue,t.metricFormat,t.locale),comparison:x(e.comparisonValue,t.metricFormat,t.locale)};return(t.displayMode==="difference"||t.displayMode==="both")&&(n.difference=x(e.delta,t.metricFormat,t.locale)),(t.displayMode==="percent_change"||t.displayMode==="both")&&(n.percentChange=b(e.percentChange,p(t.precision,1),t.locale,"percent")),t.displayMode==="ratio"&&(n.ratio=b(e.ratio,p(t.precision,2),t.locale,"ratio")),n}function ee(e,t){return e&&e!=="auto"?e:t}function te(e,t=new Date){try{const n={timeZone:e,timeZoneName:"short"},r=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(o=>o.type==="timeZoneName");return(r==null?void 0:r.value)||e}catch{return e}}function ne(e){try{const t={timeZone:e,timeZoneName:"long"},i=new Intl.DateTimeFormat("en-US",t).formatToParts(new Date).find(r=>r.type==="timeZoneName");return(i==null?void 0:i.value)||e}catch{return e}}function T(e,t="auto"){if(!e)return new Date(NaN);const n=e.endsWith("Z"),i=/[+-]\d{2}:?\d{2}$/.test(e),r=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||i||r?new Date(e):new Date(e+"Z");if(t==="local"){if(n||i){const o=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(o)}return new Date(e)}else return t==="UTC"?n?new Date(e):i?new Date(e):new Date(e+"Z"):n||i||r?new Date(e):a.fromZonedTime(e,t)}const re="MM/dd/yyyy",ie=(e,t,n,i="auto")=>{if(!e)return"";try{const r=T(e,i);if(isNaN(r.getTime()))return e;const c=(t&&t.trim()?t:re).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?a.formatInTimeZone(r,n,c):a.format(r,c)}catch(r){return console.error("Date formatting error:",r),e}},oe=(e,t="auto")=>{if(!e)return"";try{const n=T(e,t);return isNaN(n.getTime())?e:w(n,{addSuffix:!0})}catch(n){return console.error("Relative time formatting error:",n),e}};function U(e,t=","){if(e==null)return"";const n=String(e);return n.includes(t)||n.includes('"')||n.includes(`
2
+ `)||n.includes("\r")?`"${n.replace(/"/g,'""')}"`:n}function O(e,t=","){return e.map(n=>U(n,t)).join(t)}function $(e,t={}){const{delimiter:n=",",lineEnding:i=`
3
+ `}=t;return e.map(r=>O(r,n)).join(i)}function se(e,t={}){if(e.length===0)return"";const{delimiter:n=",",lineEnding:i=`
4
+ `,includeHeaders:r=!0,columns:o}=t,c=o||Object.keys(e[0]),s=[];r&&s.push(c);for(const u of e){const f=c.map(m=>{const D=u[m];return D==null?"":String(D)});s.push(f)}return $(s,{delimiter:n,lineEnding:i})}exports.arrayToCSV=$;exports.arrayToCSVRow=O;exports.escapeCSVValue=U;exports.formatDate=ie;exports.formatDistanceToNow=w;exports.formatDuration=F;exports.formatMetricComparison=z;exports.formatRelativeTime=oe;exports.getTimezoneAbbreviation=te;exports.getTimezoneName=ne;exports.objectsToCSV=se;exports.parseWithSourceTimezone=T;exports.resolveTimezone=ee;
@@ -0,0 +1,376 @@
1
+ import { d as M } from "./numeric-presentation-CGTcqocU.js";
2
+ import { t as u, c as L, e as O, g as p, m as T, a as D, b as Z, f as _, d as C, h as P } from "./index-CnujJ3fa.js";
3
+ function y(e, t) {
4
+ const n = u(e), s = u(t), r = n.getTime() - s.getTime();
5
+ return r < 0 ? -1 : r > 0 ? 1 : r;
6
+ }
7
+ function R(e) {
8
+ return L(e, Date.now());
9
+ }
10
+ function A(e, t) {
11
+ const n = u(e), s = u(t), r = n.getFullYear() - s.getFullYear(), i = n.getMonth() - s.getMonth();
12
+ return r * 12 + i;
13
+ }
14
+ function V(e) {
15
+ return (t) => {
16
+ const s = (e ? Math[e] : Math.trunc)(t);
17
+ return s === 0 ? 0 : s;
18
+ };
19
+ }
20
+ function E(e, t) {
21
+ return +u(e) - +u(t);
22
+ }
23
+ function X(e) {
24
+ const t = u(e);
25
+ return t.setHours(23, 59, 59, 999), t;
26
+ }
27
+ function j(e) {
28
+ const t = u(e), n = t.getMonth();
29
+ return t.setFullYear(t.getFullYear(), n + 1, 0), t.setHours(23, 59, 59, 999), t;
30
+ }
31
+ function Y(e) {
32
+ const t = u(e);
33
+ return +X(t) == +j(t);
34
+ }
35
+ function v(e, t) {
36
+ const n = u(e), s = u(t), r = y(n, s), i = Math.abs(
37
+ A(n, s)
38
+ );
39
+ let a;
40
+ if (i < 1)
41
+ a = 0;
42
+ else {
43
+ n.getMonth() === 1 && n.getDate() > 27 && n.setDate(30), n.setMonth(n.getMonth() - r * i);
44
+ let o = y(n, s) === -r;
45
+ Y(u(e)) && i === 1 && y(e, s) === 1 && (o = !1), a = r * (i - Number(o));
46
+ }
47
+ return a === 0 ? 0 : a;
48
+ }
49
+ function H(e, t, n) {
50
+ const s = E(e, t) / 1e3;
51
+ return V(n == null ? void 0 : n.roundingMethod)(s);
52
+ }
53
+ function k(e, t, n) {
54
+ const s = Z(), r = (n == null ? void 0 : n.locale) ?? s.locale ?? O, i = 2520, a = y(e, t);
55
+ if (isNaN(a))
56
+ throw new RangeError("Invalid time value");
57
+ const o = Object.assign({}, n, {
58
+ addSuffix: n == null ? void 0 : n.addSuffix,
59
+ comparison: a
60
+ });
61
+ let c, f;
62
+ a > 0 ? (c = u(t), f = u(e)) : (c = u(e), f = u(t));
63
+ const m = H(f, c), g = (p(f) - p(c)) / 1e3, l = Math.round((m - g) / 60);
64
+ let h;
65
+ if (l < 2)
66
+ return n != null && n.includeSeconds ? m < 5 ? r.formatDistance("lessThanXSeconds", 5, o) : m < 10 ? r.formatDistance("lessThanXSeconds", 10, o) : m < 20 ? r.formatDistance("lessThanXSeconds", 20, o) : m < 40 ? r.formatDistance("halfAMinute", 0, o) : m < 60 ? r.formatDistance("lessThanXMinutes", 1, o) : r.formatDistance("xMinutes", 1, o) : l === 0 ? r.formatDistance("lessThanXMinutes", 1, o) : r.formatDistance("xMinutes", l, o);
67
+ if (l < 45)
68
+ return r.formatDistance("xMinutes", l, o);
69
+ if (l < 90)
70
+ return r.formatDistance("aboutXHours", 1, o);
71
+ if (l < T) {
72
+ const d = Math.round(l / 60);
73
+ return r.formatDistance("aboutXHours", d, o);
74
+ } else {
75
+ if (l < i)
76
+ return r.formatDistance("xDays", 1, o);
77
+ if (l < D) {
78
+ const d = Math.round(l / T);
79
+ return r.formatDistance("xDays", d, o);
80
+ } else if (l < D * 2)
81
+ return h = Math.round(l / D), r.formatDistance("aboutXMonths", h, o);
82
+ }
83
+ if (h = v(f, c), h < 12) {
84
+ const d = Math.round(l / D);
85
+ return r.formatDistance("xMonths", d, o);
86
+ } else {
87
+ const d = h % 12, x = Math.trunc(h / 12);
88
+ return d < 3 ? r.formatDistance("aboutXYears", x, o) : d < 9 ? r.formatDistance("overXYears", x, o) : r.formatDistance("almostXYears", x + 1, o);
89
+ }
90
+ }
91
+ function B(e, t) {
92
+ return k(e, R(e), t);
93
+ }
94
+ const U = [
95
+ "day",
96
+ "hour",
97
+ "minute",
98
+ "second",
99
+ "millisecond"
100
+ ], b = {
101
+ day: 864e5,
102
+ hour: 36e5,
103
+ minute: 6e4,
104
+ second: 1e3,
105
+ millisecond: 1
106
+ }, W = {
107
+ day: "d",
108
+ hour: "hr",
109
+ minute: "min",
110
+ second: "s",
111
+ millisecond: "ms"
112
+ }, G = {
113
+ day: ["day", "days"],
114
+ hour: ["hour", "hours"],
115
+ minute: ["minute", "minutes"],
116
+ second: ["second", "seconds"],
117
+ millisecond: ["millisecond", "milliseconds"]
118
+ };
119
+ function q(e) {
120
+ return e === "day" || e === "hour" || e === "minute" || e === "second" || e === "millisecond";
121
+ }
122
+ function S(e, t) {
123
+ return q(e) ? e : t;
124
+ }
125
+ function I(e, t) {
126
+ return U.indexOf(S(e, t));
127
+ }
128
+ function J(e, t) {
129
+ const n = I(e, "day"), s = I(t, "second"), r = Math.min(n, s), i = Math.max(n, s);
130
+ return U.slice(r, i + 1);
131
+ }
132
+ function K(e, t) {
133
+ return e * b[S(t, "second")];
134
+ }
135
+ function Q(e, t) {
136
+ const n = J(t.largestUnit, t.smallestUnit), s = n[n.length - 1], r = b[s];
137
+ let i = Math.round(e / r) * r;
138
+ return n.map((a) => {
139
+ const o = b[a], c = Math.floor(i / o);
140
+ return i -= c * o, { unit: a, value: c };
141
+ });
142
+ }
143
+ function z(e, t) {
144
+ const n = e.filter((i) => i.value !== 0), s = n.length > 0 ? n : [e[e.length - 1]], r = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : s.length;
145
+ return s.slice(0, r).map((i) => `${i.value}${W[i.unit]}`).join(" ");
146
+ }
147
+ function ee(e, t) {
148
+ const n = e.filter((i) => i.value !== 0), s = n.length > 0 ? n : [e[e.length - 1]], r = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : s.length;
149
+ return s.slice(0, r).map((i) => {
150
+ const [a, o] = G[i.unit];
151
+ return `${i.value} ${i.value === 1 ? a : o}`;
152
+ }).join(" ");
153
+ }
154
+ function te(e) {
155
+ const t = e.some(
156
+ (c) => c.unit === "day" && c.value !== 0
157
+ ), n = e.some((c) => c.unit === "millisecond"), s = e.findIndex((c) => c.value !== 0), r = Math.max(0, e.length - 2), i = t ? 0 : s === -1 ? r : Math.min(s, r), a = s === -1 ? e.slice(r) : e.slice(i);
158
+ if (a.length === 0)
159
+ return "0";
160
+ const o = a.map((c, f) => c.unit === "millisecond" ? String(c.value).padStart(3, "0") : f === 0 ? String(c.value) : String(c.value).padStart(2, "0")).join(":");
161
+ return n ? o.replace(/:(\d{3})$/, ".$1") : o;
162
+ }
163
+ function ne(e, t, n) {
164
+ const s = `${n.prefix || ""}${e}${n.suffix || ""}`;
165
+ return t ? n.negativeInParentheses ? `(${s})` : `-${s}` : s;
166
+ }
167
+ function re(e, t = {}) {
168
+ if (e == null)
169
+ return "";
170
+ const n = typeof e == "number" ? e : typeof e == "string" && e.trim() ? Number(e) : NaN;
171
+ if (!Number.isFinite(n))
172
+ return "";
173
+ const s = t.inputUnit || "second", r = t.outputStyle === "digital" || t.outputStyle === "long" ? t.outputStyle : "compact", i = n < 0, a = Math.abs(K(n, s)), o = Q(a, t), c = r === "digital" ? te(o) : r === "long" ? ee(o, t.maxUnits) : z(o, t.maxUnits);
174
+ return ne(c, i, t);
175
+ }
176
+ function se(e, t, n) {
177
+ const s = {
178
+ ...t,
179
+ locale: t.locale ?? n
180
+ };
181
+ if (s.type === "number")
182
+ return M(e, s);
183
+ const { prefix: r, suffix: i, ...a } = s;
184
+ return `${r ?? ""}${M(e, {
185
+ ...a,
186
+ negativeStyle: s.type === "currency" ? s.negativeStyle : "minus"
187
+ })}${i ?? ""}`;
188
+ }
189
+ function N(e, t, n) {
190
+ return e === null ? { value: e, text: null } : !t || t.type === "date" || t.type === "string" ? {
191
+ value: e,
192
+ text: M(e, { type: "number", locale: n })
193
+ } : t.type === "duration" ? {
194
+ value: e,
195
+ text: re(e, {
196
+ inputUnit: t.inputUnit,
197
+ outputStyle: t.outputStyle,
198
+ largestUnit: t.largestUnit,
199
+ smallestUnit: t.smallestUnit,
200
+ maxUnits: t.maxUnits,
201
+ prefix: t.prefix,
202
+ suffix: t.suffix,
203
+ negativeInParentheses: t.negativeStyle === "parentheses"
204
+ })
205
+ } : { value: e, text: se(e, t, n) };
206
+ }
207
+ function w(e, t, n, s) {
208
+ return e === null ? { value: e, text: null } : s === "percent" ? {
209
+ value: e,
210
+ text: M(e, {
211
+ type: "percent",
212
+ locale: n,
213
+ minimumFractionDigits: t,
214
+ maximumFractionDigits: t,
215
+ percentValueMode: "fraction"
216
+ })
217
+ } : {
218
+ value: e,
219
+ text: M(e, {
220
+ type: "number",
221
+ locale: n,
222
+ minimumFractionDigits: t,
223
+ maximumFractionDigits: t,
224
+ suffix: "×"
225
+ })
226
+ };
227
+ }
228
+ function F(e, t) {
229
+ if (e === void 0) return t;
230
+ if (!Number.isInteger(e) || e < 0 || e > 6)
231
+ throw new RangeError("Comparison precision must be an integer from 0 to 6.");
232
+ return e;
233
+ }
234
+ function fe(e, t) {
235
+ const n = {
236
+ mode: t.displayMode,
237
+ current: N(
238
+ e.currentValue,
239
+ t.metricFormat,
240
+ t.locale
241
+ ),
242
+ comparison: N(
243
+ e.comparisonValue,
244
+ t.metricFormat,
245
+ t.locale
246
+ )
247
+ };
248
+ return (t.displayMode === "difference" || t.displayMode === "both") && (n.difference = N(
249
+ e.delta,
250
+ t.metricFormat,
251
+ t.locale
252
+ )), (t.displayMode === "percent_change" || t.displayMode === "both") && (n.percentChange = w(
253
+ e.percentChange,
254
+ F(t.precision, 1),
255
+ t.locale,
256
+ "percent"
257
+ )), t.displayMode === "ratio" && (n.ratio = w(
258
+ e.ratio,
259
+ F(t.precision, 2),
260
+ t.locale,
261
+ "ratio"
262
+ )), n;
263
+ }
264
+ function me(e, t) {
265
+ return e && e !== "auto" ? e : t;
266
+ }
267
+ function de(e, t = /* @__PURE__ */ new Date()) {
268
+ try {
269
+ const n = {
270
+ timeZone: e,
271
+ timeZoneName: "short"
272
+ }, r = new Intl.DateTimeFormat("en-US", n).formatToParts(t).find((i) => i.type === "timeZoneName");
273
+ return (r == null ? void 0 : r.value) || e;
274
+ } catch {
275
+ return e;
276
+ }
277
+ }
278
+ function he(e) {
279
+ try {
280
+ const t = {
281
+ timeZone: e,
282
+ timeZoneName: "long"
283
+ }, s = new Intl.DateTimeFormat("en-US", t).formatToParts(
284
+ /* @__PURE__ */ new Date()
285
+ ).find((r) => r.type === "timeZoneName");
286
+ return (s == null ? void 0 : s.value) || e;
287
+ } catch {
288
+ return e;
289
+ }
290
+ }
291
+ function $(e, t = "auto") {
292
+ if (!e)
293
+ return /* @__PURE__ */ new Date(NaN);
294
+ const n = e.endsWith("Z"), s = /[+-]\d{2}:?\d{2}$/.test(e), r = /\([A-Z]{3,4}\)$/.test(e);
295
+ if (t === "auto")
296
+ return n || s || r ? new Date(e) : /* @__PURE__ */ new Date(e + "Z");
297
+ if (t === "local") {
298
+ if (n || s) {
299
+ const i = e.replace(/Z$/, "").replace(/[+-]\d{2}:?\d{2}$/, "");
300
+ return new Date(i);
301
+ }
302
+ return new Date(e);
303
+ } else return t === "UTC" ? n ? new Date(e) : s ? new Date(e) : /* @__PURE__ */ new Date(e + "Z") : n || s || r ? new Date(e) : P(e, t);
304
+ }
305
+ const ie = "MM/dd/yyyy", ge = (e, t, n, s = "auto") => {
306
+ if (!e)
307
+ return "";
308
+ try {
309
+ const r = $(e, s);
310
+ if (isNaN(r.getTime()))
311
+ return e;
312
+ const a = (t && t.trim() ? t : ie).replace(/LLLL/g, "MMMM").replace(/LLL/g, "MMM");
313
+ return n && n !== "auto" ? _(r, n, a) : C(r, a);
314
+ } catch (r) {
315
+ return console.error("Date formatting error:", r), e;
316
+ }
317
+ }, Me = (e, t = "auto") => {
318
+ if (!e)
319
+ return "";
320
+ try {
321
+ const n = $(e, t);
322
+ return isNaN(n.getTime()) ? e : B(n, { addSuffix: !0 });
323
+ } catch (n) {
324
+ return console.error("Relative time formatting error:", n), e;
325
+ }
326
+ };
327
+ function oe(e, t = ",") {
328
+ if (e == null)
329
+ return "";
330
+ const n = String(e);
331
+ return n.includes(t) || n.includes('"') || n.includes(`
332
+ `) || n.includes("\r") ? `"${n.replace(/"/g, '""')}"` : n;
333
+ }
334
+ function ae(e, t = ",") {
335
+ return e.map((n) => oe(n, t)).join(t);
336
+ }
337
+ function ce(e, t = {}) {
338
+ const { delimiter: n = ",", lineEnding: s = `
339
+ ` } = t;
340
+ return e.map((r) => ae(r, n)).join(s);
341
+ }
342
+ function De(e, t = {}) {
343
+ if (e.length === 0)
344
+ return "";
345
+ const {
346
+ delimiter: n = ",",
347
+ lineEnding: s = `
348
+ `,
349
+ includeHeaders: r = !0,
350
+ columns: i
351
+ } = t, a = i || Object.keys(e[0]), o = [];
352
+ r && o.push(a);
353
+ for (const c of e) {
354
+ const f = a.map((m) => {
355
+ const g = c[m];
356
+ return g == null ? "" : String(g);
357
+ });
358
+ o.push(f);
359
+ }
360
+ return ce(o, { delimiter: n, lineEnding: s });
361
+ }
362
+ export {
363
+ ge as a,
364
+ ae as b,
365
+ ce as c,
366
+ re as d,
367
+ oe as e,
368
+ Me as f,
369
+ fe as g,
370
+ de as h,
371
+ he as i,
372
+ B as j,
373
+ De as o,
374
+ $ as p,
375
+ me as r
376
+ };