react-semaphor 0.1.449 → 0.1.453

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 (134) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +115 -109
  3. package/dist/appearance/index.cjs +1 -1
  4. package/dist/appearance/index.js +1 -1
  5. package/dist/brand-studio/index.cjs +4 -4
  6. package/dist/brand-studio/index.js +15 -13
  7. package/dist/briefings/index.cjs +1 -1
  8. package/dist/briefings/index.js +39 -2131
  9. package/dist/chunks/{analyze-result-contract-BHb7sUUW.cjs → analyze-result-contract-Dxw66nUG.cjs} +1 -1
  10. package/dist/chunks/{analyze-result-contract-T-0Ntzys.js → analyze-result-contract-GHKFwThg.js} +1 -1
  11. package/dist/chunks/canonical-result-keys-Drc2x-lf.cjs +1 -0
  12. package/dist/chunks/canonical-result-keys-KLk__J_O.js +466 -0
  13. package/dist/chunks/color-CJvdlFM_.js +2162 -0
  14. package/dist/chunks/color-CyB5o13F.cjs +4 -0
  15. package/dist/chunks/{common-types-CQ6SHfLk.cjs → common-types-Ci66eflG.cjs} +1 -1
  16. package/dist/chunks/{common-types-B7Jk3Rtj.js → common-types-F6qk6PPS.js} +1 -1
  17. package/dist/chunks/contracts-CoCOpd_i.js +11 -0
  18. package/dist/chunks/contracts-CtB2VONT.cjs +1 -0
  19. package/dist/chunks/{dashboard-briefing-launcher-DCHiEkLE.js → dashboard-briefing-launcher-CFpX0WX3.js} +86 -84
  20. package/dist/chunks/dashboard-briefing-launcher-mUXWuiOZ.cjs +26 -0
  21. package/dist/chunks/{dashboard-controls-DwRFCcHV.js → dashboard-controls-BeYAmOJc.js} +15 -13
  22. package/dist/chunks/{dashboard-controls-CaFioayc.cjs → dashboard-controls-SoNubIu1.cjs} +1 -1
  23. package/dist/chunks/dashboard-json-BublPnQ4.cjs +1 -0
  24. package/dist/chunks/{dashboard-json-WoILbfTe.js → dashboard-json-DeLUagVV.js} +25 -23
  25. package/dist/chunks/edit-dashboard-visual-CrvPcO7A.cjs +172 -0
  26. package/dist/chunks/{edit-dashboard-visual-ciFhxqaI.js → edit-dashboard-visual-Go0h82DR.js} +6925 -6947
  27. package/dist/chunks/editor-action-buttons-1Lo0fIh7.cjs +16 -0
  28. package/dist/chunks/{editor-action-buttons-BPo_45pM.js → editor-action-buttons-BFNtjFzO.js} +41 -39
  29. package/dist/chunks/format-types-CFHQoIuk.js +1350 -0
  30. package/dist/chunks/format-types-PSZZ7hG8.cjs +1 -0
  31. package/dist/chunks/index-B3ZugihZ.js +3713 -0
  32. package/dist/chunks/{index-CPuawpXJ.js → index-BsH32bn1.js} +47472 -47845
  33. package/dist/chunks/index-ByFbacH7.cjs +1 -0
  34. package/dist/chunks/index-CACdoqu3.js +318 -0
  35. package/dist/chunks/index-DSKR3nKn.js +421 -0
  36. package/dist/chunks/index-DjiIh_9n.cjs +4 -0
  37. package/dist/chunks/index-F25jnH0p.cjs +1 -0
  38. package/dist/chunks/index-q12_nNUS.cjs +1392 -0
  39. package/dist/chunks/{metric-comparison-97zHGEx5.js → metric-comparison-D0T0MKRK.js} +1 -1
  40. package/dist/chunks/{metric-comparison-CUAJ8n4y.cjs → metric-comparison-DYR3RXam.cjs} +1 -1
  41. package/dist/chunks/pivot-header-presentation-DcfPaCiy.cjs +4 -0
  42. package/dist/chunks/pivot-header-presentation-nk604qc1.js +557 -0
  43. package/dist/chunks/{pivot-result-identity-CwJWpKI7.js → pivot-result-identity-C43Ai5Kr.js} +1 -1
  44. package/dist/chunks/{pivot-result-identity-CDLRT-YG.cjs → pivot-result-identity-CRUokNgm.cjs} +1 -1
  45. package/dist/chunks/pivot-result-lifecycle-4kSe0Hk1.js +1642 -0
  46. package/dist/chunks/pivot-result-lifecycle-BiJepH5S.cjs +1 -0
  47. package/dist/chunks/raw-temporal-contract-BF7PjBY9.js +64 -0
  48. package/dist/chunks/raw-temporal-contract-CxbRFwnd.cjs +1 -0
  49. package/dist/chunks/report-preferences-dialog-BEVZAE3m.cjs +1 -0
  50. package/dist/chunks/report-preferences-dialog-BNV7qXYH.js +723 -0
  51. package/dist/chunks/{report-runtime-context-bCy3CVzK.js → report-runtime-context-BJQDu2fV.js} +1 -1
  52. package/dist/chunks/{report-runtime-context-C8LZFsqV.cjs → report-runtime-context-DjYqLV-c.cjs} +1 -1
  53. package/dist/chunks/saved-temporal-bucket-format-DiZdQXOL.js +924 -0
  54. package/dist/chunks/saved-temporal-bucket-format-Gfbh4IiP.cjs +1 -0
  55. package/dist/chunks/switch-CjJ6FHYJ.cjs +138 -0
  56. package/dist/chunks/{switch-BXet-Sno.js → switch-DgLwr7O-.js} +4352 -5249
  57. package/dist/chunks/temporal-bucket-Dnj8qT9l.cjs +1 -0
  58. package/dist/chunks/temporal-bucket-FBZGrDCe.js +560 -0
  59. package/dist/chunks/temporal-bucket-authoring-7hv2laOG.cjs +1 -0
  60. package/dist/chunks/temporal-bucket-authoring-FIRnJz0e.js +221 -0
  61. package/dist/chunks/{temporal-bucket-contract-_F6vNhhH.js → temporal-bucket-contract-BQOj6Frl.js} +1 -1
  62. package/dist/chunks/{temporal-bucket-contract-ChDBWX8I.cjs → temporal-bucket-contract-anl4h-vg.cjs} +1 -1
  63. package/dist/chunks/{token-types-BHR58aTy.js → token-types-CRpQJ4kv.js} +1 -1
  64. package/dist/chunks/{token-types-BdQ8kHBm.cjs → token-types-D0i0IUX3.cjs} +1 -1
  65. package/dist/chunks/{update-policy-BxvYMYz0.cjs → update-policy-C1i9bgsy.cjs} +1 -1
  66. package/dist/chunks/{update-policy-g0rCQ9BM.js → update-policy-CaJz9aPG.js} +1 -1
  67. package/dist/chunks/{validators-Cs74WVie.js → validators-DeMXwRON.js} +253 -233
  68. package/dist/chunks/validators-Dm7Kpz6p.cjs +1 -0
  69. package/dist/dashboard/index.cjs +1 -1
  70. package/dist/dashboard/index.js +2 -2
  71. package/dist/dashboard-authoring/index.cjs +3 -3
  72. package/dist/dashboard-authoring/index.js +32 -29
  73. package/dist/data-app-builder/index.cjs +1 -1
  74. package/dist/data-app-builder/index.js +2 -2
  75. package/dist/data-app-codegen/index.cjs +1 -1
  76. package/dist/data-app-codegen/index.js +2 -2
  77. package/dist/data-app-codegen-node/index.cjs +1 -1
  78. package/dist/data-app-codegen-node/index.js +3 -3
  79. package/dist/data-app-sdk/index.cjs +1 -1
  80. package/dist/data-app-sdk/index.js +3 -3
  81. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  82. package/dist/data-app-sdk-adapters/index.js +2 -2
  83. package/dist/data-app-sdk-validation/index.cjs +1 -1
  84. package/dist/data-app-sdk-validation/index.js +3 -3
  85. package/dist/format-utils/index.cjs +3 -3
  86. package/dist/format-utils/index.js +162 -145
  87. package/dist/index.cjs +1 -1
  88. package/dist/index.js +157 -155
  89. package/dist/report-runtime-context/index.cjs +1 -1
  90. package/dist/report-runtime-context/index.js +2 -2
  91. package/dist/style.css +1 -1
  92. package/dist/surfboard/index.cjs +1 -1
  93. package/dist/surfboard/index.js +3 -3
  94. package/dist/types/analytics-protocol.d.ts +37 -0
  95. package/dist/types/briefings.d.ts +718 -7
  96. package/dist/types/dashboard-assistant.d.ts +18 -0
  97. package/dist/types/dashboard-authoring.d.ts +52 -2
  98. package/dist/types/dashboard.d.ts +128 -0
  99. package/dist/types/data-app-sdk-validation.d.ts +13 -0
  100. package/dist/types/data-app-sdk.d.ts +13 -0
  101. package/dist/types/format-utils.d.ts +190 -3
  102. package/dist/types/index.cjs +1 -1
  103. package/dist/types/index.js +4 -4
  104. package/dist/types/main.d.ts +103 -12
  105. package/dist/types/shared.d.ts +5 -0
  106. package/dist/types/surfboard.d.ts +129 -1
  107. package/dist/types/types.d.ts +98 -6
  108. package/dist/types/value-format-preferences.d.ts +3 -0
  109. package/package.json +2 -1
  110. package/dist/chunks/card-config-utils-15sRtebL.cjs +0 -1
  111. package/dist/chunks/card-config-utils-BYZ5MJOh.js +0 -16
  112. package/dist/chunks/dashboard-briefing-launcher-DDgDr2s3.cjs +0 -26
  113. package/dist/chunks/dashboard-json-CYtvwtvj.cjs +0 -1
  114. package/dist/chunks/edit-dashboard-visual-DwKcvlsF.cjs +0 -177
  115. package/dist/chunks/editor-action-buttons-BVmsk0Aj.cjs +0 -16
  116. package/dist/chunks/format-types-CSv0V7mm.cjs +0 -1
  117. package/dist/chunks/format-types-DZGgYj39.js +0 -1663
  118. package/dist/chunks/index-CJdxSyQq.js +0 -2578
  119. package/dist/chunks/index-DPv8_Ild.cjs +0 -1395
  120. package/dist/chunks/index-DRlMUglg.cjs +0 -4
  121. package/dist/chunks/pivot-result-lifecycle-BBabQ_da.js +0 -914
  122. package/dist/chunks/pivot-result-lifecycle-DPc0ANwk.cjs +0 -4
  123. package/dist/chunks/presentation-execution-BLfPTGX_.js +0 -637
  124. package/dist/chunks/presentation-execution-BTV-Q43g.cjs +0 -1
  125. package/dist/chunks/report-preferences-dialog-D9ZCGh9l.js +0 -691
  126. package/dist/chunks/report-preferences-dialog-DaqTEcac.cjs +0 -1
  127. package/dist/chunks/switch-Cjk6G06r.cjs +0 -138
  128. package/dist/chunks/temporal-bucket-BnPxGrAi.js +0 -446
  129. package/dist/chunks/temporal-bucket-authoring-CPTwHzvs.cjs +0 -1
  130. package/dist/chunks/temporal-bucket-authoring-CgOuakGW.js +0 -205
  131. package/dist/chunks/temporal-bucket-pMnV-4Nj.cjs +0 -1
  132. package/dist/chunks/temporal-result-owner-6peubmhU.js +0 -443
  133. package/dist/chunks/temporal-result-owner-f6-i65Fb.cjs +0 -1
  134. package/dist/chunks/validators-9D4KBqKD.cjs +0 -1
@@ -0,0 +1 @@
1
+ "use strict";var H=Object.defineProperty;var U=(e,t,r)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var w=(e,t,r)=>U(e,typeof t!="symbol"?t+"":t,r);const D=require("../value-format-preferences/index.cjs"),O=["YYYY","MMMM","MMM","YY","MM","DD","HH","mm","ss"],j=new Set([" ","-","/",":",".",",","T"]),F={week_of_short:"week",week_of_long:"week",quarter_short:"quarter",quarter_long:"quarter",fiscal_quarter_short:"quarter",fiscal_year:"year"};function B(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(F,e)}function L(e,t){return O.find(r=>e.startsWith(r,t))}function _(e){var a;if(!e||e.trim()!==e)return{ok:!1,code:"invalid_temporal_bucket_pattern",message:"Temporal bucket patterns must be non-empty and trimmed."};const t=[];let r=0,n=!1;for(;r<e.length;){const s=L(e,r);if(s){if(n)return{ok:!1,code:"invalid_temporal_bucket_pattern",message:"Adjacent temporal bucket tokens require a separator."};t.push({kind:"token",value:s}),r+=s.length,n=!0;continue}const o=e[r];if(!j.has(o))return{ok:!1,code:"invalid_temporal_bucket_pattern",message:`Unsupported temporal bucket pattern character "${o}".`};if(t.length===0)return{ok:!1,code:"invalid_temporal_bucket_pattern",message:"Temporal bucket patterns cannot begin with a separator."};const c=t[t.length-1];c.kind==="literal"?c.value+=o:t.push({kind:"literal",value:o}),r+=1,n=!1}return((a=t[t.length-1])==null?void 0:a.kind)!=="token"?{ok:!1,code:"invalid_temporal_bucket_pattern",message:"Temporal bucket patterns cannot end with a separator."}:{ok:!0,segments:t}}function I(e){return e.flatMap(t=>t.kind==="token"?[t.value]:[])}function E(e,t){return e.filter(r=>t.includes(r)).length===1}function h(e,t){return e.some(r=>t.includes(r))}function z(e){return new Set(e).size!==e.length}function J(e,t){if(z(e))return!1;const r=["YYYY","YY"],n=["MMMM","MMM","MM"],a=["HH","mm","ss"],s=E(e,r),o=E(e,n),c=e.includes("DD"),u=h(e,a);switch(t){case"second":return e.includes("HH")&&e.includes("mm")&&e.includes("ss")&&(!h(e,[...r,...n,"DD"])||s&&o&&c);case"minute":return e.includes("HH")&&e.includes("mm")&&(!h(e,[...r,...n,"DD"])||s&&o&&c);case"hour":return e.includes("HH")&&(!h(e,[...r,...n,"DD"])||s&&o&&c);case"day":case"week":return s&&o&&c&&!u;case"month":return s&&o&&!c&&!u;case"quarter":return!1;case"year":return s&&!o&&!c&&!u}}function M(e,t){if(e.presentation.mode==="auto")return{ok:!0};if(e.presentation.mode==="preset"){const n=F[e.presentation.preset];return n===t?{ok:!0}:{ok:!1,code:"incompatible_temporal_bucket_preset",message:`Preset ${e.presentation.preset} requires ${n} granularity.`}}const r=_(e.presentation.pattern);return r.ok?J(I(r.segments),t)?{ok:!0,segments:r.segments}:{ok:!1,code:"incompatible_temporal_bucket_pattern",message:`Pattern ${e.presentation.pattern} is not compatible with ${t} granularity.`}:r}function K(e,t){if(!(!e||!t))return M(e,t).ok?e:void 0}function d(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 r=Object.prototype.hasOwnProperty.call(t,"constructor")?t.constructor:void 0;return typeof r=="function"&&Function.prototype.toString.call(r)===Function.prototype.toString.call(Object)}const q={dateStyle:"short",dateTime:{dateStyle:"short",timeStyle:"short"}};class p extends Error{constructor(r,n){super(n);w(this,"code");this.name="TemporalBucketContractError",this.code=r}}const V=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=["January","February","March","April","May","June","July","August","September","October","November","December"];function b(e){return{ok:!1,error:{code:"invalid_temporal_bucket_value",message:e}}}function W(e){return e%4===0&&(e%100!==0||e%400===0)}function G(e,t){return t===2?W(e)?29:28:[4,6,9,11].includes(t)?30:31}function Q(e,t,r){const n=[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)+n[t-1]+r)%7}function v(e){var t;return(t=e.calendar.fiscalCalendar)==null?void 0:t.yearStartMonth}function X(e,t){return(e-t+12)%12%3===0}function ee(e,t){const{granularity:r}=t,n=v(t)??1;switch(r){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 Q(e.year,e.month,e.day)===t.calendar.weekStart;case"month":return e.day===1;case"quarter":return e.day===1&&X(e.month,n);case"year":return e.day===1&&e.month===n}}function C(e,t){if(e===null)return{ok:!0,value:null};const r=t.granularity==="second"||t.granularity==="minute"||t.granularity==="hour",n=r?/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e):/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!n)return b(`Expected ${r?"YYYY-MM-DDTHH:mm:ss":"YYYY-MM-DD"} for ${t.granularity} granularity.`);const a={year:Number(n[1]),month:Number(n[2]),day:Number(n[3]),hour:r?Number(n[4]):0,minute:r?Number(n[5]):0,second:r?Number(n[6]):0};return a.year<1||a.month<1||a.month>12||a.day<1||a.day>G(a.year,a.month)||a.hour>23||a.minute>59||a.second>59?b(`Invalid canonical ${t.granularity} bucket value ${e}.`):ee(a,t)?{ok:!0,value:a}:b(`Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`)}function N(e){if(!d(e))return{ok:!1,issues:[{path:"$",message:"Resolved temporal bucket format must be an object."}]};const t=[],r=new Set(["type","presentation","locale"]);for(const o of Object.keys(e))r.has(o)||t.push({path:o,message:`Unknown property "${o}".`});e.type!=="temporal_bucket"&&t.push({path:"type",message:"Expected temporal_bucket."});const n=e.presentation;if(!d(n))t.push({path:"presentation",message:"Expected a presentation object."});else{const o=n.mode,c=o==="preset"?new Set(["mode","preset"]):o==="pattern"?new Set(["mode","pattern"]):o==="auto"?new Set(["mode","styles"]):new Set(["mode"]);for(const u of Object.keys(n))c.has(u)||t.push({path:`presentation.${u}`,message:`Unknown property "${u}".`});if(o==="preset")B(n.preset)||t.push({path:"presentation.preset",message:"Expected a supported preset."});else if(o==="pattern")if(typeof n.pattern!="string"||!n.pattern)t.push({path:"presentation.pattern",message:"Expected a non-empty pattern."});else{const u=_(n.pattern);u.ok||t.push({path:"presentation.pattern",message:u.message})}else if(o==="auto"){const u=n.styles;(!d(u)||!["short","medium","long"].includes(String(u.dateStyle))||!d(u.dateTime)||!["short","medium","long"].includes(String(u.dateTime.dateStyle))||!["short","medium","long"].includes(String(u.dateTime.timeStyle))||Object.keys(u).some(i=>i!=="dateStyle"&&i!=="dateTime")||Object.keys(u.dateTime).some(i=>i!=="dateStyle"&&i!=="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=D.canonicalizeSupportedLocale(e.locale);if(a||t.push({path:"locale",message:"Expected a supported base BCP 47 locale."}),t.length>0||!a||!d(n))return{ok:!1,issues:t};if(n.mode==="auto"){const o=n.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:n.mode==="preset"?{mode:"preset",preset:n.preset}:{mode:"pattern",pattern:n.pattern},locale:a}}}function te(e,t){const r=!!t.calendar.fiscalCalendar;return e==="fiscal_quarter_short"||e==="fiscal_year"?r:e==="quarter_short"||e==="quarter_long"?!r:!0}function R(e,t){return M(e,t.granularity).ok?e.presentation.mode==="preset"?te(e.presentation.preset,t):!(e.presentation.mode==="pattern"&&t.calendar.fiscalCalendar&&(t.granularity==="quarter"||t.granularity==="year")):!1}function Y(e,t){if(!(!e||e.presentation.mode==="auto"))return R(e,t)?{type:"temporal_bucket",presentation:e.presentation}:void 0}function re(e){var a;const t=D.canonicalizeSupportedLocale(e.locale);if(!t)throw new p("invalid_temporal_bucket_format","Temporal bucket locale must be a supported base BCP 47 locale.");const r=Y(e.cardFormat,e.metadata);if(r)return{format:{...r,locale:t},source:"card"};const n=((a=e.semanticFormat)==null?void 0:a.granularity)===e.metadata.granularity?Y(e.semanticFormat.format,e.metadata):void 0;return n?{format:{...n,locale:t},source:"semantic"}:{format:{type:"temporal_bucket",locale:t,presentation:{mode:"auto",styles:e.styles??q}},source:"automatic"}}function m(e,t=2){return String(e).padStart(t,"0")}function k(e,t,r){if(t==="en-US")return(r==="short"?V:Z)[e-1];const n=new Date(Date.UTC(2e3,e-1,15));return new Intl.DateTimeFormat(t,{calendar:"gregory",month:r,timeZone:"UTC"}).format(n)}function ne(e,t,r){return t.map(n=>{if(n.kind==="literal")return n.value;switch(n.value){case"YYYY":return m(e.year,4);case"YY":return m(e.year%100);case"MMMM":return k(e.month,r,"long");case"MMM":return k(e.month,r,"short");case"MM":return m(e.month);case"DD":return m(e.day);case"HH":return m(e.hour);case"mm":return m(e.minute);case"ss":return m(e.second)}}).join("")}const P=new Map;function y(e,t){const r=`${e}:${JSON.stringify(t)}`,n=P.get(r);if(n)return n;const a=new Intl.DateTimeFormat(e,t);return P.set(r,a),a}function g(e){const t=new Date(0);return t.setUTCFullYear(e.year,e.month-1,e.day),t.setUTCHours(e.hour,e.minute,e.second,0),t}function A(e,t,r){return y(t,{calendar:"gregory",dateStyle:r,timeZone:"UTC"}).format(g(e))}function ae(e,t,r){return y(t,{calendar:"gregory",dateStyle:r.dateStyle,timeStyle:r.timeStyle==="long"?"medium":r.timeStyle,timeZone:"UTC"}).format(g(e))}function oe(e,t,r){var a;if(r==="short"){const s=g(e),o=y(t,{calendar:"gregory",dateStyle:"short",timeZone:"UTC"}).formatToParts(s),c=o.findIndex(l=>l.type==="month"),u=o.findIndex(l=>l.type==="year"),i=(a=y(t,{calendar:"gregory",timeZone:"UTC",year:"numeric"}).formatToParts(s).find(l=>l.type==="year"))==null?void 0:a.value;if(c>=0&&u>=0&&i){const l=Math.min(c,u),x=Math.max(c,u);let T=!1;return o.slice(l,x+1).filter(f=>f.type==="day"?(T=!0,!1):T&&f.type==="literal"?(T=!1,!1):!0).map(f=>f.type==="year"?i:f.value).join("")}}return y(t,{calendar:"gregory",month:r==="short"?"numeric":r==="medium"?"short":"long",timeZone:"UTC",year:"numeric"}).format(g(e))}function se(e,t){return Math.floor((e.month-t+12)%12/3)+1}function $(e,t){return t===1||e.month<t?e.year:e.year+1}function ue(e){return e===1?"1st":e===2?"2nd":e===3?"3rd":`${e}th`}function S(e,t,r,n){const a=v(n)??1,s=se(e,a);switch(t){case"week_of_short":return`Week of ${k(e.month,r,"short")} ${e.day}, ${e.year}`;case"week_of_long":return`Week of ${k(e.month,r,"long")} ${e.day}, ${e.year}`;case"quarter_short":return`Q${s} ${e.year}`;case"quarter_long":return`${ue(s)} Quarter ${e.year}`;case"fiscal_quarter_short":return`Q${s} FY${$(e,a)}`;case"fiscal_year":return`FY${$(e,a)}`}}function ce(e,t,r,n){const a=v(t);switch(t.granularity){case"second":case"minute":case"hour":return ae(e,r,n.dateTime);case"day":return A(e,r,n.dateStyle);case"week":return`Week of ${A(e,r,n.dateStyle)}`;case"month":return oe(e,r,n.dateStyle);case"quarter":return S(e,a?"fiscal_quarter_short":"quarter_short",r,t);case"year":return a?S(e,"fiscal_year",r,t):String(e.year)}}function ie(e){const t=N(e.format);if(!t.ok||!R(t.value,e.metadata))throw new p("invalid_temporal_bucket_format","Resolved temporal bucket format is invalid or inapplicable to its metadata.");const r=C(e.value,e.metadata);if(!r.ok)throw new p(r.error.code,r.error.message);if(r.value===null)return"(Blank)";const{presentation:n,locale:a}=t.value;if(n.mode==="auto")return ce(r.value,e.metadata,a,n.styles);if(n.mode==="preset")return S(r.value,n.preset,a,e.metadata);const s=_(n.pattern);if(!s.ok)throw new p("invalid_temporal_bucket_format",s.message);return ne(r.value,s.segments,a)}exports.DEFAULT_RESOLVED_TEMPORAL_STYLE_SET=q;exports.TEMPORAL_BUCKET_PATTERN_TOKENS=O;exports.TemporalBucketContractError=p;exports.formatTemporalBucket=ie;exports.isPlainJsonRecord=d;exports.isTemporalBucketPreset=B;exports.parseResolvedTemporalBucketFormat=N;exports.parseTemporalBucketValue=C;exports.resolveApplicableTemporalBucketFormat=K;exports.resolveTemporalBucketPresentation=re;exports.tokenizeTemporalBucketPattern=_;exports.validateTemporalBucketFormatApplicability=M;
@@ -0,0 +1,560 @@
1
+ var x = Object.defineProperty;
2
+ var C = (e, t, r) => t in e ? x(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var w = (e, t, r) => C(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { canonicalizeSupportedLocale as E } from "../value-format-preferences/index.js";
5
+ const N = [
6
+ "YYYY",
7
+ "MMMM",
8
+ "MMM",
9
+ "YY",
10
+ "MM",
11
+ "DD",
12
+ "HH",
13
+ "mm",
14
+ "ss"
15
+ ], H = /* @__PURE__ */ new Set([" ", "-", "/", ":", ".", ",", "T"]), P = {
16
+ week_of_short: "week",
17
+ week_of_long: "week",
18
+ quarter_short: "quarter",
19
+ quarter_long: "quarter",
20
+ fiscal_quarter_short: "quarter",
21
+ fiscal_year: "year"
22
+ };
23
+ function j(e) {
24
+ return typeof e == "string" && Object.prototype.hasOwnProperty.call(P, e);
25
+ }
26
+ function B(e, t) {
27
+ return N.find(
28
+ (r) => e.startsWith(r, t)
29
+ );
30
+ }
31
+ function M(e) {
32
+ var a;
33
+ if (!e || e.trim() !== e)
34
+ return {
35
+ ok: !1,
36
+ code: "invalid_temporal_bucket_pattern",
37
+ message: "Temporal bucket patterns must be non-empty and trimmed."
38
+ };
39
+ const t = [];
40
+ let r = 0, n = !1;
41
+ for (; r < e.length; ) {
42
+ const s = B(e, r);
43
+ if (s) {
44
+ if (n)
45
+ return {
46
+ ok: !1,
47
+ code: "invalid_temporal_bucket_pattern",
48
+ message: "Adjacent temporal bucket tokens require a separator."
49
+ };
50
+ t.push({ kind: "token", value: s }), r += s.length, n = !0;
51
+ continue;
52
+ }
53
+ const o = e[r];
54
+ if (!H.has(o))
55
+ return {
56
+ ok: !1,
57
+ code: "invalid_temporal_bucket_pattern",
58
+ message: `Unsupported temporal bucket pattern character "${o}".`
59
+ };
60
+ if (t.length === 0)
61
+ return {
62
+ ok: !1,
63
+ code: "invalid_temporal_bucket_pattern",
64
+ message: "Temporal bucket patterns cannot begin with a separator."
65
+ };
66
+ const i = t[t.length - 1];
67
+ i.kind === "literal" ? i.value += o : t.push({ kind: "literal", value: o }), r += 1, n = !1;
68
+ }
69
+ return ((a = t[t.length - 1]) == null ? void 0 : a.kind) !== "token" ? {
70
+ ok: !1,
71
+ code: "invalid_temporal_bucket_pattern",
72
+ message: "Temporal bucket patterns cannot end with a separator."
73
+ } : { ok: !0, segments: t };
74
+ }
75
+ function U(e) {
76
+ return e.flatMap(
77
+ (t) => t.kind === "token" ? [t.value] : []
78
+ );
79
+ }
80
+ function v(e, t) {
81
+ return e.filter((r) => t.includes(r)).length === 1;
82
+ }
83
+ function y(e, t) {
84
+ return e.some((r) => t.includes(r));
85
+ }
86
+ function R(e) {
87
+ return new Set(e).size !== e.length;
88
+ }
89
+ function I(e, t) {
90
+ if (R(e)) return !1;
91
+ const r = ["YYYY", "YY"], n = ["MMMM", "MMM", "MM"], a = ["HH", "mm", "ss"], s = v(e, r), o = v(e, n), i = e.includes("DD"), u = y(e, a);
92
+ switch (t) {
93
+ case "second":
94
+ return e.includes("HH") && e.includes("mm") && e.includes("ss") && (!y(e, [...r, ...n, "DD"]) || s && o && i);
95
+ case "minute":
96
+ return e.includes("HH") && e.includes("mm") && (!y(e, [...r, ...n, "DD"]) || s && o && i);
97
+ case "hour":
98
+ return e.includes("HH") && (!y(e, [...r, ...n, "DD"]) || s && o && i);
99
+ case "day":
100
+ case "week":
101
+ return s && o && i && !u;
102
+ case "month":
103
+ return s && o && !i && !u;
104
+ case "quarter":
105
+ return !1;
106
+ case "year":
107
+ return s && !o && !i && !u;
108
+ }
109
+ }
110
+ function O(e, t) {
111
+ if (e.presentation.mode === "auto")
112
+ return { ok: !0 };
113
+ if (e.presentation.mode === "preset") {
114
+ const n = P[e.presentation.preset];
115
+ return n === t ? { ok: !0 } : {
116
+ ok: !1,
117
+ code: "incompatible_temporal_bucket_preset",
118
+ message: `Preset ${e.presentation.preset} requires ${n} granularity.`
119
+ };
120
+ }
121
+ const r = M(e.presentation.pattern);
122
+ return r.ok ? I(
123
+ U(r.segments),
124
+ t
125
+ ) ? { ok: !0, segments: r.segments } : {
126
+ ok: !1,
127
+ code: "incompatible_temporal_bucket_pattern",
128
+ message: `Pattern ${e.presentation.pattern} is not compatible with ${t} granularity.`
129
+ } : r;
130
+ }
131
+ function ce(e, t) {
132
+ if (!(!e || !t))
133
+ return O(e, t).ok ? e : void 0;
134
+ }
135
+ function f(e) {
136
+ if (e === null || typeof e != "object" || Array.isArray(e))
137
+ return !1;
138
+ const t = Object.getPrototypeOf(e);
139
+ if (t === null || t === Object.prototype) return !0;
140
+ const r = Object.prototype.hasOwnProperty.call(
141
+ t,
142
+ "constructor"
143
+ ) ? t.constructor : void 0;
144
+ return typeof r == "function" && Function.prototype.toString.call(r) === Function.prototype.toString.call(Object);
145
+ }
146
+ const L = {
147
+ dateStyle: "short",
148
+ dateTime: { dateStyle: "short", timeStyle: "short" }
149
+ };
150
+ class h extends Error {
151
+ constructor(r, n) {
152
+ super(n);
153
+ w(this, "code");
154
+ this.name = "TemporalBucketContractError", this.code = r;
155
+ }
156
+ }
157
+ const J = [
158
+ "Jan",
159
+ "Feb",
160
+ "Mar",
161
+ "Apr",
162
+ "May",
163
+ "Jun",
164
+ "Jul",
165
+ "Aug",
166
+ "Sep",
167
+ "Oct",
168
+ "Nov",
169
+ "Dec"
170
+ ], z = [
171
+ "January",
172
+ "February",
173
+ "March",
174
+ "April",
175
+ "May",
176
+ "June",
177
+ "July",
178
+ "August",
179
+ "September",
180
+ "October",
181
+ "November",
182
+ "December"
183
+ ];
184
+ function b(e) {
185
+ return {
186
+ ok: !1,
187
+ error: { code: "invalid_temporal_bucket_value", message: e }
188
+ };
189
+ }
190
+ function Z(e) {
191
+ return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
192
+ }
193
+ function W(e, t) {
194
+ return t === 2 ? Z(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
195
+ }
196
+ function G(e, t, r) {
197
+ const n = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], a = t < 3 ? e - 1 : e;
198
+ return (a + Math.floor(a / 4) - Math.floor(a / 100) + Math.floor(a / 400) + n[t - 1] + r) % 7;
199
+ }
200
+ function S(e) {
201
+ var t;
202
+ return (t = e.calendar.fiscalCalendar) == null ? void 0 : t.yearStartMonth;
203
+ }
204
+ function K(e, t) {
205
+ return (e - t + 12) % 12 % 3 === 0;
206
+ }
207
+ function Q(e, t) {
208
+ const { granularity: r } = t, n = S(t) ?? 1;
209
+ switch (r) {
210
+ case "second":
211
+ return !0;
212
+ case "minute":
213
+ return e.second === 0;
214
+ case "hour":
215
+ return e.minute === 0 && e.second === 0;
216
+ case "day":
217
+ return !0;
218
+ case "week":
219
+ return G(e.year, e.month, e.day) === t.calendar.weekStart;
220
+ case "month":
221
+ return e.day === 1;
222
+ case "quarter":
223
+ return e.day === 1 && K(e.month, n);
224
+ case "year":
225
+ return e.day === 1 && e.month === n;
226
+ }
227
+ }
228
+ function V(e, t) {
229
+ if (e === null) return { ok: !0, value: null };
230
+ const r = t.granularity === "second" || t.granularity === "minute" || t.granularity === "hour", n = r ? /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e) : /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
231
+ if (!n)
232
+ return b(
233
+ `Expected ${r ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD"} for ${t.granularity} granularity.`
234
+ );
235
+ const a = {
236
+ year: Number(n[1]),
237
+ month: Number(n[2]),
238
+ day: Number(n[3]),
239
+ hour: r ? Number(n[4]) : 0,
240
+ minute: r ? Number(n[5]) : 0,
241
+ second: r ? Number(n[6]) : 0
242
+ };
243
+ return a.year < 1 || a.month < 1 || a.month > 12 || a.day < 1 || a.day > W(a.year, a.month) || a.hour > 23 || a.minute > 59 || a.second > 59 ? b(`Invalid canonical ${t.granularity} bucket value ${e}.`) : Q(a, t) ? { ok: !0, value: a } : b(
244
+ `Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`
245
+ );
246
+ }
247
+ function X(e) {
248
+ if (!f(e))
249
+ return {
250
+ ok: !1,
251
+ issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
252
+ };
253
+ const t = [], r = /* @__PURE__ */ new Set(["type", "presentation", "locale"]);
254
+ for (const o of Object.keys(e))
255
+ r.has(o) || t.push({ path: o, message: `Unknown property "${o}".` });
256
+ e.type !== "temporal_bucket" && t.push({ path: "type", message: "Expected temporal_bucket." });
257
+ const n = e.presentation;
258
+ if (!f(n))
259
+ t.push({ path: "presentation", message: "Expected a presentation object." });
260
+ else {
261
+ const o = n.mode, i = 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"]);
262
+ for (const u of Object.keys(n))
263
+ i.has(u) || t.push({
264
+ path: `presentation.${u}`,
265
+ message: `Unknown property "${u}".`
266
+ });
267
+ if (o === "preset")
268
+ j(n.preset) || t.push({ path: "presentation.preset", message: "Expected a supported preset." });
269
+ else if (o === "pattern")
270
+ if (typeof n.pattern != "string" || !n.pattern)
271
+ t.push({ path: "presentation.pattern", message: "Expected a non-empty pattern." });
272
+ else {
273
+ const u = M(n.pattern);
274
+ u.ok || t.push({
275
+ path: "presentation.pattern",
276
+ message: u.message
277
+ });
278
+ }
279
+ else if (o === "auto") {
280
+ const u = n.styles;
281
+ (!f(u) || !["short", "medium", "long"].includes(String(u.dateStyle)) || !f(u.dateTime) || !["short", "medium", "long"].includes(
282
+ String(u.dateTime.dateStyle)
283
+ ) || !["short", "medium", "long"].includes(
284
+ String(u.dateTime.timeStyle)
285
+ ) || Object.keys(u).some(
286
+ (c) => c !== "dateStyle" && c !== "dateTime"
287
+ ) || Object.keys(u.dateTime).some(
288
+ (c) => c !== "dateStyle" && c !== "timeStyle"
289
+ )) && t.push({
290
+ path: "presentation.styles",
291
+ message: "Expected complete resolved date and datetime styles."
292
+ });
293
+ } else
294
+ t.push({ path: "presentation.mode", message: "Expected auto, preset, or pattern." });
295
+ }
296
+ const a = E(e.locale);
297
+ if (a || t.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), t.length > 0 || !a || !f(n))
298
+ return { ok: !1, issues: t };
299
+ if (n.mode === "auto") {
300
+ const o = n.styles;
301
+ return {
302
+ ok: !0,
303
+ value: {
304
+ type: "temporal_bucket",
305
+ locale: a,
306
+ presentation: {
307
+ mode: "auto",
308
+ styles: {
309
+ dateStyle: o.dateStyle,
310
+ dateTime: {
311
+ dateStyle: o.dateTime.dateStyle,
312
+ timeStyle: o.dateTime.timeStyle
313
+ }
314
+ }
315
+ }
316
+ }
317
+ };
318
+ }
319
+ return {
320
+ ok: !0,
321
+ value: {
322
+ type: "temporal_bucket",
323
+ presentation: n.mode === "preset" ? {
324
+ mode: "preset",
325
+ preset: n.preset
326
+ } : {
327
+ mode: "pattern",
328
+ pattern: n.pattern
329
+ },
330
+ locale: a
331
+ }
332
+ };
333
+ }
334
+ function ee(e, t) {
335
+ const r = !!t.calendar.fiscalCalendar;
336
+ return e === "fiscal_quarter_short" || e === "fiscal_year" ? r : e === "quarter_short" || e === "quarter_long" ? !r : !0;
337
+ }
338
+ function F(e, t) {
339
+ return O(e, t.granularity).ok ? e.presentation.mode === "preset" ? ee(e.presentation.preset, t) : !(e.presentation.mode === "pattern" && t.calendar.fiscalCalendar && (t.granularity === "quarter" || t.granularity === "year")) : !1;
340
+ }
341
+ function Y(e, t) {
342
+ if (!(!e || e.presentation.mode === "auto"))
343
+ return F(e, t) ? { type: "temporal_bucket", presentation: e.presentation } : void 0;
344
+ }
345
+ function le(e) {
346
+ var a;
347
+ const t = E(e.locale);
348
+ if (!t)
349
+ throw new h(
350
+ "invalid_temporal_bucket_format",
351
+ "Temporal bucket locale must be a supported base BCP 47 locale."
352
+ );
353
+ const r = Y(e.cardFormat, e.metadata);
354
+ if (r)
355
+ return { format: { ...r, locale: t }, source: "card" };
356
+ const n = ((a = e.semanticFormat) == null ? void 0 : a.granularity) === e.metadata.granularity ? Y(e.semanticFormat.format, e.metadata) : void 0;
357
+ return n ? { format: { ...n, locale: t }, source: "semantic" } : {
358
+ format: {
359
+ type: "temporal_bucket",
360
+ locale: t,
361
+ presentation: {
362
+ mode: "auto",
363
+ styles: e.styles ?? L
364
+ }
365
+ },
366
+ source: "automatic"
367
+ };
368
+ }
369
+ function m(e, t = 2) {
370
+ return String(e).padStart(t, "0");
371
+ }
372
+ function k(e, t, r) {
373
+ if (t === "en-US")
374
+ return (r === "short" ? J : z)[e - 1];
375
+ const n = new Date(Date.UTC(2e3, e - 1, 15));
376
+ return new Intl.DateTimeFormat(t, {
377
+ calendar: "gregory",
378
+ month: r,
379
+ timeZone: "UTC"
380
+ }).format(n);
381
+ }
382
+ function te(e, t, r) {
383
+ return t.map((n) => {
384
+ if (n.kind === "literal") return n.value;
385
+ switch (n.value) {
386
+ case "YYYY":
387
+ return m(e.year, 4);
388
+ case "YY":
389
+ return m(e.year % 100);
390
+ case "MMMM":
391
+ return k(e.month, r, "long");
392
+ case "MMM":
393
+ return k(e.month, r, "short");
394
+ case "MM":
395
+ return m(e.month);
396
+ case "DD":
397
+ return m(e.day);
398
+ case "HH":
399
+ return m(e.hour);
400
+ case "mm":
401
+ return m(e.minute);
402
+ case "ss":
403
+ return m(e.second);
404
+ }
405
+ }).join("");
406
+ }
407
+ const $ = /* @__PURE__ */ new Map();
408
+ function p(e, t) {
409
+ const r = `${e}:${JSON.stringify(t)}`, n = $.get(r);
410
+ if (n) return n;
411
+ const a = new Intl.DateTimeFormat(e, t);
412
+ return $.set(r, a), a;
413
+ }
414
+ function g(e) {
415
+ const t = /* @__PURE__ */ new Date(0);
416
+ return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
417
+ }
418
+ function D(e, t, r) {
419
+ return p(t, {
420
+ calendar: "gregory",
421
+ dateStyle: r,
422
+ timeZone: "UTC"
423
+ }).format(g(e));
424
+ }
425
+ function re(e, t, r) {
426
+ return p(t, {
427
+ calendar: "gregory",
428
+ dateStyle: r.dateStyle,
429
+ // Grouped buckets are civil values, not instants. Long time styles would
430
+ // append a zone label that the canonical value does not semantically own.
431
+ timeStyle: r.timeStyle === "long" ? "medium" : r.timeStyle,
432
+ timeZone: "UTC"
433
+ }).format(g(e));
434
+ }
435
+ function ne(e, t, r) {
436
+ var a;
437
+ if (r === "short") {
438
+ const s = g(e), o = p(t, {
439
+ calendar: "gregory",
440
+ dateStyle: "short",
441
+ timeZone: "UTC"
442
+ }).formatToParts(s), i = o.findIndex((l) => l.type === "month"), u = o.findIndex((l) => l.type === "year"), c = (a = p(t, {
443
+ calendar: "gregory",
444
+ timeZone: "UTC",
445
+ year: "numeric"
446
+ }).formatToParts(s).find((l) => l.type === "year")) == null ? void 0 : a.value;
447
+ if (i >= 0 && u >= 0 && c) {
448
+ const l = Math.min(i, u), q = Math.max(i, u);
449
+ let _ = !1;
450
+ return o.slice(l, q + 1).filter((d) => d.type === "day" ? (_ = !0, !1) : _ && d.type === "literal" ? (_ = !1, !1) : !0).map((d) => d.type === "year" ? c : d.value).join("");
451
+ }
452
+ }
453
+ return p(t, {
454
+ calendar: "gregory",
455
+ month: r === "short" ? "numeric" : r === "medium" ? "short" : "long",
456
+ timeZone: "UTC",
457
+ year: "numeric"
458
+ }).format(g(e));
459
+ }
460
+ function ae(e, t) {
461
+ return Math.floor((e.month - t + 12) % 12 / 3) + 1;
462
+ }
463
+ function A(e, t) {
464
+ return t === 1 || e.month < t ? e.year : e.year + 1;
465
+ }
466
+ function oe(e) {
467
+ return e === 1 ? "1st" : e === 2 ? "2nd" : e === 3 ? "3rd" : `${e}th`;
468
+ }
469
+ function T(e, t, r, n) {
470
+ const a = S(n) ?? 1, s = ae(e, a);
471
+ switch (t) {
472
+ case "week_of_short":
473
+ return `Week of ${k(e.month, r, "short")} ${e.day}, ${e.year}`;
474
+ case "week_of_long":
475
+ return `Week of ${k(e.month, r, "long")} ${e.day}, ${e.year}`;
476
+ case "quarter_short":
477
+ return `Q${s} ${e.year}`;
478
+ case "quarter_long":
479
+ return `${oe(s)} Quarter ${e.year}`;
480
+ case "fiscal_quarter_short":
481
+ return `Q${s} FY${A(e, a)}`;
482
+ case "fiscal_year":
483
+ return `FY${A(e, a)}`;
484
+ }
485
+ }
486
+ function se(e, t, r, n) {
487
+ const a = S(t);
488
+ switch (t.granularity) {
489
+ case "second":
490
+ case "minute":
491
+ case "hour":
492
+ return re(e, r, n.dateTime);
493
+ case "day":
494
+ return D(e, r, n.dateStyle);
495
+ case "week":
496
+ return `Week of ${D(e, r, n.dateStyle)}`;
497
+ case "month":
498
+ return ne(e, r, n.dateStyle);
499
+ case "quarter":
500
+ return T(
501
+ e,
502
+ a ? "fiscal_quarter_short" : "quarter_short",
503
+ r,
504
+ t
505
+ );
506
+ case "year":
507
+ return a ? T(e, "fiscal_year", r, t) : String(e.year);
508
+ }
509
+ }
510
+ function me(e) {
511
+ const t = X(e.format);
512
+ if (!t.ok || !F(t.value, e.metadata))
513
+ throw new h(
514
+ "invalid_temporal_bucket_format",
515
+ "Resolved temporal bucket format is invalid or inapplicable to its metadata."
516
+ );
517
+ const r = V(e.value, e.metadata);
518
+ if (!r.ok)
519
+ throw new h(
520
+ r.error.code,
521
+ r.error.message
522
+ );
523
+ if (r.value === null) return "(Blank)";
524
+ const { presentation: n, locale: a } = t.value;
525
+ if (n.mode === "auto")
526
+ return se(
527
+ r.value,
528
+ e.metadata,
529
+ a,
530
+ n.styles
531
+ );
532
+ if (n.mode === "preset")
533
+ return T(
534
+ r.value,
535
+ n.preset,
536
+ a,
537
+ e.metadata
538
+ );
539
+ const s = M(n.pattern);
540
+ if (!s.ok)
541
+ throw new h(
542
+ "invalid_temporal_bucket_format",
543
+ s.message
544
+ );
545
+ return te(r.value, s.segments, a);
546
+ }
547
+ export {
548
+ L as D,
549
+ N as T,
550
+ h as a,
551
+ X as b,
552
+ le as c,
553
+ f as d,
554
+ me as f,
555
+ j as i,
556
+ V as p,
557
+ ce as r,
558
+ M as t,
559
+ O as v
560
+ };
@@ -0,0 +1 @@
1
+ "use strict";const M=require("./temporal-bucket-Dnj8qT9l.cjs"),d=require("../value-format-preferences/index.cjs"),l={type:"temporal_bucket",presentation:{mode:"auto"}},m={value:"auto",label:"Automatic",format:l};function r(t,e){return{value:`pattern:${t}`,label:e,format:{type:"temporal_bucket",presentation:{mode:"pattern",pattern:t}}}}function c(t,e){return{value:`preset:${t}`,label:e,format:{type:"temporal_bucket",presentation:{mode:"preset",preset:t}}}}function p(t){return{...r(t,"Custom format…"),value:"custom",custom:!0}}const D={second:[m,r("HH:mm:ss","14:30:45 (HH:mm:ss)"),r("YYYY-MM-DD HH:mm:ss","2024-01-15 14:30:45 (YYYY-MM-DD HH:mm:ss)"),p("DD/MM/YYYY HH:mm:ss")],minute:[m,r("HH:mm","14:30 (HH:mm)"),r("YYYY-MM-DD HH:mm","2024-01-15 14:30 (YYYY-MM-DD HH:mm)"),p("DD/MM/YYYY HH:mm")],hour:[m,r("HH","14 (HH)"),r("YYYY-MM-DD HH","2024-01-15 14 (YYYY-MM-DD HH)"),p("DD/MM/YYYY HH")],day:[m,r("YYYY-MM-DD","2024-01-15 (YYYY-MM-DD)"),r("MM/DD/YYYY","01/15/2024 (MM/DD/YYYY)"),r("DD/MM/YYYY","15/01/2024 (DD/MM/YYYY)"),r("MMM DD, YYYY","Jan 15, 2024 (MMM DD, YYYY)"),r("MMMM DD, YYYY","January 15, 2024 (MMMM DD, YYYY)"),p("YYYY/MM/DD")],week:[m,c("week_of_short","Week of Jan 15, 2024"),c("week_of_long","Week of January 15, 2024"),r("YYYY-MM-DD","2024-01-15 (YYYY-MM-DD)"),p("YYYY/MM/DD")],month:[m,r("MMM YYYY","Jan 2024 (MMM YYYY)"),r("MMMM YYYY","January 2024 (MMMM YYYY)"),r("YYYY-MM","2024-01 (YYYY-MM)"),r("MM/YYYY","01/2024 (MM/YYYY)"),r("YYYY MMM","2024 Jan (YYYY MMM)"),p("YYYY/MM")],quarter:[m,c("quarter_short","Q1 2024"),c("quarter_long","1st Quarter 2024")],year:[m,r("YYYY","2024 (YYYY)"),r("YY","24 (YY)")]},T={second:"2026-07-31T14:05:09",minute:"2026-07-31T14:05:00",hour:"2026-07-31T14:00:00",day:"2026-07-31",week:"2026-07-27",month:"2026-07-01",quarter:"2026-07-01",year:"2026-01-01"};function k(t,e,Y=d.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES){return M.formatTemporalBucket({value:T[e],metadata:{kind:"temporal_bucket",granularity:e,calendar:{tz:"UTC",weekStart:1,...t.presentation.mode==="preset"&&(t.presentation.preset==="fiscal_quarter_short"||t.presentation.preset==="fiscal_year")?{fiscalCalendar:{kind:"month_aligned",yearStartMonth:7}}:{}}},format:t.presentation.mode==="auto"?{type:"temporal_bucket",locale:Y.locale,presentation:{mode:"auto",styles:{dateStyle:Y.dateStyle,dateTime:{...Y.dateTime}}}}:{type:"temporal_bucket",locale:Y.locale,presentation:t.presentation}})}function _(t,e,Y=d.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES){const n=D[t],o=(e==null?void 0:e.presentation.mode)==="preset"?e.presentation.preset:void 0,s=o&&e&&M.validateTemporalBucketFormatApplicability(e,t).ok&&!n.some(a=>{var i;return((i=a.format)==null?void 0:i.presentation.mode)==="preset"&&a.format.presentation.preset===o})?c(o,o):void 0;return(s?[...n,s]:n).map(a=>{if(!a.format||a.custom)return a;const i=k(a.format,t,Y);return a.format.presentation.mode==="pattern"?{...a,label:`${i} (${a.format.presentation.pattern})`}:a.format.presentation.mode==="auto"?{...a,label:`Automatic (${i})`}:{...a,label:i}})}function A(t,e){const Y=D[e];if(t.presentation.mode==="pattern"){const n=t.presentation.pattern,o=Y.find(s=>{var u;return((u=s.format)==null?void 0:u.presentation.mode)==="pattern"&&s.format.presentation.pattern===n});return{value:(o==null?void 0:o.value)??"custom",customPattern:o!=null&&o.custom||!o?n:"",format:t}}if(t.presentation.mode==="preset"){const n=t.presentation.preset,o=Y.find(u=>{var a;return((a=u.format)==null?void 0:a.presentation.mode)==="preset"&&u.format.presentation.preset===n}),s=M.validateTemporalBucketFormatApplicability(t,e).ok;return o?{value:o.value,customPattern:"",format:t}:s?{value:`preset:${n}`,customPattern:"",format:t}:{value:"auto",customPattern:"",format:l}}return{value:"auto",customPattern:"",format:t}}function f(t,e,Y=""){var u;const n=D[t].find(a=>a.value===e),o=e.startsWith("preset:")?e.slice(7):void 0,s=e==="custom"?{type:"temporal_bucket",presentation:{mode:"pattern",pattern:Y.trim()||(((u=n==null?void 0:n.format)==null?void 0:u.presentation.mode)==="pattern"?n.format.presentation.pattern:"")}}:(n==null?void 0:n.format)??(o&&M.isTemporalBucketPreset(o)?{type:"temporal_bucket",presentation:{mode:"preset",preset:o}}:void 0);return!s||!M.validateTemporalBucketFormatApplicability(s,t).ok?l:s}function H(t,e){return M.validateTemporalBucketFormatApplicability(t,e).ok?t:l}exports.AUTOMATIC_TEMPORAL_BUCKET_FORMAT=l;exports.getTemporalBucketAuthoringOptions=_;exports.getTemporalBucketAuthoringSelection=A;exports.previewTemporalBucketAuthoringFormat=k;exports.reconcileTemporalBucketAuthoringFormat=H;exports.resolveTemporalBucketAuthoringFormat=f;