react-semaphor 0.1.347 → 0.1.349

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 (63) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +28 -26
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +3 -3
  5. package/dist/chunks/{braces-Ccvdip75.js → braces-CBMh5wmd.js} +1 -1
  6. package/dist/chunks/{braces-DDHkbW1c.js → braces-Cc86y9Ov.js} +1 -1
  7. package/dist/chunks/{calendar-preferences-dialog-CaeYg4gz.js → calendar-preferences-dialog-C2vX2dga.js} +1 -1
  8. package/dist/chunks/{calendar-preferences-dialog-AVORk8vl.js → calendar-preferences-dialog-gMb9JPpz.js} +3 -3
  9. package/dist/chunks/{chevrons-up-down-B9fTSds9.js → chevrons-up-down-CUZL1zaU.js} +1 -1
  10. package/dist/chunks/{chevrons-up-down-pV0i9ptS.js → chevrons-up-down-fg3WME_w.js} +1 -1
  11. package/dist/chunks/{dashboard-briefing-launcher-B7hc62UJ.js → dashboard-briefing-launcher-Cx4NkJil.js} +4 -4
  12. package/dist/chunks/{dashboard-briefing-launcher-GmwoVZDA.js → dashboard-briefing-launcher-DjzTWk1f.js} +1 -1
  13. package/dist/chunks/dashboard-controls-BTz9RgtD.js +57 -0
  14. package/dist/chunks/{dashboard-controls-DOwo-4PX.js → dashboard-controls-Yo3L7krV.js} +129 -119
  15. package/dist/chunks/{dashboard-json-Bjge3tEx.js → dashboard-json-3_OGzDQh.js} +1 -1
  16. package/dist/chunks/{dashboard-json-CqWAmaOX.js → dashboard-json-OLpSyYFR.js} +2 -2
  17. package/dist/chunks/{edit-dashboard-visual-NXdSdqQS.js → edit-dashboard-visual-073yhfDG.js} +6 -6
  18. package/dist/chunks/{edit-dashboard-visual-biDU5oky.js → edit-dashboard-visual-DXzKEyXJ.js} +1 -1
  19. package/dist/chunks/index-Alj8oDV1.js +1410 -0
  20. package/dist/chunks/{index-DhuiooCy.js → index-DTSZ23bE.js} +36067 -35746
  21. package/dist/chunks/{palette-BMXS-AcI.js → palette-C1k347Tb.js} +1 -1
  22. package/dist/chunks/{palette-DKecBucs.js → palette-DP6TXUD8.js} +1 -1
  23. package/dist/chunks/{resource-management-panel-DIt7NxsX.js → resource-management-panel-BvTTEaef.js} +3 -3
  24. package/dist/chunks/{resource-management-panel-MHam0keE.js → resource-management-panel-DLJ6uWYJ.js} +1 -1
  25. package/dist/chunks/source-identity-C-xaeE_I.js +1 -0
  26. package/dist/chunks/source-identity-qAmkNtEK.js +49 -0
  27. package/dist/chunks/{switch-CP7SmEIZ.js → switch-21kU-tcj.js} +2 -2
  28. package/dist/chunks/{switch-DYRgERrC.js → switch-C0S63HAv.js} +1 -1
  29. package/dist/chunks/{use-create-flow-overlay-state-DS5aPcKd.js → use-create-flow-overlay-state-BMr_844V.js} +1 -1
  30. package/dist/chunks/{use-create-flow-overlay-state-p_i0aUhH.js → use-create-flow-overlay-state-gRSXj8dj.js} +3 -3
  31. package/dist/chunks/{use-visual-utils-EazVs86Z.js → use-visual-utils-7w01KGK7.js} +1 -1
  32. package/dist/chunks/{use-visual-utils-PfpWtYcR.js → use-visual-utils-D5zrmYt8.js} +2 -2
  33. package/dist/chunks/{validators-ZeP5TVCl.js → validators-B-NiYgGc.js} +343 -308
  34. package/dist/chunks/validators-DlEfynH8.js +1 -0
  35. package/dist/dashboard/index.cjs +1 -1
  36. package/dist/dashboard/index.js +1 -1
  37. package/dist/dashboard-assistant/index.cjs +1 -0
  38. package/dist/dashboard-assistant/index.js +12 -0
  39. package/dist/dashboard-authoring/index.cjs +3 -3
  40. package/dist/dashboard-authoring/index.js +16 -15
  41. package/dist/data-app-builder/index.cjs +1 -1
  42. package/dist/data-app-builder/index.js +1 -1
  43. package/dist/data-app-sdk/index.cjs +1 -1
  44. package/dist/data-app-sdk/index.js +23 -22
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.js +7 -7
  47. package/dist/style.css +1 -1
  48. package/dist/surfboard/index.cjs +1 -1
  49. package/dist/surfboard/index.js +2 -2
  50. package/dist/types/analytics-protocol.d.ts +17 -6
  51. package/dist/types/dashboard-assistant.d.ts +1030 -0
  52. package/dist/types/dashboard-authoring.d.ts +16 -7
  53. package/dist/types/dashboard.d.ts +1 -1
  54. package/dist/types/data-app-builder.d.ts +15 -6
  55. package/dist/types/data-app-sdk.d.ts +15 -6
  56. package/dist/types/main.d.ts +16 -7
  57. package/dist/types/shared.d.ts +1 -1
  58. package/dist/types/surfboard.d.ts +1 -1
  59. package/dist/types/types.d.ts +1 -1
  60. package/package.json +6 -1
  61. package/dist/chunks/dashboard-controls-Bthl3kl3.js +0 -52
  62. package/dist/chunks/index-D7U5s9Uk.js +0 -1425
  63. package/dist/chunks/validators-Bu5tOTYW.js +0 -1
@@ -0,0 +1 @@
1
+ "use strict";const T=require("./source-identity-C-xaeE_I.js");function n(e,i,t){return t?{code:e,message:i,path:t}:{code:e,message:i}}function D(e){for(let i=0;i<e.length;i+=1){const t=e[i];if(e.some((r,o)=>o!==i&&k(r,t)))return!1}return!0}function $(e,i){return T.semaphorFieldRefsMatch(e,i)}function k(e,i){return $(e,i)&&y(e)===y(i)}function F(e){return`Metric intent has duplicate metric "${e.name}" with the same aggregate (${y(e)}). Use different aggregates to request both, or remove one entry.`}function j(e,i){return b(e,i).length===1}function O(e,i){return b(e,i).length===1}function b(e,i){return i.filter(r=>C(e,r))}function C(e,i){return E(e,i)?e.source?$(i,e):!0:!1}function E(e,i){return!(i.name!==e.name||e.role!==void 0&&i.role!==void 0&&i.role!==e.role||q(e,i)&&y(i)!==y(e))}function q(e,i){return e.role==="measure"||i.role==="measure"||e.aggregate!==void 0||i.aggregate!==void 0}function y(e){return(e.aggregate||"SUM").toUpperCase()}const U=/^(\d{4})-(\d{2})-(\d{2})$/,P=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})$/;function g(e){if(typeof e!="string")return null;const i=e.trim(),t=U.exec(i);if(t){const[,v,A,I]=t;return M(v,A,I)?new Date(Date.UTC(Number(v),Number(A)-1,Number(I))):null}const r=P.exec(i);if(!r)return null;const[,o,a,s,p,c,l="00",,f]=r;if(!M(o,a,s)||!_(p,0,23)||!_(c,0,59)||!_(l,0,59)||!G(f))return null;const h=new Date(i);return Number.isFinite(h.getTime())?h:null}function M(e,i,t){const r=Number(e),o=Number(i),a=Number(t);if(!Number.isInteger(r)||!Number.isInteger(o)||!Number.isInteger(a)||o<1||o>12)return!1;const s=new Date(Date.UTC(r,o-1,a));return s.getUTCFullYear()===r&&s.getUTCMonth()===o-1&&s.getUTCDate()===a}function _(e,i,t){const r=Number(e);return Number.isInteger(r)&&r>=i&&r<=t}function G(e){if(e==="Z")return!0;const i=/^([+-])(\d{2}):(\d{2})$/.exec(e);return!!(i&&_(i[2],0,23)&&_(i[3],0,59))}function d(e){return typeof e=="string"&&e.trim().length>0}function u(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function S(e){const i=new Set;for(const t of e){if(i.has(t))return t;i.add(t)}return null}const H=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]);function N(e,i,t){if(!e||typeof e!="object"){t.push(n("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){d(e.domainId)||t.push(n("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),d(e.datasetName)||t.push(n("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){d(e.connectionId)||t.push(n("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),d(e.tableName)||t.push(n("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){d(e.connectionId)||t.push(n("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`));return}t.push(n("invalid_source_kind","Source kind is not supported.",i))}function m(e,i,t,r={}){if(!e||!u(e)){r.required&&t.push(n("missing_field_ref","Field reference needs a name.",i));return}d(e.name)||t.push(n("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&N(e.source,`${i}.source`,t),L(e.aggregate,`${i}.aggregate`,t)}function L(e,i,t){e!==void 0&&(typeof e!="string"||!H.has(e))&&t.push(n("invalid_aggregate","Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",i))}function V(e,i){if(e.analysis===void 0)return;if(!u(e.analysis)){i.push(n("invalid_metric_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){i.push(n("invalid_metric_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||i.push(n("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||i.push(n("missing_analysis_time_grain","Period-change analysis needs a timeGrain.","timeGrain")),e.analysis.orderBy!==void 0&&e.analysis.orderBy!=="absolute_change"&&e.analysis.orderBy!=="positive_change"&&e.analysis.orderBy!=="negative_change"&&e.analysis.orderBy!=="period"&&i.push(n("invalid_metric_analysis","Period-change analysis orderBy must be absolute_change, positive_change, negative_change, or period.","analysis.orderBy"));const{timeWindow:t}=e.analysis;t!==void 0&&B(t,"analysis.timeWindow",i)}function B(e,i,t){if(!u(e)){t.push(n("invalid_time_window","Time window must be a structured object.",i));return}if(e.kind!==void 0&&e.kind!=="relative"&&e.kind!=="absolute"&&t.push(n("invalid_time_window","Time window kind must be relative or absolute.",`${i}.kind`)),e.kind==="absolute"){if(d(e.start)||t.push(n("invalid_time_window","Absolute time window start must be a non-empty ISO date or timestamp string.",`${i}.start`)),d(e.end)||t.push(n("invalid_time_window","Absolute time window end must be a non-empty ISO date or timestamp string.",`${i}.end`)),d(e.start)&&d(e.end)){const r=g(e.start),o=g(e.end);r||t.push(n("invalid_time_window","Absolute time window start must be a valid ISO date or timestamp.",`${i}.start`)),o||t.push(n("invalid_time_window","Absolute time window end must be a valid ISO date or timestamp.",`${i}.end`)),r&&o&&r.getTime()>o.getTime()&&t.push(n("invalid_time_window","Absolute time window start must be before or equal to end.",i))}return}e.unit!=="second"&&e.unit!=="minute"&&e.unit!=="hour"&&e.unit!=="day"&&e.unit!=="week"&&e.unit!=="month"&&e.unit!=="quarter"&&e.unit!=="year"&&t.push(n("invalid_time_window","Time window unit must be second, minute, hour, day, week, month, quarter, or year.",`${i}.unit`)),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<=0)&&t.push(n("invalid_time_window","Time window value must be a positive number.",`${i}.value`)),e.anchor!==void 0&&e.anchor!=="now"&&e.anchor!=="latest_available"&&t.push(n("invalid_time_window","Time window anchor must be now or latest_available.",`${i}.anchor`)),e.completeness!==void 0&&e.completeness!=="include_partial"&&e.completeness!=="complete_periods"&&t.push(n("invalid_time_window","Time window completeness must be include_partial or complete_periods.",`${i}.completeness`))}function Q(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push(n("invalid_analytics_filters","Analytics filters must be an array.",i));return}e.forEach((r,o)=>{const a=`${i}.${o}`;if(!u(r)){t.push(n("invalid_analytics_filter","Analytics filter must be a structured object.",a));return}const s=r;m(s.field,`${a}.field`,t,{required:!0});const p=s.operator==="is_null"||s.operator==="is_not_null";if(s.operator!==void 0&&s.operator!=="="&&s.operator!=="!="&&s.operator!=="in"&&s.operator!=="not_in"&&s.operator!=="contains"&&s.operator!=="not_contains"&&s.operator!=="between"&&s.operator!=="not_between"&&s.operator!==">"&&s.operator!==">="&&s.operator!=="<"&&s.operator!=="<="&&s.operator!=="is_null"&&s.operator!=="is_not_null"&&t.push(n("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${a}.operator`)),s.values===void 0&&!p&&t.push(n("missing_analytics_filter_value","Analytics filter needs values unless it is a null check.",a)),p&&s.values!==void 0){t.push(n("invalid_analytics_filter_values","Null-check analytics filters must not include values.",`${a}.values`));return}if(s.values!==void 0&&!Array.isArray(s.values)){t.push(n("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${a}.values`));return}if(s.values!==void 0){const c=s.values.length;if(s.operator==="between"||s.operator==="not_between"){c!==2&&t.push(n("invalid_analytics_filter_values","Between analytics filters must include exactly two values.",`${a}.values`));return}(s.operator==="contains"||s.operator==="not_contains"||s.operator==="="||s.operator==="!="||s.operator===">"||s.operator===">="||s.operator==="<"||s.operator==="<="||s.operator===void 0)&&c!==1&&t.push(n("invalid_analytics_filter_values","Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",`${a}.values`))}})}}function w(e){var r;const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[n("invalid_analytics_intent","Analytics intent must be a structured object.")],warnings:t,repairHints:[{code:"invalid_analytics_intent",recommendedNextStep:"Send one structured analytics intent object with kind, source, and required fields."}]};if(e.version!==void 0&&e.version!==1&&i.push(n("invalid_version","Analytics intent version must be 1.","version")),N(e.source,"source",i),e.kind==="metric"){const o=Array.isArray(e.metrics)?e.metrics.filter(a=>u(a)&&d(a.name)):[];if(!Array.isArray(e.metrics)||e.metrics.length===0?i.push(n("missing_metric","Metric intent needs at least one metric.","metrics")):e.metrics.some(a=>!u(a)||!d(a.name))&&i.push(n("invalid_metric_list","Metric intent metrics must be an array of field references with names.","metrics")),o.forEach((a,s)=>{m(a,`metrics.${s}`,i,{required:!0})}),o.length>0&&!D(o)){const a=o.find((s,p)=>o.some((c,l)=>l!==p&&k(c,s)));a&&i.push(n("duplicate_metric",F(a),"metrics"))}if(u(e.primaryMetric)&&d(e.primaryMetric.name)&&b(e.primaryMetric,o).length>1&&i.push(n("ambiguous_primary_metric","Metric intent primaryMetric must identify exactly one selected metric.","primaryMetric")),e.primaryMetric!==void 0&&(m(e.primaryMetric,"primaryMetric",i,{required:!0}),u(e.primaryMetric)&&d(e.primaryMetric.name)&&o.length>0&&!j(e.primaryMetric,o)&&i.push(n("invalid_primary_metric","Metric intent primaryMetric must match one metric field reference.","primaryMetric"))),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(n("invalid_metric_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(a=>!u(a)||!d(a.name))&&i.push(n("invalid_metric_dimensions","Metric intent dimensions must be an array of field references with names.","dimensions")),e.dateField!==void 0&&m(e.dateField,"dateField",i),e.timeWindow!==void 0&&(B(e.timeWindow,"timeWindow",i),e.dateField||i.push(n("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),Q(e.filters,"filters",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((a,s)=>{m(a,`dimensions.${s}`,i)}),e.orderBy!==void 0){if(!u(e.orderBy))i.push(n("invalid_metric_order_by","Metric intent orderBy must be a structured object.","orderBy"));else if(m(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(n("invalid_metric_order_direction","Metric intent orderBy direction must be asc or desc.","orderBy.direction")),u(e.orderBy.field)&&d(e.orderBy.field.name)){const a=[...o,...e.timeGrain&&e.dateField&&u(e.dateField)?[e.dateField]:[],...Array.isArray(e.dimensions)?e.dimensions.filter(s=>u(s)&&d(s.name)):[]];a.length>0&&!O(e.orderBy.field,a)&&i.push(n("invalid_metric_order_by","Metric intent orderBy.field must match one selected metric, grouped dateField, or dimension.","orderBy.field"))}}V(e,i)}else e.kind==="records"?(!Array.isArray(e.fields)||e.fields.length===0?i.push(n("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(o=>!u(o)||!d(o.name))&&i.push(n("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((o,a)=>{m(o,`fields.${a}`,i)}),e.dateField!==void 0&&m(e.dateField,"dateField",i),e.orderBy!==void 0&&(u(e.orderBy)?(m(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(n("invalid_record_order_direction","Records intent orderBy direction must be asc or desc.","orderBy.direction"))):i.push(n("invalid_record_order_by","Records intent orderBy must be a structured object.","orderBy")))):e.kind==="inputOptions"?((!e.field||!d(e.field.name))&&i.push(n("missing_input_options_field","Input options intent needs a field.","field")),m(e.field,"field",i,{required:!0})):e.kind==="sql"?(((r=e.source)==null?void 0:r.kind)!=="sql"&&i.push(n("invalid_sql_source","SQL analytics intent must use a SQL execution source.","source")),d(e.sql)||i.push(n("missing_sql","SQL analytics intent needs SQL text.","sql")),Array.isArray(e.fields)&&e.fields.forEach((o,a)=>{m(o,`fields.${a}`,i)})):i.push(n("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:t,repairHints:Y(i)}}function x(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[n("invalid_operation_intent","Operation intent must be a structured object.")],warnings:t,repairHints:[{code:"invalid_operation_intent",recommendedNextStep:"Send one typed operation intent with version, kind, and required operation fields."}]};if(e.version!==1&&i.push(n("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?i.push(n("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((r,o)=>{d(r.id)||i.push(n("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${o}.id`)),d(r.prompt)||i.push(n("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${o}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(d(e.instruction)||i.push(n("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const r=w(e.analyticsIntent);i.push(...r.errors),t.push(...r.warnings)}}else i.push(n("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:t,repairHints:R(i)}}function X(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[n("invalid_recovery_plan","Analytics recovery plan must be a structured object.")],warnings:t,repairHints:[{code:"invalid_recovery_plan",recommendedNextStep:"Return a typed recovery plan with operationIntent and plannedToolCalls."}]};e.version!==1&&i.push(n("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&i.push(n("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const r=x(e.operationIntent);return i.push(...r.errors),t.push(...r.warnings),Array.isArray(e.plannedToolCalls)||i.push(n("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:i.length===0,errors:i,warnings:t,repairHints:R(i)}}function R(e){return e.map(i=>({code:i.code,recommendedNextStep:i.code==="missing_obligations"?"Normalize the user request into one or more typed analytics obligations before recovery planning.":"Correct the operation/recovery contract shape before planning execution."}))}function Y(e){return e.map(i=>{switch(i.code){case"missing_source":return{code:i.code,fieldRole:"source",recommendedNextStep:"Provide a semantic, physical, or SQL source before executing analytics."};case"missing_metric":return{code:i.code,fieldRole:"metric",recommendedNextStep:"Choose one exact metric from the grounded schema candidates."};case"missing_record_fields":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide at least one field for the records intent."};case"missing_input_options_field":return{code:i.code,fieldRole:"input",recommendedNextStep:"Provide the exact field whose option values should be listed."};case"missing_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Provide bounded read-only SQL with an explicit outer LIMIT."};case"conflicting_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Use one canonical SQL text location for the intent; prefer top-level sql."};case"missing_semantic_domain":case"missing_dataset_name":case"missing_connection_id":case"missing_table_name":return{code:i.code,fieldRole:"source",recommendedNextStep:"Use grounded catalog metadata to fill the missing source reference."};default:return}}).filter(i=>!!i)}function Z(e,i,t,r){if(!e||typeof e!="object"){t.push(n("invalid_view","Dashboard view must be an object.",i));return}if(d(e.title)||t.push(n("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){t.push(n("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){d(e.text)||r.push(n("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){t.push(n("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}const o=w(e.analytics);for(const a of o.errors)t.push(n(a.code,a.message,`${i}.analytics${a.path?`.${a.path}`:""}`));for(const a of o.warnings)r.push(n(a.code,a.message,`${i}.analytics${a.path?`.${a.path}`:""}`))}function z(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[n("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:t};e.version!==1&&i.push(n("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(n("invalid_kind","Experience intent kind must be dashboard.")),d(e.title)||i.push(n("missing_title","Dashboard intent needs a title.","title"));const r=Array.isArray(e.inputs)?e.inputs:[],o=S(r.filter(u).map(c=>c.id).filter(c=>typeof c=="string"));o&&i.push(n("duplicate_input_id",`Duplicate input id: ${o}.`,"inputs"));for(const[c,l]of r.entries()){const f=`inputs.${c}`;if(!u(l)){i.push(n("invalid_input","Dashboard input must be an object.",f));continue}d(l.id)||i.push(n("missing_input_id","Input needs an id.",`${f}.id`)),d(l.label)||i.push(n("missing_input_label","Input needs a label.",`${f}.label`)),!l.field||!d(l.field.name)?i.push(n("missing_input_field","Input needs a field.",`${f}.field`)):m(l.field,`${f}.field`,i)}const a=Array.isArray(e.sections)?e.sections:[];a.length===0&&i.push(n("missing_sections","Dashboard intent needs at least one section.","sections"));const s=a.flatMap(c=>c&&typeof c=="object"&&Array.isArray(c.views)?c.views.filter(u).map(l=>l.id).filter(l=>!!l):[]),p=S(s);p&&i.push(n("duplicate_view_id",`Duplicate dashboard view id: ${p}.`,"sections"));for(const[c,l]of a.entries()){const f=`sections.${c}`;if(!l||typeof l!="object"){i.push(n("invalid_section","Dashboard section must be an object.",f));continue}if(d(l.title)||i.push(n("missing_section_title","Dashboard section needs a title.",f)),!Array.isArray(l.views)||l.views.length===0){i.push(n("missing_section_views","Dashboard section needs at least one view.",`${f}.views`));continue}for(const[h,v]of l.views.entries())Z(v,`${f}.views.${h}`,i,t)}return{ok:i.length===0,errors:i,warnings:t}}exports.parseSemaphorIsoTimeWindowBoundary=g;exports.validateSemaphorAnalyticsIntent=w;exports.validateSemaphorAnalyticsRecoveryPlan=X;exports.validateSemaphorDashboardIntent=z;exports.validateSemaphorOperationIntent=x;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-D7U5s9Uk.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-Alj8oDV1.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-DhuiooCy.js";
1
+ import { D as o } from "../chunks/index-DTSZ23bE.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,
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=["tool-runDashboardAnalysis","tool-runAdvancedAnalysis","tool-renderDynamicVisual"];function o(a){return s.includes(a)}exports.DASHBOARD_ASSISTANT_VISUAL_TOOL_PART_TYPES=s;exports.isDashboardAssistantVisualToolPartType=o;
@@ -0,0 +1,12 @@
1
+ const n = [
2
+ "tool-runDashboardAnalysis",
3
+ "tool-runAdvancedAnalysis",
4
+ "tool-renderDynamicVisual"
5
+ ];
6
+ function o(s) {
7
+ return n.includes(s);
8
+ }
9
+ export {
10
+ n as DASHBOARD_ASSISTANT_VISUAL_TOOL_PART_TYPES,
11
+ o as isDashboardAssistantVisualToolPartType
12
+ };
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../chunks/validators-Bu5tOTYW.js"),Se=require("../chunks/catalog-field-grounding-Du6mKDcF.js"),re=["lg","md","sm","xs","xxs"],$=10;function _(e){return e&&typeof e=="object"?e:null}function D(e){return typeof e=="string"?e:null}function ae(e){var t,n,r;return!!(e&&typeof e=="object")&&(((t=_(e))==null?void 0:t.kind)==="semantic"||((n=_(e))==null?void 0:n.kind)==="physical"||((r=_(e))==null?void 0:r.kind)==="sql")}function N(e){return ae(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function we(e){return v.semaphorSourceIdentityKey(e)}function G(e,t){return v.semaphorSourcesReferToSameDataset(e,t)}function ie(e,t){return v.preferSemaphorSourceMetadata(e,t)}function M(e){const t=[];for(const n of e){const r=t.findIndex(a=>G(a,n));r===-1?t.push(n):t[r]=ie(t[r],n)}return t}function ve(e){return M(e)[0]}function H(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 W(e){return N(e)?e:void 0}function ne(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(n=>(n==null?void 0:n.kind)==="semantic"&&v.semaphorSourcesReferToSameDataset(e,n)&&!!n.connectionId)}function w(e,t){const n=W(e==null?void 0:e.source);return n?H(n,t):void 0}function oe({explicitSource:e,field:t,defaultSource:n,fallbackSources:r}){const a=[n,...r||[]],i=W(e),o=i?H(i,ne(i,a)):void 0;if(o)return o;if(e!==void 0)return;const d=w(t,n),s=d?H(d,ne(d,a)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return W(n)}function De(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const n=w(e),r=w(t);return!n||!r?!0:G(n,r)}function C(e){var t;return D((t=_(e))==null?void 0:t.kind)}function se(e){var t,n;return C(e)!=="semantic"?null:((n=D((t=_(e))==null?void 0:t.domainId))==null?void 0:n.trim())||null}function Ae(e){var t;return C(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetName)}function Ce(e){var t;return C(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetId)}function ke(e){var t;return C(e)!=="physical"?null:D((t=_(e))==null?void 0:t.connectionId)}function xe(e){var t;return C(e)!=="physical"?null:D((t=_(e))==null?void 0:t.tableName)}function Fe(e){var t;return C(e)!=="physical"?"":D((t=_(e))==null?void 0:t.databaseName)||""}function Te(e){var t;return C(e)!=="physical"?"":D((t=_(e))==null?void 0:t.schemaName)||""}function de(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function ce({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const n=e.map(se),r=new Set(n.filter(Boolean));return n.some(a=>!a)||r.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function z(e,t){if(!t)return!1;if(t.kind==="semantic"){const n=Ce(e);return se(e)===t.domainId?n&&t.datasetId?n===t.datasetId:Ae(e)===t.datasetName:!1}return t.kind==="physical"?ke(e)===t.connectionId&&xe(e)===t.tableName&&Fe(e)===(t.databaseName||"")&&Te(e)===(t.schemaName||""):!1}function $e(e,t){return e.find(n=>z(n,t))}function f(e,t,n){return n?{code:e,message:t,cardId:n}:{code:e,message:t}}function B(e){const t=new Set;for(const n of e){if(t.has(n))return n;t.add(n)}return null}function le({card:e,datasets:t,errors:n}){if(e.type==="text")return;const r=de(e);if(!r){if(t.length<=1)return;n.push(f("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(a=>z(a,r))||n.push(f("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function V(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 Me(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Ne(e){var n;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...V([...L(e.metrics),e.primaryMetric,e.dateField,...L(e.dimensions),...Me(e.filters).map(r=>r.field)])):e.kind==="records"?t.push(...V([...L(e.fields),e.dateField,(n=e.orderBy)==null?void 0:n.field])):e.kind==="inputOptions"?t.push(...V([e.field])):e.kind==="sql"&&t.push(...V(e.fields||[])),t}function ue({card:e,datasets:t,errors:n}){if(e.type!=="text"){for(const r of Ne(e.analyticsIntent))if(r&&!t.some(a=>z(a,r))){n.push(f("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function fe({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const n=v.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!n.ok)for(const r of n.errors)t.push(f(r.code,r.path?`${r.path}: ${r.message}`:r.message,e.id))}function pe({datasets:e,errors:t,requireAtLeastOne:n}){const r=ce({datasets:e,requireAtLeastOne:n});if(!r.ok){if(r.issue==="invalid_dataset_count"){t.push(f("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(f("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function he(e){var p,S;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[f("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const n=e,r=[...n.warnings||[]];n.version!==1&&t.push(f("invalid_version","Dashboard plan version must be 1.")),(p=n.title)!=null&&p.trim()||t.push(f("missing_title","Dashboard plan needs a title."));const a=Array.isArray(n.datasets)?n.datasets:[],i=Array.isArray(n.sheets)?n.sheets:[];pe({datasets:a,errors:t,requireAtLeastOne:!0}),i.length!==1&&t.push(f("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const o=i[0];o&&o.kind!=="dashboard"&&t.push(f("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(o==null?void 0:o.cards)||[];d.length>$&&t.push(f("too_many_cards",`Generated dashboards can contain at most ${$} cards.`));const s=B(d.map(l=>l.id));s&&t.push(f("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=B(d.map(l=>l.frameId));u&&t.push(f("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(S=l.title)!=null&&S.trim()||t.push(f("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(f("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&r.push(f("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),le({card:l,datasets:a,errors:t}),fe({card:l,errors:t}),ue({card:l,datasets:a,errors:t});const h=Array.isArray(n.filterInputs)?n.filterInputs:[],b=h.map(l=>l.id),y=B(b);y&&t.push(f("duplicate_input_id",`Duplicate dashboard input id: ${y}.`));const c=h.map(l=>l.variableName).filter(Boolean)||[],g=B(c);g&&t.push(f("duplicate_input_variable",`Duplicate dashboard input variable name: ${g}.`));const A=Array.isArray(n.calculatedFields)?n.calculatedFields:[];for(const l of A)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(f("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:r}}function me(e){var o;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[f("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const n=e,r=[...n.warnings||[]];n.version!==1&&t.push(f("invalid_version","Dashboard change plan version must be 1.")),(o=n.dashboardId)!=null&&o.trim()||t.push(f("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const a=Array.isArray(n.datasets)?n.datasets:[],i=Array.isArray(n.operations)?n.operations:[];pe({datasets:a,errors:t,requireAtLeastOne:!1});for(const d of i){if(d.kind==="unsupported"){r.push(f("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(f("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(le({card:d.card,datasets:a,errors:t}),fe({card:d.card,errors:t}),ue({card:d.card,datasets:a,errors:t})),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(f("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:r}}const Pe={lg:48,md:36,sm:24,xs:12,xxs:6};function Re(e,t){let n=0,r=0,a=0;return e.map(i=>{const o=Math.min(i.w,t);n>0&&n+o>t&&(n=0,r+=a,a=0);const d={i:i.frameId,x:n,y:r,w:o,h:i.h,minW:Math.min(i.minW,t),minH:i.minH,static:!1};return n+=o,a=Math.max(a,i.h),d})}function Be(e){const t=[...e].sort((s,u)=>s.priority-u.priority),n=t.filter(s=>s.role==="kpi"),r=t.filter(s=>s.role==="chart"),a=t.filter(s=>s.role==="table"),i=t.filter(s=>s.role==="text"),o=i.slice(0,1),d=i.slice(o.length);return{kpis:n,introText:o,charts:r,tables:a,supportingText:d}}function Ve(e,t,n){return t==="xxs"||t==="xs"?n:t==="sm"?Math.min(12,n):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function ze(e,t,n,r){return n==="xxs"||n==="xs"||n==="sm"||n==="md"||t===1||t%2===1&&e===0?r:r/2}function Oe(e){const{item:t,band:n,index:r,bandCount:a,breakpoint:i,columns:o}=e;return n==="kpi"?{...t,band:n,w:Ve(a,i,o),h:15,minW:Math.min(6,o),minH:12}:n==="table"?{...t,band:n,w:o,h:i==="xxs"||i==="xs"?34:38,minW:Math.min(12,o),minH:18}:n==="introText"?{...t,band:n,w:o,h:i==="xxs"||i==="xs"?12:10,minW:Math.min(12,o),minH:8}:n==="supportingText"?{...t,band:n,w:i==="lg"?o/2:o,h:i==="xxs"||i==="xs"?12:10,minW:Math.min(12,o),minH:8}:{...t,band:n,w:ze(r,a,i,o),h:i==="xxs"||i==="xs"?28:30,minW:Math.min(12,o),minH:16}}function x(e,t,n,r){return e.map((a,i)=>Oe({item:a,band:t,index:i,bandCount:e.length,breakpoint:n,columns:r}))}function O(e){const t=Be(e);return Object.fromEntries(re.map(n=>{const r=Pe[n],a=[...x(t.introText,"introText",n,r),...x(t.kpis,"kpi",n,r),...x(t.charts,"chart",n,r),...x(t.tables,"table",n,r),...x(t.supportingText,"supportingText",n,r)];return[n,Re(a,r)]}))}function qe(e){const t=Se.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function Le(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function je(e){return Le(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function Ee(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function He(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function K(e,t){if(t===void 0)return;const n=qe(e.dataType),r=e.operation||"in";if(je(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:n,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(r==="is null"||r==="is not null")return{filterId:e.id,name:e.column,operation:r,valueType:n,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const a=Array.isArray(t)?t:[t],i=n==="date"?He(a):Ee(a);if(i.length!==0&&!((r==="between"||r==="not between")&&i.length<2))return{filterId:e.id,name:e.column,operation:r,valueType:n,values:i,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function We(e,t,n){return n?{code:e,message:t,cardId:n}:{code:e,message:t}}function Ge(e,t,n){const r=(t||[]).filter(a=>a.scope==="card"&&a.targetCardId===n).map(a=>a.field).filter(Boolean);return r.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...r]}}function Ke(e){const t={};return{inputs:(e.filterInputs||[]).map((r,a)=>{const i=K(r.filter,r.defaultValue);return i&&(t.shared??(t.shared={}),t.shared[r.id]={status:"set",value:{kind:"filter",filterValue:i}}),{id:r.id,kind:"filter",label:r.label,variableName:r.variableName,scope:r.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:a},exports:["label","value","start","end","range"],filter:r.filter}}),defaultInputValues:t.shared&&Object.keys(t.shared).length>0?t:void 0}}function Ue(e){var b,y;const t=he(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
2
- `)||"Dashboard plan is invalid.");const n=e.plan.sheets[0],r=[...t.warnings],a=[],i=new Map(e.cardArtifacts.map(c=>[c.planCardId,c])),o=[];for(const c of n.cards){const g=i.get(c.id);if(!g){const p=We("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);a.push(p);continue}r.push(...g.warnings||[]);const A=Ge(g.card,e.plan.calculatedFields,c.id);o.push({id:c.frameId,cards:[A],activeCardId:A.id})}if(o.length===0)throw new Error("Dashboard plan did not produce any persistable cards.");const{inputs:d,defaultInputValues:s}=Ke(e.plan),u=O(n.cards.filter(c=>o.some(g=>g.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:n.id,kind:"dashboard",title:n.title,description:n.description,frames:o,layouts:u,calculatedFields:(b=e.plan.calculatedFields)==null?void 0:b.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:d,...s?{defaultInputValues:s}:{}},warnings:r,skippedOperations:a}}function k(e,t,n){return n?{code:e,message:t,cardId:n}:{code:e,message:t}}function Xe(e){return JSON.parse(JSON.stringify(e))}function Je(e){var t;return(t=e.sheets)==null?void 0:t.find(n=>(n.kind||"dashboard")==="dashboard")}function j(e,t){var n;for(const r of e.sheets||[])for(const a of r.frames||[]){const i=(n=a.cards)==null?void 0:n.find(o=>o.id===t);if(i)return{sheet:r,frame:a,card:i}}return null}function ge(e){var n,r;const t=(r=(n=e.cards)==null?void 0:n[0])==null?void 0:r.type;return t==="kpi"?"kpi":t==="table"||t==="detailTable"||t==="pivotTable"?"table":t==="text"?"text":"chart"}function Qe(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((n,r)=>[n.i,r]))}function be(e,t=new Map){const n=Qe(e),r=Math.max(n.size,t.size),a=(e.frames||[]).map((i,o)=>({frameId:i.id,role:ge(i),priority:t.get(i.id)??n.get(i.id)??r+o}));e.layouts=O(a)}function Ye(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function Ze(e,t){if(!Ye(e)){be(e);return}const n=O([{frameId:t.id,role:ge(t),priority:0}]);e.layouts??(e.layouts={});for(const[r,a]of Object.entries(n)){const i=e.layouts[r]||[];if(i.some(s=>s.i===t.id))continue;const o=a[0];if(!o)continue;const d=i.reduce((s,u)=>Math.max(s,u.y+u.h),0);e.layouts[r]=[...i,{...o,y:d}]}}function et(e,t){var r;const n=K(t.filter,t.defaultValue);n&&(e.defaultInputValues??(e.defaultInputValues={}),(r=e.defaultInputValues).shared??(r.shared={}),e.defaultInputValues.shared[t.id]={status:"set",value:{kind:"filter",filterValue:n}})}function tt(e){var d;const t=me(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
3
- `)||"Dashboard change plan is invalid.");const n=Xe(e.dashboard),r=[...t.warnings],a=[],i=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),o=Je(n);if(!o)throw new Error("Dashboard has no editable dashboard sheet.");o.frames??(o.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((o.frames||[]).reduce((y,c)=>{var g;return y+(((g=c.cards)==null?void 0:g.length)||0)},0)>=$){a.push(k("generated_card_limit_reached",`MVP AI refinement is capped at ${$} cards.`,s.card.id));break}const h=i.get(s.card.id);if(!h){a.push(k("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const b={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};o.frames.push(b),Ze(o,b);break}case"addFilterInput":{n.inputs??(n.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:n.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};n.inputs.push(u),et(n,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)n.calculatedFields??(n.calculatedFields=[]),n.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)o.calculatedFields??(o.calculatedFields=[]),o.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const u=s.field.targetCardId?j(n,s.field.targetCardId):null;u?((d=u.card).calculatedFields??(d.calculatedFields=[]),u.card.calculatedFields.push(s.field.field)):a.push(k("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const u=j(n,s.cardId);if(!u){a.push(k("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 b=s.cardIds[h],y=j(n,b);y&&u.set(y.frame.id,h)}be(o,u);break}case"reuseCalculatedField":r.push(k("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":a.push(k("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:n,warnings:r,skippedOperations:a}}function I(e,t,n){return n?{code:e,message:t,cardId:n}:{code:e,message:t}}function T(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function Ie(e,t){if(!t.has(e))return t.add(e),e;let n=2,r=`${e}-${n}`;for(;t.has(r);)n+=1,r=`${e}-${n}`;return t.add(r),r}function P(e){return!!(e&&typeof e=="object")}function ye(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>P(t)&&typeof t.id=="string"):[]}function U(e){return Array.isArray(e.sections)?e.sections.filter(t=>P(t)):[]}function X(e){return Array.isArray(e.views)?e.views.filter(t=>P(t)):[]}function F(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const r=w(n);r&&t.push(r)}return t}function nt(e){var r;if(!e)return[];const t=[];if(N(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...F(e.metrics));const a=w(e.dateField);a&&t.push(a),t.push(...F(e.dimensions)),t.push(...F((r=e.filters)==null?void 0:r.map(i=>i.field)))}else if(e.kind==="records"){const a=w(e.dateField);a&&t.push(a),t.push(...F(e.fields))}else if(e.kind==="inputOptions"){const a=w(e.field);a&&t.push(a)}else e.kind==="sql"&&t.push(...F(e.fields));const n="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const a of n){const i=w(a.field);i&&t.push(i)}return t}function rt(e){const t=[];for(const n of ye(e)){const r=w(n.field);r&&t.push(r)}for(const n of U(e))for(const r of X(n))t.push(...nt(r.analytics));return t}function at(e){var n;const t=[];for(const r of U(e))for(const a of X(r))N((n=a.analytics)==null?void 0:n.source)&&t.push(a.analytics.source);return t}function it(e,t){const n=M(e).filter(N);if(n.length===0)return t.push(I("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const r=n.every(i=>i.kind==="semantic"),a=Array.from(new Set(n.filter(i=>i.kind==="semantic").map(i=>i.domainId)));return n.length>1&&(!r||a.length!==1)?(t.push(I("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.")),[n[0]]):n}function ot(e,t){const n=U(e),r=ye(e),a=M(rt(e)),i=M(at(e));return{sections:n,inputs:r,sources:a,primarySources:i,defaultSource:i.length===1?i[0]:void 0,datasets:it(a,t)}}function st(e){return e&&v.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function dt(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 ct(e){var t,n,r;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((n=e.presentation)==null?void 0:n.kind)==="table"?"table":((r=e.presentation)==null?void 0:r.kind)==="text"?"text":"chart"}function lt(e){switch(e){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";default:return e||"in"}}function ut(e){return P(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function ft(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function pt(e,t,n,r,a,i){if(e.kind!=="filter")return i.push(I("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!P(e.field)||typeof e.field.name!="string")return i.push(I("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const o=oe({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:n}),d=(o==null?void 0:o.kind)==="semantic"||(o==null?void 0:o.kind)==="physical"?o.connectionId:void 0;if(!d)return i.push(I("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const h={id:`filter-${Ie(T(e.id,e.field.name),a)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:ut(e),qualifiedTableName:ft(o),sql:"",operation:lt(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(o==null?void 0:o.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(o==null?void 0:o.kind)==="semantic"?{semanticDomainId:o.domainId,connectionId:o.connectionId}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:r,filter:h,defaultValue:K(h,e.defaultValue)}}function E(e){const t=[],n=[];for(const r of e.viewIds){const a=e.viewIdToCardId.get(r);a?t.push(a):n.push(r)}return n.length>0&&e.warnings.push(I("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${n.join(", ")}.`)),Array.from(new Set(t))}function ht(e){var r,a;if(!e.protocolScope){const i=Array.from(new Set(e.boundCardIds));return i.length>0&&i.length<e.allCardIds.length?{kind:"cards",cardIds:i}:void 0}if(e.protocolScope.level==="dashboard"){if(!((r=e.protocolScope.excludeViewIds)!=null&&r.length))return;const i=new Set(E({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(o=>!i.has(o))}}if(e.protocolScope.level==="view"){const i=E({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return i.length===0?(e.warnings.push(I("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:i}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(I("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((a=e.protocolScope.excludeViewIds)!=null&&a.length))return{kind:"cards",cardIds:t};const n=new Set(E({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(i=>!n.has(i))}}function mt(e){var c,g,A;const t=[],n=v.validateSemaphorDashboardIntent(e);for(const p of n.warnings)t.push(I(p.code,p.message));for(const p of n.errors)t.push(I(p.code,p.message));const r=ot(e,t),a=[],i=new Map,o=new Map,d=new Map,s=new Set,u=new Set;let h=0;for(const[p,S]of r.sections.entries()){const l=typeof S.title=="string"?S.title:`Section ${p+1}`,J=S.id||T(l,`section-${p+1}`);o.set(J,[]);for(const[Q,m]of X(S).entries()){const Y=dt(m),q=T(m.id||`${l}-${m.title||`View ${Q+1}`}`,`card-${p+1}-${Q+1}`);if(!Y){t.push(I("unsupported_presentation",`Dashboard presentation "${((c=m.presentation)==null?void 0:c.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${q}`));continue}if(((g=m.analytics)==null?void 0:g.kind)==="sql"){t.push(I("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${q}`));continue}const Z=Ie(q,s),R=`card-${Z}`;m.id&&i.set(m.id,R),(A=o.get(J))==null||A.push(R);const _e=m.analytics&&"inputs"in m.analytics?m.analytics.inputs:void 0;for(const ee of _e||[]){const te=d.get(ee.inputId)||[];te.push(R),d.set(ee.inputId,te)}a.push({id:R,frameId:`frame-${Z}`,title:m.title,description:m.description,type:Y,role:ct(m),priority:h,section:l,analyticsIntent:st(m.analytics),text:m.text}),h+=1}}const b=r.inputs.map(p=>{const S=ht({protocolScope:p.scope,inputLabel:p.label,allCardIds:a.map(l=>l.id),boundCardIds:d.get(p.id)||[],viewIdToCardId:i,sectionIdToCardIds:o,warnings:t});return S===null?null:pt(p,r.defaultSource,r.sources,S,u,t)}).filter(p=>!!p);return{plan:{version:1,id:`plan-${T(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:r.datasets,sheets:[{id:`sheet-${T(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:a}],filterInputs:b.length?b:void 0,warnings:t.length?t:void 0,unresolvedRequests:n.ok?void 0:n.errors.map(p=>p.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=re;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=$;exports.applyDashboardChangePlan=tt;exports.compileDashboardFromPlan=Ue;exports.compileResponsiveDashboardLayouts=O;exports.dashboardAuthoringDatasetMatchesSource=z;exports.dashboardAuthoringFieldsReferToSameTarget=De;exports.dashboardAuthoringSourceFromField=w;exports.dashboardAuthoringSourceKey=we;exports.dashboardAuthoringSourcesReferToSameDataset=G;exports.dashboardPlanFromSemaphorDashboardIntent=mt;exports.findDashboardAuthoringDatasetForSource=$e;exports.getDashboardAuthoringCardSource=de;exports.isMaterializableDashboardAuthoringSource=N;exports.isSemaphorSourceRef=ae;exports.mergeDashboardAuthoringSources=M;exports.preferDashboardAuthoringSourceMetadata=ie;exports.preferredDashboardAuthoringSource=ve;exports.resolveDashboardAuthoringSource=oe;exports.validateDashboardAuthoringDatasetScope=ce;exports.validateDashboardChangePlan=me;exports.validateDashboardPlan=he;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("../chunks/source-identity-C-xaeE_I.js"),G=require("../chunks/validators-DlEfynH8.js"),we=require("../chunks/catalog-field-grounding-Du6mKDcF.js"),ae=["lg","md","sm","xs","xxs"],T=10;function _(e){return e&&typeof e=="object"?e:null}function v(e){return typeof e=="string"?e:null}function ie(e){var t,n,r;return!!(e&&typeof e=="object")&&(((t=_(e))==null?void 0:t.kind)==="semantic"||((n=_(e))==null?void 0:n.kind)==="physical"||((r=_(e))==null?void 0:r.kind)==="sql")}function N(e){return ie(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function ve(e){return M.semaphorSourceIdentityKey(e)}function K(e,t){return M.semaphorSourcesReferToSameDataset(e,t)}function oe(e,t){return M.preferSemaphorSourceMetadata(e,t)}function $(e){const t=[];for(const n of e){const r=t.findIndex(a=>K(a,n));r===-1?t.push(n):t[r]=oe(t[r],n)}return t}function De(e){return $(e)[0]}function H(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 W(e){return N(e)?e:void 0}function re(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(n=>(n==null?void 0:n.kind)==="semantic"&&M.semaphorSourcesReferToSameDataset(e,n)&&!!n.connectionId)}function w(e,t){const n=W(e==null?void 0:e.source);return n?H(n,t):void 0}function se({explicitSource:e,field:t,defaultSource:n,fallbackSources:r}){const a=[n,...r||[]],i=W(e),o=i?H(i,re(i,a)):void 0;if(o)return o;if(e!==void 0)return;const d=w(t,n),s=d?H(d,re(d,a)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return W(n)}function Ae(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const n=w(e),r=w(t);return!n||!r?!0:K(n,r)}function A(e){var t;return v((t=_(e))==null?void 0:t.kind)}function de(e){var t,n;return A(e)!=="semantic"?null:((n=v((t=_(e))==null?void 0:t.domainId))==null?void 0:n.trim())||null}function Ce(e){var t;return A(e)!=="semantic"?null:v((t=_(e))==null?void 0:t.datasetName)}function ke(e){var t;return A(e)!=="semantic"?null:v((t=_(e))==null?void 0:t.datasetId)}function xe(e){var t;return A(e)!=="physical"?null:v((t=_(e))==null?void 0:t.connectionId)}function Fe(e){var t;return A(e)!=="physical"?null:v((t=_(e))==null?void 0:t.tableName)}function Te(e){var t;return A(e)!=="physical"?"":v((t=_(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return A(e)!=="physical"?"":v((t=_(e))==null?void 0:t.schemaName)||""}function ce(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function le({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const n=e.map(de),r=new Set(n.filter(Boolean));return n.some(a=>!a)||r.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function z(e,t){if(!t)return!1;if(t.kind==="semantic"){const n=ke(e);return de(e)===t.domainId?n&&t.datasetId?n===t.datasetId:Ce(e)===t.datasetName:!1}return t.kind==="physical"?xe(e)===t.connectionId&&Fe(e)===t.tableName&&Te(e)===(t.databaseName||"")&&$e(e)===(t.schemaName||""):!1}function Me(e,t){return e.find(n=>z(n,t))}function f(e,t,n){return n?{code:e,message:t,cardId:n}:{code:e,message:t}}function B(e){const t=new Set;for(const n of e){if(t.has(n))return n;t.add(n)}return null}function ue({card:e,datasets:t,errors:n}){if(e.type==="text")return;const r=ce(e);if(!r){if(t.length<=1)return;n.push(f("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(a=>z(a,r))||n.push(f("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function V(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 Ne(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Pe(e){var n;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...V([...L(e.metrics),e.primaryMetric,e.dateField,...L(e.dimensions),...Ne(e.filters).map(r=>r.field)])):e.kind==="records"?t.push(...V([...L(e.fields),e.dateField,(n=e.orderBy)==null?void 0:n.field])):e.kind==="inputOptions"?t.push(...V([e.field])):e.kind==="sql"&&t.push(...V(e.fields||[])),t}function fe({card:e,datasets:t,errors:n}){if(e.type!=="text"){for(const r of Pe(e.analyticsIntent))if(r&&!t.some(a=>z(a,r))){n.push(f("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function pe({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const n=G.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!n.ok)for(const r of n.errors)t.push(f(r.code,r.path?`${r.path}: ${r.message}`:r.message,e.id))}function he({datasets:e,errors:t,requireAtLeastOne:n}){const r=le({datasets:e,requireAtLeastOne:n});if(!r.ok){if(r.issue==="invalid_dataset_count"){t.push(f("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(f("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function me(e){var p,S;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[f("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const n=e,r=[...n.warnings||[]];n.version!==1&&t.push(f("invalid_version","Dashboard plan version must be 1.")),(p=n.title)!=null&&p.trim()||t.push(f("missing_title","Dashboard plan needs a title."));const a=Array.isArray(n.datasets)?n.datasets:[],i=Array.isArray(n.sheets)?n.sheets:[];he({datasets:a,errors:t,requireAtLeastOne:!0}),i.length!==1&&t.push(f("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const o=i[0];o&&o.kind!=="dashboard"&&t.push(f("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(o==null?void 0:o.cards)||[];d.length>T&&t.push(f("too_many_cards",`Generated dashboards can contain at most ${T} cards.`));const s=B(d.map(l=>l.id));s&&t.push(f("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=B(d.map(l=>l.frameId));u&&t.push(f("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(S=l.title)!=null&&S.trim()||t.push(f("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(f("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&r.push(f("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),ue({card:l,datasets:a,errors:t}),pe({card:l,errors:t}),fe({card:l,datasets:a,errors:t});const h=Array.isArray(n.filterInputs)?n.filterInputs:[],b=h.map(l=>l.id),y=B(b);y&&t.push(f("duplicate_input_id",`Duplicate dashboard input id: ${y}.`));const c=h.map(l=>l.variableName).filter(Boolean)||[],g=B(c);g&&t.push(f("duplicate_input_variable",`Duplicate dashboard input variable name: ${g}.`));const D=Array.isArray(n.calculatedFields)?n.calculatedFields:[];for(const l of D)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(f("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:r}}function ge(e){var o;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[f("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const n=e,r=[...n.warnings||[]];n.version!==1&&t.push(f("invalid_version","Dashboard change plan version must be 1.")),(o=n.dashboardId)!=null&&o.trim()||t.push(f("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const a=Array.isArray(n.datasets)?n.datasets:[],i=Array.isArray(n.operations)?n.operations:[];he({datasets:a,errors:t,requireAtLeastOne:!1});for(const d of i){if(d.kind==="unsupported"){r.push(f("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(f("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(ue({card:d.card,datasets:a,errors:t}),pe({card:d.card,errors:t}),fe({card:d.card,datasets:a,errors:t})),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(f("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:r}}const Re={lg:48,md:36,sm:24,xs:12,xxs:6};function Be(e,t){let n=0,r=0,a=0;return e.map(i=>{const o=Math.min(i.w,t);n>0&&n+o>t&&(n=0,r+=a,a=0);const d={i:i.frameId,x:n,y:r,w:o,h:i.h,minW:Math.min(i.minW,t),minH:i.minH,static:!1};return n+=o,a=Math.max(a,i.h),d})}function Ve(e){const t=[...e].sort((s,u)=>s.priority-u.priority),n=t.filter(s=>s.role==="kpi"),r=t.filter(s=>s.role==="chart"),a=t.filter(s=>s.role==="table"),i=t.filter(s=>s.role==="text"),o=i.slice(0,1),d=i.slice(o.length);return{kpis:n,introText:o,charts:r,tables:a,supportingText:d}}function ze(e,t,n){return t==="xxs"||t==="xs"?n:t==="sm"?Math.min(12,n):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function Oe(e,t,n,r){return n==="xxs"||n==="xs"||n==="sm"||n==="md"||t===1||t%2===1&&e===0?r:r/2}function qe(e){const{item:t,band:n,index:r,bandCount:a,breakpoint:i,columns:o}=e;return n==="kpi"?{...t,band:n,w:ze(a,i,o),h:15,minW:Math.min(6,o),minH:12}:n==="table"?{...t,band:n,w:o,h:i==="xxs"||i==="xs"?34:38,minW:Math.min(12,o),minH:18}:n==="introText"?{...t,band:n,w:o,h:i==="xxs"||i==="xs"?12:10,minW:Math.min(12,o),minH:8}:n==="supportingText"?{...t,band:n,w:i==="lg"?o/2:o,h:i==="xxs"||i==="xs"?12:10,minW:Math.min(12,o),minH:8}:{...t,band:n,w:Oe(r,a,i,o),h:i==="xxs"||i==="xs"?28:30,minW:Math.min(12,o),minH:16}}function k(e,t,n,r){return e.map((a,i)=>qe({item:a,band:t,index:i,bandCount:e.length,breakpoint:n,columns:r}))}function O(e){const t=Ve(e);return Object.fromEntries(ae.map(n=>{const r=Re[n],a=[...k(t.introText,"introText",n,r),...k(t.kpis,"kpi",n,r),...k(t.charts,"chart",n,r),...k(t.tables,"table",n,r),...k(t.supportingText,"supportingText",n,r)];return[n,Be(a,r)]}))}function Le(e){const t=we.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function je(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ee(e){return je(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function He(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 U(e,t){if(t===void 0)return;const n=Le(e.dataType),r=e.operation||"in";if(Ee(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:n,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(r==="is null"||r==="is not null")return{filterId:e.id,name:e.column,operation:r,valueType:n,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const a=Array.isArray(t)?t:[t],i=n==="date"?We(a):He(a);if(i.length!==0&&!((r==="between"||r==="not between")&&i.length<2))return{filterId:e.id,name:e.column,operation:r,valueType:n,values:i,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function Ge(e,t,n){return n?{code:e,message:t,cardId:n}:{code:e,message:t}}function Ke(e,t,n){const r=(t||[]).filter(a=>a.scope==="card"&&a.targetCardId===n).map(a=>a.field).filter(Boolean);return r.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...r]}}function Ue(e){const t={};return{inputs:(e.filterInputs||[]).map((r,a)=>{const i=U(r.filter,r.defaultValue);return i&&(t.shared??(t.shared={}),t.shared[r.id]={status:"set",value:{kind:"filter",filterValue:i}}),{id:r.id,kind:"filter",label:r.label,variableName:r.variableName,scope:r.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:a},exports:["label","value","start","end","range"],filter:r.filter}}),defaultInputValues:t.shared&&Object.keys(t.shared).length>0?t:void 0}}function Xe(e){var b,y;const t=me(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
2
+ `)||"Dashboard plan is invalid.");const n=e.plan.sheets[0],r=[...t.warnings],a=[],i=new Map(e.cardArtifacts.map(c=>[c.planCardId,c])),o=[];for(const c of n.cards){const g=i.get(c.id);if(!g){const p=Ge("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);a.push(p);continue}r.push(...g.warnings||[]);const D=Ke(g.card,e.plan.calculatedFields,c.id);o.push({id:c.frameId,cards:[D],activeCardId:D.id})}if(o.length===0)throw new Error("Dashboard plan did not produce any persistable cards.");const{inputs:d,defaultInputValues:s}=Ue(e.plan),u=O(n.cards.filter(c=>o.some(g=>g.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:n.id,kind:"dashboard",title:n.title,description:n.description,frames:o,layouts:u,calculatedFields:(b=e.plan.calculatedFields)==null?void 0:b.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:d,...s?{defaultInputValues:s}:{}},warnings:r,skippedOperations:a}}function C(e,t,n){return n?{code:e,message:t,cardId:n}:{code:e,message:t}}function Je(e){return JSON.parse(JSON.stringify(e))}function Qe(e){var t;return(t=e.sheets)==null?void 0:t.find(n=>(n.kind||"dashboard")==="dashboard")}function j(e,t){var n;for(const r of e.sheets||[])for(const a of r.frames||[]){const i=(n=a.cards)==null?void 0:n.find(o=>o.id===t);if(i)return{sheet:r,frame:a,card:i}}return null}function be(e){var n,r;const t=(r=(n=e.cards)==null?void 0:n[0])==null?void 0:r.type;return t==="kpi"?"kpi":t==="table"||t==="detailTable"||t==="pivotTable"?"table":t==="text"?"text":"chart"}function Ye(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((n,r)=>[n.i,r]))}function Ie(e,t=new Map){const n=Ye(e),r=Math.max(n.size,t.size),a=(e.frames||[]).map((i,o)=>({frameId:i.id,role:be(i),priority:t.get(i.id)??n.get(i.id)??r+o}));e.layouts=O(a)}function Ze(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function et(e,t){if(!Ze(e)){Ie(e);return}const n=O([{frameId:t.id,role:be(t),priority:0}]);e.layouts??(e.layouts={});for(const[r,a]of Object.entries(n)){const i=e.layouts[r]||[];if(i.some(s=>s.i===t.id))continue;const o=a[0];if(!o)continue;const d=i.reduce((s,u)=>Math.max(s,u.y+u.h),0);e.layouts[r]=[...i,{...o,y:d}]}}function tt(e,t){var r;const n=U(t.filter,t.defaultValue);n&&(e.defaultInputValues??(e.defaultInputValues={}),(r=e.defaultInputValues).shared??(r.shared={}),e.defaultInputValues.shared[t.id]={status:"set",value:{kind:"filter",filterValue:n}})}function nt(e){var d;const t=ge(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
3
+ `)||"Dashboard change plan is invalid.");const n=Je(e.dashboard),r=[...t.warnings],a=[],i=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),o=Qe(n);if(!o)throw new Error("Dashboard has no editable dashboard sheet.");o.frames??(o.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((o.frames||[]).reduce((y,c)=>{var g;return y+(((g=c.cards)==null?void 0:g.length)||0)},0)>=T){a.push(C("generated_card_limit_reached",`MVP AI refinement is capped at ${T} cards.`,s.card.id));break}const h=i.get(s.card.id);if(!h){a.push(C("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const b={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};o.frames.push(b),et(o,b);break}case"addFilterInput":{n.inputs??(n.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:n.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};n.inputs.push(u),tt(n,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)n.calculatedFields??(n.calculatedFields=[]),n.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)o.calculatedFields??(o.calculatedFields=[]),o.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const u=s.field.targetCardId?j(n,s.field.targetCardId):null;u?((d=u.card).calculatedFields??(d.calculatedFields=[]),u.card.calculatedFields.push(s.field.field)):a.push(C("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const u=j(n,s.cardId);if(!u){a.push(C("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 b=s.cardIds[h],y=j(n,b);y&&u.set(y.frame.id,h)}Ie(o,u);break}case"reuseCalculatedField":r.push(C("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":a.push(C("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:n,warnings:r,skippedOperations:a}}function I(e,t,n){return n?{code:e,message:t,cardId:n}:{code:e,message:t}}function F(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function ye(e,t){if(!t.has(e))return t.add(e),e;let n=2,r=`${e}-${n}`;for(;t.has(r);)n+=1,r=`${e}-${n}`;return t.add(r),r}function P(e){return!!(e&&typeof e=="object")}function _e(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>P(t)&&typeof t.id=="string"):[]}function X(e){return Array.isArray(e.sections)?e.sections.filter(t=>P(t)):[]}function J(e){return Array.isArray(e.views)?e.views.filter(t=>P(t)):[]}function x(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const r=w(n);r&&t.push(r)}return t}function rt(e){var r;if(!e)return[];const t=[];if(N(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...x(e.metrics));const a=w(e.dateField);a&&t.push(a),t.push(...x(e.dimensions)),t.push(...x((r=e.filters)==null?void 0:r.map(i=>i.field)))}else if(e.kind==="records"){const a=w(e.dateField);a&&t.push(a),t.push(...x(e.fields))}else if(e.kind==="inputOptions"){const a=w(e.field);a&&t.push(a)}else e.kind==="sql"&&t.push(...x(e.fields));const n="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const a of n){const i=w(a.field);i&&t.push(i)}return t}function at(e){const t=[];for(const n of _e(e)){const r=w(n.field);r&&t.push(r)}for(const n of X(e))for(const r of J(n))t.push(...rt(r.analytics));return t}function it(e){var n;const t=[];for(const r of X(e))for(const a of J(r))N((n=a.analytics)==null?void 0:n.source)&&t.push(a.analytics.source);return t}function ot(e,t){const n=$(e).filter(N);if(n.length===0)return t.push(I("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const r=n.every(i=>i.kind==="semantic"),a=Array.from(new Set(n.filter(i=>i.kind==="semantic").map(i=>i.domainId)));return n.length>1&&(!r||a.length!==1)?(t.push(I("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.")),[n[0]]):n}function st(e,t){const n=X(e),r=_e(e),a=$(at(e)),i=$(it(e));return{sections:n,inputs:r,sources:a,primarySources:i,defaultSource:i.length===1?i[0]:void 0,datasets:ot(a,t)}}function dt(e){return e&&G.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function ct(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 lt(e){var t,n,r;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((n=e.presentation)==null?void 0:n.kind)==="table"?"table":((r=e.presentation)==null?void 0:r.kind)==="text"?"text":"chart"}function ut(e){switch(e){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";default:return e||"in"}}function ft(e){return P(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function pt(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function ht(e,t,n,r,a,i){if(e.kind!=="filter")return i.push(I("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!P(e.field)||typeof e.field.name!="string")return i.push(I("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const o=se({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:n}),d=(o==null?void 0:o.kind)==="semantic"||(o==null?void 0:o.kind)==="physical"?o.connectionId:void 0;if(!d)return i.push(I("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const h={id:`filter-${ye(F(e.id,e.field.name),a)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:ft(e),qualifiedTableName:pt(o),sql:"",operation:ut(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(o==null?void 0:o.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(o==null?void 0:o.kind)==="semantic"?{semanticDomainId:o.domainId,connectionId:o.connectionId}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:r,filter:h,defaultValue:U(h,e.defaultValue)}}function E(e){const t=[],n=[];for(const r of e.viewIds){const a=e.viewIdToCardId.get(r);a?t.push(a):n.push(r)}return n.length>0&&e.warnings.push(I("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${n.join(", ")}.`)),Array.from(new Set(t))}function mt(e){var r,a;if(!e.protocolScope){const i=Array.from(new Set(e.boundCardIds));return i.length>0&&i.length<e.allCardIds.length?{kind:"cards",cardIds:i}:void 0}if(e.protocolScope.level==="dashboard"){if(!((r=e.protocolScope.excludeViewIds)!=null&&r.length))return;const i=new Set(E({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(o=>!i.has(o))}}if(e.protocolScope.level==="view"){const i=E({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return i.length===0?(e.warnings.push(I("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:i}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(I("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((a=e.protocolScope.excludeViewIds)!=null&&a.length))return{kind:"cards",cardIds:t};const n=new Set(E({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(i=>!n.has(i))}}function gt(e){var c,g,D;const t=[],n=G.validateSemaphorDashboardIntent(e);for(const p of n.warnings)t.push(I(p.code,p.message));for(const p of n.errors)t.push(I(p.code,p.message));const r=st(e,t),a=[],i=new Map,o=new Map,d=new Map,s=new Set,u=new Set;let h=0;for(const[p,S]of r.sections.entries()){const l=typeof S.title=="string"?S.title:`Section ${p+1}`,Q=S.id||F(l,`section-${p+1}`);o.set(Q,[]);for(const[Y,m]of J(S).entries()){const Z=ct(m),q=F(m.id||`${l}-${m.title||`View ${Y+1}`}`,`card-${p+1}-${Y+1}`);if(!Z){t.push(I("unsupported_presentation",`Dashboard presentation "${((c=m.presentation)==null?void 0:c.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${q}`));continue}if(((g=m.analytics)==null?void 0:g.kind)==="sql"){t.push(I("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${q}`));continue}const ee=ye(q,s),R=`card-${ee}`;m.id&&i.set(m.id,R),(D=o.get(Q))==null||D.push(R);const Se=m.analytics&&"inputs"in m.analytics?m.analytics.inputs:void 0;for(const te of Se||[]){const ne=d.get(te.inputId)||[];ne.push(R),d.set(te.inputId,ne)}a.push({id:R,frameId:`frame-${ee}`,title:m.title,description:m.description,type:Z,role:lt(m),priority:h,section:l,analyticsIntent:dt(m.analytics),text:m.text}),h+=1}}const b=r.inputs.map(p=>{const S=mt({protocolScope:p.scope,inputLabel:p.label,allCardIds:a.map(l=>l.id),boundCardIds:d.get(p.id)||[],viewIdToCardId:i,sectionIdToCardIds:o,warnings:t});return S===null?null:ht(p,r.defaultSource,r.sources,S,u,t)}).filter(p=>!!p);return{plan:{version:1,id:`plan-${F(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:r.datasets,sheets:[{id:`sheet-${F(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:a}],filterInputs:b.length?b:void 0,warnings:t.length?t:void 0,unresolvedRequests:n.ok?void 0:n.errors.map(p=>p.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=ae;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=T;exports.applyDashboardChangePlan=nt;exports.compileDashboardFromPlan=Xe;exports.compileResponsiveDashboardLayouts=O;exports.dashboardAuthoringDatasetMatchesSource=z;exports.dashboardAuthoringFieldsReferToSameTarget=Ae;exports.dashboardAuthoringSourceFromField=w;exports.dashboardAuthoringSourceKey=ve;exports.dashboardAuthoringSourcesReferToSameDataset=K;exports.dashboardPlanFromSemaphorDashboardIntent=gt;exports.findDashboardAuthoringDatasetForSource=Me;exports.getDashboardAuthoringCardSource=ce;exports.isMaterializableDashboardAuthoringSource=N;exports.isSemaphorSourceRef=ie;exports.mergeDashboardAuthoringSources=$;exports.preferDashboardAuthoringSourceMetadata=oe;exports.preferredDashboardAuthoringSource=De;exports.resolveDashboardAuthoringSource=se;exports.validateDashboardAuthoringDatasetScope=le;exports.validateDashboardChangePlan=ge;exports.validateDashboardPlan=me;
@@ -1,4 +1,5 @@
1
- import { s as he, d as W, p as me, v as ne, c as ge } from "../chunks/validators-ZeP5TVCl.js";
1
+ import { a as he, b as W, p as me } from "../chunks/source-identity-qAmkNtEK.js";
2
+ import { v as ne, c as ge } from "../chunks/validators-B-NiYgGc.js";
2
3
  import { b as be } from "../chunks/catalog-field-grounding-DoEBOXQd.js";
3
4
  const Ie = [
4
5
  "lg",
@@ -20,7 +21,7 @@ function ye(e) {
20
21
  function V(e) {
21
22
  return ye(e) ? e.kind === "semantic" ? !!(e.domainId && e.datasetName) : e.kind === "physical" ? !!(e.connectionId && e.tableName) : !1 : !1;
22
23
  }
23
- function mt(e) {
24
+ function gt(e) {
24
25
  return he(e);
25
26
  }
26
27
  function re(e, t) {
@@ -42,7 +43,7 @@ function B(e) {
42
43
  }
43
44
  return t;
44
45
  }
45
- function gt(e) {
46
+ function bt(e) {
46
47
  return B(e)[0];
47
48
  }
48
49
  function O(e, t) {
@@ -84,7 +85,7 @@ function we({
84
85
  if ((t == null ? void 0 : t.source) === void 0)
85
86
  return j(n);
86
87
  }
87
- function bt(e, t) {
88
+ function It(e, t) {
88
89
  if (!(e != null && e.name) || !(t != null && t.name) || e.name !== t.name)
89
90
  return !1;
90
91
  const n = v(e), r = v(t);
@@ -146,7 +147,7 @@ function E(e, t) {
146
147
  }
147
148
  return t.kind === "physical" ? ke(e) === t.connectionId && xe(e) === t.tableName && Ce(e) === (t.databaseName || "") && De(e) === (t.schemaName || "") : !1;
148
149
  }
149
- function It(e, t) {
150
+ function yt(e, t) {
150
151
  return e.find(
151
152
  (n) => E(n, t)
152
153
  );
@@ -634,7 +635,7 @@ function Ge(e) {
634
635
  defaultInputValues: t.shared && Object.keys(t.shared).length > 0 ? t : void 0
635
636
  };
636
637
  }
637
- function yt(e) {
638
+ function _t(e) {
638
639
  var b, y;
639
640
  const t = Me(e.plan);
640
641
  if (!t.ok)
@@ -786,7 +787,7 @@ function Ze(e, t) {
786
787
  }
787
788
  });
788
789
  }
789
- function _t(e) {
790
+ function wt(e) {
790
791
  var d;
791
792
  const t = Ne(e.changePlan);
792
793
  if (!t.ok)
@@ -1222,7 +1223,7 @@ function ft(e) {
1222
1223
  cardIds: t.filter((i) => !n.has(i))
1223
1224
  };
1224
1225
  }
1225
- function wt(e) {
1226
+ function vt(e) {
1226
1227
  var c, g, k;
1227
1228
  const t = [], n = ge(e);
1228
1229
  for (const p of n.warnings)
@@ -1322,22 +1323,22 @@ function wt(e) {
1322
1323
  export {
1323
1324
  Ie as DASHBOARD_AUTHORING_BREAKPOINTS,
1324
1325
  P as DASHBOARD_AUTHORING_MAX_GENERATED_CARDS,
1325
- _t as applyDashboardChangePlan,
1326
- yt as compileDashboardFromPlan,
1326
+ wt as applyDashboardChangePlan,
1327
+ _t as compileDashboardFromPlan,
1327
1328
  H as compileResponsiveDashboardLayouts,
1328
1329
  E as dashboardAuthoringDatasetMatchesSource,
1329
- bt as dashboardAuthoringFieldsReferToSameTarget,
1330
+ It as dashboardAuthoringFieldsReferToSameTarget,
1330
1331
  v as dashboardAuthoringSourceFromField,
1331
- mt as dashboardAuthoringSourceKey,
1332
+ gt as dashboardAuthoringSourceKey,
1332
1333
  re as dashboardAuthoringSourcesReferToSameDataset,
1333
- wt as dashboardPlanFromSemaphorDashboardIntent,
1334
- It as findDashboardAuthoringDatasetForSource,
1334
+ vt as dashboardPlanFromSemaphorDashboardIntent,
1335
+ yt as findDashboardAuthoringDatasetForSource,
1335
1336
  Ae as getDashboardAuthoringCardSource,
1336
1337
  V as isMaterializableDashboardAuthoringSource,
1337
1338
  ye as isSemaphorSourceRef,
1338
1339
  B as mergeDashboardAuthoringSources,
1339
1340
  _e as preferDashboardAuthoringSourceMetadata,
1340
- gt as preferredDashboardAuthoringSource,
1341
+ bt as preferredDashboardAuthoringSource,
1341
1342
  we as resolveDashboardAuthoringSource,
1342
1343
  Fe as validateDashboardAuthoringDatasetScope,
1343
1344
  Ne as validateDashboardChangePlan,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-D7U5s9Uk.js");exports.DataAppBuilder=e.DataAppBuilder;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-Alj8oDV1.js");exports.DataAppBuilder=e.DataAppBuilder;
@@ -1,4 +1,4 @@
1
- import { b as r } from "../chunks/index-DhuiooCy.js";
1
+ import { b as r } from "../chunks/index-DTSZ23bE.js";
2
2
  export {
3
3
  r as DataAppBuilder
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../chunks/validators-Bu5tOTYW.js"),K=require("../chunks/index-BxM99sFL.js"),a=require("react"),F=require("react/jsx-runtime");function E(e){var r;const t=V(e);return{version:1,kind:"metric",id:e.id,label:e.label,source:k(e),metrics:t,primaryMetric:z(e,t),dateField:e.dateField?l(e.dateField,"date"):void 0,timeGrain:e.timeGrain,dimensions:(r=e.dimensions)==null?void 0:r.map(n=>l(n,"dimension")),comparison:X(e.comparison),orderBy:e.orderBy?{field:l(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:R(e.inputs),limit:e.limit}}function z(e,t){if(!e.primaryMetric)return t[0]||{name:"",role:"measure"};const r=l(e.primaryMetric,"measure"),n=L(r,t),o=n.length===1?n[0]:void 0;return o?B(r,o):r}function V(e){const t=[];for(const r of e.metrics.map(n=>l(n,"measure"))){if(!r.name)continue;const n=t.findIndex(o=>j(o,r));if(n===-1){t.push(r);continue}t[n]=B(t[n],r)}return t}function j(e,t){return S.semaphorFieldRefsMatch(e,t)&&g(e)===g(t)}function N(e,t){return g(t)===g(e)}function Q(e,t){return t.name!==e.name||e.source&&!S.semaphorFieldRefsMatch(t,e)?!1:N(e,t)}function L(e,t){const r=t.filter(n=>Q(e,n));return e.aggregate!==void 0,r}function g(e){return(e.aggregate||"SUM").toUpperCase()}function B(e,t){if(e.aggregate&&t.aggregate&&e.aggregate!==t.aggregate)throw new Error(`Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${t.aggregate}.`);return{...S.preferSemaphorFieldRefMetadata(e,t),aggregate:e.aggregate||t.aggregate}}function w(e){if("sort"in e)throw new Error("useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!W(e))throw new Error("useSemaphorRecords needs at least one field.");const t=G(e.fields);return{version:1,kind:"records",id:e.id,label:e.label,source:k(e),fields:t,dateField:e.dateField?l(e.dateField,"date"):void 0,timeGrain:e.timeGrain,orderBy:e.orderBy?{field:l(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:R(e.inputs),limit:e.limit}}function G(e){return e.map(t=>{const r=l(t);if(!r.role)throw new Error(`useSemaphorRecords field "${r.name}" needs an explicit role.`);return r})}function O(e){return{version:1,kind:"inputOptions",id:e.id,label:e.label,source:k(e),field:l(e.field,"dimension"),search:e.search,limit:e.limit}}function $(e){if("toAnalyticsInput"in e){const t=e.toAnalyticsInput();return{inputId:t.inputId,...t.field?{field:t.field}:{}}}return{inputId:e.inputId,...e.field?{field:e.field}:{}}}function J(e){const t=R(e);return t.length>0?t:void 0}function q(e){return(e||[]).map(H)}function M(e){return q(e).filter(t=>t.isActive)}function C(e){return e.kind==="filter"?{inputId:e.id,kind:e.kind,label:e.label,field:l(e.field,"dimension"),operator:e.operator||"in"}:{inputId:e.id,kind:e.kind,label:e.label}}function T(e=[]){return e.map(t=>typeof t=="object"?t:{label:String(t),value:t})}function y(e){return e==null?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e.trim().length>0:!0}function H(e){return"toAnalyticsInput"in e?e.toAnalyticsInput():"kind"in e&&"isActive"in e?e:{...e,kind:"filter",isActive:y(e.value),value:e.value}}function k(e){return e.source}function W(e){var t;return!!((t=e.fields)!=null&&t.length)}function l(e,t){return{...e,role:e.role||t}}function R(e){return(e||[]).map($)}function X(e){if(e)return e}function P(){return{executeMetric:(e,t)=>v(e,t),executeRecords:(e,t)=>v(e,t),executeInputOptions:(e,t)=>v(e,t)}}async function v(e,t){if(!t.token)throw new Error("SemaphorDataAppProvider needs a token to execute queries.");const r=await fetch(ee(t),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.token}`},body:JSON.stringify({intent:e,activeInputs:t.activeInputs,resultShape:e.kind})}),n=await Y(r);if(!r.ok||n.error)throw new Error(n.error||`Semaphor Data App execution failed with status ${r.status}.`);return n}async function Y(e){const t=await e.text().catch(()=>"");if(!t.trim())return e.ok?{error:"Semaphor Data App execution returned an empty response."}:{};try{return JSON.parse(t)}catch{return e.ok?{error:"Semaphor Data App execution returned invalid JSON.",details:t}:{error:Z(e,t),details:t}}}function Z(e,t){const r=e.statusText?` ${e.statusText}`:"",n=t.replace(/\s+/g," ").trim();return n?`Semaphor Data App execution failed with status ${e.status}${r}: ${n.slice(0,240)}`:`Semaphor Data App execution failed with status ${e.status}${r}.`}function ee(e){const t=te(e).replace(/\/+$/,"");return t?t.endsWith("/api")?`${t}/v1/data-app/execute`:`${t}/api/v1/data-app/execute`:"/api/v1/data-app/execute"}function te(e){if(e.apiBaseUrl)return e.apiBaseUrl;if(!e.token)return"";try{return K.jwtDecode(e.token).apiServiceUrl||""}catch{return""}}const D=a.createContext({});function U(){if(!(typeof window>"u"))return window.__SEMAPHOR_DATA_APP_RUNTIME__}function _(){return a.useContext(D)}function re({token:e,apiBaseUrl:t,executor:r,children:n}){var d;const o=U(),u=((d=o==null?void 0:o.authToken)==null?void 0:d.accessToken)||e,i=(o==null?void 0:o.dataApiBaseUrl)||(o==null?void 0:o.apiBaseUrl)||t,m=a.useMemo(()=>P(),[]),s=r||m,f=a.useMemo(()=>({token:u,apiBaseUrl:i,executor:s}),[i,s,u]);return F.jsx(D.Provider,{value:f,children:n})}const I={value:null},ne={records:[]},A={options:[]};function oe(e){const t=M(e.inputs);try{const r=E(e),n=b(r);return n?{error:n,activeInputs:t,queryKey:c(void 0,t,n),idleData:I}:{intent:r,error:null,activeInputs:t,queryKey:c(r,t),idleData:I}}catch(r){const n=h(r);return{error:n,activeInputs:t,queryKey:c(void 0,t,n),idleData:I}}}function ie(e){const t=M(e.inputs),r=ne;try{const n=w(e),o=b(n);return o?{error:o,activeInputs:t,queryKey:c(void 0,t,o),idleData:r}:{intent:n,error:null,activeInputs:t,queryKey:c(n,t),idleData:r}}catch(n){const o=h(n);return{error:o,activeInputs:t,queryKey:c(void 0,t,o),idleData:r}}}function ae(e){try{const t=O(e),r=b(t);return r?{error:r,queryKey:c(void 0,void 0,r),idleData:A}:{intent:t,error:null,queryKey:c(t),idleData:A}}catch(t){const r=h(t);return{error:r,queryKey:c(void 0,void 0,r),idleData:A}}}function h(e){return e instanceof Error?e:new Error(String(e))}function b(e){const t=S.validateSemaphorAnalyticsIntent(e);if(t.ok)return null;const r=t.errors.map(n=>n.path?`${n.code} at ${n.path}: ${n.message}`:`${n.code}: ${n.message}`).join("; ");return new Error(`Invalid Semaphor analytics intent. ${r}`)}function c(e,t,r){return JSON.stringify({intent:e,activeInputs:t,error:r==null?void 0:r.message})}function ue(e){const[t,r]=a.useState(e.defaultValue),n=Object.prototype.hasOwnProperty.call(e,"value"),o=n?e.value:t,u=a.useMemo(()=>T(e.options),[e.options]),i=a.useCallback(s=>{var d;const f=s;(d=e.onValueChange)==null||d.call(e,f),n||r(f)},[n,e]),m=a.useCallback(()=>i(void 0),[i]);return a.useMemo(()=>{const s=C(e);return{id:e.id,kind:e.kind,label:e.label,field:s.field,operator:s.operator,controlRole:e.kind==="control"?e.role:void 0,value:o,options:u,isActive:y(o),setValue:i,clear:m,toAnalyticsInput:()=>({inputId:s.inputId,field:s.field,kind:e.kind,label:e.label,value:o,isActive:y(o),operator:s.operator,controlRole:e.kind==="control"?e.role:void 0})}},[m,u,i,e,o])}function se(e){const t=a.useMemo(()=>oe(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeMetric(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData,t.activeInputs),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,value:(o==null?void 0:o.value)??null,metrics:o==null?void 0:o.metrics,comparisonValue:o==null?void 0:o.comparisonValue,delta:o==null?void 0:o.delta,deltaPercent:o==null?void 0:o.deltaPercent,records:o==null?void 0:o.records,status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function le(e){const t=a.useMemo(()=>ie(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeRecords(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData,t.activeInputs),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,records:(o==null?void 0:o.records)||[],columns:o==null?void 0:o.columns,rowCount:o==null?void 0:o.rowCount,status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function de(e){const t=a.useMemo(()=>ae(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeInputOptions(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,options:(o==null?void 0:o.options)||[],status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function x(e,t,r,n){const o=_(),u=a.useRef(t),i=a.useRef(n),[m,s]=a.useState({status:"idle",data:r,error:null});return u.current=t,i.current=n,a.useEffect(()=>{let f;try{f=u.current({...o,activeInputs:i.current})}catch(p){s({status:"error",data:r,error:h(p)});return}if(!f){s({status:"idle",data:r,error:null});return}let d=!1;return s(p=>({status:"loading",data:p.data,error:null})),f.then(p=>{d||s({status:"success",data:p,error:null})}).catch(p=>{d||s({status:"error",data:r,error:h(p)})}),()=>{d=!0}},[r,e,o]),m}exports.SemaphorDataAppContext=D;exports.SemaphorDataAppProvider=re;exports.createSemaphorQueryExecutor=P;exports.hasSemaphorInputValue=y;exports.normalizeSemaphorInputOptions=T;exports.readWindowRuntime=U;exports.toSemaphorActiveInputSnapshots=M;exports.toSemaphorInputBinding=$;exports.toSemaphorInputBindings=J;exports.toSemaphorInputOptionsIntent=O;exports.toSemaphorInputSnapshots=q;exports.toSemaphorInputSpec=C;exports.toSemaphorMetricIntent=E;exports.toSemaphorRecordsIntent=w;exports.useSemaphorDataAppRuntime=_;exports.useSemaphorInput=ue;exports.useSemaphorInputOptions=de;exports.useSemaphorMetric=se;exports.useSemaphorRecords=le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("../chunks/source-identity-C-xaeE_I.js"),K=require("../chunks/index-BxM99sFL.js"),a=require("react"),F=require("react/jsx-runtime"),z=require("../chunks/validators-DlEfynH8.js");function E(e){var r;const t=j(e);return{version:1,kind:"metric",id:e.id,label:e.label,source:k(e),metrics:t,primaryMetric:V(e,t),dateField:e.dateField?l(e.dateField,"date"):void 0,timeGrain:e.timeGrain,dimensions:(r=e.dimensions)==null?void 0:r.map(n=>l(n,"dimension")),comparison:Y(e.comparison),orderBy:e.orderBy?{field:l(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:R(e.inputs),limit:e.limit}}function V(e,t){if(!e.primaryMetric)return t[0]||{name:"",role:"measure"};const r=l(e.primaryMetric,"measure"),n=G(r,t),o=n.length===1?n[0]:void 0;return o?B(r,o):r}function j(e){const t=[];for(const r of e.metrics.map(n=>l(n,"measure"))){if(!r.name)continue;const n=t.findIndex(o=>N(o,r));if(n===-1){t.push(r);continue}t[n]=B(t[n],r)}return t}function N(e,t){return A.semaphorFieldRefsMatch(e,t)&&y(e)===y(t)}function Q(e,t){return y(t)===y(e)}function L(e,t){return t.name!==e.name||e.source&&!A.semaphorFieldRefsMatch(t,e)?!1:Q(e,t)}function G(e,t){const r=t.filter(n=>L(e,n));return e.aggregate!==void 0,r}function y(e){return(e.aggregate||"SUM").toUpperCase()}function B(e,t){if(e.aggregate&&t.aggregate&&e.aggregate!==t.aggregate)throw new Error(`Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${t.aggregate}.`);return{...A.preferSemaphorFieldRefMetadata(e,t),aggregate:e.aggregate||t.aggregate}}function w(e){if("sort"in e)throw new Error("useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!X(e))throw new Error("useSemaphorRecords needs at least one field.");const t=J(e.fields);return{version:1,kind:"records",id:e.id,label:e.label,source:k(e),fields:t,dateField:e.dateField?l(e.dateField,"date"):void 0,timeGrain:e.timeGrain,orderBy:e.orderBy?{field:l(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:R(e.inputs),limit:e.limit}}function J(e){return e.map(t=>{const r=l(t);if(!r.role)throw new Error(`useSemaphorRecords field "${r.name}" needs an explicit role.`);return r})}function O(e){return{version:1,kind:"inputOptions",id:e.id,label:e.label,source:k(e),field:l(e.field,"dimension"),search:e.search,limit:e.limit}}function q(e){if("toAnalyticsInput"in e){const t=e.toAnalyticsInput();return{inputId:t.inputId,...t.field?{field:t.field}:{}}}return{inputId:e.inputId,...e.field?{field:e.field}:{}}}function H(e){const t=R(e);return t.length>0?t:void 0}function $(e){return(e||[]).map(W)}function M(e){return $(e).filter(t=>t.isActive)}function C(e){return e.kind==="filter"?{inputId:e.id,kind:e.kind,label:e.label,field:l(e.field,"dimension"),operator:e.operator||"in"}:{inputId:e.id,kind:e.kind,label:e.label}}function T(e=[]){return e.map(t=>typeof t=="object"?t:{label:String(t),value:t})}function g(e){return e==null?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e.trim().length>0:!0}function W(e){return"toAnalyticsInput"in e?e.toAnalyticsInput():"kind"in e&&"isActive"in e?e:{...e,kind:"filter",isActive:g(e.value),value:e.value}}function k(e){return e.source}function X(e){var t;return!!((t=e.fields)!=null&&t.length)}function l(e,t){return{...e,role:e.role||t}}function R(e){return(e||[]).map(q)}function Y(e){if(e)return e}function P(){return{executeMetric:(e,t)=>S(e,t),executeRecords:(e,t)=>S(e,t),executeInputOptions:(e,t)=>S(e,t)}}async function S(e,t){if(!t.token)throw new Error("SemaphorDataAppProvider needs a token to execute queries.");const r=await fetch(te(t),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.token}`},body:JSON.stringify({intent:e,activeInputs:t.activeInputs,resultShape:e.kind})}),n=await Z(r);if(!r.ok||n.error)throw new Error(n.error||`Semaphor Data App execution failed with status ${r.status}.`);return n}async function Z(e){const t=await e.text().catch(()=>"");if(!t.trim())return e.ok?{error:"Semaphor Data App execution returned an empty response."}:{};try{return JSON.parse(t)}catch{return e.ok?{error:"Semaphor Data App execution returned invalid JSON.",details:t}:{error:ee(e,t),details:t}}}function ee(e,t){const r=e.statusText?` ${e.statusText}`:"",n=t.replace(/\s+/g," ").trim();return n?`Semaphor Data App execution failed with status ${e.status}${r}: ${n.slice(0,240)}`:`Semaphor Data App execution failed with status ${e.status}${r}.`}function te(e){const t=re(e).replace(/\/+$/,"");return t?t.endsWith("/api")?`${t}/v1/data-app/execute`:`${t}/api/v1/data-app/execute`:"/api/v1/data-app/execute"}function re(e){if(e.apiBaseUrl)return e.apiBaseUrl;if(!e.token)return"";try{return K.jwtDecode(e.token).apiServiceUrl||""}catch{return""}}const D=a.createContext({});function U(){if(!(typeof window>"u"))return window.__SEMAPHOR_DATA_APP_RUNTIME__}function _(){return a.useContext(D)}function ne({token:e,apiBaseUrl:t,executor:r,children:n}){var d;const o=U(),u=((d=o==null?void 0:o.authToken)==null?void 0:d.accessToken)||e,i=(o==null?void 0:o.dataApiBaseUrl)||(o==null?void 0:o.apiBaseUrl)||t,m=a.useMemo(()=>P(),[]),s=r||m,f=a.useMemo(()=>({token:u,apiBaseUrl:i,executor:s}),[i,s,u]);return F.jsx(D.Provider,{value:f,children:n})}const v={value:null},oe={records:[]},I={options:[]};function ie(e){const t=M(e.inputs);try{const r=E(e),n=b(r);return n?{error:n,activeInputs:t,queryKey:c(void 0,t,n),idleData:v}:{intent:r,error:null,activeInputs:t,queryKey:c(r,t),idleData:v}}catch(r){const n=h(r);return{error:n,activeInputs:t,queryKey:c(void 0,t,n),idleData:v}}}function ae(e){const t=M(e.inputs),r=oe;try{const n=w(e),o=b(n);return o?{error:o,activeInputs:t,queryKey:c(void 0,t,o),idleData:r}:{intent:n,error:null,activeInputs:t,queryKey:c(n,t),idleData:r}}catch(n){const o=h(n);return{error:o,activeInputs:t,queryKey:c(void 0,t,o),idleData:r}}}function ue(e){try{const t=O(e),r=b(t);return r?{error:r,queryKey:c(void 0,void 0,r),idleData:I}:{intent:t,error:null,queryKey:c(t),idleData:I}}catch(t){const r=h(t);return{error:r,queryKey:c(void 0,void 0,r),idleData:I}}}function h(e){return e instanceof Error?e:new Error(String(e))}function b(e){const t=z.validateSemaphorAnalyticsIntent(e);if(t.ok)return null;const r=t.errors.map(n=>n.path?`${n.code} at ${n.path}: ${n.message}`:`${n.code}: ${n.message}`).join("; ");return new Error(`Invalid Semaphor analytics intent. ${r}`)}function c(e,t,r){return JSON.stringify({intent:e,activeInputs:t,error:r==null?void 0:r.message})}function se(e){const[t,r]=a.useState(e.defaultValue),n=Object.prototype.hasOwnProperty.call(e,"value"),o=n?e.value:t,u=a.useMemo(()=>T(e.options),[e.options]),i=a.useCallback(s=>{var d;const f=s;(d=e.onValueChange)==null||d.call(e,f),n||r(f)},[n,e]),m=a.useCallback(()=>i(void 0),[i]);return a.useMemo(()=>{const s=C(e);return{id:e.id,kind:e.kind,label:e.label,field:s.field,operator:s.operator,controlRole:e.kind==="control"?e.role:void 0,value:o,options:u,isActive:g(o),setValue:i,clear:m,toAnalyticsInput:()=>({inputId:s.inputId,field:s.field,kind:e.kind,label:e.label,value:o,isActive:g(o),operator:s.operator,controlRole:e.kind==="control"?e.role:void 0})}},[m,u,i,e,o])}function le(e){const t=a.useMemo(()=>ie(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeMetric(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData,t.activeInputs),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,value:(o==null?void 0:o.value)??null,metrics:o==null?void 0:o.metrics,comparisonValue:o==null?void 0:o.comparisonValue,delta:o==null?void 0:o.delta,deltaPercent:o==null?void 0:o.deltaPercent,records:o==null?void 0:o.records,status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function de(e){const t=a.useMemo(()=>ae(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeRecords(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData,t.activeInputs),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,records:(o==null?void 0:o.records)||[],columns:o==null?void 0:o.columns,rowCount:o==null?void 0:o.rowCount,status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function ce(e){const t=a.useMemo(()=>ue(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeInputOptions(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,options:(o==null?void 0:o.options)||[],status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function x(e,t,r,n){const o=_(),u=a.useRef(t),i=a.useRef(n),[m,s]=a.useState({status:"idle",data:r,error:null});return u.current=t,i.current=n,a.useEffect(()=>{let f;try{f=u.current({...o,activeInputs:i.current})}catch(p){s({status:"error",data:r,error:h(p)});return}if(!f){s({status:"idle",data:r,error:null});return}let d=!1;return s(p=>({status:"loading",data:p.data,error:null})),f.then(p=>{d||s({status:"success",data:p,error:null})}).catch(p=>{d||s({status:"error",data:r,error:h(p)})}),()=>{d=!0}},[r,e,o]),m}exports.SemaphorDataAppContext=D;exports.SemaphorDataAppProvider=ne;exports.createSemaphorQueryExecutor=P;exports.hasSemaphorInputValue=g;exports.normalizeSemaphorInputOptions=T;exports.readWindowRuntime=U;exports.toSemaphorActiveInputSnapshots=M;exports.toSemaphorInputBinding=q;exports.toSemaphorInputBindings=H;exports.toSemaphorInputOptionsIntent=O;exports.toSemaphorInputSnapshots=$;exports.toSemaphorInputSpec=C;exports.toSemaphorMetricIntent=E;exports.toSemaphorRecordsIntent=w;exports.useSemaphorDataAppRuntime=_;exports.useSemaphorInput=se;exports.useSemaphorInputOptions=ce;exports.useSemaphorMetric=le;exports.useSemaphorRecords=de;
@@ -1,7 +1,8 @@
1
- import { e as x, f as O, v as q } from "../chunks/validators-ZeP5TVCl.js";
2
- import { j as T } from "../chunks/index-CuHybtft.js";
3
- import { createContext as U, useContext as _, useMemo as m, useState as b, useCallback as h, useRef as R, useEffect as C } from "react";
4
- import { jsx as K } from "react/jsx-runtime";
1
+ import { s as x, c as O } from "../chunks/source-identity-qAmkNtEK.js";
2
+ import { j as q } from "../chunks/index-CuHybtft.js";
3
+ import { createContext as T, useContext as U, useMemo as m, useState as b, useCallback as h, useRef as R, useEffect as _ } from "react";
4
+ import { jsx as C } from "react/jsx-runtime";
5
+ import { v as K } from "../chunks/validators-B-NiYgGc.js";
5
6
  function P(t) {
6
7
  var r;
7
8
  const e = z(t);
@@ -137,7 +138,7 @@ function H(t) {
137
138
  ...t.field ? { field: t.field } : {}
138
139
  };
139
140
  }
140
- function gt(t) {
141
+ function vt(t) {
141
142
  const e = D(t);
142
143
  return e.length > 0 ? e : void 0;
143
144
  }
@@ -261,20 +262,20 @@ function at(t) {
261
262
  if (!t.token)
262
263
  return "";
263
264
  try {
264
- return T(t.token).apiServiceUrl || "";
265
+ return q(t.token).apiServiceUrl || "";
265
266
  } catch {
266
267
  return "";
267
268
  }
268
269
  }
269
- const $ = U({});
270
+ const $ = T({});
270
271
  function ut() {
271
272
  if (!(typeof window > "u"))
272
273
  return window.__SEMAPHOR_DATA_APP_RUNTIME__;
273
274
  }
274
275
  function st() {
275
- return _($);
276
+ return U($);
276
277
  }
277
- function vt({
278
+ function St({
278
279
  token: t,
279
280
  apiBaseUrl: e,
280
281
  executor: r,
@@ -289,7 +290,7 @@ function vt({
289
290
  }),
290
291
  [i, u, a]
291
292
  );
292
- return /* @__PURE__ */ K($.Provider, { value: c, children: n });
293
+ return /* @__PURE__ */ C($.Provider, { value: c, children: n });
293
294
  }
294
295
  const S = { value: null }, lt = { records: [] }, I = { options: [] };
295
296
  function dt(t) {
@@ -370,7 +371,7 @@ function y(t) {
370
371
  return t instanceof Error ? t : new Error(String(t));
371
372
  }
372
373
  function E(t) {
373
- const e = q(t);
374
+ const e = K(t);
374
375
  if (e.ok)
375
376
  return null;
376
377
  const r = e.errors.map(
@@ -385,7 +386,7 @@ function d(t, e, r) {
385
386
  error: r == null ? void 0 : r.message
386
387
  });
387
388
  }
388
- function St(t) {
389
+ function It(t) {
389
390
  const [e, r] = b(t.defaultValue), n = Object.prototype.hasOwnProperty.call(t, "value"), o = n ? t.value : e, a = m(
390
391
  () => Y(t.options),
391
392
  [t.options]
@@ -424,7 +425,7 @@ function St(t) {
424
425
  };
425
426
  }, [p, a, i, t, o]);
426
427
  }
427
- function It(t) {
428
+ function At(t) {
428
429
  const e = m(() => dt(t), [t]), r = h(
429
430
  (a) => {
430
431
  var i;
@@ -451,7 +452,7 @@ function It(t) {
451
452
  error: e.error || n.error
452
453
  };
453
454
  }
454
- function At(t) {
455
+ function kt(t) {
455
456
  const e = m(() => ct(t), [t]), r = h(
456
457
  (a) => {
457
458
  var i;
@@ -475,7 +476,7 @@ function At(t) {
475
476
  error: e.error || n.error
476
477
  };
477
478
  }
478
- function kt(t) {
479
+ function Dt(t) {
479
480
  const e = m(() => ft(t), [t]), r = h(
480
481
  (a) => {
481
482
  var i;
@@ -502,7 +503,7 @@ function M(t, e, r, n) {
502
503
  data: r,
503
504
  error: null
504
505
  });
505
- return a.current = e, i.current = n, C(() => {
506
+ return a.current = e, i.current = n, _(() => {
506
507
  let c;
507
508
  try {
508
509
  c = a.current({
@@ -541,22 +542,22 @@ function M(t, e, r, n) {
541
542
  }
542
543
  export {
543
544
  $ as SemaphorDataAppContext,
544
- vt as SemaphorDataAppProvider,
545
+ St as SemaphorDataAppProvider,
545
546
  rt as createSemaphorQueryExecutor,
546
547
  A as hasSemaphorInputValue,
547
548
  Y as normalizeSemaphorInputOptions,
548
549
  ut as readWindowRuntime,
549
550
  B as toSemaphorActiveInputSnapshots,
550
551
  H as toSemaphorInputBinding,
551
- gt as toSemaphorInputBindings,
552
+ vt as toSemaphorInputBindings,
552
553
  J as toSemaphorInputOptionsIntent,
553
554
  W as toSemaphorInputSnapshots,
554
555
  X as toSemaphorInputSpec,
555
556
  P as toSemaphorMetricIntent,
556
557
  Q as toSemaphorRecordsIntent,
557
558
  st as useSemaphorDataAppRuntime,
558
- St as useSemaphorInput,
559
- kt as useSemaphorInputOptions,
560
- It as useSemaphorMetric,
561
- At as useSemaphorRecords
559
+ It as useSemaphorInput,
560
+ Dt as useSemaphorInputOptions,
561
+ At as useSemaphorMetric,
562
+ kt as useSemaphorRecords
562
563
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-D7U5s9Uk.js"),d=require("./chunks/common-types-C73-Ud1-.js"),P=require("./chunks/calendar-preferences-dialog-CaeYg4gz.js"),t=require("react/jsx-runtime"),a=require("./chunks/switch-DYRgERrC.js"),C=require("react"),N=require("./chunks/resource-management-panel-MHam0keE.js"),y=require("./types/index.cjs"),_=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");require("./chunks/index-DRlMUglg.js");const r=require("./chunks/dashboard-briefing-launcher-GmwoVZDA.js"),S=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");require("./chunks/index-BxM99sFL.js");function R(o){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const n in o)if(n!=="default"){const u=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(i,n,u.get?u:{enumerable:!0,get:()=>o[n]})}}return i.default=o,Object.freeze(i)}const h=R(C);function j(o){const{displayPreferences:i,cardId:n,...u}=o,s={...u,id:o.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:s,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:o.cardId}),t.jsx(e.UXProvider,{appearance:o.appearance,children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:i,children:t.jsx(e.Container,{type:"visual",cardId:n,...s,children:t.jsx(w,{cardId:n})})})})]})})}function w({cardId:o}){const i=a.useDashboardStore(s=>{var c;return(c=s.dashboard)==null?void 0:c.sheets}),{card:n,frame:u}=C.useMemo(()=>{const s=i==null?void 0:i.flatMap(l=>l.frames),c=s==null?void 0:s.flatMap(l=>l==null?void 0:l.cards),D=c==null?void 0:c.find(l=>(l==null?void 0:l.id)===o),E=s==null?void 0:s.find(l=>{var p;return(p=l==null?void 0:l.cards)==null?void 0:p.find(g=>(g==null?void 0:g.id)===o)});return{card:D,frame:E}},[i,o]);return!n||!u?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${o}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:s,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:s,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:u})})})}function M(o,i,n,u){C.useEffect(()=>{o&&!n&&i&&u(e.cloneDeep(i))},[o,n,i,u])}function L({name:o,items:i,value:n,onChange:u,isLoading:s,isError:c,refetch:D,className:E,icon:l,showNone:p=!1}){const g=h.useRef(null),[b,T]=h.useState(!1),[B,A]=h.useState("100%"),x=p?[...i||[],{id:"none",name:"None"}]:i;h.useLayoutEffect(()=>{g.current&&A(g.current.offsetWidth)},[]);function F(){var f;return s?"Loading...":c?"Error":n?(f=i==null?void 0:i.find(m=>m.id===n))==null?void 0:f.name:`Select ${o}`}function v(f,m){u(m),T(!1)}return t.jsxs(a.Popover,{open:b,onOpenChange:T,children:[t.jsx(a.PopoverTrigger,{asChild:!0,children:t.jsxs(a.Button,{ref:g,variant:"outline",role:"combobox","aria-expanded":b,className:a.cn("flex h-9 w-full justify-between",E),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[l&&t.jsx("div",{className:"mr-2",children:l}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:F()})]}),t.jsx(a.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(a.PopoverContent,{className:"w-full p-0",style:{minWidth:B},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:D,children:t.jsx(e.RefreshCw,{className:a.cn("size-3.5 opacity-50",s&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",o==null?void 0:o.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:x==null?void 0:x.map(f=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:f.name,onSelect:m=>v(m,f.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(a.Check,{className:a.cn("size-4",n===f.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:f.name,children:f.name})]})},f.id))})]})]})})]})}function I(o,i){C.useEffect(()=>(o&&i&&(window.__SEMAPHOR_PRINT_STATE__={...i}),()=>{o&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[o,i])}exports.CardSummary=e.CardSummary;exports.Dashboard=e.Dashboard;exports.DashboardCreateDialogBase=e.DashboardCreateDialogBase;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.ExportError=e.ExportError;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createExport=e.createExport;exports.downloadDocumentPdf=e.downloadDocumentPdf;exports.downloadPdf=e.downloadPdf;exports.formatFileSize=e.formatFileSize;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useCard=e.useCard;exports.useCardSummary=e.useCardSummary;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorAside=e.useEditorAside;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useTextFilterHook=e.useTextFilterHook;exports.CALCULATED_FIELD_ENTITY_MARKER=d.CALCULATED_FIELD_ENTITY_MARKER;exports.CONTROL_CARD_DEFAULT_VALUE=d.CONTROL_CARD_DEFAULT_VALUE;exports.DATE_FORMAT_VALUES=d.DATE_FORMAT_VALUES;exports.EMPTY_SELECTION=d.EMPTY_SELECTION;exports.PivotMarkerEnum=d.PivotMarkerEnum;exports.getFieldRuntimeColumnName=d.getFieldRuntimeColumnName;exports.hasCalculatedFieldMarker=d.hasCalculatedFieldMarker;exports.hasCalculatedFormulaInputs=d.hasCalculatedFormulaInputs;exports.isCalculatedDimension=d.isCalculatedDimension;exports.isCalculatedField=d.isCalculatedField;exports.isCalculatedMetric=d.isCalculatedMetric;exports.CalendarPreferencesDialog=P.CalendarPreferencesDialog;exports.createEmptyKpiConfig=a.createEmptyKpiConfig;exports.createSqlGenConfig=a.createSqlGenConfig;exports.emitDashboardLoad=a.emitDashboardLoad;exports.emitDashboardUnload=a.emitDashboardUnload;exports.fmt=a.fmt;exports.getColumnDataType=a.getColumnDataType;exports.getFilterValueType=a.getFilterValueType;exports.getFormattedTableNameForQuery=a.getFormattedTableNameForQuery;exports.getQualifiedTableName=a.getQualifiedTableName;exports.getSql=a.getSql;exports.invalidateToken=a.invalidateToken;exports.isBooleanDataType=a.isBooleanDataType;exports.isColumnInSqlGen=a.isColumnInSqlGen;exports.isDateDataType=a.isDateDataType;exports.isNumberDataType=a.isNumberDataType;exports.isTextDataType=a.isTextDataType;exports.resolveDataType=a.resolveDataType;exports.resolveDatamodelName=a.resolveDatamodelName;exports.useCurrentActiveCard=a.useCurrentActiveCard;exports.useCurrentCardConfig=a.useCurrentCardConfig;exports.useCurrentSheetActiveCards=a.useCurrentSheetActiveCards;exports.useDashboardActions=a.useDashboardActions;exports.useDashboardStore=a.useDashboardStore;exports.useEditorActions=a.useEditorActions;exports.useEditorStore=a.useEditorStore;exports.ResourceManagementPanel=N.ResourceManagementPanel;exports.DEFAULT_CALENDAR_CONTEXT=y.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=y.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.useDebouncedDirtyCheck=_.useDebouncedDirtyCheck;exports.AdvancedModeToggle=r.AdvancedModeToggle;exports.BriefingAuthor=r.BriefingAuthor;exports.BriefingsApiError=r.BriefingsApiError;exports.DashboardBriefingLauncher=r.DashboardBriefingLauncher;exports.DashboardControlsSettings=r.DashboardControlsSettings;exports.DashboardFilterControlsButton=r.DashboardFilterControlsButton;exports.DashboardFilterControlsLauncher=r.DashboardFilterControlsLauncher;exports.DocumentControlsSettings=r.DocumentControlsSettings;exports.ExportNotificationItem=r.ExportNotificationItem;exports.ExportNotificationList=r.ExportNotificationList;exports.NotificationBell=r.NotificationBell;exports.UnsavedChangesAlert=r.UnsavedChangesAlert;exports.VisualEditingControls=r.VisualEditingControls;exports.WatchDashboardButton=r.WatchDashboardButton;exports.applyBriefingFormPatch=r.applyBriefingFormPatch;exports.briefingFormDraftToCreateRequest=r.briefingFormDraftToCreateRequest;exports.briefingFormDraftToUpdateRequest=r.briefingFormDraftToUpdateRequest;exports.briefingToFormDraft=r.briefingToFormDraft;exports.cancelBriefingRun=r.cancelBriefingRun;exports.createBriefing=r.createBriefing;exports.createBriefingFormDraft=r.createBriefingFormDraft;exports.deleteBriefing=r.deleteBriefing;exports.deleteBriefingRun=r.deleteBriefingRun;exports.getBriefing=r.getBriefing;exports.getBriefingArtifact=r.getBriefingArtifact;exports.getBriefingEvidence=r.getBriefingEvidence;exports.getBriefingPreviewRun=r.getBriefingPreviewRun;exports.getBriefingRun=r.getBriefingRun;exports.listBriefingRuns=r.listBriefingRuns;exports.listBriefingTenantSummaries=r.listBriefingTenantSummaries;exports.listBriefings=r.listBriefings;exports.pauseBriefing=r.pauseBriefing;exports.polishBriefingText=r.polishBriefingText;exports.previewBriefingPlan=r.previewBriefingPlan;exports.resumeBriefing=r.resumeBriefing;exports.runBriefingNow=r.runBriefingNow;exports.runBriefingPreview=r.runBriefingPreview;exports.updateBriefing=r.updateBriefing;exports.useExportPolling=r.useExportPolling;exports.useExportRecovery=r.useExportRecovery;exports.validateBriefingFormDraft=r.validateBriefingFormDraft;exports.normalizeDashboardForDirtyCheck=S.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=S.serializeDashboardForDirtyCheck;exports.Combobox=L;exports.Visual=j;exports.useExposePrintState=I;exports.usePristineSnapshotInitializer=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-Alj8oDV1.js"),d=require("./chunks/common-types-C73-Ud1-.js"),P=require("./chunks/calendar-preferences-dialog-C2vX2dga.js"),t=require("react/jsx-runtime"),a=require("./chunks/switch-C0S63HAv.js"),C=require("react"),N=require("./chunks/resource-management-panel-DLJ6uWYJ.js"),y=require("./types/index.cjs"),_=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");require("./chunks/index-DRlMUglg.js");const r=require("./chunks/dashboard-briefing-launcher-DjzTWk1f.js"),S=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");require("./chunks/index-BxM99sFL.js");function R(o){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const n in o)if(n!=="default"){const u=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(i,n,u.get?u:{enumerable:!0,get:()=>o[n]})}}return i.default=o,Object.freeze(i)}const h=R(C);function j(o){const{displayPreferences:i,cardId:n,...u}=o,s={...u,id:o.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:s,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:o.cardId}),t.jsx(e.UXProvider,{appearance:o.appearance,children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:i,children:t.jsx(e.Container,{type:"visual",cardId:n,...s,children:t.jsx(w,{cardId:n})})})})]})})}function w({cardId:o}){const i=a.useDashboardStore(s=>{var c;return(c=s.dashboard)==null?void 0:c.sheets}),{card:n,frame:u}=C.useMemo(()=>{const s=i==null?void 0:i.flatMap(l=>l.frames),c=s==null?void 0:s.flatMap(l=>l==null?void 0:l.cards),D=c==null?void 0:c.find(l=>(l==null?void 0:l.id)===o),E=s==null?void 0:s.find(l=>{var p;return(p=l==null?void 0:l.cards)==null?void 0:p.find(g=>(g==null?void 0:g.id)===o)});return{card:D,frame:E}},[i,o]);return!n||!u?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${o}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:s,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:s,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:u})})})}function M(o,i,n,u){C.useEffect(()=>{o&&!n&&i&&u(e.cloneDeep(i))},[o,n,i,u])}function L({name:o,items:i,value:n,onChange:u,isLoading:s,isError:c,refetch:D,className:E,icon:l,showNone:p=!1}){const g=h.useRef(null),[b,T]=h.useState(!1),[B,A]=h.useState("100%"),x=p?[...i||[],{id:"none",name:"None"}]:i;h.useLayoutEffect(()=>{g.current&&A(g.current.offsetWidth)},[]);function F(){var f;return s?"Loading...":c?"Error":n?(f=i==null?void 0:i.find(m=>m.id===n))==null?void 0:f.name:`Select ${o}`}function v(f,m){u(m),T(!1)}return t.jsxs(a.Popover,{open:b,onOpenChange:T,children:[t.jsx(a.PopoverTrigger,{asChild:!0,children:t.jsxs(a.Button,{ref:g,variant:"outline",role:"combobox","aria-expanded":b,className:a.cn("flex h-9 w-full justify-between",E),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[l&&t.jsx("div",{className:"mr-2",children:l}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:F()})]}),t.jsx(a.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(a.PopoverContent,{className:"w-full p-0",style:{minWidth:B},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:D,children:t.jsx(e.RefreshCw,{className:a.cn("size-3.5 opacity-50",s&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",o==null?void 0:o.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:x==null?void 0:x.map(f=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:f.name,onSelect:m=>v(m,f.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(a.Check,{className:a.cn("size-4",n===f.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:f.name,children:f.name})]})},f.id))})]})]})})]})}function I(o,i){C.useEffect(()=>(o&&i&&(window.__SEMAPHOR_PRINT_STATE__={...i}),()=>{o&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[o,i])}exports.CardSummary=e.CardSummary;exports.Dashboard=e.Dashboard;exports.DashboardCreateDialogBase=e.DashboardCreateDialogBase;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.ExportError=e.ExportError;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createExport=e.createExport;exports.downloadDocumentPdf=e.downloadDocumentPdf;exports.downloadPdf=e.downloadPdf;exports.formatFileSize=e.formatFileSize;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useCard=e.useCard;exports.useCardSummary=e.useCardSummary;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorAside=e.useEditorAside;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useTextFilterHook=e.useTextFilterHook;exports.CALCULATED_FIELD_ENTITY_MARKER=d.CALCULATED_FIELD_ENTITY_MARKER;exports.CONTROL_CARD_DEFAULT_VALUE=d.CONTROL_CARD_DEFAULT_VALUE;exports.DATE_FORMAT_VALUES=d.DATE_FORMAT_VALUES;exports.EMPTY_SELECTION=d.EMPTY_SELECTION;exports.PivotMarkerEnum=d.PivotMarkerEnum;exports.getFieldRuntimeColumnName=d.getFieldRuntimeColumnName;exports.hasCalculatedFieldMarker=d.hasCalculatedFieldMarker;exports.hasCalculatedFormulaInputs=d.hasCalculatedFormulaInputs;exports.isCalculatedDimension=d.isCalculatedDimension;exports.isCalculatedField=d.isCalculatedField;exports.isCalculatedMetric=d.isCalculatedMetric;exports.CalendarPreferencesDialog=P.CalendarPreferencesDialog;exports.createEmptyKpiConfig=a.createEmptyKpiConfig;exports.createSqlGenConfig=a.createSqlGenConfig;exports.emitDashboardLoad=a.emitDashboardLoad;exports.emitDashboardUnload=a.emitDashboardUnload;exports.fmt=a.fmt;exports.getColumnDataType=a.getColumnDataType;exports.getFilterValueType=a.getFilterValueType;exports.getFormattedTableNameForQuery=a.getFormattedTableNameForQuery;exports.getQualifiedTableName=a.getQualifiedTableName;exports.getSql=a.getSql;exports.invalidateToken=a.invalidateToken;exports.isBooleanDataType=a.isBooleanDataType;exports.isColumnInSqlGen=a.isColumnInSqlGen;exports.isDateDataType=a.isDateDataType;exports.isNumberDataType=a.isNumberDataType;exports.isTextDataType=a.isTextDataType;exports.resolveDataType=a.resolveDataType;exports.resolveDatamodelName=a.resolveDatamodelName;exports.useCurrentActiveCard=a.useCurrentActiveCard;exports.useCurrentCardConfig=a.useCurrentCardConfig;exports.useCurrentSheetActiveCards=a.useCurrentSheetActiveCards;exports.useDashboardActions=a.useDashboardActions;exports.useDashboardStore=a.useDashboardStore;exports.useEditorActions=a.useEditorActions;exports.useEditorStore=a.useEditorStore;exports.ResourceManagementPanel=N.ResourceManagementPanel;exports.DEFAULT_CALENDAR_CONTEXT=y.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=y.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.useDebouncedDirtyCheck=_.useDebouncedDirtyCheck;exports.AdvancedModeToggle=r.AdvancedModeToggle;exports.BriefingAuthor=r.BriefingAuthor;exports.BriefingsApiError=r.BriefingsApiError;exports.DashboardBriefingLauncher=r.DashboardBriefingLauncher;exports.DashboardControlsSettings=r.DashboardControlsSettings;exports.DashboardFilterControlsButton=r.DashboardFilterControlsButton;exports.DashboardFilterControlsLauncher=r.DashboardFilterControlsLauncher;exports.DocumentControlsSettings=r.DocumentControlsSettings;exports.ExportNotificationItem=r.ExportNotificationItem;exports.ExportNotificationList=r.ExportNotificationList;exports.NotificationBell=r.NotificationBell;exports.UnsavedChangesAlert=r.UnsavedChangesAlert;exports.VisualEditingControls=r.VisualEditingControls;exports.WatchDashboardButton=r.WatchDashboardButton;exports.applyBriefingFormPatch=r.applyBriefingFormPatch;exports.briefingFormDraftToCreateRequest=r.briefingFormDraftToCreateRequest;exports.briefingFormDraftToUpdateRequest=r.briefingFormDraftToUpdateRequest;exports.briefingToFormDraft=r.briefingToFormDraft;exports.cancelBriefingRun=r.cancelBriefingRun;exports.createBriefing=r.createBriefing;exports.createBriefingFormDraft=r.createBriefingFormDraft;exports.deleteBriefing=r.deleteBriefing;exports.deleteBriefingRun=r.deleteBriefingRun;exports.getBriefing=r.getBriefing;exports.getBriefingArtifact=r.getBriefingArtifact;exports.getBriefingEvidence=r.getBriefingEvidence;exports.getBriefingPreviewRun=r.getBriefingPreviewRun;exports.getBriefingRun=r.getBriefingRun;exports.listBriefingRuns=r.listBriefingRuns;exports.listBriefingTenantSummaries=r.listBriefingTenantSummaries;exports.listBriefings=r.listBriefings;exports.pauseBriefing=r.pauseBriefing;exports.polishBriefingText=r.polishBriefingText;exports.previewBriefingPlan=r.previewBriefingPlan;exports.resumeBriefing=r.resumeBriefing;exports.runBriefingNow=r.runBriefingNow;exports.runBriefingPreview=r.runBriefingPreview;exports.updateBriefing=r.updateBriefing;exports.useExportPolling=r.useExportPolling;exports.useExportRecovery=r.useExportRecovery;exports.validateBriefingFormDraft=r.validateBriefingFormDraft;exports.normalizeDashboardForDirtyCheck=S.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=S.serializeDashboardForDirtyCheck;exports.Combobox=L;exports.Visual=j;exports.useExposePrintState=I;exports.usePristineSnapshotInitializer=M;
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
- import { E as T, F as N, S, q as P, U as _, r as w, s as F, t as x, v as R, w as I, C as M, i as L, I as k, x as U, j as O, k as z, l as V, m as H } from "./chunks/index-DhuiooCy.js";
2
- import { W as ca, D as fa, T as ma, Q as pa, N as ha, a9 as ga, A as Ca, H as Da, H as Ea, J as xa, V as Ta, a as ba, a8 as ya, a4 as va, P as Aa, O as Ba, ac as Na, a7 as Sa, a6 as Pa, a5 as _a, ab as wa, aa as Fa, a1 as Ra, _ as Ia, M as Ma, Y as La, L as ka, z as Ua, X as Oa, Z as za, B as Va, a3 as Ha, a0 as qa, $ as Wa, a2 as ja, y as Ga, K as Qa, G as Ka } from "./chunks/index-DhuiooCy.js";
1
+ import { E as T, F as N, S, q as P, U as _, r as w, s as F, t as x, v as R, w as I, C as M, i as L, I as k, x as U, j as O, k as z, l as V, m as H } from "./chunks/index-DTSZ23bE.js";
2
+ import { W as ca, D as fa, T as ma, Q as pa, N as ha, a9 as ga, A as Ca, H as Da, H as Ea, J as xa, V as Ta, a as ba, a8 as ya, a4 as va, P as Aa, O as Ba, ac as Na, a7 as Sa, a6 as Pa, a5 as _a, ab as wa, aa as Fa, a1 as Ra, _ as Ia, M as Ma, Y as La, L as ka, z as Ua, X as Oa, Z as za, B as Va, a3 as Ha, a0 as qa, $ as Wa, a2 as ja, y as Ga, K as Qa, G as Ka } from "./chunks/index-DTSZ23bE.js";
3
3
  import { a as Ya, C as $a, D as Ja, E as Za, P as ae, g as ee, d as se, h as re, b as oe, c as te, i as ne } from "./chunks/common-types-4bjoIgvm.js";
4
- import { C as le } from "./chunks/calendar-preferences-dialog-AVORk8vl.js";
4
+ import { C as le } from "./chunks/calendar-preferences-dialog-gMb9JPpz.js";
5
5
  import { jsx as a, jsxs as d } from "react/jsx-runtime";
6
- import { u as q, P as W, b as j, B as G, a as C, g as Q, d as K, e as X } from "./chunks/switch-CP7SmEIZ.js";
7
- import { F as ue, q as ce, h as fe, i as me, k as pe, s as he, r as ge, w as Ce, x as De, p as Ee, j as xe, o as Te, t as be, n as ye, m as ve, l as Ae, y as Be, v as Ne, z as Se, D as Pe, A as _e, E as we, H as Fe, G as Re } from "./chunks/switch-CP7SmEIZ.js";
6
+ import { u as q, P as W, b as j, B as G, a as C, g as Q, d as K, e as X } from "./chunks/switch-21kU-tcj.js";
7
+ import { F as ue, q as ce, h as fe, i as me, k as pe, s as he, r as ge, w as Ce, x as De, p as Ee, j as xe, o as Te, t as be, n as ye, m as ve, l as Ae, y as Be, v as Ne, z as Se, D as Pe, A as _e, E as we, H as Fe, G as Re } from "./chunks/switch-21kU-tcj.js";
8
8
  import * as m from "react";
9
9
  import { useMemo as Y, useEffect as b } from "react";
10
- import { ResourceManagementPanel as Me } from "./chunks/resource-management-panel-DIt7NxsX.js";
10
+ import { ResourceManagementPanel as Me } from "./chunks/resource-management-panel-BvTTEaef.js";
11
11
  import { DEFAULT_CALENDAR_CONTEXT as ke, DEFAULT_SEMANTIC_DOMAIN_ACCESS as Ue } from "./types/index.js";
12
12
  import { u as ze } from "./chunks/use-debounced-dirty-check-BwAbnX_5.js";
13
13
  import "react-dom";
14
14
  import "./chunks/index-CJdxSyQq.js";
15
- import { A as He, J as qe, B as We, K as je, D as Ge, d as Qe, e as Ke, c as Xe, a as Ye, E as $e, N as Je, U as Ze, V as as, W as es, C as ss, G as rs, H as os, F as ts, t as ns, h as is, z as ls, j as ds, v as us, g as cs, w as fs, x as ms, o as ps, s as hs, q as gs, f as Cs, l as Ds, p as Es, y as xs, m as Ts, r as bs, k as ys, n as vs, i as As, u as Bs, b as Ns, I as Ss } from "./chunks/dashboard-briefing-launcher-B7hc62UJ.js";
15
+ import { A as He, J as qe, B as We, K as je, D as Ge, d as Qe, e as Ke, c as Xe, a as Ye, E as $e, N as Je, U as Ze, V as as, W as es, C as ss, G as rs, H as os, F as ts, t as ns, h as is, z as ls, j as ds, v as us, g as cs, w as fs, x as ms, o as ps, s as hs, q as gs, f as Cs, l as Ds, p as Es, y as xs, m as Ts, r as bs, k as ys, n as vs, i as As, u as Bs, b as Ns, I as Ss } from "./chunks/dashboard-briefing-launcher-Cx4NkJil.js";
16
16
  import { n as _s, s as ws } from "./chunks/normalize-dashboard-for-dirty-check-5KpZN8xr.js";
17
17
  import "./chunks/index-CuHybtft.js";
18
18
  function ta(e) {