react-semaphor 0.1.467 → 0.1.469
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 +158 -285
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +4 -4
- package/dist/briefings/index.js +4 -4
- package/dist/chunks/{analyze-result-contract-CMZDRRwo.js → analyze-result-contract-kaCNxjA7.js} +1 -1
- package/dist/chunks/{common-types-Co766x6t.js → common-types-BgI-ymBp.js} +30 -23
- package/dist/chunks/common-types-tRK8fhXV.cjs +1 -0
- package/dist/chunks/{dashboard-briefing-launcher-FbEIrobt.cjs → dashboard-briefing-launcher-BqxcYhO2.cjs} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-Ctu63_Di.js → dashboard-briefing-launcher-kKSBCRLE.js} +9 -9
- package/dist/chunks/{dashboard-controls-DeDCphnd.js → dashboard-controls-DP2rftVR.js} +9 -9
- package/dist/chunks/{dashboard-controls-BKm3JIEo.cjs → dashboard-controls-Z8ow3GV6.cjs} +1 -1
- package/dist/chunks/{dashboard-filter-value-compatibility-B8ynE_O1.js → dashboard-filter-value-compatibility-Ce7jUVh-.js} +8 -8
- package/dist/chunks/{dashboard-filter-value-compatibility-Bnl2lsng.cjs → dashboard-filter-value-compatibility-iCPBcrRS.cjs} +1 -1
- package/dist/chunks/{dashboard-input-contract-Px64VWBL.js → dashboard-input-contract-Ciboc347.js} +6 -6
- package/dist/chunks/{dashboard-json-BygDylH8.js → dashboard-json-3qT123Xa.js} +7 -7
- package/dist/chunks/{dashboard-json-BV6wbV2p.cjs → dashboard-json-CPq7IMvR.cjs} +1 -1
- package/dist/chunks/edit-dashboard-visual-7eUCTZnx.cjs +172 -0
- package/dist/chunks/{edit-dashboard-visual-CYOtYa4w.js → edit-dashboard-visual-Clz6LQOX.js} +7164 -7298
- package/dist/chunks/{editor-action-buttons-Baks5RYd.js → editor-action-buttons-CFbMRQSE.js} +6 -6
- package/dist/chunks/{editor-action-buttons-CRRjegRd.cjs → editor-action-buttons-WJFWflfs.cjs} +1 -1
- package/dist/chunks/{index-B31RKKGb.js → index-8Cm77joZ.js} +29054 -28935
- package/dist/chunks/{index-yJRh4x9j.cjs → index-DKaQRhKm.cjs} +179 -167
- package/dist/chunks/{index-BlCnNcaB.js → index-DO4BESNy.js} +9 -9
- package/dist/chunks/matrix-result-contract-ClC6Pd_g.js +822 -0
- package/dist/chunks/matrix-result-contract-DF-qt0jx.cjs +1 -0
- package/dist/chunks/{pivot-header-presentation-CSf6CyOt.js → pivot-header-presentation-OpY8xzdT.js} +2 -2
- package/dist/chunks/{pivot-result-identity-BvT51Nog.js → pivot-result-identity-CCMpd8ZA.js} +1 -1
- package/dist/chunks/{pivot-result-lifecycle--NNNPUtG.js → pivot-result-lifecycle-B38AZx4a.js} +19 -19
- package/dist/chunks/{raw-temporal-contract-BqVMduCs.js → raw-temporal-contract-r_EMdR85.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-CRNoMzNj.cjs → report-preferences-dialog-C5UOCTwt.cjs} +1 -1
- package/dist/chunks/{report-preferences-dialog-CZPqG-em.js → report-preferences-dialog-D-NDYRrk.js} +6 -6
- package/dist/chunks/{report-runtime-context-CrTzKt0C.js → report-runtime-context-CcXUjpb-.js} +7 -7
- package/dist/chunks/{saved-temporal-bucket-format-DfqnCGCz.js → saved-temporal-bucket-format-hylaofsQ.js} +29 -29
- package/dist/chunks/{switch-B6rFVSdw.js → switch-BagpmPNw.js} +24 -9
- package/dist/chunks/{switch-BghC7eOM.cjs → switch-DyE2_OmQ.cjs} +2 -2
- package/dist/chunks/{temporal-bucket-DFYIkexB.js → temporal-bucket-Cc9fmx8s.js} +12 -12
- package/dist/chunks/{temporal-bucket-authoring-ZxFzhTmL.js → temporal-bucket-authoring-DjPFtRSF.js} +3 -3
- package/dist/chunks/{temporal-bucket-contract-COPPwwbi.js → temporal-bucket-contract-DT4kU0VY.js} +1 -1
- package/dist/chunks/{token-types-p1M3SA2G.js → token-types-Z889rD6g.js} +1 -1
- package/dist/chunks/{update-policy-BKOA5S76.js → update-policy-Bu5Tw43R.js} +1 -1
- package/dist/chunks/{validators-CCpBY1e0.js → validators-DhTaCK1O.js} +50 -50
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +4 -4
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.js +3 -3
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.js +9 -9
- package/dist/format-utils/index.js +10 -10
- package/dist/index.cjs +1 -1
- package/dist/index.js +117 -115
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +74 -0
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +18 -16
- package/dist/types/main.d.ts +10 -0
- package/dist/types/types.d.ts +9 -0
- package/package.json +1 -1
- package/dist/chunks/common-types-o3LJcrpg.cjs +0 -1
- package/dist/chunks/edit-dashboard-visual-DWN052a9.cjs +0 -172
- package/dist/chunks/matrix-result-contract-DQ9_UadF.js +0 -421
- package/dist/chunks/matrix-result-contract-DiHDIyQk.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var R=Object.defineProperty;var j=(e,t,a)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var $=(e,t,a)=>j(e,typeof t!="symbol"?t+"":t,a);const E=require("./temporal-bucket-BDRcWdVv.cjs"),K=require("./validators-DO-YuzgO.cjs"),O=require("./temporal-bucket-contract-vrOkax-r.cjs");function b(e){const t=G(e);return t.length>0?t.join("."):void 0}function S(e){const t=b(e.qualifiedName),a=(t==null?void 0:t.split("."))||[];if(a.length===0)return{};const r={};let s=a.length-1;for(let i=e.capabilities.prefixLevels.length-1;i>=0&&s>=0;i-=1,s-=1)V(r,e.capabilities.prefixLevels[i],a[s]);return r}function g(e){return!e.left.tableName||!e.right.tableName?!1:e.capabilities.prefixLevels.every(t=>{const a=p(e.left,t),r=p(e.right,t);return!a||!r||a===r})}function A(e){return e.capabilities.prefixLevels.every(t=>{const a=p(e.requested,t);return a?p(e.allowed,t)===a:!0})}function w(e,t={}){const a=N(e),r={connectionId:t.connectionId,connectionType:e,path:["database","schema","table"],labels:{database:"Database",schema:"Schema",table:"Table"},prefixLevels:["database","schema","table"],dialect:"postgres",supportsFilterClause:!0};return a.includes("postgres")?{...r,prefixLevels:["schema","table"],dialect:"postgres"}:a.includes("mysql")?{...r,prefixLevels:["database","table"],dialect:"mysql",supportsFilterClause:!1}:a.includes("mssql")||a.includes("sqlserver")?{...r,dialect:"mssql",supportsFilterClause:!1}:a.includes("redshift")?{...r,prefixLevels:["schema","table"],dialect:"redshift"}:a.includes("snowflake")?{...r,dialect:"snowflake"}:a.includes("clickhouse")?{connectionId:t.connectionId,connectionType:e,path:["database","table"],labels:{database:"Database",table:"Table"},prefixLevels:["database","table"],dialect:"clickhouse",supportsFilterClause:!1}:a==="s3"||a==="api"?{connectionId:t.connectionId,connectionType:e,path:["table"],labels:{table:a==="api"?"API Table":"File Table"},prefixLevels:["table"],dialect:"duckdb",supportsFilterClause:!0}:a==="googlesheets"||a==="fileupload"?{connectionId:t.connectionId,connectionType:e,path:["table"],labels:{table:"Table"},prefixLevels:["table"],dialect:"postgres",supportsFilterClause:!0}:a==="s3tables"?{...r,labels:{database:"Database",schema:"Namespace",table:"Table"},dialect:"duckdb"}:a==="bigquery"?{...r,labels:{database:"Project",schema:"Dataset",table:"Table"},prefixLevels:["schema","table"],dialect:"bigquery",supportsFilterClause:!1}:r}function Q(e){const t=N(e);switch(t){case"mysql":case"bigquery":case"redshift":case"snowflake":case"clickhouse":case"duckdb":case"sqlite":return t;case"mssql":case"sqlserver":return"mssql";case"postgres":case"postgresql":return"postgres";default:return"unknown"}}function F(e){return e.capabilities.prefixLevels.every(t=>!!p(e.source,t))}function z(e){const t=e.quoteIdentifier??D;return e.capabilities.prefixLevels.map(a=>p(e.source,a)).filter(a=>!!a).map(a=>t(a,e.capabilities.dialect)).join(".")}function p(e,t){return t==="database"?e.databaseName:t==="schema"?e.schemaName:e.tableName}function V(e,t,a){t==="database"?e.databaseName=a:t==="schema"?e.schemaName=a:e.tableName=a}function G(e){const t=e==null?void 0:e.trim();if(!t)return[];const a=t.split(".").map(r=>{const s=r.trim();return s.length>=2&&s.startsWith('"')&&s.endsWith('"')?s.slice(1,-1):s});return a.some(r=>!r)?[]:a}function D(e,t){return t==="mysql"||t==="bigquery"||t==="clickhouse"||t==="duckdb"?`\`${e.replace(/`/g,"``")}\``:t==="mssql"?`[${e.replace(/]/g,"]]")}]`:`"${e.replace(/"/g,'""')}"`}function N(e){if(typeof e!="string")return"";const t=[];for(const a of e.trim().toLowerCase())J(a)&&t.push(a);return t.join("")}function J(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=97&&t<=122}function m(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function v(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function H(e){const t=v(e);return!t||!m(t.name)||t.type==="model"?!1:t.type==="dataset"?t.datasetType==="physical":!0}function x(e){const t=v(e);if(!t)return{};const a=m(t.table)||m(t.name);return{...m(t.database)?{databaseName:m(t.database)}:{},...m(t.schema)?{schemaName:m(t.schema)}:{},...a?{tableName:a}:{}}}function W(e){const t=e.entities.filter(H),a=U(e),r=X({entities:t,connectionType:e.connectionType});if(!r)return{kind:"incompatible_capabilities"};const s=Y({hints:e.qualifiedHints||[],coordinateHint:e.coordinateHint,capabilities:r});if(s.kind!=="valid")return{kind:s.kind};const i=s.coordinates,n=i?t.filter(c=>g({left:x(c),right:i,capabilities:r})):t;if(i&&n.length===0)return{kind:"not_found",basis:"qualified",coordinates:i};if(i&&n.length===1){const c=n[0];return{kind:"resolved",basis:"qualified",entity:c,coordinates:re(x(c),i)}}const l=P([...e.bareHints||[],...s.bareHints,i==null?void 0:i.tableName]);if(l.size>0){const c=n.filter(u=>{const h=ae(u);return Array.from(l).some(d=>h.has(d))});if(c.length===1){const u=c[0];return{kind:"resolved",basis:"bare",entity:u,coordinates:x(u)}}return c.length>1?{kind:"ambiguous",basis:"bare"}:{kind:"not_found",basis:"bare"}}if(i)return{kind:"ambiguous",basis:"qualified"};if(a)return{kind:"not_found",basis:a};if(t.length===1){const c=t[0];return{kind:"resolved",basis:"unqualified",entity:c,coordinates:x(c)}}return{kind:"unqualified"}}function U(e){const t=(e.qualifiedHints||[]).map(m).filter(r=>!!r);return Object.values(e.coordinateHint||{}).some(r=>!!m(r))||t.some(r=>r.includes("."))?"qualified":[...t,...e.bareHints||[]].some(r=>!!m(r))?"bare":void 0}function X(e){var r;const t=m(e.connectionType);if(t)return w(t);const a=e.entities.flatMap(s=>{var l;const i=m((l=v(s))==null?void 0:l.connectionType);if(!i)return[];const n=w(i);return[{capabilities:n,signature:`${n.dialect}:${n.prefixLevels.join(".")}`}]});if(!(new Set(a.map(s=>s.signature)).size>1))return((r=a[0])==null?void 0:r.capabilities)||w(void 0)}function Y(e){const t=[],a=[];for(const u of e.hints){const h=m(u);if(!h)continue;if(!h.includes(".")){a.push(h);continue}const d=b(h);if(!d)return{kind:"malformed"};t.push(d)}const r=Z(e.coordinateHint);if(r.kind==="malformed")return r;const s=Array.from(new Set(t)).map(u=>S({qualifiedName:u,capabilities:e.capabilities}));if(!te(s,e.capabilities))return{kind:"conflicting"};const i=[...new Set(t)].sort((u,h)=>h.split(".").length-u.split(".").length)[0],n=i?S({qualifiedName:i,capabilities:e.capabilities}):void 0,l=ee(r.coordinates,e.capabilities),c=!!(l.tableName&&(l.databaseName||l.schemaName));return n&&c&&!g({left:n,right:l,capabilities:e.capabilities})?{kind:"conflicting"}:{kind:"valid",coordinates:n?c?{...n,...l}:n:c?l:void 0,bareHints:[...a,...!c&&l.tableName?[l.tableName]:[]]}}function Z(e){const t={};for(const[a,r]of Object.entries(e||{})){const s=m(r);if(!s)continue;const i=b(s);if(!i)return{kind:"malformed"};t[a]=i}return{kind:"valid",coordinates:t}}function ee(e,t){return{...t.prefixLevels.includes("database")&&e.databaseName?{databaseName:e.databaseName}:{},...t.prefixLevels.includes("schema")&&e.schemaName?{schemaName:e.schemaName}:{},...e.tableName?{tableName:e.tableName}:{}}}function te(e,t){return e.every((a,r)=>e.slice(r+1).every(s=>g({left:a,right:s,capabilities:t})))}function P(e){return new Set(e.map(m).map(b).filter(t=>!!t))}function ae(e){const t=v(e);return t?P([m(t.name),m(t.table),m(t.id)]):new Set}function re(e,t){return{...t,...e}}class M extends Error{constructor(a){super(a.message);$(this,"code");$(this,"path");this.name="MatrixResultContractError",this.code=a.code,this.path=a.path}}function ie(e){var c,u,h;const t=de(e);if(t!==2)throw new M({code:"unsupported_matrix_result_version",message:`Canonical Matrix results require schemaVersion 2; received ${String(t)}.`,path:"schemaVersion"});const a=K.semaphorMatrixResultSchema.safeParse(e);if(!a.success){const d=a.error.issues[0];throw o((d==null?void 0:d.message)||"Canonical Matrix result has an invalid shape.",d==null?void 0:d.path.join("."))}const r=a.data,s={row:C(r.axes.rows.levels,"axes.rows.levels"),column:C(r.axes.columns.levels,"axes.columns.levels")};ce(r),B(r,"row"),B(r,"column");const i=new Set([...r.axes.rows.nodeIds,...r.axes.columns.nodeIds]),n=new Set;for(const[d,f]of Object.entries(r.nodesById)){if(f.id!==d)throw o("Matrix node directory key must equal node.id.",`nodesById.${d}.id`);if(!i.has(d))throw o("Matrix node directory cannot contain nodes omitted from both axes.",`nodesById.${d}`);se(f,s[f.axis],`nodesById.${d}`);const y=JSON.stringify([f.axis,f.path,f.isSubtotal===!0,f.isGrandTotal===!0]);if(n.has(y))throw o("Matrix nodes must have unique canonical path and total-role identity.",`nodesById.${d}`);n.add(y),le(r,f,`nodesById.${d}`)}const l=new Set;for(const[d,f]of r.cells.entries()){if(!((c=r.nodesById[f.rowId])!=null&&c.axis)||((u=r.nodesById[f.rowId])==null?void 0:u.axis)!=="row")throw o("Matrix cell rowId must reference a row node.",`cells.${d}.rowId`);if(f.columnId&&((h=r.nodesById[f.columnId])==null?void 0:h.axis)!=="column")throw o("Matrix cell columnId must reference a column node.",`cells.${d}.columnId`);if(!r.measuresById[f.measureId])throw o("Matrix cell measureId must reference a measure.",`cells.${d}.measureId`);const y=ne(r.nodesById[f.rowId],f.columnId?r.nodesById[f.columnId]:void 0);if(f.role!==y)throw o("Matrix cell role must match its referenced row and column total roles.",`cells.${d}.role`);const q=JSON.stringify([f.rowId,f.columnId??null,f.measureId]);if(l.has(q))throw o("Matrix result cannot contain duplicate physical cell addresses.",`cells.${d}`);l.add(q)}return oe(r,s),r}function C(e,t){var r;const a=new Map;for(const[s,i]of e.entries()){const n=`${t}.${s}`;if(a.has(i.instanceId))throw o("Matrix axis level ids must be unique.",`${n}.instanceId`);a.set(i.instanceId,i);const l=i.field.role==="date"||i.field.dataType==="date"||i.field.dataType==="datetime",c=i.field.dataType==="string"||i.field.dataType==="number"||i.field.dataType==="boolean";if(l&&!i.grain)throw o("Temporal Matrix axis level is missing its explicit grain.",`${n}.grain`);if(c&&i.grain)throw o("Non-temporal Matrix axis level cannot carry a grain.",`${n}.grain`);if(i.grain){if(!i.temporalBucket)throw o("Temporal Matrix axis level is missing governed bucket metadata.",`${n}.temporalBucket`);const u=O.validateTemporalBucketMetadata(i.temporalBucket);if(!u.ok||((r=u.value)==null?void 0:r.granularity)!==i.grain)throw o("Matrix axis grain and temporal metadata must agree.",`${n}.temporalBucket`)}else if(i.temporalBucket)throw o("Non-temporal Matrix axis levels cannot carry temporal bucket metadata.",n)}return a}function B(e,t){var s;const a=t==="row"?e.axes.rows:e.axes.columns,r=new Set;for(const[i,n]of a.nodeIds.entries()){if(r.has(n))throw o("Matrix axis node ids must be unique.",`axes.${t==="row"?"rows":"columns"}.nodeIds.${i}`);if(r.add(n),((s=e.nodesById[n])==null?void 0:s.axis)!==t)throw o("Matrix axis node id references the wrong axis.",`axes.${t==="row"?"rows":"columns"}.nodeIds.${i}`)}}function se(e,t,a){if(e.isGrandTotal){if(e.isSubtotal)throw o("Matrix nodes cannot be both subtotal and grand total.",a);if(e.path.length!==0)throw o("Matrix grand-total nodes must have an empty member path.",`${a}.path`);return}if(!e.path.length||e.level!==e.path.length-1)throw o("Ordinary and subtotal Matrix nodes require a level-aligned non-empty path.",a);const r=[...t.values()];if(e.path.length>r.length)throw o("Matrix node path exceeds its authored axis depth.",`${a}.path`);if(e.isSubtotal&&e.path.length>=r.length)throw o("Matrix subtotal nodes must identify a proper authored-axis prefix.",`${a}.path`);e.path.forEach((l,c)=>{const u=r[c];if(l.instanceId==="__matrix_remaining__"&&l.fieldKey==="__matrix_remaining__"&&l.value==="__matrix_remaining__"){if(c!==e.path.length-1)throw o("Matrix remaining-member identity must be the terminal path segment.",`${a}.path.${c}`);if(typeof l.label!="string")throw o("Matrix remaining-member paths require their explicit display label.",`${a}.path.${c}.label`);return}if(!u||l.instanceId!==u.instanceId||l.fieldKey!==u.fieldKey)throw o("Matrix member path must follow authored axis order and identity.",`${a}.path.${c}`);L(l,u,`${a}.path.${c}`)});const s=e.path[e.path.length-1],i=s.instanceId==="__matrix_remaining__"&&s.fieldKey==="__matrix_remaining__"&&s.value==="__matrix_remaining__";if(!k(e.value,s.value))throw o("Matrix node value must equal its final canonical path member.",`${a}.value`);const n=r[e.path.length-1];if(n!=null&&n.temporalBucket&&!e.isSubtotal&&!i&&e.label!==void 0)throw o("Temporal Matrix nodes cannot transport display labels.",`${a}.label`);if((!(n!=null&&n.temporalBucket)||i)&&typeof e.label!="string")throw o("Non-temporal Matrix nodes require a display label.",`${a}.label`)}function ne(e,t){return e.isGrandTotal&&(t!=null&&t.isGrandTotal)?"matrixGrandTotal":e.isGrandTotal?"rowGrandTotal":t!=null&&t.isGrandTotal?"columnGrandTotal":e.isSubtotal&&(t!=null&&t.isSubtotal)?"subtotalIntersection":e.isSubtotal?"rowSubtotal":t!=null&&t.isSubtotal?"columnSubtotal":"value"}function L(e,t,a){if(t.temporalBucket){if(e.label!==void 0)throw o("Temporal Matrix path members cannot transport display labels.",`${a}.label`);if(e.value!==null&&typeof e.value!="string")throw o("Temporal Matrix member values must be canonical strings or null.",`${a}.value`);const r=E.parseTemporalBucketValue(e.value,t.temporalBucket);if(!r.ok)throw o(r.error.message,`${a}.value`)}else if(typeof e.label!="string")throw o("Non-temporal Matrix path members require a display label.",`${a}.label`)}function oe(e,t){const a=[...t.row.values()];if(e.layout.rowHeaderLevels.length!==a.length)throw o("Matrix row-header layout must describe every row-axis level exactly once.","layout.rowHeaderLevels");e.layout.rowHeaderLevels.forEach((s,i)=>{var n;if(s.fieldInstanceId!==((n=a[i])==null?void 0:n.instanceId))throw o("Matrix row-header layout must follow authored row-axis order.",`layout.rowHeaderLevels.${i}.fieldInstanceId`)});for(const[s,i]of e.layout.columnHeaderRows.entries())for(const[n,l]of i.cells.entries()){if(_(l.columnPath,t.column,`layout.columnHeaderRows.${s}.cells.${n}.columnPath`),l.measureInstanceId&&!e.measuresById[l.measureInstanceId])throw o("Matrix header measureInstanceId must reference a measure.",`layout.columnHeaderRows.${s}.cells.${n}.measureInstanceId`);if(l.role==="columnHeader"&&l.label!==void 0)throw o("Matrix member headers cannot transport composed display labels.",`layout.columnHeaderRows.${s}.cells.${n}.label`)}const r=new Set;for(const[s,i]of e.layout.columns.entries()){if(r.has(i.id))throw o("Matrix layout column ids must be unique.",`layout.columns.${s}.id`);if(r.add(i.id),_(i.columnPath,t.column,`layout.columns.${s}.columnPath`),i.role==="value"&&i.columnPath.length>0&&i.label!==void 0)throw o("Matrix value columns with member paths cannot transport composed display labels.",`layout.columns.${s}.label`);if(!e.measuresById[i.measureInstanceId])throw o("Matrix layout column measureInstanceId must reference a measure.",`layout.columns.${s}.measureInstanceId`);if(i.columnNodeId){const n=e.nodesById[i.columnNodeId];if((n==null?void 0:n.axis)!=="column"||!k(n.path,i.columnPath))throw o("Matrix layout column must match its referenced column node path.",`layout.columns.${s}.columnNodeId`)}else if(t.column.size>0)throw o("Matrix columns with an authored column axis require a columnNodeId.",`layout.columns.${s}.columnNodeId`)}}function _(e,t,a){const r=[...t.values()];if(e.length>r.length)throw o("Matrix layout path exceeds its authored axis depth.",a);e.forEach((s,i)=>{const n=r[i];if(!n||s.instanceId!==n.instanceId||s.fieldKey!==n.fieldKey)throw o("Matrix layout path must follow authored axis order and identity.",`${a}.${i}`);L(s,n,`${a}.${i}`)})}function le(e,t,a){if(!t.parentId)return;const r=e.nodesById[t.parentId];if(!r)throw o("Matrix parentId must reference an existing node.",`${a}.parentId`);if(r.axis!==t.axis||r.path.length!==t.path.length-1||!k(r.path,t.path.slice(0,-1)))throw o("Matrix parentId must reference the immediate same-axis path prefix.",`${a}.parentId`)}function ce(e){for(const[t,a]of[["rows",e.axes.rows],["columns",e.axes.columns]]){const r=t==="rows"?"row":"column";a.levels.forEach((s,i)=>{const n=e.fieldsById[s.instanceId];if(!n||n.instanceId!==s.instanceId||n.fieldKey!==s.fieldKey||n.role!==r||!T(n.field,s.field))throw o("Matrix axis level must have one matching role-scoped field descriptor.",`axes.${t}.levels.${i}`)})}for(const[t,a]of Object.entries(e.measuresById)){if(a.instanceId!==t)throw o("Matrix measure directory key must equal measure.instanceId.",`measuresById.${t}.instanceId`);const r=e.fieldsById[t];if(!r||r.instanceId!==t||r.fieldKey!==a.fieldKey||r.role!=="measure"||!T(r.field,a.field))throw o("Matrix measure must have one matching field descriptor.",`measuresById.${t}`)}}function de(e){return e&&typeof e=="object"?e.schemaVersion:void 0}function k(e,t){return JSON.stringify(e)===JSON.stringify(t)}function T(e,t){return I(e)===I(t)}function I(e){if(Array.isArray(e))return`[${e.map(I).join(",")}]`;if(e&&typeof e=="object"){const t=e;return`{${Object.keys(t).filter(a=>t[a]!==void 0).sort().map(a=>`${JSON.stringify(a)}:${I(t[a])}`).join(",")}}`}return e===void 0?"undefined":JSON.stringify(e)}function o(e,t){return new M({code:"invalid_matrix_result_contract",message:e,path:t})}exports.MatrixResultContractError=M;exports.buildSemaphorQualifiedSourcePath=z;exports.canonicalizeSemaphorQualifiedSourcePath=b;exports.getSemaphorConnectionCapabilities=w;exports.isSemaphorPhysicalSourceEntity=H;exports.normalizeSemaphorDialect=Q;exports.parseCanonicalMatrixResult=ie;exports.parseSemaphorQualifiedSourcePath=S;exports.resolveSemaphorPhysicalSourceEntity=W;exports.semaphorPhysicalSourceCoordinatesAreCompatible=g;exports.semaphorPhysicalSourceCoordinatesCover=A;exports.semaphorSourceHasRequiredCoordinates=F;
|
package/dist/chunks/{pivot-header-presentation-CSf6CyOt.js → pivot-header-presentation-OpY8xzdT.js}
RENAMED
|
@@ -2,9 +2,9 @@ var U = Object.defineProperty;
|
|
|
2
2
|
var E = (e, t, n) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var A = (e, t, n) => E(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { t as f, c as P, g as R, e as O, a as T, m as S, b as M, i as Z, f as k, d as B } from "./format-types-CFHQoIuk.js";
|
|
5
|
-
import { b as y } from "./pivot-result-lifecycle
|
|
5
|
+
import { b as y } from "./pivot-result-lifecycle-B38AZx4a.js";
|
|
6
6
|
import { f as j } from "./index-CACdoqu3.js";
|
|
7
|
-
import { h as X } from "./temporal-bucket-
|
|
7
|
+
import { h as X } from "./temporal-bucket-Cc9fmx8s.js";
|
|
8
8
|
function b(e, t) {
|
|
9
9
|
const n = f(e), o = f(t), r = n.getTime() - o.getTime();
|
|
10
10
|
return r < 0 ? -1 : r > 0 ? 1 : r;
|
|
@@ -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-DT4kU0VY.js";
|
|
5
5
|
function f(t) {
|
|
6
6
|
return !!(t != null && t.isSubtotal && t.subtotalScope === "pivot-value");
|
|
7
7
|
}
|
package/dist/chunks/{pivot-result-lifecycle--NNNPUtG.js → pivot-result-lifecycle-B38AZx4a.js}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var ee = Object.defineProperty;
|
|
2
2
|
var te = (e, t, r) => t in e ? ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var g = (e, t, r) => te(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { b as k, an as G,
|
|
5
|
-
import { p as ae } from "./raw-temporal-contract-
|
|
4
|
+
import { b as k, an as G, q as re } from "./validators-DhTaCK1O.js";
|
|
5
|
+
import { p as ae } from "./raw-temporal-contract-r_EMdR85.js";
|
|
6
6
|
import { canonicalizeSupportedLocale as E, canonicalizeSupportedCurrencyCode as $ } from "../value-format-preferences/index.js";
|
|
7
|
-
import { l as h, j as ne, a as ie } from "./temporal-bucket-
|
|
7
|
+
import { l as h, j as ne, a as ie } from "./temporal-bucket-Cc9fmx8s.js";
|
|
8
8
|
import { f as oe } from "./index-CACdoqu3.js";
|
|
9
|
-
import { b as se } from "./report-runtime-context-
|
|
10
|
-
import "./analyze-result-contract-
|
|
11
|
-
import { a as ce } from "./temporal-bucket-contract-
|
|
12
|
-
import { d as me, P as le } from "./pivot-result-identity-
|
|
9
|
+
import { b as se } from "./report-runtime-context-CcXUjpb-.js";
|
|
10
|
+
import "./analyze-result-contract-kaCNxjA7.js";
|
|
11
|
+
import { a as ce } from "./temporal-bucket-contract-DT4kU0VY.js";
|
|
12
|
+
import { d as me, P as le } from "./pivot-result-identity-CCMpd8ZA.js";
|
|
13
13
|
function N(e) {
|
|
14
14
|
if (!e) return !1;
|
|
15
15
|
const t = e.toLowerCase().replace("_", "-");
|
|
@@ -1094,7 +1094,7 @@ function K(e, t) {
|
|
|
1094
1094
|
const r = I(e), a = I(t);
|
|
1095
1095
|
return r.length === a.length && r.every((n, i) => n === a[i]);
|
|
1096
1096
|
}
|
|
1097
|
-
function
|
|
1097
|
+
function qe(e) {
|
|
1098
1098
|
if (!Array.isArray(e))
|
|
1099
1099
|
throw new Error("resolvedFormats must be an array");
|
|
1100
1100
|
const t = /* @__PURE__ */ new Set();
|
|
@@ -1159,7 +1159,7 @@ function Le(e) {
|
|
|
1159
1159
|
return t.add(s), o;
|
|
1160
1160
|
});
|
|
1161
1161
|
}
|
|
1162
|
-
function
|
|
1162
|
+
function Le(e) {
|
|
1163
1163
|
try {
|
|
1164
1164
|
if (!h(e))
|
|
1165
1165
|
throw new Error("presentation execution snapshot must be an object");
|
|
@@ -1179,7 +1179,7 @@ function qe(e) {
|
|
|
1179
1179
|
return {
|
|
1180
1180
|
version: 1,
|
|
1181
1181
|
reportContext: t.value,
|
|
1182
|
-
resolvedFormats:
|
|
1182
|
+
resolvedFormats: qe(e.resolvedFormats)
|
|
1183
1183
|
};
|
|
1184
1184
|
} catch (t) {
|
|
1185
1185
|
throw t instanceof j ? t : new j(
|
|
@@ -1188,7 +1188,7 @@ function qe(e) {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
1190
|
function vt(e) {
|
|
1191
|
-
return
|
|
1191
|
+
return Le({
|
|
1192
1192
|
version: 1,
|
|
1193
1193
|
reportContext: e.reportContext,
|
|
1194
1194
|
resolvedFormats: [...e.resolvedFormats]
|
|
@@ -1364,7 +1364,7 @@ function Be(e) {
|
|
|
1364
1364
|
}
|
|
1365
1365
|
return e;
|
|
1366
1366
|
}
|
|
1367
|
-
function
|
|
1367
|
+
function q(e, t) {
|
|
1368
1368
|
if (!Array.isArray(e) || e.some((r) => typeof r != "string" || !r) || new Set(e).size !== e.length)
|
|
1369
1369
|
throw new u(
|
|
1370
1370
|
`Canonical pivot contract ${t} must be an array of unique field identities.`
|
|
@@ -1389,12 +1389,12 @@ function Ue(e, t) {
|
|
|
1389
1389
|
"detail"
|
|
1390
1390
|
].map((f) => [
|
|
1391
1391
|
f,
|
|
1392
|
-
|
|
1392
|
+
q(
|
|
1393
1393
|
a[f],
|
|
1394
1394
|
`expectedRoleFieldIds.${f}`
|
|
1395
1395
|
)
|
|
1396
1396
|
])
|
|
1397
|
-
), o =
|
|
1397
|
+
), o = q(
|
|
1398
1398
|
r.expectedMetricAliases,
|
|
1399
1399
|
"expectedMetricAliases"
|
|
1400
1400
|
), s = r.columnKinds;
|
|
@@ -1432,7 +1432,7 @@ function Ue(e, t) {
|
|
|
1432
1432
|
columnClassifications: y
|
|
1433
1433
|
};
|
|
1434
1434
|
}
|
|
1435
|
-
function
|
|
1435
|
+
function L(e, t) {
|
|
1436
1436
|
const r = [
|
|
1437
1437
|
"groupby",
|
|
1438
1438
|
"metric",
|
|
@@ -1516,7 +1516,7 @@ function Xe(e) {
|
|
|
1516
1516
|
);
|
|
1517
1517
|
V(a, r);
|
|
1518
1518
|
const s = O(e.columnKeyMap);
|
|
1519
|
-
return
|
|
1519
|
+
return L(s, a), {
|
|
1520
1520
|
pivotResultState: "loaded_empty",
|
|
1521
1521
|
records: [],
|
|
1522
1522
|
columns: r,
|
|
@@ -1533,7 +1533,7 @@ function Xe(e) {
|
|
|
1533
1533
|
"A loaded_valid pivot result must carry at least one record."
|
|
1534
1534
|
);
|
|
1535
1535
|
const i = O(e.columnKeyMap);
|
|
1536
|
-
|
|
1536
|
+
L(i, a), Ye(i, r, a), V(a, r);
|
|
1537
1537
|
const o = r.filter(
|
|
1538
1538
|
(s) => a.columnKinds[s.key] === "pivot_metric"
|
|
1539
1539
|
);
|
|
@@ -1625,8 +1625,8 @@ export {
|
|
|
1625
1625
|
he as i,
|
|
1626
1626
|
lt as j,
|
|
1627
1627
|
Ne as k,
|
|
1628
|
-
|
|
1629
|
-
|
|
1628
|
+
qe as l,
|
|
1629
|
+
Le as m,
|
|
1630
1630
|
vt as n,
|
|
1631
1631
|
pt as o,
|
|
1632
1632
|
ye as p,
|
|
@@ -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-DhTaCK1O.js";
|
|
5
5
|
class r extends Error {
|
|
6
6
|
constructor(t) {
|
|
7
7
|
super(t);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),o=require("react"),l=require("./index-yJRh4x9j.cjs"),u=require("./switch-BghC7eOM.cjs"),V=require("./report-runtime-context-CLtzrZdC.cjs");require("./x-B6ghREd2.cjs");require("./saved-temporal-bucket-format-Ca4hUfTo.cjs");require("./validators-DO-YuzgO.cjs");require("./analyze-result-contract-CMwVg9w2.cjs");const L=require("../value-format-preferences/index.cjs");function G(a={}){const{authToken:c,tokenProps:t}=l.useSemaphorContext(),m=u.useDashboardStore(p=>p.actions.applyResolvedCalendarPreferences),s=a.enabled??!0,i=(c==null?void 0:c.accessToken)??null,h=(t==null?void 0:t.apiServiceUrl)??null,[g,S]=o.useState(!1),[b,C]=o.useState(!1),[f,j]=o.useState(!1),[T,x]=o.useState(null),[w,P]=o.useState(null),v=o.useRef(i);v.current=i,o.useEffect(()=>{P(null),x(null),S(!1),C(!1),j(!1)},[i]);const N=o.useCallback(async p=>{const r=V.parseCalendarPreferencesResponse(await p.json());if(!r.ok)throw new Error("Calendar preferences response is invalid");return r.value},[]),k=o.useCallback(async()=>{if(!s||!i||!h)return;const p=i;S(!0),x(null);try{const r=await fetch(`${h}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${i}`}});if(!r.ok){const y=await r.json().catch(()=>({}));throw new Error(y.error||"Failed to fetch preferences")}const n=await N(r);v.current===p&&P(n)}catch(r){v.current===p&&x(r instanceof Error?r.message:"Unknown error")}finally{v.current===p&&S(!1)}},[i,h,s,N]);o.useEffect(()=>{s&&k()},[s,k]);const E=o.useCallback(async p=>{if(!i||!h)return x("Not authenticated"),!1;const r=i;C(!0),x(null);try{const n=await fetch(`${h}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify(p)});if(!n.ok){const D=await n.json().catch(()=>({}));throw new Error(D.error||"Failed to update preferences")}const y=await N(n);return v.current!==r?!1:(P(y),m(y.resolved,y.sources),!0)}catch(n){return v.current===r&&x(n instanceof Error?n.message:"Unknown error"),!1}finally{v.current===r&&C(!1)}},[i,h,m,N]),A=o.useCallback(async()=>{if(!i||!h)return x("Not authenticated"),!1;const p=i;j(!0),x(null);try{const r=await fetch(`${h}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}});if(!r.ok){const y=await r.json().catch(()=>({}));throw new Error(y.error||"Failed to clear preferences")}const n=await N(r);return v.current!==p?!1:(P(n),m(n.resolved,n.sources),!0)}catch(r){return v.current===p&&x(r instanceof Error?r.message:"Unknown error"),!1}finally{v.current===p&&j(!1)}},[i,h,m,N]);return{preferences:w,isLoading:g,isSaving:b,isClearing:f,error:T,updatePreferences:E,clearPreferences:A,refetch:k}}const F=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],B=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],R="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function W(){try{const a=Intl;if(a.supportedValuesOf)return a.supportedValuesOf("timeZone")}catch{}return F.map(a=>a.value)}function H(a){if(!a)return"default";if(a.tz!==a.weekStart)return"inherited";switch(a.tz){case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"system_default":return"system";case"session_initial":return"embedded";default:return"default"}}function U(a){const c=F.find(t=>t.value===a);return c?c.label:a}function K(a){const c=B.find(t=>t.value===a);return c?c.label:String(a)}function J({active:a,onClose:c}){const{preferences:t,isLoading:m,isSaving:s,isClearing:i,updatePreferences:h,clearPreferences:g}=G({enabled:a}),S=l.useCalendarContext(),b=(t==null?void 0:t.resolved.tz)||(S==null?void 0:S.tz)||"UTC",C=(t==null?void 0:t.resolved.weekStart)??(S==null?void 0:S.weekStart)??1,[f,j]=o.useState((t==null?void 0:t.stored)===null),[T,x]=o.useState(!1),[w,P]=o.useState(b),[v,N]=o.useState(C),[k,E]=o.useState(!1),A=o.useMemo(()=>W(),[]),p=o.useMemo(()=>A.filter(d=>!F.some(M=>M.value===d)),[A]),r=o.useMemo(()=>U(w),[w]),n=t!=null&&t.inherited?U(t.inherited.tz):"UTC",y=t!=null&&t.inherited?K(t.inherited.weekStart):"Monday",D=H(t==null?void 0:t.inheritedSources);o.useEffect(()=>{if(!a){x(!1);return}T||(t&&j(t.stored===null),P(b),N(C))},[a,T,t,b,C]);const O=async()=>{if(m){l.ue.error("Preferences are still loading. Please try again.");return}f?await g()?(l.ue.success("Now using default settings."),c()):l.ue.error("Failed to save preferences. Please try again."):await h({tz:w,weekStart:v})?(l.ue.success("Preferences saved."),c()):l.ue.error("Failed to save preferences. Please try again.")},_=()=>{c()},z=s||i,$=z||m;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(l.RadioGroup,{value:f?"defaults":"custom",onValueChange:d=>{x(!0),j(d==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:u.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",f&&"bg-muted/50"),onClick:()=>{x(!0),j(!0)},children:[e.jsx(l.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",D," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[n,", week starts ",y]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:u.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!f&&"bg-muted/50"),onClick:()=>{x(!0),j(!1)},children:[e.jsx(l.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:u.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",f&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u.Label,{className:R,children:"Timezone"}),e.jsxs(u.Popover,{open:k,onOpenChange:E,modal:!0,children:[e.jsx(u.PopoverTrigger,{asChild:!0,children:e.jsxs(u.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":k,className:"w-full justify-between text-[12px] font-normal",disabled:f,children:[e.jsx("span",{className:"truncate",children:r}),e.jsx(l.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(u.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(l.Command,{className:"overflow-visible",children:[e.jsx(l.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(l.CommandList,{children:[e.jsx(l.CommandEmpty,{children:"No timezone found."}),e.jsx(l.CommandGroup,{heading:"Common",children:F.map(d=>e.jsxs(l.CommandItem,{value:`${d.value} ${d.label}`,onSelect:()=>{x(!0),P(d.value),E(!1)},children:[e.jsx(u.Check,{className:u.cn("h-3.5 w-3.5",w===d.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:d.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:d.value})]},d.value))}),e.jsx(l.CommandSeparator,{}),e.jsx(l.CommandGroup,{heading:"All timezones",children:p.map(d=>e.jsxs(l.CommandItem,{value:d,onSelect:()=>{x(!0),P(d),E(!1)},children:[e.jsx(u.Check,{className:u.cn("h-3.5 w-3.5",w===d?"opacity-100":"opacity-0")}),d]},d))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u.Label,{className:R,children:"Week starts on"}),e.jsx(l.RadioGroup,{value:String(v),onValueChange:d=>{x(!0),N(Number(d))},className:"flex gap-4",disabled:f,children:B.map(d=>e.jsxs("label",{htmlFor:`week-start-${d.value}`,className:u.cn("flex cursor-pointer items-center gap-2 text-[13px]",f&&"cursor-not-allowed"),children:[e.jsx(l.RadioGroupItem,{value:String(d.value),id:`week-start-${d.value}`,disabled:f}),d.label]},d.value))})]})]})]}),e.jsxs(l.DialogFooter,{children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:_,disabled:z,children:"Cancel"}),e.jsx(u.Button,{size:"xs",onClick:O,disabled:$,children:z?e.jsxs(e.Fragment,{children:[e.jsx(u.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})}function Y(a={}){const{authToken:c,tokenProps:t}=l.useSemaphorContext(),m=u.useDashboardStore(r=>r.actions.applyResolvedValueFormatPreferences),s=a.enabled??!0,i=(c==null?void 0:c.accessToken)??null,h=(t==null?void 0:t.apiServiceUrl)??null,g=o.useRef(i);g.current=i;const[S,b]=o.useState(null),[C,f]=o.useState(!1),[j,T]=o.useState(!1),[x,w]=o.useState(!1),[P,v]=o.useState(null);o.useEffect(()=>{b(null),v(null),f(!1),T(!1),w(!1)},[i]);const N=o.useCallback(async r=>{const n=L.parseValueFormatPreferencesResponse(await r.json());if(!n.ok)throw new Error("Value format preferences response is invalid");return n.value},[]),k=o.useCallback(async(r,n)=>{if(!i||!h)throw new Error("Not authenticated");const y=await fetch(`${h}/v1/user-preferences/value-format`,{method:r,headers:{Authorization:`Bearer ${i}`,...n?{"Content-Type":"application/json"}:{}},body:n?JSON.stringify(n):void 0});if(!y.ok){const D=await y.json().catch(()=>({}));throw new Error(D.error||"Failed to update preferences")}return N(y)},[i,h,N]),E=o.useCallback(async()=>{if(!s||!i||!h)return;const r=i;f(!0),v(null);try{const n=await k("GET");g.current===r&&b(n)}catch(n){g.current===r&&v(n instanceof Error?n.message:"Unknown error")}finally{g.current===r&&f(!1)}},[i,h,s,k]);o.useEffect(()=>{s&&E()},[s,E]);const A=o.useCallback(async r=>{const n=i;T(!0),v(null);try{const y=await k("PATCH",r);return g.current!==n?!1:(b(y),m(y.resolved,y.sources),!0)}catch(y){return g.current===n&&v(y instanceof Error?y.message:"Unknown error"),!1}finally{g.current===n&&T(!1)}},[i,m,k]),p=o.useCallback(async()=>{const r=i;w(!0),v(null);try{const n=await k("DELETE");return g.current!==r?!1:(b(n),m(n.resolved,n.sources),!0)}catch(n){return g.current===r&&v(n instanceof Error?n.message:"Unknown error"),!1}finally{g.current===r&&w(!1)}},[i,m,k]);return{preferences:S,isLoading:C,isSaving:j,isClearing:x,error:P,updatePreferences:A,clearPreferences:p,refetch:E}}const I=["locale","dateStyle","dateTime.dateStyle","dateTime.timeStyle","defaultCurrency"];function q(a,c){var t,m;switch(c){case"locale":return a==null?void 0:a.locale;case"dateStyle":return a==null?void 0:a.dateStyle;case"dateTime.dateStyle":return(t=a==null?void 0:a.dateTime)==null?void 0:t.dateStyle;case"dateTime.timeStyle":return(m=a==null?void 0:a.dateTime)==null?void 0:m.timeStyle;case"defaultCurrency":return a==null?void 0:a.defaultCurrency}}function Z(a){var m,s;const c=(m=a==null?void 0:a.dateTime)==null?void 0:m.dateStyle,t=(s=a==null?void 0:a.dateTime)==null?void 0:s.timeStyle;return{locale:a==null?void 0:a.locale,dateStyle:a==null?void 0:a.dateStyle,dateTime:c===void 0&&t===void 0?void 0:{dateStyle:c,timeStyle:t},defaultCurrency:a==null?void 0:a.defaultCurrency}}function Q({active:a,onClose:c}){var g,S,b,C,f,j,T;const{preferences:t,isLoading:m,isSaving:s,updatePreferences:i}=Y({enabled:a});if(!a)return null;if(!t)return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx("div",{className:"flex min-h-36 items-center justify-center text-[12px] text-muted-foreground",children:m?"Loading preferences…":"Preferences unavailable."})}),e.jsxs(l.DialogFooter,{className:"justify-between sm:justify-between",children:[e.jsx(u.Button,{variant:"ghost",size:"xs",disabled:!0,children:"Reset display formats"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:c,children:"Cancel"}),e.jsx(u.Button,{size:"xs",disabled:!0,children:"Save"})]})]})]});const h=[((g=t.stored)==null?void 0:g.locale)??"",((S=t.stored)==null?void 0:S.dateStyle)??"",((C=(b=t.stored)==null?void 0:b.dateTime)==null?void 0:C.dateStyle)??"",((j=(f=t.stored)==null?void 0:f.dateTime)==null?void 0:j.timeStyle)??"",((T=t.stored)==null?void 0:T.defaultCurrency)??""].join(":");return e.jsx(X,{preferences:t,isSaving:s,updatePreferences:i,onClose:c},h)}function X({preferences:a,isSaving:c,updatePreferences:t,onClose:m}){var b,C;const[s,i]=o.useState(()=>Z(a.stored)),h=(s.locale===void 0||L.canonicalizeSupportedLocale(s.locale)!==void 0)&&(s.defaultCurrency===void 0||L.canonicalizeSupportedCurrencyCode(s.defaultCurrency)!==void 0)&&(s.dateStyle===void 0||["short","medium","long"].includes(s.dateStyle))&&(((b=s.dateTime)==null?void 0:b.dateStyle)===void 0||["short","medium","long"].includes(s.dateTime.dateStyle))&&(((C=s.dateTime)==null?void 0:C.timeStyle)===void 0||["short","medium","long"].includes(s.dateTime.timeStyle)),g=async()=>{const f={...s.locale!==void 0?{locale:s.locale}:{},...s.dateStyle!==void 0?{dateStyle:s.dateStyle}:{},...s.dateTime?{dateTime:{...s.dateTime}}:{},...s.defaultCurrency!==void 0?{defaultCurrency:s.defaultCurrency}:{}},j=I.filter(w=>q(s,w)===void 0&&q(a.stored,w)!==void 0),T={...Object.keys(f).length>0?{set:f}:{},...j.length>0?{clear:j}:{}};(Object.keys(T).length===0?!0:await t(T))?(l.ue.success("Display format preferences saved."),m()):l.ue.error("Failed to save preferences. Please try again.")},S=async()=>{await t({clear:[...I]})?(l.ue.success("Display format preferences reset."),m()):l.ue.error("Failed to reset display format preferences. Please try again.")};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(l.DisplayFormatPreferencesFields,{value:s,inherited:a.inherited,inheritedSources:a.inheritedSources,onChange:i,disabled:c})}),e.jsxs(l.DialogFooter,{className:"justify-between sm:justify-between",children:[e.jsx(u.Button,{variant:"ghost",size:"xs",onClick:S,disabled:c||a.stored===null,children:"Reset display formats"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:m,disabled:c,children:"Cancel"}),e.jsx(u.Button,{size:"xs",onClick:g,disabled:c||!h,children:c?e.jsxs(e.Fragment,{children:[e.jsx(u.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})]})}function ee({open:a,onOpenChange:c}){const[t,m]=o.useState("display"),s=()=>c(!1);return e.jsx(l.Dialog,{open:a,onOpenChange:c,children:e.jsxs(l.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{className:"text-[15px]",children:"Report preferences"}),e.jsx(l.DialogDescription,{className:"text-[13px] leading-5",children:"Set how values and Calendar periods appear for you."})]}),e.jsxs(u.Tabs,{value:t,onValueChange:m,children:[e.jsxs(u.TabsList,{variant:"underline",className:"w-full justify-start",children:[e.jsx(u.TabsTrigger,{value:"display",children:"Display formats"}),e.jsx(u.TabsTrigger,{value:"calendar",children:"Calendar"})]}),e.jsx(u.TabsContent,{value:"display",children:e.jsx(Q,{active:a&&t==="display",onClose:s})}),e.jsx(u.TabsContent,{value:"calendar",children:e.jsx(J,{active:a&&t==="calendar",onClose:s})})]})]})})}exports.ReportPreferencesDialog=ee;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),l=require("./index-DKaQRhKm.cjs"),u=require("./switch-DyE2_OmQ.cjs"),V=require("./report-runtime-context-CLtzrZdC.cjs");require("./x-B6ghREd2.cjs");require("./saved-temporal-bucket-format-Ca4hUfTo.cjs");require("./validators-DO-YuzgO.cjs");require("./analyze-result-contract-CMwVg9w2.cjs");const L=require("../value-format-preferences/index.cjs");function G(a={}){const{authToken:c,tokenProps:t}=l.useSemaphorContext(),m=u.useDashboardStore(p=>p.actions.applyResolvedCalendarPreferences),s=a.enabled??!0,i=(c==null?void 0:c.accessToken)??null,h=(t==null?void 0:t.apiServiceUrl)??null,[g,S]=o.useState(!1),[b,C]=o.useState(!1),[f,j]=o.useState(!1),[T,x]=o.useState(null),[w,P]=o.useState(null),v=o.useRef(i);v.current=i,o.useEffect(()=>{P(null),x(null),S(!1),C(!1),j(!1)},[i]);const N=o.useCallback(async p=>{const r=V.parseCalendarPreferencesResponse(await p.json());if(!r.ok)throw new Error("Calendar preferences response is invalid");return r.value},[]),k=o.useCallback(async()=>{if(!s||!i||!h)return;const p=i;S(!0),x(null);try{const r=await fetch(`${h}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${i}`}});if(!r.ok){const y=await r.json().catch(()=>({}));throw new Error(y.error||"Failed to fetch preferences")}const n=await N(r);v.current===p&&P(n)}catch(r){v.current===p&&x(r instanceof Error?r.message:"Unknown error")}finally{v.current===p&&S(!1)}},[i,h,s,N]);o.useEffect(()=>{s&&k()},[s,k]);const E=o.useCallback(async p=>{if(!i||!h)return x("Not authenticated"),!1;const r=i;C(!0),x(null);try{const n=await fetch(`${h}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify(p)});if(!n.ok){const D=await n.json().catch(()=>({}));throw new Error(D.error||"Failed to update preferences")}const y=await N(n);return v.current!==r?!1:(P(y),m(y.resolved,y.sources),!0)}catch(n){return v.current===r&&x(n instanceof Error?n.message:"Unknown error"),!1}finally{v.current===r&&C(!1)}},[i,h,m,N]),A=o.useCallback(async()=>{if(!i||!h)return x("Not authenticated"),!1;const p=i;j(!0),x(null);try{const r=await fetch(`${h}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}});if(!r.ok){const y=await r.json().catch(()=>({}));throw new Error(y.error||"Failed to clear preferences")}const n=await N(r);return v.current!==p?!1:(P(n),m(n.resolved,n.sources),!0)}catch(r){return v.current===p&&x(r instanceof Error?r.message:"Unknown error"),!1}finally{v.current===p&&j(!1)}},[i,h,m,N]);return{preferences:w,isLoading:g,isSaving:b,isClearing:f,error:T,updatePreferences:E,clearPreferences:A,refetch:k}}const F=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],B=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],R="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function W(){try{const a=Intl;if(a.supportedValuesOf)return a.supportedValuesOf("timeZone")}catch{}return F.map(a=>a.value)}function H(a){if(!a)return"default";if(a.tz!==a.weekStart)return"inherited";switch(a.tz){case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"system_default":return"system";case"session_initial":return"embedded";default:return"default"}}function U(a){const c=F.find(t=>t.value===a);return c?c.label:a}function K(a){const c=B.find(t=>t.value===a);return c?c.label:String(a)}function J({active:a,onClose:c}){const{preferences:t,isLoading:m,isSaving:s,isClearing:i,updatePreferences:h,clearPreferences:g}=G({enabled:a}),S=l.useCalendarContext(),b=(t==null?void 0:t.resolved.tz)||(S==null?void 0:S.tz)||"UTC",C=(t==null?void 0:t.resolved.weekStart)??(S==null?void 0:S.weekStart)??1,[f,j]=o.useState((t==null?void 0:t.stored)===null),[T,x]=o.useState(!1),[w,P]=o.useState(b),[v,N]=o.useState(C),[k,E]=o.useState(!1),A=o.useMemo(()=>W(),[]),p=o.useMemo(()=>A.filter(d=>!F.some(M=>M.value===d)),[A]),r=o.useMemo(()=>U(w),[w]),n=t!=null&&t.inherited?U(t.inherited.tz):"UTC",y=t!=null&&t.inherited?K(t.inherited.weekStart):"Monday",D=H(t==null?void 0:t.inheritedSources);o.useEffect(()=>{if(!a){x(!1);return}T||(t&&j(t.stored===null),P(b),N(C))},[a,T,t,b,C]);const O=async()=>{if(m){l.ue.error("Preferences are still loading. Please try again.");return}f?await g()?(l.ue.success("Now using default settings."),c()):l.ue.error("Failed to save preferences. Please try again."):await h({tz:w,weekStart:v})?(l.ue.success("Preferences saved."),c()):l.ue.error("Failed to save preferences. Please try again.")},_=()=>{c()},z=s||i,$=z||m;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(l.RadioGroup,{value:f?"defaults":"custom",onValueChange:d=>{x(!0),j(d==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:u.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",f&&"bg-muted/50"),onClick:()=>{x(!0),j(!0)},children:[e.jsx(l.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",D," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[n,", week starts ",y]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:u.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!f&&"bg-muted/50"),onClick:()=>{x(!0),j(!1)},children:[e.jsx(l.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:u.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",f&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u.Label,{className:R,children:"Timezone"}),e.jsxs(u.Popover,{open:k,onOpenChange:E,modal:!0,children:[e.jsx(u.PopoverTrigger,{asChild:!0,children:e.jsxs(u.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":k,className:"w-full justify-between text-[12px] font-normal",disabled:f,children:[e.jsx("span",{className:"truncate",children:r}),e.jsx(l.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(u.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(l.Command,{className:"overflow-visible",children:[e.jsx(l.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(l.CommandList,{children:[e.jsx(l.CommandEmpty,{children:"No timezone found."}),e.jsx(l.CommandGroup,{heading:"Common",children:F.map(d=>e.jsxs(l.CommandItem,{value:`${d.value} ${d.label}`,onSelect:()=>{x(!0),P(d.value),E(!1)},children:[e.jsx(u.Check,{className:u.cn("h-3.5 w-3.5",w===d.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:d.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:d.value})]},d.value))}),e.jsx(l.CommandSeparator,{}),e.jsx(l.CommandGroup,{heading:"All timezones",children:p.map(d=>e.jsxs(l.CommandItem,{value:d,onSelect:()=>{x(!0),P(d),E(!1)},children:[e.jsx(u.Check,{className:u.cn("h-3.5 w-3.5",w===d?"opacity-100":"opacity-0")}),d]},d))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u.Label,{className:R,children:"Week starts on"}),e.jsx(l.RadioGroup,{value:String(v),onValueChange:d=>{x(!0),N(Number(d))},className:"flex gap-4",disabled:f,children:B.map(d=>e.jsxs("label",{htmlFor:`week-start-${d.value}`,className:u.cn("flex cursor-pointer items-center gap-2 text-[13px]",f&&"cursor-not-allowed"),children:[e.jsx(l.RadioGroupItem,{value:String(d.value),id:`week-start-${d.value}`,disabled:f}),d.label]},d.value))})]})]})]}),e.jsxs(l.DialogFooter,{children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:_,disabled:z,children:"Cancel"}),e.jsx(u.Button,{size:"xs",onClick:O,disabled:$,children:z?e.jsxs(e.Fragment,{children:[e.jsx(u.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})}function Y(a={}){const{authToken:c,tokenProps:t}=l.useSemaphorContext(),m=u.useDashboardStore(r=>r.actions.applyResolvedValueFormatPreferences),s=a.enabled??!0,i=(c==null?void 0:c.accessToken)??null,h=(t==null?void 0:t.apiServiceUrl)??null,g=o.useRef(i);g.current=i;const[S,b]=o.useState(null),[C,f]=o.useState(!1),[j,T]=o.useState(!1),[x,w]=o.useState(!1),[P,v]=o.useState(null);o.useEffect(()=>{b(null),v(null),f(!1),T(!1),w(!1)},[i]);const N=o.useCallback(async r=>{const n=L.parseValueFormatPreferencesResponse(await r.json());if(!n.ok)throw new Error("Value format preferences response is invalid");return n.value},[]),k=o.useCallback(async(r,n)=>{if(!i||!h)throw new Error("Not authenticated");const y=await fetch(`${h}/v1/user-preferences/value-format`,{method:r,headers:{Authorization:`Bearer ${i}`,...n?{"Content-Type":"application/json"}:{}},body:n?JSON.stringify(n):void 0});if(!y.ok){const D=await y.json().catch(()=>({}));throw new Error(D.error||"Failed to update preferences")}return N(y)},[i,h,N]),E=o.useCallback(async()=>{if(!s||!i||!h)return;const r=i;f(!0),v(null);try{const n=await k("GET");g.current===r&&b(n)}catch(n){g.current===r&&v(n instanceof Error?n.message:"Unknown error")}finally{g.current===r&&f(!1)}},[i,h,s,k]);o.useEffect(()=>{s&&E()},[s,E]);const A=o.useCallback(async r=>{const n=i;T(!0),v(null);try{const y=await k("PATCH",r);return g.current!==n?!1:(b(y),m(y.resolved,y.sources),!0)}catch(y){return g.current===n&&v(y instanceof Error?y.message:"Unknown error"),!1}finally{g.current===n&&T(!1)}},[i,m,k]),p=o.useCallback(async()=>{const r=i;w(!0),v(null);try{const n=await k("DELETE");return g.current!==r?!1:(b(n),m(n.resolved,n.sources),!0)}catch(n){return g.current===r&&v(n instanceof Error?n.message:"Unknown error"),!1}finally{g.current===r&&w(!1)}},[i,m,k]);return{preferences:S,isLoading:C,isSaving:j,isClearing:x,error:P,updatePreferences:A,clearPreferences:p,refetch:E}}const I=["locale","dateStyle","dateTime.dateStyle","dateTime.timeStyle","defaultCurrency"];function q(a,c){var t,m;switch(c){case"locale":return a==null?void 0:a.locale;case"dateStyle":return a==null?void 0:a.dateStyle;case"dateTime.dateStyle":return(t=a==null?void 0:a.dateTime)==null?void 0:t.dateStyle;case"dateTime.timeStyle":return(m=a==null?void 0:a.dateTime)==null?void 0:m.timeStyle;case"defaultCurrency":return a==null?void 0:a.defaultCurrency}}function Z(a){var m,s;const c=(m=a==null?void 0:a.dateTime)==null?void 0:m.dateStyle,t=(s=a==null?void 0:a.dateTime)==null?void 0:s.timeStyle;return{locale:a==null?void 0:a.locale,dateStyle:a==null?void 0:a.dateStyle,dateTime:c===void 0&&t===void 0?void 0:{dateStyle:c,timeStyle:t},defaultCurrency:a==null?void 0:a.defaultCurrency}}function Q({active:a,onClose:c}){var g,S,b,C,f,j,T;const{preferences:t,isLoading:m,isSaving:s,updatePreferences:i}=Y({enabled:a});if(!a)return null;if(!t)return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx("div",{className:"flex min-h-36 items-center justify-center text-[12px] text-muted-foreground",children:m?"Loading preferences…":"Preferences unavailable."})}),e.jsxs(l.DialogFooter,{className:"justify-between sm:justify-between",children:[e.jsx(u.Button,{variant:"ghost",size:"xs",disabled:!0,children:"Reset display formats"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:c,children:"Cancel"}),e.jsx(u.Button,{size:"xs",disabled:!0,children:"Save"})]})]})]});const h=[((g=t.stored)==null?void 0:g.locale)??"",((S=t.stored)==null?void 0:S.dateStyle)??"",((C=(b=t.stored)==null?void 0:b.dateTime)==null?void 0:C.dateStyle)??"",((j=(f=t.stored)==null?void 0:f.dateTime)==null?void 0:j.timeStyle)??"",((T=t.stored)==null?void 0:T.defaultCurrency)??""].join(":");return e.jsx(X,{preferences:t,isSaving:s,updatePreferences:i,onClose:c},h)}function X({preferences:a,isSaving:c,updatePreferences:t,onClose:m}){var b,C;const[s,i]=o.useState(()=>Z(a.stored)),h=(s.locale===void 0||L.canonicalizeSupportedLocale(s.locale)!==void 0)&&(s.defaultCurrency===void 0||L.canonicalizeSupportedCurrencyCode(s.defaultCurrency)!==void 0)&&(s.dateStyle===void 0||["short","medium","long"].includes(s.dateStyle))&&(((b=s.dateTime)==null?void 0:b.dateStyle)===void 0||["short","medium","long"].includes(s.dateTime.dateStyle))&&(((C=s.dateTime)==null?void 0:C.timeStyle)===void 0||["short","medium","long"].includes(s.dateTime.timeStyle)),g=async()=>{const f={...s.locale!==void 0?{locale:s.locale}:{},...s.dateStyle!==void 0?{dateStyle:s.dateStyle}:{},...s.dateTime?{dateTime:{...s.dateTime}}:{},...s.defaultCurrency!==void 0?{defaultCurrency:s.defaultCurrency}:{}},j=I.filter(w=>q(s,w)===void 0&&q(a.stored,w)!==void 0),T={...Object.keys(f).length>0?{set:f}:{},...j.length>0?{clear:j}:{}};(Object.keys(T).length===0?!0:await t(T))?(l.ue.success("Display format preferences saved."),m()):l.ue.error("Failed to save preferences. Please try again.")},S=async()=>{await t({clear:[...I]})?(l.ue.success("Display format preferences reset."),m()):l.ue.error("Failed to reset display format preferences. Please try again.")};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(l.DisplayFormatPreferencesFields,{value:s,inherited:a.inherited,inheritedSources:a.inheritedSources,onChange:i,disabled:c})}),e.jsxs(l.DialogFooter,{className:"justify-between sm:justify-between",children:[e.jsx(u.Button,{variant:"ghost",size:"xs",onClick:S,disabled:c||a.stored===null,children:"Reset display formats"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:m,disabled:c,children:"Cancel"}),e.jsx(u.Button,{size:"xs",onClick:g,disabled:c||!h,children:c?e.jsxs(e.Fragment,{children:[e.jsx(u.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})]})}function ee({open:a,onOpenChange:c}){const[t,m]=o.useState("display"),s=()=>c(!1);return e.jsx(l.Dialog,{open:a,onOpenChange:c,children:e.jsxs(l.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{className:"text-[15px]",children:"Report preferences"}),e.jsx(l.DialogDescription,{className:"text-[13px] leading-5",children:"Set how values and Calendar periods appear for you."})]}),e.jsxs(u.Tabs,{value:t,onValueChange:m,children:[e.jsxs(u.TabsList,{variant:"underline",className:"w-full justify-start",children:[e.jsx(u.TabsTrigger,{value:"display",children:"Display formats"}),e.jsx(u.TabsTrigger,{value:"calendar",children:"Calendar"})]}),e.jsx(u.TabsContent,{value:"display",children:e.jsx(Q,{active:a&&t==="display",onClose:s})}),e.jsx(u.TabsContent,{value:"calendar",children:e.jsx(J,{active:a&&t==="calendar",onClose:s})})]})]})})}exports.ReportPreferencesDialog=ee;
|
package/dist/chunks/{report-preferences-dialog-CZPqG-em.js → report-preferences-dialog-D-NDYRrk.js}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as o, Fragment as j, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import oe, { useState as S, useRef as X, useEffect as U, useCallback as E, useMemo as _ } from "react";
|
|
3
|
-
import { az as ee, aA as ce, aB as B, aC as $, aD as de, h as ue, i as me, j as fe, k as he, l as M, m as H, aE as ve, aF as V, aG as z, b as ye, aH as pe, aI as ge, aJ as Se, aK as be, aL as Te } from "./index-
|
|
4
|
-
import { u as ae, c as F, O as W, P as we, a as Ce, B as L, b as ke, d as q, L as te, T as xe, F as Ne, G, I as K } from "./switch-
|
|
5
|
-
import { a as Pe } from "./report-runtime-context-
|
|
3
|
+
import { az as ee, aA as ce, aB as B, aC as $, aD as de, h as ue, i as me, j as fe, k as he, l as M, m as H, aE as ve, aF as V, aG as z, b as ye, aH as pe, aI as ge, aJ as Se, aK as be, aL as Te } from "./index-8Cm77joZ.js";
|
|
4
|
+
import { u as ae, c as F, O as W, P as we, a as Ce, B as L, b as ke, d as q, L as te, T as xe, F as Ne, G, I as K } from "./switch-BagpmPNw.js";
|
|
5
|
+
import { a as Pe } from "./report-runtime-context-CcXUjpb-.js";
|
|
6
6
|
import "./x-CXDkqdur.js";
|
|
7
|
-
import "./saved-temporal-bucket-format-
|
|
8
|
-
import "./validators-
|
|
9
|
-
import "./analyze-result-contract-
|
|
7
|
+
import "./saved-temporal-bucket-format-hylaofsQ.js";
|
|
8
|
+
import "./validators-DhTaCK1O.js";
|
|
9
|
+
import "./analyze-result-contract-kaCNxjA7.js";
|
|
10
10
|
import { parseValueFormatPreferencesResponse as Ae, canonicalizeSupportedLocale as Ee, canonicalizeSupportedCurrencyCode as ze } from "../value-format-preferences/index.js";
|
|
11
11
|
function Le(e = {}) {
|
|
12
12
|
const { authToken: i, tokenProps: a } = ee(), d = ae(
|
package/dist/chunks/{report-runtime-context-CrTzKt0C.js → report-runtime-context-CcXUjpb-.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseValueFormatPreferences as _, isReportPreferenceSource as C } from "../value-format-preferences/index.js";
|
|
2
|
-
import { b as k,
|
|
2
|
+
import { b as k, g } from "./validators-DhTaCK1O.js";
|
|
3
3
|
const M = {
|
|
4
4
|
tz: "UTC",
|
|
5
5
|
weekStart: 1,
|
|
@@ -170,7 +170,7 @@ function l(e, a, r) {
|
|
|
170
170
|
}
|
|
171
171
|
return e;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function h(e, a) {
|
|
174
174
|
if (!o(e))
|
|
175
175
|
return {
|
|
176
176
|
ok: !1,
|
|
@@ -205,10 +205,10 @@ function D(e) {
|
|
|
205
205
|
e.inherited,
|
|
206
206
|
"inherited",
|
|
207
207
|
!1
|
|
208
|
-
), s =
|
|
208
|
+
), s = h(
|
|
209
209
|
e.inheritedSources,
|
|
210
210
|
"inheritedSources"
|
|
211
|
-
), c = d(e.resolved, "resolved", !1), i =
|
|
211
|
+
), c = d(e.resolved, "resolved", !1), i = h(e.sources, "sources");
|
|
212
212
|
for (const u of [r, t, s, c, i])
|
|
213
213
|
u.ok || a.push(...u.issues);
|
|
214
214
|
return a.length || !r.ok || !t.ok || !s.ok || !c.ok || !i.ok ? { ok: !1, issues: a } : {
|
|
@@ -293,12 +293,12 @@ function j(e) {
|
|
|
293
293
|
s.timeStyle,
|
|
294
294
|
"preferenceSources.valueFormat.dateTime.timeStyle",
|
|
295
295
|
a
|
|
296
|
-
) : void 0,
|
|
296
|
+
) : void 0, v = l(
|
|
297
297
|
t.defaultCurrency,
|
|
298
298
|
"preferenceSources.valueFormat.defaultCurrency",
|
|
299
299
|
a
|
|
300
300
|
);
|
|
301
|
-
return a.length || !c || !i || !u || !f || !m || !S || !
|
|
301
|
+
return a.length || !c || !i || !u || !f || !m || !S || !v ? { ok: !1, issues: a } : {
|
|
302
302
|
ok: !0,
|
|
303
303
|
value: {
|
|
304
304
|
calendar: {
|
|
@@ -312,7 +312,7 @@ function j(e) {
|
|
|
312
312
|
dateStyle: m,
|
|
313
313
|
timeStyle: S
|
|
314
314
|
},
|
|
315
|
-
defaultCurrency:
|
|
315
|
+
defaultCurrency: v
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { S as P, a as k } from "./color-CJvdlFM_.js";
|
|
2
|
-
import {
|
|
3
|
-
import "./analyze-result-contract-
|
|
2
|
+
import { N as R, al as v, l as O, E as D } from "./validators-DhTaCK1O.js";
|
|
3
|
+
import "./analyze-result-contract-kaCNxjA7.js";
|
|
4
4
|
import "../value-format-preferences/index.js";
|
|
5
|
-
import { A as g } from "./temporal-bucket-authoring-
|
|
5
|
+
import { A as g } from "./temporal-bucket-authoring-DjPFtRSF.js";
|
|
6
6
|
var te = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
7
7
|
function U(e) {
|
|
8
8
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
@@ -33,11 +33,11 @@ function G() {
|
|
|
33
33
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
34
34
|
return y(I);
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const s = [];
|
|
37
37
|
for (let e = 0; e < 256; ++e)
|
|
38
|
-
|
|
38
|
+
s.push((e + 256).toString(16).slice(1));
|
|
39
39
|
function L(e, r = 0) {
|
|
40
|
-
return
|
|
40
|
+
return s[e[r + 0]] + s[e[r + 1]] + s[e[r + 2]] + s[e[r + 3]] + "-" + s[e[r + 4]] + s[e[r + 5]] + "-" + s[e[r + 6]] + s[e[r + 7]] + "-" + s[e[r + 8]] + s[e[r + 9]] + "-" + s[e[r + 10]] + s[e[r + 11]] + s[e[r + 12]] + s[e[r + 13]] + s[e[r + 14]] + s[e[r + 15]];
|
|
41
41
|
}
|
|
42
42
|
const W = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), E = {
|
|
43
43
|
randomUUID: W
|
|
@@ -54,7 +54,7 @@ var T = {}, B = {}, A = { exports: {} }, o = String, S = function() {
|
|
|
54
54
|
};
|
|
55
55
|
A.exports = S();
|
|
56
56
|
A.exports.createColors = S;
|
|
57
|
-
var
|
|
57
|
+
var N = A.exports;
|
|
58
58
|
(function(e) {
|
|
59
59
|
Object.defineProperty(e, "__esModule", {
|
|
60
60
|
value: !0
|
|
@@ -67,13 +67,13 @@ var j = A.exports;
|
|
|
67
67
|
}
|
|
68
68
|
r(e, {
|
|
69
69
|
dim: function() {
|
|
70
|
-
return
|
|
70
|
+
return l;
|
|
71
71
|
},
|
|
72
72
|
default: function() {
|
|
73
73
|
return c;
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
|
-
const a = /* @__PURE__ */ t(
|
|
76
|
+
const a = /* @__PURE__ */ t(N);
|
|
77
77
|
function t(f) {
|
|
78
78
|
return f && f.__esModule ? f : {
|
|
79
79
|
default: f
|
|
@@ -83,7 +83,7 @@ var j = A.exports;
|
|
|
83
83
|
function n(f, u, p) {
|
|
84
84
|
typeof process < "u" && process.env.JEST_WORKER_ID || p && d.has(p) || (p && d.add(p), console.warn(""), u.forEach((b) => console.warn(f, "-", b)));
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function l(f) {
|
|
87
87
|
return a.default.dim(f);
|
|
88
88
|
}
|
|
89
89
|
const c = {
|
|
@@ -128,9 +128,9 @@ var j = A.exports;
|
|
|
128
128
|
default: n
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
-
function t({ version: n, from:
|
|
132
|
-
r.default.warn(`${
|
|
133
|
-
`As of Tailwind CSS ${n}, \`${
|
|
131
|
+
function t({ version: n, from: l, to: c }) {
|
|
132
|
+
r.default.warn(`${l}-color-renamed`, [
|
|
133
|
+
`As of Tailwind CSS ${n}, \`${l}\` has been renamed to \`${c}\`.`,
|
|
134
134
|
"Update your configuration file to silence this warning."
|
|
135
135
|
]);
|
|
136
136
|
}
|
|
@@ -464,10 +464,10 @@ var j = A.exports;
|
|
|
464
464
|
};
|
|
465
465
|
})(T);
|
|
466
466
|
let _ = T;
|
|
467
|
-
var
|
|
468
|
-
const i = /* @__PURE__ */ U(
|
|
467
|
+
var j = (_.__esModule ? _ : { default: _ }).default;
|
|
468
|
+
const i = /* @__PURE__ */ U(j), q = ".semaphor-scope";
|
|
469
469
|
function V(e) {
|
|
470
|
-
return e ? e.closest(
|
|
470
|
+
return e ? e.closest(q) : null;
|
|
471
471
|
}
|
|
472
472
|
function Q(e) {
|
|
473
473
|
if (!e) return "light";
|
|
@@ -478,7 +478,7 @@ const fe = !1, de = [
|
|
|
478
478
|
"table",
|
|
479
479
|
"view",
|
|
480
480
|
"materialized view"
|
|
481
|
-
], ie = ["_forecast"],
|
|
481
|
+
], ie = ["_forecast"], le = "dm", se = "semaphor_calculated_fields", ce = "calculated_fields", ue = ["lg", "md", "sm", "xs", "xxs"], pe = {
|
|
482
482
|
// dashboardHeader: ' font-mono border-b-2 border-red-700',
|
|
483
483
|
default: {
|
|
484
484
|
dashboardPanel: "",
|
|
@@ -714,8 +714,8 @@ const fe = !1, de = [
|
|
|
714
714
|
}
|
|
715
715
|
};
|
|
716
716
|
function F(e) {
|
|
717
|
-
var t, d, n,
|
|
718
|
-
const r = (c = (
|
|
717
|
+
var t, d, n, l, c, f, u, p, b;
|
|
718
|
+
const r = (c = (l = (n = (d = (t = e == null ? void 0 : e.chart) == null ? void 0 : t.config) == null ? void 0 : d._config) == null ? void 0 : n.options) == null ? void 0 : l.plugins) == null ? void 0 : c.datalabels;
|
|
719
719
|
let a = (f = e == null ? void 0 : e.dataset) == null ? void 0 : f.backgroundColor;
|
|
720
720
|
return (r == null ? void 0 : r.align) === "end" && (r == null ? void 0 : r.anchor) === "end" && (a = C((u = e == null ? void 0 : e.chart) == null ? void 0 : u.canvas)), (r == null ? void 0 : r.align) === "start" && (r == null ? void 0 : r.anchor) === "start" && (a = C((p = e == null ? void 0 : e.chart) == null ? void 0 : p.canvas)), $(a, {
|
|
721
721
|
baseColor: C((b = e == null ? void 0 : e.chart) == null ? void 0 : b.canvas)
|
|
@@ -738,11 +738,11 @@ function C(e) {
|
|
|
738
738
|
}
|
|
739
739
|
function $(e, r = {}) {
|
|
740
740
|
let a = 0, t = 0, d = 0, n = 0;
|
|
741
|
-
const
|
|
741
|
+
const l = r.baseColor ? k(r.baseColor) : null, c = (m) => {
|
|
742
742
|
if (!m) return i.gray[500];
|
|
743
743
|
const w = k(m);
|
|
744
744
|
if (!w) return i.gray[500];
|
|
745
|
-
const h = M(w,
|
|
745
|
+
const h = M(w, l);
|
|
746
746
|
a += h.r, t += h.g, d += h.b, n++;
|
|
747
747
|
};
|
|
748
748
|
if (Array.isArray(e) ? e.forEach((m) => {
|
|
@@ -772,10 +772,10 @@ function K(e) {
|
|
|
772
772
|
return !!(r || a || t || d);
|
|
773
773
|
}
|
|
774
774
|
function ge(e, r) {
|
|
775
|
-
var n,
|
|
775
|
+
var n, l, c;
|
|
776
776
|
if (r != null && r.skipSetupCheck || e.type === "text" || (n = e.customCardPreferences) != null && n.url)
|
|
777
777
|
return !1;
|
|
778
|
-
const a = !!(e.connectionId || (
|
|
778
|
+
const a = !!(e.connectionId || (l = e.dataSource) != null && l.connectionId), t = !!((c = e.sql) != null && c.trim()), d = K(e.config);
|
|
779
779
|
return !a || !d && !t;
|
|
780
780
|
}
|
|
781
781
|
function be(e) {
|
|
@@ -869,15 +869,15 @@ function me(e) {
|
|
|
869
869
|
};
|
|
870
870
|
let a, t, d;
|
|
871
871
|
if (e.format !== void 0 && e.format !== null) {
|
|
872
|
-
const
|
|
873
|
-
if (!
|
|
872
|
+
const l = R.safeParse(e.format);
|
|
873
|
+
if (!l.success)
|
|
874
874
|
a = g, t = "unsupported_pattern";
|
|
875
875
|
else {
|
|
876
876
|
const c = v(
|
|
877
|
-
|
|
877
|
+
l.data,
|
|
878
878
|
r.granularity
|
|
879
879
|
);
|
|
880
|
-
a = c.ok ?
|
|
880
|
+
a = c.ok ? l.data : g, c.ok || (t = c.code === "invalid_temporal_bucket_pattern" ? "unsupported_pattern" : "grain_incompatible_pattern", d = l.data.presentation.mode === "pattern" ? l.data.presentation.pattern : l.data.presentation.mode === "preset" ? l.data.presentation.preset : void 0);
|
|
881
881
|
}
|
|
882
882
|
} else
|
|
883
883
|
({ format: a, repairCode: t, ignoredPattern: d } = J(
|
|
@@ -901,7 +901,7 @@ function me(e) {
|
|
|
901
901
|
export {
|
|
902
902
|
ue as B,
|
|
903
903
|
ce as C,
|
|
904
|
-
|
|
904
|
+
le as D,
|
|
905
905
|
ie as M,
|
|
906
906
|
be as a,
|
|
907
907
|
fe as b,
|
|
@@ -916,7 +916,7 @@ export {
|
|
|
916
916
|
te as k,
|
|
917
917
|
oe as l,
|
|
918
918
|
F as m,
|
|
919
|
-
|
|
919
|
+
se as n,
|
|
920
920
|
me as r,
|
|
921
921
|
ne as v
|
|
922
922
|
};
|
|
@@ -2,23 +2,23 @@ import { j as mp, c as je, C as Rl } from "./x-CXDkqdur.js";
|
|
|
2
2
|
import { jsx as w, jsxs as be, Fragment as Yn } from "react/jsx-runtime";
|
|
3
3
|
import * as p from "react";
|
|
4
4
|
import Ce, { useLayoutEffect as gp, useState as yp, forwardRef as bp, useRef as qa, useMemo as vp, useId as Cp, useImperativeHandle as Sp } from "react";
|
|
5
|
-
import { e as _l, v as st, D as _r, B as Wi, f as Ip, h as Pl, r as wp, j as Ha, k as De } from "./saved-temporal-bucket-format-
|
|
6
|
-
import {
|
|
7
|
-
import "./analyze-result-contract-
|
|
5
|
+
import { e as _l, v as st, D as _r, B as Wi, f as Ip, h as Pl, r as wp, j as Ha, k as De } from "./saved-temporal-bucket-format-hylaofsQ.js";
|
|
6
|
+
import { E as Ke, N as Ol, l as xp, ap as Ep, h as Pr, ah as Vn, B as Wa } from "./validators-DhTaCK1O.js";
|
|
7
|
+
import "./analyze-result-contract-kaCNxjA7.js";
|
|
8
8
|
import "../value-format-preferences/index.js";
|
|
9
9
|
import * as Xr from "react-dom";
|
|
10
10
|
import Tp from "react-dom";
|
|
11
11
|
import { u as Fp } from "./appearance-context-DVXt8qjW.js";
|
|
12
12
|
import "react-dom/client";
|
|
13
|
-
import { D as Dp } from "./temporal-bucket-
|
|
14
|
-
import { b as Ap } from "./report-runtime-context-
|
|
13
|
+
import { D as Dp } from "./temporal-bucket-Cc9fmx8s.js";
|
|
14
|
+
import { b as Ap } from "./report-runtime-context-CcXUjpb-.js";
|
|
15
15
|
import { createFrameLayouts as Rp } from "../layouts/index.js";
|
|
16
16
|
import { t as Gi, c as Or, h as _p, j as Pp, f as Qr, k as Op, i as Zr } from "./format-types-CFHQoIuk.js";
|
|
17
17
|
import { f as Dt } from "./index-CACdoqu3.js";
|
|
18
|
-
import { a as Mp } from "./temporal-bucket-authoring-
|
|
19
|
-
import { o as Ml, l as kl, n as Nl, b as Jr, e as Vl, d as Yi, h as kp, r as Ga, g as Np, j as Vp } from "./dashboard-filter-value-compatibility-
|
|
20
|
-
import { a as Ya, C as Ll } from "./common-types-
|
|
21
|
-
import { s as Lp, e as Bp, i as $p, a as Up, q as Ki, r as ci, f as Bl, g as Kn } from "./dashboard-input-contract-
|
|
18
|
+
import { a as Mp } from "./temporal-bucket-authoring-DjPFtRSF.js";
|
|
19
|
+
import { o as Ml, l as kl, n as Nl, b as Jr, e as Vl, d as Yi, h as kp, r as Ga, g as Np, j as Vp } from "./dashboard-filter-value-compatibility-Ce7jUVh-.js";
|
|
20
|
+
import { a as Ya, C as Ll } from "./common-types-BgI-ymBp.js";
|
|
21
|
+
import { s as Lp, e as Bp, i as $p, a as Up, q as Ki, r as ci, f as Bl, g as Kn } from "./dashboard-input-contract-Ciboc347.js";
|
|
22
22
|
const Ka = (e) => {
|
|
23
23
|
let n;
|
|
24
24
|
const t = /* @__PURE__ */ new Set(), r = (c, d) => {
|
|
@@ -3952,6 +3952,21 @@ const Ie = sn()(
|
|
|
3952
3952
|
getFileAttachments: e.actions.getFileAttachments
|
|
3953
3953
|
}))
|
|
3954
3954
|
), nT = {}, ms = {}, Xm = (e) => ({
|
|
3955
|
+
updateEnableDevModePagination: (n) => e((t) => {
|
|
3956
|
+
var r, o, i;
|
|
3957
|
+
return {
|
|
3958
|
+
card: {
|
|
3959
|
+
...t.card,
|
|
3960
|
+
preferences: {
|
|
3961
|
+
...(r = t.card) == null ? void 0 : r.preferences,
|
|
3962
|
+
tablePrefs: {
|
|
3963
|
+
...(i = (o = t.card) == null ? void 0 : o.preferences) == null ? void 0 : i.tablePrefs,
|
|
3964
|
+
enableDevModePagination: n
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
};
|
|
3969
|
+
}),
|
|
3955
3970
|
// Update page size
|
|
3956
3971
|
updatePageSize: (n) => e((t) => {
|
|
3957
3972
|
var r, o, i;
|