react-semaphor 0.1.453 → 0.1.455
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 +100 -99
- 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-GHKFwThg.js → analyze-result-contract-BbRJ-C06.js} +1 -1
- package/dist/chunks/{analyze-result-contract-Dxw66nUG.cjs → analyze-result-contract-LPDNldic.cjs} +1 -1
- package/dist/chunks/canonical-result-keys-BA0HCP4e.cjs +1 -0
- package/dist/chunks/{canonical-result-keys-KLk__J_O.js → canonical-result-keys-D6avdjpA.js} +14 -13
- package/dist/chunks/{common-types-Ci66eflG.cjs → common-types-C57kJ59w.cjs} +1 -1
- package/dist/chunks/{common-types-F6qk6PPS.js → common-types-H51FLKB7.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-CFpX0WX3.js → dashboard-briefing-launcher-BgBMjAVe.js} +10 -10
- package/dist/chunks/{dashboard-briefing-launcher-mUXWuiOZ.cjs → dashboard-briefing-launcher-BmEHYblf.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-SoNubIu1.cjs → dashboard-controls-BLNG_zHC.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-BeYAmOJc.js → dashboard-controls-C-23EDdr.js} +10 -10
- package/dist/chunks/dashboard-date-comparison-definition-Ces4alFm.cjs +1 -0
- package/dist/chunks/{dashboard-date-comparison-definition-Ba-clViK.js → dashboard-date-comparison-definition-DC3ekV2S.js} +1 -1
- package/dist/chunks/{dashboard-json-BublPnQ4.cjs → dashboard-json-BJ_Z9EaL.cjs} +1 -1
- package/dist/chunks/{dashboard-json-DeLUagVV.js → dashboard-json-BTF-1Iwa.js} +8 -8
- package/dist/chunks/{edit-dashboard-visual-CrvPcO7A.cjs → edit-dashboard-visual-CR832BJc.cjs} +1 -1
- package/dist/chunks/{edit-dashboard-visual-Go0h82DR.js → edit-dashboard-visual-Mw-ZE7P7.js} +12 -12
- package/dist/chunks/{editor-action-buttons-1Lo0fIh7.cjs → editor-action-buttons-BVigIMg0.cjs} +1 -1
- package/dist/chunks/{editor-action-buttons-BFNtjFzO.js → editor-action-buttons-BxbFCerU.js} +6 -6
- package/dist/chunks/{index-BsH32bn1.js → index-B5Oy1eLv.js} +35305 -34883
- package/dist/chunks/index-C99Ow35Y.cjs +4 -0
- package/dist/chunks/{index-q12_nNUS.cjs → index-DIWJALWL.cjs} +231 -231
- package/dist/chunks/{index-B3ZugihZ.js → index-DrYILnh0.js} +799 -808
- package/dist/chunks/matrix-result-contract-CofATICL.js +437 -0
- package/dist/chunks/matrix-result-contract-zamd9euI.cjs +1 -0
- package/dist/chunks/{pivot-header-presentation-DcfPaCiy.cjs → pivot-header-presentation-DhyQXxKq.cjs} +1 -1
- package/dist/chunks/{pivot-header-presentation-nk604qc1.js → pivot-header-presentation-ckYOQ4aZ.js} +2 -2
- package/dist/chunks/{pivot-result-identity-CRUokNgm.cjs → pivot-result-identity-Bb4EixVN.cjs} +1 -1
- package/dist/chunks/{pivot-result-identity-C43Ai5Kr.js → pivot-result-identity-DU1v-5Xk.js} +1 -1
- package/dist/chunks/pivot-result-lifecycle-DmcF1ris.cjs +1 -0
- package/dist/chunks/{pivot-result-lifecycle-4kSe0Hk1.js → pivot-result-lifecycle-sjzIOpvp.js} +57 -58
- package/dist/chunks/{raw-temporal-contract-CxbRFwnd.cjs → raw-temporal-contract-BtjH_G-d.cjs} +1 -1
- package/dist/chunks/{raw-temporal-contract-BF7PjBY9.js → raw-temporal-contract-CxncLze5.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-BEVZAE3m.cjs → report-preferences-dialog-BgE3Gzsp.cjs} +1 -1
- package/dist/chunks/{report-preferences-dialog-BNV7qXYH.js → report-preferences-dialog-CFenWkcH.js} +6 -6
- package/dist/chunks/{report-runtime-context-DjYqLV-c.cjs → report-runtime-context-DqxS4wbi.cjs} +1 -1
- package/dist/chunks/{report-runtime-context-BJQDu2fV.js → report-runtime-context-SM6YO61_.js} +5 -5
- package/dist/chunks/saved-temporal-bucket-format-CFfWXRl9.cjs +1 -0
- package/dist/chunks/{saved-temporal-bucket-format-DiZdQXOL.js → saved-temporal-bucket-format-SGAV0ivR.js} +33 -35
- package/dist/chunks/{switch-DgLwr7O-.js → switch-BeZW-HnS.js} +367 -369
- package/dist/chunks/{switch-CjJ6FHYJ.cjs → switch-D-CCcfhc.cjs} +28 -28
- package/dist/chunks/temporal-bucket-5UYEotyQ.js +810 -0
- package/dist/chunks/temporal-bucket-DHY1y9lq.cjs +1 -0
- package/dist/chunks/{temporal-bucket-authoring-FIRnJz0e.js → temporal-bucket-authoring-K1kE6R_z.js} +28 -27
- package/dist/chunks/temporal-bucket-authoring-o3Emn05L.cjs +1 -0
- package/dist/chunks/{temporal-bucket-contract-anl4h-vg.cjs → temporal-bucket-contract-D2-93DGr.cjs} +1 -1
- package/dist/chunks/{temporal-bucket-contract-BQOj6Frl.js → temporal-bucket-contract-D5d-xEl3.js} +1 -1
- package/dist/chunks/{token-types-D0i0IUX3.cjs → token-types-D7CaaI80.cjs} +1 -1
- package/dist/chunks/{token-types-CRpQJ4kv.js → token-types-GbxRUozo.js} +1 -1
- package/dist/chunks/{update-policy-C1i9bgsy.cjs → update-policy-BmiOd0PB.cjs} +1 -1
- package/dist/chunks/{update-policy-CaJz9aPG.js → update-policy-hednMF-0.js} +1 -1
- package/dist/chunks/validators-BDYprKI9.cjs +1 -0
- package/dist/chunks/{validators-DeMXwRON.js → validators-DEmd8Sin.js} +1544 -1200
- 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 +7 -7
- 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 +78 -77
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +29 -30
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +21 -21
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +39 -40
- package/dist/index.cjs +1 -1
- package/dist/index.js +15 -15
- 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/analytics-protocol.d.ts +44 -11
- package/dist/types/briefings.d.ts +9 -17
- package/dist/types/dashboard-assistant.d.ts +19 -22
- package/dist/types/dashboard-authoring.d.ts +9 -17
- package/dist/types/dashboard.d.ts +9 -17
- package/dist/types/data-app-builder.d.ts +28 -2
- package/dist/types/data-app-codegen-node.d.ts +29 -3
- package/dist/types/data-app-codegen.d.ts +29 -3
- package/dist/types/data-app-sdk-adapters.d.ts +28 -2
- package/dist/types/data-app-sdk-validation.d.ts +38 -7
- package/dist/types/data-app-sdk.d.ts +42 -10
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +25 -26
- package/dist/types/shared.d.ts +9 -17
- package/dist/types/surfboard.d.ts +9 -17
- package/dist/types/types.d.ts +19 -22
- package/package.json +1 -1
- package/dist/chunks/canonical-result-keys-Drc2x-lf.cjs +0 -1
- package/dist/chunks/catalog-field-grounding-Bnx-3tE0.cjs +0 -1
- package/dist/chunks/catalog-field-grounding-S2jKwKGD.js +0 -100
- package/dist/chunks/dashboard-date-comparison-definition-DZq0htjG.cjs +0 -1
- package/dist/chunks/dashboard-input-contract-DSt8dGzP.js +0 -18
- package/dist/chunks/dashboard-input-contract-DV3cshjz.cjs +0 -1
- package/dist/chunks/index-DjiIh_9n.cjs +0 -4
- package/dist/chunks/metric-comparison-D0T0MKRK.js +0 -387
- package/dist/chunks/metric-comparison-DYR3RXam.cjs +0 -1
- package/dist/chunks/pivot-result-lifecycle-BiJepH5S.cjs +0 -1
- package/dist/chunks/saved-temporal-bucket-format-Gfbh4IiP.cjs +0 -1
- package/dist/chunks/temporal-bucket-Dnj8qT9l.cjs +0 -1
- package/dist/chunks/temporal-bucket-FBZGrDCe.js +0 -560
- package/dist/chunks/temporal-bucket-authoring-7hv2laOG.cjs +0 -1
- package/dist/chunks/validators-Dm7Kpz6p.cjs +0 -1
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-DIWJALWL.cjs"),e=require("../chunks/common-types-C57kJ59w.cjs");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
|
package/dist/dashboard/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as o } from "../chunks/index-
|
|
2
|
-
import { C as s, E as C } from "../chunks/common-types-
|
|
1
|
+
import { D as o } from "../chunks/index-B5Oy1eLv.js";
|
|
2
|
+
import { C as s, E as C } from "../chunks/common-types-H51FLKB7.js";
|
|
3
3
|
export {
|
|
4
4
|
s as CONTROL_CARD_DEFAULT_VALUE,
|
|
5
5
|
o as Dashboard,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../chunks/contracts-CtB2VONT.cjs"),D=require("../chunks/canonical-result-keys-Drc2x-lf.cjs"),v=require("../chunks/validators-Dm7Kpz6p.cjs");require("../chunks/analyze-result-contract-Dxw66nUG.cjs");const Ce=require("../chunks/catalog-field-grounding-Bnx-3tE0.cjs"),Te=require("../chunks/operators-DrTQsJXv.cjs"),M=require("../chunks/temporal-bucket-authoring-7hv2laOG.cjs");function _(e){return e&&typeof e=="object"?e:null}function C(e){return typeof e=="string"?e:null}function se(e){var t,r,n;return!!(e&&typeof e=="object")&&(((t=_(e))==null?void 0:t.kind)==="semantic"||((r=_(e))==null?void 0:r.kind)==="physical"||((n=_(e))==null?void 0:n.kind)==="sql")}function R(e){return se(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function ke(e){return v.semaphorSourceIdentityKey(e)}function X(e,t){return v.semaphorSourcesReferToSameDataset(e,t)}function de(e,t){return v.preferSemaphorSourceMetadata(e,t)}function B(e){const t=[];for(const r of e){const n=t.findIndex(o=>X(o,r));n===-1?t.push(r):t[n]=de(t[n],r)}return t}function Fe(e){return B(e)[0]}function K(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!v.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function U(e){return R(e)?e:void 0}function ie(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&v.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function w(e,t){const r=U(e==null?void 0:e.source);return r?K(r,t):void 0}function ce({explicitSource:e,field:t,defaultSource:r,fallbackSources:n}){const o=[r,...n||[]],a=U(e),i=a?K(a,ie(a,o)):void 0;if(i)return i;if(e!==void 0)return;const d=w(t,r),s=d?K(d,ie(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return U(r)}function xe(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=w(e),n=w(t);return!r||!n?!0:X(r,n)}function F(e){var t;return C((t=_(e))==null?void 0:t.kind)}function le(e){var t,r;return F(e)!=="semantic"?null:((r=C((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Re(e){var t;return F(e)!=="semantic"?null:C((t=_(e))==null?void 0:t.datasetName)}function Me(e){var t;return F(e)!=="semantic"?null:C((t=_(e))==null?void 0:t.datasetId)}function Ne(e){var t;return F(e)!=="physical"?null:C((t=_(e))==null?void 0:t.connectionId)}function Oe(e){var t;return F(e)!=="physical"?null:C((t=_(e))==null?void 0:t.tableName)}function Be(e){var t;return F(e)!=="physical"?"":C((t=_(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return F(e)!=="physical"?"":C((t=_(e))==null?void 0:t.schemaName)||""}function ue(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function fe({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(le),n=new Set(r.filter(Boolean));return r.some(o=>!o)||n.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function H(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Me(e);return le(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Re(e)===t.datasetName:!1}return t.kind==="physical"?Ne(e)===t.connectionId&&Oe(e)===t.tableName&&Be(e)===(t.databaseName||"")&&$e(e)===(t.schemaName||""):!1}function Pe(e,t){return e.find(r=>H(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function E(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function pe({card:e,datasets:t,errors:r}){if(e.type==="text")return;const n=ue(e);if(!n){if(t.length<=1)return;r.push(p("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>H(o,n))||r.push(p("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function q(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function L(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function oe(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Ee(e){var r,n;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...q([...L(e.measures),e.primaryMeasure,e.dateField,...L(e.dimensions),...oe(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...q([...L(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...oe(e.filters).map(o=>o.field)])):e.kind==="inputOptions"?(((n=e.population)==null?void 0:n.kind)==="related_population"&&t.push(e.population.baseSource),t.push(...q([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...q(e.fields||[])),t}function he({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const n of Ee(e.analyticsIntent))if(n&&!t.some(o=>H(o,n))){r.push(p("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function me({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=v.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const n of r.errors)t.push(p(n.code,n.path?`${n.path}: ${n.message}`:n.message,e.id))}function ge({datasets:e,errors:t,requireAtLeastOne:r}){const n=fe({datasets:e,requireAtLeastOne:r});if(!n.ok){if(n.issue==="invalid_dataset_count"){t.push(p("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(p("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function be({input:e,errors:t}){var r;(r=e.filter.sql)!=null&&r.trim()&&t.push(p("generated_filter_sql_out_of_scope",`Generated dashboard filter "${e.label}" must use grounded filter configuration; custom SQL is outside the dashboard-authoring contract.`))}function Ie(e){var f,g;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard plan version must be 1.")),(f=r.title)!=null&&f.trim()||t.push(p("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.sheets)?r.sheets:[];ge({datasets:o,errors:t,requireAtLeastOne:!0}),a.length!==1&&t.push(p("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const i=a[0];i&&i.kind!=="dashboard"&&t.push(p("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(i==null?void 0:i.cards)||[];d.length>k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=E(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=E(d.map(l=>l.frameId));u&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(g=l.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&n.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),pe({card:l,datasets:o,errors:t}),me({card:l,errors:t}),he({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(l=>l.id),A=E(I);A&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${A}.`));const S=h.map(l=>l.variableName).filter(Boolean)||[],y=E(S);y&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${y}.`));for(const l of h)be({input:l,errors:t});const c=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const l of c)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:n}}function ye(e){var i;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard change plan version must be 1.")),(i=r.dashboardId)!=null&&i.trim()||t.push(p("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.operations)?r.operations:[];ge({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of a){if(d.kind==="unsupported"){n.push(p("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(pe({card:d.card,datasets:o,errors:t}),me({card:d.card,errors:t}),he({card:d.card,datasets:o,errors:t})),d.kind==="addFilterInput"&&be({input:d.input,errors:t}),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${d.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:n}}const qe={lg:48,md:36,sm:24,xs:12,xxs:6};function He(e,t){let r=0,n=0,o=0;return e.map(a=>{const i=Math.min(a.w,t);r>0&&r+i>t&&(r=0,n+=o,o=0);const d={i:a.frameId,x:r,y:n,w:i,h:a.h,minW:Math.min(a.minW,t),minH:a.minH,static:!1};return r+=i,o=Math.max(o,a.h),d})}function ze(e){const t=[...e].sort((s,u)=>s.priority-u.priority),r=t.filter(s=>s.role==="kpi"),n=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),a=t.filter(s=>s.role==="text"),i=a.slice(0,1),d=a.slice(i.length);return{kpis:r,introText:i,charts:n,tables:o,supportingText:d}}function Ve(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function Le(e,t,r,n){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?n:n/2}function je(e){const{item:t,band:r,index:n,bandCount:o,breakpoint:a,columns:i}=e;return r==="kpi"?{...t,band:r,w:Ve(o,a,i),h:15,minW:Math.min(6,i),minH:12}:r==="table"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?34:38,minW:Math.min(12,i),minH:18}:r==="introText"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:r==="supportingText"?{...t,band:r,w:a==="lg"?i/2:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:{...t,band:r,w:Le(n,o,a,i),h:a==="xxs"||a==="xs"?28:30,minW:Math.min(12,i),minH:16}}function N(e,t,r,n){return e.map((o,a)=>je({item:o,band:t,index:a,bandCount:e.length,breakpoint:r,columns:n}))}function z(e){const t=ze(e);return Object.fromEntries(k.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const n=qe[r],o=[...N(t.introText,"introText",r,n),...N(t.kpis,"kpi",r,n),...N(t.charts,"chart",r,n),...N(t.tables,"table",r,n),...N(t.supportingText,"supportingText",r,n)];return[r,He(o,n)]}))}function Ge(e){const t=Ce.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function Ke(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ue(e){return Ke(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function We(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function Xe(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function Y(e,t){if(t===void 0)return;const r=Ge(e.dataType),n=e.operation||"in";if(Ue(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(n==="is null"||n==="is not null")return{filterId:e.id,name:e.column,operation:n,valueType:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const o=Array.isArray(t)?t:[t],a=r==="date"?Xe(o):We(o);if(a.length!==0&&!((n==="between"||n==="not between")&&a.length<2))return{filterId:e.id,name:e.column,operation:n,valueType:r,values:a,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function _e(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ye(e,t,r){const n=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return n.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...n]}}function W(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Qe(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=W(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function Je(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:W(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:W(e.excludeCardIds,t)}:{}}}function Ze(e,t){const r={},n=[];return{inputs:(e.filterInputs||[]).flatMap((a,i)=>{const d=Qe(a.scope,t);if(d===null)return n.push(_e("filter_input_scope_empty",`Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=Y(a.filter,a.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[a.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:a.id,kind:"filter",label:a.label,variableName:a.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:i},exports:["label","value","start","end","range"],filter:Je(a.filter,t)}]}),warnings:n,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function et(e){var S,y;const t=Ie(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
|
|
2
|
-
`)||"Dashboard plan is invalid.");const r=e.plan.sheets[0],n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(c=>[c.planCardId,c])),i=new Map(e.cardArtifacts.map(c=>[c.planCardId,c.card.id])),d=[];for(const c of r.cards){const f=a.get(c.id);if(!f){const l=_e("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);o.push(l);continue}n.push(...f.warnings||[]);const g=
|
|
3
|
-
`)||"Dashboard change plan is invalid.");const r=tt(e.dashboard),n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),i=rt(r);if(!i)throw new Error("Dashboard has no editable dashboard sheet.");i.frames??(i.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((i.frames||[]).reduce((A,S)=>{var y;return A+(((y=S.cards)==null?void 0:y.length)||0)},0)>=k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(x("generated_card_limit_reached",`AI refinement is capped at ${k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`,s.card.id));break}const h=a.get(s.card.id);if(!h){o.push(x("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const I={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};i.frames.push(I),it(i,I);break}case"addFilterInput":{r.inputs??(r.inputs=[]);const u={id:s.input.id,kind:"filter",label:s.input.label,variableName:s.input.variableName,scope:s.input.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:r.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};r.inputs.push(u),ot(r,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)r.calculatedFields??(r.calculatedFields=[]),r.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)i.calculatedFields??(i.calculatedFields=[]),i.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const u=s.field.targetCardId?j(r,s.field.targetCardId):null;u?((d=u.card).calculatedFields??(d.calculatedFields=[]),u.card.calculatedFields.push(s.field.field)):o.push(x("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const u=j(r,s.cardId);if(!u){o.push(x("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}u.card.title=s.title,s.description!==void 0&&(u.card.description=s.description);break}case"reorderCards":{const u=new Map;for(let h=0;h<s.cardIds.length;h+=1){const I=s.cardIds[h],A=j(r,I);A&&u.set(A.frame.id,h)}Se(i,u);break}case"reuseCalculatedField":n.push(x("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":o.push(x("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:r,warnings:n,skippedOperations:o}}function b(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function O(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function we(e,t){if(!t.has(e))return t.add(e),e;let r=2,n=`${e}-${r}`;for(;t.has(n);)r+=1,n=`${e}-${r}`;return t.add(n),n}function $(e){return!!(e&&typeof e=="object")}function De(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>$(t)&&typeof t.id=="string"):[]}function Q(e){return Array.isArray(e.sections)?e.sections.filter(t=>$(t)):[]}function J(e){return Array.isArray(e.views)?e.views.filter(t=>$(t)):[]}function T(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const n=w(r);n&&t.push(n)}return t}function dt(e){var n,o,a;if(!e)return[];const t=[];if(R(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...T(e.measures));const i=w(e.dateField);i&&t.push(i),t.push(...T(e.dimensions)),t.push(...T((n=e.filters)==null?void 0:n.map(d=>d.field)))}else if(e.kind==="records"){const i=w(e.dateField);i&&t.push(i),t.push(...T(e.fields)),t.push(...T((o=e.filters)==null?void 0:o.map(d=>d.field)))}else e.kind==="inputOptions"?(((a=e.population)==null?void 0:a.kind)==="related_population"&&R(e.population.baseSource)&&t.push(e.population.baseSource),t.push(...T([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(i=>!!i)))):e.kind==="sql"&&t.push(...T(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const i of r){const d=w(i.field);d&&t.push(d)}return t}function ct(e){const t=[];for(const r of De(e)){const n=w(r.field);n&&t.push(n)}for(const r of Q(e))for(const n of J(r))t.push(...dt(n.analytics));return t}function lt(e){var r;const t=[];for(const n of Q(e))for(const o of J(n))R((r=o.analytics)==null?void 0:r.source)&&t.push(o.analytics.source);return t}function ut(e,t){const r=B(e).filter(R);if(r.length===0)return t.push(b("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const n=r.every(a=>a.kind==="semantic"),o=Array.from(new Set(r.filter(a=>a.kind==="semantic").map(a=>a.domainId)));return r.length>1&&(!n||o.length!==1)?(t.push(b("multiple_datasets_out_of_scope","The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest.")),[r[0]]):r}function ft(e,t){const r=Q(e),n=De(e),o=B(ct(e)),a=B(lt(e));return{sections:r,inputs:n,sources:o,primarySources:a,defaultSource:a.length===1?a[0]:void 0,datasets:ut(o,t)}}function pt(e){return e&&v.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function ht(e){var t;switch((t=e.presentation)==null?void 0:t.kind){case"kpi":return"kpi";case"lineChart":return"line";case"barChart":return"bar";case"areaChart":return"area";case"table":return"table";case"text":return"text";default:return null}}function mt(e){var t,r,n;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((r=e.presentation)==null?void 0:r.kind)==="table"?"table":((n=e.presentation)==null?void 0:n.kind)==="text"?"text":"chart"}function gt(e){const t=Te.normalizeSemaphorInputOperator(e);switch(t){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";case"not_contains":return"not like";default:return t||"in"}}function bt(e){return $(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function It(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function yt(e,t,r,n,o,a){if(e.kind!=="filter")return a.push(b("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!$(e.field)||typeof e.field.name!="string")return a.push(b("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const i=ce({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:r}),d=(i==null?void 0:i.kind)==="semantic"||(i==null?void 0:i.kind)==="physical"?i.connectionId:void 0;if(!d)return a.push(b("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const h={id:`filter-${we(O(e.id,e.field.name),o)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:bt(e),qualifiedTableName:It(i),sql:"",operation:gt(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(i==null?void 0:i.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(i==null?void 0:i.kind)==="semantic"?{semanticDomainId:i.domainId,connectionId:i.connectionId}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:n,filter:h,defaultValue:Y(h,e.defaultValue)}}function G(e){const t=[],r=[];for(const n of e.viewIds){const o=e.viewIdToCardId.get(n);o?t.push(o):r.push(n)}return r.length>0&&e.warnings.push(b("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${r.join(", ")}.`)),Array.from(new Set(t))}function _t(e){var n,o;if(!e.protocolScope){const a=Array.from(new Set(e.boundCardIds));return a.length>0&&a.length<e.allCardIds.length?{kind:"cards",cardIds:a}:void 0}if(e.protocolScope.level==="dashboard"){if(!((n=e.protocolScope.excludeViewIds)!=null&&n.length))return;const a=new Set(G({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(i=>!a.has(i))}}if(e.protocolScope.level==="view"){const a=G({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return a.length===0?(e.warnings.push(b("input_scope_has_no_materialized_cards",`Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`)),null):{kind:"cards",cardIds:a}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(b("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((o=e.protocolScope.excludeViewIds)!=null&&o.length))return{kind:"cards",cardIds:t};const r=new Set(G({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(a=>!r.has(a))}}function At(e){var S,y,c;const t=[],r=v.validateSemaphorDashboardIntent(e);for(const f of r.warnings)t.push(b(f.code,f.message));for(const f of r.errors)t.push(b(f.code,f.message));const n=ft(e,t),o=[],a=new Map,i=new Map,d=new Map,s=new Set,u=new Set;let h=0;for(const[f,g]of n.sections.entries()){const l=typeof g.title=="string"?g.title:`Section ${f+1}`,Z=g.id||O(l,`section-${f+1}`);i.set(Z,[]);for(const[ee,m]of J(g).entries()){const te=ht(m),V=O(m.id||`${l}-${m.title||`View ${ee+1}`}`,`card-${f+1}-${ee+1}`);if(!te){t.push(b("unsupported_presentation",`Dashboard presentation "${((S=m.presentation)==null?void 0:S.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${V}`));continue}if(((y=m.analytics)==null?void 0:y.kind)==="sql"){t.push(b("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${V}`));continue}const re=we(V,s),P=`card-${re}`;m.id&&a.set(m.id,P),(c=i.get(Z))==null||c.push(P);const ve=m.analytics&&"inputs"in m.analytics?m.analytics.inputs:void 0;for(const ne of ve||[]){const ae=d.get(ne.inputId)||[];ae.push(P),d.set(ne.inputId,ae)}o.push({id:P,frameId:`frame-${re}`,title:m.title,description:m.description,type:te,role:mt(m),priority:h,section:l,analyticsIntent:pt(m.analytics),text:m.text}),h+=1}}const I=n.inputs.map(f=>{const g=_t({protocolScope:f.scope,inputLabel:f.label,allCardIds:o.map(l=>l.id),boundCardIds:d.get(f.id)||[],viewIdToCardId:a,sectionIdToCardIds:i,warnings:t});return g===null?null:yt(f,n.defaultSource,n.sources,g,u,t)}).filter(f=>!!f);return{plan:{version:1,id:`plan-${O(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:n.datasets,sheets:[{id:`sheet-${O(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:o}],filterInputs:I.length?I:void 0,warnings:t.length?t:void 0,unresolvedRequests:r.ok?void 0:r.errors.map(f=>f.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=k.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.SEMAPHOR_CARTESIAN_CHART_TYPES=D.SEMAPHOR_CARTESIAN_CHART_TYPES;exports.isSemaphorCartesianChartType=D.isSemaphorCartesianChartType;exports.resolveCanonicalDetailResultRawKey=D.resolveCanonicalDetailResultRawKey;exports.resolveCanonicalResultOutputKey=D.resolveCanonicalResultOutputKey;exports.resolveCanonicalResultRawKey=D.resolveCanonicalResultRawKey;exports.resolveTemporalResultOwner=D.resolveTemporalResultOwner;exports.supportsCanonicalDashboardTemporalResult=D.supportsCanonicalDashboardTemporalResult;exports.transformComparisonDocument=D.transformComparisonDocument;exports.AUTOMATIC_TEMPORAL_BUCKET_FORMAT=M.AUTOMATIC_TEMPORAL_BUCKET_FORMAT;exports.getTemporalBucketAuthoringOptions=M.getTemporalBucketAuthoringOptions;exports.getTemporalBucketAuthoringSelection=M.getTemporalBucketAuthoringSelection;exports.previewTemporalBucketAuthoringFormat=M.previewTemporalBucketAuthoringFormat;exports.reconcileTemporalBucketAuthoringFormat=M.reconcileTemporalBucketAuthoringFormat;exports.resolveTemporalBucketAuthoringFormat=M.resolveTemporalBucketAuthoringFormat;exports.applyDashboardChangePlan=st;exports.compileDashboardFromPlan=et;exports.compileResponsiveDashboardLayouts=z;exports.dashboardAuthoringDatasetMatchesSource=H;exports.dashboardAuthoringFieldsReferToSameTarget=xe;exports.dashboardAuthoringSourceFromField=w;exports.dashboardAuthoringSourceKey=ke;exports.dashboardAuthoringSourcesReferToSameDataset=X;exports.dashboardPlanFromSemaphorDashboardIntent=At;exports.findDashboardAuthoringDatasetForSource=Pe;exports.getDashboardAuthoringCardSource=ue;exports.isMaterializableDashboardAuthoringSource=R;exports.isSemaphorSourceRef=se;exports.mergeDashboardAuthoringSources=B;exports.preferDashboardAuthoringSourceMetadata=de;exports.preferredDashboardAuthoringSource=Fe;exports.resolveDashboardAuthoringSource=ce;exports.validateDashboardAuthoringDatasetScope=fe;exports.validateDashboardChangePlan=ye;exports.validateDashboardPlan=Ie;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../chunks/contracts-CtB2VONT.cjs"),v=require("../chunks/canonical-result-keys-BA0HCP4e.cjs"),D=require("../chunks/validators-BDYprKI9.cjs");require("../chunks/analyze-result-contract-LPDNldic.cjs");require("../value-format-preferences/index.cjs");const Ce=require("../chunks/operators-DrTQsJXv.cjs"),M=require("../chunks/temporal-bucket-authoring-o3Emn05L.cjs");function _(e){return e&&typeof e=="object"?e:null}function C(e){return typeof e=="string"?e:null}function se(e){var t,r,n;return!!(e&&typeof e=="object")&&(((t=_(e))==null?void 0:t.kind)==="semantic"||((r=_(e))==null?void 0:r.kind)==="physical"||((n=_(e))==null?void 0:n.kind)==="sql")}function R(e){return se(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function Te(e){return D.semaphorSourceIdentityKey(e)}function X(e,t){return D.semaphorSourcesReferToSameDataset(e,t)}function de(e,t){return D.preferSemaphorSourceMetadata(e,t)}function B(e){const t=[];for(const r of e){const n=t.findIndex(o=>X(o,r));n===-1?t.push(r):t[n]=de(t[n],r)}return t}function ke(e){return B(e)[0]}function K(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!D.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function U(e){return R(e)?e:void 0}function ie(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&D.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function w(e,t){const r=U(e==null?void 0:e.source);return r?K(r,t):void 0}function ce({explicitSource:e,field:t,defaultSource:r,fallbackSources:n}){const o=[r,...n||[]],a=U(e),i=a?K(a,ie(a,o)):void 0;if(i)return i;if(e!==void 0)return;const d=w(t,r),s=d?K(d,ie(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return U(r)}function Fe(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=w(e),n=w(t);return!r||!n?!0:X(r,n)}function F(e){var t;return C((t=_(e))==null?void 0:t.kind)}function le(e){var t,r;return F(e)!=="semantic"?null:((r=C((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function xe(e){var t;return F(e)!=="semantic"?null:C((t=_(e))==null?void 0:t.datasetName)}function Re(e){var t;return F(e)!=="semantic"?null:C((t=_(e))==null?void 0:t.datasetId)}function Me(e){var t;return F(e)!=="physical"?null:C((t=_(e))==null?void 0:t.connectionId)}function Ne(e){var t;return F(e)!=="physical"?null:C((t=_(e))==null?void 0:t.tableName)}function Oe(e){var t;return F(e)!=="physical"?"":C((t=_(e))==null?void 0:t.databaseName)||""}function Be(e){var t;return F(e)!=="physical"?"":C((t=_(e))==null?void 0:t.schemaName)||""}function ue(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function fe({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(le),n=new Set(r.filter(Boolean));return r.some(o=>!o)||n.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function H(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Re(e);return le(e)===t.domainId?r&&t.datasetId?r===t.datasetId:xe(e)===t.datasetName:!1}return t.kind==="physical"?Me(e)===t.connectionId&&Ne(e)===t.tableName&&Oe(e)===(t.databaseName||"")&&Be(e)===(t.schemaName||""):!1}function $e(e,t){return e.find(r=>H(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function E(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function pe({card:e,datasets:t,errors:r}){if(e.type==="text")return;const n=ue(e);if(!n){if(t.length<=1)return;r.push(p("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>H(o,n))||r.push(p("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function q(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function L(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function oe(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Pe(e){var r,n;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...q([...L(e.measures),e.primaryMeasure,e.dateField,...L(e.dimensions),...oe(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...q([...L(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...oe(e.filters).map(o=>o.field)])):e.kind==="inputOptions"?(((n=e.population)==null?void 0:n.kind)==="related_population"&&t.push(e.population.baseSource),t.push(...q([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...q(e.fields||[])),t}function he({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const n of Pe(e.analyticsIntent))if(n&&!t.some(o=>H(o,n))){r.push(p("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function me({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=D.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const n of r.errors)t.push(p(n.code,n.path?`${n.path}: ${n.message}`:n.message,e.id))}function ge({datasets:e,errors:t,requireAtLeastOne:r}){const n=fe({datasets:e,requireAtLeastOne:r});if(!n.ok){if(n.issue==="invalid_dataset_count"){t.push(p("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(p("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function be({input:e,errors:t}){var r;(r=e.filter.sql)!=null&&r.trim()&&t.push(p("generated_filter_sql_out_of_scope",`Generated dashboard filter "${e.label}" must use grounded filter configuration; custom SQL is outside the dashboard-authoring contract.`))}function Ie(e){var f,g;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard plan version must be 1.")),(f=r.title)!=null&&f.trim()||t.push(p("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.sheets)?r.sheets:[];ge({datasets:o,errors:t,requireAtLeastOne:!0}),a.length!==1&&t.push(p("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const i=a[0];i&&i.kind!=="dashboard"&&t.push(p("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(i==null?void 0:i.cards)||[];d.length>k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=E(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=E(d.map(l=>l.frameId));u&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(g=l.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&n.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),pe({card:l,datasets:o,errors:t}),me({card:l,errors:t}),he({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(l=>l.id),A=E(I);A&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${A}.`));const S=h.map(l=>l.variableName).filter(Boolean)||[],y=E(S);y&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${y}.`));for(const l of h)be({input:l,errors:t});const c=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const l of c)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:n}}function ye(e){var i;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard change plan version must be 1.")),(i=r.dashboardId)!=null&&i.trim()||t.push(p("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.operations)?r.operations:[];ge({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of a){if(d.kind==="unsupported"){n.push(p("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(pe({card:d.card,datasets:o,errors:t}),me({card:d.card,errors:t}),he({card:d.card,datasets:o,errors:t})),d.kind==="addFilterInput"&&be({input:d.input,errors:t}),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${d.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:n}}const Ee={lg:48,md:36,sm:24,xs:12,xxs:6};function qe(e,t){let r=0,n=0,o=0;return e.map(a=>{const i=Math.min(a.w,t);r>0&&r+i>t&&(r=0,n+=o,o=0);const d={i:a.frameId,x:r,y:n,w:i,h:a.h,minW:Math.min(a.minW,t),minH:a.minH,static:!1};return r+=i,o=Math.max(o,a.h),d})}function He(e){const t=[...e].sort((s,u)=>s.priority-u.priority),r=t.filter(s=>s.role==="kpi"),n=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),a=t.filter(s=>s.role==="text"),i=a.slice(0,1),d=a.slice(i.length);return{kpis:r,introText:i,charts:n,tables:o,supportingText:d}}function ze(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function Ve(e,t,r,n){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?n:n/2}function Le(e){const{item:t,band:r,index:n,bandCount:o,breakpoint:a,columns:i}=e;return r==="kpi"?{...t,band:r,w:ze(o,a,i),h:15,minW:Math.min(6,i),minH:12}:r==="table"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?34:38,minW:Math.min(12,i),minH:18}:r==="introText"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:r==="supportingText"?{...t,band:r,w:a==="lg"?i/2:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:{...t,band:r,w:Ve(n,o,a,i),h:a==="xxs"||a==="xs"?28:30,minW:Math.min(12,i),minH:16}}function N(e,t,r,n){return e.map((o,a)=>Le({item:o,band:t,index:a,bandCount:e.length,breakpoint:r,columns:n}))}function z(e){const t=He(e);return Object.fromEntries(k.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const n=Ee[r],o=[...N(t.introText,"introText",r,n),...N(t.kpis,"kpi",r,n),...N(t.charts,"chart",r,n),...N(t.tables,"table",r,n),...N(t.supportingText,"supportingText",r,n)];return[r,qe(o,n)]}))}function je(e){const t=D.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function Ge(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ke(e){return Ge(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function Ue(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function We(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function Y(e,t){if(t===void 0)return;const r=je(e.dataType),n=e.operation||"in";if(Ke(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(n==="is null"||n==="is not null")return{filterId:e.id,name:e.column,operation:n,valueType:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const o=Array.isArray(t)?t:[t],a=r==="date"?We(o):Ue(o);if(a.length!==0&&!((n==="between"||n==="not between")&&a.length<2))return{filterId:e.id,name:e.column,operation:n,valueType:r,values:a,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function _e(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Xe(e,t,r){const n=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return n.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...n]}}function W(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Ye(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=W(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function Qe(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:W(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:W(e.excludeCardIds,t)}:{}}}function Je(e,t){const r={},n=[];return{inputs:(e.filterInputs||[]).flatMap((a,i)=>{const d=Ye(a.scope,t);if(d===null)return n.push(_e("filter_input_scope_empty",`Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=Y(a.filter,a.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[a.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:a.id,kind:"filter",label:a.label,variableName:a.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:i},exports:["label","value","start","end","range"],filter:Qe(a.filter,t)}]}),warnings:n,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function Ze(e){var S,y;const t=Ie(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
|
|
2
|
+
`)||"Dashboard plan is invalid.");const r=e.plan.sheets[0],n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(c=>[c.planCardId,c])),i=new Map(e.cardArtifacts.map(c=>[c.planCardId,c.card.id])),d=[];for(const c of r.cards){const f=a.get(c.id);if(!f){const l=_e("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);o.push(l);continue}n.push(...f.warnings||[]);const g=Xe(f.card,e.plan.calculatedFields,c.id);d.push({id:c.frameId,cards:[g],activeCardId:g.id})}if(d.length===0)throw new Error("Dashboard plan did not produce any persistable cards.");const{inputs:s,defaultInputValues:u,warnings:h}=Je(e.plan,i);n.push(...h);const I=z(r.cards.filter(c=>d.some(f=>f.id===c.frameId)).map(c=>({frameId:c.frameId,priority:c.priority,role:c.role})));return{dashboard:{id:e.dashboardId,title:e.plan.title,description:e.plan.description||"",sheets:[{id:r.id,kind:"dashboard",title:r.title,description:r.description,frames:d,layouts:I,calculatedFields:(S=e.plan.calculatedFields)==null?void 0:S.filter(c=>c.scope==="sheet"&&c.field).map(c=>c.field)}],calculatedFields:(y=e.plan.calculatedFields)==null?void 0:y.filter(c=>c.scope==="dashboard"&&c.field).map(c=>c.field),inputs:s,...u?{defaultInputValues:u}:{}},warnings:n,skippedOperations:o}}function x(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function et(e){return JSON.parse(JSON.stringify(e))}function tt(e){var t;return(t=e.sheets)==null?void 0:t.find(r=>(r.kind||"dashboard")==="dashboard")}function j(e,t){var r;for(const n of e.sheets||[])for(const o of n.frames||[]){const a=(r=o.cards)==null?void 0:r.find(i=>i.id===t);if(a)return{sheet:n,frame:o,card:a}}return null}function Ae(e){var r,n;const t=(n=(r=e.cards)==null?void 0:r[0])==null?void 0:n.type;return t==="kpi"?"kpi":t==="table"||t==="detailTable"||t==="pivotTable"?"table":t==="text"?"text":"chart"}function rt(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((r,n)=>[r.i,n]))}function Se(e,t=new Map){const r=rt(e),n=Math.max(r.size,t.size),o=(e.frames||[]).map((a,i)=>({frameId:a.id,role:Ae(a),priority:t.get(a.id)??r.get(a.id)??n+i}));e.layouts=z(o)}function nt(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function at(e,t){if(!nt(e)){Se(e);return}const r=z([{frameId:t.id,role:Ae(t),priority:0}]);e.layouts??(e.layouts={});for(const[n,o]of Object.entries(r)){const a=e.layouts[n]||[];if(a.some(s=>s.i===t.id))continue;const i=o[0];if(!i)continue;const d=a.reduce((s,u)=>Math.max(s,u.y+u.h),0);e.layouts[n]=[...a,{...i,y:d}]}}function it(e,t){var n;const r=Y(t.filter,t.defaultValue);r&&(e.defaultInputValues??(e.defaultInputValues={}),(n=e.defaultInputValues).shared??(n.shared={}),e.defaultInputValues.shared[t.id]={status:"set",value:{kind:"filter",filterValue:r}})}function ot(e){var d;const t=ye(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
|
|
3
|
+
`)||"Dashboard change plan is invalid.");const r=et(e.dashboard),n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),i=tt(r);if(!i)throw new Error("Dashboard has no editable dashboard sheet.");i.frames??(i.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((i.frames||[]).reduce((A,S)=>{var y;return A+(((y=S.cards)==null?void 0:y.length)||0)},0)>=k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(x("generated_card_limit_reached",`AI refinement is capped at ${k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`,s.card.id));break}const h=a.get(s.card.id);if(!h){o.push(x("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const I={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};i.frames.push(I),at(i,I);break}case"addFilterInput":{r.inputs??(r.inputs=[]);const u={id:s.input.id,kind:"filter",label:s.input.label,variableName:s.input.variableName,scope:s.input.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:r.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};r.inputs.push(u),it(r,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)r.calculatedFields??(r.calculatedFields=[]),r.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)i.calculatedFields??(i.calculatedFields=[]),i.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const u=s.field.targetCardId?j(r,s.field.targetCardId):null;u?((d=u.card).calculatedFields??(d.calculatedFields=[]),u.card.calculatedFields.push(s.field.field)):o.push(x("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const u=j(r,s.cardId);if(!u){o.push(x("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}u.card.title=s.title,s.description!==void 0&&(u.card.description=s.description);break}case"reorderCards":{const u=new Map;for(let h=0;h<s.cardIds.length;h+=1){const I=s.cardIds[h],A=j(r,I);A&&u.set(A.frame.id,h)}Se(i,u);break}case"reuseCalculatedField":n.push(x("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":o.push(x("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:r,warnings:n,skippedOperations:o}}function b(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function O(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function we(e,t){if(!t.has(e))return t.add(e),e;let r=2,n=`${e}-${r}`;for(;t.has(n);)r+=1,n=`${e}-${r}`;return t.add(n),n}function $(e){return!!(e&&typeof e=="object")}function De(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>$(t)&&typeof t.id=="string"):[]}function Q(e){return Array.isArray(e.sections)?e.sections.filter(t=>$(t)):[]}function J(e){return Array.isArray(e.views)?e.views.filter(t=>$(t)):[]}function T(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const n=w(r);n&&t.push(n)}return t}function st(e){var n,o,a;if(!e)return[];const t=[];if(R(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...T(e.measures));const i=w(e.dateField);i&&t.push(i),t.push(...T(e.dimensions)),t.push(...T((n=e.filters)==null?void 0:n.map(d=>d.field)))}else if(e.kind==="records"){const i=w(e.dateField);i&&t.push(i),t.push(...T(e.fields)),t.push(...T((o=e.filters)==null?void 0:o.map(d=>d.field)))}else e.kind==="inputOptions"?(((a=e.population)==null?void 0:a.kind)==="related_population"&&R(e.population.baseSource)&&t.push(e.population.baseSource),t.push(...T([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(i=>!!i)))):e.kind==="sql"&&t.push(...T(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const i of r){const d=w(i.field);d&&t.push(d)}return t}function dt(e){const t=[];for(const r of De(e)){const n=w(r.field);n&&t.push(n)}for(const r of Q(e))for(const n of J(r))t.push(...st(n.analytics));return t}function ct(e){var r;const t=[];for(const n of Q(e))for(const o of J(n))R((r=o.analytics)==null?void 0:r.source)&&t.push(o.analytics.source);return t}function lt(e,t){const r=B(e).filter(R);if(r.length===0)return t.push(b("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const n=r.every(a=>a.kind==="semantic"),o=Array.from(new Set(r.filter(a=>a.kind==="semantic").map(a=>a.domainId)));return r.length>1&&(!n||o.length!==1)?(t.push(b("multiple_datasets_out_of_scope","The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest.")),[r[0]]):r}function ut(e,t){const r=Q(e),n=De(e),o=B(dt(e)),a=B(ct(e));return{sections:r,inputs:n,sources:o,primarySources:a,defaultSource:a.length===1?a[0]:void 0,datasets:lt(o,t)}}function ft(e){return e&&D.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function pt(e){var t;switch((t=e.presentation)==null?void 0:t.kind){case"kpi":return"kpi";case"lineChart":return"line";case"barChart":return"bar";case"areaChart":return"area";case"table":return"table";case"text":return"text";default:return null}}function ht(e){var t,r,n;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((r=e.presentation)==null?void 0:r.kind)==="table"?"table":((n=e.presentation)==null?void 0:n.kind)==="text"?"text":"chart"}function mt(e){const t=Ce.normalizeSemaphorInputOperator(e);switch(t){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";case"not_contains":return"not like";default:return t||"in"}}function gt(e){return $(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function bt(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function It(e,t,r,n,o,a){if(e.kind!=="filter")return a.push(b("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!$(e.field)||typeof e.field.name!="string")return a.push(b("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const i=ce({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:r}),d=(i==null?void 0:i.kind)==="semantic"||(i==null?void 0:i.kind)==="physical"?i.connectionId:void 0;if(!d)return a.push(b("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const h={id:`filter-${we(O(e.id,e.field.name),o)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:gt(e),qualifiedTableName:bt(i),sql:"",operation:mt(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(i==null?void 0:i.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(i==null?void 0:i.kind)==="semantic"?{semanticDomainId:i.domainId,connectionId:i.connectionId}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:n,filter:h,defaultValue:Y(h,e.defaultValue)}}function G(e){const t=[],r=[];for(const n of e.viewIds){const o=e.viewIdToCardId.get(n);o?t.push(o):r.push(n)}return r.length>0&&e.warnings.push(b("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${r.join(", ")}.`)),Array.from(new Set(t))}function yt(e){var n,o;if(!e.protocolScope){const a=Array.from(new Set(e.boundCardIds));return a.length>0&&a.length<e.allCardIds.length?{kind:"cards",cardIds:a}:void 0}if(e.protocolScope.level==="dashboard"){if(!((n=e.protocolScope.excludeViewIds)!=null&&n.length))return;const a=new Set(G({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(i=>!a.has(i))}}if(e.protocolScope.level==="view"){const a=G({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return a.length===0?(e.warnings.push(b("input_scope_has_no_materialized_cards",`Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`)),null):{kind:"cards",cardIds:a}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(b("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((o=e.protocolScope.excludeViewIds)!=null&&o.length))return{kind:"cards",cardIds:t};const r=new Set(G({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(a=>!r.has(a))}}function _t(e){var S,y,c;const t=[],r=D.validateSemaphorDashboardIntent(e);for(const f of r.warnings)t.push(b(f.code,f.message));for(const f of r.errors)t.push(b(f.code,f.message));const n=ut(e,t),o=[],a=new Map,i=new Map,d=new Map,s=new Set,u=new Set;let h=0;for(const[f,g]of n.sections.entries()){const l=typeof g.title=="string"?g.title:`Section ${f+1}`,Z=g.id||O(l,`section-${f+1}`);i.set(Z,[]);for(const[ee,m]of J(g).entries()){const te=pt(m),V=O(m.id||`${l}-${m.title||`View ${ee+1}`}`,`card-${f+1}-${ee+1}`);if(!te){t.push(b("unsupported_presentation",`Dashboard presentation "${((S=m.presentation)==null?void 0:S.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${V}`));continue}if(((y=m.analytics)==null?void 0:y.kind)==="sql"){t.push(b("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${V}`));continue}const re=we(V,s),P=`card-${re}`;m.id&&a.set(m.id,P),(c=i.get(Z))==null||c.push(P);const ve=m.analytics&&"inputs"in m.analytics?m.analytics.inputs:void 0;for(const ne of ve||[]){const ae=d.get(ne.inputId)||[];ae.push(P),d.set(ne.inputId,ae)}o.push({id:P,frameId:`frame-${re}`,title:m.title,description:m.description,type:te,role:ht(m),priority:h,section:l,analyticsIntent:ft(m.analytics),text:m.text}),h+=1}}const I=n.inputs.map(f=>{const g=yt({protocolScope:f.scope,inputLabel:f.label,allCardIds:o.map(l=>l.id),boundCardIds:d.get(f.id)||[],viewIdToCardId:a,sectionIdToCardIds:i,warnings:t});return g===null?null:It(f,n.defaultSource,n.sources,g,u,t)}).filter(f=>!!f);return{plan:{version:1,id:`plan-${O(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:n.datasets,sheets:[{id:`sheet-${O(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:o}],filterInputs:I.length?I:void 0,warnings:t.length?t:void 0,unresolvedRequests:r.ok?void 0:r.errors.map(f=>f.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=k.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.SEMAPHOR_CARTESIAN_CHART_TYPES=v.SEMAPHOR_CARTESIAN_CHART_TYPES;exports.isSemaphorCartesianChartType=v.isSemaphorCartesianChartType;exports.resolveCanonicalDetailResultRawKey=v.resolveCanonicalDetailResultRawKey;exports.resolveCanonicalResultOutputKey=v.resolveCanonicalResultOutputKey;exports.resolveCanonicalResultRawKey=v.resolveCanonicalResultRawKey;exports.resolveTemporalResultOwner=v.resolveTemporalResultOwner;exports.supportsCanonicalDashboardTemporalResult=v.supportsCanonicalDashboardTemporalResult;exports.transformComparisonDocument=v.transformComparisonDocument;exports.AUTOMATIC_TEMPORAL_BUCKET_FORMAT=M.AUTOMATIC_TEMPORAL_BUCKET_FORMAT;exports.getTemporalBucketAuthoringOptions=M.getTemporalBucketAuthoringOptions;exports.getTemporalBucketAuthoringSelection=M.getTemporalBucketAuthoringSelection;exports.previewTemporalBucketAuthoringFormat=M.previewTemporalBucketAuthoringFormat;exports.reconcileTemporalBucketAuthoringFormat=M.reconcileTemporalBucketAuthoringFormat;exports.resolveTemporalBucketAuthoringFormat=M.resolveTemporalBucketAuthoringFormat;exports.applyDashboardChangePlan=ot;exports.compileDashboardFromPlan=Ze;exports.compileResponsiveDashboardLayouts=z;exports.dashboardAuthoringDatasetMatchesSource=H;exports.dashboardAuthoringFieldsReferToSameTarget=Fe;exports.dashboardAuthoringSourceFromField=w;exports.dashboardAuthoringSourceKey=Te;exports.dashboardAuthoringSourcesReferToSameDataset=X;exports.dashboardPlanFromSemaphorDashboardIntent=_t;exports.findDashboardAuthoringDatasetForSource=$e;exports.getDashboardAuthoringCardSource=ue;exports.isMaterializableDashboardAuthoringSource=R;exports.isSemaphorSourceRef=se;exports.mergeDashboardAuthoringSources=B;exports.preferDashboardAuthoringSourceMetadata=de;exports.preferredDashboardAuthoringSource=ke;exports.resolveDashboardAuthoringSource=ce;exports.validateDashboardAuthoringDatasetScope=fe;exports.validateDashboardChangePlan=ye;exports.validateDashboardPlan=Ie;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { D as R, a as Ie } from "../chunks/contracts-CoCOpd_i.js";
|
|
2
|
-
import { S as Mt, i as Nt, b as Bt, c as Rt, a as Pt, r as Ot, s as zt, t as Vt } from "../chunks/canonical-result-keys-
|
|
3
|
-
import {
|
|
4
|
-
import "../chunks/analyze-result-contract-
|
|
5
|
-
import
|
|
2
|
+
import { S as Mt, i as Nt, b as Bt, c as Rt, a as Pt, r as Ot, s as zt, t as Vt } from "../chunks/canonical-result-keys-D6avdjpA.js";
|
|
3
|
+
import { m as ye, ah as H, ai as _e, B as ae, n as we, E as ve } from "../chunks/validators-DEmd8Sin.js";
|
|
4
|
+
import "../chunks/analyze-result-contract-BbRJ-C06.js";
|
|
5
|
+
import "../value-format-preferences/index.js";
|
|
6
6
|
import { n as Se } from "../chunks/operators-C8TxpM4C.js";
|
|
7
|
-
import { A as Lt, g as jt, a as Et, p as Ht, b as Wt, r as Kt } from "../chunks/temporal-bucket-authoring-
|
|
7
|
+
import { A as Lt, g as jt, a as Et, p as Ht, b as Wt, r as Kt } from "../chunks/temporal-bucket-authoring-K1kE6R_z.js";
|
|
8
8
|
function _(e) {
|
|
9
9
|
return e && typeof e == "object" ? e : null;
|
|
10
10
|
}
|
|
@@ -550,7 +550,7 @@ function K(e) {
|
|
|
550
550
|
);
|
|
551
551
|
}
|
|
552
552
|
function He(e) {
|
|
553
|
-
const t =
|
|
553
|
+
const t = we(e);
|
|
554
554
|
return t === "datetime" ? "date" : t === "unknown" ? "string" : t;
|
|
555
555
|
}
|
|
556
556
|
function We(e) {
|
|
@@ -1305,7 +1305,7 @@ function bt(e) {
|
|
|
1305
1305
|
}
|
|
1306
1306
|
function Ft(e) {
|
|
1307
1307
|
var v, y, c;
|
|
1308
|
-
const t = [], n =
|
|
1308
|
+
const t = [], n = ve(e);
|
|
1309
1309
|
for (const f of n.warnings)
|
|
1310
1310
|
t.push(b(f.code, f.message));
|
|
1311
1311
|
for (const f of n.errors)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),An=require("react-dom/client"),k=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),An=require("react-dom/client"),k=require("../chunks/index-DIWJALWL.cjs"),w=require("../chunks/switch-D-CCcfhc.cjs"),Ze=require("../data-app-builder-browser-runtime/index.cjs"),te=require("../chunks/x-B6ghREd2.cjs"),Cn=require("../chunks/save-3dYRmehL.cjs"),Rn=require("../chunks/mouse-pointer-2-DX4A_XZw.cjs"),tt=require("../chunks/search-BqqhaMx9.cjs");function Tr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const d=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,d.get?d:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const Bn=Tr(p),Dn=Tr(An);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -2,8 +2,8 @@ import { jsx as r, jsxs as c, Fragment as re } from "react/jsx-runtime";
|
|
|
2
2
|
import * as Zn from "react";
|
|
3
3
|
import { useContext as qn, useState as x, useRef as oe, useMemo as je, useEffect as W, useCallback as Ot } from "react";
|
|
4
4
|
import * as Xn from "react-dom/client";
|
|
5
|
-
import { aM as ea, aN as ta, aO as Ir, aP as jr, aQ as zr, aR as ra, aS as Wr, aT as Hr, aU as Jr, aV as Vr, aW as _r, aX as Ur, aY as Gr, aZ as na, a_ as aa, a$ as oa, b0 as Ht, b1 as on, R as Kr, b2 as sa, b3 as Vt, b4 as sn, b5 as ia, b6 as la } from "../chunks/index-
|
|
6
|
-
import { B as H, P as it, a as lt, b as dt, _ as da, $ as ca, a0 as ua, a1 as pa, a2 as ha, L as me, R as ma, d as _t } from "../chunks/switch-
|
|
5
|
+
import { aM as ea, aN as ta, aO as Ir, aP as jr, aQ as zr, aR as ra, aS as Wr, aT as Hr, aU as Jr, aV as Vr, aW as _r, aX as Ur, aY as Gr, aZ as na, a_ as aa, a$ as oa, b0 as Ht, b1 as on, R as Kr, b2 as sa, b3 as Vt, b4 as sn, b5 as ia, b6 as la } from "../chunks/index-B5Oy1eLv.js";
|
|
6
|
+
import { B as H, P as it, a as lt, b as dt, _ as da, $ as ca, a0 as ua, a1 as pa, a2 as ha, L as me, R as ma, d as _t } from "../chunks/switch-BeZW-HnS.js";
|
|
7
7
|
import { loadSemaphorBrowserRuntime as ot } from "../data-app-builder-browser-runtime/index.js";
|
|
8
8
|
import { c as Ve, X as He } from "../chunks/x-CXDkqdur.js";
|
|
9
9
|
import { S as fa } from "../chunks/save-DgMfP0j8.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/validators-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/validators-BDYprKI9.cjs"),e=require("../chunks/update-policy-BmiOd0PB.cjs");exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=a.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=a.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=e.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=e.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=e.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=e.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=e.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=e.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=e.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=e.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=e.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=e.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=e.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=e.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=e.validateCodegenSummary;exports.validateSemaphorGeneratedContract=e.validateSemaphorGeneratedContract;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as E, a as S, i as A, v as t } from "../chunks/validators-
|
|
2
|
-
import { C as R, a as r, b as s, G as C, e as o, R as p, c as d, f as O, g as i, h as m, i as n, j as N, v as T, d as I } from "../chunks/update-policy-
|
|
1
|
+
import { S as E, a as S, i as A, v as t } from "../chunks/validators-DEmd8Sin.js";
|
|
2
|
+
import { C as R, a as r, b as s, G as C, e as o, R as p, c as d, f as O, g as i, h as m, i as n, j as N, v as T, d as I } from "../chunks/update-policy-hednMF-0.js";
|
|
3
3
|
export {
|
|
4
4
|
R as CODEGEN_SUMMARY_SCHEMA_VERSION,
|
|
5
5
|
r as CODEGEN_SUMMARY_VALIDATOR_VERSION,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("../chunks/validators-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("../chunks/validators-BDYprKI9.cjs"),R=require("../chunks/update-policy-BmiOd0PB.cjs"),he=require("node:crypto"),Ce="src/semaphor/generated",H=`// Generated by Semaphor Agent Plugin. Do not hand-edit analytics wiring here.
|
|
2
2
|
// Regenerate from the accepted semaphor_plan_data_app codegenSummary when the plan changes.
|
|
3
3
|
`;function Oe(e,n={}){R.assertValidCodegenSummary(e);const r=Me(e);if(r.views.length===0&&!n.allowEmpty)throw new Error("Contract generation produced zero executable views. Stop and ask for a different domain/goal or semantic model improvement; pass --allow-empty only for an explicit model-gap report.");const t=ke(r),o=Ne({contract:r,files:t,generatorName:n.generatorName||"react-semaphor/data-app-codegen/node",generatorVersion:n.generatorVersion||"unknown"}),a={...t,"contract.manifest.json":`${JSON.stringify(o,null,2)}
|
|
4
4
|
`};return{schemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,files:a,manifest:o,contentHash:String(o.generatedContentHash||""),usageExample:Te(r),warnings:r.warnings,stats:{inputCount:r.inputs.length,executableViewCount:r.views.length,presentationViewCount:r.presentationViews.length,queryCount:r.views.length,optionQueryCount:r.optionQueries.length}}}function Me(e){var d,p,m,i,l,g,h,I,$,M,b,E;const n=[],r=[];for(const s of e.inputs){S(r,s.fieldRef);for(const V of s.bindings||[])S(r,V.fieldRef);S(r,(d=s.optionQuery)==null?void 0:d.valueFieldRef),S(r,(p=s.optionQuery)==null?void 0:p.labelFieldRef),S(r,(m=s.optionQuery)==null?void 0:m.filterFieldRef),D(r,(i=s.optionQuery)==null?void 0:i.spec)}for(const s of e.filterContracts){S(r,s.fieldRef),S(r,(l=s.optionQuery)==null?void 0:l.valueFieldRef),S(r,(g=s.optionQuery)==null?void 0:g.labelFieldRef),S(r,(h=s.optionQuery)==null?void 0:h.filterFieldRef),D(r,(I=s.optionQuery)==null?void 0:I.spec);for(const V of s.bindings||[])S(r,V.fieldRef)}for(const s of e.views){for(const V of s.fields||[])S(r,V);D(r,($=s.sdkSpec)==null?void 0:$.spec),D(r,s.visualSpec)}const t=e.implementationChecklist||{};for(const s of Object.values(t.bindingsByView||{}))for(const V of Array.isArray(s)?s:[])S(r,V.fieldRef),S(r,V.optionValueField),S(r,V.optionLabelField);for(const s of t.requiredInputOptions||[])S(r,s.visibleLabelField),S(r,s.optionValueField),S(r,s.runtimeFilterField);const o=pn([...e.sources.map(s=>({raw:s,key:Ie(s),aliases:Ve(s),name:""})),...r.map(s=>an(s)).filter(x)]);P(o,s=>{const V=F(s.raw);return j(s.raw.label||(V==null?void 0:V.datasetName)||(V==null?void 0:V.datasetId)||(V==null?void 0:V.name)||s.raw.kind||"source")});const a=ln(o),u=ne(r.filter(s=>s.name).map(s=>({raw:s,key:X(s),name:""})),s=>s.key);P(u,s=>j([s.raw.sourceKey?yn(s.raw.sourceKey):"",s.raw.aggregate?s.raw.aggregate.toLowerCase():"",s.raw.name].filter(Boolean).join("_")));const c=new Map(u.map(s=>[s.key,s.name])),w=e.inputs.map(s=>({raw:s,name:j(s.id||s.label||"input")}));P(w,s=>s.name);const f=w.filter(s=>!!s.raw.optionQuery).map(s=>({input:s,name:`${s.name}Options`,raw:s.raw.optionQuery}));P(f,s=>s.name);for(const s of f)un(s.raw.labelFieldRef,s.raw.valueFieldRef)&&dn(s.raw.valueFieldRef)&&n.push(`Input option query ${((M=s.raw.spec)==null?void 0:M.inputId)||s.input.raw.id||s.name} uses identifier field ${s.raw.valueFieldRef.name} as both label and value. It can execute, but the UI will show key values unless the semantic model exposes a human-readable label through a modeled relationship.`);const y=e.views.filter(s=>{var V,K;return!!((V=s.sdkSpec)!=null&&V.builder&&((K=s.sdkSpec)!=null&&K.spec))}).map(s=>({raw:s,name:j(s.id||s.title||"query")}));P(y,s=>s.name);const k=e.views.filter(s=>fe(s)&&!("sdkSpec"in s)).map(s=>sn(s));for(const s of e.views)(!("sdkSpec"in s)||!((b=s.sdkSpec)!=null&&b.builder)||!((E=s.sdkSpec)!=null&&E.spec))&&!fe(s)&&n.push(`Skipped view ${s.id||s.title||"unknown"} because it has no sdkSpec.`);return Ee({inputs:w,views:y,filterContracts:e.filterContracts}),{summary:e,title:e.title||"Semaphor Data App",sources:o,fields:u,inputs:w,optionQueries:f,views:y,presentationViews:k,filterContracts:e.filterContracts,checklist:t,sourceNameByKey:a,fieldNameByKey:c,warnings:n}}function Ee({inputs:e,views:n,filterContracts:r}){const t=new Set(e.map(a=>a.raw.id).filter(Boolean)),o=new Set(n.map(a=>a.raw.id).filter(Boolean));for(const[a,u]of r.entries()){if(!t.has(u.inputId))throw new Error(`filterContracts.${a}.inputId must reference a generated input.`);const c=new Set(u.appliesToViewIds||[]),w=new Set(u.notAppliedToViewIds||[]);for(const[f,y]of(u.appliesToViewIds||[]).entries())if(!o.has(y))throw new Error(`filterContracts.${a}.appliesToViewIds.${f} must reference an executable generated view.`);for(const[f,y]of(u.notAppliedToViewIds||[]).entries())if(!o.has(y))throw new Error(`filterContracts.${a}.notAppliedToViewIds.${f} must reference an executable generated view.`);for(const[f,y]of(u.bindings||[]).entries()){if(!o.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must reference an executable generated view.`);if(!c.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must be included in appliesToViewIds.`);if(w.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must not be listed in notAppliedToViewIds.`)}}}function ke(e){return{"sources.ts":ve(e),"fields.ts":qe(e),"inputs.ts":De(e),"queries.ts":Pe(e),"bindings.ts":Le(e),"accessors.ts":Ye(e),"metadata.ts":We(e),"index.ts":Xe(),"USAGE.md":Ae(e)}}function Ne({contract:e,files:n,generatorName:r,generatorVersion:t}){return{schemaVersion:R.CONTRACT_MANIFEST_SCHEMA_VERSION,generatedContractSchemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,generator:{name:r,version:t},generatedContentHash:Ge(n),codegenSummaryValidatorVersion:R.CODEGEN_SUMMARY_VALIDATOR_VERSION,codegenSummaryHash:xe(e.summary),codegenSummary:e.summary}}function Ge(e){const n=he.createHash("sha256");for(const r of Object.keys(e).filter(t=>t.endsWith(".ts")).sort())n.update(r),n.update("\0"),n.update(e[r]),n.update("\0");return`sha256:${n.digest("hex")}`}function Ae(e){const n=["# Semaphor Generated Data App Contract","","Generated files in this directory are governed Semaphor analytics wiring. Do not hand-edit them.","","Use the app-facing exports from `index.ts`:","","- `queries`: generated governed query factories.","- `queryOptionsForView`: active-input wiring for each generated view.","- `rowsForView`: table/records row readers.","- `rowValuesForView`: friendly row object readers for chart/table views.","- `metricValuesForView`: friendly metric-value readers.","- `kpiPropsForView`: KPI component props derived from runtime metric results.","- `roleValuesForView`: canonical dimension/measure/date/id role readers.","- `appInputSpecs`: generated input/filter specs.","- `inputOptionQueries`: option-list query factories for generated inputs.","- `semaphorGeneratedContractMetadata`: generated view/input metadata and presentation-only views.","","Start with these exports before opening large generated internals such as `metadata.ts`.",""];return e.views.length>0&&(n.push("Generated executable views:"),e.views.forEach(r=>{n.push(`- \`${r.raw.id}\`: ${r.raw.title||r.name}`)}),n.push("")),e.inputs.length>0&&(n.push("Generated inputs:"),e.inputs.forEach(r=>{n.push(`- \`${r.raw.id}\`: ${r.raw.label||r.name}`)}),n.push("")),`${n.join(`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as Vn, a as Fn, i as bn, v as kn } from "../chunks/validators-
|
|
2
|
-
import { c as ke, G as fe, a as Re, b as Me } from "../chunks/update-policy-
|
|
3
|
-
import { C as Mn, e as Cn, R as On, f as xn, g as Gn, h as Nn, i as En, j as An, v as jn, d as vn } from "../chunks/update-policy-
|
|
1
|
+
import { S as Vn, a as Fn, i as bn, v as kn } from "../chunks/validators-DEmd8Sin.js";
|
|
2
|
+
import { c as ke, G as fe, a as Re, b as Me } from "../chunks/update-policy-hednMF-0.js";
|
|
3
|
+
import { C as Mn, e as Cn, R as On, f as xn, g as Gn, h as Nn, i as En, j as An, v as jn, d as vn } from "../chunks/update-policy-hednMF-0.js";
|
|
4
4
|
import { createHash as ye } from "node:crypto";
|
|
5
5
|
const wn = "src/semaphor/generated", v = `// Generated by Semaphor Agent Plugin. Do not hand-edit analytics wiring here.
|
|
6
6
|
// Regenerate from the accepted semaphor_plan_data_app codegenSummary when the plan changes.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../data-app-sdk-adapters/index.cjs"),i=require("react/jsx-runtime"),c=require("react"),ae=require("../chunks/validators-Dm7Kpz6p.cjs");require("../chunks/analyze-result-contract-Dxw66nUG.cjs");const se=require("../chunks/search-BqqhaMx9.cjs"),Ke=require("../chunks/x-B6ghREd2.cjs");function ue(e,r,t={}){return{...t,name:e,role:r}}function Mr(e){return e}function Kr(e){return e}const Wr={source:{semantic(e){return{...e,kind:"semantic"}},sql(e){return{...e,kind:"sql"}}},field:{measure(e,r){return ue(e,"measure",r)},dimension(e,r){return ue(e,"dimension",r)},date(e,r){return ue(e,"date",r)},id(e,r){return ue(e,"id",r)}},filter(e){return{...e,kind:"filter"}},bindInput(e,r){return{toAnalyticsInput(){const[t]=w.toSemaphorInputSnapshots([e]),n=w.toSemaphorInputBinding({...r,inputId:r.inputId||t.inputId});return{...t,inputId:n.inputId,...n.kind?{kind:n.kind}:{},...n.controlRole?{controlRole:n.controlRole}:{},...n.operator?{operator:n.operator}:{},...n.field?{field:n.field}:{},...n.relationshipHint?{relationshipHint:n.relationshipHint}:{}}}}},control(e){return{...e,kind:"control"}},sqlParam(e){return{...e,kind:"control",role:"sqlParam"}},derivedField(e){return{...e,kind:"derived_field",expressionLanguage:e.expressionLanguage||"semaphor_sql_template"}},metric(e){return{...e,queryKind:"metric"}},analysis(e){return{...e,queryKind:"analysis"}},records(e){return{...e,queryKind:"records"}},inputOptions(e){return{...e,queryKind:"inputOptions"}},sql(e){return{...e,queryKind:"sql"}},matrix(e){return{...e,queryKind:"matrix"}}},ie=10,Le=8;function We(e,r){const t=e==null?void 0:e.result;if(t)switch(t.kind){case"records":return te({title:"Records",rowNoun:"rows",records:t.records,columns:t.columns,rowCount:t.rowCount});case"sql":return te({title:"SQL Rows",rowNoun:"rows",records:t.records,columns:t.columns,rowCount:t.rowCount});case"inputOptions":return te({title:"Options",rowNoun:"options",records:t.options.slice(0,ie).map(n=>{var s;return{label:n.label,value:n.value,count:n.count,disambiguation:(s=n.disambiguation)==null?void 0:s.join(" / ")}}),columns:[{key:"label",label:"Label"},{key:"value",label:"Value"},{key:"count",label:"Count"},{key:"disambiguation",label:"Disambiguation"}],rowCount:t.rowCount??t.options.length});case"metric":return _r(t,r);case"matrix":return te({title:"Matrix Cells",rowNoun:"cells",records:t.cells.slice(0,ie).map(n=>{const s=t.nodesById[n.rowId],o=n.columnId?t.nodesById[n.columnId]:void 0,u=t.measuresById[n.measureId];return{row:(s==null?void 0:s.label)||n.rowId,column:(o==null?void 0:o.label)||n.columnId||"Total",measure:(u==null?void 0:u.label)||n.measureId,value:n.value,role:n.role}}),columns:[{key:"row",label:"Row"},{key:"column",label:"Column"},{key:"measure",label:"Measure"},{key:"value",label:"Value"},{key:"role",label:"Role"}],rowCount:t.rowCount??t.cells.length});default:return Fr(t)}}function _r(e,r){var o,u,p,d,f;const t=[{metric:"primaryValue",value:(r==null?void 0:r.primaryValue)??e.primaryValue}],n=(r==null?void 0:r.comparisonKind)??((o=e.comparison)==null?void 0:o.kind);return n&&t.push({metric:`${n} value`,value:(r==null?void 0:r.comparisonValue)??((u=e.comparison)==null?void 0:u.value)},{metric:"delta",value:(r==null?void 0:r.delta)??((p=e.comparison)==null?void 0:p.delta)},{metric:"deltaPercent",value:(r==null?void 0:r.deltaPercent)??((d=e.comparison)==null?void 0:d.deltaPercent)}),(((f=r==null?void 0:r.missingMeasures)==null?void 0:f.filter(Boolean))??[]).forEach(g=>{t.push({metric:`missing:${g}`,value:"missing"})}),Object.entries((r==null?void 0:r.measures)??{}).sort(([g],[m])=>g.localeCompare(m)).forEach(([g,m])=>{t.push({metric:`measure:${g}`,value:m})}),Object.entries((r==null?void 0:r.measureBindings)??{}).sort(([g],[m])=>g.localeCompare(m)).forEach(([g,m])=>{t.push({metric:`binding:${g}`,value:m})}),te({title:"Metric",rowNoun:"values",records:t,columns:[{key:"metric",label:"Metric"},{key:"value",label:"Value"}],rowCount:t.length})}function te({title:e,rowNoun:r,records:t,columns:n,rowCount:s}){const o=Nr(n,t);if(!o.length)return;const u=s??t.length,p=t.slice(0,ie);return{title:e,summary:`${Pr(u)} ${r}`,columns:o.slice(0,Le),rows:p,truncatedRows:u>p.length,truncatedColumns:o.length>Le}}function Nr(e,r){if(e!=null&&e.length)return e.filter(n=>n.key).map(n=>({key:n.key,label:n.label||n.key}));const t=new Set;return r.slice(0,ie).forEach(n=>{Object.keys(n).forEach(s=>t.add(s))}),[...t].map(n=>({key:n,label:n}))}function Fr(e){throw new Error(`Unhandled Semaphor result kind: ${pr(e)}`)}function zr(e){return e===null?"null":e===void 0?"":typeof e=="string"?rr(e):typeof e=="number"||typeof e=="boolean"?String(e):rr(pr(e))}function Pr(e){return typeof e=="number"?e.toLocaleString():"-"}function pr(e){return JSON.stringify(e,null,2)??"undefined"}function rr(e){return e.length>80?`${e.slice(0,77)}...`:e}function he(e){return e.viewTitle||e.queryLabel||e.viewId||e.queryId}function Hr(e){if(e.label)return e.label;if(e.queryKind!=="inputOptions")return;const t=e.labelField.label||e.valueField.label||e.labelField.name||e.valueField.name||e.inputId;return`${Vr(t)} Options`}function Vr(e){return(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\bfilter\b/gi," ").replace(/\boptions?\b/gi," ").replace(/\bid\b/gi," ").replace(/\s+/g," ").trim()||e).split(" ").filter(Boolean).map(n=>n===n.toUpperCase()&&n.length>1?n:`${n.slice(0,1).toUpperCase()}${n.slice(1)}`).join(" ")}function _e(e){return e.flatMap(r=>{var g,m,v,y;const t=r.latestAttempt,n=t==null?void 0:t.executionResult,s=Se((g=n==null?void 0:n.validation)==null?void 0:g.warnings),o=Se((m=n==null?void 0:n.validation)==null?void 0:m.errors),u=Jr((v=n==null?void 0:n.coverage)==null?void 0:v.missingObligations),p=Se((y=n==null?void 0:n.coverage)==null?void 0:y.warnings),d=[],f=he(r);(t==null?void 0:t.status)==="error"&&d.push({trace:r,tone:"error",title:f,message:t.errorMessage||"Query attempt failed."});for(const h of r.clientWarnings)d.push({trace:r,tone:"warning",title:f,message:h});for(const h of s)d.push({trace:r,tone:"warning",title:f,...h});for(const h of o)d.push({trace:r,tone:"error",title:f,...h});for(const h of u)d.push({trace:r,tone:"warning",title:f,message:h});for(const h of p)d.push({trace:r,tone:"warning",title:f,...h});return d})}function Qr(e){return{traceId:e.trace.traceId,queryId:e.trace.queryId,viewId:e.trace.viewId,viewTitle:e.trace.viewTitle,queryLabel:e.trace.queryLabel,severity:e.tone,title:e.title,message:e.message,code:e.code,path:e.path}}function Ur(e,r){return e.filter(t=>t.trace.traceId===r.traceId).length}function Gr(e){const r=_e(e),t=e.filter(u=>{var p;return((p=u.latestAttempt)==null?void 0:p.status)==="error"}).length,n=e.filter(u=>{var p;return((p=u.latestAttempt)==null?void 0:p.status)==="loading"}).length,s=r.filter(u=>u.tone==="error").length,o=r.filter(u=>u.tone==="warning").length;return{total:e.length,failed:t,loading:n,errorCount:s,warningCount:o,issueCount:r.length,severity:t||s?"error":o?"warning":n?"loading":"ok"}}function Jr(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function Se(e){return Array.isArray(e)?e.map(Yr).filter(r=>!!r):[]}function Yr(e){if(typeof e=="string")return{message:e};if(!e||typeof e!="object"||Array.isArray(e))return;const r=e,t=typeof r.message=="string"?r.message:"",n=typeof r.code=="string"?r.code:"",s=typeof r.path=="string"?r.path:"";return t&&n?{message:s?`${t} (${n}, ${s})`:`${t} (${n})`,code:n,...s?{path:s}:{}}:t?{message:t,...s?{path:s}:{}}:n?{message:n,code:n}:void 0}function Xr(e){if(!e.enabled)return e;const r=e.queries.map(gr);return{enabled:e.enabled,queries:r,issues:e.issues,getQuery:t=>r.find(n=>n.queryId===t),getQueries:t=>r.filter(n=>n.queryId===t)}}function tr(e){return e?gr(e):void 0}function gr(e){var r;return(r=e==null?void 0:e.latestAttempt)!=null&&r.executionResult?{...e,latestAttempt:{...e.latestAttempt,resultPreview:e.latestAttempt.resultPreview||We(e.latestAttempt.executionResult),executionResult:Zr(e.latestAttempt.executionResult)}}:e}function Zr(e){const{compiledQuery:r,intent:t,result:n,...s}=e,o=et(s.metadata);return{...s,...o?{metadata:o}:{}}}function et(e){if(!e||typeof e!="object"||Array.isArray(e))return e;const r=e.dataAppDebug;if(!r||typeof r!="object"||Array.isArray(r))return e;const{compiledSql:t,...n}=r;return{...e,dataAppDebug:n}}function rt(e){return e==="relative"?{position:"relative",top:"auto",right:"auto",bottom:"auto",left:"auto"}:{top:e.startsWith("top")?20:"auto",right:e.endsWith("right")?20:"auto",bottom:e.startsWith("bottom")?20:"auto",left:e.endsWith("left")?20:"auto"}}function tt(e){return e==="error"?{borderColor:"var(--sd-error-border)",background:"var(--sd-error-bg)",color:"var(--sd-error-fg)"}:e==="warning"?{borderColor:"var(--sd-warning-border)",background:"var(--sd-warning-bg)",color:"var(--sd-warning-fg)"}:e==="loading"?{borderColor:"var(--sd-loading-border)",background:"var(--sd-loading-bg)",color:"var(--sd-loading-fg)"}:{borderColor:"var(--sd-success-border)",background:"var(--sd-success-bg)",color:"var(--sd-success-fg)"}}function nt(e){return e==="right"?{top:16,right:16,bottom:16,left:"auto",width:"min(720px, calc(100vw - 32px))",height:"auto",borderRadius:6}:{top:"auto",right:16,bottom:16,left:16,width:"auto",height:"min(420px, 45vh)",borderRadius:6}}function st(e){return e==="right"?{gridTemplateColumns:"minmax(210px, 280px) minmax(0, 1fr)"}:{gridTemplateColumns:"minmax(260px, 340px) minmax(0, 1fr)"}}function it(e){return{borderRight:"1px solid var(--sd-border)",borderBottom:0}}function mr(e){return e==="error"?{background:"var(--sd-error-dot)"}:e==="success"?{background:"var(--sd-success-dot)"}:e==="loading"?{background:"var(--sd-loading-dot)"}:{background:"var(--sd-idle-dot)"}}function ot(e){return e==="error"?{borderColor:"var(--sd-error-border)",color:"var(--sd-error-fg)"}:e==="success"?{borderColor:"var(--sd-success-border)",color:"var(--sd-success-fg)"}:e==="loading"?{borderColor:"var(--sd-loading-border)",color:"var(--sd-loading-fg)"}:{borderColor:"var(--sd-border)",color:"var(--sd-fg-muted)"}}const nr="semaphor-devtools-stylesheet",T="semaphor-devtools",at=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../data-app-sdk-adapters/index.cjs"),i=require("react/jsx-runtime"),c=require("react"),ae=require("../chunks/validators-BDYprKI9.cjs");require("../chunks/analyze-result-contract-LPDNldic.cjs");require("../value-format-preferences/index.cjs");const se=require("../chunks/search-BqqhaMx9.cjs"),Ke=require("../chunks/x-B6ghREd2.cjs");function ue(e,r,t={}){return{...t,name:e,role:r}}function Mr(e){return e}function Kr(e){return e}const Wr={source:{semantic(e){return{...e,kind:"semantic"}},sql(e){return{...e,kind:"sql"}}},field:{measure(e,r){return ue(e,"measure",r)},dimension(e,r){return ue(e,"dimension",r)},date(e,r){return ue(e,"date",r)},id(e,r){return ue(e,"id",r)}},filter(e){return{...e,kind:"filter"}},bindInput(e,r){return{toAnalyticsInput(){const[t]=w.toSemaphorInputSnapshots([e]),n=w.toSemaphorInputBinding({...r,inputId:r.inputId||t.inputId});return{...t,inputId:n.inputId,...n.kind?{kind:n.kind}:{},...n.controlRole?{controlRole:n.controlRole}:{},...n.operator?{operator:n.operator}:{},...n.field?{field:n.field}:{},...n.relationshipHint?{relationshipHint:n.relationshipHint}:{}}}}},control(e){return{...e,kind:"control"}},sqlParam(e){return{...e,kind:"control",role:"sqlParam"}},derivedField(e){return{...e,kind:"derived_field",expressionLanguage:e.expressionLanguage||"semaphor_sql_template"}},metric(e){return{...e,queryKind:"metric"}},analysis(e){return{...e,queryKind:"analysis"}},records(e){return{...e,queryKind:"records"}},inputOptions(e){return{...e,queryKind:"inputOptions"}},sql(e){return{...e,queryKind:"sql"}},matrix(e){return{...e,queryKind:"matrix"}}},ie=10,Le=8;function We(e,r){const t=e==null?void 0:e.result;if(t)switch(t.kind){case"records":return te({title:"Records",rowNoun:"rows",records:t.records,columns:t.columns,rowCount:t.rowCount});case"sql":return te({title:"SQL Rows",rowNoun:"rows",records:t.records,columns:t.columns,rowCount:t.rowCount});case"inputOptions":return te({title:"Options",rowNoun:"options",records:t.options.slice(0,ie).map(n=>{var s;return{label:n.label,value:n.value,count:n.count,disambiguation:(s=n.disambiguation)==null?void 0:s.join(" / ")}}),columns:[{key:"label",label:"Label"},{key:"value",label:"Value"},{key:"count",label:"Count"},{key:"disambiguation",label:"Disambiguation"}],rowCount:t.rowCount??t.options.length});case"metric":return _r(t,r);case"matrix":return te({title:"Matrix Cells",rowNoun:"cells",records:t.cells.slice(0,ie).map(n=>{const s=t.nodesById[n.rowId],o=n.columnId?t.nodesById[n.columnId]:void 0,u=t.measuresById[n.measureId];return{row:(s==null?void 0:s.label)||n.rowId,column:(o==null?void 0:o.label)||n.columnId||"Total",measure:(u==null?void 0:u.label)||n.measureId,value:n.value,role:n.role}}),columns:[{key:"row",label:"Row"},{key:"column",label:"Column"},{key:"measure",label:"Measure"},{key:"value",label:"Value"},{key:"role",label:"Role"}],rowCount:t.rowCount??t.cells.length});default:return Fr(t)}}function _r(e,r){var o,u,p,d,f;const t=[{metric:"primaryValue",value:(r==null?void 0:r.primaryValue)??e.primaryValue}],n=(r==null?void 0:r.comparisonKind)??((o=e.comparison)==null?void 0:o.kind);return n&&t.push({metric:`${n} value`,value:(r==null?void 0:r.comparisonValue)??((u=e.comparison)==null?void 0:u.value)},{metric:"delta",value:(r==null?void 0:r.delta)??((p=e.comparison)==null?void 0:p.delta)},{metric:"deltaPercent",value:(r==null?void 0:r.deltaPercent)??((d=e.comparison)==null?void 0:d.deltaPercent)}),(((f=r==null?void 0:r.missingMeasures)==null?void 0:f.filter(Boolean))??[]).forEach(g=>{t.push({metric:`missing:${g}`,value:"missing"})}),Object.entries((r==null?void 0:r.measures)??{}).sort(([g],[m])=>g.localeCompare(m)).forEach(([g,m])=>{t.push({metric:`measure:${g}`,value:m})}),Object.entries((r==null?void 0:r.measureBindings)??{}).sort(([g],[m])=>g.localeCompare(m)).forEach(([g,m])=>{t.push({metric:`binding:${g}`,value:m})}),te({title:"Metric",rowNoun:"values",records:t,columns:[{key:"metric",label:"Metric"},{key:"value",label:"Value"}],rowCount:t.length})}function te({title:e,rowNoun:r,records:t,columns:n,rowCount:s}){const o=Nr(n,t);if(!o.length)return;const u=s??t.length,p=t.slice(0,ie);return{title:e,summary:`${Pr(u)} ${r}`,columns:o.slice(0,Le),rows:p,truncatedRows:u>p.length,truncatedColumns:o.length>Le}}function Nr(e,r){if(e!=null&&e.length)return e.filter(n=>n.key).map(n=>({key:n.key,label:n.label||n.key}));const t=new Set;return r.slice(0,ie).forEach(n=>{Object.keys(n).forEach(s=>t.add(s))}),[...t].map(n=>({key:n,label:n}))}function Fr(e){throw new Error(`Unhandled Semaphor result kind: ${pr(e)}`)}function zr(e){return e===null?"null":e===void 0?"":typeof e=="string"?rr(e):typeof e=="number"||typeof e=="boolean"?String(e):rr(pr(e))}function Pr(e){return typeof e=="number"?e.toLocaleString():"-"}function pr(e){return JSON.stringify(e,null,2)??"undefined"}function rr(e){return e.length>80?`${e.slice(0,77)}...`:e}function he(e){return e.viewTitle||e.queryLabel||e.viewId||e.queryId}function Hr(e){if(e.label)return e.label;if(e.queryKind!=="inputOptions")return;const t=e.labelField.label||e.valueField.label||e.labelField.name||e.valueField.name||e.inputId;return`${Vr(t)} Options`}function Vr(e){return(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\bfilter\b/gi," ").replace(/\boptions?\b/gi," ").replace(/\bid\b/gi," ").replace(/\s+/g," ").trim()||e).split(" ").filter(Boolean).map(n=>n===n.toUpperCase()&&n.length>1?n:`${n.slice(0,1).toUpperCase()}${n.slice(1)}`).join(" ")}function _e(e){return e.flatMap(r=>{var g,m,v,y;const t=r.latestAttempt,n=t==null?void 0:t.executionResult,s=Se((g=n==null?void 0:n.validation)==null?void 0:g.warnings),o=Se((m=n==null?void 0:n.validation)==null?void 0:m.errors),u=Jr((v=n==null?void 0:n.coverage)==null?void 0:v.missingObligations),p=Se((y=n==null?void 0:n.coverage)==null?void 0:y.warnings),d=[],f=he(r);(t==null?void 0:t.status)==="error"&&d.push({trace:r,tone:"error",title:f,message:t.errorMessage||"Query attempt failed."});for(const h of r.clientWarnings)d.push({trace:r,tone:"warning",title:f,message:h});for(const h of s)d.push({trace:r,tone:"warning",title:f,...h});for(const h of o)d.push({trace:r,tone:"error",title:f,...h});for(const h of u)d.push({trace:r,tone:"warning",title:f,message:h});for(const h of p)d.push({trace:r,tone:"warning",title:f,...h});return d})}function Qr(e){return{traceId:e.trace.traceId,queryId:e.trace.queryId,viewId:e.trace.viewId,viewTitle:e.trace.viewTitle,queryLabel:e.trace.queryLabel,severity:e.tone,title:e.title,message:e.message,code:e.code,path:e.path}}function Ur(e,r){return e.filter(t=>t.trace.traceId===r.traceId).length}function Gr(e){const r=_e(e),t=e.filter(u=>{var p;return((p=u.latestAttempt)==null?void 0:p.status)==="error"}).length,n=e.filter(u=>{var p;return((p=u.latestAttempt)==null?void 0:p.status)==="loading"}).length,s=r.filter(u=>u.tone==="error").length,o=r.filter(u=>u.tone==="warning").length;return{total:e.length,failed:t,loading:n,errorCount:s,warningCount:o,issueCount:r.length,severity:t||s?"error":o?"warning":n?"loading":"ok"}}function Jr(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function Se(e){return Array.isArray(e)?e.map(Yr).filter(r=>!!r):[]}function Yr(e){if(typeof e=="string")return{message:e};if(!e||typeof e!="object"||Array.isArray(e))return;const r=e,t=typeof r.message=="string"?r.message:"",n=typeof r.code=="string"?r.code:"",s=typeof r.path=="string"?r.path:"";return t&&n?{message:s?`${t} (${n}, ${s})`:`${t} (${n})`,code:n,...s?{path:s}:{}}:t?{message:t,...s?{path:s}:{}}:n?{message:n,code:n}:void 0}function Xr(e){if(!e.enabled)return e;const r=e.queries.map(gr);return{enabled:e.enabled,queries:r,issues:e.issues,getQuery:t=>r.find(n=>n.queryId===t),getQueries:t=>r.filter(n=>n.queryId===t)}}function tr(e){return e?gr(e):void 0}function gr(e){var r;return(r=e==null?void 0:e.latestAttempt)!=null&&r.executionResult?{...e,latestAttempt:{...e.latestAttempt,resultPreview:e.latestAttempt.resultPreview||We(e.latestAttempt.executionResult),executionResult:Zr(e.latestAttempt.executionResult)}}:e}function Zr(e){const{compiledQuery:r,intent:t,result:n,...s}=e,o=et(s.metadata);return{...s,...o?{metadata:o}:{}}}function et(e){if(!e||typeof e!="object"||Array.isArray(e))return e;const r=e.dataAppDebug;if(!r||typeof r!="object"||Array.isArray(r))return e;const{compiledSql:t,...n}=r;return{...e,dataAppDebug:n}}function rt(e){return e==="relative"?{position:"relative",top:"auto",right:"auto",bottom:"auto",left:"auto"}:{top:e.startsWith("top")?20:"auto",right:e.endsWith("right")?20:"auto",bottom:e.startsWith("bottom")?20:"auto",left:e.endsWith("left")?20:"auto"}}function tt(e){return e==="error"?{borderColor:"var(--sd-error-border)",background:"var(--sd-error-bg)",color:"var(--sd-error-fg)"}:e==="warning"?{borderColor:"var(--sd-warning-border)",background:"var(--sd-warning-bg)",color:"var(--sd-warning-fg)"}:e==="loading"?{borderColor:"var(--sd-loading-border)",background:"var(--sd-loading-bg)",color:"var(--sd-loading-fg)"}:{borderColor:"var(--sd-success-border)",background:"var(--sd-success-bg)",color:"var(--sd-success-fg)"}}function nt(e){return e==="right"?{top:16,right:16,bottom:16,left:"auto",width:"min(720px, calc(100vw - 32px))",height:"auto",borderRadius:6}:{top:"auto",right:16,bottom:16,left:16,width:"auto",height:"min(420px, 45vh)",borderRadius:6}}function st(e){return e==="right"?{gridTemplateColumns:"minmax(210px, 280px) minmax(0, 1fr)"}:{gridTemplateColumns:"minmax(260px, 340px) minmax(0, 1fr)"}}function it(e){return{borderRight:"1px solid var(--sd-border)",borderBottom:0}}function mr(e){return e==="error"?{background:"var(--sd-error-dot)"}:e==="success"?{background:"var(--sd-success-dot)"}:e==="loading"?{background:"var(--sd-loading-dot)"}:{background:"var(--sd-idle-dot)"}}function ot(e){return e==="error"?{borderColor:"var(--sd-error-border)",color:"var(--sd-error-fg)"}:e==="success"?{borderColor:"var(--sd-success-border)",color:"var(--sd-success-fg)"}:e==="loading"?{borderColor:"var(--sd-loading-border)",color:"var(--sd-loading-fg)"}:{borderColor:"var(--sd-border)",color:"var(--sd-fg-muted)"}}const nr="semaphor-devtools-stylesheet",T="semaphor-devtools",at=`
|
|
2
2
|
.${T} {
|
|
3
3
|
--sd-bg: #ffffff;
|
|
4
4
|
--sd-bg-muted: #fafafa;
|