react-semaphor 0.1.494 → 0.1.495

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 (118) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +10 -10
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +5 -5
  7. package/dist/chunks/{calculated-field-identity-D4VOHjBJ.cjs → calculated-field-identity-Cc-RlE-0.cjs} +1 -1
  8. package/dist/chunks/{calculated-field-identity-CSabKrXt.js → calculated-field-identity-D7ygZ7oN.js} +4 -4
  9. package/dist/chunks/{constants-D47EhfJR.js → constants-BjGBVFbu.js} +5 -5
  10. package/dist/chunks/{constants-BMfm1XgO.cjs → constants-C-GvudXp.cjs} +1 -1
  11. package/dist/chunks/{dashboard-briefing-launcher-nWBKnd0X.cjs → dashboard-briefing-launcher-DyYVbfXp.cjs} +1 -1
  12. package/dist/chunks/{dashboard-briefing-launcher-DQFa0Ti1.js → dashboard-briefing-launcher-tYTkfNPj.js} +9 -9
  13. package/dist/chunks/{dashboard-controls-DWpnRtQI.js → dashboard-controls-BR7hSzDh.js} +11 -11
  14. package/dist/chunks/{dashboard-controls-BbPWWVO-.cjs → dashboard-controls-Hwo4ZnW4.cjs} +1 -1
  15. package/dist/chunks/{dashboard-date-comparison-definition-DCIUwJnZ.cjs → dashboard-date-comparison-definition-1NBx_7QQ.cjs} +1 -1
  16. package/dist/chunks/{dashboard-date-comparison-definition-CKXgDzSB.js → dashboard-date-comparison-definition-CpCZAGIz.js} +1 -1
  17. package/dist/chunks/{dashboard-json-BFJNDHxv.cjs → dashboard-json-B3CuJo_G.cjs} +1 -1
  18. package/dist/chunks/{dashboard-json-DyTQysQF.js → dashboard-json-FDNan6Lc.js} +7 -7
  19. package/dist/chunks/{edit-dashboard-visual-D-gauuNQ.js → edit-dashboard-visual-DTJwFkdX.js} +7903 -7939
  20. package/dist/chunks/edit-dashboard-visual-aqW4Jtrr.cjs +172 -0
  21. package/dist/chunks/{editor-action-buttons-B7YezrkC.cjs → editor-action-buttons-B3Dpnink.cjs} +1 -1
  22. package/dist/chunks/{editor-action-buttons-DMgnHVY1.js → editor-action-buttons-DSGiwWur.js} +6 -6
  23. package/dist/chunks/{field-aggregations-J7de9KZm.js → field-aggregations-Cy4hBBqe.js} +5 -5
  24. package/dist/chunks/{field-aggregations-hx8odlTh.cjs → field-aggregations-U54X9_Rt.cjs} +1 -1
  25. package/dist/chunks/{index-Df4YBtX5.cjs → index-B9FLuTyx.cjs} +1 -1
  26. package/dist/chunks/{index-CPWfCksu.js → index-Ne0-ePdz.js} +34332 -34316
  27. package/dist/chunks/{index-DXQsuuMQ.cjs → index-a9nBmD-v.cjs} +224 -223
  28. package/dist/chunks/{index-BDtC8et3.js → index-zKj-mqbS.js} +11 -11
  29. package/dist/chunks/{matrix-analytical-definition-B3p3vF0K.cjs → matrix-analytical-definition-B5oWAePu.cjs} +1 -1
  30. package/dist/chunks/{matrix-analytical-definition-DAFStKt2.js → matrix-analytical-definition-DSRmzber.js} +1 -1
  31. package/dist/chunks/{matrix-card-DzkJRoM4.cjs → matrix-card-BV7OPtq_.cjs} +1 -1
  32. package/dist/chunks/{matrix-card-5R39CCdj.js → matrix-card-CxTCV9HF.js} +2 -2
  33. package/dist/chunks/{matrix-control-sources-BWbqiGmN.cjs → matrix-control-sources-BLGlb4S9.cjs} +1 -1
  34. package/dist/chunks/{matrix-control-sources-DxjWV8ry.js → matrix-control-sources-DYMzccBY.js} +5 -5
  35. package/dist/chunks/{matrix-definition-BcJi7qGZ.js → matrix-definition-Djesv_9v.js} +1 -1
  36. package/dist/chunks/{matrix-definition-Z80mIEfu.cjs → matrix-definition-jy7ygO6J.cjs} +1 -1
  37. package/dist/chunks/{matrix-formatter-youWVghC.js → matrix-formatter-BhkdDosE.js} +4 -4
  38. package/dist/chunks/{matrix-formatter-3QR1mqhn.cjs → matrix-formatter-CuRTrMP2.cjs} +1 -1
  39. package/dist/chunks/{matrix-member-presentation-BEWAH5xK.js → matrix-member-presentation-BN6VD-fr.js} +1 -1
  40. package/dist/chunks/{matrix-member-presentation-DtLGyv8w.cjs → matrix-member-presentation-D82rMVDG.cjs} +1 -1
  41. package/dist/chunks/{matrix-operation-contract-D5I-t3i7.js → matrix-operation-contract-4q53iAUW.js} +1 -1
  42. package/dist/chunks/{matrix-operation-contract-BiUMcd6G.cjs → matrix-operation-contract-CbavkrJj.cjs} +1 -1
  43. package/dist/chunks/{metric-comparison-vr9j4Z_Z.js → metric-comparison-CPx_2iqI.js} +1 -1
  44. package/dist/chunks/{metric-comparison-D1VRq5Os.cjs → metric-comparison-l2X7Reol.cjs} +1 -1
  45. package/dist/chunks/{pivot-header-presentation-Dcd4IBM5.cjs → pivot-header-presentation-BDMb1Wlc.cjs} +1 -1
  46. package/dist/chunks/{pivot-header-presentation-BslEo_4O.js → pivot-header-presentation-utM9JrgD.js} +3 -3
  47. package/dist/chunks/{pivot-result-identity-CMz27nri.js → pivot-result-identity-BDntll93.js} +1 -1
  48. package/dist/chunks/{pivot-result-identity-CmvwpG4K.cjs → pivot-result-identity-Hm1sO9KE.cjs} +1 -1
  49. package/dist/chunks/{pivot-result-lifecycle-BCoOFUiU.js → pivot-result-lifecycle-Cu9hRFAp.js} +7 -7
  50. package/dist/chunks/{pivot-result-lifecycle-H_pntnd9.cjs → pivot-result-lifecycle-QiOUMsYd.cjs} +1 -1
  51. package/dist/chunks/{raw-temporal-YWo1GEmr.js → raw-temporal-CknUT-Fp.js} +2 -2
  52. package/dist/chunks/{raw-temporal-DcHmXurp.cjs → raw-temporal-DWuF9bt7.cjs} +1 -1
  53. package/dist/chunks/{raw-temporal-contract-Bg1mtRGE.cjs → raw-temporal-contract-B3YGcvzw.cjs} +1 -1
  54. package/dist/chunks/{raw-temporal-contract-DY-Jd4Sc.js → raw-temporal-contract-BVcDonCB.js} +1 -1
  55. package/dist/chunks/{report-preferences-dialog-oT-C29vV.cjs → report-preferences-dialog-BP_EdVHP.cjs} +1 -1
  56. package/dist/chunks/{report-preferences-dialog-Bt8T3To1.js → report-preferences-dialog-DsjMwa3m.js} +6 -6
  57. package/dist/chunks/{report-runtime-context-Bb0ejvVq.cjs → report-runtime-context-C-As8sq_.cjs} +1 -1
  58. package/dist/chunks/{report-runtime-context-nCHl3uHC.js → report-runtime-context-DTxVBKqP.js} +1 -1
  59. package/dist/chunks/{semantic-format-UvUAyZS-.js → semantic-format-BTEhH9ga.js} +2 -2
  60. package/dist/chunks/{semantic-format-CMPIcb8l.cjs → semantic-format-CyJWf8gZ.cjs} +1 -1
  61. package/dist/chunks/{source-entity-resolution-DeH38dTU.cjs → source-entity-resolution-BA8sdBbL.cjs} +1 -1
  62. package/dist/chunks/{source-entity-resolution-Dm4in31q.js → source-entity-resolution-DXjCZPuO.js} +1 -1
  63. package/dist/chunks/{switch-DHOv6xHT.js → switch-BmCGBb2F.js} +12 -12
  64. package/dist/chunks/{switch-CatLIoK-.cjs → switch-COujiMcB.cjs} +1 -1
  65. package/dist/chunks/{temporal-bucket-contract-Bx5TJXF3.js → temporal-bucket-contract-Bhsl_j4B.js} +1 -1
  66. package/dist/chunks/{temporal-bucket-contract-CPuYzg7A.cjs → temporal-bucket-contract-pW4c6N2M.cjs} +1 -1
  67. package/dist/chunks/{token-types-hl08eNuY.cjs → token-types-CsKRtJp0.cjs} +1 -1
  68. package/dist/chunks/{token-types-5buW2I6f.js → token-types-DpYncMPp.js} +1 -1
  69. package/dist/chunks/{update-policy-D3I1J2kl.js → update-policy-BoB26XrS.js} +2 -2
  70. package/dist/chunks/{update-policy-BP_2uCgs.cjs → update-policy-CtLb9ish.cjs} +1 -1
  71. package/dist/chunks/validators-CueUwVE4.cjs +1 -0
  72. package/dist/chunks/{validators-BpJDwDnG.js → validators-DgmJaRF4.js} +2 -0
  73. package/dist/dashboard/index.cjs +1 -1
  74. package/dist/dashboard/index.js +1 -1
  75. package/dist/dashboard-authoring/index.cjs +1 -1
  76. package/dist/dashboard-authoring/index.js +9 -9
  77. package/dist/data-app-builder/index.cjs +1 -1
  78. package/dist/data-app-builder/index.js +2 -2
  79. package/dist/data-app-codegen/index.cjs +1 -1
  80. package/dist/data-app-codegen/index.js +2 -2
  81. package/dist/data-app-codegen-node/index.cjs +1 -1
  82. package/dist/data-app-codegen-node/index.js +3 -3
  83. package/dist/data-app-sdk/index.cjs +1 -1
  84. package/dist/data-app-sdk/index.js +4 -4
  85. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  86. package/dist/data-app-sdk-adapters/index.js +2 -2
  87. package/dist/data-app-sdk-validation/index.cjs +1 -1
  88. package/dist/data-app-sdk-validation/index.js +5 -5
  89. package/dist/format-utils/index.cjs +1 -1
  90. package/dist/format-utils/index.js +16 -16
  91. package/dist/index.cjs +1 -1
  92. package/dist/index.js +15 -15
  93. package/dist/report-runtime-context/index.cjs +1 -1
  94. package/dist/report-runtime-context/index.js +2 -2
  95. package/dist/style.css +1 -1
  96. package/dist/surfboard/index.cjs +1 -1
  97. package/dist/surfboard/index.js +2 -2
  98. package/dist/types/analytics-protocol.d.ts +9 -0
  99. package/dist/types/briefings.d.ts +9 -0
  100. package/dist/types/dashboard-assistant.d.ts +9 -0
  101. package/dist/types/dashboard-authoring.d.ts +9 -0
  102. package/dist/types/dashboard.d.ts +9 -0
  103. package/dist/types/data-app-builder.d.ts +9 -0
  104. package/dist/types/data-app-codegen-node.d.ts +9 -0
  105. package/dist/types/data-app-codegen.d.ts +9 -0
  106. package/dist/types/data-app-sdk-adapters.d.ts +9 -0
  107. package/dist/types/data-app-sdk-validation.d.ts +9 -0
  108. package/dist/types/data-app-sdk.d.ts +9 -0
  109. package/dist/types/format-utils.d.ts +9 -0
  110. package/dist/types/index.cjs +1 -1
  111. package/dist/types/index.js +4 -4
  112. package/dist/types/main.d.ts +11 -0
  113. package/dist/types/shared.d.ts +9 -0
  114. package/dist/types/surfboard.d.ts +9 -0
  115. package/dist/types/types.d.ts +9 -0
  116. package/package.json +1 -1
  117. package/dist/chunks/edit-dashboard-visual-Dtacp_qY.cjs +0 -172
  118. package/dist/chunks/validators-4dRtYUI1.cjs +0 -1
@@ -1,3 +1,3 @@
1
- "use strict";const V=require("./matrix-operation-contract-BiUMcd6G.cjs"),S=require("../data-app-sdk-adapters/index.cjs");require("./validators-4dRtYUI1.cjs");const re=V.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION,k=V.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION,G="semaphor-generated-data-app-contract/v1",M="semaphor-generated-data-app-contract-manifest/v1";function q(e){return E(e)?[...V.validateSemaphorDataAppCodegenSummary(e).issues,...ae(e)]:["Plan artifact must be a Semaphor codegenSummary object."]}function ne(e){const t=q(e);if(t.length>0)throw new Error(`Invalid Semaphor codegenSummary:
1
+ "use strict";const V=require("./matrix-operation-contract-CbavkrJj.cjs"),S=require("../data-app-sdk-adapters/index.cjs");require("./validators-CueUwVE4.cjs");const re=V.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION,k=V.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION,G="semaphor-generated-data-app-contract/v1",M="semaphor-generated-data-app-contract-manifest/v1";function q(e){return E(e)?[...V.validateSemaphorDataAppCodegenSummary(e).issues,...ae(e)]:["Plan artifact must be a Semaphor codegenSummary object."]}function ne(e){const t=q(e);if(t.length>0)throw new Error(`Invalid Semaphor codegenSummary:
2
2
  - ${t.join(`
3
3
  - `)}`)}function ae(e){var r;const t=E(e);if(!t)return[];const n=[];return((r=E(t.validation))==null?void 0:r.status)==="blocked"&&n.push("validation.status blocked cannot be generated. Resolve blocked semantic model gaps and replan before generating contract files."),Array.isArray(t.unsupportedInsights)&&t.unsupportedInsights.forEach((i,o)=>{var a;((a=E(i))==null?void 0:a.reason)==="missing_relationship"&&n.push(`unsupportedInsights.${o}.reason missing_relationship blocks contract generation. Call semaphor_propose_semantic_model_change, apply an approved semantic model patch, and replan before generating contract files.`)}),Array.isArray(t.views)&&t.views.forEach((i,o)=>{var s;const a=E((s=E(i))==null?void 0:s.computation);(a==null?void 0:a.kind)==="unsupported"&&a.reason==="missing_relationship"&&n.push(`views.${o}.computation.reason missing_relationship blocks contract generation. Call semaphor_propose_semantic_model_change, apply an approved semantic model patch, and replan before generating contract files.`)}),n}function E(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}const J=["sources.ts","fields.ts","inputs.ts","queries.ts","bindings.ts","accessors.ts","metadata.ts","index.ts"],ie=["USAGE.md"],Y=[...J,...ie,"contract.manifest.json"];async function se({manifest:e,generatedFiles:t}){const n=[],r=y(e);if(!r)return{issues:[{message:"Generated contract manifest must be an object.",repairHint:"Regenerate the generated contract instead of hand-editing the manifest."}]};r.schemaVersion!==M&&n.push({path:"schemaVersion",message:`schemaVersion must be ${M}. Regenerate the contract with semaphor_create_data_app_contract.`,repairHint:"Regenerate the contract with semaphor_create_data_app_contract."}),r.generatedContractSchemaVersion!==G&&n.push({path:"generatedContractSchemaVersion",message:`generatedContractSchemaVersion must be ${G}. Regenerate the contract with semaphor_generate_data_app_contract.`,repairHint:"Regenerate the contract with semaphor_generate_data_app_contract."});const i=y(r.generator);A(i==null?void 0:i.name)||n.push({path:"generator.name",message:"generator.name is required.",repairHint:"Regenerate the generated contract so manifest generator metadata is written deterministically."}),A(i==null?void 0:i.version)||n.push({path:"generator.version",message:"generator.version is required.",repairHint:"Regenerate the generated contract so manifest generator metadata is written deterministically."});for(const a of q(r.codegenSummary))n.push({path:`codegenSummary.${a}`,message:`codegenSummary.${a}`,repairHint:"Regenerate the generated contract from a valid Data App codegenSummary."});if(r.codegenSummaryValidatorVersion!==k&&n.push({path:"codegenSummaryValidatorVersion",message:`codegenSummaryValidatorVersion must be ${k}. Regenerate the contract with semaphor_generate_data_app_contract.`,repairHint:"Regenerate the contract with semaphor_generate_data_app_contract."}),typeof r.codegenSummaryHash!="string")n.push({path:"codegenSummaryHash",message:"codegenSummaryHash is required.",repairHint:"Regenerate the generated contract so manifest hashes are written deterministically."});else if(y(r.codegenSummary)){const a=await fe(r.codegenSummary);r.codegenSummaryHash!==a&&n.push({path:"codegenSummaryHash",message:"codegenSummaryHash does not match codegenSummary. Regenerate the contract instead of editing the manifest.",repairHint:"Regenerate the generated contract instead of editing the manifest."})}n.push(...de(r.codegenSummary));const o=t?oe(t):[];if(n.push(...o),t&&o.length===0&&n.push(...ce(t)),typeof r.generatedContentHash!="string")n.push({path:"generatedContentHash",message:"generatedContentHash is required.",repairHint:"Regenerate the generated contract so manifest hashes are written deterministically."});else if(t&&o.length===0){const a=await ue(t);r.generatedContentHash!==a&&n.push({path:"generatedContentHash",message:"generatedContentHash does not match generated TypeScript files. Regenerate the contract instead of hand-editing generated files.",repairHint:"Regenerate the contract instead of hand-editing generated files."})}return{issues:n}}function oe(e){var r;const t=[],n=new Set(Y);for(const i of Object.keys(e)){if(i.includes("/")||i.includes("\\")){const o=((r=i.split("/").pop())==null?void 0:r.split("\\").pop())||i;t.push({path:`generatedFiles.${i}`,message:`generatedFiles keys must be generated filenames such as "${o}", not path-qualified keys such as "${i}".`,repairHint:'Pass generatedFiles keyed by filename, for example "queries.ts", not "src/semaphor/generated/queries.ts".'});continue}n.has(i)||t.push({path:`generatedFiles.${i}`,message:`generatedFiles contains unknown generated contract file "${i}".`,repairHint:"Pass only the generated files returned by semaphor_generate_data_app_contract, keyed by filename."})}return t}function ce(e){const t=e["USAGE.md"];return typeof t!="string"?[{path:"generatedFiles.USAGE.md",message:"generatedFiles.USAGE.md is required.",repairHint:"Regenerate the generated contract so the generated usage guide is written."}]:["queries","queryOptionsForView","rowsForView","metricValuesForView","kpiPropsForView","roleValuesForView","appInputSpecs","inputOptionQueries"].filter(r=>!t.includes(`\`${r}\``)).map(r=>({path:"generatedFiles.USAGE.md",message:`generatedFiles.USAGE.md must document ${r}.`,repairHint:"Regenerate the generated contract so the usage guide matches generated exports."}))}function de(e){const t=y(e);if(!t)return[];const n=[],r=new Set(F(t.inputs).map(o=>{var a;return(a=y(o))==null?void 0:a.id}).filter(A)),i=new Set(F(t.views).map(o=>{var a;return(a=y(o))==null?void 0:a.id}).filter(A));return F(t.filterContracts).forEach((o,a)=>{const s=y(o),c=s==null?void 0:s.inputId;(!A(c)||!r.has(c))&&n.push({path:`codegenSummary.filterContracts.${a}.inputId`,message:`codegenSummary.filterContracts.${a}.inputId must reference a generated input.`,repairHint:"Regenerate the generated contract from a valid planner output."}),Array.isArray(s==null?void 0:s.bindings)&&s.bindings.forEach((u,f)=>{const p=y(u),m=p==null?void 0:p.viewId;(!A(m)||!i.has(m))&&n.push({path:`codegenSummary.filterContracts.${a}.bindings.${f}.viewId`,message:`codegenSummary.filterContracts.${a}.bindings.${f}.viewId must reference a generated view.`,repairHint:"Regenerate the generated contract from a valid planner output."});const h=y(p==null?void 0:p.fieldRef);A(h==null?void 0:h.name)||n.push({path:`codegenSummary.filterContracts.${a}.bindings.${f}.fieldRef`,message:`codegenSummary.filterContracts.${a}.bindings.${f}.fieldRef is required.`,repairHint:"Regenerate the generated contract from a valid planner output."})})}),n}async function ue(e){const t=Object.keys(e).filter(r=>r.endsWith(".ts")).sort();let n="";for(const r of t)n+=`${r}\0${e[r]}\0`;return`sha256:${await W(n)}`}async function fe(e){return`sha256:${await W(x(e))}`}function x(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>x(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().filter(r=>t[r]!==void 0).map(r=>`${JSON.stringify(r)}:${x(t[r])}`).join(",")}}`}async function W(e){var r;if(!((r=globalThis.crypto)!=null&&r.subtle))throw new Error("SHA-256 digest support is required for generated contract validation.");const t=new TextEncoder().encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}function y(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function F(e){return Array.isArray(e)?e:[]}function A(e){return typeof e=="string"&&e.length>0}function pe(e){const t=d(e),n=N(t),r=[],i=[];return I(t==null?void 0:t.views).filter(o=>{var s;const a=d((s=d(o))==null?void 0:s.sdkSpec);return!!(a!=null&&a.builder&&(a!=null&&a.spec))}).forEach((o,a)=>{var u;const s=String(((u=d(o))==null?void 0:u.id)||`view_${a}`),c=Q(o,n);if(c){r.push({viewId:s,...c});return}i.push({viewId:s,path:`views.${s}.sdkSpec`,message:`Generated view execution validation could not build intent for "${s}".`})}),{requests:r,issues:i}}function Q(e,t){const n=d(e),r=d(n==null?void 0:n.sdkSpec),i=d(r==null?void 0:r.spec);if(!n||!(r!=null&&r.builder)||!i)return null;const o=me(t)?t:N(d(t)),a=be(r.builder),s=d(w(i,o))||{},c=ye({view:n,builder:a,rawSpec:i,spec:{...s,id:n.id,label:Ne(n,i)},context:o});try{if(a==="analysis"){const u=c;return{intent:S.toSemaphorAnalysisIntent(u),resultShape:"analysis",analysisOptions:S.toSemaphorAnalysisQueryOptions(u)}}if(a==="metric")return{intent:S.toSemaphorMetricIntent(c),resultShape:"metric"};if(a==="records")return{intent:S.toSemaphorRecordsIntent(c),resultShape:"records"};if(a==="matrix")return{intent:S.toSemaphorMatrixIntent(c),matrixWindowRequest:V.matrixWindowRequestSchema.parse(c.matrixWindowRequest),resultShape:"matrix"};if(a==="sql")return{intent:S.toSemaphorSqlIntent(c),resultShape:"sql"}}catch{return null}return null}function ge({input:e,filterContract:t,codegenSummary:n}){const r=d(e),i=d(t),o=d(r==null?void 0:r.optionQuery)||d(i==null?void 0:i.optionQuery);if(!r||!o)return null;const a=N(d(n)),s=d(o.spec),c=he(o,s,a),u=o.valueFieldRef||o.valueField||(s==null?void 0:s.valueField),f=o.labelFieldRef||o.labelField||(s==null?void 0:s.labelField);if(!c||!u||!f)return null;const m={...d(w(s||{},a))||{},id:o.id||(s==null?void 0:s.id)||`${r.id}-options`,inputId:r.id,source:c,valueField:u,labelField:f,population:o.population||(s==null?void 0:s.population),dependencies:o.dependencies||(s==null?void 0:s.dependencies),limit:o.limit||(s==null?void 0:s.limit)||100};try{return S.toSemaphorInputOptionsIntent(w(m,a))}catch{return null}}function le({input:e,filterContract:t,binding:n,option:r,codegenSummary:i}){const o=N(d(i)),a=d(e),s=d(t),c=d(n),u=w((c==null?void 0:c.fieldRef)||(s==null?void 0:s.fieldRef)||(a==null?void 0:a.fieldRef),o),f=String((s==null?void 0:s.operator)||(a==null?void 0:a.operator)||"in"),p=Fe(c);return{inputId:String((s==null?void 0:s.inputId)||(a==null?void 0:a.id)||""),kind:"filter",operator:f,value:He(f,r.value),isActive:!0,...u?{field:u}:{},...p?{relationshipHint:p}:{}}}function N(e){return{sourcesByKey:new Map(I(e==null?void 0:e.sources).map(d).filter(Me).filter(t=>typeof t.sourceKey=="string").map(t=>[String(t.sourceKey),Z(t)]))}}function me(e){var t;return e instanceof Object&&((t=d(e))==null?void 0:t.sourcesByKey)instanceof Map}function he(e,t,n){if(typeof e.sourceKey=="string")return n.sourcesByKey.get(e.sourceKey)||{sourceKey:e.sourceKey};if(e.source)return e.source;if(t!=null&&t.source)return t.source;if(typeof(t==null?void 0:t.sourceKey)=="string")return n.sourcesByKey.get(t.sourceKey)||{sourceKey:t.sourceKey}}function ye({view:e,builder:t,rawSpec:n,spec:r,context:i}){var s;if(t!=="records"&&t!=="sql")return r;const o=d((s=d(e.visualSpec))==null?void 0:s.tableBehavior);if(!o)return r;const a={...r};if(Oe(o)==="server"&&(a.pagination={page:1,pageSize:Se({tableBehavior:o,spec:r})}),t==="records"&&Ve(o)==="server"){const c=Ae({view:e,rawSpec:n,tableBehavior:o,context:i});c&&(a.orderBy=c)}return a}function Se({tableBehavior:e,spec:t}){const n=d(e.pagination),r=d(t.pagination);return H(n==null?void 0:n.pageSize)||H(r==null?void 0:r.pageSize)||H(t.limit)||100}function Ae({view:e,rawSpec:t,tableBehavior:n,context:r}){const i=d(n.sorting),o=g(i==null?void 0:i.defaultField);if(!o)return;const s=_e({view:e,rawSpec:t,context:r}).filter(c=>we(c.lookup).includes(o));if(s.length===1)return{field:s[0].field,direction:(i==null?void 0:i.defaultDirection)==="desc"?"desc":"asc"}}function _e({view:e,rawSpec:t,context:n}){var i;const r=[];for(const o of I(t.fields))$(r,o,n);$(r,t.dateField,n),$(r,(i=d(t.orderBy))==null?void 0:i.field,n);for(const o of I(e.fields))$(r,o,n);return Te(r,o=>Ee(o.lookup))}function $(e,t,n){const r=d(t);if(typeof(r==null?void 0:r.name)!="string"||r.name.length===0)return;const i=d(w(r,n))||r;e.push({lookup:r,field:i})}function we(e){return ke([g(e.name),X(e),Ie(e)])}function Ee(e){return[X(e),g(e.name),g(e.role),g(e.aggregate)].join("|")}function X(e){return[g(e.sourceKey)||Re(e.source),g(e.name),g(e.aggregate)].filter(Boolean).join(":")}function Re(e){const t=d(e);if(!t)return"";if(typeof t.kind=="string"&&typeof t.domainId=="string"){if(typeof t.datasetId=="string")return`${t.kind}:${t.domainId}:datasetId:${t.datasetId}`;if(typeof t.datasetName=="string")return`${t.kind}:${t.domainId}:datasetName:${t.datasetName}`}return JSON.stringify(t)}function Ie(e){return Ge([ve(e),g(e.aggregate).toLowerCase(),g(e.label)||g(e.name)].filter(Boolean))}function ve(e){return typeof e.sourceKey=="string"?Ce(e.sourceKey):$e(e.source)}function $e(e){const t=d(e);return t?g(t.datasetName)||g(t.datasetId)||g(t.name)||g(t.kind):""}function Ce(e){const t=String(e).split(":");return t[t.length-1]||String(e)}function Oe(e){var t;return g((t=d(e.pagination))==null?void 0:t.mode)}function Ve(e){var t;return g((t=d(e.sorting))==null?void 0:t.mode)}function w(e,t){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(i=>w(i,t));const n=e;if(typeof n.sourceKey=="string"&&typeof n.kind=="string"&&(typeof n.datasetName=="string"||typeof n.datasetId=="string"))return Z(n);const r={};for(const[i,o]of Object.entries(n))i!=="sourceKey"&&(r[i]=w(o,t));if(typeof n.sourceKey=="string"){const i=t.sourcesByKey.get(n.sourceKey);i&&!r.source&&(r.source=i)}return r}function Z(e){const{sourceKey:t,...n}=e;return n}function Ne(e,t){const n=d(e.visualSpec);return(n==null?void 0:n.title)||e.title||t.label}function be(e){const t=String(e||"").replace(/^semaphor\./,"");return["metric","records","analysis","matrix","sql"].includes(t)?t:""}function Fe(e){if(e!=null&&e.relationshipHint)return e.relationshipHint;const t=I(e==null?void 0:e.relationshipsUsed).map(n=>{var r;return(r=d(n))==null?void 0:r.id}).filter(n=>typeof n=="string"&&n.length>0);return t.length>0?{relationshipIds:t}:void 0}function He(e,t){return e==="in"||e==="not_in"?[t]:e==="between"?Array.isArray(t)?t:[t,t]:t}function H(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function g(e){return typeof e=="string"?e:""}function Te(e,t){const n=new Set,r=[];for(const i of e){const o=t(i);!o||n.has(o)||(n.add(o),r.push(i))}return r}function ke(e){return Array.from(new Set(e.filter(Boolean)))}function Ge(e){return(Array.isArray(e)?e.join(" "):e).replace(/[^a-zA-Z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).map((n,r)=>{const i=n.toLowerCase();return r===0?i:i.charAt(0).toUpperCase()+i.slice(1)}).join("")}function d(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function I(e){return Array.isArray(e)?e:[]}function Me(e){return e!==void 0}const xe=new Set(["diagnostic_fix","fix_diagnostics","fix_inspector_warnings","fix_runtime_warnings","fix_warnings"]),De=new Set(["add","edit","mixed","remove"]),j=new Set(["fields","metricBindingKeys","sdkSpec"]);function qe({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:r,constraints:i,preferences:o}){const a=l(r),s=typeof(a==null?void 0:a.kind)=="string"?a.kind.trim():"";return De.has(s)?{ok:!1,policy:{kind:s,mode:"invalid_operation_kind",reason:"Retired Data App operation aliases are not accepted. Use the hard-migrated analytics/layout/style operationIntent kinds."},violations:[{path:"operationIntent.kind",reason:"Use analytics_add, analytics_edit, analytics_remove, input_add, input_edit, layout_only, style_only, runtime_debug, semantic_model_repair, save_or_publish, or greenfield_create."}]}:B(o)?{ok:!1,policy:{kind:s,mode:"invalid_update_constraints",reason:"Metric aggregate override updates must use operationIntent.measureAggregateOverrides so deterministic update policy can guard the targeted edit."},violations:[{path:"preferences.measureAggregateOverrides",reason:"preferences is retired. Move measureAggregateOverrides to operationIntent.measureAggregateOverrides for update calls."}]}:B(i)?{ok:!1,policy:{kind:s,mode:"invalid_update_constraints",reason:"Metric aggregate override updates must use operationIntent.measureAggregateOverrides so deterministic update policy can guard the targeted edit."},violations:[{path:"constraints.measureAggregateOverrides",reason:"Move measureAggregateOverrides to operationIntent.measureAggregateOverrides for update calls."}]}:xe.has(s)?U({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:a,mode:"diagnostic_warning_fix",allowedViewChangeReasons:j,label:"Diagnostic warning fixes",reason:"Diagnostic warning fixes are preserve-by-default and may not add/remove views, inputs, or filter contracts."}):s==="analytics_edit"&&Array.isArray(a==null?void 0:a.measureAggregateOverrides)&&a.measureAggregateOverrides.length>0?U({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:a,mode:"metric_aggregate_override_edit",allowedViewChangeReasons:j,label:"Metric aggregate override edits",reason:"Metric aggregate override edits are preserve-by-default and may only adjust fields/sdkSpec on targeted views."}):{ok:!0,policy:{kind:s,mode:"general_iterative_update",reason:"General generated-contract edits are allowed to change the requested contract shape. Review the migration report for expected UI work."},violations:[]}}function B(e){var t;return Array.isArray((t=l(e))==null?void 0:t.measureAggregateOverrides)}function U({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:r,mode:i,allowedViewChangeReasons:o,label:a,reason:s}){const c=[],u=je(r==null?void 0:r.targetViewIds),f=l(n)||{};u.size===0&&c.push({path:"operationIntent.targetViewIds",reason:`${a} must declare targetViewIds so the update cannot broaden to unrelated views.`}),T({bucket:l(f.views),label:"views",operationLabel:a,violations:c}),T({bucket:l(f.inputs),label:"inputs",operationLabel:a,violations:c}),L({bucket:l(f.inputs),label:"inputs",operationLabel:a,violations:c}),T({bucket:l(f.filterContracts),label:"filterContracts",operationLabel:a,violations:c}),L({bucket:l(f.filterContracts),label:"filterContracts",operationLabel:a,violations:c});for(const m of ee(l(f.views))){u.size>0&&!u.has(_(m.id))&&c.push({path:`views.${_(m.id)||"<unknown>"}`,reason:`${a} may only change explicitly targeted views.`});const h=Array.isArray(m.reasons)?m.reasons.filter(R=>typeof R!="string"||!o.has(R)):[];h.length>0&&c.push({path:`views.${_(m.id)||"<unknown>"}`,reason:`${a} may only adjust fields/sdkSpec/metricBindingKeys; changed ${h.join(", ")}.`})}const p=Ke({beforeSummary:e,afterSummary:t,targetViewIds:u,label:a});return p&&c.push(p),{ok:c.length===0,policy:{kind:_(r==null?void 0:r.kind)||"diagnostic_fix",mode:i,allowedViewChangeReasons:Array.from(o).sort(),targetViewIds:Array.from(u).sort(),reason:s},violations:c}}function Ke({beforeSummary:e,afterSummary:t,targetViewIds:n,label:r}){const i=l(e),o=l(t);if(!i||!o)return{path:"codegenSummary",reason:`${r} require before/after codegen summaries for full-scope verification.`};const a=P(i),s=P(o),c=z(i.views),u=z(o.views),f=Array.isArray(a.views)?a.views:[];a.views=f;for(const p of n){const m=c.get(p),h=u.get(p);if(!m||!h)continue;const R=f.find(te=>{var K;return((K=l(te))==null?void 0:K.id)===p}),v=l(h);if(!R||!v)continue;const b=R;b.fields=C(v.fields),b.metricBindingKeys=C(v.metricBindingKeys),b.sdkSpec=C(v.sdkSpec)}return O(a)===O(s)?null:{path:"codegenSummary",reason:`${r} may only change fields/sdkSpec/metricBindingKeys on targetViewIds; another generated contract section changed.`}}function P(e){const t=C(e);for(const n of["implementationChecklist","assumptions","nextStep","nextRequiredTool","validation"])delete t[n];return Ue(t.unsupportedInsights)&&delete t.unsupportedInsights,t}function T({bucket:e,label:t,operationLabel:n,violations:r}){for(const i of D(e==null?void 0:e.added))r.push({path:`${t}.${_(i.id)||"<unknown>"}`,reason:`${n} may not add ${t}.`});for(const i of D(e==null?void 0:e.removed))r.push({path:`${t}.${_(i.id)||"<unknown>"}`,reason:`${n} may not remove ${t}.`})}function L({bucket:e,label:t,operationLabel:n,violations:r}){for(const i of ee(e))r.push({path:`${t}.${_(i.id)||"<unknown>"}`,reason:`${n} may not change ${t}.`})}function ee(e){return D(e==null?void 0:e.changed)}function D(e){return Array.isArray(e)?e.map(l).filter(Be):[]}function je(e){return Array.isArray(e)?new Set(e.filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim())):new Set}function z(e){var n;const t=new Map;for(const r of Array.isArray(e)?e:[]){const i=(n=l(r))==null?void 0:n.id;typeof i=="string"&&i.trim()&&t.set(i,r)}return t}function C(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function O(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(n=>O(n)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().filter(n=>t[n]!==void 0).map(n=>`${JSON.stringify(n)}:${O(t[n])}`).join(",")}}`}function l(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Be(e){return e!==void 0}function Ue(e){return Array.isArray(e)&&e.length===0}function _(e){return typeof e=="string"?e:""}exports.CODEGEN_SUMMARY_SCHEMA_VERSION=re;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=k;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=M;exports.GENERATED_CONTRACT_SCHEMA_VERSION=G;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=J;exports.REQUIRED_GENERATED_CONTRACT_FILES=Y;exports.assertValidCodegenSummary=ne;exports.buildSemaphorGeneratedActiveInput=le;exports.buildSemaphorGeneratedInputOptionIntent=ge;exports.buildSemaphorGeneratedViewExecutionRequest=Q;exports.buildSemaphorGeneratedViewExecutionRequests=pe;exports.evaluateSemaphorDataAppContractUpdatePolicy=qe;exports.validateCodegenSummary=q;exports.validateSemaphorGeneratedContract=se;
@@ -0,0 +1 @@
1
+ "use strict";const i=require("zod"),L=["second","minute","hour","day","week","month","quarter","year"];function mi(e){return typeof e=="string"&&L.includes(e)}const mt=["week_of_short","week_of_long","quarter_short","quarter_long","fiscal_quarter_short","fiscal_year"],pi={invalidMetadata:"invalid_raw_temporal_metadata"};function pt(e){return e==="second"||e==="minute"||e==="hour"?"datetime":"date"}const fi={missingMetadata:"missing_temporal_bucket_metadata",invalidMetadata:"invalid_temporal_bucket_metadata",invalidValue:"invalid_temporal_bucket_value"},gi="__auto_count__";function ft(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}const gt=i.z.record(i.z.string(),i.z.unknown()),D=i.z.array(gt),x=i.z.enum(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]),ie=i.z.enum(["postgres","mysql","mssql","snowflake","clickhouse","bigquery","redshift","duckdb","sqlite","unknown"]),P=i.z.enum(L),ae=i.z.enum(["dimension","measure","date","id","unknown"]),ne=i.z.enum(["string","number","boolean","date","datetime","unknown"]),G=i.z.union([i.z.number(),i.z.string(),i.z.null()]),ge=i.z.enum(["millisecond","second","minute","hour","day"]),hi=i.z.enum(mt),_i=i.z.discriminatedUnion("mode",[i.z.object({mode:i.z.literal("auto")}).strict(),i.z.object({mode:i.z.literal("preset"),preset:hi}).strict(),i.z.object({mode:i.z.literal("pattern"),pattern:i.z.string().min(1)}).strict()]),q=i.z.object({type:i.z.literal("temporal_bucket"),presentation:_i}).strict(),yi=i.z.object({tz:i.z.string().min(1).refine(ft,{message:"tz must be a valid IANA timezone"}),weekStart:i.z.number().int().min(0).max(6),fiscalCalendar:i.z.object({kind:i.z.literal("month_aligned"),yearStartMonth:i.z.number().int().min(1).max(12)}).strict().optional()}).strict(),K=i.z.object({kind:i.z.literal("temporal_bucket"),granularity:P,calendar:yi}).strict(),ht=i.z.object({kind:i.z.literal("raw_temporal"),valueKind:i.z.enum(["date","wall_datetime","instant"])}).strict(),oe=i.z.union([i.z.object({type:i.z.enum(["number","currency","percent","percentage","scientific"]),locale:i.z.string().optional(),minimumFractionDigits:i.z.number().optional(),maximumFractionDigits:i.z.number().optional(),useGrouping:i.z.boolean().optional(),prefix:i.z.string().optional(),suffix:i.z.string().optional(),negativeStyle:i.z.enum(["minus","parentheses"]).optional(),compact:i.z.boolean().optional(),scale:i.z.number().optional(),currency:i.z.string().optional(),percentValueMode:i.z.enum(["fraction","whole"]).optional()}).passthrough().superRefine((e,t)=>{"locale"in e&&t.addIssue({code:i.z.ZodIssueCode.custom,path:["locale"],message:"Numeric semantic formats inherit locale from viewer preferences."})}),i.z.object({type:i.z.enum(["date","datetime"]),locale:i.z.string().optional(),pattern:i.z.string().optional(),relative:i.z.boolean().optional(),timezone:i.z.string().optional(),sourceTimezone:i.z.string().optional(),prefix:i.z.string().optional(),suffix:i.z.string().optional()}).passthrough(),i.z.object({type:i.z.literal("duration"),inputUnit:ge.optional(),outputStyle:i.z.enum(["compact","digital","long"]).optional(),largestUnit:ge.optional(),smallestUnit:ge.optional(),maxUnits:i.z.number().optional(),prefix:i.z.string().optional(),suffix:i.z.string().optional(),negativeStyle:i.z.enum(["minus","parentheses"]).optional()}).passthrough(),i.z.object({type:i.z.literal("string"),prefix:i.z.string().optional(),suffix:i.z.string().optional()}).passthrough()]);function bi(e,t){return i.z.object(e).passthrough().superRefine((a,o)=>{for(const n of t)Object.prototype.hasOwnProperty.call(a,n)||o.addIssue({code:"custom",path:[n],message:`Required field "${n}" is missing.`})})}const re=i.z.object({kind:i.z.literal("semantic"),domainId:i.z.string(),datasetName:i.z.string(),datasetId:i.z.string().optional(),label:i.z.string().optional(),connectionId:i.z.string().optional()}).passthrough(),Ae=i.z.object({kind:i.z.literal("physical"),connectionId:i.z.string(),connectionType:i.z.string().optional(),tableName:i.z.string(),databaseName:i.z.string().optional(),schemaName:i.z.string().optional(),label:i.z.string().optional(),dialect:ie.optional()}).passthrough(),_t=i.z.object({kind:i.z.literal("sql"),connectionId:i.z.string(),dialect:ie.optional(),label:i.z.string().optional()}).passthrough(),xe=i.z.union([re,Ae,_t]),Re=i.z.object({name:i.z.string(),label:i.z.string().optional(),role:ae.optional(),dataType:ne.optional(),source:xe.optional(),aggregate:x.optional()}).passthrough(),Fe=Re,vi=i.z.object({kind:i.z.literal("field"),field:Fe,aggregate:x.optional()}).passthrough(),Te=i.z.object({kind:i.z.literal("derived_field"),name:i.z.string(),label:i.z.string(),description:i.z.string().optional(),resultRole:ae,dataType:ne,computeStage:i.z.enum(["row","aggregate"]),expression:i.z.string(),expressionLanguage:i.z.literal("semaphor_sql_template").optional(),inputs:i.z.record(vi),defaultAggregate:x.optional(),aggregationBehavior:i.z.enum(["additive","non_additive","ratio_of_sums","weighted","pre_aggregated","snapshot"]).optional(),aggregationStrategy:i.z.enum(["default","symmetric_aggregate","aggregate_then_join","weighted"]).optional(),format:oe.optional(),tags:i.z.array(i.z.string()).optional()}).passthrough(),Me=Te,zi=Fe.and(i.z.object({derivedField:Me.optional()}).passthrough()),Si=re,Ii=i.z.object({kind:i.z.literal("physical"),connectionId:i.z.string().optional(),connectionType:i.z.string().optional(),tableName:i.z.string(),databaseName:i.z.string().optional(),schemaName:i.z.string().optional(),label:i.z.string().optional(),dialect:ie.optional()}).passthrough(),ki=i.z.object({kind:i.z.literal("sql"),connectionId:i.z.string().optional(),dialect:ie.optional(),label:i.z.string().optional()}).passthrough(),wi=i.z.union([Si,Ii,ki]),Ai=i.z.object({key:i.z.string().optional(),name:i.z.string(),label:i.z.string().optional(),role:ae.optional(),dataType:ne.optional(),source:wi.optional(),aggregate:x.optional(),derivedField:i.z.never().optional()}).passthrough(),T=i.z.object({key:i.z.string(),name:i.z.string(),label:i.z.string(),role:ae.optional(),dataType:ne.optional(),aggregate:x.optional(),source:xe.optional(),derivedField:Me.optional(),temporalBucket:K.optional(),rawTemporal:ht.optional(),pivotIdentity:i.z.object({metricId:i.z.string().min(1),metricAlias:i.z.string().min(1),members:i.z.array(i.z.object({fieldId:i.z.string().min(1),value:i.z.string().nullable(),temporalBucket:K.optional()}).strict())}).strict().optional()}).passthrough().superRefine((e,t)=>{if(e.temporalBucket&&e.rawTemporal&&t.addIssue({code:i.z.ZodIssueCode.custom,path:["rawTemporal"],message:"A result column cannot carry both temporalBucket and rawTemporal metadata."}),e.temporalBucket){const a=pt(e.temporalBucket.granularity);e.dataType!==a&&t.addIssue({code:i.z.ZodIssueCode.custom,path:["dataType"],message:`${e.temporalBucket.granularity} temporal buckets require dataType ${a}.`})}if(e.rawTemporal){const a=e.rawTemporal.valueKind==="date"?"date":"datetime";e.dataType!==a&&t.addIssue({code:i.z.ZodIssueCode.custom,path:["dataType"],message:`${e.rawTemporal.valueKind} raw temporal values require dataType ${a}.`})}}),xi=i.z.object({records:D,columns:i.z.array(T).optional()}).passthrough(),Ri=i.z.object({records:D,columns:i.z.array(T)}).passthrough(),yt=i.z.object({code:i.z.string(),message:i.z.string().optional(),invalidField:i.z.string().optional(),fieldRole:i.z.enum(["measure","date","dimension","input","source","sql"]).optional(),validMeasureCandidates:i.z.array(i.z.string()).optional(),validDateCandidates:i.z.array(i.z.string()).optional(),validDimensionCandidates:i.z.array(i.z.string()).optional(),recommendedNextStep:i.z.string()}).passthrough(),be=i.z.object({code:i.z.string(),message:i.z.string(),path:i.z.string().optional(),fieldRole:i.z.enum(["measure","date","dimension","input","source","sql"]).optional(),repairHint:yt.optional()}).passthrough(),Fi=i.z.object({ok:i.z.boolean(),errors:i.z.array(be),warnings:i.z.array(be),repairHints:i.z.array(yt)}).passthrough(),Ti=i.z.object({page:i.z.number(),pageSize:i.z.number(),pageCount:i.z.number(),totalCount:i.z.number(),hasNextPage:i.z.boolean(),hasPrevPage:i.z.boolean()}).passthrough(),se={intentId:i.z.string().optional(),queryPath:i.z.enum(["query_spec","sql","sql_python"]),warnings:i.z.array(i.z.string()).optional(),rowCount:i.z.number().optional(),rowLimitExceeded:i.z.boolean().optional(),limit:i.z.number().optional(),pagination:Ti.optional()},Mi=i.z.object({...se,kind:i.z.literal("metric"),primaryValue:G,measures:i.z.record(G).optional(),missingMeasures:i.z.array(i.z.string()).optional(),comparison:i.z.object({kind:i.z.enum(["previous_period","previous_year","target"]),value:G.optional(),delta:i.z.union([i.z.number(),i.z.null()]).optional(),deltaPercent:i.z.union([i.z.number(),i.z.null()]).optional()}).passthrough().optional(),records:D.optional()}).passthrough(),Di=i.z.object({...se,kind:i.z.literal("records"),columns:i.z.array(T),records:D,totals:i.z.object({mode:i.z.literal("server"),scope:i.z.literal("filtered_result"),row:i.z.record(i.z.string(),i.z.unknown()),columns:i.z.array(T).optional()}).passthrough().optional()}).passthrough(),Ei=i.z.object({...se,kind:i.z.literal("inputOptions"),options:i.z.array(bi({label:i.z.string(),value:i.z.unknown(),count:i.z.number().optional(),disambiguation:i.z.array(i.z.string()).optional()},["value"]))}).passthrough(),Ni=i.z.object({...se,kind:i.z.literal("sql"),columns:i.z.array(T),records:D,sqlShape:i.z.object({statementType:i.z.string().optional(),explicitLimit:i.z.number().optional(),hasPythonCode:i.z.boolean().optional()}).passthrough().optional()}).passthrough();function s(e,t,a){return a?{code:e,message:t,path:a}:{code:e,message:t}}function m(e){return typeof e=="string"&&e.trim().length>0}function ji(e){const t=new Set;return bt(e,a=>(t.add(a),`{${a}}`)),Array.from(t)}function bt(e,t){let a="",o=0,n=0;for(;n<e.length;){const r=e[n];if(r==="'"||r==='"'){n=Ci(e,n);continue}if(r==="{"){const l=e.indexOf("}",n+1);if(l===-1){n+=1;continue}const c=e.slice(n+1,l);/^[A-Za-z_][A-Za-z0-9_]*$/.test(c)&&(a+=e.slice(o,n)+t(c),o=l+1),n=l+1;continue}n+=1}return a+e.slice(o)}function Ci(e,t){const a=e[t];let o=t+1;for(;o<e.length;){if(e[o]===a){if(e[o+1]===a){o+=2;continue}return o+1}o+=1}return e.length}function f(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}const $i=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]);function De(e,t,a){if(!e||typeof e!="object"){a.push(s("missing_source","Analytics intent needs a source.",t));return}if(e.kind==="semantic"){m(e.domainId)||a.push(s("missing_semantic_domain","Semantic source needs a domainId.",`${t}.domainId`)),m(e.datasetName)||a.push(s("missing_dataset_name","Semantic source needs a datasetName.",`${t}.datasetName`));return}if(e.kind==="physical"){m(e.connectionId)||a.push(s("missing_connection_id","Physical source needs a connectionId.",`${t}.connectionId`)),m(e.tableName)||a.push(s("missing_table_name","Physical source needs a tableName.",`${t}.tableName`));return}if(e.kind==="sql"){m(e.connectionId)||a.push(s("missing_connection_id","SQL source needs a connectionId.",`${t}.connectionId`));return}a.push(s("invalid_source_kind","Source kind is not supported.",t))}function y(e,t,a,o={}){if(!e||!f(e)){o.required&&a.push(s("missing_field_ref","Field reference needs a name.",t));return}m(e.name)||a.push(s("missing_field_ref","Field reference needs a name.",`${t}.name`)),e.source!==void 0&&De(e.source,`${t}.source`,a),Ee(e.aggregate,`${t}.aggregate`,a)}function Ee(e,t,a){e!==void 0&&(typeof e!="string"||!$i.has(e))&&a.push(s("invalid_aggregate","Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",t))}const Oi=new Set(["measure","dimension","date","id","unknown"]),Pi=new Set(["row","aggregate"]),vt=new Set(["string","number","boolean","date","datetime","unknown"]),Yi=new Set(["number","currency","percent","percentage","scientific","date","datetime","duration","string","temporal_bucket"]),Bi=new Set(["millisecond","second","minute","hour","day"]),Li=new Set(["compact","digital","long"]);function zt(e,t,a){if(e===void 0)return;if(!f(e)){a.push(s("invalid_value_format","Value format must be a structured object.",t));return}const o=e;(typeof o.type!="string"||!Yi.has(o.type))&&a.push(s("invalid_value_format_type","Value format type must be number, currency, percent, percentage, scientific, date, datetime, duration, string, or temporal_bucket.",`${t}.type`)),o.type==="temporal_bucket"&&!q.safeParse(e).success&&a.push(s("invalid_temporal_bucket_format","Temporal bucket format must contain a valid auto, preset, or pattern presentation.",t)),(o.type==="number"||o.type==="currency"||o.type==="percent"||o.type==="percentage"||o.type==="scientific")&&Object.prototype.hasOwnProperty.call(e,"locale")&&a.push(s("invalid_value_format","Numeric value formats cannot define viewer locale.",`${t}.locale`)),V(e.minimumFractionDigits,`${t}.minimumFractionDigits`,a),V(e.maximumFractionDigits,`${t}.maximumFractionDigits`,a),V(e.scale,`${t}.scale`,a),V(e.maxUnits,`${t}.maxUnits`,a),e.useGrouping!==void 0&&typeof e.useGrouping!="boolean"&&a.push(s("invalid_value_format_use_grouping","Value format useGrouping must be boolean.",`${t}.useGrouping`)),e.negativeStyle!==void 0&&e.negativeStyle!=="minus"&&e.negativeStyle!=="parentheses"&&a.push(s("invalid_value_format_negative_style","Value format negativeStyle must be minus or parentheses.",`${t}.negativeStyle`)),e.percentValueMode!==void 0&&e.percentValueMode!=="fraction"&&e.percentValueMode!=="whole"&&a.push(s("invalid_value_format_percent_mode","Value format percentValueMode must be fraction or whole.",`${t}.percentValueMode`));for(const n of["inputUnit","largestUnit","smallestUnit"]){const r=e[n];r!==void 0&&(typeof r!="string"||!Bi.has(r))&&a.push(s("invalid_value_format_duration_unit","Duration format units must be millisecond, second, minute, hour, or day.",`${t}.${n}`))}e.outputStyle!==void 0&&(typeof e.outputStyle!="string"||!Li.has(e.outputStyle))&&a.push(s("invalid_value_format_duration_style","Duration format outputStyle must be compact, digital, or long.",`${t}.outputStyle`))}function V(e,t,a){e!==void 0&&(typeof e!="number"||!Number.isFinite(e))&&a.push(s("invalid_value_format_number","Value format numeric options must be finite numbers.",t))}const qi=new Set(["additive","non_additive","ratio_of_sums","weighted","pre_aggregated","snapshot"]),Ui=new Set(["default","symmetric_aggregate","aggregate_then_join","weighted"]);function Vi(e,t,a){if(!e||!f(e)){a.push(s("invalid_derived_field_input","Derived field inputs must be structured input references.",t));return}if(e.kind==="field"){y(e.field,`${t}.field`,a,{required:!0}),Ee(e.aggregate,`${t}.aggregate`,a);return}a.push(s("invalid_derived_field_input","Derived field input kind must be field.",`${t}.kind`))}function Ne(e){const t=[];if(!f(e))return t.push(s("invalid_derived_field","Derived field definition must be a structured object.")),{ok:!1,errors:t,warnings:[]};if(e.kind!=="derived_field"&&t.push(s("invalid_derived_field_kind","Derived field kind must be derived_field.","kind")),m(e.name)||t.push(s("invalid_derived_field_name","Derived field needs a name.","name")),m(e.label)||t.push(s("invalid_derived_field_label","Derived field needs a label.","label")),Oi.has(e.resultRole)||t.push(s("invalid_derived_field_role","Derived field resultRole must be measure, dimension, date, id, or unknown.","resultRole")),vt.has(e.dataType)||t.push(s("invalid_derived_field_data_type","Derived field dataType must be string, number, boolean, date, datetime, or unknown.","dataType")),Pi.has(e.computeStage)||t.push(s("invalid_derived_field_compute_stage","Derived field computeStage must be row or aggregate.","computeStage")),e.computeStage==="aggregate"&&e.resultRole!=="measure"&&t.push(s("invalid_derived_field_compute_stage","Aggregate-stage derived fields must have resultRole measure.","computeStage")),e.resultRole!=="measure"&&e.defaultAggregate!==void 0&&t.push(s("invalid_derived_field_aggregate","Only measure derived fields may declare defaultAggregate.","defaultAggregate")),e.computeStage==="row"&&e.resultRole==="measure"&&e.defaultAggregate===void 0&&t.push(s("missing_derived_field_default_aggregate","Row-stage measure derived fields must declare defaultAggregate so row results have explicit rollup semantics.","defaultAggregate")),Ee(e.defaultAggregate,"defaultAggregate",t),e.aggregationBehavior!==void 0&&!qi.has(e.aggregationBehavior)&&t.push(s("invalid_derived_field_aggregation_behavior","Derived field aggregationBehavior is not supported.","aggregationBehavior")),e.aggregationStrategy!==void 0&&!Ui.has(e.aggregationStrategy)&&t.push(s("invalid_derived_field_aggregation_strategy","Derived field aggregationStrategy is not supported.","aggregationStrategy")),m(e.expression)||t.push(s("invalid_derived_field_expression","Derived field needs a named-token expression.","expression")),e.expressionLanguage!==void 0&&e.expressionLanguage!=="semaphor_sql_template"&&t.push(s("invalid_derived_field_expression_language","Derived field expressionLanguage must be semaphor_sql_template.","expressionLanguage")),!f(e.inputs)||Object.keys(e.inputs).length===0?t.push(s("invalid_derived_field_inputs","Derived field needs at least one typed input.","inputs")):Object.entries(e.inputs).forEach(([o,n])=>{if(!m(o)){t.push(s("invalid_derived_field_input_name","Derived field input names must be non-empty strings.","inputs"));return}Vi(n,`inputs.${o}`,t)}),m(e.expression)&&f(e.inputs)){const o=ji(e.expression),n=new Set(o),r=Object.keys(e.inputs).filter(l=>m(l));o.forEach(l=>{Object.prototype.hasOwnProperty.call(e.inputs,l)||t.push(s("invalid_derived_field_expression_token",`Derived field expression token "{${l}}" needs a matching inputs.${l} entry.`,"expression"))}),r.forEach(l=>{n.has(l)||t.push(s("unused_derived_field_input",`Derived field input "${l}" is not referenced by expression.`,`inputs.${l}`))})}const a=e.format;return f(a)&&a.type==="temporal_bucket"?t.push(s("invalid_derived_field_format","Derived field computation metadata cannot own temporal bucket presentation; declare grain and format on the grouped field.","format")):zt(a,"format",t),e.tags!==void 0&&(!Array.isArray(e.tags)||e.tags.some(o=>!m(o)))&&t.push(s("invalid_derived_field_tags","Derived field tags must be non-empty strings.","tags")),{ok:t.length===0,errors:t,warnings:[]}}const N=i.z.string().min(1).refine(e=>e.trim().length>0,"Must not be blank."),[Hi,Gi,Ki,Qi]=oe.options,St=i.z.union([Hi.innerType().omit({locale:!0}).strict().superRefine((e,t)=>{const{minimumFractionDigits:a=0,maximumFractionDigits:o=2}=e;(![a,o].every(n=>Number.isInteger(n)&&n>=0&&n<=20)||a>o)&&t.addIssue({code:"custom",message:"Fraction digits must be integers from 0 to 20 with minimum <= maximum."}),e.scale!==void 0&&!Number.isFinite(e.scale)&&t.addIssue({code:"custom",message:"Scale must be finite."})}),Gi.strict(),Ki.strict(),Qi.strict()]),ve=i.z.union([St,q]),le=i.z.union([re.extend({domainId:N,datasetName:N}).strict(),Ae.extend({connectionId:N,tableName:N}).strict()]),It=Re.extend({name:N,source:le.optional()}).strict(),de=Te.extend({format:St.optional(),inputs:i.z.record(i.z.object({kind:i.z.literal("field"),field:It,aggregate:x.optional()}).strict())}).strict().superRefine((e,t)=>{var a;for(const o of Ne(e).errors)t.addIssue({code:"custom",path:((a=o.path)==null?void 0:a.split("."))??[],message:o.message})}),Wi=It.extend({derivedField:de.optional()}).strict();function ce(e){return typeof e=="string"?e.trim().toLowerCase():""}function kt(e){return String(e.column_name||e.name||e.qualifiedFieldName||"")}function wt(e){return Array.from(new Set([e.column_name,e.name,e.qualifiedFieldName,e.alias].filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim())))}function je(e){const t=Rt(e);return t?Ji(t)?"number":t.includes("timestamp")||t.includes("datetime")||t.startsWith("time")?"datetime":t.includes("date")?"date":t.includes("bool")?"boolean":"string":"unknown"}const he=new Map([["int","integer"],["uint","integer"],["integer","integer"],["uinteger","integer"],["bigint","integer"],["ubigint","integer"],["smallint","integer"],["usmallint","integer"],["tinyint","integer"],["utinyint","integer"],["mediumint","integer"],["hugeint","integer"],["uhugeint","integer"],["numeric","decimal"],["decimal","decimal"],["float","float"],["double","float"],["real","float"],["bfloat16","float"],["number",null],["money",null],["currency",null],["percent",null]]),Zi=["int","uint","decimal","float"];function Xi(e){return e.length>0&&Array.from(e).every(t=>t>="0"&&t<="9")}function At(e){const t=e.split(/[\s(]/,1)[0]||"";if(he.has(t))return{numeric:!0,kind:he.get(t)??null};const a=Zi.find(o=>t.startsWith(o)&&Xi(t.slice(o.length)));return a?{numeric:!0,kind:he.get(a)??null}:{numeric:!1,kind:null}}function Ji(e){return At(e).numeric}function xt(e){return At(Rt(e)).kind}function Rt(e){let t=ce(e),a="";for(;t&&t!==a;)a=t,t=et(t,"nullable"),t=et(t,"lowcardinality");return t}function et(e,t){const a=`${t}(`;return!e.startsWith(a)||!e.endsWith(")")?e:e.slice(a.length,-1).trim()}function Ft(e){const t=je(e);return t==="date"||t==="datetime"}function Ce(e){return Ft(e.dataType||e.data_type)}function $e(e){const t=Tt(e);return t==="id"||t==="row_id"}function ze(e){const t=Tt(e);return $e(e)||t.endsWith("_id")||t.endsWith("_key")||t.endsWith("_number")}function Tt(e){return ce(kt(e)||e.name||e.alias).replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function Oe(e,t={}){const a=ce(e.role);return a==="metric"||a==="measure"?!t.excludeIdentifiers||!ze(e):a==="groupby"||a==="dimension"||a==="date"||a==="id"?!1:je(e.dataType||e.data_type)==="number"&&(!t.excludeIdentifiers||!ze(e))}function ea(e){return!Oe(e)&&!Ce(e)}function ta(e){const t=new Set,a=new Set,o=new Set;for(const n of e){if($e(n))continue;const r=wt(n);if(r.length!==0){if(Ce(n)){r.forEach(l=>a.add(l));continue}if(Oe(n,{excludeIdentifiers:!0})){r.forEach(l=>t.add(l));continue}r.forEach(l=>o.add(l))}}return{validMeasureCandidates:Array.from(t).sort(),validDateCandidates:Array.from(a).sort(),validDimensionCandidates:Array.from(o).sort()}}const j=16*1024;function Q(e){const t=/^([+-]?)(?:(\d+)(?:\.(\d*))?|\.(\d+))(?:[eE]([+-]?\d+))?$/.exec(e);return t?{sign:t[1],whole:t[2]??"",fraction:t[3]??t[4],exponent:Number(t[5]??"0")}:null}function tt(e){const{sign:t,whole:a,fraction:o="",exponent:n}=e,r=(a+o).replace(/^0+/,""),l=r.replace(/0+$/,""),c=n-o.length+r.length-l.length;return!Number.isSafeInteger(n)||!Number.isSafeInteger(c)?null:l?`${t==="-"?"-":""}${l}e${c}`:"0"}function Mt(e){const t=Q(e);if(!t)return null;const a=t.sign==="+"?e.slice(1):e,o=Number(e);if(!Number.isFinite(o))return a;const n=tt(t),r=Q(String(o));return n!==null&&r!==null&&n===tt(r)?o:a}function ia(e){if(e.length>j)throw new RangeError("Exact numeric text exceeds 16 KiB.");const t=Q(e);if(!t)throw new TypeError("Expected finite decimal text.");const{sign:a,whole:o,fraction:n,exponent:r}=t,l=`${a}${o||"0"}${n?`.${n}`:""}`;return k(`${l}e${r}`)}function k(e){if(e.length>j)throw new RangeError("Exact numeric text exceeds 16 KiB.");const t=Q(e);if(!t||t.whole===""||t.fraction==="")throw new TypeError("Expected finite decimal text.");const{sign:a,whole:o,fraction:n="",exponent:r}=t;if(!Number.isSafeInteger(r)||Math.abs(r)>j)throw new RangeError("Exact numeric exponent exceeds the text budget.");const l=o+n,c=o.length+r;if(Math.max(l.length,c)+Math.max(0,-c)+3>j)throw new RangeError("Normalized exact numeric text exceeds 16 KiB.");let d;c<=0?d=`0.${"0".repeat(-c)}${l}`:c>=l.length?d=l+"0".repeat(c-l.length):d=`${l.slice(0,c)}.${l.slice(c)}`;const[p,h=""]=d.split("."),v=p.replace(/^0+(?=\d)/,""),F=h.replace(/0+$/,""),_=v+(F?`.${F}`:"");return a==="-"&&_!=="0"?`-${_}`:_}function Pe(e,t){const a=e.startsWith("-"),o=t.startsWith("-");if(a!==o)return a?-1:1;const[n,r=""]=(a?e.slice(1):e).split("."),[l,c=""]=(o?t.slice(1):t).split(".");let u=Math.sign(n.length-l.length);if(!u&&n!==l&&(u=n<l?-1:1),!u){const d=Math.max(r.length,c.length),p=r.padEnd(d,"0"),h=c.padEnd(d,"0");u=p===h?0:p<h?-1:1}return u===0?0:a?-u:u}function aa(e,t){if(typeof t=="number"&&!Number.isFinite(t))throw new TypeError("Numeric scale must be finite.");const a=[e,k(String(t))].map(r=>{const[l,c=""]=r.split(".");return{coefficient:BigInt(l+c),digits:c.length}}),o=a[0].coefficient*a[1].coefficient,n=a[0].digits+a[1].digits;return k(`${o}e-${n}`)}function na(e){try{return k(e)===e}catch{return!1}}const Ye=i.z.object({kind:i.z.literal("exact_number"),type:i.z.enum(["integer","decimal"]),value:i.z.string().max(j).refine(na,"Expected canonical decimal text.")}).strict().superRefine((e,t)=>{e.type==="integer"&&e.value.includes(".")&&t.addIssue({code:"custom",path:["value"],message:"An integer cannot have fractional digits."})}),C=i.z.union([i.z.null(),i.z.string(),i.z.boolean(),i.z.number().finite(),Ye]);function Dt(e,t){return Ye.parse({kind:"exact_number",type:t,value:k(e)})}function Y(e){return typeof e=="object"&&e!==null&&"kind"in e&&e.kind==="exact_number"&&"type"in e&&(e.type==="integer"||e.type==="decimal")&&"value"in e&&typeof e.value=="string"}function oa(e){const t=xt(e.nativeDataType);if(!t)throw new TypeError("Numeric result type is not established.");if(e.value===null)return null;if(t==="float"){if(typeof e.value!="number"||!Number.isFinite(e.value))throw new TypeError("Expected a finite floating-point result.");return e.value}if(e.exactText===void 0)throw new TypeError("Exact numeric sidecar is required; rounded result values cannot substitute.");return Dt(e.exactText,t)}const Be=i.z.string().uuid(),ue=i.z.enum(["rows","columns"]),Et=i.z.enum(["member","subtotal","grand_total","others"]),Nt=i.z.discriminatedUnion("kind",[i.z.object({kind:i.z.literal("value"),value:C}).strict(),i.z.object({kind:i.z.literal("others"),rankingId:Be}).strict()]),A=i.z.array(i.z.object({levelId:Be,member:Nt}).strict()).readonly().superRefine((e,t)=>{new Set(e.map(a=>a.levelId)).size!==e.length&&t.addIssue({code:"custom",path:[],message:"Duplicate identity."}),e.some((a,o)=>a.member.kind==="others"&&o!==e.length-1)&&t.addIssue({code:"custom",path:[],message:"Others is terminal."})}),ra=i.z.object({rowPath:A,columnPath:A,measureId:Be}).strict();function Le(e){return JSON.stringify(e.map(({levelId:t,member:a})=>[t,a.kind==="others"?["others",a.rankingId]:typeof a.value=="object"&&a.value!==null?["exact_number",a.value.value]:[typeof a.value,a.value]]))}const W="SEMAPHOR_CALCULATED_FIELD",jt="calculated_fields";function sa(e){return(e==null?void 0:e.sourceField)||(e==null?void 0:e.name)||""}const Ct=["MM-DD-YYYY","YYYY-MM-DD","MM/DD/YYYY","DD/MM/YYYY","MMMM DD, YYYY","MMM DD, YYYY","DD MMM YYYY","YYYY-MM-DD HH:mm","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm Z","YYYY-MM-DD HH:mm:ss Z","Week of MMM DD, YYYY","Week of MMMM DD, YYYY","YYYY-WW","MMM YYYY","MMMM YYYY","YYYY-MM","MM/YYYY","YYYY MMM","Q1 YYYY","YYYY Q1","1st Quarter YYYY","YYYY-Q1","Quarter 1, YYYY","YYYY","YY","custom"];function la(e){return e.role==="metric"&&"expression"in e&&!!e.expression}function da(e){return!!e.expression}function ca(e){return!!e.expression}function ua(e){var a,o;const t=e;return!!(t!=null&&t.expression&&((o=(a=t.calculatedFormula)==null?void 0:a.inputFields)!=null&&o.length))}function ma(e){return!!(e&&(e.entityName===W||e.entityId===W))}function pa(e){return e?[e.entityName,e.entityId,e.qualifiedEntityName].some(t=>t===W||t===jt):!1}var $t=(e=>(e.SUBTOTAL="__SUBTOTAL__",e.TOTAL="__TOTAL__",e.ALL="__ALL__",e))($t||{});const[fa,ga,ha,_a]=oe.options,ya=i.z.union([fa.innerType().strict(),ga.extend({type:i.z.literal("date")}).strict(),ha.strict(),_a.strict(),q]),b=i.z.string().min(1),Ot=i.z.enum(["table","view","materialized view","model","file","dataset","url","upload"]),_e=i.z.object({connectionId:b,connectionType:i.z.enum(["GoogleSheets","FileUpload","MySQL","MSSQL","PostgreSQL","BigQuery","Redshift","Snowflake","S3","clickhouse","S3Tables","API","none"]),type:Ot,name:b,alias:i.z.string().optional(),id:b.optional(),domainId:b.optional(),datasetType:i.z.enum(["physical","virtual"]).optional(),label:i.z.string().optional(),description:i.z.string().optional(),dbObjectType:i.z.string().optional(),database:i.z.string().optional(),schema:i.z.string().optional(),dialect:i.z.enum(["mysql","postgres","bigquery","redshift","snowflake","clickhouse","duckdb","mssql"]).optional()}).strict(),Z=i.z.lazy(()=>i.z.object({id:b,name:b,label:i.z.string(),derivedLabel:i.z.string().optional(),qualifiedFieldName:b,dataType:b,entityId:b,entityName:b,entityType:Ot,alias:i.z.string().optional(),sourceField:i.z.string().optional(),source:le.optional(),nativeDataType:i.z.string().optional(),description:i.z.string().optional(),qualifiedEntityName:i.z.string().optional(),dateFormat:i.z.enum(Ct).optional(),customFormat:i.z.string().optional(),granularity:P.optional(),role:i.z.enum(["groupby","metric","sortby","pivotby","detail"]).optional(),expression:i.z.string().optional(),derivedField:de.optional(),format:ya.optional(),semanticTemporalPresentation:i.z.object({granularity:P,format:q}).strict().optional(),aggregate:x.optional(),fieldScope:i.z.enum(["card","sheet","dashboard","domain"]).optional(),calculatedFormula:i.z.object({operation:i.z.enum(["sum","difference","product","ratio","change","percentage","scale","custom"]),inputFields:i.z.array(Z),constant:i.z.number().finite().optional()}).strict().optional()}).strict()),ba=i.z.union([i.z.string(),i.z.number().finite(),i.z.boolean(),i.z.date(),i.z.null()]),va=i.z.object({id:b,field:Z,operator:i.z.enum(["=","!=",">",">=","<","<=","contains","startsWith","endsWith","like","not like","in","not in","between","not between","isNull","isNotNull"]),value:i.z.union([ba,i.z.array(i.z.string()),i.z.array(i.z.number().finite())]),label:i.z.string().optional(),temporalBucket:K.optional()}).strict().superRefine((e,t)=>{const{operator:a,value:o}=e;(a==="between"||a==="not between")&&(!Array.isArray(o)||o.length!==2)&&t.addIssue({code:"custom",path:["value"],message:"Between requires two endpoints."}),(a==="in"||a==="not in")&&!Array.isArray(o)&&t.addIssue({code:"custom",path:["value"],message:"Membership requires an array."})}),Pt=i.z.lazy(()=>i.z.object({id:b,logicalOperator:i.z.enum(["AND","OR"]),negate:i.z.boolean(),conditions:i.z.array(va),groups:i.z.array(Pt)}).strict()),za=i.z.object({baseEntity:_e,joins:i.z.array(i.z.object({id:b,source:_e,target:_e,joinType:i.z.enum(["INNER","LEFT","RIGHT","FULL"]),sequence:i.z.number().int().nonnegative(),relationshipId:i.z.string().optional(),relationshipName:i.z.string().optional(),relationshipCardinality:i.z.enum(["one_to_one","one_to_many","many_to_one","many_to_many"]).optional(),relationshipTraversalDirection:i.z.enum(["forward","reverse"]).optional(),joinKeyGroups:i.z.array(i.z.object({id:b,operator:i.z.enum(["AND","OR"]),keys:i.z.array(i.z.object({id:i.z.string().optional(),source:Z,target:Z,operator:i.z.enum(["=","!=",">",">=","<","<="])}).strict()).min(1)}).strict()).min(1)}).strict())}).strict(),Yt=i.z.object({axis:ue,levelId:i.z.string().uuid().optional(),oppositePath:A.transform(e=>[...e]).optional()}).strict(),S=i.z.string().min(1),Sa=i.z.array(i.z.enum(["body","header","footer","subtotal","grandTotal"])),Ia=i.z.enum(["normal","medium","semibold","bold"]),ka=i.z.enum(["none","underline","line-through"]),Bt=i.z.object({version:i.z.literal(1),rules:i.z.array(i.z.object({id:i.z.string().min(1),name:i.z.string().optional(),enabled:i.z.boolean().optional(),target:i.z.object({level:i.z.enum(["cell","row"]),matrix:Yt.optional(),columnIds:i.z.array(S).optional(),conditionColumnId:S.optional(),applyToColumnIds:i.z.array(S).optional(),tableParts:Sa.optional(),rowRoles:i.z.array(i.z.string()).optional(),depth:i.z.number().int().nonnegative().optional(),includeTotals:i.z.boolean().optional(),includeSubtotals:i.z.boolean().optional()}).strict(),condition:i.z.discriminatedUnion("kind",[i.z.object({kind:i.z.literal("comparison"),columnId:S,operator:i.z.enum(["eq","neq","gt","gte","lt","lte"]),value:C}).strict(),i.z.object({kind:i.z.literal("between"),columnId:S,min:C,max:C,inclusive:i.z.boolean().optional()}).strict(),i.z.object({kind:i.z.literal("blank"),columnId:S,isBlank:i.z.boolean()}).strict(),i.z.object({kind:i.z.literal("contains"),columnId:S,value:i.z.string(),caseSensitive:i.z.boolean().optional(),exact:i.z.boolean().optional()}).strict(),i.z.object({kind:i.z.literal("topBottom"),columnId:S,direction:i.z.enum(["top","bottom"]),count:i.z.number().int().positive()}).strict(),i.z.object({kind:i.z.literal("colorScale"),columnId:S,range:i.z.enum(["auto","manual"]),min:i.z.number().finite().optional(),mid:i.z.number().finite().optional(),max:i.z.number().finite().optional(),colors:i.z.object({min:i.z.string(),mid:i.z.string().optional(),max:i.z.string()}).strict()}).strict(),i.z.object({kind:i.z.literal("dataBar"),columnId:S,range:i.z.enum(["auto","manual"]),min:i.z.number().finite().optional(),max:i.z.number().finite().optional(),color:i.z.string(),showValue:i.z.boolean().optional()}).strict()]),style:i.z.object({backgroundColor:i.z.string().optional(),textColor:i.z.string().optional(),fontWeight:Ia.optional(),italic:i.z.boolean().optional(),textDecoration:ka.optional(),icon:i.z.enum(["arrowUp","arrowDown","warning","check","x"]).optional(),dataBar:i.z.object({color:i.z.string(),showValue:i.z.boolean()}).strict().optional()}).strict().optional()}).strict())}).strict();function wa(e,t){const a=r=>{if(Y(r))return r.value;const l=typeof r=="string"?Mt(r.trim())??X(r):X(r);if(l===null)return null;try{return ia(String(l))}catch{return null}},o=a(e),n=a(t);return o===null||n===null?null:Pe(o,n)}function Aa(e,t,a){const o=Ut(e);if(o===null)return null;if(typeof o=="number"&&typeof t=="number"&&typeof a=="number"){const _=Ea(o,t,a);return{ratio:_,midpointComparison:Math.sign(_-.5)}}if([t,a].some(_=>typeof _=="number"&&!Number.isFinite(_)))return null;const n=[o,t,a].map(_=>{const ci=typeof _=="number"?k(String(_)):_.value,[ui,Je=""]=ci.split(".");return{coefficient:ui+Je,scale:Je.length}}),r=Math.max(...n.map(_=>_.scale)),[l,c,u]=n.map(_=>BigInt(_.coefficient)*10n**BigInt(r-_.scale)),d=u-c,p=l-c;if(d<=0n)return{ratio:l>=u?1:0,midpointComparison:l>=u?1:-1};const h=p*2n-d,v=h<0n?-1:h>0n?1:0;return{ratio:p<=0n?0:p>=d?1:Number(p*1000000000n/d)/1e9,midpointComparison:v}}function xa(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ra(e){return e.enabled!==!1}function Fa(e){return e.kind==="topBottom"||e.kind==="colorScale"&&e.range==="auto"||e.kind==="dataBar"&&e.range==="auto"}function Lt(e){return e.columnId}function qt(e){const t=[Lt(e.condition)];return{validationRefs:[...new Set([...t,...e.target.conditionColumnId===void 0?[]:[e.target.conditionColumnId],...e.target.columnIds??[],...e.target.applyToColumnIds??[]])],evaluationInputs:t}}function X(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function Ut(e){return Y(e)?e:X(e)}function Ta(e){const t=new Set,a=new Set;for(const o of e)Y(o)?a.add(o.value):t.add(o);return{has:o=>Y(o)?a.has(o.value):t.has(o)}}function Ma(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):Pe(typeof e=="number"?k(String(e)):e.value,typeof t=="number"?k(String(t)):t.value)}function Da(e){return e==null||e===""}function Ea(e,t,a){return!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(a)?0:a===t?e>=a?1:0:Math.max(0,Math.min(1,(e-t)/(a-t)))}function Na(e){switch(e){case"bold":return 700;case"semibold":return 600;case"medium":return 500;case"normal":return 400;default:return}}function ja(e){return e?Vt({fontWeight:Na(e.fontWeight),fontStyle:e.italic?"italic":void 0,color:e.textColor,backgroundColor:e.backgroundColor,textDecoration:e.textDecoration}):{}}function Ca(...e){return Object.assign({},...e.filter(t=>!!t).map(Vt))}function Vt(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const z=i.z.string().uuid(),$a=i.z.string().min(1),Oa=i.z.number().int().positive().max(Number.MAX_SAFE_INTEGER),Ht=i.z.enum(["SUM","COUNT","DISTINCT","AVG","MIN","MAX"]),qe=Wi.omit({aggregate:!0}),Pa={id:z,field:qe,grain:P.optional()},J=i.z.object(Pa).strict(),Ya=i.z.object({id:z,kind:i.z.literal("aggregate"),field:qe,aggregate:Ht}).strict(),Ba=i.z.object({id:z,kind:i.z.literal("calculated"),definition:de}).strict(),Ue=i.z.discriminatedUnion("kind",[Ya,Ba]),Gt=i.z.discriminatedUnion("kind",[i.z.object({kind:i.z.literal("member")}).strict(),i.z.object({kind:i.z.literal("measure"),measureId:z,oppositePath:A}).strict()]),Ve=i.z.object({axis:ue,levelId:z,scope:i.z.discriminatedUnion("kind",[i.z.object({kind:i.z.literal("level")}).strict(),i.z.object({kind:i.z.literal("branch"),parent:A}).strict()]),target:Gt,direction:i.z.enum(["asc","desc"]),nulls:i.z.enum(["first","last"])}).strict(),Kt=i.z.object({id:z,axis:ue,levelId:z,direction:i.z.enum(["top","bottom"]),count:Oa,measureId:z,oppositePath:A,others:i.z.boolean()}).strict(),Qt=i.z.object({source:le,rows:i.z.array(J).min(1).readonly(),columns:i.z.array(J).readonly(),measures:i.z.array(Ue).min(1).readonly(),filters:Pt.optional(),joinPlan:za.optional(),relationshipHint:i.z.object({relationshipIds:i.z.array($a).optional()}).strict().optional(),sorts:i.z.array(Ve).readonly(),rankings:i.z.array(Kt).readonly()}).strict();function He(e){return JSON.stringify([e.axis,e.levelId,e.scope.kind,e.scope.kind==="branch"?Le(e.scope.parent):null])}function g(e,t,a){e.addIssue({code:"custom",path:t,message:a})}function w(e,t,a){new Set(e).size!==e.length&&g(t,a,"Duplicate identity.")}function M(e,t,a,o,n,r=!1){a.length>e[t].length&&g(o,n,"Path exceeds axis depth."),a.forEach((l,c)=>{var u;if(l.levelId!==((u=e[t][c])==null?void 0:u.id)&&g(o,[...n,c],"Path must be an ordered axis prefix."),l.member.kind==="others"){const d=l.member.rankingId;(r||c!==a.length-1||!e.rankings.some(p=>p.id===d&&p.others&&p.axis===t&&p.levelId===l.levelId))&&g(o,[...n,c],"Others must terminate a path at its enabled ranking and cannot be a sort/rank target.")}})}function Wt(e,t,a,o){w(t.map(He),a,o),t.forEach((n,r)=>{const l=[...o,r],c=e[n.axis].findIndex(u=>u.id===n.levelId);if(c<0&&g(a,l,"Sort level is not on its axis."),n.scope.kind==="branch"&&(M(e,n.axis,n.scope.parent,a,[...l,"scope","parent"],!0),n.scope.parent.length!==c&&g(a,l,"Branch sort must name the immediate parent of its level.")),n.target.kind==="measure"){const u=n.target.measureId;e.measures.some(d=>d.id===u)||g(a,l,"Unknown sort measure."),M(e,n.axis==="rows"?"columns":"rows",n.target.oppositePath,a,[...l,"target","oppositePath"],!0)}})}function H(e,t,a,o){e&&(e.kind!==t.kind||e.kind==="semantic"&&t.kind==="semantic"&&e.domainId!==t.domainId||e.kind==="physical"&&t.kind==="physical"&&e.connectionId!==t.connectionId)&&g(a,o,"Field source must belong to the same semantic domain or physical connection.")}function ye(e,t,a){(e.defaultAggregate==="MEDIAN"||Object.values(e.inputs).some(o=>o.aggregate==="MEDIAN"||o.field.aggregate==="MEDIAN"))&&g(t,a,"MEDIAN dependencies are not supported at launch."),(e.aggregationBehavior==="snapshot"||e.aggregationBehavior==="weighted"||e.aggregationStrategy==="weighted")&&g(t,a,"This measure semantic requires a later capability.")}function Zt(e,t){w([...e.rows,...e.columns,...e.measures].map(n=>n.id),t,[]),w(e.rankings.map(n=>n.id),t,["rankings"]),w(e.rankings.map(n=>JSON.stringify([n.axis,n.levelId])),t,["rankings"]);for(const n of["rows","columns"])e[n].forEach((r,l)=>{r.grain&&r.field.dataType!==void 0&&!["date","datetime","unknown"].includes(r.field.dataType)&&g(t,[n,l,"grain"],"Grain requires a temporal field.")});const a=[...e.rows,...e.columns,...e.measures.filter(n=>n.kind==="aggregate")];for(const n of a)if(H(n.field.source,e.source,t,[n.id,"field","source"]),n.field.derivedField){n.field.derivedField.computeStage!=="row"&&g(t,[n.id],"Aggregate-stage calculations cannot be grouped or wrapped in an aggregate."),ye(n.field.derivedField,t,[n.id]);for(const r of Object.values(n.field.derivedField.inputs))H(r.field.source,e.source,t,[n.id,"inputs"])}for(const n of e.measures)if(n.kind==="calculated"){(n.definition.computeStage!=="aggregate"||n.definition.resultRole!=="measure")&&g(t,[n.id],"Calculated measures require aggregate stage and measure role."),ye(n.definition,t,[n.id]);for(const r of Object.values(n.definition.inputs))H(r.field.source,e.source,t,[n.id,"inputs"])}const o=n=>{const r=(l,c)=>{var u,d;if((l.aggregate||((u=l.derivedField)==null?void 0:u.computeStage)==="aggregate")&&g(t,c,"Aggregate/HAVING filters are not supported."),l.derivedField){ye(l.derivedField,t,c);for(const p of Object.values(l.derivedField.inputs))H(p.field.source,e.source,t,c)}for(const p of((d=l.calculatedFormula)==null?void 0:d.inputFields)??[])r(p,c)};for(const l of n.conditions)r(l.field,["filters",l.id]);n.groups.forEach(o)};if(e.filters&&o(e.filters),e.joinPlan){const n=[e.joinPlan.baseEntity,...e.joinPlan.joins.flatMap(r=>[r.source,r.target])];(new Set(n.map(r=>r.connectionId)).size>1||e.source.kind==="physical"&&n[0].connectionId!==e.source.connectionId)&&g(t,["joinPlan"],"Joins must stay within the source connection."),w(e.joinPlan.joins.map(r=>r.id),t,["joinPlan","joins"])}Wt(e,e.sorts,t,["sorts"]),e.rankings.forEach((n,r)=>{(!e[n.axis].some(l=>l.id===n.levelId)||!e.measures.some(l=>l.id===n.measureId))&&g(t,["rankings",r],"Unknown ranking level or measure."),M(e,n.axis==="rows"?"columns":"rows",n.oppositePath,t,["rankings",r,"oppositePath"],!0)})}const E=Qt.superRefine(Zt),La=Qt.extend({rows:i.z.array(J).readonly(),measures:i.z.array(Ue).readonly()}),Xt=La.superRefine(Zt),qa=E.innerType().extend({kind:i.z.literal("matrix")}),Jt=qa.superRefine(({kind:e,...t},a)=>{const o=E.safeParse(t);o.success||o.error.issues.forEach(n=>a.addIssue(n))}),Se=i.z.object({visible:i.z.boolean(),position:i.z.enum(["before","after"]),label:i.z.string().optional()}).strict(),it=i.z.object({grand:Se,levels:i.z.record(z,Se).readonly()}).strict(),at=Bt.shape.rules.element,ei=Bt.extend({rules:i.z.array(at.extend({target:at.shape.target.extend({rowRoles:i.z.array(Et).optional()})}))}).superRefine((e,t)=>{var a;w(e.rules.map(o=>o.id),t,["rules"]);for(const o of e.rules){const n=o.condition;n.kind==="topBottom"&&g(t,["rules",o.id],"Relative highlighting is deferred."),(n.kind==="dataBar"||n.kind==="colorScale")&&((n.range!=="manual"||n.min===void 0||n.max===void 0||n.min>=n.max)&&g(t,["rules",o.id],"Explicit increasing range endpoints are required."),n.kind==="colorScale"&&n.mid!==void 0&&(n.mid<=n.min||n.mid>=n.max)&&g(t,["rules",o.id],"Midpoint must be inside the range.")),(a=o.style)!=null&&a.dataBar&&g(t,["rules",o.id],"Use an explicit-range dataBar condition.")}});function ti(e,t,a,o,n=[]){for(const r of e.rules){const l=[...n,"rules",r.id],c=r.target.matrix;c&&(c.levelId!==void 0&&!t[c.axis].some(u=>u.id===c.levelId)&&g(o,[...l,"target","matrix","levelId"],"Conditional-format level is not on the selected axis."),c.oppositePath!==void 0&&M(t,c.axis==="rows"?"columns":"rows",c.oppositePath,o,[...l,"target","matrix","oppositePath"])),qt(r).validationRefs.some(u=>!a.has(u))&&g(o,l,"Conditional rules must reference displayed measures.")}}const Ua={layout:i.z.discriminatedUnion("kind",[i.z.object({kind:i.z.literal("compact")}).strict(),i.z.object({kind:i.z.literal("tabular"),repeatLabels:i.z.boolean()}).strict()]),absence:i.z.object({emptyText:i.z.string(),nullText:i.z.string()}).strict(),levelLabels:i.z.record(z,i.z.string()).readonly(),measureLabels:i.z.record(z,i.z.string()).readonly(),levelFormats:i.z.record(z,ve).readonly(),measureFormats:i.z.record(z,ve).readonly(),totals:i.z.object({rows:it,columns:it}).strict(),conditionalFormatting:ei.optional()},me=i.z.object(Ua).strict(),Va=i.z.object({depth:i.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),overrides:i.z.array(i.z.object({path:A,expanded:i.z.boolean()}).strict()).readonly()}).strict(),Ie=Va.superRefine((e,t)=>w(e.overrides.map(a=>Le(a.path)),t,["overrides"])),Ha={rows:Ie,columns:Ie},U=i.z.object(Ha).strict(),Ga=U.extend({sorts:i.z.array(Ve).readonly()}).strict(),ii=Ga.superRefine((e,t)=>w(e.sorts.map(He),t,["sorts"]));function pe(e,t){var u;const{spec:a,presentation:o,defaults:n,session:r}=e,l=new Set([...a.rows,...a.columns].map(d=>d.id)),c=new Set(a.measures.map(d=>d.id));for(const d of["levelLabels","levelFormats","measureLabels","measureFormats"]){const p=d.startsWith("level")?l:c;for(const h of Object.keys(o[d]))p.has(h)||g(t,["presentation",d,h],"Unknown presentation reference.")}for(const[d,p]of Object.entries(o.measureFormats))p.type==="temporal_bucket"&&g(t,["presentation","measureFormats",d],"Measures cannot own temporal bucket formats.");for(const[d,p]of Object.entries(o.levelFormats))p.type==="temporal_bucket"&&!((u=[...a.rows,...a.columns].find(h=>h.id===d))!=null&&u.grain)&&g(t,["presentation","levelFormats",d],"Temporal bucket formats require a grain.");for(const d of["rows","columns"]){const p=Object.keys(o.totals[d].levels);(p.length!==a[d].length||p.some(h=>!a[d].some(v=>v.id===h)))&&g(t,["presentation","totals",d],"Subtotal map must contain exactly the current axis levels.");for(const h of[n,...r?[r]:[]])for(const v of h[d].overrides)M(a,d,v.path,t,[d,"overrides"],!0),v.path.length||g(t,[d,"overrides"],"Use depth to expand/collapse the root.")}r&&Wt(a,r.sorts,t,["session","sorts"]),o.conditionalFormatting&&ti(o.conditionalFormatting,a,c,t,["presentation","conditionalFormatting"])}const Ka=i.z.object({spec:E,presentation:me,defaults:U,session:ii.optional()}).strict(),Qa=Ka.superRefine(pe),Wa=i.z.object({version:i.z.literal(1),spec:E,presentation:me,defaultView:U}).strict(),ai=Wa.superRefine((e,t)=>pe({...e,defaults:e.defaultView},t)),Za=ai.innerType().extend({spec:Xt}),Xa=Za.superRefine((e,t)=>pe({...e,defaults:e.defaultView},t)),nt=i.z.object({spec:E,presentation:me}).strict(),Ja=i.z.union([nt.extend({mode:i.z.literal("layout"),format:i.z.enum(["csv","xlsx","pdf"]),expansion:i.z.union([U.extend({kind:i.z.literal("current")}).strict(),i.z.object({kind:i.z.literal("all")}).strict()])}).strict(),nt.extend({mode:i.z.literal("flat"),format:i.z.literal("csv")}).strict()]),en=Ja.superRefine((e,t)=>pe({...e,defaults:e.mode==="layout"&&e.expansion.kind==="current"?e.expansion:{rows:{depth:0,overrides:[]},columns:{depth:0,overrides:[]}}},t));function tn(e){return e&&"id"in e?e.id:void 0}const an="SUM";function I(e){return typeof e=="string"&&e.trim().length>0}function $(e){return I(e)?e.trim().toLowerCase():""}function nn(e){const t=I(e.id)?e.id.trim():void 0;if(!t)return;const a=$(t),o=I(e.table)?e.table.trim():void 0;if(!(a===$(e.name)||o&&a===$(o)))return t}function R(e){const t=I(e.datasetId)?e.datasetId.trim():void 0;if(t)return $(t)===$(e.datasetName)?void 0:t}function Ge(e){if(e.kind!=="semantic")return e;const t=R(e),{datasetId:a,...o}=e;return{...o,...t?{datasetId:t}:{}}}function on(e){return e?e.kind==="semantic"?!!(I(e.domainId)&&(I(e.datasetId)||I(e.datasetName))):e.kind==="physical"?I(e.connectionId)&&I(e.tableName):I(e.connectionId):!1}function ee(e){if(!e)return"";if(e.kind==="semantic"){const t=R(e);return[e.kind,e.domainId,t?`datasetId:${t}`:`datasetName:${e.datasetName}`].join(":")}return e.kind==="physical"?[e.kind,e.connectionId,e.databaseName||"",e.schemaName||"",e.tableName].join(":"):[e.kind,e.connectionId,e.dialect||"",e.label||""].join(":")}function fe(e,t){if(!e||!t)return e===t;if(e.kind!==t.kind)return!1;if(e.kind==="semantic"&&t.kind==="semantic"){if(e.domainId!==t.domainId)return!1;const a=R(e),o=R(t);return a&&o?a===o:e.datasetName===t.datasetName}return ee(e)===ee(t)}function Ke(e,t){return e.kind!=="semantic"||t.kind!=="semantic"?e:Ge({...e,datasetName:e.datasetName||t.datasetName,datasetId:R(e)||R(t),label:e.label||t.label,connectionId:e.connectionId||t.connectionId})}function rn(e){const t=[];for(const a of e){const o=Ge(a),n=t.findIndex(r=>fe(r,o));if(n===-1){t.push(o);continue}t[n]=Ke(t[n],o)}return t}function ni(e,t){return e.name===t.name&&fe(e.source,t.source)}function sn(e){return[e.source?ee(e.source):"unknown",Qe(e),e.name].filter(Boolean).join(":")}function Qe(e){return ln(e.aggregate||an)}function ln(e){return e.trim().toUpperCase()}function dn(e,t){return{...e,label:e.label||t.label,role:e.role||t.role,dataType:e.dataType||t.dataType,source:e.source&&t.source?Ke(e.source,t.source):e.source||t.source}}function cn(e){for(let t=0;t<e.length;t+=1){const a=e[t];if(e.some((o,n)=>n!==t&&ri(o,a)))return!1}return!0}function oi(e,t){return ni(e,t)}function ri(e,t){return oi(e,t)&&B(e)===B(t)}function un(e){return`Metric intent has duplicate measure "${e.name}" with the same aggregate (${B(e)}). Use different aggregates to request both, or remove one entry.`}function ot(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function mn(e,t,a){if(e!==void 0){if(!e||typeof e!="object"||Array.isArray(e)){a.push(s("invalid_sql_default_parameters","SQL defaultParameters must be an object keyed by parameter name.",t));return}Object.entries(e).forEach(([o,n])=>{if(!o.trim()){a.push(s("invalid_sql_default_parameter_name","SQL defaultParameters names must be non-empty strings.",`${t}.${o}`));return}(Array.isArray(n)?n.every(ot):ot(n))||a.push(s("invalid_sql_default_parameter_value","SQL defaultParameters values must be strings, numbers, booleans, nulls, or arrays of those scalar values.",`${t}.${o}`))})}}function pn(e,t){return We(e,t).length===1}function fn(e,t){return We(e,t).length===1}function We(e,t){return t.filter(o=>gn(e,o))}function gn(e,t){return hn(e,t)?e.source?oi(t,e):!0:!1}function hn(e,t){return!(t.name!==e.name||e.role!==void 0&&t.role!==void 0&&t.role!==e.role||_n(e,t)&&B(t)!==B(e))}function _n(e,t){return e.role==="measure"||t.role==="measure"||e.aggregate!==void 0||t.aggregate!==void 0}function B(e){return Qe(e)}const yn=/^(\d{4})-(\d{2})-(\d{2})$/,si=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:\d{2})$/;function te(e){if(typeof e!="string")return null;const t=e.trim(),a=yn.exec(t);if(a){const[,v,F,_]=a;return rt(v,F,_)?new Date(Date.UTC(Number(v),Number(F)-1,Number(_))):null}const o=si.exec(t);if(!o)return null;const[,n,r,l,c,u,d="00",,p]=o;if(!rt(n,r,l)||!O(c,0,23)||!O(u,0,59)||!O(d,0,59)||!vn(p))return null;const h=new Date(t);return Number.isFinite(h.getTime())?h:null}function bn(e){return typeof e!="string"||!si.test(e.trim())?null:te(e)}function rt(e,t,a){const o=Number(e),n=Number(t),r=Number(a);if(!Number.isInteger(o)||!Number.isInteger(n)||!Number.isInteger(r)||n<1||n>12)return!1;const l=new Date(Date.UTC(o,n-1,r));return l.getUTCFullYear()===o&&l.getUTCMonth()===n-1&&l.getUTCDate()===r}function O(e,t,a){const o=Number(e);return Number.isInteger(o)&&o>=t&&o<=a}function vn(e){if(e==="Z")return!0;const t=/^([+-])(\d{2}):(\d{2})$/.exec(e);return!!(t&&O(t[2],0,23)&&O(t[3],0,59))}function st(e,t,a){if(e!==void 0){if(!f(e)){a.push(s("invalid_pagination","Pagination must be an object with positive integer page and pageSize.",t));return}(!Number.isInteger(e.page)||typeof e.page!="number"||e.page<1)&&a.push(s("invalid_pagination_page","Pagination page must be a positive integer.",`${t}.page`)),(!Number.isInteger(e.pageSize)||typeof e.pageSize!="number"||e.pageSize<1)&&a.push(s("invalid_pagination_page_size","Pagination pageSize must be a positive integer.",`${t}.pageSize`))}}function lt(e){const t=new Set;for(const a of e){if(t.has(a))return a;t.add(a)}return null}function zn(e,t,a){if(!f(e)){a.push(s("invalid_input_binding","Input bindings must be structured objects.",t));return}m(e.inputId)||a.push(s("invalid_input_binding","Input bindings need a non-empty inputId.",`${t}.inputId`)),e.kind!==void 0&&e.kind!=="filter"&&e.kind!=="control"&&a.push(s("invalid_input_binding","Input binding kind must be filter or control.",`${t}.kind`)),e.field!==void 0&&y(e.field,`${t}.field`,a),e.relationshipHint!==void 0&&Ze(e.relationshipHint,`${t}.relationshipHint`,a)}function Ze(e,t,a){if(!f(e)){a.push(s("invalid_relationship_hint","Relationship hints must be structured objects.",t));return}e.relationshipIds!==void 0&&(!Array.isArray(e.relationshipIds)||e.relationshipIds.some(o=>!m(o)))&&a.push(s("invalid_relationship_hint","Relationship hint relationshipIds must be non-empty strings.",`${t}.relationshipIds`))}function Sn(e,t){var o,n;if(((o=e.source)==null?void 0:o.kind)!=="semantic"&&((n=e.source)==null?void 0:n.kind)!=="physical"&&t.push(s("invalid_input_options_source","Input options must use a semantic or physical source.","source")),m(e.inputId)||t.push(s("missing_input_options_input_id","Input options intent needs the inputId it populates.","inputId")),e.search!==void 0&&typeof e.search!="string"&&t.push(s("invalid_input_options_search","Input options search must be a string.","search")),e.limit!==void 0&&(typeof e.limit!="number"||!Number.isFinite(e.limit)||!Number.isInteger(e.limit)||e.limit<=0)&&t.push(s("invalid_input_options_limit","Input options limit must be a positive finite number.","limit")),(!e.labelField||!m(e.labelField.name))&&t.push(s("missing_input_options_label_field","Input options intent needs a labelField.","labelField")),y(e.labelField,"labelField",t,{required:!0}),(!e.valueField||!m(e.valueField.name))&&t.push(s("missing_input_options_value_field","Input options intent needs a valueField.","valueField")),y(e.valueField,"valueField",t,{required:!0}),e.searchField!==void 0&&y(e.searchField,"searchField",t,{required:!0}),e.disambiguationFields!==void 0&&(Array.isArray(e.disambiguationFields)?e.disambiguationFields.forEach((r,l)=>{y(r,`disambiguationFields.${l}`,t,{required:!0})}):t.push(s("invalid_input_options_disambiguation_fields","Input options disambiguationFields must be an array of field refs.","disambiguationFields"))),[{field:e.labelField,path:"labelField"},{field:e.valueField,path:"valueField"},...e.searchField?[{field:e.searchField,path:"searchField"}]:[],...Array.isArray(e.disambiguationFields)?e.disambiguationFields.map((r,l)=>({field:r,path:`disambiguationFields.${l}`})):[]].forEach(({field:r,path:l})=>{r!=null&&r.source&&!fe(r.source,e.source)&&t.push(s("input_options_field_source_mismatch","Input option fields must belong to the declared option source.",`${l}.source`))}),e.dependencies!==void 0){const r=e.dependencies;if(!f(r))t.push(s("invalid_input_options_dependencies","Input options dependencies must be a structured object.","dependencies"));else{const l=r.mode;l!==void 0&&l!=="independent"&&l!=="explicit"&&t.push(s("invalid_input_options_dependencies","Input options dependencies mode must be independent or explicit.","dependencies.mode")),dt(r.includeInputIds,"dependencies.includeInputIds",t,"Input options includeInputIds must be non-empty strings."),dt(r.excludeInputIds,"dependencies.excludeInputIds",t,"Input options excludeInputIds must be non-empty strings."),kn(e,t)}}if(e.population!==void 0){const r=e.population;if(!f(r))t.push(s("invalid_input_options_population","Input options population must be a structured object.","population"));else{const l=r.kind;l!=="option_source"&&l!=="related_population"&&t.push(s("invalid_input_options_population","Input options population kind must be option_source or related_population.","population.kind")),l==="option_source"&&r.baseSource!==void 0&&t.push(s("invalid_input_options_population","Input options population baseSource is only valid for related_population.","population.baseSource")),l==="option_source"&&r.relationshipHint!==void 0&&t.push(s("invalid_input_options_population","Input options population relationshipHint is only valid for related_population.","population.relationshipHint")),l==="related_population"&&(De(r.baseSource,"population.baseSource",t),r.relationshipHint!==void 0&&Ze(r.relationshipHint,"population.relationshipHint",t))}}}function In(e,t){if(!(!("inputs"in e)||e.inputs===void 0)){if(!Array.isArray(e.inputs)){t.push(s("invalid_input_binding","Analytics intent inputs must be an array of input bindings.","inputs"));return}e.inputs.forEach((a,o)=>zn(a,`inputs.${o}`,t))}}function kn(e,t){var o,n;const a=new Set(Array.isArray(e.inputs)?e.inputs.map(r=>f(r)?r.inputId:void 0).filter(r=>typeof r=="string"):[]);for(const r of((o=e.dependencies)==null?void 0:o.includeInputIds)||[])a.has(r)||t.push(s("invalid_input_options_dependencies",`Input options dependency "${r}" is not declared in inputs.`,"dependencies.includeInputIds"));for(const r of((n=e.dependencies)==null?void 0:n.excludeInputIds)||[])r!==e.inputId&&!a.has(r)&&t.push(s("invalid_input_options_dependencies",`Input options dependency exclusion "${r}" is not the populated inputId and is not declared in inputs.`,"dependencies.excludeInputIds"))}function dt(e,t,a,o){e!==void 0&&(!Array.isArray(e)||e.some(n=>!m(n)))&&a.push(s("invalid_input_options_dependencies",o,t))}const wn=new Set(L);function An(e,t,a){if(f(e)&&e.type==="temporal_bucket"){a.push(s("invalid_scalar_value_format","Scalar and measure slots cannot own temporal bucket presentation; declare it with grain on a grouped field or axis.",t));return}zt(e,t,a)}function ct(e,t,a){if(!f(e)){a.push(s("invalid_result_column_ref","Result calculation references must use columnKey or field.",t));return}const o=m(e.columnKey),n=f(e.field);if(o===n){a.push(s("invalid_result_column_ref","Result calculation references must identify exactly one of columnKey or field.",t));return}n&&y(e.field,`${t}.field`,a,{required:!0})}function xn(e,t,a){if(!f(e)){a.push(s("invalid_result_calculation_output","Result calculation output must be a structured object.",t));return}m(e.key)||a.push(s("invalid_result_calculation_output","Result calculation output needs a stable key.",`${t}.key`)),e.dataType!==void 0&&(typeof e.dataType!="string"||!vt.has(e.dataType))&&a.push(s("invalid_result_calculation_output","Result calculation output dataType must be string, number, boolean, date, datetime, or unknown.",`${t}.dataType`)),An(e.format,`${t}.format`,a)}function Rn(e,t){if(e.analysis===void 0)return;if(!f(e.analysis)){t.push(s("invalid_measure_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){t.push(s("invalid_measure_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||t.push(s("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||t.push(s("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"&&t.push(s("invalid_measure_analysis","Period-change analysis orderBy must be absolute_change, positive_change, negative_change, or period.","analysis.orderBy"));const{timeWindow:a}=e.analysis;a!==void 0&&ke(a,"analysis.timeWindow",t)}function ke(e,t,a){if(!f(e)){a.push(s("invalid_time_window","Time window must be a structured object.",t));return}if(e.kind!==void 0&&e.kind!=="relative"&&e.kind!=="absolute"&&a.push(s("invalid_time_window","Time window kind must be relative or absolute.",`${t}.kind`)),e.kind==="absolute"){if(m(e.start)||a.push(s("invalid_time_window","Absolute time window start must be a non-empty ISO date or timestamp string.",`${t}.start`)),m(e.end)||a.push(s("invalid_time_window","Absolute time window end must be a non-empty ISO date or timestamp string.",`${t}.end`)),m(e.start)&&m(e.end)){const o=te(e.start),n=te(e.end);o||a.push(s("invalid_time_window","Absolute time window start must be a valid ISO date or timestamp.",`${t}.start`)),n||a.push(s("invalid_time_window","Absolute time window end must be a valid ISO date or timestamp.",`${t}.end`)),o&&n&&o.getTime()>n.getTime()&&a.push(s("invalid_time_window","Absolute time window start must be before or equal to end.",t))}return}(typeof e.unit!="string"||!wn.has(e.unit))&&a.push(s("invalid_time_window",`Time window unit must be one of: ${L.join(", ")}.`,`${t}.unit`)),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<=0)&&a.push(s("invalid_time_window","Time window value must be a positive number.",`${t}.value`)),e.anchor!==void 0&&e.anchor!=="now"&&e.anchor!=="latest_available"&&a.push(s("invalid_time_window","Time window anchor must be now or latest_available.",`${t}.anchor`)),e.completeness!==void 0&&e.completeness!=="include_partial"&&e.completeness!=="complete_periods"&&a.push(s("invalid_time_window","Time window completeness must be include_partial or complete_periods.",`${t}.completeness`))}function we(e,t,a){if(e!==void 0){if(!Array.isArray(e)){a.push(s("invalid_analytics_filters","Analytics filters must be an array.",t));return}e.forEach((o,n)=>{var u;const r=`${t}.${n}`;if(!f(o)){a.push(s("invalid_analytics_filter","Analytics filter must be a structured object.",r));return}const l=o;y(l.field,`${r}.field`,a,{required:!0}),l.scope!==void 0&&l.scope!=="row"&&l.scope!=="aggregate"&&a.push(s("invalid_analytics_filter_scope","Analytics filter scope must be row or aggregate.",`${r}.scope`)),l.scope==="aggregate"&&((u=l.field)==null?void 0:u.role)!==void 0&&l.field.role!=="measure"&&a.push(s("invalid_analytics_filter_scope","Aggregate-scope analytics filters must target a measure field.",`${r}.scope`));const c=l.operator==="is_null"||l.operator==="is_not_null";if(l.operator!==void 0&&l.operator!=="="&&l.operator!=="!="&&l.operator!=="in"&&l.operator!=="not_in"&&l.operator!=="contains"&&l.operator!=="not_contains"&&l.operator!=="between"&&l.operator!=="not_between"&&l.operator!==">"&&l.operator!==">="&&l.operator!=="<"&&l.operator!=="<="&&l.operator!=="is_null"&&l.operator!=="is_not_null"&&a.push(s("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${r}.operator`)),l.values===void 0&&!c&&a.push(s("missing_analytics_filter_value","Analytics filter needs values unless it is a null check.",r)),c&&l.values!==void 0){a.push(s("invalid_analytics_filter_values","Null-check analytics filters must not include values.",`${r}.values`));return}if(l.values!==void 0&&!Array.isArray(l.values)){a.push(s("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${r}.values`));return}if(l.values!==void 0){const d=l.values.length;if(l.operator==="between"||l.operator==="not_between"){d!==2&&a.push(s("invalid_analytics_filter_values","Between analytics filters must include exactly two values.",`${r}.values`));return}(l.operator==="contains"||l.operator==="not_contains"||l.operator==="="||l.operator==="!="||l.operator===">"||l.operator===">="||l.operator==="<"||l.operator==="<="||l.operator===void 0)&&d!==1&&a.push(s("invalid_analytics_filter_values","Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",`${r}.values`))}})}}function Fn(e){const t=[];if(!f(e))return t.push(s("invalid_result_calculation","Result calculation must be a structured object.")),{ok:!1,errors:t,warnings:[]};if(m(e.id)||t.push(s("invalid_result_calculation_id","Result calculation needs an id.","id")),m(e.label)||t.push(s("invalid_result_calculation_label","Result calculation needs a label.","label")),e.kind!=="percent_of_total"&&e.kind!=="rank"&&e.kind!=="running_total"&&e.kind!=="previous_row_delta"&&t.push(s("invalid_result_calculation_kind","Result calculation kind must be percent_of_total, rank, running_total, or previous_row_delta.","kind")),ct(e.input,"input",t),xn(e.output,"output",t),e.kind==="percent_of_total"){const a=e.denominator;a!==void 0&&(f(a)?a.scope==="population"?(y(a.metric,"denominator.metric",t,{required:!0}),we(a.filters,"denominator.filters",t)):a.scope!=="returned_result"&&t.push(s("invalid_result_calculation_denominator","Percent-of-total denominator scope must be returned_result or population.","denominator.scope")):t.push(s("invalid_result_calculation_denominator","Percent-of-total denominator must be a structured object.","denominator")))}return e.kind==="rank"&&e.order!==void 0&&e.order!=="asc"&&e.order!=="desc"&&t.push(s("invalid_result_calculation_order","Rank result calculation order must be asc or desc.","order")),(e.kind==="running_total"||e.kind==="previous_row_delta")&&e.orderBy!==void 0&&ct(e.orderBy,"orderBy",t),{ok:t.length===0,errors:t,warnings:[]}}function Xe(e){var o;const t=[],a=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_analytics_intent","Analytics intent must be a structured object.")],warnings:a,repairHints:[{code:"invalid_analytics_intent",recommendedNextStep:"Send one structured analytics intent object with kind, source, and required fields."}]};if(e.kind==="matrix"){const n=Jt.safeParse(e);return n.success||t.push(...n.error.issues.map(r=>s("invalid_matrix_intent",r.message,r.path.join(".")))),{ok:t.length===0,errors:t,warnings:a,repairHints:ut(t)}}if(e.version!==void 0&&e.version!==1&&t.push(s("invalid_version","Analytics intent version must be 1.","version")),De(e.source,"source",t),Tn(e,t),In(e,t),"relationshipHint"in e&&e.relationshipHint!==void 0&&Ze(e.relationshipHint,"relationshipHint",t),e.kind==="metric"){const n=Array.isArray(e.measures)?e.measures.filter(r=>f(r)&&m(r.name)):[];if(!Array.isArray(e.measures)||e.measures.length===0?t.push(s("missing_measure","Metric intent needs at least one measure.","measures")):e.measures.some(r=>!f(r)||!m(r.name))&&t.push(s("invalid_measure_list","Metric intent measures must be an array of field references with names.","measures")),n.forEach((r,l)=>{y(r,`measures.${l}`,t,{required:!0})}),n.length>0&&!cn(n)){const r=n.find((l,c)=>n.some((u,d)=>d!==c&&ri(u,l)));r&&t.push(s("duplicate_measure",un(r),"measures"))}if(f(e.primaryMeasure)&&m(e.primaryMeasure.name)&&We(e.primaryMeasure,n).length>1&&t.push(s("ambiguous_primary_measure","Metric intent primaryMeasure must identify exactly one selected measure.","primaryMeasure")),e.primaryMeasure!==void 0&&(y(e.primaryMeasure,"primaryMeasure",t,{required:!0}),f(e.primaryMeasure)&&m(e.primaryMeasure.name)&&n.length>0&&!pn(e.primaryMeasure,n)&&t.push(s("invalid_primary_measure","Metric intent primaryMeasure must match one measure field reference.","primaryMeasure"))),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?t.push(s("invalid_measure_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(r=>!f(r)||!m(r.name))&&t.push(s("invalid_measure_dimensions","Metric intent dimensions must be an array of field references with names.","dimensions")),e.dateField!==void 0&&y(e.dateField,"dateField",t),e.timeWindow!==void 0&&(ke(e.timeWindow,"timeWindow",t),e.dateField||t.push(s("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),we(e.filters,"filters",t),Array.isArray(e.dimensions)&&e.dimensions.forEach((r,l)=>{y(r,`dimensions.${l}`,t)}),e.orderBy!==void 0){if(!f(e.orderBy))t.push(s("invalid_measure_order_by","Metric intent orderBy must be a structured object.","orderBy"));else if(y(e.orderBy.field,"orderBy.field",t,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&t.push(s("invalid_measure_order_direction","Metric intent orderBy direction must be asc or desc.","orderBy.direction")),f(e.orderBy.field)&&m(e.orderBy.field.name)){const r=[...n,...e.timeGrain&&e.dateField&&f(e.dateField)?[e.dateField]:[],...Array.isArray(e.dimensions)?e.dimensions.filter(l=>f(l)&&m(l.name)):[]];r.length>0&&!fn(e.orderBy.field,r)&&t.push(s("invalid_measure_order_by","Metric intent orderBy.field must match one selected measure, grouped dateField, or dimension.","orderBy.field"))}}Rn(e,t)}else if(e.kind==="records"){if(!Array.isArray(e.fields)||e.fields.length===0?t.push(s("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(n=>!f(n)||!m(n.name))&&t.push(s("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((n,r)=>{y(n,`fields.${r}`,t)}),e.dateField!==void 0&&y(e.dateField,"dateField",t),st(e.pagination,"pagination",t),e.timeWindow!==void 0&&(ke(e.timeWindow,"timeWindow",t),e.dateField||t.push(s("missing_time_window_date_field","Records timeWindow needs a dateField.","dateField"))),we(e.filters,"filters",t),Array.isArray(e.filters)&&e.filters.forEach((n,r)=>{f(n)&&n.scope==="aggregate"&&t.push(s("unsupported_record_filter_scope","Records intents support row-scope filters only. Use a metric intent for aggregate-scope filters.",`filters.${r}.scope`))}),e.orderBy!==void 0&&(f(e.orderBy)?(y(e.orderBy.field,"orderBy.field",t,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&t.push(s("invalid_record_order_direction","Records intent orderBy direction must be asc or desc.","orderBy.direction"))):t.push(s("invalid_record_order_by","Records intent orderBy must be a structured object.","orderBy"))),e.totals!==void 0)if(!f(e.totals))t.push(s("invalid_records_totals","Records totals must be a structured server totals request.","totals"));else{e.totals.mode!=="server"&&t.push(s("invalid_records_totals","Records totals mode must be server.","totals.mode"));const n=e.totals.measures;!Array.isArray(n)||n.length===0?t.push(s("missing_records_totals_measures","Records server totals need at least one measure.","totals.measures")):n.forEach((r,l)=>{y(r,`totals.measures.${l}`,t,{required:!0}),(!f(r)||r.role!=="measure")&&t.push(s("invalid_records_totals_measure","Records server totals measures must be measure field references.",`totals.measures.${l}.role`))})}}else e.kind==="inputOptions"?Sn(e,t):e.kind==="sql"?(((o=e.source)==null?void 0:o.kind)!=="sql"&&t.push(s("invalid_sql_source","SQL analytics intent must use a SQL execution source.","source")),m(e.sql)||t.push(s("missing_sql","SQL analytics intent needs SQL text.","sql")),mn(e.defaultParameters,"defaultParameters",t),Array.isArray(e.fields)&&e.fields.forEach((n,r)=>{y(n,`fields.${r}`,t)}),st(e.pagination,"pagination",t)):t.push(s("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:t.length===0,errors:t,warnings:a,repairHints:ut(t)}}function Tn(e,t){if(!(!("derivedFields"in e)||e.derivedFields===void 0)){if(!Array.isArray(e.derivedFields)){t.push(s("invalid_derived_fields","Analytics intent derivedFields must be an array of derived field definitions.","derivedFields"));return}e.derivedFields.forEach((a,o)=>{Ne(a).errors.forEach(r=>{t.push({...r,path:r.path?`derivedFields.${o}.${r.path}`:`derivedFields.${o}`})})})}}function li(e){const t=[],a=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_operation_intent","Operation intent must be a structured object.")],warnings:a,repairHints:[{code:"invalid_operation_intent",recommendedNextStep:"Send one typed operation intent with version, kind, and required operation fields."}]};if(e.version!==1&&t.push(s("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?t.push(s("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((o,n)=>{m(o.id)||t.push(s("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${n}.id`)),m(o.prompt)||t.push(s("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${n}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(m(e.instruction)||t.push(s("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const o=Xe(e.analyticsIntent);t.push(...o.errors),a.push(...o.warnings)}}else t.push(s("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:t.length===0,errors:t,warnings:a,repairHints:di(t)}}function Mn(e){const t=[],a=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_recovery_plan","Analytics recovery plan must be a structured object.")],warnings:a,repairHints:[{code:"invalid_recovery_plan",recommendedNextStep:"Return a typed recovery plan with operationIntent and plannedToolCalls."}]};e.version!==1&&t.push(s("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&t.push(s("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const o=li(e.operationIntent);return t.push(...o.errors),a.push(...o.warnings),Array.isArray(e.plannedToolCalls)||t.push(s("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:t.length===0,errors:t,warnings:a,repairHints:di(t)}}function di(e){return e.map(t=>({code:t.code,recommendedNextStep:t.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 ut(e){return e.map(t=>{switch(t.code){case"invalid_matrix_intent":return{code:t.code,recommendedNextStep:`Correct MatrixSpec at ${t.path||"the definition"}: ${t.message} Keep presentation and matrixWindowRequest outside the intent.`};case"missing_source":return{code:t.code,fieldRole:"source",recommendedNextStep:"Provide a semantic, physical, or SQL source before executing analytics."};case"missing_measure":return{code:t.code,fieldRole:"measure",recommendedNextStep:"Choose one exact measure from the grounded schema candidates."};case"missing_record_fields":return{code:t.code,fieldRole:"dimension",recommendedNextStep:"Provide at least one field for the records intent."};case"missing_matrix_rows":return{code:t.code,fieldRole:"dimension",recommendedNextStep:"Choose at least one row axis level for the matrix table."};case"missing_matrix_values":return{code:t.code,fieldRole:"measure",recommendedNextStep:"Choose at least one value field for the matrix table."};case"unsupported_matrix_sql_source":return{code:t.code,fieldRole:"source",recommendedNextStep:"Use a semantic or explorer-backed source for matrix tables; raw SQL matrix tables are not supported."};case"missing_input_options_input_id":return{code:t.code,fieldRole:"input",recommendedNextStep:"Provide the inputId that these option values populate."};case"missing_input_options_label_field":return{code:t.code,fieldRole:"dimension",recommendedNextStep:"Provide the human-readable field used as option labels."};case"missing_input_options_value_field":return{code:t.code,fieldRole:"dimension",recommendedNextStep:"Provide the stable field used as option values."};case"missing_sql":return{code:t.code,fieldRole:"sql",recommendedNextStep:"Provide bounded read-only SQL with an explicit outer LIMIT."};case"conflicting_sql":return{code:t.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:t.code,fieldRole:"source",recommendedNextStep:"Use grounded catalog metadata to fill the missing source reference."};default:return}}).filter(t=>!!t)}function Dn(e,t,a,o){if(!e||typeof e!="object"){a.push(s("invalid_view","Dashboard view must be an object.",t));return}if(m(e.title)||a.push(s("missing_view_title","Dashboard view needs a title.",t)),!e.presentation||typeof e.presentation!="object"){a.push(s("missing_presentation","Dashboard view needs a presentation.",`${t}.presentation`));return}if(e.presentation.kind==="text"){m(e.text)||o.push(s("missing_text_content","Text views should include text content.",`${t}.text`));return}if(!e.analytics){a.push(s("missing_view_analytics","Non-text dashboard views need analytics intent.",`${t}.analytics`));return}e.presentation.kind==="matrixTable"&&e.analytics.kind!=="matrix"&&a.push(s("invalid_matrix_view_analytics","Matrix table views need matrix analytics intent.",`${t}.analytics.kind`));const n=Xe(e.analytics);for(const r of n.errors)a.push(s(r.code,r.message,`${t}.analytics${r.path?`.${r.path}`:""}`));for(const r of n.warnings)o.push(s(r.code,r.message,`${t}.analytics${r.path?`.${r.path}`:""}`))}function En(e){const t=[],a=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:a};e.version!==1&&t.push(s("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&t.push(s("invalid_kind","Experience intent kind must be dashboard.")),m(e.title)||t.push(s("missing_title","Dashboard intent needs a title.","title"));const o=Array.isArray(e.inputs)?e.inputs:[],n=lt(o.filter(f).map(u=>u.id).filter(u=>typeof u=="string"));n&&t.push(s("duplicate_input_id",`Duplicate input id: ${n}.`,"inputs"));for(const[u,d]of o.entries()){const p=`inputs.${u}`;if(!f(d)){t.push(s("invalid_input","Dashboard input must be an object.",p));continue}m(d.id)||t.push(s("missing_input_id","Input needs an id.",`${p}.id`)),m(d.label)||t.push(s("missing_input_label","Input needs a label.",`${p}.label`)),!d.field||!m(d.field.name)?t.push(s("missing_input_field","Input needs a field.",`${p}.field`)):y(d.field,`${p}.field`,t)}const r=Array.isArray(e.sections)?e.sections:[];r.length===0&&t.push(s("missing_sections","Dashboard intent needs at least one section.","sections"));const l=r.flatMap(u=>u&&typeof u=="object"&&Array.isArray(u.views)?u.views.filter(f).map(d=>d.id).filter(d=>!!d):[]),c=lt(l);c&&t.push(s("duplicate_view_id",`Duplicate dashboard view id: ${c}.`,"sections"));for(const[u,d]of r.entries()){const p=`sections.${u}`;if(!d||typeof d!="object"){t.push(s("invalid_section","Dashboard section must be an object.",p));continue}if(m(d.title)||t.push(s("missing_section_title","Dashboard section needs a title.",p)),!Array.isArray(d.views)||d.views.length===0){t.push(s("missing_section_views","Dashboard section needs at least one view.",`${p}.views`));continue}for(const[h,v]of d.views.entries())Dn(v,`${p}.views.${h}`,t,a)}return{ok:t.length===0,errors:t,warnings:a}}exports.CALCULATED_FIELD_ENTITY_MARKER=W;exports.DATE_FORMAT_VALUES=Ct;exports.LEGACY_CALCULATED_FIELD_ENTITY_MARKER=jt;exports.PivotMarkerEnum=$t;exports.RAW_TEMPORAL_CONTRACT_ERROR_CODES=pi;exports.SEMAPHOR_GENERATED_COUNT_METRIC_ID=gi;exports.SEMAPHOR_TIME_GRAINS=L;exports.TEMPORAL_BUCKET_CONTRACT_ERROR_CODES=fi;exports.TEMPORAL_BUCKET_PRESETS=mt;exports.baseStyleToResolvedStyle=ja;exports.buildAnalyticsCatalogFieldSummary=ta;exports.canonicalDashboardRecordsPayloadSchema=Ri;exports.canonicalizeExactNumericText=k;exports.canonicalizeSemaphorSourceIdentity=Ge;exports.checkMatrixConditionalFormattingReferences=ti;exports.checkMatrixPath=M;exports.compareExactDecimal=Pe;exports.compareExactFormattingValues=wa;exports.compareFormattingNumbers=Ma;exports.conditionColumnId=Lt;exports.conditionNeedsRowDomainFacts=Fa;exports.conditionalRuleMeasureRefs=qt;exports.configDerivedFieldSchema=de;exports.configSourceRefSchema=le;exports.createExactNumericValue=Dt;exports.createFormattingValueSet=Ta;exports.dashboardRecordsPayloadSchema=xi;exports.decodeNumericResultValue=oa;exports.exactNumericValueSchema=Ye;exports.getAnalyticsCatalogFieldCandidates=wt;exports.getAnalyticsCatalogFieldName=kt;exports.getAnalyticsIntentId=tn;exports.getAnalyticsNumericStorageKind=xt;exports.getFieldRuntimeColumnName=sa;exports.getSemaphorDatasetEntityId=nn;exports.getSemaphorNonRedundantDatasetId=R;exports.hasCalculatedFieldMarker=ma;exports.hasCalculatedFormulaInputs=ua;exports.hasCompleteSemaphorSourceIdentity=on;exports.hasSyntheticCalculatedFieldOwner=pa;exports.isAnalyticsCatalogDateField=Ce;exports.isAnalyticsCatalogDimensionField=ea;exports.isAnalyticsCatalogMetricField=Oe;exports.isAnalyticsDateLikeDataType=Ft;exports.isAnalyticsMetricIdentifierField=ze;exports.isAnalyticsTechnicalIdentifierField=$e;exports.isBlankValue=Da;exports.isCalculatedDimension=da;exports.isCalculatedField=ca;exports.isCalculatedMetric=la;exports.isEnabledRule=Ra;exports.isExactNumericValue=Y;exports.isPlainObject=xa;exports.isSemaphorTimeGrain=mi;exports.isValidIanaTimeZone=ft;exports.mapNamedExpressionTokens=bt;exports.matrixAggregateSchema=Ht;exports.matrixAnalyticalIntentSchema=Jt;exports.matrixAuthoringConfigSchema=Xa;exports.matrixAuthoringSpecSchema=Xt;exports.matrixAxisSchema=ue;exports.matrixConditionalFormatScopeSchema=Yt;exports.matrixConditionalFormattingSchema=ei;exports.matrixConfigSchema=ai;exports.matrixCoordinateSchema=ra;exports.matrixDefaultViewSchema=U;exports.matrixDefinitionInputSchema=Qa;exports.matrixExpansionSchema=Ie;exports.matrixExportRequestSchema=en;exports.matrixFieldSchema=qe;exports.matrixFormattingRoleSchema=Et;exports.matrixLevelSchema=J;exports.matrixMeasureSchema=Ue;exports.matrixMemberSchema=Nt;exports.matrixPathKey=Le;exports.matrixPathSchema=A;exports.matrixPresentationSchema=me;exports.matrixRankingSchema=Kt;exports.matrixSortKey=He;exports.matrixSortSchema=Ve;exports.matrixSortTargetSchema=Gt;exports.matrixSpecSchema=E;exports.matrixTotalPresentationSchema=Se;exports.matrixViewStateSchema=ii;exports.mergeResolvedStyles=Ca;exports.mergeSemaphorSourcesByIdentity=rn;exports.normalizeAnalyticsCatalogDataType=je;exports.normalizeAnalyticsCatalogName=ce;exports.normalizeNumericLiteral=Mt;exports.nullableScalarSchema=G;exports.parseSemaphorIsoInstant=bn;exports.parseSemaphorIsoTimeWindowBoundary=te;exports.preferSemaphorFieldRefMetadata=dn;exports.preferSemaphorSourceMetadata=Ke;exports.rawTemporalValueMetadataSchema=ht;exports.recordArraySchema=D;exports.recordSchema=gt;exports.resolveFormattingRangePosition=Aa;exports.scaleExactDecimal=aa;exports.semaphorAggregateFunctionSchema=x;exports.semaphorAnalyticsValidationIssueSchema=be;exports.semaphorAnalyticsValidationResultSchema=Fi;exports.semaphorCompactFieldRefSchema=Ai;exports.semaphorDerivedFieldDefinitionObjectSchema=Te;exports.semaphorDerivedFieldDefinitionSchema=Me;exports.semaphorExecutionFieldRefSchema=zi;exports.semaphorFieldRefObjectSchema=Re;exports.semaphorFieldRefSchema=Fe;exports.semaphorFieldRefsMatch=ni;exports.semaphorInputOptionsResultSchema=Ei;exports.semaphorMetricAggregate=Qe;exports.semaphorMetricMeasureBindingKey=sn;exports.semaphorMetricResultSchema=Mi;exports.semaphorPhysicalSourceRefSchema=Ae;exports.semaphorRecordsResultSchema=Di;exports.semaphorResultColumnSchema=T;exports.semaphorScalarValueFormatSchema=oe;exports.semaphorScalarValueSchema=C;exports.semaphorSemanticSourceRefSchema=re;exports.semaphorSourceIdentityKey=ee;exports.semaphorSourceRefSchema=xe;exports.semaphorSourcesReferToSameDataset=fe;exports.semaphorSqlResultSchema=Ni;exports.semaphorSqlSourceRefSchema=_t;exports.semaphorTimeGrainSchema=P;exports.semaphorValueFormatSchema=ve;exports.temporalBucketDataTypeForGrain=pt;exports.temporalBucketFormatSchema=q;exports.temporalBucketMetadataSchema=K;exports.toFiniteNumber=X;exports.toFormattingNumber=Ut;exports.validateSemaphorAnalyticsIntent=Xe;exports.validateSemaphorAnalyticsRecoveryPlan=Mn;exports.validateSemaphorDashboardIntent=En;exports.validateSemaphorDerivedFieldDefinition=Ne;exports.validateSemaphorOperationIntent=li;exports.validateSemaphorResultCalculation=Fn;
@@ -1270,6 +1270,8 @@ const [Ri, Ti, Mi, Di] = pe.options, Ni = i.union([
1270
1270
  id: y,
1271
1271
  name: y,
1272
1272
  label: i.string(),
1273
+ /** Set when `label` was synthesized from `name`; see `Field.derivedLabel`. */
1274
+ derivedLabel: i.string().optional(),
1273
1275
  qualifiedFieldName: y,
1274
1276
  dataType: y,
1275
1277
  entityId: y,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-DXQsuuMQ.cjs"),e=require("../chunks/common-types-nBuCd3u2.cjs");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-a9nBmD-v.cjs"),e=require("../chunks/common-types-nBuCd3u2.cjs");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-CPWfCksu.js";
1
+ import { D as o } from "../chunks/index-Ne0-ePdz.js";
2
2
  import { C as s, E as C } from "../chunks/common-types-C6cAQgyh.js";
3
3
  export {
4
4
  s as CONTROL_CARD_DEFAULT_VALUE,
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../chunks/matrix-control-sources-BWbqiGmN.cjs"),I=require("../chunks/field-aggregations-hx8odlTh.cjs"),v=require("../chunks/validators-4dRtYUI1.cjs");require("../chunks/matrix-operation-contract-BiUMcd6G.cjs");const m=require("../chunks/calculated-field-identity-D4VOHjBJ.cjs"),Fe=require("../chunks/operators-DrTQsJXv.cjs"),Q=require("../chunks/canonical-result-keys-Cb96edol.cjs"),E=require("../chunks/matrix-definition-Z80mIEfu.cjs"),Y=require("../chunks/matrix-card-DzkJRoM4.cjs");function y(e){return e&&typeof e=="object"?e:null}function O(e){return typeof e=="string"?e:null}function ce(e){var t,r,a;return!!(e&&typeof e=="object")&&(((t=y(e))==null?void 0:t.kind)==="semantic"||((r=y(e))==null?void 0:r.kind)==="physical"||((a=y(e))==null?void 0:a.kind)==="sql")}function N(e){return ce(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 J(e,t){return v.semaphorSourcesReferToSameDataset(e,t)}function ue(e,t){return v.preferSemaphorSourceMetadata(e,t)}function L(e){const t=[];for(const r of e){const a=t.findIndex(o=>J(o,r));a===-1?t.push(r):t[a]=ue(t[a],r)}return t}function xe(e){return L(e)[0]}function K(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!v.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function W(e){return N(e)?e:void 0}function de(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&v.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function T(e,t){const r=W(e==null?void 0:e.source);return r?K(r,t):void 0}function fe({explicitSource:e,field:t,defaultSource:r,fallbackSources:a}){const o=[r,...a||[]],i=W(e),n=i?K(i,de(i,o)):void 0;if(n)return n;if(e!==void 0)return;const d=T(t,r),s=d?K(d,de(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return W(r)}function Ne(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=T(e),a=T(t);return!r||!a?!0:J(r,a)}function w(e){var t;return O((t=y(e))==null?void 0:t.kind)}function pe(e){var t,r;return w(e)!=="semantic"?null:((r=O((t=y(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Ee(e){var t;return w(e)!=="semantic"?null:O((t=y(e))==null?void 0:t.datasetName)}function ke(e){var t;return w(e)!=="semantic"?null:O((t=y(e))==null?void 0:t.datasetId)}function Me(e){var t;return w(e)!=="physical"?null:O((t=y(e))==null?void 0:t.connectionId)}function Le(e){var t;return w(e)!=="physical"?null:O((t=y(e))==null?void 0:t.tableName)}function Be(e){var t;return w(e)!=="physical"?"":O((t=y(e))==null?void 0:t.databaseName)||""}function Pe(e){var t;return w(e)!=="physical"?"":O((t=y(e))==null?void 0:t.schemaName)||""}function he(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function me({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(pe),a=new Set(r.filter(Boolean));return r.some(o=>!o)||a.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function q(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=ke(e);return pe(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Ee(e)===t.datasetName:!1}return t.kind==="physical"?Me(e)===t.connectionId&&Le(e)===t.tableName&&Be(e)===(t.databaseName||"")&&Pe(e)===(t.schemaName||""):!1}function Ve(e,t){return e.find(r=>q(r,t))}function h(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function V(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function ge({card:e,datasets:t,errors:r}){if(e.type==="text")return;const a=he(e);if(!a){if(t.length<=1)return;r.push(h("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>q(o,a))||r.push(h("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function $(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function H(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function le(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function $e(e){var r,a;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...$([...H(e.measures),e.primaryMeasure,e.dateField,...H(e.dimensions),...le(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...$([...H(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...le(e.filters).map(o=>o.field)])):e.kind==="inputOptions"?(((a=e.population)==null?void 0:a.kind)==="related_population"&&t.push(e.population.baseSource),t.push(...$([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...$(e.fields||[])),t}function Ie({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const a of $e(e.analyticsIntent))if(a&&!t.some(o=>q(o,a))){r.push(h("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function be({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=v.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const a of r.errors)t.push(h(a.code,a.path?`${a.path}: ${a.message}`:a.message,e.id))}function _e({datasets:e,errors:t,requireAtLeastOne:r}){const a=me({datasets:e,requireAtLeastOne:r});if(!a.ok){if(a.issue==="invalid_dataset_count"){t.push(h("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(h("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function Ce({input:e,errors:t}){var r;(r=e.filter.sql)!=null&&r.trim()&&t.push(h("generated_filter_sql_out_of_scope",`Generated dashboard filter "${e.label}" must use grounded filter configuration; custom SQL is outside the dashboard-authoring contract.`))}function De(e){var p,_;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[h("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,a=[...r.warnings||[]];r.version!==1&&t.push(h("invalid_version","Dashboard plan version must be 1.")),(p=r.title)!=null&&p.trim()||t.push(h("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],i=Array.isArray(r.sheets)?r.sheets:[];_e({datasets:o,errors:t,requireAtLeastOne:!0}),i.length!==1&&t.push(h("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const n=i[0];n&&n.kind!=="dashboard"&&t.push(h("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(n==null?void 0:n.cards)||[];d.length>u.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(h("too_many_cards",`Generated dashboards can contain at most ${u.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=V(d.map(c=>c.id));s&&t.push(h("duplicate_card_id",`Duplicate generated card id: ${s}.`));const f=V(d.map(c=>c.frameId));f&&t.push(h("duplicate_frame_id",`Duplicate generated frame id: ${f}.`));for(const c of d)(_=c.title)!=null&&_.trim()||t.push(h("missing_card_title","Card title is required.",c.id)),c.type==="custom"&&t.push(h("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",c.id)),c.type!=="text"&&!c.analyticsIntent&&a.push(h("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",c.id)),ge({card:c,datasets:o,errors:t}),be({card:c,errors:t}),Ie({card:c,datasets:o,errors:t});const g=Array.isArray(r.filterInputs)?r.filterInputs:[],D=g.map(c=>c.id),A=V(D);A&&t.push(h("duplicate_input_id",`Duplicate dashboard input id: ${A}.`));const R=g.map(c=>c.variableName).filter(Boolean)||[],S=V(R);S&&t.push(h("duplicate_input_variable",`Duplicate dashboard input variable name: ${S}.`));for(const c of g)Ce({input:c,errors:t});const l=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const c of l)c.scope==="domain"&&c.reuseOnly!==!0&&t.push(h("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${c.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:a}}function Se(e){var n;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[h("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,a=[...r.warnings||[]];r.version!==1&&t.push(h("invalid_version","Dashboard change plan version must be 1.")),(n=r.dashboardId)!=null&&n.trim()||t.push(h("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],i=Array.isArray(r.operations)?r.operations:[];_e({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of i){if(d.kind==="unsupported"){a.push(h("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(h("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(ge({card:d.card,datasets:o,errors:t}),be({card:d.card,errors:t}),Ie({card:d.card,datasets:o,errors:t})),d.kind==="addFilterInput"&&Ce({input:d.input,errors:t}),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(h("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:a}}const qe={lg:48,md:36,sm:24,xs:12,xxs:6};function Ge(e,t){let r=0,a=0,o=0;return e.map(i=>{const n=Math.min(i.w,t);r>0&&r+n>t&&(r=0,a+=o,o=0);const d={i:i.frameId,x:r,y:a,w:n,h:i.h,minW:Math.min(i.minW,t),minH:i.minH,static:!1};return r+=n,o=Math.max(o,i.h),d})}function ze(e){const t=[...e].sort((s,f)=>s.priority-f.priority),r=t.filter(s=>s.role==="kpi"),a=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),i=t.filter(s=>s.role==="text"),n=i.slice(0,1),d=i.slice(n.length);return{kpis:r,introText:n,charts:a,tables:o,supportingText:d}}function He(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function Ue(e,t,r,a){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?a:a/2}function je(e){const{item:t,band:r,index:a,bandCount:o,breakpoint:i,columns:n}=e;return r==="kpi"?{...t,band:r,w:He(o,i,n),h:15,minW:Math.min(6,n),minH:12}:r==="table"?{...t,band:r,w:n,h:i==="xxs"||i==="xs"?34:38,minW:Math.min(12,n),minH:18}:r==="introText"?{...t,band:r,w:n,h:i==="xxs"||i==="xs"?12:10,minW:Math.min(12,n),minH:8}:r==="supportingText"?{...t,band:r,w:i==="lg"?n/2:n,h:i==="xxs"||i==="xs"?12:10,minW:Math.min(12,n),minH:8}:{...t,band:r,w:Ue(a,o,i,n),h:i==="xxs"||i==="xs"?28:30,minW:Math.min(12,n),minH:16}}function k(e,t,r,a){return e.map((o,i)=>je({item:o,band:t,index:i,bandCount:e.length,breakpoint:r,columns:a}))}function G(e){const t=ze(e);return Object.fromEntries(u.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const a=qe[r],o=[...k(t.introText,"introText",r,a),...k(t.kpis,"kpi",r,a),...k(t.charts,"chart",r,a),...k(t.tables,"table",r,a),...k(t.supportingText,"supportingText",r,a)];return[r,Ge(o,a)]}))}function Ke(e){const t=v.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function We(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Xe(e){return We(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function Qe(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function Ye(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function Z(e,t){if(t===void 0)return;const r=Ke(e.dataType),a=e.operation||"in";if(Xe(t))return m.materializeFilterValueNativeDataType({definition:e,sourceValue:t,value:{...t,filterId:e.id,name:t.name||e.column,valueType:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}});if(a==="is null"||a==="is not null")return m.materializeFilterValueNativeDataType({definition:e,value:{filterId:e.id,name:e.column,operation:a,valueType:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}});const o=Array.isArray(t)?t:[t],i=r==="date"?Ye(o):Qe(o);if(i.length!==0&&!((a==="between"||a==="not between")&&i.length<2))return m.materializeFilterValueNativeDataType({definition:e,value:{filterId:e.id,name:e.column,operation:a,valueType:r,values:i,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}})}function ye(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Je(e,t,r){const a=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return a.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...a]}}function X(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Ze(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=X(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function et(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:X(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:X(e.excludeCardIds,t)}:{}}}function tt(e,t){const r={},a=[];return{inputs:(e.filterInputs||[]).flatMap((i,n)=>{const d=Ze(i.scope,t);if(d===null)return a.push(ye("filter_input_scope_empty",`Filter input "${i.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=Z(i.filter,i.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[i.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:i.id,kind:"filter",label:i.label,variableName:i.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:n},exports:["label","value","start","end","range"],filter:et(i.filter,t)}]}),warnings:a,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function rt(e){var R,S;const t=De(e.plan);if(!t.ok)throw new Error(t.errors.map(l=>l.message).join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../chunks/matrix-control-sources-BLGlb4S9.cjs"),I=require("../chunks/field-aggregations-U54X9_Rt.cjs"),v=require("../chunks/validators-CueUwVE4.cjs");require("../chunks/matrix-operation-contract-CbavkrJj.cjs");const m=require("../chunks/calculated-field-identity-Cc-RlE-0.cjs"),Fe=require("../chunks/operators-DrTQsJXv.cjs"),Q=require("../chunks/canonical-result-keys-Cb96edol.cjs"),E=require("../chunks/matrix-definition-jy7ygO6J.cjs"),Y=require("../chunks/matrix-card-BV7OPtq_.cjs");function y(e){return e&&typeof e=="object"?e:null}function O(e){return typeof e=="string"?e:null}function ce(e){var t,r,a;return!!(e&&typeof e=="object")&&(((t=y(e))==null?void 0:t.kind)==="semantic"||((r=y(e))==null?void 0:r.kind)==="physical"||((a=y(e))==null?void 0:a.kind)==="sql")}function N(e){return ce(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 J(e,t){return v.semaphorSourcesReferToSameDataset(e,t)}function ue(e,t){return v.preferSemaphorSourceMetadata(e,t)}function L(e){const t=[];for(const r of e){const a=t.findIndex(o=>J(o,r));a===-1?t.push(r):t[a]=ue(t[a],r)}return t}function xe(e){return L(e)[0]}function K(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!v.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function W(e){return N(e)?e:void 0}function de(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&v.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function T(e,t){const r=W(e==null?void 0:e.source);return r?K(r,t):void 0}function fe({explicitSource:e,field:t,defaultSource:r,fallbackSources:a}){const o=[r,...a||[]],i=W(e),n=i?K(i,de(i,o)):void 0;if(n)return n;if(e!==void 0)return;const d=T(t,r),s=d?K(d,de(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return W(r)}function Ne(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=T(e),a=T(t);return!r||!a?!0:J(r,a)}function w(e){var t;return O((t=y(e))==null?void 0:t.kind)}function pe(e){var t,r;return w(e)!=="semantic"?null:((r=O((t=y(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Ee(e){var t;return w(e)!=="semantic"?null:O((t=y(e))==null?void 0:t.datasetName)}function ke(e){var t;return w(e)!=="semantic"?null:O((t=y(e))==null?void 0:t.datasetId)}function Me(e){var t;return w(e)!=="physical"?null:O((t=y(e))==null?void 0:t.connectionId)}function Le(e){var t;return w(e)!=="physical"?null:O((t=y(e))==null?void 0:t.tableName)}function Be(e){var t;return w(e)!=="physical"?"":O((t=y(e))==null?void 0:t.databaseName)||""}function Pe(e){var t;return w(e)!=="physical"?"":O((t=y(e))==null?void 0:t.schemaName)||""}function he(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function me({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(pe),a=new Set(r.filter(Boolean));return r.some(o=>!o)||a.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function q(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=ke(e);return pe(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Ee(e)===t.datasetName:!1}return t.kind==="physical"?Me(e)===t.connectionId&&Le(e)===t.tableName&&Be(e)===(t.databaseName||"")&&Pe(e)===(t.schemaName||""):!1}function Ve(e,t){return e.find(r=>q(r,t))}function h(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function V(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function ge({card:e,datasets:t,errors:r}){if(e.type==="text")return;const a=he(e);if(!a){if(t.length<=1)return;r.push(h("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>q(o,a))||r.push(h("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function $(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function H(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function le(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function $e(e){var r,a;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...$([...H(e.measures),e.primaryMeasure,e.dateField,...H(e.dimensions),...le(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...$([...H(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...le(e.filters).map(o=>o.field)])):e.kind==="inputOptions"?(((a=e.population)==null?void 0:a.kind)==="related_population"&&t.push(e.population.baseSource),t.push(...$([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...$(e.fields||[])),t}function Ie({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const a of $e(e.analyticsIntent))if(a&&!t.some(o=>q(o,a))){r.push(h("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function be({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=v.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const a of r.errors)t.push(h(a.code,a.path?`${a.path}: ${a.message}`:a.message,e.id))}function _e({datasets:e,errors:t,requireAtLeastOne:r}){const a=me({datasets:e,requireAtLeastOne:r});if(!a.ok){if(a.issue==="invalid_dataset_count"){t.push(h("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(h("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function Ce({input:e,errors:t}){var r;(r=e.filter.sql)!=null&&r.trim()&&t.push(h("generated_filter_sql_out_of_scope",`Generated dashboard filter "${e.label}" must use grounded filter configuration; custom SQL is outside the dashboard-authoring contract.`))}function De(e){var p,_;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[h("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,a=[...r.warnings||[]];r.version!==1&&t.push(h("invalid_version","Dashboard plan version must be 1.")),(p=r.title)!=null&&p.trim()||t.push(h("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],i=Array.isArray(r.sheets)?r.sheets:[];_e({datasets:o,errors:t,requireAtLeastOne:!0}),i.length!==1&&t.push(h("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const n=i[0];n&&n.kind!=="dashboard"&&t.push(h("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(n==null?void 0:n.cards)||[];d.length>u.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(h("too_many_cards",`Generated dashboards can contain at most ${u.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=V(d.map(c=>c.id));s&&t.push(h("duplicate_card_id",`Duplicate generated card id: ${s}.`));const f=V(d.map(c=>c.frameId));f&&t.push(h("duplicate_frame_id",`Duplicate generated frame id: ${f}.`));for(const c of d)(_=c.title)!=null&&_.trim()||t.push(h("missing_card_title","Card title is required.",c.id)),c.type==="custom"&&t.push(h("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",c.id)),c.type!=="text"&&!c.analyticsIntent&&a.push(h("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",c.id)),ge({card:c,datasets:o,errors:t}),be({card:c,errors:t}),Ie({card:c,datasets:o,errors:t});const g=Array.isArray(r.filterInputs)?r.filterInputs:[],D=g.map(c=>c.id),A=V(D);A&&t.push(h("duplicate_input_id",`Duplicate dashboard input id: ${A}.`));const R=g.map(c=>c.variableName).filter(Boolean)||[],S=V(R);S&&t.push(h("duplicate_input_variable",`Duplicate dashboard input variable name: ${S}.`));for(const c of g)Ce({input:c,errors:t});const l=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const c of l)c.scope==="domain"&&c.reuseOnly!==!0&&t.push(h("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${c.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:a}}function Se(e){var n;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[h("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,a=[...r.warnings||[]];r.version!==1&&t.push(h("invalid_version","Dashboard change plan version must be 1.")),(n=r.dashboardId)!=null&&n.trim()||t.push(h("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],i=Array.isArray(r.operations)?r.operations:[];_e({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of i){if(d.kind==="unsupported"){a.push(h("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(h("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(ge({card:d.card,datasets:o,errors:t}),be({card:d.card,errors:t}),Ie({card:d.card,datasets:o,errors:t})),d.kind==="addFilterInput"&&Ce({input:d.input,errors:t}),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(h("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:a}}const qe={lg:48,md:36,sm:24,xs:12,xxs:6};function Ge(e,t){let r=0,a=0,o=0;return e.map(i=>{const n=Math.min(i.w,t);r>0&&r+n>t&&(r=0,a+=o,o=0);const d={i:i.frameId,x:r,y:a,w:n,h:i.h,minW:Math.min(i.minW,t),minH:i.minH,static:!1};return r+=n,o=Math.max(o,i.h),d})}function ze(e){const t=[...e].sort((s,f)=>s.priority-f.priority),r=t.filter(s=>s.role==="kpi"),a=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),i=t.filter(s=>s.role==="text"),n=i.slice(0,1),d=i.slice(n.length);return{kpis:r,introText:n,charts:a,tables:o,supportingText:d}}function He(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function Ue(e,t,r,a){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?a:a/2}function je(e){const{item:t,band:r,index:a,bandCount:o,breakpoint:i,columns:n}=e;return r==="kpi"?{...t,band:r,w:He(o,i,n),h:15,minW:Math.min(6,n),minH:12}:r==="table"?{...t,band:r,w:n,h:i==="xxs"||i==="xs"?34:38,minW:Math.min(12,n),minH:18}:r==="introText"?{...t,band:r,w:n,h:i==="xxs"||i==="xs"?12:10,minW:Math.min(12,n),minH:8}:r==="supportingText"?{...t,band:r,w:i==="lg"?n/2:n,h:i==="xxs"||i==="xs"?12:10,minW:Math.min(12,n),minH:8}:{...t,band:r,w:Ue(a,o,i,n),h:i==="xxs"||i==="xs"?28:30,minW:Math.min(12,n),minH:16}}function k(e,t,r,a){return e.map((o,i)=>je({item:o,band:t,index:i,bandCount:e.length,breakpoint:r,columns:a}))}function G(e){const t=ze(e);return Object.fromEntries(u.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const a=qe[r],o=[...k(t.introText,"introText",r,a),...k(t.kpis,"kpi",r,a),...k(t.charts,"chart",r,a),...k(t.tables,"table",r,a),...k(t.supportingText,"supportingText",r,a)];return[r,Ge(o,a)]}))}function Ke(e){const t=v.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function We(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Xe(e){return We(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function Qe(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function Ye(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function Z(e,t){if(t===void 0)return;const r=Ke(e.dataType),a=e.operation||"in";if(Xe(t))return m.materializeFilterValueNativeDataType({definition:e,sourceValue:t,value:{...t,filterId:e.id,name:t.name||e.column,valueType:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}});if(a==="is null"||a==="is not null")return m.materializeFilterValueNativeDataType({definition:e,value:{filterId:e.id,name:e.column,operation:a,valueType:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}});const o=Array.isArray(t)?t:[t],i=r==="date"?Ye(o):Qe(o);if(i.length!==0&&!((a==="between"||a==="not between")&&i.length<2))return m.materializeFilterValueNativeDataType({definition:e,value:{filterId:e.id,name:e.column,operation:a,valueType:r,values:i,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}})}function ye(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Je(e,t,r){const a=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return a.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...a]}}function X(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Ze(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=X(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function et(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:X(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:X(e.excludeCardIds,t)}:{}}}function tt(e,t){const r={},a=[];return{inputs:(e.filterInputs||[]).flatMap((i,n)=>{const d=Ze(i.scope,t);if(d===null)return a.push(ye("filter_input_scope_empty",`Filter input "${i.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=Z(i.filter,i.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[i.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:i.id,kind:"filter",label:i.label,variableName:i.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:n},exports:["label","value","start","end","range"],filter:et(i.filter,t)}]}),warnings:a,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function rt(e){var R,S;const t=De(e.plan);if(!t.ok)throw new Error(t.errors.map(l=>l.message).join(`
2
2
  `)||"Dashboard plan is invalid.");const r=e.plan.sheets[0],a=[...t.warnings],o=[],i=new Map(e.cardArtifacts.map(l=>[l.planCardId,l])),n=new Map(e.cardArtifacts.map(l=>[l.planCardId,l.card.id])),d=[];for(const l of r.cards){const p=i.get(l.id);if(!p){const c=ye("missing_card_artifact",`Card "${l.title}" was skipped because no generated artifact was supplied.`,l.id);o.push(c);continue}a.push(...p.warnings||[]);const _=Je(p.card,e.plan.calculatedFields,l.id);d.push({id:l.frameId,cards:[_],activeCardId:_.id})}if(d.length===0)throw new Error("Dashboard plan did not produce any persistable cards.");const{inputs:s,defaultInputValues:f,warnings:g}=tt(e.plan,n);a.push(...g);const D=G(r.cards.filter(l=>d.some(p=>p.id===l.frameId)).map(l=>({frameId:l.frameId,priority:l.priority,role:l.role})));return{dashboard:{id:e.dashboardId,title:e.plan.title,description:e.plan.description||"",sheets:[{id:r.id,kind:"dashboard",title:r.title,description:r.description,frames:d,layouts:D,calculatedFields:(R=e.plan.calculatedFields)==null?void 0:R.filter(l=>l.scope==="sheet"&&l.field).map(l=>l.field)}],calculatedFields:(S=e.plan.calculatedFields)==null?void 0:S.filter(l=>l.scope==="dashboard"&&l.field).map(l=>l.field),inputs:s,...f?{defaultInputValues:f}:{}},warnings:a,skippedOperations:o}}function x(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function at(e){return JSON.parse(JSON.stringify(e))}function nt(e){var t;return(t=e.sheets)==null?void 0:t.find(r=>(r.kind||"dashboard")==="dashboard")}function U(e,t){var r;for(const a of e.sheets||[])for(const o of a.frames||[]){const i=(r=o.cards)==null?void 0:r.find(n=>n.id===t);if(i)return{sheet:a,frame:o,card:i}}return null}function Ae(e){var r,a;const t=(a=(r=e.cards)==null?void 0:r[0])==null?void 0:a.type;return t==="kpi"?"kpi":t==="table"||t==="detailTable"||t==="pivotTable"?"table":t==="text"?"text":"chart"}function it(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((r,a)=>[r.i,a]))}function Re(e,t=new Map){const r=it(e),a=Math.max(r.size,t.size),o=(e.frames||[]).map((i,n)=>({frameId:i.id,role:Ae(i),priority:t.get(i.id)??r.get(i.id)??a+n}));e.layouts=G(o)}function ot(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function st(e,t){if(!ot(e)){Re(e);return}const r=G([{frameId:t.id,role:Ae(t),priority:0}]);e.layouts??(e.layouts={});for(const[a,o]of Object.entries(r)){const i=e.layouts[a]||[];if(i.some(s=>s.i===t.id))continue;const n=o[0];if(!n)continue;const d=i.reduce((s,f)=>Math.max(s,f.y+f.h),0);e.layouts[a]=[...i,{...n,y:d}]}}function dt(e,t){var a;const r=Z(t.filter,t.defaultValue);r&&(e.defaultInputValues??(e.defaultInputValues={}),(a=e.defaultInputValues).shared??(a.shared={}),e.defaultInputValues.shared[t.id]={status:"set",value:{kind:"filter",filterValue:r}})}function lt(e){var d;const t=Se(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
3
3
  `)||"Dashboard change plan is invalid.");const r=at(e.dashboard),a=[...t.warnings],o=[],i=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),n=nt(r);if(!n)throw new Error("Dashboard has no editable dashboard sheet.");n.frames??(n.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((n.frames||[]).reduce((A,R)=>{var S;return A+(((S=R.cards)==null?void 0:S.length)||0)},0)>=u.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(x("generated_card_limit_reached",`AI refinement is capped at ${u.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`,s.card.id));break}const g=i.get(s.card.id);if(!g){o.push(x("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const D={id:s.card.frameId,cards:[g.card],activeCardId:g.card.id};n.frames.push(D),st(n,D);break}case"addFilterInput":{r.inputs??(r.inputs=[]);const f={id:s.input.id,kind:"filter",label:s.input.label,variableName:s.input.variableName,scope:s.input.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:r.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};r.inputs.push(f),dt(r,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)r.calculatedFields??(r.calculatedFields=[]),r.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)n.calculatedFields??(n.calculatedFields=[]),n.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const f=s.field.targetCardId?U(r,s.field.targetCardId):null;f?((d=f.card).calculatedFields??(d.calculatedFields=[]),f.card.calculatedFields.push(s.field.field)):o.push(x("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const f=U(r,s.cardId);if(!f){o.push(x("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}f.card.title=s.title,s.description!==void 0&&(f.card.description=s.description);break}case"reorderCards":{const f=new Map;for(let g=0;g<s.cardIds.length;g+=1){const D=s.cardIds[g],A=U(r,D);A&&f.set(A.frame.id,g)}Re(n,f);break}case"reuseCalculatedField":a.push(x("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":o.push(x("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:r,warnings:a,skippedOperations:o}}function C(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function M(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function Te(e,t){if(!t.has(e))return t.add(e),e;let r=2,a=`${e}-${r}`;for(;t.has(a);)r+=1,a=`${e}-${r}`;return t.add(a),a}function B(e){return!!(e&&typeof e=="object")}function ve(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>B(t)&&typeof t.id=="string"):[]}function ee(e){return Array.isArray(e.sections)?e.sections.filter(t=>B(t)):[]}function te(e){return Array.isArray(e.views)?e.views.filter(t=>B(t)):[]}function F(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const a=T(r);a&&t.push(a)}return t}function ct(e){var a,o,i;if(!e)return[];const t=[];if(N(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...F(e.measures));const n=T(e.dateField);n&&t.push(n),t.push(...F(e.dimensions)),t.push(...F((a=e.filters)==null?void 0:a.map(d=>d.field)))}else if(e.kind==="records"){const n=T(e.dateField);n&&t.push(n),t.push(...F(e.fields)),t.push(...F((o=e.filters)==null?void 0:o.map(d=>d.field)))}else e.kind==="inputOptions"?(((i=e.population)==null?void 0:i.kind)==="related_population"&&N(e.population.baseSource)&&t.push(e.population.baseSource),t.push(...F([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(n=>!!n)))):e.kind==="sql"&&t.push(...F(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const n of r){const d=T(n.field);d&&t.push(d)}return t}function ut(e){const t=[];for(const r of ve(e)){const a=T(r.field);a&&t.push(a)}for(const r of ee(e))for(const a of te(r))t.push(...ct(a.analytics));return t}function ft(e){var r;const t=[];for(const a of ee(e))for(const o of te(a))N((r=o.analytics)==null?void 0:r.source)&&t.push(o.analytics.source);return t}function pt(e,t){const r=L(e).filter(N);if(r.length===0)return t.push(C("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const a=r.every(i=>i.kind==="semantic"),o=Array.from(new Set(r.filter(i=>i.kind==="semantic").map(i=>i.domainId)));return r.length>1&&(!a||o.length!==1)?(t.push(C("multiple_datasets_out_of_scope","The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest.")),[r[0]]):r}function ht(e,t){const r=ee(e),a=ve(e),o=L(ut(e)),i=L(ft(e));return{sections:r,inputs:a,sources:o,primarySources:i,defaultSource:i.length===1?i[0]:void 0,datasets:pt(o,t)}}function mt(e){return e&&v.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function gt(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 It(e){var t,r,a;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((r=e.presentation)==null?void 0:r.kind)==="table"?"table":((a=e.presentation)==null?void 0:a.kind)==="text"?"text":"chart"}function bt(e){const t=Fe.normalizeSemaphorInputOperator(e);switch(t){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";case"not_contains":return"not like";default:return t||"in"}}function _t(e){return B(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function Ct(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function Dt(e,t,r,a,o,i){if(e.kind!=="filter")return i.push(C("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!B(e.field)||typeof e.field.name!="string")return i.push(C("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const n=fe({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:r}),d=(n==null?void 0:n.kind)==="semantic"||(n==null?void 0:n.kind)==="physical"?n.connectionId:void 0;if(!d)return i.push(C("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const g={id:`filter-${Te(M(e.id,e.field.name),o)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:_t(e),qualifiedTableName:Ct(n),sql:"",operation:bt(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(n==null?void 0:n.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(n==null?void 0:n.kind)==="semantic"?{semanticDomainId:n.domainId,connectionId:n.connectionId}:(n==null?void 0:n.kind)==="physical"?{connectionId:n.connectionId,connectionType:n.connectionType,selectedEntities:[{type:"table",connectionId:n.connectionId,connectionType:n.connectionType,dialect:n.dialect,database:n.databaseName,schema:n.schemaName,name:n.tableName}]}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:a,filter:g,defaultValue:Z(g,e.defaultValue)}}function j(e){const t=[],r=[];for(const a of e.viewIds){const o=e.viewIdToCardId.get(a);o?t.push(o):r.push(a)}return r.length>0&&e.warnings.push(C("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${r.join(", ")}.`)),Array.from(new Set(t))}function St(e){var a,o;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(!((a=e.protocolScope.excludeViewIds)!=null&&a.length))return;const i=new Set(j({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(n=>!i.has(n))}}if(e.protocolScope.level==="view"){const i=j({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return i.length===0?(e.warnings.push(C("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(C("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((o=e.protocolScope.excludeViewIds)!=null&&o.length))return{kind:"cards",cardIds:t};const r=new Set(j({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(i=>!r.has(i))}}function yt(e){var R,S,l;const t=[],r=v.validateSemaphorDashboardIntent(e);for(const p of r.warnings)t.push(C(p.code,p.message));for(const p of r.errors)t.push(C(p.code,p.message));const a=ht(e,t),o=[],i=new Map,n=new Map,d=new Map,s=new Set,f=new Set;let g=0;for(const[p,_]of a.sections.entries()){const c=typeof _.title=="string"?_.title:`Section ${p+1}`,re=_.id||M(c,`section-${p+1}`);n.set(re,[]);for(const[ae,b]of te(_).entries()){const ne=gt(b),z=M(b.id||`${c}-${b.title||`View ${ae+1}`}`,`card-${p+1}-${ae+1}`);if(!ne){t.push(C("unsupported_presentation",`Dashboard presentation "${((R=b.presentation)==null?void 0:R.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${z}`));continue}if(((S=b.analytics)==null?void 0:S.kind)==="sql"){t.push(C("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${z}`));continue}const ie=Te(z,s),P=`card-${ie}`;b.id&&i.set(b.id,P),(l=n.get(re))==null||l.push(P);const Oe=b.analytics&&"inputs"in b.analytics?b.analytics.inputs:void 0;for(const oe of Oe||[]){const se=d.get(oe.inputId)||[];se.push(P),d.set(oe.inputId,se)}o.push({id:P,frameId:`frame-${ie}`,title:b.title,description:b.description,type:ne,role:It(b),priority:g,section:c,analyticsIntent:mt(b.analytics),text:b.text}),g+=1}}const D=a.inputs.map(p=>{const _=St({protocolScope:p.scope,inputLabel:p.label,allCardIds:o.map(c=>c.id),boundCardIds:d.get(p.id)||[],viewIdToCardId:i,sectionIdToCardIds:n,warnings:t});return _===null?null:Dt(p,a.defaultSource,a.sources,_,f,t)}).filter(p=>!!p);return{plan:{version:1,id:`plan-${M(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:a.datasets,sheets:[{id:`sheet-${M(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:o}],filterInputs:D.length?D:void 0,warnings:t.length?t:void 0,unresolvedRequests:r.ok?void 0:r.errors.map(p=>p.message)},warnings:t}}exports.CONTROL_BINDING_MAPPING_MISSING_ERROR_CODE=u.CONTROL_BINDING_MAPPING_MISSING_ERROR_CODE;exports.CONTROL_BINDING_TARGET_INVALID_ERROR_CODE=u.CONTROL_BINDING_TARGET_INVALID_ERROR_CODE;exports.CONTROL_BINDING_VALUE_INVALID_ERROR_CODE=u.CONTROL_BINDING_VALUE_INVALID_ERROR_CODE;exports.CONTROL_CONTEXT_UNSUPPORTED_ERROR_CODE=u.CONTROL_CONTEXT_UNSUPPORTED_ERROR_CODE;exports.CONTROL_DEFINITION_DUPLICATE_ERROR_CODE=u.CONTROL_DEFINITION_DUPLICATE_ERROR_CODE;exports.CONTROL_DEFINITION_INVALID_ERROR_CODE=u.CONTROL_DEFINITION_INVALID_ERROR_CODE;exports.CONTROL_PLACEHOLDER_QUOTED_ERROR_CODE=u.CONTROL_PLACEHOLDER_QUOTED_ERROR_CODE;exports.CONTROL_REFERENCE_MISSING_ERROR_CODE=u.CONTROL_REFERENCE_MISSING_ERROR_CODE;exports.CONTROL_VALUE_INVALID_ERROR_CODE=u.CONTROL_VALUE_INVALID_ERROR_CODE;exports.CONTROL_VALUE_MISSING_ERROR_CODE=u.CONTROL_VALUE_MISSING_ERROR_CODE;exports.ControlResolutionError=u.ControlResolutionError;exports.DASHBOARD_AUTHORING_BREAKPOINTS=u.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=u.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.buildControlDefinitionIndex=u.buildControlDefinitionIndex;exports.getColumnCatalogFieldId=u.getColumnCatalogFieldId;exports.matrixCatalogSources=u.matrixCatalogSources;exports.matrixExecutionSources=u.matrixExecutionSources;exports.resolveBindingControlValue=u.resolveBindingControlValue;exports.resolveGroupByFieldTarget=u.resolveGroupByFieldTarget;exports.resolveMatrixControlBindings=u.resolveMatrixControlBindings;exports.resolveMetricFieldTarget=u.resolveMetricFieldTarget;exports.resolveScalarMappedValue=u.resolveScalarMappedValue;exports.validateControlValue=u.validateControlValue;exports.AUTOMATIC_TEMPORAL_BUCKET_FORMAT=I.AUTOMATIC_TEMPORAL_BUCKET_FORMAT;exports.SEMAPHOR_CARTESIAN_CHART_TYPES=I.SEMAPHOR_CARTESIAN_CHART_TYPES;exports.buildDashboardCardSourceIndex=I.buildDashboardCardSourceIndex;exports.dashboardCardFilterSourceInventoryContains=I.dashboardCardFilterSourceInventoryContains;exports.findDashboardCardExecutableSource=I.findDashboardCardExecutableSource;exports.findDashboardCardPinnedCatalogSource=I.findDashboardCardPinnedCatalogSource;exports.findDashboardSqlPinnedCatalogSource=I.findDashboardSqlPinnedCatalogSource;exports.getFieldAggregationOptions=I.getFieldAggregationOptions;exports.getTemporalBucketAuthoringOptions=I.getTemporalBucketAuthoringOptions;exports.getTemporalBucketAuthoringSelection=I.getTemporalBucketAuthoringSelection;exports.isSemaphorCartesianChartType=I.isSemaphorCartesianChartType;exports.previewTemporalBucketAuthoringFormat=I.previewTemporalBucketAuthoringFormat;exports.reconcileTemporalBucketAuthoringFormat=I.reconcileTemporalBucketAuthoringFormat;exports.resolveDashboardEntitySource=I.resolveDashboardEntitySource;exports.resolveTemporalBucketAuthoringFormat=I.resolveTemporalBucketAuthoringFormat;exports.resolveTemporalResultOwner=I.resolveTemporalResultOwner;exports.supportsCanonicalDashboardTemporalResult=I.supportsCanonicalDashboardTemporalResult;exports.transformComparisonDocument=I.transformComparisonDocument;exports.DashboardFilterMappingContractError=m.DashboardFilterMappingContractError;exports.applyCardReferenceRemapping=m.applyCardReferenceRemapping;exports.composeCardReferenceRemapping=m.composeCardReferenceRemapping;exports.createDashboardFilterBindingId=m.createDashboardFilterBindingId;exports.dashboardFilterTargetMatchesLogicalValue=m.dashboardFilterTargetMatchesLogicalValue;exports.dashboardFilterValueTypeForDataType=m.dashboardFilterValueTypeForDataType;exports.getCalculatedFieldNamespace=m.getCalculatedFieldNamespace;exports.getDashboardFilterSubscriptionHint=m.getDashboardFilterSubscriptionHint;exports.getMatrixBindingTargets=m.getMatrixBindingTargets;exports.getStableDomainCalculatedFieldId=m.getStableDomainCalculatedFieldId;exports.hasDashboardFilterSubscription=m.hasDashboardFilterSubscription;exports.isDashboardFilterOperationCompatible=m.isDashboardFilterOperationCompatible;exports.moveMatrixLevel=m.moveMatrixLevel;exports.normalizeDashboardInputs=m.normalizeDashboardInputs;exports.reconcileMatrixSpecStructure=m.reconcileMatrixSpecStructure;exports.requireNormalizedDashboardInputs=m.requireNormalizedDashboardInputs;exports.resolveDashboardFilterAutomaticTarget=m.resolveDashboardFilterAutomaticTarget;exports.resolveDashboardFilterInheritedTarget=m.resolveDashboardFilterInheritedTarget;exports.resolveDashboardSqlFilterTarget=m.resolveDashboardSqlFilterTarget;exports.retainMatrixConditionalFormatting=m.retainMatrixConditionalFormatting;exports.updateMatrixConfig=m.updateMatrixConfig;exports.resolveCanonicalDetailResultRawKey=Q.resolveCanonicalDetailResultRawKey;exports.resolveCanonicalResultOutputKey=Q.resolveCanonicalResultOutputKey;exports.resolveCanonicalResultRawKey=Q.resolveCanonicalResultRawKey;exports.createMatrixAuthoringDraft=E.createMatrixAuthoringDraft;exports.createMatrixConfig=E.createMatrixConfig;exports.getMatrixLevelLabel=E.getMatrixLevelLabel;exports.getMatrixMeasureLabel=E.getMatrixMeasureLabel;exports.mergeMatrixSorts=E.mergeMatrixSorts;exports.resolveMatrixDefinition=E.resolveMatrixDefinition;exports.matrixDefinitionFields=Y.matrixDefinitionFields;exports.matrixDefinitionSources=Y.matrixDefinitionSources;exports.readMatrixCardConfig=Y.readMatrixCardConfig;exports.applyDashboardChangePlan=lt;exports.compileDashboardFromPlan=rt;exports.compileResponsiveDashboardLayouts=G;exports.dashboardAuthoringDatasetMatchesSource=q;exports.dashboardAuthoringFieldsReferToSameTarget=Ne;exports.dashboardAuthoringSourceFromField=T;exports.dashboardAuthoringSourceKey=we;exports.dashboardAuthoringSourcesReferToSameDataset=J;exports.dashboardPlanFromSemaphorDashboardIntent=yt;exports.findDashboardAuthoringDatasetForSource=Ve;exports.getDashboardAuthoringCardSource=he;exports.isMaterializableDashboardAuthoringSource=N;exports.isSemaphorSourceRef=ce;exports.mergeDashboardAuthoringSources=L;exports.preferDashboardAuthoringSourceMetadata=ue;exports.preferredDashboardAuthoringSource=xe;exports.resolveDashboardAuthoringSource=fe;exports.validateDashboardAuthoringDatasetScope=me;exports.validateDashboardChangePlan=Se;exports.validateDashboardPlan=De;
@@ -1,14 +1,14 @@
1
- import { D as E, a as _e } from "../chunks/matrix-control-sources-DxjWV8ry.js";
2
- import { j as Nt, k as Mt, l as Et, f as $t, h as Lt, i as Bt, C as Pt, c as Vt, e as qt, d as zt, n as jt, o as Gt, g as Ht, m as Ut, b as Wt, r as Kt, q as Qt, t as Xt, s as Yt, p as Jt, v as Zt } from "../chunks/matrix-control-sources-DxjWV8ry.js";
3
- import { A as ta, S as aa, f as ra, h as na, j as ia, k as oa, l as sa, g as da, a as ca, b as la, i as ua, p as fa, d as pa, e as ha, c as ma, r as ga, s as ba, t as Ia } from "../chunks/field-aggregations-J7de9KZm.js";
4
- import { l as ye, aO as H, aP as Ce, a2 as ie, aa as ve, a5 as Se } from "../chunks/validators-BpJDwDnG.js";
5
- import "../chunks/matrix-operation-contract-D5I-t3i7.js";
6
- import { m as B } from "../chunks/calculated-field-identity-CSabKrXt.js";
7
- import { D as ya, p as Ca, o as va, j as Sa, d as Da, k as wa, t as xa, e as Ta, g as Aa, v as Fa, h as ka, l as Ra, q as Oa, n as Na, r as Ma, i as Ea, a as $a, b as La, f as Ba, s as Pa, u as Va } from "../chunks/calculated-field-identity-CSabKrXt.js";
1
+ import { D as E, a as _e } from "../chunks/matrix-control-sources-DYMzccBY.js";
2
+ import { j as Nt, k as Mt, l as Et, f as $t, h as Lt, i as Bt, C as Pt, c as Vt, e as qt, d as zt, n as jt, o as Gt, g as Ht, m as Ut, b as Wt, r as Kt, q as Qt, t as Xt, s as Yt, p as Jt, v as Zt } from "../chunks/matrix-control-sources-DYMzccBY.js";
3
+ import { A as ta, S as aa, f as ra, h as na, j as ia, k as oa, l as sa, g as da, a as ca, b as la, i as ua, p as fa, d as pa, e as ha, c as ma, r as ga, s as ba, t as Ia } from "../chunks/field-aggregations-Cy4hBBqe.js";
4
+ import { l as ye, aO as H, aP as Ce, a2 as ie, aa as ve, a5 as Se } from "../chunks/validators-DgmJaRF4.js";
5
+ import "../chunks/matrix-operation-contract-4q53iAUW.js";
6
+ import { m as B } from "../chunks/calculated-field-identity-D7ygZ7oN.js";
7
+ import { D as ya, p as Ca, o as va, j as Sa, d as Da, k as wa, t as xa, e as Ta, g as Aa, v as Fa, h as ka, l as Ra, q as Oa, n as Na, r as Ma, i as Ea, a as $a, b as La, f as Ba, s as Pa, u as Va } from "../chunks/calculated-field-identity-D7ygZ7oN.js";
8
8
  import { n as De } from "../chunks/operators-C8TxpM4C.js";
9
9
  import { a as za, b as ja, r as Ga } from "../chunks/canonical-result-keys-CEQefvdO.js";
10
- import { b as Ua, c as Wa, g as Ka, a as Qa, m as Xa, r as Ya } from "../chunks/matrix-definition-BcJi7qGZ.js";
11
- import { m as Za, a as er, r as tr } from "../chunks/matrix-card-5R39CCdj.js";
10
+ import { b as Ua, c as Wa, g as Ka, a as Qa, m as Xa, r as Ya } from "../chunks/matrix-definition-Djesv_9v.js";
11
+ import { m as Za, a as er, r as tr } from "../chunks/matrix-card-CxTCV9HF.js";
12
12
  function y(e) {
13
13
  return e && typeof e == "object" ? e : null;
14
14
  }
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),An=require("react-dom/client"),k=require("../chunks/index-DXQsuuMQ.cjs"),w=require("../chunks/switch-CatLIoK-.cjs"),Ze=require("../data-app-builder-browser-runtime/index.cjs"),te=require("../chunks/x-B6ghREd2.cjs"),Cn=require("../chunks/save-3dYRmehL.cjs"),Rn=require("../chunks/mouse-pointer-2-DX4A_XZw.cjs"),tt=require("../chunks/search-BqqhaMx9.cjs");function Tr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const d=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,d.get?d:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const Bn=Tr(p),Dn=Tr(An);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),An=require("react-dom/client"),k=require("../chunks/index-a9nBmD-v.cjs"),w=require("../chunks/switch-COujiMcB.cjs"),Ze=require("../data-app-builder-browser-runtime/index.cjs"),te=require("../chunks/x-B6ghREd2.cjs"),Cn=require("../chunks/save-3dYRmehL.cjs"),Rn=require("../chunks/mouse-pointer-2-DX4A_XZw.cjs"),tt=require("../chunks/search-BqqhaMx9.cjs");function Tr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const d=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,d.get?d:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const Bn=Tr(p),Dn=Tr(An);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -2,8 +2,8 @@ import { jsx as r, jsxs as c, Fragment as re } from "react/jsx-runtime";
2
2
  import * as Zn from "react";
3
3
  import { useContext as qn, useState as x, useRef as oe, useMemo as je, useEffect as W, useCallback as Ot } from "react";
4
4
  import * as Xn from "react-dom/client";
5
- import { aK as ea, aL as ta, aM as Ir, aN as jr, aO as zr, aP as ra, aQ as Wr, aR as Hr, aS as Jr, aT as Vr, aU as _r, aV as Ur, aW as Kr, aX as na, aY as aa, aZ as oa, a_ as Ht, a$ as on, R as Gr, b0 as sa, b1 as Vt, b2 as sn, b3 as ia, b4 as la } from "../chunks/index-CPWfCksu.js";
6
- import { B as H, P as it, a as lt, b as dt, _ as da, $ as ca, a0 as ua, a1 as pa, a2 as ha, L as me, R as ma, d as _t } from "../chunks/switch-DHOv6xHT.js";
5
+ import { aK as ea, aL as ta, aM as Ir, aN as jr, aO as zr, aP as ra, aQ as Wr, aR as Hr, aS as Jr, aT as Vr, aU as _r, aV as Ur, aW as Kr, aX as na, aY as aa, aZ as oa, a_ as Ht, a$ as on, R as Gr, b0 as sa, b1 as Vt, b2 as sn, b3 as ia, b4 as la } from "../chunks/index-Ne0-ePdz.js";
6
+ import { B as H, P as it, a as lt, b as dt, _ as da, $ as ca, a0 as ua, a1 as pa, a2 as ha, L as me, R as ma, d as _t } from "../chunks/switch-BmCGBb2F.js";
7
7
  import { loadSemaphorBrowserRuntime as ot } from "../data-app-builder-browser-runtime/index.js";
8
8
  import { c as Ve, X as He } from "../chunks/x-CXDkqdur.js";
9
9
  import { S as fa } from "../chunks/save-DgMfP0j8.js";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/matrix-operation-contract-BiUMcd6G.cjs"),e=require("../chunks/update-policy-BP_2uCgs.cjs");exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=a.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=a.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=e.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=e.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=e.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=e.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=e.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=e.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=e.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=e.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=e.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=e.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=e.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=e.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=e.validateCodegenSummary;exports.validateSemaphorGeneratedContract=e.validateSemaphorGeneratedContract;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/matrix-operation-contract-CbavkrJj.cjs"),e=require("../chunks/update-policy-CtLb9ish.cjs");exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=a.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=a.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=e.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=e.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=e.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=e.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=e.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=e.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=e.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=e.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=e.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=e.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=e.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=e.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=e.validateCodegenSummary;exports.validateSemaphorGeneratedContract=e.validateSemaphorGeneratedContract;
@@ -1,5 +1,5 @@
1
- import { S as E, a as S, i as A, v as t } from "../chunks/matrix-operation-contract-D5I-t3i7.js";
2
- import { C as R, a as r, b as s, G as C, e as o, R as p, c as d, f as O, g as i, h as m, i as n, j as N, v as T, d as I } from "../chunks/update-policy-D3I1J2kl.js";
1
+ import { S as E, a as S, i as A, v as t } from "../chunks/matrix-operation-contract-4q53iAUW.js";
2
+ import { C as R, a as r, b as s, G as C, e as o, R as p, c as d, f as O, g as i, h as m, i as n, j as N, v as T, d as I } from "../chunks/update-policy-BoB26XrS.js";
3
3
  export {
4
4
  R as CODEGEN_SUMMARY_SCHEMA_VERSION,
5
5
  r as CODEGEN_SUMMARY_VALIDATOR_VERSION,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("../chunks/matrix-operation-contract-BiUMcd6G.cjs"),R=require("../chunks/update-policy-BP_2uCgs.cjs"),he=require("node:crypto"),Ce="src/semaphor/generated",H=`// Generated by Semaphor Agent Plugin. Do not hand-edit analytics wiring here.
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("../chunks/matrix-operation-contract-CbavkrJj.cjs"),R=require("../chunks/update-policy-CtLb9ish.cjs"),he=require("node:crypto"),Ce="src/semaphor/generated",H=`// Generated by Semaphor Agent Plugin. Do not hand-edit analytics wiring here.
2
2
  // Regenerate from the accepted semaphor_plan_data_app codegenSummary when the plan changes.
3
3
  `;function Oe(e,n={}){R.assertValidCodegenSummary(e);const r=Me(e);if(r.views.length===0&&!n.allowEmpty)throw new Error("Contract generation produced zero executable views. Stop and ask for a different domain/goal or semantic model improvement; pass --allow-empty only for an explicit model-gap report.");const t=ke(r),o=Ne({contract:r,files:t,generatorName:n.generatorName||"react-semaphor/data-app-codegen/node",generatorVersion:n.generatorVersion||"unknown"}),a={...t,"contract.manifest.json":`${JSON.stringify(o,null,2)}
4
4
  `};return{schemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,files:a,manifest:o,contentHash:String(o.generatedContentHash||""),usageExample:Te(r),warnings:r.warnings,stats:{inputCount:r.inputs.length,executableViewCount:r.views.length,presentationViewCount:r.presentationViews.length,queryCount:r.views.length,optionQueryCount:r.optionQueries.length}}}function Me(e){var d,p,m,i,l,g,h,I,$,M,b,E;const n=[],r=[];for(const s of e.inputs){S(r,s.fieldRef);for(const V of s.bindings||[])S(r,V.fieldRef);S(r,(d=s.optionQuery)==null?void 0:d.valueFieldRef),S(r,(p=s.optionQuery)==null?void 0:p.labelFieldRef),S(r,(m=s.optionQuery)==null?void 0:m.filterFieldRef),D(r,(i=s.optionQuery)==null?void 0:i.spec)}for(const s of e.filterContracts){S(r,s.fieldRef),S(r,(l=s.optionQuery)==null?void 0:l.valueFieldRef),S(r,(g=s.optionQuery)==null?void 0:g.labelFieldRef),S(r,(h=s.optionQuery)==null?void 0:h.filterFieldRef),D(r,(I=s.optionQuery)==null?void 0:I.spec);for(const V of s.bindings||[])S(r,V.fieldRef)}for(const s of e.views){for(const V of s.fields||[])S(r,V);D(r,($=s.sdkSpec)==null?void 0:$.spec),D(r,s.visualSpec)}const t=e.implementationChecklist||{};for(const s of Object.values(t.bindingsByView||{}))for(const V of Array.isArray(s)?s:[])S(r,V.fieldRef),S(r,V.optionValueField),S(r,V.optionLabelField);for(const s of t.requiredInputOptions||[])S(r,s.visibleLabelField),S(r,s.optionValueField),S(r,s.runtimeFilterField);const o=pn([...e.sources.map(s=>({raw:s,key:Ie(s),aliases:Ve(s),name:""})),...r.map(s=>an(s)).filter(x)]);P(o,s=>{const V=F(s.raw);return j(s.raw.label||(V==null?void 0:V.datasetName)||(V==null?void 0:V.datasetId)||(V==null?void 0:V.name)||s.raw.kind||"source")});const a=ln(o),u=ne(r.filter(s=>s.name).map(s=>({raw:s,key:X(s),name:""})),s=>s.key);P(u,s=>j([s.raw.sourceKey?yn(s.raw.sourceKey):"",s.raw.aggregate?s.raw.aggregate.toLowerCase():"",s.raw.name].filter(Boolean).join("_")));const c=new Map(u.map(s=>[s.key,s.name])),w=e.inputs.map(s=>({raw:s,name:j(s.id||s.label||"input")}));P(w,s=>s.name);const f=w.filter(s=>!!s.raw.optionQuery).map(s=>({input:s,name:`${s.name}Options`,raw:s.raw.optionQuery}));P(f,s=>s.name);for(const s of f)un(s.raw.labelFieldRef,s.raw.valueFieldRef)&&dn(s.raw.valueFieldRef)&&n.push(`Input option query ${((M=s.raw.spec)==null?void 0:M.inputId)||s.input.raw.id||s.name} uses identifier field ${s.raw.valueFieldRef.name} as both label and value. It can execute, but the UI will show key values unless the semantic model exposes a human-readable label through a modeled relationship.`);const y=e.views.filter(s=>{var V,K;return!!((V=s.sdkSpec)!=null&&V.builder&&((K=s.sdkSpec)!=null&&K.spec))}).map(s=>({raw:s,name:j(s.id||s.title||"query")}));P(y,s=>s.name);const k=e.views.filter(s=>fe(s)&&!("sdkSpec"in s)).map(s=>sn(s));for(const s of e.views)(!("sdkSpec"in s)||!((b=s.sdkSpec)!=null&&b.builder)||!((E=s.sdkSpec)!=null&&E.spec))&&!fe(s)&&n.push(`Skipped view ${s.id||s.title||"unknown"} because it has no sdkSpec.`);return Ee({inputs:w,views:y,filterContracts:e.filterContracts}),{summary:e,title:e.title||"Semaphor Data App",sources:o,fields:u,inputs:w,optionQueries:f,views:y,presentationViews:k,filterContracts:e.filterContracts,checklist:t,sourceNameByKey:a,fieldNameByKey:c,warnings:n}}function Ee({inputs:e,views:n,filterContracts:r}){const t=new Set(e.map(a=>a.raw.id).filter(Boolean)),o=new Set(n.map(a=>a.raw.id).filter(Boolean));for(const[a,u]of r.entries()){if(!t.has(u.inputId))throw new Error(`filterContracts.${a}.inputId must reference a generated input.`);const c=new Set(u.appliesToViewIds||[]),w=new Set(u.notAppliedToViewIds||[]);for(const[f,y]of(u.appliesToViewIds||[]).entries())if(!o.has(y))throw new Error(`filterContracts.${a}.appliesToViewIds.${f} must reference an executable generated view.`);for(const[f,y]of(u.notAppliedToViewIds||[]).entries())if(!o.has(y))throw new Error(`filterContracts.${a}.notAppliedToViewIds.${f} must reference an executable generated view.`);for(const[f,y]of(u.bindings||[]).entries()){if(!o.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must reference an executable generated view.`);if(!c.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must be included in appliesToViewIds.`);if(w.has(y.viewId))throw new Error(`filterContracts.${a}.bindings.${f}.viewId must not be listed in notAppliedToViewIds.`)}}}function ke(e){return{"sources.ts":ve(e),"fields.ts":qe(e),"inputs.ts":De(e),"queries.ts":Pe(e),"bindings.ts":Le(e),"accessors.ts":Ye(e),"metadata.ts":We(e),"index.ts":Xe(),"USAGE.md":Ae(e)}}function Ne({contract:e,files:n,generatorName:r,generatorVersion:t}){return{schemaVersion:R.CONTRACT_MANIFEST_SCHEMA_VERSION,generatedContractSchemaVersion:R.GENERATED_CONTRACT_SCHEMA_VERSION,generator:{name:r,version:t},generatedContentHash:Ge(n),codegenSummaryValidatorVersion:R.CODEGEN_SUMMARY_VALIDATOR_VERSION,codegenSummaryHash:xe(e.summary),codegenSummary:e.summary}}function Ge(e){const n=he.createHash("sha256");for(const r of Object.keys(e).filter(t=>t.endsWith(".ts")).sort())n.update(r),n.update("\0"),n.update(e[r]),n.update("\0");return`sha256:${n.digest("hex")}`}function Ae(e){const n=["# Semaphor Generated Data App Contract","","Generated files in this directory are governed Semaphor analytics wiring. Do not hand-edit them.","","Use the app-facing exports from `index.ts`:","","- `queries`: generated governed query factories.","- `queryOptionsForView`: active-input wiring for each generated view.","- `rowsForView`: table/records row readers.","- `rowValuesForView`: friendly row object readers for chart/table views.","- `metricValuesForView`: friendly metric-value readers.","- `kpiPropsForView`: KPI component props derived from runtime metric results.","- `roleValuesForView`: canonical dimension/measure/date/id role readers.","- `appInputSpecs`: generated input/filter specs.","- `inputOptionQueries`: option-list query factories for generated inputs.","- `semaphorGeneratedContractMetadata`: generated view/input metadata and presentation-only views.","","Start with these exports before opening large generated internals such as `metadata.ts`.",""];return e.views.length>0&&(n.push("Generated executable views:"),e.views.forEach(r=>{n.push(`- \`${r.raw.id}\`: ${r.raw.title||r.name}`)}),n.push("")),e.inputs.length>0&&(n.push("Generated inputs:"),e.inputs.forEach(r=>{n.push(`- \`${r.raw.id}\`: ${r.raw.label||r.name}`)}),n.push("")),`${n.join(`
@@ -1,6 +1,6 @@
1
- import { S as Vn, a as Fn, i as bn, v as kn } from "../chunks/matrix-operation-contract-D5I-t3i7.js";
2
- import { c as ke, G as fe, a as Re, b as Me } from "../chunks/update-policy-D3I1J2kl.js";
3
- import { C as Mn, e as Cn, R as On, f as xn, g as Gn, h as Nn, i as En, j as An, v as jn, d as vn } from "../chunks/update-policy-D3I1J2kl.js";
1
+ import { S as Vn, a as Fn, i as bn, v as kn } from "../chunks/matrix-operation-contract-4q53iAUW.js";
2
+ import { c as ke, G as fe, a as Re, b as Me } from "../chunks/update-policy-BoB26XrS.js";
3
+ import { C as Mn, e as Cn, R as On, f as xn, g as Gn, h as Nn, i as En, j as An, v as jn, d as vn } from "../chunks/update-policy-BoB26XrS.js";
4
4
  import { createHash as ye } from "node:crypto";
5
5
  const wn = "src/semaphor/generated", v = `// Generated by Semaphor Agent Plugin. Do not hand-edit analytics wiring here.
6
6
  // Regenerate from the accepted semaphor_plan_data_app codegenSummary when the plan changes.