@maggioli-rd/aicore-agent-chat 1.2.0 → 2.0.0

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 (146) hide show
  1. package/README.md +36 -18
  2. package/dist/aicore-agent-chat.js +164 -53
  3. package/dist/aicore-agent-chat.js.map +1 -1
  4. package/dist/bundle/a2ui-C-LAbJcp.js +87 -0
  5. package/dist/bundle/abnfDiagram-S7VZAUFO-DxkzIS8G.js +1 -0
  6. package/dist/bundle/architecture-WOLXFQ4H-BXMyXdT1.js +1 -0
  7. package/dist/bundle/architectureDiagram-YGSQEFNW-BmsDn6Ho.js +36 -0
  8. package/dist/bundle/backstage-Bfl3Tyo5.js +86 -0
  9. package/dist/bundle/blockDiagram-APKKGZFW-bG_MVPzT.js +140 -0
  10. package/dist/bundle/bpmnIcons-APHXDYXF-C0jbCElo.js +1 -0
  11. package/dist/bundle/c4Diagram-KJ2TOQU5-BVad-wQe.js +38 -0
  12. package/dist/bundle/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  13. package/dist/bundle/chunk-5VM5RSS4-CwNG0iBi.js +15 -0
  14. package/dist/bundle/chunk-6MUBBAK2-CeH4cZO-.js +2 -0
  15. package/dist/bundle/chunk-AXFCVDMN-D0Vqm50X.js +62 -0
  16. package/dist/bundle/chunk-BG4553SI-DUBI9JbR.js +127 -0
  17. package/dist/bundle/chunk-DQASFODM-DBWVlIjs.js +10 -0
  18. package/dist/bundle/chunk-DUW6YSOI-ChybIQ82.js +1 -0
  19. package/dist/bundle/chunk-HFQBQIA3-D2xPptW8.js +1 -0
  20. package/dist/bundle/chunk-J5ZVWO5B-DHB__t6z.js +1 -0
  21. package/dist/bundle/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  22. package/dist/bundle/chunk-KQLB2F66-BRGnyo9e.js +1 -0
  23. package/dist/bundle/chunk-KS47KZWR-DV3Gxewa.js +1 -0
  24. package/dist/bundle/chunk-LEVMRMFU-BdDTT4pw.js +1 -0
  25. package/dist/bundle/chunk-M57EVK23-BRqFqW5o.js +1 -0
  26. package/dist/bundle/chunk-NGNAAXSQ-DreF1ykJ.js +214 -0
  27. package/dist/bundle/chunk-OY52VR5R-BamrP8d_.js +88 -0
  28. package/dist/bundle/chunk-QB3YPZ4I-BqUUL29j.js +213 -0
  29. package/dist/bundle/chunk-R3KSYZAL-gmtEjdKU.js +1 -0
  30. package/dist/bundle/chunk-STOXU5M4-DdqxXfKq.js +72 -0
  31. package/dist/bundle/chunk-TU62E6Q5-B4GgWjUW.js +1 -0
  32. package/dist/bundle/chunk-X4PVCEUW-BcN5Aq5G.js +1 -0
  33. package/dist/bundle/chunk-XXDRQBXY-BIvjAdC_.js +1 -0
  34. package/dist/bundle/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  35. package/dist/bundle/classDiagram-v2-L25IHNXF-Dw7so3mk.js +217 -0
  36. package/dist/bundle/cose-bilkent-JH36ORCC-DUvnuVrm.js +1 -0
  37. package/dist/bundle/cynefin-EF2NZ3EQ-CcVPiRLN.js +1 -0
  38. package/dist/bundle/cynefinDiagram-L36ESFBY-eO6Z3Kvn.js +62 -0
  39. package/dist/bundle/cytoscape.esm-CsT4DLSP.js +321 -0
  40. package/dist/bundle/d3-hierarchy-i5r04UUG.js +1 -0
  41. package/dist/bundle/d3-scale-BEO6F4Sh.js +1 -0
  42. package/dist/bundle/d3-scale-chromatic-DhHjp77O.js +1 -0
  43. package/dist/bundle/d3-selection-CBFxn8wf.js +1 -0
  44. package/dist/bundle/d3-shape-v1Y4qR5e.js +1 -0
  45. package/dist/bundle/dagre-SPEB5RXH-ByBZqBaT.js +4 -0
  46. package/dist/bundle/diagram-3B7GL73J-BkQkIpxz.js +200 -0
  47. package/dist/bundle/diagram-DNEMPZML-DYthXzRv.js +24 -0
  48. package/dist/bundle/diagram-L3MUGCDN-D4DIzfHH.js +41 -0
  49. package/dist/bundle/diagram-LA4NIPWU-C2P-hZD1.js +24 -0
  50. package/dist/bundle/diagram-MHCOC4E2-BwauFnTV.js +3 -0
  51. package/dist/bundle/diagram-XPFHEONP-DC_v3Llc.js +30 -0
  52. package/dist/bundle/dist-CwuaKeLF.js +1 -0
  53. package/dist/bundle/ebnfDiagram-UZSYDL2S-CmwGlC8L.js +1 -0
  54. package/dist/bundle/elk-XV6XMXQE-CTlty3p3.js +27 -0
  55. package/dist/bundle/erDiagram-EYBAPDEH-Bu6phvJH.js +99 -0
  56. package/dist/bundle/eventmodeling-K75KTNOO-B1q0nOJE.js +1 -0
  57. package/dist/bundle/flowDiagram-MALGAFMO-D9D_AzXh.js +1 -0
  58. package/dist/bundle/ganttDiagram-23REXITY-COK7rxO4.js +292 -0
  59. package/dist/bundle/gitGraph-VSP46ZUC-DS7S_jKI.js +1 -0
  60. package/dist/bundle/gitGraphDiagram-STJD7YCW-DhVK8Hqh.js +106 -0
  61. package/dist/bundle/graphlib-Bgy7WbC7.js +1 -0
  62. package/dist/bundle/info-OHQRW6UA-BjEWvFlW.js +1 -0
  63. package/dist/bundle/infoDiagram-KBXO4MBG-Dg3zWdHP.js +2 -0
  64. package/dist/bundle/ishikawaDiagram-M35NCXHK-C2g8ghrV.js +70 -0
  65. package/dist/bundle/journeyDiagram-OPLOXDXO-DMZkL-i1.js +139 -0
  66. package/dist/bundle/kanban-definition-BZKZHSQY-Dr43IiJD.js +89 -0
  67. package/dist/bundle/katex-rAoShGnF.js +257 -0
  68. package/dist/bundle/math-Cx-Q-b8s.js +262 -0
  69. package/dist/bundle/mermaid-DaDuEHir.js +43 -0
  70. package/dist/bundle/mermaid-parser.core-Bv_Zx_ZE.js +6 -0
  71. package/dist/bundle/mindmap-definition-I2QAS2VK-BXCWJ_1R.js +98 -0
  72. package/dist/bundle/packet-JDAUHWVQ-CgB2qE5t.js +1 -0
  73. package/dist/bundle/pegDiagram-FD4XPPHP-CR58gOgF.js +1 -0
  74. package/dist/bundle/pie-XZMESJXO-CvXWTfIG.js +1 -0
  75. package/dist/bundle/pieDiagram-J4AKIIQI-D0GhbNJg.js +39 -0
  76. package/dist/bundle/quadrantDiagram-XTYBLID2-BKBEdwvC.js +7 -0
  77. package/dist/bundle/radar-ABXABTNO-8V_xx_AB.js +1 -0
  78. package/dist/bundle/railroad-I3PHUGI6-Bvb0GUva.js +1 -0
  79. package/dist/bundle/railroad-abnf-LNEFI6M7-D8xGcObq.js +1 -0
  80. package/dist/bundle/railroad-ebnf-DWYD2UWJ-Ch8wBawI.js +1 -0
  81. package/dist/bundle/railroad-peg-JR7BVNR7-CGndbjed.js +1 -0
  82. package/dist/bundle/railroadDiagram-MRQ6NCDL-DvqHkO2C.js +1 -0
  83. package/dist/bundle/requirementDiagram-Y7LWUY3S-bCLAM9sl.js +84 -0
  84. package/dist/bundle/rolldown-runtime-BNaE-Ejt.js +1 -0
  85. package/dist/bundle/rough.esm-Dy-Kn_BL.js +1 -0
  86. package/dist/bundle/sankeyDiagram-WGJFYUXA-8ehuPvHQ.js +40 -0
  87. package/dist/bundle/sequenceDiagram-5NDRBG5M-Cdg1YzMw.js +169 -0
  88. package/dist/bundle/sizeCapture-INFHLROL-Ct7XApxm.js +1 -0
  89. package/dist/bundle/stateDiagram-v2-FJ4FJNEA-B69v2YYC.js +291 -0
  90. package/dist/bundle/swimlanes-UMQ2AFYF-C_qI6rnK.js +1 -0
  91. package/dist/bundle/swimlanesDiagram-OMPLPG4O-CS11qSCX.js +8 -0
  92. package/dist/bundle/timeline-definition-SEUHKTQE-BCU0-H8D.js +120 -0
  93. package/dist/bundle/treeView-D4JQ5SDB-CpjURS-c.js +1 -0
  94. package/dist/bundle/treemap-SAJKECNS-CFFTaiIN.js +1 -0
  95. package/dist/bundle/usecaseDiagram-AFA6YXN4-46V1jsea.js +476 -0
  96. package/dist/bundle/vega-eBn1AexV.js +33 -0
  97. package/dist/bundle/vennDiagram-NNMJR3RB-q4Q4x2Q6.js +34 -0
  98. package/dist/bundle/wardley-7MLQ67FV-DhnATL7b.js +1 -0
  99. package/dist/bundle/wardleyDiagram-S7YFUSEH-BHIufnZW.js +78 -0
  100. package/dist/bundle/xychartDiagram-GGNKY7IX-CxAjpN3O.js +7 -0
  101. package/dist/chunks/a2ui-Da_YceSP.js +961 -0
  102. package/dist/chunks/a2ui-Da_YceSP.js.map +1 -0
  103. package/dist/chunks/backstage-TkKENlNl.js +1008 -0
  104. package/dist/chunks/backstage-TkKENlNl.js.map +1 -0
  105. package/dist/chunks/{core-Db3hnKpM.js → core-4PRAI1Mt.js} +60 -5
  106. package/dist/chunks/core-4PRAI1Mt.js.map +1 -0
  107. package/dist/chunks/math-D5IXRTov.js +86 -0
  108. package/dist/chunks/math-D5IXRTov.js.map +1 -0
  109. package/dist/chunks/mermaid-j9RNkOnL.js +197 -0
  110. package/dist/chunks/mermaid-j9RNkOnL.js.map +1 -0
  111. package/dist/chunks/rich-CdNA4NuG.js +156 -0
  112. package/dist/chunks/rich-CdNA4NuG.js.map +1 -0
  113. package/dist/chunks/sanitize-COLQzplk.js +240 -0
  114. package/dist/chunks/sanitize-COLQzplk.js.map +1 -0
  115. package/dist/chunks/{src-CYXMXds2.js → src-PkQozp4M.js} +725 -146
  116. package/dist/chunks/src-PkQozp4M.js.map +1 -0
  117. package/dist/chunks/vega-B07F6TI4.js +301 -0
  118. package/dist/chunks/vega-B07F6TI4.js.map +1 -0
  119. package/dist/core.js +1 -1
  120. package/dist/define.js +3 -3
  121. package/dist/index.js +3 -3
  122. package/dist/types/core/session.d.ts +31 -0
  123. package/dist/types/element/backstage/index.d.ts +10 -0
  124. package/dist/types/element/backstage/log.d.ts +13 -0
  125. package/dist/types/element/backstage/map.d.ts +12 -0
  126. package/dist/types/element/backstage/timing.d.ts +51 -0
  127. package/dist/types/element/i18n.d.ts +69 -6
  128. package/dist/types/element/icons.d.ts +3 -0
  129. package/dist/types/element/index.d.ts +15 -5
  130. package/dist/types/element/markdown.d.ts +6 -3
  131. package/dist/types/element/rich/a2ui-format.d.ts +45 -0
  132. package/dist/types/element/rich/a2ui-icons.d.ts +1 -0
  133. package/dist/types/element/rich/a2ui-views.d.ts +37 -0
  134. package/dist/types/element/rich/a2ui.d.ts +2 -0
  135. package/dist/types/element/rich/index.d.ts +72 -0
  136. package/dist/types/element/rich/math.d.ts +4 -0
  137. package/dist/types/element/rich/mermaid.d.ts +2 -0
  138. package/dist/types/element/rich/vega.d.ts +2 -0
  139. package/dist/types/element/sanitize.d.ts +34 -0
  140. package/dist/types/element/styles.d.ts +1 -1
  141. package/dist/types/element/team.d.ts +14 -0
  142. package/dist/types/index.d.ts +1 -0
  143. package/dist/types/jsx.d.ts +1 -1
  144. package/package.json +9 -3
  145. package/dist/chunks/core-Db3hnKpM.js.map +0 -1
  146. package/dist/chunks/src-CYXMXds2.js.map +0 -1
@@ -0,0 +1,87 @@
1
+ import{i as e,n as t,t as n}from"./rolldown-runtime-BNaE-Ejt.js";import{a as r,f as i,i as a,m as o,n as s,o as c,p as l,r as u,t as d}from"../aicore-agent-chat.js";var f;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(f||={});var p;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(p||={});var m=f.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),h=e=>{switch(typeof e){case`undefined`:return m.undefined;case`string`:return m.string;case`number`:return Number.isNaN(e)?m.nan:m.number;case`boolean`:return m.boolean;case`function`:return m.function;case`bigint`:return m.bigint;case`symbol`:return m.symbol;case`object`:return Array.isArray(e)?m.array:e===null?m.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?m.promise:typeof Map<`u`&&e instanceof Map?m.map:typeof Set<`u`&&e instanceof Set?m.set:typeof Date<`u`&&e instanceof Date?m.date:m.object;default:return m.unknown}},g=f.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),_=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,f.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};_.create=e=>new _(e);var ee=(e,t)=>{let n;switch(e.code){case g.invalid_type:n=e.received===m.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case g.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,f.jsonStringifyReplacer)}`;break;case g.unrecognized_keys:n=`Unrecognized key(s) in object: ${f.joinValues(e.keys,`, `)}`;break;case g.invalid_union:n=`Invalid input`;break;case g.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${f.joinValues(e.options)}`;break;case g.invalid_enum_value:n=`Invalid enum value. Expected ${f.joinValues(e.options)}, received '${e.received}'`;break;case g.invalid_arguments:n=`Invalid function arguments`;break;case g.invalid_return_type:n=`Invalid function return type`;break;case g.invalid_date:n=`Invalid date`;break;case g.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:f.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case g.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case g.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case g.custom:n=`Invalid input`;break;case g.invalid_intersection_types:n=`Intersection results could not be merged`;break;case g.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case g.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,f.assertNever(e)}return{message:n}},te=ee;function ne(){return te}var re=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function v(e,t){let n=ne(),r=re({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ee?void 0:ee].filter(e=>!!e)});e.common.issues.push(r)}var ie=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return y;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return y;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},y=Object.freeze({status:`aborted`}),ae=e=>({status:`dirty`,value:e}),oe=e=>({status:`valid`,value:e}),se=e=>e.status===`aborted`,ce=e=>e.status===`dirty`,le=e=>e.status===`valid`,ue=e=>typeof Promise<`u`&&e instanceof Promise,b;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(b||={});var de=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},fe=(e,t)=>{if(le(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new _(e.common.issues);return this._error=t,this._error}}};function x(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var S=class{get description(){return this._def.description}_getType(e){return h(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:h(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ie,ctx:{common:e.parent.common,data:e.data,parsedType:h(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ue(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:h(e)};return fe(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:h(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return le(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>le(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:h(e)},r=this._parse({data:e,path:n.path,parent:n});return fe(n,await(ue(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:g.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new ht({schema:this,typeName:C.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return gt.create(this,this._def)}nullable(){return _t.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xe.create(this)}promise(){return mt.create(this,this._def)}or(e){return $e.create([this,e],this._def)}and(e){return rt.create(this,e,this._def)}transform(e){return new ht({...x(this._def),schema:this,typeName:C.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new vt({...x(this._def),innerType:this,defaultValue:t,typeName:C.ZodDefault})}brand(){return new xt({typeName:C.ZodBranded,type:this,...x(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new yt({...x(this._def),innerType:this,catchValue:t,typeName:C.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return St.create(this,e)}readonly(){return Ct.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},pe=/^c[^\s-]{8,}$/i,me=/^[0-9a-z]+$/,he=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ge=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,_e=/^[a-z0-9_-]{21}$/i,ve=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ye=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,be=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,xe=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Se,Ce=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,we=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Te=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ee=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,De=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Oe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ke=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,Ae=RegExp(`^${ke}$`);function je(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Me(e){return RegExp(`^${je(e)}$`)}function Ne(e){let t=`${ke}T${je(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Pe(e,t){return!((t!==`v4`&&t||!Ce.test(e))&&(t!==`v6`&&t||!Te.test(e)))}function Fe(e,t){if(!ve.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Ie(e,t){return!((t!==`v4`&&t||!we.test(e))&&(t!==`v6`&&t||!Ee.test(e)))}var Le=class e extends S{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.string,received:t.parsedType}),y}let t=new ie,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:g.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:g.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?v(n,{code:g.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&v(n,{code:g.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)be.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`email`,code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)Se||=new RegExp(xe,`u`),Se.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`emoji`,code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)ge.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`uuid`,code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)_e.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`nanoid`,code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)pe.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`cuid`,code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)me.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`cuid2`,code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)he.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`ulid`,code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),v(n,{validation:`url`,code:g.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`regex`,code:g.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Ne(r).test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Ae.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Me(r).test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?ye.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`duration`,code:g.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Pe(e.data,r.version)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`ip`,code:g.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Fe(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`jwt`,code:g.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Ie(e.data,r.version)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`cidr`,code:g.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?De.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`base64`,code:g.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Oe.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:`base64url`,code:g.invalid_string,message:r.message}),t.dirty()):f.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:g.invalid_string,...b.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...b.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...b.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...b.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...b.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...b.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...b.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...b.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...b.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...b.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...b.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...b.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...b.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...b.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...b.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...b.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...b.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...b.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...b.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...b.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...b.errToObj(t)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Le.create=e=>new Le({checks:[],typeName:C.ZodString,coerce:e?.coerce??!1,...x(e)});function Re(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var ze=class e extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==m.number){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.number,received:t.parsedType}),y}let t,n=new ie;for(let r of this._def.checks)r.kind===`int`?f.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),v(t,{code:g.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Re(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),v(t,{code:g.not_finite,message:r.message}),n.dirty()):f.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,b.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,b.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,b.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,b.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:b.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:b.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:b.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:b.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:b.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:b.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&f.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};ze.create=e=>new ze({checks:[],typeName:C.ZodNumber,coerce:e?.coerce||!1,...x(e)});var Be=class e extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==m.bigint)return this._getInvalidInput(e);let t,n=new ie;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):f.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.bigint,received:t.parsedType}),y}gte(e,t){return this.setLimit(`min`,e,!0,b.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,b.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,b.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,b.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:b.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:b.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Be.create=e=>new Be({checks:[],typeName:C.ZodBigInt,coerce:e?.coerce??!1,...x(e)});var Ve=class extends S{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.boolean,received:t.parsedType}),y}return oe(e.data)}};Ve.create=e=>new Ve({typeName:C.ZodBoolean,coerce:e?.coerce||!1,...x(e)});var He=class e extends S{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.date,received:t.parsedType}),y}if(Number.isNaN(e.data.getTime()))return v(this._getOrReturnCtx(e),{code:g.invalid_date}),y;let t=new ie,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:g.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:g.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):f.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:b.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:b.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};He.create=e=>new He({checks:[],coerce:e?.coerce||!1,typeName:C.ZodDate,...x(e)});var Ue=class extends S{_parse(e){if(this._getType(e)!==m.symbol){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.symbol,received:t.parsedType}),y}return oe(e.data)}};Ue.create=e=>new Ue({typeName:C.ZodSymbol,...x(e)});var We=class extends S{_parse(e){if(this._getType(e)!==m.undefined){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.undefined,received:t.parsedType}),y}return oe(e.data)}};We.create=e=>new We({typeName:C.ZodUndefined,...x(e)});var Ge=class extends S{_parse(e){if(this._getType(e)!==m.null){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.null,received:t.parsedType}),y}return oe(e.data)}};Ge.create=e=>new Ge({typeName:C.ZodNull,...x(e)});var Ke=class extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return oe(e.data)}};Ke.create=e=>new Ke({typeName:C.ZodAny,...x(e)});var qe=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return oe(e.data)}};qe.create=e=>new qe({typeName:C.ZodUnknown,...x(e)});var Je=class extends S{_parse(e){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.never,received:t.parsedType}),y}};Je.create=e=>new Je({typeName:C.ZodNever,...x(e)});var Ye=class extends S{_parse(e){if(this._getType(e)!==m.undefined){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.void,received:t.parsedType}),y}return oe(e.data)}};Ye.create=e=>new Ye({typeName:C.ZodVoid,...x(e)});var Xe=class e extends S{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==m.array)return v(t,{code:g.invalid_type,expected:m.array,received:t.parsedType}),y;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(v(t,{code:e?g.too_big:g.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(v(t,{code:g.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(v(t,{code:g.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new de(t,e,t.path,n)))).then(e=>ie.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new de(t,e,t.path,n)));return ie.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:b.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:b.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}};Xe.create=(e,t)=>new Xe({type:e,minLength:null,maxLength:null,exactLength:null,typeName:C.ZodArray,...x(t)});function Ze(e){if(e instanceof Qe){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=gt.create(Ze(r))}return new Qe({...e._def,shape:()=>t})}return e instanceof Xe?new Xe({...e._def,type:Ze(e.element)}):e instanceof gt?gt.create(Ze(e.unwrap())):e instanceof _t?_t.create(Ze(e.unwrap())):e instanceof it?it.create(e.items.map(e=>Ze(e))):e}var Qe=class e extends S{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=f.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==m.object){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.object,received:t.parsedType}),y}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Je&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new de(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Je){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(v(n,{code:g.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new de(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>ie.mergeObjectSync(t,e)):ie.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return b.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:b.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:C.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of f.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of f.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Ze(this)}partial(t){let n={};for(let e of f.objectKeys(this.shape)){let r=this.shape[e];n[e]=t&&!t[e]?r:r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of f.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof gt;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return dt(f.objectKeys(this.shape))}};Qe.create=(e,t)=>new Qe({shape:()=>e,unknownKeys:`strip`,catchall:Je.create(),typeName:C.ZodObject,...x(t)}),Qe.strictCreate=(e,t)=>new Qe({shape:()=>e,unknownKeys:`strict`,catchall:Je.create(),typeName:C.ZodObject,...x(t)}),Qe.lazycreate=(e,t)=>new Qe({shape:e,unknownKeys:`strip`,catchall:Je.create(),typeName:C.ZodObject,...x(t)});var $e=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new _(e.ctx.common.issues));return v(t,{code:g.invalid_union,unionErrors:n}),y}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new _(e));return v(t,{code:g.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}};$e.create=(e,t)=>new $e({options:e,typeName:C.ZodUnion,...x(t)});var et=e=>e instanceof lt?et(e.schema):e instanceof ht?et(e.innerType()):e instanceof ut?[e.value]:e instanceof ft?e.options:e instanceof pt?f.objectValues(e.enum):e instanceof vt?et(e._def.innerType):e instanceof We?[void 0]:e instanceof Ge?[null]:e instanceof gt?[void 0,...et(e.unwrap())]:e instanceof _t?[null,...et(e.unwrap())]:e instanceof xt||e instanceof Ct?et(e.unwrap()):e instanceof yt?et(e._def.innerType):[],tt=class e extends S{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.object)return v(t,{code:g.invalid_type,expected:m.object,received:t.parsedType}),y;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(v(t,{code:g.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=/* @__PURE__ */ new Map;for(let e of n){let n=et(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:C.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...x(r)})}};function nt(e,t){let n=h(e),r=h(t);if(e===t)return{valid:!0,data:e};if(n===m.object&&r===m.object){let n=f.objectKeys(t),r=f.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=nt(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}if(n===m.array&&r===m.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=nt(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}return n===m.date&&r===m.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var rt=class extends S{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(se(e)||se(r))return y;let i=nt(e.value,r.value);return i.valid?((ce(e)||ce(r))&&t.dirty(),{status:t.value,value:i.data}):(v(n,{code:g.invalid_intersection_types}),y)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};rt.create=(e,t,n)=>new rt({left:e,right:t,typeName:C.ZodIntersection,...x(n)});var it=class e extends S{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.array)return v(n,{code:g.invalid_type,expected:m.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return v(n,{code:g.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),y;!this._def.rest&&n.data.length>this._def.items.length&&(v(n,{code:g.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new de(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>ie.mergeArray(t,e)):ie.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};it.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new it({items:e,typeName:C.ZodTuple,rest:null,...x(t)})};var at=class e extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.object)return v(n,{code:g.invalid_type,expected:m.object,received:n.parsedType}),y;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new de(n,e,n.path,e)),value:a._parse(new de(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?ie.mergeObjectAsync(t,r):ie.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof S?new e({keyType:t,valueType:n,typeName:C.ZodRecord,...x(r)}):new e({keyType:Le.create(),valueType:t,typeName:C.ZodRecord,...x(n)})}},ot=class extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.map)return v(n,{code:g.invalid_type,expected:m.map,received:n.parsedType}),y;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new de(n,e,n.path,[a,`key`])),value:i._parse(new de(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=/* @__PURE__ */ new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return y;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}{let e=/* @__PURE__ */ new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return y;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};ot.create=(e,t,n)=>new ot({valueType:t,keyType:e,typeName:C.ZodMap,...x(n)});var st=class e extends S{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.set)return v(n,{code:g.invalid_type,expected:m.set,received:n.parsedType}),y;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(v(n,{code:g.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(v(n,{code:g.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=/* @__PURE__ */ new Set;for(let r of e){if(r.status===`aborted`)return y;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new de(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:b.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:b.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};st.create=(e,t)=>new st({valueType:e,minSize:null,maxSize:null,typeName:C.ZodSet,...x(t)});var ct=class e extends S{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.function)return v(t,{code:g.invalid_type,expected:m.function,received:t.parsedType}),y;function n(e,n){return re({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ne(),ee].filter(e=>!!e),issueData:{code:g.invalid_arguments,argumentsError:n}})}function r(e,n){return re({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ne(),ee].filter(e=>!!e),issueData:{code:g.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof mt){let e=this;return oe(async function(...t){let o=new _([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}{let e=this;return oe(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new _([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new _([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:it.create(t).rest(qe.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||it.create([]).rest(qe.create()),returns:n||qe.create(),typeName:C.ZodFunction,...x(r)})}},lt=class extends S{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};lt.create=(e,t)=>new lt({getter:e,typeName:C.ZodLazy,...x(t)});var ut=class extends S{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return v(t,{received:t.data,code:g.invalid_literal,expected:this._def.value}),y}return{status:`valid`,value:e.data}}get value(){return this._def.value}};ut.create=(e,t)=>new ut({value:e,typeName:C.ZodLiteral,...x(t)});function dt(e,t){return new ft({values:e,typeName:C.ZodEnum,...x(t)})}var ft=class e extends S{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return v(t,{expected:f.joinValues(n),received:t.parsedType,code:g.invalid_type}),y}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return v(t,{received:t.data,code:g.invalid_enum_value,options:n}),y}return oe(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};ft.create=dt;var pt=class extends S{_parse(e){let t=f.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==m.string&&n.parsedType!==m.number){let e=f.objectValues(t);return v(n,{expected:f.joinValues(e),received:n.parsedType,code:g.invalid_type}),y}if(this._cache||=new Set(f.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=f.objectValues(t);return v(n,{received:n.data,code:g.invalid_enum_value,options:e}),y}return oe(e.data)}get enum(){return this._def.values}};pt.create=(e,t)=>new pt({values:e,typeName:C.ZodNativeEnum,...x(t)});var mt=class extends S{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==m.promise&&t.common.async===!1?(v(t,{code:g.invalid_type,expected:m.promise,received:t.parsedType}),y):oe((t.parsedType===m.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};mt.create=(e,t)=>new mt({type:e,typeName:C.ZodPromise,...x(t)});var ht=class extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===C.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{v(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return y;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?y:r.status===`dirty`||t.value===`dirty`?ae(r.value):r});{if(t.value===`aborted`)return y;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?y:r.status===`dirty`||t.value===`dirty`?ae(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?y:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?y:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`){if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!le(e))return y;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>le(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):y)}f.assertNever(r)}};ht.create=(e,t,n)=>new ht({schema:e,typeName:C.ZodEffects,effect:t,...x(n)}),ht.createWithPreprocess=(e,t,n)=>new ht({schema:t,effect:{type:`preprocess`,transform:e},typeName:C.ZodEffects,...x(n)});var gt=class extends S{_parse(e){return this._getType(e)===m.undefined?oe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};gt.create=(e,t)=>new gt({innerType:e,typeName:C.ZodOptional,...x(t)});var _t=class extends S{_parse(e){return this._getType(e)===m.null?oe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};_t.create=(e,t)=>new _t({innerType:e,typeName:C.ZodNullable,...x(t)});var vt=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===m.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};vt.create=(e,t)=>new vt({innerType:e,typeName:C.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...x(t)});var yt=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ue(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new _(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new _(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};yt.create=(e,t)=>new yt({innerType:e,typeName:C.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...x(t)});var bt=class extends S{_parse(e){if(this._getType(e)!==m.nan){let t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:m.nan,received:t.parsedType}),y}return{status:`valid`,value:e.data}}};bt.create=e=>new bt({typeName:C.ZodNaN,...x(e)});var xt=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},St=class e extends S{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?y:e.status===`dirty`?(t.dirty(),ae(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?y:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:C.ZodPipeline})}},Ct=class extends S{_parse(e){let t=this._def.innerType._parse(e),n=e=>(le(e)&&(e.value=Object.freeze(e.value)),e);return ue(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Ct.create=(e,t)=>new Ct({innerType:e,typeName:C.ZodReadonly,...x(t)}),Qe.lazycreate;var C;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(C||={});var w=Le.create,T=ze.create;bt.create,Be.create;var E=Ve.create;He.create,Ue.create,We.create,Ge.create;var wt=Ke.create,D=qe.create;Je.create,Ye.create;var O=Xe.create,k=Qe.create;Qe.strictCreate;var A=$e.create;tt.create;var Tt=rt.create;it.create;var j=at.create;ot.create,st.create,ct.create;var Et=lt.create,Dt=ut.create,M=ft.create;pt.create,mt.create,ht.create,gt.create,_t.create;var Ot=ht.createWithPreprocess;St.create;var kt={string:(e=>Le.create({...e,coerce:!0})),number:(e=>ze.create({...e,coerce:!0})),boolean:(e=>Ve.create({...e,coerce:!0})),bigint:(e=>Be.create({...e,coerce:!0})),date:(e=>He.create({...e,coerce:!0}))},At=Symbol.for(`preact-signals`);function jt(){if(It>1)It--;else{var e,t=!1;for((function(){var e=Bt;for(Bt=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();Ft!==void 0;){var n=Ft;for(Ft=void 0,Lt++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Gt(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(Lt=0,It--,t)throw e}}function Mt(e){if(It>0)return e();zt=++Rt,It++;try{return e()}finally{jt()}}var Nt,N=void 0;function Pt(e){var t=N,n=Nt;N=void 0,Nt=void 0;try{return e()}finally{N=t,Nt=n}}var Ft=void 0,It=0,Lt=0,Rt=0,zt=0,Bt=void 0,Vt=0;function Ht(e){if(N!==void 0){var t=e.n;if(t===void 0||t.t!==N)return t={i:0,S:e,p:N.s,n:void 0,t:N,e:void 0,x:void 0,r:t},N.s!==void 0&&(N.s.n=t),N.s=t,e.n=t,32&N.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=N.s,t.n=void 0,N.s.n=t,N.s=t),t}}function Ut(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}Ut.prototype.brand=At,Ut.prototype.h=function(){return!0},Ut.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?Pt(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},Ut.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&Pt(function(){var e;(e=t.Z)==null||e.call(t)}))}},Ut.prototype.subscribe=function(e){var t=this;return en(function(){var n=t.value;Pt(function(){return e(n)})},{name:`sub`})},Ut.prototype.valueOf=function(){return this.value},Ut.prototype.toString=function(){return this.value+``},Ut.prototype.toJSON=function(){return this.value},Ut.prototype.peek=function(){var e=this;return Pt(function(){return e.value})},Object.defineProperty(Ut.prototype,"value",{get:function(){var e=Ht(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Lt>100)throw Error(`Cycle detected`);(function(e){It!==0&&Lt===0&&e.l!==zt&&(e.l=zt,Bt={S:e,v:e.v,i:e.i,o:Bt})})(this),this.v=e,this.i++,Vt++,It++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{jt()}}}});function Wt(e,t){return new Ut(e,t)}function Gt(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Kt(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function qt(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Jt(e,t){Ut.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Vt-1,this.f=4}Jt.prototype=new Ut,Jt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Vt))return!0;if(this.g=Vt,this.f|=1,this.i>0&&!Gt(this))return this.f&=-2,!0;var e=N;try{Kt(this),N=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return N=e,qt(this),this.f&=-2,!0},Jt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Ut.prototype.S.call(this,e)},Jt.prototype.U=function(e){if(this.t!==void 0&&(Ut.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},Jt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Jt.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Ht(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Yt(e,t){return new Jt(e,t)}function Xt(e){var t=e.j;if(e.j=void 0,typeof t==`function`){It++;var n=N;N=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,Zt(e),t}finally{N=n,jt()}}}function Zt(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Xt(e)}function Qt(e){if(N!==this)throw Error(`Out-of-order effect`);qt(this),N=e,this.f&=-2;try{8&this.f&&Zt(this)}finally{jt()}}function $t(e,t){this.x=e,this.j=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Nt&&Nt.push(this)}$t.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.j=t)}finally{e()}},$t.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,Xt(this),Kt(this),It++;var e=N;return N=this,Qt.bind(this,e)},$t.prototype.N=function(){2&this.f||(this.f|=2,this.u=Ft,Ft=this)},$t.prototype.d=function(){this.f|=8,1&this.f||Zt(this)},$t.prototype.dispose=function(){this.d()};function en(e,t){var n=new $t(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var tn,nn,rn,an,on,sn,cn,ln;un({signal:Wt,computed:Yt,effect:en,batchWrite:Mt,isSignal:e=>typeof e==`function`||!!e&&typeof e==`object`&&(`value`in e||`peek`in e),getValue:e=>typeof e==`function`?e():e.value,setValue:(e,t)=>{if(typeof e?.set==`function`)e.set(t);else{if(e instanceof Jt||typeof e==`function`)throw TypeError(`Cannot set value of a read-only computed signal.`);e.value=t}},peekValue:e=>typeof e?.peek==`function`?e.peek():typeof e==`function`?e():e&&typeof e==`object`&&`value`in e?e.value:e});function un(e){tn=e.signal,nn=e.computed,rn=e.effect,an=e.batchWrite,on=e.isSignal,sn=e.getValue,cn=e.setValue,ln=e.peekValue}function dn(e){return tn(e)}function fn(e){return nn(e)}function pn(e){return rn(e)}function mn(e){return an(e)}function hn(e){return on(e)}function gn(e){return sn(e)}function _n(e,t){cn(e,t)}function vn(e){return ln(e)}var yn=class extends Error{constructor(e,t=`UNKNOWN_ERROR`,n){super(e),this.name=this.constructor.name,this.code=t,n?.path!==void 0&&(this.path=n.path),n?.surfaceId!==void 0&&(this.surfaceId=n.surfaceId),n?.functionCallId!==void 0&&(this.functionCallId=n.functionCallId),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},P=class extends yn{constructor(e,t,n=`VALIDATION_ERROR`,r){super(e,n,r),this.details=t}},bn=class extends yn{constructor(e,t,n){super(e,`DATA_ERROR`,{path:t,surfaceId:n})}},F=class extends yn{constructor(e,t,n,r){super(e,`EXPRESSION_ERROR`,r),this.expression=t,this.details=n}},xn=class extends yn{constructor(e,t){super(e,`STATE_ERROR`,t)}},I=class extends yn{constructor(e,t=`CATALOG_ERROR`,n){super(e,t,n)}},Sn=class extends P{constructor(e,t,n=`INTEGRITY_ERROR`,r){super(e,t,n,r),this.name=`A2uiIntegrityError`}},Cn=class extends P{constructor(e,t,n=`RECURSION_ERROR`,r){super(e,t,n,r),this.name=`A2uiRecursionError`}},L;(function(e){e.INVALID_FUNCTION_CALL=`INVALID_FUNCTION_CALL`,e.EXECUTION_ERROR=`EXECUTION_ERROR`,e.UNKNOWN_FUNCTION=`UNKNOWN_FUNCTION`,e.UNKNOWN_ERROR=`UNKNOWN_ERROR`,e.TIMEOUT=`TIMEOUT`,e.CANCELLED=`CANCELLED`,e.DISPOSED=`DISPOSED`,e.DUPLICATE=`DUPLICATE`,e.NO_LISTENER=`NO_LISTENER`,e.TOO_MANY_PENDING=`TOO_MANY_PENDING`})(L||={});var wn=class extends yn{constructor(e,t=L.UNKNOWN_ERROR,n,r){let i=t||L.UNKNOWN_ERROR;super(`[${i}] ${e}`,i),this.functionCallId=n,this.details=r,this.name=`A2uiRpcError`,this.rawMessage=e}};function Tn(e){return/^(0|[1-9]\d*)$/.test(e)}var En=1e4,Dn=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);function On(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>On(e));let t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null){let t={};for(let[n,r]of Object.entries(e))Object.defineProperty(t,n,{value:On(r),enumerable:!0,writable:!0,configurable:!0});return t}return e}var kn=class{constructor(e={}){this.data={},this.signals=/* @__PURE__ */ new Map,this.subscriptions=/* @__PURE__ */ new Set,this.data=On(e)}getSignal(e){let t=this.normalizePath(e);return this.signals.has(t)||this.signals.set(t,dn(this.get(t))),this.signals.get(t)}set(e,t,n=!1){if(e==null)throw new bn(`Path cannot be null or undefined.`);let r=this.parsePath(e);if(r.length===0)return this.data=t==null?{}:On(t),this.notifyAllSignals(),this;let i=r.pop(),a=t===void 0||!n&&t===null;if(a&&this.get(e)===void 0)return this;if(this.data===void 0||this.data===null)this.data={};else if(typeof this.data!=`object`)throw new bn(`Cannot set path '${e}': the data model root is a primitive value.`,e);let o=this.data;for(let t=0;t<r.length;t++){let n=r[t];if(Array.isArray(o)){if(!Tn(n))throw new bn(`Cannot use non-numeric segment '${n}' on an array in path '${e}'.`,e);let a=parseInt(n,10);if(a>1e4)throw new bn(`Cannot set path '${e}': array index '${n}' exceeds maximum supported index (${En}).`,e);let s=o[a];if(s!=null&&typeof s!=`object`)throw new bn(`Cannot set path '${e}': segment '${n}' is a primitive value.`,e);if(s==null){let n=t<r.length-1?r[t+1]:i;if(Tn(n)){if(parseInt(n,10)>1e4)throw new bn(`Cannot set path '${e}': array index '${n}' exceeds maximum supported index (${En}).`,e);o[a]=[]}else o[a]={}}}else{let a=Object.prototype.hasOwnProperty.call(o,n);if(a){let t=o[n];if(t!=null&&typeof t!=`object`)throw new bn(`Cannot set path '${e}': segment '${n}' is a primitive value.`,e)}if(!a||o[n]===void 0||o[n]===null){let a=t<r.length-1?r[t+1]:i;if(Tn(a)){if(parseInt(a,10)>1e4)throw new bn(`Cannot set path '${e}': array index '${a}' exceeds maximum supported index (${En}).`,e);o[n]=[]}else o[n]={}}}o=o[n]}if(Array.isArray(o)){if(!Tn(i))throw new bn(`Cannot use non-numeric segment '${i}' on an array in path '${e}'.`,e);if(parseInt(i,10)>1e4)throw new bn(`Cannot set path '${e}': array index '${i}' exceeds maximum supported index (${En}).`,e)}if(a){if(Array.isArray(o)){let e=parseInt(i,10);e<o.length&&(o[e]=void 0)}else delete o[i]}else o[i]=On(t);return this.notifySignals(e),this}delete(e){return this.set(e,void 0)}static resolvePath(e,t){return e.startsWith(`/`)?e:t?`${t.endsWith(`/`)?t:`${t}/`}${e}`:`/${e}`}get(e){if(e==null)throw new bn(`Path cannot be null or undefined.`);if(e===`/`||e===``)return this.data;let t=this.parsePath(e),n=this.data;for(let e of t){if(typeof n!=`object`||!n)return;if(Array.isArray(n)){if(!Tn(e))return;let t=parseInt(e,10);if(t<0||t>=n.length)return;n=n[t]}else{if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}}return n}hasPath(e){return e!=null&&this.get(e)!==void 0}subscribe(e,t){let n=this.getSignal(e),r=!0,i=vn(n),a=pn(()=>{let e=gn(n);i=e,r||t(e)});return r=!1,this.subscriptions.add(a),{get value(){return i},unsubscribe:()=>{a(),this.subscriptions.delete(a)}}}dispose(){for(let e of this.subscriptions)e();this.subscriptions.clear(),this.signals.clear()}normalizePath(e){let t=e.split(`/`).filter(e=>e.length>0);return t.length===0?`/`:`/${t.join(`/`)}`}parsePath(e){return e.split(`/`).filter(e=>e.length>0).map(t=>{let n=t.replace(/~([01])/g,(e,t)=>t===`1`?`/`:`~`);if(Dn.has(n))throw new bn(`Forbidden path segment '${n}' in path '${e}'.`,e);return n})}notifySignals(e){let t=this.normalizePath(e);mn(()=>{this.updateSignal(t);let e=t;for(;e!==`/`&&e!==``;)e=e.substring(0,e.lastIndexOf(`/`))||`/`,this.updateSignal(e);for(let e of this.signals.keys())this.isDescendant(e,t)&&this.updateSignal(e)})}updateSignal(e){let t=this.signals.get(e);if(t){let n=this.get(e);Array.isArray(n)?_n(t,n.slice()):typeof n==`object`&&n?_n(t,{...n}):_n(t,n)}}notifyAllSignals(){mn(()=>{for(let e of this.signals.keys())this.updateSignal(e)})}isDescendant(e,t){return t===`/`||t===``?e!==`/`:e.startsWith(t+`/`)}};function An(e,t){return e._def.a2uiChildRef=t,e}function jn(e){return e?._def?.a2uiChildRef}var Mn=/* @__PURE__ */ RegExp(`^[\\p{XID_Start}_][\\p{XID_Continue}]*$`,`u`);function Nn(e,t=!1){if(!e)return!1;let n=t&&e.startsWith(`@`)?e.slice(1):e;return Mn.test(n)}function Pn(e,t,n=!1){if(!Nn(e,n))throw new I(`Invalid UAX #31 ${t}`)}var Fn=/* @__PURE__ */ t({AccessibilityAttributesSchema:()=>Vn,ActionSchema:()=>Xn,CallIdSchema:()=>Zn,CheckRuleSchema:()=>Jn,CheckableSchema:()=>Yn,ChildListSchema:()=>Wn,ChildSchema:()=>Qn,CommonSchemas:()=>rr,ComponentCommonSchema:()=>Un,ComponentIdSchema:()=>In,DataBindingSchema:()=>Ln,DynamicBooleanSchema:()=>Bn,DynamicNumberSchema:()=>Kn,DynamicStringListSchema:()=>qn,DynamicStringSchema:()=>zn,DynamicValueSchema:()=>Gn,ExtensionsSchema:()=>Hn,FunctionCallSchema:()=>Rn,FunctionCommonSchema:()=>$n,FunctionResponseSchema:()=>nr,IndexSystemFunctionSchema:()=>er,SurfaceSchema:()=>tr}),In=An(w().describe(`REF:common_types.json#/$defs/ComponentId|The unique identifier for a component, used for both definitions and references within the same surface.`),`component-id`),Ln=k({path:w().describe(`A JSON Pointer path to a value in the data model.`).optional(),"@path":w().describe(`A JSON Pointer path to a value in the data model.`).optional()}).refine(e=>e[`@path`]!==void 0||e.path!==void 0,{message:`Either '@path' or 'path' must be provided.`}).describe(`REF:common_types.json#/$defs/DataBinding`),Rn=k({call:w().describe(`The name of the function to call.`).optional(),"@call":w().describe(`The name of the function to call.`).optional(),args:j(w(),D()).describe(`Arguments passed to the function.`).optional(),returnType:M([`string`,`number`,`boolean`,`array`,`object`,`any`,`void`]).describe(`The expected return type of the function call.`).optional(),catalogId:w().describe(`The catalog ID for this function, overriding any surface-level default catalogId.`).optional()}).strict().refine(e=>e[`@call`]!==void 0||e.call!==void 0,{message:`Either '@call' or 'call' must be provided.`}).describe(`REF:common_types.json#/$defs/FunctionCall|Invokes a named function, combining common function properties with the catalog function definition.`),zn=A([w(),Ln,Rn]).describe(`REF:common_types.json#/$defs/DynamicString|Represents a string`),Bn=A([E(),Ln,Rn]).describe(`REF:common_types.json#/$defs/DynamicBoolean|A boolean value that can be a literal, a path, or a function call returning a boolean or a validation result object (coerced to its \\'valid\\' boolean).`),Vn=k({label:zn.optional(),description:zn.optional(),live:M([`off`,`polite`,`assertive`]).default(`off`).describe(`Controls screen reader announcements for dynamic updates (WAI-ARIA aria-live). 'polite' waits for user pause; 'assertive' interrupts immediately for alerts.`).optional(),hidden:Bn.optional()}).describe(`REF:common_types.json#/$defs/AccessibilityAttributes|Attributes to enhance accessibility when using assistive technologies like screen readers or model understanding.`),Hn=j(w(),D()).superRefine((e,t)=>{for(let n in e)Nn(n)||t.addIssue({path:[n],code:g.custom,message:`Invalid extension key "${n}": Keys MUST be Unicode identifiers (UAX #31).`})}).describe(`REF:#/$defs/Extensions|Optional extension metadata. Keys MUST be Unicode identifiers (UAX #31). Keys starting with 'a2ui_' are reserved for official extensions.`),Un=k({id:In,accessibility:Vn.optional(),"@catalogId":w().describe(`The catalog ID for this component, overriding any surface-level default catalogId.`).optional(),"@accessibility":Vn.optional(),"@metadata":k({extensions:Hn.optional()}).strict().describe(`Optional component-level metadata for vendor extensions.`).optional()}).describe(`REF:common_types.json#/$defs/ComponentCommon`),Wn=An(A([O(In).describe(`A static list of child component IDs.`),k({componentId:In,path:w().describe(`The path to the list of component property objects in the data model.`)}).describe(`A template for generating a dynamic list of children.`)]).describe(`REF:common_types.json#/$defs/ChildList`),`child-list`),Gn=A([w(),T(),E(),O(D()),Ln,Rn,j(w(),D()).refine(e=>!e||!(`@path`in e)&&!(`path`in e)&&!(`@call`in e)&&!(`call`in e))]).describe(`REF:common_types.json#/$defs/DynamicValue|A value that can be a literal, a path, or a function call returning any type.`),Kn=A([T(),Ln,Rn]).describe(`REF:common_types.json#/$defs/DynamicNumber|Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number.`),qn=A([O(w()),Ln,Rn]).describe(`REF:common_types.json#/$defs/DynamicStringList|Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array.`),Jn=k({condition:A([Bn,Ln,Rn]).describe(`Path or function call evaluating to a structured validation result object or a boolean.`),message:w().describe(`Optional fallback error message.`).optional()}).describe(`REF:common_types.json#/$defs/CheckRule|A single validation check rule applied to an input component. The condition function or path evaluates to a structured validation result object or a boolean (which is coerced to a validation result object).`),Yn=k({checks:O(Jn).describe(`A list of checks to perform. These are function calls that must return a boolean indicating validity.`).optional(),"@checks":O(Jn).describe(`A list of validation check rules to perform on the component.`).optional()}).describe(`REF:common_types.json#/$defs/Checkable|Properties for components that support renderer-side checks.`),Xn=A([k({event:k({name:w().describe(`The name of the action to be dispatched to the server.`),context:j(w(),D()).describe(`A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.`).optional()}).strict().describe(`The event to dispatch to the server.`)}).strict().describe(`Triggers a server-side event.`),k({functionCall:Rn}).strict().describe(`Executes a local client-side function.`),k({event:k({name:w().describe(`The name of the action to be dispatched to the agent.`),userMessage:zn.optional(),context:j(w(),D()).describe(`A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.`).optional()}).strict().describe(`The event to dispatch to the agent.`)}).strict().describe(`Triggers an agent-side event.`),k({functionCall:Rn}).strict().describe(`Executes a renderer or agent-side function.`)]).describe(`REF:common_types.json#/$defs/Action|Defines an interaction handler that can either trigger an agent-side event or execute a local renderer-side function.`),Zn=w().describe(`REF:common_types.json#/$defs/CallId|The unique identifier for a function call.`),Qn=In,$n=k({call:w().describe(`The name of the function to call.`).optional(),"@call":w().describe(`The name of the function to call.`).optional(),catalogId:w().describe(`The catalog ID for this function, overriding any surface-level default catalogId.`).optional()}).refine(e=>e[`@call`]!==void 0||e.call!==void 0,{message:`Either '@call' or 'call' must be provided.`}).describe(`REF:common_types.json#/$defs/FunctionCommon|Baseline envelope properties common to all function calls. Function-specific argument schemas ('args') are defined individually by each function in the active catalog.`),er=k({call:Dt(`@index`).optional(),"@call":Dt(`@index`).optional(),args:k({offset:Kn.optional()}).optional()}).refine(e=>e[`@call`]!==void 0||e.call!==void 0,{message:`Either '@call' or 'call' must be '@index'.`}).describe(`REF:common_types.json#/$defs/IndexSystemFunction|Returns the 0-based index of the current item when rendering a dynamic list from a template. This function MUST ONLY be available when evaluating template items within a list context.`),tr=k({component:Dt(`Surface`).optional(),child:Dt(`root`).optional()}).strict().describe(`REF:common_types.json#/$defs/Surface|The reserved canonical container component representing an A2UI surface. The Surface component is immutable and always has \\'child\\': \\'root\\'.`),nr=k({functionCallId:Zn,value:D().describe(`The return value of the function.`).optional(),error:k({code:w(),message:w()}).strict().describe(`An error object indicating failure of the function execution.`).optional()}).strict().describe(`REF:common_types.json#/$defs/FunctionResponse|The return response matching a callAgentFunction or callRendererFunction invocation.`),rr={ComponentId:In,DataBinding:Ln,FunctionCall:Rn,DynamicString:zn,DynamicBoolean:Bn,AccessibilityAttributes:Vn,Extensions:Hn,ComponentCommon:Un,ChildList:Wn,DynamicValue:Gn,DynamicNumber:Kn,DynamicStringList:qn,CheckRule:Jn,Checkable:Yn,Action:Xn,CallId:Zn,Child:Qn,FunctionCommon:$n,IndexSystemFunction:er,Surface:tr,FunctionResponse:nr},ir=1e3;k({component:w().describe(`The type name of the component.`),id:Et(()=>In).optional(),weight:T().optional()}).passthrough().describe(`A generic A2UI component definition.`);var ar=class extends Error{constructor(e){super(e),this.name=`NonJsonValueError`}};function or(e,t=!1){return cr(e,t,/* @__PURE__ */ new Set,``)}function sr(e){try{return JSON.stringify(or(e,!0))}catch{return}}function cr(e,t,n,r){if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`){if(!Number.isFinite(e))throw new ar(`${lr(r)} is ${String(e)}`);return e}if(typeof e!=`object`)throw new ar(`${lr(r)} is a ${typeof e}`);if(n.has(e))throw new ar(`${lr(r)} is a circular reference`);n.add(e);try{if(Array.isArray(e))return e.map((e,i)=>{if(e===void 0)throw new ar(`${lr(`${r}/${i}`)} is undefined`);return cr(e,t,n,`${r}/${i}`)});let i=Object.getPrototypeOf(e);if(i!==Object.prototype&&i!==null){let t=e.constructor?.name||`object`;throw new ar(`${lr(r)} is a ${t}, not a plain object`)}let a=Object.keys(e);t&&a.sort();let o={};for(let i of a){let a=e[i];a!==void 0&&Object.defineProperty(o,i,{value:cr(a,t,n,`${r}/${i}`),enumerable:!0,writable:!0,configurable:!0})}return o}finally{n.delete(e)}}function lr(e){return e?`the value at '${e}'`:`the value`}var ur=/^[vV]?(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function dr(e){if(!e||typeof e!=`string`)return``;let t=e.trim().replace(/^[vV]/,``),n=t.indexOf(`-`),r=t.indexOf(`+`),i=t.length;return n!==-1&&r!==-1?i=Math.min(n,r):n===-1?r!==-1&&(i=r):i=n,`${t.slice(0,i).replace(/_/g,`.`)}${t.slice(i)}`}function fr(e){if(!e||typeof e!=`string`)return null;let t=e.trim().match(ur);return t?{major:parseInt(t[1],10),minor:parseInt(t[2],10),patch:t[3]===void 0?0:parseInt(t[3],10),prerelease:t[4]?t[4].split(`.`):[],build:t[5]?t[5].split(`.`):[]}:null}function pr(e){if(!e)return null;if(typeof e==`object`){let t=e;return typeof t.major!=`number`||!Number.isInteger(t.major)||t.major<0||typeof t.minor==`number`&&(!Number.isInteger(t.minor)||t.minor<0)||typeof t.patch==`number`&&(!Number.isInteger(t.patch)||t.patch<0)?null:{major:t.major,minor:typeof t.minor==`number`?t.minor:0,patch:typeof t.patch==`number`?t.patch:0,prerelease:Array.isArray(t.prerelease)?t.prerelease:[],build:Array.isArray(t.build)?t.build:[]}}return fr(dr(e))}function mr(e){if(!e)return null;let t=pr(e);if(!t)return null;if(t.patch===0&&t.prerelease.length===0&&t.build.length===0)return`${t.major}.${t.minor}`;let n=t.prerelease.length>0?`-${t.prerelease.join(`.`)}`:``,r=t.build.length>0?`+${t.build.join(`.`)}`:``;return`${t.major}.${t.minor}.${t.patch}${n}${r}`}function hr(e,t){let n=/^\d+$/.test(e),r=/^\d+$/.test(t);return n&&r?e.length===t.length?e<t?-1:+(e>t):e.length-t.length:n?-1:r?1:e<t?-1:+(e>t)}function gr(e,t){if(e.length===0&&t.length===0)return 0;if(e.length===0)return 1;if(t.length===0)return-1;let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=hr(e[r],t[r]);if(n!==0)return n}return e.length-t.length}function _r(e,t){let n=pr(e),r=pr(t);return!n&&!r?0:n?r?n.major===r.major?n.minor===r.minor?n.patch===r.patch?gr(n.prerelease,r.prerelease):n.patch-r.patch:n.minor-r.minor:n.major-r.major:1:-1}function R(e,t){if(!e)return!1;let n=pr(e),r=pr(t);return!n||!r?!1:_r(n,r)>=0}var vr=class{constructor(e){this.error=e}};function yr(e){if(e instanceof vr)return e;if(Array.isArray(e))for(let t of e){let e=yr(t);if(e)return e}else if(Cr(e))for(let t of Object.values(e)){let e=yr(t);if(e)return e}}var br=/* @__PURE__ */ new WeakMap;function xr(e,t){br.set(e,{value:t})}function Sr(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}function Cr(e){if(Array.isArray(e)||typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function wr(e){if(Sr(e)){let t=br.get(e);return t===void 0?Promise.resolve(e).then(wr):wr(t.value)}if(Array.isArray(e)){let t=e.map(wr);return t.some(Sr)?Promise.all(t):t.every((t,n)=>t===e[n])?e:t}if(Cr(e)){let t=Object.entries(e).map(([e,t])=>[e,wr(t)]);return t.some(([,e])=>Sr(e))?Promise.all(t.map(([,e])=>e)).then(e=>Object.fromEntries(t.map(([t],n)=>[t,e[n]]))):t.every(([t,n])=>n===e[t])?e:Object.fromEntries(t)}return e}var Tr;(function(e){e.V0_8=`v0.8`,e.V0_9=`v0.9`,e.V0_9_1=`v0.9.1`,e.V1_0=`1.0`})(Tr||={});function Er(e,t,n){let r=e.defaultCatalog??e.catalog;if(t!==void 0){let n=e.availableCatalogs?.get(t);if(n)return n;if(r&&r.id===t)return r;throw new I(`Catalog not found: ${t}`)}if(!r)throw new I(`${n} names no catalogId and surface '${e.id}' has no default catalogId.`);return r}var Dr=/* @__PURE__ */ t({AccessibilityAttributesSchema:()=>Fr,ActionSchema:()=>Kr,CallIdSchema:()=>kr,CheckRuleSchema:()=>Wr,CheckableSchema:()=>Gr,ChildListSchema:()=>zr,ChildSchema:()=>Rr,CommonSchemas:()=>Yr,ComponentCommonSchema:()=>Lr,ComponentIdSchema:()=>Or,DataBindingSchema:()=>Ar,DynamicBooleanSchema:()=>Pr,DynamicNumberSchema:()=>Vr,DynamicStringListSchema:()=>Hr,DynamicStringSchema:()=>Nr,DynamicValueSchema:()=>Br,ExtensionsSchema:()=>Ir,FunctionCallSchema:()=>Mr,FunctionCommonSchema:()=>jr,FunctionResponseSchema:()=>Jr,IndexSystemFunctionSchema:()=>Ur,SurfaceSchema:()=>qr}),Or=An(w().describe(`REF:#/$defs/ComponentId|The unique identifier for a component, used for both definitions and references within the same surface.`),`component-id`),kr=w().describe(`REF:#/$defs/CallId|The unique identifier for a function call.`),Ar=k({"@path":w().describe(`A JSON Pointer path to a value in the data model.`).optional(),path:w().describe(`A JSON Pointer path to a value in the data model.`).optional()}).refine(e=>e[`@path`]!==void 0||e.path!==void 0,{message:`Either '@path' or 'path' must be provided.`}).describe(`REF:#/$defs/DataBinding`),jr=k({"@call":w().describe(`The name of the function to call.`).optional(),call:w().describe(`The name of the function to call.`).optional(),catalogId:w().describe(`The catalog ID for this function, overriding any surface-level default catalogId.`).optional()}).refine(e=>e[`@call`]!==void 0||e.call!==void 0,{message:`Either '@call' or 'call' must be provided.`}).describe(`REF:#/$defs/FunctionCommon|Baseline envelope properties common to all function calls. Function-specific argument schemas ('args') are defined individually by each function in the active catalog.`),Mr=j(w(),wt()).and(Tt(jr,wt())).describe(`REF:#/$defs/FunctionCall|Invokes a named function, combining common function properties with the catalog function definition.`),Nr=A([w(),Ar,Mr]).describe(`REF:#/$defs/DynamicString|Represents a string`),Pr=A([E(),Ar,Mr]).describe(`REF:#/$defs/DynamicBoolean|A boolean value that can be a literal, a path, or a function call returning a boolean or a validation result object (coerced to its 'valid' boolean).`),Fr=k({label:Nr.optional(),description:Nr.optional(),live:M([`off`,`polite`,`assertive`]).describe(`Controls screen reader announcements for dynamic updates (WAI-ARIA aria-live). 'polite' waits for user pause; 'assertive' interrupts immediately for alerts.`).default(`off`),hidden:Pr.optional()}).strict().describe(`REF:#/$defs/AccessibilityAttributes|Attributes to enhance accessibility when using assistive technologies like screen readers or model understanding.`),Ir=j(w(),D()).superRefine((e,t)=>{for(let n in e)Nn(n)||t.addIssue({path:[n],code:g.custom,message:`Invalid extension key "${n}": Keys MUST be Unicode identifiers (UAX #31).`})}).describe(`REF:#/$defs/Extensions|Optional extension metadata. Keys MUST be Unicode identifiers (UAX #31). Keys starting with 'a2ui_' are reserved for official extensions.`),Lr=k({id:Or,"@catalogId":w().describe(`The catalog ID for this component, overriding any surface-level default catalogId.`).optional(),"@accessibility":Fr.optional(),"@metadata":k({extensions:Ir.optional()}).strict().describe(`Optional component-level metadata for vendor extensions.`).optional()}).describe(`REF:#/$defs/ComponentCommon`),Rr=Or,zr=An(A([O(Or).describe(`A static list of child component IDs.`),k({componentId:Or,path:w().describe(`The path to the list of component property objects in the data model.`)}).strict().describe("A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.")]).describe(`REF:#/$defs/ChildList`),`child-list`),Br=A([w(),T(),E(),O(wt()),j(w(),D()).refine(e=>!e||!(`@path`in e)&&!(`path`in e)&&!(`@call`in e)&&!(`call`in e)),Ar,Mr]).describe(`REF:#/$defs/DynamicValue|A value that can be a literal, a path, or a function call returning any type.`),Vr=A([T(),Ar,Mr]).describe(`REF:#/$defs/DynamicNumber|Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number.`),Hr=A([O(w()),Ar,Mr]).describe(`REF:#/$defs/DynamicStringList|Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array.`),Ur=k({"@call":Dt(`@index`).optional(),call:Dt(`@index`).optional(),args:k({offset:Vr.optional()}).optional()}).refine(e=>e[`@call`]!==void 0||e.call!==void 0,{message:`Either '@call' or 'call' must be '@index'.`}).describe(`REF:#/$defs/IndexSystemFunction`),Wr=k({condition:A([Ar,Mr]).describe(`Path or function call evaluating to a structured validation result object or a boolean.`),message:w().describe(`Optional fallback error message.`).optional()}).strict().describe(`REF:#/$defs/CheckRule|A single validation check rule applied to an input component. The condition function or path evaluates to a structured validation result object or a boolean (which is coerced to a validation result object).`),Gr=k({"@checks":O(Wr).describe(`A list of validation check rules to perform on the component.`).optional()}).describe(`REF:#/$defs/Checkable|Properties for components that support renderer-side checks.`),Kr=A([k({event:k({name:w().describe(`The name of the action to be dispatched to the agent.`),userMessage:Nr.optional(),context:j(w(),Br).describe(`A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.`).optional()}).strict().describe(`The event to dispatch to the agent.`)}).strict().describe(`Triggers an agent-side event.`),k({functionCall:Mr}).strict().describe(`Executes a renderer or agent-side function.`)]).describe(`REF:#/$defs/Action|Defines an interaction handler that can either trigger an agent-side event or execute a local renderer-side function.`),qr=k({component:Dt(`Surface`).optional(),child:Dt(`root`).optional()}).strict().describe(`REF:#/$defs/Surface|The reserved canonical container component representing an A2UI surface. The Surface component is immutable and always has 'child': 'root'.`),Jr=k({functionCallId:kr,value:wt().describe(`The return value of the function.`).optional(),error:k({code:w(),message:w()}).strict().describe(`An error object indicating failure of the function execution.`).optional()}).strict().superRefine((e,t)=>{let n=`value`in e,r=`error`in e;(n&&r||!n&&!r)&&t.addIssue({code:g.custom,message:`FunctionResponse must have either "value" or "error", but not both or neither.`})}).describe(`REF:#/$defs/FunctionResponse|The return response matching a callAgentFunction or callRendererFunction invocation.`),Yr={ComponentId:Or,CallId:kr,DataBinding:Ar,FunctionCommon:jr,FunctionCall:Mr,DynamicString:Nr,DynamicBoolean:Pr,AccessibilityAttributes:Fr,Extensions:Ir,ComponentCommon:Lr,Child:Rr,ChildList:zr,DynamicValue:Br,DynamicNumber:Vr,DynamicStringList:Hr,IndexSystemFunction:Ur,CheckRule:Wr,Checkable:Gr,Action:Kr,Surface:qr,FunctionResponse:Jr},Xr={name:`@index`,returnType:`number`,allowedCallers:`rendererOnly`,schema:k({offset:A([Ar,Mr,kt.number()]).optional()})},Zr=Y(Xr,(e,t)=>{let n=typeof e.offset==`number`&&Number.isFinite(e.offset)?e.offset:0,r=vi(t);if(r===void 0||!Number.isFinite(r))throw new P(`@index function can only be evaluated inside a collection template iteration scope.`);return r+n}),Qr=[Zr],$r;function ei(){if(!$r)throw Error(`DataContext internals have not been registered.`);return $r}function ti(e){$r=e}function ni(e,t,n,r,i){let a=ei(),o=i?.allowAgentRouting===!1?a.withFlags(e,{noAgentRouting:!0}):e;return a.resolveValue(o,t,n,r,!0)}function ri(e){return ei().allowsAgentRouting(e)}function ii(e,t){return ei().resolveSignalValue(e,t,0,!0)}function ai(e){return ei().withFlags(e,{noAgentRouting:!0})}function oi(e){return ei().activeCatalogId(e)}function si(e,t,n){let r=ei();return r.activeCatalogId(e)===t&&(n===void 0||r.activeCatalog(e)===n)?e:r.withFlags(e,{activeCatalogId:t,activeCatalog:n})}var ci=/* @__PURE__ */ new WeakMap,li=`a2ui:system-functions`,ui;function di(){return ui??=new Eu(li,Tr.V1_0,[],Qr),ui}function fi(e){if(ci.has(e))return ci.get(e);let t=(()=>{let t=e;for(;t;){if(t instanceof Qe||t._def?.typeName===`ZodObject`){if(t._def?.unknownKeys===`passthrough`)return null;let e=typeof t.shape==`function`?t.shape():t.shape;return e&&typeof e==`object`?new Set(Object.keys(e)):null}if(t instanceof ht||t._def?.typeName===`ZodEffects`)t=t._def.schema;else if(t instanceof gt||t instanceof _t||t._def?.typeName===`ZodOptional`||t._def?.typeName===`ZodNullable`)t=t._def.innerType;else if(t instanceof vt||t._def?.typeName===`ZodDefault`)t=t._def.innerType;else if(t instanceof yt||t._def?.typeName===`ZodCatch`)t=t._def.innerType;else{if(t instanceof rt||t._def?.typeName===`ZodIntersection`){let e=fi(t._def.left),n=fi(t._def.right);return!e||!n?null:/* @__PURE__ */ new Set([...e,...n])}if(t instanceof $e||t instanceof tt||t._def?.typeName===`ZodUnion`||t._def?.typeName===`ZodDiscriminatedUnion`){let e=t._def.options,n=/* @__PURE__ */ new Set;for(let t of e){let e=fi(t);if(!e)return null;for(let t of e)n.add(t)}return n}return null}}return null})();return ci.set(e,t),t}function pi(e,t,n){if(!t||typeof t!=`object`||Array.isArray(t))return;let r=Object.keys(t);if(r.length>1e3)throw new F(`Function call '${e}' exceeds maximum allowed arguments count (${ir})`,e);let i=n?.functions?.get?.(e)??(e===`@index`&&n?.protocolVersion&&R(n.protocolVersion,Tr.V1_0)?Xr:void 0);if(!i?.schema)return;let a=fi(i.schema);if(a){for(let t of r)if(!a.has(t))throw new F(`Unknown argument '${t}' passed to function '${e}'`,e);if(r.length>a.size)throw new F(`Too many arguments for function '${e}': expected at most ${a.size}, received ${r.length}`,e)}}function mi(e){return e.startsWith(`@`)&&!e.startsWith(`@@`)}function hi(e){return e.startsWith(`@@`)?e.slice(1):e}var gi=/* @__PURE__ */ new Set([`@path`,`@call`]);function _i(e,t){if(R(t,`1.0`)){for(let t of e)if(mi(t)&&!gi.has(t))throw new P(`Unrecognized reserved protocol directive '${t}' in v1.0 dynamic object. Reserved keys must be in ${Array.from(gi).join(`, `)}, or escaped with prefix doubling (e.g. '@${t}').`,void 0,`INVALID_RESERVED_KEY`)}}function vi(e){let t=e;for(;t;){if(t.explicitIndex!==void 0&&Number.isFinite(t.explicitIndex))return t.explicitIndex;if(!(t instanceof wi)&&typeof t.getIndex==`function`){let e=t.getIndex();if(e!==void 0&&Number.isFinite(e))return e}if(!(t instanceof wi)&&typeof t.index==`number`&&Number.isFinite(t.index))return t.index;if(typeof t.path==`string`){let e=t.path.split(`/`).filter(Boolean);if(e.length>0&&/^\d+$/.test(e[e.length-1]))return parseInt(e[e.length-1],10)}t=t.parent}}function yi(e){let t=new AbortController;return e?.aborted?t.abort():e?.addEventListener(`abort`,()=>t.abort(),{once:!0}),t}function bi(e,t){if(Sr(e))Promise.resolve(e).then(e=>{yr(e)&&t.abort()},()=>t.abort());else if(Array.isArray(e))for(let n of e)bi(n,t);else if(Cr(e))for(let n of Object.values(e))bi(n,t)}function xi(e){return e instanceof wn&&e.code===L.CANCELLED}function Si(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}var Ci=1e3,wi=class e{constructor(e,t,n,r){if(this.path=t,this._isUserActivated=!1,this._isPassiveEvaluation=!1,this._isActionExecution=!1,this._noAgentRouting=!1,e instanceof kn)this.surface=void 0,this.dataModel=e,this.functionInvoker=()=>void 0;else{this.surface=e,this.dataModel=e.dataModel;let t=e.defaultCatalog??e.catalog;this.functionInvoker=t?.invoker??((t,...n)=>Er(e,void 0,`Function call '${t}'`).invoker(t,...n))}this.explicitIndex=n,this.parent=r,this.warnedPaths=r?r.warnedPaths:/* @__PURE__ */ new Set}get isUserActivated(){return this._isUserActivated||!!this.parent?.isUserActivated}get isPassiveEvaluation(){return this._isPassiveEvaluation||!!this.parent?.isPassiveEvaluation}get isActionExecution(){return this._isActionExecution||!!this.parent?.isActionExecution}getIndex(){return vi(this)}get index(){return this.getIndex()}set(e,t){let n=this.resolvePath(e),r=!(!this.surfaceProtocolVersion||this.atLeastV10);this.dataModel.set(n,t,r)}get surfaceProtocolVersion(){return this.surface?.protocolVersion??this.surface?.defaultCatalog?.protocolVersion??this.activeCatalog?.protocolVersion??this.surface?.catalog?.protocolVersion}get atLeastV10(){return this._cachedAtLeastV10===void 0&&(this._cachedAtLeastV10=R(this.surfaceProtocolVersion,`1.0`)),this._cachedAtLeastV10}isDataBindingObject(e){return(this.atLeastV10?`@path`in e&&typeof e[`@path`]==`string`:`path`in e&&typeof e.path==`string`)&&!(`componentId`in e)}isFunctionCallObject(e){return this.atLeastV10?`@call`in e&&typeof e[`@call`]==`string`:`call`in e&&typeof e.call==`string`}containsDynamicValue(e){if(typeof e!=`object`||!e||Sr(e))return!1;if(Array.isArray(e))return e.some(e=>this.containsDynamicValue(e));let t=e;if(this.isDataBindingObject(t)||this.isFunctionCallObject(t))return!0;if(this.atLeastV10){for(let e of Object.keys(t))if(e.startsWith(`@`))return!0}return Object.values(t).some(e=>this.containsDynamicValue(e))}emitMissingDataBindingWarning(e){typeof this.dataModel?.hasPath==`function`&&!this.dataModel.hasPath(e)&&!this.warnedPaths.has(e)&&(this.warnedPaths.add(e),this.surface?.dispatchWarning?.({code:`MISSING_DATA_BINDING`,path:e,message:`Preflight DataBinding Warning: The bound JSON Pointer '${e}' does not physically exist in the active DataModel. Evaluating to None.`}))}resolveDynamicValue(e,t=0,n=!1){return this.resolveValue(e,t,n,!1)}resolveValue(e,t,n,r,i){if(t>1e3){let e=new F(`Maximum dynamic value nesting depth exceeded (${Ci})`);return this.dispatchExpressionError(e,`DynamicValue`),r?this.failedArgument(e):void 0}if(typeof e!=`object`||!e||Sr(e))return e;if(Array.isArray(e))return this.containsDynamicValue(e)?e.map(e=>this.resolveValue(e,t+1,n,r,i)):e;let a=e;if(this.isDataBindingObject(a)){let e=a[`@path`]??a.path,t=this.resolvePath(e),n=this.dataModel.get(t);return n===void 0&&this.emitMissingDataBindingWarning(t),n}return this.isFunctionCallObject(a)?this.resolveFunctionCallValue(a,t,n,r,i):this.resolvePlainObjectValue(a,t,n,r,i)}resolveFunctionCallValue(e,t,n,r,i){let a=e[`@call`]??e.call,o=this.resolveCallCatalog(a,e);if(!o)return r?this.failedArgument(void 0):void 0;try{pi(a,e.args,o)}catch(e){return this.dispatchExpressionError(e,a),r?this.failedArgument(e):void 0}let s=yi(i),c={};for(let[i,a]of Object.entries(e.args??{})){let e=this.resolveValue(a,t+1,n,!0,s.signal),o=yr(e);if(o)return s.abort(),r?o:void 0;Si(c,i,e)}bi(c,s);let l=a.startsWith(`@`)?void 0:o.id,u=n&&!this.isUserActivated||l!==void 0?this.withFlags({userActivated:n&&!this.isUserActivated,activeCatalogId:l,activeCatalog:l===void 0?void 0:o}):this,d=u.evaluateFunctionReactive(a,c,o.invoker,s.signal,r);if(d!==void 0)return d instanceof vr?(s.abort(),r?d:void 0):Sr(d)?r?u.keepPendingResult(d,a,s.signal):Promise.resolve(d).then(e=>{if(!(e instanceof vr))return hn(e)?vn(e):e},e=>{u.dispatchExpressionError(e,a)}):hn(d)?vn(d):d}resolvePlainObjectValue(e,t,n,r,i){if(this.atLeastV10&&_i(Object.keys(e),this.surfaceProtocolVersion),!this.containsDynamicValue(e))return e;let a={};for(let[o,s]of Object.entries(e))Si(a,this.atLeastV10?hi(o):o,this.resolveValue(s,t+1,n,r,i));return a}subscribeDynamicValue(e,t){let n=this.resolveSignal(e),r=!0,i=vn(n),a=pn(()=>{let e=gn(n);i=e,r||t(e)});return r=!1,{get value(){return i},unsubscribe:()=>{a(),n.unsubscribe?.()}}}resolveSignal(e,t=0){return this.resolveSignalValue(e,t,!1)}resolveSignalValue(e,t,n){if(t>1e3){let t=new F(`Maximum dynamic value nesting depth exceeded (${Ci})`);return this.dispatchExpressionError(t,typeof e==`object`&&e&&(`@call`in e||`call`in e)?e[`@call`]??e.call:`DynamicValue`),dn(n?this.failedArgument(t):void 0)}if(typeof e!=`object`||!e)return dn(e);if(Sr(e)){if(n)return dn(this.keepPendingResult(e,`DynamicValue`));let t=dn(void 0);return this.settleIntoSignal(t,e,`DynamicValue`),t}if(Array.isArray(e)){if(!this.containsDynamicValue(e))return dn(e);let r=e.map(e=>this.resolveSignalValue(e,t+1,n)),i=fn(()=>r.map(e=>gn(e)));return i.unsubscribe=()=>{for(let e of r)e.unsubscribe?.()},i}let r=e;if(this.isDataBindingObject(r)){let e=r[`@path`]??r.path,t=this.resolvePath(e);return this.emitMissingDataBindingWarning(t),this.dataModel.getSignal(t)}if(this.isFunctionCallObject(r)){let e=r,i=e[`@call`]??e.call,a=this.resolveCallCatalog(i,e);if(!a)return dn(n?this.failedArgument(void 0):void 0);try{pi(i,e.args,a)}catch(e){return this.dispatchExpressionError(e,i),dn(n?this.failedArgument(e):void 0)}let o=i.startsWith(`@`)?void 0:a.id,s=this.withFlags({passive:!0,activeCatalogId:o,activeCatalog:o===void 0?void 0:a}),c={};for(let[n,r]of Object.entries(e.args??{}))c[n]=this.resolveSignalValue(r,t+1,!0);if(Object.keys(c).length===0){let e=new AbortController,t=s.evaluateFunctionReactive(i,{},a.invoker,e.signal,n),r;if(hn(t))r=t;else if(Sr(t)){let a=dn(void 0);n?_n(a,s.keepPendingResult(t,i,e.signal,{onSignal:t=>s.forwardSignal(a,t,e.signal)})):s.settleIntoSignal(a,t,i,e.signal),r=a}else r=t instanceof vr?dn(n?t:this.atLeastV10?null:void 0):dn(t);return r.unsubscribe=()=>e.abort(),r}let l=Object.keys(c),u=dn(void 0),d,f,p,m=fn(()=>{let e={};for(let t=0;t<l.length;t++)Si(e,l[t],gn(c[l[t]]));return e}),h=pn(()=>{let e;try{let t=gn(m);if(e=sr(t),e!==void 0&&e===p)return;p=void 0,d&&d.abort(),f&&=(f(),void 0);let r=new AbortController;d=r;let o=e,c=()=>{r.signal.aborted||(p=o)},l=s.evaluateFunctionReactive(i,t,a.invoker,r.signal,n);hn(l)?(_n(u,vn(l)),f=pn(()=>{_n(u,gn(l))})):Sr(l)?n?_n(u,s.keepPendingResult(l,i,r.signal,{onSignal:e=>s.forwardSignal(u,e,r.signal),onFailure:c})):s.settleIntoSignal(u,l,i,r.signal,c):l instanceof vr?(c(),_n(u,n?l:this.atLeastV10?null:void 0)):_n(u,l)}catch(t){p=e,s.dispatchExpressionError(t,i),_n(u,n?s.failedArgument(t):void 0)}});return u.unsubscribe=()=>{h(),f&&f(),d&&d.abort();for(let e=0;e<l.length;e++)c[l[e]].unsubscribe?.()},u}if(this.atLeastV10&&_i(Object.keys(r),this.surfaceProtocolVersion),!this.containsDynamicValue(r))return dn(e);let i=Object.entries(r).map(([e,r])=>[this.atLeastV10?hi(e):e,this.resolveSignalValue(r,t+1,n)]),a=fn(()=>{let e={};for(let[t,n]of i)Si(e,t,gn(n));return e}),o=a.unsubscribe?.bind(a);return a.unsubscribe=()=>{o?.();for(let[,e]of i)e.unsubscribe?.()},a}handleInvalidAction(e){this.surface?.dispatchError({code:`INVALID_ACTION`,surfaceId:this.surface?.id,message:e})}resolveActionEventObject(e,t){if(typeof e.name!=`string`||e.name.length===0)return this.handleInvalidAction(`Action event is missing required 'name' string.`);let n=t?.userActivation??!0,r=this.withFlags({action:!0,passive:t?.userActivation===!1}),i=e.context&&typeof e.context==`object`&&!Array.isArray(e.context)?Object.entries(e.context):void 0,a=e.userMessage!==void 0,o=(i?.length??0)+ +!!a,s={},c,l=()=>{let t={...e};if(i&&(t.context=s),e.context===void 0&&delete t.context,a){if(c==null)delete t.userMessage;else if(typeof c!=`string`)return this.handleInvalidAction(`Action event 'userMessage' must resolve to a string.`);else t.userMessage=c}return t},u=t=>{for(let a=t;a<o;a++){let t=i?.[a],o=new AbortController,l;try{l=r.resolveValue(t?t[1]:e.userMessage,0,n,!0,o.signal)}catch(e){o.abort(),this.surface?.dispatchError({code:`EXPRESSION_ERROR`,surfaceId:this.surface?.id,message:`Action event ${t?`context entry '${t[0]}'`:`userMessage`} is invalid: ${e?.message??String(e)}`});return}let d=e=>yr(e)?(o.abort(),!1):(t?Si(s,t[0],e):c=e,!0),f=wr(l);if(Sr(f))return Promise.resolve(f).then(e=>d(e)?u(a+1):void 0,e=>{o.abort(),r.dispatchExpressionError(e,`DynamicValue`)});if(!d(f))return}return l()};return u(0)}executeActionFunctionCall(e,t){let n=`functionCall`in e?e.functionCall:e;if(n&&typeof n==`object`){let e=n[`@call`]??n.call;typeof e==`string`&&(n=this.atLeastV10&&!(`@call`in n)?{"@call":e,...n}:!this.atLeastV10&&!(`call`in n)?{call:e,...n}:n)}let r=t?.userActivation??!0;return this.withFlags({action:!0,passive:t?.userActivation===!1}).resolveValue(n,0,r,!1)}resolveAction(e,t){if(`event`in e&&typeof e.event==`object`&&e.event!==null){let n=this.resolveActionEventObject(e.event,t),r=t=>t===void 0?void 0:{...e,event:t};return Sr(n)?Promise.resolve(n).then(r):r(n)}return`name`in e?this.resolveActionEventObject(e,t):`functionCall`in e||`call`in e||`@call`in e?this.executeActionFunctionCall(e,t):e}resolveFunctionCatalog(e,t,n){if(this.atLeastV10&&e.startsWith(`@`)){if(n)throw new F(`System function '${e}' belongs to no catalog and must not name a catalogId.`,e);return di()}let r=this.atLeastV10?t:void 0;if(typeof r==`string`){let e=this.lookupActiveCatalog(r);if(e)return e}if(!this.surface)throw new I(`No surface available to resolve catalog: ${t??`default`}`);return Er(this.surface,r,`Function call '${e}'`)}resolveCallCatalog(e,t){try{return this.resolveFunctionCatalog(e,t.catalogId,`catalogId`in t)}catch(t){t instanceof I&&this.surface?this.surface.dispatchError({code:`CATALOG_ERROR`,message:t.message,expression:e}):this.dispatchExpressionError(t,e);return}}withFlags(e){let t=Object.create(this);return t._isUserActivated=this._isUserActivated||!!e.userActivated,t._isPassiveEvaluation=this._isPassiveEvaluation||!!e.passive,t._isActionExecution=this._isActionExecution||!!e.action,t._noAgentRouting=this._noAgentRouting||!!e.noAgentRouting,t._activeCatalogId=e.activeCatalogId??this._activeCatalogId,t._activeCatalog=e.activeCatalog===void 0?e.activeCatalogId!==void 0&&e.activeCatalogId!==this._activeCatalogId?void 0:this._activeCatalog:e.activeCatalog,(e.activeCatalogId!==void 0||e.activeCatalog!==void 0)&&(t._cachedAtLeastV10=void 0),t}get activeCatalogId(){return this._activeCatalogId??this.parent?.activeCatalogId}get activeCatalog(){return this._activeCatalogId===void 0?this.parent?.activeCatalog:this._activeCatalog}lookupActiveCatalog(e){let t=this.activeCatalog;return t?.id===e?t:void 0}get allowsAgentRouting(){return!this._noAgentRouting&&(this.parent?.allowsAgentRouting??!0)}failedArgument(e){return this.atLeastV10?new vr(e):void 0}evaluateFunctionReactive(e,t,n,r,i=!1){try{return n(e,t,this,r)}catch(t){return this.dispatchExpressionError(t,e),i?this.failedArgument(t):void 0}}keepPendingResult(e,t,n,r){let i=Promise.resolve(e).then(e=>{let t=hn(e)?vn(e):e;return xr(i,t),hn(e)&&!n?.aborted&&r?.onSignal?.(e),t},e=>{n?.aborted||(xi(e)||r?.onFailure?.(),this.dispatchExpressionError(e,t));let a=this.failedArgument(e);return xr(i,a),a});return i}settleIntoSignal(e,t,n,r,i){Promise.resolve(t).then(t=>{r?.aborted||this.surface?.disposed||(t instanceof vr?_n(e,this.atLeastV10?null:void 0):hn(t)&&r?this.forwardSignal(e,t,r):_n(e,hn(t)?vn(t):t))},t=>{if(r?.aborted||this.surface?.disposed)return;let a=xi(t);a||i?.(),this.dispatchExpressionError(t,n),_n(e,!a&&this.atLeastV10?null:void 0)})}forwardSignal(e,t,n){if(n.aborted)return;let r=pn(()=>{_n(e,gn(t))});n.addEventListener(`abort`,()=>r(),{once:!0})}dispatchExpressionError(e,t){if(this.surface&&!this.surface.disposed&&!xi(e)){if(e instanceof _||typeof e==`object`&&e&&e.name===`ZodError`){let n=e,r=new F(`Validation failed for function '${t}': ${n.message}`,t,n.errors??n.issues);this.surface.dispatchError({code:`EXPRESSION_ERROR`,message:r.message,expression:t,details:r.details})}else if(e instanceof F)this.surface.dispatchError({code:`EXPRESSION_ERROR`,message:e.message,expression:e.expression,details:e.details});else{let n=typeof e==`object`&&e?e:{},r=e instanceof wn;this.surface.dispatchError({code:this.isActionExecution&&!r?`EXECUTION_ERROR`:`EXPRESSION_ERROR`,message:n.message??`An unexpected error occurred in function ${t}.`,expression:t,...r&&e.functionCallId?{functionCallId:e.functionCallId}:{}})}}}nested(t,n){let r=this.resolvePath(t);return new e(this.surface??this.dataModel,r,n,this)}resolvePath(e){if(e.startsWith(`/`))return e;let t=this.path;return t.endsWith(`/`)&&t.length>1&&(t=t.slice(0,-1)),e===``||e===`.`?t||`/`:(t===`/`&&(t=``),`${t}/${e}`)}};ti({withFlags:(e,t)=>e.withFlags(t),resolveValue:(e,t,n,r,i)=>e.resolveValue(t,n,r,i),allowsAgentRouting:e=>e.allowsAgentRouting,resolveSignalValue:(e,t,n,r)=>e.resolveSignalValue(t,n,r),activeCatalogId:e=>e.activeCatalogId,activeCatalog:e=>e.activeCatalog});function Ti(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ei(e){if(!Ti(e))throw new P(`Invalid metadata.extensions: expected a plain object.`);for(let t of Object.keys(e))if(!Nn(t))throw new P(`Invalid UAX #31 extension identifier: "${t}". Keys MUST be Unicode identifiers (UAX #31).`)}function Di(e){if(e!==void 0){if(!Ti(e))throw new P(`Invalid metadata: expected a plain object.`);for(let t of Object.keys(e))if(t!==`extensions`)throw new P(`Unexpected property "${t}" in metadata; only "extensions" is allowed.`);`extensions`in e&&e.extensions!==void 0&&Ei(e.extensions)}}function Oi(e){if(Array.isArray(e)){let t=e.map(e=>Oi(e));return Object.freeze(t)}if(Ti(e)){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&Object.defineProperty(t,n,{value:Oi(r),enumerable:!0,configurable:!0,writable:!0});return Object.freeze(t)}return e}function ki(e,t){if(Di(e),Di(t),e===void 0&&t===void 0)return;if(e===void 0)return Ai(t);if(t===void 0)return Ai(e);let n={};if(Ti(e.extensions))for(let[t,r]of Object.entries(e.extensions))Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0});if(Ti(t.extensions))for(let[e,r]of Object.entries(t.extensions))Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0});return Ai(Object.keys(n).length>0?{extensions:n}:{})}function Ai(e){if(e!==void 0&&(Di(e),e.extensions&&Object.keys(e.extensions).length!==0))return Oi(e)}function ji(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ni(e[n],t[n]))return!1;return!0}function Mi(e,t){let n=Object.keys(e).filter(t=>e[t]!==void 0),r=Object.keys(t).filter(e=>t[e]!==void 0);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Ni(e[r],t[r]))return!1;return!0}function Ni(e,t){return Object.is(e,t)?!0:Array.isArray(e)&&Array.isArray(t)?ji(e,t):Ti(e)&&Ti(t)?Mi(e,t):!1}function Pi(e,t){return Ni(e,t)}var Fi=Symbol.for(`@a2ui/web_core/AgentFunction`);function Ii(e){return typeof e==`object`&&!!e&&e[Fi]===!0&&typeof e.handler==`function`}var Li=/* @__PURE__ */ new WeakMap;function Ri(e){return Li.get(e)}function zi(e,t){let n=Li.get(e);n!==void 0&&Li.set(t,n)}function Bi(e,t){for(let[n,r]of Object.entries(t)){let t=!1,i;Object.defineProperty(e,n,{enumerable:!0,get(){return t||=(i=r(),!0),i}})}}function Vi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Hi(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):void 0}var Ui=class{constructor(e,t,n){this.name=e,Li.set(this,t),Bi(this,{schema:()=>n(t),allowedParents:()=>Hi(t.allowedParents),allowedChildren:()=>Hi(t.allowedChildren),metadata:()=>Vi(t.metadata)?t.metadata:void 0}),Object.freeze(this)}get jsonSchema(){return Li.get(this)}},Wi=class{constructor(e,t,n){this.name=e,Li.set(this,t);let r=Vi(t.properties)?t.properties:void 0,i=e=>{let t=r?.[e];return Vi(t)?t.const:void 0};Bi(this,{schema:()=>n(t),returnType:()=>{let e=t.returnType??i(`returnType`);return typeof e==`string`?e:`any`},description:()=>typeof t.description==`string`?t.description:void 0,allowedCallers:()=>t.allowedCallers??i(`allowedCallers`),requiresUserActivation:()=>t.requiresUserActivation??i(`requiresUserActivation`)}),Object.freeze(this)}get jsonSchema(){return Li.get(this)}},Gi=/* @__PURE__ */ new WeakMap,Ki=/* @__PURE__ */ new WeakMap;function qi(e,t=e.description){return(Ki.get(e)??S?.prototype?.describe??e.describe).call(e,t)}function Ji(e,t,n=e.description){let r=qi(e,n);return Ki.set(r,S?.prototype?.describe??r.describe),Gi.set(r,t),r.describe=e=>Ji(r,Gi.get(r)??t,e),r}function z(e,t){let n=qi(e,e.description);return Gi.set(n,{...Gi.get(e),...t}),n}function Yi(e,t,n={}){let r=Ji(t,{...Gi.get(t),...n,defName:e});return Gi.set(r,{...Gi.get(r),defName:e,defModel:r}),r}function Xi(e){return typeof e==`object`&&e?Gi.get(e):void 0}var Zi=/* @__PURE__ */ t({AccessibilityAttributesSchema:()=>V,ActionSchema:()=>la,CheckRuleSchema:()=>sa,CheckableSchema:()=>ca,ChildListSchema:()=>ra,CommonSchemas:()=>ua,ComponentCommonSchema:()=>na,ComponentIdSchema:()=>Qi,DataBindingSchema:()=>$i,DynamicBooleanSchema:()=>aa,DynamicNumberSchema:()=>ia,DynamicStringListSchema:()=>oa,DynamicStringSchema:()=>B,DynamicValueSchema:()=>ea,FunctionCallSchema:()=>ta}),Qi=An(w().describe(`REF:#/$defs/ComponentId|The unique identifier for a component, used for both definitions and references within the same surface.`),`component-id`),$i=k({path:w().describe(`A JSON Pointer path to a value in the data model.`)}).strict().describe(`REF:#/$defs/DataBinding`),ea=A([w(),T(),E(),O(wt()),$i,Et(()=>ta)]).describe(`REF:#/$defs/DynamicValue|A value that can be a literal, a path, or a function call returning any type.`),ta=k({call:w().describe(`The name of the function to call.`),args:j(w(),A([ea,j(w(),wt()).describe(`A literal object argument (e.g. configuration).`)])).describe(`Arguments passed to the function.`).optional(),returnType:M([`string`,`number`,`boolean`,`array`,`object`,`any`,`void`]).describe(`The expected return type of the function call.`).default(`boolean`)}).describe(`REF:#/$defs/FunctionCall|Invokes a named function on the client.`),B=A([w(),$i,ta]).describe(`REF:#/$defs/DynamicString|Represents a string`),V=k({label:B.optional(),description:B.optional()}).describe(`REF:#/$defs/AccessibilityAttributes|Attributes to enhance accessibility when using assistive technologies like screen readers.`),na=k({id:Qi,accessibility:V.optional()}).describe(`REF:#/$defs/ComponentCommon`),ra=An(A([O(Qi).describe(`A static list of child component IDs.`),k({componentId:Qi,path:w().describe(`The path to the list of component property objects in the data model.`)}).strict().describe("A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.")]).describe(`REF:#/$defs/ChildList`),`child-list`),ia=A([T(),$i,ta]).describe(`REF:#/$defs/DynamicNumber|Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number.`),aa=A([E(),$i,ta]).describe(`REF:#/$defs/DynamicBoolean|A boolean value that can be a literal, a path, or a function call returning a boolean.`),oa=A([O(w()),$i,ta]).describe(`REF:#/$defs/DynamicStringList|Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array.`),sa=k({condition:aa,message:w().describe(`The error message to display if the check fails.`)}).strict().describe(`REF:#/$defs/CheckRule|A single validation rule applied to an input component.`),ca=k({checks:O(sa).describe(`A list of checks to perform. These are function calls that must return a boolean indicating validity.`).optional()}).describe(`REF:#/$defs/Checkable|Properties for components that support client-side checks.`),la=A([k({event:k({name:w().describe(`The name of the action to be dispatched to the server.`),context:j(w(),ea).describe(`A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.`).optional()}).strict().describe(`The event to dispatch to the server.`)}).strict().describe(`Triggers a server-side event.`),k({functionCall:ta}).strict().describe(`Executes a local client-side function.`)]).describe(`REF:#/$defs/Action|Defines an interaction handler that can either trigger a server-side event or execute a local client-side function.`),ua={ComponentId:Qi,DataBinding:$i,DynamicValue:ea,FunctionCall:ta,DynamicString:B,AccessibilityAttributes:V,ComponentCommon:na,ChildList:ra,DynamicNumber:ia,DynamicBoolean:aa,DynamicStringList:oa,CheckRule:sa,Checkable:ca,Action:la},da=[`metadata`,`catalogId`,`accessibility`,`checks`],fa=new Set(da.map(pa));function pa(e){return`@${e}`}var ma=/* @__PURE__ */ new WeakSet;function ha(e){return ma.add(e),e}for(let e of[Fn,Zi,Dr]){for(let[t,n]of Object.entries(e.ComponentCommonSchema.shape))t!==`id`&&ha(n);for(let t of Object.values(e.CheckableSchema.shape))ha(t);ha(e.CheckRuleSchema),ha(e.AccessibilityAttributesSchema)}var ga={customKeys:/* @__PURE__ */ new Set,schemaKeys:/* @__PURE__ */ new Map},_a=/* @__PURE__ */ new WeakMap,va=/* @__PURE__ */ new Set([`ZodOptional`,`ZodNullable`,`ZodDefault`,`ZodCatch`,`ZodReadonly`]);function ya(e){let t=e?.typeName;if(t===`ZodEffects`)return e.schema;if(va.has(t))return e.innerType;if(t===`ZodBranded`)return e.type;if(t===`ZodLazy`)return e.getter()}function ba(e,t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set){let r=e;for(;r&&!n.has(r);){n.add(r);let e=r._def;switch(e?.typeName){case`ZodObject`:{let e=typeof r.shape==`function`?r.shape():r.shape;for(let[n,r]of Object.entries(e)){let i={schema:r,siblings:e},a=t.get(n);a?a.push(i):t.set(n,[i])}return t}case`ZodIntersection`:return ba(e.left,t,n),ba(e.right,t,n),t;case`ZodUnion`:case`ZodDiscriminatedUnion`:for(let r of e.options)ba(r,t,n);return t;case`ZodPipeline`:return ba(e.in,t,n),ba(e.out,t,n),t}r=ya(e)}return t}function xa(e){let t=e;for(;t&&!ma.has(t);){let e=ya(t._def);if(!e)break;t=e}return t}function Sa(e){let t=e?.description;if(typeof t==`string`&&t.startsWith(`REF:`))return t.slice(4).split(`|`)[0].split(`/`).pop()}function Ca(e,t,{schema:n,siblings:r}){let i=xa(n);if(ma.has(n)||ma.has(i))return!0;let a=Xi(e)?.mixins??[];switch(t){case`checks`:{if(a.includes(`Checkable`))return!0;if(i?._def?.typeName!==`ZodArray`)return!1;let e=xa(i._def.type);return ma.has(e)||Sa(e)===`CheckRule`}case`accessibility`:return Sa(i)===`AccessibilityAttributes`;case`catalogId`:return Object.hasOwn(r,`id`)&&i?._def?.typeName===`ZodString`;case`metadata`:{if(!Object.hasOwn(r,`id`)||i?._def?.typeName!==`ZodObject`)return!1;let e=Object.keys(typeof i.shape==`function`?i.shape():i.shape);return e.length===1&&e[0]===`extensions`}}}function wa(e){if(!e)return ga;let t=_a.get(e);if(t)return t;let n=ba(e),r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map;for(let t of da){let a=pa(t),o=n.get(t);n.has(a)?(i.set(t,a),o&&!o.every(({schema:e})=>ma.has(e))&&r.add(t)):o&&(o.every(n=>Ca(e,t,n))?i.set(t,t):r.add(t))}let a={customKeys:r,schemaKeys:i};return _a.set(e,a),a}function Ta(e,t,n){if(!e.customKeys.has(`catalogId`)||t[pa(`catalogId`)]!==void 0||t.catalogId===void 0||wa(n).customKeys.has(`catalogId`))return e;let r=new Set(e.customKeys);return r.delete(`catalogId`),{customKeys:r,schemaKeys:e.schemaKeys}}function Ea(e,t){let n={};for(let[t,r]of Object.entries(e))t===`id`||t===`component`||fa.has(t)||(n[t]=r);let r={};for(let i of da){let a=pa(i),o=e[a]!==void 0,s=e[i]!==void 0,c=t.customKeys.has(i);if(o&&s&&!c){let t=`Component '${String(e.id)}' cannot specify both '${a}' and legacy '${i}'.`;throw new P(t,[{path:`/${a}`,code:`invalid_value`,message:t}],`VALIDATION_ERROR`,{path:`/${a}`})}o?r[i]={value:e[a],wireKey:a}:s&&!c&&(i!==`checks`||t.schemaKeys.has(`checks`))&&(r[i]={value:e[i],wireKey:i},delete n[i])}return{properties:n,mixins:r}}function Da(e,t,n,r){if(!R(t,`1.0`)){let{id:t,component:n,...r}=e;return{properties:r,metadata:void 0}}let i=wa(n);r&&(i=Ta(i,e,r.defaultCatalogSchema));let{properties:a,mixins:o}=Ea(e,i);return o.accessibility&&(a[pa(`accessibility`)]=o.accessibility.value),o.checks&&(a[pa(`checks`)]=o.checks.value),{properties:a,metadata:o.metadata?.value}}var Oa=Symbol(`Let zodToJsonSchema decide on which parser to use`),ka={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,target:`jsonSchema7`,strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`,openAiAnyTypeName:`OpenAiAnyType`},Aa=e=>typeof e==`string`?{...ka,name:e}:{...ka,...e},ja=e=>{let t=Aa(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function Ma(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function H(e,t,n,r,i){e[t]=n,Ma(e,t,r,i)}var Na=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function Pa(e){if(e.target!==`openAi`)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy===`relative`?Na(t,e.currentPath):t.join(`/`)}}function Fa(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==C.ZodAny&&(n.items=U(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&H(n,`minItems`,e.minLength.value,e.minLength.message,t),e.maxLength&&H(n,`maxItems`,e.maxLength.value,e.maxLength.message,t),e.exactLength&&(H(n,`minItems`,e.exactLength.value,e.exactLength.message,t),H(n,`maxItems`,e.exactLength.value,e.exactLength.message,t)),n}function Ia(e,t){let n={type:`integer`,format:`int64`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`min`:t.target===`jsonSchema7`?r.inclusive?H(n,`minimum`,r.value,r.message,t):H(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),H(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?H(n,`maximum`,r.value,r.message,t):H(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),H(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:H(n,`multipleOf`,r.value,r.message,t)}return n}function La(){return{type:`boolean`}}function Ra(e,t){return U(e.type._def,t)}var za=(e,t)=>U(e.innerType._def,t);function Ba(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>Ba(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return Va(e,t)}}var Va=(e,t)=>{let n={type:`integer`,format:`unix-time`};if(t.target===`openApi3`)return n;for(let r of e.checks)switch(r.kind){case`min`:H(n,`minimum`,r.value,r.message,t);break;case`max`:H(n,`maximum`,r.value,r.message,t)}return n};function Ha(e,t){return{...U(e.innerType._def,t),default:e.defaultValue()}}function Ua(e,t){return t.effectStrategy===`input`?U(e.schema._def,t):Pa(t)}function Wa(e){return{type:`string`,enum:Array.from(e.values)}}var Ga=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function Ka(e,t){let n=[U(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),U(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=t.target===`jsonSchema2019-09`?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(e=>{if(Ga(e))i.push(...e.allOf),e.unevaluatedProperties===void 0&&(r=void 0);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}else r=void 0;i.push(t)}}),i.length?{allOf:i,...r}:void 0}function qa(e,t){let n=typeof e.value;return n!==`bigint`&&n!==`number`&&n!==`boolean`&&n!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:t.target===`openApi3`?{type:n===`bigint`?`integer`:n,enum:[e.value]}:{type:n===`bigint`?`integer`:n,const:e.value}}var Ja=void 0,Ya={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Ja===void 0&&(Ja=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),Ja),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Xa(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:H(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t);break;case`max`:H(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`email`:switch(t.emailStrategy){case`format:email`:eo(n,`email`,r.message,t);break;case`format:idn-email`:eo(n,`idn-email`,r.message,t);break;case`pattern:zod`:to(n,Ya.email,r.message,t)}break;case`url`:eo(n,`uri`,r.message,t);break;case`uuid`:eo(n,`uuid`,r.message,t);break;case`regex`:to(n,r.regex,r.message,t);break;case`cuid`:to(n,Ya.cuid,r.message,t);break;case`cuid2`:to(n,Ya.cuid2,r.message,t);break;case`startsWith`:to(n,RegExp(`^${Za(r.value,t)}`),r.message,t);break;case`endsWith`:to(n,RegExp(`${Za(r.value,t)}$`),r.message,t);break;case`datetime`:eo(n,`date-time`,r.message,t);break;case`date`:eo(n,`date`,r.message,t);break;case`time`:eo(n,`time`,r.message,t);break;case`duration`:eo(n,`duration`,r.message,t);break;case`length`:H(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t),H(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`includes`:to(n,RegExp(Za(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&eo(n,`ipv4`,r.message,t),r.version!==`v4`&&eo(n,`ipv6`,r.message,t);break;case`base64url`:to(n,Ya.base64url,r.message,t);break;case`jwt`:to(n,Ya.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&to(n,Ya.ipv4Cidr,r.message,t),r.version!==`v4`&&to(n,Ya.ipv6Cidr,r.message,t);break;case`emoji`:to(n,Ya.emoji(),r.message,t);break;case`ulid`:to(n,Ya.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:eo(n,`binary`,r.message,t);break;case`contentEncoding:base64`:H(n,`contentEncoding`,`base64`,r.message,t);break;case`pattern:zod`:to(n,Ya.base64,r.message,t)}break;case`nanoid`:to(n,Ya.nanoid,r.message,t)}return n}function Za(e,t){return t.patternStrategy===`escape`?$a(e):e}var Qa=/* @__PURE__ */ new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function $a(e){let t=``;for(let n=0;n<e.length;n++)Qa.has(e[n])||(t+=`\\`),t+=e[n];return t}function eo(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):H(e,`format`,t,n,r)}function to(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:no(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):H(e,`pattern`,no(t,r),n,r)}function no(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++)if(a)i+=r[e],a=!1;else{if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
2
+ ]))`;continue}if(r[e]===`$`){i+=`($|(?=[\r
3
+ ]))`;continue}}n.s&&r[e]===`.`?i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`:(i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0))}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function ro(e,t){if(t.target===`openAi`&&console.warn(`Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.`),t.target===`openApi3`&&e.keyType?._def.typeName===C.ZodEnum)return{type:`object`,required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,r)=>({...n,[r]:U(e.valueType._def,{...t,currentPath:[...t.currentPath,`properties`,r]})??Pa(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:`object`,additionalProperties:U(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(t.target===`openApi3`)return n;if(e.keyType?._def.typeName===C.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=Xa(e.keyType._def,t);return{...n,propertyNames:i}}if(e.keyType?._def.typeName===C.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===C.ZodBranded&&e.keyType._def.type._def.typeName===C.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=Ra(e.keyType._def,t);return{...n,propertyNames:i}}return n}function io(e,t){return t.mapStrategy===`record`?ro(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[U(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Pa(t),U(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Pa(t)],minItems:2,maxItems:2}}}function ao(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function oo(e){return e.target===`openAi`?void 0:{not:Pa({...e,currentPath:[...e.currentPath,`not`]})}}function so(e){return e.target===`openApi3`?{enum:[`null`],nullable:!0}:{type:`null`}}var co={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function lo(e,t){if(t.target===`openApi3`)return uo(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in co&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=co[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return uo(e,t)}var uo=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>U(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function fo(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target===`openApi3`?{type:co[e.innerType._def.typeName],nullable:!0}:{type:[co[e.innerType._def.typeName],`null`]};if(t.target===`openApi3`){let n=U(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&`$ref`in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let n=U(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function po(e,t){let n={type:`number`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`int`:n.type=`integer`,Ma(n,`type`,r.message,t);break;case`min`:t.target===`jsonSchema7`?r.inclusive?H(n,`minimum`,r.value,r.message,t):H(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),H(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?H(n,`maximum`,r.value,r.message,t):H(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),H(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:H(n,`multipleOf`,r.value,r.message,t)}return n}function mo(e,t){let n=t.target===`openAi`,r={type:`object`,properties:{}},i=[],a=e.shape();for(let e in a){let o=a[e];if(o===void 0||o._def===void 0)continue;let s=go(o);s&&n&&(o._def.typeName===`ZodOptional`&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let c=U(o._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});c!==void 0&&(r.properties[e]=c,s||i.push(e))}i.length&&(r.required=i);let o=ho(e,t);return o!==void 0&&(r.additionalProperties=o),r}function ho(e,t){if(e.catchall._def.typeName!==`ZodNever`)return U(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function go(e){try{return e.isOptional()}catch{return!0}}var _o=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return U(e.innerType._def,t);let n=U(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Pa(t)},n]}:Pa(t)},vo=(e,t)=>{if(t.pipeStrategy===`input`)return U(e.in._def,t);if(t.pipeStrategy===`output`)return U(e.out._def,t);let n=U(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,U(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function yo(e,t){return U(e.type._def,t)}function bo(e,t){let n={type:`array`,uniqueItems:!0,items:U(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&H(n,`minItems`,e.minSize.value,e.minSize.message,t),e.maxSize&&H(n,`maxItems`,e.maxSize.value,e.maxSize.message,t),n}function xo(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>U(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:U(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>U(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function So(e){return{not:Pa(e)}}function Co(e){return Pa(e)}var wo=(e,t)=>U(e.innerType._def,t),To=(e,t,n)=>{switch(t){case C.ZodString:return Xa(e,n);case C.ZodNumber:return po(e,n);case C.ZodObject:return mo(e,n);case C.ZodBigInt:return Ia(e,n);case C.ZodBoolean:return La();case C.ZodDate:return Ba(e,n);case C.ZodUndefined:return So(n);case C.ZodNull:return so(n);case C.ZodArray:return Fa(e,n);case C.ZodUnion:case C.ZodDiscriminatedUnion:return lo(e,n);case C.ZodIntersection:return Ka(e,n);case C.ZodTuple:return xo(e,n);case C.ZodRecord:return ro(e,n);case C.ZodLiteral:return qa(e,n);case C.ZodEnum:return Wa(e);case C.ZodNativeEnum:return ao(e);case C.ZodNullable:return fo(e,n);case C.ZodOptional:return _o(e,n);case C.ZodMap:return io(e,n);case C.ZodSet:return bo(e,n);case C.ZodLazy:return()=>e.getter()._def;case C.ZodPromise:return yo(e,n);case C.ZodNaN:case C.ZodNever:return oo(n);case C.ZodEffects:return Ua(e,n);case C.ZodAny:return Pa(n);case C.ZodUnknown:return Co(n);case C.ZodDefault:return Ha(e,n);case C.ZodBranded:return Ra(e,n);case C.ZodReadonly:return wo(e,n);case C.ZodCatch:return za(e,n);case C.ZodPipeline:return vo(e,n);case C.ZodFunction:case C.ZodVoid:case C.ZodSymbol:return;default:return(e=>void 0)(t)}};function U(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==Oa)return i}if(r&&!n){let e=Eo(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=To(e,e.typeName,t),o=typeof a==`function`?U(a(),t):a;if(o&&Do(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Eo=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Na(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Pa(t)):t.$refStrategy===`seen`?Pa(t):void 0}},Do=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),Oo=(e,t)=>{let n=ja(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:U(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Pa(n)}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=U(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Pa(n),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o),n.flags.hasReferencedOpenAiAnyType&&(r||={},r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:[`string`,`number`,`integer`,`boolean`,`array`,`null`],items:{$ref:n.$refStrategy===`relative`?`1`:[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join(`/`)}}));let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return n.target===`jsonSchema7`?s.$schema=`http://json-schema.org/draft-07/schema#`:(n.target===`jsonSchema2019-09`||n.target===`openAi`)&&(s.$schema=`https://json-schema.org/draft/2019-09/schema#`),n.target===`openAi`&&(`anyOf`in s||`oneOf`in s||`allOf`in s||`type`in s&&Array.isArray(s.type))&&console.warn(`Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.`),s},ko=/* @__PURE__ */ new WeakSet;function Ao(e){let t=wt().superRefine((t,n)=>{let r=0;for(let i of e)if(i.safeParse(t).success&&++r>1){n.addIssue({code:g.custom,message:`Value matched more than one schema in oneOf`});return}});return ko.add(t._def),t.pipe(A(e))}var jo=(e,t)=>{let n=e;if(!n.in||!n.out||!ko.has(n.in._def))return Oa;let r=n.out._def.options.map((e,n)=>U(e._def,{...t,currentPath:[...t.currentPath,`oneOf`,`${n}`]})).filter(e=>e!==void 0);return e.description===void 0?{oneOf:r}:{oneOf:r,description:e.description}},Mo={childRefNames:/* @__PURE__ */ new Set([`ComponentId`,`Child`,`ChildComponentId`]),childListRefNames:/* @__PURE__ */ new Set([`ChildList`,`TemplateChildList`]),childPropertyNames:/* @__PURE__ */ new Set([`child`,`entryPointChild`,`contentChild`])},No={ComponentId:{description:`The unique identifier for a component, used for both definitions and references within the same surface.`,type:`string`},TextItem:{additionalProperties:!1,description:`The value of the text field. This can be a literal string or a reference to a value in the data model ('path', e.g. '/user/name').`,properties:{literalString:{type:`string`},path:{type:`string`}},type:`object`},UrlItem:{additionalProperties:!1,description:`The URL of the audio to be played. This can be a literal string ('literal') or a reference to a value in the data model ('path', e.g. '/song/url').`,properties:{literalString:{type:`string`},path:{type:`string`}},type:`object`},AltTextItem:{additionalProperties:!1,description:`The alt text for the image. This can be a literal string ('literal') or a reference to a value in the data model ('path', e.g. '/thumbnail/altText').`,properties:{literalString:{type:`string`},path:{type:`string`}},type:`object`},NameItem:{additionalProperties:!1,description:`The name of the icon to display. This can be a literal string or a reference to a value in the data model ('path', e.g. '/form/submit').`,properties:{literalString:{enum:/* @__PURE__ */ `accountCircle.add.arrowBack.arrowForward.attachFile.calendarToday.call.camera.check.close.delete.download.edit.event.error.favorite.favoriteOff.folder.help.home.info.locationOn.lock.lockOpen.mail.menu.moreVert.moreHoriz.notificationsOff.notifications.payment.person.phone.photo.print.refresh.search.send.settings.share.shoppingCart.star.starHalf.starOff.upload.visibility.visibilityOff.warning`.split(`.`),type:`string`},path:{type:`string`}},type:`object`},DescriptionItem:{additionalProperties:!1,description:`A description of the audio, such as a title or summary. This can be a literal string or a reference to a value in the data model ('path', e.g. '/song/title').`,properties:{literalString:{type:`string`},path:{type:`string`}},type:`object`},ChildrenItem:{additionalProperties:!1,description:`Defines the children. Use 'explicitList' for a fixed set of children, or 'template' to generate children from a data list.`,properties:{explicitList:{items:{type:`string`},type:`array`},template:{$ref:`#/$defs/TemplateItem`,description:"A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the map of components in the data model. Values in the map will define the list of children."}},type:`object`},TemplateItem:{additionalProperties:!1,description:"A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the map of components in the data model. Values in the map will define the list of children.",properties:{componentId:{type:`string`},dataBinding:{type:`string`}},required:[`componentId`,`dataBinding`],type:`object`},TabItemItem:{additionalProperties:!1,properties:{child:{type:`string`},title:{$ref:`#/$defs/TitleItem`}},required:[`title`,`child`],type:`object`},TitleItem:{additionalProperties:!1,description:`The tab title. Defines the value as either a literal value or a path to data model value (e.g. '/options/title').`,properties:{literalString:{type:`string`},path:{type:`string`}},type:`object`},ActionItem:{additionalProperties:!1,description:`The client-side action to be dispatched when the button is clicked. It includes the action's name and an optional context payload.`,properties:{context:{items:{$ref:`#/$defs/ContextItem`},type:`array`},name:{type:`string`}},required:[`name`],type:`object`},ContextItem:{additionalProperties:!1,properties:{key:{type:`string`},value:{$ref:`#/$defs/ValueItem`,description:`Defines the value to be included in the context as either a literal value or a path to a data model value (e.g. '/user/name').`}},required:[`key`,`value`],type:`object`},ValueItem:{additionalProperties:!1,description:`The current value of the slider. This can be a literal number ('literalNumber') or a reference to a value in the data model ('path', e.g. '/restaurant/cost').`,properties:{literalNumber:{type:`number`},path:{type:`string`}},type:`object`},LabelItem:{additionalProperties:!1,description:`The label for the slider. This can be a literal string or a reference to a value in the data model ('path').`,properties:{literalString:{type:`string`},path:{type:`string`}},type:`object`},OptionItem:{additionalProperties:!1,properties:{label:{$ref:`#/$defs/LabelItem`,description:`The text to display for this option. This can be a literal string or a reference to a value in the data model (e.g. '/option/label').`},value:{description:`The value to be associated with this option when selected.`,type:`string`}},required:[`label`,`value`],type:`object`},SelectionItem:{additionalProperties:!1,description:`The currently selected values for the component. This can be a literal array of strings or a path to an array in the data model('path', e.g. '/hotel/options').`,properties:{literalArray:{items:{type:`string`},type:`array`},path:{type:`string`}},type:`object`}},Po={childRefNames:/* @__PURE__ */ new Set([`ComponentId`,`Child`,`ChildComponentId`]),childListRefNames:/* @__PURE__ */ new Set([`ChildList`,`TemplateChildList`,`ChildrenItem`,`TemplateItem`])},Fo={ComponentId:{type:`string`,description:`The unique identifier for a component, used for both definitions and references within the same surface.`},AccessibilityAttributes:{type:`object`,description:`Attributes to enhance accessibility when using assistive technologies like screen readers.`,properties:{label:{$ref:`#/$defs/DynamicString`,description:`A short string, typically 1 to 3 words, used by assistive technologies to convey the purpose or intent of an element. For example, an input field might have an accessible label of 'User ID' or a button might be labeled 'Submit'.`},description:{$ref:`#/$defs/DynamicString`,description:`Additional information provided by assistive technologies about an element such as instructions, format requirements, or result of an action. For example, a mute button might have a label of 'Mute' and a description of 'Silences notifications about this conversation'.`}}},ComponentCommon:{type:`object`,properties:{id:{$ref:`#/$defs/ComponentId`},accessibility:{$ref:`#/$defs/AccessibilityAttributes`}},required:[`id`]},ChildList:{oneOf:[{type:`array`,description:`A static list of child component IDs.`,items:{$ref:`#/$defs/ComponentId`}},{type:`object`,description:"A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.",properties:{componentId:{$ref:`#/$defs/ComponentId`},path:{type:`string`,description:`The path to the list of component property objects in the data model.`}},required:[`componentId`,`path`],additionalProperties:!1}]},DataBinding:{type:`object`,properties:{path:{type:`string`,description:`A JSON Pointer path to a value in the data model.`}},required:[`path`],additionalProperties:!1},DynamicValue:{description:`A value that can be a literal, a path, or a function call returning any type.`,oneOf:[{type:`string`},{type:`number`},{type:`boolean`},{type:`array`},{$ref:`#/$defs/DataBinding`},{$ref:`#/$defs/FunctionCall`}]},DynamicString:{description:`Represents a string`,oneOf:[{type:`string`},{$ref:`#/$defs/DataBinding`},{allOf:[{$ref:`#/$defs/FunctionCall`},{properties:{returnType:{const:`string`}}}]}]},DynamicNumber:{description:`Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number.`,oneOf:[{type:`number`},{$ref:`#/$defs/DataBinding`},{allOf:[{$ref:`#/$defs/FunctionCall`},{properties:{returnType:{const:`number`}}}]}]},DynamicBoolean:{description:`A boolean value that can be a literal, a path, or a function call returning a boolean.`,oneOf:[{type:`boolean`},{$ref:`#/$defs/DataBinding`},{allOf:[{$ref:`#/$defs/FunctionCall`},{properties:{returnType:{const:`boolean`}}}]}]},DynamicStringList:{description:`Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array.`,oneOf:[{type:`array`,items:{type:`string`}},{$ref:`#/$defs/DataBinding`},{allOf:[{$ref:`#/$defs/FunctionCall`},{properties:{returnType:{const:`array`}}}]}]},FunctionCall:{type:`object`,description:`Invokes a named function on the client.`,properties:{call:{type:`string`,description:`The name of the function to call.`},args:{type:`object`,description:`Arguments passed to the function.`,additionalProperties:{anyOf:[{$ref:`#/$defs/DynamicValue`},{type:`object`,description:`A literal object argument (e.g. configuration).`}]}},returnType:{type:`string`,description:`The expected return type of the function call.`,enum:[`string`,`number`,`boolean`,`array`,`object`,`any`,`void`],default:`boolean`}},required:[`call`],oneOf:[{$ref:`catalog.json#/$defs/anyFunction`}]},CheckRule:{type:`object`,description:`A single validation rule applied to an input component.`,properties:{condition:{$ref:`#/$defs/DynamicBoolean`},message:{type:`string`,description:`The error message to display if the check fails.`}},required:[`condition`,`message`],additionalProperties:!1},Checkable:{type:`object`,description:`Properties for components that support client-side checks.`,properties:{checks:{type:`array`,description:`A list of checks to perform. These are function calls that must return a boolean indicating validity.`,items:{$ref:`#/$defs/CheckRule`}}}},Action:{description:`Defines an interaction handler that can either trigger a server-side event or execute a local client-side function.`,oneOf:[{type:`object`,description:`Triggers a server-side event.`,properties:{event:{type:`object`,description:`The event to dispatch to the server.`,properties:{name:{type:`string`,description:`The name of the action to be dispatched to the server.`},context:{type:`object`,description:`A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.`,additionalProperties:{$ref:`#/$defs/DynamicValue`}}},required:[`name`],additionalProperties:!1}},required:[`event`],additionalProperties:!1},{type:`object`,description:`Executes a local client-side function.`,properties:{functionCall:{$ref:`#/$defs/FunctionCall`}},required:[`functionCall`],additionalProperties:!1}]}},Io={childRefNames:/* @__PURE__ */ new Set([`ComponentId`,`Child`,`ChildComponentId`]),childListRefNames:/* @__PURE__ */ new Set([`ChildList`,`TemplateChildList`,`ChildrenItem`,`TemplateItem`])},Lo={ComponentId:{type:`string`,description:`The unique identifier for a component, used for both definitions and references within the same surface.`},CallId:{type:`string`,description:`The unique identifier for a function call.`},AccessibilityAttributes:{type:`object`,description:`Attributes to enhance accessibility when using assistive technologies like screen readers or model understanding.`,properties:{label:{$ref:`#/$defs/DynamicString`,description:`A short string, typically 1 to 3 words, used by assistive technologies to convey the purpose or intent of an element. For example, an input field might have an accessible label of 'User ID' or a button might be labeled 'Submit'.`},description:{$ref:`#/$defs/DynamicString`,description:`Additional information provided by assistive technologies about an element such as instructions, format requirements, or result of an action. For example, a mute button might have a label of 'Mute' and a description of 'Silences notifications about this conversation'.`},live:{type:`string`,description:`Controls screen reader announcements for dynamic updates (WAI-ARIA aria-live). 'polite' waits for user pause; 'assertive' interrupts immediately for alerts.`,enum:[`off`,`polite`,`assertive`],default:`off`},hidden:{$ref:`#/$defs/DynamicBoolean`,description:`Hides the element and its children from assistive technologies when true. Default is false.`}},additionalProperties:!1},Extensions:{type:`object`,description:`Optional extension metadata. Keys MUST be Unicode identifiers (UAX #31). Keys starting with 'a2ui_' are reserved for official extensions.`,patternProperties:{"^[\\p{XID_Start}_][\\p{XID_Continue}]*$":{}},additionalProperties:!1},ComponentCommon:{type:`object`,properties:{id:{$ref:`#/$defs/ComponentId`},"@catalogId":{type:`string`,description:`The catalog ID for this component, overriding any surface-level default catalogId.`},"@accessibility":{$ref:`#/$defs/AccessibilityAttributes`},"@metadata":{type:`object`,description:`Optional component-level metadata for vendor extensions.`,properties:{extensions:{$ref:`#/$defs/Extensions`}},additionalProperties:!1}},required:[`id`]},Child:{$ref:`#/$defs/ComponentId`,description:`A reference to a single child component ID.`},ChildList:{oneOf:[{type:`array`,description:`A static list of child component IDs.`,items:{$ref:`#/$defs/ComponentId`}},{type:`object`,description:"A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.",properties:{componentId:{$ref:`#/$defs/ComponentId`},path:{type:`string`,description:`The path to the list of component property objects in the data model.`}},required:[`componentId`,`path`],additionalProperties:!1}]},DataBinding:{type:`object`,properties:{"@path":{type:`string`,description:`A JSON Pointer path to a value in the data model.`}},required:[`@path`],additionalProperties:!1},DynamicValue:{description:`A value that can be a literal, a path, or a function call returning any type.`,oneOf:[{type:`string`},{type:`number`},{type:`boolean`},{type:`array`},{type:`object`,propertyNames:{not:{pattern:`^@([^@]|$)`}},not:{anyOf:[{required:[`@path`]},{required:[`@call`]}]}},{$ref:`#/$defs/DataBinding`},{$ref:`#/$defs/FunctionCall`}]},DynamicString:{description:`Represents a string`,oneOf:[{type:`string`},{$ref:`#/$defs/DataBinding`},{$ref:`#/$defs/FunctionCall`}]},DynamicNumber:{description:`Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number.`,oneOf:[{type:`number`},{$ref:`#/$defs/DataBinding`},{$ref:`#/$defs/FunctionCall`}]},DynamicBoolean:{description:`A boolean value that can be a literal, a path, or a function call returning a boolean or a validation result object (coerced to its 'valid' boolean).`,oneOf:[{type:`boolean`},{$ref:`#/$defs/DataBinding`},{$ref:`#/$defs/FunctionCall`}]},DynamicStringList:{description:`Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array.`,oneOf:[{type:`array`,items:{type:`string`}},{$ref:`#/$defs/DataBinding`},{$ref:`#/$defs/FunctionCall`}]},FunctionCommon:{type:`object`,description:`Baseline envelope properties common to all function calls. Function-specific argument schemas ('args') are defined individually by each function in the active catalog.`,properties:{"@call":{type:`string`,description:`The name of the function to call.`},catalogId:{type:`string`,description:`The catalog ID for this function, overriding any surface-level default catalogId.`}},required:[`@call`]},IndexSystemFunction:{type:`object`,description:`Returns the 0-based index of the current item when rendering a dynamic list from a template. This function MUST ONLY be available when evaluating template items within a list context.`,properties:{"@call":{const:`@index`},args:{type:`object`,properties:{offset:{$ref:`#/$defs/DynamicNumber`,description:`Optional. An offset to add to the 0-based index (e.g., 1 for 1-based indexing). Defaults to 0.`,default:0}},unevaluatedProperties:!1}},required:[`@call`],unevaluatedProperties:!1,returnType:`number`},FunctionCall:{type:`object`,description:`Invokes a named function, combining common function properties with the catalog function definition.`,allOf:[{$ref:`#/$defs/FunctionCommon`},{oneOf:[{$ref:`catalog.json#/$defs/anyFunction`},{$ref:`#/$defs/IndexSystemFunction`}]}],unevaluatedProperties:!1},CheckRule:{type:`object`,description:`A single validation check rule applied to an input component. The condition function or path evaluates to a structured validation result object or a boolean (which is coerced to a validation result object).`,properties:{condition:{description:`Path or function call evaluating to a structured validation result object or a boolean.`,oneOf:[{$ref:`#/$defs/DataBinding`},{$ref:`#/$defs/FunctionCall`}]},message:{type:`string`,description:`Optional fallback error message.`}},required:[`condition`],additionalProperties:!1},Checkable:{type:`object`,description:`Properties for components that support renderer-side checks.`,properties:{"@checks":{type:`array`,description:`A list of validation check rules to perform on the component.`,items:{$ref:`#/$defs/CheckRule`}}}},Action:{description:`Defines an interaction handler that can either trigger an agent-side event or execute a local renderer-side function.`,oneOf:[{type:`object`,description:`Triggers an agent-side event.`,properties:{event:{type:`object`,description:`The event to dispatch to the agent.`,properties:{name:{type:`string`,description:`The name of the action to be dispatched to the agent.`},userMessage:{$ref:`#/$defs/DynamicString`,description:`An optional human-readable message describing the action performed by the user, resolved by the renderer and included in the outbound action message.`},context:{type:`object`,description:`A JSON object containing the key-value pairs for the action context. Values can be literals or paths. Use literal values unless the value must be dynamically bound to the data model. Do NOT use paths for static IDs.`,additionalProperties:{$ref:`#/$defs/DynamicValue`}}},required:[`name`],additionalProperties:!1}},required:[`event`],additionalProperties:!1},{type:`object`,description:`Executes a renderer or agent-side function.`,properties:{functionCall:{$ref:`#/$defs/FunctionCall`}},required:[`functionCall`],additionalProperties:!1}]},Surface:{title:`Surface Container Component`,description:`The reserved canonical container component representing an A2UI surface. The Surface component is immutable and always has 'child': 'root'.`,type:`object`,allowedParents:[],properties:{component:{const:`Surface`},child:{const:`root`}},additionalProperties:!1},FunctionResponse:{type:`object`,description:`The return response matching a callAgentFunction or callRendererFunction invocation.`,properties:{functionCallId:{$ref:`#/$defs/CallId`,description:`The unique ID matching the initiating function call.`},value:{description:`The return value of the function.`},error:{type:`object`,description:`An error object indicating failure of the function execution.`,properties:{code:{type:`string`},message:{type:`string`}},required:[`code`,`message`],additionalProperties:!1}},required:[`functionCallId`],oneOf:[{required:[`value`]},{required:[`error`]}],additionalProperties:!1}},Ro=`common_types.json`,zo={"0.8":No,"0.9":Fo,"0.9.1":Fo,"1.0":Lo};function Bo(e){if(e){let t=mr(e)??dr(e);if(t in zo)return zo[t];if(R(e,`1.0`))return Lo}return Fo}function Vo(e){return JSON.parse(JSON.stringify(e))}function Ho(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Uo=8;function Wo(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function Go(e,t,n){let r=e;for(let e=0;Ho(r)&&typeof r.$ref==`string`;e++){if(e+n>Uo)return;r=t(r.$ref)}return Ho(r)?r:void 0}function Ko(e){let t=e.type;if(typeof t==`string`||Array.isArray(t))return new Set([].concat(t).map(e=>e===`integer`?`number`:String(e)));if(Object.hasOwn(e,`const`))return/* @__PURE__ */ new Set([Wo(e.const)]);if(Array.isArray(e.enum))return new Set(e.enum.map(Wo))}function qo(e){let t;if(Object.hasOwn(e,`const`))t=[e.const];else if(Array.isArray(e.enum))t=e.enum;else return;if(!t.some(e=>typeof e==`object`&&!!e))return t.map(e=>JSON.stringify(e))}function Jo(e,t,n){let r=/* @__PURE__ */ new Set;if(Array.isArray(e.required))for(let t of e.required)r.add(String(t));if(n<Uo&&Array.isArray(e.allOf))for(let i of e.allOf){let e=Go(i,t,n+1);if(e)for(let i of Jo(e,t,n+1))r.add(i)}return r}function Yo(e){if(e.additionalProperties!==!1||Object.hasOwn(e,`patternProperties`))return;let t=e.properties;return new Set(Ho(t)?Object.keys(t):[])}function Xo(e,t){let n=e.properties;return Ho(n)?n[t]:void 0}function Zo(e,t,n,r=0){if(r>Uo)return!1;let i=Go(e,n,r),a=Go(t,n,r);if(!i||!a)return!1;let o=Ko(i),s=Ko(a);if(o&&s&&![...o].some(e=>s.has(e)))return!0;let c=qo(i),l=qo(a);if(c&&l&&!c.some(e=>l.includes(e)))return!0;let u=e=>e!==void 0&&e.size===1&&e.has(`object`);if(!u(o)||!u(s))return!1;let d=Jo(i,n,r),f=Jo(a,n,r),p=Yo(i),m=Yo(a);return p&&[...f].some(e=>!p.has(e))||m&&[...d].some(e=>!m.has(e))?!0:[...d].some(e=>f.has(e)&&Zo(Xo(i,e),Xo(a,e),n,r+1))}function Qo(e){return e._def}var $o=/* @__PURE__ */ new Set([`id`,`component`]);function es(e){return rs(e).mixins!==void 0}function ts(e){return Object.keys(rs(e)).length>0}function ns(e,t,n=/* @__PURE__ */ new Set){if(!Ho(e)||e.default!==void 0)return!1;if(Array.isArray(e.required)&&e.required.length>0||typeof e.minProperties==`number`&&e.minProperties>0)return!0;let r=e.$ref;if(typeof r==`string`&&t&&r.startsWith(`#/$defs/`)&&!n.has(r)){let e=t;for(let t of r.slice(8).split(`/`)){let n=t.replace(/~1/g,`/`).replace(/~0/g,`~`);e=Ho(e)&&Object.hasOwn(e,n)?e[n]:void 0}if(e!==void 0&&ns(e,t,new Set(n).add(r)))return!0}return!!(Array.isArray(e.allOf)&&e.allOf.some(e=>ns(e,t,n))||Array.isArray(e.oneOf)&&e.oneOf.length>0&&e.oneOf.every(e=>ns(e,t,n))||Array.isArray(e.anyOf)&&e.anyOf.length>0&&e.anyOf.every(e=>ns(e,t,n)))}function rs(e,t){let n=[],r=t?Xi(t):void 0,i=e;for(;i&&typeof i==`object`&&`_def`in i;){let e=Xi(i);if(t!==void 0&&(i===t||e&&e===r))break;e&&n.push(e);let a=is(i);if(!a)break;i=a}return n.reduceRight((e,t)=>({...e,...t}),{})}function is(e){let t=Qo(e);switch(t.typeName){case`ZodOptional`:case`ZodDefault`:case`ZodCatch`:case`ZodReadonly`:return t.innerType;case`ZodEffects`:return t.schema;case`ZodBranded`:return t.type;default:return}}var as=class{constructor(e,t=Ro){this.commonTypesUri=t,this.standardDefsInCatalog=/* @__PURE__ */ new Map,this.isV08=!R(e,`0.9`),this.isV10=R(e,`1.0`),this.standardDefs=Bo(e)}componentSchema(e,t,n,r){let i=/* @__PURE__ */ new Map,a;if(this.isV08){a=this.toJson(t,i);let e=a.properties;if(Ho(e))for(let t of $o)delete e[t];if(Array.isArray(a.required)){let e=a.required.filter(e=>!$o.has(e));e.length>0?a.required=e:delete a.required}}else{let n=rs(t),r=n.mixins??[],o=new Set($o),s=[];for(let e of r){s.push({$ref:this.mixinRef(e,i)});for(let t of this.mixinProperties(e))o.add(t)}let c=os(t),l=cs(t),u=this.objectSchema(c,n,e=>!o.has(e),i),d={component:{const:e},...u.properties},f=[`component`,...u.required??[]],p={type:`object`};l!==void 0&&!this.isV10&&(p.description=l),p.properties=d,p.required=f,a={type:`object`},this.isV10?(l!==void 0&&(a.description=l),s.length>0?a.allOf=[...s,p]:(a.properties=d,a.required=f)):(a.allOf=[...s,p],a.unevaluatedProperties=!1)}return n&&n.length>0&&(a.allowedParents=[...n]),r&&r.length>0&&(a.allowedChildren=[...r]),{schema:a,catalogDefs:i}}functionSchema(e,t,n,r){let i=this.toJson(t.schema,r),a=ns(i,n),o={type:`object`};return t.description&&(o.description=t.description),this.isV10?(o.returnType=t.returnType,t.allowedCallers&&(o.allowedCallers=t.allowedCallers),t.requiresUserActivation&&(o.requiresUserActivation=!0),o.properties={"@call":{const:e},args:i},o.required=a?[`@call`,`args`]:[`@call`],o):(t.allowedCallers&&(o.allowedCallers=t.allowedCallers),t.requiresUserActivation&&(o.requiresUserActivation=!0),o.properties={call:{const:e},args:i,returnType:{const:t.returnType}},o.required=a?[`call`,`args`]:[`call`],o.unevaluatedProperties=!1,o)}defSchema(e,t){return this.toJson(e,t,!0)}mixinRef(e,t){if(typeof e==`string`)return`${this.commonTypesUri}#/$defs/${e}`;let n=rs(e).defName;if(n===void 0)throw Error(`A component mixin model must be named with specDef().`);return t.set(n,e),`#/$defs/${n}`}mixinProperties(e){if(typeof e!=`string`){let t=os(e);return Qo(t).typeName===`ZodObject`?Object.keys(t.shape):[]}let t=[],n=(e,r)=>{if(Ho(e)&&!r.has(e)){r.add(e),Ho(e.properties)&&t.push(...Object.keys(e.properties));for(let t of Array.isArray(e.allOf)?e.allOf:[]){let e=Ho(t)?t.$ref:void 0,i=typeof e==`string`&&e.startsWith(`#/$defs/`)?this.standardDefs[e.substring(8)]:t;n(i,r)}}};return n(this.standardDefs[e],/* @__PURE__ */ new Set),t}toJson(e,t,n=!1){let r=rs(e),i=ss(e),a=ls(e),o=r,s=a,c,l=i;if(!n&&t!==void 0&&r.defName!==void 0&&r.defModel!==void 0)t.set(r.defName,r.defModel),c={$ref:`#/$defs/${r.defName}`},o=rs(e,r.defModel),l=i===ss(r.defModel)?void 0:i,s=a===ls(r.defModel)?void 0:a;else if(i!==void 0&&i.startsWith(`REF:`)){let e=i.substring(4),t=e.indexOf(`|`),n=t===-1?e:e.substring(0,t);l=t===-1?void 0:e.substring(t+1),c={$ref:this.refTarget(n)}}else c=this.coreJson(os(e),r,t);o.keywords&&Object.assign(c,Vo(o.keywords));let u=o.allOf?{allOf:[c,...o.allOf.map(e=>Vo(e))]}:c;return l&&(u.description=l),s!==void 0&&(u.default=s),u}resolveStandardRef(e){let t=`${this.commonTypesUri}#/$defs/`;if(!e.startsWith(t))return;let n=e.substring(t.length);if(n.includes(`/`)||!Object.hasOwn(this.standardDefs,n))return;let r=this.standardDefsInCatalog.get(n);if(r)return r;let i=this.standardDefs[n];if(!Ho(i))return;let a=this.withCatalogRefs(i);return this.standardDefsInCatalog.set(n,a),a}withCatalogRefs(e){if(Array.isArray(e))return e.map(e=>this.withCatalogRefs(e));if(!Ho(e))return e;let t={};for(let[n,r]of Object.entries(e))t[n]=n===`$ref`&&typeof r==`string`?this.refTarget(r):this.withCatalogRefs(r);return t}refTarget(e){return e.startsWith(`#/$defs/`)?`${this.commonTypesUri}${e}`:e}coreJson(e,t,n){let r=Qo(e);switch(r.typeName){case`ZodObject`:return this.objectSchema(e,t,()=>!0,n);case`ZodString`:return ds(r);case`ZodNumber`:return fs(r);case`ZodBoolean`:return{type:`boolean`};case`ZodNull`:return{type:`null`};case`ZodEnum`:return{type:`string`,enum:[...r.values]};case`ZodLiteral`:return{const:r.value};case`ZodAny`:case`ZodUnknown`:return{};case`ZodNever`:return{not:{}};case`ZodArray`:{let e={type:`array`,items:this.toJson(r.type,n)},t=r.minLength,i=r.maxLength;return t&&(e.minItems=t.value),i&&(e.maxItems=i.value),e}case`ZodUnion`:case`ZodDiscriminatedUnion`:{let e=[...r.options].map(e=>this.toJson(e,n)),t=e=>{if(e.startsWith(`#/$defs/`)&&n!==void 0){let t=e.substring(8),r=n.get(t);if(r!==void 0)return this.defSchema(r,n)}return this.resolveStandardRef(e)};return{[e.every((n,r)=>e.slice(r+1).every(e=>Zo(n,e,t)))?`oneOf`:`anyOf`]:e}}case`ZodRecord`:return{type:`object`,additionalProperties:this.toJson(r.valueType,n)};case`ZodLazy`:return this.toJson(r.getter(),n);default:return ps(e)}}objectSchema(e,t,n,r){let i=Qo(e);if(i.typeName!==`ZodObject`)return this.toJson(e,r);let a=e.shape,o={},s=[];for(let[e,t]of Object.entries(a))n(e)&&(o[e]=this.toJson(t,r),t.isOptional()||s.push(e));let c={type:`object`,properties:o},l=t.required?.filter(e=>s.includes(e)),u=s.filter(e=>!l?.includes(e));s.length>0&&(c.required=l?[...l,...u]:s);let d=i.unknownKeys,f=i.catchall,p=t.closure??(d===`strict`?`additionalProperties`:`none`);return f&&Qo(f).typeName!==`ZodNever`?c[p===`none`?`additionalProperties`:p]=this.toJson(f,r):p!==`none`&&(c[p]=d===`passthrough`),c}};function os(e){let t=e;for(let e=is(t);e;e=is(t))t=e;return t}function ss(e){for(let t=e;t;t=is(t)){let e=Qo(t).description;if(typeof e==`string`)return e}}function cs(e){let t=ss(e);return t!==void 0&&!t.startsWith(`REF:`)?t:void 0}function ls(e){for(let t=e;t;t=is(t)){let e=Qo(t);if(e.typeName===`ZodDefault`)return e.defaultValue()}}var us={email:`email`,url:`uri`,uuid:`uuid`,datetime:`date-time`,date:`date`,time:`time`};function ds(e){let t={type:`string`};for(let n of e.checks??[])n.kind===`regex`?t.pattern=n.regex.source:n.kind===`min`?t.minLength=n.value:n.kind===`max`?t.maxLength=n.value:n.kind in us&&(t.format=us[n.kind]);return t}function fs(e){let t=e.checks??[],n={type:t.some(e=>e.kind===`int`)?`integer`:`number`};for(let e of t)e.kind===`min`?n[e.inclusive?`minimum`:`exclusiveMinimum`]=e.value:e.kind===`max`&&(n[e.inclusive?`maximum`:`exclusiveMaximum`]=e.value);return n}function ps(e){let t=Oo(e,{target:`jsonSchema2019-09`,$refStrategy:`none`,override:jo});return delete t.$schema,delete t.definitions,delete t.$defs,t}var ms=/* @__PURE__ */ new Set([`anyComponent`,`anyFunction`]),hs=[`theme`,`themeSchema`,`styles`];function gs(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function _s(e){if(typeof e==`object`&&e&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))_s(t)}return e}function vs(e){return typeof e!=`object`||!e||Object.isFrozen(e)?e:_s(gs(e))}function ys(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function bs(e,t){if(Array.isArray(e)){for(let n of e)bs(n,t);return}if(!ys(e))return;let n=e.$ref;typeof n==`string`&&n.startsWith(`#/$defs/`)&&t.add(n.slice(8).split(`/`)[0].replace(/~1/g,`/`).replace(/~0/g,`~`));for(let n of Object.values(e))bs(n,t)}function xs(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set;for(let t of e)bs(t,r);for(;r.size>0;){let[e]=r;r.delete(e),n.has(e)||(n.add(e),e in t&&bs(t[e],r))}return n}function Ss(e,t){let n=Ri(e);if(!ys(n))return;let r=t??{};for(let e of xs([n],r))if(!(e in r)&&!ms.has(e))return;return n}function Cs(e){return typeof e.name==`string`&&!(`properties`in e)}function ws(e,t,n,r){if(!e)return e;let i=t=>t.map(t=>Ss(t,e)??(Ii(t)?t.jsonSchema:void 0)).filter(e=>e!==void 0),a=xs(i(t),e),o=Object.keys(e).filter(e=>!a.has(e)),s=xs([...i(n),r,...o.map(t=>e[t])],e),c={},l=!1;for(let[t,n]of Object.entries(e))!a.has(t)||s.has(t)?c[t]=n:l=!0;return l?c:e}function Ts(e,t,n=Ro){if(Array.isArray(e))for(let r of e)Ts(r,t,n);else if(ys(e)){if(typeof e.description==`string`&&e.description.startsWith(`REF:`)){let r=e.description.substring(4),i=r.indexOf(`|`),a=i===-1?r:r.substring(0,i),o=i===-1?``:r.substring(i+1),s=e.default;for(let t of Object.keys(e))delete e[t];let c=a.split(/#\/(?:\$defs|definitions)\//)[1],l=c?.split(`/`)[0];e.$ref=l===void 0||a.startsWith(`#`)&&t.has(l)?a:`${n}#/$defs/${c}`,s!==void 0&&(e.default=s),o&&(e.description=o)}else{for(let t of[`additionalProperties`,`unevaluatedProperties`]){let n=e[t];ys(n)&&Object.keys(n).length===0&&(e[t]=!0)}delete e.$schema;for(let r of Object.values(e))Ts(r,t,n)}}}function Es(e,t,n=Ro){if(!e||typeof e!=`object`||!(`safeParse`in e))return{type:`object`,properties:{}};let r=Oo(e,{target:`jsonSchema2019-09`,$refStrategy:`none`,override:jo});return delete r.definitions,delete r.$defs,Ts(r,t,n),r}function Ds(e){if(e.type!==`object`)return;let t=e.unevaluatedProperties??e.additionalProperties;delete e.additionalProperties,e.unevaluatedProperties=typeof t==`boolean`||ys(t)?t:!1}function Os(e,t,n,r,i=Ro){let a=Es(t.schema,n,i),{component:o,id:s,...c}=ys(a.properties)?a.properties:{},l=Array.isArray(a.required)?a.required.filter(e=>e!==`component`&&e!==`id`):[],u=a.unevaluatedProperties??a.additionalProperties,d=r?u===!0||void 0:typeof u==`boolean`||ys(u)?u:!1,f={type:`object`,properties:{component:{const:e},...c},required:[`component`,...l],...d===void 0?{}:{unevaluatedProperties:d}};return t.allowedParents&&t.allowedParents.length>0&&(f.allowedParents=[...t.allowedParents]),t.allowedChildren&&t.allowedChildren.length>0&&(f.allowedChildren=[...t.allowedChildren]),t.metadata!==void 0&&(f.metadata=gs(t.metadata)),f}function ks(e,t,n,r,i,a=Ro,o){let s=Es(t.schema,n,a),c=Ii(t)?t.explicitAllowedCallers:t.allowedCallers,l=Ii(t)?t.explicitRequiresUserActivation:t.requiresUserActivation;if(i)return{name:e,...t.description?{description:t.description}:{},returnType:t.returnType,parameters:s,...c?{allowedCallers:c}:{},...l===void 0?{}:{requiresUserActivation:l}};Ds(s);let u=ns(s,o),d={type:`object`};return t.description&&(d.description=t.description),r?(d.returnType=t.returnType,c&&(d.allowedCallers=c),l!==void 0&&(d.requiresUserActivation=l),d.properties={"@call":{const:e},args:s},d.required=u?[`@call`,`args`]:[`@call`],d):(c&&(d.allowedCallers=c),l!==void 0&&(d.requiresUserActivation=l),d.properties={call:{const:e},args:s,returnType:{const:t.returnType}},d.required=u?[`call`,`args`]:[`call`],d.unevaluatedProperties=!1,d)}function As(e,t,n=Ro){let r=Es(e,t,n);return{type:`object`,properties:ys(r.properties)?r.properties:{},...Array.isArray(r.required)&&r.required.length>0?{required:r.required}:{},additionalProperties:r.additionalProperties===void 0||r.additionalProperties}}var js={not:{}};function Ms(e){let t=[...e].map(e=>({$ref:`#/components/${Ps(e)}`}));return t.length===0?{...js}:{oneOf:t,discriminator:{propertyName:`component`}}}function Ns(e){let t=[...e].map(e=>({$ref:`#/functions/${Ps(e)}`}));return t.length===0?{...js}:{oneOf:t}}function Ps(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}var Fs=/* @__PURE__ */ new WeakMap;function Is(e){let t=Fs.get(e);return t||(t=Ls(e),Fs.set(e,t)),t}function Ls(e){let t=new as(e.protocolVersion,e.commonTypesUri),n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map;for(let[i,a]of e.components){if(Ri(a)||!es(a.schema))continue;let{schema:e,catalogDefs:o}=t.componentSchema(i,a.schema,a.allowedParents,a.allowedChildren);a.metadata!==void 0&&(e.metadata=gs(a.metadata)),r.set(i,_s(e));for(let[e,t]of o)n.set(e,t)}for(let t of e.defModels??[]){let e=Xi(t)?.defName;if(e===void 0)throw Error(`A catalog definition model must be named with specDef().`);n.set(e,t)}let i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map;for(let[r,i]of e.functions)!Ri(i)&&ts(i.schema)&&(a.set(r,i),t.toJson(i.schema,n));let o={...e.defs},s=/* @__PURE__ */ new Set;for(;[...n.keys()].some(e=>!s.has(e)&&!(e in o));)for(let[e,r]of[...n])s.has(e)||e in o||(s.add(e),o[e]=t.defSchema(r,n));let c={...e.extensionFields};if(e.themeLocation===`styles`&&e.themeSchema&&!Rs(e)){let n=t.defSchema(e.themeSchema);c.styles=ys(n.properties)?n.properties:{}}let l=/* @__PURE__ */ new Map;for(let[t,n]of e.components)l.set(t,r.get(t)??Ss(n,o));for(let[r,s]of e.functions){let e=Ss(s,o);i.set(r,e??(a.has(r)?_s(t.functionSchema(r,s,o,n)):void 0))}return{components:l,functions:i,defs:_s(o),extensionFields:_s(c)}}function Rs(e){return ys(e.defs?.theme)||hs.some(t=>e.extensionFields?.[t]!==void 0)}function zs(e){let t=R(e.protocolVersion,`1.0`),n=Is(e),r=new Set(Object.keys(n.defs)),i={};e.schemaUri!==void 0&&(i.$schema=e.schemaUri),e.schemaId!==void 0&&(i.$id=e.schemaId),typeof e.declaredProtocolVersion==`string`?i.protocolVersion=e.declaredProtocolVersion:e.declaredProtocolVersion===void 0&&(i.protocolVersion=mr(e.protocolVersion)??e.protocolVersion),e.title!==void 0&&(i.title=e.title),e.description!==void 0&&(i.description=e.description),e.declaresCatalogId!==!1&&(i.catalogId=e.id),e.instructions!==void 0&&(i.instructions=e.instructions);let a=e.commonTypesUri??`common_types.json`;if(e.declaresComponents!==!1||e.components.size>0){let o={};for(let[i,s]of e.components){let e=n.components.get(i);o[i]=e?gs(e):Os(i,s,r,t,a)}i.components=o}let o=[...e.functions].filter(([e,t])=>Ri(t)!==void 0||!e.startsWith(`@`)),s=o.map(([e])=>e);if(e.functionsLayout===`list`)i.functions=o.map(([e,i])=>{let o=n.functions.get(e);return o&&Cs(o)?gs(o):ks(e,i,r,t,!0,a,n.defs)});else if(e.functionsLayout===`map`||o.length>0){let e={};for(let[i,s]of o){let o=n.functions.get(i);e[i]=o&&!Cs(o)?gs(o):ks(i,s,r,t,!1,a,n.defs)}i.functions=e}for(let[e,t]of Object.entries(n.extensionFields))e in i||(i[e]=gs(t));let c=gs({...n.defs});(e.themeLocation??(t?void 0:`defs`))===`defs`&&e.themeSchema&&!Rs(n)&&(c.theme=Xi(e.themeSchema)?new as(e.protocolVersion,e.commonTypesUri).defSchema(e.themeSchema):As(e.themeSchema,r,a));let l=e.unions??{anyComponent:t||e.components.size>0,anyFunction:t||s.length>0};if(l.anyComponent&&!(`anyComponent`in c)){let t=c.anyFunction;t!==void 0&&delete c.anyFunction,c.anyComponent=Ms(e.components.keys()),t!==void 0&&(c.anyFunction=t)}return l.anyFunction&&!(`anyFunction`in c)&&(c.anyFunction=Ns(s)),(e.defs!==void 0||Object.keys(c).length>0)&&(i.$defs=c),i}function Bs(e,t){if(!t.startsWith(`#/`))return;let n=t.slice(2).split(`/`).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return typeof r==`object`&&r?r:void 0}function Vs(e){let t=e.split(/#\/(?:\$defs|definitions)\//)[1];return t&&Object.hasOwn(rr,t)?rr[t]:void 0}function Hs(e){return e.length===0?D():e.every(e=>typeof e==`string`)?M(e):e.length===1?Dt(e[0]):A(e.map(e=>Dt(e)))}function Us(e){return typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[${e.map(Us).join(`,`)}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${Us(e[t])}`).join(`,`)}}`}function Ws(e,t,n,r,i){let a=e;if(t.not&&typeof t.not==`object`){let e=Js(t.not,n,new Set(r),i);a=Ot((t,n)=>(e.safeParse(t).success&&n.addIssue({code:g.custom,message:`Value matched prohibited "not" schema`}),t),a)}return t.default!==void 0&&(a=a.default(t.default)),typeof t.description==`string`&&(a=a.describe(t.description)),a}function Gs(e,t,n,r,i){let a=Vs(e);if(a){let n=e.split(/#\/(?:\$defs|definitions)\//)[1],r=typeof t.description==`string`?`REF:common_types.json#/$defs/${n}|${t.description}`:a.description;return r?a.describe(r):a}if(n&&e.startsWith(`#/`)){let a=Bs(n,e);if(!a)return D().superRefine((t,n)=>{n.addIssue({code:g.custom,message:`Unresolvable schema reference: '${e}'`})});if(r.has(e)){let t=i.get(e);return Et(()=>(t||(t=i.get(e)??Js(a,n,/* @__PURE__ */ new Set([e]),i),i.set(e,t)),t))}let o=i.get(e);if(!o){let t=new Set(r);t.add(e),o=Js(a,n,t,i),i.set(e,o)}return typeof t.description==`string`&&(o=o.describe(t.description)),o}}function Ks(e,t,n,r){let i=Array.isArray(e.oneOf),a=(e.oneOf||e.anyOf).filter(e=>typeof e==`object`&&!!e);if(a.length===0)return;let o=a.find(e=>Array.isArray(e.enum)),s=a.some(e=>typeof e.$ref==`string`&&e.$ref.includes(`DataBinding`)),c=a.map(e=>Js(e,t,new Set(n),r)),l;if(c.length===1)l=c[0];else{let e=[c[0],c[1],...c.slice(2)];l=i?Ao(e):A(e)}e.default!==void 0&&(l=l.default(e.default));let u=(typeof e.description==`string`?e.description:void 0)||(o&&s?`REF:common_types.json#/$defs/DynamicString`:void 0);return u?l.describe(u):l}function qs(e,t,n,r){let i=e.allOf.filter(e=>typeof e==`object`&&!!e);if(i.length===0)return;if(t){let i=ec(e,t,new Set(n),!1);if(i.length>0){let a=/* @__PURE__ */ new Set;for(let e of i)if(e.kind===`json`&&Array.isArray(e.schema.required))for(let t of e.schema.required)typeof t==`string`&&a.add(t);if(Array.isArray(e.required))for(let t of e.required)typeof t==`string`&&a.add(t);let o={};for(let e of i){if(e.kind===`zod`){Object.assign(o,e.properties);continue}let i=Zs(e.schema.properties||{},a,!1,t,new Set(n),r);Object.assign(o,i)}let s=k(o),c=e.additionalProperties===!1||e.unevaluatedProperties===!1||i.some(e=>e.kind===`json`&&(e.schema.additionalProperties===!1||e.schema.unevaluatedProperties===!1));return Ws(Qs(s,[e,...i.flatMap(t=>t.kind===`json`&&t.schema!==e?[t.schema]:[])],c,t,n,r),e,t,n,r)}}let a=i.map(e=>Js(e,t,new Set(n),r)),o=a[0];for(let e=1;e<a.length;e++)o=o.and(a[e]);return Ws(o,e,t,n,r)}function Js(e,t,n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return D();if(e instanceof S)return e;if(e.$ref&&typeof e.$ref==`string`){let i=Gs(e.$ref,e,t,n,r);if(i)return i}if(Array.isArray(e.oneOf)||Array.isArray(e.anyOf)){let i=Ks(e,t,n,r);if(i)return i}if(Array.isArray(e.allOf)&&e.allOf.length>0){let i=qs(e,t,n,r);if(i)return i}if(e.const!==void 0)return Ws(Dt(e.const),e,t,n,r);if(Array.isArray(e.enum)&&e.enum.length>0)return Ws(Hs(e.enum),e,t,n,r);if(e.type===`array`){let i=O(e.items&&typeof e.items==`object`?Js(e.items,t,new Set(n),r):D());return typeof e.minItems==`number`&&(i=i.min(e.minItems)),typeof e.maxItems==`number`&&(i=i.max(e.maxItems)),e.uniqueItems===!0&&(i=i.refine(e=>new Set(e.map(Us)).size===e.length,{message:`Array items must be unique`})),Ws(i,e,t,n,r)}switch(e.type){case`string`:{let i=w();if(typeof e.minLength==`number`&&(i=i.min(e.minLength)),typeof e.maxLength==`number`&&(i=i.max(e.maxLength)),typeof e.pattern==`string`)try{i=i.regex(new RegExp(e.pattern,`u`))}catch{}return e.format===`uri`?Ws(i.refine(e=>e.trim().length>0&&!/\s/.test(e.trim()),`Invalid URI`),e,t,n,r):Ws(i,e,t,n,r)}case`integer`:case`number`:{let i=e.type===`integer`?T().int():T();return typeof e.minimum==`number`&&(i=i.min(e.minimum)),typeof e.maximum==`number`&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum==`number`&&(i=i.gt(e.exclusiveMinimum)),typeof e.exclusiveMaximum==`number`&&(i=i.lt(e.exclusiveMaximum)),typeof e.multipleOf==`number`&&(i=i.multipleOf(e.multipleOf)),Ws(i,e,t,n,r)}case`boolean`:return Ws(E(),e,t,n,r);case`object`:{let i=e.properties,a=typeof e.patternProperties==`object`&&e.patternProperties!==null,o;if(typeof i==`object`&&i||a){let a=Array.isArray(e.required)?new Set(e.required.filter(e=>typeof e==`string`)):/* @__PURE__ */ new Set,s=k(Zs(i??{},a,!1,t,n,r)),c=e.additionalProperties===!1||e.unevaluatedProperties===!1;o=Qs(s,[e],c,t,n,r)}else o=j(D());return Ws(o,e,t,n,r)}default:return Ws(D(),e,t,n,r)}}function Ys(e){return e===`id`||e===`component`||e===`@catalogId`}function Xs(e,t,n){if(!Object.hasOwn(e,`id`)||!xc(n))return!1;switch(t){case`catalogId`:return n.type===`string`;case`metadata`:{let e=n.properties;if(n.type!==`object`||!xc(e))return!1;let t=Object.keys(e);return t.length===1&&t[0]===`extensions`}default:return!1}}function Zs(e,t,n=!1,r,i,a=/* @__PURE__ */ new Map){let o={};for(let[s,c]of Object.entries(e)){if(n&&Ys(s))continue;let e=Js(typeof c==`object`&&c?c:{},r,i?new Set(i):/* @__PURE__ */ new Set,a);o[s]=t.has(s)?e.safeParse(void 0).success?Ot((e,t)=>(e===void 0&&t.addIssue({code:g.custom,message:`Required`}),e),e):e:e instanceof vt?e:e.optional()}for(let[t,n]of Object.entries(e))Object.hasOwn(o,t)&&Xs(e,t,n)&&ha(o[t]);return o}function Qs(e,t,n,r,i,a=/* @__PURE__ */ new Map){let o=[];for(let e of new Set(t)){let t=e.patternProperties;if(t&&typeof t==`object`&&!Array.isArray(t))for(let[e,n]of Object.entries(t)){let t;try{t=new RegExp(e,`u`)}catch{continue}o.push({regex:t,schema:Js(typeof n==`object`&&n?n:{},r,i?new Set(i):/* @__PURE__ */ new Set,a)})}}if(o.length===0)return n?e.strict():e.passthrough();let s=new Set(Object.keys(e.shape));return e.passthrough().superRefine((e,t)=>{let r=[];for(let[i,a]of Object.entries(e)){if(s.has(i))continue;let e=!1;for(let{regex:n,schema:r}of o){if(!n.test(i))continue;e=!0;let o=r.safeParse(a);if(!o.success)for(let e of o.error.issues)t.addIssue({code:g.custom,message:e.message,path:[i,...e.path]})}!e&&n&&r.push(i)}r.length>0&&t.addIssue({code:g.unrecognized_keys,keys:r})})}function $s(e){let t={};for(let[n,r]of Object.entries(Un.shape)){if(!e&&n.startsWith(`@`))continue;let i=n.replace(/^@/,``);i!==`id`&&i!==`catalogId`&&(i!==`metadata`||e)&&(t[n]=ha(r))}return t}function ec(e,t,n=/* @__PURE__ */ new Set,r=!1){if(!e||typeof e!=`object`)return[];let i=[],a=[],o=[];if(Array.isArray(e.allOf)){for(let s of e.allOf)if(s&&typeof s==`object`){if(typeof s.$ref==`string`){let e=s.$ref;if(e.includes(`common_types.json`)&&e.includes(`ComponentCommon`))i.push({kind:`zod`,properties:$s(r)});else if(e.startsWith(`#/`)){if(!n.has(e)){n.add(e);let i=Bs(t,e);i&&a.push(...ec(i,t,n,r))}}else{let t=Vs(e);if(t instanceof Qe){let e={};for(let[n,i]of Object.entries(t.shape))(r||!n.startsWith(`@`))&&(e[n]=ha(i));i.push({kind:`zod`,properties:e})}}}else o.push(...ec(s,t,n,r))}}let s=[...i,...a,...o];return e.properties&&s.push({kind:`json`,schema:e}),s}function tc(e,t,n=!0,r=/* @__PURE__ */ new Map,i=!1){let a={},o=ec(e,t,void 0,i),s=/* @__PURE__ */ new Set;for(let e of o)e.kind===`json`&&Array.isArray(e.schema.required)&&e.schema.required.forEach(e=>{typeof e==`string`&&s.add(e)});for(let e of o){if(e.kind===`zod`){for(let[t,r]of Object.entries(e.properties))n&&Ys(t)||(a[t]=r);continue}let i=Zs(e.schema.properties||{},s,n,t,void 0,r);Object.assign(a,i)}let c=k(a);return e.unevaluatedProperties===!0||typeof e.unevaluatedProperties==`object`&&e.unevaluatedProperties!==null||e.additionalProperties===!0||typeof e.additionalProperties==`object`&&e.additionalProperties!==null?c.passthrough():c.strict()}function nc(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return Object.keys(t).length>0&&t.properties===void 0&&typeof t.type!=`string`&&!(`$ref`in t)&&!(`allOf`in t)&&!(`oneOf`in t)&&!(`anyOf`in t)&&!(`not`in t)&&Object.values(t).every(e=>e!==null&&(typeof e==`object`||typeof e==`boolean`))}function rc(e){return e.unevaluatedProperties===!0||typeof e.unevaluatedProperties==`object`&&e.unevaluatedProperties!==null||e.additionalProperties===!0||typeof e.additionalProperties==`object`&&e.additionalProperties!==null}function ic(e,t,n=/* @__PURE__ */ new Set){let r={schemas:[],hasUnresolvable:!1};if(!e||typeof e!=`object`||Array.isArray(e))return r;if(nc(e))return r.schemas.push({type:`object`,properties:e}),r;if(typeof e.$ref==`string`){let i=e.$ref;if(i.startsWith(`#/`)){if(!t)r.hasUnresolvable=!0;else if(!n.has(i)){n.add(i);let e=Bs(t,i);if(e){let i=ic(e,t,n);r.schemas.push(...i.schemas),i.hasUnresolvable&&(r.hasUnresolvable=!0)}else r.hasUnresolvable=!0}}else r.hasUnresolvable=!0}if(Array.isArray(e.allOf)){for(let i of e.allOf)if(i&&typeof i==`object`&&!Array.isArray(i)){let e=ic(i,t,n);r.schemas.push(...e.schemas),e.hasUnresolvable&&(r.hasUnresolvable=!0)}}let i=ac(e.anyOf);return(Array.isArray(e.anyOf)&&!i||Array.isArray(e.oneOf))&&(r.hasUnresolvable=!0),(e.properties||e.required||i||e.patternProperties||e.additionalProperties!==void 0||e.unevaluatedProperties!==void 0)&&r.schemas.push(e),r}function ac(e){if(!Array.isArray(e)||e.length===0)return;let t=[];for(let n of e){if(!xc(n))return;let e=Object.keys(n);if(e.length!==1||e[0]!==`required`||!Array.isArray(n.required))return;let r=n.required.filter(e=>typeof e==`string`);if(r.length===0||r.length!==n.required.length)return;t.push(r)}return t}function oc(e,t,n=/* @__PURE__ */ new Map){let r=ic(e,t),i=/* @__PURE__ */ new Set;for(let e of r.schemas)if(Array.isArray(e.required))for(let t of e.required)typeof t==`string`&&i.add(t);let a={};for(let e of r.schemas)if(e.properties&&typeof e.properties==`object`&&!Array.isArray(e.properties)){let r=Zs(e.properties,i,!1,t,void 0,n);Object.assign(a,r)}let o=k(a),s=r.hasUnresolvable||r.schemas.some(rc)||rc(e),c=[e,...r.schemas.filter(t=>t!==e)],l=Qs(o,c,!s,t,void 0,n);for(let e of c){let t=ac(e.anyOf);if(t){let e=t.map(e=>e.map(e=>`'${e}'`).join(`+`)).join(`, `);l=l.refine(e=>xc(e)&&t.some(t=>t.every(t=>e[t]!==void 0)),{message:`At least one of ${e} must be provided.`})}}return l}function sc(e){return typeof e==`object`&&!!e&&typeof e.safeParse==`function`}function cc(e){let t=/* @__PURE__ */ new Set,n=e=>{let r=e?._def;switch(r?.typeName){case`ZodObject`:{let n=typeof e.shape==`function`?e.shape():e.shape;if(n&&typeof n==`object`)for(let e of Object.keys(n))t.add(e);return}case`ZodEffects`:n(r.schema);return;case`ZodOptional`:case`ZodNullable`:case`ZodDefault`:case`ZodCatch`:case`ZodReadonly`:n(r.innerType);return;case`ZodBranded`:n(r.type);return;case`ZodPipeline`:n(r.in),n(r.out);return;case`ZodIntersection`:n(r.left),n(r.right);return;case`ZodUnion`:case`ZodDiscriminatedUnion`:for(let e of r.options)n(e);return;default:return}};return n(e),t}function lc(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return[];let n=e,r=[],i=/* @__PURE__ */ new Set,a=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let n=e;if(typeof n.$ref==`string`&&t&&n.$ref.startsWith(`#/`)&&!i.has(n.$ref)){i.add(n.$ref);let e=Bs(t,n.$ref);e&&a(e)}n.properties&&typeof n.properties==`object`&&n.properties!==null&&!Array.isArray(n.properties)&&r.push(...Object.keys(n.properties));for(let e of[n.allOf,n.anyOf,n.oneOf])if(Array.isArray(e))for(let t of e)a(t)};return n.properties&&typeof n.properties==`object`&&n.properties!==null&&!Array.isArray(n.properties)||Array.isArray(n.allOf)||Array.isArray(n.anyOf)||Array.isArray(n.oneOf)||typeof n.$ref==`string`?(a(n),r):nc(n)?Object.keys(n):[]}function uc(e,t,n,r=!1){let i=[];if(!e)return i;let a=/* @__PURE__ */ new Map,o=(e,t)=>{if(r){Pn(e,`function identifier: '${e}'`);for(let n of t)Pn(n,`argument identifier: '${n}' in function '${e}'`)}},s=e=>{if(r&&e.requiresUserActivation===!0&&e.allowedCallers!==void 0&&e.allowedCallers!==`rendererOnly`)throw new I(`Function '${e.name}' declares requiresUserActivation=true with allowedCallers='${e.allowedCallers}'; requiresUserActivation=true requires allowedCallers='rendererOnly'.`)};if(Array.isArray(e)){for(let r of e)if(r&&typeof r==`object`&&typeof r.name==`string`){let e=lc(r.parameters,t);o(r.name,e);let c=new Wi(r.name,r,e=>e.parameters&&typeof e.parameters==`object`?oc(e.parameters,t,a):j(D()));if(s(c),n&&!n.has(r.name))continue;i.push(c)}return i}if(typeof e==`object`&&e)for(let[r,c]of Object.entries(e)){if(o(r,lc(dc(c&&typeof c==`object`?c:{}),t)),!c||typeof c!=`object`)continue;let e=new Wi(r,c,e=>{let n=dc(e);return n?oc(n,t,a):j(D())});s(e),(!n||n.has(r))&&i.push(e)}return i}function dc(e){let t=e.properties&&typeof e.properties==`object`&&e.properties!==null&&!Array.isArray(e.properties)?e.properties:void 0;if(!t?.args&&Array.isArray(e.allOf))for(let n of e.allOf)n&&typeof n==`object`&&!Array.isArray(n)&&n.properties&&typeof n.properties==`object`&&n.properties!==null&&!Array.isArray(n.properties)&&(t={...t,...n.properties});let n=t?.args??e.args??e.parameters;return!n&&t&&!(`call`in t)&&!(`@call`in t)&&!(`function`in t)?n=e:nc(n)&&(n={type:`object`,properties:n,required:e.required,additionalProperties:e.additionalProperties}),n&&typeof n==`object`&&!Array.isArray(n)?n:void 0}function fc(e,t){if(!Array.isArray(e))return;let n=/* @__PURE__ */ new Set;for(let r of e)if(typeof r?.$ref==`string`&&r.$ref.startsWith(t)){let e=r.$ref.slice(t.length).replace(/~([01])/g,(e,t)=>t===`1`?`/`:`~`);n.add(e)}return n}function pc(e,t,n,r){let i=[],a=/* @__PURE__ */ new Map;for(let[o,s]of Object.entries(e)){let e=s||{};if(n){Pn(o,`component identifier: '${o}'`);let t=e.properties;if(t&&typeof t==`object`)for(let e of Object.keys(t))Pn(e,`property identifier: '${e}' in component '${o}'`);let n=e.metadata;if(n!==void 0)try{Di(n)}catch(e){throw new I(e instanceof Error?e.message:String(e))}}(!r||r.has(o))&&i.push(new Ui(o,e,e=>tc(e,t,!0,a,n)))}return i}function mc(e,t){let n=e.theme??e.themeSchema??e.styles??t?.theme;if(n&&typeof n==`object`){let t=n,r=`properties`in t||`allOf`in t||t.type===`object`?t:{type:`object`,properties:t},i=tc(r,e,!1);return r.additionalProperties===!1||r.unevaluatedProperties===!1?i:i.passthrough()}}function hc(e){if(e.startsWith(`#`))return!0;let t=e.indexOf(`#`),n=t===-1?e:e.slice(0,t);return n===`catalog.json`||n.split(`/`).pop()===`common_types.json`}function gc(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function _c(e,t){if(Array.isArray(e))e.forEach((e,n)=>_c(e,`${t}/${n}`));else if(xc(e))for(let[n,r]of Object.entries(e)){let e=`${t}/${gc(n)}`;if(n===`$ref`&&typeof r==`string`&&!hc(r))throw new I(`Unsupported external $ref '${r}' at ${e}: a v1.0 catalog may only reference its own components and functions (#/...) or common_types.json.`);_c(r,e)}}function vc(e,t,n){let r=gs(e),i=n??r.catalogId??r.$id??r.id;if(!i||typeof i!=`string`)throw Error(`Catalog ID must be specified via catalog metadata ('catalogId' or '$id').`);let a=r.$defs,o=a?.anyComponent,s=fc(o?.oneOf,`#/components/`),c=t??r.protocolVersion??`0.9`,l=R(c,`1.0`);l&&_c(r,``);let u=pc(r.components??{},r,l,s),d=a?.anyFunction,f=fc(d?.oneOf,`#/functions/`),p=uc(r.functions,r,f,l),m=mc(r,a);return _s(r),{id:i,protocolVersion:c,components:u,functions:p,themeSchema:m,...Cc(r,u,p)}}var yc={$schema:`schemaUri`,$id:`schemaId`,title:`title`,description:`description`,instructions:`instructions`},bc=/* @__PURE__ */ new Set([`protocolVersion`,`catalogId`,`components`]);function xc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sc(e,t){return Us(e)===Us(t)}function Cc(e,t,n){let r={},i={};for(let[a,o]of Object.entries(e))if(a in yc&&typeof o==`string`)r[yc[a]]=o;else if(a===`protocolVersion`&&typeof o==`string`)r.declaredProtocolVersion=o;else if(a===`functions`&&(Array.isArray(o)||xc(o)))r.functionsLayout=Array.isArray(o)?`list`:`map`;else if(a===`$defs`&&xc(o)){let e=Sc(o.anyComponent,Ms(t.map(e=>e.name))),i=Sc(o.anyFunction,Ns(n.map(e=>e.name)));r.unions={anyComponent:e,anyFunction:i};let a={};for(let[t,n]of Object.entries(o))t===`anyComponent`&&e||t===`anyFunction`&&i||(a[t]=n);r.defs=Object.freeze(a)}else(!bc.has(a)||a===`components`&&!xc(o))&&(i[a]=o);return r.declaredProtocolVersion??=null,r.declaresCatalogId=typeof e.catalogId==`string`,r.declaresComponents=xc(e.components),r.unions??={anyComponent:!1,anyFunction:!1},Object.keys(i).length>0&&(r.extensionFields=Object.freeze(i)),r}var wc,Tc=Symbol(`AgentFunction.fromApi`),Ec=Symbol(`AgentFunction.boundDefs`),Dc=class e{constructor(e){if(this[wc]=!0,typeof e?.handler!=`function`)throw TypeError(`Agent function '${e?.name??``}' requires a callable handler.`);let t=e[Tc],n=e[Ec];this.name=e.name,this.returnType=e.returnType??`any`,this.schema=n?n.resolvedSchema:Oc(e.schema),e.schema!==void 0&&!sc(e.schema)&&(this.jsonSchema=e.schema,this.declaredParameterNames=n?n.declaredParameterNames:lc(e.schema,e.schema)),this.boundCatalogDefs=n?.catalogDefs,this.handler=e.handler,this.explicitAllowedCallers=t?.allowedCallers,this.allowedCallers=t?.allowedCallers??`rendererOnly`,this.explicitRequiresUserActivation=e.requiresUserActivation,this.requiresUserActivation=e.requiresUserActivation??!1,this.description=e.description,this.declaration=t?.declaration}static fromApi(t,n){if(Ii(t))throw TypeError(`Function '${t.name}' is already an agent function.`);if(t.allowedCallers===`agentOnly`)throw new I(`Function '${t.name}' is agentOnly, so a renderer never calls it and it can't be an agent function.`);if(t.requiresUserActivation===!0&&t.allowedCallers!==void 0&&t.allowedCallers!==`rendererOnly`)throw new I(`Function '${t.name}' requires user activation, so its allowedCallers must be rendererOnly, not ${t.allowedCallers}.`);let r={name:t.name,returnType:t.returnType,schema:t.schema,handler:n,requiresUserActivation:t.requiresUserActivation,description:t.description,[Tc]:{declaration:t,allowedCallers:t.allowedCallers}},i=new e(r);return zi(t,i),i}withHandler(t){return this.declaration===void 0?new e({name:this.name,returnType:this.returnType,schema:this.jsonSchema??this.schema,handler:t,requiresUserActivation:this.explicitRequiresUserActivation,description:this.description}):e.fromApi(this.declaration,t)}};wc=Fi;function Oc(e){return e===void 0?j(D()):sc(e)?e:typeof e==`object`&&e&&!Array.isArray(e)?Object.keys(e).length===0?j(D()):oc(e,e):j(D())}function kc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ac(e,t){let n=kc(e.$defs)?e.$defs:void 0,r=/* @__PURE__ */ new Set,i=e=>{if(typeof e!=`object`||!e||r.has(e))return!1;if(r.add(e),Array.isArray(e))return e.some(i);let a=e;if(typeof a.$ref==`string`&&a.$ref.startsWith(`#/$defs/`)){let e=a.$ref.slice(8).split(`/`)[0].replace(/~1/g,`/`).replace(/~0/g,`~`);if(e in t&&!(n&&e in n))return!0}for(let e of Object.values(a))if(i(e))return!0;return!1};return i(e)}function jc(e,t){let n=e.jsonSchema;if(n===void 0||e.boundCatalogDefs===t)return e;let r=t!==void 0&&Object.keys(t).length>0&&Ac(n,t);if(!r&&e.boundCatalogDefs===void 0)return e;let i=kc(n.$defs)?n.$defs:void 0,a=r?{...n,$defs:{...t,...i}}:{...n},o=Object.keys(n).length===0?j(D()):oc(n,a),s=lc(n,a),c=new Dc({name:e.name,returnType:e.returnType,schema:n,handler:e.handler,requiresUserActivation:e.explicitRequiresUserActivation,description:e.description,...e.declaration===void 0?{}:{[Tc]:{declaration:e.declaration,allowedCallers:e.explicitAllowedCallers}},[Ec]:{catalogDefs:r?t:void 0,resolvedSchema:o,declaredParameterNames:s}});return zi(e,c),c}function Mc(e,t){return t?.standardDefs?t.standardDefs:Bo(t?.protocolVersion??e.protocolVersion)}var Nc=/^[^#]+#\/(?:\$defs|definitions)\/([^/]+)(\/.*)?$/;function Pc(e){let t=Nc.exec(e);return t?`#/$defs/${t[1]}${t[2]??``}`:`#/$defs/${e.split(`/`).pop()}`}function Fc(e){if(e.startsWith(`#/$defs/`))return e.substring(8).split(`/`)[0].replace(/~1/g,`/`).replace(/~0/g,`~`)}function Ic(e){if(typeof e.description!=`string`||!e.description.startsWith(`REF:`))return!1;let t=e.description.substring(4),n=t.indexOf(`|`),r=n===-1?t:t.substring(0,n),i=n===-1?``:t.substring(n+1),a=e.default;for(let t of Object.keys(e))delete e[t];return e.$ref=r.startsWith(`#`)?r:Pc(r),a!==void 0&&(e.default=a),i&&(e.description=i),!0}function Lc(e,t={}){if(Array.isArray(e.allOf)){let t=e.allOf.filter(e=>!(typeof e==`object`&&e&&Object.keys(e).length===0)),n=t.length===1?t[0]:void 0;typeof n==`object`&&n&&!Array.isArray(n)&&Object.keys(n).every(t=>!(t in e)||t===`allOf`)?(delete e.allOf,Object.assign(e,n)):t.length===0?delete e.allOf:e.allOf=t}t.stripAdditionalProperties?(delete e.additionalProperties,delete e.unevaluatedProperties):(e.additionalProperties&&typeof e.additionalProperties==`object`&&Object.keys(e.additionalProperties).length===0&&(e.additionalProperties=!0),e.unevaluatedProperties&&typeof e.unevaluatedProperties==`object`&&Object.keys(e.unevaluatedProperties).length===0&&(e.unevaluatedProperties=!0)),`$schema`in e&&delete e.$schema}function Rc(e,t=/* @__PURE__ */ new Set,n={}){if(typeof e!=`object`||!e||t.has(e))return;if(t.add(e),Array.isArray(e)){for(let r of e)Rc(r,t,n);return}let r=e;if(!Ic(r)){Lc(r,n);for(let e of Object.keys(r))Rc(r[e],t,n)}}function zc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Bc=/* @__PURE__ */ new Set([`description`,`title`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`]),Vc=/* @__PURE__ */ new Set([`id`,`component`,`catalogId`,`@catalogId`]),Hc=/* @__PURE__ */ new WeakSet,Uc=/* @__PURE__ */ new Set([`anyComponent`,`anyFunction`,`theme`]),Wc=/^(?:([^#]*common_types\.json))?#\/\$defs\/([^/]+)(\/.*)?$/,Gc=/\/(ComponentCommon|Checkable)$/;function Kc(e,t,n,r=``){if(e.$ref=`#/$defs/${t}${r}`,r||e.description!==void 0)return;let i=n[t];zc(i)&&typeof i.description==`string`&&(e.description=i.description)}function qc(e,t,n){if(Array.isArray(e)){for(let r of e)qc(r,t,n);return}if(!zc(e))return;let r=e.$ref,i=typeof r==`string`?Wc.exec(r):null;if(i){let[,r,a,o]=i;if(r!==void 0||a in t){if(n){for(let t of Object.keys(e))t!==`$ref`&&!Bc.has(t)&&delete e[t];Kc(e,a,t,o);return}Kc(e,a,t,o)}}for(let r of Object.values(e))qc(r,t,n)}function Jc(e,t){if(!t.startsWith(`#/`))return;let n=e;for(let e of t.substring(2).split(`/`)){let t=e.replace(/~([01])/g,(e,t)=>t===`1`?`/`:`~`);if(!zc(n)||!(t in n))return;n=n[t]}return n}function Yc(e,t,n){let r=[],i=[],a=[];for(let o of Array.isArray(e.allOf)?e.allOf:[]){if(!zc(o))continue;let e=o.$ref;if(typeof e!=`string`){r.push(...Yc(o,t,n));continue}let s=Gc.exec(e)?.[1],c=e.startsWith(`#/`)?Jc(t.rootDoc,e):void 0;if(s===void 0&&zc(c)){n.has(e)||(n.add(e),i.push(...Yc(c,t,n)));continue}let l=Nc.exec(e),u=s??(l&&!l[2]?l[1]:void 0),d=u===void 0?void 0:t.standardDefs[u];if(zc(d)&&zc(d.properties)){let e={properties:gs(d.properties),...Array.isArray(d.required)?{required:d.required}:{}};Hc.add(e),a.push(e)}}let o=[...a,...i,...r];return(`properties`in e||`description`in e)&&o.push(e),o}function Xc(e,t){let n=Yc(e,t,/* @__PURE__ */ new Set),r,i={},a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Set;for(let e of n){if(typeof e.description==`string`&&(r=e.description),zc(e.properties)&&(Object.assign(i,e.properties),!Hc.has(e)))for(let t of Object.keys(e.properties))a.add(t);if(Array.isArray(e.required))for(let t of e.required)typeof t==`string`&&o.add(t)}let s=e=>Vc.has(e)&&!(e===`catalogId`&&a.has(e)),c={};for(let[e,n]of Object.entries(i)){if(s(e))continue;let r=gs(n);qc(r,t.standardDefs,!0),c[e]=r}return{props:c,required:[...o].filter(e=>!s(e)).sort(),...r===void 0?{}:{description:r}}}function Zc(e,t){let n=t.model.functions.get(e);if(!n)return;let r=zc(n.properties)?n.properties:void 0,i=r?.args??n.args??n.parameters;if(i!==void 0)return zc(i)?nc(i)?{type:`object`,properties:i,...n.required===void 0?{}:{required:n.required},...n.additionalProperties===void 0?{}:{additionalProperties:n.additionalProperties}}:i:{};let a=r&&(`call`in r||`@call`in r||`function`in r);if(!r||a)return{};let{description:o,title:s,name:c,returnType:l,allowedCallers:u,requiresUserActivation:d,...f}=n;return f}function Qc(e){let t=hs.map(t=>e.extensionFields[t]).find(e=>e!==void 0)??e.defs.theme;if(zc(t))return`properties`in t||`allOf`in t||t.type===`object`?t:{type:`object`,properties:t}}function $c(e){return(mr(e.protocolVersion)??e.protocolVersion)===`0.8`||e.id.includes(`v0_8`)||e.id.includes(`v0.8`)}function el(e,t,n,r){if(!e.themeSchema)return;let i=$c(e),a=Qc(r.model);if(a){let e=gs({...a});!i&&e.additionalProperties===void 0&&e.unevaluatedProperties===void 0&&(e.additionalProperties=!0),t.theme=e;return}let o=Oo(e.themeSchema,{target:`jsonSchema2019-09`,$refStrategy:`none`,override:jo});Rc(o),tl(o,t,n);let s=o.additionalProperties===!1,c={type:`object`,...typeof o.description==`string`&&!o.description.startsWith(`REF:`)?{description:o.description}:{},properties:o.properties||{},...Array.isArray(o.required)&&o.required.length>0?{required:o.required}:{},...s?{additionalProperties:!1}:i?{}:{additionalProperties:o.additionalProperties===void 0||o.additionalProperties}};n.push(c),t.theme=c}function tl(e,t,n){let r=zc(e.definitions)?e.definitions:zc(e.$defs)?e.$defs:void 0;delete e.definitions,delete e.$defs,r&&(Object.assign(t,r),n.push(r))}function nl(e,t,n){if(!e.schema||typeof e.schema!=`object`||!(`safeParse`in e.schema))return{props:{},reqList:[],additionalProps:void 0};let r=Oo(e.schema,{target:`jsonSchema2019-09`,$refStrategy:`none`,override:jo});Rc(r),tl(r,t,n);let i=r.properties||{},a=Array.isArray(r.required)?r.required.filter(e=>e!==`component`&&e!==`id`):[],o=r.unevaluatedProperties??r.additionalProperties;return{props:i,reqList:a,additionalProps:typeof o==`boolean`||zc(o)?o:void 0}}function rl(e){let t=e.schema?.description;return typeof t==`string`&&!t.startsWith(`REF:`)?t:void 0}function il(e){return e.unevaluatedProperties??e.additionalProperties}function al(e,t,n,r,i,a){let o,s,c,l,u=i.model.components.get(e);if(u)({props:o,required:s,description:c}=Xc(u,i)),l=il(u)??(i.isV10?void 0:!1);else{let e=nl(t,n,r),{component:a,id:u,...d}=e.props;r.push(d),o=d,s=e.reqList,c=rl(t),l=i.isV10?e.additionalProps===!0||void 0:e.additionalProps??!1}let d={};Kc(d,`ComponentId`,i.standardDefs);let f={id:d,...o,component:{const:e}},p=[`id`,...s,`component`],m=l===void 0?{}:{unevaluatedProperties:l},h;return h=a?.componentEnvelopeRef?{...c===void 0?{}:{description:c},allOf:[{$ref:a.componentEnvelopeRef},{type:`object`,properties:f,required:p}],...m}:{type:`object`,...c===void 0?{}:{description:c},properties:f,required:p,...m},t.allowedParents&&t.allowedParents.length>0&&(h.allowedParents=t.allowedParents),t.allowedChildren&&t.allowedChildren.length>0&&(h.allowedChildren=t.allowedChildren),h}function ol(e,t,n,r,i,a){if(e.components.size===0){t.components={};return}let o={};for(let[t,s]of e.components.entries())o[t]=al(t,s,n,r,i,a);t.components=o,n.anyComponent={oneOf:Array.from(e.components.keys()).map(e=>({$ref:`#/components/${e}`})),discriminator:{propertyName:`component`}}}function sl(e,t,n,r,i){let a,o=Zc(e,i);if(o)a=gs(o),qc(a,i.standardDefs,!1);else if(t.schema&&typeof t.schema==`object`&&`safeParse`in t.schema){let e=Oo(t.schema,{target:`jsonSchema2019-09`,$refStrategy:`none`,override:jo});Rc(e),tl(e,n,r),r.push(e),a=e}else a={type:`object`,properties:{}};if(a.type===`object`){let e=a.additionalProperties;delete a.additionalProperties,a.unevaluatedProperties=a.unevaluatedProperties??e??!1}return a}function cl(e,t,n,r,i){let a=sl(e,t,n,r,i),o=ns(a,{...i.defs,...n}),s=i.isV10?`@call`:`call`,c=o?[s,`args`]:[s];return i.isV10?{type:`object`,...t.description?{description:t.description}:{},returnType:t.returnType,...t.allowedCallers===void 0?{}:{allowedCallers:t.allowedCallers},...t.requiresUserActivation===void 0?{}:{requiresUserActivation:t.requiresUserActivation},properties:{"@call":{const:e},args:a},required:c}:{type:`object`,...t.description?{description:t.description}:{},properties:{call:{const:e},args:a,returnType:{const:t.returnType}},required:c,unevaluatedProperties:!1}}function ll(e,t,n,r,i){let a=Array.from(e.functions.keys()).filter(e=>!e.startsWith(`@`));if(a.length===0)return;let o={};for(let t of a)o[t]=cl(t,e.functions.get(t),n,r,i);t.functions=o,n.anyFunction={oneOf:a.map(e=>({$ref:`#/functions/${e}`}))}}var ul=new Map(Object.values(rr).flatMap(e=>{let t=e.description;if(typeof t!=`string`||!t.startsWith(`REF:`))return[];let n=t.substring(4),r=n.indexOf(`|`);return r===-1?[]:[[n.substring(0,r).split(`/`).pop(),n.substring(r+1)]]}));function dl(e,t,n=/* @__PURE__ */ new Set){if(typeof e!=`object`||!e||n.has(e))return;if(n.add(e),Array.isArray(e)){for(let r of e)dl(r,t,n);return}let r=e,i=r.$ref;if(typeof i==`string`&&!i.startsWith(`#`)&&i!==t){if(!Nc.test(i))throw Error(`Cannot bundle the external schema reference '${i}'.`);r.$ref=Pc(i)}for(let e of Object.values(r))dl(e,t,n)}function fl(e,t,n=/* @__PURE__ */ new Set){if(typeof e!=`object`||!e||n.has(e))return;if(n.add(e),Array.isArray(e)){for(let r of e)fl(r,t,n);return}let r=e,i=r.$ref;if(typeof i==`string`&&i.startsWith(`#/$defs/`)){let e=i.substring(8),n=e.includes(`/`)?void 0:t[e],a=r.description===void 0||r.description===ul.get(e);n&&a&&(typeof n.description==`string`?r.description=n.description:delete r.description)}for(let e of Object.values(r))fl(e,t,n)}function pl(e,t,n=/* @__PURE__ */ new Set){if(typeof e==`object`&&e&&!n.has(e)){if(n.add(e),typeof e.$ref==`string`){let n=Fc(e.$ref);n!==void 0&&t.add(n)}if(Array.isArray(e))for(let r of e)pl(r,t,n);else for(let r of Object.values(e))pl(r,t,n)}}function ml(e,t){let n={$schema:`https://json-schema.org/draft/2020-12/schema`,...typeof e.declaredProtocolVersion==`string`?{protocolVersion:e.declaredProtocolVersion.trim().replace(/^[vV](?=\d)/,``)}:{},catalogId:e.id};e.instructions&&(n.instructions=e.instructions);let r=Mc(e,t),i=t?.protocolVersion??e.protocolVersion,a=Is(e),o=a.defs,s={standardDefs:r,model:a,defs:o,rootDoc:{$defs:o},isV10:!!i&&R(i,`1.0`)},c={},l=[];el(e,c,l,s),ol(e,n,c,l,s,t),ll(e,n,c,l,s),dl(n,t?.componentEnvelopeRef),dl(c);for(let e of l)fl(e,r);let u;do{u=Object.keys(c).length;let e=/* @__PURE__ */ new Set;pl(n,e),pl(c,e),(e.has(`DynamicString`)||e.has(`DynamicNumber`)||e.has(`DynamicBoolean`)||e.has(`DynamicValue`))&&(e.add(`DataBinding`),e.add(`FunctionCall`));for(let t of e)if(!(t in c)){if(t in r){let e=gs(r[t]);dl(e),c[t]=e}else if(!Uc.has(t)&&t in o){let e=gs(o[t]);qc(e,r,!1),dl(e),c[t]=e}}e.has(`anyFunction`)&&!(`anyFunction`in c)&&(c.anyFunction={not:{}})}while(Object.keys(c).length>u);return Object.keys(c).length>0&&(n.$defs=c),n}function hl(e){if(!e)return``;let t=e.lastIndexOf(`#`);return(t===-1?e:e.slice(t+1)).split(`/`).filter(Boolean).pop()??``}var gl=/* @__PURE__ */ new Set([`ComponentId`,`Child`,`ChildComponentId`]),_l=/* @__PURE__ */ new Set([`ChildList`,`TemplateChildList`,`ChildrenItem`,`TemplateItem`]),vl=/* @__PURE__ */ new Map,yl={},bl=/* @__PURE__ */ new WeakMap;function xl(e,t){let n=e?._def?.typeName;if(n===`ZodUnion`){let n=Sl(e)?.[0];return!(!n||n.description!==t&&n._def?.description!==t)}if(n===`ZodIntersection`){let n=e._def.left;return!(!n||n.description!==t&&n._def?.description!==t)}return!1}function W(e){let t=[],n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Set,s=``,c=!1,l=e;for(;l&&typeof l==`object`&&l._def&&!a.has(l);){if(a.add(l),l.description&&!xl(l,l.description)){t.push(l.description);let e=Ul(l.description,n,r);!s&&e&&(s=e)}let e=l._def.description;if(e&&e!==l.description&&!xl(l,e)){t.push(e);let i=Ul(e,n,r);!s&&i&&(s=i)}let u=jn(l);u&&i.add(u);let d=l._def.typeName;if(d===`ZodOptional`||d===`ZodNullable`||d===`ZodDefault`||d===`ZodReadonly`||d===`ZodCatch`)l=l._def.innerType;else if(d===`ZodEffects`){let e=l._def.effect;(e?.type===`transform`||e?.type===`preprocess`)&&(c=!0),l=l._def.schema}else if(d===`ZodBranded`)l=l._def.type;else if(d===`ZodLazy`){let e=l._def.getter;if(o.has(e))break;o.add(e),l=e()}else break}return{schema:l,descriptions:t,firstRefDefName:s,refDefNames:n,bareDefNames:r,refs:i,traversed:a,hasTransform:c}}function Sl(e){let t=e?._def?.typeName;if(t!==`ZodUnion`&&t!==`ZodDiscriminatedUnion`)return;let n=e._def.options;if(n)return Array.isArray(n)?n:Array.from(n.values())}function Cl(e){if(e?._def?.typeName!==`ZodObject`)return!1;let t=e.shape;return!!(Object.hasOwn(t,`componentId`)&&(Object.hasOwn(t,`path`)||Object.hasOwn(t,`dataBinding`))||Object.hasOwn(t,`explicitList`)||Object.hasOwn(t,`template`))}function wl(e,t){return q(W(e),/* @__PURE__ */ new Set,t)}function Tl(e,t){return J(W(e),/* @__PURE__ */ new Set,t)}function El(e,t,n){return Ll(e,t,/* @__PURE__ */ new Set,n)?.kind===`single`}function Dl(e){let t=W(e);return Xl(t,/* @__PURE__ */ new Set)||Yl(t,/* @__PURE__ */ new Set)||t.schema?._def?.typeName===`ZodArray`}function Ol(e,t){if(!e)return vl;let n=t??yl,r=bl.get(n);if(r){let t=r.get(e);if(t)return t}else r=/* @__PURE__ */ new WeakMap,bl.set(n,r);let i=jl(e,/* @__PURE__ */ new Set,t),a=i.fields;(i.isEmptyObject&&!i.declaredKeys.has(`child`)||i.openChildFallback)&&K(a,`child`,{kind:`single`}),(i.isEmptyObject&&!i.declaredKeys.has(`children`)||i.openChildrenFallback)&&K(a,`children`,{kind:`list`});let o=a.size===0?vl:a;return r.set(e,o),o}function kl(){return{fields:/* @__PURE__ */ new Map,declaredKeys:/* @__PURE__ */ new Set,compatibleSingleKeys:/* @__PURE__ */ new Set,compatibleListKeys:/* @__PURE__ */ new Set,compatibleNestedKeys:/* @__PURE__ */ new Set,nestedElementAnalyses:/* @__PURE__ */ new Map,constrainsUnknownKeys:!0,isEmptyObject:!1,openSingle:!1,openList:!1,openChildFallback:!1,openChildrenFallback:!1}}function Al(e,t,n){return n.declaredKeys.has(e)?!0:t.kind===`single`?n.openSingle:n.openList}function jl(e,t,n){let r=W(e);for(let e of r.traversed)if(t.has(e))return kl();for(let e of r.traversed)t.add(e);switch(r.schema?._def?.typeName){case`ZodObject`:{let e=r.schema,i=e.shape,a=/* @__PURE__ */ new Map,o=new Set(Object.keys(i)),s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Set,l=/* @__PURE__ */ new Set,u=/* @__PURE__ */ new Map;for(let[e,r]of Object.entries(i)){let i=Ll(e,r,t,n);i&&a.set(e,i);let o=W(r);if(q(o,new Set(t),n,!0)&&s.add(e),J(o,new Set(t),n,!0)&&c.add(e),Yl(o,new Set(t))){l.add(e);let r=zl(o,new Set(t),n);r&&u.set(e,r)}}let d=e._def,f=d.unknownKeys,p=d.catchall,m=!1,h=!1,g=!1,_=!1,ee=!1;if(f===`passthrough`)m=!0,h=!0,g=!o.has(`child`),_=!o.has(`children`);else if(p&&p._def.typeName!==`ZodNever`){let e=W(p);m=q(e,new Set(t),n,!0),h=J(e,new Set(t),n,!0),g=!o.has(`child`)&&q(e,new Set(t),n,!1),_=!o.has(`children`)&&J(e,new Set(t),n,!1),ee=!0}else f===`strict`&&(ee=!0);return{fields:a,declaredKeys:o,compatibleSingleKeys:s,compatibleListKeys:c,compatibleNestedKeys:l,nestedElementAnalyses:u,constrainsUnknownKeys:ee,isEmptyObject:o.size===0&&!ee&&!m&&!h,openSingle:m,openList:h,openChildFallback:g,openChildrenFallback:_}}case`ZodRecord`:{let e=r.schema._def.valueType,i=!0,a=!0,o=!0,s=!0;if(e){let r=W(e);i=q(r,new Set(t),n,!0),a=J(r,new Set(t),n,!0),o=q(r,new Set(t),n,!1),s=J(r,new Set(t),n,!1)}return{fields:/* @__PURE__ */ new Map,declaredKeys:/* @__PURE__ */ new Set,compatibleSingleKeys:/* @__PURE__ */ new Set,compatibleListKeys:/* @__PURE__ */ new Set,compatibleNestedKeys:/* @__PURE__ */ new Set,nestedElementAnalyses:/* @__PURE__ */ new Map,constrainsUnknownKeys:!0,isEmptyObject:!1,openSingle:i,openList:a,openChildFallback:o,openChildrenFallback:s}}case`ZodAny`:case`ZodUnknown`:return{fields:/* @__PURE__ */ new Map,declaredKeys:/* @__PURE__ */ new Set,compatibleSingleKeys:/* @__PURE__ */ new Set,compatibleListKeys:/* @__PURE__ */ new Set,compatibleNestedKeys:/* @__PURE__ */ new Set,nestedElementAnalyses:/* @__PURE__ */ new Map,constrainsUnknownKeys:!1,isEmptyObject:!1,openSingle:!0,openList:!0,openChildFallback:!0,openChildrenFallback:!0};case`ZodIntersection`:{let e=r.schema._def;return Pl(jl(e.left,new Set(t),n),jl(e.right,new Set(t),n))}case`ZodPipeline`:{let e=r.schema._def;return Nl(jl(e.in,new Set(t),n),jl(e.out,new Set(t),n))}case`ZodUnion`:case`ZodDiscriminatedUnion`:return Ml((Sl(r.schema)??[]).map(e=>jl(e,new Set(t),n)));default:return kl()}}function Ml(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=e.length>0,s=e.length>0,c=!1,l=!1,u=!1,d=!1;for(let r of e){for(let[e,n]of r.fields)K(t,e,n);for(let e of r.declaredKeys)n.add(e);o&&=r.isEmptyObject,s&&=r.constrainsUnknownKeys,c||=r.openSingle,l||=r.openList,u||=r.openChildFallback,d||=r.openChildrenFallback}for(let t of n)e.some(e=>G(t,{kind:`single`},e))&&r.add(t),e.some(e=>G(t,{kind:`list`},e))&&i.add(t),e.some(e=>G(t,{kind:`nested`,keys:/* @__PURE__ */ new Set},e))&&a.add(t);return{fields:t,declaredKeys:n,compatibleSingleKeys:r,compatibleListKeys:i,compatibleNestedKeys:a,nestedElementAnalyses:/* @__PURE__ */ new Map,constrainsUnknownKeys:s,isEmptyObject:o,openSingle:c,openList:l,openChildFallback:u,openChildrenFallback:d}}function Nl(e,t){let n=Pl(e,t,!0);for(let[r,i]of[...n.fields])Al(r,i,e)&&Al(r,i,t)||n.fields.delete(r);for(let r of[...n.compatibleSingleKeys])Al(r,{kind:`single`},e)&&Al(r,{kind:`single`},t)||n.compatibleSingleKeys.delete(r);for(let r of[...n.compatibleListKeys])Al(r,{kind:`list`},e)&&Al(r,{kind:`list`},t)||n.compatibleListKeys.delete(r);for(let r of[...n.compatibleNestedKeys]){let i={kind:`nested`,keys:/* @__PURE__ */ new Set};Al(r,i,e)&&Al(r,i,t)||(n.compatibleNestedKeys.delete(r),n.nestedElementAnalyses.delete(r))}return n.openSingle=!n.isEmptyObject&&e.openSingle&&t.openSingle,n.openList=!n.isEmptyObject&&e.openList&&t.openList,n.openChildFallback=!n.isEmptyObject&&e.openChildFallback&&t.openChildFallback,n.openChildrenFallback=!n.isEmptyObject&&e.openChildrenFallback&&t.openChildrenFallback,n}function Pl(e,t,n=!1){let r=/* @__PURE__ */ new Map;for(let[i,a]of e.fields)Il(r,i,a,e,t,n);for(let[i,a]of t.fields)Il(r,i,a,t,e,n);let i=/* @__PURE__ */ new Set([...e.declaredKeys,...t.declaredKeys]),a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Map;for(let r of i)if(G(r,{kind:`single`},e)&&G(r,{kind:`single`},t)&&a.add(r),G(r,{kind:`list`},e)&&G(r,{kind:`list`},t)&&o.add(r),G(r,{kind:`nested`,keys:/* @__PURE__ */ new Set},e)&&G(r,{kind:`nested`,keys:/* @__PURE__ */ new Set},t)){s.add(r);let i=e.nestedElementAnalyses.get(r),a=t.nestedElementAnalyses.get(r);i&&a?c.set(r,n?Nl(i,a):Pl(i,a)):(i||a)&&c.set(r,i??a)}let l=e.constrainsUnknownKeys||t.constrainsUnknownKeys,u=!l&&e.isEmptyObject&&t.isEmptyObject;return{fields:r,declaredKeys:i,compatibleSingleKeys:a,compatibleListKeys:o,compatibleNestedKeys:s,nestedElementAnalyses:c,constrainsUnknownKeys:l,isEmptyObject:u,openSingle:!u&&(e.openSingle||t.openSingle)&&(e.openSingle||!e.constrainsUnknownKeys)&&(t.openSingle||!t.constrainsUnknownKeys),openList:!u&&(e.openList||t.openList)&&(e.openList||!e.constrainsUnknownKeys)&&(t.openList||!t.constrainsUnknownKeys),openChildFallback:!u&&!i.has(`child`)&&(e.openChildFallback||t.openChildFallback)&&(e.openChildFallback||!e.constrainsUnknownKeys)&&(t.openChildFallback||!t.constrainsUnknownKeys),openChildrenFallback:!u&&!i.has(`children`)&&(e.openChildrenFallback||t.openChildrenFallback)&&(e.openChildrenFallback||!e.constrainsUnknownKeys)&&(t.openChildrenFallback||!t.constrainsUnknownKeys)}}function Fl(e,t,n,r=!1){let i=/* @__PURE__ */ new Set;for(let a of e){let e=(!t||G(a,{kind:`single`},t)&&(!r||Al(a,{kind:`single`},t)))&&(!n||G(a,{kind:`single`},n)&&(!r||Al(a,{kind:`single`},n))),o=(!t||G(a,{kind:`list`},t)&&(!r||Al(a,{kind:`list`},t)))&&(!n||G(a,{kind:`list`},n)&&(!r||Al(a,{kind:`list`},n)));(e||o)&&i.add(a)}return i}function Il(e,t,n,r,i,a=!1){if(n.kind===`nested`){if(!G(t,n,i)){r.compatibleListKeys.has(t)&&G(t,{kind:`list`},i)?K(e,t,{kind:`list`}):r.compatibleSingleKeys.has(t)&&G(t,{kind:`single`},i)&&K(e,t,{kind:`single`});return}let o=i.nestedElementAnalyses.get(t);if(!o&&!a){K(e,t,n);return}let s=Fl(n.keys,r.nestedElementAnalyses.get(t),o,a);s.size>0?K(e,t,{kind:`nested`,keys:s}):r.compatibleListKeys.has(t)&&G(t,{kind:`list`},i)?K(e,t,{kind:`list`}):r.compatibleSingleKeys.has(t)&&G(t,{kind:`single`},i)&&K(e,t,{kind:`single`})}else G(t,n,i)?K(e,t,n):n.kind===`list`&&r.compatibleSingleKeys.has(t)&&G(t,{kind:`single`},i)&&K(e,t,{kind:`single`})}function G(e,t,n){return n.declaredKeys.has(e)?t.kind===`single`?n.compatibleSingleKeys.has(e):t.kind===`list`?n.compatibleListKeys.has(e):n.compatibleNestedKeys.has(e):n.constrainsUnknownKeys?t.kind===`single`?n.openSingle:(t.kind,n.openList):!0}function K(e,t,n){let r=e.get(t);r?r.kind===`single`&&(n.kind===`list`||n.kind===`nested`)||r.kind===`list`&&n.kind===`nested`?e.set(t,n):r.kind===`nested`&&n.kind===`nested`&&e.set(t,{kind:`nested`,keys:/* @__PURE__ */ new Set([...r.keys,...n.keys])}):e.set(t,n)}function Ll(e,t,n,r){let i=Rl(t,n,r);if(i)return i;let a=W(t);if((e===`child`||r?.childPropertyNames?.has(e))&&q(a,new Set(n),r))return{kind:`single`};if(e===`children`&&J(a,new Set(n),r))return{kind:`list`}}function Rl(e,t,n){let r=W(e);for(let e of r.traversed)if(t.has(e))return;let i=new Set(t);for(let e of r.traversed)i.add(e);let a=r.schema?._def?.typeName;if(a===`ZodIntersection`){let e=r.schema._def;return Bl(e.left,e.right,i,n,r,!1)}let o=Sl(r.schema);if(o){let e=/* @__PURE__ */ new Map,t=Hl(o,i,n);return t&&K(e,`prop`,t),Gl(r,n)||Zl(r.schema)?K(e,`prop`,{kind:`list`}):Wl(r,n)&&K(e,`prop`,{kind:`single`}),e.get(`prop`)}if(Gl(r,n)||Cl(r.schema))return{kind:`list`};if(Wl(r,n))return{kind:`single`};if(a===`ZodArray`){let e=r.schema._def.type,t=jl(e,new Set(i),n),a=/* @__PURE__ */ new Set;for(let[e,n]of t.fields)(n.kind===`single`||n.kind===`list`)&&a.add(e);if(a.size>0)return{kind:`nested`,keys:a};let o=Rl(e,i,n);return o?.kind===`single`||o?.kind===`list`?{kind:`list`}:void 0}if(a===`ZodPipeline`){let e=r.schema._def,t=e.in,a=e.out,o=W(t);if(o.hasTransform){let e=Rl(t,new Set(i),n);if(e){if(e.kind===`nested`){let t=W(a);if(Yl(t,new Set(i))){let r=zl(o,new Set(i),n),a=zl(t,new Set(i),n),s=Fl(e.keys,r,a,!0);return s.size>0?{kind:`nested`,keys:s}:void 0}}return e}let r=Rl(a,new Set(i),n);return r&&Vl(r,o,new Set(i),n)?r:void 0}return Bl(t,a,i,n,r,!0)}}function zl(e,t,n){for(let n of e.traversed)if(t.has(n))return;let r=new Set(t);for(let t of e.traversed)r.add(t);let i=Sl(e.schema);if(i){let e=i.filter(e=>Yl(W(e),new Set(r)));if(e.length===0)return kl();let t=[];for(let i of e){let e=zl(W(i),new Set(r),n);if(!e)return;t.push(e)}return Ml(t)}switch(e.schema?._def?.typeName){case`ZodAny`:case`ZodUnknown`:return;case`ZodArray`:return jl(e.schema._def.type,new Set(r),n);case`ZodIntersection`:{let t=e.schema._def,i=zl(W(t.left),new Set(r),n),a=zl(W(t.right),new Set(r),n);return i&&a?Pl(i,a):i??a}case`ZodPipeline`:{let t=e.schema._def,i=zl(W(t.in),new Set(r),n),a=zl(W(t.out),new Set(r),n);return i&&a?Nl(i,a):i??a}default:return kl()}}function Bl(e,t,n,r,i,a=!1){let o=W(e),s=W(t),c=Rl(e,new Set(n),r),l=Rl(t,new Set(n),r),u=/* @__PURE__ */ new Map;i&&(Gl(i,r)&&J(o,new Set(n),r,!0)&&J(s,new Set(n),r,!0)?K(u,`prop`,{kind:`list`}):Wl(i,r)&&q(o,new Set(n),r,!0)&&q(s,new Set(n),r,!0)&&K(u,`prop`,{kind:`single`}));let d=(e,t,i)=>{if(e){if(Vl(e,i,new Set(n),r)){if(e.kind===`nested`){let o=zl(t,new Set(n),r),s=zl(i,new Set(n),r),c=Fl(e.keys,o,s,a);if(c.size>0){K(u,`prop`,{kind:`nested`,keys:c});return}}else{K(u,`prop`,e);return}}e.kind===`nested`&&J(t,new Set(n),r,!0)&&J(i,new Set(n),r,!0)?K(u,`prop`,{kind:`list`}):(e.kind===`list`||e.kind===`nested`)&&q(t,new Set(n),r,!0)&&q(i,new Set(n),r,!0)&&K(u,`prop`,{kind:`single`})}};return d(c,o,s),d(l,s,o),u.get(`prop`)}function Vl(e,t,n,r){return e.kind===`single`?q(t,n,r,!0):e.kind===`list`?J(t,n,r,!0):Yl(t,n)}function Hl(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of e){let e=Rl(i,new Set(t),n);e&&K(r,`prop`,e)}return r.get(`prop`)}function Ul(e,t,n){if(!e)return``;if(e.startsWith(`REF:`)){let n=hl(e.slice(4).split(`|`)[0]);return n&&t.add(n),n}let r=hl(e.split(`|`)[0]);r&&n.add(r);let i=e.trim();return i&&n.add(i),``}function Wl(e,t){if(e.refs.has(`component-id`))return!0;let n=t?.childRefNames??gl;for(let t of n)if(e.refDefNames.has(t)||e.bareDefNames.has(t))return!0;return!1}function Gl(e,t){if(e.refs.has(`child-list`))return!0;let n=t?.childListRefNames??_l;for(let t of n)if(e.refDefNames.has(t)||e.bareDefNames.has(t))return!0;return!1}function Kl(e,t){return e.refDefNames.size!==0&&!Wl(e,t)&&!Gl(e,t)}function ql(e){if(e?._def?.typeName!==`ZodObject`||Cl(e))return!1;let t=e.shape;return Object.hasOwn(t,`path`)||Object.hasOwn(t,`@path`)||Object.hasOwn(t,`call`)||Object.hasOwn(t,`@call`)}function Jl(e,t){let n=!1,r=!1,i=/* @__PURE__ */ new Set,a=e=>{for(let o of e){let e=W(o),s=!1;for(let t of e.traversed)if(i.has(t)){s=!0;break}if(s)continue;for(let t of e.traversed)i.add(t);if(Wl(e,t)||Gl(e,t)){n=!0;return}(Kl(e,t)||ql(e.schema))&&(r=!0);let c=Sl(e.schema);if(c){if(a(c),n)return}else if(e.schema?._def?.typeName===`ZodPipeline`){let r=e.schema._def,i=W(r.in);if(a([r.in]),n||!i.hasTransform&&(Xl(i,/* @__PURE__ */ new Set)||q(i,/* @__PURE__ */ new Set,t,!0)||J(i,/* @__PURE__ */ new Set,t,!0))&&(a([r.out]),n))return}}};return a(e),r&&!n}function q(e,t=/* @__PURE__ */ new Set,n,r=!1){for(let n of e.traversed)if(t.has(n))return!1;for(let n of e.traversed)t.add(n);let i=e.schema?._def?.typeName;if(i===`ZodIntersection`){let i=e.schema._def;return q(W(i.left),new Set(t),n,r)&&q(W(i.right),new Set(t),n,r)}if(Wl(e,n))return!0;if(!r&&Kl(e,n))return!1;let a=Sl(e.schema);if(a)return!r&&Jl(a,n)?!1:a.some(e=>q(W(e),new Set(t),n,r));if(Gl(e,n))return!1;switch(i){case`ZodString`:case`ZodAny`:case`ZodUnknown`:return!0;case`ZodPipeline`:{let i=e.schema._def,a=W(i.in);return a.hasTransform?q(a,new Set(t),n,r):q(a,new Set(t),n,r)&&q(W(i.out),new Set(t),n,r)}default:return!1}}function J(e,t=/* @__PURE__ */ new Set,n,r=!1){for(let n of e.traversed)if(t.has(n))return!1;for(let n of e.traversed)t.add(n);let i=e.schema?._def?.typeName;if(i===`ZodIntersection`){let i=e.schema._def;return J(W(i.left),new Set(t),n,r)&&J(W(i.right),new Set(t),n,r)}if(Gl(e,n)||Zl(e.schema))return!0;if(!r&&Kl(e,n))return!1;let a=Sl(e.schema);if(a)return!r&&Jl(a,n)?!1:a.some(e=>J(W(e),new Set(t),n,r));if(Wl(e,n))return!1;switch(i){case`ZodAny`:case`ZodUnknown`:return!0;case`ZodArray`:{let i=W(e.schema._def.type);return q(i,new Set(t),n,r)||Cl(i.schema)}case`ZodObject`:return Cl(e.schema);case`ZodPipeline`:{let i=e.schema._def,a=W(i.in);return a.hasTransform?J(a,new Set(t),n,r):J(a,new Set(t),n,r)&&J(W(i.out),new Set(t),n,r)}default:return!1}}function Yl(e,t=/* @__PURE__ */ new Set){for(let n of e.traversed)if(t.has(n))return!1;for(let n of e.traversed)t.add(n);let n=Sl(e.schema);if(n)return n.some(e=>Yl(W(e),new Set(t)));switch(e.schema?._def?.typeName){case`ZodAny`:case`ZodUnknown`:return!0;case`ZodArray`:return Xl(W(e.schema._def.type),new Set(t));case`ZodIntersection`:{let n=e.schema._def;return Yl(W(n.left),new Set(t))&&Yl(W(n.right),new Set(t))}case`ZodPipeline`:{let n=e.schema._def,r=W(n.in);return r.hasTransform?Yl(r,new Set(t)):Yl(r,new Set(t))&&Yl(W(n.out),new Set(t))}default:return!1}}function Xl(e,t){for(let n of e.traversed)if(t.has(n))return!1;for(let n of e.traversed)t.add(n);let n=Sl(e.schema);if(n)return n.some(e=>Xl(W(e),new Set(t)));switch(e.schema?._def?.typeName){case`ZodObject`:case`ZodRecord`:case`ZodAny`:case`ZodUnknown`:return!0;case`ZodIntersection`:{let n=e.schema._def;return Xl(W(n.left),new Set(t))&&Xl(W(n.right),new Set(t))}case`ZodPipeline`:{let n=e.schema._def,r=W(n.in);return r.hasTransform?Xl(r,new Set(t)):Xl(r,new Set(t))&&Xl(W(n.out),new Set(t))}default:return!1}}function Zl(e,t=/* @__PURE__ */ new Set){let n=Sl(e);if(!n)return!1;for(let e of n){let n=W(e),r=!1;for(let e of n.traversed)if(t.has(e)){r=!0;break}if(r)continue;let i=new Set(t);for(let e of n.traversed)i.add(e);if(Cl(n.schema)||Zl(n.schema,i))return!0;if(n.schema?._def?.typeName===`ZodPipeline`){let e=n.schema._def,t=W(e.in);if(!t.hasTransform&&J(t,new Set(i))&&(Cl(W(e.out).schema)||Zl(W(e.out).schema,i)))return!0}}return!1}function Ql(e,t){if(!e)return null;let n=hl(e),r=t.childListRefNames,i=t.childRefNames;return r.has(n)?{isChild:!1,isChildList:!0}:i.has(n)?{isChild:!0,isChildList:!1}:null}function $l(e,t){let n=!1;for(let r of e){if(typeof r!=`object`||!r)continue;let e=tu(r,t);if(e.isChildList)return{isChild:!1,isChildList:!0};e.isChild&&(n=!0)}return n?{isChild:!0,isChildList:!1}:null}function eu(e,t){let n=!1;for(let r of[`oneOf`,`anyOf`,`allOf`]){let i=e[r];if(!Array.isArray(i))continue;let a=$l(i,t);if(a?.isChildList)return a;a?.isChild&&(n=!0)}return n?{isChild:!0,isChildList:!1}:null}function tu(e,t){let n=Ql(typeof e.$ref==`string`?e.$ref:``,t);if(n)return n;if(e.type===`array`&&typeof e.items==`object`&&e.items!==null){let n=tu(e.items,t);if(n.isChild||n.isChildList)return{isChild:!1,isChildList:!0}}let r=eu(e,t);if(r)return r;let i=typeof e.properties==`object`&&e.properties!==null?e.properties:void 0;return e.type===`object`&&i&&(Object.hasOwn(i,`componentId`)&&(Object.hasOwn(i,`path`)||Object.hasOwn(i,`dataBinding`))||Object.hasOwn(i,`explicitList`)||Object.hasOwn(i,`template`))?{isChild:!1,isChildList:!0}:{isChild:!1,isChildList:!1}}function nu(e,t,n){let r=!1;for(let i of e){let e=lu(i,t,n);if(e.isChildList)return{isChild:!1,isChildList:!0};e.isChild&&(r=!0)}return r?{isChild:!0,isChildList:!1}:{isChild:!1,isChildList:!1}}function ru(e,t){if(!e)return!1;if(e.startsWith(`REF:`)){let n=hl(e.substring(4).split(`|`)[0]);if(t.has(n))return!0}let n=hl(e.split(`|`)[0]);if(n&&t.has(n))return!0;let r=e.trim();return!!t.has(r)}function iu(e,t){if(!e)return!1;if(e.startsWith(`REF:`)){let n=hl(e.substring(4).split(`|`)[0]);if(t.has(n))return!0}let n=hl(e.split(`|`)[0]);if(n&&t.has(n))return!0;let r=e.trim();return!!t.has(r)}function au(e,t){let n=t.childListRefNames,r=t.childRefNames;for(let t of e){if(ru(t,n))return{isChild:!1,isChildList:!0};if(iu(t,r))return{isChild:!0,isChildList:!1}}return null}function ou(e,t,n){let r=lu(e,t,n);return r.isChild||r.isChildList?{isChild:!1,isChildList:!0}:{isChild:!1,isChildList:!1}}function su(e,t,n,r,i){let a=lu(e,n,r),o=lu(t,n,r);return i?.isChildList&&Tl(e,n)&&Tl(t,n)||a.isChildList&&Tl(t,n)||o.isChildList&&Tl(e,n)?{isChild:!1,isChildList:!0}:i?.isChild&&wl(e,n)&&wl(t,n)||a.isChild&&wl(t,n)||o.isChild&&wl(e,n)||a.isChildList&&wl(e,n)&&wl(t,n)||o.isChildList&&wl(t,n)&&wl(e,n)?{isChild:!0,isChildList:!1}:{isChild:!1,isChildList:!1}}function cu(e,t){return lu(e,t,/* @__PURE__ */ new Set)}function lu(e,t,n){if(!e||typeof e!=`object`||n.has(e))return{isChild:!1,isChildList:!1};n.add(e);try{return uu(e,t,n)}finally{n.delete(e)}}function uu(e,t,n){if(!(`_def`in e)||!e._def)return tu(e,t);let r=W(e);for(let t of r.traversed)if(t!==e&&n.has(t))return{isChild:!1,isChildList:!1};let i=r.refs.has(`child-list`)?{isChild:!1,isChildList:!0}:r.refs.has(`component-id`)?{isChild:!0,isChildList:!1}:au(r.descriptions,t),a=r.schema;if(!a?._def)return i??{isChild:!1,isChildList:!1};if(a!==e&&n.has(a))return{isChild:!1,isChildList:!1};let o=new Set(n);for(let e of r.traversed)o.add(e);o.add(a);let s=a._def.typeName;if(s===`ZodIntersection`){let e=a._def;return su(e.left,e.right,t,o,i)}if(i?.isChildList)return i;let c=Sl(a);if(c){let e=nu(c,t,o);return e.isChildList?e:e.isChild||i?.isChild?{isChild:!0,isChildList:!1}:{isChild:!1,isChildList:!1}}if(i)return i;if(s===`ZodArray`)return ou(a._def.type,t,o);if(s===`ZodPipeline`){let e=a._def,n=e.in,r=e.out;if(W(n).hasTransform){let e=lu(n,t,o);if(e.isChild||e.isChildList)return e;let i=lu(r,t,o);return i.isChildList&&Tl(n,t)?{isChild:!1,isChildList:!0}:i.isChild&&wl(n,t)?{isChild:!0,isChildList:!1}:{isChild:!1,isChildList:!1}}return su(n,r,t,o)}return Cl(a)?{isChild:!1,isChildList:!0}:{isChild:!1,isChildList:!1}}function du(e,t,n){let r=e.nestedRefs[t];r?r.add(n):e.nestedRefs[t]=/* @__PURE__ */ new Set([n])}function fu(e){if(typeof e!=`object`||!e)return[];let t=[],n=e;if(n.type===`array`||Object.hasOwn(n,`items`)){let e=n.items;if(typeof e==`object`&&e){let n=e.properties;typeof n==`object`&&n&&t.push(n)}}for(let e of[`oneOf`,`anyOf`,`allOf`]){let r=n[e];if(Array.isArray(r))for(let e of r)t.push(...fu(e))}return t}function pu(e){if(e===!0)return!0;if(typeof e!=`object`||!e)return!1;let t=e;return t.type===void 0||t.type===`string`}function mu(e){if(e===!0)return!0;if(typeof e!=`object`||!e)return!1;let t=e;return t.type===void 0?!0:t.type===`array`?t.items===void 0||pu(t.items):!1}function hu(e,t,n){for(let[r,i]of Object.entries(e)){let e=fu(i),a=!1;for(let i of e)for(let[e,o]of Object.entries(i)){let i=cu(o,n),s=e===`child`||!!n.childPropertyNames?.has(e);(i.isChild||i.isChildList||s&&typeof o==`object`&&o&&o.type===`string`)&&(t.listRefs.add(r),du(t,r,e),a=!0)}if(a)continue;let o=cu(i,n);o.isChildList?t.listRefs.add(r):o.isChild||(r===`child`||n.childPropertyNames?.has(r))&&typeof i==`object`&&i&&i.type===`string`?t.singleRefs.add(r):r===`children`&&typeof i==`object`&&i&&i.type===`array`&&mu(i)&&t.listRefs.add(r)}}function gu(e,t,n){if(!e||typeof e!=`object`)return;if(e._def){let r=Ol(e,n);for(let[e,n]of r)if(n.kind===`single`)t.singleRefs.add(e);else if(n.kind===`list`)t.listRefs.add(e);else if(n.kind===`nested`){t.listRefs.add(e);for(let r of n.keys)du(t,e,r)}return}let r=e,i=typeof r.properties==`object`&&r.properties!==null?r.properties:void 0;i&&hu(i,t,n);for(let e of[`allOf`,`oneOf`,`anyOf`]){let i=r[e];if(Array.isArray(i))for(let e of i)gu(e,t,n)}let a=r.additionalProperties??r.unevaluatedProperties;!pu(a)||i&&Object.hasOwn(i,`child`)||t.singleRefs.add(`child`),!mu(a)||i&&Object.hasOwn(i,`children`)||t.listRefs.add(`children`)}function _u(e,t){let n={},r=e,i=typeof r?.components?.values==`function`?Array.from(r.components.values()):Array.isArray(e)?e:Array.from(e.values());for(let e of i){let r={singleRefs:/* @__PURE__ */ new Set,listRefs:/* @__PURE__ */ new Set,nestedRefs:{}};gu(e.schema,r,t),n[e.name]={singleRefs:r.singleRefs,listRefs:r.listRefs,nestedRefs:r.nestedRefs}}return n}var vu=/^REF:[^|#]*#\/\$defs\/DynamicBoolean(?:\||$)/;function yu(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e.valid;return typeof t==`boolean`?t:void 0}function bu(e){if(typeof e==`boolean`)return e;let t=yu(e);return t===void 0?typeof e==`string`?e.toLowerCase()===`true`:typeof e==`number`&&e!==0&&!Number.isNaN(e):t}function xu(e){let t=e._def;switch(t.typeName){case`ZodOptional`:case`ZodNullable`:case`ZodDefault`:case`ZodCatch`:case`ZodBranded`:case`ZodReadonly`:return t.innerType;case`ZodEffects`:return t.schema;case`ZodLazy`:return t.getter?.();default:return}}function Su(e){let t=e;for(;t;){if(typeof t.description==`string`&&vu.test(t.description))return!0;t=xu(t)}return!1}function Cu(e){let t=e;for(let e=xu(t);e;e=xu(t))t=e;return t}function wu(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Tu(e,t){if(Su(e))return bu(t);if(typeof t!=`object`||!t)return t;let n=Cu(e),r=n._def;if(r.typeName===`ZodArray`&&Array.isArray(t)&&r.type){let e=r.type,n=!1,i=t.map(t=>{let r=Tu(e,t);return n||=r!==t,r});return n?i:t}if(r.typeName===`ZodObject`&&wu(t)){let e=n.shape,r=!1,i={};for(let[n,a]of Object.entries(t)){let t=e[n],o=t?Tu(t,a):a;r||=o!==a,i[n]=o}return r?i:t}return t}function Y(e,t){return{name:e.name,returnType:e.returnType,schema:e.schema,allowedCallers:e.allowedCallers,requiresUserActivation:e.requiresUserActivation,description:e.description,execute:t}}var Eu=class e{get validationSchema(){return this.cachedValidationSchema||=ml(this),gs(this.cachedValidationSchema)}get catalogSchema(){return this.validationSchema}toJson(){return this.cachedDocument||=zs(this),gs(this.cachedDocument)}withEntries(e,t){return this.rebuild(e,t,{id:this.id,schemaId:this.schemaId,title:this.title,description:this.description,instructions:this.instructions})}copyWith(e={}){let t=e.components===void 0?[...this.components.values()]:[...e.components],n;if(e.functions!==void 0)n=[...e.functions];else if(e.agentFunctions!==void 0){n=[];for(let e of this.functions.values())Ii(e)?e.declaration!==void 0&&n.push(e.declaration):n.push(e)}else n=[...this.functions.values()];let r=e.catalogId??this.id,i=ku(r,n,e.agentFunctions);return this.rebuild(t,i,{id:r,protocolVersion:e.protocolVersion??this.protocolVersion,themeSchema:e.themeSchema??this.themeSchema,schemaId:this.schemaId,title:this.title,description:this.description,instructions:e.instructions??this.instructions})}derive(e){let t=(t,n,r)=>r===void 0?[...n.values()]:r.map(r=>{if(typeof r!=`string`)return r;let i=n.get(r);if(!i)throw new I(`Catalog '${this.id}' has no ${t} '${r}' to derive catalog '${e.catalogId}' from.`);return i});return this.rebuild(t(`component`,this.components,e.components),t(`function`,this.functions,e.functions),{id:e.catalogId,instructions:e.instructions})}rebuild(t,n,r){let i=t.length!==this.components.size||t.some(e=>this.components.get(e.name)!==e),a=n.length!==this.functions.size||n.some(e=>this.functions.get(e.name)!==e),o=this.defs;if(o&&(i||a)){let e={...o};i&&delete e.anyComponent,a&&delete e.anyFunction,o=e}let s=this.unions?{anyComponent:this.unions.anyComponent||i,anyFunction:this.unions.anyFunction||a}:void 0;return new e(r.id,r.protocolVersion??this.protocolVersion,t,n,{themeSchema:r.themeSchema??this.themeSchema,instructions:r.instructions,schemaUri:this.schemaUri,schemaId:r.schemaId,title:r.title,description:r.description,declaredProtocolVersion:this.declaredProtocolVersion,declaresCatalogId:this.declaresCatalogId,declaresComponents:this.declaresComponents,functionsLayout:this.functionsLayout,unions:s,defs:ws(o,[...this.components.values(),...this.functions.values()],[...t,...n],this.extensionFields),extensionFields:this.extensionFields,commonTypesUri:this.commonTypesUri,themeLocation:this.themeLocation,defModels:this.defModels})}get componentRefMap(){if(!this._componentRefMap){let e=R(this.protocolVersion,`1.0`)?Io:R(this.protocolVersion,`0.9`)?Po:Mo;this._componentRefMap=_u(this,e)}return this._componentRefMap}constructor(e,t,n,r,i,a){let o,s,c,l,u;if(typeof t==`string`?(o=t,s=n??[],c=r??[],l=i,u=a):(o=`0.9`,s=t??[],c=n??[],l=r,u=i),!o)throw new I(`protocolVersion must be provided.`);this.id=e,this.protocolVersion=o;let d=/* @__PURE__ */ new Map;for(let e of s)d.set(e.name,e);this.components=d;let f=sc(l)?{themeSchema:l}:l??{},p=vs(f.defs);c.some(Ii)&&Du(this.id,c);let m=/* @__PURE__ */ new Map,h=/* @__PURE__ */ new Map,g=/* @__PURE__ */ new Map;for(let e of c)if(Ii(e)){let t=jc(e,p);m.set(e.name,t),h.set(e.name,t)}else m.set(e.name,e),g.set(e.name,e);if(h.size>0){if(!R(this.protocolVersion,Tr.V1_0))throw new I(`Catalog '${this.id}' targets protocol version ${this.protocolVersion}, but agent functions need v1.0 or later.`);Ou(p,h.values());for(let[e,t]of h){Pn(e,`function identifier: '${e}'`);let n=/* @__PURE__ */ new Set([...cc(t.schema),...t.declaredParameterNames??[]]);for(let t of n)Pn(t,`argument identifier: '${t}' in function '${e}'`)}}this.functions=m,this.agentFunctions=h,this.rendererFunctions=g,this.themeSchema=f.themeSchema,this.instructions=f.instructions??u,this.schemaUri=f.schemaUri,this.schemaId=f.schemaId,this.title=f.title,this.description=f.description,this.declaredProtocolVersion=f.declaredProtocolVersion,this.declaresCatalogId=f.declaresCatalogId??!0,this.declaresComponents=f.declaresComponents??!0,this.functionsLayout=f.functionsLayout,this.unions=f.unions?Object.freeze({...f.unions}):void 0,this.defs=p,this.extensionFields=vs(f.extensionFields),this.commonTypesUri=f.commonTypesUri,this.themeLocation=f.themeLocation,this.defModels=f.defModels?Object.freeze([...f.defModels]):void 0,this.invoker=Au(this.id,this.protocolVersion,this.functions,this)}static fromJson(t,n,r){let{id:i,protocolVersion:a,components:o,functions:s,...c}=vc(t,n,r);return new e(i,a,o,s,c)}static fromSchema(t,n){return e.fromJson(t,n)}};function Du(e,t){let n=/* @__PURE__ */ new Set;for(let r of t){if(n.has(r.name))throw new I(`Catalog '${e}' already has a function named '${r.name}'.`);n.add(r.name)}}function Ou(e,t){let n=/* @__PURE__ */ new Map;for(let[t,r]of Object.entries(e??{}))n.set(t,{definition:r});for(let e of t){let t=e.jsonSchema?.$defs;if(typeof t==`object`&&t&&!Array.isArray(t))for(let[r,i]of Object.entries(t)){let t=n.get(r);if(t===void 0)n.set(r,{definition:i,owner:e.name});else if(!Ni(t.definition,i)){let n=t.owner===void 0?`the catalog`:`agent function '${t.owner}'`;throw new I(`Agent function '${e.name}' defines $defs '${r}' differently from ${n}.`)}}}}function ku(e,t,n){if(n===void 0)return[...t];let r=[...t],i=/* @__PURE__ */ new Map;for(let e=0;e<r.length;e++)i.set(r[e].name,e);let a=/* @__PURE__ */ new Set;for(let t of n){if(!Ii(t))throw new I(`Catalog '${e}' agentFunctions entry '${String(t?.name??t)}' is not an \`AgentFunction\`.`);if(a.has(t.name))throw new I(`agentFunctions lists '${t.name}' more than once; give each agent function its own name.`);a.add(t.name);let n=i.get(t.name);if(t.declaration!==void 0){if(n===void 0)throw new I(`Catalog '${e}' has no function named '${t.name}' for AgentFunction.fromApi to bind; build an agent function the catalog doesn't declare with new AgentFunction(...).`);if(r[n]!==t.declaration)throw new I(`Agent function '${t.name}' was built with AgentFunction.fromApi from a different declaration than the one in catalog '${e}' (for example, from a reloaded or copied catalog); build it from this catalog's entry: AgentFunction.fromApi(catalog.functions.get('${t.name}')!, handler).`);r[n]=t}else if(n===void 0)i.set(t.name,r.length),r.push(t);else throw new I(`Catalog '${e}' already has a function named '${t.name}', so an agent function can't use that name: a renderer that implements the other function would run it instead of calling the agent. Give the agent function its own name, or bind a handler to the declared function with AgentFunction.fromApi(catalog.functions.get('${t.name}')!, handler).`)}return r}function Au(e,t,n,r){let i=R(t,Tr.V1_0);return(t,a,o,s)=>{let c=n.get(t)??(i&&t===`@index`?Zr:void 0),l=c?.execute;if(typeof l!=`function`){let n=i&&!t.startsWith(`@`)&&o&&ri(o)?o.surface:void 0;if(n?.agentFunctionCaller)return Mu(n,e,t,c,a,o,s)}if(!c)throw new F(`Function not found in catalog '${e}': ${t}`,t);if(Nu(c),Pu(c,o),typeof l!=`function`)throw new F(`Function '${t}' in catalog '${e}' is schema-only and has no implementation.`,t);let u=i&&!t.startsWith(`@`)&&e&&o instanceof wi?si(o,e,r):o;return ju(a,s,e=>{try{let t=Tu(c.schema,e),n=c.schema.parse(t);return l.call(c,n,u,s)}catch(e){throw e?.name===`ZodError`||e instanceof _?new F(`Validation failed for function '${t}': ${e.message}`,t,e.errors??e.issues):e}})}}function ju(e,t,n){let r=wr(e);return Sr(r)?Promise.resolve(r).then(e=>yr(e)??(t?.aborted?void 0:n(e))):yr(r)??n(r)}function Mu(e,t,n,r,i,a,o){r&&(Nu(r),Pu(r,a));let s=!!a.isActionExecution;return ju(i,o,i=>{let a=i??{};if(r){a=Tu(r.schema,a);let e=r.schema.safeParse(a);if(!e.success)throw new F(`Validation failed for function '${n}': ${e.error.message}`,n,e.error.errors);a=e.data}return e.callAgentFunction({"@call":n,catalogId:t,args:a},{abortSignal:o,bypassCache:s})})}function Nu(e){if(e.allowedCallers===`agentOnly`)throw new F(`Function '${e.name}' cannot be called by renderer (allowedCallers is agentOnly).`,e.name)}function Pu(e,t){if(!e.requiresUserActivation)return;let n=!!t?.isPassiveEvaluation,r=!t?.isUserActivated&&typeof navigator<`u`&&!(navigator.userActivation?.isActive??!0);if(n||r)throw new F(`Function '${e.name}' requires user activation and cannot be evaluated without an active user gesture.`,e.name)}var Fu=class{constructor(){this.listeners=/* @__PURE__ */ new Set}subscribe(e){return this.listeners.add(e),{unsubscribe:()=>this.listeners.delete(e)}}async emit(e){for(let t of this.listeners)try{let n=t(e);n&&typeof n.then==`function`&&await n}catch(e){console.error(`EventEmitter error:`,e)}}dispose(){this.listeners.clear()}},Iu=/^(?:(?:\/(?:[^~/]|~[01])*)*|(?:[^~/]|~[01])+(?:\/(?:[^~/]|~[01])*)*)$/;function*Lu(e,t,n,r=!1){if(typeof e==`string`)yield[e,t];else if(Array.isArray(e))for(let r=0;r<e.length;r++){let i=e[r];yield*Lu(i,`${t}[${r}]`,n,!0)}else if(typeof e==`object`&&e){let i=e,a=Object.hasOwn(i,`componentId`)&&typeof i.componentId==`string`&&(Object.hasOwn(i,`path`)||Object.hasOwn(i,`dataBinding`)),o=!r&&(Array.isArray(i.explicitList)||typeof i.template==`object`&&i.template!==null);if(n?.size&&(r||!a&&!o||Array.from(n).some(e=>Object.hasOwn(i,e))))for(let e of n)Object.hasOwn(i,e)&&(yield*Lu(i[e],`${t}.${e}`));else if(a)yield[i.componentId,`${t}.componentId`];else if(Object.hasOwn(i,`path`)||Object.hasOwn(i,`@path`)||Object.hasOwn(i,`call`)||Object.hasOwn(i,`@call`))return;else for(let[e,n]of Object.entries(i))yield*Lu(n,`${t}.${e}`)}}function Ru(e){return e.componentRefMap}function*zu(e,t){if(!e||typeof e!=`object`)return;let n=t instanceof Eu?Ru(t):t,r=e.component,i=``,a=e;if(typeof r==`string`)i=r;else if(typeof r==`object`&&r){let e=r;i=Object.keys(e)[0]??``,a=e[i]??{}}if(!i||typeof a!=`object`||!a)return;let o=n[i],s=o?o.singleRefs:/* @__PURE__ */ new Set,c=o?o.listRefs:/* @__PURE__ */ new Set,l=o?.nestedRefs;for(let[e,t]of Object.entries(a))(s.has(e)||c.has(e))&&(yield*Lu(t,e,l?.[e]))}Object.freeze({allowOrphanComponents:!1,allowDanglingReferences:!1,allowMissingRoot:!1,allowUnknownElements:!1}),Object.freeze({allowOrphanComponents:!0,allowDanglingReferences:!0,allowMissingRoot:!0,allowUnknownElements:!0});function Bu(e,t,n){if(t>50)throw new Cn(`Global recursion limit exceeded: Depth > 50`);if(Array.isArray(e))for(let r of e)Bu(r,t+1,n);else if(typeof e==`object`&&e){let r=e;for(let e of[r.path,r[`@path`]])if(typeof e==`string`&&!Iu.test(e))throw new P(`Invalid path syntax: '${e}'`);let i=Object.hasOwn(r,`functionCall`)&&typeof r.functionCall==`object`&&r.functionCall!==null,a=(Object.hasOwn(r,`call`)||Object.hasOwn(r,`@call`))&&Object.hasOwn(r,`args`);if(i){if(n>=5)throw new Cn(`Recursion limit exceeded: functionCall depth > 5`);for(let[e,i]of Object.entries(r))e===`functionCall`?Bu(i,t+1,n+1):Bu(i,t+1,n)}else if(a){if(n>=5)throw new Cn(`Recursion limit exceeded: functionCall depth > 5`);for(let[e,i]of Object.entries(r))e===`args`?Bu(i,t+1,n+1):Bu(i,t+1,n)}else for(let e of Object.values(r))Bu(e,t+1,n)}}function Vu(e){Bu(e,0,0)}var Hu=class{constructor(e){this.components=/* @__PURE__ */ new Map,this._onCreated=new Fu,this._onDeleted=new Fu,this.onCreated=this._onCreated,this.onDeleted=this._onDeleted,e&&this.setCatalog(e)}setCatalog(e){this.refMap=e instanceof Eu?e.componentRefMap:e}get(e){return this.components.get(e)}getAll(){return new Map(this.components)}has(e){return this.components.has(e)}get entries(){return this.components.entries()}get keys(){return this.components.keys()}get values(){return this.components.values()}get size(){return this.components.size}get componentsMap(){return this.components}addComponent(e){if(this.components.has(e.id))throw new xn(`Component with id '${e.id}' already exists.`);this.components.set(e.id,e),this._onCreated.emit(e)}insertComponent(e,t){if(this.components.has(t.id))throw new xn(`Component with id '${t.id}' already exists.`);if(e<this.components.size){let n=[...this.components].slice(Math.max(0,e));for(let[e]of n)this.components.delete(e);this.components.set(t.id,t);for(let[e,t]of n)this.components.set(e,t)}else this.components.set(t.id,t);this._onCreated.emit(t)}removeComponent(e){let t=this.components.get(e);t&&(this.components.delete(e),t.dispose(),this._onDeleted.emit(e))}getChildReferences(e){let t=this.components.get(e);if(!t)return[];let n=t.catalog.components.size?t.catalog.componentRefMap:this.refMap??t.catalog.componentRefMap;return Array.from(zu(t.componentTree,n))}getChildIds(e){return this.getChildReferences(e).map(([e])=>e)}detectCycles(e={}){let t=e.rootId??`root`,n=e.maxDepth??50,r=e.allowMissingRoot??!1;for(let e of this.components.values())for(let[t,n]of this.getChildReferences(e.id))if(t===e.id)throw new Cn(`Circular reference detected: Component '${e.id}' references itself in field '${n}' (Self-reference detected)`);let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=(e,t)=>{if(t>n)throw new Cn(`Global recursion limit exceeded: logical depth > ${n}`);i.add(e),a.add(e);let r=this.getChildIds(e);for(let e of r)if(this.components.has(e)){if(!i.has(e))o(e,t+1);else if(a.has(e))throw new Cn(`Circular reference detected involving component '${e}'`)}a.delete(e)};if(r){let e=Array.from(this.components.keys()).sort();for(let t of e)i.has(t)||o(t,0)}else this.components.has(t)&&o(t,0);return i}validateTopology(e={}){if(this.components.size===0)return;let t=e.rootId??`root`,n=e.allowMissingRoot??!1,r=e.allowDanglingReferences??!1,i=e.allowOrphanComponents??!1;if(!n&&!this.components.has(t))throw new Sn(`Missing root component: No component has id='${t}'`);if(!r){for(let e of this.components.values())for(let[t,n]of this.getChildReferences(e.id))if(!this.components.has(t))throw new Sn(`Component '${e.id}' references non-existent component '${t}' in field '${n}' (Dangling reference '${t}' in component '${e.id}')`)}let a=this.detectCycles({rootId:t,allowMissingRoot:n,maxDepth:e.maxDepth});if(!i&&!n&&a.size<this.components.size){let e=Array.from(this.components.keys()).filter(e=>!a.has(e)).sort();if(e.length>0)throw new Sn(`Component '${e[0]}' is not reachable from '${t}' (Orphaned component '${e[0]}' is not reachable from root)`)}}validateReferences(e={}){let t=[];try{this.validateTopology(e)}catch(e){e instanceof P?t.push(e):e instanceof Error&&t.push(new P(e.message))}return t}dispose(){let e=Array.from(this.components.keys());for(let e of this.components.values())e.dispose();this.components.clear();for(let t of e)this._onDeleted.emit(t);this._onCreated.dispose(),this._onDeleted.dispose()}};function Uu(e){if(!e)return;let t=mr(e);return t?R(t,`1.0`)?t:`v${t}`:e}var Wu=class{get agentFunctionCaller(){return this._agentFunctionCaller}set agentFunctionCaller(e){e!==this._agentFunctionCaller&&(this._agentFunctionCaller=e,this.inFlightAgentCalls.clear(),this.settledAgentCalls.clear())}get maxAgentCallCacheEntries(){return this._maxAgentCallCacheEntries}set maxAgentCallCacheEntries(e){for(Ku(e),this._maxAgentCallCacheEntries=e;this.settledAgentCalls.size>e;)this.evictOldestAgentCall()}evictOldestAgentCall(){let e=this.settledAgentCalls.keys().next().value;e!==void 0&&this.settledAgentCalls.delete(e)}get disposed(){return this.isDisposed}constructor(e,t,n=/* @__PURE__ */ new Map,r={},i=!1,a,o=`root`,s,c,l){this.id=e,this.defaultCatalog=t,this.rootId=o,this._onAction=new Fu,this._onError=new Fu,this._onWarning=new Fu,this._onMetadataChanged=new Fu,this.onAction=this._onAction,this.onError=this._onError,this.onWarning=this._onWarning,this.onMetadataChanged=this._onMetadataChanged,this.inFlightAgentCalls=/* @__PURE__ */ new Map,this.settledAgentCalls=/* @__PURE__ */ new Map,this._maxAgentCallCacheEntries=Gu,this.isDisposed=!1,l!==void 0&&(Ku(l),this._maxAgentCallCacheEntries=l),this._metadataSignal=dn(Ai(s)),this.metadataSignal=fn(()=>gn(this._metadataSignal)),this.protocolVersion=Uu(c??t?.protocolVersion);let u,d={},f=!1;if(n!=null&&!(n instanceof Map)){if(typeof n==`object`&&!Array.isArray(n))d=n,f=r===!0,a=i instanceof kn?i:void 0,u=void 0;else throw TypeError(`availableCatalogs must be a Map, or undefined/null. Note that availableCatalogs is now the 3rd argument to SurfaceModel and theme is the 4th argument.`)}else u=n,d=r??{},f=!!i;this.theme=d,this.sendDataModel=f;let p=new Map(u??[]);t?.id&&!p.has(t.id)&&p.set(t.id,t),this.availableCatalogs=p,this.dataModel=a??new kn({}),this.componentsModel=new Hu(t)}get catalog(){return this.defaultCatalog}resolveCatalog(e,t=`Item`){return Er(this,e,t)}callAgentFunction(e,t){let n=t?.abortSignal;if(this.isDisposed)return Promise.reject(new wn(`Surface '${this.id}' has been disposed.`,L.CANCELLED));let r=this.agentFunctionCaller;if(!r)return Promise.reject(new F(`Function '${e[`@call`]}' is not implemented locally and surface '${this.id}' cannot call the agent.`,e[`@call`]));if(n?.aborted)return Promise.resolve(void 0);let i;try{i=or(e.args??{})}catch(t){return Promise.reject(new F(`Arguments of function '${e[`@call`]}' are not valid JSON: ${t.message}.`,e[`@call`]))}e={...e,args:i};let a=t?.bypassCache?void 0:sr([e.catalogId,e[`@call`],i]);if(a!==void 0){let e=this.settledAgentCalls.get(a);if(e!==void 0)return Promise.resolve(qu(e.value));let t=this.inFlightAgentCalls.get(a);if(t)return n?t.signals.add(n):t.hasUnabortedCaller=!0,t.promise.then(qu)}let o={promise:void 0,signals:new Set(n?[n]:[]),hasUnabortedCaller:!n},s=()=>{a!==void 0&&this.inFlightAgentCalls.get(a)===o&&this.inFlightAgentCalls.delete(a)},c=Promise.resolve().then(()=>{if(this.isDisposed||this._agentFunctionCaller!==r)throw s(),new wn(`Pending calls for surface '${this.id}' were cancelled.`,L.CANCELLED);if(!o.hasUnabortedCaller&&Array.from(o.signals).every(e=>e.aborted))s();else return r(e).then(e=>{if(s(),a!==void 0&&!this.isDisposed&&this._agentFunctionCaller===r){for(this.settledAgentCalls.delete(a);this.settledAgentCalls.size>=this._maxAgentCallCacheEntries;)this.evictOldestAgentCall();this.settledAgentCalls.set(a,{value:qu(e)})}return e},e=>{throw s(),e})});return o.promise=c,a!==void 0&&(this.inFlightAgentCalls.set(a,o),c.then(s,s)),c}get metadata(){return vn(this._metadataSignal)}set metadata(e){let t=Ai(e);Pi(vn(this._metadataSignal),t)||(_n(this._metadataSignal,t),this._onMetadataChanged.emit(t))}get extensions(){return vn(this._metadataSignal)?.extensions}setExtension(e,t){if(t===void 0){this.removeExtension(e);return}let n=vn(this._metadataSignal),r={...n?.extensions??{},[e]:t};this.metadata={...n??{},extensions:r}}removeExtension(e){let t=vn(this._metadataSignal),n=t?.extensions;if(!n||!(e in n))return;let r={...n};delete r[e];let i={...t};delete i.extensions,this.metadata=Object.keys(r).length>0?{...i,extensions:r}:Object.keys(i).length>0?i:void 0}async dispatchAction(e,t,n){try{Sr(e)&&(e=await e)}catch(e){await this.reportUnresolvedAction(e);return}if(!e||typeof e!=`object`)return;let r=Yu(e);if(!r)return;let i=r.name;if(!i||typeof i!=`string`)return;let a={},o;try{let e=wr(r.context),t=Sr(e)?await e:e;if(yr(t))return;if(t&&typeof t==`object`&&!Array.isArray(t)&&(a=t),r.userMessage!==void 0){let e=wr(r.userMessage);if(o=Sr(e)?await e:e,yr(o))return}}catch(e){await this.reportUnresolvedAction(e);return}let s={name:i,surfaceId:this.id,sourceComponentId:t,timestamp:(/* @__PURE__ */ new Date()).toISOString(),context:a},c=r.catalogId??e.catalogId;typeof c==`string`&&c&&(s.catalogId=c),typeof o==`string`&&o.length>0&&(s.userMessage=o);let l=ki(r.metadata??e.metadata,n);l!==void 0&&(s.metadata=l),await this._onAction.emit(s)}async reportUnresolvedAction(e){Ju(e)||await this.dispatchError({code:`INVALID_ACTION`,surfaceId:this.id,message:`Action could not be resolved: ${e?.message??String(e)}`})}async dispatchError(e){await this._onError.emit({...e,...e.functionCallId===void 0?{surfaceId:this.id}:{}})}async dispatchWarning(e){await this._onWarning.emit({...e,surfaceId:this.id})}dispose(){this.isDisposed=!0,this._agentFunctionCaller=void 0,this.inFlightAgentCalls.clear(),this.settledAgentCalls.clear(),this.dataModel.dispose(),this.componentsModel.dispose(),this._onAction.dispose(),this._onError.dispose(),this._onWarning.dispose(),this._onMetadataChanged.dispose()}},Gu=256;function Ku(e){if(typeof e!=`number`||!Number.isInteger(e)||e<1)throw RangeError(`maxAgentCallCacheEntries must be a positive integer.`)}function qu(e){if(typeof e!=`object`||!e)return e;try{return structuredClone(e)}catch{return e}}function Ju(e){return e instanceof wn&&e.code===L.CANCELLED}function Yu(e){return`event`in e&&e.event&&typeof e.event==`object`?e.event:`name`in e&&typeof e.name==`string`?e:null}var Xu=class{constructor(){this.surfaces=/* @__PURE__ */ new Map,this.surfaceUnsubscribers=/* @__PURE__ */ new Map,this.surfaceErrorUnsubscribers=/* @__PURE__ */ new Map,this._onSurfaceCreated=new Fu,this._onSurfaceDeleted=new Fu,this._onAction=new Fu,this._onError=new Fu,this.onSurfaceCreated=this._onSurfaceCreated,this.onSurfaceDeleted=this._onSurfaceDeleted,this.onAction=this._onAction,this.onError=this._onError}emitError(e){this._onError.emit(e)}addSurface(e){if(this.surfaces.has(e.id)){console.warn(`Surface ${e.id} already exists. Ignoring.`);return}this.surfaces.set(e.id,e);let t=e.onAction.subscribe(e=>this._onAction.emit(e));this.surfaceUnsubscribers.set(e.id,t);let n=e.onError.subscribe(e=>{this._onError.emit(e)});this.surfaceErrorUnsubscribers.set(e.id,n),this._onSurfaceCreated.emit(e)}deleteSurface(e){let t=this.surfaces.get(e);if(t){let n=this.surfaceUnsubscribers.get(e);n&&(n.unsubscribe(),this.surfaceUnsubscribers.delete(e));let r=this.surfaceErrorUnsubscribers.get(e);r&&(r.unsubscribe(),this.surfaceErrorUnsubscribers.delete(e)),this.surfaces.delete(e),t.dispose(),this._onSurfaceDeleted.emit(e)}}getSurface(e){return this.surfaces.get(e)}get surfacesMap(){return this.surfaces}dispose(){for(let e of Array.from(this.surfaces.keys()))this.deleteSurface(e);this._onSurfaceCreated.dispose(),this._onSurfaceDeleted.dispose(),this._onAction.dispose(),this._onError.dispose()}},Zu=class{constructor(e,t,n,r,i){this.id=e,this.type=t,this._onUpdated=new Fu,this._onMetadataChanged=new Fu,this.onUpdated=this._onUpdated,this.onMetadataChanged=this._onMetadataChanged,this._properties=n,this.catalog=r,this._metadataSignal=dn(Ai(i))}get metadataSignal(){return this._metadataSignal}get metadata(){return vn(this._metadataSignal)}set metadata(e){let t=Ai(e);Pi(vn(this._metadataSignal),t)||(_n(this._metadataSignal,t),this._onMetadataChanged.emit(t))}get extensions(){return vn(this._metadataSignal)?.extensions}setExtension(e,t){if(t===void 0){this.removeExtension(e);return}let n=vn(this._metadataSignal),r={...n?.extensions??{},[e]:t};this.metadata={...n??{},extensions:r}}removeExtension(e){let t=vn(this._metadataSignal),n=t?.extensions;if(!n||!(e in n))return;let r={...n};delete r[e];let i={...t};delete i.extensions,this.metadata=Object.keys(r).length>0?{...i,extensions:r}:Object.keys(i).length>0?i:void 0}get properties(){return this._properties}set properties(e){this._properties=e,this._onUpdated.emit(this)}applyUpdate(e,t){let n=Ai(t),r=!Ni(this._properties,e),i=!Pi(vn(this._metadataSignal),n);r&&(this._properties=e),i&&_n(this._metadataSignal,n),r&&this._onUpdated.emit(this),i&&this._onMetadataChanged.emit(n)}dispose(){this._onUpdated.dispose(),this._onMetadataChanged.dispose()}get componentTree(){let e=this.metadata;return{...this._properties,id:this.id,component:this.type,...e===void 0?{}:{"@metadata":e}}}},Qu=[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`,`callRendererFunction`,`agentFunctionResponse`,`beginRendering`,`surfaceUpdate`,`dataModelUpdate`];function $u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ed(e,t){if(!$u(e))return{version:t};let n=typeof e.version==`string`?e.version:t,r=Qu.find(t=>Object.hasOwn(e,t));if(!r)return{version:n};let i=r===`callRendererFunction`,a=e[r];return $u(a)?{surfaceId:typeof a.surfaceId==`string`?a.surfaceId:void 0,functionCallId:typeof a.functionCallId==`string`?a.functionCallId:void 0,actionType:r,isCallRendererFunction:i,version:n}:{actionType:r,isCallRendererFunction:i,version:n}}function td(e){return e.length>0&&Qu.includes(e[0])?e.slice(1):e}function nd(e){if(!e)return;if(e.startsWith(`/`))return e;let t=e.replace(/\[(\d+)\]/g,`/$1`).replace(/\./g,`/`).replace(/^\/+/,``);if(!t)return`/`;let n=td(t.split(`/`).filter(Boolean));return n.length>0?`/${n.join(`/`)}`:void 0}function rd(e,t){let n=[];for(let r of e)if(r.code===g.invalid_union&&`unionErrors`in r){let e=r.unionErrors.flatMap(e=>e.issues);n.push(...rd(e,t))}else n.push(r);if(!t)return n;let r=n.filter(e=>e.path[0]===t&&e.path.length>1);return r.length>0?r:n}function id(e,t){let n;if(e instanceof _)n=e.issues;else if(Array.isArray(e)&&e.length>0){let t=e[0];if(typeof t?.path==`string`)return nd(t.path);Array.isArray(t?.path)&&(n=e)}if(!n||n.length===0)return;let r=rd(n,t)[0];if(!r)return;let i=r.path.map(e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`));r.code===g.unrecognized_keys&&`keys`in r&&Array.isArray(r.keys)&&r.keys.length>0&&i.push(String(r.keys[0]).replace(/~/g,`~0`).replace(/\//g,`~1`));let a=td(i);return a.length>0?`/${a.join(`/`)}`:void 0}function ad(e){return e===`v0.8`||e===`0.8`?`v0.8`:e===`v0.9.1`||e===`0.9.1`?`v0.9.1`:e&&R(e,`1.0`)?`1.0`:`v0.9`}function od(e,t){return e instanceof Cn?`RECURSION_LIMIT_EXCEEDED`:e instanceof Sn||e instanceof xn?`INTEGRITY_ERROR`:e instanceof I?`CATALOG_NOT_FOUND`:e instanceof bn?`DATA_ERROR`:e instanceof F?`EXPRESSION_ERROR`:e instanceof P?(e.code===`UNALLOWED_PARENT`||e.code===`UNALLOWED_CHILD`)&&t?e.code:`VALIDATION_FAILED`:e instanceof yn&&e.code||`INTERNAL_ERROR`}function sd(e,t={}){let n=ad(t.version),r=n===`1.0`,i=e instanceof yn?e:void 0,a=e instanceof Error?e.message:String(e),o=i?.functionCallId??t.functionCallId;if(e instanceof wn||r&&(t.isCallRendererFunction||t.actionType===`callRendererFunction`||o!==void 0)){let r=e instanceof wn?e.code:`INVALID_FUNCTION_CALL`;return o===void 0?{version:n,error:{code:r,surfaceId:i?.surfaceId??t.surfaceId??``,message:a}}:{version:n,error:{code:r,functionCallId:o,message:a}}}let s=od(e,r),c=i?.surfaceId??t.surfaceId??``,l=nd(i?.path??(e instanceof P?id(e.details,t.actionType):void 0));return l===void 0&&(s===`VALIDATION_FAILED`||s===`UNALLOWED_PARENT`||s===`UNALLOWED_CHILD`)&&(l=`/`),{version:n,error:{code:s,surfaceId:c,...l===void 0?{}:{path:l},message:a}}}var cd=class e{constructor(){this.children=/* @__PURE__ */ new Map,this.parents=/* @__PURE__ */ new Map,this.heights=/* @__PURE__ */ new Map,this.maxHeight=0}static of(t){let n=new e;for(let[e,r]of t)n.setChildren(e,r);let r=/* @__PURE__ */ new Set;for(let e of t.keys()){if(n.heights.has(e))continue;let i=[{id:e,childIndex:0,height:0}];for(r.add(e);i.length>0;){let e=i[i.length-1],a=n.children.get(e.id)??[],o=!0;for(;e.childIndex<a.length;){let s=a[e.childIndex];if(e.childIndex++,!t.has(s))continue;let c=n.heights.get(s);if(c===void 0){if(r.has(s))return;e.childIndex--,i.push({id:s,childIndex:0,height:0}),r.add(s),o=!1;break}c>=e.height&&(e.height=c+1)}o&&(n.heights.set(e.id,e.height),e.height>n.maxHeight&&(n.maxHeight=e.height),r.delete(e.id),i.pop())}}return n}childrenOf(e){return this.children.get(e)??[]}parentsOf(e){return this.parents.get(e)??/* @__PURE__ */ new Set}setChildren(e,t){for(let t of this.children.get(e)??[])this.parents.get(t)?.delete(e);for(let n of t){let t=this.parents.get(n);t||(t=/* @__PURE__ */ new Set,this.parents.set(n,t)),t.add(e)}this.children.set(e,t)}admits(e,t,n){for(let[t,n]of e)this.setChildren(t,n);if(this.maxHeight>t)return!1;for(let[t,n]of e)if(n.includes(t))return!1;let r=t=>e.has(t)||n(t),i=[];for(let[t,n]of e){let e=0;for(let t of n){let n=this.heights.get(t)??0;r(t)&&n>=e&&(e=n+1)}this.heights.set(t,e),i.push(t)}for(let e=0;e<i.length;e++){let n=i[e],r=this.heights.get(n)??0;if(r>t)return!1;r>this.maxHeight&&(this.maxHeight=r);for(let e of this.parents.get(n)??[])(this.heights.get(e)??0)<=r&&(this.heights.set(e,r+1),i.push(e))}return!0}},ld=class e{constructor(){this.count=0,this.seenCatalogs=/* @__PURE__ */ new Set}static of(t){let n=ud.get(t);return n||(n=new e,n.watch(t),ud.set(t,n)),n}get changes(){return this.count}get catalogs(){return this.seenCatalogs}watch(e){let t=/* @__PURE__ */ new Map,n=()=>{this.count++},r=e=>{this.seenCatalogs.add(e.catalog),t.get(e.id)?.unsubscribe(),t.set(e.id,e.onUpdated.subscribe(n))};for(let t of e.values)r(t);e.onCreated.subscribe(e=>{this.count++,r(e)}),e.onDeleted.subscribe(e=>{this.count++,t.get(e)?.unsubscribe(),t.delete(e)})}},ud=/* @__PURE__ */ new WeakMap,dd=/* @__PURE__ */ new WeakMap;function fd(e,t,n,r,i){let a=e.componentsModel,o=i.get(a);if(i.delete(a),!n||!md(n)){Sd(e,t,r,n),Cd(e,t,r,n);return}let s=hd(e,t,r),c=n.rootId??e.rootId;if(s&&o&&o.changes===ld.of(a).changes&&(n.allowMissingRoot||s.children.has(c)||a.has(c))){let{bound:i}=o,c=/* @__PURE__ */ new Map;for(let e of s.children.keys())c.set(e,i.childrenOf(e));let l=i.admits(s.children,n.maxDepth??50,e=>a.has(e));if(gd(e,s,c,i,n)||Sd(e,t,r,n),l)return i;let u=Cd(e,t,r,n,!0);return u?cd.of(u):void 0}Sd(e,t,r,n);let l=Cd(e,t,r,n,!0);return l?cd.of(l):void 0}function pd(e,t,n){n.set(e,{bound:t,changes:ld.of(e).changes})}function md(e){return e!==void 0&&e.allowDanglingReferences===!0&&(e.allowOrphanComponents===!0||e.allowMissingRoot===!0)}function hd(e,t,n){let r={children:/* @__PURE__ */ new Map,types:/* @__PURE__ */ new Map,catalogs:/* @__PURE__ */ new Map};for(let i of t){let{id:t,component:a}=i;if(typeof t!=`string`||!t)continue;let o=n(i,e),s=(typeof a==`string`?a:e.componentsModel.get(t)?.type)||``;if(!s||o.components.size===0)return;let{properties:c}=Da(i,e.protocolVersion,o.components.get(s)?.schema,{defaultCatalogSchema:e.defaultCatalog?.components.get(s)?.schema}),l=Array.from(zu({...c,id:t,component:s},o.componentRefMap),([e])=>e);r.children.set(t,l),r.types.set(t,s),r.catalogs.set(t,o)}return r}function gd(e,t,n,r,i){if(!_d(e,t.catalogs.values(),i))return!0;let a=vd(e,i),o=e.componentsModel,s={get:e=>t.types.get(e)??o.get(e)?.type},c=/* @__PURE__ */ new Set,l=/* @__PURE__ */ new Map;for(let[e,i]of t.children){for(let e of i)t.children.has(e)||c.add(e);for(let r of n.get(e)??[])t.children.has(r)||c.add(r);for(let n of r.parentsOf(e)){if(t.children.has(n))continue;let r=l.get(n);r?r.push(e):l.set(n,[e])}}let u=e=>{let n=s.get(e);if(!n)return;let r=(t.catalogs.get(e)??o.get(e)?.catalog)?.components.get(n);return r?{componentType:n,componentApi:r}:void 0},d=e=>{let t=u(e);if(!t)return;let{componentType:n,componentApi:i}=t;if(i.allowedParents&&i.allowedParents.length>0){let t=Array.from(r.parentsOf(e),e=>({parentId:e,parentType:s.get(e)||`Unknown`}));yd(e,n,i.allowedParents,t,a)}},f=(e,t)=>{let n=u(e);if(!n)return;let{componentType:r,componentApi:i}=n;i.allowedChildren&&i.allowedChildren.length>0&&bd(e,r,i.allowedChildren,t,s)};try{for(let e of t.children.keys())d(e),f(e,r.childrenOf(e));for(let e of c)d(e);for(let[e,t]of l)f(e,t)}catch{return!1}return!0}function _d(e,t,n){let r=e=>{let t=dd.get(e);return t===void 0&&(t=Array.from(e.components.values()).some(e=>e.allowedParents!==void 0&&e.allowedParents.length>0||e.allowedChildren!==void 0&&e.allowedChildren.length>0),dd.set(e,t)),t};for(let e of t)if(r(e))return!0;if(md(n)){for(let t of ld.of(e.componentsModel).catalogs)if(r(t))return!0;return!1}let i=new Set(e.availableCatalogs.values());e.defaultCatalog&&i.add(e.defaultCatalog);for(let e of i)if(r(e))return!0;for(let t of e.componentsModel.values)if(!i.has(t.catalog)&&r(t.catalog))return!0;return!1}function vd(e,t){return t?.rootId??e.rootId??`root`}function yd(e,t,n,r,i,a,o,s){if(e===i&&!n.includes(`Surface`)){let r=o===void 0?`/components`:`/components/${o}`,i=`Component '${e}' (${t}) cannot be placed under parent 'Surface' (Surface). Allowed parents: ${JSON.stringify(n)}.`;throw new P(i,[{path:r,code:`UNALLOWED_PARENT`,message:i,...a===void 0?{}:{surfaceId:a}}],`UNALLOWED_PARENT`,{path:r,surfaceId:a})}for(let i of r??[])if(!n.includes(i.parentType)){let r=o??s?.get(i.parentId),c=r===void 0?`/components`:`/components/${r}`,l=`Component '${e}' (${t}) cannot be placed under parent '${i.parentId}' (${i.parentType||`unknown`}). Allowed parents: ${JSON.stringify(n)}.`;throw new P(l,[{path:c,code:`UNALLOWED_PARENT`,message:l,...a===void 0?{}:{surfaceId:a}}],`UNALLOWED_PARENT`,{path:c,surfaceId:a})}}function bd(e,t,n,r,i,a,o,s,c){for(let l of r){let r=i.get(l);if(r&&!n.includes(r)){let i;if(o!==void 0){let e=(s?.get(l)??`children`).replace(/\[(\d+)\]/g,`/$1`).replace(/\./g,`/`).replace(/^\/+/,``);i=`/components/${o}${e?`/${e}`:``}`}else{let e=c?.get(l);i=e===void 0?`/components`:`/components/${e}`}let u=`Container '${e}' (${t}) cannot contain child '${l}' (${r}). Allowed children: ${JSON.stringify(n)}.`;throw new P(u,[{path:i,code:`UNALLOWED_CHILD`,message:u,...a===void 0?{}:{surfaceId:a}}],`UNALLOWED_CHILD`,{path:i,surfaceId:a})}}}function xd(e,t,n){let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let[t,n]of e.componentsModel.entries){r.set(t,n.type),i.set(t,n.catalog);let s=e.componentsModel.getChildReferences(t);s.length>0&&(a.set(t,s.map(([e])=>e)),o.set(t,new Map(s)))}for(let c=0;c<t.length;c++){let l=t[c],{id:u,component:d,...f}=l;if(typeof u!=`string`)continue;s.set(u,c);let p=n(l,e);i.set(u,p);let m=e.componentsModel.get(u),h=(typeof d==`string`?d:m?.type)??``;h&&r.set(u,h);let g={id:u,component:h,...f},_=Array.from(zu(g,p));_.length>0?(a.set(u,_.map(([e])=>e)),o.set(u,new Map(_))):(a.delete(u),o.delete(u))}let c=/* @__PURE__ */ new Map;for(let[e,t]of a.entries()){let n=r.get(e)||`Unknown`;for(let r of t){let t=c.get(r)??[];t.push({parentId:e,parentType:n}),c.set(r,t)}}return{typeMap:r,compCatalogMap:i,childMap:a,childPathMap:o,parentMap:c,compIndexMap:s}}function Sd(e,t,n,r){if(!_d(e,t.filter(e=>typeof e.id==`string`).map(t=>n(t,e)),r))return;let{typeMap:i,compCatalogMap:a,childMap:o,childPathMap:s,parentMap:c,compIndexMap:l}=xd(e,t,n),u=vd(e,r);for(let[t,n]of i.entries()){let r=a.get(t)?.components.get(n);r&&(r.allowedParents&&r.allowedParents.length>0&&yd(t,n,r.allowedParents,c.get(t),u,e.id,l.get(t),l),r.allowedChildren&&r.allowedChildren.length>0&&bd(t,n,r.allowedChildren,o.get(t)||[],i,e.id,l.get(t),s.get(t),l))}}function Cd(e,t,n,r,i=!1){if(!r)return;let a=new Hu(e.defaultCatalog);for(let[t,n]of e.componentsModel.entries)a.addComponent(new Zu(t,n.type,n.properties,n.catalog));for(let r of t){let{id:t,component:i}=r;if(typeof t!=`string`||!t)continue;let o=n(r,e),s=a.get(t),c=(typeof i==`string`?i:s?.type)||``;if(!c)continue;let{properties:l}=Da(r,e.protocolVersion,o.components.get(c)?.schema,{defaultCatalogSchema:e.defaultCatalog?.components.get(c)?.schema});s?c!==s.type||s.catalog.id!==o.id?(a.removeComponent(t),a.addComponent(new Zu(t,c,l,o))):s.properties=l:a.addComponent(new Zu(t,c,l,o))}if(a.validateTopology({...r,rootId:r.rootId??e.rootId}),!i)return;let o=/* @__PURE__ */ new Map;for(let e of a.keys)o.set(e,a.getChildIds(e));return o}function wd(e){let t=e.path.join(`.`)||`root`;switch(e.code){case g.invalid_union:{let n=e.unionErrors?.flatMap(e=>e.issues);return n&&n.length>0?n.map(wd).join(`; `):`${t}: Invalid union`}case g.unrecognized_keys:return`${t}: Unrecognized key(s) in object: ${e.keys.map(e=>`'${e}'`).join(`, `)}`;case g.invalid_enum_value:{let n=e;return`${t}: Invalid enum value. Expected ${n.options.map(e=>String(e)).join(` | `)}, received '${String(n.received)}'`}case g.invalid_type:{let n=e;return`${t}: Expected ${n.expected}, received ${n.received}`}case g.custom:return`${t}: ${e.message}`;default:return e.message?`${t}: ${e.message}`:`${t}: Validation error (${e.code})`}}var Td={"0.8":/* @__PURE__ */ new Set([`0.8`]),"0.9":/* @__PURE__ */ new Set([`0.9`,`0.9.1`]),"0.9.1":/* @__PURE__ */ new Set([`0.9.1`,`0.9`]),"1.0":/* @__PURE__ */ new Set([`1.0`])};function Ed(e,t,n=Td){if(!e||!t)return!1;let r=mr(e),i=mr(t);if(r&&i){if(r===i)return!0;let a=n[i];if(a&&a.has(r))return!0;let o=pr(e),s=pr(t);return!!(o&&s&&o.major>=1&&o.major===s.major)}if(typeof e!=`string`||typeof t!=`string`)return!1;let a=dr(e),o=dr(t);return a.length>0&&a===o}var Dd;function Od(e){Dd=e}function kd(e,t){for(let n of t){let t=e[n];if(t&&typeof t==`object`){let e=t;if(`surfaceId`in e&&e.surfaceId!==void 0&&typeof e.surfaceId!=`string`){let e=`surfaceId must be a string`;throw new P(e,[{path:`/${n}/surfaceId`,code:`type_mismatch`,message:e}],`VALIDATION_ERROR`,{path:`/surfaceId`})}}}}function Ad(e,t,n){if(e.issues.length!==1)return e;let r=e.issues[0];if(r.code!==g.invalid_union||r.path.length!==0)return e;let i=r.unionErrors.filter(e=>!e.issues.some(e=>e.code===g.unrecognized_keys&&e.path.length===0&&e.keys.includes(t)||e.code===g.invalid_type&&e.path.length===1&&e.path[0]!==t&&n.includes(String(e.path[0]))&&e.received===`undefined`));return i.length===1?i[0]:e}var jd=class{get compatibleCatalogVersions(){let e=mr(this.version);return e?/* @__PURE__ */ new Set([e]):/* @__PURE__ */ new Set}get validActions(){return new Set(this.getNativeActionKeys())}isCatalogCompatible(e){return e?Ed(e,this.version):!1}extractOperations(e,t){if(!e||typeof e!=`object`)return[];if(Array.isArray(e))return e.flatMap(e=>this.extractOperations(e,t));let n=e;if(Array.isArray(n.messages))return this.extractOperations(n.messages,t);let r=this.getNativeActionKeys();kd(n,r);let i=r.filter(e=>Object.hasOwn(n,e)).sort();if(i.length>1)throw new P(`Message contains multiple conflicting update actions: ${i.join(`, `)}.`);if(i.length===0){let e=Dd?Dd():new Set(r),t=Object.keys(n).find(t=>e.has(t)&&!r.includes(t)),i=r.slice().sort().join(`, `);if(t){let e=`Invalid ${this.version} message: action '${t}' is not supported in protocol version ${this.version}. Allowed actions: ${i}.`;throw new P(e,[{path:`/version`,code:`invalid_value`,message:e}],`VALIDATION_ERROR`,{path:`/version`})}throw new P(`Invalid ${this.version} message: message must contain exactly one update action: ${i}.`)}let a=this.preparePayloadForValidation(n,t),o=this.schema.safeParse(a);if(!o.success){let e=Ad(o.error,i[0],r),t=e.errors.map(wd).join(`; `),a=ed(n,this.version),s=new P(`Invalid ${this.version} message: ${t}`,e,`VALIDATION_ERROR`),c=sd(s,a);throw s.path=c.error.path,s.surfaceId=c.error.surfaceId||void 0,s.functionCallId=c.error.functionCallId,s}return this.extractOperationsFromObject(a)}preparePayloadForValidation(e,t){return`version`in e?e:{version:this.version,...e}}},Md=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==void 0);n.length!==1&&t.addIssue({code:g.custom,message:`Must define exactly one property, found ${n.length} (${n.join(`, `)}).`})},Nd=k({path:w().optional(),literalString:w().optional(),literal:w().optional()}).strict().superRefine(Md),Pd=Et(()=>k({key:w(),valueString:w().optional(),valueNumber:T().optional(),valueBoolean:E().optional(),valueMap:O(Pd).optional()}).strict().superRefine((e,t)=>{let n=0;e.valueString!==void 0&&n++,e.valueNumber!==void 0&&n++,e.valueBoolean!==void 0&&n++,e.valueMap!==void 0&&n++,n!==1&&t.addIssue({code:g.custom,message:`Value map item must have exactly one value property (valueString, valueNumber, valueBoolean, valueMap), found ${n}.`})}));function Fd(e={}){let t=e.maxDepth??5;return Pd.superRefine((e,n)=>{let r=(e,i)=>{if(i>t)n.addIssue({code:g.custom,message:`valueMap recursion exceeded maximum depth of ${t}.`});else if(e.valueMap&&Array.isArray(e.valueMap))for(let t of e.valueMap)r(t,i+1)};r(e,1)})}var Id=Fd();k({path:w().optional(),literalNumber:T().optional(),literal:T().optional()}).strict().superRefine(Md),k({path:w().optional(),literalBoolean:E().optional(),literal:E().optional()}).strict().superRefine(Md);var Ld=k({name:w().describe(`A unique name identifying the action (e.g., 'submitForm').`),context:O(k({key:w(),value:k({path:w().describe(`A data binding reference to a location in the data model (e.g., '/user/name').`).optional(),literalString:w().describe(`A fixed, hardcoded string value.`).optional(),literalNumber:T().optional(),literalBoolean:E().optional()}).describe(`The dynamic value. Define EXACTLY ONE of the nested properties.`).strict().superRefine(Md)})).describe(`A key-value map of data bindings to be resolved when the action is triggered.`).optional()});k({text:Nd,usageHint:M([`h1`,`h2`,`h3`,`h4`,`h5`,`caption`,`body`]).optional()}),k({url:Nd,usageHint:M([`icon`,`avatar`,`smallFeature`,`mediumFeature`,`largeFeature`,`header`]).optional(),fit:M([`contain`,`cover`,`fill`,`none`,`scale-down`]).optional(),altText:Nd.optional()}),k({name:Nd}),k({url:Nd}),k({url:Nd,description:Nd.optional().describe(`A label, title, or placeholder text.`)}),k({tabItems:O(k({title:k({path:w().describe(`A data binding reference to a location in the data model (e.g., '/user/name').`).optional(),literalString:w().describe(`A fixed, hardcoded string value.`).optional()}),child:w().describe(`A reference to a component instance by its unique ID.`)}).strict().superRefine((e,t)=>{e.title||t.addIssue({code:g.custom,message:`Tab item is missing 'title'.`}),e.child||t.addIssue({code:g.custom,message:`Tab item is missing 'child'.`}),e.title&&Md(e.title,t)})).describe(`A list of tabs, each with a title and a child component ID.`)}),k({axis:M([`horizontal`,`vertical`]).optional().describe(`The orientation.`),color:w().optional().describe(`The color of the divider (e.g., hex code or semantic name).`),thickness:T().optional().describe(`The thickness of the divider.`)}),k({entryPointChild:w().describe(`The ID of the component (e.g., a button) that triggers the modal.`),contentChild:w().describe(`The ID of the component to display as the modal's content.`)}),k({child:w().describe(`The ID of the component to display as the button's content.`),action:Ld.describe(`Represents a user-initiated action.`),primary:E().optional().describe(`Indicates if this button should be styled as the primary action.`)}),k({label:Nd,value:k({path:w().describe(`A data binding reference to a location in the data model (e.g., '/user/name').`).optional(),literalBoolean:E().optional()}).strict().superRefine(Md)}),k({text:Nd.optional(),label:Nd.describe(`A label, title, or placeholder text.`),textFieldType:M([`shortText`,`number`,`date`,`longText`,`obscured`]).optional(),validationRegexp:w().optional().describe(`A regex string to validate the input.`)}),k({value:Nd,enableDate:E().optional(),enableTime:E().optional(),outputFormat:w().optional().describe(`The string format for the output (e.g., 'YYYY-MM-DD').`)}),k({selections:k({path:w().describe(`A data binding reference to a location in the data model (e.g., '/user/name').`).optional(),literalArray:O(w()).optional()}).strict().superRefine(Md),options:O(k({label:k({path:w().describe(`A data binding reference to a location in the data model (e.g., '/user/name').`).optional(),literalString:w().describe(`A fixed, hardcoded string value.`).optional()}).strict().superRefine(Md),value:w()})).optional(),maxAllowedSelections:T().optional(),type:M([`checkbox`,`chips`]).optional(),filterable:E().optional()}),k({value:k({path:w().describe(`A data binding reference to a location in the data model (e.g., '/user/name').`).optional(),literalNumber:T().optional()}).strict().superRefine(Md),minValue:T().optional(),maxValue:T().optional(),label:Nd.optional()});var Rd=k({componentId:w(),dataBinding:w()}),zd=k({explicitList:O(w()).optional(),template:Rd.describe("A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the map of components in the data model. Values in the map will define the list of children.").optional()}).strict().superRefine(Md);k({children:zd,distribution:M([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`]).optional(),alignment:M([`start`,`center`,`end`,`stretch`]).optional()}),k({children:zd,distribution:M([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`]).optional(),alignment:M([`start`,`center`,`end`,`stretch`]).optional()}),k({children:zd,direction:M([`vertical`,`horizontal`]).optional(),alignment:M([`start`,`center`,`end`,`stretch`]).optional()}),k({child:w().describe(`The ID of the component to be rendered inside the card.`)});var Bd=Id.describe(`A single data entry. Exactly one 'value*' property should be provided alongside the key.`),Vd=j(wt()).refine(e=>Object.keys(e).length===1,`A wrapper object that MUST contain exactly one key, which is the name of the component type (e.g., 'Heading').`),Hd=k({id:w().describe(`The unique identifier for this component.`),weight:T().optional().describe(`The relative weight of this component within a Row or Column. This corresponds to the CSS 'flex-grow' property. Note: this may ONLY be set when the component is a direct descendant of a Row or Column.`),component:Vd.describe(`A wrapper object that MUST contain exactly one key, which is the name of the component type (e.g., 'Heading'). The value is an object containing the properties for that specific component.`)}).strict().describe(`Represents a *single* component in a UI widget tree. This component could be one of many supported types.`),Ud=k({surfaceId:w().describe(`The unique identifier for the UI surface to be rendered.`),catalogId:w().optional().describe(`The identifier of the component catalog to use for this surface. If omitted, the client MUST default to the standard catalog for this A2UI version (https://a2ui.org/specification/v0_8/standard_catalog_definition.json).`),root:w().describe(`The ID of the root component to render.`),styles:k({font:w().optional().describe(`The primary font for the UI.`),primaryColor:w().regex(/^#[0-9a-fA-F]{6}$/).optional().describe(`The primary UI color as a hexadecimal code (e.g., '#00BFFF').`)}).strict().optional().describe(`Styling information for the UI.`)}).strict().describe(`Signals the client to begin rendering a surface with a root component and specific styles.`),Wd=k({surfaceId:w().describe(`The unique identifier for the UI surface to be updated. If you are adding a new surface this *must* be a new, unique identified that has never been used for any existing surfaces shown.`),components:O(Hd).min(1).describe(`A list containing all UI components for the surface.`)}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let r of e.components)r.id&&(n.has(r.id)&&t.addIssue({code:g.custom,message:`Duplicate component ID found: ${r.id}`,path:[`components`]}),n.add(r.id));let r=(e,r)=>{for(let i of e)i&&!n.has(i)&&t.addIssue({code:g.custom,message:`Component '${r}' references non-existent component ID '${i}'.`,path:[`components`]})};for(let n of e.components){if(!n.id||!n.component)continue;let e=Object.keys(n.component);if(e.length!==1)continue;let i=e[0],a=n.component[i];switch(i){case`Row`:case`Column`:case`List`:if(a.children&&!Array.isArray(a.children)){let e=!!a.children.explicitList,i=!!a.children.template;(e&&i||!e&&!i)&&t.addIssue({code:g.custom,message:`Component '${n.id}' must have either 'explicitList' or 'template' in children, but not both or neither.`}),e&&r(a.children.explicitList,n.id),i&&r([a.children.template?.componentId],n.id)}break;case`Card`:a.child&&r([a.child],n.id);break;case`Tabs`:a.tabItems&&Array.isArray(a.tabItems)&&a.tabItems.forEach(e=>{e.child&&r([e.child],n.id)});break;case`Modal`:r([a.entryPointChild,a.contentChild],n.id);break;case`Button`:a.child&&r([a.child],n.id)}}}).describe(`Updates a surface with a new set of components.`),Gd=k({surfaceId:w().describe(`The unique identifier for the UI surface this data model update applies to.`),path:w().optional().describe(`An optional path to a location within the data model (e.g., '/user/name'). If omitted, or set to '/', the entire data model will be replaced.`),contents:O(Bd).describe(`An array of data entries. Each entry must contain a 'key' and exactly one corresponding typed 'value*' property.`)}).strict().describe(`Updates the data model for a surface.`),Kd=k({surfaceId:w().describe(`The unique identifier for the UI surface to be deleted.`)}).strict().describe(`Signals the client to delete the surface identified by 'surfaceId'.`),qd=k({beginRendering:Ud.optional(),surfaceUpdate:Wd.optional(),dataModelUpdate:Gd.optional(),deleteSurface:Kd.optional()}).strict().superRefine((e,t)=>{Object.keys(e).filter(e=>[`beginRendering`,`surfaceUpdate`,`dataModelUpdate`,`deleteSurface`].includes(e)).length!==1&&t.addIssue({code:g.custom,message:`A2UI Protocol message must have exactly one of: surfaceUpdate, dataModelUpdate, beginRendering, deleteSurface.`})}).describe(`Describes a JSON payload for an A2UI message, which is used to dynamically construct and update user interfaces. A message MUST contain exactly ONE of the action properties: 'beginRendering', 'surfaceUpdate', 'dataModelUpdate', or 'deleteSurface'.`);function Jd(e){if(!e||typeof e!=`object`)return{id:``,component:``};let t=e,n=typeof t.component==`string`?t.component:``,r={};for(let[e,n]of Object.entries(t))e!==`component`&&e!==`id`&&(r[e]=n);if(t.component&&typeof t.component==`object`){let e=t.component,i=Object.keys(e);if(i.length>0){n=i[0];let t=e[i[0]];t&&typeof t==`object`&&t&&!Array.isArray(t)&&Object.assign(r,t)}}return{...r,id:String(t.id??``),component:n}}var Yd=class extends jd{constructor(){super(...arguments),this.version=`v0.8`,this.schema=qd}getNativeActionKeys(){return[`beginRendering`,`surfaceUpdate`,`dataModelUpdate`,`deleteSurface`]}preparePayloadForValidation(e){let t={...e};return delete t.version,t}extractOperationsFromObject(e){let t=[];if(`beginRendering`in e){let n=e.beginRendering;t.push({type:`createSurface`,surfaceId:String(n?.surfaceId??``),catalogId:typeof n?.catalogId==`string`?n.catalogId:void 0,theme:n?.theme??n?.styles,sendDataModel:!!n?.sendDataModel,components:Array.isArray(n?.components)?n.components.map(Jd):void 0,dataModel:n?.dataModel&&typeof n.dataModel==`object`&&!Array.isArray(n.dataModel)?n.dataModel:void 0,version:typeof e.version==`string`?e.version:this.version,rootId:typeof n?.root==`string`&&n.root?n.root:void 0})}if(`surfaceUpdate`in e){let n=e.surfaceUpdate;t.push({type:`updateComponents`,surfaceId:String(n?.surfaceId??``),components:Array.isArray(n?.components)?n.components.map(Jd):[]})}if(`dataModelUpdate`in e){let n=e.dataModelUpdate,r=String(n?.surfaceId??``),i=typeof n?.path==`string`?n.path.trim():``,a=i&&i!==`/`?(i.startsWith(`/`)?i:`/${i}`).replace(/\/+$/,``):``,o=e=>{if(`valueNumber`in e)return e.valueNumber;if(`valueString`in e)return e.valueString;if(`valueBoolean`in e)return e.valueBoolean;if(`valueObject`in e)return e.valueObject;if(`valueArray`in e)return e.valueArray;if(Array.isArray(e.valueMap)){let t={};for(let n of e.valueMap)n&&typeof n==`object`&&typeof n.key==`string`&&(t[n.key]=o(n));return t}return e.value};if(Array.isArray(n?.contents)){for(let e of n.contents)if(e&&typeof e==`object`&&typeof e.key==`string`){let n=o(e),i=e.key.replace(/^\/+/,``),s=i===`.`||i===``?a||`/`:`${a}/${i}`;t.push({type:`updateDataModel`,surfaceId:r,path:s,value:n})}}else t.push({type:`updateDataModel`,surfaceId:r,path:typeof n?.path==`string`?n.path:void 0,value:n?.value})}if(`deleteSurface`in e){let n=e.deleteSurface;t.push({type:`deleteSurface`,surfaceId:String(n?.surfaceId??``)})}return t}},Xd=A([k({version:M([`v0.9`,`v0.9.1`]),createSurface:k({surfaceId:w().describe(`The unique identifier for the UI surface to be rendered.`),catalogId:w().describe(`A string that uniquely identifies this catalog. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. mycompany.com:somecatalog'.`),theme:wt().optional(),sendDataModel:E().describe(`If true, the client will send the full data model of this surface in the metadata of every A2A message sent to the server that created the surface. Defaults to false.`).optional()}).strict().describe(`Signals the client to create a new surface and begin rendering it. It is an error to send 'createSurface' for a surfaceId that already exists without first deleting it. When this message is sent, the client will expect 'updateComponents' and/or 'updateDataModel' messages for the same surfaceId that define the component tree.`)}).strict(),k({version:M([`v0.9`,`v0.9.1`]),updateComponents:k({surfaceId:w().describe(`The unique identifier for the UI surface to be updated.`),components:O(j(w(),wt())).min(1).describe(`A list containing all UI components for the surface.`)}).strict().describe(`Updates a surface with a new set of components. This message can be sent multiple times to update the component tree of an existing surface. One of the components in one of the components lists MUST have an 'id' of 'root' to serve as the root of the component tree. A createSurface message MUST have been previously sent for the 'surfaceId' in this message; the surface's catalog is the one specified by that createSurface.`)}).strict(),k({version:M([`v0.9`,`v0.9.1`]),updateDataModel:k({surfaceId:w().describe(`The unique identifier for the UI surface this data model update applies to.`),path:w().describe(`An optional path to a location within the data model (e.g., '/user/name'). If omitted, or set to '/', refers to the entire data model.`).optional(),value:wt().describe(`The data to be updated in the data model. If present, the value at 'path' is replaced (or created). If omitted, the key at 'path' is removed.`).optional()}).strict().describe(`Updates the data model for an existing surface. This message can be sent multiple times to update the data model. A createSurface message MUST have been previously sent for the 'surfaceId' in this message; the surface's catalog is the one specified by that createSurface.`)}).strict(),k({version:M([`v0.9`,`v0.9.1`]),deleteSurface:k({surfaceId:w().describe(`The unique identifier for the UI surface to be deleted.`)}).strict().describe(`Signals the client to delete the surface identified by 'surfaceId'. A createSurface message MUST have been previously sent for the 'surfaceId' in this message; the surface's catalog is the one specified by that createSurface.`)}).strict()]);k({messages:O(Xd).describe(`A list of messages.`)}).strict().describe(`An object wrapping a list of messages.`);var Zd=class extends jd{constructor(){super(...arguments),this.version=`v0.9`,this.schema=Xd}get compatibleCatalogVersions(){return/* @__PURE__ */ new Set([`0.9`,`0.9.1`])}getNativeActionKeys(){return[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`]}extractOperationsFromObject(e){let t=[];if(`createSurface`in e){let n=e.createSurface;t.push({type:`createSurface`,surfaceId:String(n?.surfaceId||``),catalogId:typeof n?.catalogId==`string`?n.catalogId:void 0,theme:n?.theme,sendDataModel:!!n?.sendDataModel,components:Array.isArray(n?.components)?n.components:void 0,dataModel:n?.dataModel&&typeof n.dataModel==`object`&&!Array.isArray(n.dataModel)?n.dataModel:void 0,version:typeof e.version==`string`?e.version:this.version})}if(`updateComponents`in e){let n=e.updateComponents;t.push({type:`updateComponents`,surfaceId:String(n?.surfaceId||``),components:Array.isArray(n?.components)?n.components:[]})}if(`updateDataModel`in e){let n=e.updateDataModel;t.push({type:`updateDataModel`,surfaceId:String(n?.surfaceId||``),path:typeof n?.path==`string`?n.path:void 0,value:n?.value})}if(`deleteSurface`in e){let n=e.deleteSurface;t.push({type:`deleteSurface`,surfaceId:String(n?.surfaceId||``)})}return t}},Qd=[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`,`callRendererFunction`,`agentFunctionResponse`];function $d(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`&&Qd.includes(e.type)}k({componentId:Et(()=>Or),path:w().describe(`The path to the list of component property objects in the data model.`)}).strict().describe("REF:#/$defs/TemplateChildList|A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.");var ef=O(Et(()=>Lr.pick({id:!0}).extend({component:w()}).passthrough().refine(e=>e.component!==`Surface`,{message:`Component type cannot be "Surface". "Surface" is a top-level protocol container defined in createSurface, not a child component.`}))).min(1);j(w(),wt());var tf=A([k({version:Dt(`1.0`),createSurface:k({surfaceId:w().describe(`The unique identifier for the UI surface to be rendered. It must be globally unique for the renderer's lifetime.`),catalogId:w().describe(`A string that uniquely identifies the default catalog for this surface. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. 'mycompany.com:somecatalog'. Components that do not explicitly specify @catalogId and function calls that do not explicitly specify catalogId will use this surface-level default catalogId.`).optional(),sendDataModel:E().describe(`If true, the renderer will send the full data model of this surface in the metadata of every A2A message sent to the agent that created the surface. Defaults to false.`).optional(),components:ef.optional(),dataModel:j(w(),wt()).describe(`The initial root data model object for the surface.`).optional(),metadata:k({extensions:Ir.optional()}).strict().describe(`Optional surface-level metadata.`).optional()}).strict().describe(`Signals the renderer to create a new surface and begin rendering it. Creating a surface implicitly instantiates the canonical 'Surface' container component ('common_types.json#/$defs/Surface') with 'child': 'root'. It is an error to try to create a surface with an existing ID without first deleting it; surfaceId MUST be globally unique for the renderer's lifetime. The component tree and initial data model may be provided inline via 'components' and 'dataModel', or sent later in 'updateComponents' and/or 'updateDataModel' messages for the same surfaceId.`)}).strict(),k({version:Dt(`1.0`),updateComponents:k({surfaceId:w().describe(`The unique identifier for the UI surface to be updated. It must be globally unique for the renderer's lifetime.`),components:ef}).strict().describe(`Updates a surface with a new set of components. This message can be sent multiple times to update the component tree of an existing surface. One of the components in one of the components lists MUST have an 'id' of 'root' to serve as the root of the component tree. The createSurface message MUST have been previously sent for this surfaceId.`)}).strict(),k({version:Dt(`1.0`),updateDataModel:k({surfaceId:w().describe(`The unique identifier for the UI surface this data model update applies to. It must be globally unique for the renderer's lifetime.`),path:w().describe(`An optional path to a location within the data model (e.g., '/user/name'). If omitted, or set to '/', refers to the entire data model.`).optional(),value:wt().describe(`The data to be updated in the data model. To delete the key/value at 'path', set 'value' explicitly to null.`)}).strict().describe(`Updates the data model for an existing surface. This message can be sent multiple times to update the data model. The createSurface message MUST have been previously sent for this surfaceId.`)}).strict(),k({version:Dt(`1.0`),deleteSurface:k({surfaceId:w().describe(`The unique identifier for the UI surface to be deleted. It must be globally unique for the renderer's lifetime.`)}).strict().describe(`Signals the renderer to delete the surface identified by 'surfaceId'. The createSurface message MUST have been previously sent for this surfaceId.`)}).strict(),k({version:Dt(`1.0`),callRendererFunction:k({surfaceId:w().describe(`Optional ID of the surface whose data model provides the evaluation context for this call. If omitted, the function executes in a surface-independent root context with an empty data model.`).optional(),functionCallId:kr,callFunction:Tt(Mr,k({catalogId:w()}).passthrough())}).strict().describe(`Signals the renderer to execute a function locally on behalf of the agent.`)}).strict(),k({version:Dt(`1.0`),agentFunctionResponse:Jr}).strict()]);function nf(e,t,n){if(Object.hasOwn(e,`args`)&&e.args!==void 0&&(typeof e.args!=`object`||e.args===null||Array.isArray(e.args)))throw new P(`Invalid ${t} message: callRendererFunction.callFunction.args: Expected object, received ${Array.isArray(e.args)?`array`:typeof e.args}`,void 0,`VALIDATION_ERROR`,{functionCallId:n||void 0})}function rf(e,t){let n=e?.callFunction||{},r=String(e?.functionCallId||``);return nf(n,t,r),{type:`callRendererFunction`,surfaceId:typeof e?.surfaceId==`string`?e.surfaceId:void 0,functionCallId:r,call:String(n?.[`@call`]||n?.call||``),version:t,catalogId:typeof n?.catalogId==`string`?n?.catalogId:void 0,args:n?.args&&typeof n.args==`object`&&!Array.isArray(n.args)?n.args:{}}}var af=class extends jd{constructor(){super(...arguments),this.version=`1.0`,this.schema=tf}getNativeActionKeys(){return[...Qd]}preparePayloadForValidation(e,t){let n=super.preparePayloadForValidation(e,t);if((!t||(t.allowUnknownElements??!1))&&typeof n.createSurface==`object`&&n.createSurface!==null&&!Array.isArray(n.createSurface)){let e=n.createSurface;if(`theme`in e){let t={...e};return delete t.theme,{...n,createSurface:t}}}return n}extractOperationsFromObject(e){let t=[];if(`createSurface`in e){let n=e.createSurface;t.push({type:`createSurface`,surfaceId:String(n?.surfaceId||``),catalogId:typeof n?.catalogId==`string`?n.catalogId:void 0,sendDataModel:!!n?.sendDataModel,components:Array.isArray(n?.components)?n.components:void 0,dataModel:n?.dataModel&&typeof n.dataModel==`object`&&!Array.isArray(n.dataModel)?n.dataModel:void 0,version:typeof e.version==`string`?e.version:this.version,metadata:n?.metadata&&typeof n.metadata==`object`&&!Array.isArray(n.metadata)?n.metadata:void 0})}if(`updateComponents`in e){let n=e.updateComponents;t.push({type:`updateComponents`,surfaceId:String(n?.surfaceId||``),components:Array.isArray(n?.components)?n.components:[]})}if(`updateDataModel`in e){let n=e.updateDataModel;t.push({type:`updateDataModel`,surfaceId:String(n?.surfaceId||``),path:typeof n?.path==`string`?n.path:void 0,value:n?.value})}if(`deleteSurface`in e){let n=e.deleteSurface;t.push({type:`deleteSurface`,surfaceId:String(n?.surfaceId||``)})}if(`callRendererFunction`in e&&t.push(rf(e.callRendererFunction,this.version)),`agentFunctionResponse`in e){let n=e.agentFunctionResponse;t.push({type:`agentFunctionResponse`,functionCallId:String(n?.functionCallId||``),version:this.version,value:n?.value,error:n?.error&&typeof n.error==`object`?n.error:void 0})}return t}},of=new class{constructor(){this.adapters=/* @__PURE__ */ new Map([[`0.8`,new Yd],[`0.9`,new Zd],[`0.9.1`,new Zd],[`1.0`,new af]])}getAllKnownActions(){let e=/* @__PURE__ */ new Set;for(let t of this.adapters.values())if(t.validActions)for(let n of t.validActions)e.add(n);return e}registerAdapter(e){let t=mr(e.version)??dr(e.version);this.adapters.set(t,e)}getAdapter(e){let t=mr(e)??dr(e),n=this.adapters.get(t);if(!n)throw new P(`[VersionAdapterFactory] Unsupported protocol version '${e}'. Supported versions: ${Array.from(new Set(Array.from(this.adapters.entries()).map(([e,t])=>e===`0.9.1`?`v0.9.1`:t.version))).sort().join(`, `)}.`);return n}resolveFromPayload(e){let t=Array.isArray(e)?e[0]:e;if(typeof t==`object`&&t){if(`messages`in t&&Array.isArray(t.messages))return this.resolveFromPayload(t.messages);if(`version`in t){let e=t.version;if(typeof e!=`string`)throw new P(`[VersionAdapterFactory] Message payload is missing a valid 'version' string: 'version' property must be a string, got ${typeof e}.`);return this.getAdapter(e)}if(`beginRendering`in t||`surfaceUpdate`in t||`dataModelUpdate`in t||`deleteSurface`in t)return this.getAdapter(`v0.8`)}throw new P(`[VersionAdapterFactory] Message payload is missing a valid 'version' string.`)}static registerAdapter(e){of.registerAdapter(e)}static getAdapter(e){return of.getAdapter(e)}static resolveFromPayload(e){return of.resolveFromPayload(e)}static getAllKnownActions(){return of.getAllKnownActions()}};Od(()=>of.getAllKnownActions());function sf(e){return e===Xr.name?Xr:void 0}function cf(e,t){if(t.catalogId!==void 0)throw new P(`System function '${e}' belongs to no catalog and must not name a catalogId.`)}function lf(e){return`Function call '${e}' has a non-string 'catalogId'.`}function uf(e,t){if(e.functions.get(t)?.allowedCallers===`agentOnly`)throw new P(`Function '${t}' cannot be called by renderer (allowedCallers is agentOnly).`)}function df(e,t,{catalogIsDefault:n}){return e===void 0?n:e===t}var ff=class{constructor(e,t){this.catalog=e,this.config=t,this.enforceIdentifiers=R(e.protocolVersion,`1.0`)}get allowUnknown(){return this.config?this.config.allowUnknownElements??!1:!0}validateComponent(e,t,n){let r=e.id;if(typeof r!=`string`||!r){let t=`Component '${e.component}' is missing an 'id'; entries require a valid string 'id'.`;throw new P(t,[{path:`/id`,code:`missing_field`,message:t}],`VALIDATION_ERROR`,{path:`/id`})}this.assertIdentifier(r,`Component id '${r}' must be a valid UAX #31 identifier`,!1,`/id`);let i=e.component,a=typeof i==`string`?i:t;if(!a){let e=`Cannot create component ${r} without a type.`;throw new P(e,[{path:`/component`,code:`missing_field`,message:e}],`VALIDATION_ERROR`,{path:`/component`})}this.assertIdentifier(a,`Component type '${a}' must be a valid UAX #31 identifier`,!1,`/component`);let o=this.catalog.components.get(a),s=this.enforceIdentifiers?Ea(e,wa(o?.schema)):{properties:mf(e),mixins:{}},c=s.properties,l=s.mixins.catalogId?.value,u=typeof l==`string`?l:void 0;if(!o){if(!this.allowUnknown){let e=`Unknown component type '${a}' not found in catalog '${this.catalog.id}'.`;throw new P(e,[{path:`/component`,code:`invalid_value`,message:e}],`VALIDATION_ERROR`,{path:`/component`})}this.validateEnvelopeMixins(s.mixins,void 0,c,a,r,u),n?.skipNestedFunctions||this.validateNestedFunctions(c,u);return}this.enforceIdentifiers?this.validateEnvelopeMixins(s.mixins,wa(o.schema),c,a,r,u):this.validateLegacyAccessibility(c,fi(o.schema),a,r);let d=o.schema.safeParse(c);if(!d.success){let e=d.error.errors.map(wd).join(`, `),t=pf(d.error.issues),n=new Set(t.map(e=>e.path)).size===1?t[0]?.path:void 0;throw new P(`Validation failed for component '${a}' (${r}): ${e}`,t,`VALIDATION_ERROR`,{path:n&&n!==`/`?n:void 0})}n?.skipNestedFunctions||this.validateNestedFunctions(c,u,``,o.schema)}validateLegacyAccessibility(e,t,n,r){if(!(`accessibility`in e)||t?.has(`accessibility`))return;let i=e.accessibility;delete e.accessibility,this.parseEnvelopeValue(Vn.optional(),i,`/accessibility`,{componentType:n,id:r}),this.validateNestedFunctions(i,void 0,`/accessibility`,Vn)}validateEnvelopeMixins(e,t,n,r,i,a){let o={componentType:r,id:i};for(let[s,c]of Object.entries(e)){let e=`/${c.wireKey}`;s===`metadata`&&(this.parseEnvelopeValue(Un.shape[`@metadata`],c.value,e,o),hf(e,()=>Di(c.value)));let l=t?.schemaKeys.get(s);if(l!==void 0)n[l]=c.value;else switch(s){case`catalogId`:if(typeof c.value!=`string`){let t=`Component '${i}' has a non-string '${c.wireKey}'.`;throw new P(t,[{path:e,code:`invalid_value`,message:t}],`VALIDATION_ERROR`,{path:e})}break;case`accessibility`:this.parseEnvelopeValue(Vn.optional(),c.value,e,o),this.validateNestedFunctions(c.value,a,e,Vn);break;case`checks`:if(t){let t=`Component '${r}' (${i}) is not checkable and does not accept '${c.wireKey}'.`;throw new P(t,[{path:e,code:`invalid_value`,message:t}],`VALIDATION_ERROR`,{path:e})}this.validateNestedFunctions(c.value,a,e)}}}parseEnvelopeValue(e,t,n,{componentType:r,id:i}){let a=e.safeParse(t);if(a.success)return;let o=a.error.errors.map(wd).join(`, `),s=pf(a.error.issues,n);throw new P(`Validation failed for component '${r}' (${i}): ${o}`,s,`VALIDATION_ERROR`,{path:s[0]?.path})}assertFunctionIdentifiers(e,t){if(this.assertIdentifier(e,`Function name '${e}' must be a valid UAX #31 identifier`,!0),this.enforceIdentifiers&&t!=null&&(typeof t!=`object`||Array.isArray(t)))throw new P(`Validation failed for function '${e}': Expected object, received ${Array.isArray(t)?`array`:typeof t}`);if(t&&typeof t==`object`&&!Array.isArray(t)){let n=Object.keys(t);if(n.length>1e3)throw new P(`Function call '${e}' exceeds maximum allowed arguments count (${ir})`);for(let t of n)this.assertIdentifier(t,`Function argument '${t}' in function '${e}' must be a valid UAX #31 identifier`)}}checkNestedCallRecord(e,t,n,r){let i=e.args,a=i===void 0?{}:i;if(!this.enforceIdentifiers){this.validateFunction(t,a),this.assertPreV10ReturnType(e,t,r);return}if(t.startsWith(`@`)){cf(t,e),this.validateFunction(t,a);return}let o=e.catalogId;if(o!==void 0&&typeof o!=`string`)throw new P(lf(t));df(o,this.catalog.id,{catalogIsDefault:n===void 0})?(uf(this.catalog,t),this.validateFunction(t,a)):this.assertFunctionIdentifiers(t,a)}assertPreV10ReturnType(e,t,n){let r=this.catalog.functions.get(t),i=e.returnType;if(i!==void 0&&r&&r.returnType!==`any`&&i!==r.returnType)throw gf(t,r.returnType,String(i));let a=Sf(n);if(!a)return;let o=i!==void 0&&(typeof i!=`string`||!a.has(i)),s=r!==void 0&&r.returnType!==`any`&&!a.has(r.returnType);if(o||s){let e=String(i===void 0?r?.returnType:i);throw gf(t,[...a].join(`' | '`),e)}}validateNestedFunctions(e,t,n=``,r){if(Array.isArray(e)){this.validateNestedArray(e,t,n,r);return}if(typeof e!=`object`||!e)return;let i=e;this.enforceIdentifiers&&this.validateRecordDirectives(i,n);let a=this.enforceIdentifiers?i[`@call`]:i.call??i.function,o=typeof a==`string`&&(this.enforceIdentifiers||a.length>0);o&&hf(n,()=>this.checkNestedCallRecord(i,a,t,r)),this.validateNestedRecordChildren(i,o?a:void 0,t,n,r)}validateNestedArray(e,t,n,r){let i=Tf(r);for(let r=0;r<e.length;r++)this.validateNestedFunctions(e[r],t,`${n}/${r}`,i)}validateRecordDirectives(e,t){let n=Object.keys(e);_i(t===``?n.filter(e=>!fa.has(e)):n,this.catalog.protocolVersion)}validateNestedRecordChildren(e,t,n,r,i){let a=t===void 0?void 0:this.resolveCallArgsSchema(e,t,n),o=t===void 0?Of(i,e):void 0;for(let[i,s]of Object.entries(e)){let c=t===void 0?Ef(o,i,e):i===`args`?a:void 0;this.validateNestedFunctions(s,n,`${r}/${i}`,c)}}resolveCallArgsSchema(e,t,n){if(!this.enforceIdentifiers)return this.catalog.functions.get(t)?.schema;if(t.startsWith(`@`))return sf(t)?.schema;let r=e.catalogId;if((r===void 0||typeof r==`string`)&&df(r,this.catalog.id,{catalogIsDefault:n===void 0}))return this.catalog.functions.get(t)?.schema}validateFunction(e,t){this.assertFunctionIdentifiers(e,t);let n=this.enforceIdentifiers&&e.startsWith(`@`)?sf(e):this.catalog.functions.get(e);if(!n){if(!this.allowUnknown)throw new P(`Unrecognized function '${e}'`);return t??{}}if(!n.schema){if(t!==void 0&&(typeof t!=`object`||!t||Array.isArray(t)))throw new P(`Validation failed for function '${e}': Expected object, received ${Array.isArray(t)?`array`:typeof t}`,void 0,`VALIDATION_ERROR`,{path:`/args`});return t??{}}let r=n.schema.safeParse(t??{});if(!r.success){let t=r.error.errors.map(wd).join(`, `),n=pf(r.error.issues,`/args`);throw new P(`Validation failed for function '${e}': ${t}`,n,`VALIDATION_ERROR`,{path:n[0]?.path})}return r.data}validateTheme(e){let t=this.catalog.themeSchema;if(!t)return e;let n=t.safeParse(e);if(!n.success){let e=n.error.errors.map(wd).join(`, `),t=pf(n.error.issues,`/theme`);throw new P(`Validation failed for theme: ${e}`,t,`VALIDATION_ERROR`,{path:t[0]?.path??`/theme`})}return n.data}assertIdentifier(e,t,n=!1,r){if(this.enforceIdentifiers&&!Nn(e,n))throw new P(t,r?[{path:r,code:`invalid_value`,message:t}]:void 0,`VALIDATION_ERROR`,{path:r})}};function pf(e,t=``){return e.map(e=>{let n=e.path.map(e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`));return e.code===`unrecognized_keys`&&`keys`in e&&Array.isArray(e.keys)&&e.keys.length>0&&n.push(String(e.keys[0]).replace(/~/g,`~0`).replace(/\//g,`~1`)),{path:`${t}${n.length>0?`/${n.join(`/`)}`:``}`||`/`,code:e.code===`invalid_type`&&`received`in e&&e.received===`undefined`||e.message===`Required`?`missing_field`:`invalid_value`,message:e.message}})}function mf(e){let{id:t,component:n,...r}=e;return r}function hf(e,t){try{t()}catch(t){throw t instanceof P&&(t.path=t.path&&t.path!==`/`?`${e}${t.path}`:e),t}}function gf(e,t,n){let r=`Validation failed for function '${e}': Expected returnType '${t}', received '${n}'`;return new P(r,[{path:`/returnType`,code:`invalid_value`,message:r}],`VALIDATION_ERROR`,{path:`/returnType`})}var _f=/^REF:[^|#]*#\/\$defs\/(DynamicString|DynamicNumber|DynamicBoolean|DynamicStringList|DynamicValue)(?:\||$)/,vf={DynamicString:`string`,DynamicNumber:`number`,DynamicBoolean:`boolean`,DynamicStringList:`array`,DynamicValue:`any`};function yf(e){let t=e._def;switch(t.typeName){case`ZodOptional`:case`ZodNullable`:case`ZodDefault`:case`ZodCatch`:case`ZodReadonly`:return t.innerType;case`ZodBranded`:return t.type;case`ZodEffects`:return t.schema;case`ZodPipeline`:return t.out;case`ZodLazy`:return t.getter?.();default:return}}function bf(e){let t=e;for(let e=t&&yf(t);e;e=t&&yf(t))t=e;return t}function xf(e){for(let t=e;t;t=yf(t)){let e=t.description,n=typeof e==`string`?_f.exec(e):null;if(n)return vf[n[1]]}}function Sf(e){let t=xf(e);if(t!==void 0)return t===`any`?void 0:/* @__PURE__ */ new Set([t]);let n=bf(e)?._def;if(n?.typeName===`ZodIntersection`&&n.left&&n.right)return Sf(n.left)??Sf(n.right);if((n?.typeName===`ZodUnion`||n?.typeName===`ZodDiscriminatedUnion`)&&Array.isArray(n.options))return Cf(n.options)}function Cf(e){let t=/* @__PURE__ */ new Set;for(let n of e){if(xf(n)===`any`)return;let e=Sf(n);if(e)for(let n of e)t.add(n)}return t.size>0?t:void 0}function wf(e){if(e.length!==0)return e.length===1?e[0]:A(e)}function Tf(e){let t=bf(e);if(!t)return;let n=t._def;if(n.typeName===`ZodArray`)return n.type;if((n.typeName===`ZodUnion`||n.typeName===`ZodDiscriminatedUnion`)&&Array.isArray(n.options)&&xf(e)===void 0)return wf(n.options.map(e=>Tf(e)).filter(e=>e!==void 0))}function Ef(e,t,n){let r=bf(e);if(!r)return;let i=r._def;switch(i.typeName){case`ZodObject`:{let e=i.shape?.();return e&&typeof e==`object`?e[t]:void 0}case`ZodRecord`:return i.valueType;case`ZodIntersection`:return Ef(i.right,t,n)??Ef(i.left,t,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return kf(e,r,i.options,t,n);default:return}}function Df(e,t,n){if(!n)return t;let r=e._def;if(r.typeName===`ZodDiscriminatedUnion`&&typeof r.discriminator==`string`&&r.optionsMap instanceof Map){let e=r.optionsMap.get(n[r.discriminator]);return e?[e]:t}let i=t.filter(e=>e.safeParse(n).success);return i.length>0?i:t}function Of(e,t){let n=bf(e);if(!n||xf(e)!==void 0)return e;let r=n._def;return(r.typeName===`ZodUnion`||r.typeName===`ZodDiscriminatedUnion`)&&Array.isArray(r.options)?wf(Df(n,r.options,t)):n}function kf(e,t,n,r,i){if(Array.isArray(n)&&xf(e)===void 0)return wf(Df(t,n,i).map(e=>Ef(e,r,i)).filter(e=>e!==void 0))}var Af=class{constructor(e,t){if(this.pendingAgentCalls=/* @__PURE__ */ new Map,this.isDisposed=!1,Array.isArray(e))this.catalogs=e,this.outboundListener=t,this.defaultTimeoutMs=3e4;else{let t=e??{};this.catalogs=t.catalogs??[],this.outboundListener=t.outboundListener,this.defaultTimeoutMs=t.defaultTimeoutMs??3e4}}get disposed(){return this.isDisposed}async handleCallRendererFunction(e,t,n=!1){let r=this.validateInboundMessage(e);if(r)return await this.emitOutboundResponse(r),r;let{version:i,callRendererFunction:a}=e,{surfaceId:o,functionCallId:s,callFunction:c}=a;if(o!==void 0&&t?.surface?.id!==o){let e=this.createResponseError(s,L.INVALID_FUNCTION_CALL,`Surface not found: ${o}`,i);return await this.emitOutboundResponse(e),e}let l=c[`@call`]??c.call,{catalogId:u,args:d}=c,f=this.resolveFunctionImplementation(u,l,t,i);if(`error`in f){let e=this.createResponseError(s,L.INVALID_FUNCTION_CALL,f.error,i);return await this.emitOutboundResponse(e),e}let p=this.checkExecutionPermissions(f.funcImpl,l,n);if(p){let e=this.createResponseError(s,L.INVALID_FUNCTION_CALL,p,i);return await this.emitOutboundResponse(e),e}let m=this.ensureDataContext(t,f.catalog,s),h=m&&f.catalog.id?si(m,f.catalog.id,f.catalog):m,g=this.resolveDynamicArguments(d,h,n);if(`error`in g){let e=this.createResponseError(s,L.EXECUTION_ERROR,g.error,i);return await this.emitOutboundResponse(e),e}let _;try{_=await wr(g.args)}catch(e){let t=this.createResponseError(s,L.EXECUTION_ERROR,this.extractErrorMessage(e)||`An error occurred during function execution.`,i);return await this.emitOutboundResponse(t),t}let ee=yr(_);if(ee){let e=this.createResponseError(s,L.EXECUTION_ERROR,(ee.error===void 0?``:this.extractErrorMessage(ee.error))||`An argument of the function call could not be resolved.`,i);return await this.emitOutboundResponse(e),e}let te=this.parseArguments(f.catalog,f.funcImpl,_,l);if(`error`in te){let e=this.createResponseError(s,L.INVALID_FUNCTION_CALL,te.error,i);return await this.emitOutboundResponse(e),e}let ne=await this.executeFunctionSafely(f.funcImpl,te.args,h,s,i);return await this.emitOutboundResponse(ne),ne}handleAgentFunctionResponse(e){if(!e||!e.agentFunctionResponse)return;let{functionCallId:t,value:n,error:r}=e.agentFunctionResponse,i=this.pendingAgentCalls.get(t);if(i){if(this.pendingAgentCalls.delete(t),r){let e=r.code??L.UNKNOWN_ERROR,n=r.message??`Agent function execution failed`;i.reject(new wn(n,e,t,r))}else i.resolve(n)}}callAgentFunction(e,t,n){if(this.isDisposed)return Promise.reject(new wn(`RpcHandler has been disposed.`,L.DISPOSED));if(!this.outboundListener)return Promise.reject(new wn(`Cannot call agent function without outboundListener configured.`,L.NO_LISTENER));let r=t?.[`@call`]??t?.call;if(!t||!r)return Promise.reject(new wn(`Missing or invalid function call name.`,L.INVALID_FUNCTION_CALL));let i=n??{},a=i.functionCallId??this.generateFunctionCallId(),o=i.timeoutMs??this.defaultTimeoutMs;if(this.pendingAgentCalls.has(a))return Promise.reject(new wn(`A call with functionCallId '${a}' is already pending.`,L.DUPLICATE,a));let s={functionCallId:a,call:t,effectiveTimeoutMs:o,version:i.version};return this.dispatchAgentCall(e,s)}cancelSurfaceCalls(e){for(let[t,n]of Array.from(this.pendingAgentCalls.entries()))n.surfaceId===e&&n.reject(new wn(`Pending calls for surface '${e}' were cancelled.`,L.CANCELLED,t))}dispose(e){if(this.isDisposed)return;this.isDisposed=!0,this.outboundListener=void 0;let t=e!==void 0&&e.length>0?`: ${e}`:`.`;for(let[e,n]of Array.from(this.pendingAgentCalls.entries()))n.reject(new wn(`RpcHandler disposed while call '${e}' was pending${t}`,L.CANCELLED,e));this.pendingAgentCalls.clear()}async emitOutboundResponse(e){if(this.outboundListener)try{let t=this.outboundListener(e);t&&typeof t.catch==`function`&&await t}catch{}}validateInboundMessage(e){if(!e)return this.createResponseError(`unknown`,L.INVALID_FUNCTION_CALL,`Inbound message is null or undefined.`,`unknown`);let t=e.version;return this.isDisposed?this.createResponseError(e.callRendererFunction?.functionCallId??`unknown`,L.DISPOSED,`RpcHandler has been disposed.`,t):e.callRendererFunction?.callFunction?null:this.createResponseError(e.callRendererFunction?.functionCallId??`unknown`,L.INVALID_FUNCTION_CALL,`Malformed message: missing callRendererFunction or callFunction.`,t)}resolveFunctionImplementation(e,t,n,r){let i;if(e){let r=n?.surface?.availableCatalogs?.get(e),a=this.catalogs.find(t=>t.id===e);if(i=typeof r?.functions?.get(t)?.execute==`function`?r:a??r,!i)return{error:`Catalog not found: ${e}`}}if(!i)return{error:`No catalog available for function resolution.`};if(i.protocolVersion&&r&&!Ed(i.protocolVersion,r))return{error:`Catalog '${i.id}' specification version (${i.protocolVersion}) does not match message protocol version (${r}).`};let a=i.functions?.get(t);return a?{funcImpl:a,catalog:i}:{error:`Function not found: ${t}`}}ensureDataContext(e,t,n){if(e instanceof wi&&e.surface)return e;let r=/* @__PURE__ */ new Map;for(let e of this.catalogs)t.protocolVersion&&e.protocolVersion&&Ed(t.protocolVersion,e.protocolVersion)&&r.set(e.id,e);return r.set(t.id,t),new wi(new Wu(`_rpc_fallback_${n||`default`}`,t,r),`/`)}resolveDynamicArguments(e,t,n){if(e===void 0||typeof e!=`object`||!e||Array.isArray(e))return{args:e};let r={},i,a=t.surface?.onError.subscribe(e=>{!i&&e?.code===`EXPRESSION_ERROR`&&(i=e.message||`An error occurred during function execution.`)});try{for(let[i,a]of Object.entries(e))Object.defineProperty(r,i,{value:ni(t,a,1,n,{allowAgentRouting:!1}),enumerable:!0,writable:!0,configurable:!0})}catch(e){i=this.extractErrorMessage(e)||`An error occurred during function execution.`}finally{a?.unsubscribe()}return i?{error:i}:{args:r}}checkExecutionPermissions(e,t,n){let r=e.allowedCallers??`rendererOnly`;return r!==`rendererOrAgent`&&r!==`agentOnly`?`Function '${t}' cannot be called by agent (allowedCallers is ${r}).`:e.requiresUserActivation&&!n?`Function '${t}' requires user activation context to execute.`:null}parseArguments(e,t,n,r){try{return{args:new ff(e,{allowUnknownElements:!1}).validateFunction(r,n)}}catch(e){return{error:`Invalid function arguments for '${r}': ${this.extractErrorMessage(e)}`}}}async executeFunctionSafely(e,t,n,r,i){let a=i||`1.0`;try{let i=await Promise.resolve(e.execute(t,n)),o=hn(i)?gn(i):i;return{version:a,rendererFunctionResponse:{functionCallId:r,value:o===void 0?null:o}}}catch(e){let t=this.extractErrorMessage(e);return{version:a,rendererFunctionResponse:{functionCallId:r,error:{code:L.EXECUTION_ERROR,message:t||`An error occurred during function execution.`}}}}}generateFunctionCallId(){if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=Math.random().toString(36).substring(2,15).padEnd(13,`0`);return`call-${Date.now()}-${e}`}dispatchAgentCall(e,t){let{functionCallId:n,call:r,effectiveTimeoutMs:i,version:a}=t;return new Promise((t,o)=>{let s,c=()=>{s&&=(clearTimeout(s),void 0),this.pendingAgentCalls.delete(n)},l=(r[`@call`]??r.call)||`unknown`;s=this.createTimeoutTimer(n,l,i,c,o),this.pendingAgentCalls.set(n,{surfaceId:e,resolve:e=>{c(),t(e)},reject:e=>{c(),o(e)}}),this.sendOutboundMessage(e,n,r,a,c,o)})}createTimeoutTimer(e,t,n,r,i){if(!(n<=0))return setTimeout(()=>{this.pendingAgentCalls.delete(e)&&(r(),i(new wn(`Agent function call '${t}' timed out after ${n}ms.`,L.TIMEOUT,e)))},n)}sendOutboundMessage(e,t,n,r,i,a){let{call:o,"@call":s,...c}=n,l={"@call":s??o,...c},u={version:r||`1.0`,callAgentFunction:{surfaceId:e,functionCallId:t,callFunction:l}};try{let e=this.outboundListener(u);e&&typeof e.catch==`function`&&e.catch(e=>{i(),a(e)})}catch(e){i(),a(e)}}extractErrorMessage(e){return e instanceof Error?e.message:String(e)}createResponseError(e,t,n,r){return{version:r||`1.0`,rendererFunctionResponse:{functionCallId:e,error:{code:t,message:n}}}}};function jf(e,t){let n=mr(t);if(!n)return;let r={name:e.name,surfaceId:e.surfaceId,sourceComponentId:e.sourceComponentId,timestamp:e.timestamp,context:e.context,...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.catalogId===void 0?{}:{catalogId:e.catalogId},...e.metadata===void 0?{}:{metadata:e.metadata}};if(R(n,`1.0`))return{version:`1.0`,action:r};if(n===`0.9`||n===`0.9.1`)return{version:n===`0.9.1`?`v0.9.1`:`v0.9`,action:r}}var Mf=class{constructor(e,t,n){this.actionHandler=t,this.disposed=!1,this.graphBounds=/* @__PURE__ */ new WeakMap;let r=n?.maxAgentCallCacheEntries;if(r!==void 0&&(typeof r!=`number`||!Number.isInteger(r)||r<1))throw RangeError(`maxAgentCallCacheEntries must be a positive integer.`);if(n?.unifiedOutbound&&!n?.outboundListener)throw new P(`unifiedOutbound requires an outboundListener in MessageProcessorOptions.`);this.maxAgentCallCacheEntries=r,this.registeredCatalogs=[...e],this.model=new Xu,this.adapterRegistry=n?.adapterRegistry??of,this.defaultVersion=n?.version,this.errorHandler=n?.errorHandler,this.reportErrorsOnly=n?.reportErrorsOnly??!1,this.outboundListener=n?.outboundListener,this.unifiedOutbound=!!n?.unifiedOutbound,this.rpc=new Af({catalogs:this.registeredCatalogs,outboundListener:n?.outboundListener,defaultTimeoutMs:n?.defaultTimeoutMs}),this.hasOutboundListener=!!n?.outboundListener,this.validationConfig=n?.validationConfig?Ff(n.validationConfig):void 0,this.unifiedOutbound&&this.model.onAction.subscribe(e=>{this.forwardAction(e)}),this.actionHandler&&this.model.onAction.subscribe(this.actionHandler),this.model.onSurfaceDeleted.subscribe(e=>{this.rpc.cancelSurfaceCalls(e)})}get catalogs(){return[...this.registeredCatalogs]}addCatalog(e){if(this.registeredCatalogs.some(t=>t.id===e.id))throw new I(`Catalog already registered: ${e.id}`);this.registeredCatalogs.push(e)}callAgentFunction(e,t,n){return this.rpc.callAgentFunction(e,t,n)}dispose(){this.disposed=!0,this.model.dispose(),this.rpc.dispose()}getRendererCapabilities(e){let t=e?.versions??(e?.version?[e.version]:void 0);if(!t||t.length===0)throw new P(`At least one protocol version must be provided in CapabilitiesOptions to generate renderer capabilities.`);let n={};for(let r of t){let t={supportedCatalogIds:this.registeredCatalogs.map(e=>e.id)},i=e?.includeInlineCatalogs?this.registeredCatalogs.map(t=>_r(r,`1.0`)>=0?this.generateInlineCatalog(t):this.generateV09InlineCatalog(t,e?.componentEnvelopeRef??`common_types.json#/$defs/ComponentCommon`)):void 0;i&&(t.inlineCatalogs=i),n[r]=t}return n}getClientCapabilities(e){let t=e?.versions&&e.versions.length>0?e.versions:[e?.version??`v0.9`];return this.getRendererCapabilities({...e,versions:t})}generateInlineCatalog(e){let t=e.toJson();return t.catalogId=e.id,t.protocolVersion=(typeof t.protocolVersion==`string`?t.protocolVersion:mr(e.protocolVersion)??e.protocolVersion).trim().replace(/^[vV](?=\d)/,``),t}generateV09InlineCatalog(e,t=`common_types.json#/$defs/ComponentCommon`){let n={};for(let[r,i]of e.components.entries()){let e={},a=[];if(i.schema&&typeof i.schema==`object`&&`safeParse`in i.schema){let t=Oo(i.schema,{target:`jsonSchema2019-09`,$refStrategy:`none`,override:jo});Rc(t,void 0,{stripAdditionalProperties:!0}),e=t.properties||{},a=Array.isArray(t.required)?t.required.filter(e=>e!==`component`&&e!==`id`):[]}let{component:o,id:s,...c}=e;n[r]={allOf:[{$ref:t},{properties:{component:{const:r},...c},required:[`component`,...a]}]}}let r=[];for(let t of e.functions.values()){let e={type:`object`,properties:{}};if(t.schema&&typeof t.schema==`object`&&`safeParse`in t.schema){let n=Oo(t.schema,{target:`jsonSchema2019-09`,$refStrategy:`none`,override:jo});Rc(n,void 0,{stripAdditionalProperties:!0}),e=n}r.push({name:t.name,...t.description?{description:t.description}:{},returnType:t.returnType,parameters:e})}let i;if(e.themeSchema){let t=Oo(e.themeSchema,{target:`jsonSchema2019-09`,$refStrategy:`none`,override:jo});Rc(t,void 0,{stripAdditionalProperties:!0}),i=t.properties||void 0}return{catalogId:e.id,...Object.keys(n).length>0?{components:n}:{},...r.length>0?{functions:r}:{},...i?{theme:i}:{}}}getRendererDataModel(e){let t=Array.from(this.model.surfacesMap.values()).filter(e=>e.sendDataModel);if(t.length===0)return;if(e!==void 0){let n={};for(let r of t){let t=r.protocolVersion;(!t||Ed(t,e))&&(n[r.id]=r.dataModel.get(`/`))}return Object.keys(n).length===0?void 0:{version:e,surfaces:n}}let n=/* @__PURE__ */ new Set;for(let e of t)if(e.protocolVersion){let t=mr(e.protocolVersion),r=t?_r(t,`1.0`)>=0?t:`v${t}`:e.protocolVersion;n.add(r)}if(n.size>1)throw new P(`Multiple protocol versions detected among active surfaces: ${Array.from(n).sort().join(`, `)}. Specify a target protocol version in getRendererDataModel(version).`);let r=n.size===1?n.values().next().value:`1.0`,i={};for(let e of t)i[e.id]=e.dataModel.get(`/`);return{version:r,surfaces:i}}getClientDataModel(e){return this.getRendererDataModel(e)}resolvePath(e,t){return kn.resolvePath(e,t)}getSurfaces(){return this.model.surfacesMap}getSurface(e){return this.model.getSurface(e)}onSurfaceCreated(e){return this.model.onSurfaceCreated.subscribe(e)}onSurfaceDeleted(e){return this.model.onSurfaceDeleted.subscribe(e)}processMessages(e,t){this.withValidationConfig(t,()=>{let n=ed(Array.isArray(e)?e[0]:e,this.defaultVersion),r=n;try{let i=this.prepareOperations(e,e=>{r=e});for(let e of i)r=this.contextFromOperation(e,n),this.processOperation(e,t)}catch(e){if(this.handleProcessingError(e,r),!this.reportErrorsOnly)throw e}})}processMessagesWithErrors(e,t){return this.withValidationConfig(t,()=>{let n=Array.isArray(e)?e:[e],r=[];for(let e of n){let n=ed(e,this.defaultVersion),i=n;try{let r=this.prepareOperations(e,e=>{i=e});for(let e of r)i=this.contextFromOperation(e,n),this.processOperation(e,t)}catch(e){r.push(this.handleProcessingError(e,i))}}return r})}async processMessagesAsync(e,t){let n=ed(Array.isArray(e)?e[0]:e,this.defaultVersion),r=n;try{let i=this.withValidationConfig(t,()=>this.prepareOperations(e,e=>{r=e})),a=[];for(let e of i){r=this.contextFromOperation(e,n);let i=await this.processOperationAsync(e,t);i&&a.push(i)}return a}catch(e){if(this.handleProcessingError(e,r),!this.reportErrorsOnly)throw e;return[]}}contextFromOperation(e,t){let n=e.envelopeContext??t,r=`surfaceId`in e&&e.surfaceId?e.surfaceId:n.surfaceId,i=`functionCallId`in e&&e.functionCallId?e.functionCallId:n.functionCallId,a=`version`in e?e.version:void 0,o=r?this.model.getSurface(r)?.protocolVersion:void 0;return{surfaceId:r,functionCallId:i,actionType:e.type,version:a??o??n.version??this.defaultVersion}}handleProcessingError(e,t){let n=sd(e,t),r={code:n.error.code,message:n.error.message,surfaceId:n.error.surfaceId,details:e instanceof P?e.details:void 0},i=n.error.surfaceId?this.model.getSurface(n.error.surfaceId):void 0;i?i.dispatchError(r):this.model.emitError(r),this.errorHandler?.(n);let a=t.actionType===`beginRendering`||t.actionType===`surfaceUpdate`||t.actionType===`dataModelUpdate`,o=t.version??(a?`v0.8`:this.fallbackWireVersion()),s=o===t.version?n:sd(e,{...t,version:o});return this.unifiedOutbound&&_r(s.version,`0.8`)!==0&&this.invokeOutboundListener(s),n}fallbackWireVersion(){return this.defaultVersion&&mr(this.defaultVersion)?this.defaultVersion:this.registeredCatalogs.length>0&&this.registeredCatalogs.every(e=>e.protocolVersion!==void 0&&_r(e.protocolVersion,`0.8`)===0)?`v0.8`:this.registeredCatalogs.length>0&&this.registeredCatalogs.every(e=>e.protocolVersion!==void 0&&R(e.protocolVersion,`1.0`))?`1.0`:`v0.9`}forwardAction(e){if(this.disposed||!this.outboundListener)return;let t=jf(e,this.model.getSurface(e.surfaceId)?.protocolVersion??this.fallbackWireVersion());t&&this.invokeOutboundListener(t)}invokeOutboundListener(e){if(!this.disposed&&this.outboundListener)try{let t=this.outboundListener(e);t&&typeof t.catch==`function`&&t.catch(()=>{})}catch{}}extractSingleMessageOperations(e){let t=ed(e,this.defaultVersion),n;try{n=this.adapterRegistry.resolveFromPayload(e)}catch(t){if(this.isImplicitV09Payload(e)){let e=this.catalogs.some(e=>e.protocolVersion===`0.9.1`||e.protocolVersion===`v0.9.1`);n=this.adapterRegistry.getAdapter(e?`v0.9.1`:`v0.9`)}else throw t}let r=n.extractOperations(e,this.validationConfig),i=t.version;for(let e of r)i&&mr(i)&&(`version`in e&&e.version||(e.version=i)),e.envelopeContext=t;return r}withValidationConfig(e,t){let n=e?.validationConfig;if(!n)return t();let r=this.validationConfig;this.validationConfig=Ff(n);try{return t()}finally{this.validationConfig=r}}prepareSingleItem(e,t){return t?.(ed(e,this.defaultVersion)),this.validationConfig&&Vu(e),this.validationConfig?.targetVersion&&this.validateTargetVersion(e),$d(e)?[e]:this.extractSingleMessageOperations(e)}prepareOperations(e,t){return!e||Array.isArray(e)&&e.length===0?[]:Array.isArray(e)?e.flatMap(e=>this.prepareSingleItem(e,t)):this.prepareSingleItem(e,t)}isImplicitV09Payload(e){if(this.validationConfig||this.catalogs.length===0||this.catalogs.some(e=>R(e.protocolVersion,`1.0`)))return!1;let t=Array.isArray(e)?e[0]:e;return typeof t==`object`&&t&&`messages`in t&&Array.isArray(t.messages)&&(t=t.messages[0]),typeof t!=`object`||!t||`version`in t?!1:[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`].some(e=>e in t)}validateTargetVersion(e){let t=this.validationConfig?.targetVersion;if(!t)return;let n=e=>{if(typeof e==`object`&&e&&`version`in e){let n=e.version;if(n&&(mr(n)??n)!==(mr(t)??t))throw new P(`Message version '${n}' does not match expected target version '${t}'`)}};if(Array.isArray(e))for(let t of e)n(t);else n(e)}applyStateOperation(e){if(this.validationConfig?.allowedMessages&&!this.validationConfig.allowedMessages.includes(e.type))throw new P(`Operation '${e.type}' is not permitted by ValidationConfig.allowedMessages`);switch(e.type){case`createSurface`:this.processCreateSurfaceOp(e);break;case`deleteSurface`:this.processDeleteSurfaceOp(e);break;case`updateComponents`:this.processUpdateComponentsOp(e);break;case`updateDataModel`:this.processUpdateDataModelOp(e);break;case`agentFunctionResponse`:this.rpc.handleAgentFunctionResponse({version:e.version??`1.0`,agentFunctionResponse:{functionCallId:e.functionCallId,value:e.value,error:e.error}})}}resolveRpcDataContext(e){if(e.surfaceId!==void 0){let t=this.model.surfacesMap.get(e.surfaceId);return t?new wi(t,`/`):void 0}let t=e.catalogId?this.registeredCatalogs.find(t=>t.id===e.catalogId):void 0;if(!t)return;let n=`_rpc_fallback_${e.functionCallId||`default`}`,r=/* @__PURE__ */ new Map;for(let e of this.registeredCatalogs)t?.protocolVersion&&e.protocolVersion&&Ed(t.protocolVersion,e.protocolVersion)&&r.set(e.id,e);return t&&r.set(t.id,t),new wi(new Wu(n,t,r,void 0,void 0,void 0,void 0,void 0,void 0,this.maxAgentCallCacheEntries),`/`)}processOperation(e,t){if(e.type===`callRendererFunction`){let n=this.resolveRpcDataContext(e),r=t?.isUserActivated??e.isUserActivated??!1,i={version:e.version??`1.0`,callRendererFunction:{...e.surfaceId===void 0?{}:{surfaceId:e.surfaceId},functionCallId:e.functionCallId,callFunction:{"@call":e.call,catalogId:e.catalogId,args:e.args}}};this.rpc.handleCallRendererFunction(i,n,r).catch(t=>{console.error(`Unhandled error in callRendererFunction (${e.call}):`,t)})}else this.withValidationConfig(t,()=>this.applyStateOperation(e))}async processOperationAsync(e,t){if(e.type===`callRendererFunction`){let n=this.resolveRpcDataContext(e),r=t?.isUserActivated??e.isUserActivated??!1,i={version:e.version??`1.0`,callRendererFunction:{...e.surfaceId===void 0?{}:{surfaceId:e.surfaceId},functionCallId:e.functionCallId,callFunction:{"@call":e.call,catalogId:e.catalogId,args:e.args}}};return await this.rpc.handleCallRendererFunction(i,n,r)}return this.withValidationConfig(t,()=>this.applyStateOperation(e)),null}validateSurfaceTheme(e,t,n){if(!e||!t?.themeSchema)return e;try{return new ff(t,this.validationConfig).validateTheme(e)}catch(e){if(e instanceof P){let t=Array.isArray(e.details)?e.details.map(e=>typeof e==`object`&&e?{...e,surfaceId:n}:e):e.details;throw new P(e.message.replace(/^Validation failed for theme:/,`Validation failed for theme on surface '${n}':`),t,e.code,{path:e.path,surfaceId:n})}throw e}}processCreateSurfaceOp(e){let{surfaceId:t,catalogId:n,theme:r,sendDataModel:i,components:a,dataModel:o}=e,s=e.version,c=n===void 0&&s!==void 0&&R(s,`1.0`),l=c?void 0:Pf(this.registeredCatalogs,n,s);if(!l&&!c)throw n===void 0?new I(`No default catalog available for surface '${t}'.`,`CATALOG_ERROR`,{surfaceId:t}):new I(`Catalog not found: ${n}`,`CATALOG_ERROR`,{surfaceId:t});if(l?.protocolVersion&&s&&!Ed(l.protocolVersion,s)){let e=`Surface '${t}' catalog '${n??l.id}' specification version (${l.protocolVersion}) does not match message protocol version (${s}).`;throw R(s,`1.0`)?new I(e,`CATALOG_ERROR`,{surfaceId:t}):new P(e,void 0,`VALIDATION_ERROR`,{surfaceId:t})}if(this.model.getSurface(t))throw new Sn(`Surface ${t} already exists.`,void 0,`INTEGRITY_ERROR`,{surfaceId:t});let u=this.validateSurfaceTheme(r,l,t),d=s??l?.protocolVersion,f=new Wu(t,l,new Map(this.registeredCatalogs.filter(e=>Ed(e.protocolVersion,d)).map(e=>[e.id,e])),u,i??!1,void 0,e.rootId??`root`,e.metadata,d,this.maxAgentCallCacheEntries);this.hasOutboundListener&&R(f.protocolVersion,`1.0`)&&(f.agentFunctionCaller=e=>this.model.getSurface(t)===f?this.rpc.callAgentFunction(t,e,{version:f.protocolVersion}):Promise.reject(new wn(`Pending calls for surface '${t}' were cancelled.`,L.CANCELLED))),this.model.addSurface(f);try{if(o)for(let[e,n]of Object.entries(o)){let r=`/${e.replace(/~/g,`~0`).replace(/\//g,`~1`)}`;try{if(e===``){let e={...f.dataModel.get(`/`)??{}};n===void 0||n===null&&R(f.protocolVersion,`1.0`)?delete e[``]:e[``]=n,f.dataModel.set(`/`,e)}else f.dataModel.set(r,n)}catch(e){throw e instanceof bn&&!e.surfaceId&&(e.surfaceId=t),e}}a&&a.length>0&&this.processUpdateComponentsOp({type:`updateComponents`,surfaceId:t,components:a})}catch(e){throw this.model.deleteSurface(t),e}}processDeleteSurfaceOp(e){e.surfaceId&&this.model.deleteSurface(e.surfaceId)}validateComponentProperties(e,t){let{id:n,component:r}=e;if(typeof n!=`string`||!n)throw new P(`Component '${r}' is missing an 'id'; entries require a valid string 'id'.`);let i=this.resolveComponentCatalog(e,t);if(R(t.protocolVersion,`1.0`)){let{mixins:n}=Ea(e,this.componentLayout(e,t,i));Di(n.metadata?.value)}let a=t.componentsModel.get(n),o=!this.validationConfig&&!R(t.protocolVersion,`1.0`);new ff(i,this.validationConfig).validateComponent(this.componentPayloadForValidation(e,t,i),a?.type,{skipNestedFunctions:o}),o||this.validateNestedFunctionCalls(e,t,i)}componentPayloadForValidation(e,t,n){if(!R(t.protocolVersion,`1.0`))return e;let r=this.componentCatalogId(e,t);if(r!==void 0&&typeof r!=`string`)return e;let i=pa(`catalogId`),{[i]:a,...o}=e;return e[i]===void 0&&r!==void 0&&delete o.catalogId,n!==t.defaultCatalog&&(o[i]=n.id),o}componentCatalogId(e,t){if(!R(t.protocolVersion,`1.0`))return;let n=e[pa(`catalogId`)];if(n!==void 0)return n;let r=e.catalogId;if(r!==void 0)return this.componentLayout(e,t,t.defaultCatalog).customKeys.has(`catalogId`)?void 0:r}componentLayout(e,t,n){let r=wa(this.componentSchema(e,t,n));return n===t.defaultCatalog?r:Ta(r,e,this.componentSchema(e,t,t.defaultCatalog))}componentSchema(e,t,n){let{id:r,component:i}=e,a=typeof i==`string`&&i?i:typeof r==`string`?t.componentsModel.get(r)?.type:void 0;return a?n?.components.get(a)?.schema:void 0}resolveComponentCatalog(e,t){let{id:n,component:r}=e,i=`Component '${n}'`,a=R(t.protocolVersion,`1.0`),o=this.componentCatalogId(e,t);if(typeof o==`string`)return this.resolveSurfaceItemCatalog(t,o,i);if(!a){let e=typeof n==`string`?t.componentsModel.get(n):void 0;if(e&&(typeof r!=`string`||!r||r===e.type))return e.catalog}return this.resolveSurfaceItemCatalog(t,void 0,i)}validateSingleNestedCall(e,t,n,r,i){let a=e.catalogId;if(a!==void 0&&typeof a!=`string`)throw new P(lf(t),void 0,`VALIDATION_ERROR`,{path:i||void 0,surfaceId:n.id});let o=this.resolveNestedCallCatalog(n,a,t,i);df(a,r.id,{catalogIsDefault:r===n.defaultCatalog})||this.validateExternalCatalogFunction(o,t,e.args,n.id,i)}resolveNestedCallCatalog(e,t,n,r){try{return this.resolveSurfaceItemCatalog(e,t,`Function call '${n}'`)}catch(t){throw t instanceof yn&&(t.surfaceId=e.id,r&&(t.path=r)),t}}validateExternalCatalogFunction(e,t,n,r,i){try{R(e.protocolVersion,`1.0`)&&uf(e,t),new ff(e,this.validationConfig).validateFunction(t,n??{})}catch(e){throw e instanceof yn&&(e.surfaceId=r,i&&(e.path=e.path&&e.path!==`/`?`${i}${e.path}`:i)),e}}validateNestedFunctionCalls(e,t,n){if(!R(t.protocolVersion,`1.0`))return;let r=(e,i)=>{if(Array.isArray(e)){for(let t=0;t<e.length;t++)r(e[t],`${i}/${t}`);return}if(typeof e!=`object`||!e)return;let a=e,o=a[`@call`];typeof o==`string`&&!o.startsWith(`@`)&&this.validateSingleNestedCall(a,o,t,n,i);for(let[e,t]of Object.entries(a))r(t,`${i}/${e}`)},{properties:i,mixins:a}=Ea(e,this.componentLayout(e,t,n));for(let[e,t]of Object.entries(i))r(t,`/${e}`);for(let e of[a.accessibility,a.checks])e&&r(e.value,`/${e.wireKey}`)}resolveSurfaceItemCatalog(e,t,n){if(t!==void 0&&!e.availableCatalogs.has(t)){let r=this.registeredCatalogs.find(e=>e.id===t);if(r&&!Ed(r.protocolVersion,e.protocolVersion))throw new I(`${n} names catalog '${t}', whose specification version (${r.protocolVersion}) does not match surface '${e.id}' version (${e.protocolVersion}).`)}return e.resolveCatalog(t,n)}applyComponentUpdate(e,t){let{id:n,component:r}=e;if(typeof n!=`string`)return;let i=this.resolveComponentCatalog(e,t),a=Da(e,t.protocolVersion,this.componentSchema(e,t,i),{defaultCatalogSchema:this.componentSchema(e,t,t.defaultCatalog)}),o=a.properties,s=Nf(a.metadata),c=t.componentsModel.get(n);if(c){let e=typeof r==`string`?r:c.type;if(e!==c.type||c.catalog.id!==i.id){t.componentsModel.removeComponent(n);let r=new Zu(n,e,o,i,s);t.componentsModel.addComponent(r)}else mn(()=>{c.applyUpdate(o,s)})}else{if(typeof r!=`string`||!r)throw new P(`Cannot create component ${n} without a type.`);let e=new Zu(n,r,o,i,s);t.componentsModel.addComponent(e)}}rebaseComponentValidationError(e,t,n){if(e instanceof yn&&(e.surfaceId||=n,e instanceof P&&(e.path=e.path&&e.path!==`/`?`/components/${t}${e.path}`:`/components/${t}`,Array.isArray(e.details))))for(let t of e.details)typeof t==`object`&&t&&!(`surfaceId`in t)&&(t.surfaceId=n)}validateComponentsBatch(e,t){let n=/* @__PURE__ */ new Set;for(let r=0;r<e.components.length;r++){let i=e.components[r];if(i&&typeof i==`object`&&typeof i.id==`string`){if(n.has(i.id))throw new Sn(`Duplicate component ID: '${i.id}'`,[i.id],`INTEGRITY_ERROR`,{surfaceId:e.surfaceId,path:`/components/${r}/id`});n.add(i.id)}try{this.validateComponentProperties(i,t)}catch(t){throw this.rebaseComponentValidationError(t,r,e.surfaceId),t}}}validateSurfaceComponentGraph(e,t){try{return fd(t,e.components,this.validationConfig,(e,t)=>this.resolveComponentCatalog(e,t),this.graphBounds)}catch(t){throw t instanceof yn&&!t.surfaceId&&(t.surfaceId=e.surfaceId),t}}processUpdateComponentsOp(e){if(!e.surfaceId)return;let t=this.model.getSurface(e.surfaceId);if(!t)throw new Sn(`Surface not found for message: ${e.surfaceId}`,void 0,`INTEGRITY_ERROR`,{surfaceId:e.surfaceId});this.validateComponentsBatch(e,t);let n=this.validateSurfaceComponentGraph(e,t);mn(()=>{for(let n of e.components)this.applyComponentUpdate(n,t)}),n&&pd(t.componentsModel,n,this.graphBounds)}processUpdateDataModelOp(e){if(!e.surfaceId)return;let t=this.model.getSurface(e.surfaceId);if(!t)throw new Sn(`Surface not found for message: ${e.surfaceId}`,void 0,`INTEGRITY_ERROR`,{surfaceId:e.surfaceId});if(e.path!==void 0&&e.path!==``&&(!e.path.startsWith(`/`)||!Iu.test(e.path))){let t=`Invalid path syntax: '${e.path}' (path must be a valid RFC 6901 JSON Pointer starting with '/')`;throw new P(t,[{path:`/path`,code:`invalid_value`,message:t,surfaceId:e.surfaceId}],`VALIDATION_ERROR`,{path:`/path`,surfaceId:e.surfaceId})}let n=e.path||`/`,r=e.value;try{t.dataModel.set(n,r)}catch(t){throw t instanceof bn&&!t.surfaceId&&(t.surfaceId=e.surfaceId),t}}};function Nf(e){if(e&&typeof e==`object`&&!Array.isArray(e))return e}function Pf(e,t,n){return t===void 0?e.find(e=>!n||Ed(e.protocolVersion,n))??e[0]:e.find(e=>e.id===t)}function Ff(e){return{allowOrphanComponents:!1,allowDanglingReferences:!1,allowMissingRoot:!1,allowUnknownElements:!1,...e}}var If=class{constructor(e,t,n=`/`,r,i){let a=e.componentsModel.get(t);if(!a)throw new xn(`Component not found: ${t}`);this.componentModel=a,this.surfaceComponents=e.componentsModel,this.theme=e.theme,this.dataContext=new wi(e,n,i,r),this._actionDispatcher=(t,n)=>e.dispatchAction(t,this.componentModel.id,n)}dispatchAction(e,t){return this._actionDispatcher(e,t)}},Lf=Object.freeze({type:`STATIC`});function Rf(e){switch(e.type){case`STATIC`:return!1;case`DYNAMIC`:case`ACTION`:case`STRUCTURAL`:case`CHECKABLE`:return!0;case`ARRAY`:return!!e.templateFallback||Rf(e.element);case`OBJECT`:return e.catchall!==void 0&&Rf(e.catchall)||Object.values(e.shape).some(Rf)}}var zf={},Bf=/* @__PURE__ */ new WeakMap,Vf=/* @__PURE__ */ new WeakMap;function Hf(e,t){let n=t??zf,r=e.get(n);return r||(r=/* @__PURE__ */ new WeakMap,e.set(n,r)),r}function Uf(e,t){return t&&t.type!==`STATIC`?{type:`OBJECT`,shape:e,catchall:t}:{type:`OBJECT`,shape:e}}function Wf(e){if(e)return R(e,`1.0`)?Io:R(e,`0.9`)?Po:Mo}function Gf(e,t,n){let r={...t};for(let[t,i]of Ol(e,n))if(i.kind===`single`)r[t]?.type===`DYNAMIC`&&(r[t]=Lf);else if(i.kind===`list`&&r[t]?.type!==`STRUCTURAL`){let e=r[t];r[t]=e?.type===`ARRAY`&&Rf(e.element)?{type:`ARRAY`,element:e.element,templateFallback:!0}:{type:`STRUCTURAL`}}else i.kind!==`nested`||Object.hasOwn(r,t)&&r[t]?.type!==`STATIC`||(r[t]={type:`STRUCTURAL`});let i=Cp(Vn,/* @__PURE__ */ new Set,n);return Object.hasOwn(r,`accessibility`)||(r.accessibility=i),Object.hasOwn(r,Kf)||(r[Kf]=i),Object.hasOwn(r,qf)||(r[qf]={type:`CHECKABLE`}),r}var Kf=`@accessibility`,qf=`@checks`;function Jf(e,t){if(!e)return{type:`STATIC`};let n=Hf(Bf,t),r=n.get(e);if(r)return r;let i=Cp(e,/* @__PURE__ */ new Set,t),a=i.type===`OBJECT`?Uf(Gf(e,i.shape,t),i.catchall):i;return n.set(e,a),a}function Yf(e,t){if(!e)return Uf(Gf(void 0,{},t));let n=Hf(Vf,t),r=n.get(e);if(r)return r;let i=Jf(e,t),a=i.type===`OBJECT`?i:Uf(Gf(e,{},t));return n.set(e,a),a}function Xf(e,t=/* @__PURE__ */ new Set){let n=W(e);if(n.firstRefDefName)return n.firstRefDefName;for(let e of n.traversed)if(t.has(e))return``;if(n.schema?._def?.typeName===`ZodPipeline`){let e=new Set(t);for(let t of n.traversed)e.add(t);let r=n.schema._def,i=Xf(r.in,e);if(i)return i;if(!W(r.in).hasTransform)return Xf(r.out,e)}return``}function Zf(e,t,n=/* @__PURE__ */ new Set){let r=W(e);if(r.refs.has(t))return!0;for(let e of r.traversed)if(n.has(e))return!1;if(r.schema?._def?.typeName===`ZodPipeline`){let e=new Set(n);for(let t of r.traversed)e.add(t);let i=r.schema._def;if(Zf(i.in,t,e))return!0;if(!W(i.in).hasTransform)return Zf(i.out,t,e)}return!1}function Qf(e,t,n=/* @__PURE__ */ new Set){let r=W(e);for(let e of r.traversed)if(n.has(e))return!1;if(r.schema?._def?.typeName===`ZodPipeline`){let e=new Set(n);for(let t of r.traversed)e.add(t);let i=r.schema._def;return Qf(i.in,t,e)?!0:!W(i.in).hasTransform||Dl(i.in)?Qf(i.out,t,e):!1}return t(r.schema)}function $f(e,t){if(Zf(e,`component-id`))return!0;let n=Xf(e);return n===`ComponentId`||n===`Child`||!!(n&&t?.childRefNames?.has(n))}function ep(e,t){let n=t?.firstRefDefName||Xf(e);return n===`Checkable`||n===`CheckRule`||Qf(e,e=>e?._def?.typeName===`ZodArray`&&Xf(e._def.type)===`CheckRule`)}function tp(e){return Xf(e)===`Action`||Qf(e,e=>{if(e?._def?.typeName!==`ZodObject`)return!1;let t=e.shape,n=Object.keys(t);return n.length===1&&(n[0]===`event`||n[0]===`functionCall`)})}function np(e,t){let n=Xf(e);return n===`DataBinding`||n===`FunctionCall`||n.startsWith(`Dynamic`)?!0:Qf(e,e=>{if(e?._def?.typeName!==`ZodObject`)return!1;let n=e.shape,r=Cl(e)||Object.values(n).some(e=>$f(e,t));return(Object.hasOwn(n,`@path`)||Object.hasOwn(n,`path`)||Object.hasOwn(n,`@call`)||Object.hasOwn(n,`call`))&&!r})}function rp(e,t){let n=Xf(e);return Zf(e,`child-list`)||n===`ChildList`||n&&t?.childListRefNames?.has(n)?!0:Qf(e,e=>Cl(e))}function ip(e){return Qf(e,e=>e?._def?.typeName===`ZodArray`)}function ap(e,t){return Qf(e,e=>{if(e?._def?.typeName!==`ZodObject`)return!1;let n=e.shape;return Object.values(n).some(e=>$f(e,t))})}function op(e,t){return e===`DataBinding`||e===`FunctionCall`||e.startsWith(`Dynamic`)&&t!==`ZodObject`&&t!==`ZodArray`}function sp(e){return Qf(e,e=>{let t=e?._def?.typeName;return t===`ZodBoolean`||t===`ZodNull`||t===`ZodUndefined`})}function cp(e,t=/* @__PURE__ */ new Set){let n=[];for(let r of e){let e=W(r),i=!1;for(let n of e.traversed)if(t.has(n)){i=!0;break}if(i)continue;let a=new Set(t);for(let t of e.traversed)a.add(t);if(!e.firstRefDefName&&e.refs.size===0){let t=Sl(e.schema);if(t){n.push(...cp(t,a));continue}if(e.schema?._def?.typeName===`ZodPipeline`){let t=e.schema._def,r=W(t.in),i=r.schema?._def?.typeName;if(!r.hasTransform&&(i===`ZodAny`||i===`ZodUnknown`)){n.push(...cp([t.out],a));continue}}}n.push(r)}return n}function lp(e){return Qf(e,e=>e?._def?.typeName===`ZodBoolean`)}function up(e,t){let n=cp(e);if(n.some(tp))return{type:`ACTION`};if(n.some(e=>np(e,t))){let e=n.filter(e=>np(e,t)),r=n.filter(e=>!np(e,t)),i=e.some(e=>{let t=Xf(e);return t.startsWith(`Dynamic`)&&t!==`DynamicBoolean`}),a=e.some(e=>Xf(e)===`DynamicBoolean`||Su(e))||r.some(lp);return!i&&a&&r.every(sp)?{type:`DYNAMIC`,isBoolean:!0}:{type:`DYNAMIC`}}if(n.some(e=>rp(e,t))||n.some(ip)&&n.some(e=>ap(e,t)))return{type:`STRUCTURAL`}}function dp(e,t){return e===Lf?Lf:e.type===`STATIC`?t:e.type===`OBJECT`||e.type===`ARRAY`||e.type===`DYNAMIC`?pp(e,t):e}var fp={ACTION:5,CHECKABLE:4,STRUCTURAL:3,ARRAY:2,OBJECT:2,DYNAMIC:1,STATIC:0};function pp(e,t){if(e.type===`STATIC`&&t.type===`STATIC`)return e===Lf||t===Lf?Lf:{type:`STATIC`};if(e.type===`STATIC`)return t;if(t.type===`STATIC`)return e;if(e.type===`OBJECT`&&t.type===`OBJECT`){let n=/* @__PURE__ */ new Set([...Object.keys(e.shape),...Object.keys(t.shape)]),r={};for(let i of n){let n=Object.hasOwn(e.shape,i),a=Object.hasOwn(t.shape,i),o;n&&a?o=pp(e.shape[i],t.shape[i]):n?o=t.catchall?dp(e.shape[i],t.catchall):e.shape[i]:a&&(o=e.catchall?dp(t.shape[i],e.catchall):t.shape[i]),o!==void 0&&(r[i]=o)}return Uf(r,e.catchall&&t.catchall?pp(e.catchall,t.catchall):e.catchall??t.catchall)}if(e.type===`ARRAY`&&t.type===`ARRAY`){let n=pp(e.element,t.element);return e.templateFallback&&t.templateFallback?{type:`ARRAY`,element:n,templateFallback:!0}:{type:`ARRAY`,element:n}}return e.type===`DYNAMIC`&&t.type===`DYNAMIC`?e.isBoolean||t.isBoolean?{type:`DYNAMIC`,isBoolean:!0}:{type:`DYNAMIC`}:!Rf(e)&&Rf(t)?t:!Rf(t)&&Rf(e)?e:fp[t.type]>fp[e.type]?t:e}function mp(e,t){if(e.type===t.type){if(e.type===`OBJECT`&&t.type===`OBJECT`)return hp([e,t]);if(e.type===`ARRAY`&&t.type===`ARRAY`){let n=mp(e.element,t.element);return e.templateFallback||t.templateFallback?{type:`ARRAY`,element:n,templateFallback:!0}:{type:`ARRAY`,element:n}}return e.type===`DYNAMIC`&&t.type===`DYNAMIC`?e.isBoolean&&t.isBoolean?{type:`DYNAMIC`,isBoolean:!0}:{type:`DYNAMIC`}:e===Lf||t===Lf?Lf:e}return e.type===`STRUCTURAL`&&t.type===`ARRAY`?Rf(t.element)?{type:`ARRAY`,element:t.element,templateFallback:!0}:{type:`STRUCTURAL`}:e.type===`ARRAY`&&t.type===`STRUCTURAL`?Rf(e.element)?{type:`ARRAY`,element:e.element,templateFallback:!0}:{type:`STRUCTURAL`}:e.type===`STATIC`?t.type===`DYNAMIC`?{type:`DYNAMIC`}:t:t.type===`STATIC`?e.type===`DYNAMIC`?{type:`DYNAMIC`}:e:{type:`STATIC`}}function hp(e){let t=/* @__PURE__ */ new Set;for(let n of e)for(let e of Object.keys(n.shape))t.add(e);let n={};for(let r of t){let t,i=!1;for(let n of e)if(Object.hasOwn(n.shape,r)){let e=n.shape[r];e===Lf&&(i=!0),t=t===void 0?e:mp(t,e)}t!==void 0&&(n[r]=t.type===`STATIC`&&i?Lf:t)}let r;if(e.some(e=>e.catchall!==void 0))for(let t of e){let e=t.catchall??{type:`STATIC`};r=r===void 0?e:mp(r,e)}return Uf(n,r)}function gp(e,t,n=/* @__PURE__ */ new Set){if(!e)return!0;let r=W(e);for(let e of r.traversed)if(n.has(e))return!0;let i=new Set(n);for(let e of r.traversed)i.add(e);let a=r.schema;switch(a?._def?.typeName){case`ZodObject`:{let e=a.shape;if(Object.hasOwn(e,t))return!0;let n=a._def;return n.unknownKeys===`passthrough`||!!(n.catchall&&n.catchall._def?.typeName!==`ZodNever`)}case`ZodIntersection`:{let e=a._def;return gp(e.left,t,i)&&gp(e.right,t,i)}case`ZodPipeline`:{let e=a._def,n=W(e.in);return n.hasTransform?(n.schema?._def?.typeName!==`ZodObject`||gp(e.in,t,i))&&gp(e.out,t,i):gp(e.in,t,i)&&gp(e.out,t,i)}case`ZodUnion`:case`ZodDiscriminatedUnion`:return(Sl(a)??[]).some(e=>gp(e,t,i));default:return!0}}function _p(e,t=/* @__PURE__ */ new Set){return gp(e,`__a2ui_unknown_key_probe__`,t)}function vp(e){if(!e)return;let t=W(e).schema;return t?._def?.typeName===`ZodArray`?t._def.type:void 0}function yp(e,t,n,r,i=!1){if(e.type===`OBJECT`){let a={};for(let[o,s]of Object.entries(e.shape))(i||gp(t,o,r))&&gp(n,o,r)&&(a[o]=s);return Uf(a,e.catchall&&(i||_p(t,r))&&_p(n,r)?e.catchall:void 0)}if(e.type===`ARRAY`){let a=yp(e.element,vp(t),vp(n),r,i);return e.templateFallback?{type:`ARRAY`,element:a,templateFallback:!0}:{type:`ARRAY`,element:a}}return e}function bp(e,t,n,r){let i=W(e),a=Cp(e,n,r),o=Cp(t,n,r);return i.hasTransform?!Dl(e)&&!Rf(a)?a:yp(a.type===`OBJECT`||a.type===`ARRAY`||!Rf(a)?pp(a,o):a,e,t,n,!0):yp(pp(a,o),e,t,n)}function xp(e,t,n){let r=cp(e).filter(e=>{let t=W(e).schema?._def?.typeName;return t!==`ZodNull`&&t!==`ZodUndefined`});if(r.length===0)return{type:`STATIC`};let i=r.map(e=>Cp(e,t,n));if(i.every(e=>e.type===`OBJECT`))return hp(i);let a=i.filter(e=>e.type===`ARRAY`);if(a.length>0&&i.every(e=>e.type===`ARRAY`||e.type===`STATIC`)){let e=a.slice(1).reduce((e,t)=>mp(e,t),a[0]);return Rf(e)?e:{type:`STATIC`}}return{type:`STATIC`}}function Sp(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let e=Cp(a,t,n);r[i]=e.type===`STATIC`&&El(i,a,n)?Lf:e}return r}function Cp(e,t=/* @__PURE__ */ new Set,n,r=!1){if(!e)return{type:`STATIC`};let i=W(e);for(let e of i.traversed)if(t.has(e))return{type:`STATIC`};let a=new Set(t);for(let e of i.traversed)a.add(e);let o=i.firstRefDefName||Xf(e);if(ep(e,i))return{type:`CHECKABLE`};if(o===`Action`)return{type:`ACTION`};let s=i.schema;if(!s?._def)return{type:`STATIC`};let c=Sl(s),l=(i.refs.has(`child-list`)||Zf(e,`child-list`)||o===`ChildList`||!!(o&&n?.childListRefNames?.has(o)))&&Tl(e,n);if(!c&&l)return{type:`STRUCTURAL`};let u=s._def.typeName;if(op(o,u))return Su(e)||o===`DynamicBoolean`?{type:`DYNAMIC`,isBoolean:!0}:{type:`DYNAMIC`};if(u===`ZodPipeline`){let e=s._def,t=bp(e.in,e.out,a,n);return t.type===`STRUCTURAL`&&!Tl(s,n)?{type:`STATIC`}:t}if(u===`ZodIntersection`){let e=s._def,t=pp(Cp(e.left,a,n,r),Cp(e.right,a,n,r));return t.type===`STRUCTURAL`&&!Tl(s,n)?{type:`STATIC`}:t}if(c){let e=up(c,n)??(l?{type:`STRUCTURAL`}:void 0);if(e){if(e.type===`STRUCTURAL`){let e=cp(c),t;for(let r of e)if(!rp(r,n)&&ip(r)){let e=Cp(r,a,n);e.type===`ARRAY`&&(t=t===void 0?e.element:mp(t,e.element))}if(t&&Rf(t))return{type:`ARRAY`,element:t,templateFallback:!0}}return e}return xp(c,a,n)}if(u===`ZodArray`)return{type:`ARRAY`,element:Cp(s._def.type,a,n,!0)};if(u===`ZodRecord`){let e=s._def.valueType;return Uf({},e?Cp(e,a,n):void 0)}if(u===`ZodObject`){if(!r&&Cl(s))return{type:`STRUCTURAL`};let e=s.shape,t=s._def.catchall,i=t&&t._def?.typeName!==`ZodNever`?Cp(t,a,n):void 0;return Uf(Sp(e,a,n),i)}return{type:`STATIC`}}function wp(e,t){if(!e||typeof e!=`object`)return{};let{[qf]:n,...r}=e;return t&&Kf in r&&(r.accessibility=r[Kf]),r}var Tp=1e4;function Ep(e){return Array.isArray(e)?e.length>1e4?e.slice(0,Tp):e:[]}var Dp=class{constructor(e,t,n){this.dataListeners=[],this.propsListeners=[],this.currentProps={},this.isConnected=!1,this.actionClosures=/* @__PURE__ */ new Map,this.context=e;let r=n??Wf(e.componentModel?.catalog?.protocolVersion??e.dataContext?.surface?.protocolVersion??e.dataContext?.surface?.defaultCatalog?.protocolVersion);this.behaviorTree=Yf(t,r),this.mirrorsAccessibility=!wa(t).customKeys.has(`accessibility`),this.resolveInitialProps()}resolveInitialProps(){let e=this.context.componentModel.properties,t=this.resolveAndBind(e,this.behaviorTree,[],!0);this.currentProps=wp(t,this.mirrorsAccessibility)}connect(){if(this.isConnected)return;this.isConnected=!0;let e=this.context.componentModel.onUpdated?.subscribe(()=>{this.rebuildAllBindings()});this.compUnsub=e?()=>e.unsubscribe():void 0,this.rebuildAllBindings()}rebuildAllBindings(){this.dataListeners.forEach(e=>e()),this.dataListeners=[];let e=this.context.componentModel.properties;this.currentProps={},this.prevActionClosures=this.actionClosures,this.actionClosures=/* @__PURE__ */ new Map;let t;try{t=this.resolveAndBind(e,this.behaviorTree,[],!1)}finally{this.prevActionClosures=void 0}this.currentProps=wp(t,this.mirrorsAccessibility),this.notify()}bindDynamicValue(e,t,n,r){let i=r?bu:e=>e,a=this.context.dataContext.subscribeDynamicValue(e,e=>{this.updateDeepValue(t,i(e)),this.notify()});return n?a.unsubscribe():this.dataListeners.push(()=>a.unsubscribe()),i(a.value)}resolveDeepSync(e,t=0){if(typeof e!=`object`||!e)return e;if(t>1e3)return;if(`path`in e||`call`in e||`@path`in e||`@call`in e)return this.context.dataContext.resolveDynamicValue(e,t);if(Array.isArray(e))return e.map(e=>this.resolveDeepSync(e,t+1));let n={};for(let[r,i]of Object.entries(e))n[r]=this.resolveDeepSync(i,t+1);return n}bindAction(e,t){let n=t.join(`/`),r=this.actionClosures.get(n)??this.prevActionClosures?.get(n);if(r&&Op(r.raw,e))return this.actionClosures.set(n,r),r.closure;let i=async t=>{if(!e||typeof e!=`object`)return;let n=e;if(n.functionCall&&typeof n.functionCall==`object`||`call`in n||`@call`in n){await this.context.dataContext.resolveAction(e,{userActivation:!0});return}let r=this.context.dataContext.resolveAction(e,{userActivation:!0});Sr(r)&&(r=await r),r!==void 0&&await this.context.dispatchAction(r,t?.metadata)};return this.actionClosures.set(n,{raw:e,closure:i}),i}mapTemplateChildren(e,t,n){let r=Ep(e),i=this.context.dataContext.nested(n);return r.map((e,n)=>({id:t,basePath:i.nested(String(n)).path}))}bindStructuralTemplate(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return e;let r=e,i=typeof r.path==`string`?r.path:void 0,a=typeof r.componentId==`string`?r.componentId:void 0;if(!i||!a)return e;let o=this.context.dataContext.atLeastV10?{"@path":i}:{path:i},s=this.context.dataContext.subscribeDynamicValue(o,e=>{let n=this.mapTemplateChildren(e,a,i);this.updateDeepValue(t,n),this.notify()});return n?s.unsubscribe():this.dataListeners.push(()=>s.unsubscribe()),this.mapTemplateChildren(s.value,a,i)}extractValidationResult(e,t,n=`Validation failed`){if(typeof e==`object`&&e&&`valid`in e){let r=e,i=r.message,a=r.severity===`warning`||r.severity===`info`?r.severity:`error`,o=typeof r.code==`string`?r.code:void 0,s=t===void 0?i==null?n:String(i):t;return{valid:!!r.valid,message:s,...o===void 0?{}:{code:o},severity:a}}return{valid:!!e,message:t??n,severity:`error`}}bindCheckable(e,t,n,r){let i=Array.isArray(e)?e:[],a=i.map(()=>({valid:!0,message:``,severity:`error`})),o=()=>{let e=a.filter(e=>!e.valid&&e.severity===`error`).map(e=>e.message),t=a.filter(e=>!e.valid);return{isValid:e.length===0,validationErrors:e,validationResults:t}},s=t.slice(0,-1),c=()=>{let e=o();this.updateDeepValue([...s,`isValid`],e.isValid),this.updateDeepValue([...s,`validationErrors`],e.validationErrors),this.updateDeepValue([...s,`validationResults`],e.validationResults)},l=()=>{c(),this.notify()};if(i.forEach((e,t)=>{let r=typeof e==`object`&&e?e:void 0,i=r&&r.condition!==void 0?r.condition:e,o=typeof r?.message==`string`?r.message:void 0,s=this.isPathBoundCondition(i)?void 0:o,c=o??`Validation failed`;if(a[t].message=c,this.context.dataContext.atLeastV10){this.bindCheckCondition(i,n,e=>{a[t]=e},l,s,c);return}let u=this.context.dataContext.subscribeDynamicValue(i,e=>{a[t]=this.extractValidationResult(e,s,c),l()});n?u.unsubscribe():this.dataListeners.push(()=>u.unsubscribe()),a[t]=this.extractValidationResult(u.value,s,c)}),r){let e=o();r.isValid=e.isValid,r.validationErrors=e.validationErrors,r.validationResults=e.validationResults}return e}bindCheckCondition(e,t,n,r,i,a){let o=ii(this.context.dataContext,e),s=!t,c,l=(e,t)=>{c=e;let o=wr(e);Sr(o)?(n({valid:!0,message:a,severity:`error`}),Promise.resolve(o).then(t=>{s&&c===e&&(n(this.checkResultOf(t,i,a)),r())},()=>{s&&c===e&&(n({valid:!1,message:a,severity:`error`}),r())})):n(this.checkResultOf(o,i,a)),t&&r()};if(t){l(vn(o),!1),o.unsubscribe?.();return}let u=!0,d=pn(()=>{let e=gn(o);u||l(e,!0)});u=!1,l(vn(o),!1),this.dataListeners.push(()=>{s=!1,d(),o.unsubscribe?.()})}checkResultOf(e,t,n){return yr(e)?{valid:!1,message:n,severity:`error`}:this.extractValidationResult(e,t,n)}isPathBoundCondition(e){if(typeof e!=`object`||!e)return!1;let t=e;return this.context.dataContext.atLeastV10?typeof t[`@path`]==`string`&&!(`@call`in t):typeof t.path==`string`&&!(`call`in t)}getWritableBindingPath(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=t[this.context.dataContext.atLeastV10?`@path`:`path`];if(typeof n==`string`&&(this.context.dataContext.atLeastV10||!Object.hasOwn(t,`componentId`)))return n}bindObject(e,t,n,r,i){let a={};for(let[o,s]of Object.entries(e)){let e=Object.hasOwn(t,o)?t[o]:i??{type:`STATIC`};a[o]=this.resolveAndBind(s,e,[...n,o],r,a)}for(let[n,r]of Object.entries(t))if(r.type===`DYNAMIC`){let t=`set${n.charAt(0).toUpperCase()+n.slice(1)}`,r=e[n];a[t]=e=>{let t=this.getWritableBindingPath(r);t!==void 0&&this.context.dataContext.set(t,e)}}if(i?.type===`DYNAMIC`){for(let[n,r]of Object.entries(e))if(!Object.hasOwn(t,n)&&n.length>0){let t=this.getWritableBindingPath(r);if(t!==void 0){let r=`set${n.charAt(0).toUpperCase()+n.slice(1)}`;Object.hasOwn(e,r)||(a[r]=e=>{this.context.dataContext.set(t,e)})}}}return a}resolveAndBind(e,t,n,r,i){if(e===void 0||e===null&&!(t.type===`DYNAMIC`&&t.isBoolean))return e;switch(t.type){case`DYNAMIC`:return this.bindDynamicValue(e,n,r,t.isBoolean);case`ACTION`:return typeof e!=`object`||Array.isArray(e)?e:this.bindAction(e,n);case`STRUCTURAL`:return this.bindStructuralTemplate(e,n,r);case`CHECKABLE`:return Array.isArray(e)?this.bindCheckable(e,n,r,i):e;case`STATIC`:return e;case`ARRAY`:return Array.isArray(e)?e.map((e,i)=>this.resolveAndBind(e,t.element,[...n,i.toString()],r)):t.templateFallback?this.bindStructuralTemplate(e,n,r):e;case`OBJECT`:return typeof e!=`object`||Array.isArray(e)?e:this.bindObject(e,t.shape,n,r,t.catchall)}}updateDeepValue(e,t){let n=this.cloneAndUpdate(this.currentProps,e,t);this.mirrorsAccessibility&&e[0]===Kf&&Kf in n&&(n.accessibility=n[Kf]),this.currentProps=n}cloneAndUpdate(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(Array.isArray(e)){let t=[...e];return t[Number(r)]=this.cloneAndUpdate(t[Number(r)],i,n),t}{let t=typeof e==`object`&&e?e:{};return{...t,[r]:this.cloneAndUpdate(t[r],i,n)}}}dispose(){this.actionClosures.clear(),this.isConnected&&(this.isConnected=!1,this.dataListeners.forEach(e=>e()),this.dataListeners=[],this.compUnsub&&=(this.compUnsub(),void 0))}notify(){this.propsListeners.forEach(e=>e(this.currentProps))}subscribe(e){return this.propsListeners.length===0&&this.connect(),this.propsListeners.push(e),{unsubscribe:()=>{this.propsListeners=this.propsListeners.filter(t=>t!==e),this.propsListeners.length===0&&this.dispose()}}}get snapshot(){return this.currentProps}};function Op(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>Op(e,t[n]));let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&Op(e[n],t[n]))}var kp=/* @__PURE__ */ e((/* @__PURE__ */ n(((e,t)=>{t.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t||4&t&&typeof e==`object`&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&typeof e!=`string`)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=0)}([function(e,t,n){n.r(t),n.d(t,`validateHTMLColorName`,(function(){return o})),n.d(t,`validateHTMLColorSpecialName`,(function(){return s})),n.d(t,`validateHTMLColorHex`,(function(){return c})),n.d(t,`validateHTMLColorRgb`,(function(){return p})),n.d(t,`validateHTMLColorHsl`,(function(){return m})),n.d(t,`validateHTMLColorHwb`,(function(){return h})),n.d(t,`validateHTMLColorLab`,(function(){return g})),n.d(t,`validateHTMLColorLch`,(function(){return _})),n.d(t,`validateHTMLColor`,(function(){return ee}));let r=e=>e&&typeof e==`string`,i=/* @__PURE__ */ `AliceBlue.AntiqueWhite.Aqua.Aquamarine.Azure.Beige.Bisque.Black.BlanchedAlmond.Blue.BlueViolet.Brown.BurlyWood.CadetBlue.Chartreuse.Chocolate.Coral.CornflowerBlue.Cornsilk.Crimson.Cyan.DarkBlue.DarkCyan.DarkGoldenrod.DarkGray.DarkGrey.DarkGreen.DarkKhaki.DarkMagenta.DarkOliveGreen.DarkOrange.DarkOrchid.DarkRed.DarkSalmon.DarkSeaGreen.DarkSlateBlue.DarkSlateGray.DarkSlateGrey.DarkTurquoise.DarkViolet.DeepPink.DeepSkyBlue.DimGray.DimGrey.DodgerBlue.FireBrick.FloralWhite.ForestGreen.Fuchsia.Gainsboro.GhostWhite.Gold.Goldenrod.Gray.Grey.Green.GreenYellow.HoneyDew.HotPink.IndianRed.Indigo.Ivory.Khaki.Lavender.LavenderBlush.LawnGreen.LemonChiffon.LightBlue.LightCoral.LightCyan.LightGoldenrodYellow.LightGray.LightGrey.LightGreen.LightPink.LightSalmon.LightSalmon.LightSeaGreen.LightSkyBlue.LightSlateGray.LightSlateGrey.LightSteelBlue.LightYellow.Lime.LimeGreen.Linen.Magenta.Maroon.MediumAquamarine.MediumBlue.MediumOrchid.MediumPurple.MediumSeaGreen.MediumSlateBlue.MediumSlateBlue.MediumSpringGreen.MediumTurquoise.MediumVioletRed.MidnightBlue.MintCream.MistyRose.Moccasin.NavajoWhite.Navy.OldLace.Olive.OliveDrab.Orange.OrangeRed.Orchid.PaleGoldenrod.PaleGreen.PaleTurquoise.PaleVioletRed.PapayaWhip.PeachPuff.Peru.Pink.Plum.PowderBlue.Purple.RebeccaPurple.Red.RosyBrown.RoyalBlue.SaddleBrown.Salmon.SandyBrown.SeaGreen.SeaShell.Sienna.Silver.SkyBlue.SlateBlue.SlateGray.SlateGrey.Snow.SpringGreen.SteelBlue.Tan.Teal.Thistle.Tomato.Turquoise.Violet.Wheat.White.WhiteSmoke.Yellow.YellowGreen`.split(`.`),a=[`currentColor`,`inherit`,`transparent`],o=e=>{let t=!1;return r(e)&&i.map(n=>(e.toLowerCase()===n.toLowerCase()&&(t=!0),null)),t},s=e=>{let t=!1;return r(e)&&a.map(n=>(e.toLowerCase()===n.toLowerCase()&&(t=!0),null)),t},c=e=>r(e)?e&&/^#([\da-f]{3}){1,2}$|^#([\da-f]{4}){1,2}$/i.test(e):!1,l=`(([0-9]|[1-9][0-9]|100)%)`,u=`(${l}|(0?((\\.([\\d]{1,5}))?))|1)`,d=`([\\s]{0,5})\\)?)(([\\s]{0,5})(\\/?)([\\s]{1,5})${`(((${l}))|(0?((\\.([\\d]{1,5}))?))|1))?`}([\\s]{0,5})\\)`,f=`(-?(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-5][0-9])((\\.([\\d]{1,5}))?)|360)(deg)?)`,p=e=>{if(r(e)){let t=`([\\s]{0,5})([\\d]{1,5})%?([\\s]{0,5}),?`,n=`((([\\s]{0,5}),?([\\s]{0,5}))|(([\\s]{1,5})))`,r=RegExp(`^(rgb)a?\\(${`${t}${n}`}${`${t}${n}`}${`${t}${n}`}((\\/?([\\s]{0,5})(0?\\.?([\\d]{1,5})%?([\\s]{0,5}))?|1|0))?\\)$`);return e&&r.test(e)}return!1},m=e=>{if(r(e)){let t=RegExp(`^(hsl)a?\\((([\\s]{0,5})(${f}|(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-9][0-9]|400)grad)|((([0-5])?\\.([\\d]{1,5})|6\\.([0-9]|1[0-9]|2[0-8])|[0-6])rad)|((0?((\\.([\\d]{1,5}))?)|1)turn))((([\\s]{0,5}),([\\s]{0,5}))|(([\\s]{1,5}))))(([\\s]{0,5})(0|${l})((([\\s]{0,5}),([\\s]{0,5}))|(([\\s]{1,5}))))(([\\s]{0,5})(0|${l})([\\s]{0,5})\\)?)(([\\s]{0,5})(\\/?|,?)([\\s]{0,5})(((${l}))|(0?((\\.([\\d]{1,5}))?))|1))?\\)$`);return e&&t.test(e)}return!1},h=e=>{if(r(e)){let t=RegExp(`^(hwb\\(([\\s]{0,5})${f}([\\s]{1,5}))((0|${l})([\\s]{1,5}))((0|${l})${d}$`);return e&&t.test(e)}return!1},g=e=>{if(r(e)){let t=`(-?(([0-9]|[1-9][0-9]|1[0-5][0-9])((\\.([\\d]{1,5}))?)?|160))`,n=RegExp(`^(lab\\(([\\s]{0,5})((([\\d]{0,5})((\\.([\\d]{1,5}))?))%)([\\s]{1,5})${t}([\\s]{1,5})${t}${d}$`);return e&&n.test(e)}return!1},_=e=>{if(r(e)){let t=`((${f})|(0|${u})|(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-5][0-9])((\\.([\\d]{1,5}))?)|360))`,n=`(\\/([\\s]{0,5})${u})`,r=RegExp(`^lch\\(${`(([\\s]{0,5})((([0-9]|[1-9][0-9])?((\\.([\\d]{1,5}))?)|100)(%)?)([\\s]{1,5})(([\\d]{0,5})((\\.([\\d]{1,5}))?))([\\s]{1,5})${t}([\\s]{0,5})(${n})?)`}\\)$`);return e&&r.test(e)}return!1},ee=e=>!!(e&&c(e)||p(e)||m(e)||h(e)||g(e)||_(e));t.default=e=>!!(e&&c(e)||o(e)||s(e)||p(e)||m(e)||h(e)||g(e)||_(e))}])})))(),1),Ap=/^var\(\s*--[a-zA-Z0-9_-]+(?:\s*,\s*[^)]+)?\s*\)$/;function jp(e){if(typeof e!=`string`||!e.trim())return!1;let t=e.trim();if(Ap.test(t))return!0;if(typeof CSS<`u`&&typeof CSS.supports==`function`)return CSS.supports(`color`,t);let n=typeof kp.default==`function`?kp.default:kp.default?.default;return typeof n==`function`&&n(t)}var Mp=k({primaryColor:w().refine(e=>jp(e),`primaryColor must be a valid CSS color (e.g. '#00BFFF', '#17e', 'red', 'rgb(255, 0, 0)')`).optional().describe(`The primary brand color used for highlights (e.g., primary buttons, active borders). Renderers may generate variants of this color for different contexts. Format: Hexadecimal code, named color, or functional notation (e.g., '#00BFFF', 'red', 'rgb(255, 0, 0)').`),iconUrl:w().optional().describe(`A URL for an image that identifies the agent or tool associated with the surface.`),agentDisplayName:w().optional().describe(`Text to be displayed next to the surface to identify the agent or tool that created it.`)}).passthrough(),X=Yi(`CatalogComponentCommon`,k({weight:T().describe(`The relative weight of this component within a Row or Column. This is similar to the CSS 'flex-grow' property. Note: this may ONLY be set when the component is a direct descendant of a Row or Column.`).optional()}));Yi(`theme`,k({primaryColor:w().regex(/* @__PURE__ */ RegExp(`^#[0-9a-fA-F]{6}$`)).describe(`The primary brand color used for highlights (e.g., primary buttons, active borders). Renderers may generate variants of this color for different contexts. Format: Hexadecimal code (e.g., '#00BFFF').`).optional(),iconUrl:z(w().refine(e=>e.trim().length>0&&!/\s/.test(e.trim()),`Invalid URI`).describe(`A URL for an image that identifies the agent or tool associated with the surface.`),{keywords:{format:`uri`}}).optional(),agentDisplayName:w().describe(`Text to be displayed next to the surface to identify the agent or tool that created it.`).optional()}),{keywords:{additionalProperties:!0}});var Np={name:`Text`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),text:B.describe(`REF:#/$defs/DynamicString|The text content to display. While simple Markdown formatting is supported (i.e. without HTML, images, or links), utilizing dedicated UI components is generally preferred for a richer and more structured presentation.`),variant:M([`h1`,`h2`,`h3`,`h4`,`h5`,`caption`,`body`]).default(`body`).describe(`A hint for the base text style.`).optional()}).strict(),{mixins:[`ComponentCommon`,X]})},Pp={name:`Image`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),url:B.describe(`REF:#/$defs/DynamicString|The URL of the image to display.`),description:B.describe(`REF:#/$defs/DynamicString|Accessibility text for the image.`).optional(),fit:M([`contain`,`cover`,`fill`,`none`,`scaleDown`]).default(`fill`).describe(`Specifies how the image should be resized to fit its container. This corresponds to the CSS 'object-fit' property.`).optional(),variant:M([`icon`,`avatar`,`smallFeature`,`mediumFeature`,`largeFeature`,`header`]).default(`mediumFeature`).describe(`A hint for the image size and style.`).optional()}).strict(),{mixins:[`ComponentCommon`,X]})},Fp={name:`Icon`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),name:A([M(/* @__PURE__ */ `accountCircle.add.arrowBack.arrowForward.attachFile.calendarToday.call.camera.check.close.delete.download.edit.event.error.fastForward.favorite.favoriteOff.folder.help.home.info.locationOn.lock.lockOpen.mail.menu.moreVert.moreHoriz.notificationsOff.notifications.pause.payment.person.phone.photo.play.print.refresh.rewind.search.send.settings.share.shoppingCart.skipNext.skipPrevious.star.starHalf.starOff.stop.upload.visibility.visibilityOff.volumeDown.volumeMute.volumeOff.volumeUp.warning`.split(`.`)),z(k({svgPath:w()}),{closure:`additionalProperties`}),$i.describe(`REF:#/$defs/DataBinding`)]).describe(`The name of the icon to display.`)}).strict(),{mixins:[`ComponentCommon`,X]})},Ip={name:`Video`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),url:B.describe(`REF:#/$defs/DynamicString|The URL of the video to display.`)}).strict(),{mixins:[`ComponentCommon`,X]})},Lp={name:`AudioPlayer`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),url:B.describe(`REF:#/$defs/DynamicString|The URL of the audio to be played.`),description:B.describe(`REF:#/$defs/DynamicString|A description of the audio, such as a title or summary.`).optional()}).strict(),{mixins:[`ComponentCommon`,X]})},Rp={name:`Row`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),children:ra.describe(`REF:#/$defs/ChildList|Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list. Children cannot be defined inline, they must be referred to by ID.`),justify:M([`center`,`end`,`spaceAround`,`spaceBetween`,`spaceEvenly`,`start`,`stretch`]).default(`start`).describe(`Defines the arrangement of children along the main axis (horizontally). Use 'spaceBetween' to push items to the edges, or 'start'/'end'/'center' to pack them together.`).optional(),align:M([`start`,`center`,`end`,`stretch`]).default(`stretch`).describe(`Defines the alignment of children along the cross axis (vertically). This is similar to the CSS 'align-items' property, but uses camelCase values (e.g., 'start').`).optional()}).describe(`A layout component that arranges its children horizontally. To create a grid layout, nest Columns within this Row.`).strict(),{mixins:[`ComponentCommon`,X]})},zp={name:`Column`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),children:ra.describe(`REF:#/$defs/ChildList|Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list. Children cannot be defined inline, they must be referred to by ID.`),justify:M([`start`,`center`,`end`,`spaceBetween`,`spaceAround`,`spaceEvenly`,`stretch`]).default(`start`).describe(`Defines the arrangement of children along the main axis (vertically). Use 'spaceBetween' to push items to the edges (e.g. header at top, footer at bottom), or 'start'/'end'/'center' to pack them together.`).optional(),align:M([`center`,`end`,`start`,`stretch`]).default(`stretch`).describe(`Defines the alignment of children along the cross axis (horizontally). This is similar to the CSS 'align-items' property.`).optional()}).describe(`A layout component that arranges its children vertically. To create a grid layout, nest Rows within this Column.`).strict(),{mixins:[`ComponentCommon`,X]})},Bp={name:`List`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),children:ra.describe(`REF:#/$defs/ChildList|Defines the children. Use an array of strings for a fixed set of children, or a template object to generate children from a data list.`),direction:M([`vertical`,`horizontal`]).default(`vertical`).describe(`The direction in which the list items are laid out.`).optional(),align:M([`start`,`center`,`end`,`stretch`]).default(`stretch`).describe(`Defines the alignment of children along the cross axis.`).optional(),listStyle:M([`ordered`,`unordered`,`none`]).describe(`The style of the list (ordered, unordered, or none).`).optional()}).strict(),{mixins:[`ComponentCommon`,X]})},Vp={name:`Card`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),child:Qi.describe(`REF:#/$defs/ComponentId|The ID of the single child component to be rendered inside the card. To display multiple elements, you MUST wrap them in a layout component (like Column or Row) and pass that container's ID here. Do NOT pass multiple IDs or a non-existent ID.`)}).strict(),{mixins:[`ComponentCommon`,X]})},Hp={name:`Tabs`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),tabs:O(z(k({title:B.describe(`REF:#/$defs/DynamicString|The tab title.`),child:Qi.describe(`REF:#/$defs/ComponentId|The ID of the child component.`)}),{closure:`additionalProperties`})).min(1).describe(`An array of objects, where each object defines a tab with a title and a child component.`)}).strict(),{mixins:[`ComponentCommon`,X]})},Up={name:`Modal`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),trigger:Qi.describe(`REF:#/$defs/ComponentId|The ID of the component that opens the modal when interacted with (e.g., a button).`),content:Qi.describe(`REF:#/$defs/ComponentId|The ID of the component to be displayed inside the modal.`)}).strict(),{mixins:[`ComponentCommon`,X]})},Wp={name:`Divider`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),axis:M([`horizontal`,`vertical`]).default(`horizontal`).describe(`The orientation of the divider.`).optional()}).strict(),{mixins:[`ComponentCommon`,X]})},Gp={name:`Button`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),checks:O(sa.describe(`REF:#/$defs/CheckRule`)).describe(`A list of checks to perform. These are function calls that must return a boolean indicating validity.`).optional(),child:Qi.describe(`REF:#/$defs/ComponentId|The ID of the child component. Use a 'Text' component for a labeled button. Only use an 'Icon' if the requirements explicitly ask for an icon-only button.`),variant:M([`default`,`primary`,`borderless`]).default(`default`).describe(`A hint for the button style. If omitted, a default button style is used. 'primary' indicates this is the main call-to-action button. 'borderless' means the button has no visual border or background, making its child content appear like a clickable link.`).optional(),action:la.describe(`REF:#/$defs/Action`)}).strict(),{mixins:[`ComponentCommon`,X,`Checkable`]})},Kp={name:`TextField`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),checks:O(sa.describe(`REF:#/$defs/CheckRule`)).describe(`A list of checks to perform. These are function calls that must return a boolean indicating validity.`).optional(),label:B.describe(`REF:#/$defs/DynamicString|The text label for the input field.`),value:B.describe(`REF:#/$defs/DynamicString|The value of the text field.`).optional(),variant:M([`longText`,`number`,`shortText`,`obscured`]).default(`shortText`).describe(`The type of input field to display.`).optional(),validationRegexp:w().describe(`A regular expression used for client-side validation of the input.`).optional()}).strict(),{mixins:[`ComponentCommon`,X,`Checkable`]})},qp={name:`CheckBox`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),checks:O(sa.describe(`REF:#/$defs/CheckRule`)).describe(`A list of checks to perform. These are function calls that must return a boolean indicating validity.`).optional(),label:B.describe(`REF:#/$defs/DynamicString|The text to display next to the checkbox.`),value:aa.describe(`REF:#/$defs/DynamicBoolean|The current state of the checkbox (true for checked, false for unchecked).`)}).strict(),{mixins:[`ComponentCommon`,X,`Checkable`]})},Jp={name:`ChoicePicker`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),checks:O(sa.describe(`REF:#/$defs/CheckRule`)).describe(`A list of checks to perform. These are function calls that must return a boolean indicating validity.`).optional(),label:B.describe(`REF:#/$defs/DynamicString|The label for the group of options.`).optional(),variant:M([`multipleSelection`,`mutuallyExclusive`]).default(`mutuallyExclusive`).describe(`A hint for how the choice picker should be displayed and behave.`).optional(),options:O(z(k({label:B.describe(`REF:#/$defs/DynamicString|The text to display for this option.`),value:w().describe(`The stable value associated with this option.`)}),{closure:`additionalProperties`})).describe(`The list of available options to choose from.`),value:oa.describe(`REF:#/$defs/DynamicStringList|The list of currently selected values. This should be bound to a string array in the data model.`),displayStyle:M([`checkbox`,`chips`]).default(`checkbox`).describe(`The display style of the component.`).optional(),filterable:E().default(!1).describe(`If true, displays a search input to filter the options.`).optional()}).describe(`A component that allows selecting one or more options from a list.`).strict(),{mixins:[`ComponentCommon`,X,`Checkable`]})},Yp={name:`Slider`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),checks:O(sa.describe(`REF:#/$defs/CheckRule`)).describe(`A list of checks to perform. These are function calls that must return a boolean indicating validity.`).optional(),label:B.describe(`REF:#/$defs/DynamicString|The label for the slider.`).optional(),min:T().default(0).describe(`The minimum value of the slider.`).optional(),max:T().describe(`The maximum value of the slider.`),value:ia.describe(`REF:#/$defs/DynamicNumber|The current value of the slider.`)}).strict(),{mixins:[`ComponentCommon`,X,`Checkable`],required:[`value`,`max`]})},Xp={name:`DateTimeInput`,schema:z(k({...X.shape,accessibility:V.describe(`REF:#/$defs/AccessibilityAttributes`).optional(),checks:O(sa.describe(`REF:#/$defs/CheckRule`)).describe(`A list of checks to perform. These are function calls that must return a boolean indicating validity.`).optional(),value:B.describe(`REF:#/$defs/DynamicString|The selected date and/or time value in ISO 8601 format. If not yet set, initialize with an empty string.`),enableDate:E().default(!1).describe(`If true, allows the user to select a date.`).optional(),enableTime:E().default(!1).describe(`If true, allows the user to select a time.`).optional(),min:z(B.describe(`REF:#/$defs/DynamicString|The minimum allowed date/time in ISO 8601 format.`),{allOf:[{if:{type:`string`},then:{oneOf:[{format:`date`},{format:`time`},{format:`date-time`}]}}]}).optional(),max:z(B.describe(`REF:#/$defs/DynamicString|The maximum allowed date/time in ISO 8601 format.`),{allOf:[{if:{type:`string`},then:{oneOf:[{format:`date`},{format:`time`},{format:`date-time`}]}}]}).optional(),label:B.describe(`REF:#/$defs/DynamicString|The text label for the input field.`).optional()}).strict(),{mixins:[`ComponentCommon`,X,`Checkable`]})},Zp={name:`required`,returnType:`boolean`,description:`Checks that the value is not null, undefined, or empty.`,schema:z(k({value:wt().refine(e=>e!==void 0,`Required`).describe(`The value to check.`)}).strict(),{closure:`additionalProperties`})},Qp={name:`regex`,returnType:`boolean`,description:`Checks that the value matches a regular expression string.`,schema:z(k({value:B.describe(`REF:#/$defs/DynamicString`),pattern:w().describe(`The regex pattern to match against.`)}).strict(),{closure:`unevaluatedProperties`})},$p={name:`length`,returnType:`boolean`,description:`Checks string length constraints.`,schema:z(k({value:B.describe(`REF:#/$defs/DynamicString`),min:T().int().min(0).describe(`The minimum allowed length.`).optional(),max:T().int().min(0).describe(`The maximum allowed length.`).optional()}).strict().refine(e=>e.min!==void 0||e.max!==void 0,{message:`At least one of 'min', 'max' must be provided.`}),{closure:`unevaluatedProperties`,keywords:{anyOf:[{required:[`min`]},{required:[`max`]}]}})},em={name:`numeric`,returnType:`boolean`,description:`Checks numeric range constraints.`,schema:z(k({value:ia.describe(`REF:#/$defs/DynamicNumber`),min:T().describe(`The minimum allowed value.`).optional(),max:T().describe(`The maximum allowed value.`).optional()}).strict().refine(e=>e.min!==void 0||e.max!==void 0,{message:`At least one of 'min', 'max' must be provided.`}),{closure:`unevaluatedProperties`,keywords:{anyOf:[{required:[`min`]},{required:[`max`]}]}})},tm={name:`email`,returnType:`boolean`,description:`Checks that the value is a valid email address.`,schema:z(k({value:B.describe(`REF:#/$defs/DynamicString`)}).strict(),{closure:`unevaluatedProperties`})},nm={name:`formatString`,returnType:`string`,description:"Performs string interpolation of data model values and other functions in the catalog functions list and returns the resulting string. The value string can contain interpolated expressions in the `${expression}` format. Supported expression types include: JSON Pointer paths to the data model (e.g., `${/absolute/path}` or `${relative/path}`), and client-side function calls (e.g., `${now()}`). Function arguments must be named (e.g., `${formatDate(value:${/currentDate}, format:'MM-dd')}`). To include a literal `${` sequence, escape it as `\\${`.",schema:z(k({value:B.describe(`REF:#/$defs/DynamicString`)}).strict(),{closure:`unevaluatedProperties`})},rm={name:`formatNumber`,returnType:`string`,description:`Formats a number with the specified grouping and decimal precision.`,schema:z(k({value:ia.describe(`REF:#/$defs/DynamicNumber|The number to format.`),decimals:ia.describe(`REF:#/$defs/DynamicNumber|Optional. The number of decimal places to show. Defaults to 0 or 2 depending on locale.`).optional(),grouping:aa.describe(`REF:#/$defs/DynamicBoolean|Optional. If true, uses locale-specific grouping separators (e.g. '1,000'). If false, returns raw digits (e.g. '1000'). Defaults to true.`).optional()}).strict(),{closure:`unevaluatedProperties`})},im={name:`formatCurrency`,returnType:`string`,description:`Formats a number as a currency string.`,schema:z(k({value:ia.describe(`REF:#/$defs/DynamicNumber|The monetary amount.`),currency:B.describe(`REF:#/$defs/DynamicString|The ISO 4217 currency code (e.g., 'USD', 'EUR').`),decimals:ia.describe(`REF:#/$defs/DynamicNumber|Optional. The number of decimal places to show. Defaults to 0 or 2 depending on locale.`).optional(),grouping:aa.describe(`REF:#/$defs/DynamicBoolean|Optional. If true, uses locale-specific grouping separators (e.g. '1,000'). If false, returns raw digits (e.g. '1000'). Defaults to true.`).optional()}).strict(),{required:[`currency`,`value`],closure:`unevaluatedProperties`})},am={name:`formatDate`,returnType:`string`,description:`Formats a timestamp into a string using a pattern.`,schema:z(k({value:ea.describe(`REF:#/$defs/DynamicValue|The date to format.`),format:B.describe(`REF:#/$defs/DynamicString|A Unicode TR35 date pattern string.
4
+
5
+ Token Reference:
6
+ - Year: 'yy' (26), 'yyyy' (2026)
7
+ - Month: 'M' (1), 'MM' (01), 'MMM' (Jan), 'MMMM' (January)
8
+ - Day: 'd' (1), 'dd' (01), 'E' (Tue), 'EEEE' (Tuesday)
9
+ - Hour (12h): 'h' (1-12), 'hh' (01-12) - requires 'a' for AM/PM
10
+ - Hour (24h): 'H' (0-23), 'HH' (00-23) - Military Time
11
+ - Minute: 'mm' (00-59)
12
+ - Second: 'ss' (00-59)
13
+ - Period: 'a' (AM/PM)
14
+
15
+ Examples:
16
+ - 'MMM dd, yyyy' -> 'Jan 16, 2026'
17
+ - 'HH:mm' -> '14:30' (Military)
18
+ - 'h:mm a' -> '2:30 PM'
19
+ - 'EEEE, d MMMM' -> 'Friday, 16 January'`)}).strict(),{required:[`format`,`value`],closure:`unevaluatedProperties`})},om={name:`pluralize`,returnType:`string`,description:`Returns a localized string based on the Common Locale Data Repository (CLDR) plural category of the count (zero, one, two, few, many, other). Requires an 'other' fallback. For English, just use 'one' and 'other'.`,schema:z(k({value:ia.describe(`REF:#/$defs/DynamicNumber|The numeric value used to determine the plural category.`),zero:B.describe(`REF:#/$defs/DynamicString|String for the 'zero' category (e.g., 0 items).`).optional(),one:B.describe(`REF:#/$defs/DynamicString|String for the 'one' category (e.g., 1 item).`).optional(),two:B.describe(`REF:#/$defs/DynamicString|String for the 'two' category (used in Arabic, Welsh, etc.).`).optional(),few:B.describe(`REF:#/$defs/DynamicString|String for the 'few' category (e.g., small groups in Slavic languages).`).optional(),many:B.describe(`REF:#/$defs/DynamicString|String for the 'many' category (e.g., large groups in various languages).`).optional(),other:B.describe(`REF:#/$defs/DynamicString|The default/fallback string (used for general plural cases).`)}).strict(),{closure:`unevaluatedProperties`})},sm={name:`openUrl`,returnType:`void`,description:`Opens the specified URL in a browser or handler. This function has no return value.`,schema:z(k({url:z(w().refine(e=>e.trim().length>0&&!/\s/.test(e.trim()),`Invalid URI`).describe(`The URL to open.`),{keywords:{format:`uri`}})}).strict(),{closure:`additionalProperties`})},cm={name:`and`,returnType:`boolean`,description:`Performs a logical AND operation on a list of boolean values.`,schema:z(k({values:O(aa.describe(`REF:#/$defs/DynamicBoolean`)).min(2).describe(`The list of boolean values to evaluate.`)}).strict(),{closure:`unevaluatedProperties`})},lm={name:`or`,returnType:`boolean`,description:`Performs a logical OR operation on a list of boolean values.`,schema:z(k({values:O(aa.describe(`REF:#/$defs/DynamicBoolean`)).min(2).describe(`The list of boolean values to evaluate.`)}).strict(),{closure:`unevaluatedProperties`})},um={name:`not`,returnType:`boolean`,description:`Performs a logical NOT operation on a boolean value.`,schema:z(k({value:aa.describe(`REF:#/$defs/DynamicBoolean|The boolean value to negate.`)}).strict(),{closure:`unevaluatedProperties`})},dm=()=>Ot(e=>e===null?void 0:e,kt.number()),fm=()=>Ot(e=>e==null?void 0:String(e),w()),pm=()=>wt().refine(e=>e!==void 0,`Required`),mm={name:`add`,returnType:`number`,schema:k({a:dm(),b:dm()})},hm={name:`subtract`,returnType:`number`,schema:k({a:dm(),b:dm()})},gm={name:`multiply`,returnType:`number`,schema:k({a:dm(),b:dm()})},_m={name:`divide`,returnType:`number`,schema:k({a:dm(),b:dm()})},vm={name:`equals`,returnType:`boolean`,schema:k({a:pm(),b:pm()})},ym={name:`not_equals`,returnType:`boolean`,schema:k({a:pm(),b:pm()})},bm={name:`greater_than`,returnType:`boolean`,schema:k({a:dm(),b:dm()})},xm={name:`less_than`,returnType:`boolean`,schema:k({a:dm(),b:dm()})},Sm={name:`contains`,returnType:`boolean`,schema:k({string:fm(),substring:fm()})},Cm={name:`starts_with`,returnType:`boolean`,schema:k({string:fm(),prefix:fm()})},wm={name:`ends_with`,returnType:`boolean`,schema:k({string:fm(),suffix:fm()})},Tm=1e4,Em=1e3,Dm=/^[+-]?(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,Om=class e{parse(t,n=0){if(n>e.MAX_DEPTH)throw new F(`Max recursion depth reached in parse`);if(t&&t.length>1e4)throw new F(`Expression template length (${t.length}) exceeds maximum limit (${Tm})`);if(!t)return[];if(!t.includes("${"))return[t];let r=[],i=new jm(t);for(;!i.isAtEnd();){if(r.length>=1e3)throw new F(`Expression parts count exceeds maximum limit (${Em})`);if(i.matches("${")){i.advance(2);let e=this.extractInterpolationContent(i),t=this.parseExpression(e,n+1);t!==null&&r.push(t)}else if(i.peek()===`\\`&&i.peek(1)===`$`&&i.peek(2)===`{`)i.advance(),r.push("${"),i.advance(2);else{let e=i.pos;for(;!i.isAtEnd()&&!(i.matches("${")||i.peek()===`\\`&&i.peek(1)===`$`&&i.peek(2)===`{`);)i.advance();r.push(i.input.substring(e,i.pos))}}return r.filter(e=>e!==null&&e!==``)}extractInterpolationContent(e){let t=e.pos,n=1;for(;!e.isAtEnd()&&n>0;){let t=e.advance();if(t===`{`)n++;else if(t===`}`)n--;else if(t===`'`||t===`"`){let n=t;for(;!e.isAtEnd();){let t=e.advance();if(t===`\\`)e.advance();else if(t===n)break}}}if(n>0)throw new F(`Unclosed interpolation: missing '}'`);return e.input.substring(t,e.pos-1)}parseExpression(e,t=0){if(e=e.trim(),!e)return``;let n=new jm(e),r=this.parseExpressionInternal(n,t);if(!n.isAtEnd())throw new F(`Unexpected characters at end of expression: '${n.input.substring(n.pos)}'`);return r}parseExpressionInternal(t,n){if(n>e.MAX_DEPTH)throw new F(`Max recursion depth reached in parse`);if(t.skipWhitespace(),t.isAtEnd())return``;if(t.matches("${")){t.advance(2);let e=this.extractInterpolationContent(t);return this.parseExpression(e,n+1)}if(t.matchesString(`'`)||t.matchesString(`"`))return this.parseStringLiteral(t);if(this.isNumberStart(t))return this.parseNumberLiteral(t);if(t.matchesKeyword(`true`))return!0;if(t.matchesKeyword(`false`))return!1;if(t.matchesKeyword(`null`))return``;let r=this.scanPathOrIdentifier(t);if(t.skipWhitespace(),t.peek()===`(`)return this.parseFunctionCall(r,t,n);if(r.startsWith(`@`))throw new F(`Expected '(' after function name '${r}'`);return r?{path:r}:``}scanPathOrIdentifier(e){let t=e.pos;if(e.peek()===`@`){let n=e.peek(1);if(!n||!/[A-Za-z_]/.test(n))throw new F(`Invalid identifier starting with '@' in expression`);for(e.advance();!e.isAtEnd();){let t=e.peek();if(/[A-Za-z0-9_]/.test(t))e.advance();else break}return e.input.substring(t,e.pos)}for(;!e.isAtEnd();){let t=e.peek();if(Am(t)||t===`/`||t===`.`||t===`-`)e.advance();else break}return e.input.substring(t,e.pos)}parseFunctionCall(e,t,n){t.match(`(`),t.skipWhitespace();let r={};for(;!t.isAtEnd()&&t.peek()!==`)`;){let i=this.scanIdentifier(t);if(t.skipWhitespace(),!t.match(`:`))throw new F(`Expected ':' after argument name '${i}' in function '${e}'`);t.skipWhitespace(),Object.defineProperty(r,i,{value:this.parseExpressionInternal(t,n+1),enumerable:!0,writable:!0,configurable:!0}),t.skipWhitespace(),t.peek()===`,`&&(t.advance(),t.skipWhitespace())}if(!t.match(`)`))throw new F(`Expected ')' after function arguments for '${e}'`);return{call:e,args:r,returnType:`any`}}scanIdentifier(e){let t=e.pos;for(;!e.isAtEnd()&&Am(e.peek());)e.advance();return e.input.substring(t,e.pos)}parseStringLiteral(e){let t=e.advance(),n=``,r=!1;for(;!e.isAtEnd();){let i=e.advance();if(i===`\\`){if(e.isAtEnd())break;let t=e.advance();n+=t===`n`?`
20
+ `:t===`t`?` `:t===`r`?`\r`:t}else if(i===t){r=!0;break}else n+=i}if(!r)throw new F(`Unclosed string literal: missing closing ${t}`);return n}isNumberStart(e){let t=0;return(e.peek()===`-`||e.peek()===`+`)&&(t=1),this.isDigit(e.peek(t))?!0:e.peek(t)===`.`&&this.isDigit(e.peek(t+1))}parseNumberLiteral(e){let t=e.pos;for((e.peek()===`-`||e.peek()===`+`)&&e.advance();!e.isAtEnd()&&(this.isDigit(e.peek())||e.peek()===`.`);)e.advance();this.skipExponent(e);let n=e.input.substring(t,e.pos);if(!Dm.test(n))throw new F(`Invalid number literal: '${n}'`);let r=Number(n);if(!Number.isFinite(r))throw new F(`Number literal is out of range: '${n}'`);return r===0?0:r}skipExponent(e){if(!(e.isAtEnd()||e.peek()!==`e`&&e.peek()!==`E`))for(e.advance(),e.isAtEnd()||e.peek()!==`+`&&e.peek()!==`-`||e.advance();!e.isAtEnd()&&this.isDigit(e.peek());)e.advance()}isDigit(e){return e>=`0`&&e<=`9`}};Om.MAX_DEPTH=100;var km=/* @__PURE__ */ RegExp(`^\\p{XID_Continue}$`,`u`);function Am(e){return Array.from(e).length===1&&km.test(e)}var jm=class{constructor(e){this.input=e,this.pos=0}isAtEnd(){return this.pos>=this.input.length}peek(e=0){let t=this.pos+e;if(t>=this.input.length)return`\0`;let n=this.input.codePointAt(t);return n===void 0?`\0`:String.fromCodePoint(n)}advance(e){let t=e??(this.peek()===`\0`?1:this.peek().length),n=this.input.substring(this.pos,this.pos+t);return this.pos+=t,n}match(e){return this.peek()===e&&(this.advance(),!0)}matches(e){return!!this.input.startsWith(e,this.pos)}matchesString(e){return this.peek()===e}matchesKeyword(e){return this.input.startsWith(e,this.pos)&&!Am(this.peek(e.length))?(this.advance(e.length),!0):!1}skipWhitespace(){for(;!this.isAtEnd()&&/\s/.test(this.peek());)this.advance()}},Z=class extends Error{constructor(e,t=!1){super(e),this.name=`RegexSyntaxError`,this.unsupported=t}},Mm={start:55296,end:57343},Nm=1114111,Pm=65535,Fm=[{start:48,end:57}],Im=[{start:48,end:57},{start:65,end:90},{start:95,end:95},{start:97,end:122}],Lm=[{start:9,end:13},{start:32,end:32},{start:160,end:160},{start:5760,end:5760},{start:8192,end:8202},{start:8232,end:8233},{start:8239,end:8239},{start:8287,end:8287},{start:12288,end:12288},{start:65279,end:65279}],Rm=[{start:10,end:10},{start:13,end:13},{start:8232,end:8233}],zm=/* @__PURE__ */ new Set([94,36,92,46,42,43,63,40,41,91,93,123,125,124,47]),Bm=/* @__PURE__ */ new Map([[116,9],[110,10],[118,11],[102,12],[114,13]]);function Vm(e){if(e.start>e.end)return[];if(e.end<Mm.start||e.start>Mm.end)return[e];let t=[];return e.start<Mm.start&&t.push({start:e.start,end:Mm.start-1}),e.end>Mm.end&&t.push({start:Mm.end+1,end:e.end}),t}function Hm(e){let t=e.flatMap(Vm);if(t.length<=1)return t;t.sort((e,t)=>e.start-t.start||e.end-t.end);let n=[t[0]];for(let e=1;e<t.length;e++){let r=n[n.length-1],i=t[e];i.start<=r.end+1?n[n.length-1]={start:r.start,end:Math.max(r.end,i.end)}:n.push(i)}return n}function Um(e){let t=Hm([...e,Mm]),n=[],r=0;for(let e of t)e.start>r&&n.push({start:r,end:e.start-1}),r=e.end+1;return r<=Nm&&n.push({start:r,end:Nm}),n.flatMap(Vm)}var Wm=Um(Fm),Gm=Um(Im),Km=Um(Lm),qm=Um(Rm),Jm=/* @__PURE__ */ new Map([[100,Fm],[68,Wm],[119,Im],[87,Gm],[115,Lm],[83,Km]]);function Ym(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;)if(e[n].end<t[r].start)n++;else if(t[r].end<e[n].start)r++;else return!0;return!1}function Xm(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&n++}t++}return t}function Zm(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>=55296&&r<=56319){let i=n+1<e.length?e.charCodeAt(n+1):0;if(i<56320||i>57343)throw new Z(`Lone high surrogate in pattern`,!0);t.push(65536+(r-55296<<10)+(i-56320)),n++}else if(r>=56320&&r<=57343)throw new Z(`Lone low surrogate in pattern`,!0);else t.push(r)}return t}var Qm=class{constructor(e){this.cps=e,this.pos=0}eof(){return this.pos>=this.cps.length}peek(e=0){return this.cps[this.pos+e]}next(){if(this.pos>=this.cps.length)throw new Z(`Unexpected end of pattern`,!1);return this.cps[this.pos++]}eat(e){return this.cps[this.pos]===e&&(this.pos++,!0)}};function $m(e){return e!==void 0&&e>=48&&e<=57}function eh(e){return e===void 0?-1:e>=48&&e<=57?e-48:e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:-1}function th(e,t){let n=0;for(let r=0;r<t;r++){let t=eh(e.peek());if(t<0)throw new Z(`Invalid hexadecimal escape`,!1);e.next(),n=n<<4|t}return n}function nh(e){if(!e.eat(123)){let t=th(e,4);if(t>=Mm.start&&t<=Mm.end)throw new Z(`Surrogate code point escape is not supported`,!0);return t}let t=0,n=0;for(;!e.eof()&&e.peek()!==125;){let r=eh(e.peek());if(r<0)throw new Z(`Invalid braced Unicode escape`,!1);if(e.next(),t=t*16+r,n++,t>Nm)throw new Z(`Unicode escape exceeds U+10FFFF`,!1)}if(n===0||!e.eat(125))throw new Z(`Malformed braced Unicode escape`,!1);if(t>=Mm.start&&t<=Mm.end)throw new Z(`Surrogate code point escape is not supported`,!0);return t}function rh(e,t){if(t===48){if($m(e.peek()))throw new Z(`Octal escape is not supported`,!0);return 0}if(t>=49&&t<=57)throw new Z(`Backreference or octal escape is not supported`,!0);return t===120?th(e,2):t===117?nh(e):null}function ih(e,t){if(e.eof())throw new Z(`Trailing backslash in pattern`,!1);let n=e.next();if(n===98)return t?{kind:`single`,cp:8}:{kind:`anchor`,anchor:`wordBoundary`};if(n===66){if(t)throw new Z(`\\B is not supported inside a character class`,!0);return{kind:`anchor`,anchor:`notWordBoundary`}}let r=Jm.get(n);if(r!==void 0)return{kind:`ranges`,ranges:r};let i=Bm.get(n);if(i!==void 0)return{kind:`single`,cp:i};let a=rh(e,n);if(a!==null)return{kind:`single`,cp:a};if(zm.has(n)||t&&n===45)return{kind:`single`,cp:n};throw new Z(`Unsupported escape sequence`,!0)}function ah(e){let t=e.peek();if(t===92){e.next();let t=ih(e,!0);if(t.kind===`single`)return{single:t.cp,ranges:[{start:t.cp,end:t.cp}]};if(t.kind===`ranges`)return{ranges:t.ranges};throw new Z(`Assertions are not valid in a character class`,!0)}if(t===91)throw new Z(`Nested character class is not supported`,!0);if(t===38&&e.peek(1)===38)throw new Z(`Character class intersection is not supported`,!0);let n=e.next();return{single:n,ranges:[{start:n,end:n}]}}function oh(e){let t=ah(e);if(e.peek()!==45||e.peek(1)===93)return t.ranges;if(e.next(),e.peek()===45)throw new Z(`Character class subtraction is not supported`,!0);let n=ah(e);if(t.single===void 0||n.single===void 0)throw new Z(`Character class escape cannot form a range`,!1);if(t.single>n.single)throw new Z(`Character class range out of order`,!1);return[{start:t.single,end:n.single}]}function sh(e){let t=e.eat(94),n=[];for(;!e.eof()&&e.peek()!==93;)n.push(...oh(e));if(!e.eat(93))throw new Z(`Unclosed character class`,!1);if(n.length===0)throw new Z(`Empty character class`,!1);let r=Hm(n);return{kind:`charSet`,ranges:t?Um(r):r}}function ch(e){if(!$m(e.peek()))return null;let t=0;for(;$m(e.peek());)t=t*10+(e.next()-48);return t}function lh(e){let t=ch(e);if(t===null)throw new Z(`Malformed brace quantifier`,!0);if(t>Pm)throw new Z(`Quantifier lower bound ${t} exceeds ${Pm}`,!1);if(e.eat(125))return{min:t,max:t};if(!e.eat(44))throw new Z(`Malformed brace quantifier`,!0);if(e.eat(125))return{min:t,max:null};let n=ch(e);if(n===null||!e.eat(125))throw new Z(`Malformed brace quantifier`,!0);if(n>Pm)throw new Z(`Quantifier upper bound ${n} exceeds ${Pm}`,!1);if(n<t)throw new Z(`Quantifier minimum exceeds maximum`,!1);return{min:t,max:n}}function uh(e){return e===42||e===43||e===63||e===123}function dh(e,t){let n=e.next(),r=0,i=null;if(n===42)r=0,i=null;else if(n===43)r=1,i=null;else if(n===63)r=0,i=1;else{let t=lh(e);r=t.min,i=t.max}let a=e.eat(63);if(uh(e.peek()))throw new Z(`Possessive or chained quantifiers are not supported`,!0);return{kind:`repeat`,child:t,min:r,max:i,lazy:a}}function fh(e){if(!e.eat(63)){let t=gh(e);if(!e.eat(41))throw new Z(`Unclosed group`,!1);return{kind:`group`,capturing:!0,child:t}}let t=e.peek();if(t!==58&&t!==61&&t!==33)throw new Z(`Unsupported group extension`,!0);e.next();let n=gh(e);if(!e.eat(41))throw new Z(`Unclosed group`,!1);return t===58?{kind:`group`,capturing:!1,child:n}:{kind:`lookahead`,negated:t===33,child:n}}function ph(e){let t=e.next();if(t===94)return{kind:`anchor`,anchor:`start`};if(t===36)return{kind:`anchor`,anchor:`end`};if(t===46)return{kind:`charSet`,ranges:qm};if(t===91)return sh(e);if(t===40)return fh(e);if(t===92){let t=ih(e,!1);return t.kind===`anchor`?{kind:`anchor`,anchor:t.anchor}:t.kind===`ranges`?{kind:`charSet`,ranges:t.ranges}:{kind:`charSet`,ranges:[{start:t.cp,end:t.cp}]}}if(t===123||t===125||t===93)throw new Z(`Unescaped brace or bracket is not supported`,!0);if(t===42||t===43||t===63)throw new Z(`Nothing to repeat`,!1);return{kind:`charSet`,ranges:[{start:t,end:t}]}}function mh(e){let t=ph(e);if(!uh(e.peek()))return t;if(t.kind===`anchor`||t.kind===`lookahead`)throw new Z(`Quantifier on an assertion is not supported`,!0);return dh(e,t)}function hh(e){let t=[];for(;!e.eof()&&e.peek()!==124&&e.peek()!==41;)t.push(mh(e));return t.length===0?{kind:`empty`}:t.length===1?t[0]:{kind:`concat`,items:t}}function gh(e){let t=[hh(e)];for(;e.eat(124);)t.push(hh(e));return t.length===1?t[0]:{kind:`alt`,branches:t}}function _h(e){let t=new Qm(Zm(e)),n=gh(t);if(!t.eof())throw new Z(`Unmatched closing parenthesis`,!1);return n}function vh(e){let t=e;for(;t.kind===`group`;)t=t.child;return t}function yh(e){switch(e.kind){case`empty`:case`anchor`:case`lookahead`:return!0;case`charSet`:return!1;case`group`:return yh(e.child);case`repeat`:return e.min===0||yh(e.child);case`concat`:return e.items.every(yh);case`alt`:return e.branches.some(yh)}}function bh(e){switch(e.kind){case`empty`:case`anchor`:case`lookahead`:return[];case`charSet`:return e.ranges;case`group`:return bh(e.child);case`repeat`:return e.max===0?[]:bh(e.child);case`alt`:return Hm(e.branches.flatMap(bh));case`concat`:{let t=[];for(let n of e.items)if(t.push(...bh(n)),!yh(n))break;return Hm(t)}}}function xh(e){switch(e.kind){case`empty`:case`anchor`:case`lookahead`:return[];case`charSet`:return e.ranges;case`group`:return xh(e.child);case`repeat`:return e.max===0?[]:xh(e.child);case`concat`:return Hm(e.items.flatMap(xh));case`alt`:return Hm(e.branches.flatMap(xh))}}function Sh(e){switch(e.kind){case`empty`:case`charSet`:case`anchor`:return!1;case`group`:case`lookahead`:return Sh(e.child);case`repeat`:return e.max===null||Sh(e.child);case`concat`:return e.items.some(Sh);case`alt`:return e.branches.some(Sh)}}function Ch(e){switch(e.kind){case`empty`:case`charSet`:case`anchor`:return!1;case`group`:case`lookahead`:return Ch(e.child);case`repeat`:return(e.max===null||e.max>1)&&Sh(e.child)?!0:Ch(e.child);case`concat`:return e.items.some(Ch);case`alt`:return e.branches.some(Ch)}}function wh(e){let t=e.map(e=>bh(vh(e)));for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++)if(Ym(t[e],t[n]))return!0;return!1}function Th(e){switch(e.kind){case`empty`:case`charSet`:case`anchor`:return!1;case`group`:case`lookahead`:return Th(e.child);case`repeat`:{let t=vh(e.child);return e.max===null&&t.kind===`alt`&&wh(t.branches)?!0:Th(e.child)}case`concat`:return e.items.some(Th);case`alt`:return e.branches.some(Th)}}function Eh(e){for(let t=0;t<e.length;t++){let n=vh(e[t]);if(n.kind!==`repeat`||n.max!==null)continue;let r=xh(n.child);for(let n=t+1;n<e.length;n++){let t=vh(e[n]);if(t.kind===`repeat`&&t.max===null&&Ym(r,xh(t.child)))return!0;if(!yh(e[n]))break}}return!1}function Dh(e){switch(e.kind){case`empty`:case`charSet`:case`anchor`:return!1;case`group`:case`lookahead`:case`repeat`:return Dh(e.child);case`concat`:return Eh(e.items)||e.items.some(Dh);case`alt`:return e.branches.some(Dh)}}function Oh(e,t){return Xm(e)>256?`PATTERN_TOO_LONG`:Ch(t)?`NESTED_QUANTIFIER`:Th(t)?`OVERLAPPING_ALTERNATION`:Dh(t)?`ADJACENT_OVERLAP`:null}function kh(e){if(Xm(e)>256)return{ok:!1,reason:`PATTERN_TOO_LONG`,detail:`Pattern exceeds maximum length of 256 code points`};let t;try{t=_h(e)}catch(e){if(e instanceof Z)return{ok:!1,reason:`UNSUPPORTED_SYNTAX`,detail:e.message};throw e}let n=Oh(e,t);return n===null?{ok:!0,tree:t}:{ok:!1,reason:n,detail:`Unsafe regex pattern (${n})`}}var Ah=`en-US`;function jh(e){if(!e)return Ah;try{return Intl.NumberFormat.supportedLocalesOf(e).length>0?e:Ah}catch{return Ah}}function Mh(e){if(e==null)return``;if(typeof e==`object`)try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function Nh(e){let t=!0;return(e==null||typeof e==`string`&&e===``||Array.isArray(e)&&e.length===0)&&(t=!1),{valid:t,...t?{}:{message:`This field is required.`}}}var Ph=256,Fh=/* @__PURE__ */ new Map;function Ih(e){let t=Fh.get(e);if(t!==void 0)return Fh.delete(e),Fh.set(e,t),t;let n=kh(e);if(!n.ok)throw new F(`Invalid or unsafe regex pattern (${n.reason}): ${e}`,`regex`);let r;try{r=new RegExp(e,`u`)}catch(t){throw new F(`Invalid regex pattern (UNSUPPORTED_SYNTAX): ${e}`,`regex`,t)}if(Fh.size>=Ph){let e=Fh.keys().next().value;e!==void 0&&Fh.delete(e)}return Fh.set(e,r),r}function Lh(e,t){let n=Ih(t),r=String(e??``);if(Xm(r)>4096)return{valid:!1,message:`Value exceeds the maximum length for pattern matching.`};let i=n.test(r);return{valid:i,...i?{}:{message:`Value does not match required pattern.`}}}function Rh(e,t,n){let r=0;(typeof e==`string`||Array.isArray(e))&&(r=e.length);let i=!0,a;return t!==void 0&&!isNaN(t)&&r<t?(i=!1,a=`Minimum length is ${t}.`):n!==void 0&&!isNaN(n)&&r>n&&(i=!1,a=`Maximum length is ${n}.`),{valid:i,...a?{message:a}:{}}}function zh(e,t,n){let r=Number(e);if(isNaN(r))return{valid:!1,message:`Value must be a valid number.`};let i=!0,a;return t!==void 0&&!isNaN(t)&&r<t?(i=!1,a=`Minimum value is ${t}.`):n!==void 0&&!isNaN(n)&&r>n&&(i=!1,a=`Maximum value is ${n}.`),{valid:i,...a?{message:a}:{}}}var Bh=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;function Vh(e){let t=typeof e==`string`&&Bh.test(e);return{valid:t,...t?{}:{code:`INVALID_EMAIL`,severity:`error`,message:`Please enter a valid email address (e.g. user@example.com).`}}}var Hh=/* @__PURE__ */ new Map;function Uh(e,t,n){let r=`${e}:${t??`undef`}:${n??`true`}`,i=Hh.get(r);return i||(i=new Intl.NumberFormat(e,{minimumFractionDigits:t,maximumFractionDigits:t,useGrouping:n}),Hh.set(r,i)),i}var Wh=/* @__PURE__ */ new Map;function Gh(e,t,n,r){let i=`${e}:${t}:${n??`undef`}:${r??`true`}`,a=Wh.get(i);return a||(a=new Intl.NumberFormat(e,{style:`currency`,currency:t,minimumFractionDigits:n,maximumFractionDigits:n,useGrouping:r}),Wh.set(i,a)),a}var Kh=`USD`,qh=/* @__PURE__ */ new Map;function Jh(e,t,n){let r=`${e}:${t??`undef`}:${n??`true`}`,i=qh.get(r);return i||(i=new Intl.NumberFormat(e,{style:`currency`,currency:Kh,currencyDisplay:`code`,minimumFractionDigits:t,maximumFractionDigits:t,useGrouping:n}),qh.set(r,i)),i}var Yh=/* @__PURE__ */ new Map;function Xh(e){let t=Yh.get(e);if(!t){let n=(t,n)=>{let r=new Intl.DateTimeFormat(e,{...t,timeZone:`UTC`});return n.map(e=>r.format(e))},r=Array.from({length:12},(e,t)=>new Date(Date.UTC(2021,t,15))),i=Array.from({length:7},(e,t)=>new Date(Date.UTC(2021,2,1+t)));t={monthsLong:n({month:`long`},r),monthsShort:n({month:`short`},r),weekdaysLong:n({weekday:`long`},i),weekdaysShort:n({weekday:`short`},i)},Yh.set(e,t)}return t}var Zh=/yyyy|yy|MMMM|MMM|MM|M|EEEE|E|dd|d|HH|H|hh|h|mm|ss|a/g,Qh=/(?:Z|[+-]\d{2}:?\d{2})$/,$h=/^([+-]?\d{4,6})-(\d{2})-(\d{2})(?:[T ](\d{2})(?::(\d{2})(?::(\d{2}))?)?)?/;function eg(e){let t=Qh.test(e),n=new Date(t?e:`${e}Z`);if(isNaN(n.getTime()))return null;let r=0,i=/([+-])(\d{2}):?(\d{2})$/.exec(e);i&&(r=(i[1]===`-`?-1:1)*(Number(i[2])*60+Number(i[3])));let a=new Date(n.getTime()+r*6e4);return tg(e,a)?{shifted:a,instant:n}:null}function tg(e,t){let n=$h.exec(e);if(!n)return!1;let r=e=>n[e]===void 0?void 0:Number(n[e]);return r(1)===t.getUTCFullYear()&&r(2)===t.getUTCMonth()+1&&r(3)===t.getUTCDate()&&(r(4)??t.getUTCHours())===t.getUTCHours()&&(r(5)??t.getUTCMinutes())===t.getUTCMinutes()&&(r(6)??t.getUTCSeconds())===t.getUTCSeconds()}var ng=/* @__PURE__ */ new Map;function rg(e){let t=ng.get(e);return t||(t=new Intl.PluralRules(e),ng.set(e,t)),t}function ig(e,t=bu){if(!Array.isArray(e)||e.length<2)throw new F(`and requires at least 2 values`,`and`);return e.every(t)}function ag(e,t=bu){if(!Array.isArray(e)||e.length<2)throw new F(`or requires at least 2 values`,`or`);return e.some(t)}function og(e,t=bu){return!t(e)}function sg(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function cg(e,t){if(Array.isArray(e))return e.map(e=>cg(e,t));if(typeof e!=`object`||!e)return e;if(typeof e.path==`string`&&e.componentId===void 0&&e[`@path`]===void 0)return{"@path":e.path};let n=typeof e.call==`string`,r=typeof e[`@call`]==`string`,i=n&&!r?e.call:r?e[`@call`]:void 0;if(i!==void 0){let n={};if(e.args&&typeof e.args==`object`&&!Array.isArray(e.args))for(let[r,i]of Object.entries(e.args))sg(n,r,cg(i,t));let r=e.catalogId!==void 0&&e.catalogId!==null?e.catalogId:t!==void 0&&!i.startsWith(`@`)?t:void 0;return r===void 0?{"@call":i,args:n}:{"@call":i,args:n,catalogId:r}}let a={};for(let[n,r]of Object.entries(e))sg(a,n,cg(r,t));return a}function lg(e,t){let n=new Om().parse(e);if(n.length===0)return``;let r=typeof t.atLeastV10==`boolean`?t.atLeastV10:R(t.surface?.protocolVersion??t.surface?.defaultCatalog?.protocolVersion,`1.0`),i=r?oi(t):void 0,a=r?ai(t):t,o=n.map(e=>{if(typeof e!=`object`||!e||Array.isArray(e))return e;let t=r?cg(e,i):e;return a.resolveSignal(t)});return fn(()=>o.map(e=>Mh(hn(e)?gn(e):e)).join(``))}function ug(e,t,n,r=Ah){return isNaN(e)?``:Uh(r,t,n).format(e)}function dg(e,t,n=2,r,i=Ah){if(isNaN(e))return``;let a=String(t).toUpperCase();try{return Gh(i,a,n,r).format(e)}catch{return Jh(i,n,r).formatToParts(e).map(e=>e.type===`currency`?a:e.value).join(``)}}function fg(e,t=`yyyy-MM-dd`,n=Ah){if(!e)return``;let r=eg(String(e));if(!r)return``;let{shifted:i,instant:a}=r,o=t||`yyyy-MM-dd`;if(o===`ISO`)return a.toISOString();let s=Xh(n),c=(i.getUTCDay()+6)%7,l=i.getUTCHours(),u=l%12||12;return o.replace(Zh,e=>{switch(e){case`yyyy`:return String(i.getUTCFullYear());case`yy`:return String(i.getUTCFullYear()).slice(-2);case`MMMM`:return s.monthsLong[i.getUTCMonth()];case`MMM`:return s.monthsShort[i.getUTCMonth()];case`MM`:return String(i.getUTCMonth()+1).padStart(2,`0`);case`M`:return String(i.getUTCMonth()+1);case`EEEE`:return s.weekdaysLong[c];case`E`:return s.weekdaysShort[c];case`dd`:return String(i.getUTCDate()).padStart(2,`0`);case`d`:return String(i.getUTCDate());case`HH`:return String(l).padStart(2,`0`);case`H`:return String(l);case`hh`:return String(u).padStart(2,`0`);case`h`:return String(u);case`mm`:return String(i.getUTCMinutes()).padStart(2,`0`);case`ss`:return String(i.getUTCSeconds()).padStart(2,`0`);case`a`:return l<12?`AM`:`PM`;default:return e}})}function pg(e,t,n=Ah){let r;return r=e===0&&t.zero!==void 0?`zero`:e===1&&t.one!==void 0?`one`:e===2&&t.two!==void 0?`two`:rg(n).select(e),String(t[r]??t.other??``)}function mg(e){let t=typeof e==`string`?e:void 0;if(!t||typeof window>`u`||typeof window.open!=`function`)return;let n=typeof window<`u`&&window.location!==void 0&&window.location.href?window.location.href:void 0,r;try{r=n?new URL(t,n):new URL(t)}catch(e){throw new F(`Invalid URL specified: ${t}`,`openUrl`,e)}if(r.protocol!==`https:`&&r.protocol!==`http:`&&r.protocol!==`mailto:`&&r.protocol!==`tel:`)throw new F(`Unsupported URL scheme: ${r.protocol}`,`openUrl`);window.open(r.href,`_blank`,`noopener,noreferrer`)}function hg(e,{truthy:t=bu}={}){return Y(e,e=>ig(e.values,t))}function gg(e,{truthy:t=bu}={}){return Y(e,e=>ag(e.values,t))}function _g(e,{truthy:t=bu}={}){return Y(e,e=>og(e.value,t))}function vg(e){return Y(e,(e,t)=>lg(e.value,t))}function yg(e,t){let n=jh(t);return Y(e,e=>ug(e.value,e.decimals,e.grouping,n))}function bg(e,t){let n=jh(t);return Y(e,e=>dg(e.value,e.currency,e.decimals??2,e.grouping,n))}function xg(e,t){let n=jh(t);return Y(e,e=>fg(e.value,e.format,n))}function Sg(e,t){let n=jh(t);return Y(e,e=>pg(e.value,e,n))}function Cg(e){return Y(e,e=>mg(e.url))}var wg=[Y(mm,e=>e.a+e.b),Y(hm,e=>e.a-e.b),Y(gm,e=>e.a*e.b),Y(_m,e=>{let t=Number(e.a),n=Number(e.b);return Number.isNaN(t)||Number.isNaN(n)?NaN:n===0?1/0:t/n}),Y(vm,e=>e.a===e.b),Y(ym,e=>e.a!==e.b),Y(bm,e=>e.a>e.b),Y(xm,e=>e.a<e.b),Y(Sm,e=>e.string.includes(e.substring)),Y(Cm,e=>e.string.startsWith(e.prefix)),Y(wm,e=>e.string.endsWith(e.suffix))],Tg=hg(cm),Eg=gg(lm),Dg=_g(um),Og=Y(Zp,e=>Nh(e.value).valid),kg=Y(Qp,e=>Lh(e.value,e.pattern).valid),Ag=Y($p,e=>Rh(e.value,e.min,e.max).valid),jg=Y(em,e=>zh(e.value,e.min,e.max).valid),Mg=Y(tm,e=>Vh(e.value).valid),Ng=vg(nm);function Pg(e){return yg(rm,e)}Pg();function Fg(e){return bg(im,e)}Fg();function Ig(e){return xg(am,e)}Ig();function Lg(e){return Sg(om,e)}Lg();var Rg=Cg(sm);function zg(e){let t=e?.locale;return[Og,kg,Ag,jg,Mg,Ng,Pg(t),Fg(t),Ig(t),Lg(t),Rg,Tg,Eg,Dg]}var Bg=zg();function Vg(e){return[...wg,...zg(e)]}Vg();var Hg={accountCircle:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6zm0 14c-2.03 0-4.43-.82-6.14-2.88a9.947 9.947 0 0 1 12.28 0C16.43 19.18 14.03 20 12 20z`,add:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z`,arrowBack:`M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z`,arrowForward:`m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z`,attachFile:`M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5a2.5 2.5 0 0 1 5 0v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5a2.5 2.5 0 0 0 5 0V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z`,calendarToday:`M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z`,call:`M20.01 15.38c-1.23 0-2.42-.2-3.53-.56a.977.977 0 0 0-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z`,camera:`M12 8.8a3.2 3.2 0 1 0 0 6.4 3.2 3.2 0 1 0 0-6.4z M9 2 7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z`,check:`M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z`,close:`M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`,delete:`M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z`,download:`M5 20h14v-2H5v2zM19 9h-4V3H9v6H5l7 7 7-7z`,edit:`M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 0 0 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z`,error:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z`,event:`M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z`,fastForward:`m4 18 8.5-6L4 6v12zm9-12v12l8.5-6L13 6z`,favorite:`m12 21.35-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z`,favoriteOff:`M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z`,folder:`M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z`,help:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z`,home:`M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z`,info:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z`,locationOn:`M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5a2.5 2.5 0 0 1 0-5 2.5 2.5 0 0 1 0 5z`,lock:`M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z`,lockOpen:`M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6h1.9c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm0 12H6V10h12v10z`,mail:`M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z`,menu:`M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z`,moreHoriz:`M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z`,moreVert:`M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z`,notifications:`M12 22c1.1 0 2-.9 2-2h-4a2 2 0 0 0 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z`,notificationsOff:`M20 18.69 7.84 6.14 5.27 3.49 4 4.76l2.8 2.8v.01c-.52.99-.8 2.16-.8 3.42v5l-2 2v1h13.73l2 2L21 19.72l-1-1.03zM12 22c1.11 0 2-.89 2-2h-4c0 1.11.89 2 2 2zm6-7.32V11c0-3.08-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68c-.15.03-.29.08-.42.12-.1.03-.2.07-.3.11h-.01c-.01 0-.01 0-.02.01-.23.09-.46.2-.68.31 0 0-.01 0-.01.01L18 14.68z`,pause:`M6 19h4V5H6v14zm8-14v14h4V5h-4z`,payment:`M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z`,person:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z`,phone:`M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z`,photo:`M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z`,play:`M8 5v14l11-7z`,print:`M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z`,refresh:`M17.65 6.35A7.958 7.958 0 0 0 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z`,rewind:`M11 18V6l-8.5 6 8.5 6zm.5-6 8.5 6V6l-8.5 6z`,search:`M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z`,send:`M2.01 21 23 12 2.01 3 2 10l15 2-15 2z`,settings:`M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z`,share:`M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 2.92-2.92s-1.31-2.92-2.92-2.92z`,shoppingCart:`M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zM1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49A1.003 1.003 0 0 0 20 4H5.21l-.94-2H1zm16 16c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z`,skipNext:`m6 18 8.5-6L6 6v12zM16 6v12h2V6h-2z`,skipPrevious:`M6 6h2v12H6zm3.5 6 8.5 6V6z`,star:`M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z`,starHalf:`m22 9.24-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4V6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z`,starOff:`m22 9.24-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z`,stop:`M6 6h12v12H6z`,upload:`M5 20h14v-2H5v2zm0-10h4v6h6v-6h4l-7-7-7 7z`,visibility:`M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z`,visibilityOff:`M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46A11.804 11.804 0 0 0 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z`,volumeDown:`M18.5 12A4.5 4.5 0 0 0 16 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z`,volumeMute:`M7 9v6h4l5 5V4l-5 5H7z`,volumeOff:`M16.5 12A4.5 4.5 0 0 0 14 7.97v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51A8.796 8.796 0 0 0 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06a8.99 8.99 0 0 0 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4 9.91 6.09 12 8.18V4z`,volumeUp:`M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z`,warning:`M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z`};function Q(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!==void 0&&(r.textContent=n),r}function $(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function Ug(e,t){e.style.flex=typeof t==`number`?String(t):``}function Wg(e){let t=e.accessibility;if(o(t)&&typeof t.label==`string`)return t.label||void 0}function Gg(e,t,n){n===void 0?e.removeAttribute(t):e.setAttribute(t,n)}function Kg(e,t){let n=Wg(t);Gg(e,`role`,n===void 0?void 0:`group`),Gg(e,`aria-label`,n)}function qg(e){let t=e.validationErrors;return Array.isArray(t)?t.map($).join(` `):``}function Jg(e,t,n){let r=qg(n);e.textContent=r,e.hidden=r===``,Gg(t,`aria-invalid`,r===``?void 0:`true`)}function Yg(e,t){let n=Q(`p`,`a2ui-error`);return n.id=e.uid(),n.hidden=!0,t.setAttribute(`aria-describedby`,n.id),n}function Xg(e){let t=$(e);return/^https?:\/\//i.test(t)?t:null}function Zg(e,t){return typeof e==`string`?{id:e,path:t}:o(e)&&typeof e.id==`string`?{id:e.id,path:typeof e.basePath==`string`?e.basePath:t}:null}function Qg(e,t){let n=/* @__PURE__ */ new Map;return{sync(r,i){let a=/* @__PURE__ */ new Map,o=[];for(let r of Array.isArray(i)?i:[i]){let i=Zg(r,t);if(!i)continue;let s=`${i.id}@${i.path}`,c=a.get(s)??n.get(s)??e.mount(i.id,i.path);a.set(s,c),o.push(c.el)}for(let[e,t]of n)a.has(e)||t.dispose();n=a;let s=r.children;(o.length!==s.length||o.some((e,t)=>e!==s[t]))&&r.replaceChildren(...o)},dispose(){for(let e of n.values())e.dispose();n.clear()}}}var $g=[`h1`,`h2`,`h3`,`h4`,`h5`],e_=e=>{let t=Q(`div`,`a2ui-text`),n=null;return{el:t,update(i){Ug(t,i.weight);let a=$(i.variant)||`body`,o=$(i.text),s=`${a}\n${o}`;if(s===n)return;n=s;let c=$g.find(e=>e===a);if(c)t.replaceChildren(Q(c,`a2ui-title`,o));else if(a===`caption`)t.replaceChildren(Q(`span`,`a2ui-caption`,o));else{let n=Q(`div`,`markdown`);r(n,o,{host:e.env.host,widgets:!1,lang:e.env.lang,strings:e.strings});for(let e of n.querySelectorAll(`a`))e.replaceWith(...e.childNodes);t.replaceChildren(n)}}}},t_=`http://www.w3.org/2000/svg`,n_=()=>{let e=Q(`span`,`a2ui-icon`);return{el:e,update(t){let n=t.name,r=typeof n==`string`?Hg[n]:o(n)&&typeof n.svgPath==`string`?n.svgPath:void 0;if(r===void 0){e.replaceChildren();return}let i=document.createElementNS(t_,`svg`);i.setAttribute(`viewBox`,`0 0 24 24`);let a=document.createElementNS(t_,`path`);a.setAttribute(`d`,r),a.setAttribute(`fill`,`currentColor`),i.append(a),e.replaceChildren(i);let s=Wg(t);Gg(e,`role`,s===void 0?void 0:`img`),Gg(e,`aria-label`,s),Gg(e,`aria-hidden`,s===void 0?`true`:void 0)}}},r_=e=>()=>{let t=Q(`span`,`a2ui-media a2ui-${e}`);return{el:t,update(e){Ug(t,e.weight),t.textContent=$(e.description)||(Wg(e)??Xg(e.url)??``)}}},i_=e=>(t,n)=>{let r=Q(`div`,`a2ui-${e}`),i=Qg(t,n);return{el:r,update(t){Ug(r,t.weight),Kg(r,t),r.dataset.justify=$(t.justify)||`start`,r.dataset.align=$(t.align)||`stretch`,e===`list`&&(r.dataset.direction=$(t.direction)||`vertical`),i.sync(r,t.children)},dispose:()=>i.dispose()}},a_=(e,t)=>{let n=Q(`div`,`a2ui-card`),r=Qg(e,t);return{el:n,update(e){Ug(n,e.weight),Kg(n,e),r.sync(n,e.child)},dispose:()=>r.dispose()}},o_=()=>{let e=Q(`hr`,`a2ui-divider`);return{el:e,update(t){let n=t.axis===`vertical`;e.classList.toggle(`vertical`,n),Gg(e,`aria-orientation`,n?`vertical`:void 0)}}},s_=(e,t)=>{let n=Q(`div`,`a2ui-tabs`),r=Q(`div`,`a2ui-tablist`);r.setAttribute(`role`,`tablist`),r.setAttribute(`aria-label`,e.strings.a2uiTabs);let i=Q(`div`,`a2ui-tabpanel`);i.id=e.uid(),i.setAttribute(`role`,`tabpanel`),n.append(r,i);let a=Qg(e,t),s=0,c={},l=()=>{let e=Array.isArray(c.tabs)?c.tabs.filter(o):[];n.hidden=e.length===0,s>=e.length&&(s=0),r.replaceChildren(...e.map((e,t)=>{let n=Q(`button`,`a2ui-tab`,$(e.title));return n.type=`button`,n.setAttribute(`role`,`tab`),n.setAttribute(`aria-selected`,String(t===s)),n.setAttribute(`aria-controls`,i.id),n.addEventListener(`click`,()=>{s=t,l()}),n})),a.sync(i,e[s]?.child)};return{el:n,update(e){Ug(n,e.weight),c=e,l()},dispose:()=>a.dispose()}},c_=(e,t)=>{let n=Q(`span`,`a2ui-modal`),r=Q(`span`,`a2ui-modal-trigger`),i=Q(`dialog`,`a2ui-dialog`),a=Q(`h2`,`a2ui-title`,e.strings.a2uiDetails);a.id=e.uid(),i.setAttribute(`aria-labelledby`,a.id);let o=Q(`div`,`a2ui-dialog-body`),s=Q(`button`,`a2ui-button`,e.strings.close);s.type=`button`,s.dataset.variant=`default`;let c=Q(`div`,`a2ui-dialog-footer`);c.append(s),i.append(a,o,c),n.append(r,i);let l=Qg(e,t),u=Qg(e,t),d={};return r.addEventListener(`click`,()=>{u.sync(o,d.content),i.showModal()}),s.addEventListener(`click`,()=>i.close()),i.addEventListener(`close`,()=>u.sync(o,[])),{el:n,update(e){d=e,l.sync(r,e.trigger),i.open&&u.sync(o,e.content)},dispose(){l.dispose(),u.dispose()}}},l_=(e,t)=>{let n=Q(`button`,`a2ui-button`);n.type=`button`;let r=Qg(e,t),i={};return e.control(n,()=>i.isValid===!1),n.addEventListener(`click`,()=>{let e=i.action;typeof e==`function`&&e()}),{el:n,update(t){i=t,Ug(n,t.weight),n.dataset.variant=$(t.variant)||`default`,Gg(n,`aria-label`,Wg(t)),r.sync(n,t.child),e.refresh(n)},dispose:()=>r.dispose()}};function u_(e,t=`setValue`){let n=e[t];return typeof n==`function`?n:()=>void 0}function d_(e,t){let n=Q(`div`,`a2ui-field`),r=Q(`label`,`a2ui-label`);t.id=e.uid(),r.htmlFor=t.id;let i=Yg(e,t);return n.append(r,t,i),e.control(t),{el:n,label:r,errors:i}}var f_=e=>{let t=null,n=null,r=``,i={},a=Q(`div`,`a2ui-field-wrapper`);return{el:a,update(o){i=o;let s=$(o.variant)||`shortText`;if(s!==r||!t||!n){if(r=s,s===`longText`)t=Q(`textarea`,`a2ui-input`);else{let e=Q(`input`,`a2ui-input`);e.type=s===`number`?`number`:s===`obscured`?`password`:`text`,t=e}t.addEventListener(`input`,e=>{u_(i)(e.target.value)}),n=d_(e,t),a.replaceChildren(n.el)}Ug(a,o.weight),n.label.textContent=$(o.label),Gg(t,`aria-label`,Wg(o));let c=$(o.value);t.value!==c&&(t.value=c),Jg(n.errors,t,o)}}},p_=e=>{let t=Q(`div`,`a2ui-field`),n=Q(`label`,`a2ui-check`),r=Q(`input`);r.type=`checkbox`;let i=Q(`span`);n.append(r,i);let a=Yg(e,r);t.append(n,a),e.control(r);let o={};return r.addEventListener(`change`,()=>u_(o)(r.checked)),{el:t,update(e){o=e,Ug(t,e.weight),i.textContent=$(e.label),r.checked=e.value===!0,Jg(a,r,e)}}},m_=e=>{let t=Q(`fieldset`,`a2ui-choices`),n=Q(`legend`,`a2ui-label`),r=Q(`div`,`a2ui-options`),i=Yg(e,t);t.append(n,r,i);let a=e.uid(),s={},c=``,l=e=>{let t=e.value;return Array.isArray(t)?t.filter(e=>typeof e==`string`):typeof t==`string`?[t]:[]},u=(e,t)=>{let n=s.variant===`multipleSelection`,r=l(s).filter(t=>t!==e);u_(s)(n?t?[...r,e]:r:t?[e]:[])};return{el:t,update(d){s=d,Ug(t,d.weight),n.textContent=$(d.label),n.hidden=n.textContent===``,Gg(t,`aria-label`,Wg(d));let f=(Array.isArray(d.options)?d.options:[]).filter(o).map(e=>({value:$(e.value),label:$(e.label)})),p=$(d.displayStyle),m=d.variant===`multipleSelection`,h=JSON.stringify([p,m,f]),g=l(d);h!==c&&(c=h,r.dataset.style=p===`chips`?`chips`:`list`,r.replaceChildren(...f.map(t=>{if(p===`chips`){let n=Q(`button`,`a2ui-chip`,t.label);return n.type=`button`,n.dataset.value=t.value,n.addEventListener(`click`,()=>u(t.value,n.getAttribute(`aria-pressed`)!==`true`)),e.control(n),n}let n=Q(`label`,`a2ui-check`),r=Q(`input`);return r.type=m?`checkbox`:`radio`,r.name=a,r.dataset.value=t.value,r.addEventListener(`change`,()=>u(t.value,r.checked)),e.control(r),n.append(r,Q(`span`,void 0,t.label)),n})));for(let e of r.querySelectorAll(`.a2ui-chip`))e.setAttribute(`aria-pressed`,String(g.includes(e.dataset.value??``)));for(let e of r.querySelectorAll(`input`))e.checked=g.includes(e.dataset.value??``);Jg(i,t,d)}}},h_=e=>{let t=Q(`input`,`a2ui-range`);t.type=`range`;let n=d_(e,t),r={};return t.addEventListener(`input`,()=>u_(r)(Number(t.value))),{el:n.el,update(e){r=e,Ug(n.el,e.weight);let i=typeof e.value==`number`?e.value:void 0,a=$(e.label)||(Wg(e)??``);n.label.textContent=i===void 0?a:a?`${a}: ${i}`:String(i);let o=typeof e.min==`number`?e.min:0;t.min=String(o),t.max=typeof e.max==`number`?String(e.max):``;let s=String(i??o);t.value!==s&&(t.value=s),Jg(n.errors,t,e)}}};function g_(e,t){if(!e)return``;let[n=``,r=``]=e.includes(`T`)?e.split(`T`,2):e.includes(`-`)?[e,``]:[``,e],i=n.slice(0,10),a=r.includes(`:`)?r.slice(0,5):``;return t===`date`?i:t===`time`?a:i?`${i}T${a||`00:00`}`:``}var __={Text:e_,Image:r_(`image`),Icon:n_,Video:r_(`video`),AudioPlayer:r_(`audio`),Row:i_(`row`),Column:i_(`column`),List:i_(`list`),Card:a_,Tabs:s_,Modal:c_,Divider:o_,Button:l_,TextField:f_,CheckBox:p_,ChoicePicker:m_,Slider:h_,DateTimeInput:e=>{let t=Q(`input`,`a2ui-input`),n=d_(e,t),r={};return t.addEventListener(`input`,()=>u_(r)(t.value)),{el:n.el,update(e){r=e,Ug(n.el,e.weight);let i=e.enableTime===!0,a=(typeof e.enableDate==`boolean`?e.enableDate:!i)&&i?`datetime-local`:i?`time`:`date`;t.type!==a&&(t.type=a),n.label.textContent=$(e.label),Gg(t,`aria-label`,Wg(e));let o=g_($(e.value),a);t.value!==o&&(t.value=o),Gg(t,`min`,g_($(e.min),a)||void 0),Gg(t,`max`,g_($(e.max),a)||void 0),Jg(n.errors,t,e)}}}},v_=`https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json`,y_=Bg.filter(e=>e.name!==`openUrl`),b_=new Eu(v_,`0.9`,[Np,Pp,Fp,Ip,Lp,Rp,zp,Bp,Vp,Hp,Up,Wp,Gp,Kp,qp,Jp,Yp,Xp],y_,{themeSchema:Mp}),x_=/^https:\/\/a2ui\.org\/specification\/v0_9(?:_\d+)?\/catalogs\/basic\/catalog\.json$/;function S_(e){return e.map(e=>{let t=e.createSurface;return!o(t)||typeof t.catalogId!=`string`||t.catalogId===v_||!x_.test(t.catalogId)?e:{...e,createSurface:{...t,catalogId:v_}}})}function C_(e,t){return e.map(e=>{let n=e.updateComponents;if(!o(n)||!Array.isArray(n.components))return e;let r=n.components,i=r.map(e=>o(e)?t(e):e);return i.some((e,t)=>e!==r[t])?{...e,updateComponents:{...n,components:i}}:e})}function w_(e){return C_(e,e=>e.component===`Icon`&&typeof e.name==`string`&&!(e.name in Hg)?{id:e.id,component:`Text`,text:``}:e)}function T_(e){let t=e;for(let e=0;e<16&&t?._def;e++){let e=t._def,n=e.innerType??e.schema??(e.getter?e.getter():void 0);if(!n)return t;t=n}return t}var E_=/* @__PURE__ */ new Map;function D_(e){let t=E_.get(e);if(t)return t;t=/* @__PURE__ */ new Map;let n=T_(b_.components.get(e)?.schema)?._def?.shape?.()??{};for(let[e,r]of Object.entries(n)){let n=T_(r)?._def;n?.typeName===`ZodEnum`&&Array.isArray(n.values)&&t.set(e,n.values)}return E_.set(e,t),t}var O_=e=>e.toLowerCase().replace(/[^a-z0-9]/g,``);function k_(e,t){let n=O_(e);return t.find(e=>{let t=O_(e);return t===n||t===`space${n}`||n===`flex${t}`})}function A_(e){return C_(e,e=>{if(typeof e.component!=`string`)return e;let t=D_(e.component),n;for(let[r,i]of Object.entries(e)){let a=t.get(r);if(typeof i!=`string`||!a||a.includes(i))continue;n??={...e};let o=k_(i,a);o===void 0?delete n[r]:n[r]=o}return n??e})}function j_(e,t){if(o(e)){if(o(e.error)&&typeof e.error.message==`string`)return e.error.message;if(typeof e.message==`string`)return e.message}return t}var M_=`
21
+ .a2ui { display: flex; flex-direction: column; gap: 8px; margin-block: 0 0.75em; padding: 20px; border: 1px solid var(--_border); border-radius: var(--_radius-sm); background: var(--_bg); overflow-x: auto; }
22
+ .a2ui[data-disabled] .a2ui-surface { opacity: 0.75; }
23
+ .a2ui-surface { display: flex; flex-direction: column; gap: 8px; }
24
+ .a2ui-row, .a2ui-column, .a2ui-list { display: flex; gap: 8px; min-inline-size: 0; }
25
+ .a2ui-row { flex-direction: row; flex-wrap: wrap; }
26
+ .a2ui-column, .a2ui-list { flex-direction: column; }
27
+ .a2ui-list[data-direction="horizontal"] { flex-direction: row; overflow-x: auto; }
28
+ [data-justify="center"] { justify-content: center; }
29
+ [data-justify="end"] { justify-content: flex-end; }
30
+ [data-justify="spaceBetween"] { justify-content: space-between; }
31
+ [data-justify="spaceAround"] { justify-content: space-around; }
32
+ [data-justify="spaceEvenly"] { justify-content: space-evenly; }
33
+ [data-justify="stretch"] { justify-content: stretch; }
34
+ [data-align="start"] { align-items: flex-start; }
35
+ [data-align="center"] { align-items: center; }
36
+ [data-align="end"] { align-items: flex-end; }
37
+ [data-align="stretch"] { align-items: stretch; }
38
+ .a2ui-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--_border); border-radius: var(--_radius-sm); background: var(--_bg); }
39
+ .a2ui-title { margin: 0; line-height: 1.3; }
40
+ h1.a2ui-title { font-size: 1.4em; } h2.a2ui-title { font-size: 1.25em; } h3.a2ui-title { font-size: 1.1em; }
41
+ h4.a2ui-title, h5.a2ui-title { font-size: 1em; }
42
+ .a2ui-caption { color: var(--_muted); font-size: 0.85em; }
43
+ .a2ui-icon { display: inline-flex; }
44
+ .a2ui-icon svg { inline-size: 24px; block-size: 24px; }
45
+ .a2ui-button .a2ui-icon svg { inline-size: 18px; block-size: 18px; }
46
+ .a2ui-divider { inline-size: 100%; margin: 4px 0; border: 0; border-block-start: 1px solid var(--_border); }
47
+ .a2ui-divider.vertical { inline-size: 1px; align-self: stretch; margin: 0; border: 0; background: var(--_border); }
48
+ .a2ui-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-block-size: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--_radius-sm); font-weight: 600; }
49
+ .a2ui-button[data-variant="primary"] { background: var(--_accent); color: var(--_on-accent); }
50
+ .a2ui-button[data-variant="primary"]:not(:disabled):hover { background: var(--_accent-hover); }
51
+ .a2ui-button[data-variant="default"] { background: var(--_accent-soft); color: var(--_accent-fg); }
52
+ .a2ui-button[data-variant="borderless"] { color: var(--_accent-fg); }
53
+ .a2ui-button[data-variant="borderless"]:not(:disabled):hover { background: var(--_raised); }
54
+ .a2ui-button .markdown p, .a2ui-button .a2ui-text { margin: 0; }
55
+ .a2ui-field, .a2ui-field-wrapper { display: flex; flex-direction: column; gap: 4px; min-inline-size: 0; }
56
+ .a2ui-label { font-weight: 600; font-size: 0.9em; padding: 0; }
57
+ .a2ui-input { font: inherit; color: inherit; padding: 8px 10px; border: 1px solid var(--_border); border-radius: var(--_radius-sm); background: var(--_bg); }
58
+ textarea.a2ui-input { min-block-size: 5em; resize: vertical; }
59
+ .a2ui-input:focus-visible, .a2ui-range:focus-visible, .a2ui-check input:focus-visible, .a2ui-chip:focus-visible, .a2ui-button:focus-visible, .a2ui-tab:focus-visible { outline: 2px solid var(--_accent); outline-offset: 2px; }
60
+ .a2ui-input[aria-invalid="true"] { border-color: var(--_danger); }
61
+ .a2ui-error { margin: 0; color: var(--_danger); font-size: 0.85em; }
62
+ .a2ui-check { display: inline-flex; align-items: center; gap: 8px; }
63
+ .a2ui-check input { accent-color: var(--_accent); margin: 0; }
64
+ .a2ui-range { accent-color: var(--_accent); }
65
+ .a2ui-choices { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-inline-size: 0; }
66
+ .a2ui-options { display: flex; flex-direction: column; gap: 6px; }
67
+ .a2ui-options[data-style="chips"] { flex-direction: row; flex-wrap: wrap; gap: 8px; }
68
+ .a2ui-chip { padding: 4px 12px; border: 1px solid var(--_border); border-radius: 999px; }
69
+ .a2ui-chip[aria-pressed="true"] { background: var(--_accent-soft); border-color: var(--_accent); color: var(--_accent-fg); }
70
+ .a2ui-tabs { display: flex; flex-direction: column; gap: 12px; }
71
+ .a2ui-tablist { display: flex; gap: 4px; border-block-end: 1px solid var(--_border); }
72
+ .a2ui-tab { padding: 6px 12px; border-block-end: 2px solid transparent; color: var(--_muted); }
73
+ .a2ui-tab[aria-selected="true"] { color: var(--_fg); border-block-end-color: var(--_accent); }
74
+ .a2ui-modal-trigger { display: contents; }
75
+ .a2ui-dialog { max-inline-size: min(560px, 90vw); padding: 20px; border: 1px solid var(--_border); border-radius: var(--_radius); background: var(--_bg); color: var(--_fg); }
76
+ .a2ui-dialog::backdrop { background: rgb(0 0 0 / 0.3); }
77
+ .a2ui-dialog-body { display: flex; flex-direction: column; gap: 8px; margin-block: 12px; }
78
+ .a2ui-dialog-footer { display: flex; justify-content: flex-end; }
79
+ .a2ui-sent { margin: 0; color: var(--_accent-fg); font-size: 0.85em; font-weight: 600; }
80
+ .a2ui-refused { margin: 0 0 4px; color: var(--_danger); font-size: 0.85em; font-weight: 600; }
81
+ .a2ui-placeholder { display: flex; flex-direction: column; gap: 8px; }
82
+ .a2ui-placeholder span { block-size: 12px; border-radius: 4px; background: var(--_raised); }
83
+ .a2ui-placeholder span:nth-child(1) { inline-size: 40%; }
84
+ .a2ui-placeholder span:nth-child(2) { block-size: 48px; }
85
+ .a2ui-placeholder span:nth-child(3) { inline-size: 30%; }
86
+ .a2ui-placeholder p { margin: 0; color: var(--_muted); font-size: 0.85em; }
87
+ `,N_;function P_(e){if(N_===void 0)try{N_=new CSSStyleSheet,N_.replaceSync(M_)}catch{N_=null}N_&&e.root!==document&&c(e.root,N_)}var F_=0;function I_(e){let t=document.createElement(`div`);t.className=`a2ui a2ui-placeholder`,t.setAttribute(`role`,`status`),t.append(document.createElement(`span`),document.createElement(`span`),document.createElement(`span`));let n=document.createElement(`p`);return n.textContent=e.strings.a2uiPreparing,t.append(n),t}function L_(e){let t=document.createElement(`pre`),n=document.createElement(`code`);return n.className=`language-a2ui`,n.textContent=`${e}\n`,t.append(n),t}function R_(e,t,n){let r=document.createElement(`div`),i=document.createElement(`p`);return i.className=`a2ui-refused`,i.setAttribute(`role`,`alert`),i.textContent=n.strings.a2uiRefused(t),r.append(i,L_(e)),r}function z_(e,t){let n=s(e);if(!n)return t.live?I_(t):null;P_(t);let r=t.interface??{working:t.live,sent:/* @__PURE__ */ new Map},o=!1,c=a(n),f=()=>o||c.some(e=>r.sent.has(e)),p=()=>f()||r.working||!r.send,m=new Mf([b_],e=>{let t=r.send;!p()&&t&&t(d({name:e.name,surfaceId:e.surfaceId,sourceComponentId:e.sourceComponentId,timestamp:e.timestamp,context:e.context}))&&(o=!0,v())}),h;try{h=m.processMessagesWithErrors(w_(A_(S_(n))))}catch(e){h=[e]}if(h.length>0)return m.dispose(),R_(e,j_(h[0],t.strings.a2uiInvalid),t);let g=c.flatMap(e=>{let t=r.sent.get(e);return t?u(n,t):[]});if(g.length>0)try{m.processMessagesWithErrors(g)}catch{}let _=document.createElement(`div`);_.className=`a2ui`;let ee=/* @__PURE__ */ new Map,te=(e,t)=>{e.disabled=p()||t()},ne=[];for(let e of m.model.surfacesMap.values()){let n=B_(e,t,{control(e,t=()=>!1){ee.set(e,t),te(e,t)},refresh(e){let t=ee.get(e);t&&te(e,t)}}).mount(e.rootId,`/`),r=document.createElement(`div`);r.className=`a2ui-surface`,r.append(n.el),_.append(r),ne.push(n)}let re=document.createElement(`p`);re.className=`a2ui-sent`,re.textContent=t.strings.a2uiSent,_.append(re);function v(){_.toggleAttribute(`data-disabled`,p()),re.hidden=!f();for(let[e,t]of ee)_.contains(e)?te(e,t):ee.delete(e)}return v(),l.set(_,e=>{r=e,v()}),i.set(_,()=>{for(let e of ne)e.dispose();m.dispose(),l.delete(_)}),_}function B_(e,t,n){let r={env:t,strings:t.strings,...n,uid:()=>`a2ui-${++F_}`,mount(t,n){let i=e.componentsModel.get(t),a=i&&b_.components.get(i.type),o=i&&__[i.type];if(!i||!a||!o){let e=document.createElement(`span`);return e.hidden=!0,{el:e,dispose:()=>void 0}}let s=new If(e,t,n),c=new Dp(s,a.schema),l=o(r,s.dataContext.path);l.update(c.snapshot);let u=c.subscribe(e=>l.update(e));return{el:l.el,dispose(){u.unsubscribe(),c.dispose(),l.dispose?.()}}}};return r}export{z_ as draw};