react-semaphor 0.1.607 → 0.1.608

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 (73) hide show
  1. package/dist/analytics-protocol/index.js +1 -1
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/brand-studio/index.js +1 -1
  4. package/dist/briefings/index.js +1 -1
  5. package/dist/chunks/{appearance-provider-C4lPZcaN.js → appearance-provider-BBYTKSjL.js} +59 -59
  6. package/dist/chunks/{assistant-chat-B7Fngg8U.js → assistant-chat-x3NCrm5n.js} +8 -8
  7. package/dist/chunks/attachment-filter-line-ClTS4GvQ.js +1 -0
  8. package/dist/chunks/{bookmark-impact-DjrrJomS.js → bookmark-impact-xCmo8x3V.js} +1 -1
  9. package/dist/chunks/{bookmark-state-x9hJS83D.js → bookmark-state-BmbBu1th.js} +1 -1
  10. package/dist/chunks/{brand-DgFcvKJI.js → brand-3m_qSMyC.js} +1 -1
  11. package/dist/chunks/card-filter-builder-CM3SZ4kO.js +11 -0
  12. package/dist/chunks/{visual-contract-DQPKg5QW.js → check-input-C7S2sNzB.js} +13 -5
  13. package/dist/chunks/{comparison-window-caption-zUZDe4tL.js → comparison-window-caption-WzGsqv4n.js} +1 -1
  14. package/dist/chunks/{currency-presentation-binding-w9WDUk3b.js → currency-presentation-binding-s4PlA3Wu.js} +1 -1
  15. package/dist/chunks/{custom-visual-inputs-D8U98aBz.js → custom-visual-inputs-CUtxCe4T.js} +1 -1
  16. package/dist/chunks/custom-visual-write-CH-k-4HE.js +1 -0
  17. package/dist/chunks/{dashboard-BEd6i29E.js → dashboard-BwuurlUI.js} +1 -1
  18. package/dist/chunks/{dashboard-briefing-launcher-DMDYM9IA.js → dashboard-briefing-launcher-CX7mCnPi.js} +14 -9
  19. package/dist/chunks/{dashboard-controls-5B2vCIjJ.js → dashboard-controls-Bwjy9G1i.js} +3 -3
  20. package/dist/chunks/{dashboard-json-C6r30x-5.js → dashboard-json-B9lK28i0.js} +1 -1
  21. package/dist/chunks/{dashboard-temporal-snapshot-Wki-YACw.js → dashboard-temporal-snapshot-CcndP6CF.js} +1 -1
  22. package/dist/chunks/edit-dashboard-visual-BF3mfrWf.js +103 -0
  23. package/dist/chunks/{filter-line-COFQaF4_.js → filter-line-W-qQAjke.js} +1 -1
  24. package/dist/chunks/{filter-reach-preview-BWRGfSmb.js → filter-reach-preview-DSH_k8AJ.js} +1 -1
  25. package/dist/chunks/filter-value-text-DQwYZHz0.js +1 -0
  26. package/dist/chunks/kpi-trend-rule-DDbguInc.js +1 -0
  27. package/dist/chunks/{layout-grid-DahW4ClC.js → layout-grid-Bx0jBVXj.js} +1 -1
  28. package/dist/chunks/{matrix-analytical-definition-Bd-dXB8q.js → matrix-analytical-definition-jn075ooo.js} +1 -1
  29. package/dist/chunks/{matrix-member-presentation-CfvxPV-i.js → matrix-member-presentation-Chz6uGYz.js} +1 -1
  30. package/dist/chunks/{matrix-operation-contract-Cw7U53Ao.js → matrix-operation-contract-DceN49RX.js} +1 -1
  31. package/dist/chunks/{metric-formatting-QDqXfQGY.js → metric-formatting-DILSVxLq.js} +1 -1
  32. package/dist/chunks/{numeric-range-options-s6i_nDXg.js → numeric-range-options-Drc1EZ6H.js} +1 -1
  33. package/dist/chunks/{palette-CYvJHSqP.js → palette-CZJ4ZCY9.js} +1 -1
  34. package/dist/chunks/{pivot-result-contract-expectations-BX5gLcze.js → pivot-result-contract-expectations-D_ane7I2.js} +1 -1
  35. package/dist/chunks/{pivot-result-identity-DOISzHU4.js → pivot-result-identity-DRhVJMsF.js} +1 -1
  36. package/dist/chunks/{raw-temporal-value-Cssny3RJ.js → raw-temporal-value-B4Md6Xfb.js} +1 -1
  37. package/dist/chunks/{report-preferences-dialog-BNpB9byP.js → report-preferences-dialog-EQNoTych.js} +1 -1
  38. package/dist/chunks/{report-runtime-context-B8HuY0bu.js → report-runtime-context-CkxgMKr6.js} +1 -1
  39. package/dist/chunks/{resolve-dashboard-input-context-B-0tONJg.js → resolve-dashboard-input-context-B5yUS9ZM.js} +2 -2
  40. package/dist/chunks/{sandbox-host-Drf58_oU.js → sandbox-host-WJXxpvz7.js} +1 -1
  41. package/dist/chunks/{saved-dashboard-context-dbdbQ5bB.js → saved-dashboard-context-DQlA4Mg0.js} +1 -1
  42. package/dist/chunks/{selection-filter-compiler-DK8KkS9g.js → selection-filter-compiler-BxtEEB6Z.js} +1 -1
  43. package/dist/chunks/semaphor-ready-indicator-Cq3C2SNo.js +622 -0
  44. package/dist/chunks/{set-oJDaJdtI.js → set-wWdhgHSh.js} +1 -1
  45. package/dist/chunks/slider-C4jUvJtd.js +599 -0
  46. package/dist/chunks/stored-dashboard-1x0q2cNx.js +1 -0
  47. package/dist/chunks/{table-cell-text-2x6r_oHO.js → table-cell-text-DFHUGeG6.js} +1 -1
  48. package/dist/chunks/{table-export-sheet-CWqKiQu4.js → table-export-sheet-CthBUHu4.js} +1 -1
  49. package/dist/chunks/{token-types-BSyWn2pb.js → token-types-BM0mpZce.js} +1 -1
  50. package/dist/chunks/{validators-BPGmPz8-.js → validators-U8IL8djK.js} +1 -1
  51. package/dist/chunks/{variable-draft-DGA22H2g.js → variable-draft-CwX-b6Fs.js} +1 -1
  52. package/dist/dashboard/index.js +1 -1
  53. package/dist/dashboard-authoring/index.js +1 -1
  54. package/dist/extensions/index.js +1 -1
  55. package/dist/format-utils/index.js +1 -1
  56. package/dist/index.js +1 -1
  57. package/dist/report-runtime-context/index.js +1 -1
  58. package/dist/style.css +1 -1
  59. package/dist/surfboard/index.js +1 -1
  60. package/dist/types/index.js +1 -1
  61. package/dist/types/shared/dashboard-authoring/card-settings/custom-visual-write.d.ts +6 -0
  62. package/dist/types/shared/dashboard-authoring/table-sheet-shape.d.ts +8 -0
  63. package/dist/types/shared/extensions/visual-contract.d.ts +3 -1
  64. package/package.json +1 -1
  65. package/dist/chunks/attachment-filter-line-wJRB0GSP.js +0 -1
  66. package/dist/chunks/card-filter-builder-CvxygmsE.js +0 -16
  67. package/dist/chunks/check-input-7DVPUuco.js +0 -1
  68. package/dist/chunks/edit-dashboard-visual-F2w7v4iB.js +0 -83
  69. package/dist/chunks/filter-value-text-BSAMEgve.js +0 -1
  70. package/dist/chunks/kpi-trend-rule-BcnKbY7d.js +0 -1
  71. package/dist/chunks/semaphor-ready-indicator-BSFsqsBJ.js +0 -617
  72. package/dist/chunks/slider-DAvAdfMC.js +0 -599
  73. package/dist/chunks/stored-dashboard-DmgJQcyZ.js +0 -1
@@ -1 +1 @@
1
- var Kn=Object.defineProperty;var Vn=(e,t,n)=>t in e?Kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _=(e,t,n)=>Vn(e,typeof t!="symbol"?t+"":t,n);import{b2 as Bn,b3 as Gn,T as Qn,K as B,U as Jn,b4 as Jt,b5 as er,aX as tr,j as nr,m as dt,O as rr}from"./validators-BPGmPz8-.js";import{l as ar,r as ir}from"./matrix-operation-contract-Cw7U53Ao.js";import{o as or,p as sr,a as cr,c as ur,i as ht,s as be,Y as lr,J as mr}from"./raw-temporal-value-Cssny3RJ.js";import{z as p}from"zod";import{E as en,l as tn}from"./export-file-format-B-wQNHIn.js";import{j as fr,i as ve}from"./analytics-base-schemas-DMFrDqn_.js";import{b as dr}from"./report-runtime-context-B8HuY0bu.js";import{canonicalizeSupportedLocale as te,canonicalizeSupportedCurrencyCode as Ze,DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as hr}from"../value-format-preferences/index.js";function Vs(e,t){return t.levelLabels[e.id]??e.field.label??e.field.name;}function Bs(e,t){return t.measureLabels[e.id]??(e.kind==="aggregate"?e.field.label??e.field.name:e.definition.label);}function Gs(e){return Jn.parse(gr(e));}function gr(e){const t=Bn.parse(e),n=r=>({grand:{visible:!0,position:"after"},levels:Object.fromEntries(r.map(a=>[a.id,{visible:!0,position:"before"}]))});return Gn.parse({version:1,spec:t,presentation:{layout:{kind:"compact"},absence:{emptyText:"—",nullText:""},levelLabels:{},measureLabels:{},levelFormats:{},measureFormats:{},totals:{rows:n(t.rows),columns:n(t.columns)}},defaultView:{rows:{depth:0,overrides:[]},columns:{depth:t.columns.length>1?1:0,overrides:[]}}});}function yr(e,t){const n=new Map(e.map(r=>[B(r),r]));for(const r of t??[])n.set(B(r),r);return[...n.values()];}function Qs(e){const{spec:t,presentation:n,defaults:r,session:a}=Qn.parse(e),i=new Map(yr(t.sorts,a==null?void 0:a.sorts).map(s=>[B(s),s]));for(const s of["rows","columns"])for(const c of t[s]){const u={axis:s,levelId:c.id,scope:{kind:"level"},target:{kind:"member"},direction:"asc",nulls:"last"};i.has(B(u))||i.set(B(u),u);}const o=(s,c)=>({depth:Math.min(s.depth,Math.max(0,c-1)),overrides:s.overrides.filter(u=>u.path.length<c)});return{spec:{...t,sorts:[...i.values()]},presentation:n,view:{rows:o((a==null?void 0:a.rows)??r.rows,t.rows.length),columns:o((a==null?void 0:a.columns)??r.columns,t.columns.length),sorts:(a==null?void 0:a.sorts)??[]}};}const gt=["YYYY","MMMM","MMM","YY","MM","DD","HH","mm","ss"],wr=["hh","h","a","A"],pr={semaphor_tokens:gt,grouped:[...gt,...wr]},Tr=/* @__PURE__ */new Set([" ","-","/",":",".",",","T"]),se=["day","week","month","quarter","year"],nn={week_of_short:["week"],week_of_long:["week"],quarter_short:["quarter"],quarter_long:["quarter"],fiscal_quarter_short:["quarter"],fiscal_year:["year"],short:se,long:se,numeric:se,iso:se};function br(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(nn,e);}function vr(e,t,n){return pr[n].find(r=>e.startsWith(r,t));}function F(e){return{ok:!1,code:"invalid_temporal_bucket_pattern",message:e};}function ne(e,t){var i;if(!e)return F("Type a pattern, for example HH:mm.");if(e.trim()!==e)return F("A pattern can't start or end with a space.");const n=[];let r=0,a=!1;for(;r<e.length;){const o=vr(e,r,t);if(o){if(a)return F("Put a separator between two parts, for example HH:mm.");n.push({kind:"token",value:o}),r+=o.length,a=!0;continue;}const s=e[r];if(!Tr.has(s))return F(`"${s}" isn't a pattern letter.`);if(n.length===0)return F("A pattern can't start with a separator.");const c=n[n.length-1];c.kind==="literal"?c.value+=s:n.push({kind:"literal",value:s}),r+=1,a=!1;}return((i=n[n.length-1])==null?void 0:i.kind)!=="token"?F("A pattern can't end with a separator."):{ok:!0,segments:n};}function xr(e){return e.flatMap(t=>t.kind==="token"?[t.value]:[]);}function ce(e,t){return e.filter(n=>t.includes(n)).length;}function Z(e,t){return e.some(n=>t.includes(n));}const rn=["YYYY","YY"],an=["MMMM","MMM","MM"],Dr=[...rn,...an,"DD"],Xe=["HH","hh","h"],Sr=["hh","h"],Ke=["a","A"],Mr=[...Xe,"mm","ss",...Ke],ue="A date needs its year, month and day.";function kr(e,t){if(new Set(e).size!==e.length)return"Use each part once.";if(ce(e,Xe)>1)return"Use one hour: HH for a 24-hour clock, or h with a for 12-hour.";if(ce(e,Ke)>1)return"Use a once to show AM or PM.";const n=Z(e,Sr),r=Z(e,Ke);if(r&&!n)return"a shows AM or PM: pair it with h or hh, not HH.";if(n&&!r)return"Add a after a 12-hour hour, so 2:30 reads 2:30 PM.";const a=ce(e,rn)===1,i=ce(e,an)===1,o=e.includes("DD"),s=Z(e,Xe),c=Z(e,Mr),u=!Z(e,Dr)||a&&i&&o;switch(t){case"second":return!s||!e.includes("mm")||!e.includes("ss")?"A second shows hours, minutes and seconds, for example h:mm:ss a.":u?void 0:ue;case"minute":return!s||!e.includes("mm")?"A minute shows hours and minutes, for example h:mm a.":u?void 0:ue;case"hour":return s?u?void 0:ue:"An hour shows its hour, for example h a.";case"day":case"week":return c?`A ${t} shows a date without a time, for example MMM DD, YYYY.`:a&&i&&o?void 0:ue;case"month":return a&&i&&!o&&!c?void 0:"A month shows its month and year, for example MMM YYYY.";case"quarter":return"A quarter takes a preset, such as Q1 2024, not a pattern.";case"year":return a&&!i&&!o&&!c?void 0:"A year shows only its year, for example YYYY.";}}function on(e,t){if(e.presentation.mode==="auto")return{ok:!0};if(e.presentation.mode==="preset"){const a=nn[e.presentation.preset];return a.includes(t)?{ok:!0}:{ok:!1,code:"incompatible_temporal_bucket_preset",message:`Preset ${e.presentation.preset} requires ${a.join(", ")} granularity.`};}const n=ne(e.presentation.pattern,"grouped");if(!n.ok)return n;const r=kr(xr(n.segments),t);return r?{ok:!1,code:"incompatible_temporal_bucket_pattern",message:r}:{ok:!0,segments:n.segments};}function Js(e,t){if(!(!e||!t))return on(e,t).ok?e:void 0;}function w(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):/* @__PURE__ */new Date(NaN);}function N(e,t){return e instanceof Date?new e.constructor(t):new Date(t);}const sn=6048e5,_r=864e5,cn=6e4,un=36e5,ec=525600,le=43200,yt=1440;let $r={};function j(){return $r;}function G(e,t){var s,c,u,l;const n=j(),r=(t==null?void 0:t.weekStartsOn)??((c=(s=t==null?void 0:t.locale)==null?void 0:s.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((l=(u=n.locale)==null?void 0:u.options)==null?void 0:l.weekStartsOn)??0,a=w(e),i=a.getDay(),o=(i<r?7:0)+i-r;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a;}function xe(e){return G(e,{weekStartsOn:1});}function ln(e){const t=w(e),n=t.getFullYear(),r=N(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const a=xe(r),i=N(e,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const o=xe(i);return t.getTime()>=a.getTime()?n+1:t.getTime()>=o.getTime()?n:n-1;}function wt(e){const t=w(e);return t.setHours(0,0,0,0),t;}function De(e){const t=w(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n;}function Nr(e,t){const n=wt(e),r=wt(t),a=+n-De(n),i=+r-De(r);return Math.round((a-i)/_r);}function Er(e){const t=ln(e),n=N(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),xe(n);}function ge(e,t){const n=w(e),r=w(t),a=n.getTime()-r.getTime();return a<0?-1:a>0?1:a;}function Or(e){return N(e,Date.now());}function Ir(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]";}function Cr(e){if(!Ir(e)&&typeof e!="number")return!1;const t=w(e);return!isNaN(Number(t));}function Fr(e,t){const n=w(e),r=w(t),a=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth();return a*12+i;}function Pr(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r;};}function Yr(e,t){return+w(e)-+w(t);}function Ar(e){const t=w(e);return t.setHours(23,59,59,999),t;}function zr(e){const t=w(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t;}function Ur(e){const t=w(e);return+Ar(t)==+zr(t);}function Rr(e,t){const n=w(e),r=w(t),a=ge(n,r),i=Math.abs(Fr(n,r));let o;if(i<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-a*i);let s=ge(n,r)===-a;Ur(w(e))&&i===1&&ge(e,r)===1&&(s=!1),o=a*(i-Number(s));}return o===0?0:o;}function Lr(e,t,n){const r=Yr(e,t)/1e3;return Pr(n==null?void 0:n.roundingMethod)(r);}function Wr(e){const t=w(e),n=N(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n;}const Hr={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},jr=(e,t,n)=>{let r;const a=Hr[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r;};function Fe(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth];};}const qr={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Zr={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Xr={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Kr={date:Fe({formats:qr,defaultWidth:"full"}),time:Fe({formats:Zr,defaultWidth:"full"}),dateTime:Fe({formats:Xr,defaultWidth:"full"})},Vr={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Br=(e,t,n,r)=>Vr[e];function X(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,s=n!=null&&n.width?String(n.width):o;a=e.formattingValues[s]||e.formattingValues[o];}else{const o=e.defaultWidth,s=n!=null&&n.width?String(n.width):e.defaultWidth;a=e.values[s]||e.values[o];}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i];};}const Gr={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Qr={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Jr={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},ea={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ta={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},na={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ra=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd";}return n+"th";},aa={ordinalNumber:ra,era:X({values:Gr,defaultWidth:"wide"}),quarter:X({values:Qr,defaultWidth:"wide",argumentCallback:e=>e-1}),month:X({values:Jr,defaultWidth:"wide"}),day:X({values:ea,defaultWidth:"wide"}),dayPeriod:X({values:ta,defaultWidth:"wide",formattingValues:na,defaultFormattingWidth:"wide"})};function K(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const o=i[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?oa(s,f=>f.test(o)):ia(s,f=>f.test(o));let u;u=e.valueCallback?e.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const l=t.slice(o.length);return{value:u,rest:l};};}function ia(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n;}function oa(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n;}function sa(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const a=r[0],i=t.match(e.parsePattern);if(!i)return null;let o=e.valueCallback?e.valueCallback(i[0]):i[0];o=n.valueCallback?n.valueCallback(o):o;const s=t.slice(a.length);return{value:o,rest:s};};}const ca=/^(\d+)(th|st|nd|rd)?/i,ua=/\d+/i,la={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ma={any:[/^b/i,/^(a|c)/i]},fa={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},da={any:[/1/i,/2/i,/3/i,/4/i]},ha={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},ga={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ya={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},wa={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},pa={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Ta={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ba={ordinalNumber:sa({matchPattern:ca,parsePattern:ua,valueCallback:e=>parseInt(e,10)}),era:K({matchPatterns:la,defaultMatchWidth:"wide",parsePatterns:ma,defaultParseWidth:"any"}),quarter:K({matchPatterns:fa,defaultMatchWidth:"wide",parsePatterns:da,defaultParseWidth:"any",valueCallback:e=>e+1}),month:K({matchPatterns:ha,defaultMatchWidth:"wide",parsePatterns:ga,defaultParseWidth:"any"}),day:K({matchPatterns:ya,defaultMatchWidth:"wide",parsePatterns:wa,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:pa,defaultMatchWidth:"any",parsePatterns:Ta,defaultParseWidth:"any"})},mn={code:"en-US",formatDistance:jr,formatLong:Kr,formatRelative:Br,localize:aa,match:ba,options:{weekStartsOn:0,firstWeekContainsDate:1}};function va(e){const t=w(e);return Nr(t,Wr(t))+1;}function xa(e){const t=w(e),n=+xe(t)-+Er(t);return Math.round(n/sn)+1;}function fn(e,t){var l,f,m,d;const n=w(e),r=n.getFullYear(),a=j(),i=(t==null?void 0:t.firstWeekContainsDate)??((f=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((d=(m=a.locale)==null?void 0:m.options)==null?void 0:d.firstWeekContainsDate)??1,o=N(e,0);o.setFullYear(r+1,0,i),o.setHours(0,0,0,0);const s=G(o,t),c=N(e,0);c.setFullYear(r,0,i),c.setHours(0,0,0,0);const u=G(c,t);return n.getTime()>=s.getTime()?r+1:n.getTime()>=u.getTime()?r:r-1;}function Da(e,t){var s,c,u,l;const n=j(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(s=t==null?void 0:t.locale)==null?void 0:s.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((l=(u=n.locale)==null?void 0:u.options)==null?void 0:l.firstWeekContainsDate)??1,a=fn(e,t),i=N(e,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),G(i,t);}function Sa(e,t){const n=w(e),r=+G(n,t)-+Da(n,t);return Math.round(r/sn)+1;}function y(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r;}const $={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return y(t==="yy"?r%100:r,t.length);},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):y(n+1,2);},d(e,t){return y(e.getDate(),t.length);},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m.";}},h(e,t){return y(e.getHours()%12||12,t.length);},H(e,t){return y(e.getHours(),t.length);},m(e,t){return y(e.getMinutes(),t.length);},s(e,t){return y(e.getSeconds(),t.length);},S(e,t){const n=t.length,r=e.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return y(a,t.length);}},P={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},pt={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"});}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"});}return $.y(e,t);},Y:function(e,t,n,r){const a=fn(e,r),i=a>0?a:1-a;if(t==="YY"){const o=i%100;return y(o,2);}return t==="Yo"?n.ordinalNumber(i,{unit:"year"}):y(i,t.length);},R:function(e,t){const n=ln(e);return y(n,t.length);},u:function(e,t){const n=e.getFullYear();return y(n,t.length);},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return y(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"});}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return y(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"});}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return $.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"});}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return y(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"});}},w:function(e,t,n,r){const a=Sa(e,r);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):y(a,t.length);},I:function(e,t,n){const r=xa(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):y(r,t.length);},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):$.d(e,t);},D:function(e,t,n){const r=va(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):y(r,t.length);},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"});}},e:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return y(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"});}},c:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return y(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"});}},i:function(e,t,n){const r=e.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return y(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"});}},a:function(e,t,n){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"});}},b:function(e,t,n){const r=e.getHours();let a;switch(r===12?a=P.noon:r===0?a=P.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"});}},B:function(e,t,n){const r=e.getHours();let a;switch(r>=17?a=P.evening:r>=12?a=P.afternoon:r>=4?a=P.morning:a=P.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"});}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"});}return $.h(e,t);},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):$.H(e,t);},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):y(r,t.length);},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):y(r,t.length);},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):$.m(e,t);},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):$.s(e,t);},S:function(e,t){return $.S(e,t);},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return bt(r);case"XXXX":case"XX":return I(r);case"XXXXX":case"XXX":default:return I(r,":");}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return bt(r);case"xxxx":case"xx":return I(r);case"xxxxx":case"xxx":default:return I(r,":");}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Tt(r,":");case"OOOO":default:return"GMT"+I(r,":");}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Tt(r,":");case"zzzz":default:return"GMT"+I(r,":");}},t:function(e,t,n){const r=Math.trunc(e.getTime()/1e3);return y(r,t.length);},T:function(e,t,n){const r=e.getTime();return y(r,t.length);}};function Tt(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+t+y(i,2);}function bt(e,t){return e%60===0?(e>0?"-":"+")+y(Math.abs(e)/60,2):I(e,t);}function I(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=y(Math.trunc(r/60),2),i=y(r%60,2);return n+a+t+i;}const vt=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"});}},dn=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"});}},Ma=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return vt(e,t);let i;switch(r){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break;}return i.replace("{{date}}",vt(r,t)).replace("{{time}}",dn(a,t));},ka={p:dn,P:Ma},_a=/^D+$/,$a=/^Y+$/,Na=["D","DD","YY","YYYY"];function Ea(e){return _a.test(e);}function Oa(e){return $a.test(e);}function Ia(e,t,n){const r=Ca(e,t,n);if(console.warn(r),Na.includes(e))throw new RangeError(r);}function Ca(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;}const Fa=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Pa=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Ya=/^'([^]*?)'?$/,Aa=/''/g,za=/[a-zA-Z]/;function nt(e,t,n){var l,f,m,d,h,S,mt,ft;const r=j(),a=(n==null?void 0:n.locale)??r.locale??mn,i=(n==null?void 0:n.firstWeekContainsDate)??((f=(l=n==null?void 0:n.locale)==null?void 0:l.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((d=(m=r.locale)==null?void 0:m.options)==null?void 0:d.firstWeekContainsDate)??1,o=(n==null?void 0:n.weekStartsOn)??((S=(h=n==null?void 0:n.locale)==null?void 0:h.options)==null?void 0:S.weekStartsOn)??r.weekStartsOn??((ft=(mt=r.locale)==null?void 0:mt.options)==null?void 0:ft.weekStartsOn)??0,s=w(e);if(!Cr(s))throw new RangeError("Invalid time value");let c=t.match(Pa).map(D=>{const x=D[0];if(x==="p"||x==="P"){const Ce=ka[x];return Ce(D,a.formatLong);}return D;}).join("").match(Fa).map(D=>{if(D==="''")return{isToken:!1,value:"'"};const x=D[0];if(x==="'")return{isToken:!1,value:Ua(D)};if(pt[x])return{isToken:!0,value:D};if(x.match(za))throw new RangeError("Format string contains an unescaped latin alphabet character `"+x+"`");return{isToken:!1,value:D};});a.localize.preprocessor&&(c=a.localize.preprocessor(s,c));const u={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return c.map(D=>{if(!D.isToken)return D.value;const x=D.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&Oa(x)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&Ea(x))&&Ia(x,t,String(e));const Ce=pt[x[0]];return Ce(s,x,a.localize,u);}).join("");}function Ua(e){const t=e.match(Ya);return t?t[1].replace(Aa,"'"):e;}function Ra(e,t,n){const r=j(),a=(n==null?void 0:n.locale)??r.locale??mn,i=2520,o=ge(e,t);if(isNaN(o))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:o});let c,u;o>0?(c=w(t),u=w(e)):(c=w(e),u=w(t));const l=Lr(u,c),f=(De(u)-De(c))/1e3,m=Math.round((l-f)/60);let d;if(m<2)return n!=null&&n.includeSeconds?l<5?a.formatDistance("lessThanXSeconds",5,s):l<10?a.formatDistance("lessThanXSeconds",10,s):l<20?a.formatDistance("lessThanXSeconds",20,s):l<40?a.formatDistance("halfAMinute",0,s):l<60?a.formatDistance("lessThanXMinutes",1,s):a.formatDistance("xMinutes",1,s):m===0?a.formatDistance("lessThanXMinutes",1,s):a.formatDistance("xMinutes",m,s);if(m<45)return a.formatDistance("xMinutes",m,s);if(m<90)return a.formatDistance("aboutXHours",1,s);if(m<yt){const h=Math.round(m/60);return a.formatDistance("aboutXHours",h,s);}else{if(m<i)return a.formatDistance("xDays",1,s);if(m<le){const h=Math.round(m/yt);return a.formatDistance("xDays",h,s);}else if(m<le*2)return d=Math.round(m/le),a.formatDistance("aboutXMonths",d,s);}if(d=Rr(u,c),d<12){const h=Math.round(m/le);return a.formatDistance("xMonths",h,s);}else{const h=d%12,S=Math.trunc(d/12);return h<3?a.formatDistance("aboutXYears",S,s):h<9?a.formatDistance("overXYears",S,s):a.formatDistance("almostXYears",S+1,s);}}function La(e,t){return Ra(e,Or(e),t);}function Wa(){return Object.assign({},j());}function tc(e,t){const r=Za(e);let a;if(r.date){const c=Xa(r.date,2);a=Ka(c.restDateString,c.year);}if(!a||isNaN(a.getTime()))return/* @__PURE__ */new Date(NaN);const i=a.getTime();let o=0,s;if(r.time&&(o=Va(r.time),isNaN(o)))return/* @__PURE__ */new Date(NaN);if(r.timezone){if(s=Ba(r.timezone),isNaN(s))return/* @__PURE__ */new Date(NaN);}else{const c=new Date(i+o),u=/* @__PURE__ */new Date(0);return u.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),u.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),u;}return new Date(i+o+s);}const me={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Ha=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,ja=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,qa=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Za(e){const t={},n=e.split(me.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],me.timeZoneDelimiter.test(t.date)&&(t.date=e.split(me.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const a=me.timezone.exec(r);a?(t.time=r.replace(a[1],""),t.timezone=a[1]):t.time=r;}return t;}function Xa(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const a=r[1]?parseInt(r[1]):null,i=r[2]?parseInt(r[2]):null;return{year:i===null?a:i*100,restDateString:e.slice((r[1]||r[2]).length)};}function Ka(e,t){if(t===null)return/* @__PURE__ */new Date(NaN);const n=e.match(Ha);if(!n)return/* @__PURE__ */new Date(NaN);const r=!!n[4],a=V(n[1]),i=V(n[2])-1,o=V(n[3]),s=V(n[4]),c=V(n[5])-1;if(r)return ti(t,s,c)?Ga(t,s,c):/* @__PURE__ */new Date(NaN);{const u=/* @__PURE__ */new Date(0);return!Ja(t,i,o)||!ei(t,a)?/* @__PURE__ */new Date(NaN):(u.setUTCFullYear(t,i,Math.max(a,o)),u);}}function V(e){return e?parseInt(e):1;}function Va(e){const t=e.match(ja);if(!t)return NaN;const n=Pe(t[1]),r=Pe(t[2]),a=Pe(t[3]);return ni(n,r,a)?n*un+r*cn+a*1e3:NaN;}function Pe(e){return e&&parseFloat(e.replace(",","."))||0;}function Ba(e){if(e==="Z")return 0;const t=e.match(qa);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),a=t[3]&&parseInt(t[3])||0;return ri(r,a)?n*(r*un+a*cn):NaN;}function Ga(e,t,n){const r=/* @__PURE__ */new Date(0);r.setUTCFullYear(e,0,4);const a=r.getUTCDay()||7,i=(t-1)*7+n+1-a;return r.setUTCDate(r.getUTCDate()+i),r;}const Qa=[31,null,31,30,31,30,31,31,30,31,30,31];function hn(e){return e%400===0||e%4===0&&e%100!==0;}function Ja(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Qa[t]||(hn(e)?29:28));}function ei(e,t){return t>=1&&t<=(hn(e)?366:365);}function ti(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6;}function ni(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25;}function ri(e,t){return t>=0&&t<=59;}const ai=Object.freeze({source:"automatic"});function ii(e,t){var r,a;const n=e.preferences;switch(t){case"tooltip":return(r=n==null?void 0:n.tooltipConfig)==null?void 0:r.valueFormat;case"dataLabel":case"pieLabel":return(a=n==null?void 0:n.dataLabelsConfig)==null?void 0:a.valueFormat;default:return;}}function xt(e,t){const n=e.config;if(n)return[...(n.metricColumns??[]),...(n.groupByColumns??[]),...(n.detailColumns??[]),...(n.pivotByColumns??[])].find(r=>r.id===t);}function oi(e,t){if(t.kind==="field")return xt(e,t.fieldId);if(t.kind==="pivot")return xt(e,t.metricId);}function si(e,t,n){var r,a,i,o,s,c,u,l,f;switch(t.kind){case"field":case"pivot":return n!=null&&n.format&&n.formatOrigin==="override"?n.format:void 0;case"result":return(i=(a=(r=e.preferences)==null?void 0:r.sqlColumns)==null?void 0:a[t.key])==null?void 0:i.format;case"sqlKpiValue":return(s=(o=e.preferences)==null?void 0:o.sqlKpiValue)==null?void 0:s.format;case"matrixMeasure":return(u=(c=e.config)==null?void 0:c.matrix)==null?void 0:u.presentation.measureFormats[t.measureId];case"matrixLevel":return(f=(l=e.config)==null?void 0:l.matrix)==null?void 0:f.presentation.levelFormats[t.levelId];}}function ci(e){if(!e)return;if(e.format&&e.formatOrigin!=="override")return e.format;const t=e.semanticTemporalPresentation;return t&&t.granularity===e.granularity?t.format:void 0;}function rt(e){return e.surface?{format:e.surface,source:"surface"}:e.override?{format:e.override,source:"override"}:e.model?{format:e.model,source:"model"}:e.snapshot?{format:e.snapshot,source:"snapshot"}:ai;}function ui(e){var o;const{card:t,column:n,surface:r}=e,a=oi(t,n),i=n.kind==="field"?n.fieldId:n.kind==="pivot"?n.metricId:void 0;return rt({surface:r?ii(t,r):void 0,override:si(t,n,a),model:(i!==void 0?(o=e.modelFormats)==null?void 0:o[i]:void 0)??e.catalogFormat,snapshot:ci(a)});}function li(e,t){const n=r=>r&&typeof r=="object"&&!Array.isArray(r)?Object.fromEntries(Object.keys(r).sort().map(a=>[a,n(r[a])])):r;return JSON.stringify(n(e))===JSON.stringify(n(t));}const mi=["metricColumns","groupByColumns","detailColumns","pivotByColumns"],Dt=/* @__PURE__ */new WeakMap();function nc(e,t){const n=t==null?void 0:t.modelFormats;if(!e||!n||Object.keys(n).length===0)return e;let r=Dt.get(e);if(r||Dt.set(e,r=/* @__PURE__ */new WeakMap()),r.has(n))return r.get(n);const a=fi(e,n);return r.set(n,a),a;}function fi(e,t){const n={config:e};let r;for(const a of mi){const i=e[a];if(!(i!=null&&i.length))continue;let o=!1;const s=i.map(c=>{const u=ui({card:n,column:{kind:"field",fieldId:c.id},modelFormats:t});return u.source!=="model"||li(u.format,c.format)?c:(o=!0,{...c,format:u.format});});o&&((r??(r={...e}))[a]=s);}return r??e;}const M=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function St(e){return e?e.period?e.period:e.unit&&e.count?`${e.unit}s`:e.days<=1?"day":"days":"period";}function di(e,t){return t!=null&&t.period?e===1?`Previous ${t.period}`:`${M(e,t.period)} back`:t!=null&&t.unit&&t.count?e===1?`Previous ${M(t.count,t.unit)}`:`${M(e,"period")} back`:t&&t.days<=1?e===1?"Previous day":`${M(e,"day")} back`:t?e===1?`Previous ${t.days} days`:`${M(e,"period")} back`:e===1?"Previous period":`${M(e,"period")} back`;}function fe(e){return e.charAt(0).toLowerCase()+e.slice(1);}function hi(e){return e.period?`a ${e.period}`:e.unit&&e.count?M(e.count,e.unit):e.days<=1?"a day":M(e.days,"day");}function rc(e,t){const n=Ve(e,t).label,r=or(t).map(a=>`"${Ve(a,t).label}"`);return{message:`"${n}" lands inside the window it compares (${hi(t)}), so it shows no comparison there.`,fix:`Pick a step that clears the window: ${r.join(", ")}.`};}function Ve(e,t){const n=ar(e);if(n.kind==="target")return{label:`Target · ${n.targetValue.toLocaleString("en-US")}`,sentence:`a target of ${n.targetValue.toLocaleString("en-US")}`};const r=n.offset??1,a=n.matchWeekdays?", matching weekdays":"";if(n.unit==="period"){const o=di(r,t);return{label:o,sentence:r===1?`the ${fe(o)}`:fe(o)};}if(n.unit==="day"){const o=r===1?"The day before":`${M(r,"day")} back`;return{label:o,sentence:fe(o)};}const i=r===1?`Same ${St(t)} last ${n.unit}${a}`:`Same ${St(t)} ${M(r,n.unit)} back${a}`;return{label:i,sentence:`the ${fe(i)}`};}function gi(e){return(e==null?void 0:e.kind)==="field_date"?`the ${JSON.stringify(e.label)} filter`:"the dashboard date";}function ac(e,t){const n=t.source==="explicit"?"set on the measure":`from the dashboard date comparison on ${gi(t.owner)}`;return`${e} is compared with ${Ve(t.spec).sentence} (${n})`;}function re(e){if(!e||typeof e!="object")return!1;const t=e.type;return t==="number"||t==="currency"||t==="percent"||t==="scientific";}function ic(e){return re(e)||!!e&&typeof e=="object"&&e.type==="duration";}const gn=["day","hour","minute","second","millisecond"],Be={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},yi={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},wi={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function pi(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond";}function yn(e,t){return pi(e)?e:t;}function Mt(e,t){return gn.indexOf(yn(e,t));}function Ti(e,t){const n=Mt(e,"day"),r=Mt(t,"second"),a=Math.min(n,r),i=Math.max(n,r);return gn.slice(a,i+1);}function bi(e,t){return e*Be[yn(t,"second")];}function vi(e,t){const n=Ti(t.largestUnit,t.smallestUnit),r=n[n.length-1],a=Be[r];let i=Math.round(e/a)*a;return n.map(o=>{const s=Be[o],c=Math.floor(i/s);return i-=c*s,{unit:o,value:c};});}function xi(e,t){const n=e.filter(i=>i.value!==0),r=n.length>0?n:[e[e.length-1]],a=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):r.length;return r.slice(0,a).map(i=>`${i.value}${yi[i.unit]}`).join(" ");}function Di(e,t){const n=e.filter(i=>i.value!==0),r=n.length>0?n:[e[e.length-1]],a=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):r.length;return r.slice(0,a).map(i=>{const[o,s]=wi[i.unit];return`${i.value} ${i.value===1?o:s}`;}).join(" ");}function Si(e){const t=e.some(c=>c.unit==="day"&&c.value!==0),n=e.some(c=>c.unit==="millisecond"),r=e.findIndex(c=>c.value!==0),a=Math.max(0,e.length-2),i=t?0:r===-1?a:Math.min(r,a),o=r===-1?e.slice(a):e.slice(i);if(o.length===0)return"0";const s=o.map((c,u)=>c.unit==="millisecond"?String(c.value).padStart(3,"0"):u===0?String(c.value):String(c.value).padStart(2,"0")).join(":");return n?s.replace(/:(\d{3})$/,".$1"):s;}function Mi(e,t,n){const r=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${r})`:`-${r}`:r;}function wn(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 r=t.inputUnit||"second",a=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",i=n<0,o=Math.abs(bi(n,r)),s=vi(o,t),c=a==="digital"?Si(s):a==="long"?Di(s,t.maxUnits):xi(s,t.maxUnits);return Mi(c,i,t);}function ki(e,t){return wn(e!==null&&typeof e=="object"?e.value: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"});}let kt;function _t(e,t){const n=e.format;return n(t);}function _i(e,t){if(kt??(kt=_t(new Intl.NumberFormat("en-US",{useGrouping:!1,maximumFractionDigits:6}),"9007199254740993.000009")==="9007199254740993.000009"),!kt)throw new RangeError("This runtime cannot format exact decimal strings.");const n=Number(e);if(!Number.isFinite(n)||n===0&&e!=="0")throw new RangeError("Exact value is outside the Intl formatting range; use raw text.");return _t(t,e);}function ae(e){return typeof e=="number"?e<0:e.value.startsWith("-");}function Q(e){return typeof e=="number"?Math.abs(e):ae(e)?{...e,value:e.value.slice(1)}:e;}function $i(e){return typeof e=="number"?e===0:/^-?0*(\.0*)?$/.test(e.value);}function pn(e,t){return typeof e=="number"?e*t:{kind:"exact_number",type:"decimal",value:Jt(e.value,t)};}function Se(e,t){return t===0?e:typeof e=="number"?e/10**t:{kind:"exact_number",type:"decimal",value:Jt(e.value,`1e-${t}`)};}function R(e,t){return typeof e=="number"?t.format(e):_i(e.value,t);}function $t(e){if(!e)return!1;const t=e.toLowerCase().replace("_","-");return t==="en-in"||t.startsWith("en-in-");}function Nt(e,t){const n=Q(e),r=a=>typeof n=="number"?n>=a:er(n.value,String(a))>=0;return r(1e12)?{power:12,suffix:"T"}:r(1e9)?{power:9,suffix:"B"}:$t(t)&&r(1e7)?{power:7,suffix:"Cr"}:r(1e6)?{power:6,suffix:"M"}:$t(t)&&r(1e5)?{power:5,suffix:"L"}:r(1e3)?{power:3,suffix:"K"}:{power:0,suffix:""};}function Ge(e,t){try{const n=q(t);return Nt(e,n);}catch{return Nt(e,"en-US");}}const Tn=500,de=/* @__PURE__ */new Map(),he=/* @__PURE__ */new Map();function E(e,t={}){const n=`${e}|${JSON.stringify(t)}`;let r=de.get(n);return r||(r=new Intl.NumberFormat(e,t),de.size>=Tn&&de.clear(),de.set(n,r)),r;}function Ni(e){let t=he.get(e);if(t===void 0){try{E(e),t=!0;}catch{t=!1;}he.size>=Tn&&he.clear(),he.set(e,t);}return t;}function q(e){return e&&Ni(e)?e:"en-US";}function at(e,t){if(e==null||Number.isNaN(e))return"";const n=q(t==null?void 0:t.locale);let r=e;if(t!=null&&t.multiplyBy&&(r=pn(r,t.multiplyBy)),t!=null&&t.useSuffix){const{power:i,suffix:o}=Ge(r,n);r=Se(r,i);const s=R(r,E(n,{minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}));return`${(t==null?void 0:t.prefix)??""}${s}${o}${(t==null?void 0:t.suffix)??""}`;}const a=R(r,E(n,{minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}));if(t!=null&&t.negativeInParentheses&&ae(r)){const i=a.replace("-","");return`(${(t==null?void 0:t.prefix)??""}${i}${(t==null?void 0:t.suffix)??""})`;}return`${(t==null?void 0:t.prefix)??""}${a}${(t==null?void 0:t.suffix)??""}`;}function bn(e,t){if(e==null||Number.isNaN(e))return"";const n=q(t==null?void 0:t.locale),r=(t==null?void 0:t.currency)||"USD",a=ae(e),i=!!(t!=null&&t.negativeInParentheses&&a),o=i?Q(e):e;try{if(t!=null&&t.useSuffix){const{power:c,suffix:u}=Ge(o,n),l=Se(o,c),m=`${R(l,E(n,{style:"currency",currency:r,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}))}${u}`;return i?`(${m})`:m;}const s=R(o,E(n,{style:"currency",currency:r,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}));return i?`(${s})`:s;}catch{const s=Q(e),c=t!=null&&t.useSuffix?Ge(s,n):{power:0,suffix:""},u=at(Se(s,c.power),{locale:n,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}),l=`${r} ${u}${c.suffix}`;return a?t!=null&&t.negativeInParentheses?`(${l})`:`-${l}`:l;}}function vn(e,t){if(e==null||Number.isNaN(e))return"";const n=q(t==null?void 0:t.locale),a=(t==null?void 0:t.alreadyPercent)??(t==null?void 0:t.percentValueMode)==="whole"?Se(e,2):e;return R(a,E(n,{style:"percent",minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}));}function xn(e,t){if(e==null||Number.isNaN(e))return"";const n=q(t==null?void 0:t.locale);return R(e,E(n,{notation:"scientific",minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2}));}function Ei(e,t){const n=t??"auto",r=n==="never"?Q(e):e,a=!ae(r)&&(n==="always"||n==="exceptZero"&&!$i(r));return{value:r,plus:a};}function oc(e){if(!e||!("signDisplay"in e))return e;const{signDisplay:t,...n}=e;return n;}function Dn(e,t){if(e==null||Number.isNaN(e))return"";const n=t.scale===void 0?e:pn(e,t.scale),r=Ei(n,t.signDisplay),a=r.value,i=r.plus?"+":"",o=t.negativeStyle==="parentheses"&&ae(a),s=o?Q(a):a,c={style:t.type==="number"?"decimal":t.type,locale:t.locale,currency:t.currency,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,useGrouping:t.useGrouping,percentValueMode:t.percentValueMode,useSuffix:t.compact};let u;switch(t.type){case"currency":u=bn(s,c);break;case"percent":u=vn(s,c);break;case"scientific":u=xn(s,c);break;default:u=at(s,c);break;}const l=`${t.prefix??""}${i}${u}${t.suffix??""}`;return o?`(${l})`:l;}function Oi(e,t){return t.type==="duration"?e==null?"":ki(e,t):Dn(e,t);}function Ii(e,t="en-US"){if((e==null?void 0:e.style)==="duration")return{type:"duration",...e.duration,prefix:e.prefix,suffix:e.suffix,negativeStyle:e.negativeStyle};const n=q((e==null?void 0:e.locale)||t),r=(e==null?void 0:e.style)||"decimal",a=r==="decimal"?"number":r;return{type:a,locale:n,currency:a==="currency"?(e==null?void 0:e.currency)||"USD":void 0,minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0,percentValueMode:a==="percent"?(e==null?void 0:e.percentValueMode)??"whole":void 0,scale:e==null?void 0:e.scale,compact:e==null?void 0:e.compact,negativeStyle:e==null?void 0:e.negativeStyle,prefix:e==null?void 0:e.prefix,suffix:e==null?void 0:e.suffix};}function Ci(e,t,n="en-US"){if(e==null||typeof e=="number"&&isNaN(e))return"";const r=Ii(t,n);return r.type==="currency"&&E(r.locale,{style:"currency",currency:r.currency}),Oi(e,r);}function sc(e,t,n){const r={style:t==="currency"?"currency":t==="percent"?"percent":"decimal",locale:n==null?void 0:n.locale,currency:n==null?void 0:n.currency,minimumFractionDigits:n==null?void 0:n.decimalPlaces,maximumFractionDigits:n==null?void 0:n.decimalPlaces,useSuffix:n==null?void 0:n.useSuffix,prefix:n==null?void 0:n.prefix,suffix:n==null?void 0:n.suffix,negativeInParentheses:n==null?void 0:n.negativeInParentheses,multiplyBy:n==null?void 0:n.multiplyBy};switch(t){case"currency":return bn(e,r);case"percent":return vn(e,r);case"scientific":return xn(e,r);default:return at(e,r);}}function Et(e,t,n){const r=Wa(),a=Yi(e,n.timeZone,n.locale??r.locale);return"formatToParts"in a?Fi(a,t):Pi(a,t);}function Fi(e,t){const n=e.formatToParts(t);for(let r=n.length-1;r>=0;--r)if(n[r].type==="timeZoneName")return n[r].value;}function Pi(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/ [\w-+ ]+$/.exec(n);return r?r[0].substr(1):"";}function Yi(e,t,n){return new Intl.DateTimeFormat(n?[n.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e});}function Ai(e,t){const n=Wi(t);return"formatToParts"in n?Ui(n,e):Ri(n,e);}const zi={year:0,month:1,day:2,hour:3,minute:4,second:5};function Ui(e,t){try{const n=e.formatToParts(t),r=[];for(let a=0;a<n.length;a++){const i=zi[n[a].type];i!==void 0&&(r[i]=parseInt(n[a].value,10));}return r;}catch(n){if(n instanceof RangeError)return[NaN];throw n;}}function Ri(e,t){const n=e.format(t),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[parseInt(r[3],10),parseInt(r[1],10),parseInt(r[2],10),parseInt(r[4],10),parseInt(r[5],10),parseInt(r[6],10)];}const Ye={},Ot=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(/* @__PURE__ */new Date("2014-06-25T04:00:00.123Z")),Li=Ot==="06/25/2014, 00:00:00"||Ot==="‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";function Wi(e){return Ye[e]||(Ye[e]=Li?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),Ye[e];}function it(e,t,n,r,a,i,o){const s=/* @__PURE__ */new Date(0);return s.setUTCFullYear(e,t,n),s.setUTCHours(r,a,i,o),s;}const It=36e5,Hi=6e4,Ae={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Oe(e,t,n){if(!e)return 0;let r=Ae.timezoneZ.exec(e);if(r)return 0;let a,i;if(r=Ae.timezoneHH.exec(e),r)return a=parseInt(r[1],10),Ct(a)?-(a*It):NaN;if(r=Ae.timezoneHHMM.exec(e),r){a=parseInt(r[2],10);const o=parseInt(r[3],10);return Ct(a,o)?(i=Math.abs(a)*It+o*Hi,r[1]==="+"?-i:i):NaN;}if(Zi(e)){t=new Date(t||Date.now());const o=n?t:ji(t),s=Qe(o,e);return-(n?s:qi(t,s,e));}return NaN;}function ji(e){return it(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds());}function Qe(e,t){const n=Ai(e,t),r=it(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime();let a=e.getTime();const i=a%1e3;return a-=i>=0?i:1e3+i,r-a;}function qi(e,t,n){let a=e.getTime()-t;const i=Qe(new Date(a),n);if(t===i)return t;a-=i-t;const o=Qe(new Date(a),n);return i===o?i:Math.max(i,o);}function Ct(e,t){return-23<=e&&e<=23&&(t==null||0<=t&&t<=59);}const Ft={};function Zi(e){if(Ft[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Ft[e]=!0,!0;}catch{return!1;}}const Xi=60*1e3,Ki={X:function(e,t,n){const r=ze(n.timeZone,e);if(r===0)return"Z";switch(t){case"X":return Pt(r);case"XXXX":case"XX":return Y(r);case"XXXXX":case"XXX":default:return Y(r,":");}},x:function(e,t,n){const r=ze(n.timeZone,e);switch(t){case"x":return Pt(r);case"xxxx":case"xx":return Y(r);case"xxxxx":case"xxx":default:return Y(r,":");}},O:function(e,t,n){const r=ze(n.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+Vi(r,":");case"OOOO":default:return"GMT"+Y(r,":");}},z:function(e,t,n){switch(t){case"z":case"zz":case"zzz":return Et("short",e,n);case"zzzz":default:return Et("long",e,n);}}};function ze(e,t){const n=e?Oe(e,t,!0)/Xi:(t==null?void 0:t.getTimezoneOffset())??0;if(Number.isNaN(n))throw new RangeError("Invalid time zone specified: "+e);return n;}function Me(e,t){const n=e<0?"-":"";let r=Math.abs(e).toString();for(;r.length<t;)r="0"+r;return n+r;}function Y(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Me(Math.floor(r/60),2),i=Me(Math.floor(r%60),2);return n+a+t+i;}function Pt(e,t){return e%60===0?(e>0?"-":"+")+Me(Math.abs(e)/60,2):Y(e,t);}function Vi(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.floor(r/60),i=r%60;return i===0?n+String(a):n+String(a)+t+Me(i,2);}function Yt(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+e-+t;}const Sn=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,Ue=36e5,At=6e4,Bi=2,v={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:Sn};function ke(e,t={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(e===null)return/* @__PURE__ */new Date(NaN);const n=t.additionalDigits==null?Bi:Number(t.additionalDigits);if(n!==2&&n!==1&&n!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]")return new Date(e.getTime());if(typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]")return new Date(e);if(Object.prototype.toString.call(e)!=="[object String]")return/* @__PURE__ */new Date(NaN);const r=Gi(e),{year:a,restDateString:i}=Qi(r.date,n),o=Ji(i,a);if(o===null||isNaN(o.getTime()))return/* @__PURE__ */new Date(NaN);if(o){const s=o.getTime();let c=0,u;if(r.time&&(c=eo(r.time),c===null||isNaN(c)))return/* @__PURE__ */new Date(NaN);if(r.timeZone||t.timeZone){if(u=Oe(r.timeZone||t.timeZone,new Date(s+c)),isNaN(u))return/* @__PURE__ */new Date(NaN);}else u=Yt(new Date(s+c)),u=Yt(new Date(s+c+u));return new Date(s+c+u);}else return/* @__PURE__ */new Date(NaN);}function Gi(e){const t={};let n=v.dateTimePattern.exec(e),r;if(n?(t.date=n[1],r=n[3]):(n=v.datePattern.exec(e),n?(t.date=n[1],r=n[2]):(t.date=null,r=e)),r){const a=v.timeZone.exec(r);a?(t.time=r.replace(a[1],""),t.timeZone=a[1].trim()):t.time=r;}return t;}function Qi(e,t){if(e){const n=v.YYY[t],r=v.YYYYY[t];let a=v.YYYY.exec(e)||r.exec(e);if(a){const i=a[1];return{year:parseInt(i,10),restDateString:e.slice(i.length)};}if(a=v.YY.exec(e)||n.exec(e),a){const i=a[1];return{year:parseInt(i,10)*100,restDateString:e.slice(i.length)};}}return{year:null};}function Ji(e,t){if(t===null)return null;let n,r,a;if(!e||!e.length)return n=/* @__PURE__ */new Date(0),n.setUTCFullYear(t),n;let i=v.MM.exec(e);if(i)return n=/* @__PURE__ */new Date(0),r=parseInt(i[1],10)-1,Ut(t,r)?(n.setUTCFullYear(t,r),n):/* @__PURE__ */new Date(NaN);if(i=v.DDD.exec(e),i){n=/* @__PURE__ */new Date(0);const o=parseInt(i[1],10);return ro(t,o)?(n.setUTCFullYear(t,0,o),n):/* @__PURE__ */new Date(NaN);}if(i=v.MMDD.exec(e),i){n=/* @__PURE__ */new Date(0),r=parseInt(i[1],10)-1;const o=parseInt(i[2],10);return Ut(t,r,o)?(n.setUTCFullYear(t,r,o),n):/* @__PURE__ */new Date(NaN);}if(i=v.Www.exec(e),i)return a=parseInt(i[1],10)-1,Rt(a)?zt(t,a):/* @__PURE__ */new Date(NaN);if(i=v.WwwD.exec(e),i){a=parseInt(i[1],10)-1;const o=parseInt(i[2],10)-1;return Rt(a,o)?zt(t,a,o):/* @__PURE__ */new Date(NaN);}return null;}function eo(e){let t,n,r=v.HH.exec(e);if(r)return t=parseFloat(r[1].replace(",",".")),Re(t)?t%24*Ue:NaN;if(r=v.HHMM.exec(e),r)return t=parseInt(r[1],10),n=parseFloat(r[2].replace(",",".")),Re(t,n)?t%24*Ue+n*At:NaN;if(r=v.HHMMSS.exec(e),r){t=parseInt(r[1],10),n=parseInt(r[2],10);const a=parseFloat(r[3].replace(",","."));return Re(t,n,a)?t%24*Ue+n*At+a*1e3:NaN;}return null;}function zt(e,t,n){t=t||0,n=n||0;const r=/* @__PURE__ */new Date(0);r.setUTCFullYear(e,0,4);const a=r.getUTCDay()||7,i=t*7+n+1-a;return r.setUTCDate(r.getUTCDate()+i),r;}const to=[31,28,31,30,31,30,31,31,30,31,30,31],no=[31,29,31,30,31,30,31,31,30,31,30,31];function Mn(e){return e%400===0||e%4===0&&e%100!==0;}function Ut(e,t,n){if(t<0||t>11)return!1;if(n!=null){if(n<1)return!1;const r=Mn(e);if(r&&n>no[t]||!r&&n>to[t])return!1;}return!0;}function ro(e,t){if(t<1)return!1;const n=Mn(e);return!(n&&t>366||!n&&t>365);}function Rt(e,t){return!(e<0||e>52||t!=null&&(t<0||t>6));}function Re(e,t,n){return!(e<0||e>=25||t!=null&&(t<0||t>=60)||n!=null&&(n<0||n>=60));}const ao=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function io(e,t,n={}){t=String(t);const r=t.match(ao);if(r){const a=ke(n.originalDate||e,n);t=r.reduce(function(i,o){if(o[0]==="'")return i;const s=i.indexOf(o),c=i[s-1]==="'",u=i.replace(o,"'"+Ki[o[0]](a,o,n)+"'");return c?u.substring(0,s-1)+u.substring(s+1):u;},t);}return nt(e,t,n);}function oo(e,t,n){e=ke(e,n);const r=Oe(t,e,!0),a=new Date(e.getTime()-r),i=/* @__PURE__ */new Date(0);return i.setFullYear(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()),i.setHours(a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()),i;}function kn(e,t,n,r){return r={...r,timeZone:t,originalDate:e},io(oo(e,t,{timeZone:r.timeZone}),n,r);}function ie(e,t,n){if(typeof e=="string"&&!e.match(Sn))return ke(e,{...n,timeZone:t});e=ke(e,n);const r=it(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()).getTime(),a=Oe(t,new Date(r));return new Date(r+a);}function cc(e,t){return e&&e!=="auto"?e:t;}function uc(e,t=/* @__PURE__ */new Date()){try{const n={timeZone:e,timeZoneName:"short"},a=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(i=>i.type==="timeZoneName");return(a==null?void 0:a.value)||e;}catch{return e;}}function lc(e){try{const t={timeZone:e,timeZoneName:"long"},r=new Intl.DateTimeFormat("en-US",t).formatToParts(/* @__PURE__ */new Date()).find(a=>a.type==="timeZoneName");return(r==null?void 0:r.value)||e;}catch{return e;}}function ot(e,t="auto"){if(!e)return/* @__PURE__ */new Date(NaN);const n=e.endsWith("Z"),r=/[+-]\d{2}:?\d{2}$/.test(e),a=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||r||a?new Date(e):/* @__PURE__ */new Date(e+"Z");if(t==="local"){if(n||r){const i=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(i);}return new Date(e);}else return t==="UTC"?n?new Date(e):r?new Date(e):/* @__PURE__ */new Date(e+"Z"):n||r||a?new Date(e):ie(e,t);}const so="MM/dd/yyyy",co=(e,t,n,r="auto")=>{if(!e)return"";try{const a=ot(e,r);if(isNaN(a.getTime()))return e;const o=(t&&t.trim()?t:so).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?kn(a,n,o):nt(a,o);}catch(a){return console.error("Date formatting error:",a),e;}};function mc(e,t,n="auto"){if(e)try{const r=ot(e,n);if(isNaN(r.getTime()))return;const a="yyyy M d H m s",i=t&&t!=="auto"?kn(r,t,a):nt(r,a),[o,s,c,u,l,f]=i.split(" ").map(Number);return{year:o,month:s,day:c,hour:u,minute:l,second:f};}catch{return;}}const uo=(e,t="auto")=>{if(!e)return"";try{const n=ot(e,t);return isNaN(n.getTime())?e:La(n,{addSuffix:!0});}catch(n){return console.error("Relative time formatting error:",n),e;}};function lo(e,t,n,r){const a=e instanceof Date?e.toISOString():String(e),i=(r==null?void 0:r.browserTimezone)||n,o=(r==null?void 0:r.isSqlCard)??!1;if(t!=null&&t.useRelativeTime)return uo(a,(t==null?void 0:t.sourceTimezone)||"auto");const s=t!=null&&t.useCustomFormat&&t!=null&&t.customFormat?t.customFormat:(t==null?void 0:t.format)||"MM/dd/yyyy";return co(a,s,t!=null&&t.timezone&&(t==null?void 0:t.timezone)!=="auto"?t.timezone:o?i:n,(t==null?void 0:t.sourceTimezone)||"auto");}function _n(e,t,n){var o,s;if(e==null)return e===null?((o=n.absence)==null?void 0:o.nullText)??"":((s=n.absence)==null?void 0:s.emptyText)??"";const r=tr(e)?e:void 0,a=r?r.value:e,i=r??(typeof e=="number"?e:void 0);if(!n.useFormattedValues||!t)return String(a);switch(t.type){case"number":return i!==void 0?Ci(i,t.numberFormat,n.locale):String(a);case"date":return lo(a,t.dateFormat,n.timezone,{browserTimezone:n.browserTimezone,isSqlCard:n.isSqlCard});case"progress":return i!==void 0?`${a}%`:String(a);case"badge":case"link":case"text":case"none":default:return String(a);}}function fc(e,t){return t.visibleColumns.map(n=>{const r=e[n],a=t.columnSettings[n];return _n(r,a,{useFormattedValues:t.useFormattedValues,timezone:t.timezone,locale:t.locale});});}const $n=1e4,mo=1e6,dc=5e6,hc=1024**3,gc=1024**3;function yc(e){return e>$n;}function wc(e){return e.cardType==="matrixTable"?"try-direct":e.loadedRowCount===null||e.loadedRowCount<=$n?"direct":e.loadedRowCount<=mo?"background":"blocked";}const fo=5*1024*1024,pc=64*1024*1024,_e=p.number().int().positive().max(Number.MAX_SAFE_INTEGER),ye=p.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),$e=ye.refine(e=>e>0),ho=e=>!!e&&e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\");function A(e,t){const n=t.split("/");if(n.length!==5||n[0]!=="exports"||n[1]!==e||n[2]!=="attempts"||!n.every(ho))throw new Error("Invalid Matrix export artifact namespace.");return{attemptId:n[3],filename:n[4]};}function Tc(e,t,n){const r=`exports/${e}/attempts/${t}/${n}`;return A(e,r),r;}const bc=p.object({acquisition:p.literal("continuation"),jobId:p.string().min(1),sequence:$e,deadlineAt:_e}),go=["application/json",...en.map(e=>tn(e).partContentType)],yo=p.object({key:p.string(),content:p.string(),contentType:p.enum(go),encoding:p.literal("gzip-base64").optional()}).refine(e=>!e.encoding||e.contentType==="application/json"||e.contentType===tn("xlsx").partContentType,"Unsupported Matrix artifact encoding."),wo=p.discriminatedUnion("kind",[p.object({kind:p.literal("work"),sequence:$e,checkpointKey:p.string(),objects:p.array(yo).min(2).max(4),deadlineAt:_e}),p.object({kind:p.literal("committed"),sequence:$e,done:p.boolean(),deadlineAt:_e})]);function po(e){const t=JSON.stringify(e);if(t===void 0||new TextEncoder().encode(t).byteLength>fo)throw new RangeError("Matrix export batch exceeds its transport byte limit.");}function vc(e,t){const n=wo.parse(e);if(po(e),n.deadlineAt!==t.deadlineAt)throw new Error("Matrix deadline does not match the job.");if(n.sequence!==t.sequence+(n.kind==="committed"?1:0))throw new Error("Invalid Matrix batch sequence.");if(n.kind==="work"){A(t.jobId,n.checkpointKey);for(const r of n.objects)A(t.jobId,r.key);}return n;}const To=p.object({acquisition:p.literal("continuation"),deadlineAt:_e,chunks:p.array(p.object({chunkNumber:$e,dataKey:p.string()})).min(1),totalRows:ye,totalBytes:ye,fileKey:p.string().min(1).optional(),fileSize:ye.optional(),format:p.enum(en).optional(),sheetKey:p.string().min(1).optional()}).refine(e=>e.fileKey===void 0==(e.fileSize===void 0),"Incomplete published Matrix artifact.").refine(e=>e.format==="xlsx"==(e.sheetKey!==void 0),"An Excel Matrix manifest names its sheet layout, and only it does.");function xc(e,t,n){const r=To.parse(e);if(r.deadlineAt!==n)throw new Error("Matrix deadline does not match the job.");return r.chunks.forEach((a,i)=>{if(a.chunkNumber!==i+1)throw new Error("Invalid committed Matrix chunk order.");A(t,a.dataKey);}),r.fileKey!==void 0&&A(t,r.fileKey),r.sheetKey!==void 0&&A(t,r.sheetKey),r;}const bo="en-US";function Lt(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t;}function we(e){if(!(typeof e!="number"||!Number.isFinite(e)))return Math.max(0,Math.min(10,Math.trunc(e)));}function vo(e){return e==="currency"?2:e==="percent"?1:e==="scientific"?2:0;}function xo(e,t,n){const r=we(t.minimumFractionDigits),a=we(t.maximumFractionDigits);if(typeof r=="number"||typeof a=="number"){const s=r??0,c=a??Math.max(s,2);return{minimumFractionDigits:Math.min(s,c),maximumFractionDigits:Math.max(s,c)};}const i=we(t.decimals);if(typeof i=="number")return{minimumFractionDigits:i,maximumFractionDigits:i};if(n!=null&&n.preserveOmittedProperties)return{};const o=vo(e);return{minimumFractionDigits:o,maximumFractionDigits:o};}function Do(e,t){if(!(typeof t!="string"||e==="percent"&&t==="%"))return t;}function Wt(e){const t=Lt(e.locale),n=Lt(e.currency),r=Do(e.type,e.suffix);return{...e,...(t!==e.locale?{locale:t}:{}),...(n!==e.currency?{currency:n}:{}),...(r!==e.suffix?{suffix:r}:{})};}function O(e,t,n){const r={...t,type:e};if((n==null?void 0:n.numericInput)==="canonical"&&re(r))return Wt(r);const a=xo(e,t,n),i=typeof t.prefix=="string"?t.prefix:void 0,o={type:e,locale:t.locale,minimumFractionDigits:a.minimumFractionDigits,maximumFractionDigits:a.maximumFractionDigits,useGrouping:typeof t.useGrouping=="boolean"?t.useGrouping:typeof t.thousandsSeparator=="boolean"?t.thousandsSeparator:!0,prefix:i,suffix:t.suffix,negativeStyle:t.negativeStyle||"minus",compact:!!t.compact,scale:typeof t.scale=="number"?t.scale:void 0,...(t.signDisplay?{signDisplay:t.signDisplay}:{})};return e==="currency"&&t.currency&&(o.currency=t.currency),e==="percent"&&(o.percentValueMode=t.percentValueMode||"fraction"),Wt(o);}function Ht(e){return{type:"date",locale:e.locale||bo,pattern:e.pattern,...(e.dialect?{dialect:e.dialect}:{}),...(e.preset?{preset:e.preset}:{}),relative:!!e.relative,timezone:e.timezone,sourceTimezone:e.sourceTimezone,prefix:e.prefix,suffix:e.suffix};}function Le(e){return e==="millisecond"||e==="second"||e==="minute"||e==="hour"||e==="day";}function jt(e){const t=we(e.maxUnits);return{type:"duration",inputUnit:Le(e.inputUnit)?e.inputUnit:"second",outputStyle:e.outputStyle==="digital"||e.outputStyle==="long"?e.outputStyle:"compact",largestUnit:Le(e.largestUnit)?e.largestUnit:void 0,smallestUnit:Le(e.smallestUnit)?e.smallestUnit:"second",maxUnits:t,prefix:e.prefix,suffix:e.suffix,negativeStyle:e.negativeStyle||"minus"};}function qt(e){return{type:"string",prefix:e.prefix,suffix:e.suffix};}function So(e,t){if(!e)return;if(typeof e=="string"){const r=e.trim().toLowerCase();return r==="currency"?O("currency",{type:"currency"},t):r==="percentage"||r==="percent"?O("percent",{type:"percentage",percentValueMode:"fraction"},t):r==="scientific"?O("scientific",{type:"scientific"},t):r==="date"?Ht({}):r==="duration"?jt({}):r==="string"?qt({}):r==="number"?O("number",{type:"number"},t):void 0;}if("type"in e&&e.type==="temporal_bucket"){const r=fr.safeParse(e);return r.success?r.data:void 0;}const n=e;if((t==null?void 0:t.numericInput)==="canonical"){const r=n.type==="percentage"?{...n,type:"percent"}:n;if(re(r))return O(r.type,r,t);}if(n.type==="percentage")return O("percent",{...n,percentValueMode:n.percentValueMode||"fraction"},t);if(n.type==="number"||n.type==="currency"||n.type==="percent"||n.type==="scientific")return O(n.type,n,t);if(n.type==="date")return Ht(n);if(n.type==="duration")return jt(n);if(n.type==="string")return qt(n);}function b(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.prototype.hasOwnProperty.call(t,"constructor")?t.constructor:void 0;return typeof n=="function"&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object);}const Mo=["type","locale","minimumFractionDigits","maximumFractionDigits","useGrouping","prefix","suffix","negativeStyle","compact","scale","currency","percentValueMode","signDisplay"];function ko(e){if(!b(e))return{ok:!1,issues:[{path:"$",message:"Numeric format must be an object."}]};const t=[],n=new Set(Mo);Object.keys(e).filter(i=>!n.has(i)).forEach(i=>t.push({path:i,message:`Unknown property "${i}".`})),e.type!=="number"&&e.type!=="currency"&&e.type!=="percent"&&e.type!=="scientific"&&t.push({path:"type",message:"Expected number, currency, percent, or scientific."});const r=e.locale===void 0?void 0:te(e.locale);e.locale!==void 0&&!r&&t.push({path:"locale",message:"Expected a supported BCP 47 locale."});const a=e.currency===void 0?void 0:Ze(e.currency);e.currency!==void 0&&!a&&t.push({path:"currency",message:"Expected a supported ISO 4217 currency code."});for(const i of["minimumFractionDigits","maximumFractionDigits"]){const o=e[i];o!==void 0&&(!Number.isInteger(o)||typeof o!="number"||o<0||o>20)&&t.push({path:i,message:"Expected an integer from 0 to 20."});}typeof e.minimumFractionDigits=="number"&&typeof e.maximumFractionDigits=="number"&&e.minimumFractionDigits>e.maximumFractionDigits&&t.push({path:"maximumFractionDigits",message:"Must be greater than or equal to minimumFractionDigits."});for(const i of["useGrouping","compact"])e[i]!==void 0&&typeof e[i]!="boolean"&&t.push({path:i,message:"Expected a boolean."});for(const i of["prefix","suffix"])e[i]!==void 0&&typeof e[i]!="string"&&t.push({path:i,message:"Expected a string."});return e.negativeStyle!==void 0&&e.negativeStyle!=="minus"&&e.negativeStyle!=="parentheses"&&t.push({path:"negativeStyle",message:"Expected minus or parentheses."}),e.percentValueMode!==void 0&&e.percentValueMode!=="fraction"&&e.percentValueMode!=="whole"&&t.push({path:"percentValueMode",message:"Expected fraction or whole."}),e.scale!==void 0&&(typeof e.scale!="number"||!Number.isFinite(e.scale))&&t.push({path:"scale",message:"Expected a finite number."}),e.signDisplay!==void 0&&e.signDisplay!=="auto"&&e.signDisplay!=="always"&&e.signDisplay!=="exceptZero"&&e.signDisplay!=="never"&&t.push({path:"signDisplay",message:"Expected auto, always, exceptZero, or never."}),t.length>0?{ok:!1,issues:t}:{ok:!0,value:{type:e.type,...(r?{locale:r}:{}),...(e.minimumFractionDigits!==void 0?{minimumFractionDigits:e.minimumFractionDigits}:{}),...(e.maximumFractionDigits!==void 0?{maximumFractionDigits:e.maximumFractionDigits}:{}),...(e.useGrouping!==void 0?{useGrouping:e.useGrouping}:{}),...(e.prefix!==void 0?{prefix:e.prefix}:{}),...(e.suffix!==void 0?{suffix:e.suffix}:{}),...(e.negativeStyle!==void 0?{negativeStyle:e.negativeStyle}:{}),...(e.compact!==void 0?{compact:e.compact}:{}),...(e.scale!==void 0?{scale:e.scale}:{}),...(a?{currency:a}:{}),...(e.percentValueMode!==void 0?{percentValueMode:e.percentValueMode}:{}),...(e.signDisplay!==void 0?{signDisplay:e.signDisplay}:{})}};}function _o(e){const t=ko(e);if(!t.ok)return t;const n=[];return t.value.locale||n.push({path:"locale",message:"Resolved numeric formats require an explicit locale."}),t.value.minimumFractionDigits===void 0&&n.push({path:"minimumFractionDigits",message:"Resolved numeric formats require minimumFractionDigits."}),t.value.maximumFractionDigits===void 0&&n.push({path:"maximumFractionDigits",message:"Resolved numeric formats require maximumFractionDigits."}),t.value.type==="currency"&&!t.value.currency&&n.push({path:"currency",message:"Resolved currency formats require an explicit currency."}),n.length>0?{ok:!1,issues:n}:t;}function Dc(e){var r;const t=/* @__PURE__ */new Set();if(e.snapshot.resolvedFormats.forEach((a,i)=>{if(a.format.type!=="temporal_bucket"){if(a.scope.attachmentIndex!==void 0)throw new Error(`resolvedFormats.${i}.scope.attachmentIndex is not valid for a card export`);if(a.scope.dashboardId!==e.expectedScope.dashboardId||a.scope.cardId!==e.expectedScope.cardId)throw new Error(`resolvedFormats.${i}.scope must match the executing dashboard/card`);if(a.target.kind!=="column")throw new Error(`resolvedFormats.${i}.target must identify an export column`);if(t.has(a.target.columnKey))throw new Error(`resolvedFormats.${i} duplicates export column "${a.target.columnKey}"`);t.add(a.target.columnKey);}}),!e.useFormattedValues)return;if(!((r=e.visibleColumns)!=null&&r.length))throw new Error("visibleColumns must identify every formatted export column");const n=e.visibleColumns.find(a=>!t.has(a));if(n)throw new Error(`resolvedFormats is missing visible export column "${n}"`);}function $o(e,t){const n=new Intl.NumberFormat(e,{style:"currency",currency:t}).resolvedOptions();return{minimumFractionDigits:n.minimumFractionDigits,maximumFractionDigits:n.maximumFractionDigits};}function No(e){if(e.minimumFractionDigits!==void 0||e.maximumFractionDigits!==void 0){const n=e.minimumFractionDigits??0;return{minimumFractionDigits:n,maximumFractionDigits:e.maximumFractionDigits??Math.max(n,2)};}const t=e.type==="percent"?1:e.type==="scientific"?2:0;return{minimumFractionDigits:t,maximumFractionDigits:t};}function Eo(e,t,n){const r=te(e.locale)??t.locale,a=e.type==="number"||e.type==="currency"?Ze(n):void 0;if(!(e.type==="currency"||a!==void 0))return{...e,locale:r,...No(e)};const o=a??Ze(e.currency)??t.defaultCurrency,s=$o(r,o),c=s.minimumFractionDigits??0,u=s.maximumFractionDigits??c,l=e.minimumFractionDigits??Math.min(c,e.maximumFractionDigits??c),f=e.maximumFractionDigits??Math.max(l,u);return{...e,type:"currency",locale:r,currency:o,minimumFractionDigits:l,maximumFractionDigits:f};}const Zt=/* @__PURE__ */new Map();function Nn(e,t){var r;let n=Zt.get(e);return n||(n=new Intl.DateTimeFormat(e,{calendar:"gregory",timeZone:"UTC",hour:"numeric",hour12:!0}),Zt.set(e,n)),((r=n.formatToParts(new Date(Date.UTC(2e3,0,1,t))).find(a=>a.type==="dayPeriod"))==null?void 0:r.value)??"";}function Oo(e){return e.preset?{mode:"preset",preset:e.preset}:e.pattern?{mode:"pattern",dialect:e.dialect??"semaphor_tokens",pattern:e.pattern}:{mode:"auto"};}class L extends Error{constructor(n,r){super(r);_(this,"code");this.name="RawTemporalFormatContractError",this.code=n;}}const Io=["SSSSSSSSS","SSSSSSSS","SSSSSSS","SSSSSS","SSSSS","SSSS","SSS","SS","S"],Co=["yyyy","MMMM","LLLL","zzz","XXX","MMM","LLL","yy","MM","dd","HH","hh","mm","ss","M","d","H","h","m","s","a"],Fo=/* @__PURE__ */new Set(["HH","H","hh","h","mm","m","ss","s","a",...Io]),Po=/* @__PURE__ */new Set(["zzz","XXX"]),We=/* @__PURE__ */new Set(["short","medium","long"]);function k(e,t){return Object.keys(e).length===t.length&&t.every(r=>r in e);}function g(e){throw new L("invalid_raw_temporal_format",e);}function En(e){if(!e||e.trim()!==e||e.length>256)return g("date_fns patterns must be non-empty, trimmed, and at most 256 characters.");const t=[],n=a=>{const i=t[t.length-1];(i==null?void 0:i.kind)==="literal"?i.value+=a:t.push({kind:"literal",value:a});};let r=0;for(;r<e.length;){if(e[r]==="'"){if(e[r+1]==="'"){n("'"),r+=2;continue;}let o="",s=!1;for(r+=1;r<e.length;){if(e[r]==="'"){if(e[r+1]==="'"){o+="'",r+=2;continue;}s=!0,r+=1;break;}o+=e[r],r+=1;}if(!s)return g("date_fns pattern has an unclosed quote.");n(o);continue;}if(e[r]==="S"){let o=r+1;for(;e[o]==="S";)o+=1;const s=e.slice(r,o);if(s.length>9)return g("date_fns fractional-second tokens support at most nine digits.");t.push({kind:"token",value:s}),r=o;continue;}const a=Co.find(o=>e.startsWith(o,r));if(a){t.push({kind:"token",value:a}),r+=a.length;continue;}const i=e[r];if(/[A-Za-z]/.test(i))return g(`Unsupported date_fns pattern token beginning at "${e.slice(r)}".`);n(i),r+=1;}return t.some(a=>a.kind==="token")?t:g("date_fns patterns must contain at least one token.");}function On(e,t){if(e==="semaphor_tokens"){const n=ne(t,"semaphor_tokens");n.ok||g(n.message);return;}En(t);}function Yo(e){return!b(e)||!k(e,["dateStyle","dateTime"])?g("Automatic raw temporal styles are incomplete."):We.has(e.dateStyle)?!b(e.dateTime)||!k(e.dateTime,["dateStyle","timeStyle"])||!We.has(e.dateTime.dateStyle)||!We.has(e.dateTime.timeStyle)?g("Automatic dateTime styles are incomplete or invalid."):{dateStyle:e.dateStyle,dateTime:{dateStyle:e.dateTime.dateStyle,timeStyle:e.dateTime.timeStyle}}:g("Automatic dateStyle is invalid.");}function st(e){const t=["type","locale","calendarTimezone","presentation"],n=[...t,"sourceTimezone"];if(!b(e)||!k(e,t)&&!k(e,n)||e.type!=="raw_temporal")return g("Resolved raw temporal format has an invalid shape.");const r=te(e.locale);return r?typeof e.calendarTimezone!="string"||!ve(e.calendarTimezone)?g("Raw temporal calendarTimezone must be a valid IANA timezone."):e.sourceTimezone!==void 0&&(typeof e.sourceTimezone!="string"||!ve(e.sourceTimezone))?g("Raw temporal sourceTimezone must be a valid IANA timezone."):b(e.presentation)?e.presentation.mode==="auto"?k(e.presentation,["mode","styles"])?{type:"raw_temporal",locale:r,calendarTimezone:e.calendarTimezone,...(e.sourceTimezone?{sourceTimezone:e.sourceTimezone}:{}),presentation:{mode:"auto",styles:Yo(e.presentation.styles)}}:g("Automatic raw temporal presentation has unknown fields."):e.presentation.mode==="preset"?!k(e.presentation,["mode","preset"])||!Yn(e.presentation.preset)?g("Preset raw temporal presentation has an invalid shape."):{type:"raw_temporal",locale:r,calendarTimezone:e.calendarTimezone,...(e.sourceTimezone?{sourceTimezone:e.sourceTimezone}:{}),presentation:{mode:"preset",preset:e.presentation.preset}}:e.presentation.mode!=="pattern"||!k(e.presentation,["mode","dialect","pattern"])||e.presentation.dialect!=="semaphor_tokens"&&e.presentation.dialect!=="date_fns"||typeof e.presentation.pattern!="string"?g("Pattern raw temporal presentation has an invalid shape."):(On(e.presentation.dialect,e.presentation.pattern),{type:"raw_temporal",locale:r,calendarTimezone:e.calendarTimezone,...(e.sourceTimezone?{sourceTimezone:e.sourceTimezone}:{}),presentation:{mode:"pattern",dialect:e.presentation.dialect,pattern:e.presentation.pattern}}):g("Raw temporal presentation must be an object."):g("Raw temporal locale is invalid or unsupported.");}function In(e){var s,c,u;if(e.format){if(!b(e.format))return g("Authored raw temporal format has an invalid shape.");const l=Object.keys(e.format);if(!l.includes("type")||!l.includes("presentation")||l.some(m=>m!=="type"&&m!=="presentation"&&m!=="timezone"&&m!=="sourceTimezone")||e.format.type!=="raw_temporal"||!b(e.format.presentation))return g("Authored raw temporal format has an invalid shape.");const f=e.format.presentation;if(f.mode==="auto"){if(!k(f,["mode"]))return g("Automatic authored raw temporal format has unknown fields.");}else if(f.mode==="preset"){if(!k(f,["mode","preset"])||!Yn(f.preset))return g("Authored raw temporal preset has an invalid shape.");}else{if(f.mode!=="pattern"||!k(f,["mode","dialect","pattern"])||f.dialect!=="semaphor_tokens"&&f.dialect!=="date_fns"||typeof f.pattern!="string")return g("Authored raw temporal pattern has an invalid shape.");On(f.dialect,f.pattern);}}const t=(s=e.format)==null?void 0:s.timezone,n=(c=e.format)==null?void 0:c.sourceTimezone,r=t&&t!=="auto"?t:e.calendar.tz,a=n&&n!=="auto"?n==="local"?Intl.DateTimeFormat().resolvedOptions().timeZone:n:void 0;if(t!==void 0&&t!=="auto"&&!ve(r)||a!==void 0&&!ve(a))return g("Authored raw temporal timezone is invalid.");const i=((u=e.format)==null?void 0:u.presentation)??{mode:"auto"},o={type:"raw_temporal",locale:e.preferences.locale,calendarTimezone:r,...(a?{sourceTimezone:a}:{}),presentation:i.mode==="pattern"||i.mode==="preset"?{...i}:{mode:"auto",styles:{dateStyle:e.preferences.dateStyle,dateTime:{...e.preferences.dateTime}}}};return st(o);}function Sc(e){const t=/* @__PURE__ */new Set();let n=!1;for(const r of e.values){if(r===null)continue;n=!0;const a=ur(r);a&&t.add(a);}if(!n)return{status:"empty"};if(t.size===0)return{status:"invalid_only"};if(t.size>1)throw new L("mixed_sql_temporal_semantics",`Declared SQL temporal column "${e.columnKey}" mixes date, wall-datetime, or instant semantics. Normalize it to one kind.`);return{status:"classified",metadata:{kind:"raw_temporal",valueKind:[...t][0]}};}function Mc(e){return{version:1,columns:Object.fromEntries([...e].map(([t,n])=>[t,n.status==="classified"?n.metadata.valueKind:n.status]))};}function Ao(e){if(!b(e)||e.version!==1||!b(e.columns)||Object.keys(e).some(r=>r!=="version"&&r!=="columns"))throw new L("invalid_raw_temporal_format","Raw temporal chunk classification evidence is malformed.");const t={},n=/* @__PURE__ */new Set(["empty","invalid_only","date","wall_datetime","instant"]);for(const[r,a]of Object.entries(e.columns)){if(!r.trim()||!n.has(a))throw new L("invalid_raw_temporal_format","Raw temporal chunk classification evidence contains an invalid column or status.");t[r]=a;}return{version:1,columns:t};}function kc(e){if(e.length===0)return;const t=e.map(Ao),n=Object.keys(t[0].columns).sort();for(let r=1;r<t.length;r+=1){const a=Object.keys(t[r].columns).sort();if(a.length!==n.length||a.some((i,o)=>i!==n[o]))throw new L("invalid_raw_temporal_format","Raw temporal chunk classification evidence has inconsistent columns.");}for(const r of n)if(new Set(t.map(i=>i.columns[r]).filter(i=>i!=="empty"&&i!=="invalid_only")).size>1)throw new L("mixed_sql_temporal_semantics",`Declared SQL temporal column "${r}" has inconsistent semantics across export chunks. Normalize it to one kind.`);}function Je(e){const t=/* @__PURE__ */new Date(0);return t.setUTCFullYear(e.year,e.month-1,e.day),t.setUTCHours(e.hour,e.minute,e.second,0),t;}function ct(e,t){const n=e.fraction?`.${e.fraction.padEnd(3,"0").slice(0,3)}`:"";return ie(`${String(e.year).padStart(4,"0")}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}T${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${n}`,t);}function Cn(e,t){const n=/* @__PURE__ */new Map(),r=/* @__PURE__ */new Map();let a,i,o;return{number(s,c=1){let u=n.get(c);return u||(u=new Intl.NumberFormat(e,{useGrouping:!1,minimumIntegerDigits:c,maximumFractionDigits:0}),n.set(c,u)),u.format(s);},month(s,c,u){var m;const l=`${c}:${u?"standalone":"contextual"}`;let f=r.get(l);if(!f){const d={calendar:"gregory",timeZone:"UTC",month:c};u||(d.day="numeric"),f=new Intl.DateTimeFormat(e,d),r.set(l,f);}return((m=f.formatToParts(s).find(d=>d.type==="month"))==null?void 0:m.value)??"";},dayPeriod(s){return Nn(e,s.getUTCHours());},instantFields(s){a??(a=new Intl.DateTimeFormat("en-CA",{calendar:"gregory",numberingSystem:"latn",timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}));const c=a.formatToParts(s),u=l=>{var f;return Number((f=c.find(m=>m.type===l))==null?void 0:f.value);};return{year:u("year"),month:u("month"),day:u("day"),hour:u("hour"),minute:u("minute"),second:u("second"),fraction:""};},timezoneName(s){var c;return i??(i=new Intl.DateTimeFormat(e,{calendar:"gregory",timeZone:t,timeZoneName:"short"})),((c=i.formatToParts(s).find(u=>u.type==="timeZoneName"))==null?void 0:c.value)??"";},timezoneOffset(s){var l;o??(o=new Intl.DateTimeFormat("en-US",{calendar:"gregory",timeZone:t,timeZoneName:"longOffset"}));const c=(l=o.formatToParts(s).find(f=>f.type==="timeZoneName"))==null?void 0:l.value;if(!c)return g("Unable to resolve the instant timezone offset.");const u=c.replace(/^GMT/,"");return u===""||/^[+-]00:00$/.test(u)?"Z":u;}};}function zo(e,t,n,r,a){if(/^S{1,9}$/.test(e)){const i=t.fraction.padEnd(e.length,"0").slice(0,e.length);return r.number(Number(i),e.length);}switch(e){case"YYYY":case"yyyy":return r.number(t.year,4);case"YY":case"yy":return r.number(t.year%100,2);case"MMMM":return r.month(n,"long",!1);case"LLLL":return r.month(n,"long",!0);case"MMM":return r.month(n,"short",!1);case"LLL":return r.month(n,"short",!0);case"MM":return r.number(t.month,2);case"M":return r.number(t.month);case"DD":case"dd":return r.number(t.day,2);case"d":return r.number(t.day);case"HH":return r.number(t.hour,2);case"H":return r.number(t.hour);case"hh":return r.number(t.hour%12||12,2);case"h":return r.number(t.hour%12||12);case"mm":return r.number(t.minute,2);case"m":return r.number(t.minute);case"ss":return r.number(t.second,2);case"s":return r.number(t.second);case"a":return r.dayPeriod(n);case"zzz":return a?r.timezoneName(a):g("Timezone pattern tokens require an instant value.");case"XXX":return a?r.timezoneOffset(a):g("Timezone pattern tokens require an instant value.");default:return g(`Unsupported raw temporal pattern token "${e}".`);}}function Uo(e,t,n,r){const a=Je(t);return e.map(i=>i.kind==="literal"?i.value:zo(i.value,t,a,n,r)).join("");}function Fn(e,t,n){const r=t==="date_fns"?En(n):(()=>{const i=ne(n,"semaphor_tokens");return i.ok?i.segments:g(i.message);})(),a=r.filter(i=>i.kind==="token").map(i=>i.value);return e==="date"&&a.some(i=>Fo.has(i))?g("Date patterns cannot contain time tokens."):e!=="instant"&&a.some(i=>Po.has(i))?g("Timezone pattern tokens require an instant value."):r;}function Ro(e){Fn(e.valueKind??"instant",e.dialect,e.pattern);}function Lo(e,t,n,r){const a=Fn(e.valueKind,n,r),i=Cn(t.locale,t.calendarTimezone);return o=>{const s=e.valueKind==="wall_datetime"&&t.sourceTimezone?ct(o.fields,t.sourceTimezone):void 0,c=e.valueKind==="instant"?{...i.instantFields(o.instant),fraction:o.fields.fraction}:s?{...i.instantFields(s),fraction:o.fields.fraction}:o.fields;return Uo(a,c,i,o.instant??s);};}function Pn(e,t){const n=Cn(t.locale,t.calendarTimezone);return r=>{const a=e.valueKind==="instant"?n.instantFields(r.instant):e.valueKind==="wall_datetime"&&t.sourceTimezone?n.instantFields(ct(r.fields,t.sourceTimezone)):r.fields;return{year:a.year,month:a.month,day:a.day,hour:a.hour,minute:a.minute,second:a.second};};}const Wo=/* @__PURE__ */new Set(["short","long","numeric","iso"]);function Yn(e){return typeof e=="string"&&Wo.has(e);}function Ho(e,t,n){const r=Pn(e,t),a=e.valueKind!=="date",i=(s,c=2)=>String(s).padStart(c,"0");if(n==="iso")return s=>{const c=r(s),u=`${i(c.year,4)}-${i(c.month)}-${i(c.day)}`;return a?`${u} ${i(c.hour)}:${i(c.minute)}`:u;};const o=new Intl.DateTimeFormat(t.locale,{calendar:"gregory",timeZone:"UTC",year:"numeric",month:n,day:"numeric",...(a?{hour:"numeric",minute:"2-digit"}:{})});return s=>{const c=r(s),u=/* @__PURE__ */new Date(0);return u.setUTCFullYear(c.year,c.month-1,c.day),u.setUTCHours(c.hour,c.minute,c.second,0),o.format(u);};}function jo(e,t){const n=t.presentation.mode==="auto"?t.presentation.styles:g("Automatic raw temporal formatting requires styles.");if(e.valueKind==="date"){const o=new Intl.DateTimeFormat(t.locale,{calendar:"gregory",timeZone:"UTC",dateStyle:n.dateStyle});return s=>o.format(Je(s.fields));}const r=e.valueKind==="instant",a=!r&&n.dateTime.timeStyle==="long"?"medium":n.dateTime.timeStyle,i=new Intl.DateTimeFormat(t.locale,{calendar:"gregory",timeZone:r||e.valueKind==="wall_datetime"&&t.sourceTimezone?t.calendarTimezone:"UTC",dateStyle:n.dateTime.dateStyle,timeStyle:a});return o=>r?i.format(o.instant):e.valueKind==="wall_datetime"&&t.sourceTimezone?i.format(ct(o.fields,t.sourceTimezone)):i.format(Je(o.fields));}function Xt(e,t,n){return{ok:!1,text:e,diagnostic:{code:n,message:`Raw temporal ${t.valueKind} value is ${n==="invalid_raw_temporal_value"?"malformed":"out of range"}.`}};}function An(e){const t=sr(e.metadata),n=st(e.format),r=n.presentation.mode==="auto"?jo(t,n):n.presentation.mode==="preset"?Ho(t,n,n.presentation.preset):Lo(t,n,n.presentation.dialect,n.presentation.pattern),a=Pn(t,n);return i=>{if(i===null)return{ok:!0,text:"",status:"empty"};const o=cr(i,t.valueKind);return o.status==="invalid_shape"?Xt(i,t,"invalid_raw_temporal_value"):o.status==="out_of_range"?Xt(i,t,"out_of_range_raw_temporal_value"):{ok:!0,text:r(o),status:"formatted",wallClock:a(o)};};}function qo(e){return An({metadata:e.metadata,format:e.format})(e.value);}function Zo(e){const t=In({format:e.authored,preferences:e.preferences,calendar:e.calendar});return{format:t,formatValue:An({metadata:e.metadata,format:t})};}const Xo={dateStyle:"short",dateTime:{dateStyle:"short",timeStyle:"short"}};class pe extends Error{constructor(n,r){super(r);_(this,"code");this.name="TemporalBucketContractError",this.code=n;}}const Ko=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Vo=["January","February","March","April","May","June","July","August","September","October","November","December"];function He(e){return{ok:!1,error:{code:"invalid_temporal_bucket_value",message:e}};}function Bo(e){return e%4===0&&(e%100!==0||e%400===0);}function Go(e,t){return t===2?Bo(e)?29:28:[4,6,9,11].includes(t)?30:31;}function Qo(e,t,n){const r=[0,3,2,5,0,3,5,1,4,6,2,4],a=t<3?e-1:e;return(a+Math.floor(a/4)-Math.floor(a/100)+Math.floor(a/400)+r[t-1]+n)%7;}function Ie(e){var t;return(t=e.calendar.fiscalCalendar)==null?void 0:t.yearStartMonth;}function Jo(e,t){return(e-t+12)%12%3===0;}function es(e,t){const{granularity:n}=t,r=Ie(t)??1;switch(n){case"second":return!0;case"minute":return e.second===0;case"hour":return e.minute===0&&e.second===0;case"day":return!0;case"week":return Qo(e.year,e.month,e.day)===t.calendar.weekStart;case"month":return e.day===1;case"quarter":return e.day===1&&Jo(e.month,r);case"year":return e.day===1&&e.month===r;}}function oe(e,t){if(e===null)return{ok:!0,value:null};const n=t.granularity==="second"||t.granularity==="minute"||t.granularity==="hour",r=n?/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e):/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return He(`Expected ${n?"YYYY-MM-DDTHH:mm:ss":"YYYY-MM-DD"} for ${t.granularity} granularity.`);const a={year:Number(r[1]),month:Number(r[2]),day:Number(r[3]),hour:n?Number(r[4]):0,minute:n?Number(r[5]):0,second:n?Number(r[6]):0};return a.year<1||a.month<1||a.month>12||a.day<1||a.day>Go(a.year,a.month)||a.hour>23||a.minute>59||a.second>59?He(`Invalid canonical ${t.granularity} bucket value ${e}.`):es(a,t)?{ok:!0,value:a}:He(`Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`);}const Ne=e=>`${T(e.year,4)}-${T(e.month)}-${T(e.day)}`;function _c(e,t,n){const r=oe(e,t);if(!r.ok||!r.value)return;const a=be({...r.value,millisecond:0},n.amount,n.unit),{granularity:i}=t;if(i==="second"||i==="minute"||i==="hour"){const o={...a,second:i==="second"?a.second:0,minute:i==="hour"?0:a.minute};return`${Ne(o)}T${T(o.hour)}:${T(o.minute)}:${T(o.second)}`;}return Ne(lr(a,i,t.calendar));}function $c(e,t){const n=oe(e,t);if(!n.ok||!n.value)return;const r={...n.value,millisecond:0},a=t.calendar.tz;return{startInclusive:ht(r,a).toISOString(),endExclusive:ht(be(r,1,t.granularity),a).toISOString(),timezone:a};}function Nc(e,t){const{granularity:n}=t;if(n==="second"||n==="minute"||n==="hour")return;const r=oe(e,t);if(!r.ok||!r.value)return;const a={...r.value,hour:0,minute:0,second:0,millisecond:0},i=be(be(a,1,n),-1,"day");return{first:Ne(a),last:Ne(i)};}function Ec(e){const{granularity:t,calendar:n}=e,r=(o,s)=>new Intl.DateTimeFormat("en-US",{...o,timeZone:"UTC"}).format(s),a=[`by ${t} in the ${n.tz} calendar`];t==="week"&&a.push(`weeks starting on ${r({weekday:"long"},new Date(Date.UTC(2023,0,1+n.weekStart)))}`);const i=Ie(e);return i&&(t==="quarter"||t==="year")&&a.push(`the fiscal year starting in ${r({month:"long"},new Date(Date.UTC(2e3,i-1,1)))}`),`${a.join(", ")}; each value is a bucket's start`;}function zn(e){if(!b(e))return{ok:!1,issues:[{path:"$",message:"Resolved temporal bucket format must be an object."}]};const t=[],n=/* @__PURE__ */new Set(["type","presentation","locale"]);for(const o of Object.keys(e))n.has(o)||t.push({path:o,message:`Unknown property "${o}".`});e.type!=="temporal_bucket"&&t.push({path:"type",message:"Expected temporal_bucket."});const r=e.presentation;if(!b(r))t.push({path:"presentation",message:"Expected a presentation object."});else{const o=r.mode,s=o==="preset"?/* @__PURE__ */new Set(["mode","preset"]):o==="pattern"?/* @__PURE__ */new Set(["mode","pattern"]):o==="auto"?/* @__PURE__ */new Set(["mode","styles"]):/* @__PURE__ */new Set(["mode"]);for(const c of Object.keys(r))s.has(c)||t.push({path:`presentation.${c}`,message:`Unknown property "${c}".`});if(o==="preset")br(r.preset)||t.push({path:"presentation.preset",message:"Expected a supported preset."});else if(o==="pattern"){if(typeof r.pattern!="string"||!r.pattern)t.push({path:"presentation.pattern",message:"Expected a non-empty pattern."});else{const c=ne(r.pattern,"grouped");c.ok||t.push({path:"presentation.pattern",message:c.message});}}else if(o==="auto"){const c=r.styles;(!b(c)||!["short","medium","long"].includes(String(c.dateStyle))||!b(c.dateTime)||!["short","medium","long"].includes(String(c.dateTime.dateStyle))||!["short","medium","long"].includes(String(c.dateTime.timeStyle))||Object.keys(c).some(u=>u!=="dateStyle"&&u!=="dateTime")||Object.keys(c.dateTime).some(u=>u!=="dateStyle"&&u!=="timeStyle"))&&t.push({path:"presentation.styles",message:"Expected complete resolved date and datetime styles."});}else t.push({path:"presentation.mode",message:"Expected auto, preset, or pattern."});}const a=te(e.locale);if(a||t.push({path:"locale",message:"Expected a supported base BCP 47 locale."}),t.length>0||!a||!b(r))return{ok:!1,issues:t};if(r.mode==="auto"){const o=r.styles;return{ok:!0,value:{type:"temporal_bucket",locale:a,presentation:{mode:"auto",styles:{dateStyle:o.dateStyle,dateTime:{dateStyle:o.dateTime.dateStyle,timeStyle:o.dateTime.timeStyle}}}}};}return{ok:!0,value:{type:"temporal_bucket",presentation:r.mode==="preset"?{mode:"preset",preset:r.preset}:{mode:"pattern",pattern:r.pattern},locale:a}};}function ts(e,t){const n=!!t.calendar.fiscalCalendar;return e==="fiscal_quarter_short"||e==="fiscal_year"?n:e==="quarter_short"||e==="quarter_long"||Hn(e)&&(t.granularity==="quarter"||t.granularity==="year")?!n:!0;}function Un(e,t){return on(e,t.granularity).ok?e.presentation.mode==="preset"?ts(e.presentation.preset,t):!(e.presentation.mode==="pattern"&&t.calendar.fiscalCalendar&&(t.granularity==="quarter"||t.granularity==="year")):!1;}function Kt(e,t){if(!(!e||e.presentation.mode==="auto"))return Un(e,t)?{type:"temporal_bucket",presentation:e.presentation}:void 0;}function Rn(e){var a;const t=te(e.locale);if(!t)throw new pe("invalid_temporal_bucket_format","Temporal bucket locale must be a supported base BCP 47 locale.");const n=Kt(e.cardFormat,e.metadata);if(n)return{format:{...n,locale:t},source:"card"};const r=((a=e.semanticFormat)==null?void 0:a.granularity)===e.metadata.granularity?Kt(e.semanticFormat.format,e.metadata):void 0;return r?{format:{...r,locale:t},source:"semantic"}:{format:{type:"temporal_bucket",locale:t,presentation:{mode:"auto",styles:e.styles??Xo}},source:"automatic"};}function T(e,t=2){return String(e).padStart(t,"0");}function J(e,t,n){if(t==="en-US")return(n==="short"?Ko:Vo)[e-1];const r=new Date(Date.UTC(2e3,e-1,15));return new Intl.DateTimeFormat(t,{calendar:"gregory",month:n,timeZone:"UTC"}).format(r);}function ns(e,t,n){return t.map(r=>{if(r.kind==="literal")return r.value;switch(r.value){case"YYYY":return T(e.year,4);case"YY":return T(e.year%100);case"MMMM":return J(e.month,n,"long");case"MMM":return J(e.month,n,"short");case"MM":return T(e.month);case"DD":return T(e.day);case"HH":return T(e.hour);case"hh":return T(e.hour%12||12);case"h":return String(e.hour%12||12);case"a":case"A":return Nn(n,e.hour);case"mm":return T(e.minute);case"ss":return T(e.second);}}).join("");}const Vt=/* @__PURE__ */new Map();function z(e,t){const n=`${e}:${JSON.stringify(t)}`,r=Vt.get(n);if(r)return r;const a=new Intl.DateTimeFormat(e,t);return Vt.set(n,a),a;}function ee(e){const t=/* @__PURE__ */new Date(0);return t.setUTCFullYear(e.year,e.month-1,e.day),t.setUTCHours(e.hour,e.minute,e.second,0),t;}function Bt(e,t,n){return z(t,{calendar:"gregory",dateStyle:n,timeZone:"UTC"}).format(ee(e));}function rs(e,t,n){return z(t,{calendar:"gregory",dateStyle:n.dateStyle,timeStyle:n.timeStyle==="long"?"medium":n.timeStyle,timeZone:"UTC"}).format(ee(e));}function as(e,t,n){var a;if(n==="short"){const i=ee(e),o=z(t,{calendar:"gregory",dateStyle:"short",timeZone:"UTC"}).formatToParts(i),s=o.findIndex(l=>l.type==="month"),c=o.findIndex(l=>l.type==="year"),u=(a=z(t,{calendar:"gregory",timeZone:"UTC",year:"numeric"}).formatToParts(i).find(l=>l.type==="year"))==null?void 0:a.value;if(s>=0&&c>=0&&u){const l=Math.min(s,c),f=Math.max(s,c);let m=!1;return o.slice(l,f+1).filter(d=>d.type==="day"?(m=!0,!1):m&&d.type==="literal"?(m=!1,!1):!0).map(d=>d.type==="year"?u:d.value).join("");}}return z(t,{calendar:"gregory",month:n==="short"?"numeric":n==="medium"?"short":"long",timeZone:"UTC",year:"numeric"}).format(ee(e));}function Ln(e,t){return Math.floor((e.month-t+12)%12/3)+1;}function Gt(e,t){return t===1||e.month<t?e.year:e.year+1;}function Wn(e){return e===1?"1st":e===2?"2nd":e===3?"3rd":`${e}th`;}function Hn(e){return e==="short"||e==="long"||e==="numeric"||e==="iso";}function je(e,t,n){return t==="iso"?`${T(e.year,4)}-${T(e.month)}-${T(e.day)}`:z(n,{calendar:"gregory",month:t==="numeric"?"numeric":t==="long"?"long":"short",day:"numeric",year:"numeric",timeZone:"UTC"}).format(ee(e));}function is(e,t,n,r){const a=Ln(e,1);switch(r){case"week":return t==="numeric"||t==="iso"?je(e,t,n):`Week of ${je(e,t,n)}`;case"month":return t==="iso"?`${T(e.year,4)}-${T(e.month)}`:t==="numeric"?`${T(e.month)}/${T(e.year,4)}`:`${J(e.month,n,t==="long"?"long":"short")} ${e.year}`;case"quarter":return t==="iso"?`${T(e.year,4)}-Q${a}`:t==="long"?`${Wn(a)} Quarter ${e.year}`:`Q${a} ${e.year}`;case"year":return String(e.year);default:return je(e,t,n);}}function et(e,t,n,r){if(Hn(t))return is(e,t,n,r.granularity);const a=Ie(r)??1,i=Ln(e,a);switch(t){case"week_of_short":return`Week of ${J(e.month,n,"short")} ${e.day}, ${e.year}`;case"week_of_long":return`Week of ${J(e.month,n,"long")} ${e.day}, ${e.year}`;case"quarter_short":return`Q${i} ${e.year}`;case"quarter_long":return`${Wn(i)} Quarter ${e.year}`;case"fiscal_quarter_short":return`Q${i} FY${Gt(e,a)}`;case"fiscal_year":return`FY${Gt(e,a)}`;}}function os(e,t,n,r){const a=Ie(t);switch(t.granularity){case"second":case"minute":case"hour":return rs(e,n,r.dateTime);case"day":return Bt(e,n,r.dateStyle);case"week":return`Week of ${Bt(e,n,r.dateStyle)}`;case"month":return as(e,n,r.dateStyle);case"quarter":return et(e,a?"fiscal_quarter_short":"quarter_short",n,t);case"year":return a?et(e,"fiscal_year",n,t):String(e.year);}}function Oc(e,t){if(t.granularity!=="second"&&t.granularity!=="minute"&&t.granularity!=="hour"&&t.granularity!=="day"&&t.granularity!=="month")return;const n=oe(e,t);if(!n.ok||n.value===null)return;const{year:r,month:a,day:i,hour:o,minute:s,second:c}=n.value;return{year:r,month:a,day:i,hour:o,minute:s,second:c};}function ut(e){const t=zn(e.format);if(!t.ok||!Un(t.value,e.metadata))throw new pe("invalid_temporal_bucket_format","Resolved temporal bucket format is invalid or inapplicable to its metadata.");const n=oe(e.value,e.metadata);if(!n.ok)throw new pe(n.error.code,n.error.message);if(n.value===null)return"(Blank)";const{presentation:r,locale:a}=t.value;if(r.mode==="auto")return os(n.value,e.metadata,a,r.styles);if(r.mode==="preset")return et(n.value,r.preset,a,e.metadata);const i=ne(r.pattern,"grouped");if(!i.ok)throw new pe("invalid_temporal_bucket_format",i.message);return ns(n.value,i.segments,a);}function ss(e,t){var a;const n=e[e.length-1];if(!n)return"";if(n.member.kind==="others")return"Others";const r=n.member.value;return r===null?"(Blank)":((a=t==null?void 0:t.get(n.levelId))==null?void 0:a(r))??(typeof r=="object"?r.value:String(r));}function cs(e,t,n){return e==="grand_total"?n??"Grand Total":e==="subtotal"?(n==null?void 0:n.split(rr).join(t))??`${t} Total`:t;}function Ic(e,t,n,r){var o;const a=e[e.length-1],i=t==="grand_total"?n.grand.label:a?(o=n.levels[a.levelId])==null?void 0:o.label:void 0;return cs(t,ss(e,r),i);}function Cc(e,t,n){return e.kind==="value"?(t==null?void 0:t(e.value))??"":e.kind==="null"?n.nullText:n.emptyText;}function Fc(e){const{path:t,previousPath:n,role:r,repeatLabels:a,levelCount:i}=e;return Array.from({length:i},(o,s)=>{const c=t.slice(0,s+1),u=r==="grand_total"?s===0:r==="subtotal"&&s===t.length-1,l=n&&n.length>s&&dt(n.slice(0,s+1))===dt(c);return{path:c,total:u,visible:u||t.length>s&&(a||!l||s===t.length-1)};});}function us(e){return(e==null?void 0:e.type)==="date"?{type:"raw_temporal",timezone:e.timezone,sourceTimezone:e.sourceTimezone,presentation:Oo(e)}:void 0;}function ls(e,t){return So(rt({override:e,model:t}).format,{preserveOmittedProperties:!0,numericInput:"canonical"});}function Pc(e,t,n){const r=/* @__PURE__ */new Map(),a=/* @__PURE__ */new Map(),i=(o,s)=>{const c=(s==="levels"?t.levelFormats:t.measureFormats)[o.id],u=o.semanticFormat,l=ls(c,u);s==="measures"&&r.set(o.id,{isNumeric:nr(o.column.dataType)==="number",hasTextAffixes:!!l&&!!("prefix"in l&&l.prefix||"suffix"in l&&l.suffix)});const f=m=>_n(m,void 0,{useFormattedValues:!0,timezone:n.calendar.tz,locale:n.valueFormat.locale,absence:t.absence});if(o.column.temporalBucket){const m=o.column.temporalBucket,d=Rn({metadata:m,cardFormat:(c==null?void 0:c.type)==="temporal_bucket"?c:void 0,semanticFormat:(u==null?void 0:u.type)==="temporal_bucket"?{granularity:m.granularity,format:u}:void 0,locale:n.valueFormat.locale,styles:{dateStyle:n.valueFormat.dateStyle,dateTime:n.valueFormat.dateTime}});return h=>typeof h=="string"?ut({value:h,metadata:m,format:d.format}):f(h);}if(o.column.rawTemporal){const m=rt({override:c,model:u}).format,{formatValue:d}=Zo({authored:us(m),metadata:o.column.rawTemporal,preferences:n.valueFormat,calendar:n.calendar});return h=>{if(typeof h!="string")return f(h);const S=d(h);return S.ok?S.text:f(h);};}if(re(l)){const m=Eo(l,n.valueFormat);return s==="measures"&&a.set(o.id,m),d=>typeof d=="number"||typeof d=="object"&&d!==null?Dn(d,m):f(d);}return(l==null?void 0:l.type)==="duration"&&s==="measures"&&a.set(o.id,l),(l==null?void 0:l.type)==="duration"?m=>typeof m=="number"||typeof m=="string"||typeof m=="object"&&m!==null?wn(typeof m=="object"?m.value:m,l):f(m):(l==null?void 0:l.type)==="string"?m=>m===null?f(m):`${l.prefix??""}${f(m)}${l.suffix??""}`:f;};return{levels:new Map(e.levels.map(o=>[o.id,i(o,"levels")])),measures:new Map(e.measures.map(o=>[o.id,i(o,"measures")])),measureSemantics:r,measureFormats:a,absence:t.absence};}class Qt extends Error{constructor(n){super(`invalid_presentation_execution_snapshot: ${n} Resave this report before running it again.`);_(this,"code","invalid_presentation_execution_snapshot");_(this,"deliveryBlocking",!0);this.name="PresentationExecutionSnapshotError";}}class Yc extends Error{constructor(n){super(`missing_resolved_raw_temporal_format: Column "${n}" has no captured presentation. Resave this report before running it again.`);_(this,"code","missing_resolved_raw_temporal_format");_(this,"deliveryBlocking",!0);this.name="MissingResolvedRawTemporalFormatError";}}function C(e,t,n){const r=new Set(t),a=Object.keys(e).find(i=>!r.has(i));if(a)throw new Error(`${n} contains unknown property "${a}"`);}function ms(e,t="scope"){if(!b(e))throw new Error(`${t} must be an object`);C(e,["dashboardId","cardId","attachmentIndex"],t);const n=typeof e.dashboardId=="string"?e.dashboardId.trim():"";if(!n)throw new Error(`${t}.dashboardId is required`);const r=typeof e.cardId=="string"?e.cardId.trim():void 0;if(e.cardId!==void 0&&!r)throw new Error(`${t}.cardId must be a non-empty string`);const a=e.attachmentIndex;if(a!==void 0&&(typeof a!="number"||!Number.isInteger(a)||a<0))throw new Error(`${t}.attachmentIndex must be a non-negative integer`);return{dashboardId:n,...(r?{cardId:r}:{}),...(typeof a=="number"?{attachmentIndex:a}:{})};}function U(e,t,n,r){if(e.kind!==t)return;C(e,["kind",n],r);const a=e[n];if(typeof a!="string"||!a.trim())throw new Error(`${r}.${n} is required`);return a;}function qe(e,t){if(!b(e))throw new Error(`${t} must be an object`);const n=U(e,"metric","metricId",t);if(n)return{kind:"metric",metricId:n};const r=U(e,"column","columnKey",t);if(r)return{kind:"column",columnKey:r};const a=U(e,"matrix_measure","measureId",t);if(a)return{kind:"matrix_measure",measureId:a};throw new Error(`${t} is not a valid numeric presentation target`);}const fs=["type","inputUnit","outputStyle","largestUnit","smallestUnit","maxUnits","prefix","suffix","negativeStyle"];function ds(e){return e==="millisecond"||e==="second"||e==="minute"||e==="hour"||e==="day";}const hs=["type","locale","pattern","timezone","sourceTimezone"];function gs(e,t){if(C(e,hs,t),typeof e.locale!="string"||!e.locale.trim())throw new Error(`${t}.locale must be a non-empty string`);for(const n of["pattern","timezone","sourceTimezone"])if(e[n]!==void 0&&typeof e[n]!="string")throw new Error(`${t}.${n} must be a string`);return{type:"date",locale:e.locale,...(typeof e.pattern=="string"?{pattern:e.pattern}:{}),...(typeof e.timezone=="string"?{timezone:e.timezone}:{}),...(typeof e.sourceTimezone=="string"?{sourceTimezone:e.sourceTimezone}:{})};}function ys(e,t){C(e,fs,t);for(const i of["inputUnit","largestUnit","smallestUnit"])if(e[i]!==void 0&&!ds(e[i]))throw new Error(`${t}.${i} must be a duration unit`);const n=e.outputStyle;if(n!==void 0&&n!=="compact"&&n!=="digital"&&n!=="long")throw new Error(`${t}.outputStyle must be compact, digital, or long`);const r=e.maxUnits;if(r!==void 0&&(typeof r!="number"||!Number.isInteger(r)||r<0||r>10))throw new Error(`${t}.maxUnits must be an integer from 0 to 10`);for(const i of["prefix","suffix"])if(e[i]!==void 0&&typeof e[i]!="string")throw new Error(`${t}.${i} must be a string`);const a=e.negativeStyle;if(a!==void 0&&a!=="minus"&&a!=="parentheses")throw new Error(`${t}.negativeStyle must be minus or parentheses`);return{type:"duration",...(e.inputUnit!==void 0?{inputUnit:e.inputUnit}:{}),...(n!==void 0?{outputStyle:n}:{}),...(e.largestUnit!==void 0?{largestUnit:e.largestUnit}:{}),...(e.smallestUnit!==void 0?{smallestUnit:e.smallestUnit}:{}),...(r!==void 0?{maxUnits:r}:{}),...(e.prefix!==void 0?{prefix:e.prefix}:{}),...(e.suffix!==void 0?{suffix:e.suffix}:{}),...(a!==void 0?{negativeStyle:a}:{})};}function ws(e,t){if(!b(e))throw new Error(`${t} must be an object`);if(e.kind==="field"){C(e,["kind","fieldId","role"],t);const a=typeof e.fieldId=="string"?e.fieldId.trim():"";if(!a)throw new Error(`${t}.fieldId is required`);const i=e.role;if(i!==void 0&&i!=="groupby"&&i!=="pivotby")throw new Error(`${t}.role must be groupby or pivotby`);return{kind:"field",fieldId:a,...(i?{role:i}:{})};}const n=U(e,"column","columnKey",t);if(n)return{kind:"column",columnKey:n};const r=U(e,"matrix_axis","axisInstanceId",t);if(r)return{kind:"matrix_axis",axisInstanceId:r};throw new Error(`${t} is not a valid temporal bucket presentation target`);}function ps(e,t){if(!b(e))throw new Error(`${t} must be an object`);const n=U(e,"column","columnKey",t);if(!n)throw new Error(`${t} must identify a column`);return{kind:"column",columnKey:n};}function Ts(e){return[e.dashboardId,e.cardId??null,e.attachmentIndex??null];}function Ee(e){switch(e.kind){case"metric":return[e.kind,e.metricId];case"column":return[e.kind,e.columnKey];case"matrix_measure":return[e.kind,e.measureId];case"field":return[e.kind,e.fieldId,e.role??""];case"matrix_axis":return[e.kind,e.axisInstanceId];}}function W(e,t){return e.dashboardId===t.dashboardId&&e.cardId===t.cardId&&e.attachmentIndex===t.attachmentIndex;}function H(e,t){const n=Ee(e),r=Ee(t);return n.length===r.length&&n.every((a,i)=>a===r[i]);}function bs(e){if(!Array.isArray(e))throw new Error("resolvedFormats must be an array");const t=/* @__PURE__ */new Set();return e.map((n,r)=>{var c,u;const a=`resolvedFormats.${r}`;if(!b(n))throw new Error(`${a} must be an object`);C(n,["scope","target","format"],a);const i=ms(n.scope,`${a}.scope`);if(!b(n.format))throw new Error(`${a}.format must be an object`);let o;switch(n.format.type){case"temporal_bucket":{const l=zn(n.format);if(!l.ok)throw new Error(`${a}.format is invalid: ${((c=l.issues[0])==null?void 0:c.message)??"invalid value"}`);o={scope:i,target:ws(n.target,`${a}.target`),format:l.value};break;}case"raw_temporal":o={scope:i,target:ps(n.target,`${a}.target`),format:st(n.format)};break;case"number":case"currency":case"percent":case"scientific":{const l=_o(n.format);if(!l.ok)throw new Error(`${a}.format is invalid: ${((u=l.issues[0])==null?void 0:u.message)??"invalid value"}`);o={scope:i,target:qe(n.target,`${a}.target`),format:l.value};break;}case"date":{const l=qe(n.target,`${a}.target`);if(l.kind!=="column")throw new Error(`${a}.target must identify a column for a date format`);o={scope:i,target:l,format:gs(n.format,`${a}.format`)};break;}case"duration":o={scope:i,target:qe(n.target,`${a}.target`),format:ys(n.format,`${a}.format`)};break;default:throw new Error(`${a}.format.type is unsupported`);}const s=JSON.stringify([...Ts(o.scope),...Ee(o.target)]);if(t.has(s))throw new Error(`${a} duplicates a scoped presentation target`);return t.add(s),o;});}function vs(e){try{if(!b(e))throw new Error("presentation execution snapshot must be an object");if(C(e,["version","reportContext","resolvedFormats"],"presentation execution snapshot"),e.version!==1)throw new Error("presentation execution snapshot version must be 1");const t=dr(e.reportContext);if(!t.ok){const n=t.issues[0];throw new Error(`presentation execution snapshot reportContext is invalid: ${n!=null&&n.path&&n.path!=="$"?`${n.path}: `:""}${(n==null?void 0:n.message)??"invalid value"}`);}return{version:1,reportContext:t.value,resolvedFormats:bs(e.resolvedFormats)};}catch(t){throw t instanceof Qt?t:new Qt(t instanceof Error?t.message:"Snapshot is invalid.");}}function xs(e){return vs({version:1,reportContext:e.reportContext,resolvedFormats:[...e.resolvedFormats]});}function Ac(e,t){const n=t.filter((r,a)=>!e.resolvedFormats.some(i=>W(i.scope,r.scope)&&H(i.target,r.target))&&t.findIndex(i=>W(i.scope,r.scope)&&H(i.target,r.target))===a);return n.length===0?e:xs({reportContext:e.reportContext,resolvedFormats:[...e.resolvedFormats,...n]});}function zc(e){const t=Ds(e);return re(t)?t:void 0;}function Ds(e){const t=e.snapshot.resolvedFormats.find(n=>n.format.type!=="temporal_bucket"&&n.format.type!=="raw_temporal"&&n.format.type!=="date"&&W(n.scope,e.scope)&&H(n.target,e.target));return t==null?void 0:t.format;}function Uc(e){const t=e.snapshot.resolvedFormats.find(n=>n.format.type==="date"&&W(n.scope,e.scope)&&H(n.target,e.target));return t==null?void 0:t.format;}function Rc(e){const t=e.snapshot.resolvedFormats.find(n=>n.format.type==="raw_temporal"&&W(n.scope,e.scope)&&H(n.target,e.target));return t==null?void 0:t.format;}function Lc(e){const t=e.snapshot.resolvedFormats.find(n=>n.format.type==="temporal_bucket"&&W(n.scope,e.scope)&&H(n.target,e.target));return t==null?void 0:t.format;}function Wc(e){var a;const t=/* @__PURE__ */new Set(),n=/* @__PURE__ */new Set();if(e.snapshot.resolvedFormats.forEach((i,o)=>{if(i.scope.attachmentIndex!==void 0)throw new Error(`resolvedFormats.${o}.scope.attachmentIndex is not valid for a card export`);if(i.scope.dashboardId!==e.expectedScope.dashboardId||i.scope.cardId!==e.expectedScope.cardId)throw new Error(`resolvedFormats.${o}.scope must match the executing dashboard/card`);if(i.target.kind==="field"&&i.format.type==="temporal_bucket"){const s=JSON.stringify(Ee(i.target));if(n.has(s))throw new Error(`resolvedFormats.${o} duplicates export field "${i.target.fieldId}"`);n.add(s);return;}if(i.target.kind!=="column")throw new Error(`resolvedFormats.${o}.target must identify an export column or temporal pivot field`);if(t.has(i.target.columnKey))throw new Error(`resolvedFormats.${o} duplicates export column "${i.target.columnKey}"`);t.add(i.target.columnKey);}),!e.useFormattedValues)return;if(!((a=e.visibleColumns)!=null&&a.length))throw new Error("visibleColumns must identify every formatted export column");const r=e.visibleColumns.find(i=>!t.has(i));if(r)throw new Error(`resolvedFormats is missing visible export column "${r}"`);}const Ss=/* @__PURE__ */new Set(["short","medium","long"]),Ms=/^(\d{4})-(\d{2})-(\d{2})$/,ks=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/,_s=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/,lt=" – ";function Hc(e){if(!b(e))return;const t=Object.keys(e);if(e.mode==="period_label"&&t.length===1)return{mode:"period_label"};if(e.mode==="style"&&t.length===2&&typeof e.dateStyle=="string"&&Ss.has(e.dateStyle))return{mode:"style",dateStyle:e.dateStyle};if(e.mode==="pattern"&&t.length===3&&e.dialect==="semaphor_tokens"&&typeof e.pattern=="string"&&$s(e.pattern)===null)return{mode:"pattern",dialect:"semaphor_tokens",pattern:e.pattern};}function $s(e){try{return Ro({dialect:"semaphor_tokens",pattern:e}),null;}catch(t){return t instanceof Error?t.message:"The pattern is invalid.";}}function jc(e){const{value:t,part:n,presentation:r,preferences:a,calendar:i}=e;if((r==null?void 0:r.mode)==="period_label"&&t.periodLabel&&n==="range")return{ok:!0,text:t.periodLabel};const[o,s]=t.bounds,u=s===void 0||n==="start"?[{raw:o,role:"start"}]:n==="end"?[{raw:s,role:"end"}]:[{raw:o,role:"start"},{raw:s,role:"end"}],l=u.map(({raw:h})=>Is(h,i.tz));if(l.some(h=>h===null))return{ok:!1,text:u.map(({raw:h})=>h).join(lt),diagnostic:{code:"invalid_temporal_input_value",message:"A date input bound is not a date or an instant."}};const f=t.precision==="day"?l.map((h,S)=>Fs(h,u[S].role,i.tz)):[],m=f.length>0&&f.every(h=>h!==null)?f:null;return{ok:!0,text:m?Ns(m,r,a,i):Es(l.map(h=>Cs(h,i.tz)),r,a,i)};}function Ns(e,t,n,r){const[a,i=a]=e;if((t==null?void 0:t.mode)==="pattern")return Zn(e.map(c=>qn(tt(c),"date",t.pattern,n,r)));const o=(t==null?void 0:t.mode)==="style"?t.dateStyle:n.dateStyle;if(!t||t.mode==="period_label"){const c=Ps(a,i,r);if(c)return ut({value:tt(a),metadata:{kind:"temporal_bucket",granularity:c,calendar:{tz:r.tz,weekStart:r.weekStart??1}},format:Rn({metadata:{kind:"temporal_bucket",granularity:c,calendar:{tz:r.tz,weekStart:r.weekStart??1}},locale:n.locale,styles:{dateStyle:o,dateTime:{...n.dateTime}}}).format});}const s=new Intl.DateTimeFormat(n.locale,{calendar:"gregory",timeZone:"UTC",dateStyle:o});return As(a,i)?s.format(Te(a)):jn(s,Te(a),Te(i));}function Es(e,t,n,r){if((t==null?void 0:t.mode)==="pattern")return Zn(e.map(s=>qn(s.toISOString(),"instant",t.pattern,n,r)));const a=new Intl.DateTimeFormat(n.locale,{calendar:"gregory",timeZone:r.tz,dateStyle:(t==null?void 0:t.mode)==="style"?t.dateStyle:n.dateTime.dateStyle,timeStyle:n.dateTime.timeStyle}),[i,o]=e;return o&&o.getTime()!==i.getTime()?jn(a,i,o):a.format(i);}function jn(e,t,n){const r=e;return typeof r.formatRange=="function"?r.formatRange(t,n):`${e.format(t)}${lt}${e.format(n)}`;}function qn(e,t,n,r,a){const i=In({format:{type:"raw_temporal",presentation:{mode:"pattern",dialect:"semaphor_tokens",pattern:n}},preferences:{...r,defaultCurrency:hr.defaultCurrency},calendar:{tz:a.tz}}),o=t==="date"&&Os(n)?"instant":t;return qo({value:o===t?e:ie(`${e}T00:00:00`,a.tz).toISOString(),metadata:{kind:"raw_temporal",valueKind:o},format:i}).text;}function Os(e){return /HH|mm|ss/.test(e);}function Zn(e){return e[1]===void 0||e[0]===e[1]?e[0]:e.join(lt);}function Is(e,t){const n=Ms.exec(e);if(n){const a={year:Number(n[1]),month:Number(n[2]),day:Number(n[3])};return zs(a)?{kind:"date",date:a}:null;}const r=_s.test(e)?new Date(e.replace(" ","T")):ks.test(e)?ie(e.replace(" ","T"),t):null;return r&&!Number.isNaN(r.getTime())?{kind:"instant",instant:r}:null;}function Cs(e,t){return e.kind==="instant"?e.instant:ie(`${tt(e.date)}T00:00:00`,t);}function Fs(e,t,n){if(e.kind==="date")return e.date;const r=mr(e.instant,n),a={year:r.year,month:r.month,day:r.day};if(r.hour===0&&r.minute===0&&r.second===0&&e.instant.getUTCMilliseconds()===0)return t==="start"?a:Ys(a,-1);const o=r.hour===23&&r.minute===59&&r.second===59;return t==="end"&&o?a:null;}function Ps(e,t,n){return n.fiscalCalendar||e.day!==1||e.year!==t.year||t.day!==Xn(t.year,t.month)?null:e.month===t.month?"month":e.month%3===1&&t.month===e.month+2?"quarter":e.month===1&&t.month===12?"year":null;}function tt(e){return`${String(e.year).padStart(4,"0")}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}`;}function Te(e){const t=/* @__PURE__ */new Date(0);return t.setUTCFullYear(e.year,e.month-1,e.day),t.setUTCHours(0,0,0,0),t;}function Ys(e,t){const n=Te(e);return n.setUTCDate(n.getUTCDate()+t),{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate()};}function As(e,t){return e.year===t.year&&e.month===t.month&&e.day===t.day;}function Xn(e,t){return new Date(Date.UTC(e,t,0)).getUTCDate();}function zs(e){return e.year>=1&&e.month>=1&&e.month<=12&&e.day>=1&&e.day<=Xn(e.year,e.month);}class Us extends Error{constructor(n,r){super(`${n}: ${r}`);_(this,"deliveryBlocking",!0);this.code=n,this.name="PivotHeaderPresentationError";}}function qc(e){var a;const t=e.mode??"formatted",n=e.members.map(i=>{var s;if(t==="canonical"||!i.temporalBucket)return i.value===null?"":String(i.value);const o=(s=e.resolveTemporalFormat)==null?void 0:s.call(e,i.fieldId);if(!o)throw new Us("missing_resolved_temporal_format",`Missing resolved temporal presentation for pivot field "${i.fieldId}"`);return ut({value:i.value,metadata:i.temporalBucket,format:o});}),r=((a=e.metricLabel)==null?void 0:a.trim())||void 0;return{memberLabels:n,...(r?{metricLabel:r}:{}),flattenedLabel:[...n,...(r?[r]:[])].join(" / ")};}function Zc(e){const t=/* @__PURE__ */new Map();return e.forEach(n=>{n.id&&t.set(n.id,(t.get(n.id)??0)+1);}),e.flatMap(n=>n.id&&(t.get(n.id)??0)>1?[ir(n)]:[]);}export{ms as $,fc as A,hc as B,gc as C,$n as D,yc as E,mo as F,wc as G,fo as H,pc as I,_e as J,A as K,Tc as L,dc as M,bc as N,wo as O,po as P,vc as Q,To as R,xc as S,Pc as T,ko as U,_o as V,Dc as W,$o as X,Eo as Y,Qt as Z,Yc as _,Oi as a,nt as a$,bs as a0,vs as a1,xs as a2,Ac as a3,zc as a4,Uc as a5,Rc as a6,Lc as a7,Wc as a8,gt as a9,qo as aA,Zo as aB,Hc as aC,$s as aD,jc as aE,Us as aF,qc as aG,Zc as aH,ls as aI,Bs as aJ,Qs as aK,Ii as aL,ss as aM,Ic as aN,Fc as aO,Cc as aP,Vs as aQ,oc as aR,kn as aS,tc as aT,ac as aU,bo as aV,Ei as aW,rc as aX,Gs as aY,gr as aZ,yr as a_,wr as aa,br as ab,ne as ac,on as ad,Js as ae,Xo as af,pe as ag,oe as ah,_c as ai,$c as aj,Nc as ak,Ec as al,zn as am,Rn as an,Oc as ao,ut as ap,Oo as aq,L as ar,st as as,In as at,Sc as au,Mc as av,Ao as aw,kc as ax,Ro as ay,An as az,So as b,j as b0,mn as b1,ge as b2,w as b3,Pr as b4,De as b5,yt as b6,le as b7,ec as b8,cn as b9,Or as ba,Ra as bb,jt as bc,O as bd,Ht as be,Lt as bf,us as bg,ie as bh,cs as bi,ic as c,Ve as d,at as e,Ds as f,bn as g,vn as h,re as i,xn as j,Dn as k,Ci as l,sc as m,wn as n,ki as o,rt as p,co as q,ui as r,uo as s,mc as t,cc as u,uc as v,nc as w,lc as x,ot as y,_n as z};
1
+ var Kn=Object.defineProperty;var Vn=(e,t,n)=>t in e?Kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _=(e,t,n)=>Vn(e,typeof t!="symbol"?t+"":t,n);import{b2 as Bn,b3 as Gn,T as Qn,K as B,U as Jn,b4 as Jt,b5 as er,aX as tr,l as nr,m as dt,O as rr}from"./validators-U8IL8djK.js";import{l as ar,r as ir}from"./matrix-operation-contract-DceN49RX.js";import{o as or,p as sr,a as cr,c as ur,i as ht,s as be,Y as lr,J as mr}from"./raw-temporal-value-B4Md6Xfb.js";import{z as p}from"zod";import{E as en,l as tn}from"./export-file-format-B-wQNHIn.js";import{j as fr,i as ve}from"./analytics-base-schemas-DMFrDqn_.js";import{b as dr}from"./report-runtime-context-CkxgMKr6.js";import{canonicalizeSupportedLocale as te,canonicalizeSupportedCurrencyCode as Ze,DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as hr}from"../value-format-preferences/index.js";function Vs(e,t){return t.levelLabels[e.id]??e.field.label??e.field.name;}function Bs(e,t){return t.measureLabels[e.id]??(e.kind==="aggregate"?e.field.label??e.field.name:e.definition.label);}function Gs(e){return Jn.parse(gr(e));}function gr(e){const t=Bn.parse(e),n=r=>({grand:{visible:!0,position:"after"},levels:Object.fromEntries(r.map(a=>[a.id,{visible:!0,position:"before"}]))});return Gn.parse({version:1,spec:t,presentation:{layout:{kind:"compact"},absence:{emptyText:"—",nullText:""},levelLabels:{},measureLabels:{},levelFormats:{},measureFormats:{},totals:{rows:n(t.rows),columns:n(t.columns)}},defaultView:{rows:{depth:0,overrides:[]},columns:{depth:t.columns.length>1?1:0,overrides:[]}}});}function yr(e,t){const n=new Map(e.map(r=>[B(r),r]));for(const r of t??[])n.set(B(r),r);return[...n.values()];}function Qs(e){const{spec:t,presentation:n,defaults:r,session:a}=Qn.parse(e),i=new Map(yr(t.sorts,a==null?void 0:a.sorts).map(s=>[B(s),s]));for(const s of["rows","columns"])for(const c of t[s]){const u={axis:s,levelId:c.id,scope:{kind:"level"},target:{kind:"member"},direction:"asc",nulls:"last"};i.has(B(u))||i.set(B(u),u);}const o=(s,c)=>({depth:Math.min(s.depth,Math.max(0,c-1)),overrides:s.overrides.filter(u=>u.path.length<c)});return{spec:{...t,sorts:[...i.values()]},presentation:n,view:{rows:o((a==null?void 0:a.rows)??r.rows,t.rows.length),columns:o((a==null?void 0:a.columns)??r.columns,t.columns.length),sorts:(a==null?void 0:a.sorts)??[]}};}const gt=["YYYY","MMMM","MMM","YY","MM","DD","HH","mm","ss"],wr=["hh","h","a","A"],pr={semaphor_tokens:gt,grouped:[...gt,...wr]},Tr=/* @__PURE__ */new Set([" ","-","/",":",".",",","T"]),se=["day","week","month","quarter","year"],nn={week_of_short:["week"],week_of_long:["week"],quarter_short:["quarter"],quarter_long:["quarter"],fiscal_quarter_short:["quarter"],fiscal_year:["year"],short:se,long:se,numeric:se,iso:se};function br(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(nn,e);}function vr(e,t,n){return pr[n].find(r=>e.startsWith(r,t));}function F(e){return{ok:!1,code:"invalid_temporal_bucket_pattern",message:e};}function ne(e,t){var i;if(!e)return F("Type a pattern, for example HH:mm.");if(e.trim()!==e)return F("A pattern can't start or end with a space.");const n=[];let r=0,a=!1;for(;r<e.length;){const o=vr(e,r,t);if(o){if(a)return F("Put a separator between two parts, for example HH:mm.");n.push({kind:"token",value:o}),r+=o.length,a=!0;continue;}const s=e[r];if(!Tr.has(s))return F(`"${s}" isn't a pattern letter.`);if(n.length===0)return F("A pattern can't start with a separator.");const c=n[n.length-1];c.kind==="literal"?c.value+=s:n.push({kind:"literal",value:s}),r+=1,a=!1;}return((i=n[n.length-1])==null?void 0:i.kind)!=="token"?F("A pattern can't end with a separator."):{ok:!0,segments:n};}function xr(e){return e.flatMap(t=>t.kind==="token"?[t.value]:[]);}function ce(e,t){return e.filter(n=>t.includes(n)).length;}function Z(e,t){return e.some(n=>t.includes(n));}const rn=["YYYY","YY"],an=["MMMM","MMM","MM"],Dr=[...rn,...an,"DD"],Xe=["HH","hh","h"],Sr=["hh","h"],Ke=["a","A"],Mr=[...Xe,"mm","ss",...Ke],ue="A date needs its year, month and day.";function kr(e,t){if(new Set(e).size!==e.length)return"Use each part once.";if(ce(e,Xe)>1)return"Use one hour: HH for a 24-hour clock, or h with a for 12-hour.";if(ce(e,Ke)>1)return"Use a once to show AM or PM.";const n=Z(e,Sr),r=Z(e,Ke);if(r&&!n)return"a shows AM or PM: pair it with h or hh, not HH.";if(n&&!r)return"Add a after a 12-hour hour, so 2:30 reads 2:30 PM.";const a=ce(e,rn)===1,i=ce(e,an)===1,o=e.includes("DD"),s=Z(e,Xe),c=Z(e,Mr),u=!Z(e,Dr)||a&&i&&o;switch(t){case"second":return!s||!e.includes("mm")||!e.includes("ss")?"A second shows hours, minutes and seconds, for example h:mm:ss a.":u?void 0:ue;case"minute":return!s||!e.includes("mm")?"A minute shows hours and minutes, for example h:mm a.":u?void 0:ue;case"hour":return s?u?void 0:ue:"An hour shows its hour, for example h a.";case"day":case"week":return c?`A ${t} shows a date without a time, for example MMM DD, YYYY.`:a&&i&&o?void 0:ue;case"month":return a&&i&&!o&&!c?void 0:"A month shows its month and year, for example MMM YYYY.";case"quarter":return"A quarter takes a preset, such as Q1 2024, not a pattern.";case"year":return a&&!i&&!o&&!c?void 0:"A year shows only its year, for example YYYY.";}}function on(e,t){if(e.presentation.mode==="auto")return{ok:!0};if(e.presentation.mode==="preset"){const a=nn[e.presentation.preset];return a.includes(t)?{ok:!0}:{ok:!1,code:"incompatible_temporal_bucket_preset",message:`Preset ${e.presentation.preset} requires ${a.join(", ")} granularity.`};}const n=ne(e.presentation.pattern,"grouped");if(!n.ok)return n;const r=kr(xr(n.segments),t);return r?{ok:!1,code:"incompatible_temporal_bucket_pattern",message:r}:{ok:!0,segments:n.segments};}function Js(e,t){if(!(!e||!t))return on(e,t).ok?e:void 0;}function w(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):/* @__PURE__ */new Date(NaN);}function N(e,t){return e instanceof Date?new e.constructor(t):new Date(t);}const sn=6048e5,_r=864e5,cn=6e4,un=36e5,ec=525600,le=43200,yt=1440;let $r={};function j(){return $r;}function G(e,t){var s,c,u,l;const n=j(),r=(t==null?void 0:t.weekStartsOn)??((c=(s=t==null?void 0:t.locale)==null?void 0:s.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((l=(u=n.locale)==null?void 0:u.options)==null?void 0:l.weekStartsOn)??0,a=w(e),i=a.getDay(),o=(i<r?7:0)+i-r;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a;}function xe(e){return G(e,{weekStartsOn:1});}function ln(e){const t=w(e),n=t.getFullYear(),r=N(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const a=xe(r),i=N(e,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const o=xe(i);return t.getTime()>=a.getTime()?n+1:t.getTime()>=o.getTime()?n:n-1;}function wt(e){const t=w(e);return t.setHours(0,0,0,0),t;}function De(e){const t=w(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n;}function Nr(e,t){const n=wt(e),r=wt(t),a=+n-De(n),i=+r-De(r);return Math.round((a-i)/_r);}function Er(e){const t=ln(e),n=N(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),xe(n);}function ge(e,t){const n=w(e),r=w(t),a=n.getTime()-r.getTime();return a<0?-1:a>0?1:a;}function Or(e){return N(e,Date.now());}function Ir(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]";}function Cr(e){if(!Ir(e)&&typeof e!="number")return!1;const t=w(e);return!isNaN(Number(t));}function Fr(e,t){const n=w(e),r=w(t),a=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth();return a*12+i;}function Pr(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r;};}function Yr(e,t){return+w(e)-+w(t);}function Ar(e){const t=w(e);return t.setHours(23,59,59,999),t;}function zr(e){const t=w(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t;}function Ur(e){const t=w(e);return+Ar(t)==+zr(t);}function Rr(e,t){const n=w(e),r=w(t),a=ge(n,r),i=Math.abs(Fr(n,r));let o;if(i<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-a*i);let s=ge(n,r)===-a;Ur(w(e))&&i===1&&ge(e,r)===1&&(s=!1),o=a*(i-Number(s));}return o===0?0:o;}function Lr(e,t,n){const r=Yr(e,t)/1e3;return Pr(n==null?void 0:n.roundingMethod)(r);}function Wr(e){const t=w(e),n=N(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n;}const Hr={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},jr=(e,t,n)=>{let r;const a=Hr[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r;};function Fe(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth];};}const qr={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Zr={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Xr={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Kr={date:Fe({formats:qr,defaultWidth:"full"}),time:Fe({formats:Zr,defaultWidth:"full"}),dateTime:Fe({formats:Xr,defaultWidth:"full"})},Vr={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Br=(e,t,n,r)=>Vr[e];function X(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,s=n!=null&&n.width?String(n.width):o;a=e.formattingValues[s]||e.formattingValues[o];}else{const o=e.defaultWidth,s=n!=null&&n.width?String(n.width):e.defaultWidth;a=e.values[s]||e.values[o];}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i];};}const Gr={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Qr={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Jr={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},ea={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ta={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},na={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ra=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd";}return n+"th";},aa={ordinalNumber:ra,era:X({values:Gr,defaultWidth:"wide"}),quarter:X({values:Qr,defaultWidth:"wide",argumentCallback:e=>e-1}),month:X({values:Jr,defaultWidth:"wide"}),day:X({values:ea,defaultWidth:"wide"}),dayPeriod:X({values:ta,defaultWidth:"wide",formattingValues:na,defaultFormattingWidth:"wide"})};function K(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const o=i[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?oa(s,f=>f.test(o)):ia(s,f=>f.test(o));let u;u=e.valueCallback?e.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const l=t.slice(o.length);return{value:u,rest:l};};}function ia(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n;}function oa(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n;}function sa(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const a=r[0],i=t.match(e.parsePattern);if(!i)return null;let o=e.valueCallback?e.valueCallback(i[0]):i[0];o=n.valueCallback?n.valueCallback(o):o;const s=t.slice(a.length);return{value:o,rest:s};};}const ca=/^(\d+)(th|st|nd|rd)?/i,ua=/\d+/i,la={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ma={any:[/^b/i,/^(a|c)/i]},fa={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},da={any:[/1/i,/2/i,/3/i,/4/i]},ha={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},ga={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ya={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},wa={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},pa={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Ta={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ba={ordinalNumber:sa({matchPattern:ca,parsePattern:ua,valueCallback:e=>parseInt(e,10)}),era:K({matchPatterns:la,defaultMatchWidth:"wide",parsePatterns:ma,defaultParseWidth:"any"}),quarter:K({matchPatterns:fa,defaultMatchWidth:"wide",parsePatterns:da,defaultParseWidth:"any",valueCallback:e=>e+1}),month:K({matchPatterns:ha,defaultMatchWidth:"wide",parsePatterns:ga,defaultParseWidth:"any"}),day:K({matchPatterns:ya,defaultMatchWidth:"wide",parsePatterns:wa,defaultParseWidth:"any"}),dayPeriod:K({matchPatterns:pa,defaultMatchWidth:"any",parsePatterns:Ta,defaultParseWidth:"any"})},mn={code:"en-US",formatDistance:jr,formatLong:Kr,formatRelative:Br,localize:aa,match:ba,options:{weekStartsOn:0,firstWeekContainsDate:1}};function va(e){const t=w(e);return Nr(t,Wr(t))+1;}function xa(e){const t=w(e),n=+xe(t)-+Er(t);return Math.round(n/sn)+1;}function fn(e,t){var l,f,m,d;const n=w(e),r=n.getFullYear(),a=j(),i=(t==null?void 0:t.firstWeekContainsDate)??((f=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((d=(m=a.locale)==null?void 0:m.options)==null?void 0:d.firstWeekContainsDate)??1,o=N(e,0);o.setFullYear(r+1,0,i),o.setHours(0,0,0,0);const s=G(o,t),c=N(e,0);c.setFullYear(r,0,i),c.setHours(0,0,0,0);const u=G(c,t);return n.getTime()>=s.getTime()?r+1:n.getTime()>=u.getTime()?r:r-1;}function Da(e,t){var s,c,u,l;const n=j(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(s=t==null?void 0:t.locale)==null?void 0:s.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((l=(u=n.locale)==null?void 0:u.options)==null?void 0:l.firstWeekContainsDate)??1,a=fn(e,t),i=N(e,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),G(i,t);}function Sa(e,t){const n=w(e),r=+G(n,t)-+Da(n,t);return Math.round(r/sn)+1;}function y(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r;}const $={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return y(t==="yy"?r%100:r,t.length);},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):y(n+1,2);},d(e,t){return y(e.getDate(),t.length);},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m.";}},h(e,t){return y(e.getHours()%12||12,t.length);},H(e,t){return y(e.getHours(),t.length);},m(e,t){return y(e.getMinutes(),t.length);},s(e,t){return y(e.getSeconds(),t.length);},S(e,t){const n=t.length,r=e.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return y(a,t.length);}},P={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},pt={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"});}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"});}return $.y(e,t);},Y:function(e,t,n,r){const a=fn(e,r),i=a>0?a:1-a;if(t==="YY"){const o=i%100;return y(o,2);}return t==="Yo"?n.ordinalNumber(i,{unit:"year"}):y(i,t.length);},R:function(e,t){const n=ln(e);return y(n,t.length);},u:function(e,t){const n=e.getFullYear();return y(n,t.length);},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return y(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"});}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return y(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"});}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return $.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"});}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return y(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"});}},w:function(e,t,n,r){const a=Sa(e,r);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):y(a,t.length);},I:function(e,t,n){const r=xa(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):y(r,t.length);},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):$.d(e,t);},D:function(e,t,n){const r=va(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):y(r,t.length);},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"});}},e:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return y(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"});}},c:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return y(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"});}},i:function(e,t,n){const r=e.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return y(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"});}},a:function(e,t,n){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"});}},b:function(e,t,n){const r=e.getHours();let a;switch(r===12?a=P.noon:r===0?a=P.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"});}},B:function(e,t,n){const r=e.getHours();let a;switch(r>=17?a=P.evening:r>=12?a=P.afternoon:r>=4?a=P.morning:a=P.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"});}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"});}return $.h(e,t);},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):$.H(e,t);},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):y(r,t.length);},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):y(r,t.length);},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):$.m(e,t);},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):$.s(e,t);},S:function(e,t){return $.S(e,t);},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return bt(r);case"XXXX":case"XX":return I(r);case"XXXXX":case"XXX":default:return I(r,":");}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return bt(r);case"xxxx":case"xx":return I(r);case"xxxxx":case"xxx":default:return I(r,":");}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Tt(r,":");case"OOOO":default:return"GMT"+I(r,":");}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Tt(r,":");case"zzzz":default:return"GMT"+I(r,":");}},t:function(e,t,n){const r=Math.trunc(e.getTime()/1e3);return y(r,t.length);},T:function(e,t,n){const r=e.getTime();return y(r,t.length);}};function Tt(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+t+y(i,2);}function bt(e,t){return e%60===0?(e>0?"-":"+")+y(Math.abs(e)/60,2):I(e,t);}function I(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=y(Math.trunc(r/60),2),i=y(r%60,2);return n+a+t+i;}const vt=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"});}},dn=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"});}},Ma=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return vt(e,t);let i;switch(r){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break;}return i.replace("{{date}}",vt(r,t)).replace("{{time}}",dn(a,t));},ka={p:dn,P:Ma},_a=/^D+$/,$a=/^Y+$/,Na=["D","DD","YY","YYYY"];function Ea(e){return _a.test(e);}function Oa(e){return $a.test(e);}function Ia(e,t,n){const r=Ca(e,t,n);if(console.warn(r),Na.includes(e))throw new RangeError(r);}function Ca(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;}const Fa=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Pa=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Ya=/^'([^]*?)'?$/,Aa=/''/g,za=/[a-zA-Z]/;function nt(e,t,n){var l,f,m,d,h,S,mt,ft;const r=j(),a=(n==null?void 0:n.locale)??r.locale??mn,i=(n==null?void 0:n.firstWeekContainsDate)??((f=(l=n==null?void 0:n.locale)==null?void 0:l.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((d=(m=r.locale)==null?void 0:m.options)==null?void 0:d.firstWeekContainsDate)??1,o=(n==null?void 0:n.weekStartsOn)??((S=(h=n==null?void 0:n.locale)==null?void 0:h.options)==null?void 0:S.weekStartsOn)??r.weekStartsOn??((ft=(mt=r.locale)==null?void 0:mt.options)==null?void 0:ft.weekStartsOn)??0,s=w(e);if(!Cr(s))throw new RangeError("Invalid time value");let c=t.match(Pa).map(D=>{const x=D[0];if(x==="p"||x==="P"){const Ce=ka[x];return Ce(D,a.formatLong);}return D;}).join("").match(Fa).map(D=>{if(D==="''")return{isToken:!1,value:"'"};const x=D[0];if(x==="'")return{isToken:!1,value:Ua(D)};if(pt[x])return{isToken:!0,value:D};if(x.match(za))throw new RangeError("Format string contains an unescaped latin alphabet character `"+x+"`");return{isToken:!1,value:D};});a.localize.preprocessor&&(c=a.localize.preprocessor(s,c));const u={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return c.map(D=>{if(!D.isToken)return D.value;const x=D.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&Oa(x)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&Ea(x))&&Ia(x,t,String(e));const Ce=pt[x[0]];return Ce(s,x,a.localize,u);}).join("");}function Ua(e){const t=e.match(Ya);return t?t[1].replace(Aa,"'"):e;}function Ra(e,t,n){const r=j(),a=(n==null?void 0:n.locale)??r.locale??mn,i=2520,o=ge(e,t);if(isNaN(o))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:o});let c,u;o>0?(c=w(t),u=w(e)):(c=w(e),u=w(t));const l=Lr(u,c),f=(De(u)-De(c))/1e3,m=Math.round((l-f)/60);let d;if(m<2)return n!=null&&n.includeSeconds?l<5?a.formatDistance("lessThanXSeconds",5,s):l<10?a.formatDistance("lessThanXSeconds",10,s):l<20?a.formatDistance("lessThanXSeconds",20,s):l<40?a.formatDistance("halfAMinute",0,s):l<60?a.formatDistance("lessThanXMinutes",1,s):a.formatDistance("xMinutes",1,s):m===0?a.formatDistance("lessThanXMinutes",1,s):a.formatDistance("xMinutes",m,s);if(m<45)return a.formatDistance("xMinutes",m,s);if(m<90)return a.formatDistance("aboutXHours",1,s);if(m<yt){const h=Math.round(m/60);return a.formatDistance("aboutXHours",h,s);}else{if(m<i)return a.formatDistance("xDays",1,s);if(m<le){const h=Math.round(m/yt);return a.formatDistance("xDays",h,s);}else if(m<le*2)return d=Math.round(m/le),a.formatDistance("aboutXMonths",d,s);}if(d=Rr(u,c),d<12){const h=Math.round(m/le);return a.formatDistance("xMonths",h,s);}else{const h=d%12,S=Math.trunc(d/12);return h<3?a.formatDistance("aboutXYears",S,s):h<9?a.formatDistance("overXYears",S,s):a.formatDistance("almostXYears",S+1,s);}}function La(e,t){return Ra(e,Or(e),t);}function Wa(){return Object.assign({},j());}function tc(e,t){const r=Za(e);let a;if(r.date){const c=Xa(r.date,2);a=Ka(c.restDateString,c.year);}if(!a||isNaN(a.getTime()))return/* @__PURE__ */new Date(NaN);const i=a.getTime();let o=0,s;if(r.time&&(o=Va(r.time),isNaN(o)))return/* @__PURE__ */new Date(NaN);if(r.timezone){if(s=Ba(r.timezone),isNaN(s))return/* @__PURE__ */new Date(NaN);}else{const c=new Date(i+o),u=/* @__PURE__ */new Date(0);return u.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),u.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),u;}return new Date(i+o+s);}const me={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Ha=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,ja=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,qa=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Za(e){const t={},n=e.split(me.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],me.timeZoneDelimiter.test(t.date)&&(t.date=e.split(me.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const a=me.timezone.exec(r);a?(t.time=r.replace(a[1],""),t.timezone=a[1]):t.time=r;}return t;}function Xa(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const a=r[1]?parseInt(r[1]):null,i=r[2]?parseInt(r[2]):null;return{year:i===null?a:i*100,restDateString:e.slice((r[1]||r[2]).length)};}function Ka(e,t){if(t===null)return/* @__PURE__ */new Date(NaN);const n=e.match(Ha);if(!n)return/* @__PURE__ */new Date(NaN);const r=!!n[4],a=V(n[1]),i=V(n[2])-1,o=V(n[3]),s=V(n[4]),c=V(n[5])-1;if(r)return ti(t,s,c)?Ga(t,s,c):/* @__PURE__ */new Date(NaN);{const u=/* @__PURE__ */new Date(0);return!Ja(t,i,o)||!ei(t,a)?/* @__PURE__ */new Date(NaN):(u.setUTCFullYear(t,i,Math.max(a,o)),u);}}function V(e){return e?parseInt(e):1;}function Va(e){const t=e.match(ja);if(!t)return NaN;const n=Pe(t[1]),r=Pe(t[2]),a=Pe(t[3]);return ni(n,r,a)?n*un+r*cn+a*1e3:NaN;}function Pe(e){return e&&parseFloat(e.replace(",","."))||0;}function Ba(e){if(e==="Z")return 0;const t=e.match(qa);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),a=t[3]&&parseInt(t[3])||0;return ri(r,a)?n*(r*un+a*cn):NaN;}function Ga(e,t,n){const r=/* @__PURE__ */new Date(0);r.setUTCFullYear(e,0,4);const a=r.getUTCDay()||7,i=(t-1)*7+n+1-a;return r.setUTCDate(r.getUTCDate()+i),r;}const Qa=[31,null,31,30,31,30,31,31,30,31,30,31];function hn(e){return e%400===0||e%4===0&&e%100!==0;}function Ja(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Qa[t]||(hn(e)?29:28));}function ei(e,t){return t>=1&&t<=(hn(e)?366:365);}function ti(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6;}function ni(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25;}function ri(e,t){return t>=0&&t<=59;}const ai=Object.freeze({source:"automatic"});function ii(e,t){var r,a;const n=e.preferences;switch(t){case"tooltip":return(r=n==null?void 0:n.tooltipConfig)==null?void 0:r.valueFormat;case"dataLabel":case"pieLabel":return(a=n==null?void 0:n.dataLabelsConfig)==null?void 0:a.valueFormat;default:return;}}function xt(e,t){const n=e.config;if(n)return[...(n.metricColumns??[]),...(n.groupByColumns??[]),...(n.detailColumns??[]),...(n.pivotByColumns??[])].find(r=>r.id===t);}function oi(e,t){if(t.kind==="field")return xt(e,t.fieldId);if(t.kind==="pivot")return xt(e,t.metricId);}function si(e,t,n){var r,a,i,o,s,c,u,l,f;switch(t.kind){case"field":case"pivot":return n!=null&&n.format&&n.formatOrigin==="override"?n.format:void 0;case"result":return(i=(a=(r=e.preferences)==null?void 0:r.sqlColumns)==null?void 0:a[t.key])==null?void 0:i.format;case"sqlKpiValue":return(s=(o=e.preferences)==null?void 0:o.sqlKpiValue)==null?void 0:s.format;case"matrixMeasure":return(u=(c=e.config)==null?void 0:c.matrix)==null?void 0:u.presentation.measureFormats[t.measureId];case"matrixLevel":return(f=(l=e.config)==null?void 0:l.matrix)==null?void 0:f.presentation.levelFormats[t.levelId];}}function ci(e){if(!e)return;if(e.format&&e.formatOrigin!=="override")return e.format;const t=e.semanticTemporalPresentation;return t&&t.granularity===e.granularity?t.format:void 0;}function rt(e){return e.surface?{format:e.surface,source:"surface"}:e.override?{format:e.override,source:"override"}:e.model?{format:e.model,source:"model"}:e.snapshot?{format:e.snapshot,source:"snapshot"}:ai;}function ui(e){var o;const{card:t,column:n,surface:r}=e,a=oi(t,n),i=n.kind==="field"?n.fieldId:n.kind==="pivot"?n.metricId:void 0;return rt({surface:r?ii(t,r):void 0,override:si(t,n,a),model:(i!==void 0?(o=e.modelFormats)==null?void 0:o[i]:void 0)??e.catalogFormat,snapshot:ci(a)});}function li(e,t){const n=r=>r&&typeof r=="object"&&!Array.isArray(r)?Object.fromEntries(Object.keys(r).sort().map(a=>[a,n(r[a])])):r;return JSON.stringify(n(e))===JSON.stringify(n(t));}const mi=["metricColumns","groupByColumns","detailColumns","pivotByColumns"],Dt=/* @__PURE__ */new WeakMap();function nc(e,t){const n=t==null?void 0:t.modelFormats;if(!e||!n||Object.keys(n).length===0)return e;let r=Dt.get(e);if(r||Dt.set(e,r=/* @__PURE__ */new WeakMap()),r.has(n))return r.get(n);const a=fi(e,n);return r.set(n,a),a;}function fi(e,t){const n={config:e};let r;for(const a of mi){const i=e[a];if(!(i!=null&&i.length))continue;let o=!1;const s=i.map(c=>{const u=ui({card:n,column:{kind:"field",fieldId:c.id},modelFormats:t});return u.source!=="model"||li(u.format,c.format)?c:(o=!0,{...c,format:u.format});});o&&((r??(r={...e}))[a]=s);}return r??e;}const M=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function St(e){return e?e.period?e.period:e.unit&&e.count?`${e.unit}s`:e.days<=1?"day":"days":"period";}function di(e,t){return t!=null&&t.period?e===1?`Previous ${t.period}`:`${M(e,t.period)} back`:t!=null&&t.unit&&t.count?e===1?`Previous ${M(t.count,t.unit)}`:`${M(e,"period")} back`:t&&t.days<=1?e===1?"Previous day":`${M(e,"day")} back`:t?e===1?`Previous ${t.days} days`:`${M(e,"period")} back`:e===1?"Previous period":`${M(e,"period")} back`;}function fe(e){return e.charAt(0).toLowerCase()+e.slice(1);}function hi(e){return e.period?`a ${e.period}`:e.unit&&e.count?M(e.count,e.unit):e.days<=1?"a day":M(e.days,"day");}function rc(e,t){const n=Ve(e,t).label,r=or(t).map(a=>`"${Ve(a,t).label}"`);return{message:`"${n}" lands inside the window it compares (${hi(t)}), so it shows no comparison there.`,fix:`Pick a step that clears the window: ${r.join(", ")}.`};}function Ve(e,t){const n=ar(e);if(n.kind==="target")return{label:`Target · ${n.targetValue.toLocaleString("en-US")}`,sentence:`a target of ${n.targetValue.toLocaleString("en-US")}`};const r=n.offset??1,a=n.matchWeekdays?", matching weekdays":"";if(n.unit==="period"){const o=di(r,t);return{label:o,sentence:r===1?`the ${fe(o)}`:fe(o)};}if(n.unit==="day"){const o=r===1?"The day before":`${M(r,"day")} back`;return{label:o,sentence:fe(o)};}const i=r===1?`Same ${St(t)} last ${n.unit}${a}`:`Same ${St(t)} ${M(r,n.unit)} back${a}`;return{label:i,sentence:`the ${fe(i)}`};}function gi(e){return(e==null?void 0:e.kind)==="field_date"?`the ${JSON.stringify(e.label)} filter`:"the dashboard date";}function ac(e,t){const n=t.source==="explicit"?"set on the measure":`from the dashboard date comparison on ${gi(t.owner)}`;return`${e} is compared with ${Ve(t.spec).sentence} (${n})`;}function re(e){if(!e||typeof e!="object")return!1;const t=e.type;return t==="number"||t==="currency"||t==="percent"||t==="scientific";}function ic(e){return re(e)||!!e&&typeof e=="object"&&e.type==="duration";}const gn=["day","hour","minute","second","millisecond"],Be={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},yi={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},wi={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function pi(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond";}function yn(e,t){return pi(e)?e:t;}function Mt(e,t){return gn.indexOf(yn(e,t));}function Ti(e,t){const n=Mt(e,"day"),r=Mt(t,"second"),a=Math.min(n,r),i=Math.max(n,r);return gn.slice(a,i+1);}function bi(e,t){return e*Be[yn(t,"second")];}function vi(e,t){const n=Ti(t.largestUnit,t.smallestUnit),r=n[n.length-1],a=Be[r];let i=Math.round(e/a)*a;return n.map(o=>{const s=Be[o],c=Math.floor(i/s);return i-=c*s,{unit:o,value:c};});}function xi(e,t){const n=e.filter(i=>i.value!==0),r=n.length>0?n:[e[e.length-1]],a=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):r.length;return r.slice(0,a).map(i=>`${i.value}${yi[i.unit]}`).join(" ");}function Di(e,t){const n=e.filter(i=>i.value!==0),r=n.length>0?n:[e[e.length-1]],a=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):r.length;return r.slice(0,a).map(i=>{const[o,s]=wi[i.unit];return`${i.value} ${i.value===1?o:s}`;}).join(" ");}function Si(e){const t=e.some(c=>c.unit==="day"&&c.value!==0),n=e.some(c=>c.unit==="millisecond"),r=e.findIndex(c=>c.value!==0),a=Math.max(0,e.length-2),i=t?0:r===-1?a:Math.min(r,a),o=r===-1?e.slice(a):e.slice(i);if(o.length===0)return"0";const s=o.map((c,u)=>c.unit==="millisecond"?String(c.value).padStart(3,"0"):u===0?String(c.value):String(c.value).padStart(2,"0")).join(":");return n?s.replace(/:(\d{3})$/,".$1"):s;}function Mi(e,t,n){const r=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${r})`:`-${r}`:r;}function wn(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 r=t.inputUnit||"second",a=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",i=n<0,o=Math.abs(bi(n,r)),s=vi(o,t),c=a==="digital"?Si(s):a==="long"?Di(s,t.maxUnits):xi(s,t.maxUnits);return Mi(c,i,t);}function ki(e,t){return wn(e!==null&&typeof e=="object"?e.value: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"});}let kt;function _t(e,t){const n=e.format;return n(t);}function _i(e,t){if(kt??(kt=_t(new Intl.NumberFormat("en-US",{useGrouping:!1,maximumFractionDigits:6}),"9007199254740993.000009")==="9007199254740993.000009"),!kt)throw new RangeError("This runtime cannot format exact decimal strings.");const n=Number(e);if(!Number.isFinite(n)||n===0&&e!=="0")throw new RangeError("Exact value is outside the Intl formatting range; use raw text.");return _t(t,e);}function ae(e){return typeof e=="number"?e<0:e.value.startsWith("-");}function Q(e){return typeof e=="number"?Math.abs(e):ae(e)?{...e,value:e.value.slice(1)}:e;}function $i(e){return typeof e=="number"?e===0:/^-?0*(\.0*)?$/.test(e.value);}function pn(e,t){return typeof e=="number"?e*t:{kind:"exact_number",type:"decimal",value:Jt(e.value,t)};}function Se(e,t){return t===0?e:typeof e=="number"?e/10**t:{kind:"exact_number",type:"decimal",value:Jt(e.value,`1e-${t}`)};}function R(e,t){return typeof e=="number"?t.format(e):_i(e.value,t);}function $t(e){if(!e)return!1;const t=e.toLowerCase().replace("_","-");return t==="en-in"||t.startsWith("en-in-");}function Nt(e,t){const n=Q(e),r=a=>typeof n=="number"?n>=a:er(n.value,String(a))>=0;return r(1e12)?{power:12,suffix:"T"}:r(1e9)?{power:9,suffix:"B"}:$t(t)&&r(1e7)?{power:7,suffix:"Cr"}:r(1e6)?{power:6,suffix:"M"}:$t(t)&&r(1e5)?{power:5,suffix:"L"}:r(1e3)?{power:3,suffix:"K"}:{power:0,suffix:""};}function Ge(e,t){try{const n=q(t);return Nt(e,n);}catch{return Nt(e,"en-US");}}const Tn=500,de=/* @__PURE__ */new Map(),he=/* @__PURE__ */new Map();function E(e,t={}){const n=`${e}|${JSON.stringify(t)}`;let r=de.get(n);return r||(r=new Intl.NumberFormat(e,t),de.size>=Tn&&de.clear(),de.set(n,r)),r;}function Ni(e){let t=he.get(e);if(t===void 0){try{E(e),t=!0;}catch{t=!1;}he.size>=Tn&&he.clear(),he.set(e,t);}return t;}function q(e){return e&&Ni(e)?e:"en-US";}function at(e,t){if(e==null||Number.isNaN(e))return"";const n=q(t==null?void 0:t.locale);let r=e;if(t!=null&&t.multiplyBy&&(r=pn(r,t.multiplyBy)),t!=null&&t.useSuffix){const{power:i,suffix:o}=Ge(r,n);r=Se(r,i);const s=R(r,E(n,{minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}));return`${(t==null?void 0:t.prefix)??""}${s}${o}${(t==null?void 0:t.suffix)??""}`;}const a=R(r,E(n,{minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}));if(t!=null&&t.negativeInParentheses&&ae(r)){const i=a.replace("-","");return`(${(t==null?void 0:t.prefix)??""}${i}${(t==null?void 0:t.suffix)??""})`;}return`${(t==null?void 0:t.prefix)??""}${a}${(t==null?void 0:t.suffix)??""}`;}function bn(e,t){if(e==null||Number.isNaN(e))return"";const n=q(t==null?void 0:t.locale),r=(t==null?void 0:t.currency)||"USD",a=ae(e),i=!!(t!=null&&t.negativeInParentheses&&a),o=i?Q(e):e;try{if(t!=null&&t.useSuffix){const{power:c,suffix:u}=Ge(o,n),l=Se(o,c),m=`${R(l,E(n,{style:"currency",currency:r,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}))}${u}`;return i?`(${m})`:m;}const s=R(o,E(n,{style:"currency",currency:r,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}));return i?`(${s})`:s;}catch{const s=Q(e),c=t!=null&&t.useSuffix?Ge(s,n):{power:0,suffix:""},u=at(Se(s,c.power),{locale:n,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}),l=`${r} ${u}${c.suffix}`;return a?t!=null&&t.negativeInParentheses?`(${l})`:`-${l}`:l;}}function vn(e,t){if(e==null||Number.isNaN(e))return"";const n=q(t==null?void 0:t.locale),a=(t==null?void 0:t.alreadyPercent)??(t==null?void 0:t.percentValueMode)==="whole"?Se(e,2):e;return R(a,E(n,{style:"percent",minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}));}function xn(e,t){if(e==null||Number.isNaN(e))return"";const n=q(t==null?void 0:t.locale);return R(e,E(n,{notation:"scientific",minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2}));}function Ei(e,t){const n=t??"auto",r=n==="never"?Q(e):e,a=!ae(r)&&(n==="always"||n==="exceptZero"&&!$i(r));return{value:r,plus:a};}function oc(e){if(!e||!("signDisplay"in e))return e;const{signDisplay:t,...n}=e;return n;}function Dn(e,t){if(e==null||Number.isNaN(e))return"";const n=t.scale===void 0?e:pn(e,t.scale),r=Ei(n,t.signDisplay),a=r.value,i=r.plus?"+":"",o=t.negativeStyle==="parentheses"&&ae(a),s=o?Q(a):a,c={style:t.type==="number"?"decimal":t.type,locale:t.locale,currency:t.currency,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,useGrouping:t.useGrouping,percentValueMode:t.percentValueMode,useSuffix:t.compact};let u;switch(t.type){case"currency":u=bn(s,c);break;case"percent":u=vn(s,c);break;case"scientific":u=xn(s,c);break;default:u=at(s,c);break;}const l=`${t.prefix??""}${i}${u}${t.suffix??""}`;return o?`(${l})`:l;}function Oi(e,t){return t.type==="duration"?e==null?"":ki(e,t):Dn(e,t);}function Ii(e,t="en-US"){if((e==null?void 0:e.style)==="duration")return{type:"duration",...e.duration,prefix:e.prefix,suffix:e.suffix,negativeStyle:e.negativeStyle};const n=q((e==null?void 0:e.locale)||t),r=(e==null?void 0:e.style)||"decimal",a=r==="decimal"?"number":r;return{type:a,locale:n,currency:a==="currency"?(e==null?void 0:e.currency)||"USD":void 0,minimumFractionDigits:(e==null?void 0:e.minimumFractionDigits)??0,maximumFractionDigits:(e==null?void 0:e.maximumFractionDigits)??2,useGrouping:(e==null?void 0:e.useGrouping)??!0,percentValueMode:a==="percent"?(e==null?void 0:e.percentValueMode)??"whole":void 0,scale:e==null?void 0:e.scale,compact:e==null?void 0:e.compact,negativeStyle:e==null?void 0:e.negativeStyle,prefix:e==null?void 0:e.prefix,suffix:e==null?void 0:e.suffix};}function Ci(e,t,n="en-US"){if(e==null||typeof e=="number"&&isNaN(e))return"";const r=Ii(t,n);return r.type==="currency"&&E(r.locale,{style:"currency",currency:r.currency}),Oi(e,r);}function sc(e,t,n){const r={style:t==="currency"?"currency":t==="percent"?"percent":"decimal",locale:n==null?void 0:n.locale,currency:n==null?void 0:n.currency,minimumFractionDigits:n==null?void 0:n.decimalPlaces,maximumFractionDigits:n==null?void 0:n.decimalPlaces,useSuffix:n==null?void 0:n.useSuffix,prefix:n==null?void 0:n.prefix,suffix:n==null?void 0:n.suffix,negativeInParentheses:n==null?void 0:n.negativeInParentheses,multiplyBy:n==null?void 0:n.multiplyBy};switch(t){case"currency":return bn(e,r);case"percent":return vn(e,r);case"scientific":return xn(e,r);default:return at(e,r);}}function Et(e,t,n){const r=Wa(),a=Yi(e,n.timeZone,n.locale??r.locale);return"formatToParts"in a?Fi(a,t):Pi(a,t);}function Fi(e,t){const n=e.formatToParts(t);for(let r=n.length-1;r>=0;--r)if(n[r].type==="timeZoneName")return n[r].value;}function Pi(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/ [\w-+ ]+$/.exec(n);return r?r[0].substr(1):"";}function Yi(e,t,n){return new Intl.DateTimeFormat(n?[n.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e});}function Ai(e,t){const n=Wi(t);return"formatToParts"in n?Ui(n,e):Ri(n,e);}const zi={year:0,month:1,day:2,hour:3,minute:4,second:5};function Ui(e,t){try{const n=e.formatToParts(t),r=[];for(let a=0;a<n.length;a++){const i=zi[n[a].type];i!==void 0&&(r[i]=parseInt(n[a].value,10));}return r;}catch(n){if(n instanceof RangeError)return[NaN];throw n;}}function Ri(e,t){const n=e.format(t),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[parseInt(r[3],10),parseInt(r[1],10),parseInt(r[2],10),parseInt(r[4],10),parseInt(r[5],10),parseInt(r[6],10)];}const Ye={},Ot=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(/* @__PURE__ */new Date("2014-06-25T04:00:00.123Z")),Li=Ot==="06/25/2014, 00:00:00"||Ot==="‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";function Wi(e){return Ye[e]||(Ye[e]=Li?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),Ye[e];}function it(e,t,n,r,a,i,o){const s=/* @__PURE__ */new Date(0);return s.setUTCFullYear(e,t,n),s.setUTCHours(r,a,i,o),s;}const It=36e5,Hi=6e4,Ae={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Oe(e,t,n){if(!e)return 0;let r=Ae.timezoneZ.exec(e);if(r)return 0;let a,i;if(r=Ae.timezoneHH.exec(e),r)return a=parseInt(r[1],10),Ct(a)?-(a*It):NaN;if(r=Ae.timezoneHHMM.exec(e),r){a=parseInt(r[2],10);const o=parseInt(r[3],10);return Ct(a,o)?(i=Math.abs(a)*It+o*Hi,r[1]==="+"?-i:i):NaN;}if(Zi(e)){t=new Date(t||Date.now());const o=n?t:ji(t),s=Qe(o,e);return-(n?s:qi(t,s,e));}return NaN;}function ji(e){return it(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds());}function Qe(e,t){const n=Ai(e,t),r=it(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime();let a=e.getTime();const i=a%1e3;return a-=i>=0?i:1e3+i,r-a;}function qi(e,t,n){let a=e.getTime()-t;const i=Qe(new Date(a),n);if(t===i)return t;a-=i-t;const o=Qe(new Date(a),n);return i===o?i:Math.max(i,o);}function Ct(e,t){return-23<=e&&e<=23&&(t==null||0<=t&&t<=59);}const Ft={};function Zi(e){if(Ft[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Ft[e]=!0,!0;}catch{return!1;}}const Xi=60*1e3,Ki={X:function(e,t,n){const r=ze(n.timeZone,e);if(r===0)return"Z";switch(t){case"X":return Pt(r);case"XXXX":case"XX":return Y(r);case"XXXXX":case"XXX":default:return Y(r,":");}},x:function(e,t,n){const r=ze(n.timeZone,e);switch(t){case"x":return Pt(r);case"xxxx":case"xx":return Y(r);case"xxxxx":case"xxx":default:return Y(r,":");}},O:function(e,t,n){const r=ze(n.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+Vi(r,":");case"OOOO":default:return"GMT"+Y(r,":");}},z:function(e,t,n){switch(t){case"z":case"zz":case"zzz":return Et("short",e,n);case"zzzz":default:return Et("long",e,n);}}};function ze(e,t){const n=e?Oe(e,t,!0)/Xi:(t==null?void 0:t.getTimezoneOffset())??0;if(Number.isNaN(n))throw new RangeError("Invalid time zone specified: "+e);return n;}function Me(e,t){const n=e<0?"-":"";let r=Math.abs(e).toString();for(;r.length<t;)r="0"+r;return n+r;}function Y(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Me(Math.floor(r/60),2),i=Me(Math.floor(r%60),2);return n+a+t+i;}function Pt(e,t){return e%60===0?(e>0?"-":"+")+Me(Math.abs(e)/60,2):Y(e,t);}function Vi(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.floor(r/60),i=r%60;return i===0?n+String(a):n+String(a)+t+Me(i,2);}function Yt(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+e-+t;}const Sn=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,Ue=36e5,At=6e4,Bi=2,v={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:Sn};function ke(e,t={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(e===null)return/* @__PURE__ */new Date(NaN);const n=t.additionalDigits==null?Bi:Number(t.additionalDigits);if(n!==2&&n!==1&&n!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]")return new Date(e.getTime());if(typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]")return new Date(e);if(Object.prototype.toString.call(e)!=="[object String]")return/* @__PURE__ */new Date(NaN);const r=Gi(e),{year:a,restDateString:i}=Qi(r.date,n),o=Ji(i,a);if(o===null||isNaN(o.getTime()))return/* @__PURE__ */new Date(NaN);if(o){const s=o.getTime();let c=0,u;if(r.time&&(c=eo(r.time),c===null||isNaN(c)))return/* @__PURE__ */new Date(NaN);if(r.timeZone||t.timeZone){if(u=Oe(r.timeZone||t.timeZone,new Date(s+c)),isNaN(u))return/* @__PURE__ */new Date(NaN);}else u=Yt(new Date(s+c)),u=Yt(new Date(s+c+u));return new Date(s+c+u);}else return/* @__PURE__ */new Date(NaN);}function Gi(e){const t={};let n=v.dateTimePattern.exec(e),r;if(n?(t.date=n[1],r=n[3]):(n=v.datePattern.exec(e),n?(t.date=n[1],r=n[2]):(t.date=null,r=e)),r){const a=v.timeZone.exec(r);a?(t.time=r.replace(a[1],""),t.timeZone=a[1].trim()):t.time=r;}return t;}function Qi(e,t){if(e){const n=v.YYY[t],r=v.YYYYY[t];let a=v.YYYY.exec(e)||r.exec(e);if(a){const i=a[1];return{year:parseInt(i,10),restDateString:e.slice(i.length)};}if(a=v.YY.exec(e)||n.exec(e),a){const i=a[1];return{year:parseInt(i,10)*100,restDateString:e.slice(i.length)};}}return{year:null};}function Ji(e,t){if(t===null)return null;let n,r,a;if(!e||!e.length)return n=/* @__PURE__ */new Date(0),n.setUTCFullYear(t),n;let i=v.MM.exec(e);if(i)return n=/* @__PURE__ */new Date(0),r=parseInt(i[1],10)-1,Ut(t,r)?(n.setUTCFullYear(t,r),n):/* @__PURE__ */new Date(NaN);if(i=v.DDD.exec(e),i){n=/* @__PURE__ */new Date(0);const o=parseInt(i[1],10);return ro(t,o)?(n.setUTCFullYear(t,0,o),n):/* @__PURE__ */new Date(NaN);}if(i=v.MMDD.exec(e),i){n=/* @__PURE__ */new Date(0),r=parseInt(i[1],10)-1;const o=parseInt(i[2],10);return Ut(t,r,o)?(n.setUTCFullYear(t,r,o),n):/* @__PURE__ */new Date(NaN);}if(i=v.Www.exec(e),i)return a=parseInt(i[1],10)-1,Rt(a)?zt(t,a):/* @__PURE__ */new Date(NaN);if(i=v.WwwD.exec(e),i){a=parseInt(i[1],10)-1;const o=parseInt(i[2],10)-1;return Rt(a,o)?zt(t,a,o):/* @__PURE__ */new Date(NaN);}return null;}function eo(e){let t,n,r=v.HH.exec(e);if(r)return t=parseFloat(r[1].replace(",",".")),Re(t)?t%24*Ue:NaN;if(r=v.HHMM.exec(e),r)return t=parseInt(r[1],10),n=parseFloat(r[2].replace(",",".")),Re(t,n)?t%24*Ue+n*At:NaN;if(r=v.HHMMSS.exec(e),r){t=parseInt(r[1],10),n=parseInt(r[2],10);const a=parseFloat(r[3].replace(",","."));return Re(t,n,a)?t%24*Ue+n*At+a*1e3:NaN;}return null;}function zt(e,t,n){t=t||0,n=n||0;const r=/* @__PURE__ */new Date(0);r.setUTCFullYear(e,0,4);const a=r.getUTCDay()||7,i=t*7+n+1-a;return r.setUTCDate(r.getUTCDate()+i),r;}const to=[31,28,31,30,31,30,31,31,30,31,30,31],no=[31,29,31,30,31,30,31,31,30,31,30,31];function Mn(e){return e%400===0||e%4===0&&e%100!==0;}function Ut(e,t,n){if(t<0||t>11)return!1;if(n!=null){if(n<1)return!1;const r=Mn(e);if(r&&n>no[t]||!r&&n>to[t])return!1;}return!0;}function ro(e,t){if(t<1)return!1;const n=Mn(e);return!(n&&t>366||!n&&t>365);}function Rt(e,t){return!(e<0||e>52||t!=null&&(t<0||t>6));}function Re(e,t,n){return!(e<0||e>=25||t!=null&&(t<0||t>=60)||n!=null&&(n<0||n>=60));}const ao=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function io(e,t,n={}){t=String(t);const r=t.match(ao);if(r){const a=ke(n.originalDate||e,n);t=r.reduce(function(i,o){if(o[0]==="'")return i;const s=i.indexOf(o),c=i[s-1]==="'",u=i.replace(o,"'"+Ki[o[0]](a,o,n)+"'");return c?u.substring(0,s-1)+u.substring(s+1):u;},t);}return nt(e,t,n);}function oo(e,t,n){e=ke(e,n);const r=Oe(t,e,!0),a=new Date(e.getTime()-r),i=/* @__PURE__ */new Date(0);return i.setFullYear(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()),i.setHours(a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()),i;}function kn(e,t,n,r){return r={...r,timeZone:t,originalDate:e},io(oo(e,t,{timeZone:r.timeZone}),n,r);}function ie(e,t,n){if(typeof e=="string"&&!e.match(Sn))return ke(e,{...n,timeZone:t});e=ke(e,n);const r=it(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()).getTime(),a=Oe(t,new Date(r));return new Date(r+a);}function cc(e,t){return e&&e!=="auto"?e:t;}function uc(e,t=/* @__PURE__ */new Date()){try{const n={timeZone:e,timeZoneName:"short"},a=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(i=>i.type==="timeZoneName");return(a==null?void 0:a.value)||e;}catch{return e;}}function lc(e){try{const t={timeZone:e,timeZoneName:"long"},r=new Intl.DateTimeFormat("en-US",t).formatToParts(/* @__PURE__ */new Date()).find(a=>a.type==="timeZoneName");return(r==null?void 0:r.value)||e;}catch{return e;}}function ot(e,t="auto"){if(!e)return/* @__PURE__ */new Date(NaN);const n=e.endsWith("Z"),r=/[+-]\d{2}:?\d{2}$/.test(e),a=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||r||a?new Date(e):/* @__PURE__ */new Date(e+"Z");if(t==="local"){if(n||r){const i=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(i);}return new Date(e);}else return t==="UTC"?n?new Date(e):r?new Date(e):/* @__PURE__ */new Date(e+"Z"):n||r||a?new Date(e):ie(e,t);}const so="MM/dd/yyyy",co=(e,t,n,r="auto")=>{if(!e)return"";try{const a=ot(e,r);if(isNaN(a.getTime()))return e;const o=(t&&t.trim()?t:so).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?kn(a,n,o):nt(a,o);}catch(a){return console.error("Date formatting error:",a),e;}};function mc(e,t,n="auto"){if(e)try{const r=ot(e,n);if(isNaN(r.getTime()))return;const a="yyyy M d H m s",i=t&&t!=="auto"?kn(r,t,a):nt(r,a),[o,s,c,u,l,f]=i.split(" ").map(Number);return{year:o,month:s,day:c,hour:u,minute:l,second:f};}catch{return;}}const uo=(e,t="auto")=>{if(!e)return"";try{const n=ot(e,t);return isNaN(n.getTime())?e:La(n,{addSuffix:!0});}catch(n){return console.error("Relative time formatting error:",n),e;}};function lo(e,t,n,r){const a=e instanceof Date?e.toISOString():String(e),i=(r==null?void 0:r.browserTimezone)||n,o=(r==null?void 0:r.isSqlCard)??!1;if(t!=null&&t.useRelativeTime)return uo(a,(t==null?void 0:t.sourceTimezone)||"auto");const s=t!=null&&t.useCustomFormat&&t!=null&&t.customFormat?t.customFormat:(t==null?void 0:t.format)||"MM/dd/yyyy";return co(a,s,t!=null&&t.timezone&&(t==null?void 0:t.timezone)!=="auto"?t.timezone:o?i:n,(t==null?void 0:t.sourceTimezone)||"auto");}function _n(e,t,n){var o,s;if(e==null)return e===null?((o=n.absence)==null?void 0:o.nullText)??"":((s=n.absence)==null?void 0:s.emptyText)??"";const r=tr(e)?e:void 0,a=r?r.value:e,i=r??(typeof e=="number"?e:void 0);if(!n.useFormattedValues||!t)return String(a);switch(t.type){case"number":return i!==void 0?Ci(i,t.numberFormat,n.locale):String(a);case"date":return lo(a,t.dateFormat,n.timezone,{browserTimezone:n.browserTimezone,isSqlCard:n.isSqlCard});case"progress":return i!==void 0?`${a}%`:String(a);case"badge":case"link":case"text":case"none":default:return String(a);}}function fc(e,t){return t.visibleColumns.map(n=>{const r=e[n],a=t.columnSettings[n];return _n(r,a,{useFormattedValues:t.useFormattedValues,timezone:t.timezone,locale:t.locale});});}const $n=1e4,mo=1e6,dc=5e6,hc=1024**3,gc=1024**3;function yc(e){return e>$n;}function wc(e){return e.cardType==="matrixTable"?"try-direct":e.loadedRowCount===null||e.loadedRowCount<=$n?"direct":e.loadedRowCount<=mo?"background":"blocked";}const fo=5*1024*1024,pc=64*1024*1024,_e=p.number().int().positive().max(Number.MAX_SAFE_INTEGER),ye=p.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),$e=ye.refine(e=>e>0),ho=e=>!!e&&e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\");function A(e,t){const n=t.split("/");if(n.length!==5||n[0]!=="exports"||n[1]!==e||n[2]!=="attempts"||!n.every(ho))throw new Error("Invalid Matrix export artifact namespace.");return{attemptId:n[3],filename:n[4]};}function Tc(e,t,n){const r=`exports/${e}/attempts/${t}/${n}`;return A(e,r),r;}const bc=p.object({acquisition:p.literal("continuation"),jobId:p.string().min(1),sequence:$e,deadlineAt:_e}),go=["application/json",...en.map(e=>tn(e).partContentType)],yo=p.object({key:p.string(),content:p.string(),contentType:p.enum(go),encoding:p.literal("gzip-base64").optional()}).refine(e=>!e.encoding||e.contentType==="application/json"||e.contentType===tn("xlsx").partContentType,"Unsupported Matrix artifact encoding."),wo=p.discriminatedUnion("kind",[p.object({kind:p.literal("work"),sequence:$e,checkpointKey:p.string(),objects:p.array(yo).min(2).max(4),deadlineAt:_e}),p.object({kind:p.literal("committed"),sequence:$e,done:p.boolean(),deadlineAt:_e})]);function po(e){const t=JSON.stringify(e);if(t===void 0||new TextEncoder().encode(t).byteLength>fo)throw new RangeError("Matrix export batch exceeds its transport byte limit.");}function vc(e,t){const n=wo.parse(e);if(po(e),n.deadlineAt!==t.deadlineAt)throw new Error("Matrix deadline does not match the job.");if(n.sequence!==t.sequence+(n.kind==="committed"?1:0))throw new Error("Invalid Matrix batch sequence.");if(n.kind==="work"){A(t.jobId,n.checkpointKey);for(const r of n.objects)A(t.jobId,r.key);}return n;}const To=p.object({acquisition:p.literal("continuation"),deadlineAt:_e,chunks:p.array(p.object({chunkNumber:$e,dataKey:p.string()})).min(1),totalRows:ye,totalBytes:ye,fileKey:p.string().min(1).optional(),fileSize:ye.optional(),format:p.enum(en).optional(),sheetKey:p.string().min(1).optional()}).refine(e=>e.fileKey===void 0==(e.fileSize===void 0),"Incomplete published Matrix artifact.").refine(e=>e.format==="xlsx"==(e.sheetKey!==void 0),"An Excel Matrix manifest names its sheet layout, and only it does.");function xc(e,t,n){const r=To.parse(e);if(r.deadlineAt!==n)throw new Error("Matrix deadline does not match the job.");return r.chunks.forEach((a,i)=>{if(a.chunkNumber!==i+1)throw new Error("Invalid committed Matrix chunk order.");A(t,a.dataKey);}),r.fileKey!==void 0&&A(t,r.fileKey),r.sheetKey!==void 0&&A(t,r.sheetKey),r;}const bo="en-US";function Lt(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t;}function we(e){if(!(typeof e!="number"||!Number.isFinite(e)))return Math.max(0,Math.min(10,Math.trunc(e)));}function vo(e){return e==="currency"?2:e==="percent"?1:e==="scientific"?2:0;}function xo(e,t,n){const r=we(t.minimumFractionDigits),a=we(t.maximumFractionDigits);if(typeof r=="number"||typeof a=="number"){const s=r??0,c=a??Math.max(s,2);return{minimumFractionDigits:Math.min(s,c),maximumFractionDigits:Math.max(s,c)};}const i=we(t.decimals);if(typeof i=="number")return{minimumFractionDigits:i,maximumFractionDigits:i};if(n!=null&&n.preserveOmittedProperties)return{};const o=vo(e);return{minimumFractionDigits:o,maximumFractionDigits:o};}function Do(e,t){if(!(typeof t!="string"||e==="percent"&&t==="%"))return t;}function Wt(e){const t=Lt(e.locale),n=Lt(e.currency),r=Do(e.type,e.suffix);return{...e,...(t!==e.locale?{locale:t}:{}),...(n!==e.currency?{currency:n}:{}),...(r!==e.suffix?{suffix:r}:{})};}function O(e,t,n){const r={...t,type:e};if((n==null?void 0:n.numericInput)==="canonical"&&re(r))return Wt(r);const a=xo(e,t,n),i=typeof t.prefix=="string"?t.prefix:void 0,o={type:e,locale:t.locale,minimumFractionDigits:a.minimumFractionDigits,maximumFractionDigits:a.maximumFractionDigits,useGrouping:typeof t.useGrouping=="boolean"?t.useGrouping:typeof t.thousandsSeparator=="boolean"?t.thousandsSeparator:!0,prefix:i,suffix:t.suffix,negativeStyle:t.negativeStyle||"minus",compact:!!t.compact,scale:typeof t.scale=="number"?t.scale:void 0,...(t.signDisplay?{signDisplay:t.signDisplay}:{})};return e==="currency"&&t.currency&&(o.currency=t.currency),e==="percent"&&(o.percentValueMode=t.percentValueMode||"fraction"),Wt(o);}function Ht(e){return{type:"date",locale:e.locale||bo,pattern:e.pattern,...(e.dialect?{dialect:e.dialect}:{}),...(e.preset?{preset:e.preset}:{}),relative:!!e.relative,timezone:e.timezone,sourceTimezone:e.sourceTimezone,prefix:e.prefix,suffix:e.suffix};}function Le(e){return e==="millisecond"||e==="second"||e==="minute"||e==="hour"||e==="day";}function jt(e){const t=we(e.maxUnits);return{type:"duration",inputUnit:Le(e.inputUnit)?e.inputUnit:"second",outputStyle:e.outputStyle==="digital"||e.outputStyle==="long"?e.outputStyle:"compact",largestUnit:Le(e.largestUnit)?e.largestUnit:void 0,smallestUnit:Le(e.smallestUnit)?e.smallestUnit:"second",maxUnits:t,prefix:e.prefix,suffix:e.suffix,negativeStyle:e.negativeStyle||"minus"};}function qt(e){return{type:"string",prefix:e.prefix,suffix:e.suffix};}function So(e,t){if(!e)return;if(typeof e=="string"){const r=e.trim().toLowerCase();return r==="currency"?O("currency",{type:"currency"},t):r==="percentage"||r==="percent"?O("percent",{type:"percentage",percentValueMode:"fraction"},t):r==="scientific"?O("scientific",{type:"scientific"},t):r==="date"?Ht({}):r==="duration"?jt({}):r==="string"?qt({}):r==="number"?O("number",{type:"number"},t):void 0;}if("type"in e&&e.type==="temporal_bucket"){const r=fr.safeParse(e);return r.success?r.data:void 0;}const n=e;if((t==null?void 0:t.numericInput)==="canonical"){const r=n.type==="percentage"?{...n,type:"percent"}:n;if(re(r))return O(r.type,r,t);}if(n.type==="percentage")return O("percent",{...n,percentValueMode:n.percentValueMode||"fraction"},t);if(n.type==="number"||n.type==="currency"||n.type==="percent"||n.type==="scientific")return O(n.type,n,t);if(n.type==="date")return Ht(n);if(n.type==="duration")return jt(n);if(n.type==="string")return qt(n);}function b(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.prototype.hasOwnProperty.call(t,"constructor")?t.constructor:void 0;return typeof n=="function"&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object);}const Mo=["type","locale","minimumFractionDigits","maximumFractionDigits","useGrouping","prefix","suffix","negativeStyle","compact","scale","currency","percentValueMode","signDisplay"];function ko(e){if(!b(e))return{ok:!1,issues:[{path:"$",message:"Numeric format must be an object."}]};const t=[],n=new Set(Mo);Object.keys(e).filter(i=>!n.has(i)).forEach(i=>t.push({path:i,message:`Unknown property "${i}".`})),e.type!=="number"&&e.type!=="currency"&&e.type!=="percent"&&e.type!=="scientific"&&t.push({path:"type",message:"Expected number, currency, percent, or scientific."});const r=e.locale===void 0?void 0:te(e.locale);e.locale!==void 0&&!r&&t.push({path:"locale",message:"Expected a supported BCP 47 locale."});const a=e.currency===void 0?void 0:Ze(e.currency);e.currency!==void 0&&!a&&t.push({path:"currency",message:"Expected a supported ISO 4217 currency code."});for(const i of["minimumFractionDigits","maximumFractionDigits"]){const o=e[i];o!==void 0&&(!Number.isInteger(o)||typeof o!="number"||o<0||o>20)&&t.push({path:i,message:"Expected an integer from 0 to 20."});}typeof e.minimumFractionDigits=="number"&&typeof e.maximumFractionDigits=="number"&&e.minimumFractionDigits>e.maximumFractionDigits&&t.push({path:"maximumFractionDigits",message:"Must be greater than or equal to minimumFractionDigits."});for(const i of["useGrouping","compact"])e[i]!==void 0&&typeof e[i]!="boolean"&&t.push({path:i,message:"Expected a boolean."});for(const i of["prefix","suffix"])e[i]!==void 0&&typeof e[i]!="string"&&t.push({path:i,message:"Expected a string."});return e.negativeStyle!==void 0&&e.negativeStyle!=="minus"&&e.negativeStyle!=="parentheses"&&t.push({path:"negativeStyle",message:"Expected minus or parentheses."}),e.percentValueMode!==void 0&&e.percentValueMode!=="fraction"&&e.percentValueMode!=="whole"&&t.push({path:"percentValueMode",message:"Expected fraction or whole."}),e.scale!==void 0&&(typeof e.scale!="number"||!Number.isFinite(e.scale))&&t.push({path:"scale",message:"Expected a finite number."}),e.signDisplay!==void 0&&e.signDisplay!=="auto"&&e.signDisplay!=="always"&&e.signDisplay!=="exceptZero"&&e.signDisplay!=="never"&&t.push({path:"signDisplay",message:"Expected auto, always, exceptZero, or never."}),t.length>0?{ok:!1,issues:t}:{ok:!0,value:{type:e.type,...(r?{locale:r}:{}),...(e.minimumFractionDigits!==void 0?{minimumFractionDigits:e.minimumFractionDigits}:{}),...(e.maximumFractionDigits!==void 0?{maximumFractionDigits:e.maximumFractionDigits}:{}),...(e.useGrouping!==void 0?{useGrouping:e.useGrouping}:{}),...(e.prefix!==void 0?{prefix:e.prefix}:{}),...(e.suffix!==void 0?{suffix:e.suffix}:{}),...(e.negativeStyle!==void 0?{negativeStyle:e.negativeStyle}:{}),...(e.compact!==void 0?{compact:e.compact}:{}),...(e.scale!==void 0?{scale:e.scale}:{}),...(a?{currency:a}:{}),...(e.percentValueMode!==void 0?{percentValueMode:e.percentValueMode}:{}),...(e.signDisplay!==void 0?{signDisplay:e.signDisplay}:{})}};}function _o(e){const t=ko(e);if(!t.ok)return t;const n=[];return t.value.locale||n.push({path:"locale",message:"Resolved numeric formats require an explicit locale."}),t.value.minimumFractionDigits===void 0&&n.push({path:"minimumFractionDigits",message:"Resolved numeric formats require minimumFractionDigits."}),t.value.maximumFractionDigits===void 0&&n.push({path:"maximumFractionDigits",message:"Resolved numeric formats require maximumFractionDigits."}),t.value.type==="currency"&&!t.value.currency&&n.push({path:"currency",message:"Resolved currency formats require an explicit currency."}),n.length>0?{ok:!1,issues:n}:t;}function Dc(e){var r;const t=/* @__PURE__ */new Set();if(e.snapshot.resolvedFormats.forEach((a,i)=>{if(a.format.type!=="temporal_bucket"){if(a.scope.attachmentIndex!==void 0)throw new Error(`resolvedFormats.${i}.scope.attachmentIndex is not valid for a card export`);if(a.scope.dashboardId!==e.expectedScope.dashboardId||a.scope.cardId!==e.expectedScope.cardId)throw new Error(`resolvedFormats.${i}.scope must match the executing dashboard/card`);if(a.target.kind!=="column")throw new Error(`resolvedFormats.${i}.target must identify an export column`);if(t.has(a.target.columnKey))throw new Error(`resolvedFormats.${i} duplicates export column "${a.target.columnKey}"`);t.add(a.target.columnKey);}}),!e.useFormattedValues)return;if(!((r=e.visibleColumns)!=null&&r.length))throw new Error("visibleColumns must identify every formatted export column");const n=e.visibleColumns.find(a=>!t.has(a));if(n)throw new Error(`resolvedFormats is missing visible export column "${n}"`);}function $o(e,t){const n=new Intl.NumberFormat(e,{style:"currency",currency:t}).resolvedOptions();return{minimumFractionDigits:n.minimumFractionDigits,maximumFractionDigits:n.maximumFractionDigits};}function No(e){if(e.minimumFractionDigits!==void 0||e.maximumFractionDigits!==void 0){const n=e.minimumFractionDigits??0;return{minimumFractionDigits:n,maximumFractionDigits:e.maximumFractionDigits??Math.max(n,2)};}const t=e.type==="percent"?1:e.type==="scientific"?2:0;return{minimumFractionDigits:t,maximumFractionDigits:t};}function Eo(e,t,n){const r=te(e.locale)??t.locale,a=e.type==="number"||e.type==="currency"?Ze(n):void 0;if(!(e.type==="currency"||a!==void 0))return{...e,locale:r,...No(e)};const o=a??Ze(e.currency)??t.defaultCurrency,s=$o(r,o),c=s.minimumFractionDigits??0,u=s.maximumFractionDigits??c,l=e.minimumFractionDigits??Math.min(c,e.maximumFractionDigits??c),f=e.maximumFractionDigits??Math.max(l,u);return{...e,type:"currency",locale:r,currency:o,minimumFractionDigits:l,maximumFractionDigits:f};}const Zt=/* @__PURE__ */new Map();function Nn(e,t){var r;let n=Zt.get(e);return n||(n=new Intl.DateTimeFormat(e,{calendar:"gregory",timeZone:"UTC",hour:"numeric",hour12:!0}),Zt.set(e,n)),((r=n.formatToParts(new Date(Date.UTC(2e3,0,1,t))).find(a=>a.type==="dayPeriod"))==null?void 0:r.value)??"";}function Oo(e){return e.preset?{mode:"preset",preset:e.preset}:e.pattern?{mode:"pattern",dialect:e.dialect??"semaphor_tokens",pattern:e.pattern}:{mode:"auto"};}class L extends Error{constructor(n,r){super(r);_(this,"code");this.name="RawTemporalFormatContractError",this.code=n;}}const Io=["SSSSSSSSS","SSSSSSSS","SSSSSSS","SSSSSS","SSSSS","SSSS","SSS","SS","S"],Co=["yyyy","MMMM","LLLL","zzz","XXX","MMM","LLL","yy","MM","dd","HH","hh","mm","ss","M","d","H","h","m","s","a"],Fo=/* @__PURE__ */new Set(["HH","H","hh","h","mm","m","ss","s","a",...Io]),Po=/* @__PURE__ */new Set(["zzz","XXX"]),We=/* @__PURE__ */new Set(["short","medium","long"]);function k(e,t){return Object.keys(e).length===t.length&&t.every(r=>r in e);}function g(e){throw new L("invalid_raw_temporal_format",e);}function En(e){if(!e||e.trim()!==e||e.length>256)return g("date_fns patterns must be non-empty, trimmed, and at most 256 characters.");const t=[],n=a=>{const i=t[t.length-1];(i==null?void 0:i.kind)==="literal"?i.value+=a:t.push({kind:"literal",value:a});};let r=0;for(;r<e.length;){if(e[r]==="'"){if(e[r+1]==="'"){n("'"),r+=2;continue;}let o="",s=!1;for(r+=1;r<e.length;){if(e[r]==="'"){if(e[r+1]==="'"){o+="'",r+=2;continue;}s=!0,r+=1;break;}o+=e[r],r+=1;}if(!s)return g("date_fns pattern has an unclosed quote.");n(o);continue;}if(e[r]==="S"){let o=r+1;for(;e[o]==="S";)o+=1;const s=e.slice(r,o);if(s.length>9)return g("date_fns fractional-second tokens support at most nine digits.");t.push({kind:"token",value:s}),r=o;continue;}const a=Co.find(o=>e.startsWith(o,r));if(a){t.push({kind:"token",value:a}),r+=a.length;continue;}const i=e[r];if(/[A-Za-z]/.test(i))return g(`Unsupported date_fns pattern token beginning at "${e.slice(r)}".`);n(i),r+=1;}return t.some(a=>a.kind==="token")?t:g("date_fns patterns must contain at least one token.");}function On(e,t){if(e==="semaphor_tokens"){const n=ne(t,"semaphor_tokens");n.ok||g(n.message);return;}En(t);}function Yo(e){return!b(e)||!k(e,["dateStyle","dateTime"])?g("Automatic raw temporal styles are incomplete."):We.has(e.dateStyle)?!b(e.dateTime)||!k(e.dateTime,["dateStyle","timeStyle"])||!We.has(e.dateTime.dateStyle)||!We.has(e.dateTime.timeStyle)?g("Automatic dateTime styles are incomplete or invalid."):{dateStyle:e.dateStyle,dateTime:{dateStyle:e.dateTime.dateStyle,timeStyle:e.dateTime.timeStyle}}:g("Automatic dateStyle is invalid.");}function st(e){const t=["type","locale","calendarTimezone","presentation"],n=[...t,"sourceTimezone"];if(!b(e)||!k(e,t)&&!k(e,n)||e.type!=="raw_temporal")return g("Resolved raw temporal format has an invalid shape.");const r=te(e.locale);return r?typeof e.calendarTimezone!="string"||!ve(e.calendarTimezone)?g("Raw temporal calendarTimezone must be a valid IANA timezone."):e.sourceTimezone!==void 0&&(typeof e.sourceTimezone!="string"||!ve(e.sourceTimezone))?g("Raw temporal sourceTimezone must be a valid IANA timezone."):b(e.presentation)?e.presentation.mode==="auto"?k(e.presentation,["mode","styles"])?{type:"raw_temporal",locale:r,calendarTimezone:e.calendarTimezone,...(e.sourceTimezone?{sourceTimezone:e.sourceTimezone}:{}),presentation:{mode:"auto",styles:Yo(e.presentation.styles)}}:g("Automatic raw temporal presentation has unknown fields."):e.presentation.mode==="preset"?!k(e.presentation,["mode","preset"])||!Yn(e.presentation.preset)?g("Preset raw temporal presentation has an invalid shape."):{type:"raw_temporal",locale:r,calendarTimezone:e.calendarTimezone,...(e.sourceTimezone?{sourceTimezone:e.sourceTimezone}:{}),presentation:{mode:"preset",preset:e.presentation.preset}}:e.presentation.mode!=="pattern"||!k(e.presentation,["mode","dialect","pattern"])||e.presentation.dialect!=="semaphor_tokens"&&e.presentation.dialect!=="date_fns"||typeof e.presentation.pattern!="string"?g("Pattern raw temporal presentation has an invalid shape."):(On(e.presentation.dialect,e.presentation.pattern),{type:"raw_temporal",locale:r,calendarTimezone:e.calendarTimezone,...(e.sourceTimezone?{sourceTimezone:e.sourceTimezone}:{}),presentation:{mode:"pattern",dialect:e.presentation.dialect,pattern:e.presentation.pattern}}):g("Raw temporal presentation must be an object."):g("Raw temporal locale is invalid or unsupported.");}function In(e){var s,c,u;if(e.format){if(!b(e.format))return g("Authored raw temporal format has an invalid shape.");const l=Object.keys(e.format);if(!l.includes("type")||!l.includes("presentation")||l.some(m=>m!=="type"&&m!=="presentation"&&m!=="timezone"&&m!=="sourceTimezone")||e.format.type!=="raw_temporal"||!b(e.format.presentation))return g("Authored raw temporal format has an invalid shape.");const f=e.format.presentation;if(f.mode==="auto"){if(!k(f,["mode"]))return g("Automatic authored raw temporal format has unknown fields.");}else if(f.mode==="preset"){if(!k(f,["mode","preset"])||!Yn(f.preset))return g("Authored raw temporal preset has an invalid shape.");}else{if(f.mode!=="pattern"||!k(f,["mode","dialect","pattern"])||f.dialect!=="semaphor_tokens"&&f.dialect!=="date_fns"||typeof f.pattern!="string")return g("Authored raw temporal pattern has an invalid shape.");On(f.dialect,f.pattern);}}const t=(s=e.format)==null?void 0:s.timezone,n=(c=e.format)==null?void 0:c.sourceTimezone,r=t&&t!=="auto"?t:e.calendar.tz,a=n&&n!=="auto"?n==="local"?Intl.DateTimeFormat().resolvedOptions().timeZone:n:void 0;if(t!==void 0&&t!=="auto"&&!ve(r)||a!==void 0&&!ve(a))return g("Authored raw temporal timezone is invalid.");const i=((u=e.format)==null?void 0:u.presentation)??{mode:"auto"},o={type:"raw_temporal",locale:e.preferences.locale,calendarTimezone:r,...(a?{sourceTimezone:a}:{}),presentation:i.mode==="pattern"||i.mode==="preset"?{...i}:{mode:"auto",styles:{dateStyle:e.preferences.dateStyle,dateTime:{...e.preferences.dateTime}}}};return st(o);}function Sc(e){const t=/* @__PURE__ */new Set();let n=!1;for(const r of e.values){if(r===null)continue;n=!0;const a=ur(r);a&&t.add(a);}if(!n)return{status:"empty"};if(t.size===0)return{status:"invalid_only"};if(t.size>1)throw new L("mixed_sql_temporal_semantics",`Declared SQL temporal column "${e.columnKey}" mixes date, wall-datetime, or instant semantics. Normalize it to one kind.`);return{status:"classified",metadata:{kind:"raw_temporal",valueKind:[...t][0]}};}function Mc(e){return{version:1,columns:Object.fromEntries([...e].map(([t,n])=>[t,n.status==="classified"?n.metadata.valueKind:n.status]))};}function Ao(e){if(!b(e)||e.version!==1||!b(e.columns)||Object.keys(e).some(r=>r!=="version"&&r!=="columns"))throw new L("invalid_raw_temporal_format","Raw temporal chunk classification evidence is malformed.");const t={},n=/* @__PURE__ */new Set(["empty","invalid_only","date","wall_datetime","instant"]);for(const[r,a]of Object.entries(e.columns)){if(!r.trim()||!n.has(a))throw new L("invalid_raw_temporal_format","Raw temporal chunk classification evidence contains an invalid column or status.");t[r]=a;}return{version:1,columns:t};}function kc(e){if(e.length===0)return;const t=e.map(Ao),n=Object.keys(t[0].columns).sort();for(let r=1;r<t.length;r+=1){const a=Object.keys(t[r].columns).sort();if(a.length!==n.length||a.some((i,o)=>i!==n[o]))throw new L("invalid_raw_temporal_format","Raw temporal chunk classification evidence has inconsistent columns.");}for(const r of n)if(new Set(t.map(i=>i.columns[r]).filter(i=>i!=="empty"&&i!=="invalid_only")).size>1)throw new L("mixed_sql_temporal_semantics",`Declared SQL temporal column "${r}" has inconsistent semantics across export chunks. Normalize it to one kind.`);}function Je(e){const t=/* @__PURE__ */new Date(0);return t.setUTCFullYear(e.year,e.month-1,e.day),t.setUTCHours(e.hour,e.minute,e.second,0),t;}function ct(e,t){const n=e.fraction?`.${e.fraction.padEnd(3,"0").slice(0,3)}`:"";return ie(`${String(e.year).padStart(4,"0")}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}T${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${n}`,t);}function Cn(e,t){const n=/* @__PURE__ */new Map(),r=/* @__PURE__ */new Map();let a,i,o;return{number(s,c=1){let u=n.get(c);return u||(u=new Intl.NumberFormat(e,{useGrouping:!1,minimumIntegerDigits:c,maximumFractionDigits:0}),n.set(c,u)),u.format(s);},month(s,c,u){var m;const l=`${c}:${u?"standalone":"contextual"}`;let f=r.get(l);if(!f){const d={calendar:"gregory",timeZone:"UTC",month:c};u||(d.day="numeric"),f=new Intl.DateTimeFormat(e,d),r.set(l,f);}return((m=f.formatToParts(s).find(d=>d.type==="month"))==null?void 0:m.value)??"";},dayPeriod(s){return Nn(e,s.getUTCHours());},instantFields(s){a??(a=new Intl.DateTimeFormat("en-CA",{calendar:"gregory",numberingSystem:"latn",timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}));const c=a.formatToParts(s),u=l=>{var f;return Number((f=c.find(m=>m.type===l))==null?void 0:f.value);};return{year:u("year"),month:u("month"),day:u("day"),hour:u("hour"),minute:u("minute"),second:u("second"),fraction:""};},timezoneName(s){var c;return i??(i=new Intl.DateTimeFormat(e,{calendar:"gregory",timeZone:t,timeZoneName:"short"})),((c=i.formatToParts(s).find(u=>u.type==="timeZoneName"))==null?void 0:c.value)??"";},timezoneOffset(s){var l;o??(o=new Intl.DateTimeFormat("en-US",{calendar:"gregory",timeZone:t,timeZoneName:"longOffset"}));const c=(l=o.formatToParts(s).find(f=>f.type==="timeZoneName"))==null?void 0:l.value;if(!c)return g("Unable to resolve the instant timezone offset.");const u=c.replace(/^GMT/,"");return u===""||/^[+-]00:00$/.test(u)?"Z":u;}};}function zo(e,t,n,r,a){if(/^S{1,9}$/.test(e)){const i=t.fraction.padEnd(e.length,"0").slice(0,e.length);return r.number(Number(i),e.length);}switch(e){case"YYYY":case"yyyy":return r.number(t.year,4);case"YY":case"yy":return r.number(t.year%100,2);case"MMMM":return r.month(n,"long",!1);case"LLLL":return r.month(n,"long",!0);case"MMM":return r.month(n,"short",!1);case"LLL":return r.month(n,"short",!0);case"MM":return r.number(t.month,2);case"M":return r.number(t.month);case"DD":case"dd":return r.number(t.day,2);case"d":return r.number(t.day);case"HH":return r.number(t.hour,2);case"H":return r.number(t.hour);case"hh":return r.number(t.hour%12||12,2);case"h":return r.number(t.hour%12||12);case"mm":return r.number(t.minute,2);case"m":return r.number(t.minute);case"ss":return r.number(t.second,2);case"s":return r.number(t.second);case"a":return r.dayPeriod(n);case"zzz":return a?r.timezoneName(a):g("Timezone pattern tokens require an instant value.");case"XXX":return a?r.timezoneOffset(a):g("Timezone pattern tokens require an instant value.");default:return g(`Unsupported raw temporal pattern token "${e}".`);}}function Uo(e,t,n,r){const a=Je(t);return e.map(i=>i.kind==="literal"?i.value:zo(i.value,t,a,n,r)).join("");}function Fn(e,t,n){const r=t==="date_fns"?En(n):(()=>{const i=ne(n,"semaphor_tokens");return i.ok?i.segments:g(i.message);})(),a=r.filter(i=>i.kind==="token").map(i=>i.value);return e==="date"&&a.some(i=>Fo.has(i))?g("Date patterns cannot contain time tokens."):e!=="instant"&&a.some(i=>Po.has(i))?g("Timezone pattern tokens require an instant value."):r;}function Ro(e){Fn(e.valueKind??"instant",e.dialect,e.pattern);}function Lo(e,t,n,r){const a=Fn(e.valueKind,n,r),i=Cn(t.locale,t.calendarTimezone);return o=>{const s=e.valueKind==="wall_datetime"&&t.sourceTimezone?ct(o.fields,t.sourceTimezone):void 0,c=e.valueKind==="instant"?{...i.instantFields(o.instant),fraction:o.fields.fraction}:s?{...i.instantFields(s),fraction:o.fields.fraction}:o.fields;return Uo(a,c,i,o.instant??s);};}function Pn(e,t){const n=Cn(t.locale,t.calendarTimezone);return r=>{const a=e.valueKind==="instant"?n.instantFields(r.instant):e.valueKind==="wall_datetime"&&t.sourceTimezone?n.instantFields(ct(r.fields,t.sourceTimezone)):r.fields;return{year:a.year,month:a.month,day:a.day,hour:a.hour,minute:a.minute,second:a.second};};}const Wo=/* @__PURE__ */new Set(["short","long","numeric","iso"]);function Yn(e){return typeof e=="string"&&Wo.has(e);}function Ho(e,t,n){const r=Pn(e,t),a=e.valueKind!=="date",i=(s,c=2)=>String(s).padStart(c,"0");if(n==="iso")return s=>{const c=r(s),u=`${i(c.year,4)}-${i(c.month)}-${i(c.day)}`;return a?`${u} ${i(c.hour)}:${i(c.minute)}`:u;};const o=new Intl.DateTimeFormat(t.locale,{calendar:"gregory",timeZone:"UTC",year:"numeric",month:n,day:"numeric",...(a?{hour:"numeric",minute:"2-digit"}:{})});return s=>{const c=r(s),u=/* @__PURE__ */new Date(0);return u.setUTCFullYear(c.year,c.month-1,c.day),u.setUTCHours(c.hour,c.minute,c.second,0),o.format(u);};}function jo(e,t){const n=t.presentation.mode==="auto"?t.presentation.styles:g("Automatic raw temporal formatting requires styles.");if(e.valueKind==="date"){const o=new Intl.DateTimeFormat(t.locale,{calendar:"gregory",timeZone:"UTC",dateStyle:n.dateStyle});return s=>o.format(Je(s.fields));}const r=e.valueKind==="instant",a=!r&&n.dateTime.timeStyle==="long"?"medium":n.dateTime.timeStyle,i=new Intl.DateTimeFormat(t.locale,{calendar:"gregory",timeZone:r||e.valueKind==="wall_datetime"&&t.sourceTimezone?t.calendarTimezone:"UTC",dateStyle:n.dateTime.dateStyle,timeStyle:a});return o=>r?i.format(o.instant):e.valueKind==="wall_datetime"&&t.sourceTimezone?i.format(ct(o.fields,t.sourceTimezone)):i.format(Je(o.fields));}function Xt(e,t,n){return{ok:!1,text:e,diagnostic:{code:n,message:`Raw temporal ${t.valueKind} value is ${n==="invalid_raw_temporal_value"?"malformed":"out of range"}.`}};}function An(e){const t=sr(e.metadata),n=st(e.format),r=n.presentation.mode==="auto"?jo(t,n):n.presentation.mode==="preset"?Ho(t,n,n.presentation.preset):Lo(t,n,n.presentation.dialect,n.presentation.pattern),a=Pn(t,n);return i=>{if(i===null)return{ok:!0,text:"",status:"empty"};const o=cr(i,t.valueKind);return o.status==="invalid_shape"?Xt(i,t,"invalid_raw_temporal_value"):o.status==="out_of_range"?Xt(i,t,"out_of_range_raw_temporal_value"):{ok:!0,text:r(o),status:"formatted",wallClock:a(o)};};}function qo(e){return An({metadata:e.metadata,format:e.format})(e.value);}function Zo(e){const t=In({format:e.authored,preferences:e.preferences,calendar:e.calendar});return{format:t,formatValue:An({metadata:e.metadata,format:t})};}const Xo={dateStyle:"short",dateTime:{dateStyle:"short",timeStyle:"short"}};class pe extends Error{constructor(n,r){super(r);_(this,"code");this.name="TemporalBucketContractError",this.code=n;}}const Ko=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Vo=["January","February","March","April","May","June","July","August","September","October","November","December"];function He(e){return{ok:!1,error:{code:"invalid_temporal_bucket_value",message:e}};}function Bo(e){return e%4===0&&(e%100!==0||e%400===0);}function Go(e,t){return t===2?Bo(e)?29:28:[4,6,9,11].includes(t)?30:31;}function Qo(e,t,n){const r=[0,3,2,5,0,3,5,1,4,6,2,4],a=t<3?e-1:e;return(a+Math.floor(a/4)-Math.floor(a/100)+Math.floor(a/400)+r[t-1]+n)%7;}function Ie(e){var t;return(t=e.calendar.fiscalCalendar)==null?void 0:t.yearStartMonth;}function Jo(e,t){return(e-t+12)%12%3===0;}function es(e,t){const{granularity:n}=t,r=Ie(t)??1;switch(n){case"second":return!0;case"minute":return e.second===0;case"hour":return e.minute===0&&e.second===0;case"day":return!0;case"week":return Qo(e.year,e.month,e.day)===t.calendar.weekStart;case"month":return e.day===1;case"quarter":return e.day===1&&Jo(e.month,r);case"year":return e.day===1&&e.month===r;}}function oe(e,t){if(e===null)return{ok:!0,value:null};const n=t.granularity==="second"||t.granularity==="minute"||t.granularity==="hour",r=n?/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e):/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return He(`Expected ${n?"YYYY-MM-DDTHH:mm:ss":"YYYY-MM-DD"} for ${t.granularity} granularity.`);const a={year:Number(r[1]),month:Number(r[2]),day:Number(r[3]),hour:n?Number(r[4]):0,minute:n?Number(r[5]):0,second:n?Number(r[6]):0};return a.year<1||a.month<1||a.month>12||a.day<1||a.day>Go(a.year,a.month)||a.hour>23||a.minute>59||a.second>59?He(`Invalid canonical ${t.granularity} bucket value ${e}.`):es(a,t)?{ok:!0,value:a}:He(`Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`);}const Ne=e=>`${T(e.year,4)}-${T(e.month)}-${T(e.day)}`;function _c(e,t,n){const r=oe(e,t);if(!r.ok||!r.value)return;const a=be({...r.value,millisecond:0},n.amount,n.unit),{granularity:i}=t;if(i==="second"||i==="minute"||i==="hour"){const o={...a,second:i==="second"?a.second:0,minute:i==="hour"?0:a.minute};return`${Ne(o)}T${T(o.hour)}:${T(o.minute)}:${T(o.second)}`;}return Ne(lr(a,i,t.calendar));}function $c(e,t){const n=oe(e,t);if(!n.ok||!n.value)return;const r={...n.value,millisecond:0},a=t.calendar.tz;return{startInclusive:ht(r,a).toISOString(),endExclusive:ht(be(r,1,t.granularity),a).toISOString(),timezone:a};}function Nc(e,t){const{granularity:n}=t;if(n==="second"||n==="minute"||n==="hour")return;const r=oe(e,t);if(!r.ok||!r.value)return;const a={...r.value,hour:0,minute:0,second:0,millisecond:0},i=be(be(a,1,n),-1,"day");return{first:Ne(a),last:Ne(i)};}function Ec(e){const{granularity:t,calendar:n}=e,r=(o,s)=>new Intl.DateTimeFormat("en-US",{...o,timeZone:"UTC"}).format(s),a=[`by ${t} in the ${n.tz} calendar`];t==="week"&&a.push(`weeks starting on ${r({weekday:"long"},new Date(Date.UTC(2023,0,1+n.weekStart)))}`);const i=Ie(e);return i&&(t==="quarter"||t==="year")&&a.push(`the fiscal year starting in ${r({month:"long"},new Date(Date.UTC(2e3,i-1,1)))}`),`${a.join(", ")}; each value is a bucket's start`;}function zn(e){if(!b(e))return{ok:!1,issues:[{path:"$",message:"Resolved temporal bucket format must be an object."}]};const t=[],n=/* @__PURE__ */new Set(["type","presentation","locale"]);for(const o of Object.keys(e))n.has(o)||t.push({path:o,message:`Unknown property "${o}".`});e.type!=="temporal_bucket"&&t.push({path:"type",message:"Expected temporal_bucket."});const r=e.presentation;if(!b(r))t.push({path:"presentation",message:"Expected a presentation object."});else{const o=r.mode,s=o==="preset"?/* @__PURE__ */new Set(["mode","preset"]):o==="pattern"?/* @__PURE__ */new Set(["mode","pattern"]):o==="auto"?/* @__PURE__ */new Set(["mode","styles"]):/* @__PURE__ */new Set(["mode"]);for(const c of Object.keys(r))s.has(c)||t.push({path:`presentation.${c}`,message:`Unknown property "${c}".`});if(o==="preset")br(r.preset)||t.push({path:"presentation.preset",message:"Expected a supported preset."});else if(o==="pattern"){if(typeof r.pattern!="string"||!r.pattern)t.push({path:"presentation.pattern",message:"Expected a non-empty pattern."});else{const c=ne(r.pattern,"grouped");c.ok||t.push({path:"presentation.pattern",message:c.message});}}else if(o==="auto"){const c=r.styles;(!b(c)||!["short","medium","long"].includes(String(c.dateStyle))||!b(c.dateTime)||!["short","medium","long"].includes(String(c.dateTime.dateStyle))||!["short","medium","long"].includes(String(c.dateTime.timeStyle))||Object.keys(c).some(u=>u!=="dateStyle"&&u!=="dateTime")||Object.keys(c.dateTime).some(u=>u!=="dateStyle"&&u!=="timeStyle"))&&t.push({path:"presentation.styles",message:"Expected complete resolved date and datetime styles."});}else t.push({path:"presentation.mode",message:"Expected auto, preset, or pattern."});}const a=te(e.locale);if(a||t.push({path:"locale",message:"Expected a supported base BCP 47 locale."}),t.length>0||!a||!b(r))return{ok:!1,issues:t};if(r.mode==="auto"){const o=r.styles;return{ok:!0,value:{type:"temporal_bucket",locale:a,presentation:{mode:"auto",styles:{dateStyle:o.dateStyle,dateTime:{dateStyle:o.dateTime.dateStyle,timeStyle:o.dateTime.timeStyle}}}}};}return{ok:!0,value:{type:"temporal_bucket",presentation:r.mode==="preset"?{mode:"preset",preset:r.preset}:{mode:"pattern",pattern:r.pattern},locale:a}};}function ts(e,t){const n=!!t.calendar.fiscalCalendar;return e==="fiscal_quarter_short"||e==="fiscal_year"?n:e==="quarter_short"||e==="quarter_long"||Hn(e)&&(t.granularity==="quarter"||t.granularity==="year")?!n:!0;}function Un(e,t){return on(e,t.granularity).ok?e.presentation.mode==="preset"?ts(e.presentation.preset,t):!(e.presentation.mode==="pattern"&&t.calendar.fiscalCalendar&&(t.granularity==="quarter"||t.granularity==="year")):!1;}function Kt(e,t){if(!(!e||e.presentation.mode==="auto"))return Un(e,t)?{type:"temporal_bucket",presentation:e.presentation}:void 0;}function Rn(e){var a;const t=te(e.locale);if(!t)throw new pe("invalid_temporal_bucket_format","Temporal bucket locale must be a supported base BCP 47 locale.");const n=Kt(e.cardFormat,e.metadata);if(n)return{format:{...n,locale:t},source:"card"};const r=((a=e.semanticFormat)==null?void 0:a.granularity)===e.metadata.granularity?Kt(e.semanticFormat.format,e.metadata):void 0;return r?{format:{...r,locale:t},source:"semantic"}:{format:{type:"temporal_bucket",locale:t,presentation:{mode:"auto",styles:e.styles??Xo}},source:"automatic"};}function T(e,t=2){return String(e).padStart(t,"0");}function J(e,t,n){if(t==="en-US")return(n==="short"?Ko:Vo)[e-1];const r=new Date(Date.UTC(2e3,e-1,15));return new Intl.DateTimeFormat(t,{calendar:"gregory",month:n,timeZone:"UTC"}).format(r);}function ns(e,t,n){return t.map(r=>{if(r.kind==="literal")return r.value;switch(r.value){case"YYYY":return T(e.year,4);case"YY":return T(e.year%100);case"MMMM":return J(e.month,n,"long");case"MMM":return J(e.month,n,"short");case"MM":return T(e.month);case"DD":return T(e.day);case"HH":return T(e.hour);case"hh":return T(e.hour%12||12);case"h":return String(e.hour%12||12);case"a":case"A":return Nn(n,e.hour);case"mm":return T(e.minute);case"ss":return T(e.second);}}).join("");}const Vt=/* @__PURE__ */new Map();function z(e,t){const n=`${e}:${JSON.stringify(t)}`,r=Vt.get(n);if(r)return r;const a=new Intl.DateTimeFormat(e,t);return Vt.set(n,a),a;}function ee(e){const t=/* @__PURE__ */new Date(0);return t.setUTCFullYear(e.year,e.month-1,e.day),t.setUTCHours(e.hour,e.minute,e.second,0),t;}function Bt(e,t,n){return z(t,{calendar:"gregory",dateStyle:n,timeZone:"UTC"}).format(ee(e));}function rs(e,t,n){return z(t,{calendar:"gregory",dateStyle:n.dateStyle,timeStyle:n.timeStyle==="long"?"medium":n.timeStyle,timeZone:"UTC"}).format(ee(e));}function as(e,t,n){var a;if(n==="short"){const i=ee(e),o=z(t,{calendar:"gregory",dateStyle:"short",timeZone:"UTC"}).formatToParts(i),s=o.findIndex(l=>l.type==="month"),c=o.findIndex(l=>l.type==="year"),u=(a=z(t,{calendar:"gregory",timeZone:"UTC",year:"numeric"}).formatToParts(i).find(l=>l.type==="year"))==null?void 0:a.value;if(s>=0&&c>=0&&u){const l=Math.min(s,c),f=Math.max(s,c);let m=!1;return o.slice(l,f+1).filter(d=>d.type==="day"?(m=!0,!1):m&&d.type==="literal"?(m=!1,!1):!0).map(d=>d.type==="year"?u:d.value).join("");}}return z(t,{calendar:"gregory",month:n==="short"?"numeric":n==="medium"?"short":"long",timeZone:"UTC",year:"numeric"}).format(ee(e));}function Ln(e,t){return Math.floor((e.month-t+12)%12/3)+1;}function Gt(e,t){return t===1||e.month<t?e.year:e.year+1;}function Wn(e){return e===1?"1st":e===2?"2nd":e===3?"3rd":`${e}th`;}function Hn(e){return e==="short"||e==="long"||e==="numeric"||e==="iso";}function je(e,t,n){return t==="iso"?`${T(e.year,4)}-${T(e.month)}-${T(e.day)}`:z(n,{calendar:"gregory",month:t==="numeric"?"numeric":t==="long"?"long":"short",day:"numeric",year:"numeric",timeZone:"UTC"}).format(ee(e));}function is(e,t,n,r){const a=Ln(e,1);switch(r){case"week":return t==="numeric"||t==="iso"?je(e,t,n):`Week of ${je(e,t,n)}`;case"month":return t==="iso"?`${T(e.year,4)}-${T(e.month)}`:t==="numeric"?`${T(e.month)}/${T(e.year,4)}`:`${J(e.month,n,t==="long"?"long":"short")} ${e.year}`;case"quarter":return t==="iso"?`${T(e.year,4)}-Q${a}`:t==="long"?`${Wn(a)} Quarter ${e.year}`:`Q${a} ${e.year}`;case"year":return String(e.year);default:return je(e,t,n);}}function et(e,t,n,r){if(Hn(t))return is(e,t,n,r.granularity);const a=Ie(r)??1,i=Ln(e,a);switch(t){case"week_of_short":return`Week of ${J(e.month,n,"short")} ${e.day}, ${e.year}`;case"week_of_long":return`Week of ${J(e.month,n,"long")} ${e.day}, ${e.year}`;case"quarter_short":return`Q${i} ${e.year}`;case"quarter_long":return`${Wn(i)} Quarter ${e.year}`;case"fiscal_quarter_short":return`Q${i} FY${Gt(e,a)}`;case"fiscal_year":return`FY${Gt(e,a)}`;}}function os(e,t,n,r){const a=Ie(t);switch(t.granularity){case"second":case"minute":case"hour":return rs(e,n,r.dateTime);case"day":return Bt(e,n,r.dateStyle);case"week":return`Week of ${Bt(e,n,r.dateStyle)}`;case"month":return as(e,n,r.dateStyle);case"quarter":return et(e,a?"fiscal_quarter_short":"quarter_short",n,t);case"year":return a?et(e,"fiscal_year",n,t):String(e.year);}}function Oc(e,t){if(t.granularity!=="second"&&t.granularity!=="minute"&&t.granularity!=="hour"&&t.granularity!=="day"&&t.granularity!=="month")return;const n=oe(e,t);if(!n.ok||n.value===null)return;const{year:r,month:a,day:i,hour:o,minute:s,second:c}=n.value;return{year:r,month:a,day:i,hour:o,minute:s,second:c};}function ut(e){const t=zn(e.format);if(!t.ok||!Un(t.value,e.metadata))throw new pe("invalid_temporal_bucket_format","Resolved temporal bucket format is invalid or inapplicable to its metadata.");const n=oe(e.value,e.metadata);if(!n.ok)throw new pe(n.error.code,n.error.message);if(n.value===null)return"(Blank)";const{presentation:r,locale:a}=t.value;if(r.mode==="auto")return os(n.value,e.metadata,a,r.styles);if(r.mode==="preset")return et(n.value,r.preset,a,e.metadata);const i=ne(r.pattern,"grouped");if(!i.ok)throw new pe("invalid_temporal_bucket_format",i.message);return ns(n.value,i.segments,a);}function ss(e,t){var a;const n=e[e.length-1];if(!n)return"";if(n.member.kind==="others")return"Others";const r=n.member.value;return r===null?"(Blank)":((a=t==null?void 0:t.get(n.levelId))==null?void 0:a(r))??(typeof r=="object"?r.value:String(r));}function cs(e,t,n){return e==="grand_total"?n??"Grand Total":e==="subtotal"?(n==null?void 0:n.split(rr).join(t))??`${t} Total`:t;}function Ic(e,t,n,r){var o;const a=e[e.length-1],i=t==="grand_total"?n.grand.label:a?(o=n.levels[a.levelId])==null?void 0:o.label:void 0;return cs(t,ss(e,r),i);}function Cc(e,t,n){return e.kind==="value"?(t==null?void 0:t(e.value))??"":e.kind==="null"?n.nullText:n.emptyText;}function Fc(e){const{path:t,previousPath:n,role:r,repeatLabels:a,levelCount:i}=e;return Array.from({length:i},(o,s)=>{const c=t.slice(0,s+1),u=r==="grand_total"?s===0:r==="subtotal"&&s===t.length-1,l=n&&n.length>s&&dt(n.slice(0,s+1))===dt(c);return{path:c,total:u,visible:u||t.length>s&&(a||!l||s===t.length-1)};});}function us(e){return(e==null?void 0:e.type)==="date"?{type:"raw_temporal",timezone:e.timezone,sourceTimezone:e.sourceTimezone,presentation:Oo(e)}:void 0;}function ls(e,t){return So(rt({override:e,model:t}).format,{preserveOmittedProperties:!0,numericInput:"canonical"});}function Pc(e,t,n){const r=/* @__PURE__ */new Map(),a=/* @__PURE__ */new Map(),i=(o,s)=>{const c=(s==="levels"?t.levelFormats:t.measureFormats)[o.id],u=o.semanticFormat,l=ls(c,u);s==="measures"&&r.set(o.id,{isNumeric:nr(o.column.dataType)==="number",hasTextAffixes:!!l&&!!("prefix"in l&&l.prefix||"suffix"in l&&l.suffix)});const f=m=>_n(m,void 0,{useFormattedValues:!0,timezone:n.calendar.tz,locale:n.valueFormat.locale,absence:t.absence});if(o.column.temporalBucket){const m=o.column.temporalBucket,d=Rn({metadata:m,cardFormat:(c==null?void 0:c.type)==="temporal_bucket"?c:void 0,semanticFormat:(u==null?void 0:u.type)==="temporal_bucket"?{granularity:m.granularity,format:u}:void 0,locale:n.valueFormat.locale,styles:{dateStyle:n.valueFormat.dateStyle,dateTime:n.valueFormat.dateTime}});return h=>typeof h=="string"?ut({value:h,metadata:m,format:d.format}):f(h);}if(o.column.rawTemporal){const m=rt({override:c,model:u}).format,{formatValue:d}=Zo({authored:us(m),metadata:o.column.rawTemporal,preferences:n.valueFormat,calendar:n.calendar});return h=>{if(typeof h!="string")return f(h);const S=d(h);return S.ok?S.text:f(h);};}if(re(l)){const m=Eo(l,n.valueFormat);return s==="measures"&&a.set(o.id,m),d=>typeof d=="number"||typeof d=="object"&&d!==null?Dn(d,m):f(d);}return(l==null?void 0:l.type)==="duration"&&s==="measures"&&a.set(o.id,l),(l==null?void 0:l.type)==="duration"?m=>typeof m=="number"||typeof m=="string"||typeof m=="object"&&m!==null?wn(typeof m=="object"?m.value:m,l):f(m):(l==null?void 0:l.type)==="string"?m=>m===null?f(m):`${l.prefix??""}${f(m)}${l.suffix??""}`:f;};return{levels:new Map(e.levels.map(o=>[o.id,i(o,"levels")])),measures:new Map(e.measures.map(o=>[o.id,i(o,"measures")])),measureSemantics:r,measureFormats:a,absence:t.absence};}class Qt extends Error{constructor(n){super(`invalid_presentation_execution_snapshot: ${n} Resave this report before running it again.`);_(this,"code","invalid_presentation_execution_snapshot");_(this,"deliveryBlocking",!0);this.name="PresentationExecutionSnapshotError";}}class Yc extends Error{constructor(n){super(`missing_resolved_raw_temporal_format: Column "${n}" has no captured presentation. Resave this report before running it again.`);_(this,"code","missing_resolved_raw_temporal_format");_(this,"deliveryBlocking",!0);this.name="MissingResolvedRawTemporalFormatError";}}function C(e,t,n){const r=new Set(t),a=Object.keys(e).find(i=>!r.has(i));if(a)throw new Error(`${n} contains unknown property "${a}"`);}function ms(e,t="scope"){if(!b(e))throw new Error(`${t} must be an object`);C(e,["dashboardId","cardId","attachmentIndex"],t);const n=typeof e.dashboardId=="string"?e.dashboardId.trim():"";if(!n)throw new Error(`${t}.dashboardId is required`);const r=typeof e.cardId=="string"?e.cardId.trim():void 0;if(e.cardId!==void 0&&!r)throw new Error(`${t}.cardId must be a non-empty string`);const a=e.attachmentIndex;if(a!==void 0&&(typeof a!="number"||!Number.isInteger(a)||a<0))throw new Error(`${t}.attachmentIndex must be a non-negative integer`);return{dashboardId:n,...(r?{cardId:r}:{}),...(typeof a=="number"?{attachmentIndex:a}:{})};}function U(e,t,n,r){if(e.kind!==t)return;C(e,["kind",n],r);const a=e[n];if(typeof a!="string"||!a.trim())throw new Error(`${r}.${n} is required`);return a;}function qe(e,t){if(!b(e))throw new Error(`${t} must be an object`);const n=U(e,"metric","metricId",t);if(n)return{kind:"metric",metricId:n};const r=U(e,"column","columnKey",t);if(r)return{kind:"column",columnKey:r};const a=U(e,"matrix_measure","measureId",t);if(a)return{kind:"matrix_measure",measureId:a};throw new Error(`${t} is not a valid numeric presentation target`);}const fs=["type","inputUnit","outputStyle","largestUnit","smallestUnit","maxUnits","prefix","suffix","negativeStyle"];function ds(e){return e==="millisecond"||e==="second"||e==="minute"||e==="hour"||e==="day";}const hs=["type","locale","pattern","timezone","sourceTimezone"];function gs(e,t){if(C(e,hs,t),typeof e.locale!="string"||!e.locale.trim())throw new Error(`${t}.locale must be a non-empty string`);for(const n of["pattern","timezone","sourceTimezone"])if(e[n]!==void 0&&typeof e[n]!="string")throw new Error(`${t}.${n} must be a string`);return{type:"date",locale:e.locale,...(typeof e.pattern=="string"?{pattern:e.pattern}:{}),...(typeof e.timezone=="string"?{timezone:e.timezone}:{}),...(typeof e.sourceTimezone=="string"?{sourceTimezone:e.sourceTimezone}:{})};}function ys(e,t){C(e,fs,t);for(const i of["inputUnit","largestUnit","smallestUnit"])if(e[i]!==void 0&&!ds(e[i]))throw new Error(`${t}.${i} must be a duration unit`);const n=e.outputStyle;if(n!==void 0&&n!=="compact"&&n!=="digital"&&n!=="long")throw new Error(`${t}.outputStyle must be compact, digital, or long`);const r=e.maxUnits;if(r!==void 0&&(typeof r!="number"||!Number.isInteger(r)||r<0||r>10))throw new Error(`${t}.maxUnits must be an integer from 0 to 10`);for(const i of["prefix","suffix"])if(e[i]!==void 0&&typeof e[i]!="string")throw new Error(`${t}.${i} must be a string`);const a=e.negativeStyle;if(a!==void 0&&a!=="minus"&&a!=="parentheses")throw new Error(`${t}.negativeStyle must be minus or parentheses`);return{type:"duration",...(e.inputUnit!==void 0?{inputUnit:e.inputUnit}:{}),...(n!==void 0?{outputStyle:n}:{}),...(e.largestUnit!==void 0?{largestUnit:e.largestUnit}:{}),...(e.smallestUnit!==void 0?{smallestUnit:e.smallestUnit}:{}),...(r!==void 0?{maxUnits:r}:{}),...(e.prefix!==void 0?{prefix:e.prefix}:{}),...(e.suffix!==void 0?{suffix:e.suffix}:{}),...(a!==void 0?{negativeStyle:a}:{})};}function ws(e,t){if(!b(e))throw new Error(`${t} must be an object`);if(e.kind==="field"){C(e,["kind","fieldId","role"],t);const a=typeof e.fieldId=="string"?e.fieldId.trim():"";if(!a)throw new Error(`${t}.fieldId is required`);const i=e.role;if(i!==void 0&&i!=="groupby"&&i!=="pivotby")throw new Error(`${t}.role must be groupby or pivotby`);return{kind:"field",fieldId:a,...(i?{role:i}:{})};}const n=U(e,"column","columnKey",t);if(n)return{kind:"column",columnKey:n};const r=U(e,"matrix_axis","axisInstanceId",t);if(r)return{kind:"matrix_axis",axisInstanceId:r};throw new Error(`${t} is not a valid temporal bucket presentation target`);}function ps(e,t){if(!b(e))throw new Error(`${t} must be an object`);const n=U(e,"column","columnKey",t);if(!n)throw new Error(`${t} must identify a column`);return{kind:"column",columnKey:n};}function Ts(e){return[e.dashboardId,e.cardId??null,e.attachmentIndex??null];}function Ee(e){switch(e.kind){case"metric":return[e.kind,e.metricId];case"column":return[e.kind,e.columnKey];case"matrix_measure":return[e.kind,e.measureId];case"field":return[e.kind,e.fieldId,e.role??""];case"matrix_axis":return[e.kind,e.axisInstanceId];}}function W(e,t){return e.dashboardId===t.dashboardId&&e.cardId===t.cardId&&e.attachmentIndex===t.attachmentIndex;}function H(e,t){const n=Ee(e),r=Ee(t);return n.length===r.length&&n.every((a,i)=>a===r[i]);}function bs(e){if(!Array.isArray(e))throw new Error("resolvedFormats must be an array");const t=/* @__PURE__ */new Set();return e.map((n,r)=>{var c,u;const a=`resolvedFormats.${r}`;if(!b(n))throw new Error(`${a} must be an object`);C(n,["scope","target","format"],a);const i=ms(n.scope,`${a}.scope`);if(!b(n.format))throw new Error(`${a}.format must be an object`);let o;switch(n.format.type){case"temporal_bucket":{const l=zn(n.format);if(!l.ok)throw new Error(`${a}.format is invalid: ${((c=l.issues[0])==null?void 0:c.message)??"invalid value"}`);o={scope:i,target:ws(n.target,`${a}.target`),format:l.value};break;}case"raw_temporal":o={scope:i,target:ps(n.target,`${a}.target`),format:st(n.format)};break;case"number":case"currency":case"percent":case"scientific":{const l=_o(n.format);if(!l.ok)throw new Error(`${a}.format is invalid: ${((u=l.issues[0])==null?void 0:u.message)??"invalid value"}`);o={scope:i,target:qe(n.target,`${a}.target`),format:l.value};break;}case"date":{const l=qe(n.target,`${a}.target`);if(l.kind!=="column")throw new Error(`${a}.target must identify a column for a date format`);o={scope:i,target:l,format:gs(n.format,`${a}.format`)};break;}case"duration":o={scope:i,target:qe(n.target,`${a}.target`),format:ys(n.format,`${a}.format`)};break;default:throw new Error(`${a}.format.type is unsupported`);}const s=JSON.stringify([...Ts(o.scope),...Ee(o.target)]);if(t.has(s))throw new Error(`${a} duplicates a scoped presentation target`);return t.add(s),o;});}function vs(e){try{if(!b(e))throw new Error("presentation execution snapshot must be an object");if(C(e,["version","reportContext","resolvedFormats"],"presentation execution snapshot"),e.version!==1)throw new Error("presentation execution snapshot version must be 1");const t=dr(e.reportContext);if(!t.ok){const n=t.issues[0];throw new Error(`presentation execution snapshot reportContext is invalid: ${n!=null&&n.path&&n.path!=="$"?`${n.path}: `:""}${(n==null?void 0:n.message)??"invalid value"}`);}return{version:1,reportContext:t.value,resolvedFormats:bs(e.resolvedFormats)};}catch(t){throw t instanceof Qt?t:new Qt(t instanceof Error?t.message:"Snapshot is invalid.");}}function xs(e){return vs({version:1,reportContext:e.reportContext,resolvedFormats:[...e.resolvedFormats]});}function Ac(e,t){const n=t.filter((r,a)=>!e.resolvedFormats.some(i=>W(i.scope,r.scope)&&H(i.target,r.target))&&t.findIndex(i=>W(i.scope,r.scope)&&H(i.target,r.target))===a);return n.length===0?e:xs({reportContext:e.reportContext,resolvedFormats:[...e.resolvedFormats,...n]});}function zc(e){const t=Ds(e);return re(t)?t:void 0;}function Ds(e){const t=e.snapshot.resolvedFormats.find(n=>n.format.type!=="temporal_bucket"&&n.format.type!=="raw_temporal"&&n.format.type!=="date"&&W(n.scope,e.scope)&&H(n.target,e.target));return t==null?void 0:t.format;}function Uc(e){const t=e.snapshot.resolvedFormats.find(n=>n.format.type==="date"&&W(n.scope,e.scope)&&H(n.target,e.target));return t==null?void 0:t.format;}function Rc(e){const t=e.snapshot.resolvedFormats.find(n=>n.format.type==="raw_temporal"&&W(n.scope,e.scope)&&H(n.target,e.target));return t==null?void 0:t.format;}function Lc(e){const t=e.snapshot.resolvedFormats.find(n=>n.format.type==="temporal_bucket"&&W(n.scope,e.scope)&&H(n.target,e.target));return t==null?void 0:t.format;}function Wc(e){var a;const t=/* @__PURE__ */new Set(),n=/* @__PURE__ */new Set();if(e.snapshot.resolvedFormats.forEach((i,o)=>{if(i.scope.attachmentIndex!==void 0)throw new Error(`resolvedFormats.${o}.scope.attachmentIndex is not valid for a card export`);if(i.scope.dashboardId!==e.expectedScope.dashboardId||i.scope.cardId!==e.expectedScope.cardId)throw new Error(`resolvedFormats.${o}.scope must match the executing dashboard/card`);if(i.target.kind==="field"&&i.format.type==="temporal_bucket"){const s=JSON.stringify(Ee(i.target));if(n.has(s))throw new Error(`resolvedFormats.${o} duplicates export field "${i.target.fieldId}"`);n.add(s);return;}if(i.target.kind!=="column")throw new Error(`resolvedFormats.${o}.target must identify an export column or temporal pivot field`);if(t.has(i.target.columnKey))throw new Error(`resolvedFormats.${o} duplicates export column "${i.target.columnKey}"`);t.add(i.target.columnKey);}),!e.useFormattedValues)return;if(!((a=e.visibleColumns)!=null&&a.length))throw new Error("visibleColumns must identify every formatted export column");const r=e.visibleColumns.find(i=>!t.has(i));if(r)throw new Error(`resolvedFormats is missing visible export column "${r}"`);}const Ss=/* @__PURE__ */new Set(["short","medium","long"]),Ms=/^(\d{4})-(\d{2})-(\d{2})$/,ks=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/,_s=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/,lt=" – ";function Hc(e){if(!b(e))return;const t=Object.keys(e);if(e.mode==="period_label"&&t.length===1)return{mode:"period_label"};if(e.mode==="style"&&t.length===2&&typeof e.dateStyle=="string"&&Ss.has(e.dateStyle))return{mode:"style",dateStyle:e.dateStyle};if(e.mode==="pattern"&&t.length===3&&e.dialect==="semaphor_tokens"&&typeof e.pattern=="string"&&$s(e.pattern)===null)return{mode:"pattern",dialect:"semaphor_tokens",pattern:e.pattern};}function $s(e){try{return Ro({dialect:"semaphor_tokens",pattern:e}),null;}catch(t){return t instanceof Error?t.message:"The pattern is invalid.";}}function jc(e){const{value:t,part:n,presentation:r,preferences:a,calendar:i}=e;if((r==null?void 0:r.mode)==="period_label"&&t.periodLabel&&n==="range")return{ok:!0,text:t.periodLabel};const[o,s]=t.bounds,u=s===void 0||n==="start"?[{raw:o,role:"start"}]:n==="end"?[{raw:s,role:"end"}]:[{raw:o,role:"start"},{raw:s,role:"end"}],l=u.map(({raw:h})=>Is(h,i.tz));if(l.some(h=>h===null))return{ok:!1,text:u.map(({raw:h})=>h).join(lt),diagnostic:{code:"invalid_temporal_input_value",message:"A date input bound is not a date or an instant."}};const f=t.precision==="day"?l.map((h,S)=>Fs(h,u[S].role,i.tz)):[],m=f.length>0&&f.every(h=>h!==null)?f:null;return{ok:!0,text:m?Ns(m,r,a,i):Es(l.map(h=>Cs(h,i.tz)),r,a,i)};}function Ns(e,t,n,r){const[a,i=a]=e;if((t==null?void 0:t.mode)==="pattern")return Zn(e.map(c=>qn(tt(c),"date",t.pattern,n,r)));const o=(t==null?void 0:t.mode)==="style"?t.dateStyle:n.dateStyle;if(!t||t.mode==="period_label"){const c=Ps(a,i,r);if(c)return ut({value:tt(a),metadata:{kind:"temporal_bucket",granularity:c,calendar:{tz:r.tz,weekStart:r.weekStart??1}},format:Rn({metadata:{kind:"temporal_bucket",granularity:c,calendar:{tz:r.tz,weekStart:r.weekStart??1}},locale:n.locale,styles:{dateStyle:o,dateTime:{...n.dateTime}}}).format});}const s=new Intl.DateTimeFormat(n.locale,{calendar:"gregory",timeZone:"UTC",dateStyle:o});return As(a,i)?s.format(Te(a)):jn(s,Te(a),Te(i));}function Es(e,t,n,r){if((t==null?void 0:t.mode)==="pattern")return Zn(e.map(s=>qn(s.toISOString(),"instant",t.pattern,n,r)));const a=new Intl.DateTimeFormat(n.locale,{calendar:"gregory",timeZone:r.tz,dateStyle:(t==null?void 0:t.mode)==="style"?t.dateStyle:n.dateTime.dateStyle,timeStyle:n.dateTime.timeStyle}),[i,o]=e;return o&&o.getTime()!==i.getTime()?jn(a,i,o):a.format(i);}function jn(e,t,n){const r=e;return typeof r.formatRange=="function"?r.formatRange(t,n):`${e.format(t)}${lt}${e.format(n)}`;}function qn(e,t,n,r,a){const i=In({format:{type:"raw_temporal",presentation:{mode:"pattern",dialect:"semaphor_tokens",pattern:n}},preferences:{...r,defaultCurrency:hr.defaultCurrency},calendar:{tz:a.tz}}),o=t==="date"&&Os(n)?"instant":t;return qo({value:o===t?e:ie(`${e}T00:00:00`,a.tz).toISOString(),metadata:{kind:"raw_temporal",valueKind:o},format:i}).text;}function Os(e){return /HH|mm|ss/.test(e);}function Zn(e){return e[1]===void 0||e[0]===e[1]?e[0]:e.join(lt);}function Is(e,t){const n=Ms.exec(e);if(n){const a={year:Number(n[1]),month:Number(n[2]),day:Number(n[3])};return zs(a)?{kind:"date",date:a}:null;}const r=_s.test(e)?new Date(e.replace(" ","T")):ks.test(e)?ie(e.replace(" ","T"),t):null;return r&&!Number.isNaN(r.getTime())?{kind:"instant",instant:r}:null;}function Cs(e,t){return e.kind==="instant"?e.instant:ie(`${tt(e.date)}T00:00:00`,t);}function Fs(e,t,n){if(e.kind==="date")return e.date;const r=mr(e.instant,n),a={year:r.year,month:r.month,day:r.day};if(r.hour===0&&r.minute===0&&r.second===0&&e.instant.getUTCMilliseconds()===0)return t==="start"?a:Ys(a,-1);const o=r.hour===23&&r.minute===59&&r.second===59;return t==="end"&&o?a:null;}function Ps(e,t,n){return n.fiscalCalendar||e.day!==1||e.year!==t.year||t.day!==Xn(t.year,t.month)?null:e.month===t.month?"month":e.month%3===1&&t.month===e.month+2?"quarter":e.month===1&&t.month===12?"year":null;}function tt(e){return`${String(e.year).padStart(4,"0")}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}`;}function Te(e){const t=/* @__PURE__ */new Date(0);return t.setUTCFullYear(e.year,e.month-1,e.day),t.setUTCHours(0,0,0,0),t;}function Ys(e,t){const n=Te(e);return n.setUTCDate(n.getUTCDate()+t),{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate()};}function As(e,t){return e.year===t.year&&e.month===t.month&&e.day===t.day;}function Xn(e,t){return new Date(Date.UTC(e,t,0)).getUTCDate();}function zs(e){return e.year>=1&&e.month>=1&&e.month<=12&&e.day>=1&&e.day<=Xn(e.year,e.month);}class Us extends Error{constructor(n,r){super(`${n}: ${r}`);_(this,"deliveryBlocking",!0);this.code=n,this.name="PivotHeaderPresentationError";}}function qc(e){var a;const t=e.mode??"formatted",n=e.members.map(i=>{var s;if(t==="canonical"||!i.temporalBucket)return i.value===null?"":String(i.value);const o=(s=e.resolveTemporalFormat)==null?void 0:s.call(e,i.fieldId);if(!o)throw new Us("missing_resolved_temporal_format",`Missing resolved temporal presentation for pivot field "${i.fieldId}"`);return ut({value:i.value,metadata:i.temporalBucket,format:o});}),r=((a=e.metricLabel)==null?void 0:a.trim())||void 0;return{memberLabels:n,...(r?{metricLabel:r}:{}),flattenedLabel:[...n,...(r?[r]:[])].join(" / ")};}function Zc(e){const t=/* @__PURE__ */new Map();return e.forEach(n=>{n.id&&t.set(n.id,(t.get(n.id)??0)+1);}),e.flatMap(n=>n.id&&(t.get(n.id)??0)>1?[ir(n)]:[]);}export{ms as $,fc as A,hc as B,gc as C,$n as D,yc as E,mo as F,wc as G,fo as H,pc as I,_e as J,A as K,Tc as L,dc as M,bc as N,wo as O,po as P,vc as Q,To as R,xc as S,Pc as T,ko as U,_o as V,Dc as W,$o as X,Eo as Y,Qt as Z,Yc as _,Oi as a,nt as a$,bs as a0,vs as a1,xs as a2,Ac as a3,zc as a4,Uc as a5,Rc as a6,Lc as a7,Wc as a8,gt as a9,qo as aA,Zo as aB,Hc as aC,$s as aD,jc as aE,Us as aF,qc as aG,Zc as aH,ls as aI,Bs as aJ,Qs as aK,Ii as aL,ss as aM,Ic as aN,Fc as aO,Cc as aP,Vs as aQ,oc as aR,kn as aS,tc as aT,ac as aU,bo as aV,Ei as aW,rc as aX,Gs as aY,gr as aZ,yr as a_,wr as aa,br as ab,ne as ac,on as ad,Js as ae,Xo as af,pe as ag,oe as ah,_c as ai,$c as aj,Nc as ak,Ec as al,zn as am,Rn as an,Oc as ao,ut as ap,Oo as aq,L as ar,st as as,In as at,Sc as au,Mc as av,Ao as aw,kc as ax,Ro as ay,An as az,So as b,j as b0,mn as b1,ge as b2,w as b3,Pr as b4,De as b5,yt as b6,le as b7,ec as b8,cn as b9,Or as ba,Ra as bb,jt as bc,O as bd,Ht as be,Lt as bf,us as bg,ie as bh,cs as bi,ic as c,Ve as d,at as e,Ds as f,bn as g,vn as h,re as i,xn as j,Dn as k,Ci as l,sc as m,wn as n,ki as o,rt as p,co as q,ui as r,uo as s,mc as t,cc as u,uc as v,nc as w,lc as x,ot as y,_n as z};