react-semaphor 0.1.399 → 0.1.400

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +1 -1
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +2 -2
  5. package/dist/chunks/{analyze-result-contract-CUO5QmqV.js → analyze-result-contract-BUgK3759.js} +675 -639
  6. package/dist/chunks/analyze-result-contract-S8u7CcPL.js +1 -0
  7. package/dist/chunks/{calendar-preferences-dialog-B3fnFtJt.js → calendar-preferences-dialog-Ci3rHHgA.js} +1 -1
  8. package/dist/chunks/{calendar-preferences-dialog-9SvYDLp6.js → calendar-preferences-dialog-i3-jBIYS.js} +3 -3
  9. package/dist/chunks/{dashboard-briefing-launcher-APVyc9al.js → dashboard-briefing-launcher-BpwjeJsQ.js} +4 -4
  10. package/dist/chunks/{dashboard-briefing-launcher-D3R4R7ww.js → dashboard-briefing-launcher-DiEpMS9E.js} +1 -1
  11. package/dist/chunks/{dashboard-controls-v7jslCXR.js → dashboard-controls-BaUUrvSI.js} +1 -1
  12. package/dist/chunks/{dashboard-controls-CHDQlMZ9.js → dashboard-controls-Bkjpgr3d.js} +5 -5
  13. package/dist/chunks/{dashboard-json-L1Qo5xcX.js → dashboard-json-CxNyExRm.js} +1 -1
  14. package/dist/chunks/{dashboard-json-DF_syvRu.js → dashboard-json-DvULhhN2.js} +3 -3
  15. package/dist/chunks/{edit-dashboard-visual-DwfIWUe-.js → edit-dashboard-visual-DBrsgEtL.js} +4 -4
  16. package/dist/chunks/{edit-dashboard-visual-qdruQruO.js → edit-dashboard-visual-DJRPiKdY.js} +1 -1
  17. package/dist/chunks/{index-DH7hOGQl.js → index-BepF6hoa.js} +2 -2
  18. package/dist/chunks/{index-BdVymLVq.js → index-Drz04wqE.js} +5 -5
  19. package/dist/chunks/{switch-CYG3dY8r.js → switch-D2oOmorN.js} +1 -1
  20. package/dist/chunks/{switch-BiU6-YSY.js → switch-qUw8u-gU.js} +1 -1
  21. package/dist/chunks/update-policy-BmtOqvbf.js +3 -0
  22. package/dist/chunks/update-policy-KImUg4Od.js +831 -0
  23. package/dist/chunks/{use-create-flow-overlay-state-CwUkhLBL.js → use-create-flow-overlay-state-CFJIHt5D.js} +3 -3
  24. package/dist/chunks/{use-create-flow-overlay-state-qe7DHQKr.js → use-create-flow-overlay-state-DrkYiyQz.js} +1 -1
  25. package/dist/dashboard/index.cjs +1 -1
  26. package/dist/dashboard/index.js +1 -1
  27. package/dist/dashboard-authoring/index.cjs +1 -1
  28. package/dist/dashboard-authoring/index.js +1 -1
  29. package/dist/data-app-builder/index.cjs +1 -1
  30. package/dist/data-app-builder/index.js +2 -2
  31. package/dist/data-app-codegen/index.cjs +1 -0
  32. package/dist/data-app-codegen/index.js +22 -0
  33. package/dist/data-app-codegen-node/index.cjs +462 -0
  34. package/dist/data-app-codegen-node/index.js +1424 -0
  35. package/dist/data-app-sdk/index.cjs +1 -1
  36. package/dist/data-app-sdk/index.js +1 -1
  37. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  38. package/dist/data-app-sdk-adapters/index.js +1 -1
  39. package/dist/data-app-sdk-validation/index.cjs +1 -1
  40. package/dist/data-app-sdk-validation/index.js +1 -1
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.js +7 -7
  43. package/dist/surfboard/index.cjs +1 -1
  44. package/dist/surfboard/index.js +2 -2
  45. package/dist/types/data-app-codegen-node.d.ts +1165 -0
  46. package/dist/types/data-app-codegen.d.ts +1137 -0
  47. package/package.json +9 -1
  48. package/dist/chunks/analyze-result-contract-OqFtOCpZ.js +0 -1
@@ -1,9 +1,9 @@
1
1
  import { c as ge, X as et, C as je } from "./x-CXDkqdur.js";
2
2
  import { useState as K, useEffect as ie, useCallback as B, useMemo as P, useRef as Se, Fragment as bt } from "react";
3
- import { F as de, A as Le, u as Z, E as M, a4 as yt, Q as vt, V as xt, W as Ct, c as fe, Y as kt, a5 as St, B as q, d as Nt, e as tt, a6 as wt, a7 as Dt, a8 as pe, a9 as Qe, aa as $e, ab as Ne, ac as we, ad as Et, ae as Pe, af as It, ag as Ft, ah as me, ai as Vt, aj as He, ak as at, al as rt, am as st, L as oe, Z as nt, _ as De, $ as Ee, a0 as Ie, a1 as Fe, a2 as Ve, an as ot, ao as Tt, ap as _t, aq as We, ar as Lt, as as Ke, at as At, au as Te } from "./switch-BiU6-YSY.js";
4
- import { aB as qt, u as Mt, aC as ce, aD as Ot, aE as Ae, aF as zt, aG as Ut, aH as Bt, p as R, aI as Rt, aJ as jt, aK as lt, aL as Qt, aM as $t, aN as Pt, aO as Ht, aP as Wt, y as Kt, aQ as Yt, aR as it, aS as dt, aT as Gt, aU as Jt, aV as Xt, aW as Zt, aX as ea, aY as ct, aZ as ut, a_ as ta, a$ as aa, b0 as ra, b1 as sa, b2 as na, ar as oa, b3 as la, b4 as ia } from "./index-BdVymLVq.js";
3
+ import { F as de, A as Le, u as Z, E as M, a4 as yt, Q as vt, V as xt, W as Ct, c as fe, Y as kt, a5 as St, B as q, d as Nt, e as tt, a6 as wt, a7 as Dt, a8 as pe, a9 as Qe, aa as $e, ab as Ne, ac as we, ad as Et, ae as Pe, af as It, ag as Ft, ah as me, ai as Vt, aj as He, ak as at, al as rt, am as st, L as oe, Z as nt, _ as De, $ as Ee, a0 as Ie, a1 as Fe, a2 as Ve, an as ot, ao as Tt, ap as _t, aq as We, ar as Lt, as as Ke, at as At, au as Te } from "./switch-qUw8u-gU.js";
4
+ import { aB as qt, u as Mt, aC as ce, aD as Ot, aE as Ae, aF as zt, aG as Ut, aH as Bt, p as R, aI as Rt, aJ as jt, aK as lt, aL as Qt, aM as $t, aN as Pt, aO as Ht, aP as Wt, y as Kt, aQ as Yt, aR as it, aS as dt, aT as Gt, aU as Jt, aV as Xt, aW as Zt, aX as ea, aY as ct, aZ as ut, a_ as ta, a$ as aa, b0 as ra, b1 as sa, b2 as na, ar as oa, b3 as la, b4 as ia } from "./index-Drz04wqE.js";
5
5
  import { jsx as a, jsxs as m, Fragment as re } from "react/jsx-runtime";
6
- import "./analyze-result-contract-CUO5QmqV.js";
6
+ import "./analyze-result-contract-BUgK3759.js";
7
7
  import { S as pt } from "./save-DgMfP0j8.js";
8
8
  import { C as Ye } from "./search-BHsQIWBV.js";
9
9
  /**
@@ -1,4 +1,4 @@
1
- "use strict";const W=require("./x-B6ghREd2.js"),C=require("react"),s=require("./switch-CYG3dY8r.js"),f=require("./index-DH7hOGQl.js"),e=require("react/jsx-runtime");require("./analyze-result-contract-OqFtOCpZ.js");const ke=require("./save-C__QggEE.js"),ye=require("./search-DNCejM7Z.js");/**
1
+ "use strict";const W=require("./x-B6ghREd2.js"),C=require("react"),s=require("./switch-D2oOmorN.js"),f=require("./index-BepF6hoa.js"),e=require("react/jsx-runtime");require("./analyze-result-contract-S8u7CcPL.js");const ke=require("./save-C__QggEE.js"),ye=require("./search-DNCejM7Z.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-DH7hOGQl.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-BepF6hoa.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as o } from "../chunks/index-BdVymLVq.js";
1
+ import { D as o } from "../chunks/index-Drz04wqE.js";
2
2
  import { C as s, E as C } from "../chunks/common-types-4bjoIgvm.js";
3
3
  export {
4
4
  s as CONTROL_CARD_DEFAULT_VALUE,
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("../chunks/contracts-CtB2VONT.js"),M=require("../chunks/source-identity-uMaUe036.js"),U=require("../chunks/validators-DFOX0tYY.js");require("../chunks/analyze-result-contract-OqFtOCpZ.js");const De=require("../chunks/catalog-field-grounding-Bnx-3tE0.js"),ve=require("../chunks/operators-DrTQsJXv.js");function _(e){return e&&typeof e=="object"?e:null}function D(e){return typeof e=="string"?e:null}function oe(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 F(e){return oe(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function Ce(e){return M.semaphorSourceIdentityKey(e)}function K(e,t){return M.semaphorSourcesReferToSameDataset(e,t)}function se(e,t){return M.preferSemaphorSourceMetadata(e,t)}function N(e){const t=[];for(const r of e){const n=t.findIndex(o=>K(o,r));n===-1?t.push(r):t[n]=se(t[n],r)}return t}function ke(e){return N(e)[0]}function j(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!M.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function G(e){return F(e)?e:void 0}function ae(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&M.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function w(e,t){const r=G(e==null?void 0:e.source);return r?j(r,t):void 0}function de({explicitSource:e,field:t,defaultSource:r,fallbackSources:n}){const o=[r,...n||[]],a=G(e),i=a?j(a,ae(a,o)):void 0;if(i)return i;if(e!==void 0)return;const d=w(t,r),s=d?j(d,ae(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return G(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:K(r,n)}function k(e){var t;return D((t=_(e))==null?void 0:t.kind)}function ce(e){var t,r;return k(e)!=="semantic"?null:((r=D((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Fe(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetName)}function Te(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetId)}function Re(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.connectionId)}function Ne(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.tableName)}function Me(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.schemaName)||""}function le(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function ue({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(ce),n=new Set(r.filter(Boolean));return r.some(o=>!o)||n.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function q(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Te(e);return ce(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Fe(e)===t.datasetName:!1}return t.kind==="physical"?Re(e)===t.connectionId&&Ne(e)===t.tableName&&Me(e)===(t.databaseName||"")&&$e(e)===(t.schemaName||""):!1}function Be(e,t){return e.find(r=>q(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function O(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function fe({card:e,datasets:t,errors:r}){if(e.type==="text")return;const n=le(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=>q(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 P(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function V(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function ie(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Oe(e){var r,n;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...P([...V(e.measures),e.primaryMeasure,e.dateField,...V(e.dimensions),...ie(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...P([...V(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...ie(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(...P([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...P(e.fields||[])),t}function pe({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const n of Oe(e.analyticsIntent))if(n&&!t.some(o=>q(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 he({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=U.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 me({datasets:e,errors:t,requireAtLeastOne:r}){const n=ue({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 ge(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:[];me({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>C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=O(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=O(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)),fe({card:l,datasets:o,errors:t}),he({card:l,errors:t}),pe({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(l=>l.id),S=O(I);S&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${S}.`));const A=h.map(l=>l.variableName).filter(Boolean)||[],y=O(A);y&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${y}.`));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 be(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:[];me({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"&&(fe({card:d.card,datasets:o,errors:t}),he({card:d.card,errors:t}),pe({card:d.card,datasets:o,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 Pe={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 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 Ee(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 He(e){const{item:t,band:r,index:n,bandCount:o,breakpoint:a,columns:i}=e;return r==="kpi"?{...t,band:r,w:Ee(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 T(e,t,r,n){return e.map((o,a)=>He({item:o,band:t,index:a,bandCount:e.length,breakpoint:r,columns:n}))}function z(e){const t=ze(e);return Object.fromEntries(C.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const n=Pe[r],o=[...T(t.introText,"introText",r,n),...T(t.kpis,"kpi",r,n),...T(t.charts,"chart",r,n),...T(t.tables,"table",r,n),...T(t.supportingText,"supportingText",r,n)];return[r,qe(o,n)]}))}function Le(e){const t=De.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function je(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ge(e){return je(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 Ue(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function X(e,t){if(t===void 0)return;const r=Le(e.dataType),n=e.operation||"in";if(Ge(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"?Ue(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 Ie(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ke(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 Xe(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 Qe(e,t){const r={},n=[];return{inputs:(e.filterInputs||[]).flatMap((a,i)=>{const d=Xe(a.scope,t);if(d===null)return n.push(Ie("filter_input_scope_empty",`Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=X(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 Ye(e){var A,y;const t=ge(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("../chunks/contracts-CtB2VONT.js"),M=require("../chunks/source-identity-uMaUe036.js"),U=require("../chunks/validators-DFOX0tYY.js");require("../chunks/analyze-result-contract-S8u7CcPL.js");const De=require("../chunks/catalog-field-grounding-Bnx-3tE0.js"),ve=require("../chunks/operators-DrTQsJXv.js");function _(e){return e&&typeof e=="object"?e:null}function D(e){return typeof e=="string"?e:null}function oe(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 F(e){return oe(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function Ce(e){return M.semaphorSourceIdentityKey(e)}function K(e,t){return M.semaphorSourcesReferToSameDataset(e,t)}function se(e,t){return M.preferSemaphorSourceMetadata(e,t)}function N(e){const t=[];for(const r of e){const n=t.findIndex(o=>K(o,r));n===-1?t.push(r):t[n]=se(t[n],r)}return t}function ke(e){return N(e)[0]}function j(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!M.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function G(e){return F(e)?e:void 0}function ae(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&M.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function w(e,t){const r=G(e==null?void 0:e.source);return r?j(r,t):void 0}function de({explicitSource:e,field:t,defaultSource:r,fallbackSources:n}){const o=[r,...n||[]],a=G(e),i=a?j(a,ae(a,o)):void 0;if(i)return i;if(e!==void 0)return;const d=w(t,r),s=d?j(d,ae(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return G(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:K(r,n)}function k(e){var t;return D((t=_(e))==null?void 0:t.kind)}function ce(e){var t,r;return k(e)!=="semantic"?null:((r=D((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Fe(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetName)}function Te(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetId)}function Re(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.connectionId)}function Ne(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.tableName)}function Me(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.schemaName)||""}function le(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function ue({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(ce),n=new Set(r.filter(Boolean));return r.some(o=>!o)||n.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function q(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Te(e);return ce(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Fe(e)===t.datasetName:!1}return t.kind==="physical"?Re(e)===t.connectionId&&Ne(e)===t.tableName&&Me(e)===(t.databaseName||"")&&$e(e)===(t.schemaName||""):!1}function Be(e,t){return e.find(r=>q(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function O(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function fe({card:e,datasets:t,errors:r}){if(e.type==="text")return;const n=le(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=>q(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 P(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function V(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function ie(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Oe(e){var r,n;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...P([...V(e.measures),e.primaryMeasure,e.dateField,...V(e.dimensions),...ie(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...P([...V(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...ie(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(...P([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...P(e.fields||[])),t}function pe({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const n of Oe(e.analyticsIntent))if(n&&!t.some(o=>q(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 he({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=U.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 me({datasets:e,errors:t,requireAtLeastOne:r}){const n=ue({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 ge(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:[];me({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>C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=O(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=O(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)),fe({card:l,datasets:o,errors:t}),he({card:l,errors:t}),pe({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(l=>l.id),S=O(I);S&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${S}.`));const A=h.map(l=>l.variableName).filter(Boolean)||[],y=O(A);y&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${y}.`));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 be(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:[];me({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"&&(fe({card:d.card,datasets:o,errors:t}),he({card:d.card,errors:t}),pe({card:d.card,datasets:o,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 Pe={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 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 Ee(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 He(e){const{item:t,band:r,index:n,bandCount:o,breakpoint:a,columns:i}=e;return r==="kpi"?{...t,band:r,w:Ee(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 T(e,t,r,n){return e.map((o,a)=>He({item:o,band:t,index:a,bandCount:e.length,breakpoint:r,columns:n}))}function z(e){const t=ze(e);return Object.fromEntries(C.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const n=Pe[r],o=[...T(t.introText,"introText",r,n),...T(t.kpis,"kpi",r,n),...T(t.charts,"chart",r,n),...T(t.tables,"table",r,n),...T(t.supportingText,"supportingText",r,n)];return[r,qe(o,n)]}))}function Le(e){const t=De.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function je(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ge(e){return je(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 Ue(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function X(e,t){if(t===void 0)return;const r=Le(e.dataType),n=e.operation||"in";if(Ge(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"?Ue(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 Ie(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ke(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 Xe(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 Qe(e,t){const r={},n=[];return{inputs:(e.filterInputs||[]).flatMap((a,i)=>{const d=Xe(a.scope,t);if(d===null)return n.push(Ie("filter_input_scope_empty",`Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=X(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 Ye(e){var A,y;const t=ge(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
2
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=Ie("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=Ke(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}=Qe(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:(A=e.plan.calculatedFields)==null?void 0:A.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 Ze(e){return JSON.parse(JSON.stringify(e))}function et(e){var t;return(t=e.sheets)==null?void 0:t.find(r=>(r.kind||"dashboard")==="dashboard")}function H(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 ye(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 tt(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((r,n)=>[r.i,n]))}function _e(e,t=new Map){const r=tt(e),n=Math.max(r.size,t.size),o=(e.frames||[]).map((a,i)=>({frameId:a.id,role:ye(a),priority:t.get(a.id)??r.get(a.id)??n+i}));e.layouts=z(o)}function rt(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function nt(e,t){if(!rt(e)){_e(e);return}const r=z([{frameId:t.id,role:ye(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 at(e,t){var n;const r=X(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 it(e){var d;const t=be(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
3
3
  `)||"Dashboard change plan is invalid.");const r=Ze(e.dashboard),n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),i=et(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((S,A)=>{var y;return S+(((y=A.cards)==null?void 0:y.length)||0)},0)>=C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(x("generated_card_limit_reached",`AI refinement is capped at ${C.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),nt(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),at(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?H(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=H(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],S=H(r,I);S&&u.set(S.frame.id,h)}_e(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 R(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function Se(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 Ae(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>$(t)&&typeof t.id=="string"):[]}function J(e){return Array.isArray(e.sections)?e.sections.filter(t=>$(t)):[]}function Q(e){return Array.isArray(e.views)?e.views.filter(t=>$(t)):[]}function v(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const n=w(r);n&&t.push(n)}return t}function ot(e){var n,o,a;if(!e)return[];const t=[];if(F(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...v(e.measures));const i=w(e.dateField);i&&t.push(i),t.push(...v(e.dimensions)),t.push(...v((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(...v(e.fields)),t.push(...v((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"&&F(e.population.baseSource)&&t.push(e.population.baseSource),t.push(...v([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(i=>!!i)))):e.kind==="sql"&&t.push(...v(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 st(e){const t=[];for(const r of Ae(e)){const n=w(r.field);n&&t.push(n)}for(const r of J(e))for(const n of Q(r))t.push(...ot(n.analytics));return t}function dt(e){var r;const t=[];for(const n of J(e))for(const o of Q(n))F((r=o.analytics)==null?void 0:r.source)&&t.push(o.analytics.source);return t}function ct(e,t){const r=N(e).filter(F);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 lt(e,t){const r=J(e),n=Ae(e),o=N(st(e)),a=N(dt(e));return{sections:r,inputs:n,sources:o,primarySources:a,defaultSource:a.length===1?a[0]:void 0,datasets:ct(o,t)}}function ut(e){return e&&U.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function ft(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 pt(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 ht(e){const t=ve.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 mt(e){return $(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function gt(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function bt(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=de({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-${Se(R(e.id,e.field.name),o)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:mt(e),qualifiedTableName:gt(i),sql:"",operation:ht(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:X(h,e.defaultValue)}}function L(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 It(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(L({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=L({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(L({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(a=>!r.has(a))}}function yt(e){var A,y,c;const t=[],r=U.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=lt(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}`,Y=g.id||R(l,`section-${f+1}`);i.set(Y,[]);for(const[Z,m]of Q(g).entries()){const ee=ft(m),E=R(m.id||`${l}-${m.title||`View ${Z+1}`}`,`card-${f+1}-${Z+1}`);if(!ee){t.push(b("unsupported_presentation",`Dashboard presentation "${((A=m.presentation)==null?void 0:A.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${E}`));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-${E}`));continue}const te=Se(E,s),B=`card-${te}`;m.id&&a.set(m.id,B),(c=i.get(Y))==null||c.push(B);const we=m.analytics&&"inputs"in m.analytics?m.analytics.inputs:void 0;for(const re of we||[]){const ne=d.get(re.inputId)||[];ne.push(B),d.set(re.inputId,ne)}o.push({id:B,frameId:`frame-${te}`,title:m.title,description:m.description,type:ee,role:pt(m),priority:h,section:l,analyticsIntent:ut(m.analytics),text:m.text}),h+=1}}const I=n.inputs.map(f=>{const g=It({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:bt(f,n.defaultSource,n.sources,g,u,t)}).filter(f=>!!f);return{plan:{version:1,id:`plan-${R(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:n.datasets,sheets:[{id:`sheet-${R(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=C.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.applyDashboardChangePlan=it;exports.compileDashboardFromPlan=Ye;exports.compileResponsiveDashboardLayouts=z;exports.dashboardAuthoringDatasetMatchesSource=q;exports.dashboardAuthoringFieldsReferToSameTarget=xe;exports.dashboardAuthoringSourceFromField=w;exports.dashboardAuthoringSourceKey=Ce;exports.dashboardAuthoringSourcesReferToSameDataset=K;exports.dashboardPlanFromSemaphorDashboardIntent=yt;exports.findDashboardAuthoringDatasetForSource=Be;exports.getDashboardAuthoringCardSource=le;exports.isMaterializableDashboardAuthoringSource=F;exports.isSemaphorSourceRef=oe;exports.mergeDashboardAuthoringSources=N;exports.preferDashboardAuthoringSourceMetadata=se;exports.preferredDashboardAuthoringSource=ke;exports.resolveDashboardAuthoringSource=de;exports.validateDashboardAuthoringDatasetScope=ue;exports.validateDashboardChangePlan=be;exports.validateDashboardPlan=ge;
@@ -1,7 +1,7 @@
1
1
  import { D as P, a as be } from "../chunks/contracts-CoCOpd_i.js";
2
2
  import { a as Ie, b as E, c as ye } from "../chunks/source-identity-y0VSSreA.js";
3
3
  import { b as ae, e as _e } from "../chunks/validators-B1Mgdr3T.js";
4
- import "../chunks/analyze-result-contract-CUO5QmqV.js";
4
+ import "../chunks/analyze-result-contract-BUgK3759.js";
5
5
  import { b as we } from "../chunks/catalog-field-grounding-CJKAqtiC.js";
6
6
  import { n as ve } from "../chunks/operators-C8TxpM4C.js";
7
7
  function _(e) {
@@ -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-DH7hOGQl.js"),w=require("../chunks/switch-CYG3dY8r.js"),Ze=require("../data-app-builder-browser-runtime/index.cjs"),Q=require("../chunks/x-B6ghREd2.js"),Cn=require("../chunks/save-C__QggEE.js"),tt=require("../chunks/search-DNCejM7Z.js");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 Rn=Tr(p),Bn=Tr(An);/**
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-BepF6hoa.js"),w=require("../chunks/switch-D2oOmorN.js"),Ze=require("../data-app-builder-browser-runtime/index.cjs"),Q=require("../chunks/x-B6ghREd2.js"),Cn=require("../chunks/save-C__QggEE.js"),tt=require("../chunks/search-DNCejM7Z.js");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 Rn=Tr(p),Bn=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 Yn from "react";
3
3
  import { useContext as Zn, useState as x, useRef as oe, useMemo as ze, useEffect as W, useCallback as Ot } from "react";
4
4
  import * as Xn from "react-dom/client";
5
- import { ae as ea, af as ta, ag as Ir, ah as jr, ai as zr, aj as ra, ak as Wr, al as Hr, am as Jr, an as Vr, ao as _r, ap as Ur, aq as Gr, ar as na, as as aa, at as oa, au as Ht, av as on, x as Kr, aw as sa, ax as Vt, ay as sn, az as ia, aA as la } from "../chunks/index-BdVymLVq.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, e as me, R as ma, d as _t } from "../chunks/switch-BiU6-YSY.js";
5
+ import { ae as ea, af as ta, ag as Ir, ah as jr, ai as zr, aj as ra, ak as Wr, al as Hr, am as Jr, an as Vr, ao as _r, ap as Ur, aq as Gr, ar as na, as as aa, at as oa, au as Ht, av as on, x as Kr, aw as sa, ax as Vt, ay as sn, az as ia, aA as la } from "../chunks/index-Drz04wqE.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, e as me, R as ma, d as _t } from "../chunks/switch-qUw8u-gU.js";
7
7
  import { loadSemaphorBrowserRuntime as ot } from "../data-app-builder-browser-runtime/index.js";
8
8
  import { c as $e, X as Je } from "../chunks/x-CXDkqdur.js";
9
9
  import { S as fa } from "../chunks/save-DgMfP0j8.js";
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/analyze-result-contract-S8u7CcPL.js"),e=require("../chunks/update-policy-BmtOqvbf.js");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;
@@ -0,0 +1,22 @@
1
+ import { S as E, a as S, i as A, v as t } from "../chunks/analyze-result-contract-BUgK3759.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-KImUg4Od.js";
3
+ export {
4
+ R as CODEGEN_SUMMARY_SCHEMA_VERSION,
5
+ r as CODEGEN_SUMMARY_VALIDATOR_VERSION,
6
+ s as CONTRACT_MANIFEST_SCHEMA_VERSION,
7
+ C as GENERATED_CONTRACT_SCHEMA_VERSION,
8
+ o as GENERATED_CONTRACT_TYPESCRIPT_FILES,
9
+ p as REQUIRED_GENERATED_CONTRACT_FILES,
10
+ E as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION,
11
+ S as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION,
12
+ d as assertValidCodegenSummary,
13
+ O as buildSemaphorGeneratedActiveInput,
14
+ i as buildSemaphorGeneratedInputOptionIntent,
15
+ m as buildSemaphorGeneratedViewExecutionRequest,
16
+ n as buildSemaphorGeneratedViewExecutionRequests,
17
+ N as evaluateSemaphorDataAppContractUpdatePolicy,
18
+ A as isSemaphorDataAppCodegenSummary,
19
+ T as validateCodegenSummary,
20
+ t as validateSemaphorDataAppCodegenSummary,
21
+ I as validateSemaphorGeneratedContract
22
+ };