@arcgis/portal-components 5.2.0-next.4 → 5.2.0-next.41

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 (207) hide show
  1. package/dist/cdn/2C475EKD.js +2 -0
  2. package/dist/cdn/3J46PXFF.js +3 -0
  3. package/dist/cdn/3MBOA5WF.js +2 -0
  4. package/dist/cdn/{GQFWFZXP.js → 3OBIA66A.js} +1 -1
  5. package/dist/cdn/3Z3ZPFGJ.js +2 -0
  6. package/dist/cdn/5NMFQE4U.js +2 -0
  7. package/dist/cdn/{7WZHZP6U.js → 63THOLAY.js} +9 -3
  8. package/dist/cdn/6AGZRMJC.js +2 -0
  9. package/dist/cdn/6DYBW2C6.js +2 -0
  10. package/dist/cdn/6RK4FBHZ.js +2 -0
  11. package/dist/cdn/6W2IHKCA.js +2 -0
  12. package/dist/cdn/7E5GJIZV.js +2 -0
  13. package/dist/cdn/AL57LV4E.js +2 -0
  14. package/dist/cdn/{LQ3DMZ3K.js → AXM6XCZD.js} +1 -1
  15. package/dist/cdn/AYR65LXN.js +65 -0
  16. package/dist/cdn/BUJPYZSX.js +2 -0
  17. package/dist/cdn/{DKBTJJMW.js → C7ZFXRPS.js} +1 -1
  18. package/dist/cdn/D76KMXZD.js +2 -0
  19. package/dist/cdn/DFTUMKSN.js +3 -0
  20. package/dist/cdn/DZJMNZY6.js +451 -0
  21. package/dist/cdn/EI6BAXCQ.js +2 -0
  22. package/dist/cdn/EVMYGWC6.js +637 -0
  23. package/dist/cdn/FXIP4QXJ.js +2 -0
  24. package/dist/cdn/GE75KDIM.js +2 -0
  25. package/dist/cdn/GJTJLK6T.js +2 -0
  26. package/dist/cdn/GKOXTQHB.js +2 -0
  27. package/dist/cdn/GQMPPCEL.js +2 -0
  28. package/dist/cdn/GXJU3U7U.js +2 -0
  29. package/dist/cdn/HMBSJR37.js +2 -0
  30. package/dist/cdn/HZ5W3DBR.js +2 -0
  31. package/dist/cdn/{V2EOXGK2.js → I234NUZ5.js} +1 -1
  32. package/dist/cdn/I5HSJRM3.js +2 -0
  33. package/dist/cdn/IBP5XPD5.js +2 -0
  34. package/dist/cdn/IC65R4QE.js +2 -0
  35. package/dist/cdn/IHSJ4MKS.js +2 -0
  36. package/dist/cdn/IJ3CLFAU.js +22 -0
  37. package/dist/cdn/IWUJRI4G.js +2 -0
  38. package/dist/cdn/{ZTHTFEYA.js → IXVR3KMC.js} +1 -1
  39. package/dist/cdn/{QNUYUNEY.js → JS45DWQ3.js} +1 -1
  40. package/dist/cdn/{DHHSKOUY.js → JV23HJTE.js} +1 -1
  41. package/dist/cdn/{LAFNDBTQ.js → JYIPREIH.js} +1 -1
  42. package/dist/cdn/JZKBUYPV.js +2 -0
  43. package/dist/cdn/KM5XGRXL.js +2 -0
  44. package/dist/cdn/{3PAHY5KA.js → KNRJ3WXR.js} +1 -1
  45. package/dist/cdn/L4DRNGOL.js +2 -0
  46. package/dist/cdn/{F6V7MLPY.js → L6KBBJEC.js} +1 -1
  47. package/dist/cdn/NJ2WDAJM.js +2 -0
  48. package/dist/cdn/NWIIOJEG.js +2 -0
  49. package/dist/cdn/{53MSUMA3.js → OT4PZJNB.js} +17 -1
  50. package/dist/cdn/POIXW2OA.js +2 -0
  51. package/dist/cdn/QE4CNVDQ.js +34 -0
  52. package/dist/cdn/{AQWTJKUH.js → QKCV7CY2.js} +10 -8
  53. package/dist/cdn/RKNDXSVK.js +2 -0
  54. package/dist/cdn/SLTFLCVR.js +99 -0
  55. package/dist/cdn/SUPKZF5M.js +2 -0
  56. package/dist/cdn/{GT26WGJS.js → SXZRHHXC.js} +1 -1
  57. package/dist/cdn/TJAX7J4T.js +2 -0
  58. package/dist/cdn/{DXCPWJU4.js → TKCE4WYE.js} +1 -1
  59. package/dist/cdn/U3FVMN32.js +2 -0
  60. package/dist/cdn/UZLQALHY.js +2 -0
  61. package/dist/cdn/{RR4BIAPA.js → V4EYW3O6.js} +1 -1
  62. package/dist/cdn/{74XFARCV.js → VW7DSKPH.js} +1 -1
  63. package/dist/cdn/W2SYL7IJ.js +71 -0
  64. package/dist/cdn/{W6PSG4GX.js → W4FGRGLV.js} +10 -5
  65. package/dist/cdn/{SYJSVUUR.js → W4SAWMXS.js} +1 -1
  66. package/dist/cdn/WBZLQZYR.js +134 -0
  67. package/dist/cdn/WGZZB2DJ.js +2 -0
  68. package/dist/cdn/WO23VQK3.js +2 -0
  69. package/dist/cdn/{2UUZHENH.js → WSNLUGEP.js} +1 -1
  70. package/dist/cdn/WSWHK6LB.js +2 -0
  71. package/dist/cdn/{WOZDQW3S.js → WX65MRDH.js} +1 -1
  72. package/dist/cdn/XEK22IDA.js +2 -0
  73. package/dist/cdn/ZPIXIG3Z.js +2 -0
  74. package/dist/cdn/ZVFNCDG5.js +2 -0
  75. package/dist/cdn/assets/portal-browser/t9n/messages.en.json +1 -0
  76. package/dist/cdn/assets/portal-group-badges/t9n/messages.en.json +1 -0
  77. package/dist/cdn/assets/portal-group-card/t9n/messages.en.json +1 -0
  78. package/dist/cdn/assets/portal-item-type/icons/parquetfeaturelayer16.svg +1 -0
  79. package/dist/cdn/assets/portal-item-type/icons/parquetfeaturelayer32.svg +1 -0
  80. package/dist/cdn/assets/portal-item-type/icons/storymapframe16.svg +1 -0
  81. package/dist/cdn/assets/portal-item-type/icons/storymapframe32.svg +1 -0
  82. package/dist/cdn/assets/portal-item-type/t9n/messages.en.json +1 -1
  83. package/dist/cdn/assets/portal-user-popup/t9n/messages.en.json +1 -0
  84. package/dist/cdn/index.js +1 -1
  85. package/dist/cdn/main.css +1 -1
  86. package/dist/chunks/dom.js +36 -0
  87. package/dist/chunks/functionalities.js +5 -4
  88. package/dist/chunks/groups.js +7 -83
  89. package/dist/chunks/item2.js +86 -0
  90. package/dist/chunks/portal.js +48 -8
  91. package/dist/chunks/store.js +18 -0
  92. package/dist/chunks/ui.js +10 -0
  93. package/dist/chunks/user2.js +26 -25
  94. package/dist/components/arcgis-portal-ai-assistant/agents/types.d.ts +11 -2
  95. package/dist/components/arcgis-portal-ai-assistant/customElement.d.ts +4 -2
  96. package/dist/components/arcgis-portal-ai-assistant/customElement.js +797 -488
  97. package/dist/components/arcgis-portal-ai-assistant-interrupt/customElement.js +10 -10
  98. package/dist/components/arcgis-portal-browser/customElement.d.ts +235 -0
  99. package/dist/components/arcgis-portal-browser/customElement.js +201 -0
  100. package/dist/components/arcgis-portal-browser/index.d.ts +1 -0
  101. package/dist/components/arcgis-portal-browser/index.js +6 -0
  102. package/dist/components/arcgis-portal-browser/utils/store.d.ts +31 -0
  103. package/dist/components/arcgis-portal-browser/utils/types.d.ts +18 -0
  104. package/dist/components/arcgis-portal-browser-actions/customElement.d.ts +187 -0
  105. package/dist/components/arcgis-portal-browser-actions/customElement.js +70 -0
  106. package/dist/components/arcgis-portal-browser-actions/index.d.ts +1 -0
  107. package/dist/components/arcgis-portal-browser-actions/index.js +6 -0
  108. package/dist/components/arcgis-portal-browser-actions/types.d.ts +9 -0
  109. package/dist/components/arcgis-portal-browser-filter/customElement.d.ts +226 -0
  110. package/dist/components/arcgis-portal-browser-filter/customElement.js +32 -0
  111. package/dist/components/arcgis-portal-browser-filter/index.d.ts +1 -0
  112. package/dist/components/arcgis-portal-browser-filter/index.js +4 -0
  113. package/dist/components/arcgis-portal-browser-filter-date/customElement.d.ts +233 -0
  114. package/dist/components/arcgis-portal-browser-filter-date/customElement.js +117 -0
  115. package/dist/components/arcgis-portal-browser-filter-date/index.d.ts +1 -0
  116. package/dist/components/arcgis-portal-browser-filter-date/index.js +5 -0
  117. package/dist/components/arcgis-portal-browser-filter-status/customElement.d.ts +193 -0
  118. package/dist/components/arcgis-portal-browser-filter-status/customElement.js +56 -0
  119. package/dist/components/arcgis-portal-browser-filter-status/index.d.ts +1 -0
  120. package/dist/components/arcgis-portal-browser-filter-status/index.js +5 -0
  121. package/dist/components/arcgis-portal-browser-filters/customElement.d.ts +7 -0
  122. package/dist/components/arcgis-portal-browser-filters/customElement.js +29 -0
  123. package/dist/components/arcgis-portal-browser-filters/index.d.ts +1 -0
  124. package/dist/components/arcgis-portal-browser-filters/index.js +2 -0
  125. package/dist/components/arcgis-portal-browser-pagination/customElement.d.ts +194 -0
  126. package/dist/components/arcgis-portal-browser-pagination/customElement.js +51 -0
  127. package/dist/components/arcgis-portal-browser-pagination/index.d.ts +1 -0
  128. package/dist/components/arcgis-portal-browser-pagination/index.js +2 -0
  129. package/dist/components/arcgis-portal-browser-search/customElement.d.ts +195 -0
  130. package/dist/components/arcgis-portal-browser-search/customElement.js +65 -0
  131. package/dist/components/arcgis-portal-browser-search/index.d.ts +1 -0
  132. package/dist/components/arcgis-portal-browser-search/index.js +3 -0
  133. package/dist/components/arcgis-portal-browser-sort/customElement.d.ts +196 -0
  134. package/dist/components/arcgis-portal-browser-sort/customElement.js +93 -0
  135. package/dist/components/arcgis-portal-browser-sort/index.d.ts +1 -0
  136. package/dist/components/arcgis-portal-browser-sort/index.js +9 -0
  137. package/dist/components/arcgis-portal-browser-sort/utils.d.ts +3 -0
  138. package/dist/components/arcgis-portal-browser-top-bar/customElement.d.ts +184 -0
  139. package/dist/components/arcgis-portal-browser-top-bar/customElement.js +51 -0
  140. package/dist/components/arcgis-portal-browser-top-bar/index.d.ts +1 -0
  141. package/dist/components/arcgis-portal-browser-top-bar/index.js +3 -0
  142. package/dist/components/arcgis-portal-browser-view/customElement.d.ts +21 -0
  143. package/dist/components/arcgis-portal-browser-view/customElement.js +30 -0
  144. package/dist/components/arcgis-portal-browser-view/index.d.ts +1 -0
  145. package/dist/components/arcgis-portal-browser-view/index.js +5 -0
  146. package/dist/components/arcgis-portal-group-badges/customElement.d.ts +102 -0
  147. package/dist/components/arcgis-portal-group-badges/customElement.js +50 -0
  148. package/dist/components/arcgis-portal-group-badges/index.d.ts +1 -0
  149. package/dist/components/arcgis-portal-group-badges/index.js +3 -0
  150. package/dist/components/arcgis-portal-group-badges/types.d.ts +3 -0
  151. package/dist/components/arcgis-portal-group-card/customElement.d.ts +167 -0
  152. package/dist/components/arcgis-portal-group-card/customElement.js +183 -0
  153. package/dist/components/arcgis-portal-group-card/index.d.ts +1 -0
  154. package/dist/components/arcgis-portal-group-card/index.js +8 -0
  155. package/dist/components/arcgis-portal-group-thumbnail/customElement.d.ts +32 -0
  156. package/dist/components/arcgis-portal-group-thumbnail/customElement.js +153 -0
  157. package/dist/components/arcgis-portal-group-thumbnail/index.d.ts +1 -0
  158. package/dist/components/arcgis-portal-group-thumbnail/index.js +3 -0
  159. package/dist/components/arcgis-portal-item-type/customElement.d.ts +2 -0
  160. package/dist/components/arcgis-portal-item-type/customElement.js +45 -37
  161. package/dist/components/arcgis-portal-mentionable-text-area/customElement.js +1 -1
  162. package/dist/components/arcgis-portal-replacement-item-redirect/customElement.js +53 -42
  163. package/dist/components/arcgis-portal-user-popup/customElement.d.ts +111 -0
  164. package/dist/components/arcgis-portal-user-popup/customElement.js +224 -0
  165. package/dist/components/arcgis-portal-user-popup/index.d.ts +1 -0
  166. package/dist/components/arcgis-portal-user-popup/index.js +5 -0
  167. package/dist/components/arcgis-portal-voice-input/customElement.d.ts +1 -1
  168. package/dist/docs/api.json +1 -1
  169. package/dist/docs/docs.json +1 -1
  170. package/dist/docs/vscode.html-custom-data.json +1 -1
  171. package/dist/docs/web-types.json +1 -1
  172. package/dist/index.d.ts +122 -2
  173. package/dist/loader.js +19 -4
  174. package/dist/types/group.d.ts +13 -13
  175. package/dist/types/item.d.ts +77 -2
  176. package/dist/types/lumina.d.ts +93 -1
  177. package/dist/types/preact.d.ts +108 -1
  178. package/dist/types/react.d.ts +123 -1
  179. package/dist/types/search.d.ts +27 -0
  180. package/dist/types/stencil.d.ts +93 -1
  181. package/dist/types/tracking.d.ts +10 -0
  182. package/dist/types/user.d.ts +2 -2
  183. package/package.json +11 -11
  184. package/dist/cdn/5DPWJ7DI.js +0 -2
  185. package/dist/cdn/5VSDGPHH.js +0 -2
  186. package/dist/cdn/72N3KAXN.js +0 -2
  187. package/dist/cdn/ANPXRYLV.js +0 -5
  188. package/dist/cdn/B7633S2A.js +0 -422
  189. package/dist/cdn/BEHLBKKM.js +0 -2
  190. package/dist/cdn/CI5ENGVT.js +0 -2
  191. package/dist/cdn/EVDOPN3G.js +0 -54
  192. package/dist/cdn/G47ZZQYL.js +0 -2
  193. package/dist/cdn/GAHILDQF.js +0 -45
  194. package/dist/cdn/GHQ3ZW4U.js +0 -2
  195. package/dist/cdn/GNOZCQ34.js +0 -2
  196. package/dist/cdn/JNRN6DTV.js +0 -2
  197. package/dist/cdn/K3HS2LQ7.js +0 -2
  198. package/dist/cdn/KEKBRUUC.js +0 -2
  199. package/dist/cdn/N6G6Z7BF.js +0 -516
  200. package/dist/cdn/OQDPULPD.js +0 -2
  201. package/dist/cdn/RNLVNDGG.js +0 -2
  202. package/dist/cdn/SM4GWLRA.js +0 -66
  203. package/dist/cdn/TMYTUOSS.js +0 -2
  204. package/dist/cdn/YG5YYL6X.js +0 -2
  205. package/dist/cdn/YIMNOUTF.js +0 -2
  206. package/dist/cdn/YL7PGYWC.js +0 -5
  207. package/dist/cdn/YMPTDKT6.js +0 -2
@@ -0,0 +1,451 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as La,b as An,c as Vu}from"./UZLQALHY.js";var HE=La((F8,Gg)=>{"use strict";var pD=Object.prototype.hasOwnProperty,cr="~";function rl(){}Object.create&&(rl.prototype=Object.create(null),new rl().__proto__||(cr=!1));function mD(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function ZE(e,t,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var a=new mD(r,n||e,i),o=cr?cr+t:t;return e._events[o]?e._events[o].fn?e._events[o]=[e._events[o],a]:e._events[o].push(a):(e._events[o]=a,e._eventsCount++),e}function Ld(e,t){--e._eventsCount===0?e._events=new rl:delete e._events[t]}function Zt(){this._events=new rl,this._eventsCount=0}Zt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)pD.call(r,n)&&t.push(cr?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};Zt.prototype.listeners=function(t){var r=cr?cr+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=new Array(a);i<a;i++)o[i]=n[i].fn;return o};Zt.prototype.listenerCount=function(t){var r=cr?cr+t:t,n=this._events[r];return n?n.fn?1:n.length:0};Zt.prototype.emit=function(t,r,n,i,a,o){var s=cr?cr+t:t;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,a),!0;case 6:return c.fn.call(c.context,r,n,i,a,o),!0}for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(t,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,r);break;case 3:c[d].fn.call(c[d].context,r,n);break;case 4:c[d].fn.call(c[d].context,r,n,i);break;default:if(!u)for(p=1,u=new Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0};Zt.prototype.on=function(t,r,n){return ZE(this,t,r,n,!1)};Zt.prototype.once=function(t,r,n){return ZE(this,t,r,n,!0)};Zt.prototype.removeListener=function(t,r,n,i){var a=cr?cr+t:t;if(!this._events[a])return this;if(!r)return Ld(this,a),this;var o=this._events[a];if(o.fn)o.fn===r&&(!i||o.once)&&(!n||o.context===n)&&Ld(this,a);else{for(var s=0,c=[],l=o.length;s<l;s++)(o[s].fn!==r||i&&!o[s].once||n&&o[s].context!==n)&&c.push(o[s]);c.length?this._events[a]=c.length===1?c[0]:c:Ld(this,a)}return this};Zt.prototype.removeAllListeners=function(t){var r;return t?(r=cr?cr+t:t,this._events[r]&&Ld(this,r)):(this._events=new rl,this._eventsCount=0),this};Zt.prototype.off=Zt.prototype.removeListener;Zt.prototype.addListener=Zt.prototype.on;Zt.prefixed=cr;Zt.EventEmitter=Zt;typeof Gg<"u"&&(Gg.exports=Zt)});var WE=La((B8,GE)=>{"use strict";GE.exports=(e,t)=>(t=t||(()=>{}),e.then(r=>new Promise(n=>{n(t())}).then(()=>r),r=>new Promise(n=>{n(t())}).then(()=>{throw r})))});var KE=La((V8,Bd)=>{"use strict";var hD=WE(),Fd=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},JE=(e,t,r)=>new Promise((n,i)=>{if(typeof t!="number"||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0){n(e);return}let a=setTimeout(()=>{if(typeof r=="function"){try{n(r())}catch(c){i(c)}return}let o=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,s=r instanceof Error?r:new Fd(o);typeof e.cancel=="function"&&e.cancel(),i(s)},t);hD(e.then(n,i),()=>{clearTimeout(a)})});Bd.exports=JE;Bd.exports.default=JE;Bd.exports.TimeoutError=Fd});var qE=La(Wg=>{"use strict";Object.defineProperty(Wg,"__esModule",{value:!0});function gD(e,t,r){let n=0,i=e.length;for(;i>0;){let a=i/2|0,o=n+a;r(e[o],t)<=0?(n=++o,i-=a+1):i=a}return n}Wg.default=gD});var XE=La(Kg=>{"use strict";Object.defineProperty(Kg,"__esModule",{value:!0});var _D=qE(),Jg=class{constructor(){this._queue=[]}enqueue(t,r){r=Object.assign({priority:0},r);let n={priority:r.priority,run:t};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(n);return}let i=_D.default(this._queue,n,(a,o)=>o.priority-a.priority);this._queue.splice(i,0,n)}dequeue(){let t=this._queue.shift();return t?.run}filter(t){return this._queue.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this._queue.length}};Kg.default=Jg});var Zd=La(Xg=>{"use strict";Object.defineProperty(Xg,"__esModule",{value:!0});var yD=HE(),YE=KE(),vD=XE(),Vd=()=>{},bD=new YE.TimeoutError,qg=class extends yD{constructor(t){var r,n,i,a;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=Vd,this._resolveIdle=Vd,t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:vD.default},t),!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(i=t.interval)===null||i===void 0?void 0:i.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);this._carryoverConcurrencyCount=t.carryoverConcurrencyCount,this._isIntervalIgnored=t.intervalCap===1/0||t.interval===0,this._intervalCap=t.intervalCap,this._interval=t.interval,this._queue=new t.queueClass,this._queueClass=t.queueClass,this.concurrency=t.concurrency,this._timeout=t.timeout,this._throwOnTimeout=t.throwOnTimeout===!0,this._isPaused=t.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=Vd,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=Vd,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let t=Date.now();if(this._intervalId===void 0){let r=this._intervalEnd-t;if(r<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},r)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){let t=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let r=this._queue.dequeue();return r?(this.emit("active"),r(),t&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this._concurrency=t,this._processQueue()}async add(t,r={}){return new Promise((n,i)=>{let a=async()=>{this._pendingCount++,this._intervalCount++;try{let o=this._timeout===void 0&&r.timeout===void 0?t():YE.default(Promise.resolve(t()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&i(bD)});n(await o)}catch(o){i(o)}this._next()};this._queue.enqueue(a,r),this._tryToStartAnother(),this.emit("add")})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(this._queue.size!==0)return new Promise(t=>{let r=this._resolveEmpty;this._resolveEmpty=()=>{r(),t()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(t=>{let r=this._resolveIdle;this._resolveIdle=()=>{r(),t()}})}get size(){return this._queue.size}sizeBy(t){return this._queue.filter(t).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(t){this._timeout=t}};Xg.default=qg});var WO=La(Hp=>{"use strict";Hp.byteLength=bF;Hp.toByteArray=xF;Hp.fromByteArray=$F;var Yn=[],en=[],vF=typeof Uint8Array<"u"?Uint8Array:Array,Ww="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Fo=0,HO=Ww.length;Fo<HO;++Fo)Yn[Fo]=Ww[Fo],en[Ww.charCodeAt(Fo)]=Fo;var Fo,HO;en[45]=62;en[95]=63;function GO(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function bF(e){var t=GO(e),r=t[0],n=t[1];return(r+n)*3/4-n}function wF(e,t,r){return(t+r)*3/4-r}function xF(e){var t,r=GO(e),n=r[0],i=r[1],a=new vF(wF(e,n,i)),o=0,s=i>0?n-4:n,c;for(c=0;c<s;c+=4)t=en[e.charCodeAt(c)]<<18|en[e.charCodeAt(c+1)]<<12|en[e.charCodeAt(c+2)]<<6|en[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=en[e.charCodeAt(c)]<<2|en[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=en[e.charCodeAt(c)]<<10|en[e.charCodeAt(c+1)]<<4|en[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function SF(e){return Yn[e>>18&63]+Yn[e>>12&63]+Yn[e>>6&63]+Yn[e&63]}function kF(e,t,r){for(var n,i=[],a=t;a<r;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(SF(n));return i.join("")}function $F(e){for(var t,r=e.length,n=r%3,i=[],a=16383,o=0,s=r-n;o<s;o+=a)i.push(kF(e,o,o+a>s?s:o+a));return n===1?(t=e[r-1],i.push(Yn[t>>2]+Yn[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Yn[t>>10]+Yn[t>>4&63]+Yn[t<<2&63]+"=")),i.join("")}});function HS(e,t){if(e!=null){if(typeof e!="number"||Number.isNaN(e)||e<=0)throw new Error(`${t} must be greater than 0`);return e}}function Bi(e){if(e==null)return;let t=typeof e=="number"?{runTimeout:e}:e,r=t.refreshOn??"auto";if(r!=="auto"&&r!=="heartbeat")throw new Error('refreshOn must be "auto" or "heartbeat"');let n=HS(t.runTimeout,"runTimeout"),i=HS(t.idleTimeout,"idleTimeout");if(!(n===void 0&&i===void 0))return{runTimeout:n,idleTimeout:i,refreshOn:r}}var Je="__start__",Qe="__end__",Pn="__input__";var Vi="__error__",jc="__error_source_node__",Zu="__pregel_ns_writes";function GS(){let e=typeof process<"u"?process.env?.LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT:void 0;if(e!==void 0&&e!==""){let t=Number.parseInt(e,10);if(Number.isFinite(t)&&t>0)return t}return 5e3}var Ft="__pregel_send",Nn="__pregel_call",er="__pregel_read",Vr="__pregel_checkpointer",Ba="__pregel_resuming",Qo="__pregel_task_id",Dc="__pregel_stream",rj="__pregel_resume_value",Va="__pregel_resume_map",tr="__pregel_scratchpad",Zi="__pregel_previous",nj="__pregel_durability",Hi="checkpoint_id",Cr="checkpoint_ns",WS="__pregel_node_finished",zc="__pregel_node_error",Bt="checkpoint_map",Hu="__pregel_replay_state",JS="__pregel_abort_signals",Le="__interrupt__",rr="__resume__",Uc="__no_writes__",Gi="__return__",Wi="__previous__",ht="langsmith:hidden";var Bh="__self__",Rn="__pregel_tasks",nr="__pregel_push",Gu="__pregel_pull",ir="00000000-0000-0000-0000-000000000000",KS=[ht,Pn,Le,rr,Vi,jc,Uc,Ft,er,Vr,nj,Dc,Ba,Qo,Nn,rj,tr,Zi,Bt,Cr,Hi,Hu],Fh=Symbol.for("langgraph.command"),qS=class{[Fh];constructor(e){this[Fh]=e}};function Wu(e){let t=e;return t!=null&&typeof t.node=="string"&&t.args!==void 0}var Fa=class{lg_name="Send";node;args;timeout;constructor(e,t,r){this.node=e,this.args=Mc(t),this.timeout=Bi(r?.timeout)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args,timeout:this.timeout}}};function wt(e){return e instanceof Fa}var On="__overwrite__",ij=class{lg_name="Overwrite";[On];constructor(e){this[On]=e}get value(){return this[On]}toJSON(){return{[On]:this[On]}}static isInstance(e){return!e||typeof e!="object"?!1:"__overwrite__"in e||"lg_name"in e&&e.lg_name==="Overwrite"}};function sn(e){if(typeof e=="object"&&e!==null){if("__overwrite__"in e)return[!0,e[On]];let t=e;if(t.type==="__overwrite__"&&"value"in t)return[!0,t.value]}return[!1,void 0]}function Za(e){return sn(e)[0]}function Ha(e){return!e||typeof e!="object"||!("__interrupt__"in e)?!1:Array.isArray(e[Le])}var _r=class extends qS{lg_name="Command";lc_direct_tool_output=!0;graph;update;resume;goto=[];static PARENT="__parent__";constructor(e){super(e),this.resume=e.resume,this.graph=e.graph,this.update=e.update,e.goto&&(this.goto=Array.isArray(e.goto)?Mc(e.goto):[Mc(e.goto)])}_updateAsTuples(){return this.update&&typeof this.update=="object"&&!Array.isArray(this.update)?Object.entries(this.update):Array.isArray(this.update)&&this.update.every(e=>Array.isArray(e)&&e.length===2&&typeof e[0]=="string")?this.update:[["__root__",this.update]]}toJSON(){let e;return typeof this.goto=="string"?e=this.goto:wt(this.goto)?e=this.goto.toJSON():e=this.goto?.map(t=>typeof t=="string"?t:t.toJSON()),{lg_name:this.lg_name,update:this.update,resume:this.resume,goto:e}}};function Ct(e){return typeof e!="object"||e==null?!1:"lg_name"in e&&e.lg_name==="Command"}function aj(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Mc(e,t=new Map){if(e!=null&&typeof e=="object"){if(t.has(e))return t.get(e);let r;if(Array.isArray(e))r=[],t.set(e,r),e.forEach((n,i)=>{r[i]=Mc(n,t)});else if(e instanceof _r||e instanceof Fa||!aj(e))r=e,t.set(e,r);else if(Ct(e))r=new _r(e),t.set(e,r);else if(Wu(e))r=new Fa(e.node,e.args,e.timeout!==void 0?{timeout:e.timeout}:void 0),t.set(e,r);else if("lc_serializable"in e&&e.lc_serializable)r=e,t.set(e,r);else{r={},t.set(e,r);for(let[n,i]of Object.entries(e))r[n]=Mc(i,t)}return r}return e}var Zr=class extends Error{lc_error_code;constructor(e,t){let r=e??"";t?.lc_error_code&&(r=`${r}
3
+
4
+ Troubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${t.lc_error_code}/
5
+ `),super(r),this.lc_error_code=t?.lc_error_code}},Ju=class extends Zr{get is_bubble_up(){return!0}},Vh=class extends Zr{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},Ga=class extends Zr{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},Ku=class extends Ju{reason;constructor(e="shutdown",t){super(`Graph drained: ${e}`,t),this.name="GraphDrained",this.reason=e}static get unminifiable_name(){return"GraphDrained"}};function qu(e){return e!==void 0&&e.name===Ku.unminifiable_name}var li=class extends Ju{interrupts;constructor(e,t){super(JSON.stringify(e,null,2),t),this.name="GraphInterrupt",this.interrupts=e??[]}static get unminifiable_name(){return"GraphInterrupt"}},Xu=class extends li{constructor(e,t){super([{value:e}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},Yu=class{node;error;constructor(e,t){this.node=e,this.error=t}static get unminifiable_name(){return"NodeError"}};function oj(e){return e!=null&&typeof e=="object"&&e.constructor!=null&&e.constructor.unminifiable_name===Yu.unminifiable_name}var Qu=class extends Ju{command;constructor(e){super(),this.name="ParentCommand",this.command=e}static get unminifiable_name(){return"ParentCommand"}};function Zh(e){return e!==void 0&&e.name===Qu.unminifiable_name}function Ji(e){return e!==void 0&&e.is_bubble_up===!0}function ui(e){return e!==void 0&&[li.unminifiable_name,Xu.unminifiable_name].includes(e.name)}var ed=class extends Zr{node;kind;timeout;elapsed;runTimeout;idleTimeout;constructor(e,t){let{node:r,elapsed:n,kind:i,runTimeout:a,idleTimeout:o}=e,s,c;if(i==="idle"){if(o===void 0)throw new Error("idleTimeout is required when kind='idle'");c=o,s=`Node "${r}" exceeded its idle timeout of ${o}ms without making progress (elapsed: ${n}ms).`}else{if(a===void 0)throw new Error("runTimeout is required when kind='run'");c=a,s=`Node "${r}" exceeded its run timeout of ${a}ms (elapsed: ${n}ms).`}super(s,t),this.name="NodeTimeoutError",this.node=r,this.kind=i,this.timeout=c,this.elapsed=n,this.runTimeout=a,this.idleTimeout=o}static get unminifiable_name(){return"NodeTimeoutError"}};function sj(e){return e!==void 0&&e.name===ed.unminifiable_name}var td=class extends Zr{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},je=class extends Zr{constructor(e,t){let r=Error.stackTraceLimit;Error.stackTraceLimit=0,super(e,t),Error.stackTraceLimit=r,this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}},ve=class extends Zr{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}},cj=class extends Zr{constructor(e,t){super(e,t),this.name="MultipleSubgraphError"}static get unminifiable_name(){return"MultipleSubgraphError"}},Hh=class extends Zr{constructor(e,t){super(e,t),this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}},lj=class extends Zr{constructor(e,t){super(e,t),this.name="RemoteException"}static get unminifiable_name(){return"RemoteException"}},Lc=class extends Zr{constructor(e,t){super(e,t),this.name="StateGraphInputError",this.message="Invalid StateGraph input. Make sure to pass a valid StateDefinition, Annotation.Root, or Zod schema."}static get unminifiable_name(){return"StateGraphInputError"}},uj=()=>(globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]===void 0&&(globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]=new Set),globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]);var XS=Object.defineProperty,T=(e,t)=>{let r={};for(var n in e)XS(r,n,{get:e[n],enumerable:!0});return t||XS(r,Symbol.toStringTag,{value:"Module"}),r};var YS="ffffffff-ffff-ffff-ffff-ffffffffffff";var QS="00000000-0000-0000-0000-000000000000";var ek=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Ki(e){return typeof e=="string"&&ek.test(e)}function Wa(e){if(!Ki(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var Mt=[];for(let e=0;e<256;++e)Mt.push((e+256).toString(16).slice(1));function Ar(e,t=0){return(Mt[e[t+0]]+Mt[e[t+1]]+Mt[e[t+2]]+Mt[e[t+3]]+"-"+Mt[e[t+4]]+Mt[e[t+5]]+"-"+Mt[e[t+6]]+Mt[e[t+7]]+"-"+Mt[e[t+8]]+Mt[e[t+9]]+"-"+Mt[e[t+10]]+Mt[e[t+11]]+Mt[e[t+12]]+Mt[e[t+13]]+Mt[e[t+14]]+Mt[e[t+15]]).toLowerCase()}function tk(e,t=0){let r=Ar(e,t);if(!Ki(r))throw TypeError("Stringified UUID is invalid");return r}var dj=new Uint8Array(16);function qi(){return crypto.getRandomValues(dj)}var Fc={};function rd(e,t,r){let n,i=e?._v6??!1;if(e){let a=Object.keys(e);a.length===1&&a[0]==="_v6"&&(e=void 0)}if(e)n=rk(e.random??e.rng?.()??qi(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{let a=Date.now(),o=qi();fj(Fc,a,o),n=rk(o,Fc.msecs,Fc.nsecs,i?void 0:Fc.clockseq,i?void 0:Fc.node,t,r)}return t??Ar(n)}function fj(e,t,r){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=r.slice(10,16),e.node[0]|=1,e.clockseq=(r[8]<<8|r[9])&16383),e.msecs=t,e}function rk(e,t,r,n,i,a,o=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!a)a=new Uint8Array(16),o=0;else if(o<0||o+16>a.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);t??=Date.now(),r??=0,n??=(e[8]<<8|e[9])&16383,i??=e.slice(10,16),t+=122192928e5;let s=((t&268435455)*1e4+r)%4294967296;a[o++]=s>>>24&255,a[o++]=s>>>16&255,a[o++]=s>>>8&255,a[o++]=s&255;let c=t/4294967296*1e4&268435455;a[o++]=c>>>8&255,a[o++]=c&255,a[o++]=c>>>24&15|16,a[o++]=c>>>16&255,a[o++]=n>>>8|128,a[o++]=n&255;for(let l=0;l<6;++l)a[o++]=i[l];return a}function nk(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():pj(e,t,r)}function pj(e,t,r){e=e||{};let n=e.random??e.rng?.()??qi();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Ar(n)}function mj(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function Gh(e,t){return e<<t|e>>>32-t}function ik(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128,e=n;let i=e.length/4+2,a=Math.ceil(i/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let l=0;l<16;++l)c[l]=e[s*64+l*4]<<24|e[s*64+l*4+1]<<16|e[s*64+l*4+2]<<8|e[s*64+l*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/2**32,o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=Gh(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let l=r[0],u=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let h=Math.floor(m/20),_=Gh(l,5)+mj(h,u,d,f)+p+t[h]+c[m]>>>0;p=f,f=d,d=Gh(u,30)>>>0,u=l,l=_}r[0]=r[0]+l>>>0,r[1]=r[1]+u>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+f>>>0,r[4]=r[4]+p>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function hj(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var ak="6ba7b810-9dad-11d1-80b4-00c04fd430c8",ok="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function sk(e,t,r,n,i,a){let o=typeof r=="string"?hj(r):r,s=typeof n=="string"?Wa(n):n;if(typeof n=="string"&&(n=Wa(n)),n?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,i){if(a??=0,a<0||a+16>i.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let l=0;l<16;++l)i[a+l]=c[l];return i}return Ar(c)}function nd(e,t,r,n){return sk(80,ik,e,t,r,n)}nd.DNS=ak;nd.URL=ok;function ck(e){let t=gj(typeof e=="string"?Wa(e):e);return typeof e=="string"?Ar(t):t}function gj(e){return Uint8Array.of((e[6]&15)<<4|e[7]>>4&15,(e[7]&15)<<4|(e[4]&240)>>4,(e[4]&15)<<4|(e[5]&240)>>4,(e[5]&15)<<4|(e[0]&240)>>4,(e[0]&15)<<4|(e[1]&240)>>4,(e[1]&15)<<4|(e[2]&240)>>4,96|e[2]&15,e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function lk(e,t,r){e??={},r??=0;let n=rd({...e,_v6:!0},new Uint8Array(16));if(n=ck(n),t){if(r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;i++)t[r+i]=n[i];return t}return Ar(n)}var Wh={};function dk(e,t,r){let n;if(e)n=uk(e.random??e.rng?.()??qi(),e.msecs,e.seq,t,r);else{let i=Date.now(),a=qi();_j(Wh,i,a),n=uk(a,Wh.msecs,Wh.seq,t,r)}return t??Ar(n)}function _j(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function uk(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!n)n=new Uint8Array(16),i=0;else if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=t&255,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|e[10]&3,n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}function fk(e){if(!Ki(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var pk=T({MAX:()=>yj,NIL:()=>vj,parse:()=>bj,stringify:()=>wj,v1:()=>xj,v4:()=>Xi,v5:()=>es,v6:()=>Jh,v7:()=>Hr,validate:()=>di,version:()=>Sj}),yj=YS,vj=QS,bj=Wa,wj=tk,xj=rd,Xi=nk,es=nd,Jh=lk,Hr=dk,di=Ki,Sj=fk;var Kh=0,Bc=0;function Vc(e){let t=Date.now();return t<=Kh?(Bc+=1,Bc>=1e4&&(Bc=0,t=Kh+1)):Bc=0,Kh=t,Jh({clockseq:e,msecs:t,nsecs:Bc})}function Mn(e,t){let r=t.replace(/-/g,"").match(/.{2}/g).map(n=>parseInt(n,16));return es(e,new Uint8Array(r))}var Zc="__pregel_tasks",qh="__error__",Ja="__scheduled__",Xh="__interrupt__",Yh="__resume__",ts=class{lg_name="DeltaSnapshot";value;constructor(e){this.value=e}};function Qh(e){return e!=null&&typeof e=="object"&&e.lg_name==="DeltaSnapshot"}var mk="[...]",kj="[Circular]",id=[],rs=[];function $j(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function hk(e,t,r,n){typeof n>"u"&&(n=$j()),tg(e,"",0,[],void 0,0,n);var i;try{rs.length===0?i=JSON.stringify(e,t,r):i=JSON.stringify(e,Ej(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;id.length!==0;){var a=id.pop();a.length===4?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return i}function eg(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:e}),id.push([n,r,t,i])):rs.push([t,r,e]):(n[r]=e,id.push([n,r,t]))}function tg(e,t,r,n,i,a,o){a+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<n.length;s++)if(n[s]===e){eg(kj,e,t,i);return}if(typeof o.depthLimit<"u"&&a>o.depthLimit){eg(mk,e,t,i);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){eg(mk,e,t,i);return}if(n.push(e),Array.isArray(e))for(s=0;s<e.length;s++)tg(e[s],s,s,n,e,a,o);else{var c=Object.keys(e);for(s=0;s<c.length;s++){var l=c[s];tg(e[l],l,s,n,e,a,o)}}n.pop()}}function Ej(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(rs.length>0)for(var n=0;n<rs.length;n++){var i=rs[n];if(i[1]===t&&i[0]===r){r=i[2],rs.splice(n,1);break}}return e.call(this,t,r)}}var Ij=/([A-Z]+)([A-Z][a-z0-9]+)/g,Tj=/([a-z0-9])([A-Z])/g,gk=/[-_\s]+/g;function Cj(e){return e.replace(Ij,"$1_$2").replace(Tj,"$1_$2").replace(gk,"_").toLowerCase()}function Aj(e){let t=e.trim();return/[-_\s]/.test(t)?t.replace(gk,"_").toLowerCase().replace(/_+([a-z0-9])/g,(r,n)=>n.toUpperCase()):t}function _k(e,t){return t?.[e]||Cj(e)}function yk(e,t){return t?.[e]||Aj(e)}function ad(e,t,r){let n={};for(let i in e)Object.hasOwn(e,i)&&(n[t(i,r)]=e[i]);return n}var vk="__lc_escaped__";function Oj(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function Pj(e){return{[vk]:e}}function rg(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function Nj(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function Rj(e){let t;return e!==null&&typeof e=="object"?"lc_id"in e&&Array.isArray(e.lc_id)?t=e.lc_id:t=[e.constructor?.name??"Object"]:t=[typeof e],{lc:1,type:"not_implemented",id:t}}function od(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return Rj(e);if(Nj(e))return e;t.add(e);let r=e;if(Oj(r))return t.delete(e),Pj(r);let n={};for(let[i,a]of Object.entries(r))n[i]=od(a,t);return t.delete(e),n}return Array.isArray(e)?e.map(r=>od(r,t)):e}function sd(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(rg(t))return t[vk];let r={};for(let[n,i]of Object.entries(t))r[n]=sd(i);return r}return Array.isArray(e)?e.map(t=>sd(t)):e}var wk=T({Serializable:()=>pt,get_lc_unique_name:()=>ns});function bk(e){return Array.isArray(e)?[...e]:{...e}}function Mj(e,t){let r=bk(e);for(let[n,i]of Object.entries(t)){let[a,...o]=n.split(".").reverse(),s=r;for(let c of o.reverse()){if(s[c]===void 0)break;s[c]=bk(s[c]),s=s[c]}s[a]!==void 0&&(s[a]={lc:1,type:"secret",id:[i]})}return r}function ns(e){let t=Object.getPrototypeOf(e);return typeof e.lc_name=="function"&&(typeof t.lc_name!="function"||e.lc_name()!==t.lc_name())?e.lc_name():e.name}var pt=class xk{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,ns(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(t,...r){this.lc_serializable_keys!==void 0?this.lc_kwargs=Object.fromEntries(Object.entries(t||{}).filter(([n])=>this.lc_serializable_keys?.includes(n))):this.lc_kwargs=t??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof xk||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},r={},n=Object.keys(this.lc_kwargs).reduce((s,c)=>(s[c]=c in this?this[c]:this.lc_kwargs[c],s),{});for(let s=Object.getPrototypeOf(this);s;s=Object.getPrototypeOf(s))Object.assign(t,Reflect.get(s,"lc_aliases",this)),Object.assign(r,Reflect.get(s,"lc_secrets",this)),Object.assign(n,Reflect.get(s,"lc_attributes",this));Object.keys(r).forEach(s=>{let c=this,l=n,[u,...d]=s.split(".").reverse();for(let f of d.reverse()){if(!(f in c)||c[f]===void 0)return;(!(f in l)||l[f]===void 0)&&(typeof c[f]=="object"&&c[f]!=null?l[f]={}:Array.isArray(c[f])&&(l[f]=[])),c=c[f],l=l[f]}u in c&&c[u]!==void 0&&(l[u]=l[u]||c[u])});let i={},a=new WeakSet;a.add(this);for(let[s,c]of Object.entries(n))i[s]=od(c,a);let o=ad(Object.keys(r).length?Mj(i,r):i,_k,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:o}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};var Sk=T({getEnv:()=>Tk,getEnvironmentVariable:()=>ar,getRuntimeEnvironment:()=>ig,isBrowser:()=>kk,isDeno:()=>cd,isJsDom:()=>Ek,isNode:()=>Ik,isWebWorker:()=>$k}),kk=()=>typeof window<"u"&&typeof window.document<"u",$k=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",Ek=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),cd=()=>typeof Deno<"u",Ik=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!cd(),Tk=()=>{let e;return kk()?e="browser":Ik()?e="node":$k()?e="webworker":Ek()?e="jsdom":cd()?e="deno":e="other",e},ng;function ig(){return ng===void 0&&(ng={library:"langchain-js",runtime:Tk()}),ng}function ar(e){try{return typeof process<"u"?process.env?.[e]:cd()?Deno?.env.get(e):void 0}catch{return}}var Ck=[];var Ak=T({});var Ok=T({});var ee="0123456789abcdef".split(""),jj=[-2147483648,8388608,32768,128],cn=[24,16,8,0],ld=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],At=[];function ln(e,t){t?(At[0]=At[16]=At[1]=At[2]=At[3]=At[4]=At[5]=At[6]=At[7]=At[8]=At[9]=At[10]=At[11]=At[12]=At[13]=At[14]=At[15]=0,this.blocks=At):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}ln.prototype.update=function(e){if(!this.finalized){var t,r=typeof e;if(r!=="string"){if(r==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);t=!0}for(var n,i=0,a,o=e.length,s=this.blocks;i<o;){if(this.hashed&&(this.hashed=!1,s[0]=this.block,this.block=s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),t)for(a=this.start;i<o&&a<64;++i)s[a>>>2]|=e[i]<<cn[a++&3];else for(a=this.start;i<o&&a<64;++i)n=e.charCodeAt(i),n<128?s[a>>>2]|=n<<cn[a++&3]:n<2048?(s[a>>>2]|=(192|n>>>6)<<cn[a++&3],s[a>>>2]|=(128|n&63)<<cn[a++&3]):n<55296||n>=57344?(s[a>>>2]|=(224|n>>>12)<<cn[a++&3],s[a>>>2]|=(128|n>>>6&63)<<cn[a++&3],s[a>>>2]|=(128|n&63)<<cn[a++&3]):(n=65536+((n&1023)<<10|e.charCodeAt(++i)&1023),s[a>>>2]|=(240|n>>>18)<<cn[a++&3],s[a>>>2]|=(128|n>>>12&63)<<cn[a++&3],s[a>>>2]|=(128|n>>>6&63)<<cn[a++&3],s[a>>>2]|=(128|n&63)<<cn[a++&3]);this.lastByteIndex=a,this.bytes+=a-this.start,a>=64?(this.block=s[16],this.start=a-64,this.hash(),this.hashed=!0):this.start=a}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};ln.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=jj[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};ln.prototype.hash=function(){var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7,c=this.blocks,l,u,d,f,p,m,h,_,y,w,x;for(l=16;l<64;++l)p=c[l-15],u=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,p=c[l-2],d=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,c[l]=c[l-16]+u+c[l-7]+d<<0;for(x=t&r,l=0;l<64;l+=4)this.first?(this.is224?(_=300032,p=c[0]-1413257819,s=p-150054599<<0,n=p+24177077<<0):(_=704751109,p=c[0]-210244248,s=p-1521486534<<0,n=p+143694565<<0),this.first=!1):(u=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),_=e&t,f=_^e&r^x,h=i&a^~i&o,p=s+d+h+ld[l]+c[l],m=u+f,s=n+p<<0,n=p+m<<0),u=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),y=n&e,f=y^n&t^_,h=o&s^~o&i,p=a+d+h+ld[l+1]+c[l+1],m=u+f,o=r+p<<0,r=p+m<<0,u=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),w=r&n,f=w^r&e^y,h=a&o^~a&s,p=i+d+h+ld[l+2]+c[l+2],m=u+f,a=t+p<<0,t=p+m<<0,u=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),x=t&r,f=x^t&n^w,h=a&o^~a&s,p=i+d+h+ld[l+3]+c[l+3],m=u+f,i=e+p<<0,e=p+m<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+n<<0,this.h4=this.h4+i<<0,this.h5=this.h5+a<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};ln.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7,c=ee[e>>>28&15]+ee[e>>>24&15]+ee[e>>>20&15]+ee[e>>>16&15]+ee[e>>>12&15]+ee[e>>>8&15]+ee[e>>>4&15]+ee[e&15]+ee[t>>>28&15]+ee[t>>>24&15]+ee[t>>>20&15]+ee[t>>>16&15]+ee[t>>>12&15]+ee[t>>>8&15]+ee[t>>>4&15]+ee[t&15]+ee[r>>>28&15]+ee[r>>>24&15]+ee[r>>>20&15]+ee[r>>>16&15]+ee[r>>>12&15]+ee[r>>>8&15]+ee[r>>>4&15]+ee[r&15]+ee[n>>>28&15]+ee[n>>>24&15]+ee[n>>>20&15]+ee[n>>>16&15]+ee[n>>>12&15]+ee[n>>>8&15]+ee[n>>>4&15]+ee[n&15]+ee[i>>>28&15]+ee[i>>>24&15]+ee[i>>>20&15]+ee[i>>>16&15]+ee[i>>>12&15]+ee[i>>>8&15]+ee[i>>>4&15]+ee[i&15]+ee[a>>>28&15]+ee[a>>>24&15]+ee[a>>>20&15]+ee[a>>>16&15]+ee[a>>>12&15]+ee[a>>>8&15]+ee[a>>>4&15]+ee[a&15]+ee[o>>>28&15]+ee[o>>>24&15]+ee[o>>>20&15]+ee[o>>>16&15]+ee[o>>>12&15]+ee[o>>>8&15]+ee[o>>>4&15]+ee[o&15];return this.is224||(c+=ee[s>>>28&15]+ee[s>>>24&15]+ee[s>>>20&15]+ee[s>>>16&15]+ee[s>>>12&15]+ee[s>>>8&15]+ee[s>>>4&15]+ee[s&15]),c};ln.prototype.toString=ln.prototype.hex;ln.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7,c=[e>>>24&255,e>>>16&255,e>>>8&255,e&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255];return this.is224||c.push(s>>>24&255,s>>>16&255,s>>>8&255,s&255),c};ln.prototype.array=ln.prototype.digest;ln.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};var is=(...e)=>new ln(!1,!0).update(e.join("")).hex();var Pk=T({sha256:()=>is});function Nk(e){let t=Symbol.for(e);return{brand(r,n){let i=n?Symbol.for(`${e}.${n}`):t;class a extends r{[i]=!0;constructor(...s){super(...s)}static isInstance(s){return typeof s=="object"&&s!==null&&i in s&&s[i]===!0}}return Object.defineProperty(a,"name",{value:r.name}),a},sub(r){return Nk(`${e}.${r}`)},isInstance(r){return typeof r=="object"&&r!==null&&t in r&&r[t]===!0}}}var Rk=Nk("langchain");var Mk=T({ContextOverflowError:()=>Dj,LangChainError:()=>ag,ModelAbortError:()=>dd,addLangChainErrorFields:()=>fi,ns:()=>ud});function fi(e,t){return e.lc_error_code=t,e.message=`${e.message}
6
+
7
+ Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/
8
+ `,e}var ud=Rk.sub("error"),ag=class extends ud.brand(Error){name="LangChainError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},dd=class extends ud.brand(ag,"model-abort"){name="ModelAbortError";partialOutput;constructor(e,t){super(e),this.partialOutput=t}},Dj=class jk extends ud.brand(ag,"context-overflow"){name="ContextOverflowError";cause;constructor(t){super(t??"Input exceeded the model's context window.")}static fromError(t){let r=new jk(t.message);return r.cause=t,r}};function jn(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"&&"source_type"in e&&(e.source_type==="url"||e.source_type==="base64"||e.source_type==="text"||e.source_type==="id")}function as(e){return jn(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function os(e){return jn(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function Dk(e){return jn(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function fd(e){return jn(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function pd(e){if(jn(e)){if(e.source_type==="url")return{type:"image_url",image_url:{url:e.url}};if(e.source_type==="base64"){if(!e.mime_type)throw new Error("mime_type key is required for base64 data.");return{type:"image_url",image_url:{url:`data:${e.mime_type};base64,${e.data}`}}}}throw new Error("Unsupported source type. Only 'url' and 'base64' are supported.")}function zk(e){let t=e.split(";")[0].split("/");if(t.length!==2)throw new Error(`Invalid mime type: "${e}" - does not match type/subtype format.`);let r=t[0].trim(),n=t[1].trim();if(r===""||n==="")throw new Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let i={};for(let a of e.split(";").slice(1)){let o=a.split("=");if(o.length!==2)throw new Error(`Invalid parameter syntax in mime type: "${e}".`);let s=o[0].trim(),c=o[1].trim();if(s==="")throw new Error(`Invalid parameter syntax in mime type: "${e}".`);i[s]=c}return{type:r,subtype:n,parameters:i}}function Hc({dataUrl:e,asTypedArray:t=!1}){let r=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),n;if(r){n=r[1].toLowerCase();let i=t?Uint8Array.from(atob(r[2]),a=>a.charCodeAt(0)):r[2];return{mime_type:n,data:i}}}function Uk(e,t){if(e.type==="text"){if(!t.fromStandardTextBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardTextBlock\` method.`);return t.fromStandardTextBlock(e)}if(e.type==="image"){if(!t.fromStandardImageBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardImageBlock\` method.`);return t.fromStandardImageBlock(e)}if(e.type==="audio"){if(!t.fromStandardAudioBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardAudioBlock\` method.`);return t.fromStandardAudioBlock(e)}if(e.type==="file"){if(!t.fromStandardFileBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardFileBlock\` method.`);return t.fromStandardFileBlock(e)}throw new Error(`Unable to convert content block type '${e.type}' to provider-specific format: not recognized.`)}function W(e,t){return te(e)&&e.type===t}function te(e){return typeof e=="object"&&e!==null}function xt(e){return Array.isArray(e)}function A(e){return typeof e=="string"}function Or(e){return typeof e=="number"}function md(e){return e instanceof Uint8Array}function og(e){try{return JSON.parse(e)}catch{return}}var Pr=e=>e();function zj(e){if(e.type==="char_location"&&A(e.document_title)&&Or(e.start_char_index)&&Or(e.end_char_index)&&A(e.cited_text)){let{document_title:t,start_char_index:r,end_char_index:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"char",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="page_location"&&A(e.document_title)&&Or(e.start_page_number)&&Or(e.end_page_number)&&A(e.cited_text)){let{document_title:t,start_page_number:r,end_page_number:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"page",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="content_block_location"&&A(e.document_title)&&Or(e.start_block_index)&&Or(e.end_block_index)&&A(e.cited_text)){let{document_title:t,start_block_index:r,end_block_index:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"block",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="web_search_result_location"&&A(e.url)&&A(e.title)&&A(e.encrypted_index)&&A(e.cited_text)){let{url:t,title:r,encrypted_index:n,cited_text:i,...a}=e;return{...a,type:"citation",source:"url",url:t,title:r,startIndex:Number(n),endIndex:Number(n),citedText:i}}if(e.type==="search_result_location"&&A(e.source)&&A(e.title)&&Or(e.start_block_index)&&Or(e.end_block_index)&&A(e.cited_text)){let{source:t,title:r,start_block_index:n,end_block_index:i,cited_text:a,...o}=e;return{...o,type:"citation",source:"search",url:t,title:r??void 0,startIndex:n,endIndex:i,citedText:a}}}function Fk(e){if(W(e,"document")&&te(e.source)&&"type"in e.source){if(e.source.type==="base64"&&A(e.source.media_type)&&A(e.source.data))return{type:"file",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&A(e.source.url))return{type:"file",url:e.source.url};if(e.source.type==="file"&&A(e.source.file_id))return{type:"file",fileId:e.source.file_id};if(e.source.type==="text"&&A(e.source.data))return{type:"file",mimeType:String(e.source.media_type??"text/plain"),data:e.source.data}}else if(W(e,"image")&&te(e.source)&&"type"in e.source){if(e.source.type==="base64"&&A(e.source.media_type)&&A(e.source.data))return{type:"image",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&A(e.source.url))return{type:"image",url:e.source.url};if(e.source.type==="file"&&A(e.source.file_id))return{type:"image",fileId:e.source.file_id}}}function Bk(e){function*t(){for(let r of e){let n=Fk(r);n?yield n:yield r}}return Array.from(t())}function Lk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(W(n,"text")&&A(n.text)){let{text:i,citations:a,...o}=n;if(xt(a)&&a.length){let s=a.reduce((c,l)=>{let u=zj(l);return u?[...c,u]:c},[]);yield{...o,type:"text",text:i,annotations:s};continue}else{yield{...o,type:"text",text:i};continue}}else if(W(n,"thinking")&&A(n.thinking)){let{thinking:i,signature:a,...o}=n;yield{...o,type:"reasoning",reasoning:i,signature:a};continue}else if(W(n,"redacted_thinking")){yield{type:"non_standard",value:n};continue}else if(W(n,"tool_use")&&A(n.name)&&A(n.id)){yield{type:"tool_call",id:n.id,name:n.name,args:n.input};continue}else if(W(n,"input_json_delta")){if(Uj(e)&&e.tool_call_chunks?.length){let i=e.tool_call_chunks[0];yield{type:"tool_call_chunk",id:i.id,name:i.name,args:i.args,index:i.index};continue}}else if(W(n,"server_tool_use")&&A(n.name)&&A(n.id)){let{name:i,id:a}=n;if(i==="web_search"){yield{id:a,type:"server_tool_call",name:"web_search",args:{query:Pr(()=>{if(typeof n.input=="string")return n.input;if(te(n.input)&&A(n.input.query))return n.input.query;if(A(n.partial_json)){let o=og(n.partial_json);if(o?.query)return o.query}return""})}};continue}else if(n.name==="code_execution"){yield{id:a,type:"server_tool_call",name:"code_execution",args:{code:Pr(()=>{if(typeof n.input=="string")return n.input;if(te(n.input)&&A(n.input.code))return n.input.code;if(A(n.partial_json)){let o=og(n.partial_json);if(o?.code)return o.code}return""})}};continue}}else if(W(n,"web_search_tool_result")&&A(n.tool_use_id)&&xt(n.content)){let{content:i,tool_use_id:a}=n;yield{type:"server_tool_call_result",name:"web_search",toolCallId:a,status:"success",output:{urls:i.reduce((o,s)=>W(s,"web_search_result")?[...o,s.url]:o,[])}};continue}else if(W(n,"code_execution_tool_result")&&A(n.tool_use_id)&&te(n.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:n.tool_use_id,status:"success",output:n.content};continue}else if(W(n,"mcp_tool_use")){yield{id:n.id,type:"server_tool_call",name:"mcp_tool_use",args:n.input};continue}else if(W(n,"mcp_tool_result")&&A(n.tool_use_id)&&te(n.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:n.tool_use_id,status:"success",output:n.content};continue}else if(W(n,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:n.input};continue}else if(W(n,"search_result")){yield{id:n.id,type:"non_standard",value:n};continue}else if(W(n,"tool_result")){yield{id:n.id,type:"non_standard",value:n};continue}else{let i=Fk(n);if(i){yield i;continue}}yield{type:"non_standard",value:n}}}return Array.from(t())}var Vk={translateContent:Lk,translateContentChunk:Lk};function Uj(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function Lj(e){return as(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:os(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:fd(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function Zk(e){return e.map(Lj)}function Hk(e){return!!(W(e,"image_url")&&te(e.image_url)||W(e,"input_audio")&&te(e.input_audio)||W(e,"file")&&te(e.file))}function Gk(e){if(W(e,"image_url")&&te(e.image_url)&&A(e.image_url.url)){let t=Hc({dataUrl:e.image_url.url});return t?{type:"image",mimeType:t.mime_type,data:t.data}:{type:"image",url:e.image_url.url}}else{if(W(e,"input_audio")&&te(e.input_audio)&&A(e.input_audio.data)&&A(e.input_audio.format))return{type:"audio",data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};if(W(e,"file")&&te(e.file)&&A(e.file.data)){let t=Hc({dataUrl:e.file.data});if(t)return{type:"file",data:t.data,mimeType:t.mime_type};if(A(e.file.file_id))return{type:"file",fileId:e.file.file_id}}}return e}function Fj(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...hd(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function Bj(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...hd(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function hd(e){let t=[];for(let r of e)Hk(r)?t.push(Gk(r)):t.push(r);return t}function Vj(e){if(e.type==="url_citation"){let{url:t,title:r,start_index:n,end_index:i}=e;return{type:"citation",url:t,title:r,startIndex:n,endIndex:i}}if(e.type==="file_citation"){let{file_id:t,filename:r,index:n}=e;return{type:"citation",title:r,startIndex:n,endIndex:n,fileId:t}}return e}function Wk(e){function*t(){te(e.additional_kwargs?.reasoning)&&xt(e.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:e.additional_kwargs.reasoning.summary.reduce((n,i)=>te(i)&&A(i.text)?`${n}${i.text}`:n,"")});let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r)if(W(n,"text")){let{text:i,annotations:a,phase:o,extras:s,...c}=n,l=te(s)?{...s}:{};A(o)&&(l.phase=o);let u=Object.keys(l).length>0?{extras:l}:{};Array.isArray(a)?yield{...c,...u,type:"text",text:String(i),annotations:a.map(Vj)}:yield{...c,...u,type:"text",text:String(i)}}for(let n of e.tool_calls??[])yield{type:"tool_call",id:n.id,name:n.name,args:n.args};if(te(e.additional_kwargs)&&xt(e.additional_kwargs.tool_outputs))for(let n of e.additional_kwargs.tool_outputs){if(W(n,"web_search_call")){let i={};if(te(n.action)&&A(n.action.query)&&(i.query=n.action.query),yield{id:n.id,type:"server_tool_call",name:"web_search",args:i},n.status==="completed"||n.status==="failed"){let a={};te(n.action)&&(a.action=n.action),yield{type:"server_tool_call_result",toolCallId:A(n.id)?n.id:"",status:n.status==="completed"?"success":"error",output:a}}continue}else if(W(n,"file_search_call")){yield{id:n.id,type:"server_tool_call",name:"file_search",args:{queries:xt(n.queries)?n.queries:[]}},(n.status==="completed"||n.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:A(n.id)?n.id:"",status:n.status==="completed"?"success":"error",output:xt(n.results)?{results:n.results}:{}});continue}else if(W(n,"computer_call")){yield{type:"non_standard",value:n};continue}else if(W(n,"code_interpreter_call")){if(A(n.code)&&(yield{id:n.id,type:"server_tool_call",name:"code_interpreter",args:{code:n.code}}),xt(n.outputs)){let i=Pr(()=>{if(n.status!=="in_progress"){if(n.status==="completed")return 0;if(n.status==="incomplete")return 127;if(n.status!=="interpreting"&&n.status==="failed")return 1}});for(let a of n.outputs)if(W(a,"logs")){yield{type:"server_tool_call_result",toolCallId:n.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:i??0,stderr:[0,void 0].includes(i)?void 0:String(a.logs),stdout:[0,void 0].includes(i)?String(a.logs):void 0}};continue}}continue}else if(W(n,"mcp_call")){yield{id:n.id,type:"server_tool_call",name:"mcp_call",args:n.input};continue}else if(W(n,"mcp_list_tools")){yield{id:n.id,type:"server_tool_call",name:"mcp_list_tools",args:n.input};continue}else if(W(n,"mcp_approval_request")){yield{type:"non_standard",value:n};continue}else if(W(n,"tool_search_call")){let i={};te(n.arguments)&&Object.assign(i,n.arguments);let a={};A(n.execution)&&(a.execution=n.execution),A(n.status)&&(a.status=n.status),A(n.call_id)&&(a.call_id=n.call_id),yield{id:A(n.id)?n.id:"",type:"server_tool_call",name:"tool_search",args:i,...Object.keys(a).length>0?{extras:a}:{}};continue}else if(W(n,"tool_search_output")){let i={name:"tool_search"};A(n.execution)&&(i.execution=n.execution),yield{type:"server_tool_call_result",toolCallId:A(n.id)?n.id:"",status:n.status==="completed"?"success":n.status==="failed"?"error":"success",output:{tools:xt(n.tools)?n.tools:[]},extras:i};continue}else if(W(n,"image_generation_call")){A(n.result)&&(yield{type:"image",mimeType:"image/png",data:n.result,id:A(n.id)?n.id:void 0,metadata:{status:A(n.status)?n.status:void 0}}),yield{type:"non_standard",value:n};continue}te(n)&&(yield{type:"non_standard",value:n})}}return Array.from(t())}function Zj(e){function*t(){yield*Wk(e);for(let r of e.tool_call_chunks??[])yield{type:"tool_call_chunk",id:r.id,name:r.name,args:r.args}}return Array.from(t())}var Jk={translateContent:e=>typeof e.content=="string"?Fj(e):Wk(e),translateContentChunk:e=>typeof e.content=="string"?Bj(e):Zj(e)};function gd(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function Kk(e,t="pretty"){return t==="pretty"?Hj(e):JSON.stringify(e)}function Hj(e){let t=[],r=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,n=Math.floor((80-r.length)/2),i="=".repeat(n),a=r.length%2===0?i:`${i}=`;if(t.push(`${i}${r}${a}`),e.type==="ai"){let o=e;if(o.tool_calls&&o.tool_calls.length>0){t.push("Tool Calls:");for(let s of o.tool_calls){t.push(` ${s.name} (${s.id})`),t.push(` Call ID: ${s.id}`),t.push(" Args:");for(let[c,l]of Object.entries(s.args))t.push(` ${c}: ${typeof l=="object"?JSON.stringify(l):l}`)}}}if(e.type==="tool"){let o=e;o.name&&t.push(`Name: ${o.name}`)}return typeof e.content=="string"&&e.content.trim()&&(t.length>1&&t.push(""),t.push(e.content)),t.join(`
9
+ `)}var sg=Symbol.for("langchain.message");function qk(e){return Array.isArray(e)?e:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e==null?[]:[e]}function Vt(e,t){if(typeof e=="string")return e===""?t:typeof t=="string"?e+t:Array.isArray(t)&&t.length===0?e:Array.isArray(t)&&t.some(r=>jn(r))?[{type:"text",source_type:"text",text:e},...t]:[{type:"text",text:e},...t];if(Array.isArray(t)){let r=qk(e);return Yi(r,t)??[...r,...t]}else return t===""?e:Array.isArray(e)&&e.some(r=>jn(r))?[...e,{type:"file",source_type:"text",text:t}]:[...qk(e),{type:"text",text:t}]}function _d(e,t){return e==="error"||t==="error"?"error":"success"}function Gj(e,t){function r(n,i){if(typeof n!="object"||n===null||n===void 0)return n;if(i>=t)return Array.isArray(n)?"[Array]":"[Object]";if(Array.isArray(n))return n.map(o=>r(o,i+1));let a={};for(let o of Object.keys(n))a[o]=r(n[o],i+1);return a}return JSON.stringify(r(e,0),null,2)}var Pe=class extends pt{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[sg]=!0;id;name;content;additional_kwargs;response_metadata;_getType(){return this.type}getType(){return this._getType()}constructor(e){let t=typeof e=="string"||Array.isArray(e)?{content:e}:e;t.additional_kwargs||(t.additional_kwargs={}),t.response_metadata||(t.response_metadata={}),super(t),this.name=t.name,t.content===void 0&&t.contentBlocks!==void 0?(this.content=t.contentBlocks,this.response_metadata={output_version:"v1",...t.response_metadata}):t.content!==void 0?(this.content=t.content??[],this.response_metadata=t.response_metadata):(this.content=[],this.response_metadata=t.response_metadata),this.additional_kwargs=t.additional_kwargs,this.id=t.id}get text(){return typeof this.content=="string"?this.content:Array.isArray(this.content)?this.content.map(e=>typeof e=="string"?e:e.type==="text"?e.text:"").join(""):""}get contentBlocks(){let e=typeof this.content=="string"?[{type:"text",text:this.content}]:this.content;return[Zk,hd,Bk].reduce((t,r)=>r(t),e)}toDict(){return{type:this.getType(),data:this.toJSON().kwargs}}static lc_name(){return"BaseMessage"}get _printableFields(){return{id:this.id,content:this.content,name:this.name,additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata}}static isInstance(e){return typeof e=="object"&&e!==null&&sg in e&&e[sg]===!0&&gd(e)}_updateId(e){this.id=e,this.lc_kwargs.id=e}get[Symbol.toStringTag](){return this.constructor.lc_name()}[Symbol.for("nodejs.util.inspect.custom")](e){if(e===null)return this;let t=Gj(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}toFormattedString(e="pretty"){return Kk(this,e)}};function e$(e){return Array.isArray(e)&&e.every(t=>typeof t.index=="number")}var cg=["index","created","timestamp"];function et(e,t,r){let n=r?.ignoreKeys??cg;if(e==null&&t==null)return;if(e==null||t==null)return e??t;let i={...e};for(let[a,o]of Object.entries(t))if(i[a]==null)i[a]=o;else{if(o==null)continue;if(typeof i[a]!=typeof o||Array.isArray(i[a])!==Array.isArray(o))throw new Error(`field[${a}] already exists in the message chunk, but with a different type.`);if(typeof i[a]=="string"){if(a==="type")continue;if(["id","name","output_version","model_provider"].includes(a))o&&(i[a]=o);else{if(n.includes(a))continue;i[a]+=o}}else if(typeof i[a]=="number"){if(n.includes(a))continue;i[a]=i[a]+o}else if(typeof i[a]=="object"&&!Array.isArray(i[a]))i[a]=et(i[a],o,r);else if(Array.isArray(i[a]))i[a]=Yi(i[a],o,r);else{if(i[a]===o)continue;console.warn(`field[${a}] already exists in this message chunk and value has unsupported type.`)}}return i}function Wj(e){return typeof e=="number"||typeof e=="string"}function Xk(e){return typeof e!="object"||e===null||!("index"in e)?!1:Wj(e.index)}function Yk(e){if(typeof e!="object"||e===null||!("id"in e))return!1;let t=e.id;return t!=null&&t!==""}function Qk(e){return e.endsWith("_delta")?e.slice(0,-6):e}function Jj(e,t){return typeof e!="object"||e===null||typeof t!="object"||t===null||!("type"in e)||!("type"in t)?!1:typeof e.type=="string"&&typeof t.type=="string"&&Qk(e.type)!==Qk(t.type)}function Kj(e,t){let r=Xk(t),n=Yk(t);return!r&&!n?-1:e.findIndex(i=>{let a=Xk(i),o=Yk(i);return r&&a?i.index!==t.index||Jj(i,t)?!1:o&&n?i.id===t.id:!0:!r&&!a&&n&&o?i.id===t.id:!1})}function Yi(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e||t;{let n=[...e];for(let i of t){let a=Kj(n,i);if(a!==-1)n[a]=et(n[a],i,r);else{if(typeof i=="object"&&i!==null&&"text"in i&&i.text==="")continue;n.push(i)}}return n}}}function yd(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e??t;if(typeof e!=typeof t)throw new Error(`Cannot merge objects of different types.
10
+ Left ${typeof e}
11
+ Right ${typeof t}`);if(typeof e=="string"&&typeof t=="string")return e+t;if(Array.isArray(e)&&Array.isArray(t))return Yi(e,t,r);if(typeof e=="object"&&typeof t=="object")return et(e,t,r);if(e===t)return e;throw new Error(`Can not merge objects of different types.
12
+ Left ${e}
13
+ Right ${t}`)}}var Ot=class t$ extends Pe{static isInstance(t){if(!super.isInstance(t))return!1;let r=Object.getPrototypeOf(t);for(;r!==null;){if(r===t$.prototype)return!0;r=Object.getPrototypeOf(r)}return!1}};function vd(e){return typeof e.role=="string"}function tt(e){return typeof e?._getType=="function"}function pi(e){return Ot.isInstance(e)}var r$=T({ToolMessage:()=>St,ToolMessageChunk:()=>ss,defaultToolCallParser:()=>Wc,isDirectToolOutput:()=>Gc,isToolMessage:()=>Jc,isToolMessageChunk:()=>lg});function Gc(e){return e!=null&&typeof e=="object"&&"lc_direct_tool_output"in e&&e.lc_direct_tool_output===!0}var St=class extends Pe{static lc_name(){return"ToolMessage"}get lc_aliases(){return{tool_call_id:"tool_call_id"}}lc_direct_tool_output=!0;type="tool";status;tool_call_id;metadata;artifact;constructor(e,t,r){let n=typeof e=="string"||Array.isArray(e)?{content:e,name:r,tool_call_id:t}:e;super(n),this.tool_call_id=n.tool_call_id,this.artifact=n.artifact,this.status=n.status,this.metadata=n.metadata}static isInstance(e){return super.isInstance(e)&&e.type==="tool"}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}},ss=class extends Ot{type="tool";tool_call_id;status;artifact;constructor(e){super(e),this.tool_call_id=e.tool_call_id,this.artifact=e.artifact,this.status=e.status}static lc_name(){return"ToolMessageChunk"}concat(e){let t=this.constructor;return new t({content:Vt(this.content,e.content),additional_kwargs:et(this.additional_kwargs,e.additional_kwargs),response_metadata:et(this.response_metadata,e.response_metadata),artifact:yd(this.artifact,e.artifact),tool_call_id:this.tool_call_id,id:this.id??e.id,status:_d(this.status,e.status)})}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}};function Wc(e){let t=[],r=[];for(let n of e)if(n.function){let i=n.function.name;try{let a=JSON.parse(n.function.arguments);t.push({name:i||"",args:a||{},id:n.id})}catch{r.push({name:i,args:n.function.arguments,id:n.id,error:"Malformed args."})}}else continue;return[t,r]}function Jc(e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="tool"}function lg(e){return e._getType()==="tool"}function Qi(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="tool_call")}function n$(e){return!!(e&&typeof e=="object"&&"toolCall"in e&&e.toolCall!=null&&typeof e.toolCall=="object"&&"id"in e.toolCall&&typeof e.toolCall.id=="string")}var cs=class extends Error{output;constructor(e,t){super(e),this.output=t}};function Ka(e,t=Dn){e=e.trim();let r=e.indexOf("```");if(r===-1)return t(e);let n=e.substring(r+3);n.startsWith(`json
14
+ `)?n=n.substring(5):n.startsWith("json")?n=n.substring(4):n.startsWith(`
15
+ `)&&(n=n.substring(1));let i=n.indexOf("```"),a=n;return i!==-1&&(a=n.substring(0,i)),t(a.trim())}function qj(e){try{return JSON.parse(e)}catch{}let t=e.trim();if(t.length===0)throw new Error("Unexpected end of JSON input");let r=0;function n(){for(;r<t.length&&/\s/.test(t[r]);)r+=1}function i(){if(t[r]!=='"')throw new Error(`Expected '"' at position ${r}, got '${t[r]}'`);r+=1;let u="",d=!1;for(;r<t.length;){let f=t[r];if(d){if(f==="n")u+=`
16
+ `;else if(f==="t")u+=" ";else if(f==="r")u+="\r";else if(f==="\\")u+="\\";else if(f==='"')u+='"';else if(f==="b")u+="\b";else if(f==="f")u+="\f";else if(f==="/")u+="/";else if(f==="u"){let p=t.substring(r+1,r+5);if(/^[0-9A-Fa-f]{0,4}$/.test(p))p.length===4?u+=String.fromCharCode(Number.parseInt(p,16)):u+=`u${p}`,r+=p.length;else throw new Error(`Invalid unicode escape sequence '\\u${p}' at position ${r}`)}else throw new Error(`Invalid escape sequence '\\${f}' at position ${r}`);d=!1}else if(f==="\\")d=!0;else{if(f==='"')return r+=1,u;u+=f}r+=1}return d&&(u+="\\"),u}function a(){let u=r,d="";if(t[r]==="-"&&(d+="-",r+=1),r<t.length&&t[r]==="0"&&(d+="0",r+=1,t[r]>="0"&&t[r]<="9"))throw new Error(`Invalid number at position ${u}`);if(r<t.length&&t[r]>="1"&&t[r]<="9")for(;r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(r<t.length&&t[r]===".")for(d+=".",r+=1;r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(r<t.length&&(t[r]==="e"||t[r]==="E"))for(d+=t[r],r+=1,r<t.length&&(t[r]==="+"||t[r]==="-")&&(d+=t[r],r+=1);r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(d==="-")return-0;let f=Number.parseFloat(d);if(Number.isNaN(f))throw r=u,new Error(`Invalid number '${d}' at position ${u}`);return f}function o(){if(n(),r>=t.length)throw new Error(`Unexpected end of input at position ${r}`);let u=t[r];if(u==="{")return c();if(u==="[")return s();if(u==='"')return i();if("null".startsWith(t.substring(r,r+4)))return r+=Math.min(4,t.length-r),null;if("true".startsWith(t.substring(r,r+4)))return r+=Math.min(4,t.length-r),!0;if("false".startsWith(t.substring(r,r+5)))return r+=Math.min(5,t.length-r),!1;if(u==="-"||u>="0"&&u<="9")return a();throw new Error(`Unexpected character '${u}' at position ${r}`)}function s(){if(t[r]!=="[")throw new Error(`Expected '[' at position ${r}, got '${t[r]}'`);let u=[];if(r+=1,n(),r>=t.length)return u;if(t[r]==="]")return r+=1,u;for(;r<t.length;){if(n(),r>=t.length||(u.push(o()),n(),r>=t.length))return u;if(t[r]==="]")return r+=1,u;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or ']' at position ${r}, got '${t[r]}'`)}return u}function c(){if(t[r]!=="{")throw new Error(`Expected '{' at position ${r}, got '${t[r]}'`);let u={};if(r+=1,n(),r>=t.length)return u;if(t[r]==="}")return r+=1,u;for(;r<t.length;){if(n(),r>=t.length)return u;let d=i();if(n(),r>=t.length)return u;if(t[r]!==":")throw new Error(`Expected ':' at position ${r}, got '${t[r]}'`);if(r+=1,n(),r>=t.length||(u[d]=o(),n(),r>=t.length))return u;if(t[r]==="}")return r+=1,u;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or '}' at position ${r}, got '${t[r]}'`)}return u}let l=o();if(n(),r<t.length)throw new Error(`Unexpected character '${t[r]}' at position ${r}`);return l}function Dn(e){try{return typeof e>"u"?null:qj(e)}catch{return null}}function ug(e){switch(e){case"csv":return"text/csv";case"doc":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"html":return"text/html";case"md":return"text/markdown";case"pdf":return"application/pdf";case"txt":return"text/plain";case"xls":return"application/vnd.ms-excel";case"xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"gif":return"image/gif";case"jpeg":return"image/jpeg";case"jpg":return"image/jpeg";case"png":return"image/png";case"webp":return"image/webp";case"flv":return"video/flv";case"mkv":return"video/mkv";case"mov":return"video/mov";case"mp4":return"video/mp4";case"mpeg":return"video/mpeg";case"mpg":return"video/mpg";case"three_gp":return"video/three_gp";case"webm":return"video/webm";case"wmv":return"video/wmv";default:return"application/octet-stream"}}function Xj(e){if(te(e.document)&&te(e.document.source)){let t=ug(te(e.document)&&A(e.document.format)?e.document.format:"");if(te(e.document.source)){if(te(e.document.source.s3Location)&&A(e.document.source.s3Location.uri))return{type:"file",mimeType:t,fileId:e.document.source.s3Location.uri};if(md(e.document.source.bytes))return{type:"file",mimeType:t,data:e.document.source.bytes};if(A(e.document.source.text))return{type:"file",mimeType:t,data:Buffer.from(e.document.source.text).toString("base64")};if(xt(e.document.source.content))return{type:"file",mimeType:t,data:e.document.source.content.reduce((r,n)=>te(n)&&A(n.text)?r+n.text:r,"")}}}return{type:"non_standard",value:e}}function Yj(e){if(W(e,"image")&&te(e.image)){let t=ug(te(e.image)&&A(e.image.format)?e.image.format:"");if(te(e.image.source)){if(te(e.image.source.s3Location)&&A(e.image.source.s3Location.uri))return{type:"image",mimeType:t,fileId:e.image.source.s3Location.uri};if(md(e.image.source.bytes))return{type:"image",mimeType:t,data:e.image.source.bytes}}}return{type:"non_standard",value:e}}function Qj(e){if(W(e,"video")&&te(e.video)){let t=ug(te(e.video)&&A(e.video.format)?e.video.format:"");if(te(e.video.source)){if(te(e.video.source.s3Location)&&A(e.video.source.s3Location.uri))return{type:"video",mimeType:t,fileId:e.video.source.s3Location.uri};if(md(e.video.source.bytes))return{type:"video",mimeType:t,data:e.video.source.bytes}}}return{type:"non_standard",value:e}}function i$(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(W(n,"cache_point")){yield{type:"non_standard",value:n};continue}else if(W(n,"citations_content")&&te(n.citationsContent)){yield{type:"text",text:xt(n.citationsContent.content)?n.citationsContent.content.reduce((i,a)=>te(a)&&A(a.text)?i+a.text:i,""):"",annotations:xt(n.citationsContent.citations)?n.citationsContent.citations.reduce((i,a)=>{if(te(a)){let o=xt(a.sourceContent)?a.sourceContent.reduce((c,l)=>te(l)&&A(l.text)?c+l.text:c,""):"",s=Pr(()=>{if(te(a.location)){let c=a.location.documentChar||a.location.documentPage||a.location.documentChunk;if(te(c))return{source:Or(c.documentIndex)?c.documentIndex.toString():void 0,startIndex:Or(c.start)?c.start:void 0,endIndex:Or(c.end)?c.end:void 0}}return{}});i.push({type:"citation",citedText:o,...s})}return i},[]):[]};continue}else if(W(n,"document")&&te(n.document)){yield Xj(n);continue}else if(W(n,"guard_content")){yield{type:"non_standard",value:n};continue}else if(W(n,"image")&&te(n.image)){yield Yj(n);continue}else if(W(n,"reasoning_content")&&A(n.reasoningText)){yield{type:"reasoning",reasoning:n.reasoningText};continue}else if(W(n,"text")&&A(n.text)){yield{type:"text",text:n.text};continue}else if(W(n,"tool_result")){yield{type:"non_standard",value:n};continue}else{if(W(n,"tool_call"))continue;if(W(n,"video")&&te(n.video)){yield Qj(n);continue}}yield{type:"non_standard",value:n}}}return Array.from(t())}var a$={translateContent:i$,translateContentChunk:i$};function o$(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(A(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let n of e.content)typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&A(n.text)&&t.push({type:"text",text:n.text});for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}var s$={translateContent:o$,translateContentChunk:o$};function c$(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(W(n,"text")&&A(n.text)){yield{type:"text",text:n.text};continue}else if(W(n,"thinking")&&A(n.thinking)){yield{type:"reasoning",reasoning:n.thinking,...n.signature?{signature:n.signature}:{}};continue}else if(W(n,"inlineData")&&te(n.inlineData)&&A(n.inlineData.mimeType)&&A(n.inlineData.data)){yield{type:"file",mimeType:n.inlineData.mimeType,data:n.inlineData.data};continue}else if(W(n,"functionCall")&&te(n.functionCall)&&A(n.functionCall.name)&&te(n.functionCall.args)){yield{type:"tool_call",id:e.id,name:n.functionCall.name,args:n.functionCall.args};continue}else if(W(n,"functionResponse")){yield{type:"non_standard",value:n};continue}else if(W(n,"fileData")&&te(n.fileData)&&A(n.fileData.mimeType)&&A(n.fileData.fileUri)){yield{type:"file",mimeType:n.fileData.mimeType,fileId:n.fileData.fileUri};continue}else if(W(n,"executableCode")){yield{type:"non_standard",value:n};continue}else if(W(n,"codeExecutionResult")){yield{type:"non_standard",value:n};continue}yield{type:"non_standard",value:n}}}return Array.from(t())}var l$={translateContent:c$,translateContentChunk:c$};function u$(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(W(n,"reasoning")&&A(n.reasoning)){let i=Pr(()=>{let a=r.indexOf(n);if(xt(e.additional_kwargs?.signatures)&&a>=0)return e.additional_kwargs.signatures.at(a)});A(i)?yield{type:"reasoning",reasoning:n.reasoning,signature:i}:yield{type:"reasoning",reasoning:n.reasoning};continue}else if(W(n,"thinking")&&A(n.thinking)){yield{type:"reasoning",reasoning:n.thinking,...n.signature?{signature:n.signature}:{}};continue}else if(W(n,"text")&&A(n.text)){yield{type:"text",text:n.text};continue}else if(W(n,"image_url")){if(A(n.image_url))if(n.image_url.startsWith("data:")){let i=n.image_url.match(/^data:([^;]+);base64,(.+)$/);i?yield{type:"image",data:i[2],mimeType:i[1]}:yield{type:"image",url:n.image_url}}else yield{type:"image",url:n.image_url};continue}else if(W(n,"media")&&A(n.mimeType)&&A(n.data)){yield{type:"file",mimeType:n.mimeType,data:n.data};continue}yield{type:"non_standard",value:n}}}return Array.from(t())}var d$={translateContent:u$,translateContentChunk:u$};function f$(e){let t=[],r=e.additional_kwargs?.reasoning;if(A(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string"){let n=e.content,i=n.match(/<think>([\s\S]*?)<\/think>/);if(i){let a=i[1].trim();a.length>0&&t.push({type:"reasoning",reasoning:a}),n=n.replace(/<think>[\s\S]*?<\/think>/,"").trim()}n.length>0&&t.push({type:"text",text:n})}else for(let n of e.content)if(typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&A(n.text)){let i=n.text,a=i.match(/<think>([\s\S]*?)<\/think>/);if(a){let o=a[1].trim();o.length>0&&t.push({type:"reasoning",reasoning:o}),i=i.replace(/<think>[\s\S]*?<\/think>/,"").trim()}i.length>0&&t.push({type:"text",text:i})}for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}var p$={translateContent:f$,translateContentChunk:f$};function m$(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(A(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let n of e.content)typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&A(n.text)&&t.push({type:"text",text:n.text});for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}var h$={translateContent:m$,translateContentChunk:m$};function g$(e){let t=[],r=e.additional_kwargs?.reasoning_details,n=!1;if(Array.isArray(r)&&r.length>0)for(let i of r){if(i==null||typeof i!="object")continue;let a=i.type;if(a==="reasoning.summary"){let o=i.summary;A(o)&&o.length>0&&(t.push({type:"reasoning",reasoning:o}),n=!0)}else if(a==="reasoning.text"){let o=i.text;A(o)&&o.length>0&&(t.push({type:"reasoning",reasoning:o}),n=!0)}}if(!n){let i=e.additional_kwargs?.reasoning_content;A(i)&&i.length>0&&t.push({type:"reasoning",reasoning:i})}if(typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&A(i.text)&&t.push({type:"text",text:i.text});for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var _$={translateContent:g$,translateContentChunk:g$};function y$(e){let t=[];if(te(e.additional_kwargs?.reasoning)){let n=e.additional_kwargs.reasoning;if(xt(n.summary)){let i=n.summary.reduce((a,o)=>te(o)&&A(o.text)?`${a}${o.text}`:a,"");i.length>0&&t.push({type:"reasoning",reasoning:i})}}let r=e.additional_kwargs?.reasoning_content;if(A(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let n of e.content)typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&A(n.text)&&t.push({type:"text",text:n.text});for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}var v$={translateContent:y$,translateContentChunk:y$};function b$(e){function*t(){let r=Pr(()=>{if(typeof e.content=="string")return e.additional_kwargs.originalTextContentBlock?[{...e.additional_kwargs.originalTextContentBlock,type:"text"}]:[{type:"text",text:e.content}];{let n=e.additional_kwargs?.originalTextContentBlock;if(n?.thoughtSignature&&!e.content.some(i=>"thoughtSignature"in i)){let i=[...e.content];for(let a=i.length-1;a>=0;a--){let o=i[a];if(o.type==="text"&&!o.thought)return o.thoughtSignature=n.thoughtSignature,i}}return e.content}});for(let n of r){let i=Pr(()=>W(n,"text")&&A(n.text)?{type:"text",text:n.text}:W(n,"inlineData")&&te(n.inlineData)&&A(n.inlineData.mimeType)&&A(n.inlineData.data)?{type:"file",mimeType:n.inlineData.mimeType,data:n.inlineData.data}:W(n,"functionCall")&&te(n.functionCall)&&A(n.functionCall.name)&&te(n.functionCall.args)?{type:"tool_call",id:e.id,name:n.functionCall.name,args:n.functionCall.args}:W(n,"functionResponse")?{type:"non_standard",value:n}:W(n,"fileData")&&te(n.fileData)&&A(n.fileData.mimeType)&&A(n.fileData.fileUri)?{type:"file",mimeType:n.fileData.mimeType,fileId:n.fileData.fileUri}:W(n,"executableCode")?{type:"non_standard",value:n}:W(n,"codeExecutionResult")?{type:"non_standard",value:n}:{type:"non_standard",value:n}),a=Pr(()=>"thought"in n&&n.thought?{type:"reasoning",reasoning:i.type==="text"?i.text:"",reasoningContentBlock:i}:i),o={thought:n.thought,thoughtSignature:n.thoughtSignature,partMetadata:n.partMetadata,...a};for(let s in o)o[s]===void 0&&delete o[s];yield o}}return Array.from(t())}var w$={translateContent:b$,translateContentChunk:b$};globalThis.lc_block_translators_registry??=new Map([["anthropic",Vk],["bedrock-converse",a$],["deepseek",s$],["google",w$],["google-genai",l$],["google-vertexai",d$],["groq",p$],["ollama",h$],["openai",Jk],["openrouter",_$],["xai",v$]]);function dg(e){return globalThis.lc_block_translators_registry.get(e)}function bd(e,t){return et(e,t)??{}}function x$(e,t){let r={};return(e?.audio!==void 0||t?.audio!==void 0)&&(r.audio=(e?.audio??0)+(t?.audio??0)),(e?.image!==void 0||t?.image!==void 0)&&(r.image=(e?.image??0)+(t?.image??0)),(e?.video!==void 0||t?.video!==void 0)&&(r.video=(e?.video??0)+(t?.video??0)),(e?.document!==void 0||t?.document!==void 0)&&(r.document=(e?.document??0)+(t?.document??0)),(e?.text!==void 0||t?.text!==void 0)&&(r.text=(e?.text??0)+(t?.text??0)),r}function e4(e,t){let r={...x$(e,t)};return(e?.cache_read!==void 0||t?.cache_read!==void 0)&&(r.cache_read=(e?.cache_read??0)+(t?.cache_read??0)),(e?.cache_creation!==void 0||t?.cache_creation!==void 0)&&(r.cache_creation=(e?.cache_creation??0)+(t?.cache_creation??0)),r}function t4(e,t){let r={...x$(e,t)};return(e?.reasoning!==void 0||t?.reasoning!==void 0)&&(r.reasoning=(e?.reasoning??0)+(t?.reasoning??0)),r}function ls(e,t){return{input_tokens:(e?.input_tokens??0)+(t?.input_tokens??0),output_tokens:(e?.output_tokens??0)+(t?.output_tokens??0),total_tokens:(e?.total_tokens??0)+(t?.total_tokens??0),input_token_details:e4(e?.input_token_details,t?.input_token_details),output_token_details:t4(e?.output_token_details,t?.output_token_details)}}var Ne=class extends Pe{type="ai";tool_calls=[];invalid_tool_calls=[];usage_metadata;get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",usage_metadata:"usage_metadata"}}constructor(e){let t;if(typeof e=="string"||Array.isArray(e))t={content:e,tool_calls:[],invalid_tool_calls:[],additional_kwargs:{}};else{t=e;let r=t.additional_kwargs?.tool_calls,n=t.tool_calls;r!=null&&r.length>0&&(n===void 0||n.length===0)&&console.warn(["New LangChain packages are available that more efficiently handle",`tool calling.
17
+
18
+ Please upgrade your packages to versions that set`,"message tool calls. e.g., `pnpm install @langchain/anthropic`,","pnpm install @langchain/openai`, etc."].join(" "));try{if(r!=null&&n===void 0){let[i,a]=Wc(r);t.tool_calls=i??[],t.invalid_tool_calls=a??[]}else t.tool_calls=t.tool_calls??[],t.invalid_tool_calls=t.invalid_tool_calls??[]}catch{t.tool_calls=[],t.invalid_tool_calls=[]}if(t.response_metadata!==void 0&&"output_version"in t.response_metadata&&t.response_metadata.output_version==="v1"&&t.content!==void 0&&(t.contentBlocks=t.content,t.content=void 0),t.contentBlocks!==void 0){if(t.tool_calls){let a=t.tool_calls.filter(o=>!t.contentBlocks?.some(s=>s.type==="tool_call"&&s.id===o.id&&s.name===o.name));t.contentBlocks.push(...a.map(o=>({type:"tool_call",id:o.id,name:o.name,args:o.args})))}let i=t.contentBlocks.filter(a=>a.type==="tool_call").filter(a=>!t.tool_calls?.some(o=>o.id===a.id&&o.name===a.name));i.length>0&&(t.tool_calls=[...t.tool_calls??[],...i.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.args}))])}}super(t),typeof t!="string"&&(this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls),this.usage_metadata=t.usage_metadata}static lc_name(){return"AIMessage"}get contentBlocks(){if(this.response_metadata&&"output_version"in this.response_metadata&&this.response_metadata.output_version==="v1")return this.content;if(this.response_metadata&&"model_provider"in this.response_metadata&&typeof this.response_metadata.model_provider=="string"){let t=dg(this.response_metadata.model_provider);if(t)return t.translateContent(this)}let e=super.contentBlocks;if(this.tool_calls){let t=this.tool_calls.filter(r=>!e.some(n=>n.id===r.id&&n.name===r.name));e.push(...t.map(r=>({type:"tool_call",id:r.id,name:r.name,args:r.args})))}return e}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}};function us(e){return e._getType()==="ai"}function Kc(e){return e._getType()==="ai"}var it=class extends Ot{type="ai";tool_calls=[];invalid_tool_calls=[];tool_call_chunks=[];usage_metadata;constructor(e){let t;if(typeof e=="string"||Array.isArray(e))t={content:e,tool_calls:[],invalid_tool_calls:[],tool_call_chunks:[]};else if(e.tool_call_chunks===void 0||e.tool_call_chunks.length===0)t={...e,tool_calls:e.tool_calls??[],invalid_tool_calls:[],tool_call_chunks:[],usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0};else{let r=wd(e.tool_call_chunks??[]);t={...e,tool_call_chunks:r.tool_call_chunks,tool_calls:r.tool_calls,invalid_tool_calls:r.invalid_tool_calls,usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0}}super(t),this.tool_call_chunks=t.tool_call_chunks??this.tool_call_chunks,this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls,this.usage_metadata=t.usage_metadata}get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",tool_call_chunks:"tool_call_chunks",usage_metadata:"usage_metadata"}}static lc_name(){return"AIMessageChunk"}get contentBlocks(){if(this.response_metadata&&"output_version"in this.response_metadata&&this.response_metadata.output_version==="v1")return this.content;if(this.response_metadata&&"model_provider"in this.response_metadata&&typeof this.response_metadata.model_provider=="string"){let t=dg(this.response_metadata.model_provider);if(t)return t.translateContent(this)}let e=super.contentBlocks;if(this.tool_calls&&typeof this.content!="string"){let t=this.content.filter(r=>r.type==="tool_call").map(r=>r.id);for(let r of this.tool_calls)r.id&&!t.includes(r.id)&&e.push({...r,type:"tool_call",id:r.id,name:r.name,args:r.args})}return e}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,tool_call_chunks:this.tool_call_chunks,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}concat(e){let t={content:Vt(this.content,e.content),additional_kwargs:et(this.additional_kwargs,e.additional_kwargs),response_metadata:bd(this.response_metadata,e.response_metadata),tool_call_chunks:[],tool_calls:[],id:this.id??e.id};if(this.tool_call_chunks!==void 0||e.tool_call_chunks!==void 0){let n=Yi(this.tool_call_chunks,e.tool_call_chunks);n!==void 0&&n.length>0&&(t.tool_call_chunks=n)}if(this.tool_calls!==void 0||e.tool_calls!==void 0){let n=Yi(this.tool_calls,e.tool_calls);n!==void 0&&n.length>0&&(t.tool_calls=n)}(this.usage_metadata!==void 0||e.usage_metadata!==void 0)&&(t.usage_metadata=ls(this.usage_metadata,e.usage_metadata));let r=this.constructor;return new r(t)}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}};var un=class S$ extends Pe{static lc_name(){return"ChatMessage"}type="generic";role;static _chatMessageClass(){return S$}constructor(t,r){(typeof t=="string"||Array.isArray(t))&&(t={content:t,role:r}),super(t),this.role=t.role}static isInstance(t){return super.isInstance(t)&&t.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}},qa=class extends Ot{static lc_name(){return"ChatMessageChunk"}type="generic";role;constructor(e,t){(typeof e=="string"||Array.isArray(e))&&(e={content:e,role:t}),super(e),this.role=e.role}concat(e){let t=this.constructor;return new t({content:Vt(this.content,e.content),additional_kwargs:et(this.additional_kwargs,e.additional_kwargs),response_metadata:et(this.response_metadata,e.response_metadata),role:this.role,id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}};function k$(e){return e._getType()==="generic"}function $$(e){return e._getType()==="generic"}var Xa=class extends Pe{static lc_name(){return"FunctionMessage"}type="function";name;constructor(e){super(e),this.name=e.name}},Ya=class extends Ot{static lc_name(){return"FunctionMessageChunk"}type="function";concat(e){let t=this.constructor;return new t({content:Vt(this.content,e.content),additional_kwargs:et(this.additional_kwargs,e.additional_kwargs),response_metadata:et(this.response_metadata,e.response_metadata),name:this.name??"",id:this.id??e.id})}};function E$(e){return e._getType()==="function"}function I$(e){return e._getType()==="function"}var ot=class extends Pe{static lc_name(){return"HumanMessage"}type="human";constructor(e){super(e)}static isInstance(e){return super.isInstance(e)&&e.type==="human"}},Qa=class extends Ot{static lc_name(){return"HumanMessageChunk"}type="human";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Vt(this.content,e.content),additional_kwargs:et(this.additional_kwargs,e.additional_kwargs),response_metadata:et(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="human"}};function T$(e){return e.getType()==="human"}function C$(e){return e.getType()==="human"}var Nr=class extends Pe{type="remove";id;constructor(e){super({...e,content:[]}),this.id=e.id}get _printableFields(){return{...super._printableFields,id:this.id}}static isInstance(e){return super.isInstance(e)&&e.type==="remove"}};var or=class xd extends Pe{static lc_name(){return"SystemMessage"}type="system";constructor(t){super(t)}concat(t){if(typeof t=="string")return new xd({content:Vt(this.content,t),additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata,id:this.id,name:this.name});if(xd.isInstance(t))return new xd({content:Vt(this.content,t.content),additional_kwargs:{...this.additional_kwargs,...t.additional_kwargs},response_metadata:{...this.response_metadata,...t.response_metadata},id:this.id??t.id,name:this.name??t.name});throw new Error("Unexpected chunk type for system message")}static isInstance(t){return super.isInstance(t)&&t.type==="system"}},mi=class extends Ot{static lc_name(){return"SystemMessageChunk"}type="system";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Vt(this.content,e.content),additional_kwargs:et(this.additional_kwargs,e.additional_kwargs),response_metadata:et(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="system"}};function A$(e){return e._getType()==="system"}function O$(e){return e._getType()==="system"}function r4(e){return e.isCustomTool===!0}var P$=e=>e();function n4(e){return Qi(e)?e:typeof e.id=="string"&&e.type==="function"&&typeof e.function=="object"&&e.function!==null&&"arguments"in e.function&&typeof e.function.arguments=="string"&&"name"in e.function&&typeof e.function.name=="string"?{id:e.id,args:JSON.parse(e.function.arguments),name:e.function.name,type:"tool_call"}:e}function i4(e){return typeof e=="object"&&e!=null&&e.lc===1&&Array.isArray(e.id)&&e.kwargs!=null&&typeof e.kwargs=="object"}function fg(e){let t,r;if(i4(e)){let n=e.id.at(-1);n==="HumanMessage"||n==="HumanMessageChunk"?t="user":n==="AIMessage"||n==="AIMessageChunk"?t="assistant":n==="SystemMessage"||n==="SystemMessageChunk"?t="system":n==="FunctionMessage"||n==="FunctionMessageChunk"?t="function":n==="ToolMessage"||n==="ToolMessageChunk"?t="tool":t="unknown",r=e.kwargs}else{let{type:n,...i}=e;t=n,r=i}if(t==="human"||t==="user")return new ot(r);if(t==="ai"||t==="assistant"){let{tool_calls:n,...i}=r;if(!Array.isArray(n))return new Ne(r);let a=n.map(n4);return new Ne({...i,tool_calls:a})}else{if(t==="system")return new or(r);if(t==="developer")return new or({...r,additional_kwargs:{...r.additional_kwargs,__openai_role__:"developer"}});if(t==="tool"&&"tool_call_id"in r)return new St({...r,content:r.content,tool_call_id:r.tool_call_id,name:r.name});if(t==="remove"&&"id"in r&&typeof r.id=="string")return new Nr({...r,id:r.id});throw fi(new Error(`Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.
19
+
20
+ Received: ${JSON.stringify(e,null,2)}`),"MESSAGE_COERCION_FAILURE")}}function kt(e){if(typeof e=="string")return new ot(e);if(tt(e))return e;if(Array.isArray(e)){let[t,r]=e;return fg({type:t,content:r})}else if(vd(e)){let{role:t,...r}=e;return fg({...r,type:t})}else return fg(e)}function a4(e){if(typeof e=="string")return e;switch(e.type){case"text":return e.text??"";case"text-plain":return e.text??"[text-plain file]";case"image":case"image_url":return"[image]";case"audio":case"input_audio":return"[audio]";case"video":return"[video]";case"file":return"[file]";case"reasoning":case"tool_call":case"tool_call_chunk":case"invalid_tool_call":case"server_tool_call":case"server_tool_call_chunk":case"server_tool_call_result":case"non_standard":return"";default:return e.type?`[${e.type}]`:""}}function ds(e,t="Human",r="AI"){let n=[];for(let i of e){let a;if(i.type==="human")a=t;else if(i.type==="ai")a=r;else if(i.type==="system")a="System";else if(i.type==="tool")a="Tool";else if(i.type==="generic")a=i.role;else throw new Error(`Got unsupported message type: ${i.type}`);let o=i.name?`${i.name}, `:"",s=typeof i.content=="string"?i.content:Array.isArray(i.content)?i.content.map(a4).filter(Boolean).join(""):"",c=`${a}: ${o}${s}`;if(i.type==="ai"){let l=i;l.tool_calls&&l.tool_calls.length>0?c+=JSON.stringify(l.tool_calls):l.additional_kwargs&&"function_call"in l.additional_kwargs&&(c+=JSON.stringify(l.additional_kwargs.function_call))}n.push(c)}return n.join(`
21
+ `)}function o4(e){if(e.data!==void 0)return e;{let t=e;return{type:t.type,data:{content:t.text,role:t.role,name:void 0,tool_call_id:void 0}}}}function qc(e){let t=o4(e);switch(t.type){case"human":return new ot(t.data);case"ai":return new Ne(t.data);case"system":return new or(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new Xa(t.data);case"tool":if(t.data.tool_call_id===void 0)throw new Error("Tool call ID must be defined for tool messages");return new St(t.data);case"generic":if(t.data.role===void 0)throw new Error("Role must be defined for chat messages");return new un(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function N$(e){return e.map(qc)}function R$(e){return e.map(t=>t.toDict())}function eo(e){let t=e._getType();if(t==="human")return new Qa({...e});if(t==="ai"){let r={...e};return"tool_calls"in r&&(r={...r,tool_call_chunks:r.tool_calls?.map(n=>({...n,type:"tool_call_chunk",index:void 0,args:JSON.stringify(n.args)}))}),new it({...r})}else{if(t==="system")return new mi({...e});if(t==="function")return new Ya({...e});if(un.isInstance(e))return new qa({...e});throw new Error("Unknown message type.")}}function wd(e){let t=e.reduce((i,a)=>{let o=i.findIndex(([s])=>"id"in a&&a.id&&"index"in a&&a.index!==void 0?a.id===s.id&&a.index===s.index:"id"in a&&a.id?a.id===s.id:"index"in a&&a.index!==void 0?a.index===s.index:!1);return o!==-1?i[o].push(a):i.push([a]),i},[]),r=[],n=[];for(let i of t){let a=null,o=i.some(r4),s=i[0]?.name??"",c=i.map(f=>f.args||"").join(""),l=o?c:c.trim(),u=l.length?l:"{}",d=i.find(f=>f.id)?.id??i[0]?.id;if(o&&d){r.push({name:s,args:{input:l},id:d,type:"tool_call"});continue}try{if(a=Dn(u),!d||a===null||typeof a!="object"||Array.isArray(a))throw new Error("Malformed tool call chunk args.");r.push({name:s,args:a,id:d,type:"tool_call"})}catch{n.push({name:s,args:u,id:d,error:"Malformed args.",type:"invalid_tool_call"})}}return{tool_call_chunks:e,tool_calls:r,invalid_tool_calls:n}}var M$=T({BaseCache:()=>D$,InMemoryCache:()=>pg,defaultHashKeyEncoder:()=>j$,deserializeStoredGeneration:()=>s4,serializeGeneration:()=>c4}),j$=(...e)=>is(e.join("_"));function s4(e){return e.message!==void 0?{text:e.text,message:qc(e.message)}:{text:e.text}}function c4(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var D$=class{keyEncoder=j$;makeDefaultKeyEncoder(e){this.keyEncoder=e}},l4=new Map,pg=class z$ extends D${cache;constructor(t){super(),this.cache=t??new Map}lookup(t,r){return Promise.resolve(this.cache.get(this.keyEncoder(t,r))??null)}async update(t,r,n){this.cache.set(this.keyEncoder(t,r),n)}static global(){return new z$(l4)}};var U$=T({BaseCallbackHandler:()=>sr,callbackHandlerPrefersChatModelStreamEvents:()=>mg,callbackHandlerPrefersStreaming:()=>Xc,isBaseCallbackHandler:()=>hg}),u4=class{};function Xc(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}function mg(e){return"lc_prefer_chat_model_stream_events"in e&&e.lc_prefer_chat_model_stream_events}var sr=class extends u4{lc_serializable=!1;get lc_namespace(){return["langchain_core","callbacks",this.name]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,ns(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=ar("LANGCHAIN_CALLBACKS_BACKGROUND")==="false";constructor(e){super(),this.lc_kwargs=e||{},e&&(this.ignoreLLM=e.ignoreLLM??this.ignoreLLM,this.ignoreChain=e.ignoreChain??this.ignoreChain,this.ignoreAgent=e.ignoreAgent??this.ignoreAgent,this.ignoreRetriever=e.ignoreRetriever??this.ignoreRetriever,this.ignoreCustomEvent=e.ignoreCustomEvent??this.ignoreCustomEvent,this.raiseError=e.raiseError??this.raiseError,this.awaitHandlers=this.raiseError||(e._awaitHandler??this.awaitHandlers))}copy(){return new this.constructor(this)}toJSON(){return pt.prototype.toJSON.call(this)}toJSONNotImplemented(){return pt.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends sr{name=Hr();constructor(){super(),Object.assign(this,e)}}return new t}},hg=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"};var L$=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function d4(e){return typeof e=="string"&&L$.test(e)}var Yc=d4;function f4(e){if(!Yc(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var Sd=f4;var jt=[];for(let e=0;e<256;++e)jt.push((e+256).toString(16).slice(1));function fs(e,t=0){return(jt[e[t+0]]+jt[e[t+1]]+jt[e[t+2]]+jt[e[t+3]]+"-"+jt[e[t+4]]+jt[e[t+5]]+"-"+jt[e[t+6]]+jt[e[t+7]]+"-"+jt[e[t+8]]+jt[e[t+9]]+"-"+jt[e[t+10]]+jt[e[t+11]]+jt[e[t+12]]+jt[e[t+13]]+jt[e[t+14]]+jt[e[t+15]]).toLowerCase()}var p4=new Uint8Array(16);function ps(){return crypto.getRandomValues(p4)}function m4(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():h4(e,t,r)}function h4(e,t,r){e=e||{};let n=e.random??e.rng?.()??ps();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return fs(n)}var to=m4;function g4(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function gg(e,t){return e<<t|e>>>32-t}function _4(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128,e=n;let i=e.length/4+2,a=Math.ceil(i/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let l=0;l<16;++l)c[l]=e[s*64+l*4]<<24|e[s*64+l*4+1]<<16|e[s*64+l*4+2]<<8|e[s*64+l*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/2**32,o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=gg(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let l=r[0],u=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let h=Math.floor(m/20),_=gg(l,5)+g4(h,u,d,f)+p+t[h]+c[m]>>>0;p=f,f=d,d=gg(u,30)>>>0,u=l,l=_}r[0]=r[0]+l>>>0,r[1]=r[1]+u>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+f>>>0,r[4]=r[4]+p>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}var F$=_4;function y4(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var _g="6ba7b810-9dad-11d1-80b4-00c04fd430c8",yg="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function vg(e,t,r,n,i,a){let o=typeof r=="string"?y4(r):r,s=typeof n=="string"?Sd(n):n;if(typeof n=="string"&&(n=Sd(n)),n?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,i){if(a??=0,a<0||a+16>i.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let l=0;l<16;++l)i[a+l]=c[l];return i}return fs(c)}function bg(e,t,r,n){return vg(80,F$,e,t,r,n)}bg.DNS=_g;bg.URL=yg;var wg=bg;var xg={};function v4(e,t,r){let n;if(e)n=B$(e.random??e.rng?.()??ps(),e.msecs,e.seq,t,r);else{let i=Date.now(),a=ps();b4(xg,i,a),n=B$(a,xg.msecs,xg.seq,t,r)}return t??fs(n)}function b4(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function B$(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!n)n=new Uint8Array(16),i=0;else if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=t&255,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|e[10]&3,n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}var ms=v4;var V$="gen_ai.operation.name",Z$="gen_ai.system",Sg="gen_ai.request.model",H$="gen_ai.response.model",kg="gen_ai.usage.input_tokens",$g="gen_ai.usage.output_tokens",Eg="gen_ai.usage.total_tokens",G$="gen_ai.request.max_tokens",W$="gen_ai.request.temperature",J$="gen_ai.request.top_p",K$="gen_ai.request.frequency_penalty",q$="gen_ai.request.presence_penalty",X$="gen_ai.response.finish_reasons",Y$="gen_ai.prompt",Q$="gen_ai.completion",eE="gen_ai.request.extra_query",tE="gen_ai.request.extra_body",rE="gen_ai.serialized.name",nE="gen_ai.serialized.signature",iE="gen_ai.serialized.doc",aE="gen_ai.response.id",oE="gen_ai.response.service_tier",sE="gen_ai.response.system_fingerprint",cE="gen_ai.usage.input_token_details",lE="gen_ai.usage.output_token_details",uE="langsmith.trace.session_id",dE="langsmith.trace.session_name",fE="langsmith.span.kind",pE="langsmith.trace.name",mE="langsmith.metadata",Ig="langsmith.span.tags";var hE="langsmith.request.streaming",gE="langsmith.request.headers";var Tg="langsmith.usage_metadata";var S4=(...e)=>fetch(...e),k4,_E=Symbol.for("ls:fetch_implementation");var yE=()=>globalThis[_E]===void 0?!0:k4??!1,vE=e=>async(...t)=>{if(e||Ke("DEBUG")==="true"){let[n,i]=t;console.log(`\u2192 ${i?.method||"GET"} ${n}`)}let r=await(globalThis[_E]??S4)(...t);return(e||Ke("DEBUG")==="true")&&console.log(`\u2190 ${r.status} ${r.statusText} ${r.url}`),r};var Qc=()=>Ke("PROJECT")??Pt("LANGCHAIN_SESSION")??"default";var bE={};function ro(e){bE[e]||(console.warn(e),bE[e]=!0)}var N=e=>BigInt(e),kE=N("0x9E3779B1"),$E=N("0x85EBCA77"),$4=N("0xC2B2AE3D"),ea=N("0x9E3779B185EBCA87"),no=N("0xC2B2AE3D27D4EB4F"),EE=N("0x165667B19E3779F9"),Pg=N("0x85EBCA77C2B2AE63"),E4=N("0x27D4EB2F165667C5"),I4=N("0x165667919E3779F9"),T4=N("0x9FB21C651E98DF25");function C4(e){let t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.substring(r,r+2),16);return t}var zn=C4("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),gs=(N(1)<<N(128))-N(1),be=(N(1)<<N(64))-N(1),Id=(N(1)<<N(32))-N(1),hi=64,IE=hi/8,A4=8,kd=4;function He(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function qe(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getBigUint64(0,!0)}function hs(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getUint32(0,!0)}function Cg(e,t=0){return e[t]}var O4=e=>(e&N(255))<<N(56)|(e&N(65280))<<N(40)|(e&N(16711680))<<N(24)|(e&N(4278190080))<<N(8)|(e&N(0xff00000000))>>N(8)|(e&N(0xff0000000000))>>N(24)|(e&N(0xff000000000000))>>N(40)|(e&N(0xff00000000000000))>>N(56),P4=e=>(e=(e&N(65535))<<N(16)|(e&N(4294901760))>>N(16),e=(e&N(16711935))<<N(8)|(e&N(4278255360))>>N(8),e),N4=(e,t)=>(e&Id)*(t&Id)&be,_s=e=>{if(!e)throw new Error("Assert failed")};function R4(e,t){return(e<<t|e>>N(32)-t)&Id}function TE(e,t,r){for(let n=0;n<IE;n++){let i=qe(t,n*8),a=i^qe(r,n*8);e[n^1]+=i,e[n]+=N4(a,a>>N(32))}return e}function wE(e,t,r,n){for(let i=0;i<n;i++)TE(e,He(t,i*hi),He(r,i*8));return e}function M4(e,t){for(let r=0;r<IE;r++){let n=qe(t,r*8),i=e[r];i=Ag(i,N(47)),i^=n,i*=kE,e[r]=i&be}return e}function $d(e,t){return CE(e[0]^qe(t,0),e[1]^qe(t,A4))}function xE(e,t,r){let n=r;return n+=$d(e.slice(0),He(t,0*kd)),n+=$d(e.slice(2),He(t,4*kd)),n+=$d(e.slice(4),He(t,8*kd)),n+=$d(e.slice(6),He(t,12*kd)),Un(n&be)}function j4(e,t,r,n,i){let a=Math.floor((r.byteLength-hi)/8),o=hi*a,s=Math.floor((t.byteLength-1)/o);for(let c=0;c<s;c++)e=wE(e,He(t,c*o),r,a),e=i(e,He(r,r.byteLength-hi));{let c=Math.floor((t.byteLength-1-o*s)/hi);e=wE(e,He(t,s*o),r,c),e=n(e,He(t,t.byteLength-hi),He(r,r.byteLength-hi-7))}return e}function D4(e,t,r){let n=new BigUint64Array([$4,ea,no,EE,Pg,$E,E4,kE]);_s(e.length>128),n=j4(n,e,t,TE,M4),_s(n.length*8==64);{let i=xE(n,He(t,11),N(e.byteLength)*ea&be);return xE(n,He(t,t.byteLength-hi-11),~(N(e.byteLength)*no)&be)<<N(64)|i}}function CE(e,t){let r=e*t&gs;return r&be^r>>N(64)}function SE(e,t,r){return CE((qe(e,0)^qe(t,0)+r)&be,(qe(e,8)^qe(t,8)-r)&be)}function Ed(e,t,r,n,i){let a=e&be,o=e>>N(64)&be;return a+=SE(t,n,i),a^=qe(r,0)+qe(r,8),a&=be,o+=SE(r,He(n,16),i),o^=qe(t,0)+qe(t,8),o&=be,o<<N(64)|a}function Un(e){return e^=e>>N(37),e*=I4,e&=be,e^=e>>N(32),e}function Td(e){return e^=e>>N(33),e*=no,e&=be,e^=e>>N(29),e*=EE,e&=be,e^=e>>N(32),e}function z4(e,t,r){let n=e.byteLength;_s(n>0&&n<=3);let i=N(Cg(e,n-1))|N(n<<8)|N(Cg(e,0)<<16)|N(Cg(e,n>>1)<<24),a=(N(hs(t,0))^N(hs(t,4)))+r,o=(i^a)&be,s=(N(hs(t,8))^N(hs(t,12)))-r,c=(R4(P4(i),N(13))^s)&be;return(Td(c)&be)<<N(64)|Td(o)}function Ag(e,t){return e^e>>t}function U4(e,t,r){let n=e.byteLength;_s(n>=4&&n<=8);{let i=hs(e,0),a=hs(e,n-4),o=N(i)|N(a)<<N(32),s=(qe(t,16)^qe(t,24))+r&be,l=(o^s)*(ea+(N(n)<<N(2)))&gs;return l+=(l&be)<<N(65),l&=gs,l^=l>>N(67),Ag(Ag(l&be,N(35))*T4&be,N(28))|Un(l>>N(64))<<N(64)}}function L4(e,t,r){let n=e.byteLength;_s(n>=9&&n<=16);{let i=(qe(t,32)^qe(t,40))+r&be,a=(qe(t,48)^qe(t,56))-r&be,o=qe(e),s=qe(e,n-8),c=(o^s^i)*ea,l=(c&be)+(N(n-1)<<N(54));c=c&(gs^be)|l,s^=a,c+=s+(s&Id)*($E-N(1))<<N(64),c&=gs,c^=O4(c>>N(64));let u=(c&be)*no;return u+=(c>>N(64))*no<<N(64),u&=gs,Un(u&be)|Un(u>>N(64))<<N(64)}}function F4(e,t){let r=e.byteLength;return _s(r<=16),r>8?L4(e,zn,t):r>=4?U4(e,zn,t):r>0?z4(e,zn,t):Td(t^qe(zn,64)^qe(zn,72))|Td(t^qe(zn,80)^qe(zn,88))<<N(64)}function Og(e){return~e+N(1)&be}function B4(e,t,r){let n=N(e.byteLength)*ea&be,i=N(e.byteLength-1)/N(32);for(;i>=0;){let s=Number(i);n=Ed(n,He(e,16*s),He(e,e.byteLength-16*(s+1)),He(t,32*s),r),i--}let a=n+(n>>N(64))&be;a=Un(a);let o=(n&be)*ea+(n>>N(64))*Pg+(N(e.byteLength)-r&be)*no;return o&=be,o=Og(Un(o)),a|o<<N(64)}function V4(e,t,r){let n=N(e.byteLength)*ea&be;for(let o=32;o<160;o+=32)n=Ed(n,He(e,o-32),He(e,o-16),He(t,o-32),r);n=Un(n&be)|Un(n>>N(64))<<N(64);for(let o=160;o<=e.byteLength;o+=32)n=Ed(n,He(e,o-32),He(e,o-16),He(t,3+o-160),r);n=Ed(n,He(e,e.byteLength-16),He(e,e.byteLength-32),He(t,103),Og(r));let i=n+(n>>N(64))&be;i=Un(i);let a=(n&be)*ea+(n>>N(64))*Pg+(N(e.byteLength)-r&be)*no;return a&=be,a=Og(Un(a)),i|a<<N(64)}function AE(e,t=N(0)){let r=e.byteLength;return r<=16?F4(e,t):r<=128?B4(e,zn,t):r<=240?V4(e,zn,t):D4(e,zn,t)}function OE(e){let t=new Uint8Array(16),r=new DataView(t.buffer),n=e&be,i=e>>N(64);return r.setBigUint64(0,i,!1),r.setBigUint64(8,n,!1),t}var PE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function he(e,t){if(!PE.test(e)){let r=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(r)}return e}function Cd(e){let t=typeof e=="string"?Date.parse(e):e;return ms({msecs:t,seq:0})}function Z4(e){if(!PE.test(e))return null;let t=e[14];return parseInt(t,16)}function H4(e){let t=e.replace(/-/g,""),r=new Uint8Array(16);for(let n=0;n<16;n++)r[n]=parseInt(t.slice(n*2,n*2+2),16);return r}function G4(e){let t=Array.from(e).map(r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var W4=new TextEncoder;function J4(e){let t=W4.encode(e),r=AE(t);return OE(r)}function el(e,t){let r=`${e}:${t}`,n=J4(r),i=new Uint8Array(16);if(Z4(e)===7){let o=H4(e);i.set(o.slice(0,6),0)}else{let o=Date.now();i[0]=o/1099511627776&255,i[1]=o/4294967296&255,i[2]=o/16777216&255,i[3]=o/65536&255,i[4]=o/256&255,i[5]=o&255}return i[6]=112|n[0]&15,i[7]=n[1],i[8]=128|n[2]&63,i.set(n.slice(3,10),9),G4(i)}var io={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function NE(e){}async function Ad(e,t){}async function RE(e){return[]}async function ME(e){return{size:0}}function ys(e){return!1}function Od(e){return""}function K4(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var Pd=class{constructor(t={}){Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ttlSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshIntervalSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_metrics",{enumerable:!0,configurable:!0,writable:!0,value:{hits:0,misses:0,refreshes:0,refreshErrors:0}}),this.configure(t)}get metrics(){return{...this._metrics}}get totalRequests(){return this._metrics.hits+this._metrics.misses}get hitRate(){let t=this.totalRequests;return t>0?this._metrics.hits/t:0}resetMetrics(){this._metrics={hits:0,misses:0,refreshes:0,refreshErrors:0}}get(t,r){if(this.maxSize===0)return;let n=this.cache.get(t);if(!n){this._metrics.misses+=1;return}return this.cache.delete(t),this.cache.set(t,{...n,refreshFunc:r}),this._metrics.hits+=1,n.value}set(t,r,n){if(this.maxSize===0)return;if(this.refreshTimer===void 0&&this.startRefreshLoop(),!this.cache.has(t)&&this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a!==void 0&&this.cache.delete(a)}let i={value:r,createdAt:Date.now(),refreshFunc:n};this.cache.delete(t),this.cache.set(t,i)}invalidate(t){this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}stop(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=void 0)}dump(t){let r={};for(let[a,o]of this.cache.entries())r[a]=o.value;let n=io.dirname(t);ys(n)||void 0;let i=`${t}.tmp`;try{JSON.stringify({entries:r},null,2)}catch(a){throw ys(i)&&void 0,a}}load(t){if(!ys(t))return 0;let r;try{let a=Od(t);r=JSON.parse(a).entries??null}catch{return 0}if(!r)return 0;let n=0,i=Date.now();for(let[a,o]of Object.entries(r)){if(this.cache.size>=this.maxSize)break;let s={value:o,createdAt:i};this.cache.set(a,s),n+=1}return n}startRefreshLoop(){this.stop(),this.ttlSeconds!==null&&(this.refreshTimer=setInterval(()=>{this.refreshStaleEntries().catch(t=>{console.warn("Unexpected error in cache refresh loop:",t)})},this.refreshIntervalSeconds*1e3),this.refreshTimer.unref&&this.refreshTimer.unref())}getStaleEntries(){let t=[];for(let[r,n]of this.cache.entries())K4(n,this.ttlSeconds)&&t.push([r,n]);return t}async refreshStaleEntries(){let t=this.getStaleEntries();if(t.length!==0){for(let[r,n]of t)if(n.refreshFunc!==void 0)try{let i=await n.refreshFunc();this.set(r,i,n.refreshFunc),this._metrics.refreshes+=1}catch(i){this._metrics.refreshErrors+=1,console.warn(`Failed to refresh cache entry ${r}:`,i)}}}configure(t){this.stop(),this.refreshIntervalSeconds=t.refreshIntervalSeconds??60,this.maxSize=t.maxSize??100,this.ttlSeconds=t.ttlSeconds??300}},Nd=new Pd;var Rd="0.6.3";var Fn,q4=()=>typeof window<"u"&&typeof window.document<"u",X4=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",Y4=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),UE=()=>typeof Deno<"u",Q4=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!UE(),tl=()=>Fn||(typeof Bun<"u"?Fn="bun":q4()?Fn="browser":Q4()?Fn="node":X4()?Fn="webworker":Y4()?Fn="jsdom":UE()?Fn="deno":Fn="other",Fn),Ng;function Md(){if(Ng===void 0){let e=tl(),t=tD();Ng={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:Rd,...t}}return Ng}function Mg(){let e=eD(),t={},r=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION","LANGSMITH_API_KEY","LANGSMITH_ENDPOINT","LANGSMITH_TRACING_V2","LANGSMITH_CONFIG_FILE","LANGSMITH_PROJECT","LANGSMITH_SESSION"];for(let[n,i]of Object.entries(e))typeof i=="string"&&!r.includes(n)&&!n.toLowerCase().includes("key")&&!n.toLowerCase().includes("secret")&&!n.toLowerCase().includes("token")&&(n==="LANGCHAIN_REVISION_ID"?t.revision_id=i:t[n]=i);return t}function eD(){let e={};try{if(typeof process<"u"&&process.env)for(let[t,r]of Object.entries(process.env))(t.startsWith("LANGCHAIN_")||t.startsWith("LANGSMITH_"))&&r!=null&&((t.toLowerCase().includes("key")||t.toLowerCase().includes("secret")||t.toLowerCase().includes("token"))&&typeof r=="string"?e[t]=r.slice(0,2)+"*".repeat(r.length-4)+r.slice(-2):e[t]=r)}catch{}return e}function Pt(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function Ke(e){return Pt(`LANGSMITH_${e}`)||Pt(`LANGCHAIN_${e}`)}var Rg;function tD(){if(Rg!==void 0)return Rg;let e=["VERCEL_GIT_COMMIT_SHA","NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA","COMMIT_REF","RENDER_GIT_COMMIT","CI_COMMIT_SHA","CIRCLE_SHA1","CF_PAGES_COMMIT_SHA","REACT_APP_GIT_SHA","SOURCE_VERSION","GITHUB_SHA","TRAVIS_COMMIT","GIT_COMMIT","BUILD_VCS_NUMBER","bamboo_planRepository_revision","Build.SourceVersion","BITBUCKET_COMMIT","DRONE_COMMIT_SHA","SEMAPHORE_GIT_SHA","BUILDKITE_COMMIT"],t={};for(let r of e){let n=Pt(r);n!==void 0&&(t[r]=n)}return Rg=t,t}function DE(){return Pt("OTEL_ENABLED")==="true"||Ke("OTEL_ENABLED")==="true"}var zE=new Set(["langsmith","otel"]);function jd(e){if(e!==void 0)return e;let t=Ke("TRACING_MODE");if(t!==void 0&&t!==""){let r=t.toLowerCase();if(!zE.has(r))throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(t)}. Must be one of: ${[...zE].sort().join(", ")}`);return DE()&&console.warn("Both LANGSMITH_TRACING_MODE and the legacy OTEL_ENABLED / LANGSMITH_OTEL_ENABLED env vars are set. LANGSMITH_TRACING_MODE takes precedence."),r}return DE()?"otel":"langsmith"}var zg=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...r){!this.hasWarned&&jd()==="otel"&&(console.warn('OTel tracing mode is active (via LANGSMITH_TRACING_MODE, OTEL_ENABLED, or LANGSMITH_OTEL_ENABLED), but the required OTEL instances have not been initialized. Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.'),this.hasWarned=!0);let n;if(r.length===1&&typeof r[0]=="function"?n=r[0]:r.length===2&&typeof r[1]=="function"?n=r[1]:r.length===3&&typeof r[2]=="function"&&(n=r[2]),typeof n=="function")return n()}},Ug=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new zg})}getTracer(t,r){return this.mockTracer}getActiveSpan(){}setSpan(t,r){return t}getSpan(t){}setSpanContext(t,r){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},Lg=class{active(){return{}}with(t,r){return r()}},jg=Symbol.for("ls:otel_trace"),Dg=Symbol.for("ls:otel_context"),LE=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),rD=new Ug,nD=new Lg,Fg=class{getTraceInstance(){return globalThis[jg]??rD}getContextInstance(){return globalThis[Dg]??nD}initializeGlobalInstances(t){globalThis[jg]===void 0&&(globalThis[jg]=t.trace),globalThis[Dg]===void 0&&(globalThis[Dg]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[LE]=t}getDefaultOTLPTracerComponents(){return globalThis[LE]??void 0}},Bg=new Fg;function Dd(){return Bg.getTraceInstance()}function FE(){return Bg.getContextInstance()}function BE(){return Bg.getDefaultOTLPTracerComponents()}var iD={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function aD(e){return iD[e]||e}function oD(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var zd=class{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(t,r){for(let n of t)try{if(!n.run)continue;if(n.operation==="post"){let i=this.createSpanForRun(n,n.run,r.get(n.id));i&&!n.run.end_time&&this.spans.set(n.id,i)}else this.updateSpanForRun(n,n.run)}catch(i){console.error(`Error processing operation ${n.id}:`,i)}}createSpanForRun(t,r,n){let i=n&&Dd().getSpan(n);if(i)try{return this.finishSpanSetup(i,r,t)}catch(a){console.error(`Failed to create span for run ${t.id}:`,a);return}}finishSpanSetup(t,r,n){return this.setSpanAttributes(t,r,n),r.error?(t.setStatus({code:2}),t.recordException(new Error(r.error))):t.setStatus({code:1}),r.end_time&&t.end(new Date(r.end_time)),t}updateSpanForRun(t,r){try{let n=this.spans.get(t.id);if(!n){console.debug(`No span found for run ${t.id} during update`);return}this.setSpanAttributes(n,r,t),r.error?(n.setStatus({code:2}),n.recordException(new Error(r.error))):n.setStatus({code:1});let i=r.end_time;i&&(n.end(new Date(i)),this.spans.delete(t.id))}catch(n){console.error(`Failed to update span for run ${t.id}:`,n)}}extractModelName(t){if(t.extra?.metadata){let r=t.extra.metadata;if(r.ls_model_name)return r.ls_model_name;if(r.invocation_params){let n=r.invocation_params;if(n.model)return n.model;if(n.model_name)return n.model_name}}}setSpanAttributes(t,r,n){if("run_type"in r&&r.run_type){t.setAttribute(fE,r.run_type);let s=aD(r.run_type||"chain");t.setAttribute(V$,s)}"name"in r&&r.name&&t.setAttribute(pE,r.name),"session_id"in r&&r.session_id&&t.setAttribute(uE,r.session_id),"session_name"in r&&r.session_name&&t.setAttribute(dE,r.session_name),this.setGenAiSystem(t,r);let i=this.extractModelName(r);i&&t.setAttribute(Sg,i),r.extra?.metadata?.usage_metadata&&typeof r.extra.metadata.usage_metadata=="object"&&t.setAttribute(Tg,JSON.stringify(r.extra.metadata.usage_metadata)),"prompt_tokens"in r&&typeof r.prompt_tokens=="number"&&t.setAttribute(kg,r.prompt_tokens),"completion_tokens"in r&&typeof r.completion_tokens=="number"&&t.setAttribute($g,r.completion_tokens),"total_tokens"in r&&typeof r.total_tokens=="number"&&t.setAttribute(Eg,r.total_tokens),this.setInvocationParameters(t,r);let a=r.extra?.metadata||{};for(let[s,c]of Object.entries(a))c!=null&&t.setAttribute(`${mE}.${s}`,oD(c)?String(c):JSON.stringify(c));let o=r.tags;if(o&&Array.isArray(o)?t.setAttribute(Ig,o.join(", ")):o&&t.setAttribute(Ig,String(o)),"serialized"in r&&typeof r.serialized=="object"){let s=r.serialized;s.name&&t.setAttribute(rE,String(s.name)),s.signature&&t.setAttribute(nE,String(s.signature)),s.doc&&t.setAttribute(iE,String(s.doc))}this.setIOAttributes(t,n)}setGenAiSystem(t,r){let n="langchain",i=this.extractModelName(r);if(i){let a=i.toLowerCase();a.includes("anthropic")||a.startsWith("claude")?n="anthropic":a.includes("bedrock")?n="aws.bedrock":a.includes("azure")&&a.includes("openai")?n="az.ai.openai":a.includes("azure")&&a.includes("inference")?n="az.ai.inference":a.includes("cohere")?n="cohere":a.includes("deepseek")?n="deepseek":a.includes("gemini")?n="gemini":a.includes("groq")?n="groq":a.includes("watson")||a.includes("ibm")?n="ibm.watsonx.ai":a.includes("mistral")?n="mistral_ai":a.includes("gpt")||a.includes("openai")?n="openai":a.includes("perplexity")||a.includes("sonar")?n="perplexity":a.includes("vertex")?n="vertex_ai":(a.includes("xai")||a.includes("grok"))&&(n="xai")}t.setAttribute(Z$,n)}setInvocationParameters(t,r){if(!r.extra?.metadata?.invocation_params)return;let n=r.extra.metadata.invocation_params;n.max_tokens!==void 0&&t.setAttribute(G$,n.max_tokens),n.temperature!==void 0&&t.setAttribute(W$,n.temperature),n.top_p!==void 0&&t.setAttribute(J$,n.top_p),n.frequency_penalty!==void 0&&t.setAttribute(K$,n.frequency_penalty),n.presence_penalty!==void 0&&t.setAttribute(q$,n.presence_penalty)}setIOAttributes(t,r){if(r.run.inputs)try{let n=r.run.inputs;typeof n=="object"&&n!==null&&(n.model&&Array.isArray(n.messages)&&t.setAttribute(Sg,n.model),n.stream!==void 0&&t.setAttribute(hE,n.stream),n.extra_headers&&t.setAttribute(gE,JSON.stringify(n.extra_headers)),n.extra_query&&t.setAttribute(eE,JSON.stringify(n.extra_query)),n.extra_body&&t.setAttribute(tE,JSON.stringify(n.extra_body))),t.setAttribute(Y$,JSON.stringify(n))}catch(n){console.debug(`Failed to process inputs for run ${r.id}`,n)}if(r.run.outputs)try{let n=r.run.outputs,i=this.getUnifiedRunTokens(n);if(i&&(t.setAttribute(kg,i[0]),t.setAttribute($g,i[1]),t.setAttribute(Eg,i[0]+i[1])),n&&typeof n=="object"){if(n.model&&t.setAttribute(H$,String(n.model)),n.id&&t.setAttribute(aE,n.id),n.choices&&Array.isArray(n.choices)){let a=n.choices.map(o=>o.finish_reason).filter(o=>o).map(String);a.length>0&&t.setAttribute(X$,a.join(", "))}if(n.service_tier&&t.setAttribute(oE,n.service_tier),n.system_fingerprint&&t.setAttribute(sE,n.system_fingerprint),n.usage_metadata&&typeof n.usage_metadata=="object"){let a=n.usage_metadata;t.setAttribute(Tg,JSON.stringify(a)),a.input_token_details&&t.setAttribute(cE,JSON.stringify(a.input_token_details)),a.output_token_details&&t.setAttribute(lE,JSON.stringify(a.output_token_details))}}t.setAttribute(Q$,JSON.stringify(n))}catch(n){console.debug(`Failed to process outputs for run ${r.id}`,n)}}getUnifiedRunTokens(t){if(!t)return null;let r=this.extractUnifiedRunTokens(t.usage_metadata);if(r)return r;let n=Object.keys(t);for(let o of n){let s=t[o];if(!(!s||typeof s!="object")&&(r=this.extractUnifiedRunTokens(s.usage_metadata),r||s.lc===1&&s.kwargs&&typeof s.kwargs=="object"&&(r=this.extractUnifiedRunTokens(s.kwargs.usage_metadata),r)))return r}let i=t.generations||[];if(!Array.isArray(i))return null;let a=Array.isArray(i[0])?i.flat():i;for(let o of a)if(typeof o=="object"&&o.message&&typeof o.message=="object"&&o.message.kwargs&&typeof o.message.kwargs=="object"&&(r=this.extractUnifiedRunTokens(o.message.kwargs.usage_metadata),r))return r;return null}extractUnifiedRunTokens(t){return!t||typeof t!="object"||typeof t.input_tokens!="number"||typeof t.output_tokens!="number"?null:[t.input_tokens,t.output_tokens]}};var sD=Object.prototype.toString,cD=e=>sD.call(e)==="[object Error]",lD=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function Vg(e){if(!(e&&cD(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:r,stack:n}=e;return r==="Load failed"?n===void 0||"__sentry_captured__"in e:r.startsWith("error sending request for url")?!0:lD.has(r)}function uD(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function Ud(e,t,{min:r=0,allowInfinity:n=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${n?" or Infinity":""}.`);if(!n&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var Zg=class extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}};function dD(e,t){let r=Math.max(1,e+1),n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*t.factor**(r-1));return i=Math.min(i,t.maxTimeout),i}function VE(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function fD({error:e,attemptNumber:t,retriesConsumed:r,startTime:n,options:i}){let a=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(a instanceof Zg)throw a.originalError;let o=Number.isFinite(i.retries)?Math.max(0,i.retries-r):i.retries,s=i.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:a,attemptNumber:t,retriesLeft:o,retriesConsumed:r});if(await i.onFailedAttempt(c),VE(n,s)<=0)throw a;let l=await i.shouldConsumeRetry(c),u=VE(n,s);if(u<=0||o<=0)throw a;if(a instanceof TypeError&&!Vg(a)){if(l)throw a;return i.signal?.throwIfAborted(),!1}if(!await i.shouldRetry(c))throw a;if(!l)return i.signal?.throwIfAborted(),!1;let d=dD(r,i),f=Math.min(d,u);return f>0&&await new Promise((p,m)=>{let h=()=>{clearTimeout(_),i.signal?.removeEventListener("abort",h),m(i.signal.reason)},_=setTimeout(()=>{i.signal?.removeEventListener("abort",h),p()},f);i.unref&&_.unref?.(),i.signal?.addEventListener("abort",h,{once:!0})}),i.signal?.throwIfAborted(),!0}async function Hg(e,t={}){if(t={...t},uD(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,Ud("factor",t.factor,{min:0,allowInfinity:!1}),Ud("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Ud("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Ud("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,n=0,i=performance.now();for(;!Number.isFinite(t.retries)||n<=t.retries;){r++;try{t.signal?.throwIfAborted();let a=await e(r);return t.signal?.throwIfAborted(),a}catch(a){await fD({error:a,attemptNumber:r,retriesConsumed:n,startTime:i,options:t})&&n++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Hd=Vu(Zd(),1),QE="default"in Hd.default?Hd.default.default:Hd.default;var wD=[408,425,429,500,502,503,504],nl=class{constructor(t){Object.defineProperty(this,"maxConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxRetries",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxQueueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailedResponseHook",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0}),this.maxConcurrency=t.maxConcurrency??1/0,this.maxRetries=t.maxRetries??6,this.maxQueueSizeBytes=t.maxQueueSizeBytes,this.queue=new QE({concurrency:this.maxConcurrency}),this.onFailedResponseHook=t?.onFailedResponseHook}call(t,...r){return this.callWithOptions({},t,...r)}callWithOptions(t,r,...n){let i=t.sizeBytes??0;if(this.maxQueueSizeBytes!==void 0&&i>0&&this.queueSizeBytes+i>this.maxQueueSizeBytes)return Promise.reject(new Error(`Queue size limit (${this.maxQueueSizeBytes} bytes) exceeded. Current queue size: ${this.queueSizeBytes} bytes, attempted addition: ${i} bytes.`));i>0&&(this.queueSizeBytes+=i);let a=this.onFailedResponseHook,o=this.queue.add(()=>Hg(()=>r(...n).catch(s=>{throw s instanceof Error?s:new Error(s)}),{async onFailedAttempt({error:s}){if(typeof s!="object"||s==null)throw s;let c="message"in s&&typeof s.message=="string"?s.message:void 0;if(c?.startsWith("Cancel")||c?.startsWith("TimeoutError")||c?.startsWith("AbortError")||"name"in s&&s.name==="TimeoutError"||"code"in s&&s.code==="ECONNABORTED")throw s;let l="response"in s?s.response:void 0;if(a&&await a(l))return;let u=l?.status??("status"in s?s.status:void 0);if(u!=null&&(typeof u=="number"||typeof u=="string")&&!wD.includes(+u))throw s},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return i>0&&(o=o.finally(()=>{this.queueSizeBytes-=i})),t.signal?Promise.race([o,new Promise((s,c)=>{t.signal?.addEventListener("abort",()=>{c(new Error("AbortError"))})})]):o}};function Yg(e){return typeof e?._getType=="function"}function Qg(e){let t={type:e._getType(),data:{content:e.content}};return e?.additional_kwargs&&Object.keys(e.additional_kwargs).length>0&&(t.data.additional_kwargs={...e.additional_kwargs}),t}function Wd(e){return`Invalid prompt identifier format: "${e}". Expected one of:
22
+ - "prompt-name" (for private prompts)
23
+ - "owner/prompt-name" (for prompts with explicit owner)
24
+ - "prompt-name:commit-hash" (with commit reference)
25
+ - "owner/prompt-name:commit-hash" (with owner and commit)`}var e_=class extends Error{constructor(t){super(t),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="LangSmithConflictError",this.status=409}},t_=class extends Error{constructor(t){super(t),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="LangSmithNotFoundError",this.status=404}};function Jd(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithNotFoundError"}function eI(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithConflictError"}async function X(e,t,r){let n;if(e.ok){r&&(n=await e.text());return}if(e.status===403)try{(await e.json())?.error==="org_scoped_key_requires_workspace"&&(n="This API key is org-scoped and requires workspace specification. Please provide 'workspaceId' parameter, or set LANGSMITH_WORKSPACE_ID environment variable.")}catch{let s=new Error(`${e.status} ${e.statusText}`);throw s.status=e?.status,s}if(n===void 0)try{n=await e.text()}catch{n=""}let i=`Failed to ${t}. Received status [${e.status}]: ${e.statusText}. Message: ${n}`;if(e.status===404)throw new t_(i);if(e.status===409)throw new e_(i);let a=new Error(i);throw a.status=e.status,a}var tI="ERR_CONFLICTING_ENDPOINTS",Gd=class extends Error{constructor(){super("You cannot provide both LANGSMITH_ENDPOINT / LANGCHAIN_ENDPOINT and LANGSMITH_RUNS_ENDPOINTS."),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:tI}),this.name="ConflictingEndpointsError"}};function rI(e){return typeof e=="object"&&e!==null&&e.code===tI}function Ht(e){if(!e||e.split("/").length>2||e.startsWith("/")||e.endsWith("/")||e.split(":").length>2)throw new Error(Wd(e));let[t,r]=e.split(":"),n=r||"latest";if(t.includes("/")){let[i,a]=t.split("/",2);if(!i||!a)throw new Error(Wd(e));return[i,a,n]}else{if(!t)throw new Error(Wd(e));return["-",t,n]}}var Kd="https://api.smith.langchain.com",xD="langsmith-cli",SD=6e4,kD=1e4;function $D(){let e=tl();return e==="browser"||e==="webworker"}function ED(){let e=Pt("LANGSMITH_CONFIG_FILE");if(e)return e;let t=Pt("HOME")??Pt("USERPROFILE");if(t)return io.join(t,".langsmith","config.json")}function ID(e){let t=Pt("LANGSMITH_PROFILE");if(t)return t;if(e.current_profile)return e.current_profile;if(e.profiles?.default)return"default"}function TD(){if($D())return;let e=ED();if(!(!e||!ys(e)))try{let t=JSON.parse(Od(e)),r=ID(t),n=r?t.profiles?.[r]:void 0;return!r||!n?void 0:{configPath:e,config:t,profileName:r,profile:n}}catch{return}}function Gr(e){return e!=null&&e.trim()!==""}function ta(e){return e?.trim().replace(/^["']|["']$/g,"")}function CD(e){let t=e.oauth;if(!t?.refresh_token)return!1;if(!t.access_token)return!0;if(!t.expires_at)return!1;let r=Date.parse(t.expires_at);return Number.isNaN(r)?!1:r<=Date.now()+SD}function AD(e){let t=e;for(;t.endsWith("/");)t=t.slice(0,-1);let r="/api/v1";return t.endsWith(r)?t.slice(0,-r.length):t}function OD(e,t){e.oauth??={},t.access_token&&(e.oauth.access_token=t.access_token),t.refresh_token&&(e.oauth.refresh_token=t.refresh_token),typeof t.expires_in=="number"&&t.expires_in>0&&(e.oauth.expires_at=new Date(Date.now()+t.expires_in*1e3).toISOString())}function nI(e){return e.reason??new Error("The operation was aborted.")}async function PD(e,t){if(!t)return e;if(t.aborted)throw nI(t);let r,n=new Promise((i,a)=>{let o=()=>{a(nI(t))};t.addEventListener("abort",o,{once:!0}),r=()=>{t.removeEventListener("abort",o)}});try{return await Promise.race([e,n])}finally{r?.()}}function iI(){let e=TD(),t=e?.profile;if(!e||!t)return{};let r=ta(t.api_key),n=ta(t.oauth?.access_token),i=ta(t.oauth?.refresh_token);return{apiUrl:t.api_url,apiKey:r,workspaceId:t.workspace_id,oauthAccessToken:n,oauthRefreshToken:i,profileAuth:r||n||i?new r_(e):void 0}}var r_=class{constructor(t){Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"refreshPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"managedAuthorizationValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.rememberProfileAuthHeader(this.currentAuthHeader())}currentAuthHeader(){let t=ND(this.state.profile);return this.rememberProfileAuthHeader(t),t}async getAuthHeader(t,r){CD(this.state.profile)&&(this.refreshPromise||(this.refreshPromise=this.refreshOAuthToken(t).finally(()=>{this.refreshPromise=void 0})),await PD(this.refreshPromise,r));let n=aI(this.state.profile);return this.rememberProfileAuthHeader(n),n}isProfileAuthorizationHeader(t){return t===this.managedAuthorizationValue}async refreshOAuthToken(t){let r=this.state.profile.oauth?.refresh_token;if(!r)return;let n=ta(this.state.profile.api_url)??Kd;try{let i=new URLSearchParams({grant_type:"refresh_token",client_id:xD,refresh_token:r}),a=await t(`${AD(n)}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i.toString(),signal:AbortSignal.timeout(kD)});if(!a.ok)return;let o=await a.json();if(!o.access_token)return;OD(this.state.profile,o),this.state.config.profiles??={},this.state.config.profiles[this.state.profileName]=this.state.profile,await Ad(this.state.configPath,`${JSON.stringify(this.state.config,null,2)}
26
+ `)}catch{return}}rememberProfileAuthHeader(t){this.managedAuthorizationValue=t?.name==="Authorization"?t.value:void 0}};function ND(e){let t=ta(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};if(!ta(e.oauth?.refresh_token))return aI(e)}function aI(e){let t=ta(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};let r=ta(e.api_key);if(r)return{name:"x-api-key",value:r}}var oI="[...]",RD={result:"[Circular]"},Xd=[],vs=[],MD=new TextEncoder;function jD(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function qd(e){return MD.encode(e)}function sI(e){if(e&&typeof e=="object"&&e!==null){if(e instanceof Map)return Object.fromEntries(e);if(e instanceof Set)return Array.from(e);if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(e instanceof Error)return{name:e.name,message:e.message}}else if(typeof e=="bigint")return e.toString();return e}function DD(e){return function(t,r){if(e){let n=e.call(this,t,r);if(n!==void 0)return n}return sI(r)}}function cI(e){try{let i=function(u){let d=n(u);return d>r&&(r=d),d+2},a=function(u){return u===0?2:2+u*4},o=function(u){return u===void 0||typeof u=="function"||typeof u=="symbol"},s=function(u){return u===void 0||typeof u=="function"||typeof u=="symbol"?4:c(u)},c=function(u){if(u===null)return 4;if(u===void 0)return 0;let d=typeof u;if(d==="boolean")return 5;if(d==="number")return Number.isFinite(u)?u.toString().length:4;if(d==="bigint")return u.toString().length+2;if(d==="string")return i(u);if(d==="function"||d==="symbol")return 0;let f=u;if(f instanceof Date)return 26;if(f instanceof RegExp)return n(f.toString())+2;if(f instanceof Error){let m=f.name??"",h=f.message??"";return 22+n(m)+n(h)}if(typeof Buffer<"u"&&f instanceof Buffer)return 28+a(f.byteLength);if(ArrayBuffer.isView(f)){if(f instanceof DataView)return 2;let m=f.length??0,_=f instanceof Float32Array||f instanceof Float64Array?30:12;return 2+m*_}if(f instanceof ArrayBuffer)return 2;if(t.has(f))return 24;if(typeof f.toJSON=="function"){let m;try{m=f.toJSON("")}catch{return 16}t.add(f);let h=c(m);return t.delete(f),h}t.add(f);let p;if(Array.isArray(f)){p=2;let m=f.length;for(let h=0;h<m;h++)p+=s(f[h]),h<m-1&&(p+=1)}else if(f instanceof Map){p=2;let m=0;for(let[h,_]of f){if(o(_))continue;m>0&&(p+=1);let y=typeof h=="string"?h:String(h);p+=n(y)+3,p+=c(_),m++}}else if(f instanceof Set){p=2;let m=0;for(let h of f)m>0&&(p+=1),p+=s(h),m++}else{p=2;let m=0,h=Object.keys(f);for(let _=0;_<h.length;_++){let y=h[_],w=f[y];o(w)||(m>0&&(p+=1),p+=n(y)+3,p+=c(w),m++)}}return t.delete(f),p},t=new Set,r=0,n=typeof Buffer<"u"&&typeof Buffer.byteLength=="function"?u=>Buffer.byteLength(u,"utf8"):u=>u.length;return{size:c(e),maxStringLen:r}}catch{return{size:Gt(e).length,maxStringLen:0}}}function Gt(e,t,r,n,i){try{let a=JSON.stringify(e,DD(r),n);return qd(a)}catch(a){if(!a.message?.includes("Converting circular structure to JSON"))return console.warn(`[WARNING]: LangSmith received unserializable value.${t?`
27
+ Context: ${t}`:""}`),qd("[Unserializable]");Ke("SUPPRESS_CIRCULAR_JSON_WARNINGS")!=="true"&&console.warn(`[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. ${t?`
28
+ Context: ${t}`:""}`),typeof i>"u"&&(i=jD()),i_(e,"",0,[],void 0,0,i);let o;try{vs.length===0?o=JSON.stringify(e,r,n):o=JSON.stringify(e,zD(r),n)}catch{return qd("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Xd.length!==0;){let s=Xd.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return qd(o)}}function n_(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:e}),Xd.push([n,r,t,i])):vs.push([t,r,e]):(n[r]=e,Xd.push([n,r,t]))}function i_(e,t,r,n,i,a,o){a+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<n.length;s++)if(n[s]===e){n_(RD,e,t,i);return}if(typeof o.depthLimit<"u"&&a>o.depthLimit){n_(oI,e,t,i);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){n_(oI,e,t,i);return}if(n.push(e),Array.isArray(e))for(s=0;s<e.length;s++)i_(e[s],s,s,n,e,a,o);else{e=sI(e);var c=Object.keys(e);for(s=0;s<c.length;s++){var l=c[s];i_(e[l],l,s,n,e,a,o)}}n.pop()}}function zD(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(vs.length>0)for(var n=0;n<vs.length;n++){var i=vs[n];if(i[1]===t&&i[0]===r){r=i[2],vs.splice(n,1);break}}return e.call(this,t,r)}}var LD=`
29
+ const { parentPort } = require("worker_threads");
30
+
31
+ const CIRCULAR_REPLACE_NODE = { result: "[Circular]" };
32
+
33
+ function serializeWellKnownTypes(val) {
34
+ if (val && typeof val === "object") {
35
+ if (val instanceof Map) return Object.fromEntries(val);
36
+ if (val instanceof Set) return Array.from(val);
37
+ if (val instanceof Date) return val.toISOString();
38
+ if (val instanceof RegExp) return val.toString();
39
+ if (val instanceof Error) return { name: val.name, message: val.message };
40
+ } else if (typeof val === "bigint") {
41
+ return val.toString();
42
+ }
43
+ return val;
44
+ }
45
+
46
+ function defaultReplacer(_key, val) {
47
+ return serializeWellKnownTypes(val);
48
+ }
49
+
50
+ // Decirculate in-place: replace circular refs with { result: "[Circular]" }
51
+ // then restore after stringify. Mirrors fast-safe-stringify's decirc().
52
+ const restoreStack = [];
53
+ function decirc(val, k, stack, parent) {
54
+ if (typeof val === "object" && val !== null) {
55
+ for (let i = 0; i < stack.length; i++) {
56
+ if (stack[i] === val) {
57
+ const orig = parent[k];
58
+ parent[k] = CIRCULAR_REPLACE_NODE;
59
+ restoreStack.push([parent, k, orig]);
60
+ return;
61
+ }
62
+ }
63
+ stack.push(val);
64
+ if (Array.isArray(val)) {
65
+ for (let i = 0; i < val.length; i++) decirc(val[i], i, stack, val);
66
+ } else {
67
+ const normalized = serializeWellKnownTypes(val);
68
+ // Only recurse into normalized if it's still an object (arrays/objects),
69
+ // else it was replaced with a primitive (e.g. Date -> string).
70
+ if (normalized === val) {
71
+ const keys = Object.keys(val);
72
+ for (let i = 0; i < keys.length; i++) decirc(val[keys[i]], keys[i], stack, val);
73
+ }
74
+ }
75
+ stack.pop();
76
+ }
77
+ }
78
+
79
+ function serialize(obj) {
80
+ try {
81
+ return JSON.stringify(obj, defaultReplacer);
82
+ } catch (e) {
83
+ if (!String(e && e.message).includes("Converting circular structure to JSON")) {
84
+ return "[Unserializable]";
85
+ }
86
+ decirc(obj, "", [], { "": obj });
87
+ try {
88
+ return JSON.stringify(obj, defaultReplacer);
89
+ } catch (_) {
90
+ return "[unable to serialize, circular reference is too complex to analyze]";
91
+ } finally {
92
+ while (restoreStack.length) {
93
+ const [p, k, v] = restoreStack.pop();
94
+ p[k] = v;
95
+ }
96
+ }
97
+ }
98
+ }
99
+
100
+ parentPort.on("message", (msg) => {
101
+ const { id, op, payload } = msg;
102
+ try {
103
+ if (op === "serialize") {
104
+ const str = serialize(payload);
105
+ const buf = Buffer.from(str, "utf8");
106
+ // Slice into its own ArrayBuffer so we can transfer without dragging
107
+ // unrelated bytes from any shared pool buffer.
108
+ const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
109
+ parentPort.postMessage({ id, bytes: ab, length: buf.byteLength }, [ab]);
110
+ } else if (op === "ping") {
111
+ parentPort.postMessage({ id });
112
+ } else {
113
+ parentPort.postMessage({ id, error: "unknown op: " + op });
114
+ }
115
+ } catch (e) {
116
+ parentPort.postMessage({ id, error: String((e && e.message) || e) });
117
+ }
118
+ });
119
+ `,o_=class{constructor(){Object.defineProperty(this,"worker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"nextId",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"pending",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"startPromise",{enumerable:!0,configurable:!0,writable:!0,value:null})}async ensureStarted(){if(this.disabled)return!1;if(this.worker!==null)return!0;if(this.startPromise!==null)return this.startPromise;this.startPromise=this._start();try{return await this.startPromise}finally{this.startPromise=null}}async _start(){if(!!1||null===null)return this.disabled=!0,!1;try{let t=new null(LD,{eval:!0});return t.on("message",r=>{let n=this.pending.get(r.id);n&&(this.pending.delete(r.id),r.error?n.reject(new Error(r.error)):r.bytes&&typeof r.length=="number"?n.resolve(new Uint8Array(r.bytes,0,r.length)):n.reject(new Error("worker returned malformed message")))}),t.on("error",r=>{for(let[,n]of this.pending)n.reject(r);this.pending.clear(),this.disabled=!0,this.worker=null}),t.on("exit",r=>{for(let[,n]of this.pending)n.reject(new Error(`worker exited with code ${r}`));this.pending.clear(),this.worker=null}),t.unref(),this.worker=t,!0}catch{return this.disabled=!0,!1}}async serialize(t){if(!await this.ensureStarted())return null;let n=this.nextId++;return new Promise((i,a)=>{this.pending.set(n,{resolve:i,reject:a});try{this.worker.postMessage({id:n,op:"serialize",payload:t})}catch(o){this.pending.delete(n),a(o)}})}async terminate(){this.worker&&(await this.worker.terminate(),this.worker=null);for(let[,t]of this.pending)t.reject(new Error("worker terminated"));this.pending.clear()}},a_=null;function uI(){return a_===null&&(a_=new o_),a_}var FD=64*1024,BD=2048;function dI(e,t=FD,r=BD){if(e===null||typeof e!="object")return typeof e=="string"&&e.length>=t;let n=[e],i=new Set,a=0;for(;n.length>0;){if(a++>=r)return!1;let o=n.pop();if(o==null)continue;let s=typeof o;if(s==="string"){if(o.length>=t)return!0;continue}if(s!=="object")continue;let c=o;if(i.has(c)||(i.add(c),c instanceof Date||c instanceof RegExp||c instanceof Error||c instanceof ArrayBuffer||ArrayBuffer.isView(c)))continue;if(Array.isArray(c)){for(let u=c.length-1;u>=0;u--)n.push(c[u]);continue}if(c instanceof Map){for(let[,u]of c)n.push(u);continue}if(c instanceof Set){for(let u of c)n.push(u);continue}let l=Object.keys(c);for(let u=l.length-1;u>=0;u--)n.push(c[l[u]])}return!1}function VD(e,t){let[r]=Ht(e);if(r!=="-"&&!t)throw new Error("Pulling a public prompt by owner/name is disabled by default because prompts may contain untrusted serialized LangChain objects. If you trust this prompt, set `dangerouslyPullPublicPrompt: true` to acknowledge the risk.")}function fI(e){return typeof e=="string"&&e.length>0&&!e.includes("Z")&&!e.includes("+")&&!e.includes("-",10)?e+"Z":e}function il(e){return{...e,start_time:fI(e.start_time),end_time:fI(e.end_time)}}function pI(e,t,r){if(r)return e;let n=Md(),i=t??Mg(),a=e.extra??{},o=a.metadata;return e.extra={...a,runtime:{...n,...a?.runtime},metadata:{...i,...i.revision_id||"revision_id"in e&&e.revision_id?{revision_id:("revision_id"in e?e.revision_id:void 0)??i.revision_id}:{},...o}},e}var ZD=e=>{let t=e?.toString()??Ke("TRACING_SAMPLING_RATE");if(t===void 0)return;let r=parseFloat(t);if(r<0||r>1)throw new Error(`LANGSMITH_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${r}`);return r},HD=e=>{let r=e.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return r==="localhost"||r==="127.0.0.1"||r==="::1"};async function GD(e){let t=[];for await(let r of e)t.push(r);return t}function Yd(e){if(e!==void 0)return e.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}var WD=async e=>{if(e?.status===429){let t=parseInt(e.headers.get("retry-after")??"10",10)*1e3;if(t>0)return await new Promise(r=>setTimeout(r,t)),!0}return!1};function mI(e){return typeof e=="number"?Number(e.toFixed(4)):e}var JD=24*1024*1024,gI=1024*1024*1024,KD=1e4,qD=100,s_=class{constructor(t){Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"sizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"maxSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSizeBytes=t??gI}peek(){return this.items[0]}push(t){let r,n=new Promise(a=>{r=a}),i=cI(t.item).size;return this.sizeBytes+i>this.maxSizeBytes&&this.items.length>0?(console.warn(`AutoBatchQueue size limit (${this.maxSizeBytes} bytes) exceeded. Dropping run with id: ${t.item.id}. Current queue size: ${this.sizeBytes} bytes, attempted addition: ${i} bytes.`),r(),n):(this.items.push({action:t.action,payload:t.item,otelContext:t.otelContext,apiKey:t.apiKey,apiUrl:t.apiUrl,itemPromiseResolve:r,itemPromise:n,size:i}),this.sizeBytes+=i,n)}pop({upToSizeBytes:t,upToSize:r}){if(t<1)throw new Error("Number of bytes to pop off may not be less than 1.");let n=[],i=0;for(;i+(this.peek()?.size??0)<t&&this.items.length>0&&n.length<r;){let a=this.items.shift();a&&(n.push(a),i+=a.size,this.sizeBytes-=a.size)}if(n.length===0&&this.items.length>0){let a=this.items.shift();n.push(a),i+=a.size,this.sizeBytes-=a.size}return[n.map(a=>({action:a.action,item:a.payload,otelContext:a.otelContext,apiKey:a.apiKey,apiUrl:a.apiUrl,size:a.size})),()=>n.forEach(a=>a.itemPromiseResolve())]}},Ln=class e{get tracingMode(){return this._tracingMode}get _fetch(){let t=this.fetchImplementation||vE(this.debug);return(async(r,n)=>{let i,a=this.getProfileManagedAuthorizationHeader(n);return this.apiKey!==void 0?i={name:"x-api-key",value:`${this.apiKey}`}:this.hasExplicitAuthHeader(n,a)||(i=await this.profileAuth?.getAuthHeader(t,n?.signal)),t(r,this.applyCurrentAuthHeaders(n,i,a))})}getProfileManagedAuthorizationHeader(t){if(!t?.headers||!this.profileAuth)return;let r=new Headers(t.headers).get("Authorization");if(Gr(r))return this.profileAuth.isProfileAuthorizationHeader(r??"")?r??void 0:void 0}isProfileManagedAuthorizationHeader(t,r){return t===r||this.profileAuth?.isProfileAuthorizationHeader(t)===!0}hasExplicitAuthHeader(t,r){if(!t?.headers)return!1;let n=new Headers(t.headers);if(Gr(n.get("x-api-key")))return!0;let i=n.get("Authorization");return Gr(i)?!this.isProfileManagedAuthorizationHeader(i??"",r):!1}applyCurrentAuthHeaders(t,r,n){if(!r)return t;let i=d=>{if(this.apiKey!==void 0&&r.name==="x-api-key")return d.delete("Authorization"),d.has("x-api-key")||d.set("x-api-key",r.value),d;if(r.name==="Authorization"){if(Gr(d.get("x-api-key")))return d;let p=d.get("Authorization");return Gr(p)&&!this.isProfileManagedAuthorizationHeader(p??"",n)||d.set("Authorization",r.value),d}let f=d.get("Authorization");return Gr(f)&&!this.isProfileManagedAuthorizationHeader(f??"",n)||(Gr(f)&&d.delete("Authorization"),d.has("x-api-key")||d.set("x-api-key",r.value)),d};if(!t)return{headers:{[r.name]:r.value}};if(t.headers instanceof Headers)return{...t,headers:i(new Headers(t.headers))};if(Array.isArray(t.headers))return{...t,headers:i(new Headers(t.headers))};let a={...t.headers??{}},o=d=>Object.keys(a).find(f=>f.toLowerCase()===d),s=d=>{let f=o(d);return f?a[f]:void 0},c=Gr(s("x-api-key")),l=s("authorization"),u=Gr(l)&&!this.isProfileManagedAuthorizationHeader(l??"",n);if(this.apiKey!==void 0&&r.name==="x-api-key"){let d=o("authorization");return d&&delete a[d],c||(a["x-api-key"]=r.value),{...t,headers:a}}if(r.name==="Authorization"){if(!c&&!u){let d=o("authorization");d&&d!=="Authorization"&&delete a[d],a.Authorization=r.value}return{...t,headers:a}}if(!u){let d=o("authorization");d&&delete a[d],c||(a["x-api-key"]=r.value)}return{...t,headers:a}}_trackDrain(t){this._pendingDrains.add(t),t.finally(()=>{this._pendingDrains.delete(t)})}async _serializeBody(t,r){if(this.manualFlushMode)return Gt(t,r);if(!dI(t))return Gt(t,r);if(this._serializeWorker===void 0&&(this._serializeWorker=uI()),this._serializeWorker===null)return Gt(t,r);try{let n=await this._serializeWorker.serialize(t);return n===null?(this._serializeWorker=null,Gt(t,r)):n}catch{return Gt(t,r)}}constructor(t={}){Object.defineProperty(this,"apiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"webUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"workspaceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchIngestCaller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timeout_ms",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tenantId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"hideInputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideOutputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"omitTracedRuntimeInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingSampleRate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"filteredPostUuids",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"autoBatchTracing",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"autoBatchQueue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchAggregationDelayMs",{enumerable:!0,configurable:!0,writable:!0,value:250}),Object.defineProperty(this,"batchSizeBytesLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchSizeLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fetchOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"settings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockOnRootRunFinalization",{enumerable:!0,configurable:!0,writable:!0,value:Pt("LANGSMITH_TRACING_BACKGROUND")==="false"}),Object.defineProperty(this,"traceBatchConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:5}),Object.defineProperty(this,"_serverInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_getServerInfoPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualFlushMode",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_serializeWorker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pendingDrains",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"langSmithToOTELTranslator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tracingMode",{enumerable:!0,configurable:!0,writable:!0,value:"langsmith"}),Object.defineProperty(this,"fetchImplementation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cachedLSEnvVarsForMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_promptCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"profileAuth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"multipartStreamingDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_multipartDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_runCompressionDisabled",{enumerable:!0,configurable:!0,writable:!0,value:Ke("DISABLE_RUN_COMPRESSION")==="true"}),Object.defineProperty(this,"failedTracesDir",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"failedTracesMaxBytes",{enumerable:!0,configurable:!0,writable:!0,value:100*1024*1024}),Object.defineProperty(this,"_customHeaders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"debug",{enumerable:!0,configurable:!0,writable:!0,value:Pt("LANGSMITH_DEBUG")==="true"});let r=e.getDefaultClientConfig();this.tracingSampleRate=ZD(t.tracingSamplingRate),this.apiUrl=Yd(t.apiUrl??r.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1));let n=Yd(t.apiKey??r.apiKey);if(this.apiKey=Gr(n)?n:void 0,this.profileAuth=this.apiKey!==void 0?void 0:r.profileAuth,this.webUrl=Yd(t.webUrl??r.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=Yd(t.workspaceId??r.workspaceId),this.timeout_ms=t.timeout_ms??9e4,this.caller=new nl({...t.callerOptions??{},maxRetries:4,debug:t.debug??this.debug}),this.traceBatchConcurrency=t.traceBatchConcurrency??this.traceBatchConcurrency,this.traceBatchConcurrency<1)throw new Error("Trace batch concurrency must be positive.");this.debug=t.debug??this.debug,this.fetchImplementation=t.fetchImplementation,this.failedTracesDir=Ke("FAILED_TRACES_DIR")||void 0;let i=Ke("FAILED_TRACES_MAX_MB");if(i){let o=parseInt(i,10);Number.isFinite(o)&&o>0&&(this.failedTracesMaxBytes=o*1024*1024)}let a=t.maxIngestMemoryBytes??gI;this.batchIngestCaller=new nl({maxRetries:4,maxConcurrency:this.traceBatchConcurrency,maxQueueSizeBytes:a,...t.callerOptions??{},onFailedResponseHook:WD,debug:t.debug??this.debug}),this.hideInputs=t.hideInputs??t.anonymizer??r.hideInputs,this.hideOutputs=t.hideOutputs??t.anonymizer??r.hideOutputs,this.hideMetadata=t.hideMetadata??r.hideMetadata,this.omitTracedRuntimeInfo=t.omitTracedRuntimeInfo??!1,this.autoBatchTracing=t.autoBatchTracing??this.autoBatchTracing,this.autoBatchQueue=new s_(a),this.blockOnRootRunFinalization=t.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=t.batchSizeBytesLimit,this.batchSizeLimit=t.batchSizeLimit,this.fetchOptions=t.fetchOptions||{},this.manualFlushMode=t.manualFlushMode??this.manualFlushMode,this._tracingMode=jd(t.tracingMode),this._tracingMode==="otel"&&(this.langSmithToOTELTranslator=new zd),this.cachedLSEnvVarsForMetadata=Mg(),t.cache!==void 0&&t.disablePromptCache&&ro("Both 'cache' and 'disablePromptCache' were provided. The 'cache' parameter is deprecated and will be removed in a future version. Using 'cache' parameter value."),t.cache!==void 0?(ro("The 'cache' parameter is deprecated and will be removed in a future version. Use 'configureGlobalPromptCache()' to configure the global cache, or 'disablePromptCache: true' to disable caching for this client."),t.cache===!1?this._promptCache=void 0:t.cache===!0?this._promptCache=Nd:this._promptCache=t.cache):t.disablePromptCache||(this._promptCache=Nd),this._customHeaders=t.headers??{}}static getDefaultClientConfig(){let t=iI(),r=Ke("API_KEY"),n=Ke("ENDPOINT"),i=Ke("WORKSPACE_ID"),a=Gr(r),o=n??t.apiUrl??Kd,s=i??t.workspaceId,c=Ke("HIDE_INPUTS")==="true",l=Ke("HIDE_OUTPUTS")==="true",u=Ke("HIDE_METADATA")==="true";return{apiUrl:o,apiKey:r,webUrl:void 0,hideInputs:c,hideOutputs:l,hideMetadata:u,workspaceId:s,oauthAccessToken:a?void 0:t.oauthAccessToken,oauthRefreshToken:a?void 0:t.oauthRefreshToken,profileAuth:a?void 0:t.profileAuth}}getHostUrl(){return this.webUrl?this.webUrl:HD(this.apiUrl)?(this.webUrl="http://localhost:3000",this.webUrl):this.apiUrl.endsWith("/api/v1")?(this.webUrl=this.apiUrl.replace("/api/v1",""),this.webUrl):this.apiUrl.includes("/api")&&!this.apiUrl.split(".",1)[0].endsWith("api")?(this.webUrl=this.apiUrl.replace("/api",""),this.webUrl):this.apiUrl.split(".",1)[0].includes("dev")?(this.webUrl="https://dev.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("eu")?(this.webUrl="https://eu.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("aws")?(this.webUrl="https://aws.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("apac")?(this.webUrl="https://apac.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("beta")?(this.webUrl="https://beta.smith.langchain.com",this.webUrl):(this.webUrl="https://smith.langchain.com",this.webUrl)}get _mergedHeaders(){let t={"User-Agent":`langsmith-js/${Rd}`,...this._customHeaders};if(this.apiKey!==void 0)t["x-api-key"]=`${this.apiKey}`;else{let r=this.profileAuth?.currentAuthHeader();r&&(t[r.name]=r.value)}return this.workspaceId&&(t["x-tenant-id"]=this.workspaceId),t}get headers(){return this._customHeaders}set headers(t){this._customHeaders=t??{}}_getPlatformEndpointPath(t){return this.apiUrl.slice(-3)!=="/v1"&&this.apiUrl.slice(-4)!=="/v1/"?`/v1/platform/${t}`:`/platform/${t}`}async processInputs(t){return this.hideInputs===!1?t:this.hideInputs===!0?{}:typeof this.hideInputs=="function"?this.hideInputs(t):t}async processOutputs(t){return this.hideOutputs===!1?t:this.hideOutputs===!0?{}:typeof this.hideOutputs=="function"?this.hideOutputs(t):t}async processMetadata(t){return this.hideMetadata===!1?t:this.hideMetadata===!0?{}:typeof this.hideMetadata=="function"?this.hideMetadata(t):t}_filterNewTokenEvents(t){return!t||t.length===0?t:t.map(r=>{if(r.name==="new_token"){let{kwargs:n,...i}=r;return i}return r})}async prepareRunCreateOrUpdateInputs(t){let r={...t};return r.inputs!==void 0&&(r.inputs=await this.processInputs(r.inputs)),r.outputs!==void 0&&(r.outputs=await this.processOutputs(r.outputs)),r.extra!=null&&"metadata"in r.extra&&(r.extra={...r.extra,metadata:await this.processMetadata(r.extra.metadata)}),r.events!==void 0&&(r.events=this._filterNewTokenEvents(r.events)),r}async _getResponse(t,r){let n=r?.toString()??"",i=`${this.apiUrl}${t}?${n}`;return await this.caller.call(async()=>{let o=await this._fetch(i,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(o,`fetch ${t}`),o})}async _get(t,r){return(await this._getResponse(t,r)).json()}async*_getPaginated(t,r=new URLSearchParams,n){let i=Number(r.get("offset"))||0,a=Number(r.get("limit"))||100;for(;;){r.set("offset",String(i)),r.set("limit",String(a));let o=`${this.apiUrl}${t}?${r}`,s=await this.caller.call(async()=>{let l=await this._fetch(o,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(l,`fetch ${t}`),l}),c=n?n(await s.json()):await s.json();if(c.length===0||(yield c,c.length<a))break;i+=c.length}}async*_getCursorPaginatedList(t,r=null,n="POST",i="runs"){let a=r?{...r}:{};for(;;){let o=JSON.stringify(a),c=await(await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}${t}`,{method:n,headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await X(u,`fetch ${t}`),u})).json();if(!c||!c[i])break;yield c[i];let l=c.cursors;if(!l||!l.next)break;a.cursor=l.next}}_shouldSample(){return this.tracingSampleRate===void 0?!0:Math.random()<this.tracingSampleRate}_filterForSampling(t,r=!1){if(this.tracingSampleRate===void 0)return t;if(r){let n=[];for(let i of t)this.filteredPostUuids.has(i.trace_id)?i.id===i.trace_id&&this.filteredPostUuids.delete(i.trace_id):n.push(i);return n}else{let n=[];for(let i of t){let a=i.trace_id??i.id;this.filteredPostUuids.has(a)||(i.id===a?this._shouldSample()?n.push(i):this.filteredPostUuids.add(a):n.push(i))}return n}}async _getBatchSizeLimitBytes(){let t=await this._ensureServerInfo();return this.batchSizeBytesLimit??t?.batch_ingest_config?.size_limit_bytes??JD}async _getBatchSizeLimit(){let t=await this._ensureServerInfo();return this.batchSizeLimit??t?.batch_ingest_config?.size_limit??qD}async _getDatasetExamplesMultiPartSupport(){return(await this._ensureServerInfo()).instance_flags?.dataset_examples_multipart_enabled??!1}drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r}){let n=[];for(;this.autoBatchQueue.items.length>0;){let[i,a]=this.autoBatchQueue.pop({upToSizeBytes:t,upToSize:r});if(!i.length){a();break}let o=i.reduce((l,u)=>{let d=u.apiUrl??this.apiUrl,f=u.apiKey??this.apiKey,m=u.apiKey===this.apiKey&&u.apiUrl===this.apiUrl?"default":`${d}|${f}`;return l[m]||(l[m]=[]),l[m].push(u),l},{}),s=[];for(let[l,u]of Object.entries(o)){let d=this._processBatch(u,{apiUrl:l==="default"?void 0:l.split("|")[0],apiKey:l==="default"?void 0:l.split("|")[1]});s.push(d)}let c=Promise.all(s).finally(a);n.push(c)}return Promise.all(n)}static async _writeTraceToFallbackDir(t,r,n,i,a){try{let o=typeof r=="string"?Buffer.from(r,"utf8"):Buffer.from(r),s=JSON.stringify({version:1,endpoint:i,headers:n,body_base64:o.toString("base64")}),c=`trace_${Date.now()}_${to().slice(0,8)}.json`,l=io.join(t,c);if(e._fallbackDirsCreated.has(t)||(await NE(t),e._fallbackDirsCreated.add(t)),a!==void 0&&a>0)try{let d=(await RE(t)).filter(p=>p.startsWith("trace_")&&p.endsWith(".json")),f=0;for(let p of d){let{size:m}=await ME(io.join(t,p));f+=m}if(f>=a){console.warn(`Could not write trace to fallback dir ${t} as it's already over size limit (${f} bytes >= ${a} bytes). Increase LANGSMITH_FAILED_TRACES_MAX_MB if possible.`);return}}catch{}await Ad(l,s),console.warn(`LangSmith trace upload failed; data saved to ${l} for later replay.`)}catch(o){console.error(`LangSmith tracing error: could not write trace to fallback dir ${t}:`,o)}}async _processBatch(t,r){if(!t.length)return;let n=t.reduce((i,a)=>i+(a.size??0),0);try{if(this.langSmithToOTELTranslator!==void 0)this._sendBatchToOTELTranslator(t);else{let i={runCreates:t.filter(s=>s.action==="create").map(s=>s.item),runUpdates:t.filter(s=>s.action==="update").map(s=>s.item)},a=await this._ensureServerInfo();if(!this._multipartDisabled&&(a?.batch_ingest_config?.use_multipart_endpoint??!0)){let s=!this._runCompressionDisabled&&a?.instance_flags?.gzip_body_enabled;try{await this.multipartIngestRuns(i,{...r,useGzip:s,sizeBytes:n})}catch(c){if(Jd(c))this._multipartDisabled=!0,await this.batchIngestRuns(i,{...r,sizeBytes:n});else throw c}}else await this.batchIngestRuns(i,{...r,sizeBytes:n})}}catch(i){console.error("Error exporting batch:",i)}}_sendBatchToOTELTranslator(t){if(this.langSmithToOTELTranslator!==void 0){let r=new Map,n=[];for(let i of t)i.item.id&&i.otelContext&&(r.set(i.item.id,i.otelContext),i.action==="create"?n.push({operation:"post",id:i.item.id,trace_id:i.item.trace_id??i.item.id,run:i.item}):n.push({operation:"patch",id:i.item.id,trace_id:i.item.trace_id??i.item.id,run:i.item}));this.langSmithToOTELTranslator.exportBatch(n,r)}}async processRunOperation(t){clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,t.item=pI(t.item,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);let r=this.autoBatchQueue.push(t);if(this.manualFlushMode)return r;let n=await this._getBatchSizeLimitBytes(),i=await this._getBatchSizeLimit();return(this.autoBatchQueue.sizeBytes>n||this.autoBatchQueue.items.length>i)&&this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:n,batchSizeLimit:i})),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:n,batchSizeLimit:i}))},this.autoBatchAggregationDelayMs)),r}async _getServerInfo(){let r=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/info`,{method:"GET",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(KD),...this.fetchOptions});return await X(n,"get server info"),n})).json();return this.debug&&console.log(`
120
+ === LangSmith Server Configuration ===
121
+ `+JSON.stringify(r,null,2)+`
122
+ `),r}async _ensureServerInfo(){return this._getServerInfoPromise===void 0&&(this._getServerInfoPromise=(async()=>{if(this._serverInfo===void 0)try{this._serverInfo=await this._getServerInfo()}catch(t){console.warn(`[LANGSMITH]: Failed to fetch info on supported operations. Falling back to batch operations and default limits. Info: ${t.status??"Unspecified status code"} ${t.message}`)}return this._serverInfo??{}})()),this._getServerInfoPromise.then(t=>(this._serverInfo===void 0&&(this._getServerInfoPromise=void 0),t))}async _getSettings(){return this.settings||(this.settings=this._get("/settings")),await this.settings}async flush(){let t=await this._getBatchSizeLimitBytes(),r=await this._getBatchSizeLimit();await this.drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r})}_cloneCurrentOTELContext(){let t=Dd(),r=FE();if(this.langSmithToOTELTranslator!==void 0){let n=t.getActiveSpan();if(n)return t.setSpan(r.active(),n)}}async createRun(t,r){if(!this._filterForSampling([t]).length)return;let n={...this._mergedHeaders,"Content-Type":"application/json"},i=t.project_name;delete t.project_name;let a=await this.prepareRunCreateOrUpdateInputs({session_name:i,...t,start_time:t.start_time??Date.now()});if(this.autoBatchTracing&&a.trace_id!==void 0&&a.dotted_order!==void 0){let c=this._cloneCurrentOTELContext();this.processRunOperation({action:"create",item:a,otelContext:c,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error);return}let o=pI(a,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);r?.apiKey!==void 0&&(n["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(n["x-tenant-id"]=r.workspaceId);let s=Gt(o,`Creating run with id: ${o.id}`);await this.caller.call(async()=>{let c=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs`,{method:"POST",headers:n,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await X(c,"create run",!0),c})}async batchIngestRuns({runCreates:t,runUpdates:r},n){if(t===void 0&&r===void 0)return;let i=await Promise.all(t?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]),a=await Promise.all(r?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]);if(i.length>0&&a.length>0){let c=i.reduce((u,d)=>(d.id&&(u[d.id]=d),u),{}),l=[];for(let u of a)u.id!==void 0&&c[u.id]?c[u.id]={...c[u.id],...u}:l.push(u);i=Object.values(c),a=l}let o={post:i,patch:a};if(!o.post.length&&!o.patch.length)return;let s={post:[],patch:[]};for(let c of["post","patch"]){let l=c,u=o[l].reverse(),d=u.pop();for(;d!==void 0;)s[l].push(d),d=u.pop()}if(s.post.length>0||s.patch.length>0){let c=s.post.map(l=>l.id).concat(s.patch.map(l=>l.id)).join(",");await this._postBatchIngestRuns(await this._serializeBody(s,`Ingesting runs with ids: ${c}`),n)}}async _postBatchIngestRuns(t,r){let n={...this._mergedHeaders,"Content-Type":"application/json",Accept:"application/json"};r?.apiKey!==void 0&&(n["x-api-key"]=r.apiKey),await this.batchIngestCaller.callWithOptions({sizeBytes:r?.sizeBytes},async()=>{let i=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/batch`,{method:"POST",headers:n,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:t});return await X(i,"batch create run",!0),i})}async multipartIngestRuns({runCreates:t,runUpdates:r},n){if(t===void 0&&r===void 0)return;let i={},a=[];for(let d of t??[]){let f=await this.prepareRunCreateOrUpdateInputs(d);f.id!==void 0&&f.attachments!==void 0&&(i[f.id]=f.attachments),delete f.attachments,a.push(f)}let o=[];for(let d of r??[])o.push(await this.prepareRunCreateOrUpdateInputs(d));if(a.find(d=>d.trace_id===void 0||d.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when creating a run');if(o.find(d=>d.trace_id===void 0||d.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when updating a run');if(a.length>0&&o.length>0){let d=a.reduce((p,m)=>(m.id&&(p[m.id]=m),p),{}),f=[];for(let p of o)p.id!==void 0&&d[p.id]?d[p.id]={...d[p.id],...p}:f.push(p);a=Object.values(d),o=f}if(a.length===0&&o.length===0)return;let l=[],u=[];for(let[d,f]of[["post",a],["patch",o]])for(let p of f){let{inputs:m,outputs:h,events:_,extra:y,error:w,serialized:x,attachments:S,...$}=p,P={inputs:m,outputs:h,events:_,extra:y,error:w,serialized:x},C=await this._serializeBody($,`Serializing for multipart ingestion of run with id: ${$.id}`);u.push({name:`${d}.${$.id}`,payload:new Blob([C],{type:`application/json; length=${C.length}`})});for(let[b,B]of Object.entries(P)){if(B===void 0)continue;let L=await this._serializeBody(B,`Serializing ${b} for multipart ingestion of run with id: ${$.id}`);u.push({name:`${d}.${$.id}.${b}`,payload:new Blob([L],{type:`application/json; length=${L.length}`})})}if($.id!==void 0){let b=i[$.id];if(b){delete i[$.id];for(let[B,L]of Object.entries(b)){let q,ae;if(Array.isArray(L)?[q,ae]=L:(q=L.mimeType,ae=L.data),B.includes(".")){console.warn(`Skipping attachment '${B}' for run ${$.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`);continue}u.push({name:`attachment.${$.id}.${B}`,payload:new Blob([ae],{type:`${q}; length=${ae.byteLength}`})})}}}l.push(`trace=${$.trace_id},id=${$.id}`)}await this._sendMultipartRequest(u,l.join("; "),n)}async _createNodeFetchBody(t,r){let n=[];for(let o of t)n.push(new Blob([`--${r}\r
123
+ `])),n.push(new Blob([`Content-Disposition: form-data; name="${o.name}"\r
124
+ `,`Content-Type: ${o.payload.type}\r
125
+ \r
126
+ `])),n.push(o.payload),n.push(new Blob([`\r
127
+ `]));return n.push(new Blob([`--${r}--\r
128
+ `])),await new Blob(n).arrayBuffer()}async _createMultipartStream(t,r){let n=new TextEncoder;return new ReadableStream({async start(a){let o=async s=>{typeof s=="string"?a.enqueue(n.encode(s)):a.enqueue(s)};for(let s of t){await o(`--${r}\r
129
+ `),await o(`Content-Disposition: form-data; name="${s.name}"\r
130
+ `),await o(`Content-Type: ${s.payload.type}\r
131
+ \r
132
+ `);let l=s.payload.stream().getReader();try{let u;for(;!(u=await l.read()).done;)a.enqueue(u.value)}finally{l.releaseLock()}await o(`\r
133
+ `)}await o(`--${r}--\r
134
+ `),a.close()}})}async _sendMultipartRequest(t,r,n){let i="----LangSmithFormBoundary"+Math.random().toString(36).slice(2),a=()=>this._createNodeFetchBody(t,i),o=()=>this._createMultipartStream(t,i),s=async c=>this.batchIngestCaller.callWithOptions({sizeBytes:n?.sizeBytes},async()=>{let l=await c(),u={...this._mergedHeaders,"Content-Type":`multipart/form-data; boundary=${i}`};n?.apiKey!==void 0&&(u["x-api-key"]=n.apiKey);let d=l;n?.useGzip&&typeof l=="object"&&"pipeThrough"in l&&(d=l.pipeThrough(new CompressionStream("gzip")),u["Content-Encoding"]="gzip");let f=await this._fetch(`${n?.apiUrl??this.apiUrl}/runs/multipart`,{method:"POST",headers:u,body:d,duplex:"half",signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(f,"Failed to send multipart request",!0),f});try{let c,l=!1;yE()&&!this.multipartStreamingDisabled&&tl()!=="bun"?(l=!0,c=await s(o)):c=await s(a),(!this.multipartStreamingDisabled||l)&&c.status===422&&(n?.apiUrl??this.apiUrl)!==Kd&&(console.warn(`Streaming multipart upload to ${n?.apiUrl??this.apiUrl}/runs/multipart failed. This usually means the host does not support chunked uploads. Retrying with a buffered upload for operation "${r}".`),this.multipartStreamingDisabled=!0,c=await s(a))}catch(c){if(Jd(c))throw c;if(console.warn(`${c.message.trim()}
135
+
136
+ Context: ${r}`),this.failedTracesDir){let l=await this._createNodeFetchBody(t,i).catch(()=>null);l&&await e._writeTraceToFallbackDir(this.failedTracesDir,l,{"Content-Type":`multipart/form-data; boundary=${i}`},"runs/multipart",this.failedTracesMaxBytes)}}}async updateRun(t,r,n){he(t),r.inputs&&(r.inputs=await this.processInputs(r.inputs)),r.outputs&&(r.outputs=await this.processOutputs(r.outputs)),r.extra!=null&&"metadata"in r.extra&&(r.extra={...r.extra,metadata:await this.processMetadata(r.extra.metadata)}),r.events&&(r.events=this._filterNewTokenEvents(r.events));let i={...r,id:t};if(!this._filterForSampling([i],!0).length)return;if(this.autoBatchTracing&&i.trace_id!==void 0&&i.dotted_order!==void 0){let s=this._cloneCurrentOTELContext();if(r.end_time!==void 0&&i.parent_run_id===void 0&&this.blockOnRootRunFinalization&&!this.manualFlushMode){await this.processRunOperation({action:"update",item:i,otelContext:s,apiKey:n?.apiKey,apiUrl:n?.apiUrl}).catch(console.error);return}else this.processRunOperation({action:"update",item:i,otelContext:s,apiKey:n?.apiKey,apiUrl:n?.apiUrl}).catch(console.error);return}let a={...this._mergedHeaders,"Content-Type":"application/json"};n?.apiKey!==void 0&&(a["x-api-key"]=n.apiKey),n?.workspaceId!==void 0&&(a["x-tenant-id"]=n.workspaceId);let o=Gt(r,`Serializing payload to update run with id: ${t}`);await this.caller.call(async()=>{let s=await this._fetch(`${n?.apiUrl??this.apiUrl}/runs/${t}`,{method:"PATCH",headers:a,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await X(s,"update run",!0),s})}async readRun(t,{loadChildRuns:r}={loadChildRuns:!1}){he(t);let n=il(await this._get(`/runs/${t}`));return r&&(n=await this._loadChildRuns(n)),n}async getRunUrl({runId:t,run:r,projectOpts:n}){if(r!==void 0){let i;r.session_id?i=r.session_id:n?.projectName?i=(await this.readProject({projectName:n?.projectName})).id:n?.projectId?i=n?.projectId:i=(await this.readProject({projectName:Ke("PROJECT")||"default"})).id;let a=await this._getTenantId();return`${this.getHostUrl()}/o/${a}/projects/p/${i}/r/${r.id}?poll=true`}else if(t!==void 0){let i=await this.readRun(t);if(!i.app_path)throw new Error(`Run ${t} has no app_path`);return`${this.getHostUrl()}${i.app_path}`}else throw new Error("Must provide either runId or run")}async _loadChildRuns(t){let r=await GD(this.listRuns({isRoot:!1,projectId:t.session_id,traceId:t.trace_id})),n={},i={};r.sort((a,o)=>(a?.dotted_order??"").localeCompare(o?.dotted_order??""));for(let a of r){if(a.parent_run_id===null||a.parent_run_id===void 0)throw new Error(`Child run ${a.id} has no parent`);a.dotted_order?.startsWith(t.dotted_order??"")&&a.id!==t.id&&(a.parent_run_id in n||(n[a.parent_run_id]=[]),n[a.parent_run_id].push(a),i[a.id]=a)}t.child_runs=n[t.id]||[];for(let a in n)a!==t.id&&(i[a].child_runs=n[a]);return t}async*listRuns(t){let{projectId:r,projectName:n,parentRunId:i,traceId:a,referenceExampleId:o,startTime:s,executionOrder:c,isRoot:l,runType:u,error:d,id:f,query:p,filter:m,traceFilter:h,treeFilter:_,limit:y,select:w,order:x}=t,S=[];if(r&&(S=Array.isArray(r)?r:[r]),n){let b=Array.isArray(n)?n:[n],B=await Promise.all(b.map(L=>this.readProject({projectName:L}).then(q=>q.id)));S.push(...B)}let $=["app_path","completion_cost","completion_tokens","dotted_order","end_time","error","events","extra","feedback_stats","first_token_time","id","inputs","name","outputs","parent_run_id","parent_run_ids","prompt_cost","prompt_tokens","reference_example_id","run_type","session_id","start_time","status","tags","total_cost","total_tokens","trace_id"],P={session:S.length?S:null,run_type:u,reference_example:o,query:p,filter:m,trace_filter:h,tree_filter:_,execution_order:c,parent_run:i,start_time:s?s.toISOString():null,error:d,id:f,limit:y,trace:a,select:w||$,is_root:l,order:x};P.select.includes("child_run_ids")&&ro("Deprecated: 'child_run_ids' in the listRuns select parameter is deprecated and will be removed in a future version.");let C=0;for await(let b of this._getCursorPaginatedList("/runs/query",P)){let B=b.map(il);if(y){if(C>=y)break;if(B.length+C>y){yield*B.slice(0,y-C);break}C+=B.length,yield*B}else yield*B}}async*listGroupRuns(t){let{projectId:r,projectName:n,groupBy:i,filter:a,startTime:o,endTime:s,limit:c,offset:l}=t,d={session_id:r||(await this.readProject({projectName:n})).id,group_by:i,filter:a,start_time:o?o.toISOString():null,end_time:s?s.toISOString():null,limit:Number(c)||100},f=Number(l)||0,p="/runs/group",m=`${this.apiUrl}${p}`;for(;;){let h={...d,offset:f},_=Object.fromEntries(Object.entries(h).filter(([P,C])=>C!==void 0)),y=JSON.stringify(_),x=await(await this.caller.call(async()=>{let P=await this._fetch(m,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:y});return await X(P,`Failed to fetch ${p}`),P})).json(),{groups:S,total:$}=x;if(S.length===0)break;for(let P of S)yield P;if(f+=S.length,f>=$)break}}async*readThread(t){let{threadId:r,projectId:n,projectName:i,isRoot:a=!0,limit:o,filter:s,order:c="asc"}=t;if(!n&&!i)throw new Error("threadId requires projectId or projectName");let l=`eq(thread_id, ${JSON.stringify(r)})`,u=s?`and(${l}, ${s})`:l;yield*this.listRuns({projectId:n??void 0,projectName:i??void 0,isRoot:a,limit:o,filter:u,order:c})}async listThreads(t){let{projectId:r,projectName:n,limit:i,offset:a=0,filter:o,startTime:s,isRoot:c=!0}=t;if(!r&&!n)throw new Error("Either projectId or projectName must be provided");if(r&&n)throw new Error("Provide exactly one of projectId or projectName");let l=r??(await this.readProject({projectName:n})).id,u=s??new Date(Date.now()-1440*60*1e3),f={session:[l],is_root:c,limit:100,order:"desc",select:["id","name","status","start_time","end_time","thread_id","trace_id","run_type","error","tags","session_id","parent_run_id","total_tokens","total_cost","dotted_order","reference_example_id","feedback_stats","app_path","completion_cost","completion_tokens","prompt_cost","prompt_tokens","first_token_time"],start_time:u.toISOString()};o!=null&&(f.filter=o);let p=new Map;for await(let y of this._getCursorPaginatedList("/runs/query",f))for(let w of y){let x=il(w),S=x.thread_id;if(S){let $=p.get(S)??[];$.push(x),p.set(S,$)}}let m=[];for(let[y,w]of p.entries()){w.sort((C,b)=>{let B=C,L=b,q=B.start_time??"",ae=L.start_time??"";if(q!==ae)return q.localeCompare(ae);let Se=B.dotted_order??"",Oe=L.dotted_order??"";return Se.localeCompare(Oe)});let S=[...w.map(C=>C.start_time).filter(Boolean)].sort(),$=S.length?S[0]:"",P=S.length?S[S.length-1]:"";m.push({thread_id:y,runs:w,count:w.length,filter:"",total_tokens:0,total_cost:null,min_start_time:$,max_start_time:P,latency_p50:0,latency_p99:0,feedback_stats:null,first_inputs:"",last_outputs:"",last_error:null})}m.sort((y,w)=>{let x=y.max_start_time??"";return(w.max_start_time??"").localeCompare(x)});let h=a>0?m.slice(a):m;return i!==void 0?h.slice(0,i):h}async getRunStats({id:t,trace:r,parentRun:n,runType:i,projectNames:a,projectIds:o,referenceExampleIds:s,startTime:c,endTime:l,error:u,query:d,filter:f,traceFilter:p,treeFilter:m,isRoot:h,dataSourceType:_}){let y=o||[];a&&(y=[...o||[],...await Promise.all(a.map(C=>this.readProject({projectName:C}).then(b=>b.id)))]);let x=Object.fromEntries(Object.entries({id:t,trace:r,parent_run:n,run_type:i,session:y,reference_example:s,start_time:c,end_time:l,error:u,query:d,filter:f,trace_filter:p,tree_filter:m,is_root:h,data_source_type:_}).filter(([C,b])=>b!==void 0)),S=JSON.stringify(x);return await(await this.caller.call(async()=>{let C=await this._fetch(`${this.apiUrl}/runs/stats`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:S});return await X(C,"get run stats"),C})).json()}async shareRun(t,{shareId:r}={}){let n={run_id:t,share_token:r||to()};he(t);let i=JSON.stringify(n),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"PUT",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await X(s,"share run"),s})).json();if(o===null||!("share_token"in o))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${o.share_token}/r`}async unshareRun(t){he(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(r,"unshare run",!0),r})}async readRunSharedLink(t){he(t);let n=await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"read run shared link"),i})).json();if(!(n===null||!("share_token"in n)))return`${this.getHostUrl()}/public/${n.share_token}/r`}async listSharedRuns(t,{runIds:r}={}){let n=new URLSearchParams({share_token:t});if(r!==void 0)for(let o of r)n.append("id",o);return he(t),(await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/public/${t}/runs${n}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(o,"list shared runs"),o})).json()).map(il)}async readDatasetSharedSchema(t,r){if(!t&&!r)throw new Error("Either datasetId or datasetName must be given");t||(t=(await this.readDataset({datasetName:r})).id),he(t);let i=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,"read dataset shared schema"),a})).json();return i.url=`${this.getHostUrl()}/public/${i.share_token}/d`,i}async shareDataset(t,r){if(!t&&!r)throw new Error("Either datasetId or datasetName must be given");t||(t=(await this.readDataset({datasetName:r})).id);let n={dataset_id:t};he(t);let i=JSON.stringify(n),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"PUT",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await X(s,"share dataset"),s})).json();return o.url=`${this.getHostUrl()}/public/${o.share_token}/d`,o}async unshareDataset(t){he(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(r,"unshare dataset",!0),r})}async readSharedDataset(t){return he(t),await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/public/${t}/datasets`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"read shared dataset"),i})).json()}async listSharedExamples(t,r){let n={};r?.exampleIds&&(n.id=r.exampleIds);let i=new URLSearchParams;Object.entries(n).forEach(([s,c])=>{Array.isArray(c)?c.forEach(l=>i.append(s,l)):i.append(s,c)});let a=await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/public/${t}/examples?${i.toString()}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(s,"list shared examples"),s}),o=await a.json();if(!a.ok)throw"detail"in o?new Error(`Failed to list shared examples.
137
+ Status: ${a.status}
138
+ Message: ${Array.isArray(o.detail)?o.detail.join(`
139
+ `):"Unspecified error"}`):new Error(`Failed to list shared examples: ${a.status} ${a.statusText}`);return o.map(s=>({...s,_hostUrl:this.getHostUrl()}))}async createProject({projectName:t,description:r=null,metadata:n=null,upsert:i=!1,projectExtra:a=null,referenceDatasetId:o=null}){let s=i?"?upsert=true":"",c=`${this.apiUrl}/sessions${s}`,l=a||{};n&&(l.metadata=n);let u={name:t,extra:l,description:r};o!==null&&(u.reference_dataset_id=o);let d=JSON.stringify(u);return await(await this.caller.call(async()=>{let m=await this._fetch(c,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:d});return await X(m,"create project"),m})).json()}async updateProject(t,{name:r=null,description:n=null,metadata:i=null,projectExtra:a=null,endTime:o=null}){let s=`${this.apiUrl}/sessions/${t}`,c=a;i&&(c={...c||{},metadata:i});let l=JSON.stringify({name:r,extra:c,description:n,end_time:o?new Date(o).toISOString():null});return await(await this.caller.call(async()=>{let f=await this._fetch(s,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await X(f,"update project"),f})).json()}async hasProject({projectId:t,projectName:r}){let n="/sessions",i=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)he(t),n+=`/${t}`;else if(r!==void 0)i.append("name",r);else throw new Error("Must provide projectName or projectId");let a=await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${n}?${i}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(o,"has project"),o});try{let o=await a.json();return a.ok?Array.isArray(o)?o.length>0:!0:!1}catch{return!1}}async readProject({projectId:t,projectName:r,includeStats:n}){let i="/sessions",a=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)he(t),i+=`/${t}`;else if(r!==void 0)a.append("name",r);else throw new Error("Must provide projectName or projectId");n!==void 0&&a.append("include_stats",n.toString());let o=await this._get(i,a),s;if(Array.isArray(o)){if(o.length===0)throw new Error(`Project[id=${t}, name=${r}] not found`);s=o[0]}else s=o;return s}async getProjectUrl({projectId:t,projectName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either projectName or projectId");let n=await this.readProject({projectId:t,projectName:r}),i=await this._getTenantId();return`${this.getHostUrl()}/o/${i}/projects/p/${n.id}`}async getDatasetUrl({datasetId:t,datasetName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");let n=await this.readDataset({datasetId:t,datasetName:r}),i=await this._getTenantId();return`${this.getHostUrl()}/o/${i}/datasets/${n.id}`}async _getTenantId(){if(this._tenantId!==null)return this._tenantId;let t=new URLSearchParams({limit:"1"});for await(let r of this._getPaginated("/sessions",t))return this._tenantId=r[0].tenant_id,r[0].tenant_id;throw new Error("No projects found to resolve tenant.")}async*listProjects({projectIds:t,name:r,nameContains:n,referenceDatasetId:i,referenceDatasetName:a,includeStats:o,datasetVersion:s,referenceFree:c,metadata:l}={}){let u=new URLSearchParams;if(t!==void 0)for(let d of t)u.append("id",d);if(r!==void 0&&u.append("name",r),n!==void 0&&u.append("name_contains",n),i!==void 0)u.append("reference_dataset",i);else if(a!==void 0){let d=await this.readDataset({datasetName:a});u.append("reference_dataset",d.id)}o!==void 0&&u.append("include_stats",o.toString()),s!==void 0&&u.append("dataset_version",s),c!==void 0&&u.append("reference_free",c.toString()),l!==void 0&&u.append("metadata",JSON.stringify(l));for await(let d of this._getPaginated("/sessions",u))yield*d}async deleteProject({projectId:t,projectName:r}){let n;if(t===void 0&&r===void 0)throw new Error("Must provide projectName or projectId");if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");t===void 0?n=(await this.readProject({projectName:r})).id:n=t,he(n),await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/sessions/${n}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,`delete session ${n} (${r})`,!0),i})}async uploadCsv({csvFile:t,fileName:r,inputKeys:n,outputKeys:i,description:a,dataType:o,name:s}){let c=`${this.apiUrl}/datasets/upload`,l=new FormData,u=new Blob([t],{type:"text/csv"});return l.append("file",u,r),n.forEach(p=>{l.append("input_keys",p)}),i.forEach(p=>{l.append("output_keys",p)}),a&&l.append("description",a),o&&l.append("data_type",o),s&&l.append("name",s),await(await this.caller.call(async()=>{let p=await this._fetch(c,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await X(p,"upload CSV"),p})).json()}async createDataset(t,{description:r,dataType:n,inputsSchema:i,outputsSchema:a,metadata:o}={}){let s={name:t,description:r,extra:{source:"sdk",...o?{metadata:o}:{}}};n&&(s.data_type=n),i&&(s.inputs_schema_definition=i),a&&(s.outputs_schema_definition=a);let c=JSON.stringify(s);return await(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/datasets`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await X(d,"create dataset"),d})).json()}async readDataset({datasetId:t,datasetName:r}){let n="/datasets",i=new URLSearchParams({limit:"1"});if(t&&r)throw new Error("Must provide either datasetName or datasetId, not both");if(t)he(t),n+=`/${t}`;else if(r)i.append("name",r);else throw new Error("Must provide datasetName or datasetId");let a=await this._get(n,i),o;if(Array.isArray(a)){if(a.length===0)throw new Error(`Dataset[id=${t}, name=${r}] not found`);o=a[0]}else o=a;return o}async hasDataset({datasetId:t,datasetName:r}){try{return await this.readDataset({datasetId:t,datasetName:r}),!0}catch(n){if(n instanceof Error&&n.message.toLocaleLowerCase().includes("not found"))return!1;throw n}}async diffDatasetVersions({datasetId:t,datasetName:r,fromVersion:n,toVersion:i}){let a=t;if(a===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");if(a!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");a===void 0&&(a=(await this.readDataset({datasetName:r})).id);let o=new URLSearchParams({from_version:typeof n=="string"?n:n.toISOString(),to_version:typeof i=="string"?i:i.toISOString()});return await this._get(`/datasets/${a}/versions/diff`,o)}async readDatasetOpenaiFinetuning({datasetId:t,datasetName:r}){let n="/datasets";if(t===void 0)if(r!==void 0)t=(await this.readDataset({datasetName:r})).id;else throw new Error("Must provide either datasetName or datasetId");return(await(await this._getResponse(`${n}/${t}/openai_ft`)).text()).trim().split(`
140
+ `).map(s=>JSON.parse(s))}async*listDatasets({limit:t=100,offset:r=0,datasetIds:n,datasetName:i,datasetNameContains:a,metadata:o}={}){let s="/datasets",c=new URLSearchParams({limit:t.toString(),offset:r.toString()});if(n!==void 0)for(let l of n)c.append("id",l);i!==void 0&&c.append("name",i),a!==void 0&&c.append("name_contains",a),o!==void 0&&c.append("metadata",JSON.stringify(o));for await(let l of this._getPaginated(s,c))yield*l}async updateDataset(t){let{datasetId:r,datasetName:n,...i}=t;if(!r&&!n)throw new Error("Must provide either datasetName or datasetId");let a=r??(await this.readDataset({datasetName:n})).id;he(a);let o=JSON.stringify(i);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await X(c,"update dataset"),c})).json()}async updateDatasetTag(t){let{datasetId:r,datasetName:n,asOf:i,tag:a}=t;if(!r&&!n)throw new Error("Must provide either datasetName or datasetId");let o=r??(await this.readDataset({datasetName:n})).id;he(o);let s=JSON.stringify({as_of:typeof i=="string"?i:i.toISOString(),tag:a});await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${o}/tags`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await X(c,"update dataset tags",!0),c})}async deleteDataset({datasetId:t,datasetName:r}){let n="/datasets",i=t;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(r!==void 0&&(i=(await this.readDataset({datasetName:r})).id),i!==void 0)he(i),n+=`/${i}`;else throw new Error("Must provide datasetName or datasetId");await this.caller.call(async()=>{let a=await this._fetch(this.apiUrl+n,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,`delete ${n}`,!0),a})}async createExample(t,r,n){if(hI(t)&&(r!==void 0||n!==void 0))throw new Error("Cannot provide outputs or options when using ExampleCreate object");let i=r?n?.datasetId:t.dataset_id,a=r?n?.datasetName:t.dataset_name;if(i===void 0&&a===void 0)throw new Error("Must provide either datasetName or datasetId");if(i!==void 0&&a!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");i===void 0&&(i=(await this.readDataset({datasetName:a})).id);let o=(r?n?.createdAt:t.created_at)||new Date,s;hI(t)?s=t:s={inputs:t,outputs:r,created_at:o?.toISOString(),id:n?.exampleId,metadata:n?.metadata,split:n?.split,source_run_id:n?.sourceRunId,use_source_run_io:n?.useSourceRunIO,use_source_run_attachments:n?.useSourceRunAttachments,attachments:n?.attachments};let c=await this._uploadExamplesMultipart(i,[s]);return await this.readExample(c.example_ids?.[0]??to())}async createExamples(t){if(Array.isArray(t)){if(t.length===0)return[];let w=t,x=w[0].dataset_id,S=w[0].dataset_name;if(x===void 0&&S===void 0)throw new Error("Must provide either datasetName or datasetId");if(x!==void 0&&S!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");x===void 0&&(x=(await this.readDataset({datasetName:S})).id);let $=await this._uploadExamplesMultipart(x,w);return await Promise.all($.example_ids.map(C=>this.readExample(C)))}let{inputs:r,outputs:n,metadata:i,splits:a,sourceRunIds:o,useSourceRunIOs:s,useSourceRunAttachments:c,attachments:l,exampleIds:u,datasetId:d,datasetName:f}=t;if(r===void 0)throw new Error("Must provide inputs when using legacy parameters");let p=d,m=f;if(p===void 0&&m===void 0)throw new Error("Must provide either datasetName or datasetId");if(p!==void 0&&m!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");p===void 0&&(p=(await this.readDataset({datasetName:m})).id);let h=r.map((w,x)=>({dataset_id:p,inputs:w,outputs:n?.[x],metadata:i?.[x],split:a?.[x],id:u?.[x],attachments:l?.[x],source_run_id:o?.[x],use_source_run_io:s?.[x],use_source_run_attachments:c?.[x]})),_=await this._uploadExamplesMultipart(p,h);return await Promise.all(_.example_ids.map(w=>this.readExample(w)))}async createLLMExample(t,r,n){return this.createExample({input:t},{output:r},n)}async createChatExample(t,r,n){let i=t.map(o=>Yg(o)?Qg(o):o),a=Yg(r)?Qg(r):r;return this.createExample({input:i},{output:a},n)}async readExample(t){he(t);let r=`/examples/${t}`,n=await this._get(r),{attachment_urls:i,...a}=n,o=a;return i&&(o.attachments=Object.entries(i).reduce((s,[c,l])=>(s[c.slice(11)]={presigned_url:l.presigned_url,mime_type:l.mime_type},s),{})),o}async*listExamples({datasetId:t,datasetName:r,exampleIds:n,asOf:i,splits:a,inlineS3Urls:o,metadata:s,limit:c,offset:l,filter:u,includeAttachments:d}={}){let f;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(t!==void 0)f=t;else if(r!==void 0)f=(await this.readDataset({datasetName:r})).id;else throw new Error("Must provide a datasetName or datasetId");let p=new URLSearchParams({dataset:f}),m=i?typeof i=="string"?i:i?.toISOString():void 0;m&&p.append("as_of",m);let h=o??!0;if(p.append("inline_s3_urls",h.toString()),n!==void 0)for(let y of n)p.append("id",y);if(a!==void 0)for(let y of a)p.append("splits",y);if(s!==void 0){let y=JSON.stringify(s);p.append("metadata",y)}c!==void 0&&p.append("limit",c.toString()),l!==void 0&&p.append("offset",l.toString()),u!==void 0&&p.append("filter",u),d===!0&&["attachment_urls","outputs","metadata"].forEach(y=>p.append("select",y));let _=0;for await(let y of this._getPaginated("/examples",p)){for(let w of y){let{attachment_urls:x,...S}=w,$=S;x&&($.attachments=Object.entries(x).reduce((P,[C,b])=>(P[C.slice(11)]={presigned_url:b.presigned_url,mime_type:b.mime_type||void 0},P),{})),yield $,_++}if(c!==void 0&&_>=c)break}}async deleteExample(t){he(t);let r=`/examples/${t}`;await this.caller.call(async()=>{let n=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,`delete ${r}`,!0),n})}async deleteExamples(t,r){if(t.forEach(n=>he(n)),r?.hardDelete){let n=this._getPlatformEndpointPath("datasets/examples/delete");await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}${n}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},body:JSON.stringify({example_ids:t,hard_delete:!0}),signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"hard delete examples",!0),i})}else{let n=new URLSearchParams;t.forEach(i=>n.append("example_ids",i)),await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/examples?${n.toString()}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"delete examples",!0),i})}}async updateExample(t,r){let n;r?n=t:n=t.id,he(n);let i;r?i={id:n,...r}:i=t;let a;return i.dataset_id!==void 0?a=i.dataset_id:a=(await this.readExample(n)).dataset_id,this._updateExamplesMultipart(a,[i])}async updateExamples(t){let r;return t[0].dataset_id===void 0?r=(await this.readExample(t[0].id)).dataset_id:r=t[0].dataset_id,this._updateExamplesMultipart(r,t)}async readDatasetVersion({datasetId:t,datasetName:r,asOf:n,tag:i}){let a;if(t?a=t:a=(await this.readDataset({datasetName:r})).id,he(a),n&&i||!n&&!i)throw new Error("Exactly one of asOf and tag must be specified.");let o=new URLSearchParams;return n!==void 0&&o.append("as_of",typeof n=="string"?n:n.toISOString()),i!==void 0&&o.append("tag",i),await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}/version?${o.toString()}`,{method:"GET",headers:{...this._mergedHeaders},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(c,"read dataset version"),c})).json()}async listDatasetSplits({datasetId:t,datasetName:r,asOf:n}){let i;if(t===void 0&&r===void 0)throw new Error("Must provide dataset name or ID");if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");t===void 0?i=(await this.readDataset({datasetName:r})).id:i=t,he(i);let a=new URLSearchParams,o=n?typeof n=="string"?n:n?.toISOString():void 0;return o&&a.append("as_of",o),await this._get(`/datasets/${i}/splits`,a)}async updateDatasetSplits({datasetId:t,datasetName:r,splitName:n,exampleIds:i,remove:a=!1}){let o;if(t===void 0&&r===void 0)throw new Error("Must provide dataset name or ID");if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");t===void 0?o=(await this.readDataset({datasetName:r})).id:o=t,he(o);let s={split_name:n,examples:i.map(l=>(he(l),l)),remove:a},c=JSON.stringify(s);await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}/datasets/${o}/splits`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await X(l,"update dataset splits",!0),l})}async createFeedback(t,r,{score:n,value:i,correction:a,comment:o,sourceInfo:s,feedbackSourceType:c="api",sourceRunId:l,feedbackId:u,feedbackConfig:d,projectId:f,comparativeExperimentId:p,sessionId:m,startTime:h}){if(!t&&!f)throw new Error("One of runId or projectId must be provided");if(t&&f)throw new Error("Only one of runId or projectId can be provided");let _={type:c??"api",metadata:s??{}};l!==void 0&&_?.metadata!==void 0&&!_.metadata.__run&&(_.metadata.__run={run_id:l}),_?.metadata!==void 0&&_.metadata.__run?.run_id!==void 0&&he(_.metadata.__run.run_id);let y={id:u??ms(),run_id:t,key:r,score:mI(n),value:i,correction:a,comment:o,feedback_source:_,comparative_experiment_id:p,feedbackConfig:d,session_id:m??f,start_time:h},w=JSON.stringify(y),x=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{let S=await this._fetch(x,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:w});return await X(S,"create feedback",!0),S}),y}async updateFeedback(t,{score:r,value:n,correction:i,comment:a}){let o={};r!=null&&(o.score=mI(r)),n!=null&&(o.value=n),i!=null&&(o.correction=i),a!=null&&(o.comment=a),he(t);let s=JSON.stringify(o);await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/${t}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await X(c,"update feedback",!0),c})}async readFeedback(t){he(t);let r=`/feedback/${t}`;return await this._get(r)}async deleteFeedback(t){he(t);let r=`/feedback/${t}`;await this.caller.call(async()=>{let n=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,`delete ${r}`,!0),n})}async*listFeedback({runIds:t,feedbackKeys:r,feedbackSourceTypes:n}={}){let i=new URLSearchParams;if(t)for(let a of t)he(a),i.append("run",a);if(r)for(let a of r)i.append("key",a);if(n)for(let a of n)i.append("source",a);for await(let a of this._getPaginated("/feedback",i))yield*a}async createPresignedFeedbackToken(t,r,{expiration:n,feedbackConfig:i}={}){let a={run_id:t,feedback_key:r,feedback_config:i};n?typeof n=="string"?a.expires_at=n:(n?.hours||n?.minutes||n?.days)&&(a.expires_in=n):a.expires_in={hours:3};let o=JSON.stringify(a);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/tokens`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await X(c,"create presigned feedback token"),c})).json()}async createComparativeExperiment({name:t,experimentIds:r,referenceDatasetId:n,createdAt:i,description:a,metadata:o,id:s}){if(r.length===0)throw new Error("At least one experiment is required");if(n||(n=(await this.readProject({projectId:r[0]})).reference_dataset_id),!n==null)throw new Error("A reference dataset is required");let c={id:s,name:t,experiment_ids:r,reference_dataset_id:n,description:a,created_at:(i??new Date)?.toISOString(),extra:{}};o&&(c.extra.metadata=o);let l=JSON.stringify(c);return(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/datasets/comparative`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await X(d,"create comparative experiment"),d})).json()}async*listPresignedFeedbackTokens(t){he(t);let r=new URLSearchParams({run_id:t});for await(let n of this._getPaginated("/feedback/tokens",r))yield*n}_selectEvalResults(t){let r;return"results"in t?r=t.results:Array.isArray(t)?r=t:r=[t],r}async _logEvaluationFeedback(t,r,n){let i=this._selectEvalResults(t),a=[];for(let o of i){let s=n||{};o.evaluatorInfo&&(s={...o.evaluatorInfo,...s});let c=null;o.targetRunId?c=o.targetRunId:r&&(c=r.id),a.push(await this.createFeedback(c,o.key,{score:o.score,value:o.value,comment:o.comment,correction:o.correction,sourceInfo:s,sourceRunId:o.sourceRunId,feedbackConfig:o.feedbackConfig,feedbackSourceType:"model",sessionId:r?.session_id,startTime:r?.start_time}))}return[i,a]}async logEvaluationFeedback(t,r,n){let[i]=await this._logEvaluationFeedback(t,r,n);return i}async createFeedbackConfig(t){let{feedbackKey:r,feedbackConfig:n,isLowerScoreBetter:i=!1}=t,a={feedback_key:r,feedback_config:n,is_lower_score_better:i};return(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await X(s,"create feedback config"),s})).json()}async*listFeedbackConfigs(t={}){let{feedbackKeys:r,nameContains:n,limit:i}=t,a=new URLSearchParams;r&&r.forEach(s=>{a.append("key",s)}),n&&a.append("name_contains",n),a.append("limit",(i!==void 0?Math.min(i,100):100).toString());let o=0;for await(let s of this._getPaginated("/feedback-configs",a))if(yield*s,o+=s.length,i!==void 0&&o>=i)break}async updateFeedbackConfig(t,r={}){let{feedbackConfig:n,isLowerScoreBetter:i}=r,a={feedback_key:t};return n!==void 0&&(a.feedback_config=n),i!==void 0&&(a.is_lower_score_better=i),(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await X(s,"update feedback config"),s})).json()}async deleteFeedbackConfig(t){let r=new URLSearchParams({feedback_key:t});await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/feedback-configs?${r}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"delete feedback config",!0),n})}async*listAnnotationQueues(t={}){let{queueIds:r,name:n,nameContains:i,limit:a}=t,o=new URLSearchParams;r&&r.forEach((c,l)=>{he(c,`queueIds[${l}]`),o.append("ids",c)}),n&&o.append("name",n),i&&o.append("name_contains",i),o.append("limit",(a!==void 0?Math.min(a,100):100).toString());let s=0;for await(let c of this._getPaginated("/annotation-queues",o))if(yield*c,s++,a!==void 0&&s>=a)break}async createAnnotationQueue(t){let{name:r,description:n,queueId:i,rubricInstructions:a,rubricItems:o}=t,s={name:r,description:n,id:i||to(),rubric_instructions:a,rubric_items:o},c=JSON.stringify(Object.fromEntries(Object.entries(s).filter(([u,d])=>d!==void 0)));return(await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/annotation-queues`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await X(u,"create annotation queue"),u})).json()}async readAnnotationQueue(t){return(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${he(t,"queueId")}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"read annotation queue"),n})).json()}async updateAnnotationQueue(t,r){let{name:n,description:i,rubricInstructions:a,rubricItems:o}=r,s={};n!==void 0&&(s.name=n),i!==void 0&&(s.description=i),a!==void 0&&(s.rubric_instructions=a),o!==void 0&&(s.rubric_items=o);let c=JSON.stringify(s);await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}/annotation-queues/${he(t,"queueId")}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await X(l,"update annotation queue",!0),l})}async deleteAnnotationQueue(t){await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/annotation-queues/${he(t,"queueId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(r,"delete annotation queue",!0),r})}async addRunsToAnnotationQueue(t,r){let n=JSON.stringify(r.map((i,a)=>he(i,`runIds[${a}]`).toString()));await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${he(t,"queueId")}/runs`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await X(i,"add runs to annotation queue",!0),i})}async getRunFromAnnotationQueue(t,r){let n=`/annotation-queues/${he(t,"queueId")}/run`,a=await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${n}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(o,"get run from annotation queue"),o})).json();return il(a)}async deleteRunFromAnnotationQueue(t,r){await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${he(t,"queueId")}/runs/${he(r,"queueRunId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"delete run from annotation queue",!0),n})}async getSizeFromAnnotationQueue(t){return(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${he(t,"queueId")}/size`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"get size from annotation queue"),n})).json()}async _currentTenantIsOwner(t){let r=await this._getSettings();return t=="-"||r.tenant_handle===t}async _ownerConflictError(t,r){let n=await this._getSettings();return new Error(`Cannot ${t} for another tenant.
141
+
142
+ Current tenant: ${n.tenant_handle}
143
+
144
+ Requested tenant: ${r}`)}async _getLatestCommitHash(t){let n=await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/commits/${t}/?limit=1&offset=0`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"get latest commit hash"),i})).json();if(n.commits.length!==0)return n.commits[0].commit_hash}async _likeOrUnlikePrompt(t,r){let[n,i,a]=Ht(t),o=JSON.stringify({like:r});return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/likes/${n}/${i}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await X(c,`${r?"like":"unlike"} prompt`),c})).json()}async _getPromptUrl(t){let[r,n,i]=Ht(t);if(await this._currentTenantIsOwner(r)){let a=await this._getSettings();return i!=="latest"?`${this.getHostUrl()}/prompts/${n}/${i.substring(0,8)}?organizationId=${a.id}`:`${this.getHostUrl()}/prompts/${n}?organizationId=${a.id}`}else return i!=="latest"?`${this.getHostUrl()}/hub/${r}/${n}/${i.substring(0,8)}`:`${this.getHostUrl()}/hub/${r}/${n}`}async promptExists(t){return!!await this.getPrompt(t)}async likePrompt(t){return this._likeOrUnlikePrompt(t,!0)}async unlikePrompt(t){return this._likeOrUnlikePrompt(t,!1)}async*listCommits(t){let[r,n,i]=Ht(t);for await(let a of this._getPaginated(`/commits/${r}/${n}/`,new URLSearchParams,o=>o.commits))yield*a}async*listPrompts(t){let r=new URLSearchParams;r.append("sort_field",t?.sortField??"updated_at"),r.append("sort_direction","desc"),r.append("is_archived",(!!t?.isArchived).toString()),t?.isPublic!==void 0&&r.append("is_public",t.isPublic.toString()),t?.query&&r.append("query",t.query);for await(let n of this._getPaginated("/repos",r,i=>i.repos))yield*n}async getPrompt(t){let[r,n,i]=Ht(t),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/${r}/${n}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return s?.status===404?null:(await X(s,"get prompt"),s)}))?.json();return o?.repo?o.repo:null}async createPrompt(t,r){let n=await this._getSettings();if(r?.isPublic&&!n.tenant_handle)throw new Error(`Cannot create a public prompt without first
145
+
146
+ creating a LangChain Hub handle.
147
+ You can add a handle by creating a public prompt at:
148
+
149
+ https://smith.langchain.com/prompts`);let[i,a,o]=Ht(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError("create a prompt",i);let s={repo_handle:a,...r?.description&&{description:r.description},...r?.readme&&{readme:r.readme},...r?.tags&&{tags:r.tags},is_public:!!r?.isPublic},c=JSON.stringify(s),l=await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await X(d,"create prompt"),d}),{repo:u}=await l.json();return u}async createCommit(t,r,n){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[i,a,o]=Ht(t),s=n?.parentCommitHash==="latest"||!n?.parentCommitHash?await this._getLatestCommitHash(`${i}/${a}`):n?.parentCommitHash,c={manifest:JSON.parse(JSON.stringify(r)),parent_commit:s,...n?.description!==void 0&&{description:n.description}},l=JSON.stringify(c),d=await(await this.caller.call(async()=>{let f=await this._fetch(`${this.apiUrl}/commits/${i}/${a}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await X(f,"create commit"),f})).json();return this._getPromptUrl(`${i}/${a}${d.commit_hash?`:${d.commit_hash}`:""}`)}async updateExamplesMultipart(t,r=[]){return this._updateExamplesMultipart(t,r)}async _updateExamplesMultipart(t,r=[]){if(!await this._getDatasetExamplesMultiPartSupport())throw new Error("Your LangSmith deployment does not allow using the multipart examples endpoint, please upgrade your deployment to the latest version.");let n=new FormData;for(let o of r){let s=o.id,c={...o.metadata&&{metadata:o.metadata},...o.split&&{split:o.split}},l=Gt(c,`Serializing body for example with id: ${s}`),u=new Blob([l],{type:"application/json"});if(n.append(s,u),o.inputs){let d=Gt(o.inputs,`Serializing inputs for example with id: ${s}`),f=new Blob([d],{type:"application/json"});n.append(`${s}.inputs`,f)}if(o.outputs){let d=Gt(o.outputs,`Serializing outputs whle updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});n.append(`${s}.outputs`,f)}if(o.attachments)for(let[d,f]of Object.entries(o.attachments)){let p,m;Array.isArray(f)?[p,m]=f:(p=f.mimeType,m=f.data);let h=new Blob([m],{type:`${p}; length=${m.byteLength}`});n.append(`${s}.attachment.${d}`,h)}if(o.attachments_operations){let d=Gt(o.attachments_operations,`Serializing attachments while updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});n.append(`${s}.attachments_operations`,f)}}let i=t??r[0]?.dataset_id;return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${i}/examples`)}`,{method:"PATCH",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await X(o,"update examples"),o})).json()}async uploadExamplesMultipart(t,r=[]){return this._uploadExamplesMultipart(t,r)}async _uploadExamplesMultipart(t,r=[]){if(!await this._getDatasetExamplesMultiPartSupport())throw new Error("Your LangSmith deployment does not allow using the multipart examples endpoint, please upgrade your deployment to the latest version.");let n=new FormData;for(let a of r){let o=(a.id??to()).toString(),s={created_at:a.created_at,...a.metadata&&{metadata:a.metadata},...a.split&&{split:a.split},...a.source_run_id&&{source_run_id:a.source_run_id},...a.use_source_run_io&&{use_source_run_io:a.use_source_run_io},...a.use_source_run_attachments&&{use_source_run_attachments:a.use_source_run_attachments}},c=Gt(s,`Serializing body for uploaded example with id: ${o}`),l=new Blob([c],{type:"application/json"});if(n.append(o,l),a.inputs){let u=Gt(a.inputs,`Serializing inputs for uploaded example with id: ${o}`),d=new Blob([u],{type:"application/json"});n.append(`${o}.inputs`,d)}if(a.outputs){let u=Gt(a.outputs,`Serializing outputs for uploaded example with id: ${o}`),d=new Blob([u],{type:"application/json"});n.append(`${o}.outputs`,d)}if(a.attachments)for(let[u,d]of Object.entries(a.attachments)){let f,p;Array.isArray(d)?[f,p]=d:(f=d.mimeType,p=d.data);let m=new Blob([p],{type:`${f}; length=${p.byteLength}`});n.append(`${o}.attachment.${u}`,m)}}return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${t}/examples`)}`,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await X(a,"upload examples"),a})).json()}async updatePrompt(t,r){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[n,i]=Ht(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError("update a prompt",n);let a={};if(r?.description!==void 0&&(a.description=r.description),r?.readme!==void 0&&(a.readme=r.readme),r?.tags!==void 0&&(a.tags=r.tags),r?.isPublic!==void 0&&(a.is_public=r.isPublic),r?.isArchived!==void 0&&(a.is_archived=r.isArchived),Object.keys(a).length===0)throw new Error("No valid update options provided");let o=JSON.stringify(a);return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/repos/${n}/${i}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await X(c,"update prompt"),c})).json()}async deletePrompt(t){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[r,n,i]=Ht(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete a prompt",r);return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/repos/${r}/${n}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(o,"delete prompt"),o})).json()}_getPromptCacheKey(t,r){return`${t}${r?":with_model":""}`}async _fetchPromptFromApi(t,r){let[n,i,a]=Ht(t),s=await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/commits/${n}/${i}/${a}${r?.includeModel?"?include_model=true":""}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(c,"pull prompt commit"),c})).json();return{owner:n,repo:i,commit_hash:s.commit_hash,manifest:s.manifest,examples:s.examples,hub_model_config:s.model_config,hub_model_provider:s.model_provider}}async pullPromptCommit(t,r){VD(t,r?.dangerouslyPullPublicPrompt);let n=this._fetchPromptFromApi.bind(this,t,r);if(!r?.skipCache&&this._promptCache){let i=this._getPromptCacheKey(t,r?.includeModel),a=this._promptCache.get(i,n);if(a)return a;let o=await n();return this._promptCache.set(i,o,n),o}return this._fetchPromptFromApi(t,r)}async _pullPrompt(t,r){let n=await this.pullPromptCommit(t,{includeModel:r?.includeModel,skipCache:r?.skipCache,dangerouslyPullPublicPrompt:r?.dangerouslyPullPublicPrompt});return JSON.stringify(n.manifest)}async pushPrompt(t,r){return await this.promptExists(t)?r&&Object.keys(r).some(i=>i!=="object")&&await this.updatePrompt(t,{description:r?.description,readme:r?.readme,tags:r?.tags,isPublic:r?.isPublic}):await this.createPrompt(t,{description:r?.description,readme:r?.readme,tags:r?.tags,isPublic:r?.isPublic}),r?.object?await this.createCommit(t,r?.object,{parentCommitHash:r?.parentCommitHash,description:r?.commitDescription}):await this._getPromptUrl(t)}async agentExists(t){let[r,n]=Ht(t);return this._repoExists(r,n)}async skillExists(t){let[r,n]=Ht(t);return this._repoExists(r,n)}async pullAgent(t,r){return await this._pullDirectory(t,"agent",r?.version)}async pullSkill(t,r){return await this._pullDirectory(t,"skill",r?.version)}async pushAgent(t,r){return this._pushDirectory(t,"agent",r)}async pushSkill(t,r){return this._pushDirectory(t,"skill",r)}async deleteAgent(t){return this._deleteDirectory(t)}async deleteSkill(t){return this._deleteDirectory(t)}async*listAgents(t){yield*this._listReposByType("agent",t)}async*listSkills(t){yield*this._listReposByType("skill",t)}async*_listReposByType(t,r){let n=new URLSearchParams;n.append("repo_type",t),n.append("is_archived",(!!r?.isArchived).toString()),r?.isPublic!==void 0&&n.append("is_public",r.isPublic.toString()),r?.query&&n.append("query",r.query);for await(let i of this._getPaginated("/repos",n,a=>a.repos))yield*i}async _pullDirectory(t,r,n){let[i,a,o]=Ht(t),s=n??(o!=="latest"?o:void 0),c=new URL(`${this.apiUrl}/v1/platform/hub/repos/${i}/${a}/directories`);return c.searchParams.set("repo_type",r),s&&c.searchParams.set("commit",s),await(await this.caller.call(async()=>{let u=await this._fetch(c.toString(),{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(u,"pull directory"),u})).json()}async _pushDirectory(t,r,n){if(n.parentCommit!==void 0&&(n.parentCommit.length<8||n.parentCommit.length>64))throw new Error("parent_commit must be 8-64 characters");let[i,a]=Ht(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError(`push ${r}`,i);if(await this._repoExists(i,a))(n.description!==void 0||n.readme!==void 0||n.tags!==void 0||n.isPublic!==void 0)&&await this._updateRepoMetadata(i,a,n);else{let d=/^[a-z][a-z0-9-_]*$/;if(!d.test(a))throw new Error(`Invalid repo_handle ${JSON.stringify(a)}: must match ${d}`);await this._createRepo(a,r,n)}let o={files:n.files};n.parentCommit&&(o.parent_commit=n.parentCommit);let l=(await(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/v1/platform/hub/repos/${i}/${a}/directories/commits`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(o)});return await X(d,`push ${r}`),d})).json()).commit.commit_hash,u=i;return i==="-"&&(u=(await this._getSettings()).tenant_handle||i),`${this.getHostUrl()}/hub/${u}/${a}:${l.slice(0,8)}`}async _deleteDirectory(t){let[r,n]=Ht(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete",r);await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/v1/platform/hub/repos/${r}/${n}/directories`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"delete directory"),i})}async _repoExists(t,r){try{return await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"check repo exists"),n}),!0}catch(n){if(Jd(n))return!1;throw n}}async _createRepo(t,r,n){let i={repo_handle:t,repo_type:r,is_public:!!n.isPublic};n.description!==void 0&&(i.description=n.description),n.readme!==void 0&&(i.readme=n.readme),n.tags!==void 0&&(i.tags=n.tags);try{await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(i)});return await X(a,`create ${r}`),a})}catch(a){if(eI(a))return;throw a}}async _updateRepoMetadata(t,r,n){let i={};n.description!==void 0&&(i.description=n.description),n.readme!==void 0&&(i.readme=n.readme),n.tags!==void 0&&(i.tags=n.tags),n.isPublic!==void 0&&(i.is_public=n.isPublic),Object.keys(i).length!==0&&await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(i)});return await X(a,"update repo metadata"),a})}async clonePublicDataset(t,r={}){let{sourceApiUrl:n=this.apiUrl,datasetName:i}=r,[a,o]=this.parseTokenOrUrl(t,n),s=new e({apiUrl:a,apiKey:"placeholder"}),c=await s.readSharedDataset(o),l=i||c.name;try{if(await this.hasDataset({datasetId:l})){console.log(`Dataset ${l} already exists in your tenant. Skipping.`);return}}catch{}let u=await s.listSharedExamples(o),d=await this.createDataset(l,{description:c.description,dataType:c.data_type||"kv",inputsSchema:c.inputs_schema_definition??void 0,outputsSchema:c.outputs_schema_definition??void 0});try{await this.createExamples({inputs:u.map(f=>f.inputs),outputs:u.flatMap(f=>f.outputs?[f.outputs]:[]),datasetId:d.id})}catch(f){throw console.error(`An error occurred while creating dataset ${l}. You should delete it manually.`),f}}parseTokenOrUrl(t,r,n=2,i="dataset"){try{return he(t),[r,t]}catch{}try{let o=new URL(t).pathname.split("/").filter(s=>s!=="");if(o.length>=n){let s=o[o.length-n];return[r,s]}else throw new Error(`Invalid public ${i} URL: ${t}`)}catch{throw new Error(`Invalid public ${i} URL or token: ${t}`)}}cleanup(){this._promptCache&&this._promptCache.stop()}async awaitPendingTraceBatches(){if(this.manualFlushMode)return console.warn("[WARNING]: When tracing in manual flush mode, you must call `await client.flush()` manually to submit trace batches."),Promise.resolve();for(await new Promise(t=>setTimeout(t,1));this._pendingDrains.size>0;)await Promise.all([...this._pendingDrains]);await Promise.all([...this.autoBatchQueue.items.map(({itemPromise:t})=>t),this.batchIngestCaller.queue.onIdle()]),this.langSmithToOTELTranslator!==void 0&&await BE()?.DEFAULT_LANGSMITH_SPAN_PROCESSOR?.forceFlush()}toString(){let t=[`apiUrl=${JSON.stringify(this.apiUrl)}`];return this.webUrl!==void 0&&t.push(`webUrl=${JSON.stringify(this.webUrl)}`),this.workspaceId!==void 0&&t.push(`workspaceId=${JSON.stringify(this.workspaceId)}`),`[LangSmithClient ${t.join(" ")}]`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};Object.defineProperty(Ln,"_fallbackDirsCreated",{enumerable:!0,configurable:!0,writable:!0,value:new Set});function hI(e){return"dataset_id"in e||"dataset_name"in e}var _I=e=>e!==void 0?e:!!["TRACING_V2","TRACING"].find(r=>Ke(r)==="true");var Bn=Symbol.for("lc:context_variables");var Qd=Symbol.for("langsmith:replica_trace_roots");function c_(e,t){if(Bn in e)return e[Bn][t]}function yI(e,t,r){let n=Bn in e?e[Bn]:{};n[t]=r,e[Bn]=n}var al=36,XD="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function vI(e){let r=Object.keys(e).sort().map(n=>`${n}:${e[n]??""}`).join("|");return wg(r,XD)}function YD(e){return e.replace(/[-:.]/g,"")}function wI(e,t=1){let r=t.toFixed(0).slice(0,3).padStart(3,"0");return`${new Date(e).toISOString().slice(0,-1)}${r}Z`}function l_(e,t,r=1){let n=wI(e,r);return{dottedOrder:YD(n)+t,microsecondPrecisionDatestring:n}}var QD=new Set(["projectName","updates","reroot"]);function ez(e){let t={};for(let r of Object.keys(e))QD.has(r)&&(t[r]=e[r]);return t}var ef=class e{constructor(t,r,n,i){Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.metadata=t,this.tags=r,this.project_name=n,this.replicas=i}static fromHeader(t){let r=t.split(","),n={},i=[],a,o;for(let s of r){let[c,l]=s.split("="),u=decodeURIComponent(l);c==="langsmith-metadata"?n=JSON.parse(u):c==="langsmith-tags"?i=u.split(","):c==="langsmith-project"?a=u:c==="langsmith-replicas"&&(o=JSON.parse(u).map(f=>Array.isArray(f)?f:ez(f)))}return new e(n,i,a,o)}toHeader(){let t=[];return this.metadata&&Object.keys(this.metadata).length>0&&t.push(`langsmith-metadata=${encodeURIComponent(JSON.stringify(this.metadata))}`),this.tags&&this.tags.length>0&&t.push(`langsmith-tags=${encodeURIComponent(this.tags.join(","))}`),this.project_name&&t.push(`langsmith-project=${encodeURIComponent(this.project_name)}`),t.join(",")}},dn=class e{constructor(t){if(Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"run_type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_runs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"end_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extra",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"error",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"serialized",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reference_example_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"trace_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dotted_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"attachments",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"distributedParentId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_serialized_start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_awaitInputsOnPost",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),xI(t)){Object.assign(this,{...t});return}let r=e.getDefaultConfig(),{metadata:n,...i}=t,a=i.client??e.getSharedClient(),o={...n,...i?.extra?.metadata};if(i.extra={...i.extra,metadata:o},"id"in i&&i.id==null&&delete i.id,Object.assign(this,{...r,...i,client:a}),this.execution_order??=1,this.child_execution_order??=1,this.dotted_order||(this._serialized_start_time=wI(this.start_time,this.execution_order)),this.id||(this.id=Cd(this._serialized_start_time??this.start_time)),this.trace_id||(this.parent_run?this.trace_id=this.parent_run.trace_id??this.id:this.trace_id=this.id),this.replicas=iz(this.replicas),!this.dotted_order){let{dottedOrder:s}=l_(this.start_time,this.id,this.execution_order);this.parent_run?this.dotted_order=this.parent_run.dotted_order+"."+s:this.dotted_order=s}}set metadata(t){this.extra={...this.extra,metadata:{...this.extra?.metadata,...t}}}get metadata(){return this.extra?.metadata}static getDefaultConfig(){let t=Date.now();return{run_type:"chain",project_name:Qc(),child_runs:[],api_url:Pt("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:Pt("LANGCHAIN_API_KEY"),caller_options:{},start_time:t,serialized:{},inputs:{},extra:{}}}static getSharedClient(){return e.sharedClient||(e.sharedClient=new Ln),e.sharedClient}createChild(t){let r=this.child_execution_order+1,n=this.replicas?.map(f=>{let{reroot:p,...m}=f;return m}),i=t.replicas??n,a=new e({...t,parent_run:this,project_name:this.project_name,replicas:i,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:r,child_execution_order:r}),o=this.extra?.metadata??{},s=a.extra?.metadata??{};Object.keys(o).length>0&&(a.extra={...a.extra,metadata:{...o,...s}}),Bn in this&&(a[Bn]=this[Bn]);let c=Symbol.for("lc:child_config"),l=t.extra?.[c]??this.extra[c];if(rz(l)){let f={...l},p=tz(f.callbacks)?f.callbacks.copy?.():void 0;p&&(Object.assign(p,{_parentRunId:a.id}),p.handlers?.find(SI)?.updateFromRunTree?.(a),f.callbacks=p),a.extra[c]=f}let u=new Set,d=this;for(;d!=null&&!u.has(d.id);)u.add(d.id),d.child_execution_order=Math.max(d.child_execution_order,r),d=d.parent_run;return this.child_runs.push(a),a}async end(t,r,n=Date.now(),i){this.outputs=this.outputs??t,this.error=this.error??r,this.end_time=this.end_time??n,i&&Object.keys(i).length>0&&(this.extra=this.extra?{...this.extra,metadata:{...this.extra.metadata,...i}}:{metadata:i})}_convertToCreate(t,r,n=!0){let i=t.extra??{};if(i?.runtime?.library===void 0&&(i.runtime||(i.runtime={}),r))for(let[s,c]of Object.entries(r))i.runtime[s]||(i.runtime[s]=c);let a=t.parent_run?.id??t.parent_run_id,o;return n?o=[]:o=t.child_runs.map(s=>this._convertToCreate(s,r,n)),{id:t.id,name:t.name,start_time:t._serialized_start_time??t.start_time,end_time:t.end_time,run_type:t.run_type,reference_example_id:t.reference_example_id,extra:i,serialized:t.serialized,error:t.error,inputs:t.inputs,outputs:t.outputs,session_name:t.project_name,child_runs:o,parent_run_id:a,trace_id:t.trace_id,dotted_order:t.dotted_order,tags:t.tags,attachments:t.attachments,events:t.events}}_sliceParentId(t,r){if(r.dotted_order){let n=r.dotted_order.split("."),i=null;for(let a=0;a<n.length;a++)if(n[a].slice(-al)===t){i=a;break}if(i!==null){let a=n.slice(i+1);r.dotted_order=a.join("."),a.length>0?r.trace_id=a[0].slice(-al):r.trace_id=r.id}}r.parent_run_id===t&&(r.parent_run_id=void 0)}_setReplicaTraceRoot(t,r){let n=c_(this,Qd)??{};n[t]=r,yI(this,Qd,n);for(let i of this.child_runs)i._setReplicaTraceRoot(t,r)}_remapForProject(t){let{projectName:r,runtimeEnv:n,excludeChildRuns:i=!0,reroot:a=!1,distributedParentId:o,apiUrl:s,apiKey:c,workspaceId:l}=t,u=this._convertToCreate(this,n,i);if(r===this.project_name)return{...u,session_name:r};if(a){if(o)this._sliceParentId(o,u);else if(u.parent_run_id=void 0,u.dotted_order){let w=u.dotted_order.split(".");w.length>0&&(u.dotted_order=w[w.length-1],u.trace_id=u.id)}let y=vI({projectName:r,apiUrl:s,apiKey:c,workspaceId:l});this._setReplicaTraceRoot(y,u.id)}let d;if(!a){let y=c_(this,Qd)??{},w=vI({projectName:r,apiUrl:s,apiKey:c,workspaceId:l});if(d=y[w],d&&(u.trace_id=d,u.dotted_order)){let x=u.dotted_order.split("."),S=null;for(let $=0;$<x.length;$++)if(x[$].slice(-al)===d){S=$;break}if(S!==null){let $=x.slice(S);u.dotted_order=$.join(".")}}}let f=u.id,p=el(f,r),m;u.trace_id?m=el(u.trace_id,r):m=p;let h;u.parent_run_id&&(h=el(u.parent_run_id,r));let _;return u.dotted_order&&(_=u.dotted_order.split(".").map(x=>{let S=x.slice(-al),$=el(S,r);return x.slice(0,-al)+$}).join(".")),{...u,id:p,trace_id:m,parent_run_id:h,dotted_order:_,session_name:r}}async postRun(t=!0){this._awaitInputsOnPost&&(this.inputs=await this.inputs);try{let r=Md();if(this.replicas&&this.replicas.length>0)for(let{projectName:n,apiKey:i,apiUrl:a,workspaceId:o,reroot:s,client:c}of this.replicas){let l=this._remapForProject({projectName:n??this.project_name,runtimeEnv:r,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:a,apiKey:i,workspaceId:o});await(c??this.client).createRun(l,{apiKey:i,apiUrl:a,workspaceId:o})}else{let n=this._convertToCreate(this,r,t);await this.client.createRun(n)}if(!t){ro("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(let n of this.child_runs)await n.postRun(!1)}this.child_runs=[]}catch(r){console.error(`Error in postRun for run ${this.id}:`,r)}}async patchRun(t){if(this.replicas&&this.replicas.length>0)for(let{projectName:r,apiKey:n,apiUrl:i,workspaceId:a,updates:o,reroot:s,client:c}of this.replicas){let l=this._remapForProject({projectName:r??this.project_name,runtimeEnv:void 0,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:i,apiKey:n,workspaceId:a}),u={id:l.id,name:l.name,run_type:l.run_type,start_time:l.start_time,outputs:l.outputs,error:l.error,parent_run_id:l.parent_run_id,session_name:l.session_name,reference_example_id:l.reference_example_id,end_time:l.end_time,dotted_order:l.dotted_order,trace_id:l.trace_id,events:l.events,tags:l.tags,extra:l.extra,attachments:this.attachments,...o};t?.excludeInputs||(u.inputs=l.inputs),await(c??this.client).updateRun(l.id,u,{apiKey:n,apiUrl:i,workspaceId:a})}else try{let r={name:this.name,run_type:this.run_type,start_time:this._serialized_start_time??this.start_time,end_time:this.end_time,error:this.error,outputs:this.outputs,parent_run_id:this.parent_run?.id??this.parent_run_id,reference_example_id:this.reference_example_id,extra:this.extra,events:this.events,dotted_order:this.dotted_order,trace_id:this.trace_id,tags:this.tags,attachments:this.attachments,session_name:this.project_name};t?.excludeInputs||(r.inputs=this.inputs),await this.client.updateRun(this.id,r)}catch(r){console.error(`Error in patchRun for run ${this.id}`,r)}this.child_runs=[]}toJSON(){return this._convertToCreate(this,void 0,!1)}addEvent(t){this.events||(this.events=[]),typeof t=="string"?this.events.push({name:"event",time:new Date().toISOString(),message:t}):this.events.push({...t,time:t.time??new Date().toISOString()})}static fromRunnableConfig(t,r){let n=t?.callbacks,i,a,o,s=_I();if(n){let l=n?.getParentRunId?.()??"",u=n?.handlers?.find(d=>d?.name=="langchain_tracer");i=u?.getRun?.(l),a=u?.projectName,o=u?.client,s=s||!!u}return i?new e({name:i.name,id:i.id,trace_id:i.trace_id,dotted_order:i.dotted_order,client:o,tracingEnabled:s,project_name:a,tags:[...new Set((i?.tags??[]).concat(t?.tags??[]))],extra:{metadata:{...i?.extra?.metadata,...t?.metadata}}}).createChild(r):new e({...r,client:o,tracingEnabled:s,project_name:a})}static fromDottedOrder(t){return this.fromHeaders({"langsmith-trace":t})}static fromHeaders(t,r){let n="get"in t&&typeof t.get=="function"?{"langsmith-trace":t.get("langsmith-trace"),baggage:t.get("baggage")}:t,i=n["langsmith-trace"];if(!i||typeof i!="string")return;let a=i.trim(),o=a.split(".").map(u=>{let[d,f]=u.split("Z");return{strTime:d,time:Date.parse(d+"Z"),uuid:f}}),s=o[0].uuid,c={...r,name:r?.name??"parent",run_type:r?.run_type??"chain",start_time:r?.start_time??Date.now(),id:o.at(-1)?.uuid,trace_id:s,dotted_order:a};if(n.baggage&&typeof n.baggage=="string"){let u=ef.fromHeader(n.baggage);c.metadata=u.metadata,c.tags=u.tags,c.project_name=u.project_name,c.replicas=u.replicas}let l=new e(c);return l.distributedParentId=l.id,l}toHeaders(t){let r={"langsmith-trace":this.dotted_order,baggage:new ef(this.extra?.metadata,this.tags,this.project_name,this.replicas).toHeader()};if(t)for(let[n,i]of Object.entries(r))t.set(n,i);return r}};Object.defineProperty(dn,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function xI(e){return e!=null&&typeof e.createChild=="function"&&typeof e.postRun=="function"}function SI(e){return typeof e=="object"&&e!=null&&typeof e.name=="string"&&e.name==="langchain_tracer"}function bI(e){return Array.isArray(e)&&e.some(t=>SI(t))}function tz(e){return typeof e=="object"&&e!=null&&Array.isArray(e.handlers)}function rz(e){let t=e?.callbacks;return e!=null&&typeof t=="object"&&(bI(t?.handlers)||bI(t))}function nz(){let e=Pt("LANGSMITH_RUNS_ENDPOINTS");if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){let r=[];for(let n of t){if(typeof n!="object"||n===null){console.warn(`Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got ${typeof n}`);continue}if(typeof n.api_url!="string"){console.warn(`Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof n.api_url}`);continue}if(typeof n.api_key!="string"){console.warn(`Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof n.api_key}`);continue}r.push({apiUrl:n.api_url.replace(/\/$/,""),apiKey:n.api_key})}return r}else if(typeof t=="object"&&t!==null){az(t);let r=[];for(let[n,i]of Object.entries(t)){let a=n.replace(/\/$/,"");if(typeof i=="string")r.push({apiUrl:a,apiKey:i});else{console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${n}: expected string, got ${typeof i}`);continue}}return r}else return console.warn(`Invalid LANGSMITH_RUNS_ENDPOINTS \u2013 must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey, got ${typeof t}`),[]}catch(t){if(rI(t))throw t;return console.warn("Invalid LANGSMITH_RUNS_ENDPOINTS \u2013 must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey"),[]}}function iz(e){return e?e.map(t=>Array.isArray(t)?{projectName:t[0],updates:t[1]}:t):nz()}function az(e){if(Object.keys(e).length>0&&Ke("ENDPOINT"))throw new Gd}var kI=T({BaseTracer:()=>Dt,isBaseTracer:()=>ao}),oz=e=>{if(e)return e.events=e.events??[],e.child_runs=e.child_runs??[],e};function d_(e,t){if(e)return new dn({...e,start_time:e._serialized_start_time??e.start_time,parent_run:d_(t),child_runs:e.child_runs.map(r=>d_(r)).filter(r=>r!==void 0),extra:{...e.extra,runtime:ig()},tracingEnabled:!1})}function u_(e,t){return e&&!Array.isArray(e)&&typeof e=="object"?e:{[t]:e}}function ao(e){return typeof e._addRunToRunMap=="function"}var Dt=class extends sr{runMap=new Map;runTreeMap=new Map;usesRunTreeMap=!1;constructor(e){super(...arguments)}copy(){return this}getRunById(e){if(e!==void 0)return this.usesRunTreeMap?oz(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`
150
+
151
+ ${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){let{dottedOrder:t,microsecondPrecisionDatestring:r}=l_(new Date(e.start_time).getTime(),e.id,e.execution_order),n={...e},i=this.getRunById(n.parent_run_id);if(n.parent_run_id!==void 0?i?(this._addChildRun(i,n),i.child_execution_order=Math.max(i.child_execution_order,n.child_execution_order),n.trace_id=i.trace_id,i.dotted_order!==void 0&&(n.dotted_order=[i.dotted_order,t].join("."),n._serialized_start_time=r)):n.parent_run_id=void 0:(n.trace_id=n.id,n.dotted_order=t,n._serialized_start_time=r),this.usesRunTreeMap){let a=d_(n,i);a!==void 0&&this.runTreeMap.set(n.id,a)}else this.runMap.set(n.id,n);return n}async _endTrace(e){let t=e.parent_run_id!==void 0&&this.getRunById(e.parent_run_id);t?t.child_execution_order=Math.max(t.child_execution_order,e.child_execution_order):await this.persistRun(e),await this.onRunUpdate?.(e),this.usesRunTreeMap?this.runTreeMap.delete(e.id):this.runMap.delete(e.id)}_getExecutionOrder(e){let t=e!==void 0&&this.getRunById(e);return t?t.child_execution_order+1:1}_createRunForLLMStart(e,t,r,n,i,a,o,s){let c=this._getExecutionOrder(n),l=Date.now(),u=o?{...i,metadata:o}:i,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:{prompts:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:u??{},tags:a||[]};return this._addRunToRunMap(d)}async handleLLMStart(e,t,r,n,i,a,o,s){let c=this.getRunById(r)??this._createRunForLLMStart(e,t,r,n,i,a,o,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}_createRunForChatModelStart(e,t,r,n,i,a,o,s){let c=this._getExecutionOrder(n),l=Date.now(),u=o?{...i,metadata:o}:i,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:{messages:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:u??{},tags:a||[]};return this._addRunToRunMap(d)}async handleChatModelStart(e,t,r,n,i,a,o,s){let c=this.getRunById(r)??this._createRunForChatModelStart(e,t,r,n,i,a,o,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}async handleLLMEnd(e,t,r,n,i){let a=this.getRunById(t);if(!a||a?.run_type!=="llm")throw new Error("No LLM run to end.");return a.end_time=Date.now(),a.outputs=e,a.events.push({name:"end",time:new Date(a.end_time).toISOString()}),a.extra={...a.extra,...i},await this.onLLMEnd?.(a),await this._endTrace(a),a}async handleLLMError(e,t,r,n,i){let a=this.getRunById(t);if(!a||a?.run_type!=="llm")throw new Error("No LLM run to end.");return a.end_time=Date.now(),a.error=this.stringifyError(e),a.events.push({name:"error",time:new Date(a.end_time).toISOString()}),a.extra={...a.extra,...i},await this.onLLMError?.(a),await this._endTrace(a),a}_createRunForChainStart(e,t,r,n,i,a,o,s,c){let l=this._getExecutionOrder(n),u=Date.now(),d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:t,execution_order:l,child_execution_order:l,run_type:o??"chain",child_runs:[],extra:a?{...c,metadata:a}:{...c},tags:i||[]};return this._addRunToRunMap(d)}async handleChainStart(e,t,r,n,i,a,o,s){let c=this.getRunById(r)??this._createRunForChainStart(e,t,r,n,i,a,o,s);return await this.onRunCreate?.(c),await this.onChainStart?.(c),c}async handleChainEnd(e,t,r,n,i){let a=this.getRunById(t);if(!a)throw new Error("No chain run to end.");return a.end_time=Date.now(),a.outputs=u_(e,"output"),a.events.push({name:"end",time:new Date(a.end_time).toISOString()}),i?.inputs!==void 0&&(a.inputs=u_(i.inputs,"input")),await this.onChainEnd?.(a),await this._endTrace(a),a}async handleChainError(e,t,r,n,i){let a=this.getRunById(t);if(!a)throw new Error("No chain run to end.");return a.end_time=Date.now(),a.error=this.stringifyError(e),a.events.push({name:"error",time:new Date(a.end_time).toISOString()}),i?.inputs!==void 0&&(a.inputs=u_(i.inputs,"input")),await this.onChainError?.(a),await this._endTrace(a),a}_createRunForToolStart(e,t,r,n,i,a,o){let s=this._getExecutionOrder(n),c=Date.now(),l={id:r,name:o??e.id[e.id.length-1],parent_run_id:n,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{input:t},execution_order:s,child_execution_order:s,run_type:"tool",child_runs:[],extra:a?{metadata:a}:{},tags:i||[]};return this._addRunToRunMap(l)}async handleToolStart(e,t,r,n,i,a,o){let s=this.getRunById(r)??this._createRunForToolStart(e,t,r,n,i,a,o);return await this.onRunCreate?.(s),await this.onToolStart?.(s),s}async handleToolEnd(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.outputs={output:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),await this.onToolEnd?.(r),await this._endTrace(r),r}async handleToolError(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),await this.onToolError?.(r),await this._endTrace(r),r}async handleAgentAction(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="chain")return;let n=r;n.actions=n.actions||[],n.actions.push(e),n.events.push({name:"agent_action",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentAction?.(r)}async handleAgentEnd(e,t){let r=this.getRunById(t);!r||r?.run_type!=="chain"||(r.events.push({name:"agent_end",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentEnd?.(r))}_createRunForRetrieverStart(e,t,r,n,i,a,o){let s=this._getExecutionOrder(n),c=Date.now(),l={id:r,name:o??e.id[e.id.length-1],parent_run_id:n,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{query:t},execution_order:s,child_execution_order:s,run_type:"retriever",child_runs:[],extra:a?{metadata:a}:{},tags:i||[]};return this._addRunToRunMap(l)}async handleRetrieverStart(e,t,r,n,i,a,o){let s=this.getRunById(r)??this._createRunForRetrieverStart(e,t,r,n,i,a,o);return await this.onRunCreate?.(s),await this.onRetrieverStart?.(s),s}async handleRetrieverEnd(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.outputs={documents:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),await this.onRetrieverEnd?.(r),await this._endTrace(r),r}async handleRetrieverError(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),await this.onRetrieverError?.(r),await this._endTrace(r),r}async handleText(e,t){let r=this.getRunById(t);!r||r?.run_type!=="chain"||(r.events.push({name:"text",time:new Date().toISOString(),kwargs:{text:e}}),await this.onText?.(r))}async handleLLMNewToken(e,t,r,n,i,a){let o=this.getRunById(r);if(!o||o?.run_type!=="llm")throw new Error('Invalid "runId" provided to "handleLLMNewToken" callback.');return o.events.push({name:"new_token",time:new Date().toISOString(),kwargs:{token:e,idx:t,chunk:a?.chunk}}),await this.onLLMNewToken?.(o,e,{chunk:a?.chunk}),o}};var EI=T({ConsoleCallbackHandler:()=>tf}),II={bold:{open:"\x1B[1m",close:"\x1B[22m"},color:{grey:{open:"\x1B[90m",close:"\x1B[39m"},green:{open:"\x1B[32m",close:"\x1B[39m"},cyan:{open:"\x1B[36m",close:"\x1B[39m"},red:{open:"\x1B[31m",close:"\x1B[39m"},blue:{open:"\x1B[34m",close:"\x1B[39m"}}};function lr(e,t){return`${e.open}${t}${e.close}`}function Wr(e,t){try{return JSON.stringify(e,null,2)}catch{return t}}function $I(e){return typeof e=="string"?e.trim():e==null?e:Wr(e,e.toString())}function ra(e){if(!e.end_time)return"";let t=e.end_time-e.start_time;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`}var{color:yr}=II,tf=class extends Dt{name="console_callback_handler";persistRun(e){return Promise.resolve()}getParents(e){let t=[],r=e;for(;r.parent_run_id;){let n=this.runMap.get(r.parent_run_id);if(n)t.push(n),r=n;else break}return t}getBreadcrumbs(e){let t=[...this.getParents(e).reverse(),e].map((r,n,i)=>{let a=`${r.execution_order}:${r.run_type}:${r.name}`;return n===i.length-1?lr(II.bold,a):a}).join(" > ");return lr(yr.grey,t)}onChainStart(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.green,"[chain/start]")} [${t}] Entering Chain run with input: ${Wr(e.inputs,"[inputs]")}`)}onChainEnd(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.cyan,"[chain/end]")} [${t}] [${ra(e)}] Exiting Chain run with output: ${Wr(e.outputs,"[outputs]")}`)}onChainError(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.red,"[chain/error]")} [${t}] [${ra(e)}] Chain run errored with error: ${Wr(e.error,"[error]")}`)}onLLMStart(e){let t=this.getBreadcrumbs(e),r="prompts"in e.inputs?{prompts:e.inputs.prompts.map(n=>n.trim())}:e.inputs;console.log(`${lr(yr.green,"[llm/start]")} [${t}] Entering LLM run with input: ${Wr(r,"[inputs]")}`)}onLLMEnd(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.cyan,"[llm/end]")} [${t}] [${ra(e)}] Exiting LLM run with output: ${Wr(e.outputs,"[response]")}`)}onLLMError(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.red,"[llm/error]")} [${t}] [${ra(e)}] LLM run errored with error: ${Wr(e.error,"[error]")}`)}onToolStart(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.green,"[tool/start]")} [${t}] Entering Tool run with input: "${$I(e.inputs.input)}"`)}onToolEnd(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.cyan,"[tool/end]")} [${t}] [${ra(e)}] Exiting Tool run with output: "${$I(e.outputs?.output)}"`)}onToolError(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.red,"[tool/error]")} [${t}] [${ra(e)}] Tool run errored with error: ${Wr(e.error,"[error]")}`)}onRetrieverStart(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${Wr(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.cyan,"[retriever/end]")} [${t}] [${ra(e)}] Exiting Retriever run with output: ${Wr(e.outputs,"[outputs]")}`)}onRetrieverError(e){let t=this.getBreadcrumbs(e);console.log(`${lr(yr.red,"[retriever/error]")} [${t}] [${ra(e)}] Retriever run errored with error: ${Wr(e.error,"[error]")}`)}onAgentAction(e){let t=e,r=this.getBreadcrumbs(e);console.log(`${lr(yr.blue,"[agent/action]")} [${r}] Agent selected action: ${Wr(t.actions[t.actions.length-1],"[action]")}`)}};var f_,rf=()=>(f_===void 0&&(f_=new Ln(ar("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"?{blockOnRootRunFinalization:!0}:{})),f_);var m_=class{getStore(){}run(t,r){return r()}},p_=Symbol.for("ls:tracing_async_local_storage"),sz=new m_,h_=class{getInstance(){return globalThis[p_]??sz}initializeGlobalInstance(t){globalThis[p_]===void 0&&(globalThis[p_]=t)}},cz=new h_;function TI(e=!1){let t=cz.getInstance().getStore();if(!e&&t===void 0)throw new Error(`Could not get the current run tree.
152
+
153
+ Please make sure you are calling this method within a traceable function and that tracing is enabled.`);return t}function nf(e){return typeof e=="function"&&"langsmith:traceable"in e}var AI=T({LangChainTracer:()=>bs,OVERRIDABLE_LANGSMITH_INHERITABLE_METADATA_KEYS:()=>__}),__=new Set(["ls_agent_type"]);function lz(e){let t;for(let r of e)for(let n of r)Ne.isInstance(n.message)&&n.message.usage_metadata!==void 0&&(t=ls(t,n.message.usage_metadata));return t}var bs=class g_ extends Dt{name="langchain_tracer";projectName;exampleId;client;replicas;usesRunTreeMap=!0;tracingMetadata;tracingTags=[];constructor(t={}){super(t),this.fields=t;let{exampleId:r,projectName:n,client:i,replicas:a,metadata:o,tags:s}=t;this.projectName=n??Qc(),this.replicas=a,this.exampleId=r,this.client=i??rf(),this.tracingMetadata=o?{...o}:void 0,this.tracingTags=s??[];let c=g_.getTraceableRunTree();c&&this.updateFromRunTree(c)}async persistRun(t){}async onRunCreate(t){CI(this,t),t.extra?.lc_defers_inputs||await this.getRunTreeWithTracingConfig(t.id)?.postRun()}async onRunUpdate(t){CI(this,t);let r=this.getRunTreeWithTracingConfig(t.id);t.extra?.lc_defers_inputs?await r?.postRun():await r?.patchRun()}onLLMEnd(t){let r=t.outputs;if(r?.generations){let n=lz(r.generations);if(n!==void 0){t.extra=t.extra??{};let i=t.extra.metadata??{};i.usage_metadata=n,t.extra.metadata=i}}}copyWithTracingConfig({metadata:t,tags:r}){let n;if(t===void 0)n=this.tracingMetadata?{...this.tracingMetadata}:void 0;else if(this.tracingMetadata===void 0)n={...t};else{n={...this.tracingMetadata};for(let[o,s]of Object.entries(t))(!Object.prototype.hasOwnProperty.call(n,o)||__.has(o))&&(n[o]=s)}let i=r?Array.from(new Set([...this.tracingTags,...r])):[...this.tracingTags],a=new g_({...this.fields,metadata:n,tags:i});return a.runMap=this.runMap,a.runTreeMap=this.runTreeMap,a}getRun(t){return this.runTreeMap.get(t)}updateFromRunTree(t){this.runTreeMap.set(t.id,t);let r=t,n=new Set;for(;r.parent_run&&!(n.has(r.id)||(n.add(r.id),!r.parent_run));)r=r.parent_run;n.clear();let i=[r];for(;i.length>0;){let a=i.shift();!a||n.has(a.id)||(n.add(a.id),this.runTreeMap.set(a.id,a),a.child_runs&&i.push(...a.child_runs))}this.client=t.client??this.client,this.replicas=t.replicas??this.replicas,this.projectName=t.project_name??this.projectName,this.exampleId=t.reference_example_id??this.exampleId,this.fields={...this.fields,client:this.client,replicas:this.replicas,projectName:this.projectName,exampleId:this.exampleId}}getRunTreeWithTracingConfig(t){let r=this.runTreeMap.get(t);if(r)return new dn({...r,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return TI(!0)}catch{return}}static[Symbol.hasInstance](t){if(typeof t!="object"||t===null)return!1;let r=t;return"name"in r&&r.name==="langchain_tracer"&&"copyWithTracingConfig"in r&&typeof r.copyWithTracingConfig=="function"&&"getRunTreeWithTracingConfig"in r&&typeof r.getRunTreeWithTracingConfig=="function"}};function CI(e,t){if(e.tracingMetadata){t.extra??={};let r=t.extra.metadata??{},n=!1;for(let[i,a]of Object.entries(e.tracingMetadata))(!Object.prototype.hasOwnProperty.call(r,i)||__.has(i))&&r[i]!==a&&(r[i]=a,n=!0);n&&(t.extra.metadata=r)}e.tracingTags.length>0&&(t.tags=Array.from(new Set([...t.tags??[],...e.tracingTags])))}var OI=Symbol.for("ls:tracing_async_local_storage"),na=Symbol.for("lc:context_variables"),PI=e=>{globalThis[OI]=e},ia=()=>globalThis[OI];var af=Vu(Zd(),1),oo;function uz(){return new("default"in af.default?af.default.default:af.default)({autoStart:!0,concurrency:1})}function dz(){return typeof oo>"u"&&(oo=uz()),oo}async function rt(e,t){if(t===!0){let r=ia();r!==void 0?await r.run(void 0,async()=>e()):await e()}else oo=dz(),oo.add(async()=>{let r=ia();r!==void 0?await r.run(void 0,async()=>e()):await e()})}async function NI(){let e=rf();await Promise.allSettled([typeof oo<"u"?oo.onIdle():Promise.resolve(),e.awaitPendingTraceBatches()])}var RI=T({awaitAllCallbacks:()=>NI,consumeCallback:()=>rt});var MI=e=>e!==void 0?e:!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>ar(t)==="true");function y_(e){let t=ia();if(t!==void 0)return t.getStore()?.[na]?.[e]}var fz=Symbol("lc:configure_hooks"),jI=()=>y_(fz)||[];var DI=T({BaseCallbackManager:()=>zI,BaseRunManager:()=>sl,CallbackManager:()=>Xe,CallbackManagerForChainRun:()=>LI,CallbackManagerForLLMRun:()=>v_,CallbackManagerForRetrieverRun:()=>UI,CallbackManagerForToolRun:()=>FI,ensureHandler:()=>gi,parseCallbackConfigArg:()=>so});function so(e){return e?Array.isArray(e)||"name"in e?{callbacks:e}:e:{}}var zI=class{setHandler(e){return this.setHandlers([e])}},sl=class{constructor(e,t,r,n,i,a,o,s){this.runId=e,this.handlers=t,this.inheritableHandlers=r,this.tags=n,this.inheritableTags=i,this.metadata=a,this.inheritableMetadata=o,this._parentRunId=s}get parentRunId(){return this._parentRunId}async handleText(e){await Promise.all(this.handlers.map(t=>rt(async()=>{try{await t.handleText?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleText: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleCustomEvent(e,t,r,n,i){await Promise.all(this.handlers.map(a=>rt(async()=>{try{await a.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleCustomEvent: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}},UI=class extends sl{getChild(e){let t=new Xe(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleRetrieverEnd(e){await Promise.all(this.handlers.map(t=>rt(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetriever`),t.raiseError)throw r}},t.awaitHandlers)))}async handleRetrieverError(e){await Promise.all(this.handlers.map(t=>rt(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetrieverError: ${r}`),t.raiseError)throw e}},t.awaitHandlers)))}},v_=class extends sl{async handleLLMNewToken(e,t,r,n,i,a){await Promise.all(this.handlers.map(o=>rt(async()=>{if(!o.ignoreLLM)try{await o.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,a)}catch(s){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMNewToken: ${s}`),o.raiseError)throw s}},o.awaitHandlers)))}async handleChatModelStreamEvent(e){await Promise.all(this.handlers.map(t=>rt(async()=>{if(!t.ignoreLLM)try{await t.handleChatModelStreamEvent?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleChatModelStreamEvent: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleLLMError(e,t,r,n,i){await Promise.all(this.handlers.map(a=>rt(async()=>{if(!a.ignoreLLM)try{await a.handleLLMError?.(e,this.runId,this._parentRunId,this.tags,i)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMError: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleLLMEnd(e,t,r,n,i){await Promise.all(this.handlers.map(a=>rt(async()=>{if(!a.ignoreLLM)try{await a.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags,i)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMEnd: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}},LI=class extends sl{getChild(e){let t=new Xe(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleChainError(e,t,r,n,i){await Promise.all(this.handlers.map(a=>rt(async()=>{if(!a.ignoreChain)try{await a.handleChainError?.(e,this.runId,this._parentRunId,this.tags,i)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleChainError: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleChainEnd(e,t,r,n,i){await Promise.all(this.handlers.map(a=>rt(async()=>{if(!a.ignoreChain)try{await a.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,i)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleChainEnd: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleAgentAction(e){await Promise.all(this.handlers.map(t=>rt(async()=>{if(!t.ignoreAgent)try{await t.handleAgentAction?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentAction: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleAgentEnd(e){await Promise.all(this.handlers.map(t=>rt(async()=>{if(!t.ignoreAgent)try{await t.handleAgentEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentEnd: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}},FI=class extends sl{getChild(e){let t=new Xe(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleToolError(e){await Promise.all(this.handlers.map(t=>rt(async()=>{if(!t.ignoreAgent)try{await t.handleToolError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolError: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleToolEvent(e){await Promise.all(this.handlers.map(t=>rt(async()=>{if(!t.ignoreAgent)try{await t.handleToolEvent?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if(t.raiseError)throw r}},t.awaitHandlers)))}async handleToolEnd(e){await Promise.all(this.handlers.map(t=>rt(async()=>{if(!t.ignoreAgent)try{await t.handleToolEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolEnd: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}},Xe=class ol extends zI{handlers=[];inheritableHandlers=[];tags=[];inheritableTags=[];metadata={};inheritableMetadata={};name="callback_manager";_parentRunId;constructor(t,r){super(),this.handlers=r?.handlers??this.handlers,this.inheritableHandlers=r?.inheritableHandlers??this.inheritableHandlers,this.tags=r?.tags??this.tags,this.inheritableTags=r?.inheritableTags??this.inheritableTags,this.metadata=r?.metadata??this.metadata,this.inheritableMetadata=r?.inheritableMetadata??this.inheritableMetadata,this._parentRunId=t}getParentRunId(){return this._parentRunId}async handleLLMStart(t,r,n=void 0,i=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(l,u)=>{let d=u===0&&n?n:Hr();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return ao(f)&&f._createRunForLLMStart(t,[l],d,this._parentRunId,a,this.tags,this.metadata,c),rt(async()=>{try{await f.handleLLMStart?.(t,[l],d,this._parentRunId,a,this.tags,this.metadata,c)}catch(p){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${p}`),f.raiseError)throw p}},f.awaitHandlers)})),new v_(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChatModelStart(t,r,n=void 0,i=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(l,u)=>{let d=u===0&&n?n:Hr();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return ao(f)&&f._createRunForChatModelStart(t,[l],d,this._parentRunId,a,this.tags,this.metadata,c),rt(async()=>{try{if(f.handleChatModelStart)await f.handleChatModelStart?.(t,[l],d,this._parentRunId,a,this.tags,this.metadata,c);else if(f.handleLLMStart){let p=ds(l);await f.handleLLMStart?.(t,[p],d,this._parentRunId,a,this.tags,this.metadata,c)}}catch(p){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${p}`),f.raiseError)throw p}},f.awaitHandlers)})),new v_(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(t,r,n=Hr(),i=void 0,a=void 0,o=void 0,s=void 0,c=void 0,l=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreChain)return ao(u)&&u._createRunForChainStart(t,r,n,this._parentRunId,this.tags,this.metadata,i,s,l),rt(async()=>{try{await u.handleChainStart?.(t,r,n,this._parentRunId,this.tags,this.metadata,i,s,l)}catch(d){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleChainStart: ${d}`),u.raiseError)throw d}},u.awaitHandlers)})),new LI(n,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(t,r,n=Hr(),i=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return await Promise.all(this.handlers.map(l=>{if(!l.ignoreAgent)return ao(l)&&l._createRunForToolStart(t,r,n,this._parentRunId,this.tags,this.metadata,s),rt(async()=>{try{await l.handleToolStart?.(t,r,n,this._parentRunId,this.tags,this.metadata,s,c)}catch(u){if((l.raiseError?console.error:console.warn)(`Error in handler ${l.constructor.name}, handleToolStart: ${u}`),l.raiseError)throw u}},l.awaitHandlers)})),new FI(n,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(t,r,n=Hr(),i=void 0,a=void 0,o=void 0,s=void 0){return await Promise.all(this.handlers.map(c=>{if(!c.ignoreRetriever)return ao(c)&&c._createRunForRetrieverStart(t,r,n,this._parentRunId,this.tags,this.metadata,s),rt(async()=>{try{await c.handleRetrieverStart?.(t,r,n,this._parentRunId,this.tags,this.metadata,s)}catch(l){if((c.raiseError?console.error:console.warn)(`Error in handler ${c.constructor.name}, handleRetrieverStart: ${l}`),c.raiseError)throw l}},c.awaitHandlers)})),new UI(n,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleCustomEvent(t,r,n,i,a){await Promise.all(this.handlers.map(o=>rt(async()=>{if(!o.ignoreCustomEvent)try{await o.handleCustomEvent?.(t,r,n,this.tags,this.metadata)}catch(s){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleCustomEvent: ${s}`),o.raiseError)throw s}},o.awaitHandlers)))}addHandler(t,r=!0){this.handlers.push(t),r&&this.inheritableHandlers.push(t)}removeHandler(t){this.handlers=this.handlers.filter(r=>r!==t),this.inheritableHandlers=this.inheritableHandlers.filter(r=>r!==t)}setHandlers(t,r=!0){this.handlers=[],this.inheritableHandlers=[];for(let n of t)this.addHandler(n,r)}addTags(t,r=!0){this.removeTags(t),this.tags.push(...t),r&&this.inheritableTags.push(...t)}removeTags(t){this.tags=this.tags.filter(r=>!t.includes(r)),this.inheritableTags=this.inheritableTags.filter(r=>!t.includes(r))}addMetadata(t,r=!0){this.metadata={...this.metadata,...t},r&&(this.inheritableMetadata={...this.inheritableMetadata,...t})}removeMetadata(t){for(let r of Object.keys(t))delete this.metadata[r],delete this.inheritableMetadata[r]}copy(t=[],r=!0){let n=new ol(this._parentRunId);for(let i of this.handlers){let a=this.inheritableHandlers.includes(i);n.addHandler(i,a)}for(let i of this.tags){let a=this.inheritableTags.includes(i);n.addTags([i],a)}for(let i of Object.keys(this.metadata)){let a=Object.keys(this.inheritableMetadata).includes(i);n.addMetadata({[i]:this.metadata[i]},a)}for(let i of t)n.handlers.filter(a=>a.name==="console_callback_handler").some(a=>a.name===i.name)||n.addHandler(i,r);return n}static fromHandlers(t){class r extends sr{name=Hr();constructor(){super(),Object.assign(this,t)}}let n=new this;return n.addHandler(new r),n}static configure(t,r,n,i,a,o,s){return this._configureSync(t,r,n,i,a,o,s)}static _configureSync(t,r,n,i,a,o,s){let c;(t||r)&&(Array.isArray(t)||!t?(c=new ol,c.setHandlers(t?.map(gi)??[],!0)):c=t,c=c.copy(Array.isArray(r)?r.map(gi):r?.handlers,!1));let l=ar("LANGCHAIN_VERBOSE")==="true"||s?.verbose,u=bs.getTraceableRunTree(),d=u?.tracingEnabled??MI();if(u?.tracingEnabled===!1&&c){let h=c.handlers.filter(_=>_.name==="langchain_tracer");for(let _ of h)c.removeHandler(_)}let f=d||(ar("LANGCHAIN_TRACING")??!1);if(l||f){if(c||(c=new ol),l&&!c.handlers.some(h=>h.name===tf.prototype.name)){let h=new tf;c.addHandler(h,!0)}if(f&&!c.handlers.some(h=>h.name==="langchain_tracer")&&d){let h=new bs;c.addHandler(h,!0)}d&&u&&c._parentRunId===void 0&&(c._parentRunId=u.id,c.handlers.find(h=>h.name==="langchain_tracer")?.updateFromRunTree(u))}for(let{contextVar:h,inheritable:_=!0,handlerClass:y,envVar:w}of jI()){let x=w&&ar(w)==="true"&&y,S,$=h!==void 0?y_(h):void 0;$&&hg($)?S=$:x&&(S=new y({})),S!==void 0&&(c||(c=new ol),c.handlers.some(P=>P.name===S.name)||c.addHandler(S,_))}(n||i)&&c&&(c.addTags(n??[]),c.addTags(i??[],!1)),(a||o)&&c&&(c.addMetadata(a??{}),c.addMetadata(o??{},!1));let p=s?.tracerInheritableMetadata,m=s?.tracerInheritableTags;return c&&(p||m)&&(c.handlers=c.handlers.map(h=>h instanceof bs?h.copyWithTracingConfig({metadata:p,tags:m}):h),c.inheritableHandlers=c.inheritableHandlers.map(h=>h instanceof bs?h.copyWithTracingConfig({metadata:p,tags:m}):h)),c}};function gi(e){return"name"in e?e:sr.fromMethods(e)}var b_=class{getStore(){}run(e,t){return t()}enterWith(e){}},pz=new b_,BI=Symbol.for("lc:child_config"),mz=class{getInstance(){return ia()??pz}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[BI]}runWithConfig(e,t,r){let n=Xe._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),i=this.getInstance(),a=i.getStore(),o=n?.getParentRunId(),s=n?.handlers?.find(l=>l?.name==="langchain_tracer"),c;return s&&o?c=s.getRunTreeWithTracingConfig(o):r||(c=new dn({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra={...c.extra,[BI]:e}),a!==void 0&&a[na]!==void 0&&(c===void 0&&(c={}),c[na]=a[na]),i.run(c,t)}initializeGlobalInstance(e){ia()===void 0&&PI(e)}},Re=new mz;var VI=T({AsyncLocalStorageProviderSingleton:()=>Re,MockAsyncLocalStorage:()=>b_,_CONTEXT_VARIABLES_KEY:()=>na});var hz=new Set(["api_key"]),gz=new Set(["string","number","boolean"]);function _z(e){let t=e.configurable??{},r=e.metadata??{},n={};for(let[i,a]of Object.entries(t))!i.startsWith("__")&&!Object.prototype.hasOwnProperty.call(r,i)&&!hz.has(i)&&gz.has(typeof a)&&(n[i]=a);return Object.keys(n).length>0?n:void 0}async function Wt(e){return Xe._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata,void 0,{tracerInheritableMetadata:e?_z(e):void 0})}function $t(...e){let t={};for(let r of e.filter(n=>!!n))for(let n of Object.keys(r))if(n==="metadata")t[n]={...t[n],...r[n]};else if(n==="tags"){let i=t[n]??[];t[n]=[...new Set(i.concat(r[n]??[]))]}else if(n==="configurable")t[n]={...t[n],...r[n]};else if(n==="timeout")t.timeout===void 0?t.timeout=r.timeout:r.timeout!==void 0&&(t.timeout=Math.min(t.timeout,r.timeout));else if(n==="signal")t.signal===void 0?t.signal=r.signal:r.signal!==void 0&&("any"in AbortSignal?t.signal=AbortSignal.any([t.signal,r.signal]):t.signal=r.signal);else if(n==="callbacks"){let i=t.callbacks,a=r.callbacks;if(Array.isArray(a))if(!i)t.callbacks=a;else if(Array.isArray(i))t.callbacks=i.concat(a);else{let o=i.copy();for(let s of a)o.addHandler(gi(s),!0);t.callbacks=o}else if(a)if(!i)t.callbacks=a;else if(Array.isArray(i)){let o=a.copy();for(let s of i)o.addHandler(gi(s),!0);t.callbacks=o}else t.callbacks=new Xe(a._parentRunId,{handlers:i.handlers.concat(a.handlers),inheritableHandlers:i.inheritableHandlers.concat(a.inheritableHandlers),tags:Array.from(new Set(i.tags.concat(a.tags))),inheritableTags:Array.from(new Set(i.inheritableTags.concat(a.inheritableTags))),metadata:{...i.metadata,...a.metadata}})}else{let i=n;t[i]=r[i]??t[i]}return t}function ke(e){let t=Re.getRunnableConfig(),r={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){let{runId:n,runName:i,...a}=t;r=Object.entries(a).reduce((o,[s,c])=>(c!==void 0&&(o[s]=c),o),r)}if(e&&(r=Object.entries(e).reduce((n,[i,a])=>(a!==void 0&&(n[i]=a),n),r)),r?.configurable&&typeof r.configurable.model=="string"&&r.metadata?.model===void 0&&(r.metadata||(r.metadata={}),r.metadata.model=r.configurable.model),r.timeout!==void 0){if(r.timeout<=0)throw new Error("Timeout must be a positive number");let n=r.timeout,i=AbortSignal.timeout(n);r.metadata||(r.metadata={}),r.metadata.timeoutMs===void 0&&(r.metadata.timeoutMs=n),r.signal!==void 0?"any"in AbortSignal&&(r.signal=AbortSignal.any([r.signal,i])):r.signal=i,delete r.timeout}return r}function Ee(e={},{callbacks:t,maxConcurrency:r,recursionLimit:n,runName:i,configurable:a,runId:o}={}){let s=ke(e);return t!==void 0&&(delete s.runName,s.callbacks=t),n!==void 0&&(s.recursionLimit=n),r!==void 0&&(s.maxConcurrency=r),i!==void 0&&(s.runName=i),a!==void 0&&(s.configurable={...s.configurable,...a}),o!==void 0&&delete s.runId,s}function vr(e){if(e)return{configurable:e.configurable,recursionLimit:e.recursionLimit,callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,maxConcurrency:e.maxConcurrency,timeout:e.timeout,signal:e.signal,store:e.store}}async function Rr(e,t){if(t===void 0)return e;let r;return Promise.race([e.catch(n=>{if(!t?.aborted)throw n}),new Promise((n,i)=>{r=()=>{i(aa(t))},t.addEventListener("abort",r,{once:!0}),t.aborted&&i(aa(t))})]).finally(()=>t.removeEventListener("abort",r))}function aa(e){return e?.reason instanceof Error?e.reason:typeof e?.reason=="string"?new Error(e.reason):new Error("Aborted")}var ZI=T({AsyncGeneratorWithSetup:()=>oa,IterableReadableStream:()=>gt,atee:()=>of,concat:()=>Mr,pipeGeneratorWithSetup:()=>x_}),gt=class w_ extends ReadableStream{reader;ensureReader(){this.reader||(this.reader=this.getReader())}async next(){this.ensureReader();try{let t=await this.reader.read();return t.done?(this.reader.releaseLock(),{done:!0,value:void 0}):{done:!1,value:t.value}}catch(t){throw this.reader.releaseLock(),t}}async return(){if(this.ensureReader(),this.locked){let t=this.reader.cancel();this.reader.releaseLock(),await t}return{done:!0,value:void 0}}async throw(t){if(this.ensureReader(),this.locked){let r=this.reader.cancel();this.reader.releaseLock(),await r}throw t}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}static fromReadableStream(t){let r=t.getReader();return new w_({start(n){return i();function i(){return r.read().then(({done:a,value:o})=>{if(a){n.close();return}return n.enqueue(o),i()})}},cancel(){r.releaseLock()}})}static fromAsyncGenerator(t){return new w_({async pull(r){let{value:n,done:i}=await t.next();i&&r.close(),r.enqueue(n)},async cancel(r){await t.return(r)}})}};function of(e,t=2){let r=Array.from({length:t},()=>[]);return r.map(async function*(i){for(;;)if(i.length===0){let a=await e.next();for(let o of r)o.push(a)}else{if(i[0].done)return;yield i.shift().value}})}function Mr(e,t){if(Array.isArray(e)&&Array.isArray(t))return e.concat(t);if(typeof e=="string"&&typeof t=="string")return e+t;if(typeof e=="number"&&typeof t=="number")return e+t;if("concat"in e&&typeof e.concat=="function")return e.concat(t);if(typeof e=="object"&&typeof t=="object"){let r={...e};for(let[n,i]of Object.entries(t))n in r&&!Array.isArray(r[n])?r[n]=Mr(r[n],i):r[n]=i;return r}else throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}var oa=class{generator;setup;config;signal;firstResult;firstResultUsed=!1;constructor(e){this.generator=e.generator,this.config=e.config,this.signal=e.signal??this.config?.signal,this.setup=new Promise((t,r)=>{Re.runWithConfig(vr(e.config),async()=>{this.firstResult=this.signal?Rr(e.generator.next(),this.signal):e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(n=>t(void 0),r)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?Re.runWithConfig(vr(this.config),this.signal?async()=>Rr(this.generator.next(...e),this.signal):async()=>this.generator.next(...e),!0):(this.firstResultUsed=!0,this.firstResult)}async return(e){return this.generator.return(e)}async throw(e){return this.generator.throw(e)}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}};async function x_(e,t,r,n,...i){let a=new oa({generator:t,startSetup:r,signal:n}),o=await a.setup;return{output:e(a,o,...i),setup:o}}var yz=Object.prototype.hasOwnProperty;function cf(e,t){return yz.call(e,t)}function lf(e){if(Array.isArray(e)){let r=new Array(e.length);for(let n=0;n<r.length;n++)r[n]=""+n;return r}if(Object.keys)return Object.keys(e);let t=[];for(let r in e)cf(e,r)&&t.push(r);return t}function jr(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function uf(e){let t=0,r=e.length,n;for(;t<r;){if(n=e.charCodeAt(t),n>=48&&n<=57){t++;continue}return!1}return!0}function co(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function GI(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function sf(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(sf(e[r]))return!0}else if(typeof e=="object"){let r=lf(e),n=r.length;for(var t=0;t<n;t++)if(sf(e[r[t]]))return!0}}return!1}function HI(e,t){let r=[e];for(let n in t){let i=typeof t[n]=="object"?JSON.stringify(t[n],null,2):t[n];typeof i<"u"&&r.push(`${n}: ${i}`)}return r.join(`
154
+ `)}var WI=class extends Error{constructor(e,t,r,n,i){super(HI(e,{name:t,index:r,operation:n,tree:i})),this.name=t,this.index=r,this.operation=n,this.tree=i,Object.setPrototypeOf(this,new.target.prototype),this.message=HI(e,{name:t,index:r,operation:n,tree:i})}};var JI=T({JsonPatchError:()=>st,_areEquals:()=>cl,applyOperation:()=>lo,applyPatch:()=>sa,applyReducer:()=>wz,deepClone:()=>vz,getValueByPointer:()=>df,validate:()=>KI,validator:()=>ff}),st=WI,vz=jr,ws={add:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");return e[t]=this.value,{newDocument:r}},remove:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var n=e[t];return delete e[t],{newDocument:r,removed:n}},replace:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:function(e,t,r){let n=df(r,this.path);n&&(n=jr(n));let i=lo(r,{op:"remove",path:this.from}).removed;return lo(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(e,t,r){let n=df(r,this.from);return lo(r,{op:"add",path:this.path,value:jr(n)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:cl(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},bz={add:function(e,t,r){return uf(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:r,index:t}},remove:function(e,t,r){return{newDocument:r,removed:e.splice(t,1)[0]}},replace:function(e,t,r){var n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:ws.move,copy:ws.copy,test:ws.test,_get:ws._get};function df(e,t){if(t=="")return e;var r={op:"_get",path:t};return lo(e,r),r.value}function lo(e,t,r=!1,n=!0,i=!0,a=0){if(r&&(typeof r=="function"?r(t,0,e,t.path):ff(t,0)),t.path===""){let o={newDocument:e};if(t.op==="add")return o.newDocument=t.value,o;if(t.op==="replace")return o.newDocument=t.value,o.removed=e,o;if(t.op==="move"||t.op==="copy")return o.newDocument=df(e,t.from),t.op==="move"&&(o.removed=e),o;if(t.op==="test"){if(o.test=cl(e,t.value),o.test===!1)throw new st("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return o.newDocument=e,o}else{if(t.op==="remove")return o.removed=e,o.newDocument=null,o;if(t.op==="_get")return t.value=e,o;if(r)throw new st("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",a,t,e);return o}}else{n||(e=jr(e));let o=(t.path||"").split("/"),s=e,c=1,l=o.length,u,d,f;for(typeof r=="function"?f=r:f=ff;;){if(d=o[c],d&&d.indexOf("~")!=-1&&(d=GI(d)),i&&(d=="__proto__"||d=="prototype"&&c>0&&o[c-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&u===void 0&&(s[d]===void 0?u=o.slice(0,c).join("/"):c==l-1&&(u=t.path),u!==void 0&&f(t,0,e,u)),c++,Array.isArray(s)){if(d==="-")d=s.length;else{if(r&&!uf(d))throw new st("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",a,t,e);uf(d)&&(d=~~d)}if(c>=l){if(r&&t.op==="add"&&d>s.length)throw new st("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",a,t,e);let p=bz[t.op].call(t,s,d,e);if(p.test===!1)throw new st("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return p}}else if(c>=l){let p=ws[t.op].call(t,s,d,e);if(p.test===!1)throw new st("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return p}if(s=s[d],r&&c<l&&(!s||typeof s!="object"))throw new st("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",a,t,e)}}}function sa(e,t,r,n=!0,i=!0){if(r&&!Array.isArray(t))throw new st("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(e=jr(e));let a=new Array(t.length);for(let o=0,s=t.length;o<s;o++)a[o]=lo(e,t[o],r,!0,i,o),e=a[o].newDocument;return a.newDocument=e,a}function wz(e,t,r){let n=lo(e,t);if(n.test===!1)throw new st("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return n.newDocument}function ff(e,t,r,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new st("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(ws[e.op]){if(typeof e.path!="string")throw new st("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new st('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,r);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new st("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new st("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&sf(e.value))throw new st("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,r);if(r){if(e.op=="add"){var i=e.path.split("/").length,a=n.split("/").length;if(i!==a+1&&i!==a)throw new st("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,r)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==n)throw new st("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,r)}else if(e.op==="move"||e.op==="copy"){var o=KI([{op:"_get",path:e.from,value:void 0}],r);if(o&&o.name==="OPERATION_PATH_UNRESOLVABLE")throw new st("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new st("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function KI(e,t,r){try{if(!Array.isArray(e))throw new st("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)sa(jr(t),jr(e),r||!0);else{r=r||ff;for(var n=0;n<e.length;n++)r(e[n],n,t,void 0)}}catch(i){if(i instanceof st)return i;throw i}}function cl(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var r=Array.isArray(e),n=Array.isArray(t),i,a,o;if(r&&n){if(a=e.length,a!=t.length)return!1;for(i=a;i--!==0;)if(!cl(e[i],t[i]))return!1;return!0}if(r!=n)return!1;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(i=a;i--!==0;)if(!t.hasOwnProperty(s[i]))return!1;for(i=a;i--!==0;)if(o=s[i],!cl(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}function qI(e,t,r,n,i){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var a=lf(t),o=lf(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if(cf(t,l)&&!(t[l]===void 0&&u!==void 0&&Array.isArray(t)===!1)){var d=t[l];typeof u=="object"&&u!=null&&typeof d=="object"&&d!=null&&Array.isArray(u)===Array.isArray(d)?qI(u,d,r,n+"/"+co(l),i):u!==d&&(i&&r.push({op:"test",path:n+"/"+co(l),value:jr(u)}),r.push({op:"replace",path:n+"/"+co(l),value:jr(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&r.push({op:"test",path:n+"/"+co(l),value:jr(u)}),r.push({op:"remove",path:n+"/"+co(l)}),s=!0):(i&&r.push({op:"test",path:n,value:e}),r.push({op:"replace",path:n,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c<a.length;c++){var l=a[c];!cf(e,l)&&t[l]!==void 0&&r.push({op:"add",path:n+"/"+co(l),value:jr(t[l])})}}}function ca(e,t,r=!1){var n=[];return qI(e,t,n,"",r),n}({...JI});var QI=T({LogStreamCallbackHandler:()=>mf,RunLog:()=>pf,RunLogPatch:()=>Vn,isLogStreamHandler:()=>k_}),Vn=class{ops;constructor(e){this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),r=sa({},t);return new pf({ops:t,state:r[r.length-1].newDocument})}},pf=class S_ extends Vn{state;constructor(t){super(t),this.state=t.state}concat(t){let r=this.ops.concat(t.ops),n=sa(this.state,t.ops);return new S_({ops:r,state:n[n.length-1].newDocument})}static fromRunLogPatch(t){let r=sa({},t.ops);return new S_({ops:t.ops,state:r[r.length-1].newDocument})}},k_=e=>e.name==="log_stream_tracer";async function XI(e,t){if(t==="original")throw new Error("Do not assign inputs with original schema drop the key for now. When inputs are added to streamLog they should be added with standardized schema for streaming events.");let{inputs:r}=e;if(["retriever","llm","prompt"].includes(e.run_type))return r;if(!(Object.keys(r).length===1&&r?.input===""))return r.input}async function YI(e,t){let{outputs:r}=e;return t==="original"||["retriever","llm","prompt"].includes(e.run_type)?r:r!==void 0&&Object.keys(r).length===1&&r?.output!==void 0?r.output:r}function xz(e){return e!==void 0&&e.message!==void 0}var mf=class extends Dt{autoClose=!0;includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;_schemaFormat="original";rootId;keyMapByRunId={};counterMapByRunName={};transformStream;writer;receiveStream;name="log_stream_tracer";lc_prefer_streaming=!0;constructor(e){super({_awaitHandler:!0,...e}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this._schemaFormat=e?._schemaFormat??this._schemaFormat,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=gt.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){if(e.id===this.rootId)return!1;let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.run_type)),this.includeTags!==void 0&&(r=r||t.find(n=>this.includeTags?.includes(n))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.run_type)),this.excludeTags!==void 0&&(r=r&&t.every(n=>!this.excludeTags?.includes(n))),r}async*tapOutputIterable(e,t){for await(let r of t){if(e!==this.rootId){let n=this.keyMapByRunId[e];n&&await this.writer.write(new Vn({ops:[{op:"add",path:`/logs/${n}/streamed_output/-`,value:r}]}))}yield r}}async onRunCreate(e){if(this.rootId===void 0&&(this.rootId=e.id,await this.writer.write(new Vn({ops:[{op:"replace",path:"",value:{id:e.id,name:e.name,type:e.run_type,streamed_output:[],final_output:void 0,logs:{}}}]}))),!this._includeRun(e))return;this.counterMapByRunName[e.name]===void 0&&(this.counterMapByRunName[e.name]=0),this.counterMapByRunName[e.name]+=1;let t=this.counterMapByRunName[e.name];this.keyMapByRunId[e.id]=t===1?e.name:`${e.name}:${t}`;let r={id:e.id,name:e.name,type:e.run_type,tags:e.tags??[],metadata:e.extra?.metadata??{},start_time:new Date(e.start_time).toISOString(),streamed_output:[],streamed_output_str:[],final_output:void 0,end_time:void 0};this._schemaFormat==="streaming_events"&&(r.inputs=await XI(e,this._schemaFormat)),await this.writer.write(new Vn({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:r}]}))}async onRunUpdate(e){try{let t=this.keyMapByRunId[e.id];if(t===void 0)return;let r=[];this._schemaFormat==="streaming_events"&&r.push({op:"replace",path:`/logs/${t}/inputs`,value:await XI(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await YI(e,this._schemaFormat)}),e.end_time!==void 0&&r.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});let n=new Vn({ops:r});await this.writer.write(n)}finally{if(e.id===this.rootId){let t=new Vn({ops:[{op:"replace",path:"/final_output",value:await YI(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,r){let n=this.keyMapByRunId[e.id];if(n===void 0)return;let i=e.inputs.messages!==void 0,a;i?xz(r?.chunk)?a=r?.chunk:a=new it({id:`run-${e.id}`,content:t}):a=t;let o=new Vn({ops:[{op:"add",path:`/logs/${n}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${n}/streamed_output/-`,value:a}]});await this.writer.write(o)}};var eT=T({ChatGenerationChunk:()=>la,GenerationChunk:()=>_i,RUN_KEY:()=>uo}),uo="__run",_i=class tT{text;generationInfo;constructor(t){this.text=t.text,this.generationInfo=t.generationInfo}concat(t){return new tT({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo}})}},la=class rT extends _i{message;constructor(t){super(t),this.message=t.message}concat(t){return new rT({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo},message:this.message.concat(t.message)})}};var Sz=Object.prototype.toString,kz=e=>Sz.call(e)==="[object Error]",$z=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function nT(e){if(!(e&&kz(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:t,stack:r}=e;return t==="Load failed"?r===void 0||"__sentry_captured__"in e:t.startsWith("error sending request for url")?!0:$z.has(t)}function Ez(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function hf(e,t,{min:r=0,allowInfinity:n=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${n?" or Infinity":""}.`);if(!n&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var Iz=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}};function Tz(e,t){let r=Math.max(1,e+1),n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*t.factor**(r-1));return i=Math.min(i,t.maxTimeout),i}function iT(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function Cz({error:e,attemptNumber:t,retriesConsumed:r,startTime:n,options:i}){let a=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(a instanceof Iz)throw a.originalError;let o=Number.isFinite(i.retries)?Math.max(0,i.retries-r):i.retries,s=i.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:a,attemptNumber:t,retriesLeft:o,retriesConsumed:r});if(await i.onFailedAttempt(c),iT(n,s)<=0)throw a;let l=await i.shouldConsumeRetry(c),u=iT(n,s);if(u<=0||o<=0)throw a;if(a instanceof TypeError&&!nT(a)){if(l)throw a;return i.signal?.throwIfAborted(),!1}if(!await i.shouldRetry(c))throw a;if(!l)return i.signal?.throwIfAborted(),!1;let d=Tz(r,i),f=typeof a.retryAfterMs=="number"&&a.retryAfterMs>=0?a.retryAfterMs:void 0;f!==void 0&&(d=Math.max(d,f));let p=Math.min(d,u);return p>0&&await new Promise((m,h)=>{let _=()=>{clearTimeout(y),i.signal?.removeEventListener("abort",_),h(i.signal.reason)},y=setTimeout(()=>{i.signal?.removeEventListener("abort",_),m()},p);i.unref&&y.unref?.(),i.signal?.addEventListener("abort",_,{once:!0})}),i.signal?.throwIfAborted(),!0}async function ll(e,t={}){if(t={...t},Ez(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,hf("factor",t.factor,{min:0,allowInfinity:!1}),hf("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),hf("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),hf("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,n=0,i=performance.now();for(;!Number.isFinite(t.retries)||n<=t.retries;){r++;try{t.signal?.throwIfAborted();let a=await e(r);return t.signal?.throwIfAborted(),a}catch(a){await Cz({error:a,attemptNumber:r,retriesConsumed:n,startTime:i,options:t})&&n++}}throw new Error("Retry attempts exhausted without throwing an error.")}var gf=Vu(Zd(),1),oT=T({AsyncCaller:()=>yi,classifyRateLimitError:()=>dT,parseRetryAfterMs:()=>uT}),Az=[400,401,402,403,404,405,406,407,409],Oz=6e4,Pz=[/insufficient[_ -]?quota/i,/exceeded (?:your|the current|the available).+quota/i,/usage quota/i,/quota (?:has been )?exhausted/i,/billing/i,/credit balance/i,/out of credits/i,/will reset at/i],Nz=/(?:try again in|retry after)\s+(\d+(?:\.\d+)?)\s*(milliseconds?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h)\b/i;function sT(e){return typeof e=="object"&&e!==null&&"response"in e&&typeof e.response=="object"&&e.response!==null&&"status"in e.response&&typeof e.response.status=="number"?e.response.status:void 0}function cT(e){if(!(typeof e!="object"||e===null)){if("status"in e&&typeof e.status=="number")return e.status;if("statusCode"in e&&typeof e.statusCode=="number")return e.statusCode}}function E_(e){return typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:void 0}function lT(e){if(!(typeof e!="object"||e===null))return"code"in e&&typeof e.code=="string"?e.code:"error"in e&&typeof e.error=="object"&&e.error!==null&&"code"in e.error&&typeof e.error.code=="string"?e.error.code:void 0}function Rz(e){if(e?.headers)return typeof e.headers.get=="function"?e.headers.get("retry-after"):e.headers["retry-after"]??e.headers["Retry-After"];if(e?.response?.headers)return typeof e.response.headers.get=="function"?e.response.headers.get("retry-after"):e.response.headers["retry-after"]??e.response.headers["Retry-After"]}function Mz(e){if(e==null)return;let t=Nz.exec(e);if(!t)return;let r=Number(t[1]),n=t[2]?.toLowerCase();if(!(Number.isNaN(r)||!n))return n==="ms"||n.startsWith("millisecond")?r:n==="m"||n.startsWith("min")?r*6e4:n==="h"||n.startsWith("hr")||n.startsWith("hour")?r*36e5:r*1e3}function aT(e,t){if(e instanceof Error)return e;let r=new Error(t);return typeof e=="object"&&e!==null&&Object.assign(r,e),r}function $_(e,t){if(typeof e!="object"||e===null)return;let r=e;r.rateLimitType=t.action,r.rateLimitReason=t.reason,t.retryAfterMs!==void 0&&(r.retryAfterMs=t.retryAfterMs)}function uT(e){if(e==null)return;let t=e.trim();if(!t)return;let r=Number(t);if(!Number.isNaN(r)&&r>=0)return r*1e3;let n=Date.parse(t);if(!Number.isNaN(n)){let i=n-Date.now();return i>0?i:0}}function dT(e){if((sT(e)??cT(e))!==429)return;if(lT(e)==="insufficient_quota")return{action:"stop",reason:"insufficient_quota"};let t=E_(e);if(t&&Pz.some(n=>n.test(t)))return{action:"stop",reason:"quota_message"};let r=uT(Rz(e))??Mz(t);return r!==void 0?r<=Oz?{action:"wait",retryAfterMs:r,reason:"retry_after_hint"}:{action:"capacity",retryAfterMs:r,reason:"retry_after_too_large"}:{action:"capacity",reason:"headerless_429"}}var jz=e=>{if(typeof e!="object"||e===null)return;if("message"in e&&typeof e.message=="string"&&(e.message.startsWith("Cancel")||e.message.startsWith("AbortError"))||"name"in e&&typeof e.name=="string"&&e.name==="AbortError"||"code"in e&&typeof e.code=="string"&&e.code==="ECONNABORTED")throw e;let t=sT(e)??cT(e);if(t&&Az.includes(+t))throw e;if(lT(e)==="insufficient_quota"){let n=aT(e,E_(e)??"Insufficient quota");throw n.name="InsufficientQuotaError",$_(n,{action:"stop",reason:"insufficient_quota"}),n}let r=dT(e);if(r){if(r.action==="wait"){$_(e,r);return}let n=aT(e,E_(e)??"Rate limit exceeded");throw n.name==="Error"&&(n.name=r.action==="stop"?"RateLimitQuotaExhaustedError":"RateLimitCapacityError"),$_(n,r),n}},yi=class{maxConcurrency;maxRetries;onFailedAttempt;queue;constructor(e){this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??jz;let t="default"in gf.default?gf.default.default:gf.default;this.queue=new t({concurrency:this.maxConcurrency})}async call(e,...t){return this.queue.add(()=>ll(()=>e(...t).catch(r=>{throw r instanceof Error?r:new Error(r)}),{onFailedAttempt:({error:r})=>this.onFailedAttempt?.(r),retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){if(e.signal){let n;return Promise.race([this.call(t,...r),new Promise((i,a)=>{n=()=>{a(aa(e.signal))},e.signal?.addEventListener("abort",n,{once:!0})})]).finally(()=>{e.signal&&n&&e.signal.removeEventListener("abort",n)})}return this.call(t,...r)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}};var fT=T({isSerializableSchema:()=>fo,isStandardJsonSchema:()=>_f,isStandardSchema:()=>pT});function pT(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function _f(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function fo(e){return pT(e)&&_f(e)}var wi={};An(wi,{$ZodAny:()=>gv,$ZodArray:()=>vv,$ZodAsyncError:()=>fn,$ZodBase64:()=>ov,$ZodBase64URL:()=>sv,$ZodBigInt:()=>Df,$ZodBigIntFormat:()=>fv,$ZodBoolean:()=>xl,$ZodCIDRv4:()=>nv,$ZodCIDRv6:()=>iv,$ZodCUID:()=>Hy,$ZodCUID2:()=>Gy,$ZodCatch:()=>Dv,$ZodCheck:()=>Ze,$ZodCheckBigIntFormat:()=>wy,$ZodCheckEndsWith:()=>Ny,$ZodCheckGreaterThan:()=>Of,$ZodCheckIncludes:()=>Oy,$ZodCheckLengthEquals:()=>Iy,$ZodCheckLessThan:()=>Af,$ZodCheckLowerCase:()=>Cy,$ZodCheckMaxLength:()=>$y,$ZodCheckMaxSize:()=>xy,$ZodCheckMimeType:()=>My,$ZodCheckMinLength:()=>Ey,$ZodCheckMinSize:()=>Sy,$ZodCheckMultipleOf:()=>vy,$ZodCheckNumberFormat:()=>by,$ZodCheckOverwrite:()=>jy,$ZodCheckProperty:()=>Ry,$ZodCheckRegex:()=>Ty,$ZodCheckSizeEquals:()=>ky,$ZodCheckStartsWith:()=>Py,$ZodCheckStringFormat:()=>Cs,$ZodCheckUpperCase:()=>Ay,$ZodCodec:()=>El,$ZodCustom:()=>Hv,$ZodCustomStringFormat:()=>uv,$ZodDate:()=>yv,$ZodDefault:()=>Nv,$ZodDiscriminatedUnion:()=>xv,$ZodE164:()=>cv,$ZodEmail:()=>Fy,$ZodEmoji:()=>Vy,$ZodEncodeError:()=>ua,$ZodEnum:()=>Iv,$ZodError:()=>gl,$ZodExactOptional:()=>Ov,$ZodFile:()=>Cv,$ZodFunction:()=>Bv,$ZodGUID:()=>Uy,$ZodIPv4:()=>ev,$ZodIPv6:()=>tv,$ZodISODate:()=>Xy,$ZodISODateTime:()=>qy,$ZodISODuration:()=>Qy,$ZodISOTime:()=>Yy,$ZodIntersection:()=>Sv,$ZodJWT:()=>lv,$ZodKSUID:()=>Ky,$ZodLazy:()=>Zv,$ZodLiteral:()=>Tv,$ZodMAC:()=>rv,$ZodMap:()=>$v,$ZodNaN:()=>zv,$ZodNanoID:()=>Zy,$ZodNever:()=>kl,$ZodNonOptional:()=>Mv,$ZodNull:()=>hv,$ZodNullable:()=>Pv,$ZodNumber:()=>jf,$ZodNumberFormat:()=>dv,$ZodObject:()=>ZT,$ZodObjectJIT:()=>bv,$ZodOptional:()=>yo,$ZodPipe:()=>Uf,$ZodPrefault:()=>Rv,$ZodPreprocess:()=>Uv,$ZodPromise:()=>Vv,$ZodReadonly:()=>Lv,$ZodRealError:()=>wr,$ZodRecord:()=>kv,$ZodRegistry:()=>Vf,$ZodSet:()=>Ev,$ZodString:()=>_o,$ZodStringFormat:()=>Fe,$ZodSuccess:()=>jv,$ZodSymbol:()=>pv,$ZodTemplateLiteral:()=>Fv,$ZodTransform:()=>Av,$ZodTuple:()=>zf,$ZodType:()=>pe,$ZodULID:()=>Wy,$ZodURL:()=>By,$ZodUUID:()=>Ly,$ZodUndefined:()=>mv,$ZodUnion:()=>$l,$ZodUnknown:()=>Sl,$ZodVoid:()=>_v,$ZodXID:()=>Jy,$ZodXor:()=>wv,$brand:()=>T_,$constructor:()=>k,$input:()=>Wv,$output:()=>Gv,Doc:()=>wl,JSONSchema:()=>GC,JSONSchemaGenerator:()=>vp,NEVER:()=>I_,TimePrecision:()=>Xv,_any:()=>yb,_array:()=>Sb,_base64:()=>sp,_base64url:()=>cp,_bigint:()=>db,_boolean:()=>lb,_catch:()=>aL,_check:()=>HC,_cidrv4:()=>ap,_cidrv6:()=>op,_coercedBigint:()=>fb,_coercedBoolean:()=>ub,_coercedDate:()=>wb,_coercedNumber:()=>nb,_coercedString:()=>Kv,_cuid:()=>Yf,_cuid2:()=>Qf,_custom:()=>$b,_date:()=>bb,_decode:()=>wf,_decodeAsync:()=>Sf,_default:()=>rL,_discriminatedUnion:()=>Z2,_e164:()=>lp,_email:()=>Hf,_emoji:()=>qf,_encode:()=>bf,_encodeAsync:()=>xf,_endsWith:()=>js,_enum:()=>q2,_file:()=>kb,_float32:()=>ab,_float64:()=>ob,_gt:()=>Hn,_gte:()=>dr,_guid:()=>Cl,_includes:()=>Rs,_int:()=>ib,_int32:()=>sb,_int64:()=>pb,_intersection:()=>H2,_ipv4:()=>np,_ipv6:()=>ip,_isoDate:()=>Qv,_isoDateTime:()=>Yv,_isoDuration:()=>tb,_isoTime:()=>eb,_jwt:()=>up,_ksuid:()=>rp,_lazy:()=>lL,_length:()=>wo,_literal:()=>Y2,_lowercase:()=>Ps,_lt:()=>Zn,_lte:()=>zr,_mac:()=>qv,_map:()=>J2,_max:()=>zr,_maxLength:()=>bo,_maxSize:()=>_a,_mime:()=>Ds,_min:()=>dr,_minLength:()=>bi,_minSize:()=>Gn,_multipleOf:()=>ga,_nan:()=>xb,_nanoid:()=>Xf,_nativeEnum:()=>X2,_negative:()=>fp,_never:()=>Pl,_nonnegative:()=>mp,_nonoptional:()=>nL,_nonpositive:()=>pp,_normalize:()=>zs,_null:()=>_b,_nullable:()=>tL,_number:()=>rb,_optional:()=>eL,_overwrite:()=>pn,_parse:()=>$s,_parseAsync:()=>Es,_pipe:()=>oL,_positive:()=>dp,_promise:()=>uL,_property:()=>hp,_readonly:()=>sL,_record:()=>W2,_refine:()=>Eb,_regex:()=>Os,_safeDecode:()=>$f,_safeDecodeAsync:()=>If,_safeEncode:()=>kf,_safeEncodeAsync:()=>Ef,_safeParse:()=>Is,_safeParseAsync:()=>Ts,_set:()=>K2,_size:()=>vo,_slugify:()=>Bs,_startsWith:()=>Ms,_string:()=>Jv,_stringFormat:()=>Vs,_stringbool:()=>Ab,_success:()=>iL,_superRefine:()=>Ib,_symbol:()=>hb,_templateLiteral:()=>cL,_toLowerCase:()=>Ls,_toUpperCase:()=>Fs,_transform:()=>Q2,_trim:()=>Us,_tuple:()=>G2,_uint32:()=>cb,_uint64:()=>mb,_ulid:()=>ep,_undefined:()=>gb,_union:()=>B2,_unknown:()=>Ol,_uppercase:()=>Ns,_url:()=>Al,_uuid:()=>Gf,_uuidv4:()=>Wf,_uuidv6:()=>Jf,_uuidv7:()=>Kf,_void:()=>vb,_xid:()=>tp,_xor:()=>V2,clone:()=>Ye,config:()=>ct,createStandardJSONSchemaMethod:()=>Zs,createToJSONSchemaMethod:()=>Ob,decode:()=>uU,decodeAsync:()=>fU,describe:()=>Tb,encode:()=>lU,encodeAsync:()=>dU,extractDefs:()=>va,finalize:()=>ba,flattenError:()=>_l,formatError:()=>yl,globalConfig:()=>po,globalRegistry:()=>De,initializeContext:()=>ya,isValidBase64:()=>av,isValidBase64URL:()=>LT,isValidJWT:()=>FT,locales:()=>Tl,meta:()=>Cb,parse:()=>ha,parseAsync:()=>ho,prettifyError:()=>F_,process:()=>ze,regexes:()=>Dr,registry:()=>Zf,safeDecode:()=>mU,safeDecodeAsync:()=>gU,safeEncode:()=>pU,safeEncodeAsync:()=>hU,safeParse:()=>B_,safeParseAsync:()=>V_,toDotPath:()=>vT,toJSONSchema:()=>xo,treeifyError:()=>L_,util:()=>j,version:()=>Dy});var mT,I_=Object.freeze({status:"aborted"});function k(e,t,r){function n(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);let l=o.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let f=u[d];f in s||(s[f]=l[f].bind(s))}}let i=r?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(s){var c;let l=r?.Parent?new a:this;n(l,s),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var T_=Symbol("zod_brand"),fn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ua=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(mT=globalThis).__zod_globalConfig??(mT.__zod_globalConfig={});var po=globalThis.__zod_globalConfig;function ct(e){return e&&Object.assign(po,e),po}var j={};An(j,{BIGINT_FORMAT_RANGES:()=>z_,Class:()=>A_,NUMBER_FORMAT_RANGES:()=>D_,aborted:()=>ma,allowsEval:()=>N_,assert:()=>Fz,assertEqual:()=>Dz,assertIs:()=>Uz,assertNever:()=>Lz,assertNotEqual:()=>zz,assignProp:()=>fa,base64ToUint8Array:()=>gT,base64urlToUint8Array:()=>iU,cached:()=>Ss,captureStackTrace:()=>vf,cleanEnum:()=>nU,cleanRegex:()=>fl,clone:()=>Ye,cloneDef:()=>Vz,createTransparentProxy:()=>Kz,defineLazy:()=>$e,esc:()=>yf,escapeRegex:()=>Jr,explicitlyAborted:()=>U_,extend:()=>Yz,finalizeIssue:()=>ur,floatSafeRemainder:()=>O_,getElementAtPath:()=>Zz,getEnumValues:()=>dl,getLengthableOrigin:()=>hl,getParsedType:()=>Jz,getSizableOrigin:()=>ml,hexToUint8Array:()=>oU,isObject:()=>mo,isPlainObject:()=>pa,issue:()=>ks,joinValues:()=>I,jsonStringifyReplacer:()=>xs,merge:()=>eU,mergeDefs:()=>vi,normalizeParams:()=>U,nullish:()=>da,numKeys:()=>Wz,objectClone:()=>Bz,omit:()=>Xz,optionalKeys:()=>j_,parsedType:()=>M,partial:()=>tU,pick:()=>qz,prefixIssues:()=>br,primitiveTypes:()=>M_,promiseAllObject:()=>Hz,propertyKeyTypes:()=>pl,randomString:()=>Gz,required:()=>rU,safeExtend:()=>Qz,shallowClone:()=>R_,slugify:()=>P_,stringifyPrimitive:()=>R,uint8ArrayToBase64:()=>_T,uint8ArrayToBase64url:()=>aU,uint8ArrayToHex:()=>sU,unwrapMessage:()=>ul});function Dz(e){return e}function zz(e){return e}function Uz(e){}function Lz(e){throw new Error("Unexpected value in exhaustive check")}function Fz(e){}function dl(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function I(e,t="|"){return e.map(r=>R(r)).join(t)}function xs(e,t){return typeof t=="bigint"?t.toString():t}function Ss(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function da(e){return e==null}function fl(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function O_(e,t){let r=e/t,n=Math.round(r),i=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<i?0:r-n}var hT=Symbol("evaluating");function $e(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==hT)return n===void 0&&(n=hT,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Bz(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function fa(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function vi(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Vz(e){return vi(e._zod.def)}function Zz(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Hz(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let i={};for(let a=0;a<t.length;a++)i[t[a]]=n[a];return i})}function Gz(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function yf(e){return JSON.stringify(e)}function P_(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var vf="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function mo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var N_=Ss(()=>{if(po.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function pa(e){if(mo(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(mo(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function R_(e){return pa(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Wz(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Jz=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},pl=new Set(["string","number","symbol"]),M_=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Jr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ye(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function U(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Kz(e){let t;return new Proxy({},{get(r,n,i){return t??(t=e()),Reflect.get(t,n,i)},set(r,n,i,a){return t??(t=e()),Reflect.set(t,n,i,a)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,i){return t??(t=e()),Reflect.defineProperty(t,n,i)}})}function R(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function j_(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var D_={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},z_={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function qz(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let a=vi(e._zod.def,{get shape(){let o={};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=r.shape[s])}return fa(this,"shape",o),o},checks:[]});return Ye(e,a)}function Xz(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let a=vi(e._zod.def,{get shape(){let o={...e._zod.def.shape};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return fa(this,"shape",o),o},checks:[]});return Ye(e,a)}function Yz(e,t){if(!pa(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let a=e._zod.def.shape;for(let o in t)if(Object.getOwnPropertyDescriptor(a,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=vi(e._zod.def,{get shape(){let a={...e._zod.def.shape,...t};return fa(this,"shape",a),a}});return Ye(e,i)}function Qz(e,t){if(!pa(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=vi(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return fa(this,"shape",n),n}});return Ye(e,r)}function eU(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=vi(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return fa(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ye(e,r)}function tU(e,t,r){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let o=vi(t._zod.def,{get shape(){let s=t._zod.def.shape,c={...s};if(r)for(let l in r){if(!(l in s))throw new Error(`Unrecognized key: "${l}"`);r[l]&&(c[l]=e?new e({type:"optional",innerType:s[l]}):s[l])}else for(let l in s)c[l]=e?new e({type:"optional",innerType:s[l]}):s[l];return fa(this,"shape",c),c},checks:[]});return Ye(t,o)}function rU(e,t,r){let n=vi(t._zod.def,{get shape(){let i=t._zod.def.shape,a={...i};if(r)for(let o in r){if(!(o in a))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(a[o]=new e({type:"nonoptional",innerType:i[o]}))}else for(let o in i)a[o]=new e({type:"nonoptional",innerType:i[o]});return fa(this,"shape",a),a}});return Ye(t,n)}function ma(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function U_(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function br(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ul(e){return typeof e=="string"?e:e?.message}function ur(e,t,r){let n=e.message?e.message:ul(e.inst?._zod.def?.error?.(e))??ul(t?.error?.(e))??ul(r.customError?.(e))??ul(r.localeError?.(e))??"Invalid input",{inst:i,continue:a,input:o,...s}=e;return s.path??(s.path=[]),s.message=n,t?.reportInput&&(s.input=o),s}function ml(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function hl(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function M(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function ks(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function nU(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function gT(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function _T(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function iU(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return gT(t+r)}function aU(e){return _T(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function oU(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function sU(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var A_=class{constructor(...t){}};var yT=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,xs,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},gl=k("$ZodError",yT),wr=k("$ZodError",yT,{Parent:Error});function _l(e,t=r=>r.message){let r={},n=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function yl(e,t=r=>r.message){let r={_errors:[]},n=(i,a=[])=>{for(let o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(s=>n({issues:s},[...a,...o.path]));else if(o.code==="invalid_key")n({issues:o.issues},[...a,...o.path]);else if(o.code==="invalid_element")n({issues:o.issues},[...a,...o.path]);else{let s=[...a,...o.path];if(s.length===0)r._errors.push(t(o));else{let c=r,l=0;for(;l<s.length;){let u=s[l];l===s.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}}};return n(e),r}function L_(e,t=r=>r.message){let r={errors:[]},n=(i,a=[])=>{var o,s;for(let c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>n({issues:l},[...a,...c.path]));else if(c.code==="invalid_key")n({issues:c.issues},[...a,...c.path]);else if(c.code==="invalid_element")n({issues:c.issues},[...a,...c.path]);else{let l=[...a,...c.path];if(l.length===0){r.errors.push(t(c));continue}let u=r,d=0;for(;d<l.length;){let f=l[d],p=d===l.length-1;typeof f=="string"?(u.properties??(u.properties={}),(o=u.properties)[f]??(o[f]={errors:[]}),u=u.properties[f]):(u.items??(u.items=[]),(s=u.items)[f]??(s[f]={errors:[]}),u=u.items[f]),p&&u.errors.push(t(c)),d++}}};return n(e),r}function vT(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function F_(e){let t=[],r=[...e.issues].sort((n,i)=>(n.path??[]).length-(i.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${vT(n.path)}`);return t.join(`
155
+ `)}var $s=e=>(t,r,n,i)=>{let a=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new fn;if(o.issues.length){let s=new(i?.Err??e)(o.issues.map(c=>ur(c,a,ct())));throw vf(s,i?.callee),s}return o.value},ha=$s(wr),Es=e=>async(t,r,n,i)=>{let a=n?{...n,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let s=new(i?.Err??e)(o.issues.map(c=>ur(c,a,ct())));throw vf(s,i?.callee),s}return o.value},ho=Es(wr),Is=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new fn;return a.issues.length?{success:!1,error:new(e??gl)(a.issues.map(o=>ur(o,i,ct())))}:{success:!0,data:a.value}},B_=Is(wr),Ts=e=>async(t,r,n)=>{let i=n?{...n,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(o=>ur(o,i,ct())))}:{success:!0,data:a.value}},V_=Ts(wr),bf=e=>(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return $s(e)(t,r,i)},lU=bf(wr),wf=e=>(t,r,n)=>$s(e)(t,r,n),uU=wf(wr),xf=e=>async(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return Es(e)(t,r,i)},dU=xf(wr),Sf=e=>async(t,r,n)=>Es(e)(t,r,n),fU=Sf(wr),kf=e=>(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return Is(e)(t,r,i)},pU=kf(wr),$f=e=>(t,r,n)=>Is(e)(t,r,n),mU=$f(wr),Ef=e=>async(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return Ts(e)(t,r,i)},hU=Ef(wr),If=e=>async(t,r,n)=>Ts(e)(t,r,n),gU=If(wr);var Dr={};An(Dr,{base64:()=>ay,base64url:()=>Tf,bigint:()=>fy,boolean:()=>my,browserEmail:()=>kU,cidrv4:()=>ny,cidrv6:()=>iy,cuid:()=>Z_,cuid2:()=>H_,date:()=>cy,datetime:()=>uy,domain:()=>IU,duration:()=>q_,e164:()=>sy,email:()=>Y_,emoji:()=>Q_,extendedDuration:()=>_U,guid:()=>X_,hex:()=>TU,hostname:()=>EU,html5Email:()=>wU,httpProtocol:()=>oy,idnEmail:()=>SU,integer:()=>py,ipv4:()=>ey,ipv6:()=>ty,ksuid:()=>J_,lowercase:()=>_y,mac:()=>ry,md5_base64:()=>AU,md5_base64url:()=>OU,md5_hex:()=>CU,nanoid:()=>K_,null:()=>hy,number:()=>Cf,rfc5322Email:()=>xU,sha1_base64:()=>NU,sha1_base64url:()=>RU,sha1_hex:()=>PU,sha256_base64:()=>jU,sha256_base64url:()=>DU,sha256_hex:()=>MU,sha384_base64:()=>UU,sha384_base64url:()=>LU,sha384_hex:()=>zU,sha512_base64:()=>BU,sha512_base64url:()=>VU,sha512_hex:()=>FU,string:()=>dy,time:()=>ly,ulid:()=>G_,undefined:()=>gy,unicodeEmail:()=>bT,uppercase:()=>yy,uuid:()=>go,uuid4:()=>yU,uuid6:()=>vU,uuid7:()=>bU,xid:()=>W_});var Z_=/^[cC][0-9a-z]{6,}$/,H_=/^[0-9a-z]+$/,G_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,W_=/^[0-9a-vA-V]{20}$/,J_=/^[A-Za-z0-9]{27}$/,K_=/^[a-zA-Z0-9_-]{21}$/,q_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,_U=/^[-+]?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)?)??$/,X_=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,go=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,yU=go(4),vU=go(6),bU=go(7),Y_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,wU=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,xU=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,bT=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,SU=bT,kU=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,$U="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Q_(){return new RegExp($U,"u")}var ey=/^(?:(?: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])$/,ty=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,ry=e=>{let t=Jr(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},ny=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,iy=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ay=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Tf=/^[A-Za-z0-9_-]*$/,EU=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,IU=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,oy=/^https?$/,sy=/^\+[1-9]\d{6,14}$/,wT="(?:(?:\\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])))",cy=new RegExp(`^${wT}$`);function xT(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ly(e){return new RegExp(`^${xT(e)}$`)}function uy(e){let t=xT({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${wT}T(?:${n})$`)}var dy=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},fy=/^-?\d+n?$/,py=/^-?\d+$/,Cf=/^-?\d+(?:\.\d+)?$/,my=/^(?:true|false)$/i,hy=/^null$/i;var gy=/^undefined$/i;var _y=/^[^A-Z]*$/,yy=/^[^a-z]*$/,TU=/^[0-9a-fA-F]*$/;function vl(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function bl(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var CU=/^[0-9a-fA-F]{32}$/,AU=vl(22,"=="),OU=bl(22),PU=/^[0-9a-fA-F]{40}$/,NU=vl(27,"="),RU=bl(27),MU=/^[0-9a-fA-F]{64}$/,jU=vl(43,"="),DU=bl(43),zU=/^[0-9a-fA-F]{96}$/,UU=vl(64,""),LU=bl(64),FU=/^[0-9a-fA-F]{128}$/,BU=vl(86,"=="),VU=bl(86);var Ze=k("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),kT={number:"number",bigint:"bigint",object:"date"},Af=k("$ZodCheckLessThan",(e,t)=>{Ze.init(e,t);let r=kT[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,a=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Of=k("$ZodCheckGreaterThan",(e,t)=>{Ze.init(e,t);let r=kT[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,a=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vy=k("$ZodCheckMultipleOf",(e,t)=>{Ze.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):O_(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),by=k("$ZodCheckNumberFormat",(e,t)=>{Ze.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,a]=D_[t.format];e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,s.minimum=i,s.maximum=a,r&&(s.pattern=py)}),e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s)){o.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),wy=k("$ZodCheckBigIntFormat",(e,t)=>{Ze.init(e,t);let[r,n]=z_[t.format];e._zod.onattach.push(i=>{let a=i._zod.bag;a.format=t.format,a.minimum=r,a.maximum=n}),e._zod.check=i=>{let a=i.value;a<r&&i.issues.push({origin:"bigint",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>n&&i.issues.push({origin:"bigint",input:a,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),xy=k("$ZodCheckMaxSize",(e,t)=>{var r;Ze.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!da(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;i.size<=t.maximum||n.issues.push({origin:ml(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Sy=k("$ZodCheckMinSize",(e,t)=>{var r;Ze.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!da(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;i.size>=t.minimum||n.issues.push({origin:ml(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),ky=k("$ZodCheckSizeEquals",(e,t)=>{var r;Ze.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!da(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.size,i.maximum=t.size,i.size=t.size}),e._zod.check=n=>{let i=n.value,a=i.size;if(a===t.size)return;let o=a>t.size;n.issues.push({origin:ml(i),...o?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$y=k("$ZodCheckMaxLength",(e,t)=>{var r;Ze.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!da(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;if(i.length<=t.maximum)return;let o=hl(i);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Ey=k("$ZodCheckMinLength",(e,t)=>{var r;Ze.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!da(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;if(i.length>=t.minimum)return;let o=hl(i);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Iy=k("$ZodCheckLengthEquals",(e,t)=>{var r;Ze.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!da(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=n=>{let i=n.value,a=i.length;if(a===t.length)return;let o=hl(i),s=a>t.length;n.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Cs=k("$ZodCheckStringFormat",(e,t)=>{var r,n;Ze.init(e,t),e._zod.onattach.push(i=>{let a=i._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Ty=k("$ZodCheckRegex",(e,t)=>{Cs.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Cy=k("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=_y),Cs.init(e,t)}),Ay=k("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=yy),Cs.init(e,t)}),Oy=k("$ZodCheckIncludes",(e,t)=>{Ze.init(e,t);let r=Jr(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(i=>{let a=i._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Py=k("$ZodCheckStartsWith",(e,t)=>{Ze.init(e,t);let r=new RegExp(`^${Jr(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ny=k("$ZodCheckEndsWith",(e,t)=>{Ze.init(e,t);let r=new RegExp(`.*${Jr(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function ST(e,t,r){e.issues.length&&t.issues.push(...br(r,e.issues))}var Ry=k("$ZodCheckProperty",(e,t)=>{Ze.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(i=>ST(i,r,t.property));ST(n,r,t.property)}}),My=k("$ZodCheckMimeType",(e,t)=>{Ze.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),jy=k("$ZodCheckOverwrite",(e,t)=>{Ze.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var wl=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
156
+ `).filter(o=>o),i=Math.min(...n.map(o=>o.length-o.trimStart().length)),a=n.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(let o of a)this.content.push(o)}compile(){let t=Function,r=this?.args,i=[...(this?.content??[""]).map(a=>` ${a}`)];return new t(...r,i.join(`
157
+ `))}};var Dy={major:4,minor:4,patch:3};var pe=k("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Dy;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let a of i._zod.onattach)a(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(o,s,c)=>{let l=ma(o),u;for(let d of s){if(d._zod.def.when){if(U_(o)||!d._zod.def.when(o))continue}else if(l)continue;let f=o.issues.length,p=d._zod.check(o);if(p instanceof Promise&&c?.async===!1)throw new fn;if(u||p instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await p,o.issues.length!==f&&(l||(l=ma(o,f)))});else{if(o.issues.length===f)continue;l||(l=ma(o,f))}}return u?u.then(()=>o):o},a=(o,s,c)=>{if(ma(o))return o.aborted=!0,o;let l=i(s,n,c);if(l instanceof Promise){if(c.async===!1)throw new fn;return l.then(u=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(o,s)=>{if(s.skipChecks)return e._zod.parse(o,s);if(s.direction==="backward"){let l=e._zod.parse({value:o.value,issues:[]},{...s,skipChecks:!0});return l instanceof Promise?l.then(u=>a(u,o,s)):a(l,o,s)}let c=e._zod.parse(o,s);if(c instanceof Promise){if(s.async===!1)throw new fn;return c.then(l=>i(l,n,s))}return i(c,n,s)}}$e(e,"~standard",()=>({validate:i=>{try{let a=B_(e,i);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return V_(e,i).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),_o=k("$ZodString",(e,t)=>{pe.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??dy(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Fe=k("$ZodStringFormat",(e,t)=>{Cs.init(e,t),_o.init(e,t)}),Uy=k("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=X_),Fe.init(e,t)}),Ly=k("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=go(n))}else t.pattern??(t.pattern=go());Fe.init(e,t)}),Fy=k("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Y_),Fe.init(e,t)}),By=k("$ZodURL",(e,t)=>{Fe.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===oy.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Vy=k("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Q_()),Fe.init(e,t)}),Zy=k("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=K_),Fe.init(e,t)}),Hy=k("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Z_),Fe.init(e,t)}),Gy=k("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=H_),Fe.init(e,t)}),Wy=k("$ZodULID",(e,t)=>{t.pattern??(t.pattern=G_),Fe.init(e,t)}),Jy=k("$ZodXID",(e,t)=>{t.pattern??(t.pattern=W_),Fe.init(e,t)}),Ky=k("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=J_),Fe.init(e,t)}),qy=k("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=uy(t)),Fe.init(e,t)}),Xy=k("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=cy),Fe.init(e,t)}),Yy=k("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ly(t)),Fe.init(e,t)}),Qy=k("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=q_),Fe.init(e,t)}),ev=k("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ey),Fe.init(e,t),e._zod.bag.format="ipv4"}),tv=k("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ty),Fe.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),rv=k("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=ry(t.delimiter)),Fe.init(e,t),e._zod.bag.format="mac"}),nv=k("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ny),Fe.init(e,t)}),iv=k("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=iy),Fe.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[i,a]=n;if(!a)throw new Error;let o=Number(a);if(`${o}`!==a)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function av(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ov=k("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ay),Fe.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{av(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function LT(e){if(!Tf.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return av(r)}var sv=k("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Tf),Fe.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{LT(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),cv=k("$ZodE164",(e,t)=>{t.pattern??(t.pattern=sy),Fe.init(e,t)});function FT(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var lv=k("$ZodJWT",(e,t)=>{Fe.init(e,t),e._zod.check=r=>{FT(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),uv=k("$ZodCustomStringFormat",(e,t)=>{Fe.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),jf=k("$ZodNumber",(e,t)=>{pe.init(e,t),e._zod.pattern=e._zod.bag.pattern??Cf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let a=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...a?{received:a}:{}}),r}}),dv=k("$ZodNumberFormat",(e,t)=>{by.init(e,t),jf.init(e,t)}),xl=k("$ZodBoolean",(e,t)=>{pe.init(e,t),e._zod.pattern=my,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),Df=k("$ZodBigInt",(e,t)=>{pe.init(e,t),e._zod.pattern=fy,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),fv=k("$ZodBigIntFormat",(e,t)=>{wy.init(e,t),Df.init(e,t)}),pv=k("$ZodSymbol",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:e}),r}}),mv=k("$ZodUndefined",(e,t)=>{pe.init(e,t),e._zod.pattern=gy,e._zod.values=new Set([void 0]),e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),r}}),hv=k("$ZodNull",(e,t)=>{pe.init(e,t),e._zod.pattern=hy,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),r}}),gv=k("$ZodAny",(e,t)=>{pe.init(e,t),e._zod.parse=r=>r}),Sl=k("$ZodUnknown",(e,t)=>{pe.init(e,t),e._zod.parse=r=>r}),kl=k("$ZodNever",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),_v=k("$ZodVoid",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),r}}),yv=k("$ZodDate",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let i=r.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...a?{received:"Invalid Date"}:{},inst:e}),r}});function ET(e,t,r){e.issues.length&&t.issues.push(...br(r,e.issues)),t.value[r]=e.value}var vv=k("$ZodArray",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let a=[];for(let o=0;o<i.length;o++){let s=i[o],c=t.element._zod.run({value:s,issues:[]},n);c instanceof Promise?a.push(c.then(l=>ET(l,r,o))):ET(c,r,o)}return a.length?Promise.all(a).then(()=>r):r}});function Mf(e,t,r,n,i,a){let o=r in n;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...br(r,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?o&&(t.value[r]=void 0):t.value[r]=e.value}function BT(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=j_(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function VT(e,t,r,n,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin==="optional",d=c.optout==="optional";for(let f in t){if(f==="__proto__"||s.has(f))continue;if(l==="never"){o.push(f);continue}let p=c.run({value:t[f],issues:[]},n);p instanceof Promise?e.push(p.then(m=>Mf(m,r,f,t,u,d))):Mf(p,r,f,t,u,d)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}var ZT=k("$ZodObject",(e,t)=>{if(pe.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let s=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}let n=Ss(()=>BT(t));$e(e._zod,"propValues",()=>{let s=t.shape,c={};for(let l in s){let u=s[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let d of u.values)c[l].add(d)}}return c});let i=mo,a=t.catchall,o;e._zod.parse=(s,c)=>{o??(o=n.value);let l=s.value;if(!i(l))return s.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),s;s.value={};let u=[],d=o.shape;for(let f of o.keys){let p=d[f],m=p._zod.optin==="optional",h=p._zod.optout==="optional",_=p._zod.run({value:l[f],issues:[]},c);_ instanceof Promise?u.push(_.then(y=>Mf(y,s,f,l,m,h))):Mf(_,s,f,l,m,h)}return a?VT(u,l,s,c,n.value,e):u.length?Promise.all(u).then(()=>s):s}}),bv=k("$ZodObjectJIT",(e,t)=>{ZT.init(e,t);let r=e._zod.parse,n=Ss(()=>BT(t)),i=f=>{let p=new wl(["shape","payload","ctx"]),m=n.value,h=x=>{let S=yf(x);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};p.write("const input = payload.value;");let _=Object.create(null),y=0;for(let x of m.keys)_[x]=`key_${y++}`;p.write("const newResult = {};");for(let x of m.keys){let S=_[x],$=yf(x),P=f[x],C=P?._zod?.optin==="optional",b=P?._zod?.optout==="optional";p.write(`const ${S} = ${h(x)};`),C&&b?p.write(`
158
+ if (${S}.issues.length) {
159
+ if (${$} in input) {
160
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
161
+ ...iss,
162
+ path: iss.path ? [${$}, ...iss.path] : [${$}]
163
+ })));
164
+ }
165
+ }
166
+
167
+ if (${S}.value === undefined) {
168
+ if (${$} in input) {
169
+ newResult[${$}] = undefined;
170
+ }
171
+ } else {
172
+ newResult[${$}] = ${S}.value;
173
+ }
174
+
175
+ `):C?p.write(`
176
+ if (${S}.issues.length) {
177
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
178
+ ...iss,
179
+ path: iss.path ? [${$}, ...iss.path] : [${$}]
180
+ })));
181
+ }
182
+
183
+ if (${S}.value === undefined) {
184
+ if (${$} in input) {
185
+ newResult[${$}] = undefined;
186
+ }
187
+ } else {
188
+ newResult[${$}] = ${S}.value;
189
+ }
190
+
191
+ `):p.write(`
192
+ const ${S}_present = ${$} in input;
193
+ if (${S}.issues.length) {
194
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
195
+ ...iss,
196
+ path: iss.path ? [${$}, ...iss.path] : [${$}]
197
+ })));
198
+ }
199
+ if (!${S}_present && !${S}.issues.length) {
200
+ payload.issues.push({
201
+ code: "invalid_type",
202
+ expected: "nonoptional",
203
+ input: undefined,
204
+ path: [${$}]
205
+ });
206
+ }
207
+
208
+ if (${S}_present) {
209
+ if (${S}.value === undefined) {
210
+ newResult[${$}] = undefined;
211
+ } else {
212
+ newResult[${$}] = ${S}.value;
213
+ }
214
+ }
215
+
216
+ `)}p.write("payload.value = newResult;"),p.write("return payload;");let w=p.compile();return(x,S)=>w(f,x,S)},a,o=mo,s=!po.jitless,l=s&&N_.value,u=t.catchall,d;e._zod.parse=(f,p)=>{d??(d=n.value);let m=f.value;return o(m)?s&&l&&p?.async===!1&&p.jitless!==!0?(a||(a=i(t.shape)),f=a(f,p),u?VT([],m,f,p,d,e):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),f)}});function IT(e,t,r,n){for(let a of e)if(a.issues.length===0)return t.value=a.value,t;let i=e.filter(a=>!ma(a));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(a=>a.issues.map(o=>ur(o,n,ct())))}),t)}var $l=k("$ZodUnion",(e,t)=>{pe.init(e,t),$e(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),$e(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),$e(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),$e(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){let n=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${n.map(i=>fl(i.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let a=!1,o=[];for(let s of t.options){let c=s._zod.run({value:n.value,issues:[]},i);if(c instanceof Promise)o.push(c),a=!0;else{if(c.issues.length===0)return c;o.push(c)}}return a?Promise.all(o).then(s=>IT(s,n,e,i)):IT(o,n,e,i)}});function TT(e,t,r,n){let i=e.filter(a=>a.issues.length===0);return i.length===1?(t.value=i[0].value,t):(i.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(a=>a.issues.map(o=>ur(o,n,ct())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var wv=k("$ZodXor",(e,t)=>{$l.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let a=!1,o=[];for(let s of t.options){let c=s._zod.run({value:n.value,issues:[]},i);c instanceof Promise?(o.push(c),a=!0):o.push(c)}return a?Promise.all(o).then(s=>TT(s,n,e,i)):TT(o,n,e,i)}}),xv=k("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,$l.init(e,t);let r=e._zod.parse;$e(e._zod,"propValues",()=>{let i={};for(let a of t.options){let o=a._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let[s,c]of Object.entries(o)){i[s]||(i[s]=new Set);for(let l of c)i[s].add(l)}}return i});let n=Ss(()=>{let i=t.options,a=new Map;for(let o of i){let s=o._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let c of s){if(a.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);a.set(c,o)}}return a});e._zod.parse=(i,a)=>{let o=i.value;if(!mo(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),i;let s=n.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction==="backward"?r(i,a):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Sv=k("$ZodIntersection",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,a=t.left._zod.run({value:i,issues:[]},n),o=t.right._zod.run({value:i,issues:[]},n);return a instanceof Promise||o instanceof Promise?Promise.all([a,o]).then(([c,l])=>CT(r,c,l)):CT(r,a,o)}});function zy(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(pa(e)&&pa(t)){let r=Object.keys(t),n=Object.keys(e).filter(a=>r.indexOf(a)!==-1),i={...e,...t};for(let a of n){let o=zy(e[a],t[a]);if(!o.valid)return{valid:!1,mergeErrorPath:[a,...o.mergeErrorPath]};i[a]=o.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],a=t[n],o=zy(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function CT(e,t,r){let n=new Map,i;for(let s of t.issues)if(s.code==="unrecognized_keys"){i??(i=s);for(let c of s.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(s);for(let s of r.issues)if(s.code==="unrecognized_keys")for(let c of s.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(s);let a=[...n].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(a.length&&i&&e.issues.push({...i,keys:a}),ma(e))return e;let o=zy(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var zf=k("$ZodTuple",(e,t)=>{pe.init(e,t);let r=t.items;e._zod.parse=(n,i)=>{let a=n.value;if(!Array.isArray(a))return n.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let o=[],s=AT(r,"optin"),c=AT(r,"optout");if(!t.rest){if(a.length<s)return n.issues.push({code:"too_small",minimum:s,inclusive:!0,input:a,inst:e,origin:"array"}),n;a.length>r.length&&n.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:a,inst:e,origin:"array"})}let l=new Array(r.length);for(let u=0;u<r.length;u++){let d=r[u]._zod.run({value:a[u],issues:[]},i);d instanceof Promise?o.push(d.then(f=>{l[u]=f})):l[u]=d}if(t.rest){let u=r.length-1,d=a.slice(r.length);for(let f of d){u++;let p=t.rest._zod.run({value:f,issues:[]},i);p instanceof Promise?o.push(p.then(m=>OT(m,n,u))):OT(p,n,u)}}return o.length?Promise.all(o).then(()=>PT(l,n,r,a,c)):PT(l,n,r,a,c)}});function AT(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function OT(e,t,r){e.issues.length&&t.issues.push(...br(r,e.issues)),t.value[r]=e.value}function PT(e,t,r,n,i){for(let a=0;a<r.length;a++){let o=e[a],s=a<n.length;if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...br(a,o.issues))}t.value[a]=o.value}for(let a=t.value.length-1;a>=n.length&&(r[a]._zod.optout==="optional"&&t.value[a]===void 0);a--)t.value.length=a;return t}var kv=k("$ZodRecord",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!pa(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let a=[],o=t.keyType._zod.values;if(o){r.value={};let s=new Set;for(let l of o)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){s.add(typeof l=="number"?l.toString():l);let u=t.keyType._zod.run({value:l,issues:[]},n);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>ur(p,n,ct())),input:l,path:[l],inst:e});continue}let d=u.value,f=t.valueType._zod.run({value:i[l],issues:[]},n);f instanceof Promise?a.push(f.then(p=>{p.issues.length&&r.issues.push(...br(l,p.issues)),r.value[d]=p.value})):(f.issues.length&&r.issues.push(...br(l,f.issues)),r.value[d]=f.value)}let c;for(let l in i)s.has(l)||(c=c??[],c.push(l));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{r.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,s))continue;let c=t.keyType._zod.run({value:s,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&Cf.test(s)&&c.issues.length){let d=t.keyType._zod.run({value:Number(s),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[s]=i[s]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>ur(d,n,ct())),input:s,path:[s],inst:e});continue}let u=t.valueType._zod.run({value:i[s],issues:[]},n);u instanceof Promise?a.push(u.then(d=>{d.issues.length&&r.issues.push(...br(s,d.issues)),r.value[c.value]=d.value})):(u.issues.length&&r.issues.push(...br(s,u.issues)),r.value[c.value]=u.value)}}return a.length?Promise.all(a).then(()=>r):r}}),$v=k("$ZodMap",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),r;let a=[];r.value=new Map;for(let[o,s]of i){let c=t.keyType._zod.run({value:o,issues:[]},n),l=t.valueType._zod.run({value:s,issues:[]},n);c instanceof Promise||l instanceof Promise?a.push(Promise.all([c,l]).then(([u,d])=>{NT(u,d,r,o,i,e,n)})):NT(c,l,r,o,i,e,n)}return a.length?Promise.all(a).then(()=>r):r}});function NT(e,t,r,n,i,a,o){e.issues.length&&(pl.has(typeof n)?r.issues.push(...br(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:i,inst:a,issues:e.issues.map(s=>ur(s,o,ct()))})),t.issues.length&&(pl.has(typeof n)?r.issues.push(...br(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:i,inst:a,key:n,issues:t.issues.map(s=>ur(s,o,ct()))})),r.value.set(e.value,t.value)}var Ev=k("$ZodSet",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),r;let a=[];r.value=new Set;for(let o of i){let s=t.valueType._zod.run({value:o,issues:[]},n);s instanceof Promise?a.push(s.then(c=>RT(c,r))):RT(s,r)}return a.length?Promise.all(a).then(()=>r):r}});function RT(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Iv=k("$ZodEnum",(e,t)=>{pe.init(e,t);let r=dl(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(i=>pl.has(typeof i)).map(i=>typeof i=="string"?Jr(i):i.toString()).join("|")})$`),e._zod.parse=(i,a)=>{let o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:r,input:o,inst:e}),i}}),Tv=k("$ZodLiteral",(e,t)=>{if(pe.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?Jr(n):n?Jr(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,i)=>{let a=n.value;return r.has(a)||n.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),n}}),Cv=k("$ZodFile",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return i instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),r}}),Av=k("$ZodTransform",(e,t)=>{pe.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ua(e.constructor.name);let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(r.value=o,r.fallback=!0,r));if(i instanceof Promise)throw new fn;return r.value=i,r.fallback=!0,r}});function MT(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var yo=k("$ZodOptional",(e,t)=>{pe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",$e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),$e(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${fl(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=r.value,a=t.innerType._zod.run(r,n);return a instanceof Promise?a.then(o=>MT(o,i)):MT(a,i)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Ov=k("$ZodExactOptional",(e,t)=>{yo.init(e,t),$e(e._zod,"values",()=>t.innerType._zod.values),$e(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Pv=k("$ZodNullable",(e,t)=>{pe.init(e,t),$e(e._zod,"optin",()=>t.innerType._zod.optin),$e(e._zod,"optout",()=>t.innerType._zod.optout),$e(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${fl(r.source)}|null)$`):void 0}),$e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Nv=k("$ZodDefault",(e,t)=>{pe.init(e,t),e._zod.optin="optional",$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(a=>jT(a,t)):jT(i,t)}});function jT(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Rv=k("$ZodPrefault",(e,t)=>{pe.init(e,t),e._zod.optin="optional",$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Mv=k("$ZodNonOptional",(e,t)=>{pe.init(e,t),$e(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(a=>DT(a,e)):DT(i,e)}});function DT(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var jv=k("$ZodSuccess",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ua("ZodSuccess");let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(a=>(r.value=a.issues.length===0,r)):(r.value=i.issues.length===0,r)}}),Dv=k("$ZodCatch",(e,t)=>{pe.init(e,t),e._zod.optin="optional",$e(e._zod,"optout",()=>t.innerType._zod.optout),$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(a=>(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(o=>ur(o,n,ct()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>ur(a,n,ct()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),zv=k("$ZodNaN",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),Uf=k("$ZodPipe",(e,t)=>{pe.init(e,t),$e(e._zod,"values",()=>t.in._zod.values),$e(e._zod,"optin",()=>t.in._zod.optin),$e(e._zod,"optout",()=>t.out._zod.optout),$e(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let a=t.out._zod.run(r,n);return a instanceof Promise?a.then(o=>Pf(o,t.in,n)):Pf(a,t.in,n)}let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(a=>Pf(a,t.out,n)):Pf(i,t.out,n)}});function Pf(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var El=k("$ZodCodec",(e,t)=>{pe.init(e,t),$e(e._zod,"values",()=>t.in._zod.values),$e(e._zod,"optin",()=>t.in._zod.optin),$e(e._zod,"optout",()=>t.out._zod.optout),$e(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let a=t.in._zod.run(r,n);return a instanceof Promise?a.then(o=>Nf(o,t,n)):Nf(a,t,n)}else{let a=t.out._zod.run(r,n);return a instanceof Promise?a.then(o=>Nf(o,t,n)):Nf(a,t,n)}}});function Nf(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let i=t.transform(e.value,e);return i instanceof Promise?i.then(a=>Rf(e,a,t.out,r)):Rf(e,i,t.out,r)}else{let i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(a=>Rf(e,a,t.in,r)):Rf(e,i,t.in,r)}}function Rf(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}var Uv=k("$ZodPreprocess",(e,t)=>{Uf.init(e,t)}),Lv=k("$ZodReadonly",(e,t)=>{pe.init(e,t),$e(e._zod,"propValues",()=>t.innerType._zod.propValues),$e(e._zod,"values",()=>t.innerType._zod.values),$e(e._zod,"optin",()=>t.innerType?._zod?.optin),$e(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(zT):zT(i)}});function zT(e){return e.value=Object.freeze(e.value),e}var Fv=k("$ZodTemplateLiteral",(e,t)=>{pe.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let i=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!i)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let a=i.startsWith("^")?1:0,o=i.endsWith("$")?i.length-1:i.length;r.push(i.slice(a,o))}else if(n===null||M_.has(typeof n))r.push(Jr(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,i)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),Bv=k("$ZodFunction",(e,t)=>(pe.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...n){let i=e._def.input?ha(e._def.input,n):n,a=Reflect.apply(r,this,i);return e._def.output?ha(e._def.output,a):a}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let i=e._def.input?await ho(e._def.input,n):n,a=await Reflect.apply(r,this,i);return e._def.output?await ho(e._def.output,a):a}},e._zod.parse=(r,n)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new zf({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),Vv=k("$ZodPromise",(e,t)=>{pe.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(i=>t.innerType._zod.run({value:i,issues:[]},n))}),Zv=k("$ZodLazy",(e,t)=>{pe.init(e,t),$e(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),$e(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),$e(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),$e(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),$e(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),Hv=k("$ZodCustom",(e,t)=>{Ze.init(e,t),pe.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(a=>UT(a,r,n,e));UT(i,r,n,e)}});function UT(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(ks(i))}}var Tl={};An(Tl,{ar:()=>HT,az:()=>GT,be:()=>JT,bg:()=>KT,ca:()=>qT,cs:()=>XT,da:()=>YT,de:()=>QT,el:()=>eC,en:()=>Lf,eo:()=>tC,es:()=>rC,fa:()=>nC,fi:()=>iC,fr:()=>aC,frCA:()=>oC,he:()=>sC,hr:()=>cC,hu:()=>lC,hy:()=>dC,id:()=>fC,is:()=>pC,it:()=>mC,ja:()=>hC,ka:()=>gC,kh:()=>_C,km:()=>Ff,ko:()=>yC,lt:()=>bC,mk:()=>wC,ms:()=>xC,nl:()=>SC,no:()=>kC,ota:()=>$C,pl:()=>IC,ps:()=>EC,pt:()=>TC,ro:()=>CC,ru:()=>OC,sl:()=>PC,sv:()=>NC,ta:()=>RC,th:()=>MC,tr:()=>jC,ua:()=>DC,uk:()=>Bf,ur:()=>zC,uz:()=>UC,vi:()=>LC,yo:()=>VC,zhCN:()=>FC,zhTW:()=>BC});var HU=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(i){return e[i]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${i.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${a}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`}case"invalid_value":return i.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${R(i.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${a} ${i.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${a} ${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${a} ${i.minimum.toString()} ${o.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${a} ${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${i.prefix}"`:a.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${a.suffix}"`:a.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${a.includes}"`:a.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${a.pattern}`:`${r[a.format]??i.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${i.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${i.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${i.keys.length>1?"\u0629":""}: ${I(i.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${i.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${i.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function HT(){return{localeError:HU()}}var GU=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(i){return e[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${i.expected}, daxil olan ${s}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${a}, daxil olan ${s}`}case"invalid_value":return i.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${R(i.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${a}${i.maximum.toString()} ${o.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${a}${i.minimum.toString()} ${o.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${a.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:a.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${a.suffix}" il\u0259 bitm\u0259lidir`:a.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${a.includes}" daxil olmal\u0131d\u0131r`:a.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${a.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[a.format]??i.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${i.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${i.keys.length>1?"lar":""}: ${I(i.keys,", ")}`;case"invalid_key":return`${i.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${i.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function GT(){return{localeError:GU()}}function WT(e,t,r,n){let i=Math.abs(e),a=i%10,o=i%100;return o>=11&&o<=19?n:a===1?t:a>=2&&a<=4?r:n}var WU=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(i){return e[i]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},n={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${i.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${a}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`}case"invalid_value":return i.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${R(i.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);if(o){let s=Number(i.maximum),c=WT(s,o.unit.one,o.unit.few,o.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${o.verb} ${a}${i.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);if(o){let s=Number(i.minimum),c=WT(s,o.unit.one,o.unit.few,o.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${o.verb} ${a}${i.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${a.includes}"`:a.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[a.format]??i.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${i.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${I(i.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${i.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${i.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function JT(){return{localeError:WU()}}var JU=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(i){return e[i]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${i.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${a}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${R(i.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${a}${i.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${a}${i.minimum.toString()} ${o.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;if(a.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${a.prefix}"`;if(a.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${a.suffix}"`;if(a.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${a.includes}"`;if(a.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${a.pattern}`;let o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return a.format==="emoji"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="datetime"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="date"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),a.format==="time"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="duration"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${o} ${r[a.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${i.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u043E\u0432\u0435":""}: ${I(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${i.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function KT(){return{localeError:JU()}}var KU=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(i){return e[i]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${i.expected}, s'ha rebut ${s}`:`Tipus inv\xE0lid: s'esperava ${a}, s'ha rebut ${s}`}case"invalid_value":return i.values.length===1?`Valor inv\xE0lid: s'esperava ${R(i.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${I(i.values," o ")}`;case"too_big":{let a=i.inclusive?"com a m\xE0xim":"menys de",o=t(i.origin);return o?`Massa gran: s'esperava que ${i.origin??"el valor"} contingu\xE9s ${a} ${i.maximum.toString()} ${o.unit??"elements"}`:`Massa gran: s'esperava que ${i.origin??"el valor"} fos ${a} ${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?"com a m\xEDnim":"m\xE9s de",o=t(i.origin);return o?`Massa petit: s'esperava que ${i.origin} contingu\xE9s ${a} ${i.minimum.toString()} ${o.unit}`:`Massa petit: s'esperava que ${i.origin} fos ${a} ${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${a.prefix}"`:a.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${a.suffix}"`:a.format==="includes"?`Format inv\xE0lid: ha d'incloure "${a.includes}"`:a.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${a.pattern}`:`Format inv\xE0lid per a ${r[a.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${i.divisor}`;case"unrecognized_keys":return`Clau${i.keys.length>1?"s":""} no reconeguda${i.keys.length>1?"s":""}: ${I(i.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${i.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${i.origin}`;default:return"Entrada inv\xE0lida"}}};function qT(){return{localeError:KU()}}var qU=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(i){return e[i]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},n={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${i.expected}, obdr\u017Eeno ${s}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${a}, obdr\u017Eeno ${s}`}case"invalid_value":return i.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${R(i.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${a}${i.maximum.toString()} ${o.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${a}${i.minimum.toString()} ${o.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${a.prefix}"`:a.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${a.suffix}"`:a.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${a.includes}"`:a.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${a.pattern}`:`Neplatn\xFD form\xE1t ${r[a.format]??i.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${i.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${I(i.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${i.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${i.origin}`;default:return"Neplatn\xFD vstup"}}};function XT(){return{localeError:qU()}}var XU=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(i){return e[i]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},n={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ugyldigt input: forventede instanceof ${i.expected}, fik ${s}`:`Ugyldigt input: forventede ${a}, fik ${s}`}case"invalid_value":return i.values.length===1?`Ugyldig v\xE6rdi: forventede ${R(i.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin),s=n[i.origin]??i.origin;return o?`For stor: forventede ${s??"value"} ${o.verb} ${a} ${i.maximum.toString()} ${o.unit??"elementer"}`:`For stor: forventede ${s??"value"} havde ${a} ${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin),s=n[i.origin]??i.origin;return o?`For lille: forventede ${s} ${o.verb} ${a} ${i.minimum.toString()} ${o.unit}`:`For lille: forventede ${s} havde ${a} ${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Ugyldig streng: skal starte med "${a.prefix}"`:a.format==="ends_with"?`Ugyldig streng: skal ende med "${a.suffix}"`:a.format==="includes"?`Ugyldig streng: skal indeholde "${a.includes}"`:a.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${a.pattern}`:`Ugyldig ${r[a.format]??i.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${I(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${i.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${i.origin}`;default:return"Ugyldigt input"}}};function YT(){return{localeError:XU()}}var YU=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(i){return e[i]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},n={nan:"NaN",number:"Zahl",array:"Array"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${i.expected}, erhalten ${s}`:`Ung\xFCltige Eingabe: erwartet ${a}, erhalten ${s}`}case"invalid_value":return i.values.length===1?`Ung\xFCltige Eingabe: erwartet ${R(i.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${a}${i.maximum.toString()} ${o.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${a}${i.maximum.toString()} ist`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Zu klein: erwartet, dass ${i.origin} ${a}${i.minimum.toString()} ${o.unit} hat`:`Zu klein: erwartet, dass ${i.origin} ${a}${i.minimum.toString()} ist`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Ung\xFCltiger String: muss mit "${a.prefix}" beginnen`:a.format==="ends_with"?`Ung\xFCltiger String: muss mit "${a.suffix}" enden`:a.format==="includes"?`Ung\xFCltiger String: muss "${a.includes}" enthalten`:a.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${a.pattern} entsprechen`:`Ung\xFCltig: ${r[a.format]??i.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${i.divisor} sein`;case"unrecognized_keys":return`${i.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${I(i.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${i.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${i.origin}`;default:return"Ung\xFCltige Eingabe"}}};function QT(){return{localeError:YU()}}var QU=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(i){return e[i]??null}let r={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return typeof i.expected=="string"&&/^[A-Z]/.test(i.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${i.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${a}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`}case"invalid_value":return i.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${R(i.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${a}${i.maximum.toString()} ${o.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${a}${i.minimum.toString()} ${o.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${a.prefix}"`:a.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${a.suffix}"`:a.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${a.includes}"`:a.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${a.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[a.format]??i.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${i.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${i.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${i.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${I(i.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${i.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${i.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function eC(){return{localeError:QU()}}var e2=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return`Invalid input: expected ${a}, received ${s}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${R(i.values[0])}`:`Invalid option: expected one of ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Too big: expected ${i.origin??"value"} to have ${a}${i.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Too small: expected ${i.origin} to have ${a}${i.minimum.toString()} ${o.unit}`:`Too small: expected ${i.origin} to be ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Invalid string: must start with "${a.prefix}"`:a.format==="ends_with"?`Invalid string: must end with "${a.suffix}"`:a.format==="includes"?`Invalid string: must include "${a.includes}"`:a.format==="regex"?`Invalid string: must match pattern ${a.pattern}`:`Invalid ${r[a.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${I(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(o=>`'${o}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Lf(){return{localeError:e2()}}var t2=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(i){return e[i]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},n={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${i.expected}, ricevi\u011Dis ${s}`:`Nevalida enigo: atendi\u011Dis ${a}, ricevi\u011Dis ${s}`}case"invalid_value":return i.values.length===1?`Nevalida enigo: atendi\u011Dis ${R(i.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${a}${i.maximum.toString()} ${o.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Tro malgranda: atendi\u011Dis ke ${i.origin} havu ${a}${i.minimum.toString()} ${o.unit}`:`Tro malgranda: atendi\u011Dis ke ${i.origin} estu ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${a.prefix}"`:a.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${a.suffix}"`:a.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${a.includes}"`:a.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${a.pattern}`:`Nevalida ${r[a.format]??i.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${i.divisor}`;case"unrecognized_keys":return`Nekonata${i.keys.length>1?"j":""} \u015Dlosilo${i.keys.length>1?"j":""}: ${I(i.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${i.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${i.origin}`;default:return"Nevalida enigo"}}};function tC(){return{localeError:t2()}}var r2=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(i){return e[i]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${i.expected}, recibido ${s}`:`Entrada inv\xE1lida: se esperaba ${a}, recibido ${s}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: se esperaba ${R(i.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin),s=n[i.origin]??i.origin;return o?`Demasiado grande: se esperaba que ${s??"valor"} tuviera ${a}${i.maximum.toString()} ${o.unit??"elementos"}`:`Demasiado grande: se esperaba que ${s??"valor"} fuera ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin),s=n[i.origin]??i.origin;return o?`Demasiado peque\xF1o: se esperaba que ${s} tuviera ${a}${i.minimum.toString()} ${o.unit}`:`Demasiado peque\xF1o: se esperaba que ${s} fuera ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${a.prefix}"`:a.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${a.suffix}"`:a.format==="includes"?`Cadena inv\xE1lida: debe incluir "${a.includes}"`:a.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${a.pattern}`:`Inv\xE1lido ${r[a.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Llave${i.keys.length>1?"s":""} desconocida${i.keys.length>1?"s":""}: ${I(i.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${n[i.origin]??i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${n[i.origin]??i.origin}`;default:return"Entrada inv\xE1lida"}}};function rC(){return{localeError:r2()}}var n2=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(i){return e[i]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${i.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${a} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return i.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${R(i.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${I(i.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${a}${i.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${a}${i.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${a}${i.minimum.toString()} ${o.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${a}${i.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${a.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:a.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${a.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:a.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${a.includes}" \u0628\u0627\u0634\u062F`:a.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${a.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[a.format]??i.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${i.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${i.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${I(i.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${i.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${i.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function nC(){return{localeError:n2()}}var i2=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(i){return e[i]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Virheellinen tyyppi: odotettiin instanceof ${i.expected}, oli ${s}`:`Virheellinen tyyppi: odotettiin ${a}, oli ${s}`}case"invalid_value":return i.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${R(i.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Liian suuri: ${o.subject} t\xE4ytyy olla ${a}${i.maximum.toString()} ${o.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Liian pieni: ${o.subject} t\xE4ytyy olla ${a}${i.minimum.toString()} ${o.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${a.prefix}"`:a.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${a.suffix}"`:a.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${a.includes}"`:a.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${a.pattern}`:`Virheellinen ${r[a.format]??i.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${i.divisor} monikerta`;case"unrecognized_keys":return`${i.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${I(i.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function iC(){return{localeError:i2()}}var a2=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(i){return e[i]??null}let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},n={string:"cha\xEEne",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"enregistrement",map:"carte",set:"ensemble",file:"fichier",nonoptional:"non-optionnel",nan:"NaN",function:"fonction"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : instanceof ${i.expected} attendu, ${s} re\xE7u`:`Entr\xE9e invalide : ${a} attendu, ${s} re\xE7u`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : ${R(i.values[0])} attendu`:`Option invalide : une valeur parmi ${I(i.values,"|")} attendue`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Trop grand : ${n[i.origin]??"valeur"} doit ${o.verb} ${a}${i.maximum.toString()} ${o.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${n[i.origin]??"valeur"} doit \xEAtre ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Trop petit : ${n[i.origin]??"valeur"} doit ${o.verb} ${a}${i.minimum.toString()} ${o.unit}`:`Trop petit : ${n[i.origin]??"valeur"} doit \xEAtre ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${a.prefix}"`:a.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${a.suffix}"`:a.format==="includes"?`Cha\xEEne invalide : doit inclure "${a.includes}"`:a.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${a.pattern}`:`${r[a.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${I(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}};function aC(){return{localeError:a2()}}var o2=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(i){return e[i]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : attendu instanceof ${i.expected}, re\xE7u ${s}`:`Entr\xE9e invalide : attendu ${a}, re\xE7u ${s}`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : attendu ${R(i.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"\u2264":"<",o=t(i.origin);return o?`Trop grand : attendu que ${i.origin??"la valeur"} ait ${a}${i.maximum.toString()} ${o.unit}`:`Trop grand : attendu que ${i.origin??"la valeur"} soit ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?"\u2265":">",o=t(i.origin);return o?`Trop petit : attendu que ${i.origin} ait ${a}${i.minimum.toString()} ${o.unit}`:`Trop petit : attendu que ${i.origin} soit ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${a.prefix}"`:a.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${a.suffix}"`:a.format==="includes"?`Cha\xEEne invalide : doit inclure "${a.includes}"`:a.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${a.pattern}`:`${r[a.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${I(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}};function oC(){return{localeError:o2()}}var s2=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=l=>l?e[l]:void 0,n=l=>{let u=r(l);return u?u.label:l??e.unknown.label},i=l=>`\u05D4${n(l)}`,a=l=>(r(l)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",o=l=>l?t[l]??null:null,s={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return l=>{switch(l.code){case"invalid_type":{let u=l.expected,d=c[u??""]??n(u),f=M(l.input),p=c[f]??e[f]?.label??f;return/^[A-Z]/.test(l.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${l.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${p}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${p}`}case"invalid_value":{if(l.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${R(l.values[0])}`;let u=l.values.map(p=>R(p));if(l.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u[0]} \u05D0\u05D5 ${u[1]}`;let d=u[u.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let u=o(l.origin),d=i(l.origin??"value");if(l.origin==="string")return`${u?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.maximum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(l.origin==="number"){let m=l.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${l.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(l.origin==="array"||l.origin==="set"){let m=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=l.inclusive?`${l.maximum} ${u?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${l.maximum} ${u?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let f=l.inclusive?"<=":"<",p=a(l.origin??"value");return u?.unit?`${u.longLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.maximum.toString()} ${u.unit}`:`${u?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.maximum.toString()}`}case"too_small":{let u=o(l.origin),d=i(l.origin??"value");if(l.origin==="string")return`${u?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.minimum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(l.origin==="number"){let m=l.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${l.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(l.origin==="array"||l.origin==="set"){let m=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(l.minimum===1&&l.inclusive){let _=(l.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${_}`}let h=l.inclusive?`${l.minimum} ${u?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${l.minimum} ${u?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let f=l.inclusive?">=":">",p=a(l.origin??"value");return u?.unit?`${u.shortLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.minimum.toString()} ${u.unit}`:`${u?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${l.minimum.toString()}`}case"invalid_format":{let u=l;if(u.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${u.prefix}"`;if(u.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${u.suffix}"`;if(u.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${u.includes}"`;if(u.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${u.pattern}`;let d=s[u.format],f=d?.label??u.format,m=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${f} \u05DC\u05D0 ${m}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${l.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${l.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${l.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${I(l.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${i(l.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function sC(){return{localeError:s2()}}var c2=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(i){return e[i]??null}let r={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",jwt:"JWT",template_literal:"unos"},n={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${i.expected}, a primljeno je ${s}`:`Neispravan unos: o\u010Dekuje se ${a}, a primljeno je ${s}`}case"invalid_value":return i.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${R(i.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin),s=n[i.origin]??i.origin;return o?`Preveliko: o\u010Dekivano da ${s??"vrijednost"} ima ${a}${i.maximum.toString()} ${o.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${s??"vrijednost"} bude ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin),s=n[i.origin]??i.origin;return o?`Premalo: o\u010Dekivano da ${s} ima ${a}${i.minimum.toString()} ${o.unit}`:`Premalo: o\u010Dekivano da ${s} bude ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${a.prefix}"`:a.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${a.suffix}"`:a.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${a.includes}"`:a.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${a.pattern}`:`Neispravna ${r[a.format]??i.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${i.divisor}`;case"unrecognized_keys":return`Neprepoznat${i.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${I(i.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${n[i.origin]??i.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${n[i.origin]??i.origin}`;default:return"Neispravan unos"}}};function cC(){return{localeError:c2()}}var l2=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(i){return e[i]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},n={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${i.expected}, a kapott \xE9rt\xE9k ${s}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${a}, a kapott \xE9rt\xE9k ${s}`}case"invalid_value":return i.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${R(i.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`T\xFAl nagy: ${i.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${a}${i.maximum.toString()} ${o.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${i.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} m\xE9rete t\xFAl kicsi ${a}${i.minimum.toString()} ${o.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} t\xFAl kicsi ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\xC9rv\xE9nytelen string: "${a.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:a.format==="ends_with"?`\xC9rv\xE9nytelen string: "${a.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:a.format==="includes"?`\xC9rv\xE9nytelen string: "${a.includes}" \xE9rt\xE9ket kell tartalmaznia`:a.format==="regex"?`\xC9rv\xE9nytelen string: ${a.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[a.format]??i.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${i.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${i.keys.length>1?"s":""}: ${I(i.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${i.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${i.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function lC(){return{localeError:l2()}}function uC(e,t,r){return Math.abs(e)===1?t:r}function As(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=e[e.length-1];return e+(t.includes(r)?"\u0576":"\u0568")}var u2=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(i){return e[i]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},n={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${i.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${a}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`}case"invalid_value":return i.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${R(i.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);if(o){let s=Number(i.maximum),c=uC(s,o.unit.one,o.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${As(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${a}${i.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${As(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);if(o){let s=Number(i.minimum),c=uC(s,o.unit.one,o.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${As(i.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${a}${i.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${As(i.origin)} \u056C\u056B\u0576\u056B ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${a.prefix}"-\u0578\u057E`:a.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${a.suffix}"-\u0578\u057E`:a.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${a.includes}"`:a.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${a.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[a.format]??i.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${i.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${i.keys.length>1?"\u0576\u0565\u0580":""}. ${I(i.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${As(i.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${As(i.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function dC(){return{localeError:u2()}}var d2=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(i){return e[i]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Input tidak valid: diharapkan instanceof ${i.expected}, diterima ${s}`:`Input tidak valid: diharapkan ${a}, diterima ${s}`}case"invalid_value":return i.values.length===1?`Input tidak valid: diharapkan ${R(i.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Terlalu besar: diharapkan ${i.origin??"value"} memiliki ${a}${i.maximum.toString()} ${o.unit??"elemen"}`:`Terlalu besar: diharapkan ${i.origin??"value"} menjadi ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Terlalu kecil: diharapkan ${i.origin} memiliki ${a}${i.minimum.toString()} ${o.unit}`:`Terlalu kecil: diharapkan ${i.origin} menjadi ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`String tidak valid: harus dimulai dengan "${a.prefix}"`:a.format==="ends_with"?`String tidak valid: harus berakhir dengan "${a.suffix}"`:a.format==="includes"?`String tidak valid: harus menyertakan "${a.includes}"`:a.format==="regex"?`String tidak valid: harus sesuai pola ${a.pattern}`:`${r[a.format]??i.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${i.keys.length>1?"s":""}: ${I(i.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${i.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${i.origin}`;default:return"Input tidak valid"}}};function fC(){return{localeError:d2()}}var f2=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(i){return e[i]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},n={nan:"NaN",number:"n\xFAmer",array:"fylki"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera instanceof ${i.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera ${a}`}case"invalid_value":return i.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${R(i.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} hafi ${a}${i.maximum.toString()} ${o.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} s\xE9 ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} hafi ${a}${i.minimum.toString()} ${o.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} s\xE9 ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${a.prefix}"`:a.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${a.suffix}"`:a.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${a.includes}"`:a.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${a.pattern}`:`Rangt ${r[a.format]??i.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${i.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${i.keys.length>1?"ir lyklar":"ur lykill"}: ${I(i.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${i.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${i.origin}`;default:return"Rangt gildi"}}};function pC(){return{localeError:f2()}}var p2=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(i){return e[i]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"numero",array:"vettore"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Input non valido: atteso instanceof ${i.expected}, ricevuto ${s}`:`Input non valido: atteso ${a}, ricevuto ${s}`}case"invalid_value":return i.values.length===1?`Input non valido: atteso ${R(i.values[0])}`:`Opzione non valida: atteso uno tra ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Troppo grande: ${i.origin??"valore"} deve avere ${a}${i.maximum.toString()} ${o.unit??"elementi"}`:`Troppo grande: ${i.origin??"valore"} deve essere ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Troppo piccolo: ${i.origin} deve avere ${a}${i.minimum.toString()} ${o.unit}`:`Troppo piccolo: ${i.origin} deve essere ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Stringa non valida: deve iniziare con "${a.prefix}"`:a.format==="ends_with"?`Stringa non valida: deve terminare con "${a.suffix}"`:a.format==="includes"?`Stringa non valida: deve includere "${a.includes}"`:a.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${a.pattern}`:`Input non valido: ${r[a.format]??i.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${i.divisor}`;case"unrecognized_keys":return`Chiav${i.keys.length>1?"i":"e"} non riconosciut${i.keys.length>1?"e":"a"}: ${I(i.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${i.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${i.origin}`;default:return"Input non valido"}}};function mC(){return{localeError:p2()}}var m2=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(i){return e[i]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},n={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${i.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${a}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return i.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${R(i.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${I(i.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let a=i.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",o=t(i.origin);return o?`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${o.unit??"\u8981\u7D20"}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let a=i.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",o=t(i.origin);return o?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${o.unit}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${a.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[a.format]??i.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${i.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${i.keys.length>1?"\u7FA4":""}: ${I(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function hC(){return{localeError:m2()}}var h2=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(i){return e[i]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},n={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${i.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${a}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`}case"invalid_value":return i.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${R(i.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${I(i.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${o.verb} ${a}${i.maximum.toString()} ${o.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin} ${o.verb} ${a}${i.minimum.toString()} ${o.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin} \u10D8\u10E7\u10DD\u10E1 ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${a.prefix}"-\u10D8\u10D7`:a.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${a.suffix}"-\u10D8\u10D7`:a.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${a.includes}"-\u10E1`:a.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${a.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[a.format]??i.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${i.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${i.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${I(i.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${i.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${i.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function gC(){return{localeError:h2()}}var g2=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(i){return e[i]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},n={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${i.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${a} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`}case"invalid_value":return i.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${R(i.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${a} ${i.maximum.toString()} ${o.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${a} ${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${a} ${i.minimum.toString()} ${o.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${a} ${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${a.prefix}"`:a.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${a.suffix}"`:a.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${a.includes}"`:a.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${a.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[a.format]??i.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${i.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${I(i.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${i.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${i.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function Ff(){return{localeError:g2()}}function _C(){return Ff()}var _2=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(i){return e[i]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${i.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${a}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`}case"invalid_value":return i.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${R(i.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${I(i.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let a=i.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",o=a==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(i.origin),c=s?.unit??"\uC694\uC18C";return s?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()}${c} ${a}${o}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()} ${a}${o}`}case"too_small":{let a=i.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",o=a==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(i.origin),c=s?.unit??"\uC694\uC18C";return s?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()}${c} ${a}${o}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()} ${a}${o}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:a.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:a.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:a.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${a.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[a.format]??i.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${i.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${I(i.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${i.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${i.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function yC(){return{localeError:_2()}}var Il=e=>e.charAt(0).toUpperCase()+e.slice(1);function vC(e){let t=Math.abs(e),r=t%10,n=t%100;return n>=11&&n<=19||r===0?"many":r===1?"one":"few"}var y2=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(i,a,o,s){let c=e[i]??null;return c===null?c:{unit:c.unit[a],verb:c.verb[s][o?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},n={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Gautas tipas ${s}, o tik\u0117tasi - instanceof ${i.expected}`:`Gautas tipas ${s}, o tik\u0117tasi - ${a}`}case"invalid_value":return i.values.length===1?`Privalo b\u016Bti ${R(i.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${I(i.values,"|")} pasirinkim\u0173`;case"too_big":{let a=n[i.origin]??i.origin,o=t(i.origin,vC(Number(i.maximum)),i.inclusive??!1,"smaller");if(o?.verb)return`${Il(a??i.origin??"reik\u0161m\u0117")} ${o.verb} ${i.maximum.toString()} ${o.unit??"element\u0173"}`;let s=i.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${Il(a??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${i.maximum.toString()} ${o?.unit}`}case"too_small":{let a=n[i.origin]??i.origin,o=t(i.origin,vC(Number(i.minimum)),i.inclusive??!1,"bigger");if(o?.verb)return`${Il(a??i.origin??"reik\u0161m\u0117")} ${o.verb} ${i.minimum.toString()} ${o.unit??"element\u0173"}`;let s=i.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${Il(a??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${i.minimum.toString()} ${o?.unit}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${a.prefix}"`:a.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${a.suffix}"`:a.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${a.includes}"`:a.format==="regex"?`Eilut\u0117 privalo atitikti ${a.pattern}`:`Neteisingas ${r[a.format]??i.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${i.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${i.keys.length>1?"i":"as"} rakt${i.keys.length>1?"ai":"as"}: ${I(i.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let a=n[i.origin]??i.origin;return`${Il(a??i.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function bC(){return{localeError:y2()}}var v2=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(i){return e[i]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},n={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${i.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${a}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${R(i.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${a}${i.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0438\u043C\u0430 ${a}${i.minimum.toString()} ${o.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${a.pattern}`:`Invalid ${r[a.format]??i.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${I(i.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${i.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${i.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function wC(){return{localeError:v2()}}var b2=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(i){return e[i]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"nombor"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Input tidak sah: dijangka instanceof ${i.expected}, diterima ${s}`:`Input tidak sah: dijangka ${a}, diterima ${s}`}case"invalid_value":return i.values.length===1?`Input tidak sah: dijangka ${R(i.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Terlalu besar: dijangka ${i.origin??"nilai"} ${o.verb} ${a}${i.maximum.toString()} ${o.unit??"elemen"}`:`Terlalu besar: dijangka ${i.origin??"nilai"} adalah ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Terlalu kecil: dijangka ${i.origin} ${o.verb} ${a}${i.minimum.toString()} ${o.unit}`:`Terlalu kecil: dijangka ${i.origin} adalah ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`String tidak sah: mesti bermula dengan "${a.prefix}"`:a.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${a.suffix}"`:a.format==="includes"?`String tidak sah: mesti mengandungi "${a.includes}"`:a.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${a.pattern}`:`${r[a.format]??i.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${I(i.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${i.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${i.origin}`;default:return"Input tidak sah"}}};function xC(){return{localeError:b2()}}var w2=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(i){return e[i]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},n={nan:"NaN",number:"getal"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ongeldige invoer: verwacht instanceof ${i.expected}, ontving ${s}`:`Ongeldige invoer: verwacht ${a}, ontving ${s}`}case"invalid_value":return i.values.length===1?`Ongeldige invoer: verwacht ${R(i.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin),s=i.origin==="date"?"laat":i.origin==="string"?"lang":"groot";return o?`Te ${s}: verwacht dat ${i.origin??"waarde"} ${a}${i.maximum.toString()} ${o.unit??"elementen"} ${o.verb}`:`Te ${s}: verwacht dat ${i.origin??"waarde"} ${a}${i.maximum.toString()} is`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin),s=i.origin==="date"?"vroeg":i.origin==="string"?"kort":"klein";return o?`Te ${s}: verwacht dat ${i.origin} ${a}${i.minimum.toString()} ${o.unit} ${o.verb}`:`Te ${s}: verwacht dat ${i.origin} ${a}${i.minimum.toString()} is`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Ongeldige tekst: moet met "${a.prefix}" beginnen`:a.format==="ends_with"?`Ongeldige tekst: moet op "${a.suffix}" eindigen`:a.format==="includes"?`Ongeldige tekst: moet "${a.includes}" bevatten`:a.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${a.pattern}`:`Ongeldig: ${r[a.format]??i.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${i.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${i.keys.length>1?"s":""}: ${I(i.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${i.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${i.origin}`;default:return"Ongeldige invoer"}}};function SC(){return{localeError:w2()}}var x2=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(i){return e[i]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"tall",array:"liste"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ugyldig input: forventet instanceof ${i.expected}, fikk ${s}`:`Ugyldig input: forventet ${a}, fikk ${s}`}case"invalid_value":return i.values.length===1?`Ugyldig verdi: forventet ${R(i.values[0])}`:`Ugyldig valg: forventet en av ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${a}${i.maximum.toString()} ${o.unit??"elementer"}`:`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`For lite(n): forventet ${i.origin} til \xE5 ha ${a}${i.minimum.toString()} ${o.unit}`:`For lite(n): forventet ${i.origin} til \xE5 ha ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${a.prefix}"`:a.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${a.suffix}"`:a.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${a.includes}"`:a.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${a.pattern}`:`Ugyldig ${r[a.format]??i.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${I(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${i.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${i.origin}`;default:return"Ugyldig input"}}};function kC(){return{localeError:x2()}}var S2=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(i){return e[i]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},n={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`F\xE2sit giren: umulan instanceof ${i.expected}, al\u0131nan ${s}`:`F\xE2sit giren: umulan ${a}, al\u0131nan ${s}`}case"invalid_value":return i.values.length===1?`F\xE2sit giren: umulan ${R(i.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${a}${i.maximum.toString()} ${o.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${a}${i.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${a}${i.minimum.toString()} ${o.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${a}${i.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let a=i;return a.format==="starts_with"?`F\xE2sit metin: "${a.prefix}" ile ba\u015Flamal\u0131.`:a.format==="ends_with"?`F\xE2sit metin: "${a.suffix}" ile bitmeli.`:a.format==="includes"?`F\xE2sit metin: "${a.includes}" ihtiv\xE2 etmeli.`:a.format==="regex"?`F\xE2sit metin: ${a.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[a.format]??i.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${i.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${i.keys.length>1?"s":""}: ${I(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${i.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function $C(){return{localeError:S2()}}var k2=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(i){return e[i]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${i.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${a} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return i.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${R(i.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${I(i.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${a}${i.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${a}${i.maximum.toString()} \u0648\u064A`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${a}${i.minimum.toString()} ${o.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${a}${i.minimum.toString()} \u0648\u064A`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${a.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:a.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${a.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:a.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${a.includes}" \u0648\u0644\u0631\u064A`:a.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${a.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[a.format]??i.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${i.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${i.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${I(i.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${i.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${i.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function EC(){return{localeError:k2()}}var $2=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(i){return e[i]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},n={nan:"NaN",number:"liczba",array:"tablica"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${i.expected}, otrzymano ${s}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${a}, otrzymano ${s}`}case"invalid_value":return i.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${R(i.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${a}${i.maximum.toString()} ${o.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${a}${i.minimum.toString()} ${o.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${a.prefix}"`:a.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${a.suffix}"`:a.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${a.includes}"`:a.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${a.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[a.format]??i.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${i.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${i.keys.length>1?"s":""}: ${I(i.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${i.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${i.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function IC(){return{localeError:$2()}}var E2=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(i){return e[i]??null}let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN",number:"n\xFAmero",null:"nulo"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Tipo inv\xE1lido: esperado instanceof ${i.expected}, recebido ${s}`:`Tipo inv\xE1lido: esperado ${a}, recebido ${s}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: esperado ${R(i.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Muito grande: esperado que ${i.origin??"valor"} tivesse ${a}${i.maximum.toString()} ${o.unit??"elementos"}`:`Muito grande: esperado que ${i.origin??"valor"} fosse ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Muito pequeno: esperado que ${i.origin} tivesse ${a}${i.minimum.toString()} ${o.unit}`:`Muito pequeno: esperado que ${i.origin} fosse ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${a.prefix}"`:a.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${a.suffix}"`:a.format==="includes"?`Texto inv\xE1lido: deve incluir "${a.includes}"`:a.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${a.pattern}`:`${r[a.format]??i.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Chave${i.keys.length>1?"s":""} desconhecida${i.keys.length>1?"s":""}: ${I(i.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${i.origin}`;default:return"Campo inv\xE1lido"}}};function TC(){return{localeError:E2()}}var I2=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(i){return e[i]??null}let r={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",jwt:"JWT",template_literal:"intrare"},n={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return`Intrare invalid\u0103: a\u0219teptat ${a}, primit ${s}`}case"invalid_value":return i.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${R(i.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} ${o.verb} ${a}${i.maximum.toString()} ${o.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} s\u0103 fie ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Prea mic: a\u0219teptat ca ${i.origin} ${o.verb} ${a}${i.minimum.toString()} ${o.unit}`:`Prea mic: a\u0219teptat ca ${i.origin} s\u0103 fie ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${a.prefix}"`:a.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${a.suffix}"`:a.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${a.includes}"`:a.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${a.pattern}`:`Format invalid: ${r[a.format]??i.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${i.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${I(i.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${i.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${i.origin}`;default:return"Intrare invalid\u0103"}}};function CC(){return{localeError:I2()}}function AC(e,t,r,n){let i=Math.abs(e),a=i%10,o=i%100;return o>=11&&o<=19?n:a===1?t:a>=2&&a<=4?r:n}var T2=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(i){return e[i]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${i.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${a}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${R(i.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);if(o){let s=Number(i.maximum),c=AC(s,o.unit.one,o.unit.few,o.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${a}${i.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);if(o){let s=Number(i.minimum),c=AC(s,o.unit.one,o.unit.few,o.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${a}${i.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin} \u0431\u0443\u0434\u0435\u0442 ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[a.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${i.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0438":""}: ${I(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${i.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function OC(){return{localeError:T2()}}var C2=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(i){return e[i]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},n={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${i.expected}, prejeto ${s}`:`Neveljaven vnos: pri\u010Dakovano ${a}, prejeto ${s}`}case"invalid_value":return i.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${R(i.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} imelo ${a}${i.maximum.toString()} ${o.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Premajhno: pri\u010Dakovano, da bo ${i.origin} imelo ${a}${i.minimum.toString()} ${o.unit}`:`Premajhno: pri\u010Dakovano, da bo ${i.origin} ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${a.prefix}"`:a.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${a.suffix}"`:a.format==="includes"?`Neveljaven niz: mora vsebovati "${a.includes}"`:a.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${a.pattern}`:`Neveljaven ${r[a.format]??i.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${i.divisor}`;case"unrecognized_keys":return`Neprepoznan${i.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${I(i.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${i.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${i.origin}`;default:return"Neveljaven vnos"}}};function PC(){return{localeError:C2()}}var A2=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(i){return e[i]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},n={nan:"NaN",number:"antal",array:"lista"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${i.expected}, fick ${s}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${a}, fick ${s}`}case"invalid_value":return i.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${R(i.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`F\xF6r stor(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${a}${i.maximum.toString()} ${o.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${i.origin??"v\xE4rdet"} att ha ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${a}${i.minimum.toString()} ${o.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${a.prefix}"`:a.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${a.suffix}"`:a.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${a.includes}"`:a.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${a.pattern}"`:`Ogiltig(t) ${r[a.format]??i.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${I(i.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${i.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${i.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function NC(){return{localeError:A2()}}var O2=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(i){return e[i]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${i.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`}case"invalid_value":return i.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${R(i.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${I(i.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${a}${i.maximum.toString()} ${o.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${a}${i.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin} ${a}${i.minimum.toString()} ${o.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin} ${a}${i.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${a.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[a.format]??i.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${i.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${i.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${I(i.keys,", ")}`;case"invalid_key":return`${i.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${i.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function RC(){return{localeError:O2()}}var P2=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(i){return e[i]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},n={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${i.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${a} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`}case"invalid_value":return i.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${R(i.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",o=t(i.origin);return o?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${i.maximum.toString()} ${o.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",o=t(i.origin);return o?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${i.minimum.toString()} ${o.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${a.prefix}"`:a.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${a.suffix}"`:a.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${a.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:a.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${a.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[a.format]??i.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${i.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${I(i.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${i.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${i.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function MC(){return{localeError:P2()}}var N2=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(i){return e[i]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${i.expected}, al\u0131nan ${s}`:`Ge\xE7ersiz de\u011Fer: beklenen ${a}, al\u0131nan ${s}`}case"invalid_value":return i.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${R(i.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${a}${i.maximum.toString()} ${o.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${a}${i.minimum.toString()} ${o.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Ge\xE7ersiz metin: "${a.prefix}" ile ba\u015Flamal\u0131`:a.format==="ends_with"?`Ge\xE7ersiz metin: "${a.suffix}" ile bitmeli`:a.format==="includes"?`Ge\xE7ersiz metin: "${a.includes}" i\xE7ermeli`:a.format==="regex"?`Ge\xE7ersiz metin: ${a.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[a.format]??i.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${i.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${i.keys.length>1?"lar":""}: ${I(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${i.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function jC(){return{localeError:N2()}}var R2=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(i){return e[i]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${i.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${a}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${R(i.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${o.verb} ${a}${i.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} ${o.verb} ${a}${i.minimum.toString()} ${o.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} \u0431\u0443\u0434\u0435 ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[a.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0456":""}: ${I(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${i.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function Bf(){return{localeError:R2()}}function DC(){return Bf()}var M2=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(i){return e[i]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},n={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${i.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${a} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return i.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${R(i.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${I(i.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${a}${i.maximum.toString()} ${o.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${a}${i.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u06D2 ${a}${i.minimum.toString()} ${o.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u0627 ${a}${i.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${a.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[a.format]??i.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${i.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${i.keys.length>1?"\u0632":""}: ${I(i.keys,"\u060C ")}`;case"invalid_key":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function zC(){return{localeError:M2()}}var j2=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(i){return e[i]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},n={nan:"NaN",number:"raqam",array:"massiv"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${i.expected}, qabul qilingan ${s}`:`Noto\u2018g\u2018ri kirish: kutilgan ${a}, qabul qilingan ${s}`}case"invalid_value":return i.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${R(i.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Juda katta: kutilgan ${i.origin??"qiymat"} ${a}${i.maximum.toString()} ${o.unit} ${o.verb}`:`Juda katta: kutilgan ${i.origin??"qiymat"} ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Juda kichik: kutilgan ${i.origin} ${a}${i.minimum.toString()} ${o.unit} ${o.verb}`:`Juda kichik: kutilgan ${i.origin} ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${a.prefix}" bilan boshlanishi kerak`:a.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${a.suffix}" bilan tugashi kerak`:a.format==="includes"?`Noto\u2018g\u2018ri satr: "${a.includes}" ni o\u2018z ichiga olishi kerak`:a.format==="regex"?`Noto\u2018g\u2018ri satr: ${a.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[a.format]??i.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${i.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${i.keys.length>1?"lar":""}: ${I(i.keys,", ")}`;case"invalid_key":return`${i.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${i.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function UC(){return{localeError:j2()}}var D2=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(i){return e[i]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},n={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${i.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${a}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`}case"invalid_value":return i.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${R(i.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${o.verb} ${a}${i.maximum.toString()} ${o.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${o.verb} ${a}${i.minimum.toString()} ${o.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${a.prefix}"`:a.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${a.suffix}"`:a.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${a.includes}"`:a.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${a.pattern}`:`${r[a.format]??i.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${i.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${I(i.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${i.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${i.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function LC(){return{localeError:D2()}}var z2=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(i){return e[i]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},n={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${i.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${a}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`}case"invalid_value":return i.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${R(i.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${a}${i.maximum.toString()} ${o.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${a}${i.minimum.toString()} ${o.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${a.prefix}" \u5F00\u5934`:a.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${a.suffix}" \u7ED3\u5C3E`:a.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${a.includes}"`:a.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${a.pattern}`:`\u65E0\u6548${r[a.format]??i.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${i.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${I(i.keys,", ")}`;case"invalid_key":return`${i.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${i.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function FC(){return{localeError:z2()}}var U2=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(i){return e[i]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${i.expected}\uFF0C\u4F46\u6536\u5230 ${s}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${a}\uFF0C\u4F46\u6536\u5230 ${s}`}case"invalid_value":return i.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${R(i.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${a}${i.maximum.toString()} ${o.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${a}${i.maximum.toString()}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${a}${i.minimum.toString()} ${o.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${a.prefix}" \u958B\u982D`:a.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${a.suffix}" \u7D50\u5C3E`:a.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${a.includes}"`:a.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${a.pattern}`:`\u7121\u6548\u7684 ${r[a.format]??i.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${i.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${i.keys.length>1?"\u5011":""}\uFF1A${I(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function BC(){return{localeError:U2()}}var L2=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function t(i){return e[i]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},n={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return i=>{switch(i.code){case"invalid_type":{let a=n[i.expected]??i.expected,o=M(i.input),s=n[o]??o;return/^[A-Z]/.test(i.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${i.expected}, \xE0m\u1ECD\u0300 a r\xED ${s}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${a}, \xE0m\u1ECD\u0300 a r\xED ${s}`}case"invalid_value":return i.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${R(i.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${I(i.values,"|")}`;case"too_big":{let a=i.inclusive?"<=":"<",o=t(i.origin);return o?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin??"iye"} ${o.verb} ${a}${i.maximum} ${o.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${a}${i.maximum}`}case"too_small":{let a=i.inclusive?">=":">",o=t(i.origin);return o?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin} ${o.verb} ${a}${i.minimum} ${o.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${a}${i.minimum}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${a.prefix}"`:a.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${a.suffix}"`:a.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${a.includes}"`:a.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${a.pattern}`:`A\u1E63\xEC\u1E63e: ${r[a.format]??i.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${i.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${I(i.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${i.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${i.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function VC(){return{localeError:L2()}}var ZC,Gv=Symbol("ZodOutput"),Wv=Symbol("ZodInput"),Vf=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Zf(){return new Vf}(ZC=globalThis).__zod_globalRegistry??(ZC.__zod_globalRegistry=Zf());var De=globalThis.__zod_globalRegistry;function Jv(e,t){return new e({type:"string",...U(t)})}function Kv(e,t){return new e({type:"string",coerce:!0,...U(t)})}function Hf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...U(t)})}function Cl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...U(t)})}function Gf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...U(t)})}function Wf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...U(t)})}function Jf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...U(t)})}function Kf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...U(t)})}function Al(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...U(t)})}function qf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...U(t)})}function Xf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...U(t)})}function Yf(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...U(t)})}function Qf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...U(t)})}function ep(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...U(t)})}function tp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...U(t)})}function rp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...U(t)})}function np(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...U(t)})}function ip(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...U(t)})}function qv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...U(t)})}function ap(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...U(t)})}function op(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...U(t)})}function sp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...U(t)})}function cp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...U(t)})}function lp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...U(t)})}function up(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...U(t)})}var Xv={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Yv(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...U(t)})}function Qv(e,t){return new e({type:"string",format:"date",check:"string_format",...U(t)})}function eb(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...U(t)})}function tb(e,t){return new e({type:"string",format:"duration",check:"string_format",...U(t)})}function rb(e,t){return new e({type:"number",checks:[],...U(t)})}function nb(e,t){return new e({type:"number",coerce:!0,checks:[],...U(t)})}function ib(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...U(t)})}function ab(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...U(t)})}function ob(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...U(t)})}function sb(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...U(t)})}function cb(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...U(t)})}function lb(e,t){return new e({type:"boolean",...U(t)})}function ub(e,t){return new e({type:"boolean",coerce:!0,...U(t)})}function db(e,t){return new e({type:"bigint",...U(t)})}function fb(e,t){return new e({type:"bigint",coerce:!0,...U(t)})}function pb(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...U(t)})}function mb(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...U(t)})}function hb(e,t){return new e({type:"symbol",...U(t)})}function gb(e,t){return new e({type:"undefined",...U(t)})}function _b(e,t){return new e({type:"null",...U(t)})}function yb(e){return new e({type:"any"})}function Ol(e){return new e({type:"unknown"})}function Pl(e,t){return new e({type:"never",...U(t)})}function vb(e,t){return new e({type:"void",...U(t)})}function bb(e,t){return new e({type:"date",...U(t)})}function wb(e,t){return new e({type:"date",coerce:!0,...U(t)})}function xb(e,t){return new e({type:"nan",...U(t)})}function Zn(e,t){return new Af({check:"less_than",...U(t),value:e,inclusive:!1})}function zr(e,t){return new Af({check:"less_than",...U(t),value:e,inclusive:!0})}function Hn(e,t){return new Of({check:"greater_than",...U(t),value:e,inclusive:!1})}function dr(e,t){return new Of({check:"greater_than",...U(t),value:e,inclusive:!0})}function dp(e){return Hn(0,e)}function fp(e){return Zn(0,e)}function pp(e){return zr(0,e)}function mp(e){return dr(0,e)}function ga(e,t){return new vy({check:"multiple_of",...U(t),value:e})}function _a(e,t){return new xy({check:"max_size",...U(t),maximum:e})}function Gn(e,t){return new Sy({check:"min_size",...U(t),minimum:e})}function vo(e,t){return new ky({check:"size_equals",...U(t),size:e})}function bo(e,t){return new $y({check:"max_length",...U(t),maximum:e})}function bi(e,t){return new Ey({check:"min_length",...U(t),minimum:e})}function wo(e,t){return new Iy({check:"length_equals",...U(t),length:e})}function Os(e,t){return new Ty({check:"string_format",format:"regex",...U(t),pattern:e})}function Ps(e){return new Cy({check:"string_format",format:"lowercase",...U(e)})}function Ns(e){return new Ay({check:"string_format",format:"uppercase",...U(e)})}function Rs(e,t){return new Oy({check:"string_format",format:"includes",...U(t),includes:e})}function Ms(e,t){return new Py({check:"string_format",format:"starts_with",...U(t),prefix:e})}function js(e,t){return new Ny({check:"string_format",format:"ends_with",...U(t),suffix:e})}function hp(e,t,r){return new Ry({check:"property",property:e,schema:t,...U(r)})}function Ds(e,t){return new My({check:"mime_type",mime:e,...U(t)})}function pn(e){return new jy({check:"overwrite",tx:e})}function zs(e){return pn(t=>t.normalize(e))}function Us(){return pn(e=>e.trim())}function Ls(){return pn(e=>e.toLowerCase())}function Fs(){return pn(e=>e.toUpperCase())}function Bs(){return pn(e=>P_(e))}function Sb(e,t,r){return new e({type:"array",element:t,...U(r)})}function B2(e,t,r){return new e({type:"union",options:t,...U(r)})}function V2(e,t,r){return new e({type:"union",options:t,inclusive:!1,...U(r)})}function Z2(e,t,r,n){return new e({type:"union",options:r,discriminator:t,...U(n)})}function H2(e,t,r){return new e({type:"intersection",left:t,right:r})}function G2(e,t,r,n){let i=r instanceof pe,a=i?n:r,o=i?r:null;return new e({type:"tuple",items:t,rest:o,...U(a)})}function W2(e,t,r,n){return new e({type:"record",keyType:t,valueType:r,...U(n)})}function J2(e,t,r,n){return new e({type:"map",keyType:t,valueType:r,...U(n)})}function K2(e,t,r){return new e({type:"set",valueType:t,...U(r)})}function q2(e,t,r){let n=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:n,...U(r)})}function X2(e,t,r){return new e({type:"enum",entries:t,...U(r)})}function Y2(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...U(r)})}function kb(e,t){return new e({type:"file",...U(t)})}function Q2(e,t){return new e({type:"transform",transform:t})}function eL(e,t){return new e({type:"optional",innerType:t})}function tL(e,t){return new e({type:"nullable",innerType:t})}function rL(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():R_(r)}})}function nL(e,t,r){return new e({type:"nonoptional",innerType:t,...U(r)})}function iL(e,t){return new e({type:"success",innerType:t})}function aL(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function oL(e,t,r){return new e({type:"pipe",in:t,out:r})}function sL(e,t){return new e({type:"readonly",innerType:t})}function cL(e,t,r){return new e({type:"template_literal",parts:t,...U(r)})}function lL(e,t){return new e({type:"lazy",getter:t})}function uL(e,t){return new e({type:"promise",innerType:t})}function $b(e,t,r){let n=U(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Eb(e,t,r){return new e({type:"custom",check:"custom",fn:t,...U(r)})}function Ib(e,t){let r=HC(n=>(n.addIssue=i=>{if(typeof i=="string")n.issues.push(ks(i,n.value,r._zod.def));else{let a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=r),a.continue??(a.continue=!r._zod.def.abort),n.issues.push(ks(a))}},e(n.value,n)),t);return r}function HC(e,t){let r=new Ze({check:"custom",...U(t)});return r._zod.check=e,r}function Tb(e){let t=new Ze({check:"describe"});return t._zod.onattach=[r=>{let n=De.get(r)??{};De.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function Cb(e){let t=new Ze({check:"meta"});return t._zod.onattach=[r=>{let n=De.get(r)??{};De.add(r,{...n,...e})}],t._zod.check=()=>{},t}function Ab(e,t){let r=U(t),n=r.truthy??["true","1","yes","on","y","enabled"],i=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(p=>typeof p=="string"?p.toLowerCase():p),i=i.map(p=>typeof p=="string"?p.toLowerCase():p));let a=new Set(n),o=new Set(i),s=e.Codec??El,c=e.Boolean??xl,l=e.String??_o,u=new l({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),f=new s({type:"pipe",in:u,out:d,transform:((p,m)=>{let h=p;return r.case!=="sensitive"&&(h=h.toLowerCase()),a.has(h)?!0:o.has(h)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...a,...o],input:m.value,inst:f,continue:!1}),{})}),reverseTransform:((p,m)=>p===!0?n[0]||"true":i[0]||"false"),error:r.error});return f}function Vs(e,t,r,n={}){let i=U(n),a={...U(n),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...i};return r instanceof RegExp&&(a.pattern=r),new e(a)}function ya(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??De,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function ze(e,t,r={path:[],schemaPath:[]}){var n;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let f=o.schema,p=t.processors[i.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);p(e,t,f,u)}let d=e._zod.parent;d&&(o.ref||(o.ref=d),ze(d,t,u),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&fr(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function va(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let o of e.seen.entries()){let s=e.metadataRegistry.get(o[0])?.id;if(s){let c=n.get(s);if(c&&c!==o[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(s,o[0])}}let i=o=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(o[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=p,{defId:p,ref:`${f("__shared")}#/${s}/${p}`}}if(o[1]===r)return{ref:"#"};let l=`#/${s}/`,u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},a=o=>{if(o[1].schema.$ref)return;let s=o[1],{ref:c,defId:l}=i(o);s.def={...s.schema},l&&(s.defId=l);let u=s.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let s=o[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
217
+
218
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let s=o[1];if(t===o[0]){a(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){a(o);continue}}if(e.metadataRegistry.get(o[0])?.id){a(o);continue}if(s.cycle){a(o);continue}if(s.count>1&&e.reused==="ref"){a(o);continue}}}function ba(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=s=>{let c=e.seen.get(s);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){n(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(m)):Object.assign(l,m),Object.assign(l,u),s._zod.parent===d)for(let _ in l)_==="$ref"||_==="allOf"||_ in u||delete l[_];if(m.$ref&&p.def)for(let _ in l)_==="$ref"||_==="allOf"||_ in p.def&&JSON.stringify(l[_])===JSON.stringify(p.def[_])&&delete l[_]}let f=s._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(l.$ref=p.schema.$ref,p.def))for(let m in l)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(l[m])===JSON.stringify(p.def[m])&&delete l[m]}e.override({zodSchema:s,jsonSchema:l,path:c.path??[]})};for(let s of[...e.seen.entries()].reverse())n(s[0]);let i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(s)}Object.assign(i,r.def??r.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,o[c.defId]=c.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{let s=JSON.parse(JSON.stringify(i));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Zs(t,"input",e.processors),output:Zs(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function fr(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return fr(n.element,r);if(n.type==="set")return fr(n.valueType,r);if(n.type==="lazy")return fr(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return fr(n.innerType,r);if(n.type==="intersection")return fr(n.left,r)||fr(n.right,r);if(n.type==="record"||n.type==="map")return fr(n.keyType,r)||fr(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:fr(n.in,r)||fr(n.out,r);if(n.type==="object"){for(let i in n.shape)if(fr(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(fr(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(fr(i,r))return!0;return!!(n.rest&&fr(n.rest,r))}return!1}var Ob=(e,t={})=>r=>{let n=ya({...r,processors:t});return ze(e,n),va(n,e),ba(n,e)},Zs=(e,t,r={})=>n=>{let{libraryOptions:i,target:a}=n??{},o=ya({...i??{},target:a,io:t,processors:r});return ze(e,o),va(o,e),ba(o,e)};var dL={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Pb=(e,t,r,n)=>{let i=r;i.type="string";let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a=="number"&&(i.minLength=a),typeof o=="number"&&(i.maxLength=o),s&&(i.format=dL[s]??s,i.format===""&&delete i.format,s==="time"&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let u=[...c];u.length===1?i.pattern=u[0].source:u.length>1&&(i.allOf=[...u.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Nb=(e,t,r,n)=>{let i=r,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s=="string"&&s.includes("int")?i.type="integer":i.type="number";let d=typeof u=="number"&&u>=(a??Number.NEGATIVE_INFINITY),f=typeof l=="number"&&l<=(o??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a=="number"&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o=="number"&&(i.maximum=o),typeof c=="number"&&(i.multipleOf=c)},Rb=(e,t,r,n)=>{r.type="boolean"},Mb=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},jb=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},Db=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},zb=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Ub=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Lb=(e,t,r,n)=>{r.not={}},Fb=(e,t,r,n)=>{},Bb=(e,t,r,n)=>{},Vb=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Zb=(e,t,r,n)=>{let i=e._zod.def,a=dl(i.entries);a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),r.enum=a},Hb=(e,t,r,n)=>{let i=e._zod.def,a=[];for(let o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(o))}else a.push(o);if(a.length!==0)if(a.length===1){let o=a[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),a.every(o=>typeof o=="boolean")&&(r.type="boolean"),a.every(o=>o===null)&&(r.type="null"),r.enum=a},Gb=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},Wb=(e,t,r,n)=>{let i=r,a=e._zod.pattern;if(!a)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=a.source},Jb=(e,t,r,n)=>{let i=r,a={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(l=>({contentMediaType:l}))):Object.assign(i,a)},Kb=(e,t,r,n)=>{r.type="boolean"},qb=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Xb=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Yb=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Qb=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},ew=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},tw=(e,t,r,n)=>{let i=r,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o=="number"&&(i.minItems=o),typeof s=="number"&&(i.maxItems=s),i.type="array",i.items=ze(a.element,t,{...n,path:[...n.path,"items"]})},rw=(e,t,r,n)=>{let i=r,a=e._zod.def;i.type="object",i.properties={};let o=a.shape;for(let l in o)i.properties[l]=ze(o[l],t,{...n,path:[...n.path,"properties",l]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(l=>{let u=a.shape[l]._zod;return t.io==="input"?u.optin===void 0:u.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type==="never"?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=ze(a.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},_p=(e,t,r,n)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((s,c)=>ze(s,t,{...n,path:[...n.path,a?"oneOf":"anyOf",c]}));a?r.oneOf=o:r.anyOf=o},nw=(e,t,r,n)=>{let i=e._zod.def,a=ze(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=ze(i.right,t,{...n,path:[...n.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];r.allOf=c},iw=(e,t,r,n)=>{let i=r,a=e._zod.def;i.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=a.items.map((f,p)=>ze(f,t,{...n,path:[...n.path,o,p]})),l=a.rest?ze(a.rest,t,{...n,path:[...n.path,s,...t.target==="openapi-3.0"?[a.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=c,l&&(i.items=l)):t.target==="openapi-3.0"?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u=="number"&&(i.minItems=u),typeof d=="number"&&(i.maxItems=d)},aw=(e,t,r,n)=>{let i=r,a=e._zod.def;i.type="object";let o=a.keyType,c=o._zod.bag?.patterns;if(a.mode==="loose"&&c&&c.size>0){let u=ze(a.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(let d of c)i.patternProperties[d.source]=u}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=ze(a.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=ze(a.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let l=o._zod.values;if(l){let u=[...l].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(i.required=u)}},ow=(e,t,r,n)=>{let i=e._zod.def,a=ze(i.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=i.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},sw=(e,t,r,n)=>{let i=e._zod.def;ze(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType},cw=(e,t,r,n)=>{let i=e._zod.def;ze(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},lw=(e,t,r,n)=>{let i=e._zod.def;ze(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},uw=(e,t,r,n)=>{let i=e._zod.def;ze(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},dw=(e,t,r,n)=>{let i=e._zod.def,a=i.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?a?i.out:i.in:i.out;ze(o,t,n);let s=t.seen.get(e);s.ref=o},fw=(e,t,r,n)=>{let i=e._zod.def;ze(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType,r.readOnly=!0},pw=(e,t,r,n)=>{let i=e._zod.def;ze(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType},yp=(e,t,r,n)=>{let i=e._zod.def;ze(i.innerType,t,n);let a=t.seen.get(e);a.ref=i.innerType},mw=(e,t,r,n)=>{let i=e._zod.innerType;ze(i,t,n);let a=t.seen.get(e);a.ref=i},gp={string:Pb,number:Nb,boolean:Rb,bigint:Mb,symbol:jb,null:Db,undefined:zb,void:Ub,never:Lb,any:Fb,unknown:Bb,date:Vb,enum:Zb,literal:Hb,nan:Gb,template_literal:Wb,file:Jb,success:Kb,custom:qb,function:Xb,transform:Yb,map:Qb,set:ew,array:tw,object:rw,union:_p,intersection:nw,tuple:iw,record:aw,nullable:ow,nonoptional:sw,default:cw,prefault:lw,catch:uw,pipe:dw,readonly:fw,promise:pw,optional:yp,lazy:mw};function xo(e,t){if("_idmap"in e){let n=e,i=ya({...t,processors:gp}),a={};for(let c of n._idmap.entries()){let[l,u]=c;ze(u,i)}let o={},s={registry:n,uri:t?.uri,defs:a};i.external=s;for(let c of n._idmap.entries()){let[l,u]=c;va(i,u),o[l]=ba(i,u)}if(Object.keys(a).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:a}}return{schemas:o}}let r=ya({...t,processors:gp});return ze(e,r),va(r,e),ba(r,e)}var vp=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=ya({processors:gp,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return ze(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),va(this.ctx,t);let n=ba(this.ctx,t),{"~standard":i,...a}=n;return a}};var GC={};function Ge(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_zod"in t))return!1;let r=t._zod;return typeof r=="object"&&r!==null&&"def"in r}function lt(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_def"in t)||"_zod"in t)return!1;let r=t._def;return typeof r=="object"&&r!=null&&"typeName"in r}function WC(e){return Ge(e)&&console.warn("[WARNING] Attempting to use Zod 4 schema in a context where Zod 3 schema is expected. This may cause unexpected behavior."),lt(e)}function xr(e){return!e||typeof e!="object"||Array.isArray(e)?!1:!!(Ge(e)||lt(e))}function hw(e){return typeof e=="object"&&e!==null&&"_def"in e&&typeof e._def=="object"&&e._def!==null&&"typeName"in e._def&&e._def.typeName==="ZodLiteral"}function gw(e){return Ge(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="literal":!1}function JC(e){return!!(hw(e)||gw(e))}async function wp(e,t){if(Ge(e))try{return{success:!0,data:await ho(e,t)}}catch(r){return{success:!1,error:r}}if(lt(e))return await e.safeParseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}async function wa(e,t){if(Ge(e))return await ho(e,t);if(lt(e))return await e.parseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function KC(e,t){if(Ge(e))try{return{success:!0,data:ha(e,t)}}catch(r){return{success:!1,error:r}}if(lt(e))return e.safeParse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function xa(e,t){if(Ge(e))return ha(e,t);if(lt(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Si(e){if(Ge(e))return De.get(e)?.description;if(lt(e)||"description"in e&&typeof e.description=="string")return e.description}function qC(e){if(!xr(e))return!1;if(lt(e)){let t=e._def;if(t.typeName==="ZodObject"){let r=e;return!r.shape||Object.keys(r.shape).length===0}if(t.typeName==="ZodRecord")return!0}if(Ge(e)){let t=e._zod.def;if(t.type==="object"){let r=e;return!r.shape||Object.keys(r.shape).length===0}if(t.type==="record")return!0}return typeof e=="object"&&e!==null&&!("shape"in e)}function Gs(e){return xr(e)?lt(e)?e._def.typeName==="ZodString":Ge(e)?e._zod.def.type==="string":!1:!1}function Nl(e){return typeof e=="object"&&e!==null&&"_def"in e&&typeof e._def=="object"&&e._def!==null&&"typeName"in e._def&&e._def.typeName==="ZodObject"}function Kr(e){return Ge(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="object":!1}function Rl(e){return Ge(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="array":!1}function _w(e){return Ge(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="optional":!1}function yw(e){return Ge(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="nullable":!1}function Jt(e){return!!(Nl(e)||Kr(e))}function xi(e){if(lt(e))return e.shape;if(Ge(e))return e._zod.def.shape;throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function xp(e,t){if(lt(e))return e.extend(t);if(Ge(e))return j.extend(e,t);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Sa(e){if(lt(e))return e.partial();if(Ge(e))return j.partial(yo,e,void 0);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Hs(e,t=!1){if(Nl(e))return e.strict();if(Kr(e)){let r=e._zod.def.shape;if(t)for(let[a,o]of Object.entries(e._zod.def.shape)){if(Kr(o))r[a]=Hs(o,t);else if(Rl(o)){let c=o._zod.def.element;Kr(c)&&(c=Hs(c,t)),r[a]=Ye(o,{...o._zod.def,element:c})}else r[a]=o;let s=De.get(o);s&&De.add(r[a],s)}let n=Ye(e,{...e._zod.def,shape:r,catchall:Pl(kl)}),i=De.get(e);return i&&De.add(n,i),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function bp(e,t=!1){if(Nl(e))return e.passthrough();if(Kr(e)){let r=e._zod.def.shape;if(t)for(let[a,o]of Object.entries(e._zod.def.shape)){if(Kr(o))r[a]=bp(o,t);else if(Rl(o)){let c=o._zod.def.element;Kr(c)&&(c=bp(c,t)),r[a]=Ye(o,{...o._zod.def,element:c})}else r[a]=o;let s=De.get(o);s&&De.add(r[a],s)}let n=Ye(e,{...e._zod.def,shape:r,catchall:Ol(Sl)}),i=De.get(e);return i&&De.add(n,i),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Sp(e){if(lt(e))try{let t=e.parse(void 0);return()=>t}catch{return}if(Ge(e))try{let t=ha(e,void 0);return()=>t}catch{return}}function pL(e){return lt(e)&&"typeName"in e._def&&e._def.typeName==="ZodEffects"}function mL(e){return Ge(e)&&e._zod.def.type==="pipe"}function So(e,t,r){let n=r.get(e);if(n!==void 0)return n;if(lt(e))return pL(e)?So(e._def.schema,t,r):e;if(Ge(e)){let i=e;if(mL(e)&&(i=So(e._zod.def.in,t,r)),t){if(Kr(i)){let o={};for(let[s,c]of Object.entries(i._zod.def.shape))o[s]=So(c,t,r);i=Ye(i,{...i._zod.def,shape:o})}else if(Rl(i)){let o=So(i._zod.def.element,t,r);i=Ye(i,{...i._zod.def,element:o})}else if(_w(i)){let o=So(i._zod.def.innerType,t,r);i=Ye(i,{...i._zod.def,innerType:o})}else if(yw(i)){let o=So(i._zod.def.innerType,t,r);i=Ye(i,{...i._zod.def,innerType:o})}}let a=De.get(e);return a&&De.add(i,a),r.set(e,i),i}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function kp(e,t=!1){return So(e,t,new WeakMap)}function XC(e,t){if(lt(e)){let r=xi(e),n={};for(let[i,a]of Object.entries(r))t(i,a)?n[i]=a.optional():n[i]=a;return e.extend(n)}if(Ge(e)){let r=xi(e),n={...e._zod.def.shape};for(let[o,s]of Object.entries(r))t(o,s)&&(n[o]=new yo({type:"optional",innerType:s}));let i=Ye(e,{...e._zod.def,shape:n}),a=De.get(e);return a&&De.add(i,a),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function $p(e){return e instanceof Error&&(e.constructor.name==="ZodError"||e.constructor.name==="$ZodError")}var QC=Symbol("Let zodToJsonSchema decide on which parser to use"),YC={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"},eA=e=>typeof e=="string"?{...YC,name:e}:{...YC,...e};var tA=e=>{let t=eA(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};var Ep=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function nt(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?Ep(t,e.currentPath):t.join("/")}}function vw(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Me(e,t,r,n,i){e[t]=r,vw(e,t,n,i)}var Nt={};An(Nt,{BRAND:()=>LL,DIRTY:()=>ko,EMPTY_PATH:()=>yL,INVALID:()=>ce,NEVER:()=>k6,OK:()=>Kt,ParseStatus:()=>zt,Schema:()=>we,ZodAny:()=>Ea,ZodArray:()=>Ii,ZodBigInt:()=>Eo,ZodBoolean:()=>Io,ZodBranded:()=>jl,ZodCatch:()=>zo,ZodDate:()=>To,ZodDefault:()=>Do,ZodDiscriminatedUnion:()=>Cp,ZodEffects:()=>Yr,ZodEnum:()=>Mo,ZodError:()=>Sr,ZodFirstPartyTypeKind:()=>z,ZodFunction:()=>Op,ZodIntersection:()=>Po,ZodIssueCode:()=>D,ZodLazy:()=>No,ZodLiteral:()=>Ro,ZodMap:()=>Ys,ZodNaN:()=>ec,ZodNativeEnum:()=>jo,ZodNever:()=>mn,ZodNull:()=>Ao,ZodNullable:()=>Kn,ZodNumber:()=>$o,ZodObject:()=>kr,ZodOptional:()=>qr,ZodParsedType:()=>K,ZodPipeline:()=>Dl,ZodPromise:()=>Ia,ZodReadonly:()=>Uo,ZodRecord:()=>Ap,ZodSchema:()=>we,ZodSet:()=>Qs,ZodString:()=>$a,ZodSymbol:()=>qs,ZodTransformer:()=>Yr,ZodTuple:()=>Jn,ZodType:()=>we,ZodUndefined:()=>Co,ZodUnion:()=>Oo,ZodUnknown:()=>Ei,ZodVoid:()=>Xs,addIssueToContext:()=>Z,any:()=>KL,array:()=>QL,bigint:()=>ZL,boolean:()=>fA,coerce:()=>S6,custom:()=>lA,date:()=>HL,datetimeRegex:()=>sA,defaultErrorMap:()=>ki,discriminatedUnion:()=>n6,effect:()=>h6,enum:()=>f6,function:()=>l6,getErrorMap:()=>Ws,getParsedType:()=>Wn,instanceof:()=>BL,intersection:()=>i6,isAborted:()=>Ip,isAsync:()=>Js,isDirty:()=>Tp,isValid:()=>ka,late:()=>FL,lazy:()=>u6,literal:()=>d6,makeIssue:()=>Ml,map:()=>s6,nan:()=>VL,nativeEnum:()=>p6,never:()=>XL,null:()=>JL,nullable:()=>_6,number:()=>dA,object:()=>e6,objectUtil:()=>bw,oboolean:()=>x6,onumber:()=>w6,optional:()=>g6,ostring:()=>b6,pipeline:()=>v6,preprocess:()=>y6,promise:()=>m6,quotelessJson:()=>hL,record:()=>o6,set:()=>c6,setErrorMap:()=>_L,strictObject:()=>t6,string:()=>uA,symbol:()=>GL,transformer:()=>h6,tuple:()=>a6,undefined:()=>WL,union:()=>r6,unknown:()=>qL,util:()=>Ae,void:()=>YL});var Ae;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let a={};for(let o of i)a[o]=o;return a},e.getValidEnumValues=i=>{let a=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(let s of a)o[s]=i[s];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},e.find=(i,a)=>{for(let o of i)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=n,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(Ae||(Ae={}));var bw;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(bw||(bw={}));var K=Ae.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Wn=e=>{switch(typeof e){case"undefined":return K.undefined;case"string":return K.string;case"number":return Number.isNaN(e)?K.nan:K.number;case"boolean":return K.boolean;case"function":return K.function;case"bigint":return K.bigint;case"symbol":return K.symbol;case"object":return Array.isArray(e)?K.array:e===null?K.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?K.promise:typeof Map<"u"&&e instanceof Map?K.map:typeof Set<"u"&&e instanceof Set?K.set:typeof Date<"u"&&e instanceof Date?K.date:K.object;default:return K.unknown}};var D=Ae.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"]),hL=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Sr=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(a){return a.message},n={_errors:[]},i=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let s=n,c=0;for(;c<o.path.length;){let l=o.path[c];c===o.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(r(o))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ae.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),n=[];for(let i of this.issues)if(i.path.length>0){let a=i.path[0];r[a]=r[a]||[],r[a].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Sr.create=e=>new Sr(e);var gL=(e,t)=>{let r;switch(e.code){case D.invalid_type:e.received===K.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case D.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Ae.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ae.joinValues(e.keys,", ")}`;break;case D.invalid_union:r="Invalid input";break;case D.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ae.joinValues(e.options)}`;break;case D.invalid_enum_value:r=`Invalid enum value. Expected ${Ae.joinValues(e.options)}, received '${e.received}'`;break;case D.invalid_arguments:r="Invalid function arguments";break;case D.invalid_return_type:r="Invalid function return type";break;case D.invalid_date:r="Invalid date";break;case D.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Ae.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case D.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case D.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case D.custom:r="Invalid input";break;case D.invalid_intersection_types:r="Intersection results could not be merged";break;case D.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case D.not_finite:r="Number must be finite";break;default:r=t.defaultError,Ae.assertNever(e)}return{message:r}},ki=gL;var rA=ki;function _L(e){rA=e}function Ws(){return rA}var Ml=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)s=l(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},yL=[];function Z(e,t){let r=Ws(),n=Ml({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===ki?void 0:ki].filter(i=>!!i)});e.common.issues.push(n)}var zt=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return ce;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let a=await i.key,o=await i.value;n.push({key:a,value:o})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return ce;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[a.value]=o.value)}return{status:t.value,value:n}}},ce=Object.freeze({status:"aborted"}),ko=e=>({status:"dirty",value:e}),Kt=e=>({status:"valid",value:e}),Ip=e=>e.status==="aborted",Tp=e=>e.status==="dirty",ka=e=>e.status==="valid",Js=e=>typeof Promise<"u"&&e instanceof Promise;var re;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(re||(re={}));var Xr=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}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}},nA=(e,t)=>{if(ka(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Sr(e.common.issues);return this._error=r,this._error}}};function ge(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,s)=>{let{message:c}=e;return o.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:i}}var we=class{get description(){return this._def.description}_getType(t){return Wn(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Wn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new zt,ctx:{common:t.parent.common,data:t.data,parsedType:Wn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Js(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Wn(t)},i=this._parseSync({data:t,path:n.path,parent:n});return nA(n,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Wn(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return ka(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>ka(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Wn(t)},i=this._parse({data:t,path:n.path,parent:n}),a=await(Js(i)?i:Promise.resolve(i));return nA(n,a)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{let o=t(i),s=()=>a.addIssue({code:D.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new Yr({schema:this,typeName:z.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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:r=>this["~validate"](r)}}optional(){return qr.create(this,this._def)}nullable(){return Kn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ii.create(this)}promise(){return Ia.create(this,this._def)}or(t){return Oo.create([this,t],this._def)}and(t){return Po.create(this,t,this._def)}transform(t){return new Yr({...ge(this._def),schema:this,typeName:z.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Do({...ge(this._def),innerType:this,defaultValue:r,typeName:z.ZodDefault})}brand(){return new jl({typeName:z.ZodBranded,type:this,...ge(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new zo({...ge(this._def),innerType:this,catchValue:r,typeName:z.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Dl.create(this,t)}readonly(){return Uo.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},vL=/^c[^\s-]{8,}$/i,bL=/^[0-9a-z]+$/,wL=/^[0-9A-HJKMNP-TV-Z]{26}$/i,xL=/^[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,SL=/^[a-z0-9_-]{21}$/i,kL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,$L=/^[-+]?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)?)??$/,EL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,IL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ww,TL=/^(?:(?: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])$/,CL=/^(?:(?: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])$/,AL=/^(([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]))$/,OL=/^(([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])$/,PL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,NL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,aA="((\\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])))",RL=new RegExp(`^${aA}$`);function oA(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function ML(e){return new RegExp(`^${oA(e)}$`)}function sA(e){let t=`${aA}T${oA(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function jL(e,t){return!!((t==="v4"||!t)&&TL.test(e)||(t==="v6"||!t)&&AL.test(e))}function DL(e,t){if(!kL.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function zL(e,t){return!!((t==="v4"||!t)&&CL.test(e)||(t==="v6"||!t)&&OL.test(e))}var $a=class e extends we{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==K.string){let a=this._getOrReturnCtx(t);return Z(a,{code:D.invalid_type,expected:K.string,received:a.parsedType}),ce}let n=new zt,i;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),Z(i,{code:D.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")t.data.length>a.value&&(i=this._getOrReturnCtx(t,i),Z(i,{code:D.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let o=t.data.length>a.value,s=t.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(t,i),o?Z(i,{code:D.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&Z(i,{code:D.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")EL.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"email",code:D.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")ww||(ww=new RegExp(IL,"u")),ww.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"emoji",code:D.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")xL.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"uuid",code:D.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")SL.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"nanoid",code:D.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")vL.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"cuid",code:D.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")bL.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"cuid2",code:D.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")wL.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"ulid",code:D.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Z(i,{validation:"url",code:D.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"regex",code:D.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(t,i),Z(i,{code:D.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(i=this._getOrReturnCtx(t,i),Z(i,{code:D.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),Z(i,{code:D.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?sA(a).test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{code:D.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?RL.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{code:D.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?ML(a).test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{code:D.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?$L.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"duration",code:D.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?jL(t.data,a.version)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"ip",code:D.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?DL(t.data,a.alg)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"jwt",code:D.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?zL(t.data,a.version)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"cidr",code:D.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?PL.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"base64",code:D.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?NL.test(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{validation:"base64url",code:D.invalid_string,message:a.message}),n.dirty()):Ae.assertNever(a);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:D.invalid_string,...re.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...re.errToObj(t)})}url(t){return this._addCheck({kind:"url",...re.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...re.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...re.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...re.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...re.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...re.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...re.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...re.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...re.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...re.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...re.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...re.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...re.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...re.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...re.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...re.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...re.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...re.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...re.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...re.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...re.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...re.errToObj(r)})}nonempty(t){return this.min(1,re.errToObj(t))}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(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};$a.create=e=>new $a({checks:[],typeName:z.ZodString,coerce:e?.coerce??!1,...ge(e)});function UL(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,a=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return a%o/10**i}var $o=class e extends we{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==K.number){let a=this._getOrReturnCtx(t);return Z(a,{code:D.invalid_type,expected:K.number,received:a.parsedType}),ce}let n,i=new zt;for(let a of this._def.checks)a.kind==="int"?Ae.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{code:D.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),Z(n,{code:D.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),Z(n,{code:D.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?UL(t.data,a.value)!==0&&(n=this._getOrReturnCtx(t,n),Z(n,{code:D.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{code:D.not_finite,message:a.message}),i.dirty()):Ae.assertNever(a);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,re.toString(r))}gt(t,r){return this.setLimit("min",t,!1,re.toString(r))}lte(t,r){return this.setLimit("max",t,!0,re.toString(r))}lt(t,r){return this.setLimit("max",t,!1,re.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:re.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:re.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:re.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:re.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:re.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:re.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:re.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:re.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:re.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:re.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ae.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};$o.create=e=>new $o({checks:[],typeName:z.ZodNumber,coerce:e?.coerce||!1,...ge(e)});var Eo=class e extends we{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==K.bigint)return this._getInvalidInput(t);let n,i=new zt;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),Z(n,{code:D.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),Z(n,{code:D.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),Z(n,{code:D.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):Ae.assertNever(a);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return Z(r,{code:D.invalid_type,expected:K.bigint,received:r.parsedType}),ce}gte(t,r){return this.setLimit("min",t,!0,re.toString(r))}gt(t,r){return this.setLimit("min",t,!1,re.toString(r))}lte(t,r){return this.setLimit("max",t,!0,re.toString(r))}lt(t,r){return this.setLimit("max",t,!1,re.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:re.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:re.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:re.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:re.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:re.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:re.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Eo.create=e=>new Eo({checks:[],typeName:z.ZodBigInt,coerce:e?.coerce??!1,...ge(e)});var Io=class extends we{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==K.boolean){let n=this._getOrReturnCtx(t);return Z(n,{code:D.invalid_type,expected:K.boolean,received:n.parsedType}),ce}return Kt(t.data)}};Io.create=e=>new Io({typeName:z.ZodBoolean,coerce:e?.coerce||!1,...ge(e)});var To=class e extends we{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==K.date){let a=this._getOrReturnCtx(t);return Z(a,{code:D.invalid_type,expected:K.date,received:a.parsedType}),ce}if(Number.isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return Z(a,{code:D.invalid_date}),ce}let n=new zt,i;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),Z(i,{code:D.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(i=this._getOrReturnCtx(t,i),Z(i,{code:D.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):Ae.assertNever(a);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:re.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:re.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};To.create=e=>new To({checks:[],coerce:e?.coerce||!1,typeName:z.ZodDate,...ge(e)});var qs=class extends we{_parse(t){if(this._getType(t)!==K.symbol){let n=this._getOrReturnCtx(t);return Z(n,{code:D.invalid_type,expected:K.symbol,received:n.parsedType}),ce}return Kt(t.data)}};qs.create=e=>new qs({typeName:z.ZodSymbol,...ge(e)});var Co=class extends we{_parse(t){if(this._getType(t)!==K.undefined){let n=this._getOrReturnCtx(t);return Z(n,{code:D.invalid_type,expected:K.undefined,received:n.parsedType}),ce}return Kt(t.data)}};Co.create=e=>new Co({typeName:z.ZodUndefined,...ge(e)});var Ao=class extends we{_parse(t){if(this._getType(t)!==K.null){let n=this._getOrReturnCtx(t);return Z(n,{code:D.invalid_type,expected:K.null,received:n.parsedType}),ce}return Kt(t.data)}};Ao.create=e=>new Ao({typeName:z.ZodNull,...ge(e)});var Ea=class extends we{constructor(){super(...arguments),this._any=!0}_parse(t){return Kt(t.data)}};Ea.create=e=>new Ea({typeName:z.ZodAny,...ge(e)});var Ei=class extends we{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Kt(t.data)}};Ei.create=e=>new Ei({typeName:z.ZodUnknown,...ge(e)});var mn=class extends we{_parse(t){let r=this._getOrReturnCtx(t);return Z(r,{code:D.invalid_type,expected:K.never,received:r.parsedType}),ce}};mn.create=e=>new mn({typeName:z.ZodNever,...ge(e)});var Xs=class extends we{_parse(t){if(this._getType(t)!==K.undefined){let n=this._getOrReturnCtx(t);return Z(n,{code:D.invalid_type,expected:K.void,received:n.parsedType}),ce}return Kt(t.data)}};Xs.create=e=>new Xs({typeName:z.ZodVoid,...ge(e)});var Ii=class e extends we{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==K.array)return Z(r,{code:D.invalid_type,expected:K.array,received:r.parsedType}),ce;if(i.exactLength!==null){let o=r.data.length>i.exactLength.value,s=r.data.length<i.exactLength.value;(o||s)&&(Z(r,{code:o?D.too_big:D.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(Z(r,{code:D.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(Z(r,{code:D.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,s)=>i.type._parseAsync(new Xr(r,o,r.path,s)))).then(o=>zt.mergeArray(n,o));let a=[...r.data].map((o,s)=>i.type._parseSync(new Xr(r,o,r.path,s)));return zt.mergeArray(n,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:re.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:re.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:re.toString(r)}})}nonempty(t){return this.min(1,t)}};Ii.create=(e,t)=>new Ii({type:e,minLength:null,maxLength:null,exactLength:null,typeName:z.ZodArray,...ge(t)});function Ks(e){if(e instanceof kr){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=qr.create(Ks(n))}return new kr({...e._def,shape:()=>t})}else return e instanceof Ii?new Ii({...e._def,type:Ks(e.element)}):e instanceof qr?qr.create(Ks(e.unwrap())):e instanceof Kn?Kn.create(Ks(e.unwrap())):e instanceof Jn?Jn.create(e.items.map(t=>Ks(t))):e}var kr=class e extends we{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=Ae.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==K.object){let l=this._getOrReturnCtx(t);return Z(l,{code:D.invalid_type,expected:K.object,received:l.parsedType}),ce}let{status:n,ctx:i}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof mn&&this._def.unknownKeys==="strip"))for(let l in i.data)o.includes(l)||s.push(l);let c=[];for(let l of o){let u=a[l],d=i.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Xr(i,d,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof mn){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(l==="strict")s.length>0&&(Z(i,{code:D.unrecognized_keys,keys:s}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of s){let d=i.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Xr(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let d=await u.key,f=await u.value;l.push({key:d,value:f,alwaysSet:u.alwaysSet})}return l}).then(l=>zt.mergeObjectSync(n,l)):zt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return re.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:re.errToObj(t).message??i}:{message:i}}}:{}})}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:z.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of Ae.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of Ae.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return Ks(this)}partial(t){let r={};for(let n of Ae.objectKeys(this.shape)){let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of Ae.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof qr;)a=a._def.innerType;r[n]=a}return new e({...this._def,shape:()=>r})}keyof(){return cA(Ae.objectKeys(this.shape))}};kr.create=(e,t)=>new kr({shape:()=>e,unknownKeys:"strip",catchall:mn.create(),typeName:z.ZodObject,...ge(t)});kr.strictCreate=(e,t)=>new kr({shape:()=>e,unknownKeys:"strict",catchall:mn.create(),typeName:z.ZodObject,...ge(t)});kr.lazycreate=(e,t)=>new kr({shape:e,unknownKeys:"strip",catchall:mn.create(),typeName:z.ZodObject,...ge(t)});var Oo=class extends we{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(s=>new Sr(s.ctx.common.issues));return Z(r,{code:D.invalid_union,unionErrors:o}),ce}if(r.common.async)return Promise.all(n.map(async a=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(i);{let a,o=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(c=>new Sr(c));return Z(r,{code:D.invalid_union,unionErrors:s}),ce}}get options(){return this._def.options}};Oo.create=(e,t)=>new Oo({options:e,typeName:z.ZodUnion,...ge(t)});var $i=e=>e instanceof No?$i(e.schema):e instanceof Yr?$i(e.innerType()):e instanceof Ro?[e.value]:e instanceof Mo?e.options:e instanceof jo?Ae.objectValues(e.enum):e instanceof Do?$i(e._def.innerType):e instanceof Co?[void 0]:e instanceof Ao?[null]:e instanceof qr?[void 0,...$i(e.unwrap())]:e instanceof Kn?[null,...$i(e.unwrap())]:e instanceof jl||e instanceof Uo?$i(e.unwrap()):e instanceof zo?$i(e._def.innerType):[],Cp=class e extends we{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==K.object)return Z(r,{code:D.invalid_type,expected:K.object,received:r.parsedType}),ce;let n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(Z(r,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ce)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let a of r){let o=$i(a.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of o){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,a)}}return new e({typeName:z.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...ge(n)})}};function xw(e,t){let r=Wn(e),n=Wn(t);if(e===t)return{valid:!0,data:e};if(r===K.object&&n===K.object){let i=Ae.objectKeys(t),a=Ae.objectKeys(e).filter(s=>i.indexOf(s)!==-1),o={...e,...t};for(let s of a){let c=xw(e[s],t[s]);if(!c.valid)return{valid:!1};o[s]=c.data}return{valid:!0,data:o}}else if(r===K.array&&n===K.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=t[a],c=xw(o,s);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return r===K.date&&n===K.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Po=class extends we{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(a,o)=>{if(Ip(a)||Ip(o))return ce;let s=xw(a.value,o.value);return s.valid?((Tp(a)||Tp(o))&&r.dirty(),{status:r.value,value:s.data}):(Z(n,{code:D.invalid_intersection_types}),ce)};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(([a,o])=>i(a,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Po.create=(e,t,r)=>new Po({left:e,right:t,typeName:z.ZodIntersection,...ge(r)});var Jn=class e extends we{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==K.array)return Z(n,{code:D.invalid_type,expected:K.array,received:n.parsedType}),ce;if(n.data.length<this._def.items.length)return Z(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ce;!this._def.rest&&n.data.length>this._def.items.length&&(Z(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((o,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new Xr(n,o,n.path,s)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>zt.mergeArray(r,o)):zt.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Jn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Jn({items:e,typeName:z.ZodTuple,rest:null,...ge(t)})};var Ap=class e extends we{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==K.object)return Z(n,{code:D.invalid_type,expected:K.object,received:n.parsedType}),ce;let i=[],a=this._def.keyType,o=this._def.valueType;for(let s in n.data)i.push({key:a._parse(new Xr(n,s,n.path,s)),value:o._parse(new Xr(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?zt.mergeObjectAsync(r,i):zt.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof we?new e({keyType:t,valueType:r,typeName:z.ZodRecord,...ge(n)}):new e({keyType:$a.create(),valueType:t,typeName:z.ZodRecord,...ge(r)})}},Ys=class extends we{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==K.map)return Z(n,{code:D.invalid_type,expected:K.map,received:n.parsedType}),ce;let i=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([s,c],l)=>({key:i._parse(new Xr(n,s,n.path,[l,"key"])),value:a._parse(new Xr(n,c,n.path,[l,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of o){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return ce;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(l.value,u.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of o){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return ce;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(l.value,u.value)}return{status:r.value,value:s}}}};Ys.create=(e,t,r)=>new Ys({valueType:t,keyType:e,typeName:z.ZodMap,...ge(r)});var Qs=class e extends we{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==K.set)return Z(n,{code:D.invalid_type,expected:K.set,received:n.parsedType}),ce;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(Z(n,{code:D.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(Z(n,{code:D.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let a=this._def.valueType;function o(c){let l=new Set;for(let u of c){if(u.status==="aborted")return ce;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}let s=[...n.data.values()].map((c,l)=>a._parse(new Xr(n,c,n.path,l)));return n.common.async?Promise.all(s).then(c=>o(c)):o(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:re.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:re.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Qs.create=(e,t)=>new Qs({valueType:e,minSize:null,maxSize:null,typeName:z.ZodSet,...ge(t)});var Op=class e extends we{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==K.function)return Z(r,{code:D.invalid_type,expected:K.function,received:r.parsedType}),ce;function n(s,c){return Ml({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ws(),ki].filter(l=>!!l),issueData:{code:D.invalid_arguments,argumentsError:c}})}function i(s,c){return Ml({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ws(),ki].filter(l=>!!l),issueData:{code:D.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Ia){let s=this;return Kt(async function(...c){let l=new Sr([]),u=await s._def.args.parseAsync(c,a).catch(p=>{throw l.addIssue(n(c,p)),l}),d=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(d,a).catch(p=>{throw l.addIssue(i(d,p)),l})})}else{let s=this;return Kt(function(...c){let l=s._def.args.safeParse(c,a);if(!l.success)throw new Sr([n(c,l.error)]);let u=Reflect.apply(o,this,l.data),d=s._def.returns.safeParse(u,a);if(!d.success)throw new Sr([i(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Jn.create(t).rest(Ei.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||Jn.create([]).rest(Ei.create()),returns:r||Ei.create(),typeName:z.ZodFunction,...ge(n)})}},No=class extends we{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};No.create=(e,t)=>new No({getter:e,typeName:z.ZodLazy,...ge(t)});var Ro=class extends we{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return Z(r,{received:r.data,code:D.invalid_literal,expected:this._def.value}),ce}return{status:"valid",value:t.data}}get value(){return this._def.value}};Ro.create=(e,t)=>new Ro({value:e,typeName:z.ZodLiteral,...ge(t)});function cA(e,t){return new Mo({values:e,typeName:z.ZodEnum,...ge(t)})}var Mo=class e extends we{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return Z(r,{expected:Ae.joinValues(n),received:r.parsedType,code:D.invalid_type}),ce}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return Z(r,{received:r.data,code:D.invalid_enum_value,options:n}),ce}return Kt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};Mo.create=cA;var jo=class extends we{_parse(t){let r=Ae.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==K.string&&n.parsedType!==K.number){let i=Ae.objectValues(r);return Z(n,{expected:Ae.joinValues(i),received:n.parsedType,code:D.invalid_type}),ce}if(this._cache||(this._cache=new Set(Ae.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=Ae.objectValues(r);return Z(n,{received:n.data,code:D.invalid_enum_value,options:i}),ce}return Kt(t.data)}get enum(){return this._def.values}};jo.create=(e,t)=>new jo({values:e,typeName:z.ZodNativeEnum,...ge(t)});var Ia=class extends we{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==K.promise&&r.common.async===!1)return Z(r,{code:D.invalid_type,expected:K.promise,received:r.parsedType}),ce;let n=r.parsedType===K.promise?r.data:Promise.resolve(r.data);return Kt(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Ia.create=(e,t)=>new Ia({type:e,typeName:z.ZodPromise,...ge(t)});var Yr=class extends we{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:o=>{Z(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let o=i.transform(n.data,a);if(n.common.async)return Promise.resolve(o).then(async s=>{if(r.value==="aborted")return ce;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?ce:c.status==="dirty"?ko(c.value):r.value==="dirty"?ko(c.value):c});{if(r.value==="aborted")return ce;let s=this._def.schema._parseSync({data:o,path:n.path,parent:n});return s.status==="aborted"?ce:s.status==="dirty"?ko(s.value):r.value==="dirty"?ko(s.value):s}}if(i.type==="refinement"){let o=s=>{let c=i.refinement(s,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ce:(s.status==="dirty"&&r.dirty(),o(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?ce:(s.status==="dirty"&&r.dirty(),o(s.value).then(()=>({status:r.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ka(o))return ce;let s=i.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>ka(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:r.value,value:s})):ce);Ae.assertNever(i)}};Yr.create=(e,t,r)=>new Yr({schema:e,typeName:z.ZodEffects,effect:t,...ge(r)});Yr.createWithPreprocess=(e,t,r)=>new Yr({schema:t,effect:{type:"preprocess",transform:e},typeName:z.ZodEffects,...ge(r)});var qr=class extends we{_parse(t){return this._getType(t)===K.undefined?Kt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};qr.create=(e,t)=>new qr({innerType:e,typeName:z.ZodOptional,...ge(t)});var Kn=class extends we{_parse(t){return this._getType(t)===K.null?Kt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Kn.create=(e,t)=>new Kn({innerType:e,typeName:z.ZodNullable,...ge(t)});var Do=class extends we{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===K.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Do.create=(e,t)=>new Do({innerType:e,typeName:z.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ge(t)});var zo=class extends we{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Js(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Sr(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Sr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};zo.create=(e,t)=>new zo({innerType:e,typeName:z.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ge(t)});var ec=class extends we{_parse(t){if(this._getType(t)!==K.nan){let n=this._getOrReturnCtx(t);return Z(n,{code:D.invalid_type,expected:K.nan,received:n.parsedType}),ce}return{status:"valid",value:t.data}}};ec.create=e=>new ec({typeName:z.ZodNaN,...ge(e)});var LL=Symbol("zod_brand"),jl=class extends we{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Dl=class e extends we{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?ce:a.status==="dirty"?(r.dirty(),ko(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ce:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:z.ZodPipeline})}},Uo=class extends we{_parse(t){let r=this._def.innerType._parse(t),n=i=>(ka(i)&&(i.value=Object.freeze(i.value)),i);return Js(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};Uo.create=(e,t)=>new Uo({innerType:e,typeName:z.ZodReadonly,...ge(t)});function iA(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function lA(e,t={},r){return e?Ea.create().superRefine((n,i)=>{let a=e(n);if(a instanceof Promise)return a.then(o=>{if(!o){let s=iA(t,n),c=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:c})}});if(!a){let o=iA(t,n),s=o.fatal??r??!0;i.addIssue({code:"custom",...o,fatal:s})}}):Ea.create()}var FL={object:kr.lazycreate},z;(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"})(z||(z={}));var BL=(e,t={message:`Input not instance of ${e.name}`})=>lA(r=>r instanceof e,t),uA=$a.create,dA=$o.create,VL=ec.create,ZL=Eo.create,fA=Io.create,HL=To.create,GL=qs.create,WL=Co.create,JL=Ao.create,KL=Ea.create,qL=Ei.create,XL=mn.create,YL=Xs.create,QL=Ii.create,e6=kr.create,t6=kr.strictCreate,r6=Oo.create,n6=Cp.create,i6=Po.create,a6=Jn.create,o6=Ap.create,s6=Ys.create,c6=Qs.create,l6=Op.create,u6=No.create,d6=Ro.create,f6=Mo.create,p6=jo.create,m6=Ia.create,h6=Yr.create,g6=qr.create,_6=Kn.create,y6=Yr.createWithPreprocess,v6=Dl.create,b6=()=>uA().optional(),w6=()=>dA().optional(),x6=()=>fA().optional(),S6={string:(e=>$a.create({...e,coerce:!0})),number:(e=>$o.create({...e,coerce:!0})),boolean:(e=>Io.create({...e,coerce:!0})),bigint:(e=>Eo.create({...e,coerce:!0})),date:(e=>To.create({...e,coerce:!0}))};var k6=ce;function pA(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==z.ZodAny&&(r.items=le(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Me(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Me(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Me(r,"minItems",e.exactLength.value,e.exactLength.message,t),Me(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function mA(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?Me(r,"minimum",n.value,n.message,t):Me(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Me(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?Me(r,"maximum",n.value,n.message,t):Me(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Me(r,"maximum",n.value,n.message,t));break;case"multipleOf":Me(r,"multipleOf",n.value,n.message,t);break}return r}function hA(){return{type:"boolean"}}function Pp(e,t){return le(e.type._def,t)}var gA=(e,t)=>le(e.innerType._def,t);function Sw(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map(i=>Sw(e,t,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return $6(e,t)}}var $6=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":Me(r,"minimum",n.value,n.message,t);break;case"max":Me(r,"maximum",n.value,n.message,t);break}return r};function _A(e,t){return{...le(e.innerType._def,t),default:e.defaultValue()}}function yA(e,t){return t.effectStrategy==="input"?le(e.schema._def,t):nt(t)}function vA(e){return{type:"string",enum:Array.from(e.values)}}var E6=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function bA(e,t){let r=[le(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),le(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(a=>!!a),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(a=>{if(E6(a))i.push(...a.allOf),a.unevaluatedProperties===void 0&&(n=void 0);else{let o=a;if("additionalProperties"in a&&a.additionalProperties===!1){let{additionalProperties:s,...c}=a;o=c}else n=void 0;i.push(o)}}),i.length?{allOf:i,...n}:void 0}function wA(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var kw,hn={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:()=>(kw===void 0&&(kw=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),kw),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 Np(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":Me(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":Me(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":gn(r,"email",n.message,t);break;case"format:idn-email":gn(r,"idn-email",n.message,t);break;case"pattern:zod":pr(r,hn.email,n.message,t);break}break;case"url":gn(r,"uri",n.message,t);break;case"uuid":gn(r,"uuid",n.message,t);break;case"regex":pr(r,n.regex,n.message,t);break;case"cuid":pr(r,hn.cuid,n.message,t);break;case"cuid2":pr(r,hn.cuid2,n.message,t);break;case"startsWith":pr(r,RegExp(`^${$w(n.value,t)}`),n.message,t);break;case"endsWith":pr(r,RegExp(`${$w(n.value,t)}$`),n.message,t);break;case"datetime":gn(r,"date-time",n.message,t);break;case"date":gn(r,"date",n.message,t);break;case"time":gn(r,"time",n.message,t);break;case"duration":gn(r,"duration",n.message,t);break;case"length":Me(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),Me(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":pr(r,RegExp($w(n.value,t)),n.message,t);break;case"ip":n.version!=="v6"&&gn(r,"ipv4",n.message,t),n.version!=="v4"&&gn(r,"ipv6",n.message,t);break;case"base64url":pr(r,hn.base64url,n.message,t);break;case"jwt":pr(r,hn.jwt,n.message,t);break;case"cidr":n.version!=="v6"&&pr(r,hn.ipv4Cidr,n.message,t),n.version!=="v4"&&pr(r,hn.ipv6Cidr,n.message,t);break;case"emoji":pr(r,hn.emoji(),n.message,t);break;case"ulid":pr(r,hn.ulid,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":gn(r,"binary",n.message,t);break;case"contentEncoding:base64":Me(r,"contentEncoding","base64",n.message,t);break;case"pattern:zod":pr(r,hn.base64,n.message,t);break}break;case"nanoid":pr(r,hn.nanoid,n.message,t);break;case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function $w(e,t){return t.patternStrategy==="escape"?T6(e):e}var I6=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function T6(e){let t="";for(let r=0;r<e.length;r++)I6.has(e[r])||(t+="\\"),t+=e[r];return t}function gn(e,t,r,n){e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.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,...r&&n.errorMessages&&{errorMessage:{format:r}}})):Me(e,"format",t,r,n)}function pr(e,t,r,n){e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.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:xA(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):Me(e,"pattern",xA(t,n),r,n)}function xA(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=r.i?e.source.toLowerCase():e.source,i="",a=!1,o=!1,s=!1;for(let c=0;c<n.length;c++){if(a){i+=n[c],a=!1;continue}if(r.i){if(o){if(n[c].match(/[a-z]/)){s?(i+=n[c],i+=`${n[c-2]}-${n[c]}`.toUpperCase(),s=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(i+=n[c],s=!0):i+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){i+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){i+=`(^|(?<=[\r
219
+ ]))`;continue}else if(n[c]==="$"){i+=`($|(?=[\r
220
+ ]))`;continue}}if(r.s&&n[c]==="."){i+=o?`${n[c]}\r
221
+ `:`[${n[c]}\r
222
+ ]`;continue}i+=n[c],n[c]==="\\"?a=!0:o&&n[c]==="]"?o=!1:!o&&n[c]==="["&&(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 Rp(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===z.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,i)=>({...n,[i]:le(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??nt(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:le(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===z.ZodString&&e.keyType._def.checks?.length){let{type:n,...i}=Np(e.keyType._def,t);return{...r,propertyNames:i}}else{if(e.keyType?._def.typeName===z.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===z.ZodBranded&&e.keyType._def.type._def.typeName===z.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...i}=Pp(e.keyType._def,t);return{...r,propertyNames:i}}}return r}function SA(e,t){return t.mapStrategy==="record"?Rp(e,t):{type:"array",maxItems:125,items:{type:"array",items:[le(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||nt(t),le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||nt(t)],minItems:2,maxItems:2}}}function kA(e){let t=e.values,r=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(r.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:r}}function $A(e){return e.target==="openAi"?void 0:{not:nt({...e,currentPath:[...e.currentPath,"not"]})}}function EA(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var zl={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function TA(e,t){if(t.target==="openApi3")return IA(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in zl&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,a)=>{let o=zl[a._def.typeName];return o&&!i.includes(o)?[...i,o]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,a)=>{let o=typeof a._def.value;switch(o){case"string":case"number":case"boolean":return[...i,o];case"bigint":return[...i,"integer"];case"object":return a._def.value===null?[...i,"null"]:i;default:return i}},[]);if(n.length===r.length){let i=n.filter((a,o,s)=>s.indexOf(a)===o);return{type:i.length>1?i:i[0],enum:r.reduce((a,o)=>a.includes(o._def.value)?a:[...a,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(a=>!n.includes(a))],[])};return IA(e,t)}var IA=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,i)=>le(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function CA(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:zl[e.innerType._def.typeName],nullable:!0}:{type:[zl[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=le(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function AA(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",vw(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?Me(r,"minimum",n.value,n.message,t):Me(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Me(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?Me(r,"maximum",n.value,n.message,t):Me(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Me(r,"maximum",n.value,n.message,t));break;case"multipleOf":Me(r,"multipleOf",n.value,n.message,t);break}return r}function OA(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},i=[],a=e.shape();for(let s in a){let c=a[s];if(c===void 0||c._def===void 0)continue;let l=A6(c);l&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),l=!1);let u=le(c._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});u!==void 0&&(n.properties[s]=u,l||i.push(s))}i.length&&(n.required=i);let o=C6(e,t);return o!==void 0&&(n.additionalProperties=o),n}function C6(e,t){if(e.catchall._def.typeName!=="ZodNever")return le(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 A6(e){try{return e.isOptional()}catch{return!0}}var PA=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return le(e.innerType._def,t);let r=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:nt(t)},r]}:nt(t)};var NA=(e,t)=>{if(t.pipeStrategy==="input")return le(e.in._def,t);if(t.pipeStrategy==="output")return le(e.out._def,t);let r=le(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,le(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(n=>n!==void 0)}};function RA(e,t){return le(e.type._def,t)}function MA(e,t){let r={type:"array",uniqueItems:!0,items:le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Me(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Me(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}function jA(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>le(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:le(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>le(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function DA(e){return{not:nt(e)}}function zA(e){return nt(e)}var UA=(e,t)=>le(e.innerType._def,t);var LA=(e,t,r)=>{switch(t){case z.ZodString:return Np(e,r);case z.ZodNumber:return AA(e,r);case z.ZodObject:return OA(e,r);case z.ZodBigInt:return mA(e,r);case z.ZodBoolean:return hA();case z.ZodDate:return Sw(e,r);case z.ZodUndefined:return DA(r);case z.ZodNull:return EA(r);case z.ZodArray:return pA(e,r);case z.ZodUnion:case z.ZodDiscriminatedUnion:return TA(e,r);case z.ZodIntersection:return bA(e,r);case z.ZodTuple:return jA(e,r);case z.ZodRecord:return Rp(e,r);case z.ZodLiteral:return wA(e,r);case z.ZodEnum:return vA(e);case z.ZodNativeEnum:return kA(e);case z.ZodNullable:return CA(e,r);case z.ZodOptional:return PA(e,r);case z.ZodMap:return SA(e,r);case z.ZodSet:return MA(e,r);case z.ZodLazy:return()=>e.getter()._def;case z.ZodPromise:return RA(e,r);case z.ZodNaN:case z.ZodNever:return $A(r);case z.ZodEffects:return yA(e,r);case z.ZodAny:return nt(r);case z.ZodUnknown:return zA(r);case z.ZodDefault:return _A(e,r);case z.ZodBranded:return Pp(e,r);case z.ZodReadonly:return UA(e,r);case z.ZodCatch:return gA(e,r);case z.ZodPipeline:return NA(e,r);case z.ZodFunction:case z.ZodVoid:case z.ZodSymbol:return;default:return(n=>{})(t)}};function le(e,t,r=!1){let n=t.seen.get(e);if(t.override){let s=t.override?.(e,t,n,r);if(s!==QC)return s}if(n&&!r){let s=O6(n,t);if(s!==void 0)return s}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=LA(e,e.typeName,t),o=typeof a=="function"?le(a(),t):a;if(o&&P6(e,t,o),t.postProcess){let s=t.postProcess(o,e,t);return i.jsonSchema=o,s}return i.jsonSchema=o,o}var O6=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Ep(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),nt(t)):t.$refStrategy==="seen"?nt(t):void 0}},P6=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var FA=(e,t)=>{let r=tA(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[l,u])=>({...c,[l]:le(u._def,{...r,currentPath:[...r.basePath,r.definitionPath,l]},!0)??nt(r)}),{}):void 0,i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=le(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??nt(r),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(a.title=o),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=i===void 0?n?{...a,[r.definitionPath]:n}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:a}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),r.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};function qn(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;i++)if(!qn(e[i],t[i]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(let o of n)if(!qn(e[o],t[o]))return!1;return!0}return e===t}function Ur(e){return encodeURI(N6(e))}function N6(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var R6={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},M6={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},j6={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},D6=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function _n(e,t=Object.create(null),r=D6,n=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let a=e.$id||e.id;if(a){let o=new URL(a,r.href);o.hash.length>1?t[o.href]=e:(o.hash="",n===""?r=o:_n(e,t,r))}}else if(e!==!0&&e!==!1)return t;let i=r.href+(n?"#"+n:"");if(t[i]!==void 0)throw new Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let a=new URL(e.$ref,r.href);a.hash=a.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:a.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let a=new URL(e.$recursiveRef,r.href);a.hash=a.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:a.href})}if(e.$anchor){let a=new URL("#"+e.$anchor,r.href);t[a.href]=e}for(let a in e){if(j6[a])continue;let o=`${n}/${Ur(a)}`,s=e[a];if(Array.isArray(s)){if(R6[a]){let c=s.length;for(let l=0;l<c;l++)_n(s[l],t,r,`${o}/${l}`)}}else if(M6[a])for(let c in s)_n(s[c],t,r,`${o}/${Ur(c)}`);else _n(s,t,r,o)}return t}var z6=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,U6=[0,31,28,31,30,31,30,31,31,30,31,30,31],L6=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,F6=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,B6=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,V6=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Z6=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,H6=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,G6=/^(?:\/(?:[^~/]|~0|~1)*)*$/,W6=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,J6=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,K6=e=>{if(e[0]==='"')return!1;let[t,r,...n]=e.split("@");return!t||!r||n.length!==0||t.length>64||r.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:r.split(".").every(i=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(i))},q6=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,X6=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,Y6=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Xn(e){return e.test.bind(e)}var Ew={date:BA,time:VA.bind(void 0,!1),"date-time":tF,duration:Y6,uri:iF,"uri-reference":Xn(B6),"uri-template":Xn(V6),url:Xn(Z6),email:K6,hostname:Xn(F6),ipv4:Xn(q6),ipv6:Xn(X6),regex:oF,uuid:Xn(H6),"json-pointer":Xn(G6),"json-pointer-uri-fragment":Xn(W6),"relative-json-pointer":Xn(J6)};function Q6(e){return e%4===0&&(e%100!==0||e%400===0)}function BA(e){let t=e.match(z6);if(!t)return!1;let r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(n==2&&Q6(r)?29:U6[n])}function VA(e,t){let r=t.match(L6);if(!r)return!1;let n=+r[1],i=+r[2],a=+r[3],o=!!r[5];return(n<=23&&i<=59&&a<=59||n==23&&i==59&&a==60)&&(!e||o)}var eF=/t|\s/i;function tF(e){let t=e.split(eF);return t.length==2&&BA(t[0])&&VA(!0,t[1])}var rF=/\/|:/,nF=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function iF(e){return rF.test(e)&&nF.test(e)}var aF=/[^\\]\\Z/;function oF(e){if(aF.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}var ZA;(function(e){e[e.Flag=1]="Flag",e[e.Basic=2]="Basic",e[e.Detailed=4]="Detailed"})(ZA||(ZA={}));function HA(e){let t=0,r=e.length,n=0,i;for(;n<r;)t++,i=e.charCodeAt(n++),i>=55296&&i<=56319&&n<r&&(i=e.charCodeAt(n),(i&64512)==56320&&n++);return t}function We(e,t,r="2019-09",n=_n(t),i=!0,a=null,o="#",s="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:"false",keywordLocation:o,error:"False boolean schema."}]};let l=typeof e,u;switch(l){case"boolean":case"number":case"string":u=l;break;case"object":e===null?u="null":Array.isArray(e)?u="array":u="object";break;default:throw new Error(`Instances of "${l}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:h,enum:_,required:y,not:w,anyOf:x,allOf:S,oneOf:$,if:P,then:C,else:b,format:B,properties:L,patternProperties:q,additionalProperties:ae,unevaluatedProperties:Se,minProperties:Oe,maxProperties:mt,propertyNames:ye,dependentRequired:V,dependentSchemas:Y,dependencies:ne,prefixItems:ie,items:Te,additionalItems:Tr,unevaluatedItems:Li,contains:Fi,minContains:on,maxContains:v,minItems:g,maxItems:O,uniqueItems:E,minimum:Ce,maximum:Ue,exclusiveMinimum:bt,exclusiveMaximum:dt,multipleOf:Lt,minLength:Br,maxLength:ft,pattern:Cn,__absolute_ref__:Yo,__absolute_recursive_ref__:Bu}=t,J=[];if(p===!0&&a===null&&(a=t),f==="#"){let ue=a===null?n[Bu]:a,oe=`${s}/$recursiveRef`,me=We(e,a===null?t:a,r,n,i,ue,o,oe,c);me.valid||J.push({instanceLocation:o,keyword:"$recursiveRef",keywordLocation:oe,error:"A subschema had errors."},...me.errors)}if(d!==void 0){let oe=n[Yo||d];if(oe===void 0){let G=`Unresolved $ref "${d}".`;throw Yo&&Yo!==d&&(G+=` Absolute URI "${Yo}".`),G+=`
223
+ Known schemas:
224
+ - ${Object.keys(n).join(`
225
+ - `)}`,new Error(G)}let me=`${s}/$ref`,Q=We(e,oe,r,n,i,a,o,me,c);if(Q.valid||J.push({instanceLocation:o,keyword:"$ref",keywordLocation:me,error:"A subschema had errors."},...Q.errors),r==="4"||r==="7")return{valid:J.length===0,errors:J}}if(Array.isArray(m)){let ue=m.length,oe=!1;for(let me=0;me<ue;me++)if(u===m[me]||m[me]==="integer"&&u==="number"&&e%1===0&&e===e){oe=!0;break}oe||J.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m.join('", "')}".`})}else m==="integer"?(u!=="number"||e%1||e!==e)&&J.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`}):m!==void 0&&u!==m&&J.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`});if(h!==void 0&&(u==="object"||u==="array"?qn(e,h)||J.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&J.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),_!==void 0&&(u==="object"||u==="array"?_.some(ue=>qn(e,ue))||J.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(_)}.`}):_.some(ue=>e===ue)||J.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(_)}.`})),w!==void 0){let ue=`${s}/not`;We(e,w,r,n,i,a,o,ue).valid&&J.push({instanceLocation:o,keyword:"not",keywordLocation:ue,error:'Instance matched "not" schema.'})}let Ua=[];if(x!==void 0){let ue=`${s}/anyOf`,oe=J.length,me=!1;for(let Q=0;Q<x.length;Q++){let G=x[Q],fe=Object.create(c),de=We(e,G,r,n,i,p===!0?a:null,o,`${ue}/${Q}`,fe);J.push(...de.errors),me=me||de.valid,de.valid&&Ua.push(fe)}me?J.length=oe:J.splice(oe,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:ue,error:"Instance does not match any subschemas."})}if(S!==void 0){let ue=`${s}/allOf`,oe=J.length,me=!0;for(let Q=0;Q<S.length;Q++){let G=S[Q],fe=Object.create(c),de=We(e,G,r,n,i,p===!0?a:null,o,`${ue}/${Q}`,fe);J.push(...de.errors),me=me&&de.valid,de.valid&&Ua.push(fe)}me?J.length=oe:J.splice(oe,0,{instanceLocation:o,keyword:"allOf",keywordLocation:ue,error:"Instance does not match every subschema."})}if($!==void 0){let ue=`${s}/oneOf`,oe=J.length,me=$.filter((Q,G)=>{let fe=Object.create(c),de=We(e,Q,r,n,i,p===!0?a:null,o,`${ue}/${G}`,fe);return J.push(...de.errors),de.valid&&Ua.push(fe),de.valid}).length;me===1?J.length=oe:J.splice(oe,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:ue,error:`Instance does not match exactly one subschema (${me} matches).`})}if((u==="object"||u==="array")&&Object.assign(c,...Ua),P!==void 0){let ue=`${s}/if`;if(We(e,P,r,n,i,a,o,ue,c).valid){if(C!==void 0){let me=We(e,C,r,n,i,a,o,`${s}/then`,c);me.valid||J.push({instanceLocation:o,keyword:"if",keywordLocation:ue,error:'Instance does not match "then" schema.'},...me.errors)}}else if(b!==void 0){let me=We(e,b,r,n,i,a,o,`${s}/else`,c);me.valid||J.push({instanceLocation:o,keyword:"if",keywordLocation:ue,error:'Instance does not match "else" schema.'},...me.errors)}}if(u==="object"){if(y!==void 0)for(let Q of y)Q in e||J.push({instanceLocation:o,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${Q}".`});let ue=Object.keys(e);if(Oe!==void 0&&ue.length<Oe&&J.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${Oe} properties.`}),mt!==void 0&&ue.length>mt&&J.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${mt} properties.`}),ye!==void 0){let Q=`${s}/propertyNames`;for(let G in e){let fe=`${o}/${Ur(G)}`,de=We(G,ye,r,n,i,a,fe,Q);de.valid||J.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:Q,error:`Property name "${G}" does not match schema.`},...de.errors)}}if(V!==void 0){let Q=`${s}/dependantRequired`;for(let G in V)if(G in e){let fe=V[G];for(let de of fe)de in e||J.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:Q,error:`Instance has "${G}" but does not have "${de}".`})}}if(Y!==void 0)for(let Q in Y){let G=`${s}/dependentSchemas`;if(Q in e){let fe=We(e,Y[Q],r,n,i,a,o,`${G}/${Ur(Q)}`,c);fe.valid||J.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:G,error:`Instance has "${Q}" but does not match dependant schema.`},...fe.errors)}}if(ne!==void 0){let Q=`${s}/dependencies`;for(let G in ne)if(G in e){let fe=ne[G];if(Array.isArray(fe))for(let de of fe)de in e||J.push({instanceLocation:o,keyword:"dependencies",keywordLocation:Q,error:`Instance has "${G}" but does not have "${de}".`});else{let de=We(e,fe,r,n,i,a,o,`${Q}/${Ur(G)}`);de.valid||J.push({instanceLocation:o,keyword:"dependencies",keywordLocation:Q,error:`Instance has "${G}" but does not match dependant schema.`},...de.errors)}}}let oe=Object.create(null),me=!1;if(L!==void 0){let Q=`${s}/properties`;for(let G in L){if(!(G in e))continue;let fe=`${o}/${Ur(G)}`,de=We(e[G],L[G],r,n,i,a,fe,`${Q}/${Ur(G)}`);if(de.valid)c[G]=oe[G]=!0;else if(me=i,J.push({instanceLocation:o,keyword:"properties",keywordLocation:Q,error:`Property "${G}" does not match schema.`},...de.errors),me)break}}if(!me&&q!==void 0){let Q=`${s}/patternProperties`;for(let G in q){let fe=new RegExp(G,"u"),de=q[G];for(let gr in e){if(!fe.test(gr))continue;let VS=`${o}/${Ur(gr)}`,ZS=We(e[gr],de,r,n,i,a,VS,`${Q}/${Ur(G)}`);ZS.valid?c[gr]=oe[gr]=!0:(me=i,J.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:Q,error:`Property "${gr}" matches pattern "${G}" but does not match associated schema.`},...ZS.errors))}}}if(!me&&ae!==void 0){let Q=`${s}/additionalProperties`;for(let G in e){if(oe[G])continue;let fe=`${o}/${Ur(G)}`,de=We(e[G],ae,r,n,i,a,fe,Q);de.valid?c[G]=!0:(me=i,J.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:Q,error:`Property "${G}" does not match additional properties schema.`},...de.errors))}}else if(!me&&Se!==void 0){let Q=`${s}/unevaluatedProperties`;for(let G in e)if(!c[G]){let fe=`${o}/${Ur(G)}`,de=We(e[G],Se,r,n,i,a,fe,Q);de.valid?c[G]=!0:J.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:Q,error:`Property "${G}" does not match unevaluated properties schema.`},...de.errors)}}}else if(u==="array"){O!==void 0&&e.length>O&&J.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${O}).`}),g!==void 0&&e.length<g&&J.push({instanceLocation:o,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${g}).`});let ue=e.length,oe=0,me=!1;if(ie!==void 0){let Q=`${s}/prefixItems`,G=Math.min(ie.length,ue);for(;oe<G;oe++){let fe=We(e[oe],ie[oe],r,n,i,a,`${o}/${oe}`,`${Q}/${oe}`);if(c[oe]=!0,!fe.valid&&(me=i,J.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:Q,error:"Items did not match schema."},...fe.errors),me))break}}if(Te!==void 0){let Q=`${s}/items`;if(Array.isArray(Te)){let G=Math.min(Te.length,ue);for(;oe<G;oe++){let fe=We(e[oe],Te[oe],r,n,i,a,`${o}/${oe}`,`${Q}/${oe}`);if(c[oe]=!0,!fe.valid&&(me=i,J.push({instanceLocation:o,keyword:"items",keywordLocation:Q,error:"Items did not match schema."},...fe.errors),me))break}}else for(;oe<ue;oe++){let G=We(e[oe],Te,r,n,i,a,`${o}/${oe}`,Q);if(c[oe]=!0,!G.valid&&(me=i,J.push({instanceLocation:o,keyword:"items",keywordLocation:Q,error:"Items did not match schema."},...G.errors),me))break}if(!me&&Tr!==void 0){let G=`${s}/additionalItems`;for(;oe<ue;oe++){let fe=We(e[oe],Tr,r,n,i,a,`${o}/${oe}`,G);c[oe]=!0,fe.valid||(me=i,J.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:G,error:"Items did not match additional items schema."},...fe.errors))}}}if(Fi!==void 0)if(ue===0&&on===void 0)J.push({instanceLocation:o,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(on!==void 0&&ue<on)J.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${ue}) than minContains (${on}).`});else{let Q=`${s}/contains`,G=J.length,fe=0;for(let de=0;de<ue;de++){let gr=We(e[de],Fi,r,n,i,a,`${o}/${de}`,Q);gr.valid?(c[de]=!0,fe++):J.push(...gr.errors)}fe>=(on||0)&&(J.length=G),on===void 0&&v===void 0&&fe===0?J.splice(G,0,{instanceLocation:o,keyword:"contains",keywordLocation:Q,error:"Array does not contain item matching schema."}):on!==void 0&&fe<on?J.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${on} items matching schema. Only ${fe} items were found.`}):v!==void 0&&fe>v&&J.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${v} items matching schema. ${fe} items were found.`})}if(!me&&Li!==void 0){let Q=`${s}/unevaluatedItems`;for(oe;oe<ue;oe++){if(c[oe])continue;let G=We(e[oe],Li,r,n,i,a,`${o}/${oe}`,Q);c[oe]=!0,G.valid||J.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:Q,error:"Items did not match unevaluated items schema."},...G.errors)}}if(E)for(let Q=0;Q<ue;Q++){let G=e[Q],fe=typeof G=="object"&&G!==null;for(let de=0;de<ue;de++){if(Q===de)continue;let gr=e[de];(G===gr||fe&&(typeof gr=="object"&&gr!==null)&&qn(G,gr))&&(J.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${Q} and ${de}.`}),Q=Number.MAX_SAFE_INTEGER,de=Number.MAX_SAFE_INTEGER)}}}else if(u==="number"){if(r==="4"?(Ce!==void 0&&(bt===!0&&e<=Ce||e<Ce)&&J.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${bt?"or equal to ":""} ${Ce}.`}),Ue!==void 0&&(dt===!0&&e>=Ue||e>Ue)&&J.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${dt?"or equal to ":""} ${Ue}.`})):(Ce!==void 0&&e<Ce&&J.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${Ce}.`}),Ue!==void 0&&e>Ue&&J.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Ue}.`}),bt!==void 0&&e<=bt&&J.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${bt}.`}),dt!==void 0&&e>=dt&&J.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${dt}.`})),Lt!==void 0){let ue=e%Lt;Math.abs(0-ue)>=11920929e-14&&Math.abs(Lt-ue)>=11920929e-14&&J.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Lt}.`})}}else if(u==="string"){let ue=Br===void 0&&ft===void 0?0:HA(e);Br!==void 0&&ue<Br&&J.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${ue} < ${Br}).`}),ft!==void 0&&ue>ft&&J.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${ue} > ${ft}).`}),Cn!==void 0&&!new RegExp(Cn,"u").test(e)&&J.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),B!==void 0&&Ew[B]&&!Ew[B](e)&&J.push({instanceLocation:o,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${B}".`})}return{valid:J.length===0,errors:J}}var Mp=class{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",n=!0){this.schema=t,this.draft=r,this.shortCircuit=n,this.lookup=_n(t)}validate(t){return We(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),_n(t,this.lookup)}};var WA=T({Validator:()=>Mp,deepCompareStrict:()=>qn,toJsonSchema:()=>Et,validatesOnlyStrings:()=>tc}),GA=new WeakMap;function Et(e,t){let r=!t&&e!=null&&typeof e=="object";if(r){let i=GA.get(e);if(i)return i}let n;if(_f(e)&&!Ge(e))n=e["~standard"].jsonSchema.input({target:"draft-07"});else if(Ge(e)){let i=kp(e,!0);Kr(i)?n=xo(Hs(i,!0),t):n=xo(e,t)}else lt(e)?n=FA(e):n=e;return r&&n!=null&&typeof n=="object"&&GA.set(e,n),n}function tc(e){if(!e||typeof e!="object"||Object.keys(e).length===0||Array.isArray(e))return!1;if("type"in e)return typeof e.type=="string"?e.type==="string":Array.isArray(e.type)?e.type.every(t=>t==="string"):!1;if("enum"in e)return Array.isArray(e.enum)&&e.enum.length>0&&e.enum.every(t=>typeof t=="string");if("const"in e)return typeof e.const=="string";if("allOf"in e&&Array.isArray(e.allOf))return e.allOf.some(t=>tc(t));if("anyOf"in e&&Array.isArray(e.anyOf)||"oneOf"in e&&Array.isArray(e.oneOf)){let t="anyOf"in e?e.anyOf:e.oneOf;return t.length>0&&t.every(r=>tc(r))}if("not"in e)return!1;if("$ref"in e&&typeof e.$ref=="string"){let t=e.$ref,r=_n(e);return r[t]?tc(r[t]):!1}return!1}function Ul(e){return e?e.lc_runnable:!1}var JA=class{includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;constructor(e){this.includeNames=e.includeNames,this.includeTypes=e.includeTypes,this.includeTags=e.includeTags,this.excludeNames=e.excludeNames,this.excludeTypes=e.excludeTypes,this.excludeTags=e.excludeTags}includeEvent(e,t){let r=this.includeNames===void 0&&this.includeTypes===void 0&&this.includeTags===void 0,n=e.tags??[];return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(t)),this.includeTags!==void 0&&(r=r||n.some(i=>this.includeTags?.includes(i))),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(t)),this.excludeTags!==void 0&&(r=r&&n.every(i=>!this.excludeTags?.includes(i))),r}},KA=e=>btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function Iw(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}var sF=["*","_","`"];function cF(e){let t="";for(let[r,n]of Object.entries(e))t+=` classDef ${r} ${n};
226
+ `;return t}function qA(e,t,r){let{firstNode:n,lastNode:i,nodeColors:a,withStyles:o=!0,curveStyle:s="linear",wrapLabelNWords:c=9}=r??{},l=o?`%%{init: {'flowchart': {'curve': '${s}'}}}%%
227
+ graph TD;
228
+ `:`graph TD;
229
+ `;if(o){let m="default",h={[m]:"{0}({1})"};n!==void 0&&(h[n]="{0}([{1}]):::first"),i!==void 0&&(h[i]="{0}([{1}]):::last");for(let[_,y]of Object.entries(e)){let w=y.name.split(":").pop()??"",x=sF.some($=>w.startsWith($)&&w.endsWith($))?`<p>${w}</p>`:w;Object.keys(y.metadata??{}).length&&(x+=`<hr/><small><em>${Object.entries(y.metadata??{}).map(([$,P])=>`${$} = ${P}`).join(`
230
+ `)}</em></small>`);let S=(h[_]??h[m]).replace("{0}",Iw(_)).replace("{1}",x);l+=` ${S}
231
+ `}}let u={};for(let m of t){let h=m.source.split(":"),_=m.target.split(":"),y=h.filter((w,x)=>w===_[x]).join(":");u[y]||(u[y]=[]),u[y].push(m)}let d=new Set;function f(m){return[...m].sort((h,_)=>h.split(":").length-_.split(":").length)}function p(m,h){let _=m.length===1&&m[0].source===m[0].target;if(h&&!_){let w=h.split(":").pop();if(d.has(h))throw new Error(`Found duplicate subgraph '${w}' at '${h} -- this likely means that you're reusing a subgraph node with the same name. Please adjust your graph to have subgraph nodes with unique names.`);d.add(h),l+=` subgraph ${w}
232
+ `}let y=f(Object.keys(u).filter(w=>w.startsWith(`${h}:`)&&w!==h&&w.split(":").length===h.split(":").length+1));for(let w of y)p(u[w],w);for(let w of m){let{source:x,target:S,data:$,conditional:P}=w,C="";if($!==void 0){let b=$,B=b.split(" ");B.length>c&&(b=Array.from({length:Math.ceil(B.length/c)},(L,q)=>B.slice(q*c,(q+1)*c).join(" ")).join("&nbsp;<br>&nbsp;")),C=P?` -. &nbsp;${b}&nbsp; .-> `:` -- &nbsp;${b}&nbsp; --> `}else C=P?" -.-> ":" --> ";l+=` ${Iw(x)}${C}${Iw(S)};
233
+ `}h&&!_&&(l+=` end
234
+ `)}p(u[""]??[],"");for(let m in u)!m.includes(":")&&m!==""&&p(u[m],m);return o&&(l+=cF(a??{})),l}async function XA(e,t){let r=t?.backgroundColor??"white",n=t?.imageType??"png",i=KA(e);r!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(r)||(r=`!${r}`));let a=`https://mermaid.ink/img/${i}?bgColor=${r}&type=${n}`,o=await fetch(a);if(!o.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${o.status}`,`Status text: ${o.statusText}`].join(`
235
+ `));return await o.blob()}var eO=T({Graph:()=>Lo});function lF(e,t){if(e!==void 0&&!di(e))return e;if(Ul(t))try{let r=t.getName();return r=r.startsWith("Runnable")?r.slice(8):r,r}catch{return t.getName()}else return t.name??"UnknownSchema"}function uF(e){return Ul(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...Et(e.data.schema),title:e.data.name}}}var Lo=class tO{nodes={};edges=[];constructor(t){this.nodes=t?.nodes??this.nodes,this.edges=t?.edges??this.edges}toJSON(){let t={};return Object.values(this.nodes).forEach((r,n)=>{t[r.id]=di(r.id)?n:r.id}),{nodes:Object.values(this.nodes).map(r=>({id:t[r.id],...uF(r)})),edges:this.edges.map(r=>{let n={source:t[r.source],target:t[r.target]};return typeof r.data<"u"&&(n.data=r.data),typeof r.conditional<"u"&&(n.conditional=r.conditional),n})}}addNode(t,r,n){if(r!==void 0&&this.nodes[r]!==void 0)throw new Error(`Node with id ${r} already exists`);let i=r??Xi(),a={id:i,data:t,name:lF(r,t),metadata:n};return this.nodes[i]=a,a}removeNode(t){delete this.nodes[t.id],this.edges=this.edges.filter(r=>r.source!==t.id&&r.target!==t.id)}addEdge(t,r,n,i){if(this.nodes[t.id]===void 0)throw new Error(`Source node ${t.id} not in graph`);if(this.nodes[r.id]===void 0)throw new Error(`Target node ${r.id} not in graph`);let a={source:t.id,target:r.id,data:n,conditional:i};return this.edges.push(a),a}firstNode(){return YA(this)}lastNode(){return QA(this)}extend(t,r=""){let n=r;Object.values(t.nodes).map(c=>c.id).every(di)&&(n="");let i=c=>n?`${n}:${c}`:c;Object.entries(t.nodes).forEach(([c,l])=>{this.nodes[i(c)]={...l,id:i(c)}});let a=t.edges.map(c=>({...c,source:i(c.source),target:i(c.target)}));this.edges=[...this.edges,...a];let o=t.firstNode(),s=t.lastNode();return[o?{id:i(o.id),data:o.data}:void 0,s?{id:i(s.id),data:s.data}:void 0]}trimFirstNode(){let t=this.firstNode();t&&YA(this,[t.id])&&this.removeNode(t)}trimLastNode(){let t=this.lastNode();t&&QA(this,[t.id])&&this.removeNode(t)}reid(){let t=Object.fromEntries(Object.values(this.nodes).map(i=>[i.id,i.name])),r=new Map;Object.values(t).forEach(i=>{r.set(i,(r.get(i)||0)+1)});let n=i=>{let a=t[i];return di(i)&&r.get(a)===1?a:i};return new tO({nodes:Object.fromEntries(Object.entries(this.nodes).map(([i,a])=>[n(i),{...a,id:n(i)}])),edges:this.edges.map(i=>({...i,source:n(i.source),target:n(i.target)}))})}drawMermaid(t){let{withStyles:r,curveStyle:n,nodeColors:i={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:a}=t??{},o=this.reid(),s=o.firstNode(),c=o.lastNode();return qA(o.nodes,o.edges,{firstNode:s?.id,lastNode:c?.id,withStyles:r,curveStyle:n,nodeColors:i,wrapLabelNWords:a})}async drawMermaidPng(t){return XA(this.drawMermaid(t),{backgroundColor:t?.backgroundColor})}};function YA(e,t=[]){let r=new Set(e.edges.filter(i=>!t.includes(i.source)).map(i=>i.target)),n=[];for(let i of Object.values(e.nodes))!t.includes(i.id)&&!r.has(i.id)&&n.push(i);return n.length===1?n[0]:void 0}function QA(e,t=[]){let r=new Set(e.edges.filter(i=>!t.includes(i.target)).map(i=>i.source)),n=[];for(let i of Object.values(e.nodes))!t.includes(i.id)&&!r.has(i.id)&&n.push(i);return n.length===1?n[0]:void 0}function jp({name:e,serialized:t}){return e!==void 0?e:t?.name!==void 0?t.name:t?.id!==void 0&&Array.isArray(t?.id)?t.id[t.id.length-1]:"Unnamed"}var rO=e=>e.name==="event_stream_tracer",nO=class extends Dt{autoClose=!0;includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;runInfoMap=new Map;tappedPromises=new Map;transformStream;writer;receiveStream;readableStreamClosed=!1;name="event_stream_tracer";lc_prefer_streaming=!0;constructor(e){super({_awaitHandler:!0,...e}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this.transformStream=new TransformStream({flush:()=>{this.readableStreamClosed=!0}}),this.writer=this.transformStream.writable.getWriter(),this.receiveStream=gt.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.runType)),this.includeTags!==void 0&&(r=r||t.find(n=>this.includeTags?.includes(n))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.runType)),this.excludeTags!==void 0&&(r=r&&t.every(n=>!this.excludeTags?.includes(n))),r}async*tapOutputIterable(e,t){let r=await t.next();if(r.done)return;let n=this.runInfoMap.get(e);if(n===void 0){yield r.value;return}function i(o,s){return o==="llm"&&typeof s=="string"?new _i({text:s}):s}let a=this.tappedPromises.get(e);if(a===void 0){let o;a=new Promise(s=>{o=s}),this.tappedPromises.set(e,a);try{let s={event:`on_${n.runType}_stream`,run_id:e,name:n.name,tags:n.tags,metadata:n.metadata,data:{}};await this.send({...s,data:{chunk:i(n.runType,r.value)}},n),yield r.value;for await(let c of t)n.runType!=="tool"&&n.runType!=="retriever"&&await this.send({...s,data:{chunk:i(n.runType,c)}},n),yield c}finally{o?.()}}else{yield r.value;for await(let o of t)yield o}}async send(e,t){this.readableStreamClosed||this._includeRun(t)&&await this.writer.write(e)}async sendEndEvent(e,t){let r=this.tappedPromises.get(e.run_id);r!==void 0?r.then(()=>{this.send(e,t)}):await this.send(e,t)}async onLLMStart(e){let t=jp(e),r=e.inputs.messages!==void 0?"chat_model":"llm",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,n);let i=`on_${r}_start`;await this.send({event:i,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onLLMNewToken(e,t,r){let n=this.runInfoMap.get(e.id),i,a;if(n===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(n.runType==="chat_model")a="on_chat_model_stream",r?.chunk===void 0?i=new it({content:t,id:`run-${e.id}`}):i=r.chunk.message;else if(n.runType==="llm")a="on_llm_stream",r?.chunk===void 0?i=new _i({text:t}):i=r.chunk;else throw new Error(`Unexpected run type ${n.runType}`);await this.send({event:a,data:{chunk:i},run_id:e.id,name:n.name,tags:n.tags,metadata:n.metadata},n)}}async onLLMEnd(e){let t=this.runInfoMap.get(e.id);this.runInfoMap.delete(e.id);let r;if(t===void 0)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);let n=e.outputs?.generations,i;if(t.runType==="chat_model"){for(let a of n??[]){if(i!==void 0)break;i=a[0]?.message}r="on_chat_model_end"}else if(t.runType==="llm")i={generations:n?.map(a=>a.map(o=>({text:o.text,generationInfo:o.generationInfo}))),llmOutput:e.outputs?.llmOutput??{}},r="on_llm_end";else throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);await this.sendEndEvent({event:r,data:{output:i,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){let t=jp(e),r=e.run_type??"chain",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type},i={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(i={},n.inputs={}):e.inputs.input!==void 0?(i.input=e.inputs.input,n.inputs=e.inputs.input):(i.input=e.inputs,n.inputs=e.inputs),this.runInfoMap.set(e.id,n),await this.send({event:`on_${r}_start`,data:i,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onChainEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onChainEnd: Run ID ${e.id} not found in run map.`);let r=`on_${e.run_type}_end`,n=e.inputs??t.inputs??{},i={output:e.outputs?.output??e.outputs,input:n};n.input&&Object.keys(n).length===1&&(i.input=n.input,t.inputs=n.input),await this.sendEndEvent({event:r,data:i,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){let t=jp(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"tool",inputs:e.inputs??{}};this.runInfoMap.set(e.id,r),await this.send({event:"on_tool_start",data:{input:e.inputs??{}},name:t,run_id:e.id,tags:e.tags??[],metadata:e.extra?.metadata??{}},r)}async onToolEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);let r=e.outputs?.output===void 0?e.outputs:e.outputs.output;await this.sendEndEvent({event:"on_tool_end",data:{output:r,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onToolError(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);await this.sendEndEvent({event:"on_tool_error",data:{input:t.inputs,error:e.error},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onRetrieverStart(e){let t=jp(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"retriever",inputs:{query:e.inputs.query}};this.runInfoMap.set(e.id,r),await this.send({event:"on_retriever_start",data:{input:{query:e.inputs.query}},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},r)}async onRetrieverEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onRetrieverEnd: Run ID ${e.id} not found in run map.`);await this.sendEndEvent({event:"on_retriever_end",data:{output:e.outputs?.documents??e.outputs,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async handleCustomEvent(e,t,r){let n=this.runInfoMap.get(r);if(n===void 0)throw new Error(`handleCustomEvent: Run ID ${r} not found in run map.`);await this.send({event:"on_custom_event",run_id:r,name:e,tags:n.tags,metadata:n.metadata,data:t},n)}async finish(){let e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}};var Tw=class extends Dt{name="RootListenersTracer";rootId;config;argOnStart;argOnEnd;argOnError;constructor({config:e,onStart:t,onEnd:r,onError:n}){super({_awaitHandler:!0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=n}persistRun(e){return Promise.resolve()}async onRunCreate(e){this.rootId||(this.rootId=e.id,this.argOnStart&&await this.argOnStart(e,this.config))}async onRunUpdate(e){e.id===this.rootId&&(e.error?this.argOnError&&await this.argOnError(e,this.config):this.argOnEnd&&await this.argOnEnd(e,this.config))}};function iO(e){let t=new TextEncoder,r=new ReadableStream({async start(n){for await(let i of e)n.enqueue(t.encode(`event: data
236
+ data: ${JSON.stringify(i)}
237
+
238
+ `));n.enqueue(t.encode(`event: end
239
+
240
+ `)),n.close()}});return gt.fromReadableStream(r)}function Cw(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.iterator]=="function"&&typeof e.next=="function"}var aO=e=>e!=null&&typeof e=="object"&&"next"in e&&typeof e.next=="function";function Dp(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function"}function Aw(e){return e!=null&&typeof e=="object"&&typeof e.next=="function"}async function oO(e,t){try{let r=await e.next();for(;!r.done;)await t?.(r.value),r=await e.next();return r.value}finally{await e.return?.(void 0)}}function*Ow(e,t){for(;;){let{value:r,done:n}=Re.runWithConfig(vr(e),t.next.bind(t),!0);if(n)break;yield r}}async function*zp(e,t){let r=t[Symbol.asyncIterator]();for(;;){let{value:n,done:i}=await Re.runWithConfig(vr(e),r.next.bind(t),!0);if(i)break;yield n}}function _t(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}var se=class extends pt{lc_runnable=!0;name;getName(e){let t=this.name??this.constructor.lc_name()??this.constructor.name;return e?`${t}${e}`:t}withRetry(e){return new Lp({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new Qr({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new Pw({runnable:this,fallbacks:t})}_getOptionsList(e,t=0){if(Array.isArray(e)&&e.length!==t)throw new Error(`Passed "options" must be an array with the same length as the inputs, but got ${e.length} options for ${t} inputs`);if(Array.isArray(e))return e.map(ke);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");let r=Object.fromEntries(Object.entries(e).filter(([n])=>n!=="runId"));return Array.from({length:t},(n,i)=>ke(i===0?e:r))}return Array.from({length:t},()=>ke(e))}async batch(e,t,r){let n=this._getOptionsList(t??{},e.length),i=new yi({maxConcurrency:n[0]?.maxConcurrency??r?.maxConcurrency,onFailedAttempt:o=>{throw o}}),a=e.map((o,s)=>i.call(async()=>{try{return await this.invoke(o,n[s])}catch(c){if(r?.returnExceptions)return c;throw c}}));return Promise.all(a)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){let r=ke(t),n=new oa({generator:this._streamIterator(e,r),config:r});return await n.setup,gt.fromAsyncGenerator(n)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=ke(e):t=ke({callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,runName:e.runName,configurable:e.configurable,recursionLimit:e.recursionLimit,maxConcurrency:e.maxConcurrency,runId:e.runId,timeout:e.timeout,signal:e.signal});let r={...e};return delete r.callbacks,delete r.tags,delete r.metadata,delete r.runName,delete r.configurable,delete r.recursionLimit,delete r.maxConcurrency,delete r.runId,delete r.timeout,delete r.signal,[t,r]}async _callWithConfig(e,t,r){let n=ke(r),i=await(await Wt(n))?.handleChainStart(this.toJSON(),_t(t,"input"),n.runId,n?.runType,void 0,void 0,n?.runName??this.getName());delete n.runId;let a;try{a=await Rr(e.call(this,t,n,i),n.signal)}catch(o){throw await i?.handleChainError(o),o}return await i?.handleChainEnd(_t(a,"output")),a}async _batchWithConfig(e,t,r,n){let i=this._getOptionsList(r??{},t.length),a=await Promise.all(i.map(Wt)),o=await Promise.all(a.map(async(c,l)=>{let u=await c?.handleChainStart(this.toJSON(),_t(t[l],"input"),i[l].runId,i[l].runType,void 0,void 0,i[l].runName??this.getName());return delete i[l].runId,u})),s;try{s=await Rr(e.call(this,t,i,o,n),i?.[0]?.signal)}catch(c){throw await Promise.all(o.map(l=>l?.handleChainError(c))),c}return await Promise.all(o.map(c=>c?.handleChainEnd(_t(s,"output")))),s}_concatOutputChunks(e,t){return Mr(e,t)}async*_transformStreamWithConfig(e,t,r){let n,i=!0,a,o=!0,s=ke(r),c=await Wt(s),l=this;async function*u(){for await(let f of e){if(i)if(n===void 0)n=f;else try{n=l._concatOutputChunks(n,f)}catch{n=void 0,i=!1}yield f}}let d;try{let f=await x_(t.bind(this),u(),async()=>c?.handleChainStart(this.toJSON(),{input:""},s.runId,s.runType,void 0,void 0,s.runName??this.getName(),void 0,{lc_defers_inputs:!0}),s.signal,s);delete s.runId,d=f.setup;let p=d?.handlers.find(rO),m=f.output;p!==void 0&&d!==void 0&&(m=p.tapOutputIterable(d.runId,m));let h=d?.handlers.find(k_);h!==void 0&&d!==void 0&&(m=h.tapOutputIterable(d.runId,m));for await(let _ of m)if(yield _,o)if(a===void 0)a=_;else try{a=this._concatOutputChunks(a,_)}catch{a=void 0,o=!1}}catch(f){throw await d?.handleChainError(f,void 0,void 0,void 0,{inputs:_t(n,"input")}),f}await d?.handleChainEnd(a??{},void 0,void 0,void 0,{inputs:_t(n,"input")})}getGraph(e){let t=new Lo,r=t.addNode({name:`${this.getName()}Input`,schema:Nt.any()}),n=t.addNode(this),i=t.addNode({name:`${this.getName()}Output`,schema:Nt.any()});return t.addEdge(r,n),t.addEdge(n,i),t}pipe(e){return new Lr({first:this,last:at(e)})}pick(e){return this.pipe(new Nw(e))}assign(e){return this.pipe(new Fl(new Ta({steps:e})))}async*transform(e,t){let r;for await(let n of e)r===void 0?r=n:r=this._concatOutputChunks(r,n);yield*this._streamIterator(r,ke(t))}async*streamLog(e,t,r){let n=new mf({...r,autoClose:!1,_schemaFormat:"original"}),i=ke(t);yield*this._streamLog(e,n,i)}async*_streamLog(e,t,r){let{callbacks:n}=r;if(n===void 0)r.callbacks=[t];else if(Array.isArray(n))r.callbacks=n.concat([t]);else{let s=n.copy();s.addHandler(t,!0),r.callbacks=s}let i=this.stream(e,r);async function a(){try{let s=await i;for await(let c of s){let l=new Vn({ops:[{op:"add",path:"/streamed_output/-",value:c}]});await t.writer.write(l)}}finally{await t.writer.close()}}let o=a();try{for await(let s of t)yield s}finally{await o}}streamEvents(e,t,r){let n;if(t.version==="v1")n=this._streamEventsV1(e,t,r);else if(t.version==="v2")n=this._streamEventsV2(e,t,r);else throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');return t.encoding==="text/event-stream"?iO(n):gt.fromAsyncGenerator(n)}async*_streamEventsV2(e,t,r){let n=new nO({...r,autoClose:!1}),i=ke(t),a=i.runId??Hr();i.runId=a;let o=i.callbacks;if(o===void 0)i.callbacks=[n];else if(Array.isArray(o))i.callbacks=o.concat(n);else{let p=o.copy();p.addHandler(n,!0),i.callbacks=p}let s=new AbortController,c=this;async function l(){let p;try{if(i.signal)if("any"in AbortSignal)p=AbortSignal.any([s.signal,i.signal]);else{let _=new AbortController;i.signal.addEventListener("abort",()=>_.abort(),{once:!0}),s.signal.addEventListener("abort",()=>_.abort(),{once:!0}),p=_.signal}else p=s.signal;let m=await c.stream(e,{...i,signal:p}),h=n.tapOutputIterable(a,m);for await(let _ of h)if(s.signal.aborted)break}finally{await n.finish()}}let u=l(),d=!1,f;try{for await(let p of n){if(!d){p.data.input=e,d=!0,f=p.run_id,yield p;continue}p.run_id===f&&p.event.endsWith("_end")&&p.data?.input&&delete p.data.input,yield p}}finally{s.abort(),await u}}async*_streamEventsV1(e,t,r){let n,i=!1,a=ke(t),o=a.tags??[],s=a.metadata??{},c=a.runName??this.getName(),l=new mf({...r,autoClose:!1,_schemaFormat:"streaming_events"}),u=new JA({...r}),d=this._streamLog(e,l,a);for await(let p of d){if(n?n=n.concat(p):n=pf.fromRunLogPatch(p),n.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!i){i=!0;let y={...n.state},w={run_id:y.id,event:`on_${y.type}_start`,name:c,tags:o,metadata:s,data:{input:e}};u.includeEvent(w,y.type)&&(yield w)}let m=p.ops.filter(y=>y.path.startsWith("/logs/")).map(y=>y.path.split("/")[2]),h=[...new Set(m)];for(let y of h){let w,x={},S=n.state.logs[y];if(S.end_time===void 0?S.streamed_output.length>0?w="stream":w="start":w="end",w==="start")S.inputs!==void 0&&(x.input=S.inputs);else if(w==="end")S.inputs!==void 0&&(x.input=S.inputs),x.output=S.final_output;else if(w==="stream"){let $=S.streamed_output.length;if($!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${$} instead. Encountered in: "${S.name}"`);x={chunk:S.streamed_output[0]},S.streamed_output=[]}yield{event:`on_${S.type}_${w}`,name:S.name,run_id:S.id,tags:S.tags,metadata:S.metadata,data:x}}let{state:_}=n;if(_.streamed_output.length>0){let y=_.streamed_output.length;if(y!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${y} instead. Encountered in: "${_.name}"`);let w={chunk:_.streamed_output[0]};_.streamed_output=[];let x={event:`on_${_.type}_stream`,run_id:_.id,tags:o,metadata:s,name:c,data:w};u.includeEvent(x,_.type)&&(yield x)}}let f=n?.state;if(f!==void 0){let p={event:`on_${f.type}_end`,name:c,run_id:f.id,tags:o,metadata:s,data:{output:f.final_output}};u.includeEvent(p,f.type)&&(yield p)}}static isRunnable(e){return Ul(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new Qr({bound:this,config:{},configFactories:[n=>({callbacks:[new Tw({config:n,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return pF(this,e)}},Qr=class sO extends se{static lc_name(){return"RunnableBinding"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;bound;config;kwargs;configFactories;constructor(t){super(t),this.bound=t.bound,this.kwargs=t.kwargs,this.config=t.config,this.configFactories=t.configFactories}getName(t){return this.bound.getName(t)}async _mergeConfig(...t){let r=$t(this.config,...t);return $t(r,...this.configFactories?await Promise.all(this.configFactories.map(async n=>await n(r))):[])}withConfig(t){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...t}})}withRetry(t){return new Lp({bound:this.bound,kwargs:this.kwargs,config:this.config,maxAttemptNumber:t?.stopAfterAttempt,...t})}async invoke(t,r){return this.bound.invoke(t,await this._mergeConfig(r,this.kwargs))}async batch(t,r,n){let i=Array.isArray(r)?await Promise.all(r.map(async a=>this._mergeConfig(ke(a),this.kwargs))):await this._mergeConfig(ke(r),this.kwargs);return this.bound.batch(t,i,n)}_concatOutputChunks(t,r){return this.bound._concatOutputChunks(t,r)}async*_streamIterator(t,r){yield*this.bound._streamIterator(t,await this._mergeConfig(ke(r),this.kwargs))}async stream(t,r){return this.bound.stream(t,await this._mergeConfig(ke(r),this.kwargs))}async*transform(t,r){yield*this.bound.transform(t,await this._mergeConfig(ke(r),this.kwargs))}streamEvents(t,r,n){let i=this,a=async function*(){yield*i.bound.streamEvents(t,{...await i._mergeConfig(ke(r),i.kwargs),version:r.version},n)};return gt.fromAsyncGenerator(a())}static isRunnableBinding(t){return t.bound&&se.isRunnable(t.bound)}withListeners({onStart:t,onEnd:r,onError:n}){return new sO({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[i=>({callbacks:[new Tw({config:i,onStart:t,onEnd:r,onError:n})]})]})}},cO=class lO extends se{static lc_name(){return"RunnableEach"}lc_serializable=!0;lc_namespace=["langchain_core","runnables"];bound;constructor(t){super(t),this.bound=t.bound}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async _invoke(t,r,n){return this.bound.batch(t,Ee(r,{callbacks:n?.getChild()}))}withListeners({onStart:t,onEnd:r,onError:n}){return new lO({bound:this.bound.withListeners({onStart:t,onEnd:r,onError:n})})}},Lp=class extends Qr{static lc_name(){return"RunnableRetry"}lc_namespace=["langchain_core","runnables"];maxAttemptNumber=3;onFailedAttempt=()=>{};constructor(e){super(e),this.maxAttemptNumber=e.maxAttemptNumber??this.maxAttemptNumber,this.onFailedAttempt=e.onFailedAttempt??this.onFailedAttempt}_patchConfigForRetry(e,t,r){let n=e>1?`retry:attempt:${e}`:void 0;return Ee(t,{callbacks:r?.getChild(n)})}async _invoke(e,t,r){return ll(n=>super.invoke(e,this._patchConfigForRetry(n,t,r)),{onFailedAttempt:({error:n})=>this.onFailedAttempt(n,e),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _batch(e,t,r,n){let i={};try{await ll(async a=>{let o=e.map((d,f)=>f).filter(d=>i[d.toString()]===void 0||i[d.toString()]instanceof Error),s=o.map(d=>e[d]),c=o.map(d=>this._patchConfigForRetry(a,t?.[d],r?.[d])),l=await super.batch(s,c,{...n,returnExceptions:!0}),u;for(let d=0;d<l.length;d+=1){let f=l[d],p=o[d];f instanceof Error&&u===void 0&&(u=f,u.input=s[d]),i[p.toString()]=f}if(u)throw u;return l},{onFailedAttempt:({error:a})=>this.onFailedAttempt(a,a.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(a){if(n?.returnExceptions!==!0)throw a}return Object.keys(i).sort((a,o)=>parseInt(a,10)-parseInt(o,10)).map(a=>i[parseInt(a,10)])}async batch(e,t,r){return this._batchWithConfig(this._batch.bind(this),e,t,r)}},Lr=class Ll extends se{static lc_name(){return"RunnableSequence"}first;middle=[];last;omitSequenceTags=!1;lc_serializable=!0;lc_namespace=["langchain_core","runnables"];constructor(t){super(t),this.first=t.first,this.middle=t.middle??this.middle,this.last=t.last,this.name=t.name,this.omitSequenceTags=t.omitSequenceTags??this.omitSequenceTags}get steps(){return[this.first,...this.middle,this.last]}async invoke(t,r){let n=ke(r),i=await(await Wt(n))?.handleChainStart(this.toJSON(),_t(t,"input"),n.runId,void 0,void 0,void 0,n?.runName);delete n.runId;let a=t,o;try{let s=[this.first,...this.middle];for(let c=0;c<s.length;c+=1)a=await Rr(s[c].invoke(a,Ee(n,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`)})),n.signal);if(n.signal?.aborted)throw aa(n.signal);o=await this.last.invoke(a,Ee(n,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(s){throw await i?.handleChainError(s),s}return await i?.handleChainEnd(_t(o,"output")),o}async batch(t,r,n){let i=this._getOptionsList(r??{},t.length),a=await Promise.all(i.map(Wt)),o=await Promise.all(a.map(async(c,l)=>{let u=await c?.handleChainStart(this.toJSON(),_t(t[l],"input"),i[l].runId,void 0,void 0,void 0,i[l].runName);return delete i[l].runId,u})),s=t;try{for(let c=0;c<this.steps.length;c+=1)s=await Rr(this.steps[c].batch(s,o.map((l,u)=>{let d=l?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`);return Ee(i[u],{callbacks:d})}),n),i[0]?.signal)}catch(c){throw await Promise.all(o.map(l=>l?.handleChainError(c))),c}return await Promise.all(o.map(c=>c?.handleChainEnd(_t(s,"output")))),s}_concatOutputChunks(t,r){return this.last._concatOutputChunks(t,r)}async*_streamIterator(t,r){let n=await Wt(r),{runId:i,...a}=r??{},o=await n?.handleChainStart(this.toJSON(),_t(t,"input"),i,void 0,void 0,void 0,a?.runName),s=[this.first,...this.middle,this.last],c=!0,l;async function*u(){yield t}try{let d=s[0].transform(u(),Ee(a,{callbacks:o?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let f=1;f<s.length;f+=1)d=await s[f].transform(d,Ee(a,{callbacks:o?.getChild(this.omitSequenceTags?void 0:`seq:step:${f+1}`)}));for await(let f of d)if(r?.signal?.throwIfAborted(),yield f,c)if(l===void 0)l=f;else try{l=this._concatOutputChunks(l,f)}catch{l=void 0,c=!1}}catch(d){throw await o?.handleChainError(d),d}await o?.handleChainEnd(_t(l,"output"))}getGraph(t){let r=new Lo,n=null;return this.steps.forEach((i,a)=>{let o=i.getGraph(t);a!==0&&o.trimFirstNode(),a!==this.steps.length-1&&o.trimLastNode(),r.extend(o);let s=o.firstNode();if(!s)throw new Error(`Runnable ${i} has no first node`);n&&r.addEdge(n,s),n=o.lastNode()}),r}pipe(t){return Ll.isRunnableSequence(t)?new Ll({first:this.first,middle:this.middle.concat([this.last,t.first,...t.middle]),last:t.last,name:this.name??t.name}):new Ll({first:this.first,middle:[...this.middle,this.last],last:at(t),name:this.name})}static isRunnableSequence(t){return Array.isArray(t.middle)&&se.isRunnable(t)}static from([t,...r],n){let i={};return typeof n=="string"?i.name=n:n!==void 0&&(i=n),new Ll({...i,first:at(t),middle:r.slice(0,-1).map(at),last:at(r[r.length-1])})}},Ta=class uO extends se{static lc_name(){return"RunnableMap"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;steps;getStepsKeys(){return Object.keys(this.steps)}constructor(t){super(t),this.steps={};for(let[r,n]of Object.entries(t.steps))this.steps[r]=at(n)}static from(t){return new uO({steps:t})}async invoke(t,r){let n=ke(r),i=await(await Wt(n))?.handleChainStart(this.toJSON(),{input:t},n.runId,void 0,void 0,void 0,n?.runName);delete n.runId;let a={};try{let o=Object.entries(this.steps).map(async([s,c])=>{a[s]=await c.invoke(t,Ee(n,{callbacks:i?.getChild(`map:key:${s}`)}))});await Rr(Promise.all(o),n.signal)}catch(o){throw await i?.handleChainError(o),o}return await i?.handleChainEnd(a),a}async*_transform(t,r,n){let i={...this.steps},a=of(t,Object.keys(i).length),o=new Map(Object.entries(i).map(([s,c],l)=>{let u=c.transform(a[l],Ee(n,{callbacks:r?.getChild(`map:key:${s}`)}));return[s,u.next().then(d=>({key:s,gen:u,result:d}))]}));for(;o.size;){let{key:s,result:c,gen:l}=await Rr(Promise.race(o.values()),n?.signal);o.delete(s),c.done||(yield{[s]:c.value},o.set(s,l.next().then(u=>({key:s,gen:l,result:u}))))}}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*n(){yield t}let i=ke(r),a=new oa({generator:this.transform(n(),i),config:i});return await a.setup,gt.fromAsyncGenerator(a)}},dF=class dO extends se{lc_serializable=!1;lc_namespace=["langchain_core","runnables"];func;constructor(t){if(super(t),!nf(t.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=t.func}async invoke(t,r){let[n]=this._getOptionsList(r??{},1),i=await Wt(n);return Rr(this.func(Ee(n,{callbacks:i}),t),n?.signal)}async*_streamIterator(t,r){let[n]=this._getOptionsList(r??{},1),i=await this.invoke(t,r);if(Dp(i)){for await(let a of i)n?.signal?.throwIfAborted(),yield a;return}if(aO(i)){for(;;){n?.signal?.throwIfAborted();let a=i.next();if(a.done)break;yield a.value}return}yield i}static from(t){return new dO({func:t})}};function fF(e){if(nf(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var qt=class fO extends se{static lc_name(){return"RunnableLambda"}lc_namespace=["langchain_core","runnables"];func;constructor(t){if(nf(t.func))return dF.from(t.func);super(t),fF(t.func),this.func=t.func}static from(t){return new fO({func:t})}async _invoke(t,r,n){return new Promise((i,a)=>{let o=Ee(r,{callbacks:n?.getChild(),recursionLimit:(r?.recursionLimit??25)-1});Re.runWithConfig(vr(o),async()=>{try{let s=await this.func(t,{...o});if(s&&se.isRunnable(s)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");s=await s.invoke(t,{...o,recursionLimit:(o.recursionLimit??25)-1})}else if(Dp(s)){let c;for await(let l of zp(o,s))if(r?.signal?.throwIfAborted(),c===void 0)c=l;else try{c=this._concatOutputChunks(c,l)}catch{c=l}s=c}else if(Cw(s)){let c;for(let l of Ow(o,s))if(r?.signal?.throwIfAborted(),c===void 0)c=l;else try{c=this._concatOutputChunks(c,l)}catch{c=l}s=c}i(s)}catch(s){a(s)}})})}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async*_transform(t,r,n){let i;for await(let s of t)if(i===void 0)i=s;else try{i=this._concatOutputChunks(i,s)}catch{i=s}let a=Ee(n,{callbacks:r?.getChild(),recursionLimit:(n?.recursionLimit??25)-1}),o=await new Promise((s,c)=>{Re.runWithConfig(vr(a),async()=>{try{s(await this.func(i,{...a,config:a}))}catch(l){c(l)}})});if(o&&se.isRunnable(o)){if(n?.recursionLimit===0)throw new Error("Recursion limit reached.");let s=await o.stream(i,a);for await(let c of s)yield c}else if(Dp(o))for await(let s of zp(a,o))n?.signal?.throwIfAborted(),yield s;else if(Cw(o))for(let s of Ow(a,o))n?.signal?.throwIfAborted(),yield s;else yield o}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*n(){yield t}let i=ke(r),a=new oa({generator:this.transform(n(),i),config:i});return await a.setup,gt.fromAsyncGenerator(a)}},pO=class extends Ta{},Pw=class extends se{static lc_name(){return"RunnableWithFallbacks"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnable;fallbacks;constructor(e){super(e),this.runnable=e.runnable,this.fallbacks=e.fallbacks}*runnables(){yield this.runnable;for(let e of this.fallbacks)yield e}async invoke(e,t){let r=ke(t),n=await Wt(r),{runId:i,...a}=r,o=await n?.handleChainStart(this.toJSON(),_t(e,"input"),i,void 0,void 0,void 0,a?.runName),s=Ee(a,{callbacks:o?.getChild()});return await Re.runWithConfig(s,async()=>{let c;for(let l of this.runnables()){r?.signal?.throwIfAborted();try{let u=await l.invoke(e,s);return await o?.handleChainEnd(_t(u,"output")),u}catch(u){c===void 0&&(c=u)}}throw c===void 0?new Error("No error stored at end of fallback."):(await o?.handleChainError(c),c)})}async*_streamIterator(e,t){let r=ke(t),n=await Wt(r),{runId:i,...a}=r,o=await n?.handleChainStart(this.toJSON(),_t(e,"input"),i,void 0,void 0,void 0,a?.runName),s,c;for(let u of this.runnables()){r?.signal?.throwIfAborted();let d=Ee(a,{callbacks:o?.getChild()});try{c=zp(d,await u.stream(e,d));break}catch(f){s===void 0&&(s=f)}}if(c===void 0){let u=s??new Error("No error stored at end of fallback.");throw await o?.handleChainError(u),u}let l;try{for await(let u of c){yield u;try{l=l===void 0?l:this._concatOutputChunks(l,u)}catch{l=void 0}}}catch(u){throw await o?.handleChainError(u),u}await o?.handleChainEnd(_t(l,"output"))}async batch(e,t,r){if(r?.returnExceptions)throw new Error("Not implemented.");let n=this._getOptionsList(t??{},e.length),i=await Promise.all(n.map(s=>Wt(s))),a=await Promise.all(i.map(async(s,c)=>{let l=await s?.handleChainStart(this.toJSON(),_t(e[c],"input"),n[c].runId,void 0,void 0,void 0,n[c].runName);return delete n[c].runId,l})),o;for(let s of this.runnables()){n[0].signal?.throwIfAborted();try{let c=await s.batch(e,a.map((l,u)=>Ee(n[u],{callbacks:l?.getChild()})),r);return await Promise.all(a.map((l,u)=>l?.handleChainEnd(_t(c[u],"output")))),c}catch(c){o===void 0&&(o=c)}}throw o?(await Promise.all(a.map(s=>s?.handleChainError(o))),o):new Error("No error stored at end of fallbacks.")}};function at(e){if(typeof e=="function")return new qt({func:e});if(se.isRunnable(e))return e;if(!Array.isArray(e)&&typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[r]=at(n);return new Ta({steps:t})}else throw new Error(`Expected a Runnable, function or object.
241
+ Instead got an unsupported type.`)}var Fl=class extends se{static lc_name(){return"RunnableAssign"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;mapper;constructor(e){e instanceof Ta&&(e={mapper:e}),super(e),this.mapper=e.mapper}async invoke(e,t){let r=await this.mapper.invoke(e,t);return{...e,...r}}async*_transform(e,t,r){let n=this.mapper.getStepsKeys(),[i,a]=of(e),o=this.mapper.transform(a,Ee(r,{callbacks:t?.getChild()})),s=o.next();for await(let c of i){if(typeof c!="object"||Array.isArray(c))throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof c}`);let l=Object.fromEntries(Object.entries(c).filter(([u])=>!n.includes(u)));Object.keys(l).length>0&&(yield l)}yield(await s).value;for await(let c of o)yield c}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let n=ke(t),i=new oa({generator:this.transform(r(),n),config:n});return await i.setup,gt.fromAsyncGenerator(i)}},Nw=class extends se{static lc_name(){return"RunnablePick"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;keys;constructor(e){(typeof e=="string"||Array.isArray(e))&&(e={keys:e}),super(e),this.keys=e.keys}async _pick(e){if(typeof this.keys=="string")return e[this.keys];{let t=this.keys.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0);return t.length===0?void 0:Object.fromEntries(t)}}async invoke(e,t){return this._callWithConfig(this._pick.bind(this),e,t)}async*_transform(e){for await(let t of e){let r=await this._pick(t);r!==void 0&&(yield r)}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let n=ke(t),i=new oa({generator:this.transform(r(),n),config:n});return await i.setup,gt.fromAsyncGenerator(i)}},Up=class extends Qr{name;description;schema;constructor(e){let t=Lr.from([qt.from(async r=>{let n;if(Qi(r))try{n=await wa(this.schema,r.args)}catch{throw new cs("Received tool input did not match expected schema",JSON.stringify(r.args))}else n=r;return n}).withConfig({runName:`${e.name}:parse_input`}),e.bound]).withConfig({runName:e.name});super({bound:t,config:e.config??{}}),this.name=e.name,this.description=e.description,this.schema=e.schema}static lc_name(){return"RunnableToolLike"}};function pF(e,t){let r=t.name??e.getName(),n=t.description??Si(t.schema);return Gs(t.schema)?new Up({name:r,description:n,schema:Nt.object({input:Nt.string()}).transform(i=>i.input),bound:e}):new Up({name:r,description:n,schema:t.schema,bound:e})}var Fp=(e,t)=>{let r=[...new Set(t?.map(i=>{if(typeof i=="string")return i;let a=new i({});if(!("getType"in a)||typeof a.getType!="function")throw new Error("Invalid type provided.");return a.getType()}))],n=e.getType();return r.some(i=>i===n)};function yO(e,t){return Array.isArray(e)?mO(e,t):qt.from(r=>mO(r,e))}function mO(e,t={}){let{includeNames:r,excludeNames:n,includeTypes:i,excludeTypes:a,includeIds:o,excludeIds:s}=t,c=[];for(let l of e)if(!(n&&l.name&&n.includes(l.name))){{if(a&&Fp(l,a))continue;if(s&&l.id&&s.includes(l.id))continue}i||o||r?(r&&l.name&&r.some(u=>u===l.name)||i&&Fp(l,i)||o&&l.id&&o.some(u=>u===l.id))&&c.push(l):c.push(l)}return c}function vO(e){return Array.isArray(e)?hO(e):qt.from(hO)}function hO(e){if(!e.length)return[];let t=[];for(let r of e){let n=r,i=t.pop();if(!i)t.push(n);else if(n.getType()==="tool"||n.getType()!==i.getType())t.push(i,n);else{let a=eo(i),o=eo(n),s=a.concat(o);typeof a.content=="string"&&typeof o.content=="string"&&(s.content=`${a.content}
242
+ ${o.content}`),t.push(hF(s))}}return t}function bO(e,t){if(Array.isArray(e)){let r=e;if(!t)throw new Error("Options parameter is required when providing messages.");return gO(r,t)}else{let r=e;return qt.from(n=>gO(n,r)).withConfig({runName:"trim_messages"})}}async function gO(e,t){let{maxTokens:r,tokenCounter:n,strategy:i="last",allowPartial:a=!1,endOn:o,startOn:s,includeSystem:c=!1,textSplitter:l}=t;if(s&&i==="first")throw new Error("`startOn` should only be specified if `strategy` is 'last'.");if(c&&i==="first")throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");let u;"getNumTokens"in n?u=async f=>(await Promise.all(f.map(p=>n.getNumTokens(p.content)))).reduce((p,m)=>p+m,0):u=async f=>n(f);let d=Mw;if(l&&("splitText"in l?d=l.splitText:d=async f=>l(f)),i==="first")return wO(e,{maxTokens:r,tokenCounter:u,textSplitter:d,partialStrategy:a?"first":void 0,endOn:o});if(i==="last")return mF(e,{maxTokens:r,tokenCounter:u,textSplitter:d,allowPartial:a,includeSystem:c,startOn:s,endOn:o});throw new Error(`Unrecognized strategy: '${i}'. Must be one of 'first' or 'last'.`)}async function wO(e,t){let{maxTokens:r,tokenCounter:n,textSplitter:i,partialStrategy:a,endOn:o}=t,s=[...e],c=0;for(let l=0;l<s.length;l+=1)if(await n(l>0?s.slice(0,-l):s)<=r){c=s.length-l;break}if(c<s.length&&a){let l=!1;if(Array.isArray(s[c].content)){let u=s[c];if(typeof u.content=="string")throw new Error("Expected content to be an array.");let d=u.content.length,f=a==="last"?[...u.content].reverse():u.content;for(let p=1;p<=d;p+=1){let m=a==="first"?f.slice(0,p):f.slice(-p),h=Object.fromEntries(Object.entries(u).filter(([w])=>w!=="type"&&!w.startsWith("lc_"))),_=Rw(u.getType(),{...h,content:m}),y=[...s.slice(0,c),_];if(await n(y)<=r)s=y,c+=1,l=!0;else break}l&&a==="last"&&(u.content=[...f].reverse())}if(!l){let u=s[c],d;if(Array.isArray(u.content)&&u.content.some(f=>typeof f=="string"||f.type==="text")?d=u.content.find(f=>f.type==="text"&&f.text)?.text:typeof u.content=="string"&&(d=u.content),d){let f=await i(d),p=f.length;a==="last"&&f.reverse();for(let m=0;m<p-1;m+=1)if(f.pop(),u.content=f.join(""),await n([...s.slice(0,c),u])<=r){a==="last"&&(u.content=[...f].reverse().join("")),s=[...s.slice(0,c),u],c+=1;break}}}}if(o){let l=Array.isArray(o)?o:[o];for(;c>0&&!Fp(s[c-1],l);)c-=1}return s.slice(0,c)}async function mF(e,t){let{allowPartial:r=!1,includeSystem:n=!1,endOn:i,startOn:a,...o}=t,s=e.map(u=>{let d=Object.fromEntries(Object.entries(u).filter(([f])=>f!=="type"&&!f.startsWith("lc_")));return Rw(u.getType(),d,pi(u))});if(i){let u=Array.isArray(i)?i:[i];for(;s.length>0&&!Fp(s[s.length-1],u);)s=s.slice(0,-1)}let c=n&&s[0]?.getType()==="system",l=c?s.slice(0,1).concat(s.slice(1).reverse()):s.reverse();return l=await wO(l,{...o,partialStrategy:r?"last":void 0,endOn:a}),c?[l[0],...l.slice(1).reverse()]:l.reverse()}var _O={human:{message:ot,messageChunk:Qa},ai:{message:Ne,messageChunk:it},system:{message:or,messageChunk:mi},developer:{message:or,messageChunk:mi},tool:{message:St,messageChunk:ss},function:{message:Xa,messageChunk:Ya},generic:{message:un,messageChunk:qa},remove:{message:Nr,messageChunk:Nr}};function Rw(e,t,r){let n,i;switch(e){case"human":r?n=new Qa(t):i=new ot(t);break;case"ai":if(r){let a={...t};"tool_calls"in a&&(a={...a,tool_call_chunks:a.tool_calls?.map(o=>({...o,type:"tool_call_chunk",index:void 0,args:JSON.stringify(o.args)}))}),n=new it(a)}else i=new Ne(t);break;case"system":r?n=new mi(t):i=new or(t);break;case"developer":r?n=new mi({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}}):i=new or({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}});break;case"tool":if("tool_call_id"in t)r?n=new ss(t):i=new St(t);else throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");break;case"function":if(r)n=new Ya(t);else{if(!t.name)throw new Error("FunctionMessage must have a 'name' field");i=new Xa(t)}break;case"generic":if("role"in t)r?n=new qa(t):i=new un(t);else throw new Error("Can not convert ChatMessage to ChatMessageChunk if 'role' field is not defined.");break;default:throw new Error(`Unrecognized message type ${e}`)}if(r&&n)return n;if(i)return i;throw new Error(`Unrecognized message type ${e}`)}function hF(e){let t=e.getType(),r,n=Object.fromEntries(Object.entries(e).filter(([i])=>!["type","tool_call_chunks"].includes(i)&&!i.startsWith("lc_")));if(t in _O&&(r=Rw(t,n)),!r)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys(_O)}`);return r}function Mw(e){let t=e.split(`
243
+ `);return Promise.resolve([...t.slice(0,-1).map(r=>`${r}
244
+ `),t[t.length-1]])}var xO=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"];var SO=["image","video","audio","text-plain","file"];var kO=["text","reasoning",...xO,...SO];var $O=T({AIMessage:()=>Ne,AIMessageChunk:()=>it,BaseMessage:()=>Pe,BaseMessageChunk:()=>Ot,ChatMessage:()=>un,ChatMessageChunk:()=>qa,DEFAULT_MERGE_IGNORE_KEYS:()=>cg,FunctionMessage:()=>Xa,FunctionMessageChunk:()=>Ya,HumanMessage:()=>ot,HumanMessageChunk:()=>Qa,KNOWN_BLOCK_TYPES:()=>kO,RemoveMessage:()=>Nr,SystemMessage:()=>or,SystemMessageChunk:()=>mi,ToolMessage:()=>St,ToolMessageChunk:()=>ss,_isMessageFieldWithRole:()=>vd,_mergeDicts:()=>et,_mergeLists:()=>Yi,_mergeObj:()=>yd,_mergeStatus:()=>_d,coerceMessageLikeToMessage:()=>kt,collapseToolCallChunks:()=>wd,convertToChunk:()=>eo,convertToOpenAIImageBlock:()=>pd,convertToProviderContentBlock:()=>Uk,defaultTextSplitter:()=>Mw,defaultToolCallParser:()=>Wc,filterMessages:()=>yO,getBufferString:()=>ds,iife:()=>P$,isAIMessage:()=>us,isAIMessageChunk:()=>Kc,isBase64ContentBlock:()=>os,isBaseMessage:()=>tt,isBaseMessageChunk:()=>pi,isChatMessage:()=>k$,isChatMessageChunk:()=>$$,isDataContentBlock:()=>jn,isDirectToolOutput:()=>Gc,isFunctionMessage:()=>E$,isFunctionMessageChunk:()=>I$,isHumanMessage:()=>T$,isHumanMessageChunk:()=>C$,isIDContentBlock:()=>fd,isMessage:()=>gd,isOpenAIToolCallArray:()=>e$,isPlainTextContentBlock:()=>Dk,isSystemMessage:()=>A$,isSystemMessageChunk:()=>O$,isToolMessage:()=>Jc,isToolMessageChunk:()=>lg,isURLContentBlock:()=>as,mapChatMessagesToStoredMessages:()=>R$,mapStoredMessageToChatMessage:()=>qc,mapStoredMessagesToChatMessages:()=>N$,mergeContent:()=>Vt,mergeMessageRuns:()=>vO,mergeResponseMetadata:()=>bd,mergeUsageMetadata:()=>ls,parseBase64DataUrl:()=>Hc,parseMimeType:()=>zk,trimMessages:()=>bO});var EO=T({BaseChatMessageHistory:()=>jw,BaseListChatMessageHistory:()=>Bp,InMemoryChatMessageHistory:()=>gF}),jw=class extends pt{async addMessages(e){for(let t of e)await this.addMessage(t)}},Bp=class extends pt{addUserMessage(e){return this.addMessage(new ot(e))}addAIMessage(e){return this.addMessage(new Ne(e))}async addMessages(e){for(let t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}},gF=class extends Bp{lc_namespace=["langchain","stores","message","in_memory"];messages=[];constructor(e){super(...arguments),this.messages=e??[]}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async clear(){this.messages=[]}};var Fr=class{pageContent;metadata;id;constructor(e){this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};var Dw=class extends se{lc_namespace=["langchain_core","documents","transformers"];invoke(e,t){return this.transformDocuments(e)}},IO=class extends Dw{async transformDocuments(e){let t=[];for(let r of e){let n=await this._transformDocument(r);t.push(n)}return t}};var TO=T({BaseDocumentTransformer:()=>Dw,Document:()=>Fr,MappingDocumentTransformer:()=>IO});var CO=T({BaseDocumentLoader:()=>zw}),zw=class{};var AO=T({LangSmithLoader:()=>_F}),_F=class extends zw{datasetId;datasetName;exampleIds;asOf;splits;inlineS3Urls;offset;limit;metadata;filter;contentKey;formatContent;client;constructor(e){if(super(),e.client&&e.clientConfig)throw new Error("client and clientConfig cannot both be provided.");this.client=e.client??new Ln(e?.clientConfig),this.contentKey=e.contentKey?e.contentKey.split("."):[],this.formatContent=e.formatContent??yF,this.datasetId=e.datasetId,this.datasetName=e.datasetName,this.exampleIds=e.exampleIds,this.asOf=e.asOf,this.splits=e.splits,this.inlineS3Urls=e.inlineS3Urls,this.offset=e.offset,this.limit=e.limit,this.metadata=e.metadata,this.filter=e.filter}async load(){let e=[];for await(let t of this.client.listExamples({datasetId:this.datasetId,datasetName:this.datasetName,exampleIds:this.exampleIds,asOf:this.asOf,splits:this.splits,inlineS3Urls:this.inlineS3Urls,offset:this.offset,limit:this.limit,metadata:this.metadata,filter:this.filter})){let r=t.inputs;for(let a of this.contentKey)r=r[a];let n=this.formatContent(r),i=t;["created_at","modified_at"].forEach(a=>{a in i&&typeof i[a]=="object"&&(i[a]=i[a].toString())}),e.push({pageContent:n,metadata:i})}return e}};function yF(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}var OO=T({Embeddings:()=>Vp}),Vp=class{caller;constructor(e){this.caller=new yi(e??{})}};var rc=class extends pt{lc_namespace=["langchain_core","example_selectors","base"]};var Uw=class{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}},PO=class extends Uw{defaultPrompt;conditionals;constructor(e,t=[]){super(),this.defaultPrompt=e,this.conditionals=t}getPrompt(e){for(let[t,r]of this.conditionals)if(t(e))return r;return this.defaultPrompt}};function NO(e){return e._modelType()==="base_llm"}function RO(e){return e._modelType()==="base_chat_model"}function MO(e){return e.split(/\n| /).length}var jO=class DO extends rc{examples=[];examplePrompt;getTextLength=MO;maxLength=2048;exampleTextLengths=[];constructor(t){super(t),this.examplePrompt=t.examplePrompt,this.maxLength=t.maxLength??2048,this.getTextLength=t.getTextLength??MO}async addExample(t){this.examples.push(t);let r=await this.examplePrompt.format(t);this.exampleTextLengths.push(this.getTextLength(r))}async calculateExampleTextLengths(t,r){if(t.length>0)return t;let{examples:n,examplePrompt:i}=r;return(await Promise.all(n.map(a=>i.format(a)))).map(a=>this.getTextLength(a))}async selectExamples(t){let r=Object.values(t).join(" "),n=this.maxLength-this.getTextLength(r),i=0,a=[];for(;n>0&&i<this.examples.length;){let o=n-this.exampleTextLengths[i];if(o<0)break;a.push(this.examples[i]),n=o,i+=1}return a}static async fromExamples(t,r){let n=new DO(r);return await Promise.all(t.map(i=>n.addExample(i))),n}};function Lw(e){return Object.keys(e).sort().map(t=>e[t])}var zO=class UO extends rc{vectorStoreRetriever;exampleKeys;inputKeys;constructor(t){if(super(t),this.exampleKeys=t.exampleKeys,this.inputKeys=t.inputKeys,t.vectorStore!==void 0)this.vectorStoreRetriever=t.vectorStore.asRetriever({k:t.k??4,filter:t.filter});else if(t.vectorStoreRetriever)this.vectorStoreRetriever=t.vectorStoreRetriever;else throw new Error('You must specify one of "vectorStore" and "vectorStoreRetriever".')}async addExample(t){let r=Lw((this.inputKeys??Object.keys(t)).reduce((n,i)=>({...n,[i]:t[i]}),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new Fr({pageContent:r,metadata:t})])}async selectExamples(t){let r=Lw((this.inputKeys??Object.keys(t)).reduce((i,a)=>({...i,[a]:t[a]}),{})).join(" "),n=(await this.vectorStoreRetriever.invoke(r)).map(i=>i.metadata);return this.exampleKeys?n.map(i=>this.exampleKeys.reduce((a,o)=>({...a,[o]:i[o]}),{})):n}static async fromExamples(t,r,n,i={}){let a=i.inputKeys??null,o=t.map(s=>Lw(a?a.reduce((c,l)=>({...c,[l]:s[l]}),{}):s).join(" "));return new UO({vectorStore:await n.fromTexts(o,t,r,i),k:i.k??4,exampleKeys:i.exampleKeys,inputKeys:i.inputKeys})}};var LO=T({BaseExampleSelector:()=>rc,BasePromptSelector:()=>Uw,ConditionalPromptSelector:()=>PO,LengthBasedExampleSelector:()=>jO,SemanticSimilarityExampleSelector:()=>zO,isChatModel:()=>RO,isLLM:()=>NO});var Bl="10f90ea3-90a4-4962-bf75-83a0f3c1c62a",FO=class extends pt{lc_namespace=["langchain","recordmanagers"]};var Fw=class{uid;hash_;contentHash;metadataHash;pageContent;metadata;keyEncoder=is;constructor(e){this.uid=e.uid,this.pageContent=e.pageContent,this.metadata=e.metadata}makeDefaultKeyEncoder(e){this.keyEncoder=e}calculateHashes(){let e=["hash_","content_hash","metadata_hash"];for(let r of e)if(r in this.metadata)throw new Error(`Metadata cannot contain key ${r} as it is reserved for internal use. Restricted keys: [${e.join(", ")}]`);let t=this._hashStringToUUID(this.pageContent);try{let r=this._hashNestedDictToUUID(this.metadata);this.contentHash=t,this.metadataHash=r}catch(r){throw new Error(`Failed to hash metadata: ${r}. Please use a dict that can be serialized using json.`)}this.hash_=this._hashStringToUUID(this.contentHash+this.metadataHash),this.uid||(this.uid=this.hash_)}toDocument(){return new Fr({pageContent:this.pageContent,metadata:this.metadata})}static fromDocument(e,t){let r=new this({pageContent:e.pageContent,metadata:e.metadata,uid:t||e.uid});return r.calculateHashes(),r}_hashStringToUUID(e){return es(this.keyEncoder(e),Bl)}_hashNestedDictToUUID(e){let t=JSON.stringify(e,Object.keys(e).sort());return es(this.keyEncoder(t),Bl)}};function Bw(e,t){let r=[],n=[];return t.forEach(i=>{n.push(i),n.length>=e&&(r.push(n),n=[])}),n.length>0&&r.push(n),r}function Vw(e){let t=new Set,r=[];for(let n of e){if(!n.hash_)throw new Error("Hashed document does not have a hash");t.has(n.hash_)||(t.add(n.hash_),r.push(n))}return r}function Zw(e){if(e===null)return t=>null;if(typeof e=="string")return t=>t.metadata[e];if(typeof e=="function")return e;throw new Error(`sourceIdKey should be null, a string or a function, got ${typeof e}`)}var Hw=e=>"load"in e&&typeof e.load=="function"&&"loadAndSplit"in e&&typeof e.loadAndSplit=="function";async function BO(e){let{docsSource:t,recordManager:r,vectorStore:n,options:i}=e,{batchSize:a=100,cleanup:o,sourceIdKey:s,cleanupBatchSize:c=1e3,forceUpdate:l=!1}=i??{};if(o==="incremental"&&!s)throw new Error("sourceIdKey is required when cleanup mode is incremental. Please provide through 'options.sourceIdKey'.");let u=Hw(t)?await t.load():t,d=Zw(s??null),f=await r.getTime(),p=0,m=0,h=0,_=0,y=Bw(a??100,u);for(let w of y){let x=Vw(w.map(L=>Fw.fromDocument(L))),S=x.map(L=>d(L));o==="incremental"&&x.forEach((L,q)=>{if(S[q]===null)throw new Error("sourceIdKey must be provided when cleanup is incremental")});let $=await r.exists(x.map(L=>L.uid)),P=[],C=[],b=[],B=new Set;if(x.forEach((L,q)=>{if($[q])if(l)B.add(L.uid);else{b.push(L.uid);return}P.push(L.uid),C.push(L.toDocument())}),b.length>0&&(await r.update(b,{timeAtLeast:f}),_+=b.length),C.length>0&&(await n.addDocuments(C,{ids:P}),p+=C.length-B.size,h+=B.size),await r.update(x.map(L=>L.uid),{timeAtLeast:f,groupIds:S}),o==="incremental"){S.forEach(q=>{if(!q)throw new Error("Source id cannot be null")});let L=await r.listKeys({before:f,groupIds:S});L.length>0&&(await n.delete({ids:L}),await r.deleteKeys(L),m+=L.length)}}if(o==="full"){let w=await r.listKeys({before:f,limit:c});for(;w.length>0;)await n.delete({ids:w}),await r.deleteKeys(w),m+=w.length,w=await r.listKeys({before:f,limit:c})}return{numAdded:p,numDeleted:m,numUpdated:h,numSkipped:_}}var VO=T({RecordManager:()=>FO,UUIDV5_NAMESPACE:()=>Bl,_HashedDocument:()=>Fw,_batch:()=>Bw,_deduplicateInOrder:()=>Vw,_getSourceIdAssigner:()=>Zw,_isBaseDocumentLoader:()=>Hw,index:()=>BO});var ZO=T({BasePromptValue:()=>Zp,ChatPromptValue:()=>Zl,ImagePromptValue:()=>Gw,StringPromptValue:()=>Vl}),Zp=class extends pt{},Vl=class extends Zp{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(e){super({value:e}),this.value=e}toString(){return this.value}toChatMessages(){return[new ot(this.value)]}},Zl=class extends Zp{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),this.messages=e.messages}toString(){return ds(this.messages)}toChatMessages(){return this.messages}},Gw=class extends Zp{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new ot({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}};var JO=Vu(WO(),1),EF=Object.defineProperty,IF=(e,t,r)=>t in e?EF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,TF=(e,t,r)=>(IF(e,typeof t!="symbol"?t+"":t,r),r);function CF(e,t){let r=Array.from({length:e.length},(n,i)=>({start:i,end:i+1}));for(;r.length>1;){let n=null;for(let i=0;i<r.length-1;i++){let a=e.slice(r[i].start,r[i+1].end),o=t.get(a.join(","));o!=null&&(n==null||o<n[0])&&(n=[o,i])}if(n!=null){let i=n[1];r[i]={start:r[i].start,end:r[i+1].end},r.splice(i+1,1)}else break}return r}function AF(e,t){return e.length===1?[t.get(e.join(","))]:CF(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(r=>r!=null)}function OF(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var Jw=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(e,t){this.patStr=e.pat_str;let r=e.bpe_ranks.split(`
245
+ `).filter(Boolean).reduce((n,i)=>{let[a,o,...s]=i.split(" "),c=Number.parseInt(o,10);return s.forEach((l,u)=>n[l]=c+u),n},{});for(let[n,i]of Object.entries(r)){let a=JO.default.toByteArray(n);this.rankMap.set(a.join(","),i),this.textMap.set(i,a)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((n,[i,a])=>(n[a]=this.textEncoder.encode(i),n),{})}encode(e,t=[],r="all"){let n=new RegExp(this.patStr,"ug"),i=Jw.specialTokenRegex(Object.keys(this.specialTokens)),a=[],o=new Set(t==="all"?Object.keys(this.specialTokens):t),s=new Set(r==="all"?Object.keys(this.specialTokens).filter(l=>!o.has(l)):r);if(s.size>0){let l=Jw.specialTokenRegex([...s]),u=e.match(l);if(u!=null)throw new Error(`The text contains a special token that is not allowed: ${u[0]}`)}let c=0;for(;;){let l=null,u=c;for(;i.lastIndex=u,l=i.exec(e),!(l==null||o.has(l[0]));)u=l.index+1;let d=l?.index??e.length;for(let p of e.substring(c,d).matchAll(n)){let m=this.textEncoder.encode(p[0]),h=this.rankMap.get(m.join(","));if(h!=null){a.push(h);continue}a.push(...AF(m,this.rankMap))}if(l==null)break;let f=this.specialTokens[l[0]];a.push(f),c=l.index+l[0].length}return a}decode(e){let t=[],r=0;for(let a=0;a<e.length;++a){let o=e[a],s=this.textMap.get(o)??this.inverseSpecialTokens[o];s!=null&&(t.push(s),r+=s.length)}let n=new Uint8Array(r),i=0;for(let a of t)n.set(a,i),i+=a.length;return this.textDecoder.decode(n)}},Gp=Jw;TF(Gp,"specialTokenRegex",e=>new RegExp(e.map(t=>OF(t)).join("|"),"g"));function Kw(e){switch(e){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":case"gpt-5":case"gpt-5-2025-08-07":case"gpt-5-nano":case"gpt-5-nano-2025-08-07":case"gpt-5-mini":case"gpt-5-mini-2025-08-07":case"gpt-5-chat-latest":return"o200k_base";default:throw new Error("Unknown model")}}var KO=T({encodingForModel:()=>Jp,getEncoding:()=>qO}),Wp={},PF=new yi({});async function qO(e){return e in Wp||(Wp[e]=PF.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(t=>t.json()).then(t=>new Gp(t)).catch(t=>{throw delete Wp[e],t})),await Wp[e]}async function Jp(e){return qO(Kw(e))}var XO=T({BaseLangChain:()=>qp,BaseLanguageModel:()=>Hl,calculateMaxTokens:()=>MF,getEmbeddingContextSize:()=>NF,getModelContextSize:()=>YO,getModelNameForTiktoken:()=>Kp,isOpenAITool:()=>RF}),Kp=e=>e.startsWith("gpt-5")?"gpt-5":e.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":e.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":e.startsWith("gpt-4-32k")?"gpt-4-32k":e.startsWith("gpt-4-")?"gpt-4":e.startsWith("gpt-4o")?"gpt-4o":e,NF=e=>e==="text-embedding-ada-002"?8191:2046,YO=e=>{switch(Kp(e)){case"gpt-5":case"gpt-5-turbo":case"gpt-5-turbo-preview":return 4e5;case"gpt-4o":case"gpt-4o-mini":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":return 128e3;case"gpt-4-turbo":case"gpt-4-turbo-preview":case"gpt-4-turbo-2024-04-09":case"gpt-4-0125-preview":case"gpt-4-1106-preview":return 128e3;case"gpt-4-32k":case"gpt-4-32k-0314":case"gpt-4-32k-0613":return 32768;case"gpt-4":case"gpt-4-0314":case"gpt-4-0613":return 8192;case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-16k-0613":return 16384;case"gpt-3.5-turbo":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-1106":case"gpt-3.5-turbo-0125":return 4096;case"text-davinci-003":case"text-davinci-002":return 4097;case"text-davinci-001":return 2049;case"text-curie-001":case"text-babbage-001":case"text-ada-001":return 2048;case"code-davinci-002":case"code-davinci-001":return 8e3;case"code-cushman-001":return 2048;case"claude-3-5-sonnet-20241022":case"claude-3-5-sonnet-20240620":case"claude-3-opus-20240229":case"claude-3-sonnet-20240229":case"claude-3-haiku-20240307":case"claude-2.1":return 2e5;case"claude-2.0":case"claude-instant-1.2":return 1e5;case"gemini-1.5-pro":case"gemini-1.5-pro-latest":case"gemini-1.5-flash":case"gemini-1.5-flash-latest":return 1e6;case"gemini-pro":case"gemini-pro-vision":return 32768;default:return 4097}};function RF(e){return typeof e!="object"||!e?!1:!!("type"in e&&e.type==="function"&&"function"in e&&typeof e.function=="object"&&e.function&&"name"in e.function&&"parameters"in e.function)}var MF=async({prompt:e,modelName:t})=>{let r;try{r=(await Jp(Kp(t))).encode(e).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),r=Math.ceil(e.length/4)}return YO(t)-r},jF=()=>!1,qp=class extends se{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??jF(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{},this._addVersion("@langchain/core","1.2.1")}_addVersion(e,t){let r=this.metadata?.versions;this.metadata={...this.metadata,versions:{...typeof r=="object"&&r!==null?r:{},[e]:t}}}},Hl=class extends qp{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:t,...r}){let{cache:n,...i}=r;super({callbacks:e??t,...i}),typeof n=="object"?this.cache=n:n?this.cache=pg.global():this.cache=void 0,this.caller=new yi(r??{})}_encoding;async getNumTokens(e){let t;typeof e=="string"?t=e:t=e.map(n=>typeof n=="string"?n:n.type==="text"&&"text"in n?n.text:"").join("");let r=Math.ceil(t.length/4);if(!this._encoding)try{this._encoding=await Jp("modelName"in this?Kp(this.modelName):"gpt2")}catch(n){console.warn("Failed to calculate number of tokens, falling back to approximate count",n)}if(this._encoding)try{r=this._encoding.encode(t).length}catch(n){console.warn("Failed to calculate number of tokens, falling back to approximate count",n)}return r}static _convertInputToPromptValue(e){return typeof e=="string"?new Vl(e):Array.isArray(e)?new Zl(e.map(kt)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){let r={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()};return Object.entries(r).filter(([n,i])=>i!==void 0).map(([n,i])=>`${n}:${JSON.stringify(i)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}get profile(){return{}}_filterInvocationParamsForTracing(e){let{tools:t,functions:r,messages:n,response_format:i,...a}=e;return a}};var Ti=class extends se{static lc_name(){return"RunnablePassthrough"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;func;constructor(e){super(e),e&&(this.func=e.func)}async invoke(e,t){let r=ke(t);return this.func&&await this.func(e,r),this._callWithConfig(n=>Promise.resolve(n),e,r)}async*transform(e,t){let r=ke(t),n,i=!0;for await(let a of this._transformStreamWithConfig(e,o=>o,r))if(yield a,i)if(n===void 0)n=a;else try{n=Mr(n,a)}catch{n=void 0,i=!1}this.func&&n!==void 0&&await this.func(n,r)}static assign(e){return new Fl(new Ta({steps:e}))}};var QO=class extends se{static lc_name(){return"RouterRunnable"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnables;constructor(e){super(e),this.runnables=e.runnables}async invoke(e,t){let{key:r,input:n}=e,i=this.runnables[r];if(i===void 0)throw new Error(`No runnable associated with key "${r}".`);return i.invoke(n,ke(t))}async batch(e,t,r){let n=e.map(u=>u.key),i=e.map(u=>u.input);if(n.find(u=>this.runnables[u]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");let a=n.map(u=>this.runnables[u]),o=this._getOptionsList(t??{},e.length),s=o[0]?.maxConcurrency??r?.maxConcurrency,c=s&&s>0?s:e.length,l=[];for(let u=0;u<i.length;u+=c){let d=i.slice(u,u+c).map((p,m)=>a[m].invoke(p,o[m])),f=await Promise.all(d);l.push(f)}return l.flat()}async stream(e,t){let{key:r,input:n}=e,i=this.runnables[r];if(i===void 0)throw new Error(`No runnable associated with key "${r}".`);return i.stream(n,t)}};var eP=class extends se{static lc_name(){return"RunnableBranch"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;default;branches;constructor(e){super(e),this.branches=e.branches,this.default=e.default}static from(e){if(e.length<1)throw new Error("RunnableBranch requires at least one branch");let t=e.slice(0,-1).map(([n,i])=>[at(n),at(i)]),r=at(e[e.length-1]);return new this({branches:t,default:r})}async _invoke(e,t,r){let n;for(let i=0;i<this.branches.length;i+=1){let[a,o]=this.branches[i];if(await a.invoke(e,Ee(t,{callbacks:r?.getChild(`condition:${i+1}`)}))){n=await o.invoke(e,Ee(t,{callbacks:r?.getChild(`branch:${i+1}`)}));break}}return n||(n=await this.default.invoke(e,Ee(t,{callbacks:r?.getChild("branch:default")}))),n}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){let r=await(await Wt(t))?.handleChainStart(this.toJSON(),_t(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName),n,i=!0,a;try{for(let o=0;o<this.branches.length;o+=1){let[s,c]=this.branches[o];if(await s.invoke(e,Ee(t,{callbacks:r?.getChild(`condition:${o+1}`)}))){a=await c.stream(e,Ee(t,{callbacks:r?.getChild(`branch:${o+1}`)}));for await(let l of a)if(yield l,i)if(n===void 0)n=l;else try{n=Mr(n,l)}catch{n=void 0,i=!1}break}}if(a===void 0){a=await this.default.stream(e,Ee(t,{callbacks:r?.getChild("branch:default")}));for await(let o of a)if(yield o,i)if(n===void 0)n=o;else try{n=Mr(n,o)}catch{n=void 0,i=!1}}}catch(o){throw await r?.handleChainError(o),o}await r?.handleChainEnd(n??{})}};var tP=class extends Qr{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let t=qt.from((a,o)=>this._enterHistory(a,o??{})).withConfig({runName:"loadHistory"}),r=e.historyMessagesKey??e.inputMessagesKey;r&&(t=Ti.assign({[r]:t}).withConfig({runName:"insertHistory"}));let n=t.pipe(e.runnable.withListeners({onEnd:(a,o)=>this._exitHistory(a,o??{})})).withConfig({runName:"RunnableWithMessageHistory"}),i=e.config??{};super({...e,config:i,bound:n}),this.runnable=e.runnable,this.getMessageHistory=e.getMessageHistory,this.inputMessagesKey=e.inputMessagesKey,this.outputMessagesKey=e.outputMessagesKey,this.historyMessagesKey=e.historyMessagesKey}_getInputMessages(e){let t;if(typeof e=="object"&&!Array.isArray(e)&&!tt(e)){let r;this.inputMessagesKey?r=this.inputMessagesKey:Object.keys(e).length===1?r=Object.keys(e)[0]:r="input",Array.isArray(e[r])&&Array.isArray(e[r][0])?t=e[r][0]:t=e[r]}else t=e;if(typeof t=="string")return[new ot(t)];if(Array.isArray(t))return t;if(tt(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
246
+ Got ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(!Array.isArray(e)&&!tt(e)&&typeof e!="string"){let r;this.outputMessagesKey!==void 0?r=this.outputMessagesKey:Object.keys(e).length===1?r=Object.keys(e)[0]:r="output",e.generations!==void 0?t=e.generations[0][0].message:t=e[r]}else t=e;if(typeof t=="string")return[new Ne(t)];if(Array.isArray(t))return t;if(tt(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(t,null,2)}`)}async _enterHistory(e,t){let r=await(t?.configurable?.messageHistory).getMessages();return this.historyMessagesKey===void 0?r.concat(this._getInputMessages(e)):r}async _exitHistory(e,t){let r=t.configurable?.messageHistory,n;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?n=e.inputs[0]:n=e.inputs;let i=this._getInputMessages(n);if(this.historyMessagesKey===void 0){let s=await r.getMessages();i=i.slice(s.length)}let a=e.outputs;if(!a)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);let o=this._getOutputMessages(a);await r.addMessages([...i,...o])}async _mergeConfig(...e){let t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){let n={[this.inputMessagesKey??"input"]:"foo"};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
247
+ eg. chain.invoke(${JSON.stringify(n)}, ${JSON.stringify({configurable:{sessionId:"123"}})})`)}let{sessionId:r}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(r),t}};var rP=T({RouterRunnable:()=>QO,Runnable:()=>se,RunnableAssign:()=>Fl,RunnableBinding:()=>Qr,RunnableBranch:()=>eP,RunnableEach:()=>cO,RunnableLambda:()=>qt,RunnableMap:()=>Ta,RunnableParallel:()=>pO,RunnablePassthrough:()=>Ti,RunnablePick:()=>Nw,RunnableRetry:()=>Lp,RunnableSequence:()=>Lr,RunnableToolLike:()=>Up,RunnableWithFallbacks:()=>Pw,RunnableWithMessageHistory:()=>tP,_coerceToRunnable:()=>at,ensureConfig:()=>ke,getCallbackManagerForConfig:()=>Wt,mergeConfigs:()=>$t,patchConfig:()=>Ee,pickRunnableConfigKeys:()=>vr,raceWithSignal:()=>Rr});var nP=T({applyPatch:()=>sa,compare:()=>ca});var nc=class extends se{parseResultWithPrompt(e,t,r){return this.parseResult(e,r)}_baseMessageToString(e){return typeof e.content=="string"?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,t){return typeof e=="string"?this._callWithConfig(async(r,n)=>this.parseResult([{text:r}],n?.callbacks),e,{...t,runType:"parser"}):this._callWithConfig(async(r,n)=>this.parseResult([{message:r,text:this._baseMessageToString(r)}],n?.callbacks),e,{...t,runType:"parser"})}},yn=class extends nc{parseResult(e,t){return this.parse(e[0].text,t)}async parseWithPrompt(e,t,r){return this.parse(e,r)}_type(){throw new Error("_type not implemented")}},Xt=class extends Error{llmOutput;observation;sendToLLM;constructor(e,t,r,n=!1){if(super(e),this.llmOutput=t,this.observation=r,this.sendToLLM=n,n&&(r===void 0||t===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");fi(this,"OUTPUT_PARSING_FAILURE")}};var Ci=class extends yn{async*_transform(e){for await(let t of e)typeof t=="string"?yield this.parseResult([{text:t}]):yield this.parseResult([{message:t,text:this._baseMessageToString(t)}])}async*transform(e,t){yield*this._transformStreamWithConfig(e,this._transform.bind(this),{...t,runType:"parser"})}},Qn=class extends Ci{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let t,r;for await(let n of e){if(typeof n!="string"&&typeof n.content!="string")throw new Error("Cannot handle non-string output.");let i;if(pi(n)){if(typeof n.content!="string")throw new Error("Cannot handle non-string message output.");i=new la({message:n,text:n.content})}else if(tt(n)){if(typeof n.content!="string")throw new Error("Cannot handle non-string message output.");i=new la({message:eo(n),text:n.content})}else i=new _i({text:n});r===void 0?r=i:r=r.concat(i);let a=await this.parsePartialResult([r]);a!=null&&!qn(a,t)&&(this.diff?yield this._diff(t,a):yield a,t=a)}}getFormatInstructions(){return""}};var iP=class extends Ci{static lc_name(){return"BytesOutputParser"}lc_namespace=["langchain_core","output_parsers","bytes"];lc_serializable=!0;textEncoder=new TextEncoder;parse(e){return Promise.resolve(this.textEncoder.encode(e))}getFormatInstructions(){return""}};var ic=class extends Ci{re;async*_transform(e){let t="";for await(let r of e)if(typeof r=="string"?t+=r:t+=r.content,this.re){let n=[...t.matchAll(this.re)];if(n.length>1){let i=0;for(let a of n.slice(0,-1))yield[a[1]],i+=(a.index??0)+a[0].length;t=t.slice(i)}}else{let n=await this.parse(t);if(n.length>1){for(let i of n.slice(0,-1))yield[i];t=n[n.length-1]}}for(let r of await this.parse(t))yield[r]}},aP=class extends ic{static lc_name(){return"CommaSeparatedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;async parse(e){try{return e.trim().split(",").map(t=>t.trim())}catch{throw new Xt(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},oP=class extends ic{lc_namespace=["langchain_core","output_parsers","list"];length;separator;constructor({length:e,separator:t}){super(...arguments),this.length=e,this.separator=t||","}async parse(e){try{let t=e.trim().split(this.separator).map(r=>r.trim());if(this.length!==void 0&&t.length!==this.length)throw new Xt(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){throw Object.getPrototypeOf(t)===Xt.prototype?t:new Xt(`Could not parse output: ${e}`)}}getFormatInstructions(){return`Your response should be a list of ${this.length===void 0?"":`${this.length} `}items separated by "${this.separator}" (eg: \`foo${this.separator} bar${this.separator} baz\`)`}},sP=class extends ic{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
248
+
249
+ 1. foo
250
+
251
+ 2. bar
252
+
253
+ 3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},cP=class extends ic{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
254
+
255
+ 1. foo
256
+
257
+ 2. bar
258
+
259
+ 3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}};var lP=class extends Ci{static lc_name(){return"StrOutputParser"}lc_namespace=["langchain_core","output_parsers","string"];lc_serializable=!0;parse(e){return Promise.resolve(e)}getFormatInstructions(){return""}_textContentToString(e){return e.text}_imageUrlContentToString(e){throw new Error('Cannot coerce a multimodal "image_url" message part into a string.')}_messageContentToString(e){switch(e.type){case"text":case"text_delta":if("text"in e)return this._textContentToString(e);break;case"image_url":if("image_url"in e)return this._imageUrlContentToString(e);break;case"reasoning":case"thinking":case"redacted_thinking":return"";default:throw new Error(`Cannot coerce "${e.type}" message part into a string.`)}throw new Error(`Invalid content type: ${e.type}`)}_baseMessageContentToString(e){return e.reduce((t,r)=>t+this._messageContentToString(r),"")}};var Xp=class extends Qn{static lc_name(){return"JsonOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_concatOutputChunks(e,t){return this.diff?super._concatOutputChunks(e,t):t}_diff(e,t){if(t)return e?ca(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return Ka(e[0].text)}async parse(e){return Ka(e,JSON.parse)}getFormatInstructions(){return""}_baseMessageToString(e){return e.text}};var Yp=class extends yn{static lc_name(){return"StandardSchemaOutputParser"}lc_namespace=["langchain","output_parsers","standard_schema"];schema;constructor(e){super(),this.schema=e}static fromSerializableSchema(e){return new this(e)}async parse(e){try{let t=Ka(e,JSON.parse),r=await this.schema["~standard"].validate(t);if(r.issues)throw new Error(`Validation failed: ${JSON.stringify(r.issues)}`);return r.value}catch(t){throw new Xt(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}getFormatInstructions(){return""}};var Gl=class extends yn{static lc_name(){return"StructuredOutputParser"}lc_namespace=["langchain","output_parsers","structured"];toJSON(){return this.toJSONNotImplemented()}constructor(e){super(e),this.schema=e}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=Nt.object(Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Nt.string().describe(n)])));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.
260
+
261
+ "JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
262
+
263
+ For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
264
+ would match an object with one required property, "foo". The "type" property specifies "foo" must be an "array", and the "description" property semantically describes it as "a list of test words". The items within "foo" must be strings.
265
+ Thus, the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of this example "JSON Schema". The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.
266
+
267
+ Your output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!
268
+
269
+ Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
270
+ \`\`\`json
271
+ ${JSON.stringify(Et(this.schema))}
272
+ \`\`\`
273
+ `}async parse(e){try{let t=e.trim(),r=(t.match(/^```(?:json)?\s*([\s\S]*?)```/)?.[1]||t.match(/```json\s*([\s\S]*?)```/)?.[1]||t).replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,(n,i)=>`"${i.replace(/\n/g,"\\n")}"`).replace(/\n/g,"");return await wa(this.schema,JSON.parse(r))}catch(t){throw new Xt(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}},qw=class extends Gl{static lc_name(){return"JsonMarkdownStructuredOutputParser"}getFormatInstructions(e){let t=e?.interpolationDepth??1;if(t<1)throw new Error("f string interpolation depth must be at least 1");return`Return a markdown code snippet with a JSON object formatted to look like:
274
+ \`\`\`json
275
+ ${this._schemaToInstruction(Et(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}
276
+ \`\`\``}_schemaToInstruction(e,t=2){let r=e;if("type"in r){let n=!1,i;if(Array.isArray(r.type)){let s=r.type.findIndex(c=>c==="null");s!==-1&&(n=!0,r.type.splice(s,1)),i=r.type.join(" | ")}else i=r.type;if(r.type==="object"&&r.properties){let s=r.description?` // ${r.description}`:"";return`{
277
+ ${Object.entries(r.properties).map(([c,l])=>{let u=r.required?.includes(c)?"":" (optional)";return`${" ".repeat(t)}"${c}": ${this._schemaToInstruction(l,t+2)}${u}`}).join(`
278
+ `)}
279
+ ${" ".repeat(t-2)}}${s}`}if(r.type==="array"&&r.items){let s=r.description?` // ${r.description}`:"";return`array[
280
+ ${" ".repeat(t)}${this._schemaToInstruction(r.items,t+2)}
281
+ ${" ".repeat(t-2)}] ${s}`}let a=n?" (nullable)":"",o=r.description?` // ${r.description}`:"";return`${i}${o}${a}`}if("anyOf"in r)return r.anyOf.map(n=>this._schemaToInstruction(n,t)).join(`
282
+ ${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=Nt.object(Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Nt.string().describe(n)])));return new this(t)}},uP=class extends yn{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new qw(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(r){throw new Xt(`Failed to parse. Text: "${e}". Error: ${r}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}};var DF=function(){let e={};e.parser=function(v,g){return new r(v,g)},e.SAXParser=r,e.SAXStream=l,e.createStream=c,e.MAX_BUFFER_LENGTH=65536;let t=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(v,g){if(!(this instanceof r))return new r(v,g);var O=this;i(O),O.q=O.c="",O.bufferCheckPosition=e.MAX_BUFFER_LENGTH,O.opt=g||{},O.opt.lowercase=O.opt.lowercase||O.opt.lowercasetags,O.looseCase=O.opt.lowercase?"toLowerCase":"toUpperCase",O.tags=[],O.closed=O.closedRoot=O.sawRoot=!1,O.tag=O.error=null,O.strict=!!v,O.noscript=!!(v||O.opt.noscript),O.state=b.BEGIN,O.strictEntities=O.opt.strictEntities,O.ENTITIES=O.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),O.attribList=[],O.opt.xmlns&&(O.ns=Object.create(m)),O.trackPosition=O.opt.position!==!1,O.trackPosition&&(O.position=O.line=O.column=0),L(O,"onready")}Object.create||(Object.create=function(v){function g(){}return g.prototype=v,new g}),Object.keys||(Object.keys=function(v){var g=[];for(var O in v)v.hasOwnProperty(O)&&g.push(O);return g});function n(v){for(var g=Math.max(e.MAX_BUFFER_LENGTH,10),O=0,E=0,Ce=t.length;E<Ce;E++){var Ue=v[t[E]].length;if(Ue>g)switch(t[E]){case"textNode":ae(v);break;case"cdata":q(v,"oncdata",v.cdata),v.cdata="";break;case"script":q(v,"onscript",v.script),v.script="";break;default:Oe(v,"Max buffer length exceeded: "+t[E])}O=Math.max(O,Ue)}v.bufferCheckPosition=e.MAX_BUFFER_LENGTH-O+v.position}function i(v){for(var g=0,O=t.length;g<O;g++)v[t[g]]=""}function a(v){ae(v),v.cdata!==""&&(q(v,"oncdata",v.cdata),v.cdata=""),v.script!==""&&(q(v,"onscript",v.script),v.script="")}r.prototype={end:function(){mt(this)},write:on,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o=ReadableStream;o||(o=function(){});var s=e.EVENTS.filter(function(v){return v!=="error"&&v!=="end"});function c(v,g){return new l(v,g)}function l(v,g){if(!(this instanceof l))return new l(v,g);o.apply(this),this._parser=new r(v,g),this.writable=!0,this.readable=!0;var O=this;this._parser.onend=function(){O.emit("end")},this._parser.onerror=function(E){O.emit("error",E),O._parser.error=null},this._decoder=null,s.forEach(function(E){Object.defineProperty(O,"on"+E,{get:function(){return O._parser["on"+E]},set:function(Ce){if(!Ce)return O.removeAllListeners(E),O._parser["on"+E]=Ce,Ce;O.on(E,Ce)},enumerable:!0,configurable:!1})})}l.prototype=Object.create(o.prototype,{constructor:{value:l}}),l.prototype.write=function(v){return this._parser.write(v.toString()),this.emit("data",v),!0},l.prototype.end=function(v){return v&&v.length&&this.write(v),this._parser.end(),!0},l.prototype.on=function(v,g){var O=this;return!O._parser["on"+v]&&s.indexOf(v)!==-1&&(O._parser["on"+v]=function(){var E=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);E.splice(0,0,v),O.emit.apply(O,E)}),o.prototype.on.call(O,v,g)};var u="[CDATA[",d="DOCTYPE",f="http://www.w3.org/XML/1998/namespace",p="http://www.w3.org/2000/xmlns/",m={xml:f,xmlns:p},h=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,y=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function x(v){return v===" "||v===`
283
+ `||v==="\r"||v===" "}function S(v){return v==='"'||v==="'"}function $(v){return v===">"||x(v)}function P(v,g){return v.test(g)}function C(v,g){return!P(v,g)}var b=0;e.STATE={BEGIN:b++,BEGIN_WHITESPACE:b++,TEXT:b++,TEXT_ENTITY:b++,OPEN_WAKA:b++,SGML_DECL:b++,SGML_DECL_QUOTED:b++,DOCTYPE:b++,DOCTYPE_QUOTED:b++,DOCTYPE_DTD:b++,DOCTYPE_DTD_QUOTED:b++,COMMENT_STARTING:b++,COMMENT:b++,COMMENT_ENDING:b++,COMMENT_ENDED:b++,CDATA:b++,CDATA_ENDING:b++,CDATA_ENDING_2:b++,PROC_INST:b++,PROC_INST_BODY:b++,PROC_INST_ENDING:b++,OPEN_TAG:b++,OPEN_TAG_SLASH:b++,ATTRIB:b++,ATTRIB_NAME:b++,ATTRIB_NAME_SAW_WHITE:b++,ATTRIB_VALUE:b++,ATTRIB_VALUE_QUOTED:b++,ATTRIB_VALUE_CLOSED:b++,ATTRIB_VALUE_UNQUOTED:b++,ATTRIB_VALUE_ENTITY_Q:b++,ATTRIB_VALUE_ENTITY_U:b++,CLOSE_TAG:b++,CLOSE_TAG_SAW_WHITE:b++,SCRIPT:b++,SCRIPT_ENDING:b++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach(function(v){var g=e.ENTITIES[v],O=typeof g=="number"?String.fromCharCode(g):g;e.ENTITIES[v]=O});for(var B in e.STATE)e.STATE[e.STATE[B]]=B;b=e.STATE;function L(v,g,O){v[g]&&v[g](O)}function q(v,g,O){v.textNode&&ae(v),L(v,g,O)}function ae(v){v.textNode=Se(v.opt,v.textNode),v.textNode&&L(v,"ontext",v.textNode),v.textNode=""}function Se(v,g){return v.trim&&(g=g.trim()),v.normalize&&(g=g.replace(/\s+/g," ")),g}function Oe(v,g){return ae(v),v.trackPosition&&(g+=`
284
+ Line: `+v.line+`
285
+ Column: `+v.column+`
286
+ Char: `+v.c),g=new Error(g),v.error=g,L(v,"onerror",g),v}function mt(v){return v.sawRoot&&!v.closedRoot&&ye(v,"Unclosed root tag"),v.state!==b.BEGIN&&v.state!==b.BEGIN_WHITESPACE&&v.state!==b.TEXT&&Oe(v,"Unexpected end"),ae(v),v.c="",v.closed=!0,L(v,"onend"),r.call(v,v.strict,v.opt),v}function ye(v,g){if(typeof v!="object"||!(v instanceof r))throw new Error("bad call to strictFail");v.strict&&Oe(v,g)}function V(v){v.strict||(v.tagName=v.tagName[v.looseCase]());var g=v.tags[v.tags.length-1]||v,O=v.tag={name:v.tagName,attributes:{}};v.opt.xmlns&&(O.ns=g.ns),v.attribList.length=0,q(v,"onopentagstart",O)}function Y(v,g){var O=v.indexOf(":")<0?["",v]:v.split(":"),E=O[0],Ce=O[1];return g&&v==="xmlns"&&(E="xmlns",Ce=""),{prefix:E,local:Ce}}function ne(v){if(v.strict||(v.attribName=v.attribName[v.looseCase]()),v.attribList.indexOf(v.attribName)!==-1||v.tag.attributes.hasOwnProperty(v.attribName)){v.attribName=v.attribValue="";return}if(v.opt.xmlns){var g=Y(v.attribName,!0),O=g.prefix,E=g.local;if(O==="xmlns")if(E==="xml"&&v.attribValue!==f)ye(v,"xml: prefix must be bound to "+f+`
287
+ Actual: `+v.attribValue);else if(E==="xmlns"&&v.attribValue!==p)ye(v,"xmlns: prefix must be bound to "+p+`
288
+ Actual: `+v.attribValue);else{var Ce=v.tag,Ue=v.tags[v.tags.length-1]||v;Ce.ns===Ue.ns&&(Ce.ns=Object.create(Ue.ns)),Ce.ns[E]=v.attribValue}v.attribList.push([v.attribName,v.attribValue])}else v.tag.attributes[v.attribName]=v.attribValue,q(v,"onattribute",{name:v.attribName,value:v.attribValue});v.attribName=v.attribValue=""}function ie(v,g){if(v.opt.xmlns){var O=v.tag,E=Y(v.tagName);O.prefix=E.prefix,O.local=E.local,O.uri=O.ns[E.prefix]||"",O.prefix&&!O.uri&&(ye(v,"Unbound namespace prefix: "+JSON.stringify(v.tagName)),O.uri=E.prefix);var Ce=v.tags[v.tags.length-1]||v;O.ns&&Ce.ns!==O.ns&&Object.keys(O.ns).forEach(function(Ua){q(v,"onopennamespace",{prefix:Ua,uri:O.ns[Ua]})});for(var Ue=0,bt=v.attribList.length;Ue<bt;Ue++){var dt=v.attribList[Ue],Lt=dt[0],Br=dt[1],ft=Y(Lt,!0),Cn=ft.prefix,Yo=ft.local,Bu=Cn===""?"":O.ns[Cn]||"",J={name:Lt,value:Br,prefix:Cn,local:Yo,uri:Bu};Cn&&Cn!=="xmlns"&&!Bu&&(ye(v,"Unbound namespace prefix: "+JSON.stringify(Cn)),J.uri=Cn),v.tag.attributes[Lt]=J,q(v,"onattribute",J)}v.attribList.length=0}v.tag.isSelfClosing=!!g,v.sawRoot=!0,v.tags.push(v.tag),q(v,"onopentag",v.tag),g||(!v.noscript&&v.tagName.toLowerCase()==="script"?v.state=b.SCRIPT:v.state=b.TEXT,v.tag=null,v.tagName=""),v.attribName=v.attribValue="",v.attribList.length=0}function Te(v){if(!v.tagName){ye(v,"Weird empty close tag."),v.textNode+="</>",v.state=b.TEXT;return}if(v.script){if(v.tagName!=="script"){v.script+="</"+v.tagName+">",v.tagName="",v.state=b.SCRIPT;return}q(v,"onscript",v.script),v.script=""}var g=v.tags.length,O=v.tagName;v.strict||(O=O[v.looseCase]());for(var E=O;g--&&v.tags[g].name!==E;)ye(v,"Unexpected close tag");if(g<0){ye(v,"Unmatched closing tag: "+v.tagName),v.textNode+="</"+v.tagName+">",v.state=b.TEXT;return}v.tagName=O;for(var Ce=v.tags.length;Ce-- >g;){var Ue=v.tag=v.tags.pop();v.tagName=v.tag.name,q(v,"onclosetag",v.tagName);var bt={};for(var dt in Ue.ns)bt[dt]=Ue.ns[dt];var Lt=v.tags[v.tags.length-1]||v;v.opt.xmlns&&Ue.ns!==Lt.ns&&Object.keys(Ue.ns).forEach(function(Br){var ft=Ue.ns[Br];q(v,"onclosenamespace",{prefix:Br,uri:ft})})}g===0&&(v.closedRoot=!0),v.tagName=v.attribValue=v.attribName="",v.attribList.length=0,v.state=b.TEXT}function Tr(v){var g=v.entity,O=g.toLowerCase(),E,Ce="";return v.ENTITIES[g]?v.ENTITIES[g]:v.ENTITIES[O]?v.ENTITIES[O]:(g=O,g.charAt(0)==="#"&&(g.charAt(1)==="x"?(g=g.slice(2),E=parseInt(g,16),Ce=E.toString(16)):(g=g.slice(1),E=parseInt(g,10),Ce=E.toString(10))),g=g.replace(/^0+/,""),isNaN(E)||Ce.toLowerCase()!==g?(ye(v,"Invalid character entity"),"&"+v.entity+";"):String.fromCodePoint(E))}function Li(v,g){g==="<"?(v.state=b.OPEN_WAKA,v.startTagPosition=v.position):x(g)||(ye(v,"Non-whitespace before first tag."),v.textNode=g,v.state=b.TEXT)}function Fi(v,g){var O="";return g<v.length&&(O=v.charAt(g)),O}function on(v){var g=this;if(this.error)throw this.error;if(g.closed)return Oe(g,"Cannot write after close. Assign an onready handler.");if(v===null)return mt(g);typeof v=="object"&&(v=v.toString());for(var O=0,E="";E=Fi(v,O++),g.c=E,!!E;)switch(g.trackPosition&&(g.position++,E===`
289
+ `?(g.line++,g.column=0):g.column++),g.state){case b.BEGIN:if(g.state=b.BEGIN_WHITESPACE,E==="\uFEFF")continue;Li(g,E);continue;case b.BEGIN_WHITESPACE:Li(g,E);continue;case b.TEXT:if(g.sawRoot&&!g.closedRoot){for(var Ce=O-1;E&&E!=="<"&&E!=="&";)E=Fi(v,O++),E&&g.trackPosition&&(g.position++,E===`
290
+ `?(g.line++,g.column=0):g.column++);g.textNode+=v.substring(Ce,O-1)}E==="<"&&!(g.sawRoot&&g.closedRoot&&!g.strict)?(g.state=b.OPEN_WAKA,g.startTagPosition=g.position):(!x(E)&&(!g.sawRoot||g.closedRoot)&&ye(g,"Text data outside of root node."),E==="&"?g.state=b.TEXT_ENTITY:g.textNode+=E);continue;case b.SCRIPT:E==="<"?g.state=b.SCRIPT_ENDING:g.script+=E;continue;case b.SCRIPT_ENDING:E==="/"?g.state=b.CLOSE_TAG:(g.script+="<"+E,g.state=b.SCRIPT);continue;case b.OPEN_WAKA:if(E==="!")g.state=b.SGML_DECL,g.sgmlDecl="";else if(!x(E))if(P(h,E))g.state=b.OPEN_TAG,g.tagName=E;else if(E==="/")g.state=b.CLOSE_TAG,g.tagName="";else if(E==="?")g.state=b.PROC_INST,g.procInstName=g.procInstBody="";else{if(ye(g,"Unencoded <"),g.startTagPosition+1<g.position){var Ue=g.position-g.startTagPosition;E=new Array(Ue).join(" ")+E}g.textNode+="<"+E,g.state=b.TEXT}continue;case b.SGML_DECL:(g.sgmlDecl+E).toUpperCase()===u?(q(g,"onopencdata"),g.state=b.CDATA,g.sgmlDecl="",g.cdata=""):g.sgmlDecl+E==="--"?(g.state=b.COMMENT,g.comment="",g.sgmlDecl=""):(g.sgmlDecl+E).toUpperCase()===d?(g.state=b.DOCTYPE,(g.doctype||g.sawRoot)&&ye(g,"Inappropriately located doctype declaration"),g.doctype="",g.sgmlDecl=""):E===">"?(q(g,"onsgmldeclaration",g.sgmlDecl),g.sgmlDecl="",g.state=b.TEXT):(S(E)&&(g.state=b.SGML_DECL_QUOTED),g.sgmlDecl+=E);continue;case b.SGML_DECL_QUOTED:E===g.q&&(g.state=b.SGML_DECL,g.q=""),g.sgmlDecl+=E;continue;case b.DOCTYPE:E===">"?(g.state=b.TEXT,q(g,"ondoctype",g.doctype),g.doctype=!0):(g.doctype+=E,E==="["?g.state=b.DOCTYPE_DTD:S(E)&&(g.state=b.DOCTYPE_QUOTED,g.q=E));continue;case b.DOCTYPE_QUOTED:g.doctype+=E,E===g.q&&(g.q="",g.state=b.DOCTYPE);continue;case b.DOCTYPE_DTD:g.doctype+=E,E==="]"?g.state=b.DOCTYPE:S(E)&&(g.state=b.DOCTYPE_DTD_QUOTED,g.q=E);continue;case b.DOCTYPE_DTD_QUOTED:g.doctype+=E,E===g.q&&(g.state=b.DOCTYPE_DTD,g.q="");continue;case b.COMMENT:E==="-"?g.state=b.COMMENT_ENDING:g.comment+=E;continue;case b.COMMENT_ENDING:E==="-"?(g.state=b.COMMENT_ENDED,g.comment=Se(g.opt,g.comment),g.comment&&q(g,"oncomment",g.comment),g.comment=""):(g.comment+="-"+E,g.state=b.COMMENT);continue;case b.COMMENT_ENDED:E!==">"?(ye(g,"Malformed comment"),g.comment+="--"+E,g.state=b.COMMENT):g.state=b.TEXT;continue;case b.CDATA:E==="]"?g.state=b.CDATA_ENDING:g.cdata+=E;continue;case b.CDATA_ENDING:E==="]"?g.state=b.CDATA_ENDING_2:(g.cdata+="]"+E,g.state=b.CDATA);continue;case b.CDATA_ENDING_2:E===">"?(g.cdata&&q(g,"oncdata",g.cdata),q(g,"onclosecdata"),g.cdata="",g.state=b.TEXT):E==="]"?g.cdata+="]":(g.cdata+="]]"+E,g.state=b.CDATA);continue;case b.PROC_INST:E==="?"?g.state=b.PROC_INST_ENDING:x(E)?g.state=b.PROC_INST_BODY:g.procInstName+=E;continue;case b.PROC_INST_BODY:if(!g.procInstBody&&x(E))continue;E==="?"?g.state=b.PROC_INST_ENDING:g.procInstBody+=E;continue;case b.PROC_INST_ENDING:E===">"?(q(g,"onprocessinginstruction",{name:g.procInstName,body:g.procInstBody}),g.procInstName=g.procInstBody="",g.state=b.TEXT):(g.procInstBody+="?"+E,g.state=b.PROC_INST_BODY);continue;case b.OPEN_TAG:P(_,E)?g.tagName+=E:(V(g),E===">"?ie(g):E==="/"?g.state=b.OPEN_TAG_SLASH:(x(E)||ye(g,"Invalid character in tag name"),g.state=b.ATTRIB));continue;case b.OPEN_TAG_SLASH:E===">"?(ie(g,!0),Te(g)):(ye(g,"Forward-slash in opening tag not followed by >"),g.state=b.ATTRIB);continue;case b.ATTRIB:if(x(E))continue;E===">"?ie(g):E==="/"?g.state=b.OPEN_TAG_SLASH:P(h,E)?(g.attribName=E,g.attribValue="",g.state=b.ATTRIB_NAME):ye(g,"Invalid attribute name");continue;case b.ATTRIB_NAME:E==="="?g.state=b.ATTRIB_VALUE:E===">"?(ye(g,"Attribute without value"),g.attribValue=g.attribName,ne(g),ie(g)):x(E)?g.state=b.ATTRIB_NAME_SAW_WHITE:P(_,E)?g.attribName+=E:ye(g,"Invalid attribute name");continue;case b.ATTRIB_NAME_SAW_WHITE:if(E==="=")g.state=b.ATTRIB_VALUE;else{if(x(E))continue;ye(g,"Attribute without value"),g.tag.attributes[g.attribName]="",g.attribValue="",q(g,"onattribute",{name:g.attribName,value:""}),g.attribName="",E===">"?ie(g):P(h,E)?(g.attribName=E,g.state=b.ATTRIB_NAME):(ye(g,"Invalid attribute name"),g.state=b.ATTRIB)}continue;case b.ATTRIB_VALUE:if(x(E))continue;S(E)?(g.q=E,g.state=b.ATTRIB_VALUE_QUOTED):(ye(g,"Unquoted attribute value"),g.state=b.ATTRIB_VALUE_UNQUOTED,g.attribValue=E);continue;case b.ATTRIB_VALUE_QUOTED:if(E!==g.q){E==="&"?g.state=b.ATTRIB_VALUE_ENTITY_Q:g.attribValue+=E;continue}ne(g),g.q="",g.state=b.ATTRIB_VALUE_CLOSED;continue;case b.ATTRIB_VALUE_CLOSED:x(E)?g.state=b.ATTRIB:E===">"?ie(g):E==="/"?g.state=b.OPEN_TAG_SLASH:P(h,E)?(ye(g,"No whitespace between attributes"),g.attribName=E,g.attribValue="",g.state=b.ATTRIB_NAME):ye(g,"Invalid attribute name");continue;case b.ATTRIB_VALUE_UNQUOTED:if(!$(E)){E==="&"?g.state=b.ATTRIB_VALUE_ENTITY_U:g.attribValue+=E;continue}ne(g),E===">"?ie(g):g.state=b.ATTRIB;continue;case b.CLOSE_TAG:if(g.tagName)E===">"?Te(g):P(_,E)?g.tagName+=E:g.script?(g.script+="</"+g.tagName,g.tagName="",g.state=b.SCRIPT):(x(E)||ye(g,"Invalid tagname in closing tag"),g.state=b.CLOSE_TAG_SAW_WHITE);else{if(x(E))continue;C(h,E)?g.script?(g.script+="</"+E,g.state=b.SCRIPT):ye(g,"Invalid tagname in closing tag."):g.tagName=E}continue;case b.CLOSE_TAG_SAW_WHITE:if(x(E))continue;E===">"?Te(g):ye(g,"Invalid characters in closing tag");continue;case b.TEXT_ENTITY:case b.ATTRIB_VALUE_ENTITY_Q:case b.ATTRIB_VALUE_ENTITY_U:var bt,dt;switch(g.state){case b.TEXT_ENTITY:bt=b.TEXT,dt="textNode";break;case b.ATTRIB_VALUE_ENTITY_Q:bt=b.ATTRIB_VALUE_QUOTED,dt="attribValue";break;case b.ATTRIB_VALUE_ENTITY_U:bt=b.ATTRIB_VALUE_UNQUOTED,dt="attribValue";break}if(E===";")if(g.opt.unparsedEntities){var Lt=Tr(g);g.entity="",g.state=bt,g.write(Lt)}else g[dt]+=Tr(g),g.entity="",g.state=bt;else P(g.entity.length?w:y,E)?g.entity+=E:(ye(g,"Invalid character in entity name"),g[dt]+="&"+g.entity+E,g.entity="",g.state=bt);continue;default:throw new Error(g,"Unknown state: "+g.state)}return g.position>=g.bufferCheckPosition&&n(g),g}return String.fromCodePoint||(function(){var v=String.fromCharCode,g=Math.floor,O=function(){var E=16384,Ce=[],Ue,bt,dt=-1,Lt=arguments.length;if(!Lt)return"";for(var Br="";++dt<Lt;){var ft=Number(arguments[dt]);if(!isFinite(ft)||ft<0||ft>1114111||g(ft)!==ft)throw RangeError("Invalid code point: "+ft);ft<=65535?Ce.push(ft):(ft-=65536,Ue=(ft>>10)+55296,bt=ft%1024+56320,Ce.push(Ue,bt)),(dt+1===Lt||Ce.length>E)&&(Br+=v.apply(null,Ce),Ce.length=0)}return Br};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:O,configurable:!0,writable:!0}):String.fromCodePoint=O})(),e},dP=DF();var Qp=`The output should be formatted as a XML file.
291
+ 1. Output should conform to the tags below.
292
+ 2. If tags are not given, make them on your own.
293
+ 3. Remember to always open and close all the tags.
294
+
295
+ As an example, for the tags ["foo", "bar", "baz"]:
296
+ 1. String "<foo>
297
+ <bar>
298
+ <baz></baz>
299
+ </bar>
300
+ </foo>" is a well-formatted instance of the schema.
301
+ 2. String "<foo>
302
+ <bar>
303
+ </foo>" is a badly-formatted instance.
304
+ 3. String "<foo>
305
+ <tag>
306
+ </tag>
307
+ </foo>" is a badly-formatted instance.
308
+
309
+ Here are the output tags:
310
+ \`\`\`
311
+ {tags}
312
+ \`\`\``,fP=class extends Qn{tags;constructor(e){super(e),this.tags=e?.tags}static lc_name(){return"XMLOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_diff(e,t){if(t)return e?ca(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return em(e[0].text)}async parse(e){return em(e)}getFormatInstructions(){return this.tags&&this.tags.length>0?Qp.replace("{tags}",this.tags?.join(", ")??""):Qp}},zF=e=>e.split(`
313
+ `).map(t=>t.replace(/^\s+/,"")).join(`
314
+ `).trim(),pP=e=>{if(Object.keys(e).length===0)return{};let t={};return e.children.length>0?(t[e.name]=e.children.map(pP),t):(t[e.name]=e.text??void 0,t)};function em(e){let t=zF(e),r=dP.parser(!0),n={},i=[];r.onopentag=s=>{let c={name:s.name,attributes:s.attributes,children:[],text:"",isSelfClosing:s.isSelfClosing};i.length>0?i[i.length-1].children.push(c):n=c,s.isSelfClosing||i.push(c)},r.onclosetag=()=>{if(i.length>0){let s=i.pop();i.length===0&&s&&(n=s)}},r.ontext=s=>{if(i.length>0){let c=i[i.length-1];c.text+=s}},r.onattribute=s=>{if(i.length>0){let c=i[i.length-1];c.attributes[s.name]=s.value}};let a=/```(xml)?(.*)```/s.exec(t),o=a?a[2]:t;return r.write(o).close(),n&&n.name==="?xml"&&(n=n.children[0]),pP(n)}var mP=T({AsymmetricStructuredOutputParser:()=>uP,BaseCumulativeTransformOutputParser:()=>Qn,BaseLLMOutputParser:()=>nc,BaseOutputParser:()=>yn,BaseTransformOutputParser:()=>Ci,BytesOutputParser:()=>iP,CommaSeparatedListOutputParser:()=>aP,CustomListOutputParser:()=>oP,JsonMarkdownStructuredOutputParser:()=>qw,JsonOutputParser:()=>Xp,ListOutputParser:()=>ic,MarkdownListOutputParser:()=>cP,NumberedListOutputParser:()=>sP,OutputParserException:()=>Xt,StandardSchemaOutputParser:()=>Yp,StringOutputParser:()=>lP,StructuredOutputParser:()=>Gl,XMLOutputParser:()=>fP,XML_FORMAT_INSTRUCTIONS:()=>Qp,parseJsonMarkdown:()=>Ka,parsePartialJson:()=>Dn,parseXMLMarkdown:()=>em});var hP=T({extendInteropZodObject:()=>xp,getInteropZodDefaultGetter:()=>Sp,getInteropZodObjectShape:()=>xi,getSchemaDescription:()=>Si,interopParse:()=>xa,interopParseAsync:()=>wa,interopSafeParse:()=>KC,interopSafeParseAsync:()=>wp,interopZodObjectMakeFieldsOptional:()=>XC,interopZodObjectPartial:()=>Sa,interopZodObjectPassthrough:()=>bp,interopZodObjectStrict:()=>Hs,interopZodTransformInputSchema:()=>kp,isInteropZodError:()=>$p,isInteropZodLiteral:()=>JC,isInteropZodObject:()=>Jt,isInteropZodSchema:()=>xr,isShapelessZodSchema:()=>qC,isSimpleStringZodSchema:()=>Gs,isZodArrayV4:()=>Rl,isZodLiteralV3:()=>hw,isZodLiteralV4:()=>gw,isZodNullableV4:()=>yw,isZodObjectV3:()=>Nl,isZodObjectV4:()=>Kr,isZodOptionalV4:()=>_w,isZodSchema:()=>WC,isZodSchemaV3:()=>lt,isZodSchemaV4:()=>Ge});function Xw(e,t){if(e.function===void 0)return;let r;if(t?.partial)try{r=Dn(e.function.arguments??"{}")}catch{return}else try{r=JSON.parse(e.function.arguments)}catch(i){throw new Xt([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${i.message}`].join(`
315
+ `))}let n={name:e.function.name,args:r,type:"tool_call"};return t?.returnId&&(n.id=e.id),n}function gP(e){if(e.id===void 0)throw new Error('All OpenAI tool calls must have an "id" field.');return{id:e.id,type:"function",function:{name:e.name,arguments:JSON.stringify(e.args)}}}function _P(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}var Yw=class extends Qn{static lc_name(){return"JsonOutputToolsParser"}returnId=!1;lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;constructor(e){super(e),this.returnId=e?.returnId??this.returnId}_diff(){throw new Error("Not supported.")}async parse(){throw new Error("Not implemented.")}async parseResult(e){return await this.parsePartialResult(e,!1)}async parsePartialResult(e,t=!0){let r=e[0].message,n;if(us(r)&&r.tool_calls?.length?n=r.tool_calls.map(a=>{let{id:o,...s}=a;return this.returnId?{id:o,...s}:s}):r.additional_kwargs.tool_calls!==void 0&&(n=JSON.parse(JSON.stringify(r.additional_kwargs.tool_calls)).map(a=>Xw(a,{returnId:this.returnId,partial:t}))),!n)return[];let i=[];for(let a of n)if(a!==void 0){let o={type:a.name,args:a.args,id:a.id};i.push(o)}return i}},tm=class extends Yw{static lc_name(){return"JsonOutputKeyToolsParser"}lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;returnId=!1;keyName;returnSingle=!1;zodSchema;serializableSchema;constructor(e){super(e),this.keyName=e.keyName,this.returnSingle=e.returnSingle??this.returnSingle,"zodSchema"in e&&(this.zodSchema=e.zodSchema),"serializableSchema"in e&&(this.serializableSchema=e.serializableSchema)}async _validateResult(e){if(this.serializableSchema!==void 0){let r=await this.serializableSchema["~standard"].validate(e);if(r.issues)throw new Xt(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(r.issues)}`,JSON.stringify(e,null,2));return r.value}if(this.zodSchema===void 0)return e;let t=await wp(this.zodSchema,e);if(t.success)return t.data;throw new Xt(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(t.error?.issues)}`,JSON.stringify(e,null,2))}async parsePartialResult(e){let t=(await super.parsePartialResult(e)).filter(n=>n.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(n=>n.args)),this.returnSingle?r[0]:r}async parseResult(e){let t=(await super.parsePartialResult(e,!1)).filter(n=>n.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(n=>n.args)),this.returnSingle?this._validateResult(r[0]):await Promise.all(r.map(n=>this._validateResult(n)))}};var yP=T({assembleStructuredOutputPipeline:()=>Qw,createContentParser:()=>UF,createFunctionCallingParser:()=>LF});function UF(e){return xr(e)?Gl.fromZodSchema(e):fo(e)?Yp.fromSerializableSchema(e):new Xp}function LF(e,t,r){let n=r??tm;return xr(e)?new n({returnSingle:!0,keyName:t,zodSchema:e}):fo(e)?new n({returnSingle:!0,keyName:t,serializableSchema:e}):new n({returnSingle:!0,keyName:t})}function Qw(e,t,r,n){if(!r){let c=e.pipe(t);return n?c.withConfig({runName:n}):c}let i=Ti.assign({parsed:(c,l)=>t.invoke(c.raw,l)}),a=Ti.assign({parsed:()=>null}),o=i.withFallbacks({fallbacks:[a]}),s=Lr.from([{raw:e},o]);return n?s.withConfig({runName:n}):s}var bP=T({ChatModelStream:()=>Ca,ReasoningContentStream:()=>SP,TextContentStream:()=>wP,ToolCallsStream:()=>xP,UsageMetadataStream:()=>kP}),FF=class{events=[];finished=!1;waiters=[];error=null;push(e){this.events.push(e);let t=this.waiters.splice(0);for(let r of t)r()}finish(){this.finished=!0;let e=this.waiters.splice(0);for(let t of e)t()}setError(e){this.error=e,this.finished=!0;let t=this.waiters.splice(0);for(let r of t)r()}async*iterate(){if(this.finished){if(this.error)throw this.error;yield*this.events;return}let e=0;for(;;){for(;e<this.events.length;)yield this.events[e],e++;if(this.finished){if(this.error)throw this.error;return}await new Promise(t=>{if(e<this.events.length||this.finished){t();return}this.waiters.push(t)})}}};function BF(e,t){switch(t.type){case"text-delta":return e.type==="text"?{...e,text:(e.text??"")+t.text}:e;case"reasoning-delta":return e.type==="thinking"?{...e,thinking:(e.thinking??"")+t.reasoning}:e.type==="reasoning"?{...e,reasoning:(e.reasoning??"")+t.reasoning}:e;case"data-delta":return{...e,data:(e.data??"")+t.data};case"block-delta":return{...e,...t.fields};default:throw new Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function Wl(e){if(e.event!=="content-block-delta")return;if("delta"in e&&e.delta)return e.delta;let t=e.content;if(t==null||typeof t!="object")return;let r=t;if(r.type==="text"&&typeof r.text=="string")return{type:"text-delta",text:r.text};if(r.type==="reasoning"&&typeof r.reasoning=="string")return{type:"reasoning-delta",reasoning:r.reasoning};if(r.type==="thinking"&&typeof r.thinking=="string")return{type:"reasoning-delta",reasoning:r.thinking};if(typeof r.data=="string")return{type:"data-delta",data:r.data,encoding:"base64"};if(typeof r.type=="string")return{type:"block-delta",fields:{...r,type:r.type}}}function vP(e){if(e==null||typeof e!="object")return;let t=e;if(t.type==="reasoning"&&typeof t.reasoning=="string")return t.reasoning;if(t.type==="thinking"&&typeof t.thinking=="string")return t.thinking}function rm(e){if(e==null||typeof e!="object")return!1;let t=e.type;return t==="reasoning"||t==="thinking"}function ac(e){if(e)return{...e,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,total_tokens:e.total_tokens??0}}function VF(e){if(e!=null&&typeof e=="object"&&!Array.isArray(e))return e;if(typeof e!="string"||e.length===0)return{};try{let t=JSON.parse(e);return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function ZF(e){let t=e;if(e.type==="tool_call"||e.type!=="tool_call_chunk"&&e.type!=="tool_use"&&e.type!=="input_json_delta")return e;let r=typeof t.name=="string"?t.name:void 0;if(r==null)return e;let n=t.args??t.input;return{...t,type:"tool_call",name:r,args:VF(n)}}var wP=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="";for await(let r of e.iterate()){let n=Wl(r);n?.type==="text-delta"&&(t+=n.text,yield t)}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate()){let n=Wl(r);n?.type==="text-delta"&&(yield n.text)}}return t()}then(e,t){return(async()=>{let r="";for await(let n of this)r+=n;return r})().then(e,t)}},xP=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t=[];for await(let r of e.iterate())r.event==="content-block-finish"&&r.content.type==="tool_call"&&(t.push(r.content),yield[...t])}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate())r.event==="content-block-finish"&&r.content.type==="tool_call"&&(yield r.content)}return t()}then(e,t){return(async()=>{let r=[];for await(let n of this)r.push(n);return r})().then(e,t)}},SP=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="",r=!1;for await(let n of e.iterate())if(n.event==="content-block-start"){if(!rm(n.content)){if(r)return;continue}r=!0;let i=vP(n.content);if(i==null||i.length===0)continue;t+=i,yield t}else if(n.event==="content-block-delta"){let i=Wl(n);if(i?.type!=="reasoning-delta")continue;r=!0;let a=i.reasoning;if(a==null||a.length===0)continue;t+=a,yield t}else{if(n.event==="content-block-finish"&&rm(n.content))return;if(n.event==="message-finish")return}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){let r=!1;for await(let n of e.iterate())if(n.event==="content-block-start"){if(!rm(n.content)){if(r)return;continue}r=!0;let i=vP(n.content);i!=null&&i.length>0&&(yield i)}else if(n.event==="content-block-delta"){let i=Wl(n);if(i?.type!=="reasoning-delta")continue;r=!0;let a=i.reasoning;a!=null&&a.length>0&&(yield a)}else{if(n.event==="content-block-finish"&&rm(n.content))return;if(n.event==="message-finish")return}}return t()}then(e,t){return(async()=>{let r="";for await(let n of this)r+=n;return r})().then(e,t)}},kP=class{_buffer;constructor(e){this._buffer=e}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate())if(r.event==="usage"){let n=ac(r.usage);n&&(yield n)}else if(r.event==="message-start"&&r.usage){let n=ac(r.usage);n&&(yield n)}else if(r.event==="message-finish"&&r.usage){let n=ac(r.usage);n&&(yield n)}}return t()}then(e,t){return(async()=>{let r;for await(let n of this)r=n;return r})().then(e,t)}},Ca=class{_buffer;constructor(e){this._buffer=new FF,this._consume(e)}async _consume(e){try{for await(let t of e)this._buffer.push(t);this._buffer.finish()}catch(t){this._buffer.setError(t instanceof Error?t:new Error(String(t)))}}[Symbol.asyncIterator](){return this._buffer.iterate()}get text(){return new wP(this._buffer)}get toolCalls(){return new xP(this._buffer)}get reasoning(){return new SP(this._buffer)}get usage(){return new kP(this._buffer)}get output(){return this._assembleMessage()}then(e,t){return this._assembleMessage().then(e,t)}async _assembleMessage(){let e=[],t,r,n={},i;for await(let o of this._buffer.iterate())switch(o.event){case"message-start":t=o.id??t,o.usage&&(r=ac(o.usage));break;case"content-block-start":e[o.index]=o.content;break;case"content-block-delta":{let s=e[o.index],c=Wl(o);s&&c&&(e[o.index]=BF(s,c));break}case"content-block-finish":e[o.index]=o.content;break;case"usage":r=ac(o.usage);break;case"message-finish":i=o.reason,o.usage&&(r=ac(o.usage)),o.responseMetadata&&(n={...n,...o.responseMetadata});break;default:break}let a=e.filter(o=>o!=null).map(ZF);return new Ne({id:t,content:a,usage_metadata:r,response_metadata:{...n,...i?{finish_reason:i}:{},output_version:"v1"}})}};var EP=T({convertChunksToEvents:()=>ex,finalizeContentBlock:()=>nm}),HF={wav:"audio/wav",mp3:"audio/mpeg",flac:"audio/flac",opus:"audio/opus",aac:"audio/aac",pcm16:"audio/pcm"},GF={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif"};function $P(e){let t=0;for(let r of e.keys())r>=t&&(t=r+1);return t}function IP(e){let t=e.additional_kwargs;return t!=null&&typeof t=="object"?t:{}}function WF(e){let t=IP(e).tool_outputs;if(!Array.isArray(t))return[];let r=[];for(let n of t){if(n==null||typeof n!="object")continue;let i=n;if(i.type!=="image_generation_call")continue;let a=typeof i.result=="string"?i.result:void 0,o=typeof i.url=="string"?i.url:void 0;if(a==null&&o==null)continue;let s=typeof i.output_format=="string"?i.output_format.toLowerCase():void 0,c=(s!=null?GF[s]:void 0)??"image/png";r.push({type:"image",...typeof i.id=="string"?{id:i.id}:{},...o!=null?{url:o}:{},...a!=null?{data:a}:{},mimeType:c})}return r}function JF(e){let t=IP(e).audio;if(t==null||typeof t!="object")return;let r=t,n=typeof r.data=="string"?r.data:void 0,i=typeof r.url=="string"?r.url:void 0,a=typeof r.transcript=="string"?r.transcript:void 0;if(n==null&&i==null&&a==null)return;let o=typeof r.mime_type=="string"?r.mime_type:typeof r.mimeType=="string"?r.mimeType:void 0,s=typeof r.format=="string"?r.format.toLowerCase():void 0,c=o??(s!=null?HF[s]:void 0)??(n!=null?"audio/wav":"audio/pcm");return{...typeof r.id=="string"?{id:r.id}:{},...n!=null?{data:n}:{},...i!=null?{url:i}:{},...a!=null?{transcript:a}:{},mimeType:c}}async function*ex(e,t){let r=new Map,n=!1,i,a,o=new Set;for await(let s of e){t?.signal?.throwIfAborted();let c=s.message,l=!1;if(!n){n=!0;let f={event:"message-start",id:c.id??void 0};it.isInstance(c)&&c.usage_metadata&&(f.usage=c.usage_metadata,i={...c.usage_metadata},l=!0),yield f}let u=c.content;if(typeof u=="string"){if(u!==""){if(!r.has(0)){let m={type:"text",text:""};r.set(0,{type:"text",accumulated:m}),yield{event:"content-block-start",index:0,content:m}}let p=r.get(0);p.accumulated={...p.accumulated,text:(p.accumulated.text??"")+u},yield{event:"content-block-delta",index:0,delta:{type:"text-delta",text:u}}}}else if(Array.isArray(u))for(let f of u){let p=typeof f.index=="number"?f.index:r.size;if(!r.has(p))r.set(p,{type:f.type,accumulated:{...f}}),yield{event:"content-block-start",index:p,content:{...f}};else{let m=r.get(p),h=qF(f);m.accumulated=KF(m.accumulated,h),yield{event:"content-block-delta",index:p,delta:h}}}if(it.isInstance(c)&&c.tool_call_chunks&&c.tool_call_chunks.length>0)for(let f of c.tool_call_chunks){let p=typeof f.index=="number"?f.index:r.size;if(!r.has(p)){let h={type:"tool_call_chunk",id:f.id,name:f.name,args:"",index:p};r.set(p,{type:"tool_call_chunk",accumulated:h}),yield{event:"content-block-start",index:p,content:h}}let m=r.get(p).accumulated;f.id!=null&&(m.id=f.id),f.name!=null&&(m.name=f.name),m.args=(m.args??"")+(f.args??""),yield{event:"content-block-delta",index:p,delta:{type:"block-delta",fields:{type:"tool_call_chunk",..."id"in m&&m.id!=null?{id:m.id}:{},..."name"in m&&m.name!=null?{name:m.name}:{},args:m.args}}}}let d=JF(c);if(d!=null){if(a==null){let p=$P(r);a={index:p,id:d.id,mimeType:d.mimeType,transcript:""};let m={type:"audio",...d.id!=null?{id:d.id}:{},...d.url!=null?{url:d.url}:{},data:"",mimeType:d.mimeType};r.set(p,{type:"audio",accumulated:m}),yield{event:"content-block-start",index:p,content:m}}let f=r.get(a.index);if(f!=null){let p=f.accumulated;d.id!=null&&a.id==null&&(a.id=d.id,p.id=d.id),d.transcript!=null&&(a.transcript+=d.transcript,p.transcript=a.transcript,yield{event:"content-block-delta",index:a.index,delta:{type:"block-delta",fields:{type:"audio",transcript:a.transcript}}}),d.data!=null&&d.data.length>0&&(p.data=(p.data??"")+d.data,yield{event:"content-block-delta",index:a.index,delta:{type:"data-delta",data:d.data,encoding:"base64"}})}}for(let f of WF(c)){let p=f,m=p.id??p.url??(p.data!=null?`${p.data.length}:${p.data.slice(0,32)}`:void 0);if(m!=null&&o.has(m))continue;m!=null&&o.add(m);let h=$P(r);r.set(h,{type:"image",accumulated:f}),yield{event:"content-block-start",index:h,content:f}}if(!l&&it.isInstance(c)&&c.usage_metadata){let f=c.usage_metadata;i?i={input_tokens:i.input_tokens+f.input_tokens,output_tokens:i.output_tokens+f.output_tokens,total_tokens:i.total_tokens+f.total_tokens}:i={...f},yield{event:"usage",usage:{...i}}}}for(let[s,c]of r)yield{event:"content-block-finish",index:s,content:nm(c.accumulated)};yield{event:"message-finish",reason:"stop",...i?{usage:i}:{}}}function KF(e,t){switch(t.type){case"text-delta":return e.type==="text"?{...e,text:(e.text??"")+t.text}:e;case"reasoning-delta":return e.type==="thinking"?{...e,thinking:(e.thinking??"")+t.reasoning}:e.type==="reasoning"?{...e,reasoning:(e.reasoning??"")+t.reasoning}:e;case"data-delta":return{...e,data:(e.data??"")+t.data};case"block-delta":return{...e,...t.fields};default:throw new Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function qF(e){if(e.type==="text")return{type:"text-delta",text:e.text};if(e.type==="reasoning")return{type:"reasoning-delta",reasoning:e.reasoning};if(e.type==="thinking"&&typeof e.thinking=="string")return{type:"reasoning-delta",reasoning:e.thinking};if(typeof e.data=="string")return{type:"data-delta",data:e.data,encoding:"base64"};if(typeof e.type=="string")return{type:"block-delta",fields:{...e}};throw new Error(`Unsupported content block delta: ${JSON.stringify(e)}`)}function nm(e){if(e.type==="tool_call_chunk"){let t=e,r;try{r=JSON.parse(t.args??"{}")}catch{return{type:"invalid_tool_call",id:t.id,name:t.name,args:t.args,error:"Failed to parse tool call arguments as JSON"}}return{type:"tool_call",id:t.id,name:t.name,args:r}}return e}var TP=e=>e();function Jl(e){let t=e.constructor;return new t({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var CP=T({BaseChatModel:()=>Aa,SimpleChatModel:()=>XF});function tx(e){let t=[];for(let r of e){let n=r;if(Array.isArray(r.content))for(let i=0;i<r.content.length;i++){let a=r.content[i];(as(a)||os(a))&&n===r&&(n=new r.constructor({...n,content:[...r.content.slice(0,i),pd(a),...r.content.slice(i+1)]}))}t.push(n)}return t}var Aa=class ei extends Hl{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(t){super(t),this.outputVersion=TP(()=>{let r=t.outputVersion??ar("LC_OUTPUT_VERSION");return r&&["v0","v1"].includes(r)?r:"v0"})}_separateRunnableConfigFromCallOptionsCompat(t){let[r,n]=super._separateRunnableConfigFromCallOptions(t);return n.signal=r.signal,[r,n]}async invoke(t,r){let n=ei._convertInputToPromptValue(t);return(await this.generatePrompt([n],r,r?.callbacks)).generations[0][0].message}async*_streamResponseChunks(t,r,n){throw new Error("Not implemented.")}async*_streamChatModelEvents(t,r,n){yield*ex(this._streamResponseChunks(t,r,n),{signal:r.signal})}streamEvents(t,r,n){if(r?.version==="v1"||r?.version==="v2")return super.streamEvents(t,r,n);let i=ei._convertInputToPromptValue(t).toChatMessages(),[,a]=this._separateRunnableConfigFromCallOptionsCompat(r);return new Ca(this._streamChatModelEvents(i,a))}streamV2(t,r){return this.streamEvents(t,r)}async*_streamIterator(t,r){if(this._streamResponseChunks===ei.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,r);else{let n=ei._convertInputToPromptValue(t).toChatMessages(),[i,a]=this._separateRunnableConfigFromCallOptionsCompat(r),o={...i.metadata,...this.getLsParamsWithDefaults(a)},s=this.invocationParams(a),c=await Xe.configure(i.callbacks,this.callbacks,i.tags,this.tags,o,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),l={options:a,invocation_params:s,batch_size:1},u=a.outputVersion??this.outputVersion,d=await c?.handleChatModelStart(this.toJSON(),[tx(n)],i.runId,void 0,l,void 0,void 0,i.runName),f,p;try{for await(let m of this._streamResponseChunks(n,a,d?.[0])){if(a.signal?.throwIfAborted(),m.message.id==null){let h=d?.at(0)?.runId;h!=null&&m.message._updateId(`run-${h}`)}m.message.response_metadata={...m.generationInfo,...m.message.response_metadata},u==="v1"?yield Jl(m.message):yield m.message,f?f=f.concat(m):f=m,Kc(m.message)&&m.message.usage_metadata!==void 0&&(p={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}})}a.signal?.throwIfAborted()}catch(m){throw await Promise.all((d??[]).map(h=>h?.handleLLMError(m))),m}await Promise.all((d??[]).map(m=>m?.handleLLMEnd({generations:[[f]],llmOutput:p})))}}getLsParams(t){let r=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:t.stop,ls_provider:r}}getLsParamsWithDefaults(t){return{...this.getLsParams(t),ls_integration:"langchain_chat_model"}}async _generateUncached(t,r,n,i){let a=t.map(p=>p.map(kt)),o;if(i!==void 0&&i.length===a.length)o=i;else{let p={...n.metadata,...this.getLsParamsWithDefaults(r)},m=this.invocationParams(r),h=await Xe.configure(n.callbacks,this.callbacks,n.tags,this.tags,p,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(m)}),_={options:r,invocation_params:m,batch_size:1};o=await h?.handleChatModelStart(this.toJSON(),a.map(tx),n.runId,void 0,_,void 0,void 0,n.runName)}let s=r.outputVersion??this.outputVersion,c=[],l=[],u=!!o?.[0].handlers.find(mg),d=!!o?.[0].handlers.find(Xc);if(u&&!this.disableStreaming&&a.length===1&&(this._streamChatModelEvents!==ei.prototype._streamChatModelEvents||this._streamResponseChunks!==ei.prototype._streamResponseChunks))try{let p=!1,m=o?.[0],h=this._streamChatModelEvents(a[0],r),_=await new Ca({async*[Symbol.asyncIterator](){for await(let x of h){r.signal?.throwIfAborted(),p=!0;let S=x.event==="message-start"&&x.id==null&&m?.runId!=null?{...x,id:`run-${m.runId}`}:x;await m?.handleChatModelStreamEvent(S),yield S}}});if(r.signal?.throwIfAborted(),!p)throw new Error("Received empty response from chat model call.");if(_.id==null){let x=o?.at(0)?.runId;x!=null&&_._updateId(`run-${x}`)}let y={text:_.text,message:_};c.push([y]);let w=_.usage_metadata!==void 0?{tokenUsage:{promptTokens:_.usage_metadata.input_tokens,completionTokens:_.usage_metadata.output_tokens,totalTokens:_.usage_metadata.total_tokens}}:void 0;await o?.[0].handleLLMEnd({generations:c,llmOutput:w})}catch(p){throw await o?.[0].handleLLMError(p),p}else if(d&&!this.disableStreaming&&a.length===1&&this._streamResponseChunks!==ei.prototype._streamResponseChunks)try{let p=await this._streamResponseChunks(a[0],r,o?.[0]),m,h;for await(let _ of p){if(r.signal?.aborted){let y=m?.message;throw new dd("Model invocation was aborted.",y)}if(_.message.id==null){let y=o?.at(0)?.runId;y!=null&&_.message._updateId(`run-${y}`)}m===void 0?m=_:m=Mr(m,_),Kc(_.message)&&_.message.usage_metadata!==void 0&&(h={tokenUsage:{promptTokens:_.message.usage_metadata.input_tokens,completionTokens:_.message.usage_metadata.output_tokens,totalTokens:_.message.usage_metadata.total_tokens}})}if(r.signal?.aborted){let _=m?.message;throw new dd("Model invocation was aborted.",_)}if(m===void 0)throw new Error("Received empty response from chat model call.");s==="v1"&&(m.message=Jl(m.message)),c.push([m]),await o?.[0].handleLLMEnd({generations:c,llmOutput:h})}catch(p){throw await o?.[0].handleLLMError(p),p}else{let p=await Promise.allSettled(a.map(async(m,h)=>{let _=await this._generate(m,{...r,promptIndex:h},o?.[h]);if(s==="v1")for(let y of _.generations)y.message=Jl(y.message);return _}));await Promise.all(p.map(async(m,h)=>{if(m.status==="fulfilled"){let _=m.value;for(let y of _.generations){if(y.message.id==null){let w=o?.at(0)?.runId;w!=null&&y.message._updateId(`run-${w}`)}y.message.response_metadata={...y.generationInfo,...y.message.response_metadata}}return _.generations.length===1&&(_.generations[0].message.response_metadata={..._.llmOutput,..._.generations[0].message.response_metadata}),c[h]=_.generations,l[h]=_.llmOutput,o?.[h]?.handleLLMEnd({generations:[_.generations],llmOutput:_.llmOutput})}else return await o?.[h]?.handleLLMError(m.reason),Promise.reject(m.reason)}))}let f={generations:c,llmOutput:l.length?this._combineLLMOutput?.(...l):void 0};return Object.defineProperty(f,uo,{value:o?{runIds:o?.map(p=>p.runId)}:void 0,configurable:!0}),f}async _generateCached({messages:t,cache:r,llmStringKey:n,parsedOptions:i,handledOptions:a}){let o=t.map(y=>y.map(kt)),s={...a.metadata,...this.getLsParamsWithDefaults(i)},c=this.invocationParams(i),l=await Xe.configure(a.callbacks,this.callbacks,a.tags,this.tags,s,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(c)}),u={options:i,invocation_params:c,batch_size:1},d=await l?.handleChatModelStart(this.toJSON(),o.map(tx),a.runId,void 0,u,void 0,void 0,a.runName),f=[],p=(await Promise.allSettled(o.map(async(y,w)=>{let x=ei._convertInputToPromptValue(y).toString(),S=await r.lookup(x,n);return S==null&&f.push(w),S}))).map((y,w)=>({result:y,runManager:d?.[w]})).filter(({result:y})=>y.status==="fulfilled"&&y.value!=null||y.status==="rejected"),m=i.outputVersion??this.outputVersion,h=[];await Promise.all(p.map(async({result:y,runManager:w},x)=>{if(y.status==="fulfilled"){let S=y.value;return h[x]=S.map($=>("message"in $&&tt($.message)&&us($.message)&&($.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},m==="v1"&&($.message=Jl($.message))),$.generationInfo={...$.generationInfo,tokenUsage:{}},$)),S.length&&await w?.handleLLMNewToken(S[0].text),w?.handleLLMEnd({generations:[S]},void 0,void 0,void 0,{cached:!0})}else return await w?.handleLLMError(y.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(y.reason)}));let _={generations:h,missingPromptIndices:f,startedRunManagers:d};return Object.defineProperty(_,uo,{value:d?{runIds:d?.map(y=>y.runId)}:void 0,configurable:!0}),_}async generate(t,r,n){let i;Array.isArray(r)?i={stop:r}:i=r;let a=t.map(m=>m.map(kt)),[o,s]=this._separateRunnableConfigFromCallOptionsCompat(i);if(o.callbacks=o.callbacks??n,!this.cache)return this._generateUncached(a,s,o);let{cache:c}=this,l=this._getSerializedCacheKeyParametersForCall(s),{generations:u,missingPromptIndices:d,startedRunManagers:f}=await this._generateCached({messages:a,cache:c,llmStringKey:l,parsedOptions:s,handledOptions:o}),p={};if(d.length>0){let m=await this._generateUncached(d.map(h=>a[h]),s,o,f!==void 0?d.map(h=>f?.[h]):void 0);await Promise.all(m.generations.map(async(h,_)=>{let y=d[_];u[y]=h;let w=ei._convertInputToPromptValue(a[y]).toString();return c.update(w,l,h)})),p=m.llmOutput??{}}return{generations:u,llmOutput:p}}invocationParams(t){return{}}_modelType(){return"base_chat_model"}async generatePrompt(t,r,n){let i=t.map(a=>a.toChatMessages());return this.generate(i,r,n)}withStructuredOutput(t,r){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(r?.strict)throw new Error('"strict" mode is not supported for this model by default.');let n=t,i=r?.name,a=Si(n)??"A function available to call.",o=r?.method,s=r?.includeRaw;if(o==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let c=i??"extract";!xr(n)&&!fo(n)&&"name"in n&&(c=n.name);let l=xr(n)||fo(n)?Et(n):n,u=[{type:"function",function:{name:c,description:a,parameters:l}}];return Qw(this.bindTools(u),qt.from(d=>{if(!it.isInstance(d))throw new Error("Input is not an AIMessageChunk.");if(!d.tool_calls||d.tool_calls.length===0)throw new Error("No tool calls found in the response.");let f=d.tool_calls.find(p=>p.name===c);if(!f)throw new Error(`No tool call found with name ${c}.`);return f.args}),s,s?"StructuredOutputRunnable":"StructuredOutput")}},XF=class extends Aa{async _generate(e,t,r){let n=new Ne(await this._call(e,t,r));if(typeof n.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:n.content,message:n}]}}};var AP=T({convertOpenAICompletionsStream:()=>YF});async function*YF(e,t={}){let r=t.streamUsage??!0,n=t.provider??"openai",i=t.mapChunk,a=new Map,o=new Map,s=0,c=!1,l,u,d,f=!1,p=(m,h)=>{let _=o.get(m);if(_!==void 0)return{index:_,isNew:!1};let y=s++;return o.set(m,y),a.set(y,{...h}),{index:y,isNew:!0}};for await(let m of e){i&&(m=i(m)),c||(c=!0,yield{event:"message-start",id:m.id}),!f&&(m.model||m.service_tier)&&(f=!0,yield{event:"provider",provider:n,name:"stream_metadata",payload:{model:m.model,service_tier:m.service_tier}}),m.usage&&r&&(l=rB(m.usage),yield{event:"usage",usage:l});let h=m.x_groq?.usage;h&&r&&(l=eB(h),yield{event:"usage",usage:l});let _=m.choices?.[0];if(!_)continue;_.finish_reason!=null&&(u=tB(_.finish_reason),d=nB(m,_));let{delta:y}=_;if(!y)continue;let w=QF(y);if(w){let{index:x,isNew:S}=p("reasoning",{type:"reasoning",reasoning:""});S&&(yield{event:"content-block-start",index:x,content:{type:"reasoning",reasoning:""}});let $=a.get(x);$.reasoning=($.reasoning??"")+w,yield{event:"content-block-delta",index:x,delta:{type:"reasoning-delta",reasoning:w}}}if(y.content){let{index:x,isNew:S}=p("text",{type:"text",text:""});S&&(yield{event:"content-block-start",index:x,content:{type:"text",text:""}});let $=a.get(x);$.text=($.text??"")+y.content,yield{event:"content-block-delta",index:x,delta:{type:"text-delta",text:y.content}}}if(Array.isArray(y.tool_calls))for(let x of y.tool_calls){let S=x.index??0,{index:$,isNew:P}=p(`tool:${S}`,{type:"tool_call_chunk",id:x.id,name:x.function?.name,args:"",index:S});P&&(yield{event:"content-block-start",index:$,content:{type:"tool_call_chunk",id:x.id,name:x.function?.name,args:"",index:S}});let C=a.get($);x.id!=null&&(C.id=x.id),x.function?.name!=null&&(C.name=x.function.name);let b=x.function?.arguments??"";C.args=(C.args??"")+b,yield{event:"content-block-delta",index:$,delta:{type:"block-delta",fields:{type:"tool_call_chunk",...C.id!=null?{id:C.id}:{},...C.name!=null?{name:C.name}:{},args:C.args}}}}if(y.audio){let{index:x,isNew:S}=p("audio",{type:"audio",id:y.audio.id,data:"",mimeType:"audio/pcm",transcript:y.audio.transcript??""});S&&(yield{event:"content-block-start",index:x,content:{type:"audio",id:y.audio.id,data:"",mimeType:"audio/pcm",transcript:y.audio.transcript??""}});let $=a.get(x);y.audio.transcript&&($.transcript=($.transcript??"")+y.audio.transcript,yield{event:"content-block-delta",index:x,delta:{type:"block-delta",fields:{type:"audio",transcript:$.transcript}}}),y.audio.data&&($.data=($.data??"")+y.audio.data,yield{event:"content-block-delta",index:x,delta:{type:"data-delta",data:y.audio.data,encoding:"base64"}})}y.function_call&&(yield{event:"provider",provider:n,name:"function_call",payload:y.function_call}),_.logprobs&&(yield{event:"provider",provider:n,name:"logprobs",payload:_.logprobs})}for(let[m,h]of a)yield{event:"content-block-finish",index:m,content:nm(h)};yield{event:"message-finish",reason:u,...l?{usage:l}:{},...d?{responseMetadata:d}:{}}}function QF(e){let t=e.reasoning_content??e.reasoning;return typeof t=="string"&&t.length>0?t:void 0}function eB(e){return{input_tokens:e.prompt_tokens??0,output_tokens:e.completion_tokens??0,total_tokens:e.total_tokens??0}}function tB(e){switch(e){case"stop":return"stop";case"length":case"max_tokens":return"length";case"tool_calls":case"function_call":return"tool_use";case"content_filter":return"content_filter";default:return"stop"}}function rB(e){let t={...e.prompt_tokens_details?.audio_tokens!=null&&{audio:e.prompt_tokens_details.audio_tokens},...e.prompt_tokens_details?.cached_tokens!=null&&{cache_read:e.prompt_tokens_details.cached_tokens}},r={...e.completion_tokens_details?.audio_tokens!=null&&{audio:e.completion_tokens_details.audio_tokens},...e.completion_tokens_details?.reasoning_tokens!=null&&{reasoning:e.completion_tokens_details.reasoning_tokens}};return{input_tokens:e.prompt_tokens??0,output_tokens:e.completion_tokens??0,total_tokens:e.total_tokens??0,...Object.keys(t).length>0&&{input_token_details:t},...Object.keys(r).length>0&&{output_token_details:r}}}function nB(e,t){return{model_provider:"openai",model_name:e.model,system_fingerprint:e.system_fingerprint,service_tier:e.service_tier,finish_reason:t.finish_reason,...e.usage?{usage:e.usage}:{}}}var OP=T({});var PP=T({BaseLLM:()=>NP,LLM:()=>im}),NP=class Kl extends Hl{lc_namespace=["langchain","llms",this._llmType()];async invoke(t,r){let n=Kl._convertInputToPromptValue(t);return(await this.generatePrompt([n],r,r?.callbacks)).generations[0][0].text}async*_streamResponseChunks(t,r,n){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(t){let[r,n]=super._separateRunnableConfigFromCallOptions(t);return n.signal=r.signal,[r,n]}async*_streamIterator(t,r){if(this._streamResponseChunks===Kl.prototype._streamResponseChunks)yield this.invoke(t,r);else{let n=Kl._convertInputToPromptValue(t),[i,a]=this._separateRunnableConfigFromCallOptionsCompat(r),o=this.invocationParams(a),s=await Xe.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(o)}),c={options:a,invocation_params:o,batch_size:1},l=await s?.handleLLMStart(this.toJSON(),[n.toString()],i.runId,void 0,c,void 0,void 0,i.runName),u=new _i({text:""});try{for await(let d of this._streamResponseChunks(n.toString(),a,l?.[0]))u?u=u.concat(d):u=d,typeof d.text=="string"&&(yield d.text)}catch(d){throw await Promise.all((l??[]).map(f=>f?.handleLLMError(d))),d}await Promise.all((l??[]).map(d=>d?.handleLLMEnd({generations:[[u]]})))}}async generatePrompt(t,r,n){let i=t.map(a=>a.toString());return this.generate(i,r,n)}invocationParams(t){return{}}_flattenLLMResult(t){let r=[];for(let n=0;n<t.generations.length;n+=1){let i=t.generations[n];if(n===0)r.push({generations:[i],llmOutput:t.llmOutput});else{let a=t.llmOutput?{...t.llmOutput,tokenUsage:{}}:void 0;r.push({generations:[i],llmOutput:a})}}return r}async _generateUncached(t,r,n,i){let a;if(i!==void 0&&i.length===t.length)a=i;else{let l=this.invocationParams(r),u=await Xe.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(l)}),d={options:r,invocation_params:l,batch_size:t.length};a=await u?.handleLLMStart(this.toJSON(),t,n.runId,void 0,d,void 0,void 0,n?.runName)}let o=!!a?.[0].handlers.find(Xc),s;if(o&&t.length===1&&this._streamResponseChunks!==Kl.prototype._streamResponseChunks)try{let l=await this._streamResponseChunks(t[0],r,a?.[0]),u;for await(let d of l)u===void 0?u=d:u=Mr(u,d);if(u===void 0)throw new Error("Received empty response from chat model call.");s={generations:[[u]],llmOutput:{}},await a?.[0].handleLLMEnd(s)}catch(l){throw await a?.[0].handleLLMError(l),l}else{try{s=await this._generate(t,r,a?.[0])}catch(u){throw await Promise.all((a??[]).map(d=>d?.handleLLMError(u))),u}let l=this._flattenLLMResult(s);await Promise.all((a??[]).map((u,d)=>u?.handleLLMEnd(l[d])))}let c=a?.map(l=>l.runId)||void 0;return Object.defineProperty(s,uo,{value:c?{runIds:c}:void 0,configurable:!0}),s}async _generateCached({prompts:t,cache:r,llmStringKey:n,parsedOptions:i,handledOptions:a,runId:o}){let s=this.invocationParams(i),c=await Xe.configure(a.callbacks,this.callbacks,a.tags,this.tags,a.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),l={options:i,invocation_params:s,batch_size:t.length},u=await c?.handleLLMStart(this.toJSON(),t,o,void 0,l,void 0,void 0,a?.runName),d=[],f=(await Promise.allSettled(t.map(async(h,_)=>{let y=await r.lookup(h,n);return y==null&&d.push(_),y}))).map((h,_)=>({result:h,runManager:u?.[_]})).filter(({result:h})=>h.status==="fulfilled"&&h.value!=null||h.status==="rejected"),p=[];await Promise.all(f.map(async({result:h,runManager:_},y)=>{if(h.status==="fulfilled"){let w=h.value;return p[y]=w.map(x=>(x.generationInfo={...x.generationInfo,tokenUsage:{}},x)),w.length&&await _?.handleLLMNewToken(w[0].text),_?.handleLLMEnd({generations:[w]},void 0,void 0,void 0,{cached:!0})}else return await _?.handleLLMError(h.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(h.reason)}));let m={generations:p,missingPromptIndices:d,startedRunManagers:u};return Object.defineProperty(m,uo,{value:u?{runIds:u?.map(h=>h.runId)}:void 0,configurable:!0}),m}async generate(t,r,n){if(!Array.isArray(t))throw new Error("Argument 'prompts' is expected to be a string[]");let i;Array.isArray(r)?i={stop:r}:i=r;let[a,o]=this._separateRunnableConfigFromCallOptionsCompat(i);if(a.callbacks=a.callbacks??n,!this.cache)return this._generateUncached(t,o,a);let{cache:s}=this,c=this._getSerializedCacheKeyParametersForCall(o),{generations:l,missingPromptIndices:u,startedRunManagers:d}=await this._generateCached({prompts:t,cache:s,llmStringKey:c,parsedOptions:o,handledOptions:a,runId:a.runId}),f={};if(u.length>0){let p=await this._generateUncached(u.map(m=>t[m]),o,a,d!==void 0?u.map(m=>d?.[m]):void 0);await Promise.all(p.generations.map(async(m,h)=>{let _=u[h];return l[_]=m,s.update(t[_],c,m)})),f=p.llmOutput??{}}return{generations:l,llmOutput:f}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},im=class extends NP{async _generate(e,t,r){return{generations:await Promise.all(e.map((n,i)=>this._call(n,{...t,promptIndex:i},r).then(a=>[{text:a}])))}}};var RP=T({});var MP=T({BaseMemory:()=>iB,getInputValue:()=>aB,getOutputValue:()=>oB,getPromptInputKey:()=>sB}),iB=class{},jP=(e,t)=>{if(t!==void 0)return e[t];let r=Object.keys(e);if(r.length===1)return e[r[0]]},aB=(e,t)=>{let r=jP(e,t);if(!r)throw new Error(`input values have ${Object.keys(e).length} keys, you must specify an input key or pass only 1 key as input`);return r},oB=(e,t)=>{let r=jP(e,t);if(!r&&r!=="")throw new Error(`output values have ${Object.keys(e).length} keys, you must specify an output key or pass only 1 key as output`);return r};function sB(e,t){let r=Object.keys(e).filter(n=>!t.includes(n)&&n!=="stop");if(r.length!==1)throw new Error(`One input key expected, but got ${r.length}`);return r[0]}var rx=class extends nc{static lc_name(){return"OutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;argsOnly=!0;constructor(e){super(),this.argsOnly=e?.argsOnly??this.argsOnly}async parseResult(e){if("message"in e[0]){let t=e[0].message.additional_kwargs.function_call;if(!t)throw new Error(`No function_call in message ${JSON.stringify(e)}`);if(!t.arguments)throw new Error(`No arguments in function_call ${JSON.stringify(e)}`);return this.argsOnly?t.arguments:JSON.stringify(t)}else throw new Error(`No message in generations ${JSON.stringify(e)}`)}},nx=class extends Qn{static lc_name(){return"JsonOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser;argsOnly=!0;constructor(e){super(e),this.argsOnly=e?.argsOnly??this.argsOnly,this.outputParser=new rx(e)}_diff(e,t){if(t)return ca(e??{},t)}async parsePartialResult(e){let t=e[0];if(!t.message)return;let{message:r}=t,n=r.additional_kwargs.function_call;if(n)return this.argsOnly?Dn(n.arguments):{...n,arguments:Dn(n.arguments)}}async parseResult(e){let t=await this.outputParser.parseResult(e);if(!t)throw new Error(`No result from "OutputFunctionsParser" ${JSON.stringify(e)}`);return this.parse(t)}async parse(e){let t=JSON.parse(e);return this.argsOnly||(t.arguments=JSON.parse(t.arguments)),t}getFormatInstructions(){return""}},DP=class extends nc{static lc_name(){return"JsonKeyOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser=new nx;attrName;get lc_aliases(){return{attrName:"key_name"}}constructor(e){super(e),this.attrName=e.attrName}async parseResult(e){return(await this.outputParser.parseResult(e))[this.attrName]}};var zP=T({JsonKeyOutputFunctionsParser:()=>DP,JsonOutputFunctionsParser:()=>nx,OutputFunctionsParser:()=>rx});var UP=T({JsonOutputKeyToolsParser:()=>tm,JsonOutputToolsParser:()=>Yw,convertLangChainToolCallToOpenAI:()=>gP,makeInvalidToolCall:()=>_P,parseToolCall:()=>Xw});var ti=class extends se{lc_serializable=!0;lc_namespace=["langchain_core","prompts",this._getPromptType()];get lc_attributes(){return{partialVariables:void 0}}inputVariables;outputParser;partialVariables;metadata;tags;constructor(e){super(e);let{inputVariables:t}=e;if(t.includes("stop"))throw new Error("Cannot have an input variable named 'stop', as it is used internally, please rename.");Object.assign(this,e)}async mergePartialAndUserVariables(e){let t=this.partialVariables??{},r={};for(let[n,i]of Object.entries(t))typeof i=="string"?r[n]=i:r[n]=await i();return{...r,...e}}async invoke(e,t){let r={...this.metadata,...t?.metadata},n=[...this.tags??[],...t?.tags??[]];return this._callWithConfig(i=>this.formatPromptValue(i),e,{...t,tags:n,metadata:r,runType:"prompt"})}};var Ai=class extends ti{async formatPromptValue(e){return new Vl(await this.format(e))}};var cB=Object.prototype.toString,sc=Array.isArray||function(t){return cB.call(t)==="[object Array]"};function ax(e){return typeof e=="function"}function lB(e){return sc(e)?"array":typeof e}function ix(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function LP(e,t){return e!=null&&typeof e=="object"&&t in e}function uB(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var dB=RegExp.prototype.test;function fB(e,t){return dB.call(e,t)}var pB=/\S/;function mB(e){return!fB(pB,e)}var hB={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function gB(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return hB[r]})}var _B=/\s*/,yB=/\s+/,FP=/\s*=/,vB=/\s*\}/,bB=/#|\^|\/|>|\{|&|=|!/;function wB(e,t){if(!e)return[];var r=!1,n=[],i=[],a=[],o=!1,s=!1,c="",l=0;function u(){if(o&&!s)for(;a.length;)delete i[a.pop()];else a=[];o=!1,s=!1}var d,f,p;function m(b){if(typeof b=="string"&&(b=b.split(yB,2)),!sc(b)||b.length!==2)throw new Error("Invalid tags: "+b);d=new RegExp(ix(b[0])+"\\s*"),f=new RegExp("\\s*"+ix(b[1])),p=new RegExp("\\s*"+ix("}"+b[1]))}m(t||tn.tags);for(var h=new Xl(e),_,y,w,x,S,$;!h.eos();){if(_=h.pos,w=h.scanUntil(d),w)for(var P=0,C=w.length;P<C;++P)x=w.charAt(P),mB(x)?(a.push(i.length),c+=x):(s=!0,r=!0,c+=" "),i.push(["text",x,_,_+1]),_+=1,x===`
316
+ `&&(u(),c="",l=0,r=!1);if(!h.scan(d))break;if(o=!0,y=h.scan(bB)||"name",h.scan(_B),y==="="?(w=h.scanUntil(FP),h.scan(FP),h.scanUntil(f)):y==="{"?(w=h.scanUntil(p),h.scan(vB),h.scanUntil(f),y="&"):w=h.scanUntil(f),!h.scan(f))throw new Error("Unclosed tag at "+h.pos);if(y==">"?S=[y,w,_,h.pos,c,l,r]:S=[y,w,_,h.pos],l++,i.push(S),y==="#"||y==="^")n.push(S);else if(y==="/"){if($=n.pop(),!$)throw new Error('Unopened section "'+w+'" at '+_);if($[1]!==w)throw new Error('Unclosed section "'+$[1]+'" at '+_)}else y==="name"||y==="{"||y==="&"?s=!0:y==="="&&m(w)}if(u(),$=n.pop(),$)throw new Error('Unclosed section "'+$[1]+'" at '+h.pos);return SB(xB(i))}function xB(e){for(var t=[],r,n,i=0,a=e.length;i<a;++i)r=e[i],r&&(r[0]==="text"&&n&&n[0]==="text"?(n[1]+=r[1],n[3]=r[3]):(t.push(r),n=r));return t}function SB(e){for(var t=[],r=t,n=[],i,a,o=0,s=e.length;o<s;++o)switch(i=e[o],i[0]){case"#":case"^":r.push(i),n.push(i),r=i[4]=[];break;case"/":a=n.pop(),a[5]=i[2],r=n.length>0?n[n.length-1][4]:t;break;default:r.push(i)}return t}function Xl(e){this.string=e,this.tail=e,this.pos=0}Xl.prototype.eos=function(){return this.tail===""};Xl.prototype.scan=function(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var n=r[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n};Xl.prototype.scanUntil=function(t){var r=this.tail.search(t),n;switch(r){case-1:n=this.tail,this.tail="";break;case 0:n="";break;default:n=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=n.length,n};function oc(e,t){this.view=e,this.cache={".":this.view},this.parent=t}oc.prototype.push=function(t){return new oc(t,this)};oc.prototype.lookup=function(t){var r=this.cache,n;if(r.hasOwnProperty(t))n=r[t];else{for(var i=this,a,o,s,c=!1;i;){if(t.indexOf(".")>0)for(a=i.view,o=t.split("."),s=0;a!=null&&s<o.length;)s===o.length-1&&(c=LP(a,o[s])||uB(a,o[s])),a=a[o[s++]];else a=i.view[t],c=LP(i.view,t);if(c){n=a;break}i=i.parent}r[t]=n}return ax(n)&&(n=n.call(this.view)),n};function mr(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}mr.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};mr.prototype.parse=function(t,r){var n=this.templateCache,i=t+":"+(r||tn.tags).join(":"),a=typeof n<"u",o=a?n.get(i):void 0;return o==null&&(o=wB(t,r),a&&n.set(i,o)),o};mr.prototype.render=function(t,r,n,i){var a=this.getConfigTags(i),o=this.parse(t,a),s=r instanceof oc?r:new oc(r,void 0);return this.renderTokens(o,s,n,t,i)};mr.prototype.renderTokens=function(t,r,n,i,a){for(var o="",s,c,l,u=0,d=t.length;u<d;++u)l=void 0,s=t[u],c=s[0],c==="#"?l=this.renderSection(s,r,n,i,a):c==="^"?l=this.renderInverted(s,r,n,i,a):c===">"?l=this.renderPartial(s,r,n,a):c==="&"?l=this.unescapedValue(s,r):c==="name"?l=this.escapedValue(s,r,a):c==="text"&&(l=this.rawValue(s)),l!==void 0&&(o+=l);return o};mr.prototype.renderSection=function(t,r,n,i,a){var o=this,s="",c=r.lookup(t[1]);function l(f){return o.render(f,r,n,a)}if(c){if(sc(c))for(var u=0,d=c.length;u<d;++u)s+=this.renderTokens(t[4],r.push(c[u]),n,i,a);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")s+=this.renderTokens(t[4],r.push(c),n,i,a);else if(ax(c)){if(typeof i!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(r.view,i.slice(t[3],t[5]),l),c!=null&&(s+=c)}else s+=this.renderTokens(t[4],r,n,i,a);return s}};mr.prototype.renderInverted=function(t,r,n,i,a){var o=r.lookup(t[1]);if(!o||sc(o)&&o.length===0)return this.renderTokens(t[4],r,n,i,a)};mr.prototype.indentPartial=function(t,r,n){for(var i=r.replace(/[^ \t]/g,""),a=t.split(`
317
+ `),o=0;o<a.length;o++)a[o].length&&(o>0||!n)&&(a[o]=i+a[o]);return a.join(`
318
+ `)};mr.prototype.renderPartial=function(t,r,n,i){if(n){var a=this.getConfigTags(i),o=ax(n)?n(t[1]):n[t[1]];if(o!=null){var s=t[6],c=t[5],l=t[4],u=o;c==0&&l&&(u=this.indentPartial(o,l,s));var d=this.parse(u,a);return this.renderTokens(d,r,n,u,i)}}};mr.prototype.unescapedValue=function(t,r){var n=r.lookup(t[1]);if(n!=null)return n};mr.prototype.escapedValue=function(t,r,n){var i=this.getConfigEscape(n)||tn.escape,a=r.lookup(t[1]);if(a!=null)return typeof a=="number"&&i===tn.escape?String(a):i(a)};mr.prototype.rawValue=function(t){return t[1]};mr.prototype.getConfigTags=function(t){return sc(t)?t:t&&typeof t=="object"?t.tags:void 0};mr.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!sc(t))return t.escape};var tn={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){ql.templateCache=e},get templateCache(){return ql.templateCache}},ql=new mr;tn.clearCache=function(){return ql.clearCache()};tn.parse=function(t,r){return ql.parse(t,r)};tn.render=function(t,r,n,i){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+lB(t)+'" was given as the first argument for mustache#render(template, view, partials)');return ql.render(t,r,n,i)};tn.escape=gB;tn.Scanner=Xl;tn.Context=oc;tn.Writer=mr;var am=tn;function BP(){am.escape=e=>e}var Bo=e=>{let t=e.split(""),r=[],n=(a,o)=>{for(let s=o;s<t.length;s+=1)if(a.includes(t[s]))return s;return-1},i=0;for(;i<t.length;)if(t[i]==="{"&&i+1<t.length&&t[i+1]==="{")r.push({type:"literal",text:"{"}),i+=2;else if(t[i]==="}"&&i+1<t.length&&t[i+1]==="}")r.push({type:"literal",text:"}"}),i+=2;else if(t[i]==="{"){let a=n("}",i);if(a<0)throw new Error("Unclosed '{' in template.");r.push({type:"variable",name:t.slice(i+1,a).join("")}),i=a+1}else{if(t[i]==="}")throw new Error("Single '}' in template.");{let a=n("{}",i),o=(a<0?t.slice(i):t.slice(i,a)).join("");r.push({type:"literal",text:o}),i=a<0?t.length:a}}return r},VP=(e,t=[])=>{let r=[];for(let n of e)if(n[0]==="name"){let i=n[1].includes(".")?n[1].split(".")[0]:n[1];r.push({type:"variable",name:i})}else if(["#","&","^",">"].includes(n[0])){if(r.push({type:"variable",name:n[1]}),n[0]==="#"&&n.length>4&&Array.isArray(n[4])){let i=[...t,n[1]],a=VP(n[4],i);r.push(...a)}}else r.push({type:"literal",text:n[1]});return r},cc=e=>(BP(),VP(am.parse(e))),ox=(e,t)=>Bo(e).reduce((r,n)=>{if(n.type==="variable"){if(n.name in t)return r+(typeof t[n.name]=="string"?t[n.name]:JSON.stringify(t[n.name]));throw new Error(`(f-string) Missing value for input ${n.name}`)}return r+n.text},""),sx=(e,t)=>(BP(),am.render(e,t)),Yl={"f-string":ox,mustache:sx},cx={"f-string":Bo,mustache:cc},Yt=(e,t,r)=>{try{return Yl[t](e,r)}catch(n){throw fi(n,"INVALID_PROMPT_INPUT")}},Vo=(e,t)=>cx[t](e),Oi=(e,t,r)=>{if(!(t in Yl))throw new Error(`Invalid template format. Got \`${t}\`;
319
+ should be one of ${Object.keys(Yl)}`);try{let n=Object.fromEntries(r.map(i=>[i,"foo"]));Array.isArray(e)?e.forEach(i=>{if(i.type==="text"&&"text"in i&&typeof i.text=="string")Yt(i.text,t,n);else if(i.type==="image_url"){if(typeof i.image_url=="string")Yt(i.image_url,t,n);else if(typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url&&typeof i.image_url.url=="string"){let a=i.image_url.url;Yt(a,t,n)}}else throw new Error(`Invalid message template received. ${JSON.stringify(i,null,2)}`)}):Yt(e,t,n)}catch(n){throw new Error(`Invalid prompt schema: ${n.message}`)}};var vn=class Ql extends Ai{static lc_name(){return"PromptTemplate"}template;templateFormat="f-string";validateTemplate=!0;additionalContentFields;constructor(t){if(super(t),t.templateFormat==="mustache"&&t.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,t),this.validateTemplate){if(this.templateFormat==="mustache")throw new Error("Mustache templates cannot be validated.");let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Oi(this.template,this.templateFormat,r)}}_getPromptType(){return"prompt"}async format(t){let r=await this.mergePartialAndUserVariables(t);return Yt(this.template,this.templateFormat,r)}static fromExamples(t,r,n,i=`
320
+
321
+ `,a=""){return new Ql({inputVariables:n,template:[a,...t,r].join(i)})}static fromTemplate(t,r){let{templateFormat:n="f-string",...i}=r??{},a=new Set;return Vo(t,n).forEach(o=>{o.type==="variable"&&a.add(o.name)}),new Ql({inputVariables:[...a],templateFormat:n,template:t,...i})}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new Ql({...this,inputVariables:r,partialVariables:n})}serialize(){if(this.outputParser!==void 0)throw new Error("Cannot serialize a prompt template with an output parser");return{_type:this._getPromptType(),input_variables:this.inputVariables,template:this.template,template_format:this.templateFormat}}static async deserialize(t){if(!t.template)throw new Error("Prompt template must have a template");return new Ql({inputVariables:t.input_variables,template:t.template,templateFormat:t.template_format})}};var lc=class ZP extends ti{static lc_name(){return"ImagePromptTemplate"}lc_namespace=["langchain_core","prompts","image"];template;templateFormat="f-string";validateTemplate=!0;additionalContentFields;constructor(t){if(super(t),this.template=t.template,this.templateFormat=t.templateFormat??this.templateFormat,this.validateTemplate=t.validateTemplate??this.validateTemplate,this.additionalContentFields=t.additionalContentFields,this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Oi([{type:"image_url",image_url:this.template}],this.templateFormat,r)}}_getPromptType(){return"prompt"}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new ZP({...this,inputVariables:r,partialVariables:n})}async format(t){let r={};for(let[o,s]of Object.entries(this.template))typeof s=="string"?r[o]=Yt(s,this.templateFormat,t):r[o]=s;let n=t.url||r.url,i=t.detail||r.detail;if(!n)throw new Error("Must provide either an image URL.");if(typeof n!="string")throw new Error("url must be a string.");let a={url:n};return i&&(a.detail=i),a}async formatPromptValue(t){return new Gw(await this.format(t))}};var eu=class extends se{lc_namespace=["langchain_core","prompts","dict"];lc_serializable=!0;template;templateFormat;inputVariables;static lc_name(){return"DictPromptTemplate"}constructor(e){let t=e.templateFormat??"f-string",r=lx(e.template,t);super({inputVariables:r,...e}),this.template=e.template,this.templateFormat=t,this.inputVariables=r}async format(e){return ux(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}};function lx(e,t){let r=[];for(let n of Object.values(e))if(typeof n=="string")Vo(n,t).forEach(i=>{i.type==="variable"&&r.push(i.name)});else if(Array.isArray(n))for(let i of n)typeof i=="string"?Vo(i,t).forEach(a=>{a.type==="variable"&&r.push(a.name)}):typeof i=="object"&&r.push(...lx(i,t));else typeof n=="object"&&n!==null&&r.push(...lx(n,t));return Array.from(new Set(r))}function ux(e,t,r){let n={};for(let[i,a]of Object.entries(e))if(typeof a=="string")n[i]=Yt(a,r,t);else if(Array.isArray(a)){let o=[];for(let s of a)typeof s=="string"?o.push(Yt(s,r,t)):typeof s=="object"&&o.push(ux(s,t,r));n[i]=o}else typeof a=="object"&&a!==null?n[i]=ux(a,t,r):n[i]=a;return n}var tu=class extends se{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;async invoke(e,t){return this._callWithConfig(r=>this.formatMessages(r),e,{...t,runType:"prompt"})}},sm=class extends tu{static lc_name(){return"MessagesPlaceholder"}variableName;optional;constructor(e){typeof e=="string"&&(e={variableName:e}),super(e),this.variableName=e.variableName,this.optional=e.optional??!1}get inputVariables(){return[this.variableName]}async formatMessages(e){let t=e[this.variableName];if(this.optional&&!t)return[];if(!t){let n=new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);throw n.name="InputFormatError",n}let r;try{Array.isArray(t)?r=t.map(kt):r=[kt(t)]}catch(n){let i=typeof t=="string"?t:JSON.stringify(t,null,2),a=new Error([`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages or coerceable values as input.`,`Received value: ${i}`,`Additional message: ${n.message}`].join(`
322
+
323
+ `));throw a.name="InputFormatError",a.lc_error_code=n.lc_error_code,a}return r}},dx=class extends tu{prompt;constructor(e){"prompt"in e||(e={prompt:e}),super(e),this.prompt=e.prompt}get inputVariables(){return this.prompt.inputVariables}async formatMessages(e){return[await this.format(e)]}},ru=class extends ti{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){return new Zl(await this.formatMessages(e))}},fx=class extends dx{static lc_name(){return"ChatMessagePromptTemplate"}role;constructor(e,t){"prompt"in e||(e={prompt:e,role:t}),super(e),this.role=e.role}async format(e){return new un(await this.prompt.format(e),this.role)}static fromTemplate(e,t,r){return new this(vn.fromTemplate(e,{templateFormat:r?.templateFormat}),t)}};function kB(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).length===1&&"text"in e&&typeof e.text=="string"}function $B(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:"image_url"in e&&(typeof e.image_url=="string"||typeof e.image_url=="object"&&e.image_url!==null&&"url"in e.image_url&&typeof e.image_url.url=="string")}var px=class extends tu{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;inputVariables=[];additionalOptions={};prompt;messageClass;static _messageClass(){throw new Error("Can not invoke _messageClass from inside _StringImageMessagePromptTemplate")}chatMessageClass;constructor(e,t){if("prompt"in e||(e={prompt:e}),super(e),this.prompt=e.prompt,Array.isArray(this.prompt)){let r=[];this.prompt.forEach(n=>{"inputVariables"in n&&(r=r.concat(n.inputVariables))}),this.inputVariables=r}else this.inputVariables=this.prompt.inputVariables;this.additionalOptions=t??this.additionalOptions}createMessage(e){let t=this.constructor;if(t._messageClass())return new(t._messageClass())({content:e});if(t.chatMessageClass){let r=t.chatMessageClass();return new r({content:e,role:this.getRoleFromMessageClass(r.lc_name())})}else throw new Error("No message class defined")}getRoleFromMessageClass(e){switch(e){case"HumanMessage":return"human";case"AIMessage":return"ai";case"SystemMessage":return"system";case"ChatMessage":return"chat";default:throw new Error("Invalid message class name")}}static fromTemplate(e,t){if(typeof e=="string")return new this(vn.fromTemplate(e,t));let r=[];for(let n of e)if(typeof n=="string")r.push(vn.fromTemplate(n,t));else if(n!==null)if(kB(n)){let i="";typeof n.text=="string"&&(i=n.text??"");let a={...t,additionalContentFields:n};r.push(vn.fromTemplate(i,a))}else if($B(n)){let i=n.image_url??"",a,o=[];if(typeof i=="string"){let s;t?.templateFormat==="mustache"?s=cc(i):s=Bo(i);let c=s.flatMap(l=>l.type==="variable"?[l.name]:[]);if((c?.length??0)>0){if(c.length>1)throw new Error(`Only one format variable allowed per image template.
324
+ Got: ${c}
325
+ From: ${i}`);o=[c[0]]}else o=[];i={url:i},a=new lc({template:i,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:n})}else if(typeof i=="object"){if("url"in i){let s;t?.templateFormat==="mustache"?s=cc(i.url):s=Bo(i.url),o=s.flatMap(c=>c.type==="variable"?[c.name]:[])}else o=[];a=new lc({template:i,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:n})}else throw new Error("Invalid image template");r.push(a)}else typeof n=="object"&&r.push(new eu({template:n,templateFormat:t?.templateFormat}));return new this({prompt:r,additionalOptions:t})}async format(e){if(this.prompt instanceof Ai){let t=await this.prompt.format(e);return this.createMessage(t)}else{let t=[];for(let r of this.prompt){let n={};if(!("inputVariables"in r))throw new Error(`Prompt ${r} does not have inputVariables defined.`);for(let i of r.inputVariables)n||(n={[i]:e[i]}),n={...n,[i]:e[i]};if(r instanceof Ai){let i=await r.format(n),a;"additionalContentFields"in r&&(a=r.additionalContentFields),i!==""&&t.push({...a,type:"text",text:i})}else if(r instanceof lc){let i=await r.format(n),a;"additionalContentFields"in r&&(a=r.additionalContentFields),t.push({...a,type:"image_url",image_url:i})}else if(r instanceof eu){let i=await r.format(n),a;"additionalContentFields"in r&&(a=r.additionalContentFields),t.push({...a,...i})}}return this.createMessage(t)}}async formatMessages(e){return[await this.format(e)]}},cm=class extends px{static _messageClass(){return ot}static lc_name(){return"HumanMessagePromptTemplate"}},mx=class extends px{static _messageClass(){return Ne}static lc_name(){return"AIMessagePromptTemplate"}},hx=class extends px{static _messageClass(){return or}static lc_name(){return"SystemMessagePromptTemplate"}};function EB(e){return typeof e.formatMessages=="function"}function IB(e,t){if(EB(e)||tt(e))return e;if(Array.isArray(e)&&e[0]==="placeholder"){let i=e[1];if(t?.templateFormat==="mustache"&&typeof i=="string"&&i.slice(0,2)==="{{"&&i.slice(-2)==="}}")return new sm({variableName:i.slice(2,-2),optional:!0});if(typeof i=="string"&&i[0]==="{"&&i[i.length-1]==="}")return new sm({variableName:i.slice(1,-1),optional:!0});throw new Error(`Invalid placeholder template for format ${t?.templateFormat??'"f-string"'}: "${e[1]}". Expected a variable name surrounded by ${t?.templateFormat==="mustache"?"double":"single"} curly braces.`)}let r=kt(e),n;if(typeof r.content=="string"?n=r.content:n=r.content.map(i=>"text"in i?{...i,text:i.text}:"image_url"in i?{...i,image_url:i.image_url}:i),r._getType()==="human")return cm.fromTemplate(n,t);if(r._getType()==="ai")return mx.fromTemplate(n,t);if(r._getType()==="system")return hx.fromTemplate(n,t);if(un.isInstance(r))return fx.fromTemplate(r.content,r.role,t);throw new Error(`Could not coerce message prompt template from input. Received message type: "${r._getType()}".`)}function TB(e){return e.constructor.lc_name()==="MessagesPlaceholder"}var uc=class om extends ru{static lc_name(){return"ChatPromptTemplate"}get lc_aliases(){return{promptMessages:"messages"}}promptMessages;validateTemplate=!0;templateFormat="f-string";constructor(t){if(super(t),t.templateFormat==="mustache"&&t.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,t),this.validateTemplate){let r=new Set;for(let s of this.promptMessages)if(!(s instanceof Pe))for(let c of s.inputVariables)r.add(c);let n=this.inputVariables,i=new Set(this.partialVariables?n.concat(Object.keys(this.partialVariables)):n),a=new Set([...i].filter(s=>!r.has(s)));if(a.size>0)throw new Error(`Input variables \`${[...a]}\` are not used in any of the prompt messages.`);let o=new Set([...r].filter(s=>!i.has(s)));if(o.size>0)throw new Error(`Input variables \`${[...o]}\` are used in prompt messages but not in the prompt template.`)}}_getPromptType(){return"chat"}async _parseImagePrompts(t,r){return typeof t.content=="string"||(t.content=await Promise.all(t.content.map(async n=>{if(n.type!=="image_url")return n;let i="";typeof n.image_url=="string"?i=n.image_url:typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url&&typeof n.image_url.url=="string"&&(i=n.image_url.url);let a=await vn.fromTemplate(i,{templateFormat:this.templateFormat}).format(r);return typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url?n.image_url.url=a:n.image_url=a,n}))),t}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),n=[];for(let i of this.promptMessages)if(i instanceof Pe)n.push(await this._parseImagePrompts(i,r));else{let a;this.templateFormat==="mustache"?a={...r}:a=i.inputVariables.reduce((s,c)=>{if(!(c in r)&&!(TB(i)&&i.optional))throw fi(new Error(`Missing value for input variable \`${c.toString()}\``),"INVALID_PROMPT_INPUT");return s[c]=r[c],s},{});let o=await i.formatMessages(a);n=n.concat(o)}return n}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new om({...this,inputVariables:r,partialVariables:n})}static fromTemplate(t,r){let n=new cm({prompt:vn.fromTemplate(t,r)});return this.fromMessages([n])}static fromMessages(t,r){let n=t.reduce((o,s)=>o.concat(s instanceof om?s.promptMessages:[IB(s,r)]),[]),i=t.reduce((o,s)=>s instanceof om?Object.assign(o,s.partialVariables):o,Object.create(null)),a=new Set;for(let o of n)if(!(o instanceof Pe))for(let s of o.inputVariables)s in i||a.add(s);return new this({...r,inputVariables:[...a],promptMessages:n,partialVariables:i,templateFormat:r?.templateFormat})}};var HP=class gx extends Ai{lc_serializable=!1;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
326
+
327
+ `;prefix="";templateFormat="f-string";validateTemplate=!0;constructor(t){if(super(t),Object.assign(this,t),this.examples!==void 0&&this.exampleSelector!==void 0)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(this.examples===void 0&&this.exampleSelector===void 0)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Oi(this.prefix+this.suffix,this.templateFormat,r)}}_getPromptType(){return"few_shot"}static lc_name(){return"FewShotPromptTemplate"}async getExamples(t){if(this.examples!==void 0)return this.examples;if(this.exampleSelector!==void 0)return this.exampleSelector.selectExamples(t);throw new Error("One of 'examples' and 'example_selector' should be provided")}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new gx({...this,inputVariables:r,partialVariables:n})}async format(t){let r=await this.mergePartialAndUserVariables(t),n=await this.getExamples(r),i=await Promise.all(n.map(a=>this.examplePrompt.format(a)));return Yt([this.prefix,...i,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}serialize(){if(this.exampleSelector||!this.examples)throw new Error("Serializing an example selector is not currently supported");if(this.outputParser!==void 0)throw new Error("Serializing an output parser is not currently supported");return{_type:this._getPromptType(),input_variables:this.inputVariables,example_prompt:this.examplePrompt.serialize(),example_separator:this.exampleSeparator,suffix:this.suffix,prefix:this.prefix,template_format:this.templateFormat,examples:this.examples}}static async deserialize(t){let{example_prompt:r}=t;if(!r)throw new Error("Missing example prompt");let n=await vn.deserialize(r),i;if(Array.isArray(t.examples))i=t.examples;else throw new Error("Invalid examples format. Only list or string are supported.");return new gx({inputVariables:t.input_variables,examplePrompt:n,examples:i,exampleSeparator:t.example_separator,prefix:t.prefix,suffix:t.suffix,templateFormat:t.template_format})}},GP=class WP extends ru{lc_serializable=!0;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
328
+
329
+ `;prefix="";templateFormat="f-string";validateTemplate=!0;_getPromptType(){return"few_shot_chat"}static lc_name(){return"FewShotChatMessagePromptTemplate"}constructor(t){if(super(t),this.examples=t.examples,this.examplePrompt=t.examplePrompt,this.exampleSeparator=t.exampleSeparator??`
330
+
331
+ `,this.exampleSelector=t.exampleSelector,this.prefix=t.prefix??"",this.suffix=t.suffix??"",this.templateFormat=t.templateFormat??"f-string",this.validateTemplate=t.validateTemplate??!0,this.examples!==void 0&&this.exampleSelector!==void 0)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(this.examples===void 0&&this.exampleSelector===void 0)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),Oi(this.prefix+this.suffix,this.templateFormat,r)}}async getExamples(t){if(this.examples!==void 0)return this.examples;if(this.exampleSelector!==void 0)return this.exampleSelector.selectExamples(t);throw new Error("One of 'examples' and 'example_selector' should be provided")}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),n=await this.getExamples(r);n=n.map(a=>{let o={};return this.examplePrompt.inputVariables.forEach(s=>{o[s]=a[s]}),o});let i=[];for(let a of n){let o=await this.examplePrompt.formatMessages(a);i.push(...o)}return i}async format(t){let r=await this.mergePartialAndUserVariables(t),n=await this.getExamples(r),i=(await Promise.all(n.map(a=>this.examplePrompt.formatMessages(a)))).flat().map(a=>a.content);return Yt([this.prefix,...i,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new WP({...this,inputVariables:r,partialVariables:n})}};var JP=class lm extends ti{static lc_name(){return"PipelinePromptTemplate"}pipelinePrompts;finalPrompt;constructor(t){super({...t,inputVariables:[]}),this.pipelinePrompts=t.pipelinePrompts,this.finalPrompt=t.finalPrompt,this.inputVariables=this.computeInputValues()}computeInputValues(){let t=this.pipelinePrompts.map(n=>n.name),r=this.pipelinePrompts.map(n=>n.prompt.inputVariables.filter(i=>!t.includes(i))).flat();return[...new Set(r)]}static extractRequiredInputValues(t,r){return r.reduce((n,i)=>(n[i]=t[i],n),{})}async formatPipelinePrompts(t){let r=await this.mergePartialAndUserVariables(t);for(let{name:n,prompt:i}of this.pipelinePrompts){let a=lm.extractRequiredInputValues(r,i.inputVariables);i instanceof uc?r[n]=await i.formatMessages(a):r[n]=await i.format(a)}return lm.extractRequiredInputValues(r,this.finalPrompt.inputVariables)}async formatPromptValue(t){return this.finalPrompt.formatPromptValue(await this.formatPipelinePrompts(t))}async format(t){return this.finalPrompt.format(await this.formatPipelinePrompts(t))}async partial(t){let r={...this};return r.inputVariables=this.inputVariables.filter(n=>!(n in t)),r.partialVariables={...this.partialVariables??{},...t},new lm(r)}serialize(){throw new Error("Not implemented.")}_getPromptType(){return"pipeline"}};function KP(e){return typeof e=="object"&&e!=null&&"withStructuredOutput"in e&&typeof e.withStructuredOutput=="function"}function CB(e){return typeof e=="object"&&e!=null&&"lc_id"in e&&Array.isArray(e.lc_id)&&e.lc_id.join("/")==="langchain_core/runnables/RunnableBinding"}var qP=class XP extends uc{schema;method;lc_namespace=["langchain_core","prompts","structured"];get lc_aliases(){return{...super.lc_aliases,schema:"schema_"}}constructor(t){super(t),this.schema=t.schema,this.method=t.method}pipe(t){if(KP(t))return super.pipe(t.withStructuredOutput(this.schema));if(CB(t)&&KP(t.bound))return super.pipe(new Qr({bound:t.bound.withStructuredOutput(this.schema,...this.method?[{method:this.method}]:[]),kwargs:t.kwargs??{},config:t.config,configFactories:t.configFactories}));throw new Error('Structured prompts need to be piped to a language model that supports the "withStructuredOutput()" method.')}static fromMessagesAndSchema(t,r,n){return XP.fromMessages(t,{schema:r,method:n})}};var YP=T({AIMessagePromptTemplate:()=>mx,BaseChatPromptTemplate:()=>ru,BaseMessagePromptTemplate:()=>tu,BaseMessageStringPromptTemplate:()=>dx,BasePromptTemplate:()=>ti,BaseStringPromptTemplate:()=>Ai,ChatMessagePromptTemplate:()=>fx,ChatPromptTemplate:()=>uc,DEFAULT_FORMATTER_MAPPING:()=>Yl,DEFAULT_PARSER_MAPPING:()=>cx,DictPromptTemplate:()=>eu,FewShotChatMessagePromptTemplate:()=>GP,FewShotPromptTemplate:()=>HP,HumanMessagePromptTemplate:()=>cm,ImagePromptTemplate:()=>lc,MessagesPlaceholder:()=>sm,PipelinePromptTemplate:()=>JP,PromptTemplate:()=>vn,StructuredPrompt:()=>qP,SystemMessagePromptTemplate:()=>hx,checkValidTemplate:()=>Oi,interpolateFString:()=>ox,interpolateMustache:()=>sx,parseFString:()=>Bo,parseMustache:()=>cc,parseTemplate:()=>Vo,renderTemplate:()=>Yt});var QP=T({BaseDocumentCompressor:()=>AB}),AB=class{static isBaseDocumentCompressor(e){return e?.compressDocuments!==void 0}};var eN=T({BaseRetriever:()=>nu}),nu=class extends se{callbacks;tags;metadata;verbose;constructor(e){super(e),this.callbacks=e?.callbacks,this.tags=e?.tags??[],this.metadata=e?.metadata??{},this.verbose=e?.verbose??!1}_getRelevantDocuments(e,t){throw new Error("Not implemented!")}async invoke(e,t){let r=ke(so(t)),n=await(await Xe.configure(r.callbacks,this.callbacks,r.tags,this.tags,r.metadata,this.metadata,{verbose:this.verbose}))?.handleRetrieverStart(this.toJSON(),e,r.runId,void 0,void 0,void 0,r.runName);try{let i=await this._getRelevantDocuments(e,n);return await n?.handleRetrieverEnd(i),i}catch(i){throw await n?.handleRetrieverError(i),i}}};var tN=T({BaseStore:()=>rN,InMemoryStore:()=>OB}),rN=class extends pt{},OB=class extends rN{lc_namespace=["langchain","storage"];store={};async mget(e){return e.map(t=>this.store[t])}async mset(e){for(let[t,r]of e)this.store[t]=r}async mdelete(e){for(let t of e)delete this.store[t]}async*yieldKeys(e){let t=Object.keys(this.store);for(let r of t)(e===void 0||r.startsWith(e))&&(yield r)}};var bn={and:"and",or:"or",not:"not"},Ie={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte"},um=class{},dm=class{accept(e){if(this.exprName==="Operation")return e.visitOperation(this);if(this.exprName==="Comparison")return e.visitComparison(this);if(this.exprName==="StructuredQuery")return e.visitStructuredQuery(this);throw new Error("Unknown Expression type")}},fm=class extends dm{},nN=class extends fm{exprName="Comparison";constructor(e,t,r){super(),this.comparator=e,this.attribute=t,this.value=r}},iN=class extends fm{exprName="Operation";constructor(e,t){super(),this.operator=e,this.args=t}},aN=class extends dm{exprName="StructuredQuery";constructor(e,t){super(),this.query=e,this.filter=t}};function _x(e){return e&&typeof e=="object"&&!Array.isArray(e)}function $r(e){return e?typeof e=="string"&&e.length>0||typeof e=="function"?!1:_x(e)&&Object.keys(e).length===0:!0}function yx(e){if(typeof e=="number")return e%1===0;if(typeof e=="string"){let t=parseInt(e,10);return!Number.isNaN(t)&&t%1===0&&t.toString()===e}return!1}function vx(e){if(typeof e=="number")return e%1!==0;if(typeof e=="string"){let t=parseFloat(e);return!Number.isNaN(t)&&t%1!==0&&t.toString()===e}return!1}function bx(e){return typeof e=="string"&&(Number.isNaN(parseFloat(e))||parseFloat(e).toString()!==e)}function wx(e){return typeof e=="boolean"}function dc(e){let t;if(bx(e))t=e;else if(yx(e))t=parseInt(e,10);else if(vx(e))t=parseFloat(e);else if(wx(e))t=!!e;else throw new Error("Unsupported value type");return t}var iu=class extends um{},oN=class extends iu{allowedOperators;allowedComparators;constructor(e){super(),this.allowedOperators=e?.allowedOperators??[bn.and,bn.or],this.allowedComparators=e?.allowedComparators??[Ie.eq,Ie.ne,Ie.gt,Ie.gte,Ie.lt,Ie.lte]}formatFunction(e){if(e in Ie){if(this.allowedComparators.length>0&&this.allowedComparators.indexOf(e)===-1)throw new Error(`Comparator ${e} not allowed. Allowed comparators: ${this.allowedComparators.join(", ")}`)}else if(e in bn){if(this.allowedOperators.length>0&&this.allowedOperators.indexOf(e)===-1)throw new Error(`Operator ${e} not allowed. Allowed operators: ${this.allowedOperators.join(", ")}`)}else throw new Error("Unknown comparator or operator");return`$${e}`}visitOperation(e){let t=e.args?.map(r=>r.accept(this));return{[this.formatFunction(e.operator)]:t}}visitComparison(e){return{[e.attribute]:{[this.formatFunction(e.comparator)]:dc(e.value)}}}visitStructuredQuery(e){let t={};return e.filter&&(t={filter:e.filter.accept(this)}),t}mergeFilters(e,t,r="and",n=!1){if(!($r(e)&&$r(t))){if($r(e)||r==="replace")return $r(t)?void 0:t;if($r(t))return n?e:r==="and"?void 0:e;if(r==="and")return{$and:[e,t]};if(r==="or")return{$or:[e,t]};throw new Error("Unknown merge type")}}};var sN=class extends iu{allowedOperators=[bn.and,bn.or];allowedComparators=[Ie.eq,Ie.ne,Ie.gt,Ie.gte,Ie.lt,Ie.lte];formatFunction(){throw new Error("Not implemented")}getAllowedComparatorsForType(e){switch(e){case"string":return[Ie.eq,Ie.ne,Ie.gt,Ie.gte,Ie.lt,Ie.lte];case"number":return[Ie.eq,Ie.ne,Ie.gt,Ie.gte,Ie.lt,Ie.lte];case"boolean":return[Ie.eq,Ie.ne];default:throw new Error(`Unsupported data type: ${e}`)}}getComparatorFunction(e){switch(e){case Ie.eq:return(t,r)=>t===r;case Ie.ne:return(t,r)=>t!==r;case Ie.gt:return(t,r)=>t>r;case Ie.gte:return(t,r)=>t>=r;case Ie.lt:return(t,r)=>t<r;case Ie.lte:return(t,r)=>t<=r;default:throw new Error("Unknown comparator")}}getOperatorFunction(e){switch(e){case bn.and:return(t,r)=>t&&r;case bn.or:return(t,r)=>t||r;default:throw new Error("Unknown operator")}}visitOperation(e){let{operator:t,args:r}=e;if(this.allowedOperators.includes(t)){let n=this.getOperatorFunction(t);return i=>r?r.reduce((a,o)=>{let s=o.accept(this);if(typeof s=="function")return n(a,s(i));throw new Error("Filter is not a function")},!0):!0}else throw new Error("Operator not allowed")}visitComparison(e){let{comparator:t,attribute:r,value:n}=e,i=[Ie.ne];if(this.allowedComparators.includes(t)){if(!this.getAllowedComparatorsForType(typeof n).includes(t))throw new Error(`'${t}' comparator not allowed to be used with ${typeof n}`);let a=this.getComparatorFunction(t);return o=>{let s=o.metadata[r];return s===void 0?!!i.includes(t):a(s,dc(n))}}else throw new Error("Comparator not allowed")}visitStructuredQuery(e){if(!e.filter)return{};let t=e.filter?.accept(this);if(typeof t!="function")throw new Error("Structured query filter is not a function");return{filter:t}}mergeFilters(e,t,r="and"){if(!($r(e)&&$r(t))){if($r(e)||r==="replace")return $r(t)?void 0:t;if($r(t))return r==="and"?void 0:e;if(r==="and")return n=>e(n)&&t(n);if(r==="or")return n=>e(n)||t(n);throw new Error("Unknown merge type")}}};var cN=T({BaseTranslator:()=>iu,BasicTranslator:()=>oN,Comparators:()=>Ie,Comparison:()=>nN,Expression:()=>dm,FilterDirective:()=>fm,FunctionalTranslator:()=>sN,Operation:()=>iN,Operators:()=>bn,StructuredQuery:()=>aN,Visitor:()=>um,castValue:()=>dc,isBoolean:()=>wx,isFilterEmpty:()=>$r,isFloat:()=>vx,isInt:()=>yx,isObject:()=>_x,isString:()=>bx});function au(e){if(e==null||typeof e!="object")return!1;let t=e;return typeof t.text<"u"&&typeof t.toolCalls<"u"&&typeof t.reasoning<"u"&&typeof t.usage<"u"&&typeof t.output<"u"&&typeof t[Symbol.asyncIterator]=="function"}function lN(e,t,r){return e==null?!1:Object.entries(t).every(([n,i])=>r(e[n],i))}function uN(e,t,r){return e==null?!1:lN(e,t,r)}function dN(e){return e.content.find(t=>t.type==="text")?.text}function PB(e,t,r){if(t.id!==void 0&&e.id!==t.id||t.text!==void 0&&dN(e)!==t.text)return!1;if(t.toolCalls!==void 0){let n=e.tool_calls??[];if(n.length!==t.toolCalls.length)return!1;for(let i=0;i<t.toolCalls.length;i++){let a=n[i],o=t.toolCalls[i];if(a?.name!==o.name||!r(a.args,o.args))return!1}}return!(t.usage!==void 0&&!uN(e.usage_metadata,t.usage,r)||t.responseMetadata!==void 0&&!lN(e.response_metadata,t.responseMetadata,r))}function ou(e,t,r){return{pass:!1,message:()=>`${r.matcherHint(t)}
332
+
333
+ Expected: ChatModelStream (return value of model.streamEvents("Hello"))
334
+ Received: ${r.printReceived(e)}`,actual:e,expected:"ChatModelStream"}}function su(e,t){return t?!e:e}async function NB(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamText";if(!au(e))return ou(e,i,n);let a=await e.text;return{pass:su(a===t,r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
335
+
336
+ Expected stream text: ${r?"not ":""}${n.printExpected(t)}
337
+ Received stream text: ${n.printReceived(a)}`,actual:a,expected:t}}async function RB(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamReasoning";if(!au(e))return ou(e,i,n);let a=await e.reasoning;return{pass:su(a===t,r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
338
+
339
+ Expected stream reasoning: ${r?"not ":""}${n.printExpected(t)}
340
+ Received stream reasoning: ${n.printReceived(a)}`,actual:a,expected:t}}async function MB(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamToolCalls";if(!au(e))return ou(e,i,n);let a=await e.toolCalls,o=a.length===t.length&&t.every((s,c)=>{let l=a[c];return l?.name===s.name&&this.equals(l.args,s.args)});return o=su(o,r),{pass:o,message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
341
+
342
+ Expected stream tool calls: ${n.printExpected(t)}
343
+ Received stream tool calls: ${n.printReceived(a.map(s=>({name:s.name,args:s.args})))}`,actual:a.map(s=>({name:s.name,args:s.args})),expected:t}}async function jB(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamUsage";if(!au(e))return ou(e,i,n);let a=await e.usage;return{pass:su(uN(a,t,this.equals),r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
344
+
345
+ Expected stream usage: ${n.printExpected(t)}
346
+ Received stream usage: ${n.printReceived(a)}`,actual:a,expected:t}}async function DB(e,t){let{isNot:r,utils:n}=this,i="toHaveStreamOutput";if(!au(e))return ou(e,i,n);let a=await e.output;return{pass:su(PB(a,t,this.equals),r),message:()=>`${n.matcherHint(i,void 0,void 0,{isNot:r})}
347
+
348
+ Expected stream output: ${n.printExpected(t)}
349
+ Received stream output: ${n.printReceived({id:a.id,text:dN(a),tool_calls:a.tool_calls?.map(o=>({name:o.name,args:o.args})),usage_metadata:a.usage_metadata,response_metadata:a.response_metadata})}`,actual:a,expected:t}}var fc={toHaveStreamText:NB,toHaveStreamReasoning:RB,toHaveStreamToolCalls:MB,toHaveStreamUsage:jB,toHaveStreamOutput:DB};function cu(e){return Pe.isInstance(e)?e.constructor.name||e.type:typeof e}function pm(e,t){return function(r,n){let{isNot:i,utils:a}=this;if(!t(r))return{pass:!1,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
350
+
351
+ Expected: ${i?"not ":""}${e}
352
+ Received: ${cu(r)}`,actual:cu(r),expected:e};if(n===void 0)return{pass:!0,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
353
+
354
+ Expected: not ${e}
355
+ Received: ${e}`};let o=r;return typeof n=="string"?{pass:o.content===n,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
356
+
357
+ Expected: ${e} with content ${a.printExpected(n)}
358
+ Received: ${e} with content ${a.printReceived(o.content)}`,actual:o.content,expected:n}:{pass:Object.entries(n).every(([s,c])=>this.equals(o[s],c)),message:()=>{let s={};for(let c of Object.keys(n))s[c]=o[c];return`${a.matcherHint(`toBe${e}`,void 0,void 0)}
359
+
360
+ Expected: ${e} matching ${a.printExpected(n)}
361
+ Received: ${e} with ${a.printReceived(s)}`},actual:(()=>{let s={};for(let c of Object.keys(n))s[c]=o[c];return s})(),expected:n}}}var xx=pm("HumanMessage",ot.isInstance),Sx=pm("AIMessage",Ne.isInstance),kx=pm("SystemMessage",or.isInstance),$x=pm("ToolMessage",St.isInstance);function Ex(e,t){let{isNot:r,utils:n}=this;if(!Ne.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
362
+
363
+ Expected: AIMessage
364
+ Received: ${cu(e)}`};let i=e.tool_calls??[];if(i.length!==t.length)return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
365
+
366
+ Expected ${r?"not ":""}${t.length} tool call(s), received ${i.length}`,actual:i.length,expected:t.length};let a=t.filter(o=>!i.some(s=>Object.entries(o).every(([c,l])=>this.equals(s[c],l))));return a.length>0?{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
367
+
368
+ Could not find matching tool call(s) for:
369
+ ${n.printExpected(a)}
370
+ Received tool calls: ${n.printReceived(i.map(o=>({name:o.name,id:o.id,args:o.args})))}`,actual:i.map(o=>({name:o.name,id:o.id,args:o.args})),expected:t}:{pass:!0,message:()=>`${n.matcherHint("toHaveToolCalls")}
371
+
372
+ Expected AIMessage not to have matching tool calls`}}function Ix(e,t){let{isNot:r,utils:n}=this;if(!Ne.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCallCount")}
373
+
374
+ Expected: AIMessage
375
+ Received: ${cu(e)}`};let i=e.tool_calls?.length??0;return{pass:i===t,message:()=>`${n.matcherHint("toHaveToolCallCount")}
376
+
377
+ Expected ${r?"not ":""}${t} tool call(s)
378
+ Received: ${i}`,actual:i,expected:t}}function Tx(e,t){let{isNot:r,utils:n}=this;if(!Ne.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toContainToolCall")}
379
+
380
+ Expected: AIMessage
381
+ Received: ${cu(e)}`};let i=e.tool_calls??[];return{pass:i.some(a=>Object.entries(t).every(([o,s])=>this.equals(a[o],s))),message:()=>`${n.matcherHint("toContainToolCall")}
382
+
383
+ Expected AIMessage ${r?"not ":""}to contain a tool call matching ${n.printExpected(t)}
384
+ Received tool calls: ${n.printReceived(i.map(a=>({name:a.name,id:a.id})))}`,actual:i.map(a=>({name:a.name,id:a.id})),expected:t}}function Cx(e,t){let{isNot:r,utils:n}=this;if(!Array.isArray(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolMessages")}
385
+
386
+ Expected an array of messages
387
+ Received: ${typeof e}`};let i=e.filter(St.isInstance);if(i.length!==t.length)return{pass:!1,message:()=>`${n.matcherHint("toHaveToolMessages")}
388
+
389
+ Expected ${r?"not ":""}${t.length} tool message(s), found ${i.length}`,actual:i.length,expected:t.length};for(let a=0;a<t.length;a++)if(!Object.entries(t[a]).every(([o,s])=>this.equals(i[a][o],s)))return{pass:!1,message:()=>{let o={};for(let s of Object.keys(t[a]))o[s]=i[a][s];return`${n.matcherHint("toHaveToolMessages")}
390
+
391
+ Tool message at index ${a} did not match:
392
+ Expected: ${n.printExpected(t[a])}
393
+ Received: ${n.printReceived(o)}`},actual:i[a],expected:t[a]};return{pass:!0,message:()=>`${n.matcherHint("toHaveToolMessages")}
394
+
395
+ Expected messages not to contain matching tool messages`}}function Ax(e,t){let{isNot:r,utils:n}=this,i=e?.__interrupt__;if(!(Array.isArray(i)&&i.length>0))return{pass:!1,message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
396
+
397
+ Expected result ${r?"not ":""}to have been interrupted
398
+ Received __interrupt__: ${n.printReceived(i)}`};if(t===void 0)return{pass:!0,message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
399
+
400
+ Expected result not to have been interrupted
401
+ Received ${i.length} interrupt(s)`};let a=i[0]?.value;return{pass:this.equals(a,t),message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
402
+
403
+ Expected interrupt value: ${n.printExpected(t)}
404
+ Received interrupt value: ${n.printReceived(a)}`,actual:a,expected:t}}function Ox(e,t){let{isNot:r,utils:n}=this,i=e?.structuredResponse;return i===void 0?{pass:!1,message:()=>`${n.matcherHint("toHaveStructuredResponse")}
405
+
406
+ Expected result ${r?"not ":""}to have a structured response
407
+ Received structuredResponse: undefined`}:t===void 0?{pass:!0,message:()=>`${n.matcherHint("toHaveStructuredResponse")}
408
+
409
+ Expected result not to have a structured response`}:{pass:Object.entries(t).every(([a,o])=>this.equals(i[a],o)),message:()=>`${n.matcherHint("toHaveStructuredResponse")}
410
+
411
+ Expected structured response: ${n.printExpected(t)}
412
+ Received structured response: ${n.printReceived(i)}`,actual:i,expected:t}}var fN={toBeHumanMessage:xx,toBeAIMessage:Sx,toBeSystemMessage:kx,toBeToolMessage:$x,toHaveToolCalls:Ex,toHaveToolCallCount:Ix,toContainToolCall:Tx,toHaveToolMessages:Cx,toHaveBeenInterrupted:Ax,toHaveStructuredResponse:Ox,...fc};function zB(e){return e.map(t=>t.text).filter(Boolean).join("-")}var pN=0;function UB(){return pN+=1,`fake_tc_${pN}`}var Px=class mN extends Aa{queue=[];_alwaysThrowError;_structuredResponseValue;_tools=[];_state={callIndex:0,calls:[]};get calls(){return this._state.calls}get callCount(){return this._state.calls.length}constructor(){super({})}_llmType(){return"fake-model-builder"}_combineLLMOutput(){return[]}respond(t){return typeof t=="function"?this.queue.push({kind:"factory",factory:t}):Pe.isInstance(t)?this.queue.push({kind:"message",message:t}):this.queue.push({kind:"error",error:t}),this}respondWithTools(t){return this.queue.push({kind:"toolCalls",toolCalls:t.map(r=>({name:r.name,args:r.args,id:r.id??UB(),type:"tool_call"}))}),this}alwaysThrow(t){return this._alwaysThrowError=t,this}structuredResponse(t){return this._structuredResponseValue=t,this}bindTools(t){let r=[...this._tools,...t],n=new mN;return n.queue=this.queue,n._alwaysThrowError=this._alwaysThrowError,n._structuredResponseValue=this._structuredResponseValue,n._tools=r,n._state=this._state,n.withConfig({})}withStructuredOutput(t,r){let{_structuredResponseValue:n}=this;return qt.from(async()=>n)}async _generate(t,r,n){this._state.calls.push({messages:[...t],options:r});let i=this._state.callIndex;if(this._state.callIndex+=1,this._alwaysThrowError)throw this._alwaysThrowError;let a=this.queue[i];if(!a)throw new Error(`FakeModel: no response queued for invocation ${i} (${this.queue.length} total queued).`);if(a.kind==="error")throw a.error;if(a.kind==="factory"){let s=a.factory(t);if(!Pe.isInstance(s))throw s;return{generations:[{text:"",message:s}]}}if(a.kind==="message")return{generations:[{text:"",message:a.message}]};let o=zB(t);return{generations:[{text:o,message:new Ne({content:o,id:i.toString(),tool_calls:a.toolCalls.length>0?a.toolCalls.map(s=>({...s,type:"tool_call"})):void 0})}],llmOutput:{}}}};function hN(){return new Px}function mm(e){return{async*[Symbol.asyncIterator](){for(let t of e)yield t}}}function hm(e="test-model"){let t=lu(e),r=t[t.length-1];return t[t.length-1]={...r,usage:{prompt_tokens:10,completion_tokens:2,total_tokens:12}},t}function lu(e="test-model"){return[{id:"chatcmpl-text",model:e,choices:[{index:0,delta:{role:"assistant",content:"Hello"},finish_reason:null}]},{id:"chatcmpl-text",model:e,choices:[{index:0,delta:{content:" world"},finish_reason:null}]},{id:"chatcmpl-text",model:e,choices:[{index:0,delta:{},finish_reason:"stop"}]}]}function gm(e="test-model"){return[{id:"chatcmpl-reason",model:e,choices:[{index:0,delta:{role:"assistant",reasoning_content:"Let me reason..."},finish_reason:null}]},{id:"chatcmpl-reason",model:e,choices:[{index:0,delta:{content:"Answer."},finish_reason:null}]},{id:"chatcmpl-reason",model:e,choices:[{index:0,delta:{},finish_reason:"stop"}]}]}function _m(e="test-model"){return[{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{role:"assistant",content:"Let me search."},finish_reason:null}]},{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{tool_calls:[{index:0,id:"call_abc",type:"function",function:{name:"web_search",arguments:'{"query"'}}]},finish_reason:null}]},{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{tool_calls:[{index:0,function:{arguments:':"weather"}'}}]},finish_reason:null}]},{id:"chatcmpl-tools",model:e,choices:[{index:0,delta:{},finish_reason:"tool_calls"}]}]}function ym(e){let t=new TextEncoder;return new Response(new ReadableStream({start(r){for(let n of e)r.enqueue(t.encode(`data: ${JSON.stringify(n)}
413
+
414
+ `));r.close()}}),{status:200,headers:{"Content-Type":"text/event-stream"}})}var gN=T({FakeBuiltModel:()=>Px,asAsyncIterable:()=>mm,fakeModel:()=>hN,langchainMatchers:()=>fN,openAIReasoningTextChunks:()=>gm,openAITextOnlyChunks:()=>lu,openAITextOnlyChunksWithUsage:()=>hm,openAIToolCallChunks:()=>_m,sseResponseFromOpenAIChunks:()=>ym,streamMatchers:()=>fc,toBeAIMessage:()=>Sx,toBeHumanMessage:()=>xx,toBeSystemMessage:()=>kx,toBeToolMessage:()=>$x,toContainToolCall:()=>Tx,toHaveBeenInterrupted:()=>Ax,toHaveStructuredResponse:()=>Ox,toHaveToolCallCount:()=>Ix,toHaveToolCalls:()=>Ex,toHaveToolMessages:()=>Cx});function uu(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function du(e){return e!==void 0&&se.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function fu(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(xr(e.schema)||e.schema!=null&&typeof e.schema=="object"&&"type"in e.schema&&typeof e.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(e.schema.type))}function pu(e){return fu(e)||du(e)||uu(e)}var rn={};An(rn,{$brand:()=>T_,$input:()=>Wv,$output:()=>Gv,NEVER:()=>I_,TimePrecision:()=>Xv,ZodAny:()=>r0,ZodArray:()=>o0,ZodBase64:()=>Um,ZodBase64URL:()=>Lm,ZodBigInt:()=>bc,ZodBigIntFormat:()=>Vm,ZodBoolean:()=>vc,ZodCIDRv4:()=>Dm,ZodCIDRv6:()=>zm,ZodCUID:()=>Am,ZodCUID2:()=>Om,ZodCatch:()=>T0,ZodCodec:()=>Eu,ZodCustom:()=>Iu,ZodCustomStringFormat:()=>_c,ZodDate:()=>wu,ZodDefault:()=>x0,ZodDiscriminatedUnion:()=>c0,ZodE164:()=>Fm,ZodEmail:()=>Im,ZodEmoji:()=>Tm,ZodEnum:()=>hc,ZodError:()=>LB,ZodExactOptional:()=>v0,ZodFile:()=>_0,ZodFirstPartyTypeKind:()=>F0,ZodFunction:()=>z0,ZodGUID:()=>gu,ZodIPv4:()=>Mm,ZodIPv6:()=>jm,ZodISODate:()=>wm,ZodISODateTime:()=>bm,ZodISODuration:()=>Sm,ZodISOTime:()=>xm,ZodIntersection:()=>l0,ZodIssueCode:()=>BB,ZodJWT:()=>Bm,ZodKSUID:()=>Rm,ZodLazy:()=>M0,ZodLiteral:()=>g0,ZodMAC:()=>Kx,ZodMap:()=>m0,ZodNaN:()=>A0,ZodNanoID:()=>Cm,ZodNever:()=>i0,ZodNonOptional:()=>Km,ZodNull:()=>e0,ZodNullable:()=>w0,ZodNumber:()=>yc,ZodNumberFormat:()=>Ho,ZodObject:()=>Su,ZodOptional:()=>Jm,ZodPipe:()=>$u,ZodPrefault:()=>k0,ZodPreprocess:()=>O0,ZodPromise:()=>D0,ZodReadonly:()=>P0,ZodRealError:()=>Er,ZodRecord:()=>mc,ZodSet:()=>h0,ZodString:()=>gc,ZodStringFormat:()=>Be,ZodSuccess:()=>I0,ZodSymbol:()=>Yx,ZodTemplateLiteral:()=>R0,ZodTransform:()=>y0,ZodTuple:()=>d0,ZodType:()=>_e,ZodULID:()=>Pm,ZodURL:()=>bu,ZodUUID:()=>ri,ZodUndefined:()=>Qx,ZodUnion:()=>ku,ZodUnknown:()=>n0,ZodVoid:()=>a0,ZodXID:()=>Nm,ZodXor:()=>s0,_ZodString:()=>Em,_default:()=>S0,_function:()=>$1,any:()=>r1,array:()=>xu,base64:()=>UN,base64url:()=>LN,bigint:()=>XN,boolean:()=>Xx,catch:()=>C0,check:()=>E1,cidrv4:()=>DN,cidrv6:()=>zN,clone:()=>Ye,codec:()=>w1,coerce:()=>B0,config:()=>ct,core:()=>wi,cuid:()=>CN,cuid2:()=>AN,custom:()=>I1,date:()=>i1,decode:()=>Bx,decodeAsync:()=>Zx,describe:()=>T1,discriminatedUnion:()=>u1,e164:()=>FN,email:()=>vN,emoji:()=>IN,encode:()=>Fx,encodeAsync:()=>Vx,endsWith:()=>js,enum:()=>Gm,exactOptional:()=>b0,file:()=>_1,flattenError:()=>_l,float32:()=>WN,float64:()=>JN,formatError:()=>yl,fromJSONSchema:()=>M1,function:()=>$1,getErrorMap:()=>ZB,globalRegistry:()=>De,gt:()=>Hn,gte:()=>dr,guid:()=>bN,hash:()=>GN,hex:()=>HN,hostname:()=>ZN,httpUrl:()=>EN,includes:()=>Rs,instanceof:()=>A1,int:()=>km,int32:()=>KN,int64:()=>YN,intersection:()=>u0,invertCodec:()=>x1,ipv4:()=>RN,ipv6:()=>jN,iso:()=>pc,json:()=>P1,jwt:()=>BN,keyof:()=>a1,ksuid:()=>NN,lazy:()=>j0,length:()=>wo,literal:()=>g1,locales:()=>Tl,looseObject:()=>c1,looseRecord:()=>f1,lowercase:()=>Ps,lt:()=>Zn,lte:()=>zr,mac:()=>MN,map:()=>p1,maxLength:()=>bo,maxSize:()=>_a,meta:()=>C1,mime:()=>Ds,minLength:()=>bi,minSize:()=>Gn,multipleOf:()=>ga,nan:()=>b1,nanoid:()=>TN,nativeEnum:()=>h1,negative:()=>fp,never:()=>Zm,nonnegative:()=>mp,nonoptional:()=>E0,nonpositive:()=>pp,normalize:()=>zs,null:()=>t0,nullable:()=>yu,nullish:()=>y1,number:()=>qx,object:()=>o1,optional:()=>_u,overwrite:()=>pn,parse:()=>Dx,parseAsync:()=>zx,partialRecord:()=>d1,pipe:()=>$m,positive:()=>dp,prefault:()=>$0,preprocess:()=>N1,prettifyError:()=>F_,promise:()=>k1,property:()=>hp,readonly:()=>N0,record:()=>p0,refine:()=>U0,regex:()=>Os,regexes:()=>Dr,registry:()=>Zf,safeDecode:()=>Gx,safeDecodeAsync:()=>Jx,safeEncode:()=>Hx,safeEncodeAsync:()=>Wx,safeParse:()=>Ux,safeParseAsync:()=>Lx,set:()=>m1,setErrorMap:()=>VB,size:()=>vo,slugify:()=>Bs,startsWith:()=>Ms,strictObject:()=>s1,string:()=>hu,stringFormat:()=>VN,stringbool:()=>O1,success:()=>v1,superRefine:()=>L0,symbol:()=>e1,templateLiteral:()=>S1,toJSONSchema:()=>xo,toLowerCase:()=>Ls,toUpperCase:()=>Fs,transform:()=>Wm,treeifyError:()=>L_,trim:()=>Us,tuple:()=>f0,uint32:()=>qN,uint64:()=>QN,ulid:()=>ON,undefined:()=>t1,union:()=>Hm,unknown:()=>Zo,uppercase:()=>Ns,url:()=>$N,util:()=>j,uuid:()=>wN,uuidv4:()=>xN,uuidv6:()=>SN,uuidv7:()=>kN,void:()=>n1,xid:()=>PN,xor:()=>l1});var mu={};An(mu,{ZodAny:()=>r0,ZodArray:()=>o0,ZodBase64:()=>Um,ZodBase64URL:()=>Lm,ZodBigInt:()=>bc,ZodBigIntFormat:()=>Vm,ZodBoolean:()=>vc,ZodCIDRv4:()=>Dm,ZodCIDRv6:()=>zm,ZodCUID:()=>Am,ZodCUID2:()=>Om,ZodCatch:()=>T0,ZodCodec:()=>Eu,ZodCustom:()=>Iu,ZodCustomStringFormat:()=>_c,ZodDate:()=>wu,ZodDefault:()=>x0,ZodDiscriminatedUnion:()=>c0,ZodE164:()=>Fm,ZodEmail:()=>Im,ZodEmoji:()=>Tm,ZodEnum:()=>hc,ZodExactOptional:()=>v0,ZodFile:()=>_0,ZodFunction:()=>z0,ZodGUID:()=>gu,ZodIPv4:()=>Mm,ZodIPv6:()=>jm,ZodIntersection:()=>l0,ZodJWT:()=>Bm,ZodKSUID:()=>Rm,ZodLazy:()=>M0,ZodLiteral:()=>g0,ZodMAC:()=>Kx,ZodMap:()=>m0,ZodNaN:()=>A0,ZodNanoID:()=>Cm,ZodNever:()=>i0,ZodNonOptional:()=>Km,ZodNull:()=>e0,ZodNullable:()=>w0,ZodNumber:()=>yc,ZodNumberFormat:()=>Ho,ZodObject:()=>Su,ZodOptional:()=>Jm,ZodPipe:()=>$u,ZodPrefault:()=>k0,ZodPreprocess:()=>O0,ZodPromise:()=>D0,ZodReadonly:()=>P0,ZodRecord:()=>mc,ZodSet:()=>h0,ZodString:()=>gc,ZodStringFormat:()=>Be,ZodSuccess:()=>I0,ZodSymbol:()=>Yx,ZodTemplateLiteral:()=>R0,ZodTransform:()=>y0,ZodTuple:()=>d0,ZodType:()=>_e,ZodULID:()=>Pm,ZodURL:()=>bu,ZodUUID:()=>ri,ZodUndefined:()=>Qx,ZodUnion:()=>ku,ZodUnknown:()=>n0,ZodVoid:()=>a0,ZodXID:()=>Nm,ZodXor:()=>s0,_ZodString:()=>Em,_default:()=>S0,_function:()=>$1,any:()=>r1,array:()=>xu,base64:()=>UN,base64url:()=>LN,bigint:()=>XN,boolean:()=>Xx,catch:()=>C0,check:()=>E1,cidrv4:()=>DN,cidrv6:()=>zN,codec:()=>w1,cuid:()=>CN,cuid2:()=>AN,custom:()=>I1,date:()=>i1,describe:()=>T1,discriminatedUnion:()=>u1,e164:()=>FN,email:()=>vN,emoji:()=>IN,enum:()=>Gm,exactOptional:()=>b0,file:()=>_1,float32:()=>WN,float64:()=>JN,function:()=>$1,guid:()=>bN,hash:()=>GN,hex:()=>HN,hostname:()=>ZN,httpUrl:()=>EN,instanceof:()=>A1,int:()=>km,int32:()=>KN,int64:()=>YN,intersection:()=>u0,invertCodec:()=>x1,ipv4:()=>RN,ipv6:()=>jN,json:()=>P1,jwt:()=>BN,keyof:()=>a1,ksuid:()=>NN,lazy:()=>j0,literal:()=>g1,looseObject:()=>c1,looseRecord:()=>f1,mac:()=>MN,map:()=>p1,meta:()=>C1,nan:()=>b1,nanoid:()=>TN,nativeEnum:()=>h1,never:()=>Zm,nonoptional:()=>E0,null:()=>t0,nullable:()=>yu,nullish:()=>y1,number:()=>qx,object:()=>o1,optional:()=>_u,partialRecord:()=>d1,pipe:()=>$m,prefault:()=>$0,preprocess:()=>N1,promise:()=>k1,readonly:()=>N0,record:()=>p0,refine:()=>U0,set:()=>m1,strictObject:()=>s1,string:()=>hu,stringFormat:()=>VN,stringbool:()=>O1,success:()=>v1,superRefine:()=>L0,symbol:()=>e1,templateLiteral:()=>S1,transform:()=>Wm,tuple:()=>f0,uint32:()=>qN,uint64:()=>QN,ulid:()=>ON,undefined:()=>t1,union:()=>Hm,unknown:()=>Zo,url:()=>$N,uuid:()=>wN,uuidv4:()=>xN,uuidv6:()=>SN,uuidv7:()=>kN,void:()=>n1,xid:()=>PN,xor:()=>l1});var vm={};An(vm,{endsWith:()=>js,gt:()=>Hn,gte:()=>dr,includes:()=>Rs,length:()=>wo,lowercase:()=>Ps,lt:()=>Zn,lte:()=>zr,maxLength:()=>bo,maxSize:()=>_a,mime:()=>Ds,minLength:()=>bi,minSize:()=>Gn,multipleOf:()=>ga,negative:()=>fp,nonnegative:()=>mp,nonpositive:()=>pp,normalize:()=>zs,overwrite:()=>pn,positive:()=>dp,property:()=>hp,regex:()=>Os,size:()=>vo,slugify:()=>Bs,startsWith:()=>Ms,toLowerCase:()=>Ls,toUpperCase:()=>Fs,trim:()=>Us,uppercase:()=>Ns});var pc={};An(pc,{ZodISODate:()=>wm,ZodISODateTime:()=>bm,ZodISODuration:()=>Sm,ZodISOTime:()=>xm,date:()=>Rx,datetime:()=>Nx,duration:()=>jx,time:()=>Mx});var bm=k("ZodISODateTime",(e,t)=>{qy.init(e,t),Be.init(e,t)});function Nx(e){return Yv(bm,e)}var wm=k("ZodISODate",(e,t)=>{Xy.init(e,t),Be.init(e,t)});function Rx(e){return Qv(wm,e)}var xm=k("ZodISOTime",(e,t)=>{Yy.init(e,t),Be.init(e,t)});function Mx(e){return eb(xm,e)}var Sm=k("ZodISODuration",(e,t)=>{Qy.init(e,t),Be.init(e,t)});function jx(e){return tb(Sm,e)}var _N=(e,t)=>{gl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>yl(e,r)},flatten:{value:r=>_l(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,xs,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,xs,2)}},isEmpty:{get(){return e.issues.length===0}}})},LB=k("ZodError",_N),Er=k("ZodError",_N,{Parent:Error});var Dx=$s(Er),zx=Es(Er),Ux=Is(Er),Lx=Ts(Er),Fx=bf(Er),Bx=wf(Er),Vx=xf(Er),Zx=Sf(Er),Hx=kf(Er),Gx=$f(Er),Wx=Ef(Er),Jx=If(Er);var yN=new WeakMap;function vu(e,t,r){let n=Object.getPrototypeOf(e),i=yN.get(n);if(i||(i=new Set,yN.set(n,i)),!i.has(t)){i.add(t);for(let a in r){let o=r[a];Object.defineProperty(n,a,{configurable:!0,enumerable:!1,get(){let s=o.bind(this);return Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:s}),s},set(s){Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:s})}})}}}var _e=k("ZodType",(e,t)=>(pe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Zs(e,"input"),output:Zs(e,"output")}}),e.toJSONSchema=Ob(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>Dx(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Ux(e,r,n),e.parseAsync=async(r,n)=>zx(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Lx(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Fx(e,r,n),e.decode=(r,n)=>Bx(e,r,n),e.encodeAsync=async(r,n)=>Vx(e,r,n),e.decodeAsync=async(r,n)=>Zx(e,r,n),e.safeEncode=(r,n)=>Hx(e,r,n),e.safeDecode=(r,n)=>Gx(e,r,n),e.safeEncodeAsync=async(r,n)=>Wx(e,r,n),e.safeDecodeAsync=async(r,n)=>Jx(e,r,n),vu(e,"ZodType",{check(...r){let n=this.def;return this.clone(j.mergeDefs(n,{checks:[...n.checks??[],...r.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return Ye(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(U0(r,n))},superRefine(r,n){return this.check(L0(r,n))},overwrite(r){return this.check(pn(r))},optional(){return _u(this)},exactOptional(){return b0(this)},nullable(){return yu(this)},nullish(){return _u(yu(this))},nonoptional(r){return E0(this,r)},array(){return xu(this)},or(r){return Hm([this,r])},and(r){return u0(this,r)},transform(r){return $m(this,Wm(r))},default(r){return S0(this,r)},prefault(r){return $0(this,r)},catch(r){return C0(this,r)},pipe(r){return $m(this,r)},readonly(){return N0(this)},describe(r){let n=this.clone();return De.add(n,{description:r}),n},meta(...r){if(r.length===0)return De.get(this);let n=this.clone();return De.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return De.get(e)?.description},configurable:!0}),e)),Em=k("_ZodString",(e,t)=>{_o.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Pb(e,n,i,a);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,vu(e,"_ZodString",{regex(...n){return this.check(Os(...n))},includes(...n){return this.check(Rs(...n))},startsWith(...n){return this.check(Ms(...n))},endsWith(...n){return this.check(js(...n))},min(...n){return this.check(bi(...n))},max(...n){return this.check(bo(...n))},length(...n){return this.check(wo(...n))},nonempty(...n){return this.check(bi(1,...n))},lowercase(n){return this.check(Ps(n))},uppercase(n){return this.check(Ns(n))},trim(){return this.check(Us())},normalize(...n){return this.check(zs(...n))},toLowerCase(){return this.check(Ls())},toUpperCase(){return this.check(Fs())},slugify(){return this.check(Bs())}})}),gc=k("ZodString",(e,t)=>{_o.init(e,t),Em.init(e,t),e.email=r=>e.check(Hf(Im,r)),e.url=r=>e.check(Al(bu,r)),e.jwt=r=>e.check(up(Bm,r)),e.emoji=r=>e.check(qf(Tm,r)),e.guid=r=>e.check(Cl(gu,r)),e.uuid=r=>e.check(Gf(ri,r)),e.uuidv4=r=>e.check(Wf(ri,r)),e.uuidv6=r=>e.check(Jf(ri,r)),e.uuidv7=r=>e.check(Kf(ri,r)),e.nanoid=r=>e.check(Xf(Cm,r)),e.guid=r=>e.check(Cl(gu,r)),e.cuid=r=>e.check(Yf(Am,r)),e.cuid2=r=>e.check(Qf(Om,r)),e.ulid=r=>e.check(ep(Pm,r)),e.base64=r=>e.check(sp(Um,r)),e.base64url=r=>e.check(cp(Lm,r)),e.xid=r=>e.check(tp(Nm,r)),e.ksuid=r=>e.check(rp(Rm,r)),e.ipv4=r=>e.check(np(Mm,r)),e.ipv6=r=>e.check(ip(jm,r)),e.cidrv4=r=>e.check(ap(Dm,r)),e.cidrv6=r=>e.check(op(zm,r)),e.e164=r=>e.check(lp(Fm,r)),e.datetime=r=>e.check(Nx(r)),e.date=r=>e.check(Rx(r)),e.time=r=>e.check(Mx(r)),e.duration=r=>e.check(jx(r))});function hu(e){return Jv(gc,e)}var Be=k("ZodStringFormat",(e,t)=>{Fe.init(e,t),Em.init(e,t)}),Im=k("ZodEmail",(e,t)=>{Fy.init(e,t),Be.init(e,t)});function vN(e){return Hf(Im,e)}var gu=k("ZodGUID",(e,t)=>{Uy.init(e,t),Be.init(e,t)});function bN(e){return Cl(gu,e)}var ri=k("ZodUUID",(e,t)=>{Ly.init(e,t),Be.init(e,t)});function wN(e){return Gf(ri,e)}function xN(e){return Wf(ri,e)}function SN(e){return Jf(ri,e)}function kN(e){return Kf(ri,e)}var bu=k("ZodURL",(e,t)=>{By.init(e,t),Be.init(e,t)});function $N(e){return Al(bu,e)}function EN(e){return Al(bu,{protocol:Dr.httpProtocol,hostname:Dr.domain,...j.normalizeParams(e)})}var Tm=k("ZodEmoji",(e,t)=>{Vy.init(e,t),Be.init(e,t)});function IN(e){return qf(Tm,e)}var Cm=k("ZodNanoID",(e,t)=>{Zy.init(e,t),Be.init(e,t)});function TN(e){return Xf(Cm,e)}var Am=k("ZodCUID",(e,t)=>{Hy.init(e,t),Be.init(e,t)});function CN(e){return Yf(Am,e)}var Om=k("ZodCUID2",(e,t)=>{Gy.init(e,t),Be.init(e,t)});function AN(e){return Qf(Om,e)}var Pm=k("ZodULID",(e,t)=>{Wy.init(e,t),Be.init(e,t)});function ON(e){return ep(Pm,e)}var Nm=k("ZodXID",(e,t)=>{Jy.init(e,t),Be.init(e,t)});function PN(e){return tp(Nm,e)}var Rm=k("ZodKSUID",(e,t)=>{Ky.init(e,t),Be.init(e,t)});function NN(e){return rp(Rm,e)}var Mm=k("ZodIPv4",(e,t)=>{ev.init(e,t),Be.init(e,t)});function RN(e){return np(Mm,e)}var Kx=k("ZodMAC",(e,t)=>{rv.init(e,t),Be.init(e,t)});function MN(e){return qv(Kx,e)}var jm=k("ZodIPv6",(e,t)=>{tv.init(e,t),Be.init(e,t)});function jN(e){return ip(jm,e)}var Dm=k("ZodCIDRv4",(e,t)=>{nv.init(e,t),Be.init(e,t)});function DN(e){return ap(Dm,e)}var zm=k("ZodCIDRv6",(e,t)=>{iv.init(e,t),Be.init(e,t)});function zN(e){return op(zm,e)}var Um=k("ZodBase64",(e,t)=>{ov.init(e,t),Be.init(e,t)});function UN(e){return sp(Um,e)}var Lm=k("ZodBase64URL",(e,t)=>{sv.init(e,t),Be.init(e,t)});function LN(e){return cp(Lm,e)}var Fm=k("ZodE164",(e,t)=>{cv.init(e,t),Be.init(e,t)});function FN(e){return lp(Fm,e)}var Bm=k("ZodJWT",(e,t)=>{lv.init(e,t),Be.init(e,t)});function BN(e){return up(Bm,e)}var _c=k("ZodCustomStringFormat",(e,t)=>{uv.init(e,t),Be.init(e,t)});function VN(e,t,r={}){return Vs(_c,e,t,r)}function ZN(e){return Vs(_c,"hostname",Dr.hostname,e)}function HN(e){return Vs(_c,"hex",Dr.hex,e)}function GN(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,i=Dr[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return Vs(_c,n,i,t)}var yc=k("ZodNumber",(e,t)=>{jf.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Nb(e,n,i,a),vu(e,"ZodNumber",{gt(n,i){return this.check(Hn(n,i))},gte(n,i){return this.check(dr(n,i))},min(n,i){return this.check(dr(n,i))},lt(n,i){return this.check(Zn(n,i))},lte(n,i){return this.check(zr(n,i))},max(n,i){return this.check(zr(n,i))},int(n){return this.check(km(n))},safe(n){return this.check(km(n))},positive(n){return this.check(Hn(0,n))},nonnegative(n){return this.check(dr(0,n))},negative(n){return this.check(Zn(0,n))},nonpositive(n){return this.check(zr(0,n))},multipleOf(n,i){return this.check(ga(n,i))},step(n,i){return this.check(ga(n,i))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function qx(e){return rb(yc,e)}var Ho=k("ZodNumberFormat",(e,t)=>{dv.init(e,t),yc.init(e,t)});function km(e){return ib(Ho,e)}function WN(e){return ab(Ho,e)}function JN(e){return ob(Ho,e)}function KN(e){return sb(Ho,e)}function qN(e){return cb(Ho,e)}var vc=k("ZodBoolean",(e,t)=>{xl.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Rb(e,r,n,i)});function Xx(e){return lb(vc,e)}var bc=k("ZodBigInt",(e,t)=>{Df.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Mb(e,n,i,a),e.gte=(n,i)=>e.check(dr(n,i)),e.min=(n,i)=>e.check(dr(n,i)),e.gt=(n,i)=>e.check(Hn(n,i)),e.gte=(n,i)=>e.check(dr(n,i)),e.min=(n,i)=>e.check(dr(n,i)),e.lt=(n,i)=>e.check(Zn(n,i)),e.lte=(n,i)=>e.check(zr(n,i)),e.max=(n,i)=>e.check(zr(n,i)),e.positive=n=>e.check(Hn(BigInt(0),n)),e.negative=n=>e.check(Zn(BigInt(0),n)),e.nonpositive=n=>e.check(zr(BigInt(0),n)),e.nonnegative=n=>e.check(dr(BigInt(0),n)),e.multipleOf=(n,i)=>e.check(ga(n,i));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function XN(e){return db(bc,e)}var Vm=k("ZodBigIntFormat",(e,t)=>{fv.init(e,t),bc.init(e,t)});function YN(e){return pb(Vm,e)}function QN(e){return mb(Vm,e)}var Yx=k("ZodSymbol",(e,t)=>{pv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>jb(e,r,n,i)});function e1(e){return hb(Yx,e)}var Qx=k("ZodUndefined",(e,t)=>{mv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>zb(e,r,n,i)});function t1(e){return gb(Qx,e)}var e0=k("ZodNull",(e,t)=>{hv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Db(e,r,n,i)});function t0(e){return _b(e0,e)}var r0=k("ZodAny",(e,t)=>{gv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Fb(e,r,n,i)});function r1(){return yb(r0)}var n0=k("ZodUnknown",(e,t)=>{Sl.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Bb(e,r,n,i)});function Zo(){return Ol(n0)}var i0=k("ZodNever",(e,t)=>{kl.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Lb(e,r,n,i)});function Zm(e){return Pl(i0,e)}var a0=k("ZodVoid",(e,t)=>{_v.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ub(e,r,n,i)});function n1(e){return vb(a0,e)}var wu=k("ZodDate",(e,t)=>{yv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Vb(e,n,i,a),e.min=(n,i)=>e.check(dr(n,i)),e.max=(n,i)=>e.check(zr(n,i));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function i1(e){return bb(wu,e)}var o0=k("ZodArray",(e,t)=>{vv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>tw(e,r,n,i),e.element=t.element,vu(e,"ZodArray",{min(r,n){return this.check(bi(r,n))},nonempty(r){return this.check(bi(1,r))},max(r,n){return this.check(bo(r,n))},length(r,n){return this.check(wo(r,n))},unwrap(){return this.element}})});function xu(e,t){return Sb(o0,e,t)}function a1(e){let t=e._zod.def.shape;return Gm(Object.keys(t))}var Su=k("ZodObject",(e,t)=>{bv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>rw(e,r,n,i),j.defineLazy(e,"shape",()=>t.shape),vu(e,"ZodObject",{keyof(){return Gm(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Zo()})},loose(){return this.clone({...this._zod.def,catchall:Zo()})},strict(){return this.clone({...this._zod.def,catchall:Zm()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return j.extend(this,r)},safeExtend(r){return j.safeExtend(this,r)},merge(r){return j.merge(this,r)},pick(r){return j.pick(this,r)},omit(r){return j.omit(this,r)},partial(...r){return j.partial(Jm,this,r[0])},required(...r){return j.required(Km,this,r[0])}})});function o1(e,t){let r={type:"object",shape:e??{},...j.normalizeParams(t)};return new Su(r)}function s1(e,t){return new Su({type:"object",shape:e,catchall:Zm(),...j.normalizeParams(t)})}function c1(e,t){return new Su({type:"object",shape:e,catchall:Zo(),...j.normalizeParams(t)})}var ku=k("ZodUnion",(e,t)=>{$l.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_p(e,r,n,i),e.options=t.options});function Hm(e,t){return new ku({type:"union",options:e,...j.normalizeParams(t)})}var s0=k("ZodXor",(e,t)=>{ku.init(e,t),wv.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_p(e,r,n,i),e.options=t.options});function l1(e,t){return new s0({type:"union",options:e,inclusive:!1,...j.normalizeParams(t)})}var c0=k("ZodDiscriminatedUnion",(e,t)=>{ku.init(e,t),xv.init(e,t)});function u1(e,t,r){return new c0({type:"union",options:t,discriminator:e,...j.normalizeParams(r)})}var l0=k("ZodIntersection",(e,t)=>{Sv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>nw(e,r,n,i)});function u0(e,t){return new l0({type:"intersection",left:e,right:t})}var d0=k("ZodTuple",(e,t)=>{zf.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>iw(e,r,n,i),e.rest=r=>e.clone({...e._zod.def,rest:r})});function f0(e,t,r){let n=t instanceof pe,i=n?r:t,a=n?t:null;return new d0({type:"tuple",items:e,rest:a,...j.normalizeParams(i)})}var mc=k("ZodRecord",(e,t)=>{kv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>aw(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType});function p0(e,t,r){return!t||!t._zod?new mc({type:"record",keyType:hu(),valueType:e,...j.normalizeParams(t)}):new mc({type:"record",keyType:e,valueType:t,...j.normalizeParams(r)})}function d1(e,t,r){let n=Ye(e);return n._zod.values=void 0,new mc({type:"record",keyType:n,valueType:t,...j.normalizeParams(r)})}function f1(e,t,r){return new mc({type:"record",keyType:e,valueType:t,mode:"loose",...j.normalizeParams(r)})}var m0=k("ZodMap",(e,t)=>{$v.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Qb(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Gn(...r)),e.nonempty=r=>e.check(Gn(1,r)),e.max=(...r)=>e.check(_a(...r)),e.size=(...r)=>e.check(vo(...r))});function p1(e,t,r){return new m0({type:"map",keyType:e,valueType:t,...j.normalizeParams(r)})}var h0=k("ZodSet",(e,t)=>{Ev.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ew(e,r,n,i),e.min=(...r)=>e.check(Gn(...r)),e.nonempty=r=>e.check(Gn(1,r)),e.max=(...r)=>e.check(_a(...r)),e.size=(...r)=>e.check(vo(...r))});function m1(e,t){return new h0({type:"set",valueType:e,...j.normalizeParams(t)})}var hc=k("ZodEnum",(e,t)=>{Iv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,i,a)=>Zb(e,n,i,a),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let a={};for(let o of n)if(r.has(o))a[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new hc({...t,checks:[],...j.normalizeParams(i),entries:a})},e.exclude=(n,i)=>{let a={...t.entries};for(let o of n)if(r.has(o))delete a[o];else throw new Error(`Key ${o} not found in enum`);return new hc({...t,checks:[],...j.normalizeParams(i),entries:a})}});function Gm(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new hc({type:"enum",entries:r,...j.normalizeParams(t)})}function h1(e,t){return new hc({type:"enum",entries:e,...j.normalizeParams(t)})}var g0=k("ZodLiteral",(e,t)=>{Tv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Hb(e,r,n,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function g1(e,t){return new g0({type:"literal",values:Array.isArray(e)?e:[e],...j.normalizeParams(t)})}var _0=k("ZodFile",(e,t)=>{Cv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Jb(e,r,n,i),e.min=(r,n)=>e.check(Gn(r,n)),e.max=(r,n)=>e.check(_a(r,n)),e.mime=(r,n)=>e.check(Ds(Array.isArray(r)?r:[r],n))});function _1(e){return kb(_0,e)}var y0=k("ZodTransform",(e,t)=>{Av.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Yb(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ua(e.constructor.name);r.addIssue=a=>{if(typeof a=="string")r.issues.push(j.issue(a,r.value,t));else{let o=a;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(j.issue(o))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(a=>(r.value=a,r.fallback=!0,r)):(r.value=i,r.fallback=!0,r)}});function Wm(e){return new y0({type:"transform",transform:e})}var Jm=k("ZodOptional",(e,t)=>{yo.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>yp(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function _u(e){return new Jm({type:"optional",innerType:e})}var v0=k("ZodExactOptional",(e,t)=>{Ov.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>yp(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function b0(e){return new v0({type:"optional",innerType:e})}var w0=k("ZodNullable",(e,t)=>{Pv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ow(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function yu(e){return new w0({type:"nullable",innerType:e})}function y1(e){return _u(yu(e))}var x0=k("ZodDefault",(e,t)=>{Nv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>cw(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function S0(e,t){return new x0({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}var k0=k("ZodPrefault",(e,t)=>{Rv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>lw(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function $0(e,t){return new k0({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}var Km=k("ZodNonOptional",(e,t)=>{Mv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>sw(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function E0(e,t){return new Km({type:"nonoptional",innerType:e,...j.normalizeParams(t)})}var I0=k("ZodSuccess",(e,t)=>{jv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Kb(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function v1(e){return new I0({type:"success",innerType:e})}var T0=k("ZodCatch",(e,t)=>{Dv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>uw(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function C0(e,t){return new T0({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var A0=k("ZodNaN",(e,t)=>{zv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Gb(e,r,n,i)});function b1(e){return xb(A0,e)}var $u=k("ZodPipe",(e,t)=>{Uf.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>dw(e,r,n,i),e.in=t.in,e.out=t.out});function $m(e,t){return new $u({type:"pipe",in:e,out:t})}var Eu=k("ZodCodec",(e,t)=>{$u.init(e,t),El.init(e,t)});function w1(e,t,r){return new Eu({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function x1(e){let t=e._zod.def;return new Eu({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var O0=k("ZodPreprocess",(e,t)=>{$u.init(e,t),Uv.init(e,t)}),P0=k("ZodReadonly",(e,t)=>{Lv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fw(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function N0(e){return new P0({type:"readonly",innerType:e})}var R0=k("ZodTemplateLiteral",(e,t)=>{Fv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Wb(e,r,n,i)});function S1(e,t){return new R0({type:"template_literal",parts:e,...j.normalizeParams(t)})}var M0=k("ZodLazy",(e,t)=>{Zv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>mw(e,r,n,i),e.unwrap=()=>e._zod.def.getter()});function j0(e){return new M0({type:"lazy",getter:e})}var D0=k("ZodPromise",(e,t)=>{Vv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>pw(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function k1(e){return new D0({type:"promise",innerType:e})}var z0=k("ZodFunction",(e,t)=>{Bv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Xb(e,r,n,i)});function $1(e){return new z0({type:"function",input:Array.isArray(e?.input)?f0(e?.input):e?.input??xu(Zo()),output:e?.output??Zo()})}var Iu=k("ZodCustom",(e,t)=>{Hv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,n,i)=>qb(e,r,n,i)});function E1(e){let t=new Ze({check:"custom"});return t._zod.check=e,t}function I1(e,t){return $b(Iu,e??(()=>!0),t)}function U0(e,t={}){return Eb(Iu,e,t)}function L0(e,t){return Ib(e,t)}var T1=Tb,C1=Cb;function A1(e,t={}){let r=new Iu({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...j.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var O1=(...e)=>Ab({Codec:Eu,Boolean:vc,String:gc},...e);function P1(e){let t=j0(()=>Hm([hu(e),qx(),Xx(),t0(),xu(t),p0(hu(),t)]));return t}function N1(e,t){return new O0({type:"pipe",in:Wm(e),out:t})}var BB={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function VB(e){ct({customError:e})}function ZB(){return ct().customError}var F0;F0||(F0={});var H={...mu,...vm,iso:pc},HB=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function GB(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function WB(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let i=r[1];if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}function R1(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return H.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return H.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);let a=WB(i,t),o=Qt(a,t);return t.refs.set(i,o),t.processing.delete(i),o}if(e.enum!==void 0){let i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return H.null();if(i.length===0)return H.never();if(i.length===1)return H.literal(i[0]);if(i.every(o=>typeof o=="string"))return H.enum(i);let a=i.map(o=>H.literal(o));return a.length<2?a[0]:H.union([a[0],a[1],...a.slice(2)])}if(e.const!==void 0)return H.literal(e.const);let r=e.type;if(Array.isArray(r)){let i=r.map(a=>{let o={...e,type:a};return R1(o,t)});return i.length===0?H.never():i.length===1?i[0]:H.union(i)}if(!r)return H.any();let n;switch(r){case"string":{let i=H.string();if(e.format){let a=e.format;a==="email"?i=i.check(H.email()):a==="uri"||a==="uri-reference"?i=i.check(H.url()):a==="uuid"||a==="guid"?i=i.check(H.uuid()):a==="date-time"?i=i.check(H.iso.datetime()):a==="date"?i=i.check(H.iso.date()):a==="time"?i=i.check(H.iso.time()):a==="duration"?i=i.check(H.iso.duration()):a==="ipv4"?i=i.check(H.ipv4()):a==="ipv6"?i=i.check(H.ipv6()):a==="mac"?i=i.check(H.mac()):a==="cidr"?i=i.check(H.cidrv4()):a==="cidr-v6"?i=i.check(H.cidrv6()):a==="base64"?i=i.check(H.base64()):a==="base64url"?i=i.check(H.base64url()):a==="e164"?i=i.check(H.e164()):a==="jwt"?i=i.check(H.jwt()):a==="emoji"?i=i.check(H.emoji()):a==="nanoid"?i=i.check(H.nanoid()):a==="cuid"?i=i.check(H.cuid()):a==="cuid2"?i=i.check(H.cuid2()):a==="ulid"?i=i.check(H.ulid()):a==="xid"?i=i.check(H.xid()):a==="ksuid"&&(i=i.check(H.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),n=i;break}case"number":case"integer":{let i=r==="integer"?H.number().int():H.number();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):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),n=i;break}case"boolean":{n=H.boolean();break}case"null":{n=H.null();break}case"object":{let i={},a=e.properties||{},o=new Set(e.required||[]);for(let[c,l]of Object.entries(a)){let u=Qt(l,t);i[c]=o.has(c)?u:u.optional()}if(e.propertyNames){let c=Qt(e.propertyNames,t),l=e.additionalProperties&&typeof e.additionalProperties=="object"?Qt(e.additionalProperties,t):H.any();if(Object.keys(i).length===0){n=H.record(c,l);break}let u=H.object(i).passthrough(),d=H.looseRecord(c,l);n=H.intersection(u,d);break}if(e.patternProperties){let c=e.patternProperties,l=Object.keys(c),u=[];for(let f of l){let p=Qt(c[f],t),m=H.string().regex(new RegExp(f));u.push(H.looseRecord(m,p))}let d=[];if(Object.keys(i).length>0&&d.push(H.object(i).passthrough()),d.push(...u),d.length===0)n=H.object({}).passthrough();else if(d.length===1)n=d[0];else{let f=H.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=H.intersection(f,d[p]);n=f}break}let s=H.object(i);e.additionalProperties===!1?n=s.strict():typeof e.additionalProperties=="object"?n=s.catchall(Qt(e.additionalProperties,t)):n=s.passthrough();break}case"array":{let i=e.prefixItems,a=e.items;if(i&&Array.isArray(i)){let o=i.map(c=>Qt(c,t)),s=a&&typeof a=="object"&&!Array.isArray(a)?Qt(a,t):void 0;s?n=H.tuple(o).rest(s):n=H.tuple(o),typeof e.minItems=="number"&&(n=n.check(H.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(H.maxLength(e.maxItems)))}else if(Array.isArray(a)){let o=a.map(c=>Qt(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?Qt(e.additionalItems,t):void 0;s?n=H.tuple(o).rest(s):n=H.tuple(o),typeof e.minItems=="number"&&(n=n.check(H.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(H.maxLength(e.maxItems)))}else if(a!==void 0){let o=Qt(a,t),s=H.array(o);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),n=s}else n=H.array(H.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n}function Qt(e,t){if(typeof e=="boolean")return e?H.any():H.never();let r=R1(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(l=>Qt(l,t)),c=H.union(s);r=n?H.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(l=>Qt(l,t)),c=H.xor(s);r=n?H.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:H.any();else{let s=n?r:Qt(e.allOf[0],t),c=n?0:1;for(let l=c;l<e.allOf.length;l++)s=H.intersection(s,Qt(e.allOf[l],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=H.nullable(r)),e.readOnly===!0&&(r=H.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let i={},a=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of a)s in e&&(i[s]=e[s]);let o=["contentEncoding","contentMediaType","contentSchema"];for(let s of o)s in e&&(i[s]=e[s]);for(let s of Object.keys(e))HB.has(s)||(i[s]=e[s]);return Object.keys(i).length>0&&t.registry.add(r,i),e.description&&(r=r.describe(e.description)),r}function M1(e,t){if(typeof e=="boolean")return e?H.any():H.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let n=GB(r,t?.defaultTarget),i=r.$defs||r.definitions||{},a={version:n,defs:i,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??De};return Qt(r,a)}var B0={};An(B0,{bigint:()=>XB,boolean:()=>qB,date:()=>YB,number:()=>KB,string:()=>JB});function JB(e){return Kv(gc,e)}function KB(e){return nb(yc,e)}function qB(e){return ub(vc,e)}function XB(e){return fb(bc,e)}function YB(e){return wb(wu,e)}ct(Lf());var j1=T({BaseToolkit:()=>QB,DynamicStructuredTool:()=>U1,DynamicTool:()=>z1,StructuredTool:()=>Tu,Tool:()=>D1,ToolInputParsingException:()=>cs,isLangChainTool:()=>pu,isRunnableToolLike:()=>du,isStructuredTool:()=>uu,isStructuredToolParams:()=>fu,tool:()=>eV}),Tu=class extends qp{extras;returnDirect=!1;verboseParsingErrors=!1;get lc_namespace(){return["langchain","tools"]}responseFormat="content";defaultConfig;constructor(e){super(e??{}),this.verboseParsingErrors=e?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=e?.responseFormat??this.responseFormat,this.defaultConfig=e?.defaultConfig??this.defaultConfig,this.metadata=e?.metadata??this.metadata,this.extras=e?.extras??this.extras}async invoke(e,t){let r,n=ke($t(this.defaultConfig,t));return Qi(e)?(r=e.args,n={...n,toolCall:e}):r=e,this.call(r,n)}async call(e,t,r){let n=Qi(e)?e.args:e,i;if(xr(this.schema))try{i=await wa(this.schema,n)}catch(p){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
415
+ Details: ${p.message}`),$p(p)&&(m=`${m}
416
+
417
+ ${rn.prettifyError(p)}`),new cs(m,JSON.stringify(e))}else{let p=We(n,this.schema);if(!p.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
418
+ Details: ${p.errors.map(h=>`${h.keywordLocation}: ${h.error}`).join(`
419
+ `)}`),new cs(m,JSON.stringify(e))}i=n}let a=so(t),o=Xe.configure(a.callbacks,this.callbacks,a.tags||r,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),s;Qi(e)&&(s=e.id),!s&&n$(a)&&(s=a.toolCall.id);let c=await o?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),a.runId,void 0,void 0,void 0,a.runName,s);delete a.runId;let l;try{let p=await this._call(i,c,a);l=Aw(p)?await oO(p,async m=>{try{await c?.handleToolEvent(m)}catch(h){await c?.handleToolError(h)}}):p}catch(p){throw await c?.handleToolError(p),p}let u,d;if(this.responseFormat==="content_and_artifact")if(Array.isArray(l)&&l.length===2)[u,d]=l;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
420
+ Result: ${JSON.stringify(l)}`);else u=l;let f=rV({content:u,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},D1=class extends Tu{schema=Nt.object({input:Nt.string().optional()}).transform(e=>e.input);constructor(e){super(e)}call(e,t){let r=typeof e=="string"||e==null?{input:e}:e;return super.call(r,t)}},z1=class extends D1{static lc_name(){return"DynamicTool"}name;description;func;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){let r=so(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},U1=class extends Tu{static lc_name(){return"DynamicStructuredTool"}description;func;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=e.schema}async call(e,t,r){let n=so(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n,r)}_call(e,t,r){return this.func(e,t,r)}},QB=class{getTools(){return this.tools}};function eV(e,t){let r=Gs(t.schema),n=tc(t.schema);if(!t.schema||r||n)return new z1({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(o,s,c)=>new Promise((l,u)=>{let d=Ee(c,{callbacks:s?.getChild()});Re.runWithConfig(vr(d),async()=>{try{l(e(o,d))}catch(f){u(f)}})})});let i=t.schema,a=t.description??t.schema.description??`${t.name} tool`;return new U1({...t,description:a,schema:i,func:async(o,s,c)=>new Promise((l,u)=>{let d,f=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{f(),u(aa(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let p=Ee(c,{callbacks:s?.getChild()});Re.runWithConfig(vr(p),async()=>{try{let m=await e(o,p);if(Aw(m)){l(m);return}if(c?.signal?.aborted){f();return}f(),l(m)}catch(m){f(),u(m)}})})})}function tV(e){return typeof e=="object"&&e!==null&&"type"in e}function rV(e){let{content:t,artifact:r,toolCallId:n,metadata:i}=e;return n&&!Gc(t)?typeof t=="string"||Array.isArray(t)&&t.every(tV)?new St({status:"success",content:t,artifact:r,tool_call_id:n,name:e.name,metadata:i}):new St({status:"success",content:nV(t),artifact:r,tool_call_id:n,name:e.name,metadata:i}):t}function nV(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}var L1=T({RunCollectorCallbackHandler:()=>iV}),iV=class extends Dt{name="run_collector";exampleId;tracedRuns;constructor({exampleId:e}={}){super({_awaitHandler:!0}),this.exampleId=e,this.tracedRuns=[]}async persistRun(e){let t={...e};t.reference_example_id=this.exampleId,this.tracedRuns.push(t)}};var F1=T({});var B1=T({chunkArray:()=>aV}),aV=(e,t)=>e.reduce((r,n,i)=>{let a=Math.floor(i/t);return r[a]=(r[a]||[]).concat([n]),r},[]);var V1=T({context:()=>oV});function oV(e,...t){let r=e.raw,n="";for(let i=0;i<r.length;i++){let a=r[i].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(n+=a,i<t.length){let o=sV(t[i],n);n+=typeof o=="string"?o:JSON.stringify(o)}}return n=cV(n),n=n.trim(),n=n.replace(/\\n/g,`
421
+ `),n}function sV(e,t){if(typeof e!="string"||!e.includes(`
422
+ `))return e;let r=t.slice(t.lastIndexOf(`
423
+ `)+1).match(/^(\s+)/);if(r){let n=r[1];return e.replace(/\n/g,`
424
+ ${n}`)}return e}function cV(e){let t=e.split(`
425
+ `),r=null;for(let n of t){let i=n.match(/^(\s+)\S+/);if(i){let a=i[1].length;r===null?r=a:r=Math.min(r,a)}}return r===null?e:t.map(n=>n[0]===" "||n[0]===" "?n.slice(r):n).join(`
426
+ `)}var Z1=T({EventStreamContentType:()=>lV,convertEventStreamToIterableReadableDataStream:()=>dV,getBytes:()=>H1,getLines:()=>G1,getMessages:()=>W1}),lV="text/event-stream";async function H1(e,t){if(e instanceof ReadableStream){let r=e.getReader();for(;;){let n=await r.read();if(n.done){t(new Uint8Array,!0);break}t(n.value)}}else try{for await(let r of e)t(new Uint8Array(r));t(new Uint8Array,!0)}catch(r){throw new Error(["Parsing event source stream failed.","Ensure your implementation of fetch returns a web or Node readable stream.",`Error: ${r.message}`].join(`
427
+ `))}}function G1(e){let t,r,n,i=!1;return function(o,s){if(s){e(o,0,!0);return}t===void 0?(t=o,r=0,n=-1):t=uV(t,o);let c=t.length,l=0;for(;r<c;){i&&(t[r]===10&&(l=++r),i=!1);let u=-1;for(;r<c&&u===-1;++r)switch(t[r]){case 58:n===-1&&(n=r-l);break;case 13:i=!0;case 10:u=r;break}if(u===-1)break;e(t.subarray(l,u),n),l=r,n=-1}l===c?t=void 0:l!==0&&(t=t.subarray(l),r-=l)}}function W1(e,t,r){let n=V0(),i=new TextDecoder;return function(o,s,c){if(c){fV(n)||(e?.(n),n=V0());return}if(o.length===0)e?.(n),n=V0();else if(s>0){let l=i.decode(o.subarray(0,s)),u=s+(o[s+1]===32?2:1),d=i.decode(o.subarray(u));switch(l){case"data":n.data=n.data?n.data+`
428
+ `+d:d;break;case"event":n.event=d;break;case"id":t?.(n.id=d);break;case"retry":{let f=parseInt(d,10);Number.isNaN(f)||r?.(n.retry=f);break}}}}}function uV(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function V0(){return{data:"",event:"",id:"",retry:void 0}}function dV(e,t){let r=new ReadableStream({async start(n){let i=W1(o=>{if(o.event==="error")throw new Error(o.data??"Unspecified event streaming error.");o.event==="metadata"?t?.(o):o.data&&n.enqueue(o.data)});await H1(e,G1((o,s,c)=>{i(o,s,c),c&&n.close()}))}});return gt.fromReadableStream(r)}function fV(e){return e.data===""&&e.event===""&&e.id===""&&e.retry===void 0}var J1=T({});var K1=T({convertToOpenAIFunction:()=>q1,convertToOpenAITool:()=>pV,isLangChainTool:()=>pu,isRunnableToolLike:()=>du,isStructuredTool:()=>uu,isStructuredToolParams:()=>fu});function q1(e,t){let r=typeof t=="number"?void 0:t;return{name:e.name,description:e.description,parameters:Et(e.schema),...r?.strict!==void 0?{strict:r.strict}:{}}}function pV(e,t){let r=typeof t=="number"?void 0:t,n;return pu(e)?n={type:"function",function:q1(e)}:n=e,r?.strict!==void 0&&(n.function.strict=r.strict),n}function qm(e,t){let r=0,n=0,i=0;for(let a=0;a<e.length;a++)r+=e[a]*t[a],n+=e[a]*e[a],i+=t[a]*t[a];return r/(Math.sqrt(n)*Math.sqrt(i))}function X1(e,t){let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}function mV(e,t){let r=0;for(let n=0;n<e.length;n++)r+=(e[n]-t[n])*(e[n]-t[n]);return r}function Y1(e,t){return Math.sqrt(mV(e,t))}var Q1=T({cosineSimilarity:()=>Z0,euclideanDistance:()=>_V,innerProduct:()=>gV,matrixFunc:()=>Xm,maximalMarginalRelevance:()=>yV,normalize:()=>hV});function Xm(e,t,r){if(e.length===0||e[0].length===0||t.length===0||t[0].length===0)return[[]];if(e[0].length!==t[0].length)throw new Error(`Number of columns in X and Y must be the same. X has shape ${[e.length,e[0].length]} and Y has shape ${[t.length,t[0].length]}.`);return e.map(n=>t.map(i=>r(n,i)).map(i=>Number.isNaN(i)?0:i))}function hV(e,t=!1){let r=vV(e);return e.map(n=>n.map(i=>t?1-i/r:i/r))}function Z0(e,t){return Xm(e,t,qm)}function gV(e,t){return Xm(e,t,X1)}function _V(e,t){return Xm(e,t,Y1)}function yV(e,t,r=.5,n=4){if(Math.min(n,t.length)<=0)return[];let i=Z0(Array.isArray(e[0])?e:[e],t)[0],a=eR(i).maxIndex,o=[t[a]],s=[a];for(;s.length<Math.min(n,t.length);){let c=-1/0,l=-1,u=Z0(t,o);i.forEach((d,f)=>{if(s.includes(f))return;let p=Math.max(...u[f]),m=r*d-(1-r)*p;m>c&&(c=m,l=f)}),o.push(t[l]),s.push(l)}return s}function eR(e){if(e.length===0)return{maxIndex:-1,maxValue:NaN};let t=e[0],r=0;for(let n=1;n<e.length;n+=1)e[n]>t&&(r=n,t=e[n]);return{maxIndex:r,maxValue:t}}function vV(e){return e.reduce((t,r)=>Math.max(t,eR(r).maxValue),0)}var tR=T({isCloudMetadata:()=>H0,isLocalhost:()=>G0,isPrivateIp:()=>oR,isSafeUrl:()=>IV,isSameOrigin:()=>TV,validateSafeUrl:()=>sR}),bV=["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","127.0.0.0/8","169.254.0.0/16","0.0.0.0/8","::1/128","fc00::/7","fe80::/10","ff00::/8"],wV=["169.254.169.254","169.254.170.2","100.100.100.200"],xV=["metadata.google.internal","metadata","instance-data"],SV=["localhost","localhost.localdomain"],kV=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function rR(e){return kV.test(e)}function Ym(e){return aR(e)!==null}function nR(e){return rR(e)||Ym(e)}function iR(e){if(rR(e))return e.split(".").map(t=>parseInt(t,10));if(Ym(e)){let t=aR(e);if(!t)return null;let r=t.split(":"),n=[];for(let i of r)n.push(parseInt(i,16));return n}return null}function aR(e){if(!e||typeof e!="string"||!e.includes(":")||!/^[0-9a-fA-F:]+$/.test(e))return null;let t=e;if(t.includes("::")){let n=t.split("::");if(n.length>2)return null;let[i,a]=n,o=i?i.split(":"):[],s=a?a.split(":"):[],c=8-(o.length+s.length);if(c<0)return null;let l=Array(c).fill("0");t=[...o,...l,...s].filter(u=>u!=="").join(":")}let r=t.split(":");if(r.length!==8)return null;for(let n of r)if(n.length===0||n.length>4||!/^[0-9a-fA-F]+$/.test(n))return null;return r.map(n=>n.padStart(4,"0").toLowerCase()).join(":")}function $V(e){let[t,r]=e.split("/");if(!t||!r)return null;let n=iR(t);if(!n)return null;let i=parseInt(r,10);if(isNaN(i))return null;let a=Ym(t);return a&&i>128||!a&&i>32?null:{addr:n,prefixLen:i,isIpv6:a}}function EV(e,t){let r=iR(e);if(!r)return!1;let n=$V(t);if(!n)return!1;let i=Ym(e);if(i!==n.isIpv6)return!1;let{addr:a,prefixLen:o}=n;if(i)for(let s=0;s<Math.ceil(o/16);s++){let c=65535<<16-Math.min(16,o-s*16)&65535;if((r[s]&c)!==(a[s]&c))return!1}else for(let s=0;s<Math.ceil(o/8);s++){let c=255<<8-Math.min(8,o-s*8)&255;if((r[s]&c)!==(a[s]&c))return!1}return!0}function oR(e){if(!nR(e))return!1;for(let t of bV)if(EV(e,t))return!0;return!1}function H0(e,t){if(wV.includes(t||""))return!0;let r=e.toLowerCase();return!!xV.includes(r)}function G0(e,t){if(t&&(t==="127.0.0.1"||t==="::1"||t==="0.0.0.0"||t.startsWith("127.")))return!0;let r=e.toLowerCase();return!!SV.includes(r)}function sR(e,t){let r=t?.allowPrivate??!1,n=t?.allowHttp??!1;try{let i;try{i=new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}let a=i.hostname;if(!a)throw new Error("URL missing hostname.");if(H0(a))throw new Error(`URL points to cloud metadata endpoint: ${a}`);if(G0(a)){if(!r)throw new Error(`URL points to localhost: ${a}`);return e}let o=i.protocol;if(o!=="http:"&&o!=="https:")throw new Error(`Invalid URL scheme: ${o}. Only http and https are allowed.`);if(o==="http:"&&!n)throw new Error("HTTP scheme not allowed. Use HTTPS or set allowHttp: true.");if(nR(a)){let s=a;if(G0(a,s)){if(!r)throw new Error(`URL points to localhost: ${a}`);return e}if(H0(a,s))throw new Error(`URL resolves to cloud metadata IP: ${s} (${a})`);if(oR(s)&&!r)throw new Error(`URL resolves to private IP: ${s} (${a}). Set allowPrivate: true to allow.`);return e}return e}catch(i){throw i&&typeof i=="object"&&"message"in i?i:new Error(`URL validation failed: ${i}`)}}function IV(e,t){try{return sR(e,t),!0}catch{return!1}}function TV(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}var cR=T({SaveableVectorStore:()=>CV,VectorStore:()=>eh,VectorStoreRetriever:()=>Qm}),Qm=class extends nu{static lc_name(){return"VectorStoreRetriever"}get lc_namespace(){return["langchain_core","vectorstores"]}vectorStore;k=4;searchType="similarity";searchKwargs;filter;_vectorstoreType(){return this.vectorStore._vectorstoreType()}constructor(e){super(e),this.vectorStore=e.vectorStore,this.k=e.k??this.k,this.searchType=e.searchType??this.searchType,this.filter=e.filter,e.searchType==="mmr"&&(this.searchKwargs=e.searchKwargs)}async _getRelevantDocuments(e,t){if(this.searchType==="mmr"){if(typeof this.vectorStore.maxMarginalRelevanceSearch!="function")throw new Error(`The vector store backing this retriever, ${this._vectorstoreType()} does not support max marginal relevance search.`);return this.vectorStore.maxMarginalRelevanceSearch(e,{k:this.k,filter:this.filter,...this.searchKwargs},t?.getChild("vectorstore"))}return this.vectorStore.similaritySearch(e,this.k,this.filter,t?.getChild("vectorstore"))}async addDocuments(e,t){return this.vectorStore.addDocuments(e,t)}},eh=class extends pt{lc_namespace=["langchain","vectorstores",this._vectorstoreType()];embeddings;constructor(e,t){super(t),this.embeddings=e}async delete(e){throw new Error("Not implemented.")}async similaritySearch(e,t=4,r=void 0,n=void 0){return(await this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)).map(i=>i[0])}async similaritySearchWithScore(e,t=4,r=void 0,n=void 0){return this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)}static fromTexts(e,t,r,n){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}static fromDocuments(e,t,r){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}asRetriever(e,t,r,n,i,a){if(typeof e=="number")return new Qm({vectorStore:this,k:e,filter:t,tags:[...n??[],this._vectorstoreType()],metadata:i,verbose:a,callbacks:r});{let o={vectorStore:this,k:e?.k,filter:e?.filter,tags:[...e?.tags??[],this._vectorstoreType()],metadata:e?.metadata,verbose:e?.verbose,callbacks:e?.callbacks,searchType:e?.searchType};return e?.searchType==="mmr"?new Qm({...o,searchKwargs:e.searchKwargs}):new Qm({...o})}}},CV=class extends eh{static load(e,t){throw new Error("Not implemented")}};var lR=class extends Aa{_combineLLMOutput(){return[]}_llmType(){return"fake"}async _generate(e,t,r){if(t?.stop?.length)return{generations:[{message:new Ne(t.stop[0]),text:t.stop[0]}]};let n=e.map(i=>typeof i.content=="string"?i.content:JSON.stringify(i.content,null,2)).join(`
429
+ `);return await r?.handleLLMNewToken(n),{generations:[{message:new Ne(n),text:n}],llmOutput:{}}}},uR=class dR extends Aa{sleep=50;responses=[];chunks=[];toolStyle="openai";thrownErrorString;tools=[];constructor({sleep:t=50,responses:r=[],chunks:n=[],toolStyle:i="openai",thrownErrorString:a,...o}){super(o),this.sleep=t,this.responses=r,this.chunks=n,this.toolStyle=i,this.thrownErrorString=a}_llmType(){return"fake"}bindTools(t){let r=[...this.tools,...t],n=r.map(o=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:o.name,description:o.description,parameters:Et(o.schema)}};case"anthropic":return{name:o.name,description:o.description,input_schema:Et(o.schema)};case"bedrock":return{toolSpec:{name:o.name,description:o.description,inputSchema:Et(o.schema)}};case"google":return{name:o.name,description:o.description,parameters:Et(o.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),i=this.toolStyle==="google"?[{functionDeclarations:n}]:n,a=new dR({sleep:this.sleep,responses:this.responses,chunks:this.chunks,toolStyle:this.toolStyle,thrownErrorString:this.thrownErrorString});return a.tools=r,a.withConfig({tools:i})}async _generate(t,r,n){if(this.thrownErrorString)throw new Error(this.thrownErrorString);return{generations:[{text:"",message:new Ne({content:this.responses?.[0]?.content??t[0].content??"",tool_calls:this.chunks?.[0]?.tool_calls})}]}}async*_streamResponseChunks(t,r,n){if(this.thrownErrorString)throw new Error(this.thrownErrorString);if(this.chunks?.length){for(let o of this.chunks){let s=new la({message:new it({content:o.content,tool_calls:o.tool_calls,additional_kwargs:o.additional_kwargs??{}}),text:o.content?.toString()??""});if(r.signal?.aborted)break;yield s,await n?.handleLLMNewToken(o.content,void 0,void 0,void 0,void 0,{chunk:s})}return}let i=this.responses?.[0]??new Ne(typeof t[0].content=="string"?t[0].content:""),a=typeof i.content=="string"?i.content:"";for(let o of a){await new Promise(c=>setTimeout(c,this.sleep));let s=new la({message:new it({content:o}),text:o});if(r.signal?.aborted)break;yield s,await n?.handleLLMNewToken(o,void 0,void 0,void 0,void 0,{chunk:s})}}},fR=class pR extends Aa{static lc_name(){return"FakeListChatModel"}lc_serializable=!0;responses;i=0;sleep;emitCustomEvent=!1;generationInfo;tools=[];toolStyle="openai";constructor(t){super(t);let{responses:r,sleep:n,emitCustomEvent:i,generationInfo:a}=t;this.responses=r,this.sleep=n,this.emitCustomEvent=i??this.emitCustomEvent,this.generationInfo=a}_combineLLMOutput(){return[]}_llmType(){return"fake-list"}async _generate(t,r,n){if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);if(this.emitCustomEvent&&await n?.handleCustomEvent("some_test_event",{someval:!0}),r?.stop?.length)return{generations:[this._formatGeneration(r.stop[0])]};{let i=this._currentResponse();return this._incrementResponse(),{generations:[this._formatGeneration(i)],llmOutput:{}}}}_formatGeneration(t){return{message:new Ne(t),text:t}}async*_streamResponseChunks(t,r,n){let i=this._currentResponse();this._incrementResponse(),this.emitCustomEvent&&await n?.handleCustomEvent("some_test_event",{someval:!0});let a=[...i];for(let o=0;o<a.length;o++){let s=a[o],c=o===a.length-1;if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);let l=this._createResponseChunk(s,c?this.generationInfo:void 0);if(r.signal?.aborted)break;yield l,n?.handleLLMNewToken(s)}}async _sleepIfRequested(){this.sleep!==void 0&&await this._sleep()}async _sleep(){return new Promise(t=>{setTimeout(()=>t(),this.sleep)})}_createResponseChunk(t,r){return new la({message:new it({content:t}),text:t,generationInfo:r})}_currentResponse(){return this.responses[this.i]}_incrementResponse(){this.i<this.responses.length-1?this.i+=1:this.i=0}bindTools(t){let r=[...this.tools,...t],n=r.map(o=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:o.name,description:o.description,parameters:Et(o.schema)}};case"anthropic":return{name:o.name,description:o.description,input_schema:Et(o.schema)};case"bedrock":return{toolSpec:{name:o.name,description:o.description,inputSchema:Et(o.schema)}};case"google":return{name:o.name,description:o.description,parameters:Et(o.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),i=this.toolStyle==="google"?[{functionDeclarations:n}]:n,a=new pR({responses:this.responses,sleep:this.sleep,emitCustomEvent:this.emitCustomEvent,generationInfo:this.generationInfo});return a.tools=r,a.toolStyle=this.toolStyle,a.i=this.i,a.withConfig({tools:i})}withStructuredOutput(t,r){return qt.from(async n=>{let i=await this.invoke(n);if(i.tool_calls?.[0]?.args)return i.tool_calls[0].args;if(typeof i.content=="string")return JSON.parse(i.content);throw new Error("No structured output found")})}};var mR=class extends Vp{vectorSize;constructor(e){super(e??{}),this.vectorSize=e?.vectorSize??4}async embedDocuments(e){return Promise.all(e.map(t=>this.embedQuery(t)))}async embedQuery(e){let t=e;t=t.toLowerCase().replaceAll(/[^a-z ]/g,"");let r=t.length%this.vectorSize,n=r===0?0:this.vectorSize-r,i=t.length+n;t=t.padEnd(i," ");let a=t.length/this.vectorSize,o=[];for(let s=0;s<t.length;s+=a)o.push(t.slice(s,s+a));return o.map(s=>{let c=0;for(let l=0;l<s.length;l+=1)c+=s===" "?0:s.charCodeAt(l);return c%26/26})}},hR=class extends Vp{constructor(e){super(e??{})}embedDocuments(e){return Promise.resolve(e.map(()=>[.1,.2,.3,.4]))}embedQuery(e){return Promise.resolve([.1,.2,.3,.4])}};var gR=class extends im{response;thrownErrorString;constructor(e){super(e),this.response=e.response,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e,t,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let n=this.response??e;return await r?.handleLLMNewToken(n),n}},_R=class extends im{sleep=50;responses;thrownErrorString;constructor(e){super(e),this.sleep=e.sleep??this.sleep,this.responses=e.responses,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let t=this.responses?.[0];return this.responses=this.responses?.slice(1),t??e}async*_streamResponseChunks(e,t,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let n=this.responses?.[0];this.responses=this.responses?.slice(1);for(let i of n??e)await new Promise(a=>setTimeout(a,this.sleep)),yield{text:i,generationInfo:{}},await r?.handleLLMNewToken(i)}};var yR=class extends jw{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async addUserMessage(e){this.messages.push(new ot(e))}async addAIMessage(e){this.messages.push(new Ne(e))}async clear(){this.messages=[]}},vR=class extends Bp{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async addMessage(e){this.messages.push(e)}async getMessages(){return this.messages}},bR=class extends Dt{name="fake_tracer";runs=[];constructor(){super()}persistRun(e){return this.runs.push(e),Promise.resolve()}};var wR=class extends yn{lc_namespace=["tests","fake"];getFormatInstructions(){return""}async parse(e){return e.split(",").map(t=>t.trim())}};var xR=class extends nu{lc_namespace=["test","fake"];output=[new Fr({pageContent:"foo"}),new Fr({pageContent:"bar"})];constructor(e){super(),this.output=e?.output??this.output}async _getRelevantDocuments(e){return this.output}};var SR=class extends se{lc_namespace=["tests","fake"];returnOptions;constructor(e){super(e),this.returnOptions=e.returnOptions}async invoke(e,t){return this.returnOptions?t??{}:{input:e}}};var kR=class extends Tu{name;description;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.schema=e.schema}async _call(e,t){return JSON.stringify(e)}};var $R=class extends Dt{runPromiseResolver;runPromise;name="single_run_extractor";constructor(){super(),this.runPromise=new Promise(e=>{this.runPromiseResolver=e})}async persistRun(e){this.runPromiseResolver(e)}async extract(){return this.runPromise}};var ER=class IR extends eh{memoryVectors=[];similarity;_vectorstoreType(){return"memory"}constructor(t,{similarity:r,...n}={}){super(t,n),this.similarity=r??qm}async addDocuments(t){let r=t.map(({pageContent:n})=>n);return this.addVectors(await this.embeddings.embedDocuments(r),t)}async addVectors(t,r){let n=t.map((i,a)=>({content:r[a].pageContent,embedding:i,metadata:r[a].metadata}));this.memoryVectors=this.memoryVectors.concat(n)}async similaritySearchVectorWithScore(t,r,n){let i=o=>n?n(new Fr({metadata:o.metadata,pageContent:o.content})):!0,a=this.memoryVectors.filter(i);return a.map((o,s)=>({similarity:this.similarity(t,o.embedding),index:s})).sort((o,s)=>o.similarity>s.similarity?-1:0).slice(0,r).map(o=>[new Fr({metadata:a[o.index].metadata,pageContent:a[o.index].content}),o.similarity])}static async fromTexts(t,r,n,i){let a=[];for(let o=0;o<t.length;o+=1){let s=Array.isArray(r)?r[o]:r,c=new Fr({pageContent:t[o],metadata:s});a.push(c)}return IR.fromDocuments(a,n,i)}static async fromDocuments(t,r,n){let i=new this(r,n);return await i.addDocuments(t),i}static async fromExistingIndex(t,r){return new this(t,r)}};var TR=T({FakeChatMessageHistory:()=>yR,FakeChatModel:()=>lR,FakeEmbeddings:()=>hR,FakeLLM:()=>gR,FakeListChatMessageHistory:()=>vR,FakeListChatModel:()=>fR,FakeRetriever:()=>xR,FakeRunnable:()=>SR,FakeSplitIntoListParser:()=>wR,FakeStreamingChatModel:()=>uR,FakeStreamingLLM:()=>_R,FakeTool:()=>kR,FakeTracer:()=>bR,FakeVectorStore:()=>ER,SingleRunExtractor:()=>$R,SyntheticEmbeddings:()=>mR,asAsyncIterable:()=>mm,openAIReasoningTextChunks:()=>gm,openAITextOnlyChunks:()=>lu,openAITextOnlyChunksWithUsage:()=>hm,openAIToolCallChunks:()=>_m,sseResponseFromOpenAIChunks:()=>ym,streamMatchers:()=>fc});var CR=T({agents:()=>Ok,caches:()=>M$,callbacks__base:()=>U$,callbacks__manager:()=>DI,callbacks__promises:()=>RI,chat_history:()=>EO,document_loaders__base:()=>CO,document_loaders__langsmith:()=>AO,documents:()=>TO,embeddings:()=>OO,errors:()=>Mk,example_selectors:()=>LO,index:()=>Ak,indexing:()=>VO,language_models__base:()=>XO,language_models__chat_models:()=>CP,language_models__compat:()=>EP,language_models__event:()=>OP,language_models__llms:()=>PP,language_models__openai_completions_stream:()=>AP,language_models__profile:()=>RP,language_models__stream:()=>bP,language_models__structured_output:()=>yP,load__serializable:()=>wk,memory:()=>MP,messages:()=>$O,messages__tool:()=>r$,output_parsers:()=>mP,output_parsers__openai_functions:()=>zP,output_parsers__openai_tools:()=>UP,outputs:()=>eT,prompt_values:()=>ZO,prompts:()=>YP,retrievers:()=>eN,retrievers__document_compressors:()=>QP,runnables:()=>rP,runnables__graph:()=>eO,singletons:()=>VI,stores:()=>tN,structured_query:()=>cN,testing:()=>gN,tools:()=>j1,tracers__base:()=>kI,tracers__console:()=>EI,tracers__log_stream:()=>QI,tracers__run_collector:()=>L1,tracers__tracer_langchain:()=>AI,types__stream:()=>F1,utils__async_caller:()=>oT,utils__chunk_array:()=>B1,utils__context:()=>V1,utils__env:()=>Sk,utils__event_source_parse:()=>Z1,utils__format:()=>J1,utils__function_calling:()=>K1,utils__hash:()=>Pk,utils__json_patch:()=>nP,utils__json_schema:()=>WA,utils__math:()=>Q1,utils__ssrf:()=>tR,utils__standard_schema:()=>fT,utils__stream:()=>ZI,utils__testing:()=>TR,utils__tiktoken:()=>KO,utils__types:()=>hP,utils__uuid:()=>pk,vectorstores:()=>cR});var AV=50;function OV(e){let t={};for(let r=e;r&&r.prototype;r=Object.getPrototypeOf(r))Object.assign(t,Reflect.get(r.prototype,"lc_aliases"));return Object.entries(t).reduce((r,[n,i])=>(r[i]=n,r),{})}async function th(e){let{optionalImportsMap:t,optionalImportEntrypoints:r,importMap:n,secretsMap:i,secretsFromEnv:a,path:o,depth:s,maxDepth:c}=this,l=o.join(".");if(s>c)throw new Error(`Maximum recursion depth (${c}) exceeded during deserialization. This may indicate a malicious payload or you may need to increase maxDepth.`);if(typeof e!="object"||e==null)return e;if(Array.isArray(e))return Promise.all(e.map((f,p)=>th.call({...this,path:[...o,`${p}`],depth:s+1},f)));let u=e;if(rg(u))return sd(u);if("lc"in u&&"type"in u&&"id"in u&&u.lc===1&&u.type==="secret"){let[f]=u.id;if(f in i)return i[f];if(a){let p=ar(f);if(p)return p}throw new Error(`Missing secret "${f}" at ${l}`)}if("lc"in u&&"type"in u&&"id"in u&&u.lc===1&&u.type==="not_implemented"){let f=JSON.stringify(u);throw new Error(`Trying to load an object that doesn't implement serialization: ${l} -> ${f}`)}if("lc"in u&&"type"in u&&"id"in u&&"kwargs"in u&&u.lc===1&&u.type==="constructor"){let f=u,p=JSON.stringify(f),[m,...h]=f.id.slice().reverse(),_=h.reverse(),y={langchain_core:CR,langchain:n},w=null,x=[_.join("/")];_[0]==="langchain_community"&&x.push(["langchain",..._.slice(1)].join("/"));let S=x.find(C=>C in t);if(Ck.concat(r).includes(_.join("/"))||S)if(S!==void 0)w=await t[S];else throw new Error(`Missing key "${_.join("/")}" for ${l} in load(optionalImportsMap={})`);else{let C;if(_[0]==="langchain"||_[0]==="langchain_core")C=y[_[0]],_.shift();else throw new Error(`Invalid namespace: ${l} -> ${p}`);if(_.length===0)throw new Error(`Invalid namespace: ${l} -> ${p}`);let b;do{if(b=_.join("__"),b in C)break;_.pop()}while(_.length>0);b in C&&(w=C[b])}if(typeof w!="object"||w===null)throw new Error(`Invalid namespace: ${l} -> ${p}`);let $=w[m]??Object.values(w).find(C=>typeof C=="function"&&ns(C)===m);if(typeof $!="function")throw new Error(`Invalid identifer: ${l} -> ${p}`);let P=new $(ad(await th.call({...this,path:[...o,"kwargs"],depth:s+1},f.kwargs),yk,OV($)));return Object.defineProperty(P.constructor,"name",{value:m}),P}let d={};for(let[f,p]of Object.entries(u))d[f]=await th.call({...this,path:[...o,f],depth:s+1},p);return d}async function AR(e,t){let r=JSON.parse(e),n={optionalImportsMap:t?.optionalImportsMap??{},optionalImportEntrypoints:t?.optionalImportEntrypoints??[],secretsMap:t?.secretsMap??{},secretsFromEnv:t?.secretsFromEnv??!1,importMap:t?.importMap??{},path:["$"],depth:0,maxDepth:t?.maxDepth??AV};return th.call(n,r)}function PV(e){return e!==null&&e.lc===1&&e.type==="constructor"&&Array.isArray(e.id)}async function W0(e){if(e&&typeof e=="object"){if(Array.isArray(e))return await Promise.all(e.map(t=>W0(t)));{let t={};for(let[r,n]of Object.entries(e))t[r]=await W0(n);if(t.lc===2&&t.type==="undefined")return;if(t.lc===2&&t.type==="delta_snapshot")return new ts(t.value);if(t.lc===2&&t.type==="constructor"&&Array.isArray(t.id))try{let r=t.id[t.id.length-1],n;switch(r){case"Set":n=Set;break;case"Map":n=Map;break;case"RegExp":n=RegExp;break;case"Error":n=Error;break;case"Uint8Array":n=Uint8Array;break;default:return t}return t.method?n[t.method](...t.args||[]):new n(...t.args||[])}catch{return t}else if(PV(t))return AR(JSON.stringify(t));return t}}return e}function rh(e,t,r,n){return{lc:2,type:"constructor",id:[e.name],method:t??null,args:r??[],kwargs:n??{}}}function NV(e){return e===void 0?{lc:2,type:"undefined"}:e instanceof ts?{lc:2,type:"delta_snapshot",value:e.value}:e instanceof Set||e instanceof Map?rh(e.constructor,void 0,[Array.from(e)]):e instanceof RegExp?rh(RegExp,void 0,[e.source,e.flags]):e instanceof Error?rh(e.constructor,void 0,[e.message]):e?.lg_name==="Send"?{node:e.node,args:e.args,...e.timeout!==void 0?{timeout:e.timeout}:{}}:e instanceof Uint8Array?rh(Uint8Array,"from",[Array.from(e)]):e}var nh=class{_dumps(e){return new TextEncoder().encode(hk(e,(t,r)=>NV(r)))}async dumpsTyped(e){return e instanceof Uint8Array?["bytes",e]:["json",this._dumps(e)]}async _loads(e){return W0(JSON.parse(e))}async loadsTyped(e,t){if(e==="bytes")return typeof t=="string"?new TextEncoder().encode(t):t;if(e==="json")return this._loads(typeof t=="string"?t:new TextDecoder().decode(t));throw new Error(`Unknown serialization type: ${e}`)}};function J0(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[]:{};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=J0(e[r]));return t}function Go(){return{v:4,id:Vc(0),ts:new Date().toISOString(),channel_values:{},channel_versions:{},versions_seen:{}}}function wn(e){return{v:e.v,id:e.id,ts:e.ts,channel_values:{...e.channel_values??{}},channel_versions:{...e.channel_versions??{}},versions_seen:J0(e.versions_seen??{})}}var ih=class{serde=new nh;constructor(e){this.serde=e||this.serde}toJSON(){return`[${this.constructor.name}]`}async get(e){let t=await this.getTuple(e);return t?t.checkpoint:void 0}async getDeltaChannelHistory(e){let{config:t,channels:r}=e;if(r.length===0)return{};let n={},i={},a=new Set(r);for(let c of r)n[c]=[];let o=(await this.getTuple(t))?.parentConfig;for(;o!=null&&a.size>0;){let c=await this.getTuple(o);if(c===void 0)break;if(c.pendingWrites&&c.pendingWrites.length>0){let l={};for(let u of c.pendingWrites){let d=u[1];a.has(d)&&(l[d]??=[]).push(u)}for(let u of Object.keys(l)){let d=l[u];d.sort((f,p)=>f[0]<p[0]?-1:f[0]>p[0]?1:0);for(let f=d.length-1;f>=0;f-=1)n[u].push(d[f])}}for(let l of Array.from(a))Object.prototype.hasOwnProperty.call(c.checkpoint.channel_values,l)&&(i[l]=c.checkpoint.channel_values[l],a.delete(l));o=c.parentConfig}let s={};for(let c of r){let l={writes:n[c].slice().reverse()};Object.prototype.hasOwnProperty.call(i,c)&&(l.seed=i[c]),s[c]=l}return s}getNextVersion(e){if(typeof e=="string")throw new Error("Please override this method to use string versions.");return e!==void 0&&typeof e=="number"?e+1:1}};function ah(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):String(e).localeCompare(String(t))}function Cu(...e){return e.reduce((t,r,n)=>n===0?r:ah(t,r)>=0?t:r)}var Au={[qh]:-1,[Ja]:-2,[Xh]:-3,[Yh]:-4},K0=new Set(["thread_id","checkpoint_id","checkpoint_ns","checkpoint_map","langgraph_step","langgraph_node","langgraph_triggers","langgraph_path","langgraph_checkpoint_ns"]);function oh(e){return e.configurable?.checkpoint_id||e.configurable?.thread_ts||""}var RV=new Set(["__proto__","constructor","prototype"]);function Ut(e,t,r={}){let{allowEmpty:n=!1}=r;if(typeof t!="string"){let i=t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t;throw new Error(`Invalid configurable value for key "${e}": expected a string identifier (got ${i}). This guard protects MemorySaver from prototype pollution.`)}if(!n&&t==="")throw new Error(`Invalid configurable value for key "${e}": empty string is not permitted as an in-memory storage key.`);if(RV.has(t))throw new Error(`Invalid configurable value for key "${e}": value "${t}" is reserved (would mutate Object.prototype). This guard protects MemorySaver from prototype pollution.`)}function wc(e,t,r){return JSON.stringify([e,t,r])}function MV(e){let[t,r,n]=JSON.parse(e);return{threadId:t,checkpointNamespace:r,checkpointId:n}}var OR=class extends ih{storage=Object.create(null);writes=Object.create(null);constructor(e){super(e)}async _migratePendingSends(e,t,r,n){let i=e,a=wc(t,r,n),o=await Promise.all(Object.values(this.writes[a]??{}).filter(([s,c])=>c===Zc).map(async([s,c,l])=>await this.serde.loadsTyped("json",l)));i.channel_values??={},i.channel_values[Zc]=o,i.channel_versions??={},i.channel_versions[Zc]=Object.keys(i.channel_versions).length>0?Cu(...Object.values(i.channel_versions)):this.getNextVersion(void 0)}async getTuple(e){let t=e.configurable?.thread_id,r=e.configurable?.checkpoint_ns??"",n=oh(e);if(t!==void 0&&Ut("thread_id",t),Ut("checkpoint_ns",r,{allowEmpty:!0}),n&&Ut("checkpoint_id",n),n){let i=this.storage[t]?.[r]?.[n];if(i!==void 0){let[a,o,s]=i,c=wc(t,r,n),l=await this.serde.loadsTyped("json",a);l.v<4&&s!==void 0&&await this._migratePendingSends(l,t,r,s);let u=await Promise.all(Object.values(this.writes[c]||{}).map(async([f,p,m])=>[f,p,await this.serde.loadsTyped("json",m)])),d={config:e,checkpoint:l,metadata:await this.serde.loadsTyped("json",o),pendingWrites:u};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}else{let i=this.storage[t]?.[r];if(i!==void 0){n=Object.keys(i).sort((f,p)=>p.localeCompare(f))[0];let[a,o,s]=i[n],c=wc(t,r,n),l=await this.serde.loadsTyped("json",a);l.v<4&&s!==void 0&&await this._migratePendingSends(l,t,r,s);let u=await Promise.all(Object.values(this.writes[c]||{}).map(async([f,p,m])=>[f,p,await this.serde.loadsTyped("json",m)])),d={config:{configurable:{thread_id:t,checkpoint_id:n,checkpoint_ns:r}},checkpoint:l,metadata:await this.serde.loadsTyped("json",o),pendingWrites:u};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}}async*list(e,t){let{before:r,limit:n,filter:i}=t??{};e.configurable?.thread_id!==void 0&&Ut("thread_id",e.configurable.thread_id),e.configurable?.checkpoint_ns!==void 0&&Ut("checkpoint_ns",e.configurable.checkpoint_ns,{allowEmpty:!0}),e.configurable?.checkpoint_id&&Ut("checkpoint_id",e.configurable.checkpoint_id),r?.configurable?.checkpoint_id&&Ut("checkpoint_id",r.configurable.checkpoint_id);let a=e.configurable?.thread_id?[e.configurable?.thread_id]:Object.keys(this.storage),o=e.configurable?.checkpoint_ns,s=e.configurable?.checkpoint_id;for(let c of a)for(let l of Object.keys(this.storage[c]??{})){if(o!==void 0&&l!==o)continue;let u=this.storage[c]?.[l]??{},d=Object.entries(u).sort((f,p)=>p[0].localeCompare(f[0]));for(let[f,[p,m,h]]of d){if(s&&f!==s||r&&r.configurable?.checkpoint_id&&f>=r.configurable.checkpoint_id)continue;let _=await this.serde.loadsTyped("json",m);if(i&&!Object.entries(i).every(([P,C])=>_[P]===C))continue;if(n!==void 0){if(n<=0)break;n-=1}let y=wc(c,l,f),w=Object.values(this.writes[y]||{}),x=await Promise.all(w.map(async([P,C,b])=>[P,C,await this.serde.loadsTyped("json",b)])),S=await this.serde.loadsTyped("json",p);S.v<4&&h!==void 0&&await this._migratePendingSends(S,c,l,h);let $={config:{configurable:{thread_id:c,checkpoint_ns:l,checkpoint_id:f}},checkpoint:S,metadata:_,pendingWrites:x};h!==void 0&&($.parentConfig={configurable:{thread_id:c,checkpoint_ns:l,checkpoint_id:h}}),yield $}}}async put(e,t,r){let n=wn(t),i=e.configurable?.thread_id,a=e.configurable?.checkpoint_ns??"";if(i===void 0)throw new Error('Failed to put checkpoint. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property. When using a checkpointer, you must pass a "thread_id" so the checkpointer knows which conversation thread to persist state for. Example: graph.stream(input, { configurable: { thread_id: "my-thread-id" } })');Ut("thread_id",i),Ut("checkpoint_ns",a,{allowEmpty:!0}),Ut("checkpoint_id",t.id),this.storage[i]||(this.storage[i]=Object.create(null)),this.storage[i][a]||(this.storage[i][a]=Object.create(null));let[[,o],[,s]]=await Promise.all([this.serde.dumpsTyped(n),this.serde.dumpsTyped(r)]);return this.storage[i][a][t.id]=[o,s,e.configurable?.checkpoint_id],{configurable:{thread_id:i,checkpoint_ns:a,checkpoint_id:t.id}}}async putWrites(e,t,r){let n=e.configurable?.thread_id,i=e.configurable?.checkpoint_ns,a=e.configurable?.checkpoint_id;if(n===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property. When using a checkpointer, you must pass a "thread_id" so the checkpointer knows which conversation thread to persist state for. Example: graph.stream(input, { configurable: { thread_id: "my-thread-id" } })');if(a===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "checkpoint_id" field in its "configurable" property.');Ut("thread_id",n),Ut("checkpoint_ns",i,{allowEmpty:!0}),Ut("checkpoint_id",a),Ut("task_id",r);let o=wc(n,i,a),s=this.writes[o];this.writes[o]===void 0&&(this.writes[o]=Object.create(null)),await Promise.all(t.map(async([c,l],u)=>{let[,d]=await this.serde.dumpsTyped(l),f=[r,Au[c]||u],p=`${f[0]},${f[1]}`;f[1]>=0&&s&&p in s||(this.writes[o][p]=[r,c,d])}))}async deleteThread(e){Ut("thread_id",e),delete this.storage[e];for(let t of Object.keys(this.writes))MV(t).threadId===e&&delete this.writes[t]}async getDeltaChannelHistory(e){let{config:t,channels:r}=e;if(r.length===0)return{};let n=t.configurable?.thread_id,i=t.configurable?.checkpoint_ns??"",a=oh(t);n!==void 0&&Ut("thread_id",n),Ut("checkpoint_ns",i,{allowEmpty:!0});let o=this.storage[n]?.[i]??{},s=[],c=(a?o[a]:void 0)?.[2];for(;c!==void 0;){let p=o[c];if(p===void 0)break;s.push(c),c=p[2]}let l={},u={},d=new Set(r);for(let p of r)l[p]=[];for(let p of s){if(d.size===0)break;let m=o[p],h=m!==void 0?await this.serde.loadsTyped("json",m[0]):void 0,_={},y=new Set;if(h!==void 0)for(let S of d)Object.prototype.hasOwnProperty.call(h.channel_values,S)&&h.channel_values[S]!==void 0&&(_[S]=h.channel_values[S],y.add(S));let w=wc(n,i,p),x=Object.entries(this.writes[w]??{});x.sort(([S],[$])=>{let[P,C]=S.split(","),[b,B]=$.split(",");return P!==b?P<b?1:-1:Number(B)-Number(C)});for(let[,[S,$,P]]of x)d.has($)&&l[$].push([S,$,await this.serde.loadsTyped("json",P)]);for(let S of y)u[S]=_[S],d.delete(S)}let f={};for(let p of r){let m={writes:l[p].slice().reverse()};Object.prototype.hasOwnProperty.call(u,p)&&(m.seed=u[p]),f[p]=m}return f}};var xc=class extends Error{constructor(e){super(e),this.name="InvalidNamespaceError"}};function jV(e){if(e.length===0)throw new xc("Namespace cannot be empty.");for(let t of e){if(typeof t!="string")throw new xc(`Invalid namespace label '${t}' found in ${e}. Namespace labels must be strings, but got ${typeof t}.`);if(t.includes("."))throw new xc(`Invalid namespace label '${t}' found in ${e}. Namespace labels cannot contain periods ('.').`);if(t==="")throw new xc(`Namespace labels cannot be empty strings. Got ${t} in ${e}`)}if(e[0]==="langgraph")throw new xc(`Root label for namespace cannot be "langgraph". Got: ${e}`)}var Sc=class{async get(e,t){return(await this.batch([{namespace:e,key:t}]))[0]}async search(e,t={}){let{filter:r,limit:n=10,offset:i=0,query:a}=t;return(await this.batch([{namespacePrefix:e,filter:r,limit:n,offset:i,query:a}]))[0]}async put(e,t,r,n){jV(e),await this.batch([{namespace:e,key:t,value:r,index:n}])}async delete(e,t){await this.batch([{namespace:e,key:t,value:null}])}async listNamespaces(e={}){let{prefix:t,suffix:r,maxDepth:n,limit:i=100,offset:a=0}=e,o=[];return t&&o.push({matchType:"prefix",path:t}),r&&o.push({matchType:"suffix",path:r}),(await this.batch([{matchConditions:o.length?o:void 0,maxDepth:n,limit:i,offset:a}]))[0]}start(){}stop(){}};var DV=e=>"lg_name"in e&&e.lg_name==="AsyncBatchedStore"?e.store:e,sh=class extends Sc{lg_name="AsyncBatchedStore";store;queue=new Map;nextKey=0;running=!1;processingTask=null;constructor(e){super(),this.store=DV(e)}get isRunning(){return this.running}async batch(e){throw new Error("The `batch` method is not implemented on `AsyncBatchedStore`.\n Instead, it calls the `batch` method on the wrapped store.\n If you are seeing this error, something is wrong.")}async get(e,t){return this.enqueueOperation({namespace:e,key:t})}async search(e,t){let{filter:r,limit:n=10,offset:i=0,query:a}=t||{};return this.enqueueOperation({namespacePrefix:e,filter:r,limit:n,offset:i,query:a})}async put(e,t,r){return this.enqueueOperation({namespace:e,key:t,value:r})}async delete(e,t){return this.enqueueOperation({namespace:e,key:t,value:null})}start(){this.running||(this.running=!0,this.processingTask=this.processBatchQueue())}async stop(){this.running=!1,this.processingTask&&await this.processingTask}enqueueOperation(e){return new Promise((t,r)=>{let n=this.nextKey;this.nextKey+=1,this.queue.set(n,{operation:e,resolve:t,reject:r})})}async processBatchQueue(){for(;this.running;){if(await new Promise(t=>{setTimeout(t,0)}),this.queue.size===0)continue;let e=new Map(this.queue);this.queue.clear();try{let t=Array.from(e.values()).map(({operation:n})=>n),r=await this.store.batch(t);e.forEach(({resolve:n},i)=>{n(r[Array.from(e.keys()).indexOf(i)])})}catch(t){e.forEach(({reject:r})=>{r(t)})}}}toJSON(){return{queue:this.queue,nextKey:this.nextKey,running:this.running,store:"[LangGraphStore]"}}};function Ou(e){if(!e)return[];let t=[],r=[],n=0;for(;n<e.length;){let i=e[n];if(i==="["){r.length&&(t.push(r.join("")),r=[]);let a=1,o=["["];for(n+=1;n<e.length&&a>0;)e[n]==="["?a+=1:e[n]==="]"&&(a-=1),o.push(e[n]),n+=1;t.push(o.join(""));continue}else if(i==="{"){r.length&&(t.push(r.join("")),r=[]);let a=1,o=["{"];for(n+=1;n<e.length&&a>0;)e[n]==="{"?a+=1:e[n]==="}"&&(a-=1),o.push(e[n]),n+=1;t.push(o.join(""));continue}else i==="."?r.length&&(t.push(r.join("")),r=[]):r.push(i);n+=1}return r.length&&t.push(r.join("")),t}function zV(e){return typeof e=="object"&&e!==null&&Object.keys(e).every(t=>t==="$eq"||t==="$ne"||t==="$gt"||t==="$gte"||t==="$lt"||t==="$lte"||t==="$in"||t==="$nin")}function PR(e,t){return zV(t)?Object.keys(t).filter(r=>r.startsWith("$")).every(r=>{let n=t[r];switch(r){case"$eq":return e===n;case"$ne":return e!==n;case"$gt":return Number(e)>Number(n);case"$gte":return Number(e)>=Number(n);case"$lt":return Number(e)<Number(n);case"$lte":return Number(e)<=Number(n);case"$in":return Array.isArray(n)?n.includes(e):!1;case"$nin":return Array.isArray(n)?!n.includes(e):!0;default:return!1}}):e===t}function NR(e,t){if(!t||t==="$")return[JSON.stringify(e,null,2)];let r=Array.isArray(t)?t:Ou(t);function n(i,a,o){if(o>=a.length)return typeof i=="string"||typeof i=="number"||typeof i=="boolean"?[String(i)]:i==null?[]:Array.isArray(i)||typeof i=="object"?[JSON.stringify(i,null,2)]:[];let s=a[o],c=[];if(o===0&&s==="$"&&c.push(JSON.stringify(i,null,2)),s.startsWith("[")&&s.endsWith("]")){if(!Array.isArray(i))return[];let l=s.slice(1,-1);if(l==="*")for(let u of i)c.push(...n(u,a,o+1));else try{let u=parseInt(l,10);u<0&&(u=i.length+u),u>=0&&u<i.length&&c.push(...n(i[u],a,o+1))}catch{return[]}}else if(s.startsWith("{")&&s.endsWith("}")){if(typeof i!="object"||i===null)return[];let l=s.slice(1,-1).split(",").map(u=>u.trim());for(let u of l){let d=Ou(u);if(d.length){let f=i;for(let p of d)if(f&&typeof f=="object"&&p in f)f=f[p];else{f=void 0;break}f!==void 0&&(typeof f=="string"||typeof f=="number"||typeof f=="boolean"?c.push(String(f)):(Array.isArray(f)||typeof f=="object")&&c.push(JSON.stringify(f,null,2)))}}}else if(s==="*"){if(Array.isArray(i))for(let l of i)c.push(...n(l,a,o+1));else if(typeof i=="object"&&i!==null)for(let l of Object.values(i))c.push(...n(l,a,o+1))}else typeof i=="object"&&i!==null&&s in i&&c.push(...n(i[s],a,o+1));return c}return n(e,r,0)}var RR=class extends Sc{data=new Map;vectors=new Map;_indexConfig;constructor(e){super(),e?.index&&(this._indexConfig={...e.index,__tokenizedFields:(e.index.fields??["$"]).map(t=>[t,t==="$"?[t]:Ou(t)])})}async batch(e){let t=[],r=new Map,n=new Map;for(let i=0;i<e.length;i+=1){let a=e[i];if("key"in a&&"namespace"in a&&!("value"in a))t.push(this.getOperation(a));else if("namespacePrefix"in a){let o=this.filterItems(a);n.set(i,[a,o]),t.push(null)}else if("value"in a){let o=`${a.namespace.join(":")}:${a.key}`;r.set(o,a),t.push(null)}else"matchConditions"in a&&t.push(this.listNamespacesOperation(a))}if(n.size>0)if(this._indexConfig?.embeddings){let i=new Set;for(let[s]of n.values())s.query&&i.add(s.query);let a=i.size>0?await Promise.all(Array.from(i).map(s=>this._indexConfig.embeddings.embedQuery(s))):[],o=Object.fromEntries(Array.from(i).map((s,c)=>[s,a[c]]));for(let[s,[c,l]]of n.entries())if(c.query&&o[c.query]){let u=o[c.query];t[s]=this.scoreResults(l,u,c.offset??0,c.limit??10)}else t[s]=this.paginateResults(l.map(u=>({...u,score:void 0})),c.offset??0,c.limit??10)}else for(let[i,[a,o]]of n.entries())t[i]=this.paginateResults(o.map(s=>({...s,score:void 0})),a.offset??0,a.limit??10);if(r.size>0&&this._indexConfig?.embeddings){let i=this.extractTexts(Array.from(r.values()));if(Object.keys(i).length>0){let a=await this._indexConfig.embeddings.embedDocuments(Object.keys(i));this.insertVectors(i,a)}}for(let i of r.values())this.putOperation(i);return t}getOperation(e){let t=e.namespace.join(":");return this.data.get(t)?.get(e.key)??null}putOperation(e){let t=e.namespace.join(":");this.data.has(t)||this.data.set(t,new Map);let r=this.data.get(t);if(e.value===null)r.delete(e.key);else{let n=new Date;if(r.has(e.key)){let i=r.get(e.key);i.value=e.value,i.updatedAt=n}else r.set(e.key,{value:e.value,key:e.key,namespace:e.namespace,createdAt:n,updatedAt:n})}}listNamespacesOperation(e){let t=Array.from(this.data.keys()).map(r=>r.split(":"));return e.matchConditions&&e.matchConditions.length>0&&(t=t.filter(r=>e.matchConditions.every(n=>this.doesMatch(n,r)))),e.maxDepth!==void 0&&(t=Array.from(new Set(t.map(r=>r.slice(0,e.maxDepth).join(":")))).map(r=>r.split(":"))),t.sort((r,n)=>r.join(":").localeCompare(n.join(":"))),t.slice(e.offset??0,(e.offset??0)+(e.limit??t.length))}doesMatch(e,t){let{matchType:r,path:n}=e;if(r==="prefix")return n.length>t.length?!1:n.every((i,a)=>{let o=t[a];return i==="*"||o===i});if(r==="suffix")return n.length>t.length?!1:n.every((i,a)=>{let o=t[t.length-n.length+a];return i==="*"||o===i});throw new Error(`Unsupported match type: ${r}`)}filterItems(e){let t=[];for(let[n,i]of this.data.entries())n.startsWith(e.namespacePrefix.join(":"))&&t.push(...i.values());let r=t;return e.filter&&(r=t.filter(n=>Object.entries(e.filter).every(([i,a])=>PR(n.value[i],a)))),r}scoreResults(e,t,r=0,n=10){let i=[],a=[],o=[];for(let u of e){let d=this.getVectors(u);if(d.length)for(let f of d)i.push(u),a.push(f);else o.push(u)}let s=this.cosineSimilarity(t,a).map((u,d)=>[u,i[d]]).sort((u,d)=>d[0]-u[0]),c=new Set,l=[];for(let[u,d]of s){let f=`${d.namespace.join(":")}:${d.key}`;if(c.has(f))continue;let p=c.size;if(p>=r+n)break;if(p<r){c.add(f);continue}c.add(f),l.push([u,d])}if(o.length&&l.length<n)for(let u of o.slice(0,n-l.length)){let d=`${u.namespace.join(":")}:${u.key}`;c.has(d)||(c.add(d),l.push([void 0,u]))}return l.map(([u,d])=>({...d,score:u}))}paginateResults(e,t,r){return e.slice(t,t+r)}extractTexts(e){if(!e.length||!this._indexConfig)return{};let t={};for(let r of e)if(r.value!==null&&r.index!==!1){let n=r.index===null||r.index===void 0?this._indexConfig.__tokenizedFields??[]:r.index.map(i=>[i,Ou(i)]);for(let[i,a]of n){let o=NR(r.value,a);o.length&&(o.length>1?o.forEach((s,c)=>{t[s]||(t[s]=[]),t[s].push([r.namespace,r.key,`${i}.${c}`])}):(t[o[0]]||(t[o[0]]=[]),t[o[0]].push([r.namespace,r.key,i])))}}return t}insertVectors(e,t){for(let[r,n]of Object.entries(e)){let i=t.shift();if(!i)throw new Error(`No embedding found for text: ${r}`);for(let[a,o,s]of n){let c=a.join(":");this.vectors.has(c)||this.vectors.set(c,new Map);let l=this.vectors.get(c);l.has(o)||l.set(o,new Map),l.get(o).set(s,i)}}}getVectors(e){let t=e.namespace.join(":"),r=e.key;if(!this.vectors.has(t))return[];let n=this.vectors.get(t);if(!n.has(r))return[];let i=n.get(r),a=Array.from(i.values());return a.length?a:[]}cosineSimilarity(e,t){if(!t.length)return[];let r=t.map(a=>a.reduce((o,s,c)=>o+s*e[c],0)),n=Math.sqrt(e.reduce((a,o)=>a+o*o,0)),i=t.map(a=>Math.sqrt(a.reduce((o,s)=>o+s*s,0)));return r.map((a,o)=>{let s=i[o];return n&&s?a/(n*s):0})}get indexConfig(){return this._indexConfig}};var ch=class{serde=new nh;constructor(e){this.serde=e||this.serde}};var UV=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function nn(e){return e!=null&&e.lc_graph_name==="DeltaChannel"}function X0(e){return e!=null&&e.lg_is_channel===!0}var yt=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(e){if(e.name===je.unminifiable_name)return!1;throw e}}equals(e){return this===e}},q0=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function kc(e){if(e[q0]===!0)return e;let t={};for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let n=e[r];X0(n)&&(t[r]=n)}return Object.assign(t,{[q0]:!0}),t}function lh(e,t){let r=kc(e),n={};for(let i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;let a=t.channel_values[i];n[i]=r[i].fromCheckpoint(a)}return Object.assign(n,{[q0]:!0}),n}function Y0(e,t){if(!UV.test(t))throw new TypeError(`Invalid task id for exit delta: ${t}`);let r=t.toLowerCase().split("-");return`${String(e).padStart(8,"0")}-${r[1]}-${r[2]}-${r[3]}-${r[4]}`}function uh(e,t){let r=new Set,n=GS();for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let a=e[i];if(!nn(a)||!a.isAvailable())continue;let[o,s]=t[i]??[0,0];(o>=a.snapshotFrequency||s>=n)&&r.add(i)}return r}function xn(e,t,r,n){let i=n?.channelsToSnapshot??new Set,{updatedChannels:a,getNextVersion:o}=n??{},s,c=e.channel_versions;if(t===void 0)s=e.channel_values;else{s={},c={...e.channel_versions};for(let l in t){if(!Object.prototype.hasOwnProperty.call(t,l))continue;let u=t[l];if(i.has(l)){o!==void 0&&(a===void 0||!a.has(l))&&(c[l]=o(c[l])),s[l]=new ts(u.get());continue}if(!nn(u))try{s[l]=u.checkpoint()}catch(d){if(d.name!==je.unminifiable_name)throw d}}}return{v:4,id:n?.id??Vc(r),ts:new Date().toISOString(),channel_values:s,channel_versions:c,versions_seen:e.versions_seen}}async function $c(e,t,r){let n=lh(e,t),{saver:i,config:a}=r??{},o=kc(e),s=[];for(let l in o)Object.prototype.hasOwnProperty.call(o,l)&&nn(o[l])&&!Object.prototype.hasOwnProperty.call(t.channel_values,l)&&s.push(l);if(s.length===0||i===void 0||a===void 0)return n;let c=await i.getDeltaChannelHistory({config:a,channels:s});for(let l of s){let u=c[l];if(u===void 0)continue;let d=o[l].fromCheckpoint(u.seed);d.replayWrites(u.writes),n[l]=d}return n}var LV=e=>e!=null&&e.lc_graph_name==="BinaryOperatorAggregate",Pi=class MR extends yt{lc_graph_name="BinaryOperatorAggregate";value;operator;initialValueFactory;constructor(t,r){super(),this.operator=t,this.initialValueFactory=r,this.value=r?.()}fromCheckpoint(t){let r=new MR(this.operator,this.initialValueFactory);return typeof t<"u"&&(r.value=t),r}update(t){let r=t;if(!r.length)return!1;if(this.value===void 0){let i=r[0],[a,o]=sn(i);a?this.value=o:this.value=i,r=r.slice(1)}let n=!1;for(let i of r)if(Za(i)){if(n)throw new ve("Can receive only one Overwrite value per step.");let[,a]=sn(i);this.value=a,n=!0;continue}else!n&&this.value!==void 0&&(this.value=this.operator(this.value,i));return!0}get(){if(this.value===void 0)throw new je;return this.value}checkpoint(){if(this.value===void 0)throw new je;return this.value}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:LV(t)?this.operator===t.operator:!1}};var Sn=class jR extends yt{lc_graph_name="LastValue";value=[];constructor(t){super(),this.initialValueFactory=t,t&&(this.value=[t()])}fromCheckpoint(t){let r=new jR(this.initialValueFactory);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0)return!1;if(t.length!==1)throw new ve("LastValue can only receive one value per step.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new je;return this.value[0]}checkpoint(){if(this.value.length===0)throw new je;return this.value[0]}isAvailable(){return this.value.length!==0}},Q0=class DR extends yt{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint(t){let r=new DR;if(typeof t<"u"){let[n,i]=t;r.value=[n],r.finished=i}return r}update(t){return t.length===0?!1:(this.finished=!1,this.value=[t[t.length-1]],!0)}get(){if(this.value.length===0||!this.finished)throw new je;return this.value[0]}checkpoint(){if(this.value.length!==0)return[this.value[0],this.finished]}consume(){return this.finished?(this.finished=!1,this.value=[],!0):!1}finish(){return!this.finished&&this.value.length>0?(this.finished=!0,!0):!1}isAvailable(){return this.value.length!==0&&this.finished}};var dh=class{lc_graph_name="AnnotationRoot";spec;constructor(e){this.spec=e}static isInstance(e){return typeof e=="object"&&e!==null&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot"}},Pu=function(e){return e?fh(e):new Sn};Pu.Root=e=>new dh(e);function fh(e){return typeof e=="object"&&e&&"reducer"in e&&e.reducer?new Pi(e.reducer,e.default):typeof e=="object"&&e&&"value"in e&&e.value?new Pi(e.value,e.default):new Sn}var FV=["tags","metadata","callbacks","configurable"],BV=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal","heartbeat","executionInfo","serverInfo","control"],VV=25,ZV=new Set(["thread_id","checkpoint_id","checkpoint_ns","task_id","run_id","assistant_id","graph_id"]);function HV(e,t){if(!e)return t;let r=t??{};for(let n of ZV){if(n in r)continue;let i=e[n];i!==void 0&&(r[n]=i)}return r}function zR(e){if(e==null||e.length===0)return;let t=e.filter(r=>!r.startsWith("seq:step"));return t.length>0?t:void 0}function GV(e,t){if(t===void 0)return e;if(e===void 0)return Array.isArray(t)?[...t]:t.copy();if(Array.isArray(t)){if(Array.isArray(e))return e.concat(t);let r=e.copy();for(let n of t)r.addHandler(gi(n),!0);return r}if(Array.isArray(e)){let r=t.copy();for(let n of e)r.addHandler(gi(n),!0);return r}return new Xe(t._parentRunId,{handlers:e.handlers.concat(t.handlers),inheritableHandlers:e.inheritableHandlers.concat(t.inheritableHandlers),tags:Array.from(new Set(e.tags.concat(t.tags))),inheritableTags:Array.from(new Set(e.inheritableTags.concat(t.inheritableTags))),metadata:{...e.metadata,...t.metadata},inheritableMetadata:{...e.inheritableMetadata,...t.inheritableMetadata}})}function WV(e){let t;for(let a=e.length-1;a>=0;a-=1)if(e[a]!==void 0){t=e[a];break}let r=t?.configurable?.thread_id!==void 0,n=e.some(a=>a?.configurable?.[er]!==void 0),i=Re.getRunnableConfig()?.configurable?.[er]!==void 0;return r&&!n&&!i}function Ec(...e){let t={tags:[],metadata:{},callbacks:void 0,recursionLimit:VV,configurable:{}},r=WV(e),n=Re.getRunnableConfig();if(n!==void 0){for(let[i,a]of Object.entries(n))if(a!==void 0){if(i==="configurable"&&r)continue;if(FV.includes(i)){let o;Array.isArray(a)?o=[...a]:typeof a=="object"?i==="callbacks"&&"copy"in a&&typeof a.copy=="function"?o=a.copy():o={...a}:o=a,t[i]=o}else t[i]=a}}for(let i of e)if(i!==void 0)for(let[a,o]of Object.entries(i))o===void 0||!BV.includes(a)||(a==="configurable"?t.configurable={...t.configurable,...o}:a==="metadata"?t.metadata={...t.metadata,...o}:a==="tags"?t.tags=[...t.tags??[],...o]:a==="callbacks"?t.callbacks=GV(t.callbacks,o):t[a]=o);return t.metadata=HV(t.configurable,t.metadata)??{},t}function JV(e){let t=e??Re.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getStore` in such environment, pass the `config` from the node function directly."].join(`
430
+ `));return t?.store}function KV(e){let t=e??Re.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getWriter` in such environment, pass the `config` from the node function directly."].join(`
431
+ `));return t?.writer||t?.configurable?.writer}function ph(){return Re.getRunnableConfig()}function qV(e){let t=e??Re.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getCurrentTaskInput` in such environment, pass the `config` from the node function directly."].join(`
432
+ `));if(t.configurable?.__pregel_scratchpad?.currentTaskInput===void 0)throw new Error("BUG: internal scratchpad not initialized.");return t.configurable[tr].currentTaskInput}function mh(e){return e.split("|").filter(t=>!t.match(/^\d+$/)).map(t=>t.split(":")[0]).join("|")}function UR(e){let t=e.split("|");for(;t.length>1&&t[t.length-1].match(/^\d+$/);)t.pop();return t.slice(0,-1).join("|")}var eS=class{#e=void 0;requestDrain(e="shutdown"){this.#e=e}get drainRequested(){return this.#e!==void 0}get drainReason(){return this.#e}};var tS=["values","updates","messages","tools","custom","tasks"];function Ic(e){if(e==null||typeof e!="object")return!1;let t=e;return typeof t.id=="string"&&("source"in t||typeof t.step=="number")&&!("values"in t)&&!("config"in t)}function XV(e){if(!Array.isArray(e)||e.length!==2)return{data:e};let[t,r]=e;if(r==null||typeof r!="object")return{data:e};let n=r,i=typeof n.langgraph_node=="string"?n.langgraph_node:void 0,a=typeof n.run_id=="string"?n.run_id:void 0;return{data:a!=null&&t!=null&&typeof t=="object"?{...t,run_id:a}:t,node:i}}function rS({namespace:e,mode:t,payload:r,seq:n}){let i=Date.now(),a={type:"event"};switch(t){case"messages":{let{data:o,node:s}=XV(r);return[{...a,seq:n,method:"messages",params:{namespace:e,timestamp:i,...s?{node:s}:{},data:o}}]}case"tools":return[{...a,seq:n,method:"tools",params:{namespace:e,timestamp:i,data:YV(r)}}];case"checkpoints":return Ic(r)?[{...a,seq:n,method:"checkpoints",params:{namespace:e,timestamp:i,data:r}}]:[];case"values":return[{...a,seq:n,method:"values",params:{namespace:e,timestamp:i,data:r}}];case"updates":{let o=QV(r);return[{...a,seq:n,method:"updates",params:{namespace:e,timestamp:i,...typeof o.node=="string"?{node:o.node}:{},data:o}}]}case"custom":{let o=typeof r=="object"&&r!==null&&!Array.isArray(r)&&"name"in r?r:{payload:r};return[{...a,seq:n,method:"custom",params:{namespace:e,timestamp:i,data:o}}]}case"tasks":return[{...a,seq:n,method:"tasks",params:{namespace:e,timestamp:i,data:r}}];default:return[]}}function YV(e){if(typeof e!="object"||e===null)return{event:"tool-error",tool_call_id:"",message:"Unexpected tools payload shape"};let t=e,r=String(t.toolCallId??"");switch(t.event){case"on_tool_start":return{event:"tool-started",tool_call_id:r,tool_name:String(t.name??"unknown"),input:t.input};case"on_tool_event":return{event:"tool-output-delta",tool_call_id:r,delta:typeof t.data=="string"?t.data:JSON.stringify(t.data??"")};case"on_tool_end":return{event:"tool-finished",tool_call_id:r,output:t.output};case"on_tool_error":{let n=t.error;return{event:"tool-error",tool_call_id:r,message:typeof n=="object"&&n!==null&&"message"in n&&typeof n.message=="string"?n.message:String(n??"unknown error")}}default:return{event:"tool-error",tool_call_id:"",message:`Unknown tool event: ${String(t.event)}`}}}function QV(e){if(typeof e!="object"||e===null)return{values:{}};let t=Object.entries(e);if(t.length===0)return{values:{}};let[r,n]=t[0];return{node:r,values:typeof n=="object"&&n!==null?n:{value:n}}}var nS=Symbol.for("langgraph.stream_channel"),an=class iS{[nS]=!0;channelName;#e=[];#t=[];#n=!1;#a;#i;constructor(t){this.channelName=t}static local(){return new iS}static remote(t){return new iS(t)}static isInstance(t){return typeof t=="object"&&t!==null&&nS in t&&t[nS]===!0}push(t){this.#e.push(t),this.#r(),this.#i?.(t)}iterate(t=0){let r=t;return{next:async()=>{for(;;){if(r<this.#e.length)return{value:this.#e[r++],done:!1};if(this.#n){if(this.#a)throw this.#a;return{value:void 0,done:!0}}await new Promise(n=>this.#t.push(n))}}}}toAsyncIterable(t=0){return{[Symbol.asyncIterator]:()=>this.iterate(t)}}toEventStream(t={}){let r=new TextEncoder,n=this.iterate(t.startAt),i=t.event??this.channelName,a=t.serialize??(o=>JSON.stringify(o)??"null");return new ReadableStream({async pull(o){try{let s=await n.next();if(s.done){o.close();return}let c=[];i!=null&&c.push(`event: ${i}`);for(let l of a(s.value).split(/\r\n|\r|\n/))c.push(`data: ${l}`);o.enqueue(r.encode(`${c.join(`
433
+ `)}
434
+
435
+ `))}catch(s){o.error(s)}},async cancel(){await n.return?.()}})}get(t){if(t<0||t>=this.#e.length)throw new RangeError(`StreamChannel index ${t} out of bounds (size=${this.#e.length})`);return this.#e[t]}get size(){return this.#e.length}get done(){return this.#n}close(){this.#n=!0,this.#r()}fail(t){this.#a=t,this.#n=!0,this.#r()}_wire(t){this.#i=t}_close(){this.close()}_fail(t){this.fail(t)}[Symbol.asyncIterator](){return this.iterate()}#r(){let t=this.#t.splice(0);for(let r of t)r()}};function LR(e){return an.isInstance(e)}var e9="custom:";function t9(e){return`${e9}${e}`}function r9(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}var hh=Symbol("resolveValues"),aS=Symbol("rejectValues"),FR=class{_events=an.local();_discoveries=an.local();#e=0;#t=!1;#n;#a=!1;#i=[];#r=[];#s=[];#o=new Map;#l=new Map;#c=[];#u=[];register(e,t){this.#o.set(vt(e),t)}addTransformer(e){let t=this._events.size;this.#r.push(e),e.onRegister&&e.onRegister({push:(r,n)=>this.push(r,n)});for(let r=0;r<t;r+=1)e.process(this._events.get(r));this.#t&&(this.#n!==void 0?e.fail?.(this.#n):e.finalize?.())}wireChannels(e){for(let[t,r]of Object.entries(e)){if(LR(r)){if(this.#s.push(r),typeof r.channelName!="string")continue;let n=t9(r.channelName);r._wire(i=>{this._events.push({type:"event",seq:this.#e++,method:n,params:{namespace:this.#i,timestamp:Date.now(),data:i}})});continue}r9(r)&&this.#u.push({name:t,promise:Promise.resolve(r)})}}push(e,t){t.method==="values"&&this.#l.set(vt(e),t.params.data);let r=this.#i;this.#i=e;let n=!0;for(let i of this.#r)i.process(t)||(n=!1);this.#i=r,n&&this._events.push({...t,seq:this.#e++})}close(){this.#t=!0;for(let[r,n]of this.#l.entries()){let i=r?r.split("\0"):[];this.#o.get(vt(i))?.[hh](n)}let e=[];for(let r of this.#r){let n=r.finalize?.();n!=null&&typeof n.then=="function"&&e.push(n)}for(let r of this.#s)r._close();let t=this.#u;t.length===0&&e.length===0?(this._events.close(),this._discoveries.close()):Promise.allSettled([...e,...t.map(async({name:r,promise:n})=>{try{let i=await n;this._events.done||this._events.push({type:"event",seq:this.#e++,method:"custom",params:{namespace:[],timestamp:Date.now(),data:{name:r,payload:i}}})}catch{}})]).then(()=>{this._events.close(),this._discoveries.close()});for(let r of this.#o.values())r[hh](void 0)}fail(e){this.#t=!0,this.#n=e;for(let t of this.#r)t.fail?.(e);for(let t of this.#s)t._fail(e);this._events.fail(e),this._discoveries.fail(e);for(let t of this.#o.values())t[aS](e)}markInterrupted(e){this.#a=!0,this.#c.push(...e)}get interrupted(){return this.#a}get interrupts(){return this.#c}subscribeEvents(e,t=0){let r=this._events.iterate(t);return{async next(){for(;;){let n=await r.next();if(n.done||ni(n.value.params.namespace,e))return n}}}}};async function BR(e,t){let r=0;try{for await(let n of e){let[i,a,o]=n;if(a==="values"&&Ha(o)){let c=o[Le];t.markInterrupted(c.map(l=>({interruptId:l.id??"",payload:l.value})))}let s=rS({namespace:i,mode:a,payload:o,seq:r});r+=s.length;for(let c of s)t.push(i,c)}}catch(n){t.fail(n);return}t.close()}function vt(e){return e.join("\0")}function ni(e,t){if(t.length>e.length)return!1;for(let r=0;r<t.length;r+=1)if(e[r]!==t[r])return!1;return!0}function gh(e,t,r=0){return{[Symbol.asyncIterator](){let n=e.iterate(r);return{async next(){for(;;){let i=await n.next();if(i.done)return{value:void 0,done:!0};if(ni(i.value.namespace,t))return{value:i.value,done:!1}}}}}}}var VR="root";function n9(e){if(e.length===0)return VR;let t=e[e.length-1],r=t.indexOf(":");return r===-1?t:t.slice(0,r)}function i9(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function ii(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function a9(e){if(!ii(e)||e.event!=="started")return;let t=e.cause;if(ii(t)&&typeof t.type=="string")return t}function o9(e){if(ii(e)&&"result"in e&&typeof e.name=="string"&&typeof e.id=="string"&&!e.name.startsWith("__"))return{name:e.name,id:e.id}}function oS(e={}){let t=e.rootGraphName??VR,r=e.initialStatus??"running",n=e.emitRootOnRegister??!0,i=e.getGraphName??n9,a=e.serializeError??i9,o=e.getTerminalStatusOverride,s=an.local(),c=new Map,l=new Map,u=new Map,d=new Map,f=new Set,p=[],m,h=0,_=!1,y=V=>{if(V.length===0)return t;let Y=u.get(vt(V));return typeof Y=="string"&&Y.length>0?Y:i(V)},w=(V,Y)=>{let ne=vt(V);if(u.has(ne))return;let ie=(ii(Y)&&ii(Y.metadata)?Y.metadata:void 0)?.lc_agent_name;u.set(ne,typeof ie=="string"?ie:void 0)},x=V=>{if(!ii(V))return;let Y=V.id;if(typeof Y!="string")return;let ne=V.input,ie;if(ii(ne)&&ii(ne.tool_call)){let Te=ne.tool_call.id;typeof Te=="string"&&(ie=Te)}else if(Array.isArray(ne)){for(let Te of ne)if(ii(Te)&&typeof Te.id=="string"){ie=Te.id;break}}ie!=null&&d.set(Y,ie)},S=V=>{if(V.length===0)return;let Y=u.get(vt(V));if(typeof Y!="string"||Y.length===0)return;let ne=V[V.length-1],ie=ne.indexOf(":");if(ie===-1)return;let Te=ne.slice(ie+1);if(Te.length===0)return;let Tr=d.get(Te);if(!(typeof Tr!="string"||Tr.length===0))return{type:"toolCall",tool_call_id:Tr}},$=V=>l.get(vt(V))??S(V),P=(V,Y,ne)=>{let ie=vt(V),Te=c.get(ie),Tr=Te?.graphName??y(V);if(Te!=null&&Te.status===Y&&Te.graphName===Tr&&ne?.error==null)return;Te==null?(Te={namespace:V,graphName:Tr,status:Y},c.set(ie,Te)):Te.status=Y;let Li={event:Y,graph_name:Tr,...ne?.cause!=null?{cause:ne.cause}:{},...ne?.error!=null?{error:ne.error}:{}},Fi=Date.now();if(s.push({namespace:V,timestamp:Fi,...Li}),!(V.length===0&&!n)&&m!=null){h+=1;try{m.push(V,{type:"event",seq:0,method:"lifecycle",params:{namespace:V,timestamp:Fi,data:Li}})}finally{h-=1}}},C=V=>{let Y=vt(V),ne=c.get(Y);return ne==null&&(ne={namespace:V,graphName:y(V),status:void 0},c.set(Y,ne)),ne},b=()=>{if(p.length===0)return;let V=p.splice(0,p.length);for(let Y of V){let ne=vt(Y.namespace),ie=c.get(ne);ie==null||ie.status!=="started"||P(Y.namespace,"completed")}},B=V=>{let Y=vt(V.namespace),ne=c.get(Y);ne==null||ne.status!=="started"||p.some(ie=>vt(ie.namespace)===Y)||p.push(V)},L=(V,Y)=>{for(let ne=p.length-1;ne>=0;ne-=1){let ie=p[ne];ie.source.type==="node"&&ie.source.node===Y&&vt(ie.source.parent)===vt(V)&&p.splice(ne,1)}},q=V=>{for(let Y=1;Y<=V.length;Y+=1){let ne=V.slice(0,Y),ie=vt(ne);if(c.has(ie))continue;C(ne);let Te=$(ne);P(ne,"started",Te!=null?{cause:Te}:void 0)}},ae=()=>f.size>0?"interrupted":"completed",Se=V=>{for(let Y of c.values())Y.namespace.length!==0&&Y.status==="started"&&P(Y.namespace,V);P([],V),s.close()},Oe=async()=>{if(o==null)return ae();try{return await o()??ae()}catch{return ae()}},mt=(V,Y)=>{let ne=`${Y}:`;for(let ie of c.values()){if(ie.namespace.length!==V.length+1||ie.status!=="started"||!ni(ie.namespace,V))continue;let Te=ie.namespace[ie.namespace.length-1];if(Te===Y||Te.startsWith(ne))return ie.namespace}},ye=(V,Y)=>{let ne=[...V,`${Y.name}:${Y.id}`];return c.get(vt(ne))?.status==="started"?ne:void 0};return{__native:!0,init(){return{_lifecycleLog:s,lifecycle:gh(s,[],0)}},onRegister(V){m=V,C([]),n&&P([],r)},process(V){let Y=V.params.namespace;if(h>0)return!0;let ne=V.method==="tasks"?o9(V.params.data):void 0;if(ne!=null?L(Y,ne.name):V.method==="tasks"&&(w(Y,V.params.data),x(V.params.data)),b(),V.method==="lifecycle"){let ie=a9(V.params.data);return ie!=null&&l.set(vt(Y),ie),q(Y),!1}if(q(Y),V.method==="input"&&ii(V.params.data)&&V.params.data.event==="requested"){let ie=V.params.data.id;typeof ie=="string"&&f.add(ie)}if(ne!=null){let ie=ye(Y,ne);ie!=null&&B({namespace:ie,source:{type:"task"}})}if(V.method==="updates"){let ie=V.params.node;if(typeof ie=="string"&&!ie.startsWith("__")){let Te=mt(Y,ie);Te!=null&&B({namespace:Te,source:{type:"node",parent:Y,node:ie}})}}return!0},finalize(){if(!_){if(_=!0,b(),o==null){Se(ae());return}return Oe().then(Se).catch(V=>{s.fail(V)})}},fail(V){if(_)return;_=!0;let Y=a(V);for(let ne of c.values())ne.namespace.length!==0&&ne.status==="started"&&P(ne.namespace,"failed");P([],"failed",{error:Y}),s.fail(V)}}}function Tc(e){let t=e;return typeof t.run_id=="string"?`run:${t.run_id}`:e.event==="message-start"&&typeof t.id=="string"?`message:${t.id}`:"__default__"}function Nu(e,t){let r=an.local(),n=new Map,i=new Set;return{init:()=>({messages:r.toAsyncIterable()}),process(a){if(a.method!=="messages"||!ni(a.params.namespace,e)||a.params.namespace.length!==e.length+1||t!==void 0&&a.params.node!==t)return!0;let o=a.params.data;switch(o.event){case"message-start":{let s=Tc(o);if(o.role==="tool"){i.add(s);break}let c=an.local(),l=Object.assign(new Ca(c.toAsyncIterable()),{namespace:a.params.namespace,node:a.params.node});n.set(s,{source:c,stream:l}),c.push(o),r.push(l);break}case"content-block-start":case"content-block-delta":case"content-block-finish":if(i.has(Tc(o)))break;n.get(Tc(o))?.source.push(o);break;case"message-finish":{let s=Tc(o);if(i.delete(s))break;let c=n.get(s);c&&(c.source.push(o),c.source.close(),n.delete(s));break}case"error":if(i.has(Tc(o)))break;n.get(Tc(o))?.source.push(o);break}return!0},finalize(){for(let[a,o]of n)o.source.push({event:"message-finish"}),o.source.close(),n.delete(a);i.clear(),r.close()},fail(a){for(let[o,s]of n)s.source.fail(a),n.delete(o);i.clear(),r.fail(a)}}}function Ru(e,t,r=0){let n=t.length+1;return{[Symbol.asyncIterator](){let i=e.iterate(r);return{async next(){for(;;){let a=await i.next();if(a.done)return{value:void 0,done:!0};let{ns:o,stream:s}=a.value;if(o.length===n&&ni(o,t))return{value:s,done:!1}}}}}}}function sS(e,t){let{createStream:r}=t,n=new Set;return{__native:!0,init(){return{_discoveries:e._discoveries,subgraphs:Ru(e._discoveries,[],0)}},process(i){let a=i.params.namespace;if(a.length===0)return!0;let o=a.slice(0,1),s=vt(o);if(n.has(s))return!0;n.add(s);let c=r(o,e._discoveries.size,e._events.size);return e.register(o,c),e._discoveries.push({ns:o,stream:c}),!0}}}function cS(e){let t=an.local();return{init:()=>({_valuesLog:t}),process(r){return r.method!=="values"||r.params.namespace.length!==e.length||!ni(r.params.namespace,e)||t.push(r.params.data),!0},finalize(){t.close()},fail(r){t.fail(r)}}}function _h(e){return"__native"in e&&e.__native===!0}var ZR=Symbol("setValuesLog"),HR=Symbol("setMessagesIterable"),lS=Symbol("setLifecycleIterable"),uS=Symbol("setSubgraphsIterable"),s9={[Symbol.asyncIterator](){return{next:()=>Promise.resolve({value:void 0,done:!0})}}},dS=class{path;extensions;_mux;#e;#t;#n;#a;#i;#r;#s;#o;#l;#c;constructor(e,t,r=0,n=0,i,a){this.path=e,this._mux=t,this.#t=r,this.#e=n,this.extensions=i??{},this.#n=a??new AbortController,this.#r=new Promise((o,s)=>{this.#a=o,this.#i=s}),this.#r.catch(()=>{})}[Symbol.asyncIterator](){return this._mux.subscribeEvents(this.path,this.#e)}get subgraphs(){return this.#c?this.#c:Ru(this._mux._discoveries,this.path,this.#t)}get values(){let e=this.#s,t=this.#r,r=this._mux,n=this.#e,i=this.path,a=e?e.toAsyncIterable():{[Symbol.asyncIterator]:()=>{let o=r.subscribeEvents(i,n);return{async next(){for(;;){let s=await o.next();if(s.done)return{value:void 0,done:!0};if(s.value.method==="values"&&s.value.params.namespace.length===i.length)return{value:s.value.params.data,done:!1}}}}}};return{[Symbol.asyncIterator]:()=>a[Symbol.asyncIterator](),then:t.then.bind(t)}}get messages(){if(this.#o)return this.#o;let e=Nu(this.path),t=e.init();return this._mux.addTransformer(e),this.#o=t.messages,this.#o}get lifecycle(){return this.#l??s9}messagesFrom(e){let t=Nu(this.path,e),r=t.init();return this._mux.addTransformer(t),r.messages}get output(){return this.#r}get interrupted(){return this._mux.interrupted}get interrupts(){return this._mux.interrupts}abort(e){this.#n.abort(e)}get signal(){return this.#n.signal}[hh](e){this.#a?.(e),this.#a=void 0}[aS](e){this.#i?.(e),this.#i=void 0}[ZR](e){this.#s=e}[HR](e){this.#o=e}[lS](e){this.#l=e}[uS](e){this.#c=e}},GR=class extends dS{name;index;constructor(e,t,r=0,n=0,i,a){super(e,t,r,n,i,a);let o=e[e.length-1]??"",s=o.lastIndexOf(":");if(s>=0){this.name=o.slice(0,s);let c=o.slice(s+1);this.index=/^\d+$/.test(c)?Number(c):0}else this.name=o,this.index=0}};function fS(e,t=[],r){let{abortController:n}=r instanceof AbortController?{abortController:r}:r??{},i=new FR,a=oS(),o=a.init(),s=o._lifecycleLog,c=sS(i,{createStream:(y,w,x)=>{let S=new GR(y,i,w,x);return S[uS](Ru(i._discoveries,y,w)),S[lS](gh(s,y,s.size)),S}}),l=c.init();i.addTransformer(c),i.addTransformer(a);let u=cS([]),d=Nu([]);i.addTransformer(u),i.addTransformer(d);let f={},p=[];for(let y of t){let w=y();i.addTransformer(w);let x=w.init();_h(w)?p.push(x):Object.assign(f,x),typeof x=="object"&&x!==null&&!_h(w)&&i.wireChannels(x)}let m=new dS([],i,0,0,f,n);for(let y of p)Object.assign(m,y);let h=u.init();m[ZR](h._valuesLog);let _=d.init();return m[HR](_.messages),m[lS](o.lifecycle),m[uS](l.subgraphs),i.register([],m),BR(e,i).catch(y=>{}),m}var F=e=>BigInt(e),Ve=(e,t=0)=>new DataView(e.buffer,e.byteOffset+t,e.byteLength-t),qR=F("0x9E3779B1"),XR=F("0x85EBCA77"),c9=F("0xC2B2AE3D"),Oa=F("0x9E3779B185EBCA87"),Wo=F("0xC2B2AE3D27D4EB4F"),YR=F("0x165667B19E3779F9"),hS=F("0x85EBCA77C2B2AE63"),l9=F("0x27D4EB2F165667C5"),u9=F("0x165667919E3779F9"),d9=F("0x9FB21C651E98DF25"),f9=e=>{let t=e.length;if(t%2!==0)throw new Error("String should have an even number of characters");let r=t/2,n=new Uint8Array(r),i=0,a=0;for(;a<r;){let o=e.slice(i,i+=2);n[a]=Number.parseInt(o,16),a+=1}return Ve(n)},ai=f9("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),Cc=(F(1)<<F(128))-F(1),xe=(F(1)<<F(64))-F(1),wh=(F(1)<<F(32))-F(1),Ni=64,QR=Ni/8,p9=8,yh=4;function Ac(e){if(!e)throw new Error("Assert failed")}function m9(e){let t=new DataView(new ArrayBuffer(8));return t.setBigUint64(0,e,!0),t.getBigUint64(0,!1)}function h9(e){let t=e;return t=(t&F(65535))<<F(16)|(t&F(4294901760))>>F(16),t=(t&F(16711935))<<F(8)|(t&F(4278255360))>>F(8),t}function g9(e,t){return(e&wh)*(t&wh)&xe}function _9(e,t){return(e<<t|e>>F(32)-t)&wh}function eM(e,t,r){for(let n=0;n<QR;n+=1){let i=t.getBigUint64(n*8,!0),a=i^r.getBigUint64(n*8,!0);e[n^1]+=i,e[n]+=g9(a,a>>F(32))}return e}function WR(e,t,r,n){for(let i=0;i<n;i+=1)eM(e,Ve(t,i*Ni),Ve(r,i*8));return e}function y9(e,t){for(let r=0;r<QR;r+=1){let n=t.getBigUint64(r*8,!0),i=e[r];i=pS(i,F(47)),i^=n,i*=qR,e[r]=i&xe}return e}function vh(e,t){return tM(e[0]^t.getBigUint64(0,!0),e[1]^t.getBigUint64(p9,!0))}function JR(e,t,r){let n=r;return n+=vh(e.slice(0),Ve(t,0*yh)),n+=vh(e.slice(2),Ve(t,4*yh)),n+=vh(e.slice(4),Ve(t,8*yh)),n+=vh(e.slice(6),Ve(t,12*yh)),oi(n&xe)}function v9(e,t,r,n,i){let a=e,o=Math.floor((r.byteLength-Ni)/8),s=Ni*o,c=Math.floor((t.byteLength-1)/s);for(let l=0;l<c;l+=1)a=WR(a,Ve(t,l*s),r,o),a=i(a,Ve(r,r.byteLength-Ni));{let l=Math.floor((t.byteLength-1-s*c)/Ni);a=WR(a,Ve(t,c*s),r,l),a=n(a,Ve(t,t.byteLength-Ni),Ve(r,r.byteLength-Ni-7))}return a}function b9(e,t){let r=new BigUint64Array([c9,Oa,Wo,YR,hS,XR,l9,qR]);Ac(e.byteLength>128),r=v9(r,e,t,eM,y9),Ac(r.length*8===64);{let n=JR(r,Ve(t,11),F(e.byteLength)*Oa&xe);return JR(r,Ve(t,t.byteLength-Ni-11),~(F(e.byteLength)*Wo)&xe)<<F(64)|n}}function tM(e,t){let r=e*t&Cc;return r&xe^r>>F(64)}function KR(e,t,r){return tM((e.getBigUint64(0,!0)^t.getBigUint64(0,!0)+r)&xe,(e.getBigUint64(8,!0)^t.getBigUint64(8,!0)-r)&xe)}function bh(e,t,r,n,i){let a=e&xe,o=e>>F(64)&xe;return a+=KR(t,n,i),a^=r.getBigUint64(0,!0)+r.getBigUint64(8,!0),a&=xe,o+=KR(r,Ve(n,16),i),o^=t.getBigUint64(0,!0)+t.getBigUint64(8,!0),o&=xe,o<<F(64)|a}function oi(e){let t=e;return t^=t>>F(37),t*=u9,t&=xe,t^=t>>F(32),t}function xh(e){let t=e;return t^=t>>F(33),t*=Wo,t&=xe,t^=t>>F(29),t*=YR,t&=xe,t^=t>>F(32),t}function w9(e,t,r){let n=e.byteLength;Ac(n>0&&n<=3);let i=F(e.getUint8(n-1))|F(n<<8)|F(e.getUint8(0)<<16)|F(e.getUint8(n>>1)<<24),a=(i^(F(t.getUint32(0,!0))^F(t.getUint32(4,!0)))+r)&xe,o=(F(t.getUint32(8,!0))^F(t.getUint32(12,!0)))-r;return(xh((_9(h9(i),F(13))^o)&xe)&xe)<<F(64)|xh(a)}function pS(e,t){return e^e>>t}function x9(e,t,r){let n=e.byteLength;Ac(n>=4&&n<=8);{let i=e.getUint32(0,!0),a=e.getUint32(n-4,!0),o=((F(i)|F(a)<<F(32))^(t.getBigUint64(16,!0)^t.getBigUint64(24,!0))+r&xe)*(Oa+(F(n)<<F(2)))&Cc;return o+=(o&xe)<<F(65),o&=Cc,o^=o>>F(67),pS(pS(o&xe,F(35))*d9&xe,F(28))|oi(o>>F(64))<<F(64)}}function S9(e,t,r){let n=e.byteLength;Ac(n>=9&&n<=16);{let i=(t.getBigUint64(32,!0)^t.getBigUint64(40,!0))+r&xe,a=(t.getBigUint64(48,!0)^t.getBigUint64(56,!0))-r&xe,o=e.getBigUint64(0,!0),s=e.getBigUint64(n-8,!0),c=(o^s^i)*Oa,l=(c&xe)+(F(n-1)<<F(54));c=c&(Cc^xe)|l,s^=a,c+=s+(s&wh)*(XR-F(1))<<F(64),c&=Cc,c^=m9(c>>F(64));let u=(c&xe)*Wo;return u+=(c>>F(64))*Wo<<F(64),u&=Cc,oi(u&xe)|oi(u>>F(64))<<F(64)}}function k9(e,t){let r=e.byteLength;return Ac(r<=16),r>8?S9(e,ai,t):r>=4?x9(e,ai,t):r>0?w9(e,ai,t):xh(t^ai.getBigUint64(64,!0)^ai.getBigUint64(72,!0))|xh(t^ai.getBigUint64(80,!0)^ai.getBigUint64(88,!0))<<F(64)}function mS(e){return~e+F(1)&xe}function $9(e,t,r){let n=F(e.byteLength)*Oa&xe,i=F(e.byteLength-1)/F(32);for(;i>=0;){let s=Number(i);n=bh(n,Ve(e,16*s),Ve(e,e.byteLength-16*(s+1)),Ve(t,32*s),r),i-=F(1)}let a=n+(n>>F(64))&xe;a=oi(a);let o=(n&xe)*Oa+(n>>F(64))*hS+(F(e.byteLength)-r&xe)*Wo;return o&=xe,o=mS(oi(o)),a|o<<F(64)}function E9(e,t,r){let n=F(e.byteLength)*Oa&xe;for(let o=32;o<160;o+=32)n=bh(n,Ve(e,o-32),Ve(e,o-16),Ve(t,o-32),r);n=oi(n&xe)|oi(n>>F(64))<<F(64);for(let o=160;o<=e.byteLength;o+=32)n=bh(n,Ve(e,o-32),Ve(e,o-16),Ve(t,3+o-160),r);n=bh(n,Ve(e,e.byteLength-16),Ve(e,e.byteLength-32),Ve(t,103),mS(r));let i=n+(n>>F(64))&xe;i=oi(i);let a=(n&xe)*Oa+(n>>F(64))*hS+(F(e.byteLength)-r&xe)*Wo;return a&=xe,a=mS(oi(a)),i|a<<F(64)}function si(e,t=F(0)){let r=new TextEncoder,n=Ve(typeof e=="string"?r.encode(e):e),i=n.byteLength,a=o=>o.toString(16).padStart(32,"0");return i<=16?a(k9(n,t)):i<=128?a($9(n,ai,t)):i<=240?a(E9(n,ai,t)):a(b9(n,ai))}function Sh(e){return/^[0-9a-f]{32}$/.test(e)}function gS(e){let t=Re.getRunnableConfig();if(!t)throw new Error("Called interrupt() outside the context of a graph.");let r=t.configurable;if(!r)throw new Error("No configurable found in config");if(!r.__pregel_checkpointer)throw new Ga("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=r[tr];n.interruptCounter+=1;let i=n.interruptCounter;if(n.resume.length>0&&i<n.resume.length)return r[Ft]?.([[rr,n.resume]]),n.resume[i];if(n.nullResume!==void 0){if(n.resume.length!==i)throw new Error(`Resume length mismatch: ${n.resume.length} !== ${i}`);let o=n.consumeNullResume();return n.resume.push(o),r[Ft]?.([[rr,n.resume]]),o}let a=r[Cr]?.split("|");throw new li([{id:a?si(a.join("|")):void 0,value:e}])}var Rt=class extends se{lc_namespace=["langgraph"];func;tags;config;trace=!0;recurse=!0;constructor(e){super(),this.name=e.name??e.func.name,this.func=e.func,this.config=e.tags?{tags:e.tags}:void 0,this.trace=e.trace??this.trace,this.recurse=e.recurse??this.recurse}async _tracedInvoke(e,t,r){return new Promise((n,i)=>{let a=Ee(t,{callbacks:r?.getChild()});Re.runWithConfig(a,async()=>{try{n(await this.func(e,a))}catch(o){i(o)}})})}async invoke(e,t){let r,n=Ec(t),i=$t(this.config,n);return this.trace?r=await this._callWithConfig(this._tracedInvoke,e,i):r=await Re.runWithConfig(i,async()=>this.func(e,i)),se.isRunnable(r)&&this.recurse?await Re.runWithConfig(i,async()=>r.invoke(e,i)):r}};function*ci(e,t){if(t===void 0)yield*e;else for(let r of e)yield[t,r]}async function kn(e){let t=[];for await(let r of await e)t.push(r);return t}function Pa(e){let t=[];for(let r of e)t.push(r);return t}function Jo(e,t){return e?"configurable"in e?{...e,configurable:{...e.configurable,...t}}:{...e,configurable:t}:{configurable:t}}function _S(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(async function*(){}).constructor}function yS(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(function*(){}).constructor}function I9(e){return typeof e=="object"&&e?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var Ir={[Symbol.for("LG_PASSTHROUGH")]:!0};function kh(e){return typeof e=="object"&&e?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var vS=Symbol("IS_WRITER"),ut=class wS extends Rt{writes;constructor(t,r){let n=`ChannelWrite<${t.map(i=>wt(i)?i.node:"channel"in i?i.channel:"...").join(",")}>`;super({writes:t,name:n,tags:r,trace:!1,func:async(i,a)=>this._write(i,a??{})}),this.writes=t}async _write(t,r){let n=this.writes.map(i=>bS(i)&&kh(i.value)?{mapper:i.mapper,value:t}:$h(i)&&kh(i.value)?{channel:i.channel,value:t,skipNone:i.skipNone,mapper:i.mapper}:i);return await wS.doWrite(r,n),t}static async doWrite(t,r){for(let a of r){if($h(a)){if(a.channel==="__pregel_tasks")throw new ve("Cannot write to the reserved channel TASKS");if(kh(a.value))throw new ve("PASSTHROUGH value must be replaced")}if(bS(a)&&kh(a.value))throw new ve("PASSTHROUGH value must be replaced")}let n=[];for(let a of r)if(wt(a))n.push([Rn,a]);else if(bS(a)){let o=await a.mapper.invoke(a.value,t);o!=null&&o.length>0&&n.push(...o)}else if($h(a)){let o=a.mapper!==void 0?await a.mapper.invoke(a.value,t):a.value;if(I9(o)||a.skipNone&&o===void 0)continue;n.push([a.channel,o])}else throw new Error(`Invalid write entry: ${JSON.stringify(a)}`);let i=t.configurable?.[Ft];i(n)}static isWriter(t){return t instanceof wS||vS in t&&!!t[vS]}static registerWriter(t){return Object.defineProperty(t,vS,{value:!0})}};function $h(e){return e!==void 0&&typeof e.channel=="string"}function bS(e){return e!==void 0&&!$h(e)&&se.isRunnable(e.mapper)}var rM=class nM extends Rt{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor(t,r,n=!1){super({trace:!1,func:(i,a)=>nM.doRead(a,this.channel,this.fresh,this.mapper)}),this.fresh=n,this.mapper=r,this.channel=t,this.name=Array.isArray(t)?`ChannelRead<${t.join(",")}>`:`ChannelRead<${t}>`}static doRead(t,r,n,i){let a=t.configurable?.[er];if(!a)throw new Error("Runnable is not configured with a read function. Make sure to call in the context of a Pregel process");return i?i(a(r,n)):a(r,n)}},Oc=new Ti,$n=class Mu extends Qr{lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=Oc;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;timeout;subgraphs;ends;isErrorHandler;errorHandlerNode;constructor(t){let{channels:r,triggers:n,mapper:i,writers:a,bound:o,kwargs:s,metadata:c,retryPolicy:l,cachePolicy:u,timeout:d,tags:f,subgraphs:p,ends:m,isErrorHandler:h,errorHandlerNode:_}=t,y=[...t.config?.tags?t.config.tags:[],...f??[]];super({...t,bound:t.bound??Oc,config:{...t.config?t.config:{},tags:y}}),this.channels=r,this.triggers=n,this.mapper=i,this.writers=a??this.writers,this.bound=o??this.bound,this.kwargs=s??this.kwargs,this.metadata=c??this.metadata,this.tags=y,this.retryPolicy=l,this.cachePolicy=u,this.timeout=d,this.subgraphs=p,this.ends=m,this.isErrorHandler=h,this.errorHandlerNode=_}getWriters(){let t=[...this.writers];for(;t.length>1&&t[t.length-1]instanceof ut&&t[t.length-2]instanceof ut;){let r=t.slice(-2),n=r[0].writes.concat(r[1].writes);t[t.length-2]=new ut(n,r[0].config?.tags),t.pop()}return t}getNode(){let t=this.getWriters();if(!(this.bound===Oc&&t.length===0))return this.bound===Oc&&t.length===1?t[0]:this.bound===Oc?new Lr({first:t[0],middle:t.slice(1,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):t.length>0?new Lr({first:this.bound,middle:t.slice(0,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):this.bound}join(t){if(!Array.isArray(t))throw new Error("channels must be a list");if(typeof this.channels!="object")throw new Error("all channels must be named when using .join()");return new Mu({channels:{...this.channels,...Object.fromEntries(t.map(r=>[r,r]))},triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound,kwargs:this.kwargs,config:this.config,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout})}pipe(t){return ut.isWriter(t)?new Mu({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:[...this.writers,t],bound:this.bound,config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout}):this.bound===Oc?new Mu({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:at(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout}):new Mu({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound.pipe(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout})}};function T9(e){return"steps"in e&&Array.isArray(e.steps)}function ju(e){return"lg_is_pregel"in e&&e.lg_is_pregel===!0}function Eh(e){let t=[e];for(let r of t){if(ju(r))return r;T9(r)&&t.push(...r.steps)}}function Ko(e,t,r=!0,n=!1){try{return e[t].get()}catch(i){if(i.name===je.unminifiable_name){if(n)return i;if(r)return null}throw i}}function En(e,t,r=!0){if(Array.isArray(t)){let n={};for(let i of t)try{n[i]=Ko(e,i,!r)}catch(a){if(a.name===je.unminifiable_name)continue}return n}else return Ko(e,t)}function*iM(e,t){if(e.graph===_r.PARENT)throw new ve("There is no parent graph.");if(e.goto){let r;Array.isArray(e.goto)?r=e.goto:r=[e.goto];for(let n of r)if(wt(n))yield[ir,Rn,n];else if(typeof n=="string")yield[ir,`branch:to:${n}`,"__start__"];else throw new Error(`In Command.send, expected Send or string, got ${typeof n}`)}if(e.resume)if(typeof e.resume=="object"&&Object.keys(e.resume).length&&Object.keys(e.resume).every(Sh))for(let[r,n]of Object.entries(e.resume)){let i=t.filter(a=>a[0]===r&&a[1]==="__resume__").map(a=>a[2]).slice(0,1)??[];i.push(n),yield[r,rr,i]}else yield[ir,rr,e.resume];if(e.update){if(typeof e.update!="object"||!e.update)throw new Error("Expected cmd.update to be a dict mapping channel names to update values");if(Array.isArray(e.update))for(let[r,n]of e.update)yield[ir,r,n];else for(let[r,n]of Object.entries(e.update))yield[ir,r,n]}}function*Ih(e,t){if(t!=null)if(Array.isArray(e)&&typeof t=="object"&&!Array.isArray(t))for(let r in t)e.includes(r)&&(yield[r,t[r]]);else{if(Array.isArray(e))throw new Error('Input chunk must be an object when "inputChannels" is an array');yield[e,t]}}function*Th(e,t,r){Array.isArray(e)?(t===!0||t.find(([n,i])=>e.includes(n)))&&(yield En(r,e)):(t===!0||t.some(([n,i])=>n===e))&&(yield Ko(r,e))}function*aM(e,t,r){let n=t.filter(([s,c])=>(s.config===void 0||!s.config.tags?.includes("langsmith:hidden"))&&c[0][0]!=="__error__"&&c[0][0]!=="__interrupt__");if(!n.length)return;let i;n.some(([s])=>s.writes.some(([c,l])=>c==="__return__"))?i=n.flatMap(([s])=>s.writes.filter(([c,l])=>c===Gi).map(([c,l])=>[s.name,l])):Array.isArray(e)?i=n.flatMap(([s])=>{let{writes:c}=s,l={};for(let[u]of c)e.includes(u)&&(l[u]=(l[u]||0)+1);return Object.values(l).some(u=>u>1)?c.filter(([u])=>e.includes(u)).map(([u,d])=>[s.name,{[u]:d}]):[[s.name,Object.fromEntries(c.filter(([u])=>e.includes(u)))]]}):i=n.flatMap(([s])=>s.writes.filter(([c,l])=>c===e).map(([c,l])=>[s.name,l]));let a={};for(let[s,c]of i)s in a||(a[s]=[]),a[s].push(c);let o={};for(let s in a)if(a[s].length===1){let[c]=a[s];o[s]=c}else o[s]=a[s];r&&(o.__metadata__={cached:r}),yield o}function Ch(e){let t=typeof e[Je];if(t==="number")return 0;if(t==="string")return"";for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let n=typeof e[r];if(n==="number")return 0;if(n==="string")return"";break}}function Pc(e,t){if(Object.keys(e).length>0){let r=Ch(t);return Object.fromEntries(Object.entries(t).filter(([n,i])=>i>(e[n]??r)))}else return t}function oM(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}function It(e,t){return e===null?{configurable:t}:e?.configurable===void 0?{...e,configurable:t}:{...e,configurable:{...e.configurable,...t}}}function Na(e,t){let r=t?.parents??{};return Object.keys(r).length>0?It(e,{[Bt]:{...r,[e.configurable?.checkpoint_ns??""]:e.configurable?.checkpoint_id}}):e}function Ra(...e){let t=[...new Set(e.filter(Boolean))];if(t.length===0)return{signal:void 0,dispose:void 0};if(t.length===1)return{signal:t[0],dispose:void 0};let r=new AbortController,n=()=>{let a=t.find(o=>o.aborted)?.reason;r.abort(a),t.forEach(o=>o.removeEventListener("abort",n))};t.forEach(a=>a.addEventListener("abort",n,{once:!0}));let i=t.find(a=>a.aborted);return i&&r.abort(i.reason),{signal:r.signal,dispose:()=>{t.forEach(a=>a.removeEventListener("abort",n))}}}var sM=class{func;name;input;retry;cache;timeout;callbacks;__lg_type="call";constructor({func:e,name:t,input:r,retry:n,cache:i,timeout:a,callbacks:o}){this.func=e,this.name=t,this.input=r,this.retry=n,this.cache=i,this.timeout=a,this.callbacks=o}};function cM(e){return typeof e=="object"&&e!==null&&"__lg_type"in e&&e.__lg_type==="call"}function lM(e,t){return new Lr({name:e,first:new Rt({func:r=>t(...r),name:e,trace:!1,recurse:!1}),last:new ut([{channel:Gi,value:Ir}],[ht])})}function uM(e,t){return new Rt({func:(r,n)=>t(r,n),name:e,trace:!1,recurse:!1})}function dM({func:e,name:t,cache:r,retry:n,timeout:i},...a){let o=Re.getRunnableConfig();if(typeof o.configurable?.__pregel_call=="function")return o.configurable[Nn](e,t,a,{retry:n,cache:r,timeout:i,callbacks:o.callbacks});throw new Error("Async local storage not initialized. Please call initializeAsyncLocalStorageSingleton() before using this function.")}var fM=e=>e!==void 0?e+1:1;function C9(e,t){if(t==null)return!1;for(let r of e)if(t[r])return!0;return!1}function A9(e){let t;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t==null?t=e[r]:t=Cu(t,e[r]));return t}function Du(e,t,r){let n=Ch(e.channel_versions),i=e.versions_seen.__interrupt__??{},a=!1;if((e.channel_versions.__start__??n)>(i.__start__??n))a=!0;else for(let s in e.channel_versions)if(Object.prototype.hasOwnProperty.call(e.channel_versions,s)&&e.channel_versions[s]>(i[s]??n)){a=!0;break}let o=r.some(s=>t==="*"?!s.config?.tags?.includes(ht):t.includes(s.name));return a&&o}function Nc(e,t,r,n,i=!1){let a=new Set;if(Array.isArray(n))a=new Set(n.filter(s=>r.writes.some(([c,l])=>c===s)));else{for(let[s]of r.writes)if(s===n){a=new Set([s]);break}a=a||new Set}let o;if(i&&a.size>0){let s=Object.fromEntries(Object.entries(t).filter(([d,f])=>a.has(d))),c=new Set;for(let d in s){if(!Object.prototype.hasOwnProperty.call(s,d))continue;let f=s[d];nn(f)&&f.isAvailable()&&c.add(d)}let l=xn(e,s,-1,{channelsToSnapshot:c}),u=lh(s,l);hr(wn(l),u,[r],void 0,void 0),o=En({...t,...u},n)}else o=En(t,n);return o}function Ah(e,t,r){for(let[n,i]of r)if(["__pregel_push","__pregel_tasks"].includes(n)&&i!=null){if(!wt(i))throw new ve(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(i)}`);if(!(i.node in t))throw new ve(`Invalid node name "${i.node}" in Send packet`)}e(r)}var O9=new Set([Uc,nr,rr,Le,Gi,Vi,jc]),P9=new Set(KS);function hr(e,t,r,n,i){let a=new Map;for(let m of r)a.set(m,m.path?.slice(0,3)||[]);r.sort((m,h)=>{let _=a.get(m),y=a.get(h);for(let w=0;w<Math.min(_.length,y.length);w+=1){if(_[w]<y[w])return-1;if(_[w]>y[w])return 1}return _.length-y.length});let o=kc(t),s=!1,c=new Set;for(let m of r){m.triggers.length>0&&(s=!0),e.versions_seen[m.name]??={};for(let h of m.triggers)h in e.channel_versions&&(e.versions_seen[m.name][h]=e.channel_versions[h]),P9.has(h)||c.add(h)}let l=A9(e.channel_versions),u=!1;for(let m of c)m in o&&o[m].consume()&&n!==void 0&&(e.channel_versions[m]=n(l),u=!0);let d={},f={};for(let m of r){let h=m.id??"";for(let[_,y]of m.writes)O9.has(_)||_ in o&&(d[_]??=[],d[_].push(y),f[_]??=[],f[_].push(h))}for(let[m,h]of Object.entries(d)){if(h.length<2||o[m]?.lc_graph_name!=="DeltaChannel")continue;let _=f[m],y=h.map((w,x)=>({val:w,taskId:_[x]}));y.sort((w,x)=>w.taskId<x.taskId?-1:w.taskId>x.taskId?1:0),d[m]=y.map(w=>w.val)}l!=null&&n!=null&&(l=u?n(l):l);let p=new Set;for(let[m,h]of Object.entries(d))if(m in o){let _=o[m],y;try{y=_.update(h)}catch(w){if(w.name===ve.unminifiable_name){let x=new ve(`Invalid update for channel "${m}" with values ${JSON.stringify(h)}: ${w.message}`);throw x.lc_error_code=w.lc_error_code,x}else throw w}y&&n!==void 0&&(e.channel_versions[m]=n(l),_.isAvailable()&&p.add(m))}if(s)for(let m in o){if(!Object.prototype.hasOwnProperty.call(o,m))continue;let h=o[m];h.isAvailable()&&!p.has(m)&&h.update([])&&n!==void 0&&(e.channel_versions[m]=n(l),h.isAvailable()&&p.add(m))}if(s&&!C9(p,i))for(let m in o){if(!Object.prototype.hasOwnProperty.call(o,m))continue;let h=o[m];h.finish()&&n!==void 0&&(e.channel_versions[m]=n(l),h.isAvailable()&&p.add(m))}return p}function*N9(e,t,r){if(r.updatedChannels!=null&&r.triggerToNodes!=null){let n=new Set;for(let i of r.updatedChannels){let a=r.triggerToNodes[i];for(let o of a??[])n.add(o)}yield*[...n].sort();return}if(!(()=>{for(let n in e.channel_versions)if(e.channel_versions[n]!==null)return!1;return!0})())for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(yield n)}function R9(e){let t,r=new Map,n=new Set;if(e)for(let[i,a,o]of e){if(i==="00000000-0000-0000-0000-000000000000"&&a==="__resume__"&&t===void 0&&(t=o),a==="__resume__"&&i!=="00000000-0000-0000-0000-000000000000"){let s=r.get(i);s||(s=[],r.set(i,s)),s.push(o)}a!=="__error__"&&n.add(i)}return{nullResume:t,resumeByTaskId:r,successfulWriteTaskIds:n}}function Ma(e,t,r,n,i,a,o){let s={},c=o.pendingWritesIndex?o:{...o,pendingWritesIndex:R9(t)},l=n[Rn];if(l?.isAvailable()){let u=l.get().length;for(let d=0;d<u;d+=1){let f=Ph([nr,d],e,t,r,n,i,a,c);f!==void 0&&(s[f.id]=f)}}for(let u of N9(e,r,c)){let d=Ph([Gu,u],e,t,r,n,i,a,c);d!==void 0&&(s[d.id]=d)}return s}function Ph(e,t,r,n,i,a,o,s){let{step:c,checkpointer:l,manager:u}=s,d=a.configurable??{},f=d.checkpoint_ns??"";if(e[0]==="__pregel_push"&&cM(e[e.length-1])){let p=e[e.length-1],m=lM(p.name,p.func),h=[nr],_=f===""?p.name:`${f}|${p.name}`,y=Mn(JSON.stringify([_,c.toString(),p.name,nr,e[1],e[2]]),t.id),w=`${_}:${y}`,x=[...e.slice(0,3),!0],S={langgraph_step:c,langgraph_node:p.name,langgraph_triggers:h,langgraph_path:x,langgraph_checkpoint_ns:w,checkpoint_ns:w};if(o){let $=[],P={checkpointId:t.id,checkpointNs:w,taskId:y,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:p.name,input:p.input,proc:m,writes:$,config:{...Ee($t(a,{metadata:S,store:s.store??a.store}),{runName:p.name,callbacks:u?.getChild(`graph:step:${c}`),configurable:{[Qo]:y,[Ft]:C=>Ah(b=>$.push(...b),n,C),[er]:(C,b=!1)=>Nc(t,i,{name:p.name,writes:$,triggers:h,path:x},C,b),[Vr]:l??d.__pregel_checkpointer,[Bt]:{...d[Bt],[f]:t.id},[tr]:Oh({pendingWrites:r??[],taskId:y,currentTaskInput:p.input,resumeMap:a.configurable?.[Va],namespaceHash:si(w),pendingWritesIndex:s.pendingWritesIndex}),[Zi]:t.channel_values[Wi],checkpoint_id:void 0,checkpoint_ns:w}}),executionInfo:P},triggers:h,retry_policy:p.retry,cache_key:p.cache?{key:si((p.cache.keyFunc??JSON.stringify)([p.input])),ns:[Zu,p.name??"__dynamic__"],ttl:p.cache.ttl}:void 0,id:y,path:x,writers:[],timeout:p.timeout}}else return{id:y,name:p.name,interrupts:[],path:x}}else if(e[0]==="__pregel_push"){let p=typeof e[1]=="number"?e[1]:parseInt(e[1],10);if(!i.__pregel_tasks?.isAvailable())return;let m=i[Rn].get();if(p<0||p>=m.length)return;let h=Wu(m[p])&&!wt(m[p])?new Fa(m[p].node,m[p].args,m[p].timeout!==void 0?{timeout:m[p].timeout}:void 0):m[p];if(!Wu(h)){console.warn(`Ignoring invalid packet ${JSON.stringify(h)} in pending sends.`);return}if(!(h.node in n)){console.warn(`Ignoring unknown node name ${h.node} in pending sends.`);return}let _=[nr],y=f===""?h.node:`${f}|${h.node}`,w=Mn(JSON.stringify([y,c.toString(),h.node,nr,p.toString()]),t.id),x=`${y}:${w}`,S={langgraph_step:c,langgraph_node:h.node,langgraph_triggers:_,langgraph_path:e.slice(0,3),langgraph_checkpoint_ns:x,checkpoint_ns:x};if(o){let $=n[h.node],P=$.getNode();if(P!==void 0){$.metadata!==void 0&&(S={...S,...$.metadata});let C=[],b={checkpointId:t.id,checkpointNs:x,taskId:w,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:h.node,input:h.args,proc:P,subgraphs:$.subgraphs,writes:C,config:{...Ee($t(a,{metadata:S,tags:$.tags,store:s.store??a.store}),{runName:h.node,callbacks:u?.getChild(`graph:step:${c}`),configurable:{[Qo]:w,[Ft]:B=>Ah(L=>C.push(...L),n,B),[er]:(B,L=!1)=>Nc(t,i,{name:h.node,writes:C,triggers:_,path:e},B,L),[Vr]:l??d.__pregel_checkpointer,[Bt]:{...d[Bt],[f]:t.id},[tr]:Oh({pendingWrites:r??[],taskId:w,currentTaskInput:h.args,resumeMap:a.configurable?.[Va],namespaceHash:si(x),pendingWritesIndex:s.pendingWritesIndex}),[Zi]:t.channel_values[Wi],checkpoint_id:void 0,checkpoint_ns:x}}),executionInfo:b},triggers:_,retry_policy:$.retryPolicy,cache_key:$.cachePolicy?{key:si(($.cachePolicy.keyFunc??JSON.stringify)([h.args])),ns:[Zu,$.name??"__dynamic__",h.node],ttl:$.cachePolicy.ttl}:void 0,id:w,path:e,writers:$.getWriters(),timeout:h.timeout??$.timeout}}}else return{id:w,name:h.node,interrupts:[],path:e}}else if(e[0]==="__pregel_pull"){let p=e[1].toString(),m=n[p];if(m===void 0)return;if(r?.length){let w=f===""?p:`${f}|${p}`,x=Mn(JSON.stringify([w,c.toString(),p,Gu,p]),t.id);if(s.pendingWritesIndex?s.pendingWritesIndex.successfulWriteTaskIds.has(x):r.some(S=>S[0]===x&&S[1]!=="__error__"))return}let h=Ch(t.channel_versions);if(h===void 0)return;let _=t.versions_seen[p]??{},y=m.triggers.find(w=>i[w].isAvailable()?(t.channel_versions[w]??h)>(_[w]??h):!1);if(y!==void 0){let w=M9(m,i,o);if(w===void 0)return;let x=f===""?p:`${f}|${p}`,S=Mn(JSON.stringify([x,c.toString(),p,Gu,[y]]),t.id),$=`${x}:${S}`,P={langgraph_step:c,langgraph_node:p,langgraph_triggers:[y],langgraph_path:e,langgraph_checkpoint_ns:$,checkpoint_ns:$};if(o){let C=m.getNode();if(C!==void 0){m.metadata!==void 0&&(P={...P,...m.metadata});let b=[],B={checkpointId:t.id,checkpointNs:$,taskId:S,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:p,input:w,proc:C,subgraphs:m.subgraphs,writes:b,config:{...Ee($t(a,{metadata:P,tags:m.tags,store:s.store??a.store}),{runName:p,callbacks:u?.getChild(`graph:step:${c}`),configurable:{[Qo]:S,[Ft]:L=>Ah(q=>{b.push(...q)},n,L),[er]:(L,q=!1)=>Nc(t,i,{name:p,writes:b,triggers:[y],path:e},L,q),[Vr]:l??d.__pregel_checkpointer,[Bt]:{...d[Bt],[f]:t.id},[tr]:Oh({pendingWrites:r??[],taskId:S,currentTaskInput:w,resumeMap:a.configurable?.[Va],namespaceHash:si($),pendingWritesIndex:s.pendingWritesIndex}),[Zi]:t.channel_values[Wi],checkpoint_id:void 0,checkpoint_ns:$}}),executionInfo:B},triggers:[y],retry_policy:m.retryPolicy,cache_key:m.cachePolicy?{key:si((m.cachePolicy.keyFunc??JSON.stringify)([w])),ns:[Zu,m.name??"__dynamic__",p],ttl:m.cachePolicy.ttl}:void 0,id:S,path:e,writers:m.getWriters(),timeout:m.timeout}}}else return{id:S,name:p,interrupts:[],path:e}}}}function pM(e,t,r,n,i,a,o,s,c){let{step:l,checkpointer:u,manager:d}=c,f=a[t];if(f===void 0)return;let p=f.getNode();if(p===void 0)return;let m=s.configurable??{},h=m.checkpoint_ns??"",_=[nr],y=h===""?t:`${h}|${t}`,w=Mn(JSON.stringify([y,l.toString(),t,nr,"node_error_handler",e.id]),n.id),x=`${y}:${w}`,S=[nr,String(e.name),t,!1],$={langgraph_step:l,langgraph_node:t,langgraph_triggers:_,langgraph_path:S,langgraph_checkpoint_ns:x,checkpoint_ns:x};f.metadata!==void 0&&($={...$,...f.metadata});let P=[],C={checkpointId:n.id,checkpointNs:x,taskId:w,threadId:m.thread_id,runId:s.runId!=null?String(s.runId):void 0,nodeAttempt:1};return{name:t,input:e.input,proc:p,subgraphs:f.subgraphs,writes:P,config:{...Ee($t(s,{metadata:$,tags:f.tags,store:c.store??s.store}),{runName:t,callbacks:d?.getChild(`graph:step:${l}`),configurable:{[Qo]:w,[Ft]:b=>Ah(B=>P.push(...B),a,b),[er]:(b,B=!1)=>Nc(n,o,{name:t,writes:P,triggers:_,path:S},b,B),[Vr]:u??m.__pregel_checkpointer,[Bt]:{...m[Bt],[h]:n.id},[tr]:Oh({pendingWrites:i??[],taskId:w,currentTaskInput:e.input,resumeMap:s.configurable?.[Va],namespaceHash:si(x)}),[Zi]:n.channel_values[Wi],[zc]:new Yu(String(e.name),r),checkpoint_id:void 0,checkpoint_ns:x}}),executionInfo:C},triggers:_,retry_policy:f.retryPolicy,cache_key:void 0,id:w,path:S,writers:f.getWriters()}}function M9(e,t,r){let n;if(typeof e.channels=="object"&&!Array.isArray(e.channels)){n={};for(let[i,a]of Object.entries(e.channels))if(e.triggers.includes(a))try{n[i]=Ko(t,a,!1)}catch(o){if(o.name===je.unminifiable_name)return;throw o}else if(a in t)try{n[i]=Ko(t,a,!1)}catch(o){if(o.name===je.unminifiable_name)continue;throw o}}else if(Array.isArray(e.channels)){let i=!1;for(let a of e.channels)try{n=Ko(t,a,!1),i=!0;break}catch(o){if(o.name===je.unminifiable_name)continue;throw o}if(!i)return}else throw new Error(`Invalid channels type, expected list or dict, got ${e.channels}`);return r&&e.mapper!==void 0&&(n=e.mapper(n)),n}function mM(e,t){if(typeof e.args!="object"||e.args===null)return e;let r={};for(let[n,i]of Object.entries(e.args)){let a=t[n];(!a||a.lc_graph_name!=="UntrackedValue")&&(r[n]=i)}return new Fa(e.node,r)}function Oh({pendingWrites:e,taskId:t,currentTaskInput:r,resumeMap:n,namespaceHash:i,pendingWritesIndex:a}){let o=a?a.nullResume:e.find(([c,l])=>c==="00000000-0000-0000-0000-000000000000"&&l==="__resume__")?.[2],s={callCounter:0,interruptCounter:-1,resume:(()=>{let c=a?(a.resumeByTaskId.get(t)??[]).flat():e.filter(([l,u])=>l===t&&u==="__resume__").flatMap(([l,u,d])=>d);if(n!=null&&i in n){let l=n[i];c.push(l)}return c})(),nullResume:o,subgraphCounter:0,currentTaskInput:r,consumeNullResume:()=>{if(s.nullResume)return delete s.nullResume,e.splice(e.findIndex(([c,l])=>c==="00000000-0000-0000-0000-000000000000"&&l==="__resume__"),1),o}};return s}var zu={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},Uu=(e,t)=>`${e.start}${t}${e.end}`;function j9(e){if(e==null)return;let t={};if(e.metadata!=null)for(let[n,i]of Object.entries(e.metadata))K0.has(n)||(t[n]=i);let r=zR(e.tags);return r!=null&&(t.tags=r),Object.keys(t).length>0?t:void 0}function*Nh(e){for(let{id:t,name:r,input:n,config:i,triggers:a,writes:o}of e){if(i?.tags?.includes("langsmith:hidden"))continue;let s={id:t,name:r,input:n,triggers:a,interrupts:o.filter(([l,u])=>l===t&&u==="__interrupt__").map(([,l])=>l)},c=j9(i);c!=null&&(s.metadata=c),yield s}}function D9(e){return typeof e!="object"||e===null?!1:"$writes"in e&&Array.isArray(e.$writes)}function hM(e){let t={};for(let[r,n]of e){let i=String(r);if(i in t){let a=D9(t[i])?t[i].$writes:[t[i]];a.push(n),t[i]={$writes:a}}else t[i]=n}return t}function*gM(e,t){for(let[{id:r,name:n,config:i},a]of e)i?.tags?.includes("langsmith:hidden")||(yield{id:r,name:n,result:hM(a.filter(([o])=>Array.isArray(t)?t.includes(o):o===t)),interrupts:a.filter(o=>o[0]===Le).map(o=>o[1])})}function*_M(e,t,r,n,i,a,o,s){function c(d){let f={};return d.callbacks!=null&&(f.callbacks=d.callbacks),d.configurable!=null&&(f.configurable=d.configurable),d.maxConcurrency!=null&&(f.max_concurrency=d.maxConcurrency),d.metadata!=null&&(f.metadata=d.metadata),d.recursionLimit!=null&&(f.recursion_limit=d.recursionLimit),d.runId!=null&&(f.run_id=d.runId),d.runName!=null&&(f.run_name=d.runName),d.tags!=null&&(f.tags=d.tags),f}let l=e.configurable?.checkpoint_ns,u={};for(let d of i){if(!(d.subgraphs?.length?d.subgraphs:[d.proc]).find(Eh))continue;let f=`${d.name}:${d.id}`;l&&(f=`${l}|${f}`),u[d.id]={configurable:{thread_id:e.configurable?.thread_id,checkpoint_ns:f}}}yield{config:c(e),values:En(t,r),metadata:n,next:i.map(d=>d.name),tasks:xS(i,a,u,s),parentConfig:o?c(o):void 0}}function xS(e,t,r,n){return e.map(i=>{let a=t.find(([l,u])=>l===i.id&&u==="__error__")?.[2],o=t.filter(([l,u])=>l===i.id&&u==="__interrupt__").map(([,,l])=>l),s=(()=>{if(a||o.length||!t.length)return;let l=t.findIndex(([u,d])=>u===i.id&&d==="__return__");if(l>=0)return t[l][2];if(typeof n=="string")return t.find(([u,d])=>u===i.id&&d===n)?.[2];if(Array.isArray(n)){let u=t.filter(([d,f])=>d===i.id&&n.includes(f)).map(([,d,f])=>[d,f]);return u.length?hM(u):void 0}})();if(a)return{id:i.id,name:i.name,path:i.path,error:a,interrupts:o,result:s};let c=r?.[i.id];return{id:i.id,name:i.name,path:i.path,interrupts:o,...c!==void 0?{state:c}:{},result:s}})}function yM(e,t,r){console.log([`${Uu(zu.blue,`[${e}:checkpoint]`)}`,`\x1B[1m State at the end of step ${e}:\x1B[0m
436
+ `,JSON.stringify(En(t,r),null,2)].join(""))}function Lu(e,t){let r=t.length;console.log([`${Uu(zu.blue,`[${e}:tasks]`)}`,`\x1B[1m Starting step ${e} with ${r} task${r===1?"":"s"}:\x1B[0m
437
+ `,t.map(n=>`- ${Uu(zu.green,String(n.name))} -> ${JSON.stringify(n.input,null,2)}`).join(`
438
+ `)].join(""))}function vM(e,t,r){let n={};for(let[i,a]of t)r.includes(i)&&(n[i]||(n[i]=[]),n[i].push(a));console.log([`${Uu(zu.blue,`[${e}:writes]`)}`,`\x1B[1m Finished step ${e} with writes to ${Object.keys(n).length} channel${Object.keys(n).length!==1?"s":""}:\x1B[0m
439
+ `,Object.entries(n).map(([i,a])=>`- ${Uu(zu.yellow,i)} -> ${a.map(o=>JSON.stringify(o)).join(", ")}`).join(`
440
+ `)].join(""))}var Rh=class extends gt{_abortController;_innerReader;constructor(e,t){let r=e.getReader(),n=t??new AbortController;super({start(i){return a();function a(){return r.read().then(({done:o,value:s})=>{if(o){i.close();return}return i.enqueue(s),a()})}}}),this._abortController=n,this._innerReader=r}async cancel(e){this._abortController.abort(e),this._innerReader.releaseLock()}get signal(){return this._abortController.signal}},kS=class extends gt{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(e){let t,r=new Promise(n=>{t=n});super({start:n=>{t(n)}}),r.then(n=>{this.controller=n}),this.passthroughFn=e.passthroughFn,this.modes=e.modes}push(e){this._closed||!this.controller||(this.passthroughFn?.(e),this.controller.enqueue(e))}close(){try{this.controller.close()}catch{}finally{this._closed=!0}}error(e){try{this.controller?.error(e)}finally{this._closed=!0}}},xM=class extends sr{name="StreamToolsHandler";awaitHandlers=!0;streamFn;runs={};constructor(e){super(),this.streamFn=e}handleToolStart(e,t,r,n,i,a,o,s){if(!a||i&&i.includes("langsmith:hidden"))return;let c=a.langgraph_checkpoint_ns?.split("|")??[],l={ns:c,toolCallId:s,toolName:o??"unknown",input:t};this.runs[r]=l,this.streamFn([c,"tools",{event:"on_tool_start",toolCallId:l.toolCallId,name:l.toolName,input:t}])}handleToolEvent(e,t){let r=this.runs[t];r&&this.streamFn([r.ns,"tools",{event:"on_tool_event",toolCallId:r.toolCallId,name:r.toolName,data:e}])}handleToolEnd(e,t){let r=this.runs[t];delete this.runs[t],r&&this.streamFn([r.ns,"tools",{event:"on_tool_end",toolCallId:r.toolCallId,name:r.toolName,output:e}])}handleToolError(e,t){let r=this.runs[t];delete this.runs[t],r&&this.streamFn([r.ns,"tools",{event:"on_tool_error",toolCallId:r.toolCallId,name:r.toolName,error:e}])}};function z9(e){return JSON.stringify(e,function(t,r){let n=this[t];if(n!=null&&typeof n=="object"&&"toDict"in n&&typeof n.toDict=="function"){let{type:i,data:a}=n.toDict();return{...a,type:i}}return r})}function U9(e){return e instanceof Error?{error:e.name,message:e.message}:{error:"Error",message:JSON.stringify(e)}}function $S(e){return typeof e!="object"||e==null?!1:"configurable"in e&&typeof e.configurable=="object"&&e.configurable!=null}function SS(e){return!$S(e)||!e.configurable.thread_id?null:{thread_id:e.configurable.thread_id,checkpoint_ns:e.configurable.checkpoint_ns||"",checkpoint_id:e.configurable.checkpoint_id||null,checkpoint_map:e.configurable.checkpoint_map||null}}function bM(e){if($S(e)){let t=Object.fromEntries(Object.entries(e.configurable).filter(([n])=>!n.startsWith("__"))),r={...e,configurable:t};return delete r.callbacks,r}return e}function wM(e){let t={...e,checkpoint:SS(e.config),parent_checkpoint:SS(e.parentConfig),config:bM(e.config),parent_config:bM(e.parentConfig),tasks:e.tasks.map(r=>{if($S(r.state)){let n=SS(r.state);if(n!=null){let i={...r,checkpoint:n};return delete i.state,i}}return r})};return delete t.parentConfig,t}function SM(e){let t=new TextEncoder;return new ReadableStream({async start(r){let n=i=>{r.enqueue(t.encode(`event: ${i.event}
441
+ data: ${z9(i.data)}
442
+
443
+ `))};try{for await(let i of e){let[a,o,s]=i,c=s;if(o==="debug"){let l=s;l.type==="checkpoint"&&(c={...l,payload:wM(l.payload)})}o==="checkpoints"&&(c=wM(s)),n({event:a?.length?`${o}|${a.join("|")}`:o,data:c})}}catch(i){n({event:"error",data:U9(i)})}r.close()}})}function kM(...e){return new kS({passthroughFn:t=>{let r=t[1]==="checkpoints"&&Ic(t[2]);for(let n of e)(n.modes.has(t[1])||r)&&n.push(t)},modes:new Set(e.flatMap(t=>Array.from(t.modes)))})}var $M=class{checkpointId;#e=new Set;constructor(e){this.checkpointId=e}#t(e){let t=e.includes(":")?e.slice(0,e.lastIndexOf(":")):e;return this.#e.has(t)?!1:(this.#e.add(t),!0)}async getCheckpoint(e,t,r){if(this.#t(e)){let n=[];for await(let i of t.list(r,{before:{configurable:{checkpoint_id:this.checkpointId}},limit:1}))n.push(i);return n.length>0?n[0]:void 0}return await t.getTuple(r)??void 0}};var Mh=Symbol.for("INPUT_DONE"),ES=Symbol.for("INPUT_RESUMING"),L9=25;function EM(e){if(!(e==null||typeof e!="object")){if(Pe.isInstance(e)){let t=e;t.id==null&&(t.id=Xi(),t.lc_kwargs!=null&&(t.lc_kwargs.id=t.id));return}if(Array.isArray(e)){for(let t of e)EM(t);return}}}function IM(e){return e===void 0||e===""?[]:e.split("|")}function F9(e){if(!e)return[];let t="";for(let r of Object.keys(e))r!==""&&r.length>t.length&&(t=r);return IM(t)}var B9=class extends ch{cache;queue=Promise.resolve();constructor(e){super(),this.cache=e}async get(e){return this.enqueueOperation("get",e)}async set(e){return this.enqueueOperation("set",e)}async clear(e){return this.enqueueOperation("clear",e)}async stop(){await this.queue}enqueueOperation(e,...t){let r=this.queue.then(()=>this.cache[e](...t));return this.queue=r.then(()=>{},()=>{}),r}},TM=class CM{input;output;config;checkpointer;checkpointerGetNextVersion;channels;checkpoint;checkpointIdSaved;_exitDeltaWrites;_deltaChannelsWithOverwrite=new Set;_hasPersistedParent=!1;_initialCheckpointConfig;checkpointConfig;checkpointMetadata;checkpointNamespace;checkpointPendingWrites=[];checkpointPreviousVersions;step;stop;durability;outputKeys;streamKeys;nodes;skipDoneTasks;prevCheckpointConfig;updatedChannels;status="pending";control;tasks={};stream;checkpointerPromises=new Set;isNested;resumeAtHead;_checkpointerChainedPromise=Promise.resolve();_trackCheckpointerPromise(t){let r=t.then(n=>(this.checkpointerPromises.delete(r),n),n=>{throw n});this.checkpointerPromises.add(r)}store;cache;manager;interruptAfter;interruptBefore;toInterrupt=[];debug=!1;triggerToNodes;get isResuming(){let t=!1;if("__start__"in this.checkpoint.channel_versions)t=!0;else for(let s in this.checkpoint.channel_versions)if(Object.prototype.hasOwnProperty.call(this.checkpoint.channel_versions,s)){t=!0;break}let r=this.config.configurable?.__pregel_resuming!==void 0&&this.config.configurable?.__pregel_resuming,n=this.input===null||this.input===void 0,i=Ct(this.input)&&this.input.resume!=null,a=this.input===ES,o=!this.isNested&&this.config.metadata?.run_id!==void 0&&this.checkpointMetadata?.run_id!==void 0&&this.config.metadata.run_id===this.checkpointMetadata?.run_id;return t&&(r||n||i||a||o)}get isReplaying(){return!this.skipDoneTasks}constructor(t){this.input=t.input,this.checkpointer=t.checkpointer,this.checkpointer!==void 0?this.checkpointerGetNextVersion=this.checkpointer.getNextVersion.bind(this.checkpointer):this.checkpointerGetNextVersion=fM,this.checkpoint=t.checkpoint,this.checkpointMetadata=t.checkpointMetadata,this.checkpointPreviousVersions=t.checkpointPreviousVersions,this.channels=t.channels,this.checkpointPendingWrites=t.checkpointPendingWrites,this.step=t.step,this.stop=t.stop,this.config=t.config,this.checkpointConfig=t.checkpointConfig,this.isNested=t.isNested,this.resumeAtHead=t.resumeAtHead,this.manager=t.manager,this.outputKeys=t.outputKeys,this.streamKeys=t.streamKeys,this.nodes=t.nodes,this.skipDoneTasks=t.skipDoneTasks,this.store=t.store,this.cache=t.cache?new B9(t.cache):void 0,this.stream=t.stream,this.checkpointNamespace=t.checkpointNamespace,this.prevCheckpointConfig=t.prevCheckpointConfig,this.interruptAfter=t.interruptAfter,this.interruptBefore=t.interruptBefore,this.durability=t.durability,this.debug=t.debug,this.triggerToNodes=t.triggerToNodes,this.control=this.config.control,this._exitDeltaWrites=this.durability==="exit"&&this.checkpointer!=null?[]:void 0,this._hasPersistedParent=t.hasPersistedParent??!1,this._initialCheckpointConfig=t.checkpointConfig,this.checkpointIdSaved=t.checkpoint.id}static async initialize(t){let{config:r,stream:n}=t;n!==void 0&&r.configurable?.__pregel_stream!==void 0&&(n=kM(n,r.configurable[Dc]));let i=r.configurable?!("checkpoint_id"in r.configurable):!0,a=r.configurable?.[tr];r.configurable&&a&&(a.subgraphCounter>0&&(r=It(r,{[Cr]:[r.configurable[Cr],a.subgraphCounter.toString()].join("|")})),a.subgraphCounter+=1);let o=r.configurable?.checkpoint_id,s=er in(r.configurable??{});!s&&r.configurable?.checkpoint_ns!==void 0&&r.configurable?.checkpoint_ns!==""&&(r=It(r,{checkpoint_ns:"",checkpoint_id:void 0}));let c=r;r.configurable?.checkpoint_id===void 0&&r.configurable?.checkpoint_map!==void 0&&r.configurable?.checkpoint_map?.[r.configurable?.checkpoint_ns]&&(c=It(r,{checkpoint_id:r.configurable[Bt][r.configurable?.checkpoint_ns]}));let l=IM(r.configurable?.checkpoint_ns),u;t.checkpointer?c.configurable?.checkpoint_id?u=await t.checkpointer.getTuple(c):r.configurable?.__pregel_replay_state?(u=await r.configurable[Hu].getCheckpoint(r.configurable?.checkpoint_ns??"",t.checkpointer,c),r.configurable&&delete r.configurable[Ba]):u=await t.checkpointer.getTuple(c):u=void 0;let d=u!==void 0;u||(u={config:r,checkpoint:Go(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]}),c={...r,...u.config,configurable:{checkpoint_ns:"",...r.configurable,...u.config.configurable}};let f=u.parentConfig,p=wn(u.checkpoint),m={...u.metadata},h=u.pendingWrites??[],_=r.configurable?.checkpoint_ns,y=r.configurable?.[Bt];typeof _=="string"&&_!==""&&typeof y=="object"&&y!==null&&_ in y&&h.length>0&&(h=h.filter(([,L])=>L!==rr));let w=!1,x=c.configurable?.thread_id,S=c.configurable?.checkpoint_ns??"";t.checkpointer&&o&&typeof x=="string"&&(w=(await t.checkpointer.getTuple({configurable:{thread_id:x,checkpoint_ns:S}}))?.config.configurable?.checkpoint_id===o&&m.source!=="update"&&m.source!=="fork");let $=await $c(t.channelSpecs,p,{saver:t.checkpointer,config:c}),P=(m.step??0)+1,C=P+(r.recursionLimit??L9)+1,b={...p.channel_versions},B=t.store?new sh(t.store):void 0;return B&&await B.start(),new CM({input:t.input,config:r,checkpointer:t.checkpointer,checkpoint:p,checkpointMetadata:m,checkpointConfig:c,prevCheckpointConfig:f,checkpointNamespace:l,channels:$,isNested:s,resumeAtHead:w,manager:t.manager,skipDoneTasks:i,step:P,stop:C,checkpointPreviousVersions:b,checkpointPendingWrites:h,outputKeys:t.outputKeys??[],streamKeys:t.streamKeys??[],nodes:t.nodes,stream:n,store:B,cache:t.cache,interruptAfter:t.interruptAfter,interruptBefore:t.interruptBefore,durability:t.durability,debug:t.debug,triggerToNodes:t.triggerToNodes,hasPersistedParent:d})}_checkpointerPutAfterPrevious(t){this._checkpointerChainedPromise=this._checkpointerChainedPromise.then(()=>this.checkpointer?.put(t.config,t.checkpoint,t.metadata,t.newVersions)),this._trackCheckpointerPromise(this._checkpointerChainedPromise)}putWrites(t,r){let n=r;if(n.length===0)return;n.every(([c])=>c in Au)&&(n=Array.from(new Map(n.map(c=>[c[0],c])).values()));let i=!1;for(let c in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,c)&&this.channels[c].lc_graph_name==="UntrackedValue"){i=!0;break}let a=n;i&&(a=n.filter(([c])=>{let l=this.channels[c];return!l||l.lc_graph_name!=="UntrackedValue"}).map(([c,l])=>c==="__pregel_tasks"&&wt(l)?[c,mM(l,this.channels)]:[c,l])),this.checkpointPendingWrites=this.checkpointPendingWrites.filter(c=>c[0]!==t);for(let[c,l]of a)this.checkpointPendingWrites.push([t,c,l]);for(let[c,l]of a){let u=this.channels[c];u!=null&&nn(u)&&EM(l)}let o=It(this.checkpointConfig,{[Cr]:this.config.configurable?.checkpoint_ns??"",[Hi]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null&&this._trackCheckpointerPromise(this.checkpointer.putWrites(o,a,t)),this.tasks&&this._outputWrites(t,n),!r.length||!this.cache||!this.tasks)return;let s=this.tasks[t];s==null||s.cache_key==null||r[0][0]==="__error__"||r[0][0]==="__interrupt__"||this.cache.set([{key:[s.cache_key.ns,s.cache_key.key],value:s.writes,ttl:s.cache_key.ttl}])}_outputWrites(t,r,n=!1){let i=this.tasks[t];if(i!==void 0){if(i.config!==void 0&&(i.config.tags??[]).includes("langsmith:hidden"))return;if(r.length>0)if(r[0][0]==="__interrupt__"){if(i.path?.[0]==="__pregel_push"&&i.path?.[i.path.length-1]===!0)return;let a=r.filter(o=>o[0]===Le).flatMap(o=>o[1]);this._emit([["updates",{[Le]:a}],["values",{[Le]:a}]])}else r[0][0]!=="__error__"&&this._emit(Pa(ci(aM(this.outputKeys,[[i,r]],n),"updates")));n||this._emit(Pa(ci(gM([[i,r]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let t=[],r=([o,s])=>`ns:${o.join(",")}|key:${s}`,n=[],i={};for(let o of Object.values(this.tasks))o.cache_key!=null&&!o.writes.length&&(n.push([o.cache_key.ns,o.cache_key.key]),i[r([o.cache_key.ns,o.cache_key.key])]=o);if(n.length===0)return[];let a=await this.cache.get(n);for(let{key:o,value:s}of a){let c=i[r(o)];c!=null&&(c.writes.push(...s),t.push({task:c,result:s}))}return t}async tick(t){this.store&&!this.store.isRunning&&await this.store?.start();let{inputKeys:r=[]}=t;if(this.status!=="pending")throw new Error(`Cannot tick when status is no longer "pending". Current status: "${this.status}"`);if(![Mh,ES].includes(this.input))await this._first(r);else{if(this.toInterrupt.length>0)throw this.status="interrupt_before",new li;if(Object.values(this.tasks).every(i=>i.writes.length>0)){let i=Object.values(this.tasks),a=i.flatMap(s=>s.writes);this.updatedChannels=hr(this.checkpoint,this.channels,i,this.checkpointerGetNextVersion,this.triggerToNodes);for(let[s,c]of a){let l=this.channels[s];l!=null&&nn(l)&&Za(c)&&this._deltaChannelsWithOverwrite.add(s)}let o=await kn(ci(Th(this.outputKeys,a,this.channels),"values"));if(this._exitDeltaWrites!==void 0)for(let[s,c,l]of this.checkpointPendingWrites){let u=this.channels[c];u!=null&&nn(u)&&this._exitDeltaWrites.push([this.step,s,c,l])}if(this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),this._emitValuesWithCheckpointMeta(o),Du(this.checkpoint,this.interruptAfter,i))throw this.status="interrupt_after",new li;this.config.configurable?.__pregel_resuming!==void 0&&delete this.config.configurable?.[Ba]}else return!1}if(this.step>this.stop)return this.status="out_of_steps",!1;this.tasks=Ma(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step,checkpointer:this.checkpointer,isResuming:this.isResuming,manager:this.manager,store:this.store,stream:this.stream,triggerToNodes:this.triggerToNodes,updatedChannels:this.updatedChannels});let n=Object.values(this.tasks);if(this.checkpointer&&(this.stream.modes.has("checkpoints")||this.stream.modes.has("debug"))&&this._emit(await kn(ci(_M(this.checkpointConfig,this.channels,this.streamKeys,this.checkpointMetadata,n,this.checkpointPendingWrites,this.prevCheckpointConfig,this.outputKeys),"checkpoints"))),n.length===0)return this.status="done",!1;if(this.control!=null&&this.control.drainRequested)return this.status="draining",!1;if(this.skipDoneTasks&&this.checkpointPendingWrites.length>0){for(let[i,a,o]of this.checkpointPendingWrites){if(a==="__error__"||a==="__error_source_node__"||a==="__interrupt__"||a==="__resume__")continue;let s=n.find(c=>c.id===i);s&&s.writes.push([a,o])}this._resumeErrorHandlersIfApplicable(),n=Object.values(this.tasks);for(let i of n)i.writes.length>0&&this._outputWrites(i.id,i.writes,!0)}if(n.every(i=>i.writes.length>0))return this.tick({inputKeys:r});if(Du(this.checkpoint,this.interruptBefore,n))throw this.status="interrupt_before",new li;if(this.stream.modes.has("tasks")||this.stream.modes.has("debug")){let i=await kn(ci(Nh(n),"tasks"));this._emit(i)}return!0}async finishAndHandleError(t){this.durability==="exit"&&(!this.isNested||typeof t<"u"||this.checkpointNamespace.every(n=>!n.includes(":")))&&(await this._putExitDeltaWrites(),this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites());let r=this._suppressInterrupt(t);return(r||t===void 0)&&(this.output=En(this.channels,this.outputKeys)),r&&(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some(n=>n.writes.length>0)&&(this.updatedChannels=hr(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emitValuesWithCheckpointMeta(Pa(ci(Th(this.outputKeys,Object.values(this.tasks).flatMap(n=>n.writes),this.channels),"values")))),ui(t)&&!t.interrupts.length&&this._emit([["updates",{[Le]:[]}],["values",{[Le]:[]}]],this.#e())),r}async acceptPush(t,r,n){if(this.interruptAfter?.length>0&&Du(this.checkpoint,this.interruptAfter,[t])){this.toInterrupt.push(t);return}let i=Ph([nr,t.path??[],r,t.id,n],this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,t.config??{},!0,{step:this.step,checkpointer:this.checkpointer,manager:this.manager,store:this.store,stream:this.stream});if(!i)return;if(this.interruptBefore?.length>0&&Du(this.checkpoint,this.interruptBefore,[i])){this.toInterrupt.push(i);return}(this.stream.modes.has("tasks")||this.stream.modes.has("debug"))&&this._emit(Pa(ci(Nh([i]),"tasks"))),this.debug&&Lu(this.step,[i]),this.tasks[i.id]=i,this.skipDoneTasks&&this._matchWrites({[i.id]:i});let a=await this._matchCachedWrites();for(let{task:o}of a)this._outputWrites(o.id,o.writes,!0);return i}getErrorHandlerNode(t){return this.nodes[t]?.errorHandlerNode}isErrorHandlerNode(t){return this.nodes[t]?.isErrorHandler===!0}scheduleErrorHandler(t,r){let n=this.getErrorHandlerNode(String(t.name));if(!n)return;let i=pM(t,n,r,this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,t.config??this.config,{step:this.step,checkpointer:this.checkpointer,manager:this.manager,store:this.store,stream:this.stream});if(i!==void 0)return this.tasks[i.id]=i,this._emit(Pa(ci(Nh([i]),"tasks"))),this.debug&&Lu(this.step,[i]),i}_resumeErrorHandlersIfApplicable(){let t=new Map;for(let[r,n]of this.checkpointPendingWrites){if(n!=="__error_source_node__")continue;let i=this.checkpointPendingWrites.find(([s,c])=>s===r&&c==="__error__");if(i===void 0)continue;let a=i[2],o=new Error(a?.message??String(a));a?.name&&(o.name=a.name),t.set(r,o)}for(let[r,n]of t){let i=this.tasks[r];i!==void 0&&this.getErrorHandlerNode(String(i.name))&&(i.writes.length===0&&i.writes.push([Vi,{message:n.message,name:n.name}]),this.scheduleErrorHandler(i,n))}}_suppressInterrupt(t){return ui(t)&&!this.isNested}async _first(t){let{configurable:r}=this.config,n=r?.[tr];if(n&&n.nullResume!==void 0&&this.putWrites(ir,[[rr,n.nullResume]]),Ct(this.input)){let l=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume=="object"&&Object.keys(this.input.resume).every(Sh)&&(this.config.configurable??={},this.config.configurable[Va]=this.input.resume),l&&this.checkpointer==null)throw new Error("Cannot use Command(resume=...) without checkpointer");let u={};for(let[d,f,p]of iM(this.input,this.checkpointPendingWrites))u[d]??=[],u[d].push([f,p]);if(Object.keys(u).length===0)throw new td("Received empty Command input");for(let[d,f]of Object.entries(u))this.putWrites(d,f)}let i=(this.checkpointPendingWrites??[]).filter(l=>l[0]===ir).map(l=>l.slice(1));i.length>0&&hr(this.checkpoint,this.channels,[{name:Pn,writes:i,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let a=Ct(this.input),o=a&&i.length>0,s=this.isReplaying&&(this.isNested&&r?.checkpoint_ns!==void 0&&r?.checkpoint_ns!==""&&r?.checkpoint_map!==void 0&&r.checkpoint_ns in r.checkpoint_map||!(a&&this.input.resume!=null||r?.__pregel_resuming===!0||this.resumeAtHead));s&&(this.checkpointPendingWrites=this.checkpointPendingWrites.filter(l=>l[1]!==rr));let c=this.isResuming;if(c||o){let l={...this.checkpoint.versions_seen[Le]};for(let d in this.channels)Object.prototype.hasOwnProperty.call(this.channels,d)&&this.checkpoint.channel_versions[d]!==void 0&&(l[d]=this.checkpoint.channel_versions[d]);this.checkpoint.versions_seen[Le]=l,s&&this.checkpointMetadata.source!=="update"&&this.checkpointMetadata.source!=="fork"&&(this.checkpointPendingWrites=this.checkpointPendingWrites.filter(d=>d[1]!==Le),await this._putCheckpoint({source:"fork"}));let u=await kn(ci(Th(this.outputKeys,!0,this.channels),"values"));c?this.input=ES:o&&(await this._putCheckpoint({source:"input"}),this.input=Mh),this._emitValuesWithCheckpointMeta(u)}else{let l=await kn(Ih(t,this.input));if(l.length>0){let u=Ma(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=hr(this.checkpoint,this.channels,Object.values(u).concat([{name:Pn,writes:l,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes);let d=l.filter(([f])=>{let p=this.channels[f];return p!=null&&nn(p)});for(let[f,p]of d)Za(p)&&this._deltaChannelsWithOverwrite.add(f);if(d.length>0)if(this._exitDeltaWrites!==void 0)for(let[f,p]of d)this._exitDeltaWrites.push([this.step,ir,f,p]);else this.checkpointer!=null&&this.putWrites(ir,d);await this._putCheckpoint({source:"input"}),this.input=Mh}else if("__pregel_resuming"in(this.config.configurable??{}))this.input=Mh;else throw new td(`Received no input writes for ${JSON.stringify(t,null,2)}`)}if(!this.isNested){let l;if(s){let u=this.checkpoint.id;(this.checkpointMetadata.source==="update"||this.checkpointMetadata.source==="fork")&&this.prevCheckpointConfig&&(u=this.prevCheckpointConfig.configurable?.checkpoint_id??u),l=new $M(u)}this.config=It(this.config,{[Ba]:this.isResuming,[Hu]:l})}}#e(){let t=this.checkpointNamespace;if(!(t.length===0||t.length===1&&t[0]==="")||this.config.configurable?.__pregel_stream===void 0)return t;let r=F9(this.config.configurable?.[Bt]);return r.length>0?r:t}_emit(t,r=this.checkpointNamespace){for(let[n,i]of t)if(this.stream.modes.has(n)&&this.stream.push([r,n,i]),(n==="checkpoints"||n==="tasks")&&this.stream.modes.has("debug")){let a=n==="checkpoints"?this.step-1:this.step,o=new Date().toISOString(),s=n==="checkpoints"?"checkpoint":typeof i=="object"&&i!=null&&"result"in i?"task_result":"task";this.stream.push([r,"debug",{step:a,type:s,timestamp:o,payload:i}])}}_currentCheckpointMeta(){if(!this.checkpointMetadata||!this.checkpoint?.id)return;let t=this.prevCheckpointConfig?.configurable?.checkpoint_id;return{checkpoint:{id:this.checkpoint.id,...t?{parent_id:t}:{},step:this.checkpointMetadata.step,source:this.checkpointMetadata.source}}}_emitValuesWithCheckpointMeta(t){let r=this._currentCheckpointMeta();for(let[n,i]of t)n==="values"&&r?.checkpoint!=null&&!this.stream.modes.has("checkpoints")&&this.stream.push([this.checkpointNamespace,"checkpoints",r.checkpoint]),this.stream.modes.has(n)&&this.stream.push([this.checkpointNamespace,n,i])}_putCheckpoint(t){let r=this.checkpointMetadata===t,n=this.checkpointer!=null&&(this.durability!=="exit"||r),i=c=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=It(this.checkpointConfig,{[Cr]:this.config.configurable?.checkpoint_ns??""});let l={...this.checkpoint.channel_versions},u=Pc(this.checkpointPreviousVersions,l);this.checkpointPreviousVersions=l,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:wn(c),metadata:{...this.checkpointMetadata},newVersions:u}),this.checkpointConfig={...this.checkpointConfig,configurable:{...this.checkpointConfig.configurable,checkpoint_id:this.checkpoint.id}}},a;if(r)a={...this.checkpointMetadata.counters_since_delta_snapshot??{}};else{let c=this.checkpointMetadata.counters_since_delta_snapshot??{};a={};let l=this.updatedChannels??new Set;for(let u in this.channels){if(!Object.prototype.hasOwnProperty.call(this.channels,u)||!nn(this.channels[u]))continue;let[d,f]=c[u]??[0,0];a[u]=[l.has(u)?d+1:d,f+1]}this.checkpointMetadata={...t,step:this.step,parents:this.config.configurable?.checkpoint_map??{}}}let o=n?uh(this.channels,a):new Set;if(n)for(let c of this._deltaChannelsWithOverwrite)o.add(c);this.checkpoint=xn(this.checkpoint,n?this.channels:void 0,this.step,{id:r?this.checkpoint.id:void 0,channelsToSnapshot:o,updatedChannels:this.updatedChannels,getNextVersion:n?c=>this.checkpointerGetNextVersion(c):void 0});for(let c of o)a[c]=[0,0],this._deltaChannelsWithOverwrite.delete(c);let s={};for(let c in a){if(!Object.prototype.hasOwnProperty.call(a,c))continue;let[l,u]=a[c];(l!==0||u!==0)&&(s[c]=[l,u])}Object.keys(s).length>0?this.checkpointMetadata.counters_since_delta_snapshot=s:delete this.checkpointMetadata.counters_since_delta_snapshot,n&&i(this.checkpoint),r||(this.step+=1)}async _putExitDeltaWrites(){if(this._exitDeltaWrites===void 0||this._exitDeltaWrites.length===0||this.checkpointer==null||this._initialCheckpointConfig===void 0)return;let t=this.checkpointMetadata.counters_since_delta_snapshot??{},r=uh(this.channels,t);for(let c of this._deltaChannelsWithOverwrite)r.add(c);let n=this._exitDeltaWrites.filter(([,,c])=>!r.has(c));if(n.length===0)return;let i;if(this._hasPersistedParent)i=this._initialCheckpointConfig;else{let c=Go();c.id=this.checkpointIdSaved??c.id,c.ts=new Date().toISOString();let l=It(this._initialCheckpointConfig,{[Hi]:void 0});i=It(this._initialCheckpointConfig,{[Hi]:c.id}),this._trackCheckpointerPromise(this.checkpointer.put(l,c,{source:"loop",step:-2,parents:{}},{})),this.checkpointConfig=i}let a=It(i,{[Cr]:this.config.configurable?.checkpoint_ns??"",[Hi]:i.configurable?.[Hi]}),o=new Map,s=[];for(let[c,l,u,d]of n){let f=`${c}\0${l}`,p=o.get(f);p===void 0&&(p=[],o.set(f,p),s.push({key:f,step:c,tid:l})),p.push([u,d])}for(let{key:c,step:l,tid:u}of s){let d=Y0(l,u);this._trackCheckpointerPromise(this.checkpointer.putWrites(a,o.get(c),d))}}_flushPendingWrites(){if(this.checkpointer==null||this.checkpointPendingWrites.length===0)return;let t=It(this.checkpointConfig,{[Cr]:this.config.configurable?.checkpoint_ns??"",[Hi]:this.checkpoint.id}),r={};for(let[n,i,a]of this.checkpointPendingWrites)r[n]??=[],r[n].push([i,a]);for(let[n,i]of Object.entries(r))this._trackCheckpointerPromise(this.checkpointer.putWrites(t,i,n))}_matchWrites(t){for(let[r,n,i]of this.checkpointPendingWrites){if(n==="__error__"||n==="__interrupt__"||n==="__resume__")continue;let a=Object.values(t).find(o=>o.id===r);a&&a.writes.push([n,i])}for(let r of Object.values(t))r.writes.length>0&&this._outputWrites(r.id,r.writes,!0)}};function V9(e){return tt(e?.message)}function AM(e,t,r){if(!e)return;let n=e.langgraph_checkpoint_ns,i=e.checkpoint_ns,a=n??i;if(a)return[a.split("|"),{tags:t,name:r,...e}]}var OM=class extends sr{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(e){super(),this.streamFn=e}_emit(e,t,r,n=!1){if(n&&t.id!==void 0&&this.seen[t.id]!==void 0)return;let i=t.id;r!=null&&(Jc(t)?i??=`run-${r}-tool-${t.tool_call_id}`:((i==null||i===`run-${r}`)&&(i=this.stableMessageIdMap[r]??i??`run-${r}`),this.stableMessageIdMap[r]??=i)),i!==t.id&&(t.id=i,t.lc_kwargs.id=i),t.id!=null&&(this.seen[t.id]=t),this.streamFn([e[0],"messages",[t,e[1]]])}handleChatModelStart(e,t,r,n,i,a,o,s){o&&(!a||!a.includes("langsmith:nostream")&&!a.includes("nostream"))&&(this.metadatas[r]=AM(o,a,s))}handleLLMNewToken(e,t,r,n,i,a){let o=a?.chunk;this.emittedChatModelRunIds[r]=!0,this.metadatas[r]!==void 0&&(V9(o)?this._emit(this.metadatas[r],o.message,r):this._emit(this.metadatas[r],new it({content:e}),r))}handleLLMEnd(e,t){if(this.metadatas[t]!==void 0){if(!this.emittedChatModelRunIds[t]){let r=e.generations?.[0]?.[0];tt(r?.message)&&this._emit(this.metadatas[t],r?.message,t,!0),delete this.emittedChatModelRunIds[t]}delete this.metadatas[t],delete this.stableMessageIdMap[t]}}handleLLMError(e,t){delete this.metadatas[t]}handleChainStart(e,t,r,n,i,a,o,s){if(a!==void 0&&s===a.langgraph_node&&(i===void 0||!i.includes("langsmith:hidden"))&&(this.metadatas[r]=AM(a,i,s),typeof t=="object")){for(let c of Object.values(t))if((tt(c)||pi(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let l of c)(tt(l)||pi(l))&&l.id!==void 0&&(this.seen[l.id]=l)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r!==void 0){if(tt(e))this._emit(r,e,t,!0);else if(Array.isArray(e))for(let n of e)tt(n)&&this._emit(r,n,t,!0);else if(e!=null&&typeof e=="object"){for(let n of Object.values(e))if(tt(n))this._emit(r,n,t,!0);else if(Array.isArray(n))for(let i of n)tt(i)&&this._emit(r,i,t,!0)}}}handleChainError(e,t){delete this.metadatas[t]}};function PM(e){if("response_metadata"in e&&typeof e.response_metadata=="object"&&e.response_metadata!=null)return e.response_metadata}function NM(e){if("usage_metadata"in e&&typeof e.usage_metadata=="object"&&e.usage_metadata!=null)return e.usage_metadata}function Z9(e){switch(e.type){case"text":return{type:"text",text:""};case"reasoning":return{type:"reasoning",reasoning:""};case"tool_call":case"tool_call_chunk":return{type:"tool_call_chunk",...e.id!=null?{id:e.id}:{},...e.name!=null?{name:e.name}:{},args:""};default:return e}}function H9(e){switch(e.type){case"text":{let t=typeof e.text=="string"?e.text:"";return t.length>0?{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"text-delta",text:t}}:void 0}case"reasoning":{let t=typeof e.reasoning=="string"?e.reasoning:"";return t.length>0?{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"reasoning-delta",reasoning:t}}:void 0}case"tool_call_chunk":return{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"block-delta",fields:{...e,type:"tool_call_chunk"}}};default:return}}var RM=class extends sr{name="StreamProtocolMessagesHandler";streamFn;metadatas={};seen={};streamedRunIds=new Set;stableMessageIdMap={};lc_prefer_chat_model_stream_events=!0;awaitHandlers=!0;constructor(e){super(),this.streamFn=e}normalizeMessageId(e,t){let r=e.id;return t!=null&&(St.isInstance(e)?r??=`run-${t}-tool-${e.tool_call_id}`:((r==null||r===`run-${t}`)&&(r=this.stableMessageIdMap[t]??r??`run-${t}`),this.stableMessageIdMap[t]??=r)),r!==e.id&&(e.id=r,e.lc_kwargs.id=r),e.id!=null&&(this.seen[e.id]=e),e.id}emit(e,t,r){let n=r!=null?{...e[1],run_id:r}:e[1];this.streamFn([e[0],"messages",[t,n]])}emitFinalMessage(e,t,r,n=!1){let i=t.id??(r!=null?this.stableMessageIdMap[r]:void 0);if(n&&i!=null&&this.seen[i]!==void 0)return;let a=this.normalizeMessageId(t,r),o=t.type==="human"?"human":t.type==="system"?"system":t.type==="tool"?"tool":"ai",s=o==="tool"&&St.isInstance(t)?t.tool_call_id:void 0;this.emit(e,{event:"message-start",...a!=null?{id:a}:{},...o!=="ai"?{role:o}:{},...typeof s=="string"?{tool_call_id:s}:{}},r),(Array.isArray(t.content)?t.content:typeof t.content=="string"&&t.content.length>0?[{type:"text",text:t.content}]:[]).forEach((c,l)=>{let u=typeof c.index=="number"?c.index:l;this.emit(e,{event:"content-block-start",index:u,content:Z9(c)},r);let d=H9({...c,index:u});d!=null&&this.emit(e,d,r),this.emit(e,{event:"content-block-finish",index:u,content:c},r)}),this.emit(e,{event:"message-finish",...NM(t)!=null?{usage:NM(t)}:{},...PM(t)!=null?{responseMetadata:PM(t)}:{}},r)}handleChatModelStart(e,t,r,n,i,a,o,s){o&&(!a||!a.includes("langsmith:nostream")&&!a.includes("nostream"))&&(this.metadatas[r]=[o.langgraph_checkpoint_ns.split("|"),{tags:a,name:s,...o}])}handleLLMNewToken(){}handleChatModelStreamEvent(e,t){let r=this.metadatas[t];if(r===void 0)return;let n=e;if(e.event==="message-start"){this.streamedRunIds.add(t);let i=e.id??`run-${t}`;this.seen[i]=!0,this.stableMessageIdMap[t]??=i,e.id==null&&(n={...e,id:i})}this.emit(r,n,t)}handleLLMEnd(e,t){let r=this.metadatas[t];if(r===void 0)return;let n=e.generations?.[0]?.[0],i=Pe.isInstance(n?.message)?n.message:void 0;if(i!=null)if(this.streamedRunIds.has(t)){let a=this.normalizeMessageId(i,t);a!=null&&(this.seen[a]=i)}else this.emitFinalMessage(r,i,t,!0);this.streamedRunIds.delete(t),delete this.metadatas[t],delete this.stableMessageIdMap[t]}handleLLMError(e,t){this.streamedRunIds.delete(t),delete this.metadatas[t],delete this.stableMessageIdMap[t]}handleChainStart(e,t,r,n,i,a,o,s){if(a!==void 0&&s===a.langgraph_node&&(i===void 0||!i.includes("langsmith:hidden"))&&(this.metadatas[r]=[a.langgraph_checkpoint_ns.split("|"),{tags:i,name:s,...a}],typeof t=="object")){for(let c of Object.values(t))if((Pe.isInstance(c)||Ot.isInstance(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let l of c)(Pe.isInstance(l)||Ot.isInstance(l))&&l.id!==void 0&&(this.seen[l.id]=l)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r===void 0)return;let n=i=>{Pe.isInstance(i)&&!St.isInstance(i)&&this.emitFinalMessage(r,i,t,!0)};if(Pe.isInstance(e))n(e);else if(Array.isArray(e))for(let i of e)n(i);else if(e!=null&&typeof e=="object")for(let i of Object.values(e))if(Array.isArray(i))for(let a of i)n(a);else n(i);delete this.stableMessageIdMap[t]}handleChainError(e,t){delete this.metadatas[t],delete this.stableMessageIdMap[t]}};var G9=class{active=!0;lastProgress=Date.now();refreshOn;constructor(e){this.refreshOn=e}touch(){this.lastProgress=Date.now()}autoTouch(){this.refreshOn==="auto"&&(this.lastProgress=Date.now())}close(){this.active=!1}},W9=class extends sr{name="IdleProgressCallbackHandler";awaitHandlers=!1;#e;constructor(e){super(),this.#e=e}#t=()=>{this.#e.autoTouch()};handleLLMStart=this.#t;handleChatModelStart=this.#t;handleLLMNewToken=this.#t;handleLLMEnd=this.#t;handleLLMError=this.#t;handleChainStart=this.#t;handleChainEnd=this.#t;handleChainError=this.#t;handleToolStart=this.#t;handleToolEnd=this.#t;handleToolError=this.#t;handleText=this.#t;handleRetrieverStart=this.#t;handleRetrieverEnd=this.#t;handleRetrieverError=this.#t;handleCustomEvent=this.#t};function J9(e,t,r,n){let i=e.configurable??{},a={},o=i[Ft];typeof o=="function"&&(a[Ft]=l=>{if(t.active)return l&&l.length&&t.autoTouch(),o(l)});let s=i[Nn];typeof s=="function"&&(a[Nn]=(...l)=>{if(!t.active)throw new Error(`Node "${n}" attempt was cancelled after its timeout fired`);return t.autoTouch(),s(...l)});let c={...Object.keys(a).length>0?It(e,a):e};if(c.heartbeat=()=>{r.idleTimeout!==void 0&&t.touch()},typeof c.writer=="function"){let l=c.writer;c.writer=(u=>{if(t.active)return t.autoTouch(),l(u)})}if((r.refreshOn??"auto")==="auto"&&r.idleTimeout!==void 0){let l=new W9(t),u=c.callbacks;if(u===void 0)c.callbacks=[l];else if(Array.isArray(u))c.callbacks=[...u,l];else{let d=u.copy();d.addHandler(l,!0),c.callbacks=d}}return c}async function MM(e,t,r,n){let i=new G9(r.refreshOn??"auto"),a=new AbortController,{signal:o,dispose:s}=Ra(t.signal,a.signal),c=J9({...t,signal:o},i,r,String(e.name)),l=Date.now(),u=n(c).then(y=>({type:"ok",value:y}),y=>({type:"err",error:y})),d,f,p=()=>{d!==void 0&&clearTimeout(d),f!==void 0&&clearTimeout(f)},m=new Promise(y=>{if(r.runTimeout!==void 0&&(d=setTimeout(()=>y({type:"timeout",kind:"run"}),r.runTimeout)),r.idleTimeout!==void 0){let w=r.idleTimeout,x=()=>{let S=i.lastProgress+w-Date.now();S<=0?y({type:"timeout",kind:"idle"}):f=setTimeout(x,S)};f=setTimeout(x,w)}}),h;try{h=await Promise.race([u,m])}finally{p()}if(h.type!=="timeout"){let y=Date.now();r.runTimeout!==void 0&&y-l>=r.runTimeout?h={type:"timeout",kind:"run"}:r.idleTimeout!==void 0&&y-i.lastProgress>=r.idleTimeout&&(h={type:"timeout",kind:"idle"})}if(h.type==="ok")return s?.(),h.value;if(h.type==="err")throw s?.(),h.error;let _=Date.now()-l;throw i.close(),e.writes.splice(0,e.writes.length),a.abort(),s?.(),new ed({node:String(e.name),elapsed:_,kind:h.kind,runTimeout:r.runTimeout,idleTimeout:r.idleTimeout})}var K9=[400,401,402,403,404,405,406,407,409],q9=e=>{if(e.message.startsWith("Cancel")||e.message.startsWith("AbortError")||e.name==="AbortError"||e.name==="GraphValueError"||e?.code==="ECONNABORTED")return!1;let t=e?.response?.status??e?.status;return!(t&&K9.includes(+t)||e?.error?.code==="insufficient_quota")};async function jh(e,t,r,n){let i=e.retry_policy??t,a=0,o,s,c=e.config??{};r&&(c=It(c,r)),c={...c,signal:n};let l=Date.now();for(c.executionInfo!=null&&(c.executionInfo={...c.executionInfo,nodeFirstAttemptTime:l});!n?.aborted;){e.writes.splice(0,e.writes.length),o=void 0;try{e.timeout!==void 0?s=await MM(e,c,e.timeout,u=>e.proc.invoke(e.input,u)):s=await e.proc.invoke(e.input,c);break}catch(u){if(o=u,o.pregelTaskId=e.id,Zh(o)){let h=c?.configurable?.checkpoint_ns,_=o.command;if(_.graph===h){for(let y of e.writers)await y.invoke(_,c);o=void 0;break}else if(_.graph===_r.PARENT){let y=UR(h);o.command=new _r({...o.command,graph:y})}}if(Ji(o)||i===void 0||(a+=1,a>=(i.maxAttempts??3))||!(i.retryOn??q9)(o))break;let d=i.initialInterval??500,f=Math.min(i.maxInterval??128e3,d*(i.backoffFactor??2)**(a-1)),p=i.jitter??!0?f+Math.random()*1e3:f;await new Promise(h=>setTimeout(h,p));let m=o.name??o.constructor.unminifiable_name??o.constructor.name;(i?.logWarning??!0)&&console.log(`Retrying task "${String(e.name)}" after ${p.toFixed(2)}ms (attempt ${a}) after ${m}: ${o}`),c=It(c,{[Ba]:!0}),c.executionInfo!=null&&(c.executionInfo={...c.executionInfo,nodeAttempt:a+1,nodeFirstAttemptTime:l})}}return{task:e,result:s,error:o,signalAborted:n?.aborted}}var IS=Symbol.for("promiseAdded");function X9(){let e={next:()=>{},wait:Promise.resolve(IS)};function t(r){e.next=()=>{e.wait=new Promise(t),r(IS)}}return e.wait=new Promise(t),e}var jM=class{nodeFinished;loop;handledExceptions=new WeakSet;constructor({loop:e,nodeFinished:t}){this.loop=e,this.nodeFinished=t}async tick(e={}){let{timeout:t,retryPolicy:r,onStepWrite:n,maxConcurrency:i}=e,a=new Set,o,s=new AbortController,c=s.signal,l=t?AbortSignal.timeout(t):void 0,u=Object.values(this.loop.tasks),d=u.filter(h=>h.writes.length===0),{signals:f,disposeCombinedSignal:p}=this._initializeAbortSignals({exceptionSignal:c,stepTimeoutSignal:l,signal:e.signal}),m=this._executeTasksWithRetry(d,{signals:f,retryPolicy:r,maxConcurrency:i});for await(let{task:h,error:_,signalAborted:y}of m)this._commit(h,_),!(_!==void 0&&this.handledExceptions.has(_))&&(ui(_)||Ji(_)&&!ui(o)?o=_:_&&(a.size===0||!y)&&(s.abort(),a.add(_)));if(p?.(),n?.(this.loop.step,u.map(h=>h.writes).flat()),a.size===1)throw Array.from(a)[0];if(a.size>1)throw new AggregateError(Array.from(a),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(ui(o)||qu(o)||Ji(o)&&this.loop.isNested)throw o}_initializeAbortSignals({exceptionSignal:e,stepTimeoutSignal:t,signal:r}){let n=this.loop.config.configurable?.__pregel_abort_signals??{},i=n.externalAbortSignal??r,a=t??n.timeoutAbortSignal,{signal:o,dispose:s}=Ra(i,a,e),c={externalAbortSignal:i,timeoutAbortSignal:a,composedAbortSignal:o};return this.loop.config=It(this.loop.config,{[JS]:c}),{signals:c,disposeCombinedSignal:s}}async*_executeTasksWithRetry(e,t){let{retryPolicy:r,maxConcurrency:n,signals:i}=t??{},a=X9(),o={},s={executingTasksMap:o,barrier:a,retryPolicy:r,scheduleTask:async(f,p,m)=>this.loop.acceptPush(f,p,m)};if(i?.composedAbortSignal?.aborted)throw new Error("Abort");let c=0,l,u=Ra(i?.externalAbortSignal,i?.timeoutAbortSignal),d=u.signal?new Promise((f,p)=>{l=()=>p(new Error("Abort")),u.signal?.addEventListener("abort",l,{once:!0})}):void 0;for(;(c===0||Object.keys(o).length>0)&&e.length;){for(;Object.values(o).length<(n??e.length)&&c<e.length;c+=1){let _=e[c];o[_.id]=jh(_,r,{[Nn]:TS?.bind(s,this,_)},i?.composedAbortSignal).catch(y=>({task:_,error:y,signalAborted:i?.composedAbortSignal?.aborted}))}let f=await Promise.race([...Object.values(o),...d?[d]:[],a.wait]);if(f===IS)continue;let p=f,{task:m,error:h}=p;if(h!==void 0&&!Ji(h)&&!this.loop.isErrorHandlerNode(String(m.name))&&this.loop.getErrorHandlerNode(String(m.name))!==void 0){let _=this.loop.scheduleErrorHandler(m,h);_!==void 0&&(o[_.id]=jh(_,r,{[Nn]:TS?.bind(s,this,_)},i?.composedAbortSignal).catch(y=>({task:_,error:y,signalAborted:i?.composedAbortSignal?.aborted})),a.next())}yield p,l!=null&&(u.signal?.removeEventListener("abort",l),u.dispose?.()),delete o[f.task.id]}}_shouldRouteToErrorHandler(e){let t=String(e.name);return this.loop.isErrorHandlerNode(t)?!1:this.loop.getErrorHandlerNode(t)!==void 0}_commit(e,t){if(t!==void 0)if(ui(t)){if(t.interrupts.length){let r=t.interrupts.map(i=>[Le,i]),n=e.writes.filter(i=>i[0]===rr);n.length&&r.push(...n),this.loop.putWrites(e.id,r)}}else qu(t)?e.writes.length&&this.loop.putWrites(e.id,e.writes):Ji(t)&&e.writes.length?this.loop.putWrites(e.id,e.writes):(e.writes.push([Vi,{message:t.message,name:t.name}]),this._shouldRouteToErrorHandler(e)&&(e.writes.push([jc,String(e.name)]),this.handledExceptions.add(t)),this.loop.putWrites(e.id,e.writes));else this.nodeFinished&&(e.config?.tags==null||!e.config.tags.includes("langsmith:hidden"))&&this.nodeFinished(String(e.name)),e.writes.length===0&&e.writes.push([Uc,null]),this.loop.putWrites(e.id,e.writes)}};async function TS(e,t,r,n,i,a={}){let o=t.config?.configurable?.[tr];if(!o)throw new Error(`BUG: No scratchpad found on task ${t.name}__${t.id}`);let s=o.callCounter;o.callCounter+=1;let c=new sM({func:r,name:n,input:i,cache:a.cache,retry:a.retry,timeout:a.timeout,callbacks:a.callbacks}),l=await this.scheduleTask(t,s,c);if(!l)return;let u=this.executingTasksMap[l.id];if(u!==void 0)return u;if(l.writes.length>0){let d=l.writes.filter(([p])=>p===Gi),f=l.writes.filter(([p])=>p===Vi);if(d.length>0){if(d.length===1)return Promise.resolve(d[0][1]);throw new Error(`BUG: multiple returns found for task ${l.name}__${l.id}`)}if(f.length>0){if(f.length===1){let p=f[0][1],m=p instanceof Error?p:new Error(String(p));return Promise.reject(m)}throw new Error(`BUG: multiple errors found for task ${l.name}__${l.id}`)}return}else{let d=jh(l,a.retry,{[Nn]:TS.bind(this,e,l)});return this.executingTasksMap[l.id]=d,this.barrier.next(),d.then(({result:f,error:p})=>p?Promise.reject(p):f)}}var Ri=class extends Error{constructor(e){super(e),this.name="GraphValidationError"}};function DM({nodes:e,channels:t,inputChannels:r,outputChannels:n,streamChannels:i,interruptAfterNodes:a,interruptBeforeNodes:o}){if(!t)throw new Ri("Channels not provided");let s=new Set,c=new Set;for(let[l,u]of Object.entries(e)){if(l==="__interrupt__")throw new Ri(`"Node name ${Le} is reserved"`);if(u.constructor===$n)u.triggers.forEach(d=>s.add(d));else throw new Ri(`Invalid node type ${typeof u}, expected PregelNode`)}for(let l of s)if(!(l in t))throw new Ri(`Subscribed channel '${String(l)}' not in channels`);if(Array.isArray(r)){if(r.every(l=>!s.has(l)))throw new Ri(`None of the input channels ${r} are subscribed to by any node`)}else if(!s.has(r))throw new Ri(`Input channel ${String(r)} is not subscribed to by any node`);Array.isArray(n)?n.forEach(l=>c.add(l)):c.add(n),i&&!Array.isArray(i)?c.add(i):Array.isArray(i)&&i.forEach(l=>c.add(l));for(let l of c)if(!(l in t))throw new Ri(`Output channel '${String(l)}' not in channels`);if(a&&a!=="*"){for(let l of a)if(!(l in e))throw new Ri(`Node ${String(l)} not in nodes`)}if(o&&o!=="*"){for(let l of o)if(!(l in e))throw new Ri(`Node ${String(l)} not in nodes`)}}function CS(e,t){if(Array.isArray(e)){for(let r of e)if(!(r in t))throw new Error(`Key ${String(r)} not found in channels`)}else if(!(e in t))throw new Error(`Key ${String(e)} not found in channels`)}var AS=class zM extends yt{lc_graph_name="Topic";unique=!1;accumulate=!1;seen;values;constructor(t){super(),this.unique=t?.unique??this.unique,this.accumulate=t?.accumulate??this.accumulate,this.seen=new Set,this.values=[]}fromCheckpoint(t){let r=new zM({unique:this.unique,accumulate:this.accumulate});return typeof t<"u"&&(r.seen=new Set(t[0]),r.values=t[1]),r}update(t){let r=!1;this.accumulate||(r=this.values.length>0,this.values=[]);let n=t.flat();if(n.length>0)if(this.unique)for(let i of n)this.seen.has(i)||(r=!0,this.seen.add(i),this.values.push(i));else r=!0,this.values.push(...n);return r}get(){if(this.values.length===0)throw new je;return this.values}checkpoint(){return[[...this.seen],this.values]}isAvailable(){return this.values.length!==0}};function Y9(e){let t=new TextEncoder;return new ReadableStream({async start(r){try{for await(let n of e){let i=n.params.namespace,a=i.length?`${n.method}|${i.join("|")}`:n.method;r.enqueue(t.encode(`event: ${a}
444
+ data: ${JSON.stringify(n.params.data??{})}
445
+
446
+ `))}}catch(n){r.enqueue(t.encode(`event: error
447
+ data: ${JSON.stringify({message:String(n)})}
448
+
449
+ `))}finally{r.close()}}})}var UM=class{static subscribeTo(e,t){let{key:r,tags:n}={key:void 0,tags:void 0,...t??{}};if(Array.isArray(e)&&r!==void 0)throw new Error("Can't specify a key when subscribing to multiple channels");let i;return typeof e=="string"?r?i={[r]:e}:i=[e]:i=Object.fromEntries(e.map(a=>[a,a])),new $n({channels:i,triggers:Array.isArray(e)?e:[e],tags:n})}static writeTo(e,t){let r=[];for(let n of e)r.push({channel:n,value:Ir,skipNone:!1});for(let[n,i]of Object.entries(t??{}))se.isRunnable(i)||typeof i=="function"?r.push({channel:n,value:Ir,skipNone:!0,mapper:at(i)}):r.push({channel:n,value:i,skipNone:!1});return new ut(r)}},Q9=class extends se{lc_namespace=["langgraph","pregel"];invoke(e,t){throw new Error("Not implemented")}withConfig(e){return super.withConfig(e)}stream(e,t){return super.stream(e,t)}},Dh=class extends Q9{static lc_name(){return"LangGraph"}lc_namespace=["langgraph","pregel"];lg_is_pregel=!0;nodes;channels;inputChannels;outputChannels;autoValidate=!0;streamMode=["values"];streamChannels;interruptAfter;interruptBefore;stepTimeout;debug=!1;checkpointer;retryPolicy;config;store;cache;userInterrupt;streamTransformers;triggerToNodes={};constructor(e){super(e);let{streamMode:t}=e;if(t!=null&&!Array.isArray(t)&&(t=[t]),this.nodes=e.nodes,this.channels=e.channels,"__pregel_tasks"in this.channels&&"lc_graph_name"in this.channels.__pregel_tasks&&this.channels.__pregel_tasks.lc_graph_name!=="Topic")throw new Error(`Channel '${Rn}' is reserved and cannot be used in the graph.`);this.channels[Rn]=new AS({accumulate:!1}),this.autoValidate=e.autoValidate??this.autoValidate,this.streamMode=t??this.streamMode,this.inputChannels=e.inputChannels,this.outputChannels=e.outputChannels,this.streamChannels=e.streamChannels??this.streamChannels,this.interruptAfter=e.interruptAfter,this.interruptBefore=e.interruptBefore,this.stepTimeout=e.stepTimeout??this.stepTimeout,this.debug=e.debug??this.debug,this.checkpointer=e.checkpointer,this.retryPolicy=e.retryPolicy,this.config=e.config,this.store=e.store,this.cache=e.cache,this.name=e.name,this.triggerToNodes=e.triggerToNodes??this.triggerToNodes,this.userInterrupt=e.userInterrupt,this.streamTransformers=e.streamTransformers??[],this.autoValidate&&this.validate()}withConfig(e){let{streamTransformers:t,...r}=e,n=$t(this.config,r),i=[...this.streamTransformers,...t??[]];return new this.constructor({...this,config:n,streamTransformers:i})}validate(){DM({nodes:this.nodes,channels:this.channels,outputChannels:this.outputChannels,inputChannels:this.inputChannels,streamChannels:this.streamChannels,interruptAfterNodes:this.interruptAfter,interruptBeforeNodes:this.interruptBefore});for(let[e,t]of Object.entries(this.nodes))for(let r of t.triggers)this.triggerToNodes[r]??=[],this.triggerToNodes[r].push(e);return this}get streamChannelsList(){return Array.isArray(this.streamChannels)?this.streamChannels:this.streamChannels?[this.streamChannels]:Object.keys(this.channels)}get streamChannelsAsIs(){return this.streamChannels?this.streamChannels:Object.keys(this.channels)}async getGraphAsync(e){return this.getGraph(e)}*getSubgraphs(e,t){for(let[r,n]of Object.entries(this.nodes)){if(e!==void 0&&!e.startsWith(r))continue;let i=n.subgraphs?.length?n.subgraphs:[n.bound];for(let a of i){let o=Eh(a);if(o!==void 0){if(r===e){yield[r,o];return}if(e===void 0&&(yield[r,o]),t){let s=e;e!==void 0&&(s=e.slice(r.length+1));for(let[c,l]of o.getSubgraphs(s,t))yield[`${r}|${c}`,l]}}}}}async*getSubgraphsAsync(e,t){yield*this.getSubgraphs(e,t)}async _prepareStateSnapshot({config:e,saved:t,subgraphCheckpointer:r,applyPendingWrites:n=!1}){if(t===void 0)return{values:{},next:[],config:e,tasks:[]};let i=await $c(this.channels,t.checkpoint,{saver:typeof this.checkpointer=="object"?this.checkpointer:void 0,config:t.config??e});if(t.pendingWrites?.length){let d=t.pendingWrites.filter(([f,p])=>f===ir).map(([f,p,m])=>[String(p),m]);d.length>0&&hr(t.checkpoint,i,[{name:Pn,writes:d,triggers:[]}],void 0,this.triggerToNodes)}let a=Object.values(Ma(t.checkpoint,t.pendingWrites,this.nodes,i,t.config,!0,{step:(t.metadata?.step??-1)+1,store:this.store})),o=await kn(this.getSubgraphsAsync()),s=t.config.configurable?.checkpoint_ns??"",c={};for(let d of a){let f=o.find(([m])=>m===d.name);if(!f)continue;let p=`${String(d.name)}:${d.id}`;if(s&&(p=`${s}|${p}`),r===void 0){let m={configurable:{thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}};c[d.id]=m}else{let m={configurable:{[Vr]:r,thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}},h=f[1];c[d.id]=await h.getState(m,{subgraphs:!0})}}if(n&&t.pendingWrites?.length){let d=Object.fromEntries(a.map(p=>[p.id,p]));for(let[p,m,h]of t.pendingWrites)["__error__","__interrupt__",Ja].includes(m)||p in d&&d[p].writes.push([String(m),h]);let f=a.filter(p=>p.writes.length>0);f.length>0&&hr(t.checkpoint,i,f,void 0,this.triggerToNodes)}let l=t?.metadata;l&&t?.config?.configurable?.thread_id&&(l={...l,thread_id:t.config.configurable.thread_id});let u=a.filter(d=>d.writes.length===0).map(d=>d.name);return{values:En(i,this.streamChannelsAsIs),next:u,tasks:xS(a,t?.pendingWrites??[],c,this.streamChannelsAsIs),metadata:l,config:Na(t.config,t.metadata),createdAt:t.checkpoint.ts,parentConfig:t.parentConfig}}async getState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new Ga("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_read===void 0&&e.configurable?.__pregel_checkpointer===void 0){let o=mh(n);for await(let[s,c]of this.getSubgraphsAsync(o,!0))if(s===o)return await c.getState(Jo(e,{[Vr]:r}),{subgraphs:t?.subgraphs})}let i=$t(this.config,e),a=await r.getTuple(e);return await this._prepareStateSnapshot({config:i,saved:a,subgraphCheckpointer:t?.subgraphs?r:void 0,applyPendingWrites:!e.configurable?.checkpoint_id})}async*getStateHistory(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new Ga("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=mh(n);for await(let[o,s]of this.getSubgraphsAsync(a,!0))if(o===a){yield*s.getStateHistory(Jo(e,{[Vr]:r}),t);return}}let i=$t(this.config,e,{configurable:{checkpoint_ns:n}});for await(let a of r.list(i,t))yield this._prepareStateSnapshot({config:a.config,saved:a})}async bulkUpdateState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new Ga("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});if(t.length===0)throw new Error("No supersteps provided");if(t.some(o=>o.updates.length===0))throw new Error("No updates provided");let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=mh(n);for await(let[,s]of this.getSubgraphsAsync(o,!0))return await s.bulkUpdateState(Jo(e,{[Vr]:r}),t);throw new Error(`Subgraph "${o}" not found`)}let i=async(o,s)=>{let c=this.config?$t(this.config,o):o,l=await r.getTuple(c),u=l!==void 0?wn(l.checkpoint):Go(),d={...l?.checkpoint.channel_versions},f=l?.metadata?.step??-1,p=Jo(c,{checkpoint_ns:c.configurable?.checkpoint_ns??""}),m=c.metadata??{};l?.config.configurable&&(p=Jo(c,l.config.configurable),m={...l.metadata,...m});let{values:h,asNode:_}=s[0];if(h==null&&_===void 0){if(s.length>1)throw new ve("Cannot create empty checkpoint with multiple updates");return Na(await r.put(p,xn(u,void 0,f),{source:"update",step:f+1,parents:l?.metadata?.parents??{}},{}),l?l.metadata:void 0)}let y=await $c(this.channels,u,{saver:r,config:l?.config??p});if(h===null&&_==="__end__"){if(s.length>1)throw new ve("Cannot apply multiple updates when clearing state");if(l){let C=Ma(u,l.pendingWrites||[],this.nodes,y,l.config,!0,{step:(l.metadata?.step??-1)+1,checkpointer:r,store:this.store}),b=(l.pendingWrites||[]).filter(B=>B[0]===ir).map(B=>B.slice(1));b.length>0&&hr(u,y,[{name:Pn,writes:b,triggers:[]}],r.getNextVersion.bind(r),this.triggerToNodes);for(let[B,L,q]of l.pendingWrites||[])["__error__","__interrupt__",Ja].includes(L)||B in C&&C[B].writes.push([L,q]);hr(u,y,Object.values(C),r.getNextVersion.bind(r),this.triggerToNodes)}return Na(await r.put(p,xn(u,y,f),{...m,source:"update",step:f+1,parents:l?.metadata?.parents??{}},Pc(d,u.channel_versions)),l?l.metadata:void 0)}if(_==="__copy__"){if(s.length>1)throw new ve("Cannot copy checkpoint with multiple updates");if(l==null)throw new ve("Cannot copy a non-existent checkpoint");let C=L=>!Array.isArray(L)||L.length===0?!1:L.every(q=>Array.isArray(q)&&q.length===2),b=xn(u,void 0,f),B=await r.put(l.parentConfig??Jo(l.config,{checkpoint_id:void 0}),b,{source:"fork",step:f+1,parents:l.metadata?.parents??{}},{});if(C(h)){let L=Ma(b,l.pendingWrites,this.nodes,y,B,!1,{step:f+2}),q=Object.values(L).reduce((Se,{name:Oe,id:mt})=>(Se[Oe]??=[],Se[Oe].push({id:mt}),Se),{}),ae=h.reduce((Se,Oe)=>{let[mt,ye]=Oe;Se[ye]??=[];let V=Se[ye].length,Y=q[ye]?.[V]?.id;return Se[ye].push({values:mt,asNode:ye,taskId:Y}),Se},{});return i(Na(B,l.metadata),Object.values(ae).flat())}return Na(B,l.metadata)}if(_==="__input__"){if(s.length>1)throw new ve("Cannot apply multiple updates when updating as input");let C=await kn(Ih(this.inputChannels,h));if(C.length===0)throw new ve(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);hr(u,y,[{name:Pn,writes:C,triggers:[]}],r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let b=l?.metadata?.step!=null?l.metadata.step+1:-1,B=await r.put(p,xn(u,y,b),{source:"input",step:b,parents:l?.metadata?.parents??{}},Pc(d,u.channel_versions));return await r.putWrites(B,C,Mn(Pn,u.id)),Na(B,l?l.metadata:void 0)}if(c.configurable?.checkpoint_id===void 0&&l?.pendingWrites!==void 0&&l.pendingWrites.length>0){let C=Ma(u,l.pendingWrites,this.nodes,y,l.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(l.metadata?.step??-1)+1}),b=(l.pendingWrites??[]).filter(L=>L[0]===ir).map(L=>L.slice(1));b.length>0&&hr(l.checkpoint,y,[{name:Pn,writes:b,triggers:[]}],void 0,this.triggerToNodes);for(let[L,q,ae]of l.pendingWrites)["__error__","__interrupt__",Ja].includes(q)||C[L]===void 0||C[L].writes.push([q,ae]);let B=Object.values(C).filter(L=>L.writes.length>0);B.length>0&&hr(u,y,B,void 0,this.triggerToNodes)}let w=Object.values(u.versions_seen).map(C=>Object.values(C)).flat().find(C=>!!C),x=[];if(s.length===1){let{values:C,asNode:b,taskId:B}=s[0];if(b===void 0&&Object.keys(this.nodes).length===1)[b]=Object.keys(this.nodes);else if(b===void 0&&w===void 0)typeof this.inputChannels=="string"&&this.nodes[this.inputChannels]!==void 0&&(b=this.inputChannels);else if(b===void 0){let L=Object.entries(u.versions_seen).map(([q,ae])=>Object.values(ae).map(Se=>[Se,q])).flat().filter(([q,ae])=>ae!==Le).sort(([q],[ae])=>ah(q,ae));L&&(L.length===1?b=L[0][1]:L[L.length-1][0]!==L[L.length-2][0]&&(b=L[L.length-1][1]))}if(b===void 0)throw new ve('Ambiguous update, specify "asNode"');x.push({values:C,asNode:b,taskId:B})}else for(let{asNode:C,values:b,taskId:B}of s){if(C==null)throw new ve('"asNode" is required when applying multiple updates');x.push({values:b,asNode:C,taskId:B})}let S=[];for(let{asNode:C,values:b,taskId:B}of x){if(this.nodes[C]===void 0)throw new ve(`Node "${C.toString()}" does not exist`);let L=this.nodes[C].getWriters();if(!L.length)throw new ve(`No writers found for node "${C.toString()}"`);S.push({name:C,input:b,proc:L.length>1?Lr.from(L,{omitSequenceTags:!0}):L[0],writes:[],triggers:[Le],id:B??Mn("__interrupt__",u.id),writers:[]})}for(let C of S)await C.proc.invoke(C.input,Ee({...c,store:c?.store??this.store},{runName:c.runName??`${this.getName()}UpdateState`,configurable:{[Ft]:b=>C.writes.push(...b),[er]:(b,B=!1)=>Nc(u,y,C,b,B)}}));for(let C of S){let b=C.writes.filter(B=>B[0]!==nr);l!==void 0&&b.length>0&&await r.putWrites(p,b,C.id)}hr(u,y,S,r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let $=Pc(d,u.channel_versions),P=await r.put(p,xn(u,y,f+1),{source:"update",step:f+1,parents:l?.metadata?.parents??{}},$);for(let C of S){let b=C.writes.filter(B=>B[0]===nr);b.length>0&&await r.putWrites(P,b,C.id)}return Na(P,l?l.metadata:void 0)},a=e;for(let{updates:o}of t)a=await i(a,o);return a}async updateState(e,t,r){return this.bulkUpdateState(e,[{updates:[{values:t,asNode:r}]}])}_defaults(e){let{debug:t,streamMode:r,inputKeys:n,outputKeys:i,interruptAfter:a,interruptBefore:o,...s}=e,c=!0,l=t!==void 0?t:this.debug,u=i;u===void 0?u=this.streamChannelsAsIs:CS(u,this.channels);let d=n;d===void 0?d=this.inputChannels:CS(d,this.channels);let f=o??this.interruptBefore??[],p=a??this.interruptAfter??[],m;r!==void 0?(m=Array.isArray(r)?r:[r],c=typeof r=="string"):(e.configurable?.__pregel_task_id!==void 0?m=["values"]:m=this.streamMode,c=!0);let h;if(this.checkpointer===!1)h=void 0;else if(e!==void 0&&e.configurable?.__pregel_checkpointer!==void 0)h=e.configurable[Vr];else{if(this.checkpointer===!0)throw new Error("checkpointer: true cannot be used for root graphs.");h=this.checkpointer}let _=e.store??this.store,y=e.cache??this.cache;if(e.durability!=null&&e.checkpointDuring!=null)throw new Error("Cannot use both `durability` and `checkpointDuring` at the same time.");let w=(()=>{if(e.checkpointDuring!=null)return e.checkpointDuring===!1?"exit":"async"})(),x=e.durability??w??e?.configurable?.__pregel_durability??"async";return[l,m,d,u,s,f,p,h,_,c,y,x]}async stream(e,t){let r=new AbortController,n=ph()?.configurable;n?.__pregel_read!==void 0&&t?.configurable?.__pregel_read===void 0&&(t={...t,configurable:{...n,...t?.configurable}});let i={recursionLimit:this.config?.recursionLimit,...t,signal:Ra(t?.signal,r.signal).signal},a=await super.stream(e,i);return new Rh(t?.encoding==="text/event-stream"?SM(a):a,r)}async#e(e,t){let{version:r,encoding:n,transformers:i,...a}=t,o={recursionLimit:this.config?.recursionLimit,...a,configurable:{...this.config?.configurable,...a?.configurable},version:r,streamMode:tS,subgraphs:!0,encoding:void 0},s=this.stream(e,o),c=fS({[Symbol.asyncIterator]:async function*(){let l=await s;for await(let u of l)yield u}},[...this.streamTransformers??[],...i??[]]);if(n==="text/event-stream"){let l=new AbortController;return l.signal.addEventListener("abort",()=>c.abort(l.signal.reason),{once:!0}),new Rh(Y9(c),l)}return c}streamEvents(e,t,r){if(t.version==="v3")return this.#e(e,t);let n=new AbortController,i={recursionLimit:this.config?.recursionLimit,...t,signal:Ra(t?.signal,n.signal).signal};return new Rh(super.streamEvents(e,i,r),n)}async _validateInput(e){return e}async _validateContext(e){return e}async*_streamIterator(e,t){let r="version"in(t??{})?void 0:t?.encoding??void 0,n=t?.subgraphs,i=t?.version==="v3",a=Ec(this.config,t);if(a.recursionLimit===void 0||a.recursionLimit<1)throw new Error('Passed "recursionLimit" must be at least 1.');if(this.checkpointer!==void 0&&this.checkpointer!==!1&&a.configurable===void 0)throw new Error('Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"');let o=await this._validateInput(e),{runId:s,...c}=a,[l,u,,d,f,p,m,h,_,y,w,x]=this._defaults(c);f.metadata={ls_integration:"langgraph",...f.metadata},typeof f.context<"u"?f.context=await this._validateContext(f.context):f.configurable=await this._validateContext(f.configurable);let S=new kS({modes:new Set(u)});if(this.checkpointer===!0){f.configurable??={};let ae=f.configurable.checkpoint_ns??"";f.configurable[Cr]=ae.split("|").map(Se=>Se.split(":")[0]).join("|")}if(u.includes("messages")){let ae=i?new RM(Oe=>S.push(Oe)):new OM(Oe=>S.push(Oe)),{callbacks:Se}=f;if(Se===void 0)f.callbacks=[ae];else if(Array.isArray(Se))f.callbacks=Se.concat(ae);else{let Oe=Se.copy();Oe.addHandler(ae,!0),f.callbacks=Oe}}if(u.includes("tools")){let ae=new xM(Oe=>S.push(Oe)),{callbacks:Se}=f;if(Se===void 0)f.callbacks=[ae];else if(Array.isArray(Se))f.callbacks=Se.concat(ae);else{let Oe=Se.copy();Oe.addHandler(ae,!0),f.callbacks=Oe}}f.writer??=ae=>{if(!u.includes("custom"))return;let Se=ph()?.configurable?.[Cr]?.split("|").slice(0,-1);S.push([Se??[],"custom",ae])},f.interrupt??=this.userInterrupt??gS,f.serverInfo==null&&(f.serverInfo=eZ(f)),f.control??=new eS;let $={tracerInheritableMetadata:nZ(f)},P=await(await Xe._configureSync(f?.callbacks,void 0,f?.tags,void 0,f?.metadata,void 0,$))?.handleChainStart(this.toJSON(),oM(e,"input"),s,void 0,void 0,void 0,f?.runName??this.getName()),C=kc(this.channels),b,B,q=(async()=>{try{b=await TM.initialize({input:o,config:f,checkpointer:h,nodes:this.nodes,channelSpecs:C,outputKeys:d,streamKeys:this.streamChannelsAsIs,store:_,cache:w,stream:S,interruptAfter:m,interruptBefore:p,manager:P,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:x});let ae=new jM({loop:b,nodeFinished:f.configurable?.[WS]});t?.subgraphs&&(b.config.configurable={...b.config.configurable,[Dc]:b.stream}),await this._runLoop({loop:b,runner:ae,debug:l,config:f}),x==="sync"&&await Promise.all(b?.checkpointerPromises??[])}catch(ae){B=ae}finally{try{b&&(await b.store?.stop(),await b.cache?.stop()),await Promise.all(b?.checkpointerPromises??[])}catch(ae){B=B??ae}B?(await new Promise(ae=>{queueMicrotask(ae)}),S.error(B)):S.close()}})();try{for await(let ae of S){if(ae===void 0)throw new Error("Data structure error.");let[Se,Oe,mt]=ae,ye="version"in(t??{});if(u.includes(Oe)||Oe==="checkpoints"&&Ic(mt)&&(i||ye&&n&&u.includes("values"))){if(r==="text/event-stream"){n?yield[Se,Oe,mt]:yield[null,Oe,mt];continue}n&&!y?yield[Se,Oe,mt]:y?n?yield[Se,mt]:yield mt:yield[Oe,mt]}}}catch(ae){throw await P?.handleChainError(B),ae}finally{await q}await P?.handleChainEnd(b?.output??{},s,void 0,void 0,void 0)}async invoke(e,t){let r=t?.streamMode??"values",n={...t,outputKeys:t?.outputKeys??this.outputChannels,streamMode:r,encoding:void 0},i=[],a=await this.stream(e,n),o=[],s;for await(let c of a)r==="values"?Ha(c)?o.push(c[Le]):s=c:i.push(c);if(r==="values"){if(o.length>0){let c=o.flat(1);if(s==null)return{[Le]:c};if(typeof s=="object")return{...s,[Le]:c}}return s}return i}async _runLoop(e){let{loop:t,runner:r,debug:n,config:i}=e,a;try{for(;await t.tick({inputKeys:this.inputChannels});){for(let{task:o}of await t._matchCachedWrites())t._outputWrites(o.id,o.writes,!0);n&&yM(t.checkpointMetadata.step,t.channels,this.streamChannelsList),n&&Lu(t.step,Object.values(t.tasks)),await r.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(o,s)=>{n&&vM(o,s,this.streamChannelsList)},maxConcurrency:i.maxConcurrency,signal:i.signal})}if(t.status==="draining")throw t.control==null?new Error("Draining status requires run control"):new Ku(t.control.drainReason??"shutdown");if(t.status==="out_of_steps")throw new Vh([`Recursion limit of ${i.recursionLimit} reached`,"without hitting a stop condition. You can increase the",'limit by setting the "recursionLimit" config key.'].join(" "),{lc_error_code:"GRAPH_RECURSION_LIMIT"})}catch(o){if(a=o,!await t.finishAndHandleError(a))throw o}finally{a===void 0&&await t.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};function eZ(e){let t=e.metadata??{},r=e.configurable??{},n=r.assistant_id??t.assistant_id,i=r.graph_id??t.graph_id,a=r.langgraph_auth_user,o;if(a!=null&&typeof a=="object"&&"identity"in a&&(o=a),n!=null||i!=null||o!=null)return{assistantId:n!=null?String(n):"",graphId:i!=null?String(i):"",user:o}}var tZ=new Set(["key","token","secret","password","auth"]);function rZ(e,t){let r=e.toLowerCase(),n=!1;for(let i of tZ)if(r.includes(i)){n=!0;break}return e.startsWith("__")||!(typeof t=="string"||typeof t=="number"||typeof t=="boolean")||n}function nZ(e){let t=e.configurable;if(!t)return;let r={};for(let[n,i]of Object.entries(t))rZ(n,i)||(r[n]=i);return Object.keys(r).length>0?r:void 0}var In=class LM extends yt{lc_graph_name="EphemeralValue";guard;value=[];constructor(t=!0){super(),this.guard=t}fromCheckpoint(t){let r=new LM(this.guard);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0){let r=this.value.length>0;return this.value=[],r}if(t.length!==1&&this.guard)throw new ve("EphemeralValue can only receive one value per step.");return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new je;return this.value[0]}checkpoint(){if(this.value.length===0)throw new je;return this.value[0]}isAvailable(){return this.value.length!==0}};var OS=class{path;ends;constructor(e){se.isRunnable(e.path)?this.path=e.path:this.path=at(e.path),this.ends=Array.isArray(e.pathMap)?e.pathMap.reduce((t,r)=>(t[r]=r,t),{}):e.pathMap}run(e,t){return ut.registerWriter(new Rt({name:"<branch_run>",trace:!1,func:async(r,n)=>{try{return await this._route(r,n,e,t)}catch(i){throw i.name===Xu.unminifiable_name&&console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
450
+ NodeInterrupt should only be thrown inside a node, not in edge conditions.`),i}}}))}async _route(e,t,r,n){let i=await this.path.invoke(n?n(t):e,t);Array.isArray(i)||(i=[i]);let a;if(this.ends?a=i.map(o=>wt(o)?o:this.ends[o]):a=i,a.some(o=>!o))throw new Error("Branch condition returned unknown or null destination");if(a.filter(wt).some(o=>o.node==="__end__"))throw new ve("Cannot send a packet to the END node");return await r(a,t)??e}},PS=class{nodes;edges;branches;entryPoint;compiled=!1;constructor(){this.nodes={},this.edges=new Set,this.branches={}}warnIfCompiled(e){this.compiled&&console.warn(e)}get allEdges(){return this.edges}addNode(...e){function t(n){return n.length>=1&&typeof n[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[n,i,a]of r){for(let s of["|",":"])if(n.includes(s))throw new Error(`"${s}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),n in this.nodes)throw new Error(`Node \`${n}\` already present.`);if(n==="__end__")throw new Error(`Node \`${n}\` is reserved.`);let o=at(i);this.nodes[n]={runnable:o,metadata:a?.metadata,subgraphs:ju(o)?[o]:a?.subgraphs,ends:a?.ends}}return this}addEdge(e,t){if(this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),e==="__end__")throw new Error("END cannot be a start node");if(t==="__start__")throw new Error("START cannot be an end node");if(Array.from(this.edges).some(([r])=>r===e)&&!("channels"in this))throw new Error(`Already found path for ${e}. For multiple edges, use StateGraph.`);return this.edges.add([e,t]),this}addConditionalEdges(e,t,r){let n=typeof e=="object"?e:{source:e,path:t,pathMap:r};this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),se.isRunnable(n.path)||(n.path=at(n.path));let i=n.path.getName()==="RunnableLambda"?"condition":n.path.getName();if(this.branches[n.source]&&this.branches[n.source][i])throw new Error(`Condition \`${i}\` already present for node \`${e}\``);return this.branches[n.source]??={},this.branches[n.source][i]=new OS(n),this}setEntryPoint(e){return this.warnIfCompiled("Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(Je,e)}setFinishPoint(e){return this.warnIfCompiled("Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(e,Qe)}compile({checkpointer:e,interruptBefore:t,interruptAfter:r,name:n,transformers:i}={}){this.validate([...Array.isArray(t)?t:[],...Array.isArray(r)?r:[]]);let a=new NS({builder:this,checkpointer:e,interruptAfter:r,interruptBefore:t,autoValidate:!1,nodes:{},channels:{[Je]:new In,[Qe]:new In},inputChannels:Je,outputChannels:Qe,streamChannels:[],streamMode:"values",name:n,streamTransformers:i});for(let[o,s]of Object.entries(this.nodes))a.attachNode(o,s);for(let[o,s]of this.edges)a.attachEdge(o,s);for(let[o,s]of Object.entries(this.branches))for(let[c,l]of Object.entries(s))a.attachBranch(o,c,l);return a.validate()}validate(e){let t=new Set([...this.allEdges].map(([n,i])=>n));for(let[n]of Object.entries(this.branches))t.add(n);for(let n of t)if(n!=="__start__"&&!(n in this.nodes))throw new Error(`Found edge starting at unknown node \`${n}\``);let r=new Set([...this.allEdges].map(([n,i])=>i));for(let[n,i]of Object.entries(this.branches))for(let a of Object.values(i))if(a.ends!=null)for(let o of Object.values(a.ends))r.add(o);else{r.add(Qe);for(let o of Object.keys(this.nodes))o!==n&&r.add(o)}for(let n of Object.values(this.nodes))for(let i of n.ends??[])r.add(i);if(Object.values(this.nodes).some(n=>n.isErrorHandler))for(let n of Object.keys(this.nodes))r.add(n);for(let n of Object.keys(this.nodes))if(!this.nodes[n].isErrorHandler&&!r.has(n))throw new Hh([`Node \`${n}\` is not reachable.`,"","If you are returning Command objects from your node,",'make sure you are passing names of potential destination nodes as an "ends" array','into ".addNode(..., { ends: ["node1", "node2"] })".'].join(`
451
+ `),{lc_error_code:"UNREACHABLE_NODE"});for(let n of r)if(n!=="__end__"&&!(n in this.nodes))throw new Error(`Found edge ending at unknown node \`${n}\``);if(e){for(let n of e)if(!(n in this.nodes))throw new Error(`Interrupt node \`${n}\` is not present`)}this.compiled=!0}},NS=class extends Dh{builder;constructor({builder:e,...t}){super(t),this.builder=e}withConfig(e){return super.withConfig(e)}attachNode(e,t){this.channels[e]=new In,this.nodes[e]=new $n({channels:[],triggers:[],metadata:t.metadata,subgraphs:t.subgraphs,ends:t.ends}).pipe(t.runnable).pipe(new ut([{channel:e,value:Ir}],[ht])),this.streamChannels.push(e)}attachEdge(e,t){if(t==="__end__"){if(e==="__start__")throw new Error("Cannot have an edge from START to END");this.nodes[e].writers.push(new ut([{channel:Qe,value:Ir}],[ht]))}else this.nodes[t].triggers.push(e),this.nodes[t].channels.push(e)}attachBranch(e,t,r){e==="__start__"&&!this.nodes.__start__&&(this.nodes[Je]=UM.subscribeTo(Je,{tags:[ht]})),this.nodes[e].pipe(r.run(i=>new ut(i.map(a=>wt(a)?a:{channel:a==="__end__"?Qe:`branch:${e}:${t}:${a}`,value:Ir}),[ht])));let n=r.ends?Object.values(r.ends):Object.keys(this.nodes);for(let i of n)if(i!=="__end__"){let a=`branch:${e}:${t}:${i}`;this.channels[a]=new In,this.nodes[i].triggers.push(a),this.nodes[i].channels.push(a)}}async getGraphAsync(e){let t=e?.xray,r=new Lo,n={[Je]:r.addNode({schema:rn.any()},Je)},i={},a={};t&&(a=Object.fromEntries((await kn(this.getSubgraphsAsync())).filter(l=>FM(l[1]))));let o=[];function s(l,u,d,f=!1){if(u==="__end__"&&i.__end__===void 0&&(i[Qe]=r.addNode({schema:rn.any()},Qe)),n[l]!==void 0){if(i[u]===void 0)throw new Error(`End node ${u} not found!`);return o.push({src:l,dest:u,conditional:f}),r.addEdge(n[l],i[u],d!==u?d:void 0,f)}}for(let[l,u]of Object.entries(this.builder.nodes)){let d=Tt(l),f=u.runnable,p=u.metadata??{};if(this.interruptBefore?.includes(l)&&this.interruptAfter?.includes(l)?p.__interrupt="before,after":this.interruptBefore?.includes(l)?p.__interrupt="before":this.interruptAfter?.includes(l)&&(p.__interrupt="after"),t){let m=typeof t=="number"?t-1:t,h=a[l]!==void 0?await a[l].getGraphAsync({...e,xray:m}):f.getGraph(e);if(h.trimFirstNode(),h.trimLastNode(),Object.keys(h.nodes).length>1){let w=function(S){return S?S.lc_runnable:!1},x=function(S,$){if(S!==void 0&&!di(S))return S;if(w($))try{let P=$.getName();return P=P.startsWith("Runnable")?P.slice(8):P,P}catch{return $.getName()}else return $.name??"UnknownSchema"},[_,y]=r.extend(h,d);if(_===void 0)throw new Error(`Could not extend subgraph "${l}" due to missing entrypoint.`);y!==void 0&&(n[d]={name:x(y.id,y.data),...y}),i[d]={name:x(_.id,_.data),..._}}else{let _=r.addNode(f,d,p);n[d]=_,i[d]=_}}else{let m=r.addNode(f,d,p);n[d]=m,i[d]=m}}let c=[...this.builder.allEdges].sort(([l],[u])=>l<u?-1:u>l?1:0);for(let[l,u]of c)s(Tt(l),Tt(u));for(let[l,u]of Object.entries(this.builder.branches)){let d={...Object.fromEntries(Object.keys(this.builder.nodes).filter(f=>f!==l).map(f=>[Tt(f),Tt(f)])),[Qe]:Qe};for(let f of Object.values(u)){let p;f.ends!==void 0?p=f.ends:p=d;for(let[m,h]of Object.entries(p))s(Tt(l),Tt(h),m,!0)}}for(let[l,u]of Object.entries(this.builder.nodes))if(u.ends!==void 0)for(let d of u.ends)s(Tt(l),Tt(d),void 0,!0);return BM(this.builder.nodes,o,s),r}getGraph(e){let t=e?.xray,r=new Lo,n={[Je]:r.addNode({schema:rn.any()},Je)},i={},a={};t&&(a=Object.fromEntries(Pa(this.getSubgraphs()).filter(l=>FM(l[1]))));let o=[];function s(l,u,d,f=!1){if(u==="__end__"&&i.__end__===void 0&&(i[Qe]=r.addNode({schema:rn.any()},Qe)),n[l]!==void 0){if(i[u]===void 0)throw new Error(`End node ${u} not found!`);return o.push({src:l,dest:u,conditional:f}),r.addEdge(n[l],i[u],d!==u?d:void 0,f)}}for(let[l,u]of Object.entries(this.builder.nodes)){let d=Tt(l),f=u.runnable,p=u.metadata??{};if(this.interruptBefore?.includes(l)&&this.interruptAfter?.includes(l)?p.__interrupt="before,after":this.interruptBefore?.includes(l)?p.__interrupt="before":this.interruptAfter?.includes(l)&&(p.__interrupt="after"),t){let m=typeof t=="number"?t-1:t,h=a[l]!==void 0?a[l].getGraph({...e,xray:m}):f.getGraph(e);if(h.trimFirstNode(),h.trimLastNode(),Object.keys(h.nodes).length>1){let w=function(S){return S?S.lc_runnable:!1},x=function(S,$){if(S!==void 0&&!di(S))return S;if(w($))try{let P=$.getName();return P=P.startsWith("Runnable")?P.slice(8):P,P}catch{return $.getName()}else return $.name??"UnknownSchema"},[_,y]=r.extend(h,d);if(_===void 0)throw new Error(`Could not extend subgraph "${l}" due to missing entrypoint.`);y!==void 0&&(n[d]={name:x(y.id,y.data),...y}),i[d]={name:x(_.id,_.data),..._}}else{let _=r.addNode(f,d,p);n[d]=_,i[d]=_}}else{let m=r.addNode(f,d,p);n[d]=m,i[d]=m}}let c=[...this.builder.allEdges].sort(([l],[u])=>l<u?-1:u>l?1:0);for(let[l,u]of c)s(Tt(l),Tt(u));for(let[l,u]of Object.entries(this.builder.branches)){let d={...Object.fromEntries(Object.keys(this.builder.nodes).filter(f=>f!==l).map(f=>[Tt(f),Tt(f)])),[Qe]:Qe};for(let f of Object.values(u)){let p;f.ends!==void 0?p=f.ends:p=d;for(let[m,h]of Object.entries(p))s(Tt(l),Tt(h),m,!0)}}for(let[l,u]of Object.entries(this.builder.nodes))if(u.ends!==void 0)for(let d of u.ends)s(Tt(l),Tt(d),void 0,!0);return BM(this.builder.nodes,o,s),r}};function FM(e){return typeof e.attachNode=="function"&&typeof e.attachEdge=="function"}function Tt(e){return e==="subgraph"?`"${e}"`:e}function BM(e,t,r){let n=new Set(t.map(a=>a.src)),i=[...new Set(t.filter(a=>!a.conditional&&a.dest!=="__end__").map(a=>a.dest))].sort();for(let a of i){if(n.has(a))continue;let o=Object.keys(e).find(s=>Tt(s)===a);o!==void 0&&e[o]?.isErrorHandler||r(a,Qe)}}function Mi(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function RS(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function iZ(e){return Mi(e)&&RS(e)}function ja(e){if(RS(e))try{return e["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function ji(e){if(e!=null&&Mi(e))try{let t=e["~standard"].validate(void 0);if(t&&typeof t=="object"&&!("then"in t&&typeof t.then=="function")){let r=t;if(!r.issues){let n=r.value;return()=>n}}}catch{}}var aZ=e=>e!=null&&e.lc_graph_name==="DeltaChannel",zh=class VM extends yt{lc_graph_name="DeltaChannel";value;reducer;snapshotFrequency;initialValueFactory;constructor(t,r){super();let n=r?.snapshotFrequency??1e3;if(!Number.isInteger(n)||n<=0)throw new Error(`snapshotFrequency must be a positive integer, got ${n}`);this.reducer=t,this.snapshotFrequency=n,this.initialValueFactory=r?.initialValueFactory??(()=>[]),this.value=void 0}fromCheckpoint(t){let r=new VM(this.reducer,{snapshotFrequency:this.snapshotFrequency,initialValueFactory:this.initialValueFactory});return t===void 0?r.value=this.initialValueFactory():Qh(t)?r.value=t.value:r.value=t,r}replayWrites(t){let r=t.map(o=>o[2]);if(r.length===0)return;let n=this.value,i=0;for(let o=0;o<r.length;o+=1){let[s,c]=sn(r[o]);s&&(n=c??this.initialValueFactory(),i=o+1)}let a=r.slice(i);this.value=a.length>0?this.reducer(n,a):n}update(t){if(t.length===0)return!1;let r,n=!1;for(let a of t)if(Za(a)){if(n)throw new ve("Can receive only one Overwrite value per step.");n=!0,[,r]=sn(a)}if(n)return this.value=r??this.initialValueFactory(),!0;let i=this.value===void 0?this.initialValueFactory():this.value;return this.value=this.reducer(i,t),!0}get(){if(this.value===void 0)throw new je;return this.value}checkpoint(){}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:!aZ(t)||this.snapshotFrequency!==t.snapshotFrequency?!1:this.reducer===t.reducer}};var MS=Symbol.for("langgraph.channel.missing"),Uh=class ZM extends yt{lc_graph_name="UntrackedValue";guard;_value=MS;initialValueFactory;constructor(t){super(),this.guard=t?.guard??!0,this.initialValueFactory=t?.initialValueFactory,this.initialValueFactory&&(this._value=this.initialValueFactory())}fromCheckpoint(t){return new ZM({guard:this.guard,initialValueFactory:this.initialValueFactory})}update(t){if(t.length===0)return!1;if(t.length!==1&&this.guard)throw new ve("UntrackedValue(guard=true) can receive only one value per step. Use guard=false if you want to store any one of multiple values.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this._value=t[t.length-1],!0}get(){if(this._value===MS)throw new je;return this._value}checkpoint(){}isAvailable(){return this._value!==MS}};var Da=(e,t)=>e.size===t.size&&[...e].every(r=>t.has(r)),jS=class HM extends yt{lc_graph_name="NamedBarrierValue";names;seen;constructor(t){super(),this.names=t,this.seen=new Set}fromCheckpoint(t){let r=new HM(this.names);return typeof t<"u"&&(r.seen=new Set(t)),r}update(t){let r=!1;for(let n of t)if(this.names.has(n))this.seen.has(n)||(this.seen.add(n),r=!0);else throw new ve(`Value ${JSON.stringify(n)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!Da(this.names,this.seen))throw new je}checkpoint(){return[...this.seen]}consume(){return this.seen&&this.names&&Da(this.seen,this.names)?(this.seen=new Set,!0):!1}isAvailable(){return!!this.names&&Da(this.names,this.seen)}},DS=class GM extends yt{lc_graph_name="NamedBarrierValueAfterFinish";names;seen;finished;constructor(t){super(),this.names=t,this.seen=new Set,this.finished=!1}fromCheckpoint(t){let r=new GM(this.names);if(typeof t<"u"){let[n,i]=t;r.seen=new Set(n),r.finished=i}return r}update(t){let r=!1;for(let n of t)if(this.names.has(n)&&!this.seen.has(n))this.seen.add(n),r=!0;else if(!this.names.has(n))throw new ve(`Value ${JSON.stringify(n)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!this.finished||!Da(this.names,this.seen))throw new je}checkpoint(){return[[...this.seen],this.finished]}consume(){return this.finished&&this.seen&&this.names&&Da(this.seen,this.names)?(this.seen=new Set,this.finished=!1,!0):!1}finish(){return!this.finished&&this.names&&Da(this.names,this.seen)?(this.finished=!0,!0):!1}isAvailable(){return this.finished&&!!this.names&&Da(this.names,this.seen)}};var zS=Symbol.for("langgraph.state.reduced_value"),Di=class{[zS]=!0;valueSchema;inputSchema;reducer;jsonSchemaExtra;constructor(e,t){this.reducer=t.reducer,this.jsonSchemaExtra=t.jsonSchemaExtra,this.valueSchema=e,this.inputSchema="inputSchema"in t?t.inputSchema:e,this.jsonSchemaExtra=t.jsonSchemaExtra}static isInstance(e){return typeof e=="object"&&e!==null&&zS in e&&e[zS]===!0}};var WM=Symbol.for("langgraph.state.untracked_value"),qo=class{[WM]=!0;schema;guard;constructor(e,t){this.schema=e,this.guard=t?.guard??!0}static isInstance(e){return typeof e=="object"&&e!==null&&WM in e}};var US=Symbol.for("langgraph.state.delta_value"),zi=class{[US]=!0;valueSchema;inputSchema;reducer;snapshotFrequency;jsonSchemaExtra;constructor(e,t){this.reducer=t.reducer,this.valueSchema=e,this.inputSchema="inputSchema"in t?t.inputSchema:e,this.snapshotFrequency=t.snapshotFrequency,this.jsonSchemaExtra=t.jsonSchemaExtra}static isInstance(e){return typeof e=="object"&&e!==null&&US in e&&e[US]===!0}};var LS=Symbol.for("langgraph.state.state_schema"),Tn=class{[LS]=!0;constructor(e){this.fields=e}getChannels(){let e={};for(let[t,r]of Object.entries(this.fields))if(zi.isInstance(r)){let n=ji(r.valueSchema);e[t]=new zh(r.reducer,{snapshotFrequency:r.snapshotFrequency,initialValueFactory:n})}else if(Di.isInstance(r)){let n=ji(r.valueSchema);e[t]=new Pi(r.reducer,n)}else if(qo.isInstance(r)){let n=r.schema?ji(r.schema):void 0;e[t]=new Uh({guard:r.guard,initialValueFactory:n})}else if(Mi(r))e[t]=new Sn(ji(r));else throw new Error(`Invalid state field "${t}": must be a schema, ReducedValue, DeltaValue, UntrackedValue, or ManagedValue`);return e}getJsonSchema(){let e={},t=[];for(let[r,n]of Object.entries(this.fields)){let i;if(zi.isInstance(n)||Di.isInstance(n)?(i=ja(n.valueSchema),n.jsonSchemaExtra&&(i={...i??{},...n.jsonSchemaExtra})):qo.isInstance(n)?i=n.schema?ja(n.schema):void 0:Mi(n)&&(i=ja(n)),i){e[r]=i;let a=!1;zi.isInstance(n)||Di.isInstance(n)?a=ji(n.valueSchema)!==void 0:qo.isInstance(n)?a=n.schema?ji(n.schema)!==void 0:!1:a=ji(n)!==void 0,a||t.push(r)}}return{type:"object",properties:e,required:t.length>0?t:void 0}}getInputJsonSchema(){let e={};for(let[t,r]of Object.entries(this.fields)){let n;zi.isInstance(r)||Di.isInstance(r)?(n=ja(r.inputSchema),r.jsonSchemaExtra&&(n={...n??{},...r.jsonSchemaExtra})):qo.isInstance(r)?n=r.schema?ja(r.schema):void 0:Mi(r)&&(n=ja(r)),n&&(e[t]=n)}return{type:"object",properties:e}}getChannelKeys(){return Object.entries(this.fields).map(([e])=>e)}getAllKeys(){return Object.keys(this.fields)}async validateInput(e){if(e==null||typeof e!="object")return e;let t={};for(let[r,n]of Object.entries(e)){let i=this.fields[r];if(i===void 0){t[r]=n;continue}let a;if(zi.isInstance(i)||Di.isInstance(i)){let[o,s]=sn(n);if(o){a=i.valueSchema;let c=await a["~standard"].validate(s);if(c.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(c.issues)}`);t[r]={[On]:c.value};continue}a=i.inputSchema}else qo.isInstance(i)?a=i.schema:Mi(i)&&(a=i);if(a){let o=await a["~standard"].validate(n);if(o.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(o.issues)}`);t[r]=o.value}else t[r]=n}return t}static isInstance(e){return typeof e=="object"&&e!==null&&LS in e&&e[LS]===!0}};var oZ="__remove_all__";function za(e,t){let r=Array.isArray(e)?e:[e],n=Array.isArray(t)?t:[t],i=r.map(kt),a=n.map(kt);for(let u of i)(u.id===null||u.id===void 0)&&(u.id=Xi(),u.lc_kwargs.id=u.id);let o;for(let u=0;u<a.length;u+=1){let d=a[u];(d.id===null||d.id===void 0)&&(d.id=Xi(),d.lc_kwargs.id=d.id),Nr.isInstance(d)&&d.id==="__remove_all__"&&(o=u)}if(o!=null)return a.slice(o+1);let s=[...i],c=new Map(s.map((u,d)=>[u.id,d])),l=new Set;for(let u of a){let d=c.get(u.id);if(d!==void 0)Nr.isInstance(u)?l.add(u.id):(l.delete(u.id),s[d]=u);else{if(Nr.isInstance(u))throw new Error(`Attempting to delete a message with an ID that doesn't exist ('${u.id}')`);c.set(u.id,s.length),s.push(u)}}return s.filter(u=>!l.has(u.id))}function FS(e,t){let r=[];for(let s of t)Array.isArray(s)?r.push(...s):r.push(s);let n=e.length>0&&Pe.isInstance(e[0])?e:e.map(kt),i=r.map(kt),a=new Map;for(let s=0;s<n.length;s+=1){let c=n[s].id;c!=null&&a.set(c,s)}let o=[...n];for(let s of i){let c=s.id;Nr.isInstance(s)&&c==="__remove_all__"?(o.length=0,a.clear()):c==null?o.push(s):Nr.isInstance(s)?a.has(c)&&(o[a.get(c)]=null,a.delete(c)):a.has(c)?o[a.get(c)]=s:(a.set(c,o.length),o.push(s))}return o.filter(s=>s!==null)}var JM=rn.custom().default(()=>[]),KM=rn.custom(),sZ=new Di(JM,{inputSchema:KM,reducer:za,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}}),cZ=new zi(JM,{inputSchema:KM,reducer:FS,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var lZ=class{_map=new Map;_extensionCache=new Map;get(e){return this._map.get(e)}extend(e,t){let r=this.get(e);this._map.set(e,t(r))}remove(e){return this._map.delete(e),this}has(e){return this._map.has(e)}getChannelsForSchema(e){let t={},r=xi(e);for(let[n,i]of Object.entries(r)){let a=this.get(i);a?.reducer?t[n]=new Pi(a.reducer.fn,a.default):t[n]=new Sn(a?.default)}return t}getExtendedChannelSchemas(e,t){if(Object.keys(t).length===0)return e;let r=Object.entries(t).filter(([,a])=>a===!0).sort(([a],[o])=>a.localeCompare(o)).map(([a,o])=>`${a}:${o}`).join("|"),n=this._extensionCache.get(r)??new Map;if(n.has(e))return n.get(e);let i=e;if(t.withReducerSchema||t.withJsonSchemaExtrasAsDescription){let a=Object.entries(xi(e)).map(([o,s])=>{let c=this.get(s),l=t.withReducerSchema?c?.reducer?.schema??s:s;if(t.withJsonSchemaExtrasAsDescription&&c?.jsonSchemaExtra){let u=Si(l)??Si(s),d=JSON.stringify({...c.jsonSchemaExtra,description:u});l=l.describe(`lg:${d}`)}return[o,l]});i=xp(e,Object.fromEntries(a)),lt(i)&&(i._def.unknownKeys="strip")}return t.asPartial&&(i=Sa(i)),n.set(e,i),this._extensionCache.set(r,n),i}},Fu=new lZ;function qM(e,t){if(t.reducer&&!t.default){let r=Sp(e);r!=null&&(t.default=r)}if(t.reducer){let r=Object.assign(e,{lg_reducer_schema:t.reducer?.schema??e});return Fu.extend(r,()=>t),r}else return Fu.extend(e,()=>t),e}function Xo(e){return e==null?!1:!!(Tn.isInstance(e)||Jt(e)||typeof e=="object"&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot"||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.values(e).every(t=>typeof t=="function"||X0(t)))}function XM(e){if(typeof e!="object"||e==null)return!1;let t=e,r="state"in t&&Xo(t.state),n="stateSchema"in t&&Xo(t.stateSchema),i="input"in t&&Xo(t.input);return!(!r&&!n&&!i||"input"in t&&t.input!=null&&!Xo(t.input)||"output"in t&&t.output!=null&&!Xo(t.output))}var Ui="__root__",Rc="__default_error_handler__",Lh=Symbol.for("langgraph.state.partial"),BS=class extends PS{channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=Fu;_configSchema;_configRuntimeSchema;_interrupt;_writer;_nodeDefaults={};constructor(e,t){super();let r=this._normalizeToStateGraphInit(e,t),n=r.state??r.stateSchema??r.input;if(!n)throw new Lc;let i=this._getChannelsFromSchema(n);this._schemaDefinition=i,Tn.isInstance(n)?this._schemaRuntimeDefinition=n:Jt(n)&&(this._schemaRuntimeDefinition=n),r.input?Tn.isInstance(r.input)?this._inputRuntimeDefinition=r.input:Jt(r.input)?this._inputRuntimeDefinition=r.input:this._inputRuntimeDefinition=Lh:this._inputRuntimeDefinition=Lh,r.output?Tn.isInstance(r.output)?this._outputRuntimeDefinition=r.output:Jt(r.output)?this._outputRuntimeDefinition=r.output:this._outputRuntimeDefinition=this._schemaRuntimeDefinition:this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let a=r.input?this._getChannelsFromSchema(r.input):i,o=r.output?this._getChannelsFromSchema(r.output):i;this._inputDefinition=a,this._outputDefinition=o,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),r.context&&Jt(r.context)&&(this._configRuntimeSchema=r.context),this._interrupt=r.interrupt,this._writer=r.writer}setNodeDefaults(e){return e.retryPolicy!==void 0&&(this._nodeDefaults.retryPolicy=e.retryPolicy),e.cachePolicy!==void 0&&(this._nodeDefaults.cachePolicy=typeof e.cachePolicy=="boolean"?e.cachePolicy?{}:void 0:e.cachePolicy),e.timeout!==void 0&&(this._nodeDefaults.timeout=Bi(e.timeout)),e.errorHandler!==void 0&&(this._nodeDefaults.errorHandler=e.errorHandler),this}_createDefaultErrorHandlerSpec(){let e=this._nodeDefaults.errorHandler;if(e!==void 0)return{runnable:new Rt({func:(t,r)=>{let n=r?.configurable?.[zc];return e(t,n,r)},name:Rc,trace:!1}),metadata:void 0,input:this._schemaDefinition,retryPolicy:void 0,cachePolicy:void 0,isErrorHandler:!0}}_normalizeToStateGraphInit(e,t){if(XM(e)){if(Jt(t)||dh.isInstance(t))return{...e,context:t};let r=t;return{...e,input:e.input??r?.input,output:e.output??r?.output,context:e.context??r?.context,interrupt:e.interrupt??r?.interrupt,writer:e.writer??r?.writer,nodes:e.nodes??r?.nodes}}if(Xo(e)){if(Jt(t)||dh.isInstance(t))return{state:e,context:t};let r=t;return{state:e,input:r?.input,output:r?.output,context:r?.context,interrupt:r?.interrupt,writer:r?.writer,nodes:r?.nodes}}if(dZ(e))return{state:uZ(e.channels)};throw new Lc}_getChannelsFromSchema(e){if(Tn.isInstance(e))return e.getChannels();if(Jt(e))return this._metaRegistry.getChannelsForSchema(e);if(typeof e=="object"&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot")return e.spec;if(typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0)return e;throw new Lc("Invalid schema type. Expected StateSchema, Zod object, AnnotationRoot, or StateDefinition.")}get allEdges(){return new Set([...this.edges,...Array.from(this.waitingEdges).flatMap(([e,t])=>e.map(r=>[r,t]))])}_addSchema(e){if(!this._schemaDefinitions.has(e)){this._schemaDefinitions.set(e,e);for(let[t,r]of Object.entries(e)){let n;if(typeof r=="function"?n=r():n=r,this.channels[t]!==void 0){if(!this.channels[t].equals(n)&&n.lc_graph_name!=="LastValue")throw new Error(`Channel "${t}" already exists with a different type.`)}else this.channels[t]=n}}}addNode(...e){function t(n){return n.length>=1&&typeof n[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]).map(([n,i])=>[n,i]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[n,i,a]of r){if(n in this.channels)throw new Error(`${n} is already being used as a state attribute (a.k.a. a channel), cannot also be used as a node name.`);for(let f of["|",":"])if(n.includes(f))throw new Error(`"${f}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),n in this.nodes)throw new Error(`Node \`${n}\` already present.`);if(n==="__end__"||n==="__start__")throw new Error(`Node \`${n}\` is reserved.`);let o=this._schemaDefinition;a?.input!==void 0&&(o=this._getChannelsFromSchema(a.input)),this._addSchema(o);let s;se.isRunnable(i)?s=i:typeof i=="function"?s=new Rt({func:i,name:n,trace:!1}):s=at(i);let c=a?.cachePolicy,l;c!==void 0&&(l=typeof c=="boolean"?c?{}:!1:c);let u;if(a?.errorHandler!==void 0){if(u=`__error_handler__${n}`,u in this.nodes)throw new Error(`Cannot add error handler to node \`${n}\`: the reserved name \`${u}\` is already in use. StateGraph registers \`__error_handler__<nodeName>\` when you pass \`errorHandler\` in addNode options. Remove or rename the existing node with that name (for example, you may have added it manually).`);let f=a.errorHandler,p={runnable:new Rt({func:(m,h)=>{let _=h?.configurable?.[zc];return f(m,_,h)},name:u,trace:!1}),metadata:void 0,input:o??this._schemaDefinition,retryPolicy:void 0,cachePolicy:void 0,isErrorHandler:!0};this.nodes[u]=p}let d={runnable:s,retryPolicy:a?.retryPolicy,cachePolicy:l,timeout:Bi(a?.timeout),metadata:a?.metadata,input:o??this._schemaDefinition,subgraphs:ju(s)?[s]:a?.subgraphs,ends:a?.ends,defer:a?.defer,errorHandlerNode:u};this.nodes[n]=d}return this}addEdge(e,t){if(typeof e=="string")return super.addEdge(e,t);this.compiled&&console.warn("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");for(let r of e){if(r==="__end__")throw new Error("END cannot be a start node");if(!Object.keys(this.nodes).some(n=>n===r))throw new Error(`Need to add a node named "${r}" first`)}if(t==="__end__")throw new Error("END cannot be an end node");if(!Object.keys(this.nodes).some(r=>r===t))throw new Error(`Need to add a node named "${t}" first`);return this.waitingEdges.add([e,t]),this}addSequence(e){let t=Array.isArray(e)?e:Object.entries(e);if(t.length===0)throw new Error("Sequence requires at least one node.");let r;for(let[n,i,a]of t){if(n in this.nodes)throw new Error(`Node names must be unique: node with the name "${n}" already exists.`);let o=n;this.addNode(n,i,a),r!=null&&this.addEdge(r,o),r=o}return this}compile({checkpointer:e,store:t,cache:r,interruptBefore:n,interruptAfter:i,name:a,description:o,transformers:s}={}){let c=this._createDefaultErrorHandlerSpec();if(c!==void 0){if(Rc in this.nodes)throw new Error(`Cannot apply a default error handler: the reserved node name \`${Rc}\` is already in use. setNodeDefaults({ errorHandler }) registers a node with that name; rename the conflicting node.`);this.nodes[Rc]=c}try{return this._compileResolved({checkpointer:e,store:t,cache:r,interruptBefore:n,interruptAfter:i,name:a,description:o,transformers:s,defaultErrorHandlerNode:c!==void 0?Rc:void 0})}finally{c!==void 0&&delete this.nodes[Rc]}}_compileResolved({checkpointer:e,store:t,cache:r,interruptBefore:n,interruptAfter:i,name:a,description:o,transformers:s,defaultErrorHandlerNode:c}){this.validate([...Array.isArray(n)?n:[],...Array.isArray(i)?i:[]]);let l=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),u=l.length===1&&l[0]===Ui?Ui:l,d=Object.keys(this.channels),f=d.length===1&&d[0]===Ui?Ui:d,p=this._interrupt,m=new QM({builder:this,checkpointer:e,interruptAfter:i,interruptBefore:n,autoValidate:!1,nodes:{},channels:{...this.channels,[Je]:new In},inputChannels:Je,outputChannels:u,streamChannels:f,streamMode:"updates",store:t,cache:r,name:a,description:o,userInterrupt:p,streamTransformers:s});m.attachNode(Je);let h=this._nodeDefaults,_=h.retryPolicy!==void 0||h.cachePolicy!==void 0||h.timeout!==void 0||c!==void 0;for(let[y,w]of Object.entries(this.nodes)){let x=w.isErrorHandler===!0,S=_?{...w,retryPolicy:w.retryPolicy??h.retryPolicy,cachePolicy:x||w.cachePolicy===!1?void 0:w.cachePolicy??h.cachePolicy,timeout:w.timeout??h.timeout,errorHandlerNode:!x&&c!==void 0&&w.errorHandlerNode===void 0?c:w.errorHandlerNode}:w;m.attachNode(y,S)}m.attachBranch(Je,Bh,YM(),{withReader:!1});for(let[y]of Object.entries(this.nodes))m.attachBranch(y,Bh,YM(),{withReader:!1});for(let[y,w]of this.edges)m.attachEdge(y,w);for(let[y,w]of this.waitingEdges)m.attachEdge(y,w);for(let[y,w]of Object.entries(this.branches))for(let[x,S]of Object.entries(w))m.attachBranch(y,x,S);return m.validate()}};function uZ(e){let t={};for(let[r,n]of Object.entries(e))r===Ui?t[r]=fh(n):t[r]=fh(n);return t}var QM=class extends NS{description;_metaRegistry=Fu;constructor({description:e,...t}){super(t),this.description=e}attachNode(e,t){let r;e==="__start__"?r=Object.entries(this.builder._schemaDefinitions.get(this.builder._inputDefinition)).map(([c])=>c):r=Object.keys(this.builder.channels);function n(c){if(Ct(c))return c.graph===_r.PARENT?null:c._updateAsTuples();if(Array.isArray(c)&&c.length>0&&c.some(l=>Ct(l))){let l=[];for(let u of c)if(Ct(u)){if(u.graph===_r.PARENT)continue;l.push(...u._updateAsTuples())}else l.push([Ui,u]);return l}else if(c!=null)return[[Ui,c]];return null}let i=e,a=async c=>{if(c==null||c.length===0)return c;let l=this.builder._schemaRuntimeDefinition;if(Tn.isInstance(l)){let u=new Set(l.getChannelKeys());return Promise.all(c.map(async([d,f])=>{if(!u.has(d))return[d,f];let p=await l.validateInput({[d]:f});return[d,Object.prototype.hasOwnProperty.call(p,d)?p[d]:f]}))}if(Jt(l)){let u=new Set(Object.keys(xi(l)));if(c.filter(([p])=>u.has(p)).length===0)return c;let d=Sa(this._metaRegistry.getExtendedChannelSchemas(l,{withReducerSchema:!0})),f=Sa(l);return c.map(([p,m])=>{if(!u.has(p))return[p,m];let[h,_]=sn(m);if(h){let w=xa(f,{[p]:_});return[p,Object.prototype.hasOwnProperty.call(w,p)?{[On]:w[p]}:m]}let y=xa(d,{[p]:m});return[p,Object.prototype.hasOwnProperty.call(y,p)?y[p]:m]})}return c};async function o(c){if(c){if(Ct(c))return c.graph===_r.PARENT?null:a(c._updateAsTuples().filter(([l])=>r.includes(l)));if(Array.isArray(c)&&c.length>0&&c.some(Ct)){let l=[];for(let u of c)if(Ct(u)){if(u.graph===_r.PARENT)continue;l.push(...u._updateAsTuples().filter(([d])=>r.includes(d)))}else{let d=await o(u);d&&l.push(...d??[])}return a(l)}else{if(typeof c=="object"&&!Array.isArray(c))return a(Object.entries(c).filter(([l])=>r.includes(l)));{let l=Array.isArray(c)?"array":typeof c;throw new ve(`Expected node "${i.toString()}" to return an object or an array containing at least one Command object, received ${l}`,{lc_error_code:"INVALID_GRAPH_NODE_RETURN_VALUE"})}}}else return null}let s=[{value:Ir,mapper:new Rt({func:r.length&&r[0]===Ui?n:o,trace:!1,recurse:!1})}];if(e==="__start__")this.nodes[e]=new $n({tags:[ht],triggers:[Je],channels:[Je],writers:[new ut(s,[ht])]});else{let c=t?.input??this.builder._schemaDefinition,l=Object.fromEntries(Object.keys(this.builder._schemaDefinitions.get(c)).map(m=>[m,m])),u=Object.keys(l).length===1&&Ui in l,d=`branch:to:${e}`;this.channels[d]=t?.defer?new Q0:new In(!1);let f=t?.cachePolicy,p=f===!1?void 0:f;this.nodes[e]=new $n({triggers:[d],channels:u?Object.keys(l):l,writers:[new ut(s,[ht])],mapper:u?void 0:m=>Object.fromEntries(Object.entries(m).filter(([h])=>h in l)),bound:t?.runnable,metadata:t?.metadata,retryPolicy:t?.retryPolicy,cachePolicy:p,timeout:t?.timeout,subgraphs:t?.subgraphs,ends:t?.ends,isErrorHandler:t?.isErrorHandler,errorHandlerNode:t?.errorHandlerNode})}}attachEdge(e,t){if(t!=="__end__"){if(typeof e=="string")this.nodes[e].writers.push(new ut([{channel:`branch:to:${t}`,value:null}],[ht]));else if(Array.isArray(e)){let r=`join:${e.join("+")}:${t}`;this.channels[r]=this.builder.nodes[t].defer?new DS(new Set(e)):new jS(new Set(e)),this.nodes[t].triggers.push(r);for(let n of e)this.nodes[n].writers.push(new ut([{channel:r,value:n}],[ht]))}}}attachBranch(e,t,r,n={withReader:!0}){let i=async(a,o)=>{let s=a.filter(l=>l!==Qe);if(!s.length)return;let c=s.map(l=>wt(l)?l:{channel:l==="__end__"?l:`branch:to:${l}`,value:e});await ut.doWrite({...o,tags:(o.tags??[]).concat([ht])},c)};this.nodes[e].writers.push(r.run(i,n.withReader?a=>rM.doRead(a,this.streamChannels??this.outputChannels,!0):void 0))}async _validateInput(e){if(e==null)return e;let t=this.builder._inputRuntimeDefinition,r=this.builder._schemaRuntimeDefinition;if(Tn.isInstance(t)){if(Ct(e)){let i=e;return e.update&&(i.update=await t.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),i}return await t.validateInput(e)}if(t===Lh&&Tn.isInstance(r)){if(Ct(e)){let i=e;return e.update&&(i.update=await r.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),i}return await r.validateInput(e)}let n=(()=>{let i=a=>{if(a!=null)return this._metaRegistry.getExtendedChannelSchemas(a,{withReducerSchema:!0})};if(Jt(t))return i(t);if(t===Lh)return Jt(r)?Sa(i(r)):void 0})();if(Ct(e)){let i=e;if(e.update&&n!=null){let a=Array.isArray(e.update)?Object.fromEntries(e.update):e.update,o=xa(n,a);i.update=Object.fromEntries(Object.keys(a).map(s=>[s,o[s]]))}return i}return n!=null?xa(n,e):e}isInterrupted(e){return Ha(e)}async _validateContext(e){let t=this.builder._configRuntimeSchema;return Jt(t)&&xa(t,e),e}};function dZ(e){return typeof e=="object"&&e!==null&&e.channels!==void 0}function fZ(e){if(wt(e))return[e];let t=[];Ct(e)?t.push(e):Array.isArray(e)&&t.push(...e.filter(Ct));let r=[];for(let n of t){if(n.graph===_r.PARENT)throw new Qu(n);wt(n.goto)||typeof n.goto=="string"?r.push(n.goto):Array.isArray(n.goto)&&r.push(...n.goto)}return r}function YM(){return new OS({path:new Rt({func:fZ,tags:[ht],trace:!1,recurse:!1,name:"<control_branch>"})})}var pZ=class extends BS{constructor(){super({channels:{__root__:{reducer:za,default:()=>[]}}})}};function mZ(e,t){let{stateKey:r,...n}=t??{},i=Ec(n),a=r??"messages";r===null&&(a=void 0);let o=kt(e);if(!o.id)throw new Error("Message ID is required.");let s=(Array.isArray(i.callbacks)?i.callbacks:typeof i.callbacks<"u"?i.callbacks.handlers:[]).find(c=>"name"in c&&c.name==="StreamMessagesHandler");if(s){let c=i.metadata??{},l=(c.langgraph_checkpoint_ns??"").split("|");s._emit([l,c],o,void 0,!1)}return a&&i.configurable?.__pregel_send?.([[a,o]]),o}function hZ(e,t){let r=typeof e=="string"?{name:e,retry:void 0,cachePolicy:void 0,timeout:void 0}:e,{name:n,retry:i}=r,a=Bi(r.timeout);if(_S(t)||yS(t))throw new Error("Generators are disallowed as tasks. For streaming responses, use config.write.");let o=r.cachePolicy??("cache"in r?r.cache:void 0),s;return typeof o=="boolean"?s=o?{}:void 0:s=o,(...c)=>dM({func:t,name:n,retry:i,cache:s,timeout:a},...c)}var ej=function(t,r){let{name:n,checkpointer:i,store:a,cache:o}=typeof t=="string"?{name:t,checkpointer:void 0,store:void 0}:t,s=Bi(typeof t=="string"?void 0:t.timeout);if(_S(r)||yS(r))throw new Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let c="updates",l=uM(n,r);function u(m){return typeof m=="object"&&m!==null&&"__lg_type"in m&&m.__lg_type==="__pregel_final"}let d=new Rt({name:"pluckReturnValue",func:m=>u(m)?m.value:m}),f=new Rt({name:"pluckSaveValue",func:m=>u(m)?m.save:m}),p=new $n({bound:l,triggers:[Je],channels:[Je],timeout:s,writers:[new ut([{channel:Qe,value:Ir,mapper:d},{channel:Wi,value:Ir,mapper:f}],[ht])]});return new Dh({name:n,checkpointer:i,nodes:{[n]:p},channels:{[Je]:new In,[Qe]:new Sn,[Wi]:new Sn},inputChannels:Je,outputChannels:Qe,streamChannels:Qe,streamMode:c,store:a,cache:o})};ej.final=function({value:t,save:r}){return{value:t,save:r,__lg_type:"__pregel_final"}};function gZ(){return Re.getRunnableConfig().configurable?.[Zi]}var _Z=Pu.Root({messages:Pu({reducer:za,default:()=>[]})}),tj={reducer:{fn:za},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},yZ=Nt.object({messages:qM(Nt.custom(),tj)});function vZ(e){let t=Re.getRunnableConfig();if(!t)throw new Error("Called interrupt() outside the context of a graph.");let r=t.configurable;if(!r)throw new Error("No configurable found in config");return r.writer?.(e)}export{Je as a,Qe as b,Le as c,Fh as d,qS as e,Fa as f,wt as g,ij as h,Ha as i,_r as j,Ct as k,Zr as l,Ju as m,Vh as n,Ga as o,Ku as p,qu as q,li as r,Xu as s,Yu as t,oj as u,Qu as v,Zh as w,Ji as x,ui as y,ed as z,sj as A,td as B,je as C,ve as D,cj as E,Hh as F,lj as G,Lc as H,uj as I,Tk as J,ar as K,Dj as L,jn as M,zk as N,Hc as O,Uk as P,Pe as Q,tt as R,St as S,ss as T,cs as U,Ne as V,us as W,it as X,un as Y,qa as Z,Ya as _,Qa as $,or as aa,mi as ba,P$ as ca,Re as da,Wt as ea,$t as fa,ke as ga,Rr as ha,gt as ia,oa as ja,la as ka,fo as la,ha as ma,Vf as na,xo as oa,Ge as pa,lt as qa,xr as ra,wp as sa,xa as ta,Si as ua,Jt as va,xi as wa,Sa as xa,Sp as ya,XC as za,z as Aa,Nt as Ba,Mp as Ca,Et as Da,se as Ea,Qr as Fa,Lr as Ga,qt as Ha,RF as Ia,Hl as Ja,Xp as Ka,Xw as La,gP as Ma,_P as Na,UF as Oa,LF as Pa,Qw as Qa,Ca as Ra,nm as Sa,Aa as Ta,YF as Ua,hx as Va,uc as Wa,pu as Xa,rn as Ya,eV as Za,pV as _a,Go as $a,wn as ab,ih as bb,OR as cb,Sc as db,sh as eb,RR as fb,yt as gb,Pi as hb,Pu as ib,JV as jb,KV as kb,ph as lb,qV as mb,eS as nb,tS as ob,Ic as pb,rS as qb,an as rb,gh as sb,oS as tb,Nu as ub,Ru as vb,sS as wb,cS as xb,_h as yb,dS as zb,GR as Ab,fS as Bb,gS as Cb,Rt as Db,PS as Eb,Mi as Fb,iZ as Gb,ja as Hb,ji as Ib,zh as Jb,Uh as Kb,Di as Lb,qo as Mb,zi as Nb,Tn as Ob,oZ as Pb,za as Qb,FS as Rb,sZ as Sb,cZ as Tb,Fu as Ub,qM as Vb,BS as Wb,QM as Xb,pZ as Yb,mZ as Zb,hZ as _b,ej as $b,gZ as ac,_Z as bc,tj as cc,yZ as dc,vZ as ec};