react-semaphor 0.1.477 → 0.1.479
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.
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +9 -9
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +4 -4
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +4 -4
- package/dist/chunks/{analyze-result-contract-OgPk-zGu.cjs → analyze-result-contract-BX_nQmPN.cjs} +1 -1
- package/dist/chunks/{analyze-result-contract-C8s8EUL5.js → analyze-result-contract-DsiAzCYn.js} +1 -1
- package/dist/chunks/{saved-temporal-bucket-format-CHsXUPJI.js → card-config-utils-CyDKaPNT.js} +190 -190
- package/dist/chunks/card-config-utils-D3Xuu0ub.cjs +1 -0
- package/dist/chunks/{common-types-C1IM7gao.cjs → common-types-BCSbPclk.cjs} +1 -1
- package/dist/chunks/{common-types-BLPy5_E0.js → common-types-D3r4PILe.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-CXHq6ime.cjs → dashboard-briefing-launcher-DWwSdfV7.cjs} +2 -2
- package/dist/chunks/{dashboard-briefing-launcher-C9d8CPxv.js → dashboard-briefing-launcher-Dk4yNOLY.js} +134 -134
- package/dist/chunks/{dashboard-controls-d7Yd2fJb.cjs → dashboard-controls-B0Pm_y8L.cjs} +10 -10
- package/dist/chunks/{dashboard-controls-BqDm4ARp.js → dashboard-controls-CIC5_549.js} +13 -12
- package/dist/chunks/{dashboard-input-contract-JFJZgenC.cjs → dashboard-date-comparison-definition-C93wv8Ua.cjs} +1 -1
- package/dist/chunks/{dashboard-input-contract-BrGdGFz0.js → dashboard-date-comparison-definition-KohOqBqR.js} +19 -19
- package/dist/chunks/dashboard-filter-value-compatibility-ByT__CYM.cjs +1 -0
- package/dist/chunks/dashboard-filter-value-compatibility-DQkUs41q.js +1220 -0
- package/dist/chunks/dashboard-json-Bk6nEHap.cjs +1 -0
- package/dist/chunks/{dashboard-json-CL_vgcWq.js → dashboard-json-YDTb3r4e.js} +7 -7
- package/dist/chunks/{edit-dashboard-visual-Dklel3MC.cjs → edit-dashboard-visual-B3oH-O0L.cjs} +6 -6
- package/dist/chunks/{edit-dashboard-visual-C0Zvyo-X.js → edit-dashboard-visual-q5Yj9dMP.js} +277 -277
- package/dist/chunks/{editor-action-buttons-BOyUtX9j.js → editor-action-buttons-BqelO0n9.js} +39 -39
- package/dist/chunks/{editor-action-buttons-AcaZsiDy.cjs → editor-action-buttons-vZ63-lN-.cjs} +1 -1
- package/dist/chunks/{format-types-CFHQoIuk.js → index-BS0_dp0l.js} +168 -168
- package/dist/chunks/{index-D9S3j7_z.js → index-BvRREsU9.js} +9 -9
- package/dist/chunks/index-ByQgqT9d.cjs +1 -0
- package/dist/chunks/{index-DrdF7QR7.js → index-CUCiMVzS.js} +34219 -35005
- package/dist/chunks/{index-v2MZLyus.cjs → index-CXeIDdjd.cjs} +1 -1
- package/dist/chunks/{index-Cd8qGOXl.cjs → index-DhDfPZUu.cjs} +232 -232
- package/dist/chunks/matrix-result-contract-CFPnlcLm.cjs +1 -0
- package/dist/chunks/{matrix-result-contract-BpzhImar.js → matrix-result-contract-DFfUvb1r.js} +3 -3
- package/dist/chunks/{temporal-bucket-CtP7hKLa.js → metric-comparison-CTexJ8V1.js} +705 -705
- package/dist/chunks/metric-comparison-x0lipytf.cjs +1 -0
- package/dist/chunks/pivot-header-presentation-8Ra1RfHg.cjs +4 -0
- package/dist/chunks/{pivot-header-presentation-CaERAWpl.js → pivot-header-presentation-tpb_J900.js} +118 -118
- package/dist/chunks/{pivot-result-identity-CIZXsI53.js → pivot-result-identity-BIeP9v8I.js} +1 -1
- package/dist/chunks/{pivot-result-identity-DRUlTWUq.cjs → pivot-result-identity-BVnhG2rR.cjs} +1 -1
- package/dist/chunks/pivot-result-lifecycle-D_bRCqaB.cjs +1 -0
- package/dist/chunks/{pivot-result-lifecycle-B9FTybxN.js → pivot-result-lifecycle-mjJ1rBvV.js} +7 -7
- package/dist/chunks/{raw-temporal-contract-U8J9RlEH.js → raw-temporal-contract-BuQIB31z.js} +1 -1
- package/dist/chunks/{raw-temporal-contract-D8YuxTAg.cjs → raw-temporal-contract-vnNwLy9R.cjs} +1 -1
- package/dist/chunks/report-preferences-dialog--aV7ITSE.cjs +1 -0
- package/dist/chunks/{report-preferences-dialog-BjygtSP3.js → report-preferences-dialog-DKq0k5BH.js} +25 -25
- package/dist/chunks/{report-runtime-context-DNbgCsko.js → report-runtime-context-B_pAmqxl.js} +1 -1
- package/dist/chunks/{report-runtime-context-RFiWq4wK.cjs → report-runtime-context-BfW4qiMJ.cjs} +1 -1
- package/dist/chunks/{source-entity-resolution-BDC-Qngk.cjs → source-entity-resolution-DCAAS-y8.cjs} +1 -1
- package/dist/chunks/{source-entity-resolution-ugN3sZUk.js → source-entity-resolution-WUstJID6.js} +1 -1
- package/dist/chunks/switch-D12C40LN.cjs +138 -0
- package/dist/chunks/{switch-C8NihGV4.js → switch-LucIPRtD.js} +13142 -11648
- package/dist/chunks/{temporal-bucket-authoring-DJ9kK2wD.js → temporal-bucket-authoring-CyTCHy1K.js} +3 -3
- package/dist/chunks/temporal-bucket-authoring-DueSgLJU.cjs +1 -0
- package/dist/chunks/{temporal-bucket-contract-CZl5D7FZ.js → temporal-bucket-contract-BeOx0uYe.js} +1 -1
- package/dist/chunks/{temporal-bucket-contract-BD862TAa.cjs → temporal-bucket-contract-Cp-usD9Z.cjs} +1 -1
- package/dist/chunks/{token-types-CoHsSJ4E.cjs → token-types-D9eN35rf.cjs} +1 -1
- package/dist/chunks/{token-types-DfDtCqlw.js → token-types-Dvomvqw0.js} +1 -1
- package/dist/chunks/{update-policy-BGNXFgBU.cjs → update-policy-Buw2LmvX.cjs} +1 -1
- package/dist/chunks/{update-policy-BybMiM61.js → update-policy-MWg0aH3d.js} +1 -1
- package/dist/chunks/{validators-D-T-2HOR.js → validators-D3AarM2T.js} +662 -663
- package/dist/chunks/validators-DqIM0B3C.cjs +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +81 -79
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +3 -3
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +3 -3
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +9 -9
- package/dist/index.cjs +1 -1
- package/dist/index.js +177 -176
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/briefings.d.ts +19 -2
- package/dist/types/dashboard-authoring.d.ts +26 -3
- package/dist/types/dashboard.d.ts +20 -3
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +39 -18
- package/dist/types/shared.d.ts +19 -2
- package/dist/types/surfboard.d.ts +20 -3
- package/dist/types/types.d.ts +20 -3
- package/package.json +1 -1
- package/dist/chunks/dashboard-filter-value-compatibility-BCVF9IHg.js +0 -1026
- package/dist/chunks/dashboard-filter-value-compatibility-DLkdeypb.cjs +0 -1
- package/dist/chunks/dashboard-json-BYQjTmqD.cjs +0 -1
- package/dist/chunks/format-types-PSZZ7hG8.cjs +0 -1
- package/dist/chunks/matrix-result-contract-Bhg60NtS.cjs +0 -1
- package/dist/chunks/pivot-header-presentation-CePk1R6g.cjs +0 -4
- package/dist/chunks/pivot-result-lifecycle-CcGt_29N.cjs +0 -1
- package/dist/chunks/report-preferences-dialog-DW40ECz1.cjs +0 -1
- package/dist/chunks/saved-temporal-bucket-format-DNMtD77o.cjs +0 -1
- package/dist/chunks/switch-B1mZx2k9.cjs +0 -138
- package/dist/chunks/temporal-bucket-9Wz9Ds6H.cjs +0 -1
- package/dist/chunks/temporal-bucket-authoring-DSpzgXHc.cjs +0 -1
- package/dist/chunks/validators-DcshgK7w.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var q=Object.defineProperty;var B=(e,r,t)=>r in e?q(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var v=(e,r,t)=>B(e,typeof r!="symbol"?r+"":r,t);const I=require("../value-format-preferences/index.cjs"),h=require("./validators-DqIM0B3C.cjs");function _(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const r=Object.getPrototypeOf(e);if(r===null||r===Object.prototype)return!0;const t=Object.prototype.hasOwnProperty.call(r,"constructor")?r.constructor:void 0;return typeof t=="function"&&Function.prototype.toString.call(t)===Function.prototype.toString.call(Object)}const F={dateStyle:"short",dateTime:{dateStyle:"short",timeStyle:"short"}};class y extends Error{constructor(t,o){super(o);v(this,"code");this.name="TemporalBucketContractError",this.code=t}}const G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],V=["January","February","March","April","May","June","July","August","September","October","November","December"];function $(e){return{ok:!1,error:{code:"invalid_temporal_bucket_value",message:e}}}function H(e){return e%4===0&&(e%100!==0||e%400===0)}function J(e,r){return r===2?H(e)?29:28:[4,6,9,11].includes(r)?30:31}function z(e,r,t){const o=[0,3,2,5,0,3,5,1,4,6,2,4],n=r<3?e-1:e;return(n+Math.floor(n/4)-Math.floor(n/100)+Math.floor(n/400)+o[r-1]+t)%7}function T(e){var r;return(r=e.calendar.fiscalCalendar)==null?void 0:r.yearStartMonth}function Z(e,r){return(e-r+12)%12%3===0}function Q(e,r){const{granularity:t}=r,o=T(r)??1;switch(t){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 z(e.year,e.month,e.day)===r.calendar.weekStart;case"month":return e.day===1;case"quarter":return e.day===1&&Z(e.month,o);case"year":return e.day===1&&e.month===o}}function R(e,r){if(e===null)return{ok:!0,value:null};const t=r.granularity==="second"||r.granularity==="minute"||r.granularity==="hour",o=t?/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e):/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!o)return $(`Expected ${t?"YYYY-MM-DDTHH:mm:ss":"YYYY-MM-DD"} for ${r.granularity} granularity.`);const n={year:Number(o[1]),month:Number(o[2]),day:Number(o[3]),hour:t?Number(o[4]):0,minute:t?Number(o[5]):0,second:t?Number(o[6]):0};return n.year<1||n.month<1||n.month>12||n.day<1||n.day>J(n.year,n.month)||n.hour>23||n.minute>59||n.second>59?$(`Invalid canonical ${r.granularity} bucket value ${e}.`):Q(n,r)?{ok:!0,value:n}:$(`Canonical value ${e} is not aligned to ${r.granularity} granularity and its governed Calendar.`)}function x(e){if(!_(e))return{ok:!1,issues:[{path:"$",message:"Resolved temporal bucket format must be an object."}]};const r=[],t=new Set(["type","presentation","locale"]);for(const s of Object.keys(e))t.has(s)||r.push({path:s,message:`Unknown property "${s}".`});e.type!=="temporal_bucket"&&r.push({path:"type",message:"Expected temporal_bucket."});const o=e.presentation;if(!_(o))r.push({path:"presentation",message:"Expected a presentation object."});else{const s=o.mode,l=s==="preset"?new Set(["mode","preset"]):s==="pattern"?new Set(["mode","pattern"]):s==="auto"?new Set(["mode","styles"]):new Set(["mode"]);for(const c of Object.keys(o))l.has(c)||r.push({path:`presentation.${c}`,message:`Unknown property "${c}".`});if(s==="preset")h.isTemporalBucketPreset(o.preset)||r.push({path:"presentation.preset",message:"Expected a supported preset."});else if(s==="pattern")if(typeof o.pattern!="string"||!o.pattern)r.push({path:"presentation.pattern",message:"Expected a non-empty pattern."});else{const c=h.tokenizeTemporalBucketPattern(o.pattern);c.ok||r.push({path:"presentation.pattern",message:c.message})}else if(s==="auto"){const c=o.styles;(!_(c)||!["short","medium","long"].includes(String(c.dateStyle))||!_(c.dateTime)||!["short","medium","long"].includes(String(c.dateTime.dateStyle))||!["short","medium","long"].includes(String(c.dateTime.timeStyle))||Object.keys(c).some(m=>m!=="dateStyle"&&m!=="dateTime")||Object.keys(c.dateTime).some(m=>m!=="dateStyle"&&m!=="timeStyle"))&&r.push({path:"presentation.styles",message:"Expected complete resolved date and datetime styles."})}else r.push({path:"presentation.mode",message:"Expected auto, preset, or pattern."})}const n=I.canonicalizeSupportedLocale(e.locale);if(n||r.push({path:"locale",message:"Expected a supported base BCP 47 locale."}),r.length>0||!n||!_(o))return{ok:!1,issues:r};if(o.mode==="auto"){const s=o.styles;return{ok:!0,value:{type:"temporal_bucket",locale:n,presentation:{mode:"auto",styles:{dateStyle:s.dateStyle,dateTime:{dateStyle:s.dateTime.dateStyle,timeStyle:s.dateTime.timeStyle}}}}}}return{ok:!0,value:{type:"temporal_bucket",presentation:o.mode==="preset"?{mode:"preset",preset:o.preset}:{mode:"pattern",pattern:o.pattern},locale:n}}}function W(e,r){const t=!!r.calendar.fiscalCalendar;return e==="fiscal_quarter_short"||e==="fiscal_year"?t:e==="quarter_short"||e==="quarter_long"?!t:!0}function L(e,r){return h.validateTemporalBucketFormatApplicability(e,r.granularity).ok?e.presentation.mode==="preset"?W(e.presentation.preset,r):!(e.presentation.mode==="pattern"&&r.calendar.fiscalCalendar&&(r.granularity==="quarter"||r.granularity==="year")):!1}function D(e,r){if(!(!e||e.presentation.mode==="auto"))return L(e,r)?{type:"temporal_bucket",presentation:e.presentation}:void 0}function K(e){var n;const r=I.canonicalizeSupportedLocale(e.locale);if(!r)throw new y("invalid_temporal_bucket_format","Temporal bucket locale must be a supported base BCP 47 locale.");const t=D(e.cardFormat,e.metadata);if(t)return{format:{...t,locale:r},source:"card"};const o=((n=e.semanticFormat)==null?void 0:n.granularity)===e.metadata.granularity?D(e.semanticFormat.format,e.metadata):void 0;return o?{format:{...o,locale:r},source:"semantic"}:{format:{type:"temporal_bucket",locale:r,presentation:{mode:"auto",styles:e.styles??F}},source:"automatic"}}function f(e,r=2){return String(e).padStart(r,"0")}function C(e,r,t){if(r==="en-US")return(t==="short"?G:V)[e-1];const o=new Date(Date.UTC(2e3,e-1,15));return new Intl.DateTimeFormat(r,{calendar:"gregory",month:t,timeZone:"UTC"}).format(o)}function X(e,r,t){return r.map(o=>{if(o.kind==="literal")return o.value;switch(o.value){case"YYYY":return f(e.year,4);case"YY":return f(e.year%100);case"MMMM":return C(e.month,t,"long");case"MMM":return C(e.month,t,"short");case"MM":return f(e.month);case"DD":return f(e.day);case"HH":return f(e.hour);case"mm":return f(e.minute);case"ss":return f(e.second)}}).join("")}const E=new Map;function g(e,r){const t=`${e}:${JSON.stringify(r)}`,o=E.get(t);if(o)return o;const n=new Intl.DateTimeFormat(e,r);return E.set(t,n),n}function w(e){const r=new Date(0);return r.setUTCFullYear(e.year,e.month-1,e.day),r.setUTCHours(e.hour,e.minute,e.second,0),r}function A(e,r,t){return g(r,{calendar:"gregory",dateStyle:t,timeZone:"UTC"}).format(w(e))}function ee(e,r,t){return g(r,{calendar:"gregory",dateStyle:t.dateStyle,timeStyle:t.timeStyle==="long"?"medium":t.timeStyle,timeZone:"UTC"}).format(w(e))}function re(e,r,t){var n;if(t==="short"){const a=w(e),s=g(r,{calendar:"gregory",dateStyle:"short",timeZone:"UTC"}).formatToParts(a),l=s.findIndex(p=>p.type==="month"),c=s.findIndex(p=>p.type==="year"),m=(n=g(r,{calendar:"gregory",timeZone:"UTC",year:"numeric"}).formatToParts(a).find(p=>p.type==="year"))==null?void 0:n.value;if(l>=0&&c>=0&&m){const p=Math.min(l,c),U=Math.max(l,c);let k=!1;return s.slice(p,U+1).filter(b=>b.type==="day"?(k=!0,!1):k&&b.type==="literal"?(k=!1,!1):!0).map(b=>b.type==="year"?m:b.value).join("")}}return g(r,{calendar:"gregory",month:t==="short"?"numeric":t==="medium"?"short":"long",timeZone:"UTC",year:"numeric"}).format(w(e))}function te(e,r){return Math.floor((e.month-r+12)%12/3)+1}function P(e,r){return r===1||e.month<r?e.year:e.year+1}function oe(e){return e===1?"1st":e===2?"2nd":e===3?"3rd":`${e}th`}function S(e,r,t,o){const n=T(o)??1,a=te(e,n);switch(r){case"week_of_short":return`Week of ${C(e.month,t,"short")} ${e.day}, ${e.year}`;case"week_of_long":return`Week of ${C(e.month,t,"long")} ${e.day}, ${e.year}`;case"quarter_short":return`Q${a} ${e.year}`;case"quarter_long":return`${oe(a)} Quarter ${e.year}`;case"fiscal_quarter_short":return`Q${a} FY${P(e,n)}`;case"fiscal_year":return`FY${P(e,n)}`}}function ne(e,r,t,o){const n=T(r);switch(r.granularity){case"second":case"minute":case"hour":return ee(e,t,o.dateTime);case"day":return A(e,t,o.dateStyle);case"week":return`Week of ${A(e,t,o.dateStyle)}`;case"month":return re(e,t,o.dateStyle);case"quarter":return S(e,n?"fiscal_quarter_short":"quarter_short",t,r);case"year":return n?S(e,"fiscal_year",t,r):String(e.year)}}function ae(e){const r=x(e.format);if(!r.ok||!L(r.value,e.metadata))throw new y("invalid_temporal_bucket_format","Resolved temporal bucket format is invalid or inapplicable to its metadata.");const t=R(e.value,e.metadata);if(!t.ok)throw new y(t.error.code,t.error.message);if(t.value===null)return"(Blank)";const{presentation:o,locale:n}=r.value;if(o.mode==="auto")return ne(t.value,e.metadata,n,o.styles);if(o.mode==="preset")return S(t.value,o.preset,n,e.metadata);const a=h.tokenizeTemporalBucketPattern(o.pattern);if(!a.ok)throw new y("invalid_temporal_bucket_format",a.message);return X(t.value,a.segments,n)}const Y="higher_is_better",ie={displayMode:"difference",showComparison:!0,indicatorStyle:"arrow_badge",showColor:!0,conditionalLabel:!1};function se(e){return h.parseSemaphorIsoInstant(e)!==null}function ce(e){var r,t,o,n;if(((r=e.metricComparison)==null?void 0:r.mode)!=="off"){if(((t=e.metricComparison)==null?void 0:t.mode)==="explicit")return{source:"explicit",spec:e.metricComparison.spec};if(!((e.inheritGlobalComparison??((o=e.globalDateComparison)==null?void 0:o.inheritGlobalComparison))===!1||((n=e.globalDateComparison)==null?void 0:n.selection.mode)!=="period"))return{source:"inherited",spec:e.globalDateComparison.selection.spec,...e.globalDateComparison.owner?{owner:e.globalDateComparison.owner}:{}}}}function le(e){if(e.alias)return e.alias;const r=e.entityName&&e.entityName!=="SEMAPHOR_CALCULATED_FIELD"?e.entityName:void 0,t=r&&r!==e.name?`${r}_`:"";if(e.role!=="metric")return`${t}${e.name}`;let o=e.aggregate||"metric";if(e.expression){const n=e.expression.match(/^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i);o=n?n[1].toLowerCase():"expr"}else o=o.toLowerCase();return`${t}${e.name}_${o}`}function i(e,r,t){return t?{code:e,message:r,path:t}:{code:e,message:r}}function d(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function u(e,r,t,o){Object.keys(e).forEach(n=>{r.includes(n)||o.push(i("invalid_comparison_spec",`Comparison kind does not accept field "${n}".`,`${t}.${n}`))})}function O(e,r,t){e.alignment!==void 0&&e.alignment!=="calendar"&&e.alignment!=="weekday"&&t.push(i("invalid_comparison_spec",'Comparison alignment must be "calendar" or "weekday".',`${r}.alignment`)),e.toDate!==void 0&&typeof e.toDate!="boolean"&&t.push(i("invalid_comparison_spec","Comparison toDate must be a boolean.",`${r}.toDate`))}function N(e,r,t){e!==void 0&&(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)&&t.push(i("invalid_comparison_spec","Comparison offset must be a positive safe integer.",r))}function M(e,r="comparison"){const t=[];return d(e)?(e.kind==="previous_period"?(u(e,["kind","offsetPeriods","alignment","toDate"],r,t),N(e.offsetPeriods,`${r}.offsetPeriods`,t),O(e,r,t)):e.kind==="previous_year"?(u(e,["kind","offsetYears","alignment","toDate"],r,t),N(e.offsetYears,`${r}.offsetYears`,t),O(e,r,t)):e.kind==="target"?(u(e,["kind","targetValue"],r,t),(typeof e.targetValue!="number"||!Number.isFinite(e.targetValue))&&t.push(i("invalid_comparison_spec","Target comparison requires a finite targetValue.",`${r}.targetValue`))):t.push(i("invalid_comparison_spec","Comparison kind must be previous_period, previous_year, or target.",`${r}.kind`)),{ok:t.length===0,errors:t,warnings:[]}):{ok:!1,errors:[i("invalid_comparison_spec","Comparison spec must be an object.",r)],warnings:[]}}function ue(e,r="comparison"){if(!d(e))return{ok:!1,errors:[i("invalid_comparison_config","Comparison config must be an object.",r)],warnings:[]};const t=[];return e.mode==="off"?u(e,["mode"],r,t):e.mode==="explicit"?(u(e,["mode","spec"],r,t),t.push(...M(e.spec,`${r}.spec`).errors)):t.push(i("invalid_comparison_config","Comparison mode must be off or explicit.",`${r}.mode`)),{ok:t.length===0,errors:t,warnings:[]}}function j(e,r="comparisonSelection"){if(!d(e))return{ok:!1,errors:[i("invalid_global_date_comparison","Global Date comparison selection must be an object.",r)],warnings:[]};const t=[];if(e.mode==="off")u(e,["mode"],r,t);else if(e.mode==="period"){u(e,["mode","spec"],r,t);const o=M(e.spec,`${r}.spec`);t.push(...o.errors),d(e.spec)&&e.spec.kind==="target"&&t.push(i("invalid_global_date_comparison","Global Date comparison supports previous_period or previous_year, not target.",`${r}.spec.kind`))}else t.push(i("invalid_global_date_comparison","Global Date comparison mode must be off or period.",`${r}.mode`));return{ok:t.length===0,errors:t,warnings:[]}}function me(e,r="globalDateComparison"){if(!d(e))return{ok:!1,errors:[i("invalid_global_date_comparison","Global Date comparison context must be an object.",r)],warnings:[]};const t=[];return u(e,["selection","inheritGlobalComparison","owner","referenceTime"],r,t),t.push(...j(e.selection,`${r}.selection`).errors),e.inheritGlobalComparison!==void 0&&e.inheritGlobalComparison!==!1&&t.push(i("invalid_global_date_comparison","inheritGlobalComparison may only be false when present.",`${r}.inheritGlobalComparison`)),e.owner!==void 0&&(d(e.owner)?e.owner.kind==="global_date"?u(e.owner,["kind"],`${r}.owner`,t):e.owner.kind==="field_date"?(u(e.owner,["kind","filterId","label"],`${r}.owner`,t),(typeof e.owner.filterId!="string"||!e.owner.filterId.trim())&&t.push(i("invalid_global_date_comparison","Field Date comparison owner requires a non-empty filterId.",`${r}.owner.filterId`)),(typeof e.owner.label!="string"||!e.owner.label.trim())&&t.push(i("invalid_global_date_comparison","Field Date comparison owner requires a non-empty label.",`${r}.owner.label`))):t.push(i("invalid_global_date_comparison","Comparison owner kind must be global_date or field_date.",`${r}.owner.kind`)):t.push(i("invalid_global_date_comparison","Comparison owner must be an object.",`${r}.owner`))),e.referenceTime!==void 0&&(typeof e.referenceTime!="string"||!se(e.referenceTime))&&t.push(i("invalid_global_date_comparison","referenceTime must be a valid ISO date-time string when present.",`${r}.referenceTime`)),{ok:t.length===0,errors:t,warnings:[]}}function de(e,r="comparisonPolarity"){return e==="higher_is_better"||e==="lower_is_better"||e==="neutral"?{ok:!0,errors:[],warnings:[]}:{ok:!1,errors:[i("invalid_comparison_polarity","Comparison polarity must be higher_is_better, lower_is_better, or neutral.",r)],warnings:[]}}function pe(e,r="comparisonPresentation"){if(!d(e))return{ok:!1,errors:[i("invalid_comparison_presentation","Comparison presentation must be an object.",r)],warnings:[]};const t=[],o=["displayMode","showComparison","precision","indicatorStyle","showColor","position","conditionalLabel","labelName","conditionalLabels","colors"];return Object.keys(e).forEach(a=>{o.includes(a)||t.push(i("invalid_comparison_presentation",`Comparison presentation does not accept field "${a}".`,`${r}.${a}`))}),[["displayMode",["difference","percent_change","both","ratio"]],["indicatorStyle",["arrow_badge","arrow","badge","none"]],["position",["left","right","top"]]].forEach(([a,s])=>{e[a]!==void 0&&!s.includes(e[a])&&t.push(i("invalid_comparison_presentation",`Comparison presentation ${a} is invalid.`,`${r}.${a}`))}),["showComparison","showColor","conditionalLabel"].forEach(a=>{e[a]!==void 0&&typeof e[a]!="boolean"&&t.push(i("invalid_comparison_presentation",`Comparison presentation ${a} must be a boolean.`,`${r}.${a}`))}),e.precision!==void 0&&(typeof e.precision!="number"||!Number.isInteger(e.precision)||e.precision<0||e.precision>6)&&t.push(i("invalid_comparison_presentation","Comparison presentation precision must be an integer from 0 through 6.",`${r}.precision`)),e.labelName!==void 0&&typeof e.labelName!="string"&&t.push(i("invalid_comparison_presentation","Comparison presentation labelName must be a string.",`${r}.labelName`)),["conditionalLabels","colors"].forEach(a=>{const s=e[a];if(s!==void 0){if(!d(s)){t.push(i("invalid_comparison_presentation",`Comparison presentation ${a} must be an object.`,`${r}.${a}`));return}Object.keys(s).forEach(l=>{["increase","decrease","neutral"].includes(l)||t.push(i("invalid_comparison_presentation",`Comparison presentation ${a} does not accept field "${l}".`,`${r}.${a}.${l}`))}),Object.entries(s).forEach(([l,c])=>{c!==void 0&&typeof c!="string"&&t.push(i("invalid_comparison_presentation",`Comparison presentation ${a}.${l} must be a string.`,`${r}.${a}.${l}`))})}}),{ok:t.length===0,errors:t,warnings:[]}}function fe(e){return e===null?"unknown":e>0?"increase":e<0?"decrease":"no_change"}function _e(e,r){return e==="unknown"||e==="no_change"||r==="neutral"?"neutral":r==="higher_is_better"&&e==="increase"||r==="lower_is_better"&&e==="decrease"?"favorable":"unfavorable"}function be(e){const{currentValue:r,comparisonValue:t,polarity:o=Y}=e,a=r!==null&&t!==null?r-t:null,s=a!==null&&t!==null&&t!==0?a/Math.abs(t):null,l=r!==null&&t!==null&&t!==0?r/t:null,c=fe(a);return{status:t===null?"insufficient_history":"available",currentValue:r,comparisonValue:t,delta:a,percentChange:s,ratio:l,direction:c,sentiment:_e(c,o)}}exports.COMPARISON_PRESENTATION_DEFAULTS=ie;exports.DEFAULT_METRIC_COMPARISON_POLARITY=Y;exports.DEFAULT_RESOLVED_TEMPORAL_STYLE_SET=F;exports.TemporalBucketContractError=y;exports.evaluateMetricComparison=be;exports.formatTemporalBucket=ae;exports.isPlainJsonRecord=_;exports.parseResolvedTemporalBucketFormat=x;exports.parseTemporalBucketValue=R;exports.resolveMetricComparisonRequest=ce;exports.resolveMetricResultAlias=le;exports.resolveTemporalBucketPresentation=K;exports.validateComparisonPresentationSpec=pe;exports.validateGlobalDateComparisonContext=me;exports.validateGlobalDateComparisonSelection=j;exports.validateMetricComparisonConfig=ue;exports.validateMetricComparisonPolarity=de;exports.validateMetricComparisonSpec=M;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";var X=Object.defineProperty;var Z=(e,t,n)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var p=(e,t,n)=>Z(e,typeof t!="symbol"?t+"":t,n);const c=require("./index-ByQgqT9d.cjs"),M=require("./pivot-result-lifecycle-D_bRCqaB.cjs"),B=require("./index-F25jnH0p.cjs"),j=require("./metric-comparison-x0lipytf.cjs"),v=["day","hour","minute","second","millisecond"],x={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},H={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},Y={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function K(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond"}function R(e,t){return K(e)?e:t}function S(e,t){return v.indexOf(R(e,t))}function W(e,t){const n=S(e,"day"),o=S(t,"second"),r=Math.min(n,o),a=Math.max(n,o);return v.slice(r,a+1)}function q(e,t){return e*x[R(t,"second")]}function J(e,t){const n=W(t.largestUnit,t.smallestUnit),o=n[n.length-1],r=x[o];let a=Math.round(e/r)*r;return n.map(i=>{const s=x[i],l=Math.floor(a/s);return a-=l*s,{unit:i,value:l}})}function Q(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>`${a.value}${H[a.unit]}`).join(" ")}function z(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>{const[i,s]=Y[a.unit];return`${a.value} ${a.value===1?i:s}`}).join(" ")}function ee(e){const t=e.some(l=>l.unit==="day"&&l.value!==0),n=e.some(l=>l.unit==="millisecond"),o=e.findIndex(l=>l.value!==0),r=Math.max(0,e.length-2),a=t?0:o===-1?r:Math.min(o,r),i=o===-1?e.slice(r):e.slice(a);if(i.length===0)return"0";const s=i.map((l,u)=>l.unit==="millisecond"?String(l.value).padStart(3,"0"):u===0?String(l.value):String(l.value).padStart(2,"0")).join(":");return n?s.replace(/:(\d{3})$/,".$1"):s}function te(e,t,n){const o=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${o})`:`-${o}`:o}function E(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 o=t.inputUnit||"second",r=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",a=n<0,i=Math.abs(q(n,o)),s=J(i,t),l=r==="digital"?ee(s):r==="long"?z(s,t.maxUnits):Q(s,t.maxUnits);return te(l,a,t)}function ne(e,t,n){const o={...t,locale:t.locale??n};if(o.type==="number")return M.formatNumericCanonical(e,o);const{prefix:r,suffix:a,...i}=o;return`${r??""}${M.formatNumericCanonical(e,{...i,negativeStyle:o.type==="currency"?o.negativeStyle:"minus"})}${a??""}`}function T(e,t,n){return e===null?{value:e,text:null}:!t||!c.isNumericCanonicalFormat(t)&&t.type!=="duration"?{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n})}:t.type==="duration"?{value:e,text:E(e,{inputUnit:t.inputUnit,outputStyle:t.outputStyle,largestUnit:t.largestUnit,smallestUnit:t.smallestUnit,maxUnits:t.maxUnits,prefix:t.prefix,suffix:t.suffix,negativeInParentheses:t.negativeStyle==="parentheses"})}:{value:e,text:ne(e,t,n)}}function C(e,t,n,o){return e===null?{value:e,text:null}:o==="percent"?{value:e,text:M.formatNumericCanonical(e,{type:"percent",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,percentValueMode:"fraction"})}:{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,suffix:"×"})}}function _(e,t){if(e===void 0)return t;if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("Comparison precision must be an integer from 0 to 6.");return e}function re(e,t){const n={mode:t.displayMode,current:T(e.currentValue,t.metricFormat,t.locale),comparison:T(e.comparisonValue,t.metricFormat,t.locale)};return(t.displayMode==="difference"||t.displayMode==="both")&&(n.difference=T(e.delta,t.metricFormat,t.locale)),(t.displayMode==="percent_change"||t.displayMode==="both")&&(n.percentChange=C(e.percentChange,_(t.precision,1),t.locale,"percent")),t.displayMode==="ratio"&&(n.ratio=C(e.ratio,_(t.precision,2),t.locale,"ratio")),n}function y(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getTime()-o.getTime();return r<0?-1:r>0?1:r}function oe(e){return c.constructFrom(e,Date.now())}function ae(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getFullYear()-o.getFullYear(),a=n.getMonth()-o.getMonth();return r*12+a}function se(e){return t=>{const o=(e?Math[e]:Math.trunc)(t);return o===0?0:o}}function ie(e,t){return+c.toDate(e)-+c.toDate(t)}function le(e){const t=c.toDate(e);return t.setHours(23,59,59,999),t}function ce(e){const t=c.toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function ue(e){const t=c.toDate(e);return+le(t)==+ce(t)}function fe(e,t){const n=c.toDate(e),o=c.toDate(t),r=y(n,o),a=Math.abs(ae(n,o));let i;if(a<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*a);let s=y(n,o)===-r;ue(c.toDate(e))&&a===1&&y(e,o)===1&&(s=!1),i=r*(a-Number(s))}return i===0?0:i}function me(e,t,n){const o=ie(e,t)/1e3;return se(n==null?void 0:n.roundingMethod)(o)}function ge(e,t,n){const o=c.getDefaultOptions(),r=(n==null?void 0:n.locale)??o.locale??c.enUS,a=2520,i=y(e,t);if(isNaN(i))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:i});let l,u;i>0?(l=c.toDate(t),u=c.toDate(e)):(l=c.toDate(e),u=c.toDate(t));const g=me(u,l),m=(c.getTimezoneOffsetInMilliseconds(u)-c.getTimezoneOffsetInMilliseconds(l))/1e3,f=Math.round((g-m)/60);let h;if(f<2)return n!=null&&n.includeSeconds?g<5?r.formatDistance("lessThanXSeconds",5,s):g<10?r.formatDistance("lessThanXSeconds",10,s):g<20?r.formatDistance("lessThanXSeconds",20,s):g<40?r.formatDistance("halfAMinute",0,s):g<60?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",1,s):f===0?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",f,s);if(f<45)return r.formatDistance("xMinutes",f,s);if(f<90)return r.formatDistance("aboutXHours",1,s);if(f<c.minutesInDay){const d=Math.round(f/60);return r.formatDistance("aboutXHours",d,s)}else{if(f<a)return r.formatDistance("xDays",1,s);if(f<c.minutesInMonth){const d=Math.round(f/c.minutesInDay);return r.formatDistance("xDays",d,s)}else if(f<c.minutesInMonth*2)return h=Math.round(f/c.minutesInMonth),r.formatDistance("aboutXMonths",h,s)}if(h=fe(u,l),h<12){const d=Math.round(f/c.minutesInMonth);return r.formatDistance("xMonths",d,s)}else{const d=h%12,w=Math.trunc(h/12);return d<3?r.formatDistance("aboutXYears",w,s):d<9?r.formatDistance("overXYears",w,s):r.formatDistance("almostXYears",w+1,s)}}function V(e,t){return ge(e,oe(e),t)}function de(e,t){return e&&e!=="auto"?e:t}function he(e,t=new Date){try{const n={timeZone:e,timeZoneName:"short"},r=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(a=>a.type==="timeZoneName");return(r==null?void 0:r.value)||e}catch{return e}}function Me(e){try{const t={timeZone:e,timeZoneName:"long"},o=new Intl.DateTimeFormat("en-US",t).formatToParts(new Date).find(r=>r.type==="timeZoneName");return(o==null?void 0:o.value)||e}catch{return e}}function A(e,t="auto"){if(!e)return new Date(NaN);const n=e.endsWith("Z"),o=/[+-]\d{2}:?\d{2}$/.test(e),r=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||o||r?new Date(e):new Date(e+"Z");if(t==="local"){if(n||o){const a=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(a)}return new Date(e)}else return t==="UTC"?n?new Date(e):o?new Date(e):new Date(e+"Z"):n||o||r?new Date(e):B.fromZonedTime(e,t)}const ye="MM/dd/yyyy",De=(e,t,n,o="auto")=>{if(!e)return"";try{const r=A(e,o);if(isNaN(r.getTime()))return e;const i=(t&&t.trim()?t:ye).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?c.formatInTimeZone(r,n,i):c.format(r,i)}catch(r){return console.error("Date formatting error:",r),e}},be=(e,t="auto")=>{if(!e)return"";try{const n=A(e,t);return isNaN(n.getTime())?e:V(n,{addSuffix:!0})}catch(n){return console.error("Relative time formatting error:",n),e}};function I(e,t=","){if(e==null)return"";const n=String(e);return n.includes(t)||n.includes('"')||n.includes(`
|
|
2
|
+
`)||n.includes("\r")?`"${n.replace(/"/g,'""')}"`:n}function N(e,t=","){return e.map(n=>I(n,t)).join(t)}function $(e,t={}){const{delimiter:n=",",lineEnding:o=`
|
|
3
|
+
`}=t;return e.map(r=>N(r,n)).join(o)}function we(e,t={}){if(e.length===0)return"";const{delimiter:n=",",lineEnding:o=`
|
|
4
|
+
`,includeHeaders:r=!0,columns:a}=t,i=a||Object.keys(e[0]),s=[];r&&s.push(i);for(const l of e){const u=i.map(g=>{const m=l[g];return m==null?"":String(m)});s.push(u)}return $(s,{delimiter:n,lineEnding:o})}const O=1e4,Te=1e6;function xe(e){return e>O}const P="__TOTAL__";function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function b(e){return e===P}function Ae(e){const t=new Map,n=(e.groupByColumns??[]).map((r,a)=>{var u,g,m;if(!D(r))throw new Error(`Aggregate groupByColumns[${a}] is invalid`);const i=typeof r.id=="string"&&r.id.length>0?r.id:void 0,s=i?(m=(g=(u=e.columnKeyMap)==null?void 0:u.byRole)==null?void 0:g.groupby)==null?void 0:m[i]:void 0,l=(s==null?void 0:s.outputKey)||(s==null?void 0:s.rawKey)||(typeof r.alias=="string"&&r.alias.length>0?r.alias:typeof r.name=="string"&&r.name.length>0?r.name:void 0);if(!l)throw new Error(`Aggregate groupByColumns[${a}] has no output key`);return[i,r.alias,r.name,l].forEach(f=>{typeof f=="string"&&f.length>0&&t.set(f,l)}),l}),o=(e.rowAggregates??[]).flatMap(r=>!D(r)||typeof r.function!="string"||typeof r.groupLevel!="string"?[]:[{function:r.function,groupLevel:r.groupLevel==="ALL"?"ALL":t.get(r.groupLevel)||r.groupLevel,...typeof r.label=="string"?{label:r.label}:{}}]);return{groupColumnKeys:n,rowAggregates:o}}function F(e){return e==="SUM"?"Total":e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function U(e){var n;if(e.customLabel)return e.customLabel;const t=F(e.aggregateFunction);if(e.levelValue!==void 0&&!b(e.levelValue)){if(e.levelValue===null){const r=(n=e.formatValue)==null?void 0:n.call(e,null);return r?`Subtotal ${r}`:`Subtotal ${t}`}const o=e.formatValue?e.formatValue(e.levelValue):String(e.levelValue);if(o)return`Subtotal (${o})`}return`Subtotal ${t}`}function G(e,t){return t||`Grand ${F(e)}`}function Le(e){const t=e.context.groupColumnKeys.indexOf(e.columnKey);if(t<0)throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);if(!e.previousRow||e.row.isSubtotal===!0||e.row.isGrandTotal===!0||e.previousRow.isSubtotal===!0||e.previousRow.isGrandTotal===!0)return!0;for(let n=0;n<=t;n++){const o=e.context.groupColumnKeys[n];if(e.row[o]!==e.previousRow[o])return!0}return!1}function L(e){var o,r;const t=e.context.groupColumnKeys,n=typeof e.row.aggregate=="string"?e.row.aggregate:"SUM";if(e.row.isGrandTotal===!0){const a=(o=e.context.rowAggregates.find(i=>i.groupLevel==="ALL"))==null?void 0:o.label;return{kind:"grand-total",cells:t.map((i,s)=>({columnKey:i,text:s===0?G(n,a):"",placement:s===0?"label":"empty",colSpan:s===0?t.length:1}))}}if(e.row.isSubtotal===!0){if(typeof e.row.subtotalLevel!="string")throw new Error("Aggregate subtotal row is missing subtotalLevel");const a=t.indexOf(e.row.subtotalLevel);if(a<0)throw new Error(`Aggregate subtotal level "${e.row.subtotalLevel}" has no group column`);const i=D(e.row.subtotalContext)?e.row.subtotalContext:void 0,s=D(i==null?void 0:i.groupByValues)?i.groupByValues:{},l=(r=e.context.rowAggregates.find(u=>u.groupLevel===e.row.subtotalLevel&&u.function===n))==null?void 0:r.label;return{kind:"subtotal",cells:t.map((u,g)=>{if(g>a)return{columnKey:u,text:"",placement:"empty",colSpan:1};if(g<a){const m=e.row[u];return{columnKey:u,text:m===void 0||b(m)?"":e.formatValue(m,u),placement:"value",colSpan:1}}return{columnKey:u,text:U({aggregateFunction:n,customLabel:l,levelValue:s[u],formatValue:m=>e.formatLabelValue?e.formatLabelValue(m,u):String(e.formatValue(m,u)??"")}),placement:"label",colSpan:t.length-a}})}}return{kind:"data",cells:t.map(a=>{const i=e.row[a];return{columnKey:a,text:i===void 0||b(i)?"":e.formatValue(i,a),placement:"value",colSpan:1}})}}function pe(e){const t=L(e).cells.find(n=>n.columnKey===e.columnKey);if(!t)throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);return t.text}function Se(e){return L(e).cells.map(t=>t.text)}class k extends Error{constructor(n,o){super(`${n}: ${o}`);p(this,"deliveryBlocking",!0);this.code=n,this.name="PivotHeaderPresentationError"}}function Ce(e){var r;const t=e.mode??"formatted",n=e.members.map(a=>{var s;if(t==="canonical"||!a.temporalBucket)return a.value===null?"":String(a.value);const i=(s=e.resolveTemporalFormat)==null?void 0:s.call(e,a.fieldId);if(!i)throw new k("missing_resolved_temporal_format",`Missing resolved temporal presentation for pivot field "${a.fieldId}"`);return j.formatTemporalBucket({value:a.value,metadata:a.temporalBucket,format:i})}),o=((r=e.metricLabel)==null?void 0:r.trim())||void 0;return{memberLabels:n,...o?{metricLabel:o}:{},flattenedLabel:[...n,...o?[o]:[]].join(" / ")}}exports.AGGREGATE_TOTAL_MEMBER_MARKER=P;exports.DIRECT_CSV_EXPORT_MAX_ROWS=O;exports.FULL_DATASET_CSV_EXPORT_MAX_ROWS=Te;exports.PivotHeaderPresentationError=k;exports.arrayToCSV=$;exports.arrayToCSVRow=N;exports.escapeCSVValue=I;exports.formatAggregateGrandTotalLabel=G;exports.formatAggregateGroupCell=pe;exports.formatAggregateGroupRow=Se;exports.formatAggregateSubtotalLabel=U;exports.formatDate=De;exports.formatDistanceToNow=V;exports.formatDuration=E;exports.formatMetricComparison=re;exports.formatRelativeTime=be;exports.getTimezoneAbbreviation=he;exports.getTimezoneName=Me;exports.isAggregateTotalMemberMarker=b;exports.objectsToCSV=we;exports.parseWithSourceTimezone=A;exports.presentAggregateGroupRow=L;exports.presentPivotHeader=Ce;exports.requiresChunkedCsvExport=xe;exports.resolveAggregateTablePresentationContext=Ae;exports.resolveTimezone=de;exports.shouldPresentAggregateGroupValue=Le;
|
package/dist/chunks/{pivot-header-presentation-CaERAWpl.js → pivot-header-presentation-tpb_J900.js}
RENAMED
|
@@ -1,101 +1,10 @@
|
|
|
1
1
|
var R = Object.defineProperty;
|
|
2
2
|
var F = (e, t, n) => t in e ? R(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var A = (e, t, n) => F(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { t as f, c as
|
|
5
|
-
import { b as y } from "./pivot-result-lifecycle-
|
|
4
|
+
import { i as U, t as f, c as O, g as P, e as k, a as T, m as S, b as M, f as Z, d as X } from "./index-BS0_dp0l.js";
|
|
5
|
+
import { b as y } from "./pivot-result-lifecycle-mjJ1rBvV.js";
|
|
6
6
|
import { f as B } from "./index-CACdoqu3.js";
|
|
7
|
-
import { h as G } from "./
|
|
8
|
-
function w(e, t) {
|
|
9
|
-
const n = f(e), o = f(t), r = n.getTime() - o.getTime();
|
|
10
|
-
return r < 0 ? -1 : r > 0 ? 1 : r;
|
|
11
|
-
}
|
|
12
|
-
function j(e) {
|
|
13
|
-
return U(e, Date.now());
|
|
14
|
-
}
|
|
15
|
-
function H(e, t) {
|
|
16
|
-
const n = f(e), o = f(t), r = n.getFullYear() - o.getFullYear(), s = n.getMonth() - o.getMonth();
|
|
17
|
-
return r * 12 + s;
|
|
18
|
-
}
|
|
19
|
-
function Y(e) {
|
|
20
|
-
return (t) => {
|
|
21
|
-
const o = (e ? Math[e] : Math.trunc)(t);
|
|
22
|
-
return o === 0 ? 0 : o;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function K(e, t) {
|
|
26
|
-
return +f(e) - +f(t);
|
|
27
|
-
}
|
|
28
|
-
function W(e) {
|
|
29
|
-
const t = f(e);
|
|
30
|
-
return t.setHours(23, 59, 59, 999), t;
|
|
31
|
-
}
|
|
32
|
-
function q(e) {
|
|
33
|
-
const t = f(e), n = t.getMonth();
|
|
34
|
-
return t.setFullYear(t.getFullYear(), n + 1, 0), t.setHours(23, 59, 59, 999), t;
|
|
35
|
-
}
|
|
36
|
-
function J(e) {
|
|
37
|
-
const t = f(e);
|
|
38
|
-
return +W(t) == +q(t);
|
|
39
|
-
}
|
|
40
|
-
function Q(e, t) {
|
|
41
|
-
const n = f(e), o = f(t), r = w(n, o), s = Math.abs(
|
|
42
|
-
H(n, o)
|
|
43
|
-
);
|
|
44
|
-
let i;
|
|
45
|
-
if (s < 1)
|
|
46
|
-
i = 0;
|
|
47
|
-
else {
|
|
48
|
-
n.getMonth() === 1 && n.getDate() > 27 && n.setDate(30), n.setMonth(n.getMonth() - r * s);
|
|
49
|
-
let a = w(n, o) === -r;
|
|
50
|
-
J(f(e)) && s === 1 && w(e, o) === 1 && (a = !1), i = r * (s - Number(a));
|
|
51
|
-
}
|
|
52
|
-
return i === 0 ? 0 : i;
|
|
53
|
-
}
|
|
54
|
-
function z(e, t, n) {
|
|
55
|
-
const o = K(e, t) / 1e3;
|
|
56
|
-
return Y(n == null ? void 0 : n.roundingMethod)(o);
|
|
57
|
-
}
|
|
58
|
-
function ee(e, t, n) {
|
|
59
|
-
const o = O(), r = (n == null ? void 0 : n.locale) ?? o.locale ?? P, s = 2520, i = w(e, t);
|
|
60
|
-
if (isNaN(i))
|
|
61
|
-
throw new RangeError("Invalid time value");
|
|
62
|
-
const a = Object.assign({}, n, {
|
|
63
|
-
addSuffix: n == null ? void 0 : n.addSuffix,
|
|
64
|
-
comparison: i
|
|
65
|
-
});
|
|
66
|
-
let l, c;
|
|
67
|
-
i > 0 ? (l = f(t), c = f(e)) : (l = f(e), c = f(t));
|
|
68
|
-
const g = z(c, l), m = (T(c) - T(l)) / 1e3, u = Math.round((g - m) / 60);
|
|
69
|
-
let h;
|
|
70
|
-
if (u < 2)
|
|
71
|
-
return n != null && n.includeSeconds ? g < 5 ? r.formatDistance("lessThanXSeconds", 5, a) : g < 10 ? r.formatDistance("lessThanXSeconds", 10, a) : g < 20 ? r.formatDistance("lessThanXSeconds", 20, a) : g < 40 ? r.formatDistance("halfAMinute", 0, a) : g < 60 ? r.formatDistance("lessThanXMinutes", 1, a) : r.formatDistance("xMinutes", 1, a) : u === 0 ? r.formatDistance("lessThanXMinutes", 1, a) : r.formatDistance("xMinutes", u, a);
|
|
72
|
-
if (u < 45)
|
|
73
|
-
return r.formatDistance("xMinutes", u, a);
|
|
74
|
-
if (u < 90)
|
|
75
|
-
return r.formatDistance("aboutXHours", 1, a);
|
|
76
|
-
if (u < S) {
|
|
77
|
-
const d = Math.round(u / 60);
|
|
78
|
-
return r.formatDistance("aboutXHours", d, a);
|
|
79
|
-
} else {
|
|
80
|
-
if (u < s)
|
|
81
|
-
return r.formatDistance("xDays", 1, a);
|
|
82
|
-
if (u < M) {
|
|
83
|
-
const d = Math.round(u / S);
|
|
84
|
-
return r.formatDistance("xDays", d, a);
|
|
85
|
-
} else if (u < M * 2)
|
|
86
|
-
return h = Math.round(u / M), r.formatDistance("aboutXMonths", h, a);
|
|
87
|
-
}
|
|
88
|
-
if (h = Q(c, l), h < 12) {
|
|
89
|
-
const d = Math.round(u / M);
|
|
90
|
-
return r.formatDistance("xMonths", d, a);
|
|
91
|
-
} else {
|
|
92
|
-
const d = h % 12, D = Math.trunc(h / 12);
|
|
93
|
-
return d < 3 ? r.formatDistance("aboutXYears", D, a) : d < 9 ? r.formatDistance("overXYears", D, a) : r.formatDistance("almostXYears", D + 1, a);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function te(e, t) {
|
|
97
|
-
return ee(e, j(e), t);
|
|
98
|
-
}
|
|
7
|
+
import { h as G } from "./metric-comparison-CTexJ8V1.js";
|
|
99
8
|
const I = [
|
|
100
9
|
"day",
|
|
101
10
|
"hour",
|
|
@@ -108,55 +17,55 @@ const I = [
|
|
|
108
17
|
minute: 6e4,
|
|
109
18
|
second: 1e3,
|
|
110
19
|
millisecond: 1
|
|
111
|
-
},
|
|
20
|
+
}, j = {
|
|
112
21
|
day: "d",
|
|
113
22
|
hour: "hr",
|
|
114
23
|
minute: "min",
|
|
115
24
|
second: "s",
|
|
116
25
|
millisecond: "ms"
|
|
117
|
-
},
|
|
26
|
+
}, H = {
|
|
118
27
|
day: ["day", "days"],
|
|
119
28
|
hour: ["hour", "hours"],
|
|
120
29
|
minute: ["minute", "minutes"],
|
|
121
30
|
second: ["second", "seconds"],
|
|
122
31
|
millisecond: ["millisecond", "milliseconds"]
|
|
123
32
|
};
|
|
124
|
-
function
|
|
33
|
+
function Y(e) {
|
|
125
34
|
return e === "day" || e === "hour" || e === "minute" || e === "second" || e === "millisecond";
|
|
126
35
|
}
|
|
127
36
|
function V(e, t) {
|
|
128
|
-
return
|
|
37
|
+
return Y(e) ? e : t;
|
|
129
38
|
}
|
|
130
39
|
function v(e, t) {
|
|
131
40
|
return I.indexOf(V(e, t));
|
|
132
41
|
}
|
|
133
|
-
function
|
|
42
|
+
function K(e, t) {
|
|
134
43
|
const n = v(e, "day"), o = v(t, "second"), r = Math.min(n, o), s = Math.max(n, o);
|
|
135
44
|
return I.slice(r, s + 1);
|
|
136
45
|
}
|
|
137
|
-
function
|
|
46
|
+
function W(e, t) {
|
|
138
47
|
return e * L[V(t, "second")];
|
|
139
48
|
}
|
|
140
|
-
function
|
|
141
|
-
const n =
|
|
49
|
+
function q(e, t) {
|
|
50
|
+
const n = K(t.largestUnit, t.smallestUnit), o = n[n.length - 1], r = L[o];
|
|
142
51
|
let s = Math.round(e / r) * r;
|
|
143
52
|
return n.map((i) => {
|
|
144
53
|
const a = L[i], l = Math.floor(s / a);
|
|
145
54
|
return s -= l * a, { unit: i, value: l };
|
|
146
55
|
});
|
|
147
56
|
}
|
|
148
|
-
function
|
|
57
|
+
function J(e, t) {
|
|
149
58
|
const n = e.filter((s) => s.value !== 0), o = n.length > 0 ? n : [e[e.length - 1]], r = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : o.length;
|
|
150
|
-
return o.slice(0, r).map((s) => `${s.value}${
|
|
59
|
+
return o.slice(0, r).map((s) => `${s.value}${j[s.unit]}`).join(" ");
|
|
151
60
|
}
|
|
152
|
-
function
|
|
61
|
+
function Q(e, t) {
|
|
153
62
|
const n = e.filter((s) => s.value !== 0), o = n.length > 0 ? n : [e[e.length - 1]], r = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : o.length;
|
|
154
63
|
return o.slice(0, r).map((s) => {
|
|
155
|
-
const [i, a] =
|
|
64
|
+
const [i, a] = H[s.unit];
|
|
156
65
|
return `${s.value} ${s.value === 1 ? i : a}`;
|
|
157
66
|
}).join(" ");
|
|
158
67
|
}
|
|
159
|
-
function
|
|
68
|
+
function z(e) {
|
|
160
69
|
const t = e.some(
|
|
161
70
|
(l) => l.unit === "day" && l.value !== 0
|
|
162
71
|
), n = e.some((l) => l.unit === "millisecond"), o = e.findIndex((l) => l.value !== 0), r = Math.max(0, e.length - 2), s = t ? 0 : o === -1 ? r : Math.min(o, r), i = o === -1 ? e.slice(r) : e.slice(s);
|
|
@@ -165,20 +74,20 @@ function ue(e) {
|
|
|
165
74
|
const a = i.map((l, c) => l.unit === "millisecond" ? String(l.value).padStart(3, "0") : c === 0 ? String(l.value) : String(l.value).padStart(2, "0")).join(":");
|
|
166
75
|
return n ? a.replace(/:(\d{3})$/, ".$1") : a;
|
|
167
76
|
}
|
|
168
|
-
function
|
|
77
|
+
function ee(e, t, n) {
|
|
169
78
|
const o = `${n.prefix || ""}${e}${n.suffix || ""}`;
|
|
170
79
|
return t ? n.negativeInParentheses ? `(${o})` : `-${o}` : o;
|
|
171
80
|
}
|
|
172
|
-
function
|
|
81
|
+
function te(e, t = {}) {
|
|
173
82
|
if (e == null)
|
|
174
83
|
return "";
|
|
175
84
|
const n = typeof e == "number" ? e : typeof e == "string" && e.trim() ? Number(e) : NaN;
|
|
176
85
|
if (!Number.isFinite(n))
|
|
177
86
|
return "";
|
|
178
|
-
const o = t.inputUnit || "second", r = t.outputStyle === "digital" || t.outputStyle === "long" ? t.outputStyle : "compact", s = n < 0, i = Math.abs(
|
|
179
|
-
return
|
|
87
|
+
const o = t.inputUnit || "second", r = t.outputStyle === "digital" || t.outputStyle === "long" ? t.outputStyle : "compact", s = n < 0, i = Math.abs(W(n, o)), a = q(i, t), l = r === "digital" ? z(a) : r === "long" ? Q(a, t.maxUnits) : J(a, t.maxUnits);
|
|
88
|
+
return ee(l, s, t);
|
|
180
89
|
}
|
|
181
|
-
function
|
|
90
|
+
function ne(e, t, n) {
|
|
182
91
|
const o = {
|
|
183
92
|
...t,
|
|
184
93
|
locale: t.locale ?? n
|
|
@@ -192,12 +101,12 @@ function ge(e, t, n) {
|
|
|
192
101
|
})}${s ?? ""}`;
|
|
193
102
|
}
|
|
194
103
|
function x(e, t, n) {
|
|
195
|
-
return e === null ? { value: e, text: null } : !t || !
|
|
104
|
+
return e === null ? { value: e, text: null } : !t || !U(t) && t.type !== "duration" ? {
|
|
196
105
|
value: e,
|
|
197
106
|
text: y(e, { type: "number", locale: n })
|
|
198
107
|
} : t.type === "duration" ? {
|
|
199
108
|
value: e,
|
|
200
|
-
text:
|
|
109
|
+
text: te(e, {
|
|
201
110
|
inputUnit: t.inputUnit,
|
|
202
111
|
outputStyle: t.outputStyle,
|
|
203
112
|
largestUnit: t.largestUnit,
|
|
@@ -207,7 +116,7 @@ function x(e, t, n) {
|
|
|
207
116
|
suffix: t.suffix,
|
|
208
117
|
negativeInParentheses: t.negativeStyle === "parentheses"
|
|
209
118
|
})
|
|
210
|
-
} : { value: e, text:
|
|
119
|
+
} : { value: e, text: ne(e, t, n) };
|
|
211
120
|
}
|
|
212
121
|
function _(e, t, n, o) {
|
|
213
122
|
return e === null ? { value: e, text: null } : o === "percent" ? {
|
|
@@ -266,6 +175,97 @@ function _e(e, t) {
|
|
|
266
175
|
"ratio"
|
|
267
176
|
)), n;
|
|
268
177
|
}
|
|
178
|
+
function w(e, t) {
|
|
179
|
+
const n = f(e), o = f(t), r = n.getTime() - o.getTime();
|
|
180
|
+
return r < 0 ? -1 : r > 0 ? 1 : r;
|
|
181
|
+
}
|
|
182
|
+
function re(e) {
|
|
183
|
+
return O(e, Date.now());
|
|
184
|
+
}
|
|
185
|
+
function oe(e, t) {
|
|
186
|
+
const n = f(e), o = f(t), r = n.getFullYear() - o.getFullYear(), s = n.getMonth() - o.getMonth();
|
|
187
|
+
return r * 12 + s;
|
|
188
|
+
}
|
|
189
|
+
function se(e) {
|
|
190
|
+
return (t) => {
|
|
191
|
+
const o = (e ? Math[e] : Math.trunc)(t);
|
|
192
|
+
return o === 0 ? 0 : o;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function ae(e, t) {
|
|
196
|
+
return +f(e) - +f(t);
|
|
197
|
+
}
|
|
198
|
+
function ie(e) {
|
|
199
|
+
const t = f(e);
|
|
200
|
+
return t.setHours(23, 59, 59, 999), t;
|
|
201
|
+
}
|
|
202
|
+
function le(e) {
|
|
203
|
+
const t = f(e), n = t.getMonth();
|
|
204
|
+
return t.setFullYear(t.getFullYear(), n + 1, 0), t.setHours(23, 59, 59, 999), t;
|
|
205
|
+
}
|
|
206
|
+
function ce(e) {
|
|
207
|
+
const t = f(e);
|
|
208
|
+
return +ie(t) == +le(t);
|
|
209
|
+
}
|
|
210
|
+
function ue(e, t) {
|
|
211
|
+
const n = f(e), o = f(t), r = w(n, o), s = Math.abs(
|
|
212
|
+
oe(n, o)
|
|
213
|
+
);
|
|
214
|
+
let i;
|
|
215
|
+
if (s < 1)
|
|
216
|
+
i = 0;
|
|
217
|
+
else {
|
|
218
|
+
n.getMonth() === 1 && n.getDate() > 27 && n.setDate(30), n.setMonth(n.getMonth() - r * s);
|
|
219
|
+
let a = w(n, o) === -r;
|
|
220
|
+
ce(f(e)) && s === 1 && w(e, o) === 1 && (a = !1), i = r * (s - Number(a));
|
|
221
|
+
}
|
|
222
|
+
return i === 0 ? 0 : i;
|
|
223
|
+
}
|
|
224
|
+
function fe(e, t, n) {
|
|
225
|
+
const o = ae(e, t) / 1e3;
|
|
226
|
+
return se(n == null ? void 0 : n.roundingMethod)(o);
|
|
227
|
+
}
|
|
228
|
+
function me(e, t, n) {
|
|
229
|
+
const o = P(), r = (n == null ? void 0 : n.locale) ?? o.locale ?? k, s = 2520, i = w(e, t);
|
|
230
|
+
if (isNaN(i))
|
|
231
|
+
throw new RangeError("Invalid time value");
|
|
232
|
+
const a = Object.assign({}, n, {
|
|
233
|
+
addSuffix: n == null ? void 0 : n.addSuffix,
|
|
234
|
+
comparison: i
|
|
235
|
+
});
|
|
236
|
+
let l, c;
|
|
237
|
+
i > 0 ? (l = f(t), c = f(e)) : (l = f(e), c = f(t));
|
|
238
|
+
const g = fe(c, l), m = (T(c) - T(l)) / 1e3, u = Math.round((g - m) / 60);
|
|
239
|
+
let h;
|
|
240
|
+
if (u < 2)
|
|
241
|
+
return n != null && n.includeSeconds ? g < 5 ? r.formatDistance("lessThanXSeconds", 5, a) : g < 10 ? r.formatDistance("lessThanXSeconds", 10, a) : g < 20 ? r.formatDistance("lessThanXSeconds", 20, a) : g < 40 ? r.formatDistance("halfAMinute", 0, a) : g < 60 ? r.formatDistance("lessThanXMinutes", 1, a) : r.formatDistance("xMinutes", 1, a) : u === 0 ? r.formatDistance("lessThanXMinutes", 1, a) : r.formatDistance("xMinutes", u, a);
|
|
242
|
+
if (u < 45)
|
|
243
|
+
return r.formatDistance("xMinutes", u, a);
|
|
244
|
+
if (u < 90)
|
|
245
|
+
return r.formatDistance("aboutXHours", 1, a);
|
|
246
|
+
if (u < S) {
|
|
247
|
+
const d = Math.round(u / 60);
|
|
248
|
+
return r.formatDistance("aboutXHours", d, a);
|
|
249
|
+
} else {
|
|
250
|
+
if (u < s)
|
|
251
|
+
return r.formatDistance("xDays", 1, a);
|
|
252
|
+
if (u < M) {
|
|
253
|
+
const d = Math.round(u / S);
|
|
254
|
+
return r.formatDistance("xDays", d, a);
|
|
255
|
+
} else if (u < M * 2)
|
|
256
|
+
return h = Math.round(u / M), r.formatDistance("aboutXMonths", h, a);
|
|
257
|
+
}
|
|
258
|
+
if (h = ue(c, l), h < 12) {
|
|
259
|
+
const d = Math.round(u / M);
|
|
260
|
+
return r.formatDistance("xMonths", d, a);
|
|
261
|
+
} else {
|
|
262
|
+
const d = h % 12, D = Math.trunc(h / 12);
|
|
263
|
+
return d < 3 ? r.formatDistance("aboutXYears", D, a) : d < 9 ? r.formatDistance("overXYears", D, a) : r.formatDistance("almostXYears", D + 1, a);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function ge(e, t) {
|
|
267
|
+
return me(e, re(e), t);
|
|
268
|
+
}
|
|
269
269
|
function Ce(e, t) {
|
|
270
270
|
return e && e !== "auto" ? e : t;
|
|
271
271
|
}
|
|
@@ -324,7 +324,7 @@ const de = "MM/dd/yyyy", Ne = (e, t, n, o = "auto") => {
|
|
|
324
324
|
return "";
|
|
325
325
|
try {
|
|
326
326
|
const n = N(e, t);
|
|
327
|
-
return isNaN(n.getTime()) ? e :
|
|
327
|
+
return isNaN(n.getTime()) ? e : ge(n, { addSuffix: !0 });
|
|
328
328
|
} catch (n) {
|
|
329
329
|
return console.error("Relative time formatting error:", n), e;
|
|
330
330
|
}
|
|
@@ -556,7 +556,7 @@ export {
|
|
|
556
556
|
Le as P,
|
|
557
557
|
Ne as a,
|
|
558
558
|
ye as b,
|
|
559
|
-
|
|
559
|
+
te as c,
|
|
560
560
|
_e as d,
|
|
561
561
|
he as e,
|
|
562
562
|
$e as f,
|
|
@@ -576,5 +576,5 @@ export {
|
|
|
576
576
|
Pe as t,
|
|
577
577
|
ke as u,
|
|
578
578
|
Ze as v,
|
|
579
|
-
|
|
579
|
+
ge as w
|
|
580
580
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var y = Object.defineProperty;
|
|
2
2
|
var c = (t, e, r) => e in t ? y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
3
|
var u = (t, e, r) => c(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { v as d } from "./temporal-bucket-contract-
|
|
4
|
+
import { v as d } from "./temporal-bucket-contract-BeOx0uYe.js";
|
|
5
5
|
function f(t) {
|
|
6
6
|
return !!(t != null && t.isSubtotal && t.subtotalScope === "pivot-value");
|
|
7
7
|
}
|
package/dist/chunks/{pivot-result-identity-DRUlTWUq.cjs → pivot-result-identity-BVnhG2rR.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var m=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const f=require("./temporal-bucket-contract-
|
|
1
|
+
"use strict";var v=Object.defineProperty;var m=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const f=require("./temporal-bucket-contract-Cp-usD9Z.cjs");function y(t){return!!(t!=null&&t.isSubtotal&&t.subtotalScope==="pivot-value")}function c(t){var e;return t.expectedPivotFieldIds.length===0?!0:!!((e=t.classification)!=null&&e.isSubtotal&&t.classification.subtotalScope==="grand-total")}class u extends Error{constructor(r){super(`missing_pivot_member_identity: ${r}`);n(this,"deliveryBlocking",!0);n(this,"code","missing_pivot_member_identity");this.name="PivotResultIdentityError"}}function d(t){const{identity:e,columnKey:r,expectedPivotFieldIds:i,allowPrefix:l=!1}=t,s=t.allowEmpty??((i==null?void 0:i.length)||0)===0;if(!e||typeof e!="object"||Array.isArray(e)||typeof e.metricId!="string"||!e.metricId||typeof e.metricAlias!="string"||!e.metricAlias||!Array.isArray(e.members))throw new u(`Physical pivot column "${r}" is missing stable metric or member identity.`);if(e.members.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o)||typeof o.fieldId!="string"||!o.fieldId||o.value!==null&&typeof o.value!="string"||o.temporalBucket!==void 0&&!f.validateTemporalBucketMetadata(o.temporalBucket).ok)throw new u(`Physical pivot column "${r}" has invalid identity for member ${a}.`);if(i&&o.fieldId!==i[a])throw new u(`Physical pivot column "${r}" has member "${o.fieldId}" at tuple position ${a}; expected "${i[a]||"no member"}".`)}),e.members.length===0){if(s)return e.members;throw new u(`Physical pivot column "${r}" is missing its required pivot tuple.`)}if(i&&(!l&&e.members.length!==i.length||e.members.length>i.length))throw new u(`Physical pivot column "${r}" has ${e.members.length} members; expected ${l?"at most ":""}${i.length}.`);return e.members}function p(t,e){t.forEach(r=>{var l,s,o;if(r.pivotIdentity===void 0)return;const i=(l=e.columnClassifications)==null?void 0:l[r.key];d({identity:r.pivotIdentity,columnKey:r.key,expectedPivotFieldIds:e.expectedPivotFieldIds,allowPrefix:((s=e.allowPrefixForColumn)==null?void 0:s.call(e,r))??y(i),allowEmpty:((o=e.allowEmptyForColumn)==null?void 0:o.call(e,r))??c({expectedPivotFieldIds:e.expectedPivotFieldIds,classification:i})})})}function h(t,e,r){var l;const i=t==null?void 0:t.byRole;if(!(!i||typeof i!="object"||Array.isArray(i)))return(l=i[r])==null?void 0:l[e]}function P(t,e){if(!t)return;const r=t.byRole;if(!r||typeof r!="object"||Array.isArray(r))return;const i=Object.values(r).flatMap(s=>{const o=s==null?void 0:s[e];return o?[o]:[]});if(i.length!==1)return;const[l]=i;if(!(l.role==="metric"&&Object.values(t.byMetricAlias??{}).some(s=>s.role===l.role&&s.rawKey===l.rawKey&&s.outputKey===l.outputKey)))return l}exports.PivotResultIdentityError=u;exports.isPivotEmptyTupleAllowed=c;exports.isPivotSubtotalPrefix=y;exports.requirePivotHeaderMembers=d;exports.requirePivotResultColumnIdentities=p;exports.resolveQueryColumnKeyMapEntry=h;exports.resolveUniqueQueryColumnKeyMapEntry=P;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var ue=Object.defineProperty;var de=(e,t,r)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var g=(e,t,r)=>de(e,typeof t!="symbol"?t+"":t,r);const w=require("./validators-DqIM0B3C.cjs"),fe=require("./raw-temporal-contract-vnNwLy9R.cjs"),x=require("../value-format-preferences/index.cjs"),h=require("./metric-comparison-x0lipytf.cjs"),ye=require("./index-F25jnH0p.cjs"),he=require("./report-runtime-context-BfW4qiMJ.cjs");require("./analyze-result-contract-BX_nQmPN.cjs");const ge=require("./temporal-bucket-contract-Cp-usD9Z.cjs"),j=require("./pivot-result-identity-BVnhG2rR.cjs");function O(e){if(!e)return!1;const t=e.toLowerCase().replace("_","-");return t==="en-in"||t.startsWith("en-in-")}function q(e,t){const r=Math.abs(e);return r>=1e12?{divisor:1e12,suffix:"T"}:r>=1e9?{divisor:1e9,suffix:"B"}:O(t)&&r>=1e7?{divisor:1e7,suffix:"Cr"}:r>=1e6?{divisor:1e6,suffix:"M"}:O(t)&&r>=1e5?{divisor:1e5,suffix:"L"}:r>=1e3?{divisor:1e3,suffix:"K"}:{divisor:1,suffix:""}}function D(e,t){try{const r=b(t);return q(e,r)}catch{return q(e,"en-US")}}function ve(e){try{return new Intl.NumberFormat(e),!0}catch{return!1}}function b(e){return e&&ve(e)?e:"en-US"}function F(e,t){if(e==null||isNaN(e))return"";const r=b(t==null?void 0:t.locale);let a=e;if(t!=null&&t.multiplyBy&&(a*=t.multiplyBy),t!=null&&t.useSuffix){const{divisor:i,suffix:o}=D(a,r);a=a/i;const s=new Intl.NumberFormat(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}).format(a);return`${(t==null?void 0:t.prefix)??""}${s}${o}${(t==null?void 0:t.suffix)??""}`}const n=new Intl.NumberFormat(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}).format(a);if(t!=null&&t.negativeInParentheses&&a<0){const i=n.replace("-","");return`(${(t==null?void 0:t.prefix)??""}${i}${(t==null?void 0:t.suffix)??""})`}return`${(t==null?void 0:t.prefix)??""}${n}${(t==null?void 0:t.suffix)??""}`}function M(e,t){if(e==null||isNaN(e))return"";const r=b(t==null?void 0:t.locale),a=(t==null?void 0:t.currency)||"USD",n=e<0,i=!!(t!=null&&t.negativeInParentheses&&n),o=i?Math.abs(e):e;try{if(t!=null&&t.useSuffix){const{divisor:l,suffix:m}=D(o,r),c=o/l,f=`${new Intl.NumberFormat(r,{style:"currency",currency:a,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}).format(c)}${m}`;return i?`(${f})`:f}const s=new Intl.NumberFormat(r,{style:"currency",currency:a,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}).format(o);return i?`(${s})`:s}catch{const s=Math.abs(e),l=t!=null&&t.useSuffix?D(s,r):{divisor:1,suffix:""},m=F(s/l.divisor,{locale: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}),c=`${a} ${m}${l.suffix}`;return n?t!=null&&t.negativeInParentheses?`(${c})`:`-${c}`:c}}function P(e,t){if(e==null||isNaN(e))return"";const r=b(t==null?void 0:t.locale),n=(t==null?void 0:t.alreadyPercent)??(t==null?void 0:t.percentValueMode)==="whole"?e/100:e;return new Intl.NumberFormat(r,{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}).format(n)}function N(e,t){if(e==null||isNaN(e))return"";const r=b(t==null?void 0:t.locale);return new Intl.NumberFormat(r,{notation:"scientific",minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2}).format(e)}function U(e,t){if(e==null||Number.isNaN(e))return"";const r=t.scale===void 0?e:e*t.scale,a=t.negativeStyle==="parentheses"&&r<0,n=a?Math.abs(r):r,i={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 o;switch(t.type){case"currency":o=M(n,i);break;case"percent":o=P(n,i);break;case"scientific":o=N(n,i);break;default:o=F(n,i);break}const s=`${t.prefix??""}${o}${t.suffix??""}`;return a?`(${s})`:s}function we(e,t,r="en-US"){if(e==null||isNaN(e))return"";const a=b((t==null?void 0:t.locale)||r),n=(t==null?void 0:t.style)||"decimal",i=n==="decimal"?"number":n;return i==="currency"&&new Intl.NumberFormat(a,{style:"currency",currency:(t==null?void 0:t.currency)||"USD"}),U(e,{type:i,locale:a,currency:i==="currency"?(t==null?void 0:t.currency)||"USD":void 0,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0,percentValueMode:i==="percent"?(t==null?void 0:t.percentValueMode)??"whole":void 0,scale:t==null?void 0:t.scale,compact:t==null?void 0:t.compact,negativeStyle:t==null?void 0:t.negativeStyle,prefix:t==null?void 0:t.prefix,suffix:t==null?void 0:t.suffix})}function pe(e,t,r){const a={style:t==="currency"?"currency":t==="percent"?"percent":"decimal",locale:r==null?void 0:r.locale,currency:r==null?void 0:r.currency,minimumFractionDigits:r==null?void 0:r.decimalPlaces,maximumFractionDigits:r==null?void 0:r.decimalPlaces,useSuffix:r==null?void 0:r.useSuffix,prefix:r==null?void 0:r.prefix,suffix:r==null?void 0:r.suffix,negativeInParentheses:r==null?void 0:r.negativeInParentheses,multiplyBy:r==null?void 0:r.multiplyBy};switch(t){case"currency":return M(e,a);case"percent":return P(e,a);case"scientific":return N(e,a);default:return F(e,a)}}const xe=["type","locale","minimumFractionDigits","maximumFractionDigits","useGrouping","prefix","suffix","negativeStyle","compact","scale","currency","percentValueMode"];function J(e){if(!h.isPlainJsonRecord(e))return{ok:!1,issues:[{path:"$",message:"Numeric format must be an object."}]};const t=[],r=new Set(xe);Object.keys(e).filter(i=>!r.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 a=e.locale===void 0?void 0:x.canonicalizeSupportedLocale(e.locale);e.locale!==void 0&&!a&&t.push({path:"locale",message:"Expected a supported BCP 47 locale."});const n=e.currency===void 0?void 0:x.canonicalizeSupportedCurrencyCode(e.currency);e.currency!==void 0&&!n&&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."}),t.length>0?{ok:!1,issues:t}:{ok:!0,value:{type:e.type,...a?{locale:a}:{},...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}:{},...n?{currency:n}:{},...e.percentValueMode!==void 0?{percentValueMode:e.percentValueMode}:{}}}}function H(e){const t=J(e);if(!t.ok)return t;const r=[];return t.value.locale||r.push({path:"locale",message:"Resolved numeric formats require an explicit locale."}),t.value.minimumFractionDigits===void 0&&r.push({path:"minimumFractionDigits",message:"Resolved numeric formats require minimumFractionDigits."}),t.value.maximumFractionDigits===void 0&&r.push({path:"maximumFractionDigits",message:"Resolved numeric formats require maximumFractionDigits."}),t.value.type==="currency"&&!t.value.currency&&r.push({path:"currency",message:"Resolved currency formats require an explicit currency."}),r.length>0?{ok:!1,issues:r}:t}function Se(e){var a;const t=new Set;if(e.snapshot.resolvedFormats.forEach((n,i)=>{if(n.format.type!=="temporal_bucket"){if(n.scope.attachmentIndex!==void 0)throw new Error(`resolvedFormats.${i}.scope.attachmentIndex is not valid for a card export`);if(n.scope.dashboardId!==e.expectedScope.dashboardId||n.scope.cardId!==e.expectedScope.cardId)throw new Error(`resolvedFormats.${i}.scope must match the executing dashboard/card`);if(n.target.kind!=="column")throw new Error(`resolvedFormats.${i}.target must identify an export column`);if(t.has(n.target.columnKey))throw new Error(`resolvedFormats.${i} duplicates export column "${n.target.columnKey}"`);t.add(n.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(n=>!t.has(n));if(r)throw new Error(`resolvedFormats is missing visible export column "${r}"`)}function Y(e,t){const r=new Intl.NumberFormat(e,{style:"currency",currency:t}).resolvedOptions();return{minimumFractionDigits:r.minimumFractionDigits,maximumFractionDigits:r.maximumFractionDigits}}function be(e){if(e.minimumFractionDigits!==void 0||e.maximumFractionDigits!==void 0){const r=e.minimumFractionDigits??0;return{minimumFractionDigits:r,maximumFractionDigits:e.maximumFractionDigits??Math.max(r,2)}}const t=e.type==="percent"?1:e.type==="scientific"?2:0;return{minimumFractionDigits:t,maximumFractionDigits:t}}function Te(e,t,r){const a=x.canonicalizeSupportedLocale(e.locale)??t.locale,n=e.type==="number"||e.type==="currency"?x.canonicalizeSupportedCurrencyCode(r):void 0;if(!(e.type==="currency"||n!==void 0))return{...e,locale:a,...be(e)};const o=n??x.canonicalizeSupportedCurrencyCode(e.currency)??t.defaultCurrency,s=Y(a,o),l=s.minimumFractionDigits??0,m=s.maximumFractionDigits??l,c=e.minimumFractionDigits??Math.min(l,e.maximumFractionDigits??l),y=e.maximumFractionDigits??Math.max(c,m);return{...e,type:"currency",locale:a,currency:o,minimumFractionDigits:c,maximumFractionDigits:y}}class p extends Error{constructor(r,a){super(a);g(this,"code");this.name="RawTemporalFormatContractError",this.code=r}}const ke=["SSSSSSSSS","SSSSSSSS","SSSSSSS","SSSSSS","SSSSS","SSSS","SSS","SS","S"],X=/^(\d{4})-(\d{2})-(\d{2})$/,W=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?$/,Q=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:\d{2})$/,_e=["yyyy","MMMM","LLLL","zzz","XXX","MMM","LLL","yy","MM","dd","HH","hh","mm","ss","M","d","H","h","m","s","a"],Re=new Set(["HH","H","hh","h","mm","m","ss","s","a",...ke]),Ce=new Set(["zzz","XXX"]),E=new Set(["short","medium","long"]);function v(e,t){return Object.keys(e).length===t.length&&t.every(a=>a in e)}function d(e){throw new p("invalid_raw_temporal_format",e)}function ee(e){if(!e||e.trim()!==e||e.length>256)return d("date_fns patterns must be non-empty, trimmed, and at most 256 characters.");const t=[],r=n=>{const i=t[t.length-1];(i==null?void 0:i.kind)==="literal"?i.value+=n:t.push({kind:"literal",value:n})};let a=0;for(;a<e.length;){if(e[a]==="'"){if(e[a+1]==="'"){r("'"),a+=2;continue}let o="",s=!1;for(a+=1;a<e.length;){if(e[a]==="'"){if(e[a+1]==="'"){o+="'",a+=2;continue}s=!0,a+=1;break}o+=e[a],a+=1}if(!s)return d("date_fns pattern has an unclosed quote.");r(o);continue}if(e[a]==="S"){let o=a+1;for(;e[o]==="S";)o+=1;const s=e.slice(a,o);if(s.length>9)return d("date_fns fractional-second tokens support at most nine digits.");t.push({kind:"token",value:s}),a=o;continue}const n=_e.find(o=>e.startsWith(o,a));if(n){t.push({kind:"token",value:n}),a+=n.length;continue}const i=e[a];if(/[A-Za-z]/.test(i))return d(`Unsupported date_fns pattern token beginning at "${e.slice(a)}".`);r(i),a+=1}return t.some(n=>n.kind==="token")?t:d("date_fns patterns must contain at least one token.")}function te(e,t){if(e==="semaphor_tokens"){const r=w.tokenizeTemporalBucketPattern(t);r.ok||d(r.message);return}ee(t)}function Fe(e){return!h.isPlainJsonRecord(e)||!v(e,["dateStyle","dateTime"])?d("Automatic raw temporal styles are incomplete."):E.has(e.dateStyle)?!h.isPlainJsonRecord(e.dateTime)||!v(e.dateTime,["dateStyle","timeStyle"])||!E.has(e.dateTime.dateStyle)||!E.has(e.dateTime.timeStyle)?d("Automatic dateTime styles are incomplete or invalid."):{dateStyle:e.dateStyle,dateTime:{dateStyle:e.dateTime.dateStyle,timeStyle:e.dateTime.timeStyle}}:d("Automatic dateStyle is invalid.")}function I(e){const t=["type","locale","calendarTimezone","presentation"],r=[...t,"sourceTimezone"];if(!h.isPlainJsonRecord(e)||!v(e,t)&&!v(e,r)||e.type!=="raw_temporal")return d("Resolved raw temporal format has an invalid shape.");const a=x.canonicalizeSupportedLocale(e.locale);return a?typeof e.calendarTimezone!="string"||!w.isValidIanaTimeZone(e.calendarTimezone)?d("Raw temporal calendarTimezone must be a valid IANA timezone."):e.sourceTimezone!==void 0&&(typeof e.sourceTimezone!="string"||!w.isValidIanaTimeZone(e.sourceTimezone))?d("Raw temporal sourceTimezone must be a valid IANA timezone."):h.isPlainJsonRecord(e.presentation)?e.presentation.mode==="auto"?v(e.presentation,["mode","styles"])?{type:"raw_temporal",locale:a,calendarTimezone:e.calendarTimezone,...e.sourceTimezone?{sourceTimezone:e.sourceTimezone}:{},presentation:{mode:"auto",styles:Fe(e.presentation.styles)}}:d("Automatic raw temporal presentation has unknown fields."):e.presentation.mode!=="pattern"||!v(e.presentation,["mode","dialect","pattern"])||e.presentation.dialect!=="semaphor_tokens"&&e.presentation.dialect!=="date_fns"||typeof e.presentation.pattern!="string"?d("Pattern raw temporal presentation has an invalid shape."):(te(e.presentation.dialect,e.presentation.pattern),{type:"raw_temporal",locale:a,calendarTimezone:e.calendarTimezone,...e.sourceTimezone?{sourceTimezone:e.sourceTimezone}:{},presentation:{mode:"pattern",dialect:e.presentation.dialect,pattern:e.presentation.pattern}}):d("Raw temporal presentation must be an object."):d("Raw temporal locale is invalid or unsupported.")}function Ie(e){var s,l,m;if(e.format){if(!h.isPlainJsonRecord(e.format))return d("Authored raw temporal format has an invalid shape.");const c=Object.keys(e.format);if(!c.includes("type")||!c.includes("presentation")||c.some(f=>f!=="type"&&f!=="presentation"&&f!=="timezone"&&f!=="sourceTimezone")||e.format.type!=="raw_temporal"||!h.isPlainJsonRecord(e.format.presentation))return d("Authored raw temporal format has an invalid shape.");const y=e.format.presentation;if(y.mode==="auto"){if(!v(y,["mode"]))return d("Automatic authored raw temporal format has unknown fields.")}else{if(y.mode!=="pattern"||!v(y,["mode","dialect","pattern"])||y.dialect!=="semaphor_tokens"&&y.dialect!=="date_fns"||typeof y.pattern!="string")return d("Authored raw temporal pattern has an invalid shape.");te(y.dialect,y.pattern)}}const t=(s=e.format)==null?void 0:s.timezone,r=(l=e.format)==null?void 0:l.sourceTimezone,a=t&&t!=="auto"?t:e.calendar.tz,n=r&&r!=="auto"?r==="local"?Intl.DateTimeFormat().resolvedOptions().timeZone:r:void 0;if(t!==void 0&&t!=="auto"&&!w.isValidIanaTimeZone(a)||n!==void 0&&!w.isValidIanaTimeZone(n))return d("Authored raw temporal timezone is invalid.");const i=((m=e.format)==null?void 0:m.presentation)??{mode:"auto"},o={type:"raw_temporal",locale:e.preferences.locale,calendarTimezone:a,...n?{sourceTimezone:n}:{},presentation:i.mode==="pattern"?{...i}:{mode:"auto",styles:{dateStyle:e.preferences.dateStyle,dateTime:{...e.preferences.dateTime}}}};return I(o)}function Ee(e){if(X.test(e))return"date";if(Q.test(e))return"instant";if(W.test(e))return"wall_datetime"}function De(e){const t=new Set;let r=!1;for(const a of e.values){if(a===null)continue;r=!0;const n=Ee(a);n&&t.add(n)}if(!r)return{status:"empty"};if(t.size===0)return{status:"invalid_only"};if(t.size>1)throw new p("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 $e(e){return{version:1,columns:Object.fromEntries([...e].map(([t,r])=>[t,r.status==="classified"?r.metadata.valueKind:r.status]))}}function re(e){if(!h.isPlainJsonRecord(e)||e.version!==1||!h.isPlainJsonRecord(e.columns)||Object.keys(e).some(a=>a!=="version"&&a!=="columns"))throw new p("invalid_raw_temporal_format","Raw temporal chunk classification evidence is malformed.");const t={},r=new Set(["empty","invalid_only","date","wall_datetime","instant"]);for(const[a,n]of Object.entries(e.columns)){if(!a.trim()||!r.has(n))throw new p("invalid_raw_temporal_format","Raw temporal chunk classification evidence contains an invalid column or status.");t[a]=n}return{version:1,columns:t}}function Ae(e){if(e.length===0)return;const t=e.map(re),r=Object.keys(t[0].columns).sort();for(let a=1;a<t.length;a+=1){const n=Object.keys(t[a].columns).sort();if(n.length!==r.length||n.some((i,o)=>i!==r[o]))throw new p("invalid_raw_temporal_format","Raw temporal chunk classification evidence has inconsistent columns.")}for(const a of r)if(new Set(t.map(i=>i.columns[a]).filter(i=>i!=="empty"&&i!=="invalid_only")).size>1)throw new p("mixed_sql_temporal_semantics",`Declared SQL temporal column "${a}" has inconsistent semantics across export chunks. Normalize it to one kind.`)}function Me(e){return e%4===0&&(e%100!==0||e%400===0)}function Pe(e,t){return t===2?Me(e)?29:28:[4,6,9,11].includes(t)?30:31}function Ne(e){return e.year>=1&&e.year<=9999&&e.month>=1&&e.month<=12&&e.day>=1&&e.day<=Pe(e.year,e.month)&&e.hour>=0&&e.hour<=23&&e.minute>=0&&e.minute<=59&&e.second>=0&&e.second<=59}function Ke(e){return{year:Number(e[1]),month:Number(e[2]),day:Number(e[3]),hour:Number(e[4]??0),minute:Number(e[5]??0),second:Number(e[6]??0),fraction:e[7]??""}}function ze(e,t){const r=t==="date"?e.match(X):t==="wall_datetime"?e.match(W):e.match(Q);if(!r)return{status:"invalid_shape"};const a=Ke(r);if(!Ne(a))return{status:"out_of_range"};if(t==="instant"){const n=r[8];if(n&&n!=="Z"){const[o,s]=n.slice(1).split(":").map(Number);if(o>23||s>59)return{status:"out_of_range"}}const i=new Date(e.replace(" ","T"));return Number.isNaN(i.getTime())?{status:"out_of_range"}:{status:"valid",fields:a,instant:i}}return{status:"valid",fields:a}}function $(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 ae(e,t){const r=e.fraction?`.${e.fraction.padEnd(3,"0").slice(0,3)}`:"";return ye.fromZonedTime(`${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")}${r}`,t)}function je(e,t){const r=new Map,a=new Map;let n,i,o,s;return{number(l,m=1){let c=r.get(m);return c||(c=new Intl.NumberFormat(e,{useGrouping:!1,minimumIntegerDigits:m,maximumFractionDigits:0}),r.set(m,c)),c.format(l)},month(l,m,c){var k;const y=`${m}:${c?"standalone":"contextual"}`;let f=a.get(y);if(!f){const _={calendar:"gregory",timeZone:"UTC",month:m};c||(_.day="numeric"),f=new Intl.DateTimeFormat(e,_),a.set(y,f)}return((k=f.formatToParts(l).find(_=>_.type==="month"))==null?void 0:k.value)??""},dayPeriod(l){var m;return n??(n=new Intl.DateTimeFormat(e,{calendar:"gregory",timeZone:"UTC",hour:"numeric",hour12:!0})),((m=n.formatToParts(l).find(c=>c.type==="dayPeriod"))==null?void 0:m.value)??""},instantFields(l){i??(i=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 m=i.formatToParts(l),c=y=>{var f;return Number((f=m.find(k=>k.type===y))==null?void 0:f.value)};return{year:c("year"),month:c("month"),day:c("day"),hour:c("hour"),minute:c("minute"),second:c("second"),fraction:""}},timezoneName(l){var m;return o??(o=new Intl.DateTimeFormat(e,{calendar:"gregory",timeZone:t,timeZoneName:"short"})),((m=o.formatToParts(l).find(c=>c.type==="timeZoneName"))==null?void 0:m.value)??""},timezoneOffset(l){var y;s??(s=new Intl.DateTimeFormat("en-US",{calendar:"gregory",timeZone:t,timeZoneName:"longOffset"}));const m=(y=s.formatToParts(l).find(f=>f.type==="timeZoneName"))==null?void 0:y.value;if(!m)return d("Unable to resolve the instant timezone offset.");const c=m.replace(/^GMT/,"");return c===""||/^[+-]00:00$/.test(c)?"Z":c}}}function Oe(e,t,r,a,n){if(/^S{1,9}$/.test(e)){const i=t.fraction.padEnd(e.length,"0").slice(0,e.length);return a.number(Number(i),e.length)}switch(e){case"YYYY":case"yyyy":return a.number(t.year,4);case"YY":case"yy":return a.number(t.year%100,2);case"MMMM":return a.month(r,"long",!1);case"LLLL":return a.month(r,"long",!0);case"MMM":return a.month(r,"short",!1);case"LLL":return a.month(r,"short",!0);case"MM":return a.number(t.month,2);case"M":return a.number(t.month);case"DD":case"dd":return a.number(t.day,2);case"d":return a.number(t.day);case"HH":return a.number(t.hour,2);case"H":return a.number(t.hour);case"hh":return a.number(t.hour%12||12,2);case"h":return a.number(t.hour%12||12);case"mm":return a.number(t.minute,2);case"m":return a.number(t.minute);case"ss":return a.number(t.second,2);case"s":return a.number(t.second);case"a":return a.dayPeriod(r);case"zzz":return n?a.timezoneName(n):d("Timezone pattern tokens require an instant value.");case"XXX":return n?a.timezoneOffset(n):d("Timezone pattern tokens require an instant value.");default:return d(`Unsupported raw temporal pattern token "${e}".`)}}function qe(e,t,r,a){const n=$(t);return e.map(i=>i.kind==="literal"?i.value:Oe(i.value,t,n,r,a)).join("")}function ne(e,t,r){const a=t==="date_fns"?ee(r):(()=>{const i=w.tokenizeTemporalBucketPattern(r);return i.ok?i.segments:d(i.message)})(),n=a.filter(i=>i.kind==="token").map(i=>i.value);return e==="date"&&n.some(i=>Re.has(i))?d("Date patterns cannot contain time tokens."):e!=="instant"&&n.some(i=>Ce.has(i))?d("Timezone pattern tokens require an instant value."):a}function Le(e){ne(e.valueKind??"instant",e.dialect,e.pattern)}function Ve(e,t,r,a){const n=ne(e.valueKind,r,a),i=je(t.locale,t.calendarTimezone);return o=>{const s=e.valueKind==="wall_datetime"&&t.sourceTimezone?ae(o.fields,t.sourceTimezone):void 0,l=e.valueKind==="instant"?{...i.instantFields(o.instant),fraction:o.fields.fraction}:s?{...i.instantFields(s),fraction:o.fields.fraction}:o.fields;return qe(n,l,i,o.instant??s)}}function Ge(e,t){const r=t.presentation.mode==="auto"?t.presentation.styles:d("Automatic raw temporal formatting requires styles.");if(e.valueKind==="date"){const o=new Intl.DateTimeFormat(t.locale,{calendar:"gregory",timeZone:"UTC",dateStyle:r.dateStyle});return s=>o.format($(s.fields))}const a=e.valueKind==="instant",n=!a&&r.dateTime.timeStyle==="long"?"medium":r.dateTime.timeStyle,i=new Intl.DateTimeFormat(t.locale,{calendar:"gregory",timeZone:a||e.valueKind==="wall_datetime"&&t.sourceTimezone?t.calendarTimezone:"UTC",dateStyle:r.dateTime.dateStyle,timeStyle:n});return o=>a?i.format(o.instant):e.valueKind==="wall_datetime"&&t.sourceTimezone?i.format(ae(o.fields,t.sourceTimezone)):i.format($(o.fields))}function L(e,t,r){return{ok:!1,text:e,diagnostic:{code:r,message:`Raw temporal ${t.valueKind} value is ${r==="invalid_raw_temporal_value"?"malformed":"out of range"}.`}}}function ie(e){const t=fe.parseRawTemporalValueMetadata(e.metadata),r=I(e.format),a=r.presentation.mode==="auto"?Ge(t,r):Ve(t,r,r.presentation.dialect,r.presentation.pattern);return n=>{if(n===null)return{ok:!0,text:"",status:"empty"};const i=ze(n,t.valueKind);return i.status==="invalid_shape"?L(n,t,"invalid_raw_temporal_value"):i.status==="out_of_range"?L(n,t,"out_of_range_raw_temporal_value"):{ok:!0,text:a(i),status:"formatted"}}}function Be(e){return ie({metadata:e.metadata,format:e.format})(e.value)}class A extends Error{constructor(r){super(`invalid_presentation_execution_snapshot: ${r} Resave this report before running it again.`);g(this,"code","invalid_presentation_execution_snapshot");g(this,"deliveryBlocking",!0);this.name="PresentationExecutionSnapshotError"}}class Ze extends Error{constructor(r){super(`missing_resolved_raw_temporal_format: Column "${r}" has no captured presentation. Resave this report before running it again.`);g(this,"code","missing_resolved_raw_temporal_format");g(this,"deliveryBlocking",!0);this.name="MissingResolvedRawTemporalFormatError"}}function T(e,t,r){const a=new Set(t),n=Object.keys(e).find(i=>!a.has(i));if(n)throw new Error(`${r} contains unknown property "${n}"`)}function oe(e,t="scope"){if(!h.isPlainJsonRecord(e))throw new Error(`${t} must be an object`);T(e,["dashboardId","cardId","attachmentIndex"],t);const r=typeof e.dashboardId=="string"?e.dashboardId.trim():"";if(!r)throw new Error(`${t}.dashboardId is required`);const a=typeof e.cardId=="string"?e.cardId.trim():void 0;if(e.cardId!==void 0&&!a)throw new Error(`${t}.cardId must be a non-empty string`);const n=e.attachmentIndex;if(n!==void 0&&(typeof n!="number"||!Number.isInteger(n)||n<0))throw new Error(`${t}.attachmentIndex must be a non-negative integer`);return{dashboardId:r,...a?{cardId:a}:{},...typeof n=="number"?{attachmentIndex:n}:{}}}function S(e,t,r,a){if(e.kind!==t)return;T(e,["kind",r],a);const n=typeof e[r]=="string"?e[r].trim():"";if(!n)throw new Error(`${a}.${r} is required`);return n}function Ue(e,t){if(!h.isPlainJsonRecord(e))throw new Error(`${t} must be an object`);const r=S(e,"metric","metricId",t);if(r)return{kind:"metric",metricId:r};const a=S(e,"column","columnKey",t);if(a)return{kind:"column",columnKey:a};const n=S(e,"matrix_measure","measureId",t);if(n)return{kind:"matrix_measure",measureId:n};throw new Error(`${t} is not a valid numeric presentation target`)}function Je(e,t){if(!h.isPlainJsonRecord(e))throw new Error(`${t} must be an object`);if(e.kind==="field"){T(e,["kind","fieldId","role"],t);const n=typeof e.fieldId=="string"?e.fieldId.trim():"";if(!n)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:n,...i?{role:i}:{}}}const r=S(e,"column","columnKey",t);if(r)return{kind:"column",columnKey:r};const a=S(e,"matrix_axis","axisInstanceId",t);if(a)return{kind:"matrix_axis",axisInstanceId:a};throw new Error(`${t} is not a valid temporal bucket presentation target`)}function He(e,t){if(!h.isPlainJsonRecord(e))throw new Error(`${t} must be an object`);const r=S(e,"column","columnKey",t);if(!r)throw new Error(`${t} must identify a column`);return{kind:"column",columnKey:r}}function Ye(e){return[e.dashboardId,e.cardId??null,e.attachmentIndex??null]}function C(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 K(e,t){return e.dashboardId===t.dashboardId&&e.cardId===t.cardId&&e.attachmentIndex===t.attachmentIndex}function z(e,t){const r=C(e),a=C(t);return r.length===a.length&&r.every((n,i)=>n===a[i])}function se(e){if(!Array.isArray(e))throw new Error("resolvedFormats must be an array");const t=new Set;return e.map((r,a)=>{var l,m;const n=`resolvedFormats.${a}`;if(!h.isPlainJsonRecord(r))throw new Error(`${n} must be an object`);T(r,["scope","target","format"],n);const i=oe(r.scope,`${n}.scope`);if(!h.isPlainJsonRecord(r.format))throw new Error(`${n}.format must be an object`);let o;switch(r.format.type){case"temporal_bucket":{const c=h.parseResolvedTemporalBucketFormat(r.format);if(!c.ok)throw new Error(`${n}.format is invalid: ${((l=c.issues[0])==null?void 0:l.message)??"invalid value"}`);o={scope:i,target:Je(r.target,`${n}.target`),format:c.value};break}case"raw_temporal":o={scope:i,target:He(r.target,`${n}.target`),format:I(r.format)};break;case"number":case"currency":case"percent":case"scientific":{const c=H(r.format);if(!c.ok)throw new Error(`${n}.format is invalid: ${((m=c.issues[0])==null?void 0:m.message)??"invalid value"}`);o={scope:i,target:Ue(r.target,`${n}.target`),format:c.value};break}default:throw new Error(`${n}.format.type is unsupported`)}const s=JSON.stringify([...Ye(o.scope),...C(o.target)]);if(t.has(s))throw new Error(`${n} duplicates a scoped presentation target`);return t.add(s),o})}function ce(e){try{if(!h.isPlainJsonRecord(e))throw new Error("presentation execution snapshot must be an object");if(T(e,["version","reportContext","resolvedFormats"],"presentation execution snapshot"),e.version!==1)throw new Error("presentation execution snapshot version must be 1");const t=he.parseReportRuntimeContext(e.reportContext);if(!t.ok){const r=t.issues[0];throw new Error(`presentation execution snapshot reportContext is invalid: ${r!=null&&r.path&&r.path!=="$"?`${r.path}: `:""}${(r==null?void 0:r.message)??"invalid value"}`)}return{version:1,reportContext:t.value,resolvedFormats:se(e.resolvedFormats)}}catch(t){throw t instanceof A?t:new A(t instanceof Error?t.message:"Snapshot is invalid.")}}function Xe(e){return ce({version:1,reportContext:e.reportContext,resolvedFormats:[...e.resolvedFormats]})}function We(e){const t=e.snapshot.resolvedFormats.find(r=>r.format.type!=="temporal_bucket"&&r.format.type!=="raw_temporal"&&K(r.scope,e.scope)&&z(r.target,e.target));return t==null?void 0:t.format}function Qe(e){const t=e.snapshot.resolvedFormats.find(r=>r.format.type==="raw_temporal"&&K(r.scope,e.scope)&&z(r.target,e.target));return t==null?void 0:t.format}function et(e){const t=e.snapshot.resolvedFormats.find(r=>r.format.type==="temporal_bucket"&&K(r.scope,e.scope)&&z(r.target,e.target));return t==null?void 0:t.format}function tt(e){var n;const t=new Set,r=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(C(i.target));if(r.has(s))throw new Error(`resolvedFormats.${o} duplicates export field "${i.target.fieldId}"`);r.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(!((n=e.visibleColumns)!=null&&n.length))throw new Error("visibleColumns must identify every formatted export column");const a=e.visibleColumns.find(i=>!t.has(i));if(a)throw new Error(`resolvedFormats is missing visible export column "${a}"`)}function R(e){return Array.from(new Set((e??[]).flatMap(t=>typeof t.id=="string"&&t.id?[t.id]:[])))}function le(e){const t=new Map;return e.forEach(r=>{r.id&&t.set(r.id,(t.get(r.id)??0)+1)}),e.flatMap(r=>r.id&&(t.get(r.id)??0)>1?[h.resolveMetricResultAlias(r)]:[])}function rt(e){const t=e.metricFields??[],r=R(t);return{expectedRoleFieldIds:{groupby:R(e.groupByFields),metric:r.length>0?r:[w.SEMAPHOR_GENERATED_COUNT_METRIC_ID],pivotby:R(e.pivotByFields),detail:R(e.detailFields)},expectedMetricAliases:le(t)}}class u extends Error{constructor(r,a){super(`invalid_pivot_result_lifecycle: ${r}`);g(this,"code","invalid_pivot_result_lifecycle");g(this,"deliveryBlocking",!0);this.cause=a,this.name="PivotResultLifecycleError"}}function at(e){if(!Array.isArray(e)||e.some(r=>!r||typeof r!="object"||Array.isArray(r)||typeof r.key!="string"||!r.key||typeof r.name!="string"||typeof r.label!="string"))throw new u("Canonical pivot columns must be an array of keyed, named result descriptors.");const t=e;if(new Set(t.map(r=>r.key)).size!==t.length)throw new u("Canonical pivot column keys must be unique.");for(const r of t){const a=ge.validateTemporalBucketResultColumn(r,{metadataRequired:!1});if(!a.ok)throw new u(`Canonical pivot column "${r.key}" has invalid temporal metadata: ${a.error.message}`)}return t}function V(e){if(!e||typeof e!="object"||Array.isArray(e)||e.version!==1||e.source!=="explorer"||!e.byRole||typeof e.byRole!="object"||Array.isArray(e.byRole))throw new u("A loaded canonical pivot result requires its role-scoped column key map.");const t=e,r=new Set(["groupby","metric","pivotby","detail"]);for(const[a,n]of Object.entries(t.byRole)){if(!r.has(a)||!n||typeof n!="object"||Array.isArray(n))throw new u(`Canonical pivot role map contains invalid "${a}" bindings.`);for(const[i,o]of Object.entries(n))if(!i||!o||typeof o!="object"||Array.isArray(o)||o.role!==a||typeof o.rawKey!="string"||!o.rawKey||o.outputKey!==void 0&&(typeof o.outputKey!="string"||!o.outputKey))throw new u(`Canonical pivot role map contains an invalid "${a}:${i}" binding.`)}if(t.byMetricAlias!==void 0){if(!t.byMetricAlias||typeof t.byMetricAlias!="object"||Array.isArray(t.byMetricAlias))throw new u("Canonical pivot metric-alias bindings must be an object.");for(const[a,n]of Object.entries(t.byMetricAlias))if(!a||!n||typeof n!="object"||Array.isArray(n)||n.role!=="metric"||typeof n.rawKey!="string"||!n.rawKey||n.outputKey!==void 0&&(typeof n.outputKey!="string"||!n.outputKey))throw new u(`Canonical pivot metric-alias map contains an invalid "${a}" binding.`)}return t}function nt(e){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))throw new u("Canonical pivot column metadata must be an object.");for(const[t,r]of Object.entries(e)){if(!t||!r||typeof r!="object"||Array.isArray(r))throw new u(`Canonical pivot column metadata contains an invalid "${t}" classification.`);const{isSubtotal:a,subtotalScope:n}=r;if(a!==void 0&&typeof a!="boolean"||n!==void 0&&n!=="base"&&n!=="pivot-value"&&n!=="grand-total"||a===!0&&n!=="pivot-value"&&n!=="grand-total"||(n==="pivot-value"||n==="grand-total")&&a!==!0||n==="base"&&a===!0)throw new u(`Canonical pivot column metadata contains an incoherent "${t}" subtotal classification.`)}return e}function G(e,t){if(!Array.isArray(e)||e.some(r=>typeof r!="string"||!r)||new Set(e).size!==e.length)throw new u(`Canonical pivot contract ${t} must be an array of unique field identities.`);return e}function it(e,t){if(!e||typeof e!="object"||Array.isArray(e)||e.version!==1)throw new u("A canonical pivot result requires its versioned result contract.");const r=e,a=r.expectedRoleFieldIds;if(!a||typeof a!="object"||Array.isArray(a))throw new u("Canonical pivot contract role identities must be an object.");const i=Object.fromEntries(["groupby","metric","pivotby","detail"].map(f=>[f,G(a[f],`expectedRoleFieldIds.${f}`)])),o=G(r.expectedMetricAliases,"expectedMetricAliases"),s=r.columnKinds;if(!s||typeof s!="object"||Array.isArray(s))throw new u("Canonical pivot contract column kinds must be an object.");const l=new Set(["row","pivot_metric","value"]),m=t.map(f=>f.key),c=Object.keys(s);if(c.length!==m.length||c.some(f=>!m.includes(f)||!l.has(s[f])))throw new u("Canonical pivot contract must classify every authoritative result column exactly once.");const y=nt(r.columnClassifications);if(Object.keys(y).some(f=>!m.includes(f)))throw new u("Canonical pivot contract contains a classification for an unknown result column.");return{version:1,expectedRoleFieldIds:i,expectedMetricAliases:o,columnKinds:s,columnClassifications:y}}function B(e,t){const r=["groupby","metric","pivotby","detail"];for(const i of r){const o=new Set(t.expectedRoleFieldIds[i]??[]),s=Object.keys(e.byRole[i]??{});if(s.length!==o.size||s.some(l=>!o.has(l)))throw new u(`The role-scoped ${i} bindings do not match the authored result fields.`)}const a=new Set(t.expectedMetricAliases),n=Object.keys(e.byMetricAlias??{});if(n.length!==a.size||n.some(i=>!a.has(i)))throw new u("The metric-alias bindings do not match the authored metric instances.")}function ot(e){if(!Array.isArray(e)||e.some(t=>!t||typeof t!="object"||Array.isArray(t)))throw new u("Canonical pivot records must be an array of row objects.");return e}function st(e,t){e.forEach((r,a)=>{t.forEach(n=>{if(!Object.prototype.hasOwnProperty.call(r,n.key)||r[n.key]===void 0)throw new u(`Canonical pivot column "${n.key}" is absent from row ${a}.`)})})}function ct(e,t,r){const a=new Set(t.map(n=>n.key));["groupby","detail"].forEach(n=>{Object.entries(e.byRole[n]??{}).forEach(([i,o])=>{const s=o.outputKey||o.rawKey;if(!a.has(s)||r.columnKinds[s]!=="row")throw new u(`The role-scoped ${n} binding for "${i}" does not name an authoritative result column.`)})})}function Z(e,t){t.forEach(r=>{const a=e.columnKinds[r.key];if(a==="pivot_metric"&&r.pivotIdentity===void 0)throw new u(`Physical pivot result column "${r.key}" is missing its identity.`);if(a!=="pivot_metric"&&r.pivotIdentity!==void 0)throw new u(`Canonical pivot result column "${r.key}" carries pivot identity outside the physical pivot projection.`)})}function me(e){const t=ot(e.records),r=at(e.columns),a=it(e.pivotResultContract,r),n=a.expectedRoleFieldIds.pivotby??[];if(e.pivotResultState==="loaded_empty"){if(t.length!==0)throw new u("A loaded_empty pivot result cannot carry records.");if(r.some(l=>a.columnKinds[l.key]==="pivot_metric"))throw new u("A loaded_empty pivot result cannot carry physical pivot columns.");Z(a,r);const s=V(e.columnKeyMap);return B(s,a),{pivotResultState:"loaded_empty",records:[],columns:r,columnKeyMap:s,pivotResultContract:a}}if(e.pivotResultState!=="loaded_valid")throw new u("A canonical pivot result must declare loaded_empty or loaded_valid.");if(t.length===0)throw new u("A loaded_valid pivot result must carry at least one record.");const i=V(e.columnKeyMap);B(i,a),ct(i,r,a),Z(a,r);const o=r.filter(s=>a.columnKinds[s.key]==="pivot_metric");if(n.length>0&&o.length===0)throw new u("A loaded_valid pivot result is missing its physical pivot columns.");try{j.requirePivotResultColumnIdentities(o,{expectedPivotFieldIds:n,columnClassifications:a.columnClassifications})}catch(s){throw s instanceof j.PivotResultIdentityError?new u(s.message,s):s}return st(t,r),{pivotResultState:"loaded_valid",records:t,columns:r,columnKeyMap:i,pivotResultContract:a}}function lt(e){const t=new Set;["groupby","detail"].forEach(i=>{Object.values(e.columnKeyMap.byRole[i]??{}).forEach(o=>{t.add(o.outputKey||o.rawKey)})});const r=new Set(e.physicalPivotColumnKeys),a=new Set(e.columns.map(i=>i.key)),n={version:1,expectedRoleFieldIds:{groupby:Array.from(new Set(e.expectedRoleFieldIds.groupby??[])),metric:Array.from(new Set(e.expectedRoleFieldIds.metric??[])),pivotby:Array.from(new Set(e.expectedRoleFieldIds.pivotby??[])),detail:Array.from(new Set(e.expectedRoleFieldIds.detail??[]))},expectedMetricAliases:[...e.expectedMetricAliases??[]],columnKinds:Object.fromEntries(e.columns.map(i=>[i.key,t.has(i.key)?"row":r.has(i.key)?"pivot_metric":"value"])),columnClassifications:Object.fromEntries(Object.entries(e.columnMetadata??{}).filter(([i])=>a.has(i)))};return me({pivotResultState:e.records.length===0?"loaded_empty":"loaded_valid",pivotResultContract:n,records:e.records,columns:e.columns,columnKeyMap:e.columnKeyMap})}exports.MissingResolvedRawTemporalFormatError=Ze;exports.PivotResultLifecycleError=u;exports.PresentationExecutionSnapshotError=A;exports.RawTemporalFormatContractError=p;exports.assertRawTemporalChunkClassificationAgreement=Ae;exports.classifyDeclaredSqlTemporalColumn=De;exports.createCanonicalPivotResultTransport=lt;exports.createPresentationExecutionSnapshot=Xe;exports.createRawTemporalChunkClassificationEvidence=$e;exports.deriveMetricInstanceAliasExpectations=le;exports.derivePivotResultContractExpectations=rt;exports.findResolvedNumericFormat=We;exports.findResolvedRawTemporalFormat=Qe;exports.findResolvedTemporalBucketFormat=et;exports.formatCurrency=M;exports.formatNumber=F;exports.formatNumberCustom=pe;exports.formatNumberWithColumnSettings=we;exports.formatNumericCanonical=U;exports.formatPercent=P;exports.formatRawTemporalValue=Be;exports.formatScientific=N;exports.parseCanonicalPivotResultTransport=me;exports.parseNumericCanonicalFormat=J;exports.parsePresentationExecutionSnapshot=ce;exports.parsePresentationScope=oe;exports.parseRawTemporalChunkClassificationEvidence=re;exports.parseResolvedNumericCanonicalFormat=H;exports.parseResolvedPresentationEntries=se;exports.parseResolvedRawTemporalFormat=I;exports.prepareRawTemporalFormatter=ie;exports.resolveCurrencyFractionDigits=Y;exports.resolveNumericPresentation=Te;exports.resolveRawTemporalFormat=Ie;exports.validateCardExportNumericPresentationSnapshot=Se;exports.validateCardExportPresentationSnapshot=tt;exports.validateRawTemporalPattern=Le;
|
package/dist/chunks/{pivot-result-lifecycle-B9FTybxN.js → pivot-result-lifecycle-mjJ1rBvV.js}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var te = Object.defineProperty;
|
|
2
2
|
var re = (e, t, r) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var g = (e, t, r) => re(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { b as k, ao as G, r as ae } from "./validators-
|
|
5
|
-
import { p as ne } from "./raw-temporal-contract-
|
|
4
|
+
import { b as k, ao as G, r as ae } from "./validators-D3AarM2T.js";
|
|
5
|
+
import { p as ne } from "./raw-temporal-contract-BuQIB31z.js";
|
|
6
6
|
import { canonicalizeSupportedLocale as E, canonicalizeSupportedCurrencyCode as $ } from "../value-format-preferences/index.js";
|
|
7
|
-
import { l as h, j as ie, a as oe } from "./
|
|
7
|
+
import { l as h, j as ie, a as oe } from "./metric-comparison-CTexJ8V1.js";
|
|
8
8
|
import { f as se } from "./index-CACdoqu3.js";
|
|
9
|
-
import { b as ce } from "./report-runtime-context-
|
|
10
|
-
import "./analyze-result-contract-
|
|
11
|
-
import { a as me } from "./temporal-bucket-contract-
|
|
12
|
-
import { d as le, P as ue } from "./pivot-result-identity-
|
|
9
|
+
import { b as ce } from "./report-runtime-context-B_pAmqxl.js";
|
|
10
|
+
import "./analyze-result-contract-DsiAzCYn.js";
|
|
11
|
+
import { a as me } from "./temporal-bucket-contract-BeOx0uYe.js";
|
|
12
|
+
import { d as le, P as ue } from "./pivot-result-identity-BIeP9v8I.js";
|
|
13
13
|
function K(e) {
|
|
14
14
|
if (!e) return !1;
|
|
15
15
|
const t = e.toLowerCase().replace("_", "-");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
2
|
var i = (a, e, t) => e in a ? d(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
3
|
var n = (a, e, t) => i(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { R as l } from "./validators-
|
|
4
|
+
import { R as l } from "./validators-D3AarM2T.js";
|
|
5
5
|
class r extends Error {
|
|
6
6
|
constructor(t) {
|
|
7
7
|
super(t);
|
package/dist/chunks/{raw-temporal-contract-D8YuxTAg.cjs → raw-temporal-contract-vnNwLy9R.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var i=(a,e,t)=>e in a?l(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var n=(a,e,t)=>i(a,typeof e!="symbol"?e+"":e,t);const s=require("./validators-
|
|
1
|
+
"use strict";var l=Object.defineProperty;var i=(a,e,t)=>e in a?l(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var n=(a,e,t)=>i(a,typeof e!="symbol"?e+"":e,t);const s=require("./validators-DqIM0B3C.cjs");class r extends Error{constructor(t){super(t);n(this,"code");this.name="RawTemporalMetadataContractError",this.code=s.RAW_TEMPORAL_CONTRACT_ERROR_CODES.invalidMetadata}}function m(a){if(a===null||typeof a!="object"||Array.isArray(a))return!1;const e=Object.getPrototypeOf(a);return e===null||e===Object.prototype}function d(a){if(!m(a))throw new r("Raw temporal metadata must be an object.");const e=Object.keys(a);if(e.length!==2||!e.includes("kind")||!e.includes("valueKind"))throw new r("Raw temporal metadata must contain only kind and valueKind.");if(a.kind!=="raw_temporal")throw new r("Raw temporal metadata kind must be raw_temporal.");if(a.valueKind!=="date"&&a.valueKind!=="wall_datetime"&&a.valueKind!=="instant")throw new r("Raw temporal valueKind must be date, wall_datetime, or instant.");return{kind:"raw_temporal",valueKind:a.valueKind}}function w(a,e){if(!a.rawTemporal){if(e.metadataRequired)throw new r("Activated raw temporal result is missing metadata.");return}if(a.temporalBucket)throw new r("A result column cannot carry both raw and grouped temporal metadata.");const t=d(a.rawTemporal),o=t.valueKind==="date"?"date":"datetime";if(a.dataType!==o)throw new r(`${t.valueKind} raw temporal values require dataType ${o}.`);return t}exports.RawTemporalMetadataContractError=r;exports.parseRawTemporalValueMetadata=d;exports.validateRawTemporalResultColumn=w;
|