@esri/solutions-components 5.1.15 → 5.1.16

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 (164) hide show
  1. package/dist/cdn/247Q2TXM.js +2 -0
  2. package/dist/cdn/{VCKCRMSD.js → 2C4JBZR3.js} +1 -1
  3. package/dist/cdn/{VW4UJ7IY.js → 2DTIYSOT.js} +1 -1
  4. package/dist/cdn/{JNQB7T54.js → 2QR2IHMG.js} +1 -1
  5. package/dist/cdn/3ODUV7DM.js +2 -0
  6. package/dist/cdn/{CPWYI2FO.js → 3TZRVL3S.js} +1 -1
  7. package/dist/cdn/{IBSFJBIL.js → 447ZMCY3.js} +1 -1
  8. package/dist/cdn/{XRQNNWH3.js → 4JE4ZZEO.js} +1 -1
  9. package/dist/cdn/4O622WUQ.js +2 -0
  10. package/dist/cdn/4OZKMC4H.js +2 -0
  11. package/dist/cdn/{T6F3TWF6.js → 4RPDNW6C.js} +1 -1
  12. package/dist/cdn/{24U5P7WR.js → 4W4LIIXK.js} +1 -1
  13. package/dist/cdn/{SNRLIWGC.js → 56OXNE5M.js} +1 -1
  14. package/dist/cdn/{5DZ55HIG.js → 5E2X2LIC.js} +1 -1
  15. package/dist/cdn/{XL66TA6C.js → 5LSAVYFC.js} +1 -1
  16. package/dist/cdn/5MVOXMG2.js +2 -0
  17. package/dist/cdn/5QGU6U72.js +2 -0
  18. package/dist/cdn/{KN2PNGQX.js → 6HPH3E35.js} +1 -1
  19. package/dist/cdn/{5AGI2QC2.js → 6IWBGRKB.js} +1 -1
  20. package/dist/cdn/6PKGJDEH.js +2 -0
  21. package/dist/cdn/6TGGKMQB.js +2 -0
  22. package/dist/cdn/{BOA6VQK6.js → 75QFNN26.js} +1 -1
  23. package/dist/cdn/{HB56DBBP.js → 7EKT4XZ2.js} +5 -5
  24. package/dist/cdn/{7MJZYDDW.js → 7FGKODSI.js} +1 -1
  25. package/dist/cdn/{BFYYWPZY.js → 7RX3CC2H.js} +1 -1
  26. package/dist/cdn/{KJTTBON2.js → ACR7LXQM.js} +1 -1
  27. package/dist/cdn/{65VKA5R3.js → AIJ5KNSJ.js} +1 -1
  28. package/dist/cdn/AVMD543K.js +2 -0
  29. package/dist/cdn/{JIOMWIMT.js → B33ONN6M.js} +1 -1
  30. package/dist/cdn/{OZVQRDTO.js → BE4N7HFP.js} +1 -1
  31. package/dist/cdn/{Z4LGN5M5.js → BSPAXBDY.js} +1 -1
  32. package/dist/cdn/{DERWSE25.js → C5IHV5FJ.js} +1 -1
  33. package/dist/cdn/{EV55ZAHX.js → C7D3FPWP.js} +1 -1
  34. package/dist/cdn/{2GBCVJXZ.js → D62YOY7Q.js} +1 -1
  35. package/dist/cdn/{4VUQR74S.js → DCNEGYEC.js} +1 -1
  36. package/dist/cdn/DG2BBLXW.js +2 -0
  37. package/dist/cdn/{7GWFZ23D.js → DTXW7GR2.js} +1 -1
  38. package/dist/cdn/DXWCRPU7.js +2 -0
  39. package/dist/cdn/{ABPXUFXN.js → E7CD7GZL.js} +1 -1
  40. package/dist/cdn/EOMG2X5B.js +357 -0
  41. package/dist/cdn/{O4MNHPWI.js → EWCJJNT5.js} +1 -1
  42. package/dist/cdn/{WQUZG2NJ.js → FILRH4BY.js} +1 -1
  43. package/dist/cdn/{OQMMSCLX.js → FUEOEICW.js} +1 -1
  44. package/dist/cdn/{2CIYQPV2.js → FWRCG7QJ.js} +1 -1
  45. package/dist/cdn/{O62JG2Y6.js → FXGWLBJ7.js} +1 -1
  46. package/dist/cdn/{6MQWDLJ6.js → GMAV5T2N.js} +1 -1
  47. package/dist/cdn/{LGJMYSGU.js → GPODLJUL.js} +1 -1
  48. package/dist/cdn/{CNNBPMQT.js → GRFNUGBT.js} +1 -1
  49. package/dist/cdn/{JXERXJF5.js → GTX5TOX6.js} +1 -1
  50. package/dist/cdn/GWKUM5FJ.js +456 -0
  51. package/dist/cdn/{5TNQ4S67.js → H3GN63Y3.js} +1 -1
  52. package/dist/cdn/{T7JWS4CF.js → HIVXXDHM.js} +1 -1
  53. package/dist/cdn/I4WRVQPK.js +2 -0
  54. package/dist/cdn/{36LRAUE4.js → IPQDASPD.js} +1 -1
  55. package/dist/cdn/{RSPNBIIE.js → IWLPFHJF.js} +1 -1
  56. package/dist/cdn/{ZXHMBCGN.js → J4Y2UUE5.js} +1 -1
  57. package/dist/cdn/{YR6F4HW7.js → JDGAPNOB.js} +1 -1
  58. package/dist/cdn/{7SZY3VBD.js → JMFXUBR7.js} +1 -1
  59. package/dist/cdn/{GNX2VU4F.js → JSKYS7P5.js} +1 -1
  60. package/dist/cdn/{AQ2USXUY.js → JY2FA5F3.js} +1 -1
  61. package/dist/cdn/{TRNQ5OTY.js → JYKJLNCR.js} +1 -1
  62. package/dist/cdn/K5DU5RWF.js +2 -0
  63. package/dist/cdn/{N5DZRJNH.js → KH4ZYXHD.js} +1 -1
  64. package/dist/cdn/{DT7GQICF.js → KMKWVYPI.js} +1 -1
  65. package/dist/cdn/{QPMXVWMP.js → L6LA4X2Q.js} +1 -1
  66. package/dist/cdn/{FTWOLF7Y.js → L76QNBH4.js} +1 -1
  67. package/dist/cdn/{SSNO5VHY.js → LC7635YE.js} +1 -1
  68. package/dist/cdn/{COKMQSEA.js → LEZRHZSL.js} +1 -1
  69. package/dist/cdn/{COEHM4BJ.js → LSPJWXOL.js} +1 -1
  70. package/dist/cdn/{PHGSNNMQ.js → LULZPSZK.js} +1 -1
  71. package/dist/cdn/{5O6E2RIA.js → LVFCQS24.js} +1 -1
  72. package/dist/cdn/{QMUSSZL2.js → M3BC47EX.js} +1 -1
  73. package/dist/cdn/{IYZ2PDYK.js → MD2W2CNY.js} +1 -1
  74. package/dist/cdn/{MECI4R4R.js → MH3W3N6T.js} +3 -3
  75. package/dist/cdn/{XOPNEAS5.js → MIC565TO.js} +1 -1
  76. package/dist/cdn/{FJAUOTG7.js → MKGWQ7ED.js} +1 -1
  77. package/dist/cdn/{XSJOQTEM.js → MTGZHZYF.js} +1 -1
  78. package/dist/cdn/{G2OBSHPX.js → N74SSEHF.js} +1 -1
  79. package/dist/cdn/{KOIHVAUY.js → NLXWDQUL.js} +1 -1
  80. package/dist/cdn/{CDZW34JV.js → NWI63TZX.js} +1 -1
  81. package/dist/cdn/{CAPXLC6T.js → O2Y2MGL7.js} +1 -1
  82. package/dist/cdn/{2A7FDE6T.js → O4Q74CU3.js} +1 -1
  83. package/dist/cdn/{SYHEO472.js → O7KEBYBS.js} +1 -1
  84. package/dist/cdn/PB4KDDNX.js +2 -0
  85. package/dist/cdn/{HW4LYJUR.js → PCRICJQB.js} +1 -1
  86. package/dist/cdn/{53YBLXWP.js → PFGAF7W7.js} +1 -1
  87. package/dist/cdn/{IDJHBEJC.js → PJ556LHC.js} +3 -3
  88. package/dist/cdn/{AONULVO2.js → PRBMUEIU.js} +1 -1
  89. package/dist/cdn/{2WXIVPKA.js → PUBYJMMF.js} +1 -1
  90. package/dist/cdn/Q5ALOX6G.js +2 -0
  91. package/dist/cdn/{FLPXST7W.js → QIYUCOCH.js} +1 -1
  92. package/dist/cdn/{RLDOLDG5.js → QT66ATR6.js} +1 -1
  93. package/dist/cdn/{K3ALRIQF.js → R22ZBXMU.js} +1 -1
  94. package/dist/cdn/{6RHFFYNC.js → RBA5LP53.js} +1 -1
  95. package/dist/cdn/{4M55FA2L.js → RJJEDOA5.js} +1 -1
  96. package/dist/cdn/{3JF7PWPA.js → RTHNTV3C.js} +1 -1
  97. package/dist/cdn/{VQ5ZAQUF.js → RWYVVDWD.js} +1 -1
  98. package/dist/cdn/{RPLXKWJA.js → SWZW76QC.js} +1 -1
  99. package/dist/cdn/{AO7XKW2U.js → SY25U3KI.js} +1 -1
  100. package/dist/cdn/T5RT73MF.js +2 -0
  101. package/dist/cdn/{W6GIBBBE.js → TWELRTPF.js} +1 -1
  102. package/dist/cdn/U3D2IIAX.js +2 -0
  103. package/dist/cdn/UAWJNBXB.js +4 -0
  104. package/dist/cdn/{KF64ALRP.js → ULAU7YYD.js} +1 -1
  105. package/dist/cdn/{VZWYFHPJ.js → UPYHIGTA.js} +1 -1
  106. package/dist/cdn/{VHAXJPRY.js → UR2RYZ4Q.js} +1 -1
  107. package/dist/cdn/{L5DQOHD5.js → V3QY6GGE.js} +1 -1
  108. package/dist/cdn/{YGVATVII.js → VEBARNK2.js} +1 -1
  109. package/dist/cdn/VSTISYVL.js +2 -0
  110. package/dist/cdn/{JMY4B4WQ.js → VT35RTGD.js} +1 -1
  111. package/dist/cdn/{RGOUIRT7.js → WFDP33EC.js} +1 -1
  112. package/dist/cdn/{4QGYS5DL.js → WMY3JAPO.js} +1 -1
  113. package/dist/cdn/{CWW74G2W.js → WNSJ26IM.js} +1 -1
  114. package/dist/cdn/{RI7U6FA5.js → WP3FT4MH.js} +1 -1
  115. package/dist/cdn/{AIUJXRA5.js → WSGJL4QG.js} +1 -1
  116. package/dist/cdn/{WVRDKKBC.js → WWRJFSPK.js} +1 -1
  117. package/dist/cdn/XGF4Z7DL.js +2 -0
  118. package/dist/cdn/{67RAW3TG.js → XTMKQTKS.js} +1 -1
  119. package/dist/cdn/{BDVFJJR4.js → XUQJ6TZ4.js} +1 -1
  120. package/dist/cdn/{RD7MZ7SN.js → XWMICWSU.js} +1 -1
  121. package/dist/cdn/{D4HAXELR.js → XZE3UIAE.js} +1 -1
  122. package/dist/cdn/{5OMXJXRL.js → Y376MZ7V.js} +1 -1
  123. package/dist/cdn/{2ZH3GVSR.js → YGHICFBD.js} +1 -1
  124. package/dist/cdn/{GWLE7PJQ.js → YJCJZHBN.js} +1 -1
  125. package/dist/cdn/{VYOCZUVH.js → YP46NHDO.js} +1 -1
  126. package/dist/cdn/{MQQ2SHRV.js → YSZNDZHZ.js} +1 -1
  127. package/dist/cdn/{P3YHSJCB.js → Z7NC4HTS.js} +1 -1
  128. package/dist/cdn/{5DMFGBJJ.js → ZBXJES7E.js} +1 -1
  129. package/dist/cdn/{5USMP4M7.js → ZZIJOG6A.js} +1 -1
  130. package/dist/cdn/index.js +1 -1
  131. package/dist/chunks/runtime.js +1 -1
  132. package/dist/chunks/solution-builder-assistant.js +2 -2
  133. package/dist/components/arcgis-solutions-assistant/customElement.js +324 -335
  134. package/dist/components/create-feature/customElement.js +77 -48
  135. package/dist/components/layer-table/customElement.js +2 -2
  136. package/dist/components/map-card/customElement.js +2 -2
  137. package/dist/components/solutions-deploy-app/customElement.js +3 -3
  138. package/dist/docs/api.json +1 -1
  139. package/dist/docs/docs.json +1 -1
  140. package/dist/docs/web-types.json +1 -1
  141. package/dist/solutions-components_commit.txt +7 -7
  142. package/package.json +9 -7
  143. package/dist/cdn/3TAQSXLA.js +0 -2
  144. package/dist/cdn/4ESJPQUS.js +0 -2
  145. package/dist/cdn/64DMFXX3.js +0 -459
  146. package/dist/cdn/6JPXLTNI.js +0 -358
  147. package/dist/cdn/7LP2DUHS.js +0 -2
  148. package/dist/cdn/ACTGIDKO.js +0 -4
  149. package/dist/cdn/BA3J7L5N.js +0 -2
  150. package/dist/cdn/BPHZAC66.js +0 -2
  151. package/dist/cdn/ECJQJ4BY.js +0 -2
  152. package/dist/cdn/F5EJPIW4.js +0 -2
  153. package/dist/cdn/FX2C3BL4.js +0 -2
  154. package/dist/cdn/GEEQWXOZ.js +0 -2
  155. package/dist/cdn/H3QX6XOJ.js +0 -2
  156. package/dist/cdn/JRUIRTL7.js +0 -2
  157. package/dist/cdn/NF77ALHM.js +0 -2
  158. package/dist/cdn/OJH4NUGT.js +0 -2
  159. package/dist/cdn/SV2XM7U2.js +0 -2
  160. package/dist/cdn/TTXN5R4E.js +0 -2
  161. package/dist/cdn/VM2LS6TR.js +0 -2
  162. package/dist/cdn/VNWIFVKC.js +0 -2
  163. package/dist/cdn/VWNMKVMJ.js +0 -2
  164. package/dist/cdn/X3YWKGD7.js +0 -2
@@ -0,0 +1,456 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{b as Pa,c as ni,d as tp}from"./EXBEKVP5.js";var nO=Pa((Aee,Lv)=>{"use strict";var M6=Object.prototype.hasOwnProperty,kr="~";function Ll(){}Object.create&&(Ll.prototype=Object.create(null),new Ll().__proto__||(kr=!1));function z6(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function rO(e,t,r,i,n){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new z6(r,i||e,n),a=kr?kr+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],o]:e._events[a].push(o):(e._events[a]=o,e._eventsCount++),e}function Qp(e,t){--e._eventsCount===0?e._events=new Ll:delete e._events[t]}function ar(){this._events=new Ll,this._eventsCount=0}ar.prototype.eventNames=function(){var t=[],r,i;if(this._eventsCount===0)return t;for(i in r=this._events)M6.call(r,i)&&t.push(kr?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};ar.prototype.listeners=function(t){var r=kr?kr+t:t,i=this._events[r];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,o=i.length,a=new Array(o);n<o;n++)a[n]=i[n].fn;return a};ar.prototype.listenerCount=function(t){var r=kr?kr+t:t,i=this._events[r];return i?i.fn?1:i.length:0};ar.prototype.emit=function(t,r,i,n,o,a){var s=kr?kr+t:t;if(!this._events[s])return!1;var c=this._events[s],u=arguments.length,l,d;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){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,i),!0;case 4:return c.fn.call(c.context,r,i,n),!0;case 5:return c.fn.call(c.context,r,i,n,o),!0;case 6:return c.fn.call(c.context,r,i,n,o,a),!0}for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}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),u){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,i);break;case 4:c[d].fn.call(c[d].context,r,i,n);break;default:if(!l)for(p=1,l=new Array(u-1);p<u;p++)l[p-1]=arguments[p];c[d].fn.apply(c[d].context,l)}}return!0};ar.prototype.on=function(t,r,i){return rO(this,t,r,i,!1)};ar.prototype.once=function(t,r,i){return rO(this,t,r,i,!0)};ar.prototype.removeListener=function(t,r,i,n){var o=kr?kr+t:t;if(!this._events[o])return this;if(!r)return Qp(this,o),this;var a=this._events[o];if(a.fn)a.fn===r&&(!n||a.once)&&(!i||a.context===i)&&Qp(this,o);else{for(var s=0,c=[],u=a.length;s<u;s++)(a[s].fn!==r||n&&!a[s].once||i&&a[s].context!==i)&&c.push(a[s]);c.length?this._events[o]=c.length===1?c[0]:c:Qp(this,o)}return this};ar.prototype.removeAllListeners=function(t){var r;return t?(r=kr?kr+t:t,this._events[r]&&Qp(this,r)):(this._events=new Ll,this._eventsCount=0),this};ar.prototype.off=ar.prototype.removeListener;ar.prototype.addListener=ar.prototype.on;ar.prefixed=kr;ar.EventEmitter=ar;typeof Lv<"u"&&(Lv.exports=ar)});var oO=Pa((Cee,iO)=>{"use strict";iO.exports=(e,t)=>(t=t||(()=>{}),e.then(r=>new Promise(i=>{i(t())}).then(()=>r),r=>new Promise(i=>{i(t())}).then(()=>{throw r})))});var sO=Pa((Oee,tm)=>{"use strict";var L6=oO(),em=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},aO=(e,t,r)=>new Promise((i,n)=>{if(typeof t!="number"||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0){i(e);return}let o=setTimeout(()=>{if(typeof r=="function"){try{i(r())}catch(c){n(c)}return}let a=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,s=r instanceof Error?r:new em(a);typeof e.cancel=="function"&&e.cancel(),n(s)},t);L6(e.then(i,n),()=>{clearTimeout(o)})});tm.exports=aO;tm.exports.default=aO;tm.exports.TimeoutError=em});var cO=Pa(Uv=>{"use strict";Object.defineProperty(Uv,"__esModule",{value:!0});function U6(e,t,r){let i=0,n=e.length;for(;n>0;){let o=n/2|0,a=i+o;r(e[a],t)<=0?(i=++a,n-=o+1):n=o}return i}Uv.default=U6});var uO=Pa(Bv=>{"use strict";Object.defineProperty(Bv,"__esModule",{value:!0});var F6=cO(),Fv=class{constructor(){this._queue=[]}enqueue(t,r){r=Object.assign({priority:0},r);let i={priority:r.priority,run:t};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(i);return}let n=F6.default(this._queue,i,(o,a)=>a.priority-o.priority);this._queue.splice(n,0,i)}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}};Bv.default=Fv});var nm=Pa(Hv=>{"use strict";Object.defineProperty(Hv,"__esModule",{value:!0});var B6=nO(),lO=sO(),V6=uO(),rm=()=>{},H6=new lO.TimeoutError,Vv=class extends B6{constructor(t){var r,i,n,o;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=rm,this._resolveIdle=rm,t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:V6.default},t),!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(i=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&i!==void 0?i:""}\` (${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 \`${(o=(n=t.interval)===null||n===void 0?void 0:n.toString())!==null&&o!==void 0?o:""}\` (${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=rm,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=rm,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((i,n)=>{let o=async()=>{this._pendingCount++,this._intervalCount++;try{let a=this._timeout===void 0&&r.timeout===void 0?t():lO.default(Promise.resolve(t()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&n(H6)});i(await a)}catch(a){n(a)}this._next()};this._queue.enqueue(o,r),this._tryToStartAnother(),this.emit("add")})}async addAll(t,r){return Promise.all(t.map(async i=>this.add(i,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}};Hv.default=Vv});var tD=Pa(jg=>{"use strict";jg.byteLength=x5;jg.toByteArray=k5;jg.fromByteArray=E5;var Ti=[],In=[],w5=typeof Uint8Array<"u"?Uint8Array:Array,Qk="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Qs=0,Qj=Qk.length;Qs<Qj;++Qs)Ti[Qs]=Qk[Qs],In[Qk.charCodeAt(Qs)]=Qs;var Qs,Qj;In[45]=62;In[95]=63;function eD(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 i=r===t?0:4-r%4;return[r,i]}function x5(e){var t=eD(e),r=t[0],i=t[1];return(r+i)*3/4-i}function S5(e,t,r){return(t+r)*3/4-r}function k5(e){var t,r=eD(e),i=r[0],n=r[1],o=new w5(S5(e,i,n)),a=0,s=n>0?i-4:i,c;for(c=0;c<s;c+=4)t=In[e.charCodeAt(c)]<<18|In[e.charCodeAt(c+1)]<<12|In[e.charCodeAt(c+2)]<<6|In[e.charCodeAt(c+3)],o[a++]=t>>16&255,o[a++]=t>>8&255,o[a++]=t&255;return n===2&&(t=In[e.charCodeAt(c)]<<2|In[e.charCodeAt(c+1)]>>4,o[a++]=t&255),n===1&&(t=In[e.charCodeAt(c)]<<10|In[e.charCodeAt(c+1)]<<4|In[e.charCodeAt(c+2)]>>2,o[a++]=t>>8&255,o[a++]=t&255),o}function $5(e){return Ti[e>>18&63]+Ti[e>>12&63]+Ti[e>>6&63]+Ti[e&63]}function I5(e,t,r){for(var i,n=[],o=t;o<r;o+=3)i=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),n.push($5(i));return n.join("")}function E5(e){for(var t,r=e.length,i=r%3,n=[],o=16383,a=0,s=r-i;a<s;a+=o)n.push(I5(e,a,a+o>s?s:a+o));return i===1?(t=e[r-1],n.push(Ti[t>>2]+Ti[t<<4&63]+"==")):i===2&&(t=(e[r-2]<<8)+e[r-1],n.push(Ti[t>>10]+Ti[t>>4&63]+Ti[t<<2&63]+"=")),n.join("")}});function YE(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 Eo(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 i=YE(t.runTimeout,"runTimeout"),n=YE(t.idleTimeout,"idleTimeout");if(!(i===void 0&&n===void 0))return{runTimeout:i,idleTimeout:n,refreshOn:r}}var rt="__start__",ct="__end__",oi="__input__";var To="__error__",vl="__error_source_node__",rp="__pregel_ns_writes";function QE(){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 nr="__pregel_send",ai="__pregel_call",_r="__pregel_read",fn="__pregel_checkpointer",Ra="__pregel_resuming",mc="__pregel_task_id",bl="__pregel_stream",xU="__pregel_resume_value",ja="__pregel_resume_map",yr="__pregel_scratchpad",Ao="__pregel_previous",SU="__pregel_durability",Co="checkpoint_id",Xr="checkpoint_ns",eT="__pregel_node_finished",wl="__pregel_node_error",ir="checkpoint_map",np="__pregel_replay_state",tT="__pregel_abort_signals",qe="__interrupt__",vr="__resume__",xl="__no_writes__",Oo="__return__",Po="__previous__",kt="langsmith:hidden";var Ty="__self__",si="__pregel_tasks",br="__pregel_push",ip="__pregel_pull",wr="00000000-0000-0000-0000-000000000000",rT=[kt,oi,qe,vr,To,vl,xl,nr,_r,fn,SU,bl,Ra,mc,ai,xU,yr,Ao,ir,Xr,Co,np],Ey=Symbol.for("langgraph.command"),nT=class{[Ey];constructor(e){this[Ey]=e}};function op(e){let t=e;return t!=null&&typeof t.node=="string"&&t.args!==void 0}var Na=class{lg_name="Send";node;args;timeout;constructor(e,t,r){this.node=e,this.args=yl(t),this.timeout=Eo(r?.timeout)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args,timeout:this.timeout}}};function Ct(e){return e instanceof Na}var ii="__overwrite__",kU=class{lg_name="Overwrite";[ii];constructor(e){this[ii]=e}get value(){return this[ii]}toJSON(){return{[ii]:this[ii]}}static isInstance(e){return!e||typeof e!="object"?!1:"__overwrite__"in e||"lg_name"in e&&e.lg_name==="Overwrite"}};function Pn(e){if(typeof e=="object"&&e!==null){if("__overwrite__"in e)return[!0,e[ii]];let t=e;if(t.type==="__overwrite__"&&"value"in t)return[!0,t.value]}return[!1,void 0]}function Da(e){return Pn(e)[0]}function Ma(e){return!e||typeof e!="object"||!("__interrupt__"in e)?!1:Array.isArray(e[qe])}var Dr=class extends nT{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)?yl(e.goto):[yl(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:Ct(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 Ft(e){return typeof e!="object"||e==null?!1:"lg_name"in e&&e.lg_name==="Command"}function $U(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function yl(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((i,n)=>{r[n]=yl(i,t)});else if(e instanceof Dr||e instanceof Na||!$U(e))r=e,t.set(e,r);else if(Ft(e))r=new Dr(e),t.set(e,r);else if(op(e))r=new Na(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[i,n]of Object.entries(e))r[i]=yl(n,t)}return r}return e}var pn=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}},ap=class extends pn{get is_bubble_up(){return!0}},Ay=class extends pn{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},za=class extends pn{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},sp=class extends ap{reason;constructor(e="shutdown",t){super(`Graph drained: ${e}`,t),this.name="GraphDrained",this.reason=e}static get unminifiable_name(){return"GraphDrained"}};function cp(e){return e!==void 0&&e.name===sp.unminifiable_name}var Li=class extends ap{interrupts;constructor(e,t){super(JSON.stringify(e,null,2),t),this.name="GraphInterrupt",this.interrupts=e??[]}static get unminifiable_name(){return"GraphInterrupt"}},up=class extends Li{constructor(e,t){super([{value:e}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},lp=class{node;error;constructor(e,t){this.node=e,this.error=t}static get unminifiable_name(){return"NodeError"}};function IU(e){return e!=null&&typeof e=="object"&&e.constructor!=null&&e.constructor.unminifiable_name===lp.unminifiable_name}var dp=class extends ap{command;constructor(e){super(),this.name="ParentCommand",this.command=e}static get unminifiable_name(){return"ParentCommand"}};function Cy(e){return e!==void 0&&e.name===dp.unminifiable_name}function No(e){return e!==void 0&&e.is_bubble_up===!0}function Ui(e){return e!==void 0&&[Li.unminifiable_name,up.unminifiable_name].includes(e.name)}var fp=class extends pn{node;kind;timeout;elapsed;runTimeout;idleTimeout;constructor(e,t){let{node:r,elapsed:i,kind:n,runTimeout:o,idleTimeout:a}=e,s,c;if(n==="idle"){if(a===void 0)throw new Error("idleTimeout is required when kind='idle'");c=a,s=`Node "${r}" exceeded its idle timeout of ${a}ms without making progress (elapsed: ${i}ms).`}else{if(o===void 0)throw new Error("runTimeout is required when kind='run'");c=o,s=`Node "${r}" exceeded its run timeout of ${o}ms (elapsed: ${i}ms).`}super(s,t),this.name="NodeTimeoutError",this.node=r,this.kind=n,this.timeout=c,this.elapsed=i,this.runTimeout=o,this.idleTimeout=a}static get unminifiable_name(){return"NodeTimeoutError"}};function EU(e){return e!==void 0&&e.name===fp.unminifiable_name}var pp=class extends pn{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},Ve=class extends pn{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"}},Se=class extends pn{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}},TU=class extends pn{constructor(e,t){super(e,t),this.name="MultipleSubgraphError"}static get unminifiable_name(){return"MultipleSubgraphError"}},Oy=class extends pn{constructor(e,t){super(e,t),this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}},AU=class extends pn{constructor(e,t){super(e,t),this.name="RemoteException"}static get unminifiable_name(){return"RemoteException"}},Sl=class extends pn{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"}},CU=()=>(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 iT=Object.defineProperty,C=(e,t)=>{let r={};for(var i in e)iT(r,i,{get:e[i],enumerable:!0});return t||iT(r,Symbol.toStringTag,{value:"Module"}),r};var oT="ffffffff-ffff-ffff-ffff-ffffffffffff";var aT="00000000-0000-0000-0000-000000000000";var sT=/^(?:[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 Ro(e){return typeof e=="string"&&sT.test(e)}function La(e){if(!Ro(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 qt=[];for(let e=0;e<256;++e)qt.push((e+256).toString(16).slice(1));function Yr(e,t=0){return(qt[e[t+0]]+qt[e[t+1]]+qt[e[t+2]]+qt[e[t+3]]+"-"+qt[e[t+4]]+qt[e[t+5]]+"-"+qt[e[t+6]]+qt[e[t+7]]+"-"+qt[e[t+8]]+qt[e[t+9]]+"-"+qt[e[t+10]]+qt[e[t+11]]+qt[e[t+12]]+qt[e[t+13]]+qt[e[t+14]]+qt[e[t+15]]).toLowerCase()}function cT(e,t=0){let r=Yr(e,t);if(!Ro(r))throw TypeError("Stringified UUID is invalid");return r}var OU=new Uint8Array(16);function jo(){return crypto.getRandomValues(OU)}var kl={};function mp(e,t,r){let i,n=e?._v6??!1;if(e){let o=Object.keys(e);o.length===1&&o[0]==="_v6"&&(e=void 0)}if(e)i=uT(e.random??e.rng?.()??jo(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{let o=Date.now(),a=jo();PU(kl,o,a),i=uT(a,kl.msecs,kl.nsecs,n?void 0:kl.clockseq,n?void 0:kl.node,t,r)}return t??Yr(i)}function PU(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 uT(e,t,r,i,n,o,a=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!o)o=new Uint8Array(16),a=0;else if(a<0||a+16>o.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);t??=Date.now(),r??=0,i??=(e[8]<<8|e[9])&16383,n??=e.slice(10,16),t+=122192928e5;let s=((t&268435455)*1e4+r)%4294967296;o[a++]=s>>>24&255,o[a++]=s>>>16&255,o[a++]=s>>>8&255,o[a++]=s&255;let c=t/4294967296*1e4&268435455;o[a++]=c>>>8&255,o[a++]=c&255,o[a++]=c>>>24&15|16,o[a++]=c>>>16&255,o[a++]=i>>>8|128,o[a++]=i&255;for(let u=0;u<6;++u)o[a++]=n[u];return o}function lT(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():NU(e,t,r)}function NU(e,t,r){e=e||{};let i=e.random??e.rng?.()??jo();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[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 n=0;n<16;++n)t[r+n]=i[n];return t}return Yr(i)}function RU(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function Py(e,t){return e<<t|e>>>32-t}function dT(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,o=Math.ceil(n/16),a=new Array(o);for(let s=0;s<o;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];a[s]=c}a[o-1][14]=(e.length-1)*8/2**32,a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<o;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=a[s][m];for(let m=16;m<80;++m)c[m]=Py(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let h=Math.floor(m/20),g=Py(u,5)+RU(h,l,d,f)+p+t[h]+c[m]>>>0;p=f,f=d,d=Py(l,30)>>>0,l=u,u=g}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>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 jU(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 fT="6ba7b810-9dad-11d1-80b4-00c04fd430c8",pT="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function mT(e,t,r,i,n,o){let a=typeof r=="string"?jU(r):r,s=typeof i=="string"?La(i):i;if(typeof i=="string"&&(i=La(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+a.length);if(c.set(s),c.set(a,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(o??=0,o<0||o+16>n.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let u=0;u<16;++u)n[o+u]=c[u];return n}return Yr(c)}function hp(e,t,r,i){return mT(80,dT,e,t,r,i)}hp.DNS=fT;hp.URL=pT;function hT(e){let t=DU(typeof e=="string"?La(e):e);return typeof e=="string"?Yr(t):t}function DU(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 gT(e,t,r){e??={},r??=0;let i=mp({...e,_v6:!0},new Uint8Array(16));if(i=hT(i),t){if(r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;n++)t[r+n]=i[n];return t}return Yr(i)}var Ny={};function yT(e,t,r){let i;if(e)i=_T(e.random??e.rng?.()??jo(),e.msecs,e.seq,t,r);else{let n=Date.now(),o=jo();MU(Ny,n,o),i=_T(o,Ny.msecs,Ny.seq,t,r)}return t??Yr(i)}function MU(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 _T(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}function vT(e){if(!Ro(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var bT=C({MAX:()=>zU,NIL:()=>LU,parse:()=>UU,stringify:()=>FU,v1:()=>BU,v4:()=>Do,v5:()=>hc,v6:()=>Ry,v7:()=>mn,validate:()=>Fi,version:()=>VU}),zU=oT,LU=aT,UU=La,FU=cT,BU=mp,Do=lT,hc=hp,Ry=gT,mn=yT,Fi=Ro,VU=vT;var jy=0,$l=0;function Il(e){let t=Date.now();return t<=jy?($l+=1,$l>=1e4&&($l=0,t=jy+1)):$l=0,jy=t,Ry({clockseq:e,msecs:t,nsecs:$l})}function ci(e,t){let r=t.replace(/-/g,"").match(/.{2}/g).map(i=>parseInt(i,16));return hc(e,new Uint8Array(r))}var El="__pregel_tasks",Dy="__error__",Ua="__scheduled__",My="__interrupt__",zy="__resume__",gc=class{lg_name="DeltaSnapshot";value;constructor(e){this.value=e}};function Ly(e){return e!=null&&typeof e=="object"&&e.lg_name==="DeltaSnapshot"}var wT="[...]",HU="[Circular]",gp=[],_c=[];function ZU(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function xT(e,t,r,i){typeof i>"u"&&(i=ZU()),Fy(e,"",0,[],void 0,0,i);var n;try{_c.length===0?n=JSON.stringify(e,t,r):n=JSON.stringify(e,GU(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;gp.length!==0;){var o=gp.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return n}function Uy(e,t,r,i){var n=Object.getOwnPropertyDescriptor(i,r);n.get!==void 0?n.configurable?(Object.defineProperty(i,r,{value:e}),gp.push([i,r,t,n])):_c.push([t,r,e]):(i[r]=e,gp.push([i,r,t]))}function Fy(e,t,r,i,n,o,a){o+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<i.length;s++)if(i[s]===e){Uy(HU,e,t,n);return}if(typeof a.depthLimit<"u"&&o>a.depthLimit){Uy(wT,e,t,n);return}if(typeof a.edgesLimit<"u"&&r+1>a.edgesLimit){Uy(wT,e,t,n);return}if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)Fy(e[s],s,s,i,e,o,a);else{var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];Fy(e[u],u,s,i,e,o,a)}}i.pop()}}function GU(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(_c.length>0)for(var i=0;i<_c.length;i++){var n=_c[i];if(n[1]===t&&n[0]===r){r=n[2],_c.splice(i,1);break}}return e.call(this,t,r)}}var KU=/([A-Z]+)([A-Z][a-z0-9]+)/g,WU=/([a-z0-9])([A-Z])/g,ST=/[-_\s]+/g;function qU(e){return e.replace(KU,"$1_$2").replace(WU,"$1_$2").replace(ST,"_").toLowerCase()}function JU(e){let t=e.trim();return/[-_\s]/.test(t)?t.replace(ST,"_").toLowerCase().replace(/_+([a-z0-9])/g,(r,i)=>i.toUpperCase()):t}function kT(e,t){return t?.[e]||qU(e)}function $T(e,t){return t?.[e]||JU(e)}function _p(e,t,r){let i={};for(let n in e)Object.hasOwn(e,n)&&(i[t(n,r)]=e[n]);return i}var IT="__lc_escaped__";function XU(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function YU(e){return{[IT]:e}}function By(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function QU(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function e2(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 yp(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return e2(e);if(QU(e))return e;t.add(e);let r=e;if(XU(r))return t.delete(e),YU(r);let i={};for(let[n,o]of Object.entries(r))i[n]=yp(o,t);return t.delete(e),i}return Array.isArray(e)?e.map(r=>yp(r,t)):e}function vp(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(By(t))return t[IT];let r={};for(let[i,n]of Object.entries(t))r[i]=vp(n);return r}return Array.isArray(e)?e.map(t=>vp(t)):e}var TT=C({Serializable:()=>xt,get_lc_unique_name:()=>yc});function ET(e){return Array.isArray(e)?[...e]:{...e}}function t2(e,t){let r=ET(e);for(let[i,n]of Object.entries(t)){let[o,...a]=i.split(".").reverse(),s=r;for(let c of a.reverse()){if(s[c]===void 0)break;s[c]=ET(s[c]),s=s[c]}s[o]!==void 0&&(s[o]={lc:1,type:"secret",id:[n]})}return r}function yc(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 xt=class AT{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,yc(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(([i])=>this.lc_serializable_keys?.includes(i))):this.lc_kwargs=t??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof AT||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},r={},i=Object.keys(this.lc_kwargs).reduce((c,u)=>(c[u]=u in this?this[u]:this.lc_kwargs[u],c),{});for(let c=Object.getPrototypeOf(this);c;c=Object.getPrototypeOf(c))Object.assign(t,Reflect.get(c,"lc_aliases",this)),Object.assign(r,Reflect.get(c,"lc_secrets",this)),Object.assign(i,Reflect.get(c,"lc_attributes",this));Object.keys(r).forEach(c=>{let u=this,l=i,[d,...f]=c.split(".").reverse();for(let p of f.reverse()){if(!(p in u)||u[p]===void 0)return;(!(p in l)||l[p]===void 0)&&(typeof u[p]=="object"&&u[p]!=null?l[p]={}:Array.isArray(u[p])&&(l[p]=[])),u=u[p],l=l[p]}d in u&&u[d]!==void 0&&(l[d]=l[d]||u[d])});let n={},o=new WeakSet;o.add(this);for(let[c,u]of Object.entries(i))n[c]=yp(u,o);let a=Object.keys(r).length?t2(n,r):n,s=_p(a,kT,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:s}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};var CT=C({getEnv:()=>jT,getEnvironmentVariable:()=>Ot,getRuntimeEnvironment:()=>Hy,isBrowser:()=>OT,isDeno:()=>bp,isJsDom:()=>NT,isNode:()=>RT,isWebWorker:()=>PT}),OT=()=>typeof window<"u"&&typeof window.document<"u",PT=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",NT=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),bp=()=>typeof Deno<"u",RT=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!bp(),jT=()=>{let e;return OT()?e="browser":RT()?e="node":PT()?e="webworker":NT()?e="jsdom":bp()?e="deno":e="other",e},Vy;function Hy(){return Vy===void 0&&(Vy={library:"langchain-js",runtime:jT()}),Vy}function Ot(e){try{return typeof process<"u"?process.env?.[e]:bp()?Deno?.env.get(e):void 0}catch{return}}var DT=[];var MT=C({});var zT=C({});var re="0123456789abcdef".split(""),r2=[-2147483648,8388608,32768,128],Nn=[24,16,8,0],wp=[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],Bt=[];function Rn(e,t){t?(Bt[0]=Bt[16]=Bt[1]=Bt[2]=Bt[3]=Bt[4]=Bt[5]=Bt[6]=Bt[7]=Bt[8]=Bt[9]=Bt[10]=Bt[11]=Bt[12]=Bt[13]=Bt[14]=Bt[15]=0,this.blocks=Bt):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}Rn.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 i,n=0,o,a=e.length,s=this.blocks;n<a;){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(o=this.start;n<a&&o<64;++n)s[o>>>2]|=e[n]<<Nn[o++&3];else for(o=this.start;n<a&&o<64;++n)i=e.charCodeAt(n),i<128?s[o>>>2]|=i<<Nn[o++&3]:i<2048?(s[o>>>2]|=(192|i>>>6)<<Nn[o++&3],s[o>>>2]|=(128|i&63)<<Nn[o++&3]):i<55296||i>=57344?(s[o>>>2]|=(224|i>>>12)<<Nn[o++&3],s[o>>>2]|=(128|i>>>6&63)<<Nn[o++&3],s[o>>>2]|=(128|i&63)<<Nn[o++&3]):(i=65536+((i&1023)<<10|e.charCodeAt(++n)&1023),s[o>>>2]|=(240|i>>>18)<<Nn[o++&3],s[o>>>2]|=(128|i>>>12&63)<<Nn[o++&3],s[o>>>2]|=(128|i>>>6&63)<<Nn[o++&3],s[o>>>2]|=(128|i&63)<<Nn[o++&3]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.block=s[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};Rn.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=r2[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()}};Rn.prototype.hash=function(){var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,o=this.h5,a=this.h6,s=this.h7,c=this.blocks,u,l,d,f,p,m,h,g,_,v,x;for(u=16;u<64;++u)p=c[u-15],l=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,p=c[u-2],d=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,c[u]=c[u-16]+l+c[u-7]+d<<0;for(x=t&r,u=0;u<64;u+=4)this.first?(this.is224?(g=300032,p=c[0]-1413257819,s=p-150054599<<0,i=p+24177077<<0):(g=704751109,p=c[0]-210244248,s=p-1521486534<<0,i=p+143694565<<0),this.first=!1):(l=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(n>>>6|n<<26)^(n>>>11|n<<21)^(n>>>25|n<<7),g=e&t,f=g^e&r^x,h=n&o^~n&a,p=s+d+h+wp[u]+c[u],m=l+f,s=i+p<<0,i=p+m<<0),l=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),_=i&e,f=_^i&t^g,h=a&s^~a&n,p=o+d+h+wp[u+1]+c[u+1],m=l+f,a=r+p<<0,r=p+m<<0,l=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),v=r&i,f=v^r&e^_,h=o&a^~o&s,p=n+d+h+wp[u+2]+c[u+2],m=l+f,o=t+p<<0,t=p+m<<0,l=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),x=t&r,f=x^t&i^v,h=o&a^~o&s,p=n+d+h+wp[u+3]+c[u+3],m=l+f,n=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+i<<0,this.h4=this.h4+n<<0,this.h5=this.h5+o<<0,this.h6=this.h6+a<<0,this.h7=this.h7+s<<0};Rn.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,o=this.h5,a=this.h6,s=this.h7,c=re[e>>>28&15]+re[e>>>24&15]+re[e>>>20&15]+re[e>>>16&15]+re[e>>>12&15]+re[e>>>8&15]+re[e>>>4&15]+re[e&15]+re[t>>>28&15]+re[t>>>24&15]+re[t>>>20&15]+re[t>>>16&15]+re[t>>>12&15]+re[t>>>8&15]+re[t>>>4&15]+re[t&15]+re[r>>>28&15]+re[r>>>24&15]+re[r>>>20&15]+re[r>>>16&15]+re[r>>>12&15]+re[r>>>8&15]+re[r>>>4&15]+re[r&15]+re[i>>>28&15]+re[i>>>24&15]+re[i>>>20&15]+re[i>>>16&15]+re[i>>>12&15]+re[i>>>8&15]+re[i>>>4&15]+re[i&15]+re[n>>>28&15]+re[n>>>24&15]+re[n>>>20&15]+re[n>>>16&15]+re[n>>>12&15]+re[n>>>8&15]+re[n>>>4&15]+re[n&15]+re[o>>>28&15]+re[o>>>24&15]+re[o>>>20&15]+re[o>>>16&15]+re[o>>>12&15]+re[o>>>8&15]+re[o>>>4&15]+re[o&15]+re[a>>>28&15]+re[a>>>24&15]+re[a>>>20&15]+re[a>>>16&15]+re[a>>>12&15]+re[a>>>8&15]+re[a>>>4&15]+re[a&15];return this.is224||(c+=re[s>>>28&15]+re[s>>>24&15]+re[s>>>20&15]+re[s>>>16&15]+re[s>>>12&15]+re[s>>>8&15]+re[s>>>4&15]+re[s&15]),c};Rn.prototype.toString=Rn.prototype.hex;Rn.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,o=this.h5,a=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,i>>>24&255,i>>>16&255,i>>>8&255,i&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255];return this.is224||c.push(s>>>24&255,s>>>16&255,s>>>8&255,s&255),c};Rn.prototype.array=Rn.prototype.digest;Rn.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 vc=(...e)=>new Rn(!1,!0).update(e.join("")).hex();var LT=C({sha256:()=>vc});function UT(e){let t=Symbol.for(e);return{brand(r,i){let n=i?Symbol.for(`${e}.${i}`):t;class o extends r{[n]=!0;constructor(...s){super(...s)}static isInstance(s){return typeof s=="object"&&s!==null&&n in s&&s[n]===!0}static[Symbol.hasInstance](s){return this.isInstance(s)}}return Object.defineProperty(o,"name",{value:r.name}),o},sub(r){return UT(`${e}.${r}`)},isInstance(r){return typeof r=="object"&&r!==null&&t in r&&r[t]===!0}}}var FT=UT("langchain");var BT=C({ContextOverflowError:()=>n2,LangChainError:()=>Gy,ModelAbortError:()=>Sp,addLangChainErrorFields:()=>Bi,getRetryable:()=>Zy,ns:()=>xp,stampRetryable:()=>Vi});function Bi(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 xp=FT.sub("error"),VT=Symbol.for("langchain.errors.retryable");function Vi(e,t){if(typeof e!="object"||e===null)return e;try{Object.defineProperty(e,VT,{value:t,configurable:!0})}catch{}return e}function Zy(e){if(!(typeof e!="object"||e===null))return Object.getOwnPropertyDescriptor(e,VT)?.value}var Gy=class extends xp.brand(Error){name="LangChainError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Sp=class extends xp.brand(Gy,"model-abort"){name="ModelAbortError";partialOutput;constructor(e,t){super(e),this.partialOutput=t,Vi(this,!1)}},n2=class HT extends xp.brand(Gy,"context-overflow"){name="ContextOverflowError";cause;constructor(t){super(t??"Input exceeded the model's context window."),Vi(this,!1)}static fromError(t){let r=new HT(t.message);return r.cause=t,r}};function ui(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 bc(e){return ui(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function wc(e){return ui(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function ZT(e){return ui(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function kp(e){return ui(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function $p(e){if(ui(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 GT(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(),i=t[1].trim();if(r===""||i==="")throw new Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let n={};for(let o of e.split(";").slice(1)){let a=o.split("=");if(a.length!==2)throw new Error(`Invalid parameter syntax in mime type: "${e}".`);let s=a[0].trim(),c=a[1].trim();if(s==="")throw new Error(`Invalid parameter syntax in mime type: "${e}".`);n[s]=c}return{type:r,subtype:i,parameters:n}}function Tl({dataUrl:e,asTypedArray:t=!1}){let r=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),i;if(r){i=r[1].toLowerCase();let n=t?Uint8Array.from(atob(r[2]),o=>o.charCodeAt(0)):r[2];return{mime_type:i,data:n}}}function KT(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 G(e,t){return Q(e)&&e.type===t}function Q(e){return typeof e=="object"&&e!==null}function St(e){return Array.isArray(e)}function N(e){return typeof e=="string"}function Qr(e){return typeof e=="number"}function Ip(e){return e instanceof Uint8Array}function Ky(e){try{return JSON.parse(e)}catch{return}}var en=e=>e();function i2(e){if(e.type==="char_location"&&N(e.document_title)&&Qr(e.start_char_index)&&Qr(e.end_char_index)&&N(e.cited_text)){let{document_title:t,start_char_index:r,end_char_index:i,cited_text:n,...o}=e;return{...o,type:"citation",source:"char",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="page_location"&&N(e.document_title)&&Qr(e.start_page_number)&&Qr(e.end_page_number)&&N(e.cited_text)){let{document_title:t,start_page_number:r,end_page_number:i,cited_text:n,...o}=e;return{...o,type:"citation",source:"page",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="content_block_location"&&N(e.document_title)&&Qr(e.start_block_index)&&Qr(e.end_block_index)&&N(e.cited_text)){let{document_title:t,start_block_index:r,end_block_index:i,cited_text:n,...o}=e;return{...o,type:"citation",source:"block",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="web_search_result_location"&&N(e.url)&&N(e.title)&&N(e.encrypted_index)&&N(e.cited_text)){let{url:t,title:r,encrypted_index:i,cited_text:n,...o}=e;return{...o,type:"citation",source:"url",url:t,title:r,startIndex:Number(i),endIndex:Number(i),citedText:n}}if(e.type==="search_result_location"&&N(e.source)&&N(e.title)&&Qr(e.start_block_index)&&Qr(e.end_block_index)&&N(e.cited_text)){let{source:t,title:r,start_block_index:i,end_block_index:n,cited_text:o,...a}=e;return{...a,type:"citation",source:"search",url:t,title:r??void 0,startIndex:i,endIndex:n,citedText:o}}}function qT(e){if(G(e,"document")&&Q(e.source)&&"type"in e.source){if(e.source.type==="base64"&&N(e.source.media_type)&&N(e.source.data))return{type:"file",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&N(e.source.url))return{type:"file",url:e.source.url};if(e.source.type==="file"&&N(e.source.file_id))return{type:"file",fileId:e.source.file_id};if(e.source.type==="text"&&N(e.source.data))return{type:"file",mimeType:String(e.source.media_type??"text/plain"),data:e.source.data}}else if(G(e,"image")&&Q(e.source)&&"type"in e.source){if(e.source.type==="base64"&&N(e.source.media_type)&&N(e.source.data))return{type:"image",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&N(e.source.url))return{type:"image",url:e.source.url};if(e.source.type==="file"&&N(e.source.file_id))return{type:"image",fileId:e.source.file_id}}}function JT(e){function*t(){for(let r of e){let i=qT(r);i?yield i:yield r}}return Array.from(t())}function WT(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(G(i,"text")&&N(i.text)){let{text:n,citations:o,...a}=i;if(St(o)&&o.length){let s=o.reduce((c,u)=>{let l=i2(u);return l?[...c,l]:c},[]);yield{...a,type:"text",text:n,annotations:s};continue}else{yield{...a,type:"text",text:n};continue}}else if(G(i,"thinking")&&N(i.thinking)){let{thinking:n,signature:o,...a}=i;yield{...a,type:"reasoning",reasoning:n,signature:o};continue}else if(G(i,"redacted_thinking")){yield{type:"non_standard",value:i};continue}else if(G(i,"tool_use")&&N(i.name)&&N(i.id)){yield{type:"tool_call",id:i.id,name:i.name,args:i.input};continue}else if(G(i,"input_json_delta")){if(o2(e)&&e.tool_call_chunks?.length){let n=e.tool_call_chunks[0];yield{type:"tool_call_chunk",id:n.id,name:n.name,args:n.args,index:n.index};continue}}else if(G(i,"server_tool_use")&&N(i.name)&&N(i.id)){let{name:n,id:o}=i;if(n==="web_search"){yield{id:o,type:"server_tool_call",name:"web_search",args:{query:en(()=>{if(typeof i.input=="string")return i.input;if(Q(i.input)&&N(i.input.query))return i.input.query;if(N(i.partial_json)){let a=Ky(i.partial_json);if(a?.query)return a.query}return""})}};continue}else if(i.name==="code_execution"){yield{id:o,type:"server_tool_call",name:"code_execution",args:{code:en(()=>{if(typeof i.input=="string")return i.input;if(Q(i.input)&&N(i.input.code))return i.input.code;if(N(i.partial_json)){let a=Ky(i.partial_json);if(a?.code)return a.code}return""})}};continue}}else if(G(i,"web_search_tool_result")&&N(i.tool_use_id)&&St(i.content)){let{content:n,tool_use_id:o}=i;yield{type:"server_tool_call_result",name:"web_search",toolCallId:o,status:"success",output:{urls:n.reduce((a,s)=>G(s,"web_search_result")?[...a,s.url]:a,[])}};continue}else if(G(i,"code_execution_tool_result")&&N(i.tool_use_id)&&Q(i.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:i.tool_use_id,status:"success",output:i.content};continue}else if(G(i,"mcp_tool_use")){yield{id:i.id,type:"server_tool_call",name:"mcp_tool_use",args:i.input};continue}else if(G(i,"mcp_tool_result")&&N(i.tool_use_id)&&Q(i.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:i.tool_use_id,status:"success",output:i.content};continue}else if(G(i,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:i.input};continue}else if(G(i,"search_result")){yield{id:i.id,type:"non_standard",value:i};continue}else if(G(i,"tool_result")){yield{id:i.id,type:"non_standard",value:i};continue}else{let n=qT(i);if(n){yield n;continue}}yield{type:"non_standard",value:i}}}return Array.from(t())}var XT={translateContent:WT,translateContentChunk:WT};function o2(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function a2(e){return bc(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:wc(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:kp(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function YT(e){return e.map(a2)}function QT(e){return!!(G(e,"image_url")&&Q(e.image_url)||G(e,"input_audio")&&Q(e.input_audio)||G(e,"file")&&Q(e.file))}function eA(e){if(G(e,"image_url")&&Q(e.image_url)&&N(e.image_url.url)){let t=Tl({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(G(e,"input_audio")&&Q(e.input_audio)&&N(e.input_audio.data)&&N(e.input_audio.format))return{type:"audio",data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};if(G(e,"file")&&Q(e.file)&&N(e.file.data)){let t=Tl({dataUrl:e.file.data});if(t)return{type:"file",data:t.data,mimeType:t.mime_type};if(N(e.file.file_id))return{type:"file",fileId:e.file.file_id}}}return e}function s2(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Ep(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 c2(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Ep(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 Ep(e){let t=[];for(let r of e)QT(r)?t.push(eA(r)):t.push(r);return t}function u2(e){if(e.type==="url_citation"){let{url:t,title:r,start_index:i,end_index:n}=e;return{type:"citation",url:t,title:r,startIndex:i,endIndex:n}}if(e.type==="file_citation"){let{file_id:t,filename:r,index:i}=e;return{type:"citation",title:r,startIndex:i,endIndex:i,fileId:t}}return e}function tA(e){if(St(e.summary))return{type:"reasoning",reasoning:e.summary.reduce((t,r)=>Q(r)&&N(r.text)?`${t}${r.text}`:t,""),...N(e.id)?{id:e.id}:{},...N(e.encrypted_content)?{encrypted_content:e.encrypted_content}:{}}}function*l2(e){if(G(e,"web_search_call")){let t={};if(Q(e.action)&&N(e.action.query)&&(t.query=e.action.query),yield{id:e.id,type:"server_tool_call",name:"web_search",args:t},e.status==="completed"||e.status==="failed"){let r={};Q(e.action)&&(r.action=e.action),yield{type:"server_tool_call_result",toolCallId:N(e.id)?e.id:"",status:e.status==="completed"?"success":"error",output:r}}return}if(G(e,"file_search_call")){yield{id:e.id,type:"server_tool_call",name:"file_search",args:{queries:St(e.queries)?e.queries:[]}},(e.status==="completed"||e.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:N(e.id)?e.id:"",status:e.status==="completed"?"success":"error",output:St(e.results)?{results:e.results}:{}});return}if(G(e,"computer_call")){yield{type:"non_standard",value:e};return}if(G(e,"code_interpreter_call")){if(N(e.code)&&(yield{id:e.id,type:"server_tool_call",name:"code_interpreter",args:{code:e.code}}),St(e.outputs)){let t=en(()=>{if(e.status!=="in_progress"){if(e.status==="completed")return 0;if(e.status==="incomplete")return 127;if(e.status!=="interpreting"&&e.status==="failed")return 1}});for(let r of e.outputs)G(r,"logs")&&(yield{type:"server_tool_call_result",toolCallId:e.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:t??0,stderr:[0,void 0].includes(t)?void 0:String(r.logs),stdout:[0,void 0].includes(t)?String(r.logs):void 0}})}return}if(G(e,"mcp_call")){yield{id:e.id,type:"server_tool_call",name:"mcp_call",args:e.input};return}if(G(e,"mcp_list_tools")){yield{id:e.id,type:"server_tool_call",name:"mcp_list_tools",args:e.input};return}if(G(e,"mcp_approval_request")){yield{type:"non_standard",value:e};return}if(G(e,"tool_search_call")){let t={};Q(e.arguments)&&Object.assign(t,e.arguments);let r={};N(e.execution)&&(r.execution=e.execution),N(e.status)&&(r.status=e.status),N(e.call_id)&&(r.call_id=e.call_id),yield{id:N(e.id)?e.id:"",type:"server_tool_call",name:"tool_search",args:t,...Object.keys(r).length>0?{extras:r}:{}};return}if(G(e,"tool_search_output")){let t={name:"tool_search"};N(e.execution)&&(t.execution=e.execution),yield{type:"server_tool_call_result",toolCallId:N(e.id)?e.id:"",status:e.status==="completed"?"success":e.status==="failed"?"error":"success",output:{tools:St(e.tools)?e.tools:[]},extras:t};return}if(G(e,"image_generation_call")){N(e.result)&&(yield{type:"image",mimeType:"image/png",data:e.result,id:N(e.id)?e.id:void 0,metadata:{status:N(e.status)?e.status:void 0}}),yield{type:"non_standard",value:e};return}Q(e)&&(yield{type:"non_standard",value:e})}function rA(e){let t=e.response_metadata?.output,r=St(t)&&t.length>0,i=new Map,n=0,o;r&&t.forEach((u,l)=>{!Q(u)||!N(u.type)||(u.type==="reasoning"&&N(u.id)?i.set(`reasoning:${u.id}`,l):(u.type==="function_call"||u.type==="custom_tool_call"||u.type==="computer_call")&&N(u.call_id)?i.set(`tool_call:${u.call_id}`,l):u.type==="message"?(n+=1,o=l):N(u.id)&&i.set(`other:${u.type}:${u.id}`,l))});let a=n===1&&o!=null?`message:${o}`:void 0;a!=null&&i.set(a,o);function*s(){if(r){for(let l of t)if(Q(l)&&l.type==="reasoning"){let d=tA(l);d&&(yield[d,N(l.id)?`reasoning:${l.id}`:void 0])}}else if(Q(e.additional_kwargs?.reasoning)&&St(e.additional_kwargs.reasoning.summary)){let l=tA(e.additional_kwargs.reasoning);l&&(yield[l,void 0])}let u=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let l of u)if(G(l,"text")){let{text:d,annotations:f,phase:p,extras:m,...h}=l,g=Q(m)?{...m}:{};N(p)&&(g.phase=p);let _=Object.keys(g).length>0?{extras:g}:{};yield[{...h,..._,type:"text",text:String(d),...Array.isArray(f)?{annotations:f.map(u2)}:{}},a]}for(let l of e.tool_calls??[])yield[{type:"tool_call",id:l.id,name:l.name,args:l.args},l.id?`tool_call:${l.id}`:void 0];if(Q(e.additional_kwargs)&&St(e.additional_kwargs.tool_outputs))for(let l of e.additional_kwargs.tool_outputs){let d=Q(l)&&N(l.type)&&N(l.id)?`other:${l.type}:${l.id}`:void 0;for(let f of l2(l))yield[f,d]}}let c=Array.from(s());return r?c.map(([u,l],d)=>({block:u,pushIndex:d,position:l!=null?i.get(l):void 0})).sort((u,l)=>{let d=u.position??Number.POSITIVE_INFINITY,f=l.position??Number.POSITIVE_INFINITY;return d!==f?d-f:u.pushIndex-l.pushIndex}).map(u=>u.block):c.map(([u])=>u)}function d2(e){function*t(){yield*rA(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 nA={translateContent:e=>typeof e.content=="string"?s2(e):rA(e),translateContentChunk:e=>typeof e.content=="string"?c2(e):d2(e)};function Tp(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function iA(e,t="pretty"){return t==="pretty"?f2(e):JSON.stringify(e)}function f2(e){let t=[],r=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,i=Math.floor((80-r.length)/2),n="=".repeat(i),o=r.length%2===0?n:`${n}=`;if(t.push(`${n}${r}${o}`),e.type==="ai"){let a=e;if(a.tool_calls&&a.tool_calls.length>0){t.push("Tool Calls:");for(let s of a.tool_calls){t.push(` ${s.name} (${s.id})`),t.push(` Call ID: ${s.id}`),t.push(" Args:");for(let[c,u]of Object.entries(s.args))t.push(` ${c}: ${typeof u=="object"?JSON.stringify(u):u}`)}}}if(e.type==="tool"){let a=e;a.name&&t.push(`Name: ${a.name}`)}return typeof e.content=="string"&&e.content.trim()&&(t.length>1&&t.push(""),t.push(e.content)),t.join(`
9
+ `)}var Wy=Symbol.for("langchain.message");function oA(e){return Array.isArray(e)?e:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e==null?[]:[e]}function or(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=>ui(r))?[{type:"text",source_type:"text",text:e},...t]:[{type:"text",text:e},...t];if(Array.isArray(t)){let r=oA(e);return Mo(r,t)??[...r,...t]}else return t===""?e:Array.isArray(e)&&e.some(r=>ui(r))?[...e,{type:"file",source_type:"text",text:t}]:[...oA(e),{type:"text",text:t}]}function Ap(e,t){return e==="error"||t==="error"?"error":"success"}function p2(e,t){function r(i,n){if(typeof i!="object"||i===null||i===void 0)return i;if(n>=t)return Array.isArray(i)?"[Array]":"[Object]";if(Array.isArray(i))return i.map(a=>r(a,n+1));let o={};for(let a of Object.keys(i))o[a]=r(i[a],n+1);return o}return JSON.stringify(r(e,0),null,2)}var ze=class extends xt{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[Wy]=!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 this.contentBlocks.filter(e=>e.type==="text").reduce((e,t)=>e+(t.text??""),"")}get contentBlocks(){let e=typeof this.content=="string"?[{type:"text",text:this.content}]:this.content;return[YT,Ep,JT].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&&Wy in e&&e[Wy]===!0&&Tp(e)}static[Symbol.hasInstance](e){return this.isInstance(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=p2(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}toFormattedString(e="pretty"){return iA(this,e)}};function uA(e){return Array.isArray(e)&&e.every(t=>typeof t.index=="number")}var qy=["index","created","timestamp"];function ut(e,t,r){let i=r?.ignoreKeys??qy;if(e==null&&t==null)return;if(e==null||t==null)return e??t;let n={...e};for(let[o,a]of Object.entries(t))if(n[o]==null)n[o]=a;else{if(a==null)continue;if(typeof n[o]!=typeof a||Array.isArray(n[o])!==Array.isArray(a))throw new Error(`field[${o}] already exists in the message chunk, but with a different type.`);if(typeof n[o]=="string"){if(o==="type")continue;if(["id","name","output_version","model_provider"].includes(o))a&&(n[o]=a);else{if(i.includes(o))continue;n[o]+=a}}else if(typeof n[o]=="number"){if(i.includes(o))continue;n[o]=n[o]+a}else if(typeof n[o]=="object"&&!Array.isArray(n[o]))n[o]=ut(n[o],a,r);else if(Array.isArray(n[o]))n[o]=Mo(n[o],a,r);else{if(n[o]===a)continue;console.warn(`field[${o}] already exists in this message chunk and value has unsupported type.`)}}return n}function m2(e){return typeof e=="number"||typeof e=="string"}function aA(e){return typeof e!="object"||e===null||!("index"in e)?!1:m2(e.index)}function sA(e){if(typeof e!="object"||e===null||!("id"in e))return!1;let t=e.id;return t!=null&&t!==""}function cA(e){return e.endsWith("_delta")?e.slice(0,-6):e}function h2(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"&&cA(e.type)!==cA(t.type)}function g2(e,t){let r=aA(t),i=sA(t);return!r&&!i?-1:e.findIndex(n=>{let o=aA(n),a=sA(n);return r&&o?n.index!==t.index||h2(n,t)?!1:a&&i?n.id===t.id:!0:!r&&!o&&i&&a?n.id===t.id:!1})}function Mo(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e||t;{let i=[...e];for(let n of t){let o=g2(i,n);if(o!==-1)i[o]=ut(i[o],n,r);else{if(typeof n=="object"&&n!==null&&"text"in n&&n.text==="")continue;i.push(n)}}return i}}}function Cp(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 Mo(e,t,r);if(typeof e=="object"&&typeof t=="object")return ut(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 Vt=class lA extends ze{static isInstance(t){if(!super.isInstance(t))return!1;let r=Object.getPrototypeOf(t);for(;r!==null;){if(r===lA.prototype)return!0;r=Object.getPrototypeOf(r)}return!1}static[Symbol.hasInstance](t){return this.isInstance(t)}};function Op(e){return typeof e.role=="string"}function lt(e){return typeof e?._getType=="function"}function Hi(e){return Vt.isInstance(e)}var dA=C({ToolMessage:()=>Pt,ToolMessageChunk:()=>xc,defaultToolCallParser:()=>Cl,isDirectToolOutput:()=>Al,isToolMessage:()=>Ol,isToolMessageChunk:()=>Jy});function Al(e){return e!=null&&typeof e=="object"&&"lc_direct_tool_output"in e&&e.lc_direct_tool_output===!0}var Pt=class extends ze{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 i=typeof e=="string"||Array.isArray(e)?{content:e,name:r,tool_call_id:t}:e;super(i),this.tool_call_id=i.tool_call_id,this.artifact=i.artifact,this.status=i.status,this.metadata=i.metadata}static isInstance(e){return super.isInstance(e)&&e.type==="tool"}static[Symbol.hasInstance](e){return this.isInstance(e)}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}},xc=class extends Vt{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:or(this.content,e.content),additional_kwargs:ut(this.additional_kwargs,e.additional_kwargs),response_metadata:ut(this.response_metadata,e.response_metadata),artifact:Cp(this.artifact,e.artifact),tool_call_id:this.tool_call_id,id:this.id??e.id,status:Ap(this.status,e.status)})}static isInstance(e){return super.isInstance(e)&&e.type==="tool"}static[Symbol.hasInstance](e){return this.isInstance(e)}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}};function Cl(e){let t=[],r=[];for(let i of e)if(i.function){let n=i.function.name;try{let o=JSON.parse(i.function.arguments);t.push({name:n||"",args:o||{},id:i.id})}catch{r.push({name:n,args:i.function.arguments,id:i.id,error:"Malformed args."})}}else continue;return[t,r]}function Ol(e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="tool"}function Jy(e){return e._getType()==="tool"}function zo(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="tool_call")}function fA(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 Sc=class extends Error{output;constructor(e,t){super(e),this.output=t}};function Fa(e,t=jn){e=e.trim();let r=e.indexOf("```");if(r===-1)return t(e);let i=e.substring(r+3);i.startsWith(`json
14
+ `)?i=i.substring(5):i.startsWith("json")?i=i.substring(4):i.startsWith(`
15
+ `)&&(i=i.substring(1));let n=i.indexOf("```"),o=i;return n!==-1&&(o=i.substring(0,n)),t(o.trim())}function _2(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 i(){for(;r<t.length&&/\s/.test(t[r]);)r+=1}function n(){if(t[r]!=='"')throw new Error(`Expected '"' at position ${r}, got '${t[r]}'`);r+=1;let l="",d=!1;for(;r<t.length;){let f=t[r];if(d){if(f==="n")l+=`
16
+ `;else if(f==="t")l+=" ";else if(f==="r")l+="\r";else if(f==="\\")l+="\\";else if(f==='"')l+='"';else if(f==="b")l+="\b";else if(f==="f")l+="\f";else if(f==="/")l+="/";else if(f==="u"){let p=t.substring(r+1,r+5);if(/^[0-9A-Fa-f]{0,4}$/.test(p))p.length===4?l+=String.fromCharCode(Number.parseInt(p,16)):l+=`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,l;l+=f}r+=1}return d&&(l+="\\"),l}function o(){let l=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 ${l}`);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=l,new Error(`Invalid number '${d}' at position ${l}`);return f}function a(){if(i(),r>=t.length)throw new Error(`Unexpected end of input at position ${r}`);let l=t[r];if(l==="{")return c();if(l==="[")return s();if(l==='"')return n();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(l==="-"||l>="0"&&l<="9")return o();throw new Error(`Unexpected character '${l}' at position ${r}`)}function s(){if(t[r]!=="[")throw new Error(`Expected '[' at position ${r}, got '${t[r]}'`);let l=[];if(r+=1,i(),r>=t.length)return l;if(t[r]==="]")return r+=1,l;for(;r<t.length;){if(i(),r>=t.length||(l.push(a()),i(),r>=t.length))return l;if(t[r]==="]")return r+=1,l;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or ']' at position ${r}, got '${t[r]}'`)}return l}function c(){if(t[r]!=="{")throw new Error(`Expected '{' at position ${r}, got '${t[r]}'`);let l={};if(r+=1,i(),r>=t.length)return l;if(t[r]==="}")return r+=1,l;for(;r<t.length;){if(i(),r>=t.length)return l;let d=n();if(i(),r>=t.length)return l;if(t[r]!==":")throw new Error(`Expected ':' at position ${r}, got '${t[r]}'`);if(r+=1,i(),r>=t.length||(l[d]=a(),i(),r>=t.length))return l;if(t[r]==="}")return r+=1,l;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or '}' at position ${r}, got '${t[r]}'`)}return l}let u=a();if(i(),r<t.length)throw new Error(`Unexpected character '${t[r]}' at position ${r}`);return u}function jn(e){try{return typeof e>"u"?null:_2(e)}catch{return null}}function Xy(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 y2(e){if(Q(e.document)&&Q(e.document.source)){let t=Xy(Q(e.document)&&N(e.document.format)?e.document.format:"");if(Q(e.document.source)){if(Q(e.document.source.s3Location)&&N(e.document.source.s3Location.uri))return{type:"file",mimeType:t,fileId:e.document.source.s3Location.uri};if(Ip(e.document.source.bytes))return{type:"file",mimeType:t,data:e.document.source.bytes};if(N(e.document.source.text))return{type:"file",mimeType:t,data:Buffer.from(e.document.source.text).toString("base64")};if(St(e.document.source.content))return{type:"file",mimeType:t,data:e.document.source.content.reduce((r,i)=>Q(i)&&N(i.text)?r+i.text:r,"")}}}return{type:"non_standard",value:e}}function v2(e){if(G(e,"image")&&Q(e.image)){let t=Xy(Q(e.image)&&N(e.image.format)?e.image.format:"");if(Q(e.image.source)){if(Q(e.image.source.s3Location)&&N(e.image.source.s3Location.uri))return{type:"image",mimeType:t,fileId:e.image.source.s3Location.uri};if(Ip(e.image.source.bytes))return{type:"image",mimeType:t,data:e.image.source.bytes}}}return{type:"non_standard",value:e}}function b2(e){if(G(e,"video")&&Q(e.video)){let t=Xy(Q(e.video)&&N(e.video.format)?e.video.format:"");if(Q(e.video.source)){if(Q(e.video.source.s3Location)&&N(e.video.source.s3Location.uri))return{type:"video",mimeType:t,fileId:e.video.source.s3Location.uri};if(Ip(e.video.source.bytes))return{type:"video",mimeType:t,data:e.video.source.bytes}}}return{type:"non_standard",value:e}}function pA(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(G(i,"reasoning")&&N(i.reasoning)){yield{...i,type:"reasoning",reasoning:i.reasoning};continue}else if(G(i,"cache_point")){yield{type:"non_standard",value:i};continue}else if(G(i,"citations_content")&&Q(i.citationsContent)){yield{type:"text",text:St(i.citationsContent.content)?i.citationsContent.content.reduce((n,o)=>Q(o)&&N(o.text)?n+o.text:n,""):"",annotations:St(i.citationsContent.citations)?i.citationsContent.citations.reduce((n,o)=>{if(Q(o)){let a=St(o.sourceContent)?o.sourceContent.reduce((c,u)=>Q(u)&&N(u.text)?c+u.text:c,""):"",s=en(()=>{if(Q(o.location)){let c=o.location.documentChar||o.location.documentPage||o.location.documentChunk;if(Q(c))return{source:Qr(c.documentIndex)?c.documentIndex.toString():void 0,startIndex:Qr(c.start)?c.start:void 0,endIndex:Qr(c.end)?c.end:void 0}}return{}});n.push({type:"citation",citedText:a,...s})}return n},[]):[]};continue}else if(G(i,"document")&&Q(i.document)){yield y2(i);continue}else if(G(i,"guard_content")){yield{type:"non_standard",value:i};continue}else if(G(i,"image")&&Q(i.image)){yield v2(i);continue}else if(G(i,"reasoning_content")&&Q(i.reasoningText)&&N(i.reasoningText.text)){yield{type:"reasoning",reasoning:i.reasoningText.text,...N(i.reasoningText.signature)?{signature:i.reasoningText.signature}:{}};continue}else if(G(i,"reasoning_content")&&N(i.reasoningText)){yield{type:"reasoning",reasoning:i.reasoningText};continue}else if(G(i,"text")&&N(i.text)){yield{type:"text",text:i.text};continue}else if(G(i,"tool_result")){yield{type:"non_standard",value:i};continue}else{if(G(i,"tool_call"))continue;if(G(i,"video")&&Q(i.video)){yield b2(i);continue}}yield{type:"non_standard",value:i}}}return Array.from(t())}var mA={translateContent:pA,translateContentChunk:pA};function hA(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(N(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 i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&N(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 gA={translateContent:hA,translateContentChunk:hA};function _A(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(G(i,"text")&&N(i.text)){yield{type:"text",text:i.text};continue}else if(G(i,"thinking")&&N(i.thinking)){yield{type:"reasoning",reasoning:i.thinking,...i.signature?{signature:i.signature}:{}};continue}else if(G(i,"inlineData")&&Q(i.inlineData)&&N(i.inlineData.mimeType)&&N(i.inlineData.data)){yield{type:"file",mimeType:i.inlineData.mimeType,data:i.inlineData.data};continue}else if(G(i,"functionCall")&&Q(i.functionCall)&&N(i.functionCall.name)&&Q(i.functionCall.args)){yield{type:"tool_call",id:e.id,name:i.functionCall.name,args:i.functionCall.args};continue}else if(G(i,"functionResponse")){yield{type:"non_standard",value:i};continue}else if(G(i,"fileData")&&Q(i.fileData)&&N(i.fileData.mimeType)&&N(i.fileData.fileUri)){yield{type:"file",mimeType:i.fileData.mimeType,fileId:i.fileData.fileUri};continue}else if(G(i,"executableCode")){yield{type:"non_standard",value:i};continue}else if(G(i,"codeExecutionResult")){yield{type:"non_standard",value:i};continue}yield{type:"non_standard",value:i}}}return Array.from(t())}var yA={translateContent:_A,translateContentChunk:_A};function vA(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(G(i,"reasoning")&&N(i.reasoning)){let n=en(()=>{let o=r.indexOf(i);if(St(e.additional_kwargs?.signatures)&&o>=0)return e.additional_kwargs.signatures.at(o)});N(n)?yield{type:"reasoning",reasoning:i.reasoning,signature:n}:yield{type:"reasoning",reasoning:i.reasoning};continue}else if(G(i,"thinking")&&N(i.thinking)){yield{type:"reasoning",reasoning:i.thinking,...i.signature?{signature:i.signature}:{}};continue}else if(G(i,"text")&&N(i.text)){if(i.text==="")continue;yield{type:"text",text:i.text};continue}else if(G(i,"image_url")){if(N(i.image_url))if(i.image_url.startsWith("data:")){let n=i.image_url.match(/^data:([^;]+);base64,(.+)$/);n?yield{type:"image",data:n[2],mimeType:n[1]}:yield{type:"image",url:i.image_url}}else yield{type:"image",url:i.image_url};continue}else if(G(i,"media")&&N(i.mimeType)&&N(i.data)){yield{type:"file",mimeType:i.mimeType,data:i.data};continue}yield{type:"non_standard",value:i}}for(let i of e.tool_calls??[])yield{type:"tool_call",id:i.id,name:i.name,args:i.args}}return Array.from(t())}var bA={translateContent:vA,translateContentChunk:vA};function wA(e){let t=[],r=e.additional_kwargs?.reasoning;if(N(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string"){let i=e.content,n=i.match(/<think>([\s\S]*?)<\/think>/);if(n){let o=n[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})}else for(let i of e.content)if(typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&N(i.text)){let n=i.text,o=n.match(/<think>([\s\S]*?)<\/think>/);if(o){let a=o[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})}for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var xA={translateContent:wA,translateContentChunk:wA};function SA(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(N(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 i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&N(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 kA={translateContent:SA,translateContentChunk:SA};function $A(e){let t=[],r=e.additional_kwargs?.reasoning_details,i=!1;if(Array.isArray(r)&&r.length>0)for(let n of r){if(n==null||typeof n!="object")continue;let o=n.type;if(o==="reasoning.summary"){let a=n.summary;N(a)&&a.length>0&&(t.push({type:"reasoning",reasoning:a}),i=!0)}else if(o==="reasoning.text"){let a=n.text;N(a)&&a.length>0&&(t.push({type:"reasoning",reasoning:a}),i=!0)}}if(!i){let n=e.additional_kwargs?.reasoning_content;N(n)&&n.length>0&&t.push({type:"reasoning",reasoning:n})}if(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&&N(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 IA={translateContent:$A,translateContentChunk:$A};function EA(e){let t=[];if(Q(e.additional_kwargs?.reasoning)){let i=e.additional_kwargs.reasoning;if(St(i.summary)){let n=i.summary.reduce((o,a)=>Q(a)&&N(a.text)?`${o}${a.text}`:o,"");n.length>0&&t.push({type:"reasoning",reasoning:n})}}let r=e.additional_kwargs?.reasoning_content;if(N(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 i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&N(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 TA={translateContent:EA,translateContentChunk:EA};function AA(e){function*t(){let r=en(()=>{if(typeof e.content=="string")return e.additional_kwargs.originalTextContentBlock?[{...e.additional_kwargs.originalTextContentBlock,type:"text"}]:[{type:"text",text:e.content}];{let i=e.additional_kwargs?.originalTextContentBlock;if(i?.thoughtSignature&&!e.content.some(n=>"thoughtSignature"in n)){let n=[...e.content];for(let o=n.length-1;o>=0;o--){let a=n[o];if(a.type==="text"&&!a.thought)return a.thoughtSignature=i.thoughtSignature,n}}return e.content}});for(let i of r){let n=en(()=>G(i,"text")&&N(i.text)?{type:"text",text:i.text}:G(i,"inlineData")&&Q(i.inlineData)&&N(i.inlineData.mimeType)&&N(i.inlineData.data)?{type:"file",mimeType:i.inlineData.mimeType,data:i.inlineData.data}:G(i,"functionCall")&&Q(i.functionCall)&&N(i.functionCall.name)&&Q(i.functionCall.args)?{type:"tool_call",id:e.id,name:i.functionCall.name,args:i.functionCall.args}:G(i,"functionResponse")?{type:"non_standard",value:i}:G(i,"fileData")&&Q(i.fileData)&&N(i.fileData.mimeType)&&N(i.fileData.fileUri)?{type:"file",mimeType:i.fileData.mimeType,fileId:i.fileData.fileUri}:G(i,"executableCode")?{type:"non_standard",value:i}:G(i,"codeExecutionResult")?{type:"non_standard",value:i}:{type:"non_standard",value:i}),o=en(()=>"thought"in i&&i.thought?{type:"reasoning",reasoning:n.type==="text"?n.text:"",reasoningContentBlock:n}:n),a={thought:i.thought,thoughtSignature:i.thoughtSignature,partMetadata:i.partMetadata,...o};for(let s in a)a[s]===void 0&&delete a[s];yield a}}return Array.from(t())}var CA={translateContent:AA,translateContentChunk:AA};globalThis.lc_block_translators_registry??=new Map([["anthropic",XT],["bedrock-converse",mA],["deepseek",gA],["google",CA],["google-genai",yA],["google-vertexai",bA],["groq",xA],["ollama",kA],["openai",nA],["openrouter",IA],["xai",TA]]);function Yy(e){return globalThis.lc_block_translators_registry.get(e)}function Pp(e,t){return ut(e,t)??{}}function OA(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 w2(e,t){let r={...OA(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 x2(e,t){let r={...OA(e,t)};return(e?.reasoning!==void 0||t?.reasoning!==void 0)&&(r.reasoning=(e?.reasoning??0)+(t?.reasoning??0)),r}function kc(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:w2(e?.input_token_details,t?.input_token_details),output_token_details:x2(e?.output_token_details,t?.output_token_details)}}function PA(e){return typeof e=="string"?e.length>0?[{type:"text",text:e}]:[]:Array.isArray(e)?e:e==null?[]:[e]}var Le=class extends ze{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,i=t.tool_calls;r!=null&&r.length>0&&(i===void 0||i.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&&i===void 0){let[n,o]=Cl(r);t.tool_calls=n??[],t.invalid_tool_calls=o??[]}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=PA(t.content),t.content=void 0),t.contentBlocks!==void 0){if(Array.isArray(t.contentBlocks)||(t.contentBlocks=PA(t.contentBlocks)),t.tool_calls){let o=t.tool_calls.filter(a=>!t.contentBlocks?.some(s=>s.type==="tool_call"&&s.id===a.id&&s.name===a.name));t.contentBlocks.push(...o.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.args})))}let n=t.contentBlocks.filter(o=>o.type==="tool_call").filter(o=>!t.tool_calls?.some(a=>a.id===o.id&&a.name===o.name));n.length>0&&(t.tool_calls=[...t.tool_calls??[],...n.map(o=>({type:"tool_call",id:o.id,name:o.name,args:o.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=Yy(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(i=>i.id===r.id&&i.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"}static[Symbol.hasInstance](e){return this.isInstance(e)}};function $c(e){return e._getType()==="ai"}function NA(e){return e._getType()==="ai"}var nt=class extends Vt{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=Np(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=Yy(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:or(this.content,e.content),additional_kwargs:ut(this.additional_kwargs,e.additional_kwargs),response_metadata:Pp(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 i=Mo(this.tool_call_chunks,e.tool_call_chunks);i!==void 0&&i.length>0&&(t.tool_call_chunks=i)}if(this.tool_calls!==void 0||e.tool_calls!==void 0){let i=Mo(this.tool_calls,e.tool_calls);i!==void 0&&i.length>0&&(t.tool_calls=i)}(this.usage_metadata!==void 0||e.usage_metadata!==void 0)&&(t.usage_metadata=kc(this.usage_metadata,e.usage_metadata));let r=this.constructor;return new r(t)}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}static[Symbol.hasInstance](e){return this.isInstance(e)}};var Dn=class RA extends ze{static lc_name(){return"ChatMessage"}type="generic";role;static _chatMessageClass(){return RA}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"}static[Symbol.hasInstance](t){return this.isInstance(t)}get _printableFields(){return{...super._printableFields,role:this.role}}},Ba=class extends Vt{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:or(this.content,e.content),additional_kwargs:ut(this.additional_kwargs,e.additional_kwargs),response_metadata:ut(this.response_metadata,e.response_metadata),role:this.role,id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="generic"}static[Symbol.hasInstance](e){return this.isInstance(e)}get _printableFields(){return{...super._printableFields,role:this.role}}};function jA(e){return e._getType()==="generic"}function DA(e){return e._getType()==="generic"}var Va=class extends ze{static lc_name(){return"FunctionMessage"}type="function";name;constructor(e){super(e),this.name=e.name}static isInstance(e){return super.isInstance(e)&&e.type==="function"}static[Symbol.hasInstance](e){return this.isInstance(e)}},Ha=class extends Vt{static lc_name(){return"FunctionMessageChunk"}type="function";concat(e){let t=this.constructor;return new t({content:or(this.content,e.content),additional_kwargs:ut(this.additional_kwargs,e.additional_kwargs),response_metadata:ut(this.response_metadata,e.response_metadata),name:this.name??"",id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="function"}static[Symbol.hasInstance](e){return this.isInstance(e)}};function MA(e){return e._getType()==="function"}function zA(e){return e._getType()==="function"}var ht=class extends ze{static lc_name(){return"HumanMessage"}type="human";constructor(e){super(e)}static isInstance(e){return super.isInstance(e)&&e.type==="human"}static[Symbol.hasInstance](e){return this.isInstance(e)}},Za=class extends Vt{static lc_name(){return"HumanMessageChunk"}type="human";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:or(this.content,e.content),additional_kwargs:ut(this.additional_kwargs,e.additional_kwargs),response_metadata:ut(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="human"}static[Symbol.hasInstance](e){return this.isInstance(e)}};function LA(e){return e.getType()==="human"}function UA(e){return e.getType()==="human"}var tn=class extends ze{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"}static[Symbol.hasInstance](e){return this.isInstance(e)}};var xr=class Rp extends ze{static lc_name(){return"SystemMessage"}type="system";constructor(t){super(t)}concat(t){if(typeof t=="string")return new Rp({content:or(this.content,t),additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata,id:this.id,name:this.name});if(Rp.isInstance(t))return new Rp({content:or(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"}static[Symbol.hasInstance](t){return this.isInstance(t)}},Zi=class extends Vt{static lc_name(){return"SystemMessageChunk"}type="system";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:or(this.content,e.content),additional_kwargs:ut(this.additional_kwargs,e.additional_kwargs),response_metadata:ut(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="system"}static[Symbol.hasInstance](e){return this.isInstance(e)}};function FA(e){return e._getType()==="system"}function BA(e){return e._getType()==="system"}function S2(e){return e.isCustomTool===!0}var VA=e=>e();function k2(e){return zo(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 $2(e){return typeof e=="object"&&e!=null&&e.lc===1&&Array.isArray(e.id)&&e.kwargs!=null&&typeof e.kwargs=="object"}function Qy(e){let t,r;if($2(e)){let i=e.id.at(-1);i==="HumanMessage"||i==="HumanMessageChunk"?t="user":i==="AIMessage"||i==="AIMessageChunk"?t="assistant":i==="SystemMessage"||i==="SystemMessageChunk"?t="system":i==="FunctionMessage"||i==="FunctionMessageChunk"?t="function":i==="ToolMessage"||i==="ToolMessageChunk"?t="tool":t="unknown",r=e.kwargs}else{let{type:i,...n}=e;t=i,r=n}if(t==="human"||t==="user")return new ht(r);if(t==="ai"||t==="assistant"){let{tool_calls:i,...n}=r;if(!Array.isArray(i))return new Le(r);let o=i.map(k2);return new Le({...n,tool_calls:o})}else{if(t==="system")return new xr(r);if(t==="developer")return new xr({...r,additional_kwargs:{...r.additional_kwargs,__openai_role__:"developer"}});if(t==="tool"&&"tool_call_id"in r)return new Pt({...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 tn({...r,id:r.id});throw Bi(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 Nt(e){if(typeof e=="string")return new ht(e);if(lt(e))return e;if(Array.isArray(e)){let[t,r]=e;return Qy({type:t,content:r})}else if(Op(e)){let{role:t,...r}=e;return Qy({...r,type:t})}else return Qy(e)}function I2(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 Ic(e,t="Human",r="AI"){let i=[];for(let n of e){let o;if(n.type==="human")o=t;else if(n.type==="ai")o=r;else if(n.type==="system")o="System";else if(n.type==="tool")o="Tool";else if(n.type==="generic")o=n.role;else throw new Error(`Got unsupported message type: ${n.type}`);let a=n.name?`${n.name}, `:"",s=typeof n.content=="string"?n.content:Array.isArray(n.content)?n.content.map(I2).filter(Boolean).join(""):"",c=`${o}: ${a}${s}`;if(n.type==="ai"){let u=n;u.tool_calls&&u.tool_calls.length>0?c+=JSON.stringify(u.tool_calls):u.additional_kwargs&&"function_call"in u.additional_kwargs&&(c+=JSON.stringify(u.additional_kwargs.function_call))}i.push(c)}return i.join(`
21
+ `)}function E2(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 Pl(e){let t=E2(e);switch(t.type){case"human":return new ht(t.data);case"ai":return new Le(t.data);case"system":return new xr(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new Va(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 Pt(t.data);case"generic":if(t.data.role===void 0)throw new Error("Role must be defined for chat messages");return new Dn(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function HA(e){return e.map(Pl)}function ZA(e){return e.map(t=>t.toDict())}function Ga(e){let t=e._getType();if(t==="human")return new Za({...e});if(t==="ai"){let r={...e};return"tool_calls"in r&&(r={...r,tool_call_chunks:r.tool_calls?.map(i=>({...i,type:"tool_call_chunk",index:void 0,args:JSON.stringify(i.args)}))}),new nt({...r})}else{if(t==="system")return new Zi({...e});if(t==="function")return new Ha({...e});if(Dn.isInstance(e))return new Ba({...e});throw new Error("Unknown message type.")}}function Np(e){let t=e.reduce((n,o)=>{let a=n.findIndex(([s])=>"id"in o&&o.id&&"index"in o&&o.index!==void 0?o.id===s.id&&o.index===s.index:"id"in o&&o.id?o.id===s.id:"index"in o&&o.index!==void 0?o.index===s.index:!1);return a!==-1?n[a].push(o):n.push([o]),n},[]),r=[],i=[];for(let n of t){let o=null,a=n.some(S2),s=n[0]?.name??"",c=n.map(f=>f.args||"").join(""),u=a?c:c.trim(),l=u.length?u:"{}",d=n.find(f=>f.id)?.id??n[0]?.id;if(a&&d){r.push({name:s,args:{input:u},id:d,type:"tool_call"});continue}try{if(o=jn(l),!d||o===null||typeof o!="object"||Array.isArray(o))throw new Error("Malformed tool call chunk args.");r.push({name:s,args:o,id:d,type:"tool_call"})}catch{i.push({name:s,args:l,id:d,error:"Malformed args.",type:"invalid_tool_call"})}}return{tool_call_chunks:e,tool_calls:r,invalid_tool_calls:i}}var GA=C({BaseCache:()=>WA,InMemoryCache:()=>ev,defaultHashKeyEncoder:()=>KA,deserializeStoredGeneration:()=>T2,serializeGeneration:()=>A2}),KA=(...e)=>vc(e.join("_"));function T2(e){return e.message!==void 0?{text:e.text,message:Pl(e.message)}:{text:e.text}}function A2(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var WA=class{keyEncoder=KA;makeDefaultKeyEncoder(e){this.keyEncoder=e}},C2=new Map,ev=class qA extends WA{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,i){this.cache.set(this.keyEncoder(t,r),i)}static global(){return new qA(C2)}};var JA=C({BaseCallbackHandler:()=>Sr,callbackHandlerPrefersChatModelStreamEvents:()=>tv,callbackHandlerPrefersStreaming:()=>Nl,isBaseCallbackHandler:()=>rv}),O2=class{};function Nl(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}function tv(e){return"lc_prefer_chat_model_stream_events"in e&&e.lc_prefer_chat_model_stream_events}var Sr=class extends O2{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,yc(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=Ot("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 xt.prototype.toJSON.call(this)}toJSONNotImplemented(){return xt.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends Sr{name=mn();constructor(){super(),Object.assign(this,e)}}return new t}},rv=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"};var XA=/^(?:[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 P2(e){return typeof e=="string"&&XA.test(e)}var Rl=P2;function N2(e){if(!Rl(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 jp=N2;var Jt=[];for(let e=0;e<256;++e)Jt.push((e+256).toString(16).slice(1));function Ec(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 R2=new Uint8Array(16);function Tc(){return crypto.getRandomValues(R2)}function j2(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():D2(e,t,r)}function D2(e,t,r){e=e||{};let i=e.random??e.rng?.()??Tc();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[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 n=0;n<16;++n)t[r+n]=i[n];return t}return Ec(i)}var Ka=j2;function M2(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function nv(e,t){return e<<t|e>>>32-t}function z2(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,o=Math.ceil(n/16),a=new Array(o);for(let s=0;s<o;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];a[s]=c}a[o-1][14]=(e.length-1)*8/2**32,a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<o;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=a[s][m];for(let m=16;m<80;++m)c[m]=nv(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let h=Math.floor(m/20),g=nv(u,5)+M2(h,l,d,f)+p+t[h]+c[m]>>>0;p=f,f=d,d=nv(l,30)>>>0,l=u,u=g}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>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 YA=z2;function L2(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 iv="6ba7b810-9dad-11d1-80b4-00c04fd430c8",ov="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function av(e,t,r,i,n,o){let a=typeof r=="string"?L2(r):r,s=typeof i=="string"?jp(i):i;if(typeof i=="string"&&(i=jp(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+a.length);if(c.set(s),c.set(a,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(o??=0,o<0||o+16>n.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let u=0;u<16;++u)n[o+u]=c[u];return n}return Ec(c)}function sv(e,t,r,i){return av(80,YA,e,t,r,i)}sv.DNS=iv;sv.URL=ov;var cv=sv;var uv={};function U2(e,t,r){let i;if(e)i=QA(e.random??e.rng?.()??Tc(),e.msecs,e.seq,t,r);else{let n=Date.now(),o=Tc();F2(uv,n,o),i=QA(o,uv.msecs,uv.seq,t,r)}return t??Ec(i)}function F2(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 QA(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}var Ac=U2;var eC="gen_ai.operation.name",tC="gen_ai.system",lv="gen_ai.request.model",rC="gen_ai.response.model",dv="gen_ai.usage.input_tokens",fv="gen_ai.usage.output_tokens",pv="gen_ai.usage.total_tokens",nC="gen_ai.request.max_tokens",iC="gen_ai.request.temperature",oC="gen_ai.request.top_p",aC="gen_ai.request.frequency_penalty",sC="gen_ai.request.presence_penalty",cC="gen_ai.response.finish_reasons",uC="gen_ai.prompt",lC="gen_ai.completion",dC="gen_ai.request.extra_query",fC="gen_ai.request.extra_body",pC="gen_ai.serialized.name",mC="gen_ai.serialized.signature",hC="gen_ai.serialized.doc",gC="gen_ai.response.id",_C="gen_ai.response.service_tier",yC="gen_ai.response.system_fingerprint",vC="gen_ai.usage.input_token_details",bC="gen_ai.usage.output_token_details",wC="langsmith.trace.session_id",xC="langsmith.trace.session_name",SC="langsmith.span.kind",kC="langsmith.trace.name",$C="langsmith.metadata",mv="langsmith.span.tags";var IC="langsmith.request.streaming",EC="langsmith.request.headers";var hv="langsmith.usage_metadata";var H2=(...e)=>fetch(...e),Z2,TC=Symbol.for("ls:fetch_implementation");var AC=()=>globalThis[TC]===void 0?!0:Z2??!1,CC=e=>async(...t)=>{if(e||Ye("DEBUG")==="true"){let[i,n]=t;console.log(`\u2192 ${n?.method||"GET"} ${i}`)}let r=await(globalThis[TC]??H2)(...t);return(e||Ye("DEBUG")==="true")&&console.log(`\u2190 ${r.status} ${r.statusText} ${r.url}`),r};var jl=()=>Ye("PROJECT")??Ht("LANGCHAIN_SESSION")??"default";var OC={};function Zt(e,t){let r=t?.code??e;OC[r]||(OC[r]=!0,t?.type&&typeof process<"u"&&typeof process.emitWarning=="function"?process.emitWarning(e,{type:t.type,code:t.code}):t?.type&&t?.code?console.warn(`${t.type} [${t.code}]: ${e}`):console.warn(e))}var M=e=>BigInt(e),jC=M("0x9E3779B1"),DC=M("0x85EBCA77"),G2=M("0xC2B2AE3D"),Lo=M("0x9E3779B185EBCA87"),Wa=M("0xC2B2AE3D27D4EB4F"),MC=M("0x165667B19E3779F9"),vv=M("0x85EBCA77C2B2AE63"),K2=M("0x27D4EB2F165667C5"),W2=M("0x165667919E3779F9"),q2=M("0x9FB21C651E98DF25");function J2(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 li=J2("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),Oc=(M(1)<<M(128))-M(1),ke=(M(1)<<M(64))-M(1),Lp=(M(1)<<M(32))-M(1),Gi=64,zC=Gi/8,X2=8,Dp=4;function Qe(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function it(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getBigUint64(0,!0)}function Cc(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getUint32(0,!0)}function gv(e,t=0){return e[t]}var Y2=e=>(e&M(255))<<M(56)|(e&M(65280))<<M(40)|(e&M(16711680))<<M(24)|(e&M(4278190080))<<M(8)|(e&M(0xff00000000))>>M(8)|(e&M(0xff0000000000))>>M(24)|(e&M(0xff000000000000))>>M(40)|(e&M(0xff00000000000000))>>M(56),Q2=e=>(e=(e&M(65535))<<M(16)|(e&M(4294901760))>>M(16),e=(e&M(16711935))<<M(8)|(e&M(4278255360))>>M(8),e),e6=(e,t)=>(e&Lp)*(t&Lp)&ke,Pc=e=>{if(!e)throw new Error("Assert failed")};function t6(e,t){return(e<<t|e>>M(32)-t)&Lp}function LC(e,t,r){for(let i=0;i<zC;i++){let n=it(t,i*8),o=n^it(r,i*8);e[i^1]+=n,e[i]+=e6(o,o>>M(32))}return e}function PC(e,t,r,i){for(let n=0;n<i;n++)LC(e,Qe(t,n*Gi),Qe(r,n*8));return e}function r6(e,t){for(let r=0;r<zC;r++){let i=it(t,r*8),n=e[r];n=_v(n,M(47)),n^=i,n*=jC,e[r]=n&ke}return e}function Mp(e,t){return UC(e[0]^it(t,0),e[1]^it(t,X2))}function NC(e,t,r){let i=r;return i+=Mp(e.slice(0),Qe(t,0*Dp)),i+=Mp(e.slice(2),Qe(t,4*Dp)),i+=Mp(e.slice(4),Qe(t,8*Dp)),i+=Mp(e.slice(6),Qe(t,12*Dp)),di(i&ke)}function n6(e,t,r,i,n){let o=Math.floor((r.byteLength-Gi)/8),a=Gi*o,s=Math.floor((t.byteLength-1)/a);for(let c=0;c<s;c++)e=PC(e,Qe(t,c*a),r,o),e=n(e,Qe(r,r.byteLength-Gi));{let c=Math.floor((t.byteLength-1-a*s)/Gi);e=PC(e,Qe(t,s*a),r,c),e=i(e,Qe(t,t.byteLength-Gi),Qe(r,r.byteLength-Gi-7))}return e}function i6(e,t,r){let i=new BigUint64Array([G2,Lo,Wa,MC,vv,DC,K2,jC]);Pc(e.length>128),i=n6(i,e,t,LC,r6),Pc(i.length*8==64);{let n=NC(i,Qe(t,11),M(e.byteLength)*Lo&ke);return NC(i,Qe(t,t.byteLength-Gi-11),~(M(e.byteLength)*Wa)&ke)<<M(64)|n}}function UC(e,t){let r=e*t&Oc;return r&ke^r>>M(64)}function RC(e,t,r){return UC((it(e,0)^it(t,0)+r)&ke,(it(e,8)^it(t,8)-r)&ke)}function zp(e,t,r,i,n){let o=e&ke,a=e>>M(64)&ke;return o+=RC(t,i,n),o^=it(r,0)+it(r,8),o&=ke,a+=RC(r,Qe(i,16),n),a^=it(t,0)+it(t,8),a&=ke,a<<M(64)|o}function di(e){return e^=e>>M(37),e*=W2,e&=ke,e^=e>>M(32),e}function Up(e){return e^=e>>M(33),e*=Wa,e&=ke,e^=e>>M(29),e*=MC,e&=ke,e^=e>>M(32),e}function o6(e,t,r){let i=e.byteLength;Pc(i>0&&i<=3);let n=M(gv(e,i-1))|M(i<<8)|M(gv(e,0)<<16)|M(gv(e,i>>1)<<24),o=(M(Cc(t,0))^M(Cc(t,4)))+r,a=(n^o)&ke,s=(M(Cc(t,8))^M(Cc(t,12)))-r,c=(t6(Q2(n),M(13))^s)&ke;return(Up(c)&ke)<<M(64)|Up(a)}function _v(e,t){return e^e>>t}function a6(e,t,r){let i=e.byteLength;Pc(i>=4&&i<=8);{let n=Cc(e,0),o=Cc(e,i-4),a=M(n)|M(o)<<M(32),s=(it(t,16)^it(t,24))+r&ke,u=(a^s)*(Lo+(M(i)<<M(2)))&Oc;return u+=(u&ke)<<M(65),u&=Oc,u^=u>>M(67),_v(_v(u&ke,M(35))*q2&ke,M(28))|di(u>>M(64))<<M(64)}}function s6(e,t,r){let i=e.byteLength;Pc(i>=9&&i<=16);{let n=(it(t,32)^it(t,40))+r&ke,o=(it(t,48)^it(t,56))-r&ke,a=it(e),s=it(e,i-8),c=(a^s^n)*Lo,u=(c&ke)+(M(i-1)<<M(54));c=c&(Oc^ke)|u,s^=o,c+=s+(s&Lp)*(DC-M(1))<<M(64),c&=Oc,c^=Y2(c>>M(64));let l=(c&ke)*Wa;return l+=(c>>M(64))*Wa<<M(64),l&=Oc,di(l&ke)|di(l>>M(64))<<M(64)}}function c6(e,t){let r=e.byteLength;return Pc(r<=16),r>8?s6(e,li,t):r>=4?a6(e,li,t):r>0?o6(e,li,t):Up(t^it(li,64)^it(li,72))|Up(t^it(li,80)^it(li,88))<<M(64)}function yv(e){return~e+M(1)&ke}function u6(e,t,r){let i=M(e.byteLength)*Lo&ke,n=M(e.byteLength-1)/M(32);for(;n>=0;){let s=Number(n);i=zp(i,Qe(e,16*s),Qe(e,e.byteLength-16*(s+1)),Qe(t,32*s),r),n--}let o=i+(i>>M(64))&ke;o=di(o);let a=(i&ke)*Lo+(i>>M(64))*vv+(M(e.byteLength)-r&ke)*Wa;return a&=ke,a=yv(di(a)),o|a<<M(64)}function l6(e,t,r){let i=M(e.byteLength)*Lo&ke;for(let a=32;a<160;a+=32)i=zp(i,Qe(e,a-32),Qe(e,a-16),Qe(t,a-32),r);i=di(i&ke)|di(i>>M(64))<<M(64);for(let a=160;a<=e.byteLength;a+=32)i=zp(i,Qe(e,a-32),Qe(e,a-16),Qe(t,3+a-160),r);i=zp(i,Qe(e,e.byteLength-16),Qe(e,e.byteLength-32),Qe(t,103),yv(r));let n=i+(i>>M(64))&ke;n=di(n);let o=(i&ke)*Lo+(i>>M(64))*vv+(M(e.byteLength)-r&ke)*Wa;return o&=ke,o=yv(di(o)),n|o<<M(64)}function Fp(e,t=M(0)){let r=e.byteLength;return r<=16?c6(e,t):r<=128?u6(e,li,t):r<=240?l6(e,li,t):i6(e,li,t)}function FC(e){let t=new Uint8Array(16),r=new DataView(t.buffer),i=e&ke,n=e>>M(64);return r.setBigUint64(0,n,!1),r.setBigUint64(8,i,!1),t}var BC=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function pe(e,t){if(!BC.test(e)){let r=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(r)}return e}function Bp(e){let t=typeof e=="string"?Date.parse(e):e;return Ac({msecs:t,seq:0})}function VC(e){if(!BC.test(e))return null;let t=e[14];return parseInt(t,16)}function d6(e){let t=e.replace(/-/g,""),r=new Uint8Array(16);for(let i=0;i<16;i++)r[i]=parseInt(t.slice(i*2,i*2+2),16);return r}function f6(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 p6=new TextEncoder;function m6(e){let t=p6.encode(e),r=Fp(t);return FC(r)}function Nc(e,t){let r=`${e}:${t}`,i=m6(r),n=new Uint8Array(16);if(VC(e)===7){let a=d6(e);n.set(a.slice(0,6),0)}else n.set(i.slice(10,16),0);return n[6]=112|i[0]&15,n[7]=i[1],n[8]=128|i[2]&63,n.set(i.slice(3,10),9),f6(n)}var bv=e=>e!==void 0?e:!!["TRACING_V2","TRACING"].find(r=>Ye(r)==="true");var xv=class{getStore(){}run(t,r){return r()}},wv=Symbol.for("ls:tracing_async_local_storage"),h6=new xv,Sv=class{getInstance(){return globalThis[wv]??h6}initializeGlobalInstance(t){globalThis[wv]===void 0&&(globalThis[wv]=t)}},g6=new Sv;function kv(e=!1){let t=g6.getInstance().getStore();if(!e&&t===void 0)throw new Error(`Could not get the current run tree.
22
+
23
+ Please make sure you are calling this method within a traceable function and that tracing is enabled.`);return t}function Vp(e){return typeof e=="function"&&"langsmith:traceable"in e}var Mn={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function Hp(e){}async function Rc(e,t){}async function HC(e){return[]}async function ZC(e){return{size:0}}function jc(e){return!1}function qa(e){return""}async function GC(e){}async function Zp(e){}function _6(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var Gp=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 i=this.cache.get(t);if(!i){this._metrics.misses+=1;return}return this.cache.delete(t),this.cache.set(t,{...i,refreshFunc:r}),this._metrics.hits+=1,i.value}set(t,r,i){if(this.maxSize===0)return;if(this.refreshTimer===void 0&&this.startRefreshLoop(),!this.cache.has(t)&&this.cache.size>=this.maxSize){let o=this.cache.keys().next().value;o!==void 0&&this.cache.delete(o)}let n={value:r,createdAt:Date.now(),refreshFunc:i};this.cache.delete(t),this.cache.set(t,n)}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[o,a]of this.cache.entries())r[o]=a.value;let i=Mn.dirname(t);jc(i)||void 0;let n=`${t}.tmp`;try{JSON.stringify({entries:r},null,2)}catch(o){throw jc(n)&&void 0,o}}load(t){if(!jc(t))return 0;let r;try{let o=qa(t);r=JSON.parse(o).entries??null}catch{return 0}if(!r)return 0;let i=0,n=Date.now();for(let[o,a]of Object.entries(r)){if(this.cache.size>=this.maxSize)break;let s={value:a,createdAt:n};this.cache.set(o,s),i+=1}return i}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,i]of this.cache.entries())_6(i,this.ttlSeconds)&&t.push([r,i]);return t}async refreshStaleEntries(){let t=this.getStaleEntries();if(t.length!==0){for(let[r,i]of t)if(i.refreshFunc!==void 0)try{let n=await i.refreshFunc();this.set(r,n,i.refreshFunc),this._metrics.refreshes+=1}catch(n){this._metrics.refreshErrors+=1,console.warn(`Failed to refresh cache entry ${r}:`,n)}}}configure(t){this.stop(),this.refreshIntervalSeconds=t.refreshIntervalSeconds??60,this.maxSize=t.maxSize??100,this.ttlSeconds=t.ttlSeconds??300}},Kp=new Gp;function KC(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}var Dl=e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){let t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};var Mr=class extends Error{},Xt=class e extends Mr{constructor(t,r,i,n){super(`${e.makeMessage(t,r,i)}`),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"error",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.status=t,this.headers=n,this.error=r}static makeMessage(t,r,i){let n=r?.message?typeof r.message=="string"?r.message:JSON.stringify(r.message):r?JSON.stringify(r):i;return t&&n?`${t} ${n}`:t?`${t} status code (no body)`:n||"(no status code or body)"}static generate(t,r,i,n){if(!t||!n)return new Ki({message:i,cause:Dl(r)});let o=r;return t===400?new Xa(t,o,i,n):t===401?new Ya(t,o,i,n):t===403?new Qa(t,o,i,n):t===404?new es(t,o,i,n):t===409?new ts(t,o,i,n):t===422?new rs(t,o,i,n):t===429?new ns(t,o,i,n):t>=500?new is(t,o,i,n):new e(t,o,i,n)}},Uo=class extends Xt{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}},Ki=class extends Xt{constructor({message:t,cause:r}){super(void 0,void 0,t||"Connection error.",void 0),r&&(this.cause=r)}},Ja=class extends Ki{constructor({message:t}={}){super({message:t??"Request timed out."})}},Xa=class extends Xt{},Ya=class extends Xt{},Qa=class extends Xt{},es=class extends Xt{},ts=class extends Xt{},rs=class extends Xt{},ns=class extends Xt{},is=class extends Xt{};var Ml="0.10.4";var pi,v6=()=>typeof window<"u"&&typeof window.document<"u",b6=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",w6=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),JC=()=>typeof globalThis.Deno<"u",x6=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!JC(),zl=()=>pi||(typeof Bun<"u"?pi="bun":v6()?pi="browser":x6()?pi="node":b6()?pi="webworker":w6()?pi="jsdom":JC()?pi="deno":pi="other",pi),Iv;function Wp(){if(Iv===void 0){let e=zl(),t=$6();Iv={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:Ml,...t}}return Iv}var S6=["key","secret","token","password","passwd","pwd","credential","email"];function XC(e){let t=e.toLowerCase();return S6.some(r=>t.includes(r))}function Tv(){let e=k6(),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[i,n]of Object.entries(e))typeof n=="string"&&!r.includes(i)&&!XC(i)&&(i==="LANGCHAIN_REVISION_ID"?t.revision_id=n:t[i]=n);return t}function k6(){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&&(XC(t)&&typeof r=="string"?e[t]=r.slice(0,2)+"*".repeat(r.length-4)+r.slice(-2):e[t]=r)}catch{}return e}function Ht(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function Ye(e){return Ht(`LANGSMITH_${e}`)||Ht(`LANGCHAIN_${e}`)}var Ev;function $6(){if(Ev!==void 0)return Ev;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 i=Ht(r);i!==void 0&&(t[r]=i)}return Ev=t,t}function WC(){return Ht("OTEL_ENABLED")==="true"||Ye("OTEL_ENABLED")==="true"}var qC=new Set(["langsmith","otel"]);function qp(e){if(e!==void 0)return e;let t=Ye("TRACING_MODE");if(t!==void 0&&t!==""){let r=t.toLowerCase();if(!qC.has(r))throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(t)}. Must be one of: ${[...qC].sort().join(", ")}`);return WC()&&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 WC()?"otel":"langsmith"}var Ov=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...r){!this.hasWarned&&qp()==="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 i;if(r.length===1&&typeof r[0]=="function"?i=r[0]:r.length===2&&typeof r[1]=="function"?i=r[1]:r.length===3&&typeof r[2]=="function"&&(i=r[2]),typeof i=="function")return i()}},Pv=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new Ov})}getTracer(t,r){return this.mockTracer}getActiveSpan(){}setSpan(t,r){return t}getSpan(t){}setSpanContext(t,r){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},Nv=class{active(){return{}}with(t,r){return r()}},Av=Symbol.for("ls:otel_trace"),Cv=Symbol.for("ls:otel_context"),YC=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),I6=new Pv,E6=new Nv,Rv=class{getTraceInstance(){return globalThis[Av]??I6}getContextInstance(){return globalThis[Cv]??E6}initializeGlobalInstances(t){globalThis[Av]===void 0&&(globalThis[Av]=t.trace),globalThis[Cv]===void 0&&(globalThis[Cv]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[YC]=t}getDefaultOTLPTracerComponents(){return globalThis[YC]??void 0}},jv=new Rv;function Jp(){return jv.getTraceInstance()}function QC(){return jv.getContextInstance()}function eO(){return jv.getDefaultOTLPTracerComponents()}var T6={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function A6(e){return T6[e]||e}function C6(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var Xp=class{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(t,r){for(let i of t)try{if(!i.run)continue;if(i.operation==="post"){let n=this.createSpanForRun(i,i.run,r.get(i.id));n&&!i.run.end_time&&this.spans.set(i.id,n)}else this.updateSpanForRun(i,i.run)}catch(n){console.error(`Error processing operation ${i.id}:`,n)}}createSpanForRun(t,r,i){let n=i&&Jp().getSpan(i);if(n)try{return this.finishSpanSetup(n,r,t)}catch(o){console.error(`Failed to create span for run ${t.id}:`,o);return}}finishSpanSetup(t,r,i){return this.setSpanAttributes(t,r,i),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 i=this.spans.get(t.id);if(!i){console.debug(`No span found for run ${t.id} during update`);return}this.setSpanAttributes(i,r,t),r.error?(i.setStatus({code:2}),i.recordException(new Error(r.error))):i.setStatus({code:1});let n=r.end_time;n&&(i.end(new Date(n)),this.spans.delete(t.id))}catch(i){console.error(`Failed to update span for run ${t.id}:`,i)}}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 i=r.invocation_params;if(i.model)return i.model;if(i.model_name)return i.model_name}}}setSpanAttributes(t,r,i){if("run_type"in r&&r.run_type){t.setAttribute(SC,r.run_type);let s=A6(r.run_type||"chain");t.setAttribute(eC,s)}"name"in r&&r.name&&t.setAttribute(kC,r.name),"session_id"in r&&r.session_id&&t.setAttribute(wC,r.session_id),"session_name"in r&&r.session_name&&t.setAttribute(xC,r.session_name),this.setGenAiSystem(t,r);let n=this.extractModelName(r);n&&t.setAttribute(lv,n),r.extra?.metadata?.usage_metadata&&typeof r.extra.metadata.usage_metadata=="object"&&t.setAttribute(hv,JSON.stringify(r.extra.metadata.usage_metadata)),"prompt_tokens"in r&&typeof r.prompt_tokens=="number"&&t.setAttribute(dv,r.prompt_tokens),"completion_tokens"in r&&typeof r.completion_tokens=="number"&&t.setAttribute(fv,r.completion_tokens),"total_tokens"in r&&typeof r.total_tokens=="number"&&t.setAttribute(pv,r.total_tokens),this.setInvocationParameters(t,r);let o=r.extra?.metadata||{};for(let[s,c]of Object.entries(o))c!=null&&t.setAttribute(`${$C}.${s}`,C6(c)?String(c):JSON.stringify(c));let a=r.tags;if(a&&Array.isArray(a)?t.setAttribute(mv,a.join(", ")):a&&t.setAttribute(mv,String(a)),"serialized"in r&&typeof r.serialized=="object"){let s=r.serialized;s.name&&t.setAttribute(pC,String(s.name)),s.signature&&t.setAttribute(mC,String(s.signature)),s.doc&&t.setAttribute(hC,String(s.doc))}this.setIOAttributes(t,i)}setGenAiSystem(t,r){let i="langchain",n=this.extractModelName(r);if(n){let o=n.toLowerCase();o.includes("anthropic")||o.startsWith("claude")?i="anthropic":o.includes("bedrock")?i="aws.bedrock":o.includes("azure")&&o.includes("openai")?i="az.ai.openai":o.includes("azure")&&o.includes("inference")?i="az.ai.inference":o.includes("cohere")?i="cohere":o.includes("deepseek")?i="deepseek":o.includes("gemini")?i="gemini":o.includes("groq")?i="groq":o.includes("watson")||o.includes("ibm")?i="ibm.watsonx.ai":o.includes("mistral")?i="mistral_ai":o.includes("gpt")||o.includes("openai")?i="openai":o.includes("perplexity")||o.includes("sonar")?i="perplexity":o.includes("vertex")?i="vertex_ai":(o.includes("xai")||o.includes("grok"))&&(i="xai")}t.setAttribute(tC,i)}setInvocationParameters(t,r){if(!r.extra?.metadata?.invocation_params)return;let i=r.extra.metadata.invocation_params;i.max_tokens!==void 0&&t.setAttribute(nC,i.max_tokens),i.temperature!==void 0&&t.setAttribute(iC,i.temperature),i.top_p!==void 0&&t.setAttribute(oC,i.top_p),i.frequency_penalty!==void 0&&t.setAttribute(aC,i.frequency_penalty),i.presence_penalty!==void 0&&t.setAttribute(sC,i.presence_penalty)}setIOAttributes(t,r){if(r.run.inputs)try{let i=r.run.inputs;typeof i=="object"&&i!==null&&(i.model&&Array.isArray(i.messages)&&t.setAttribute(lv,i.model),i.stream!==void 0&&t.setAttribute(IC,i.stream),i.extra_headers&&t.setAttribute(EC,JSON.stringify(i.extra_headers)),i.extra_query&&t.setAttribute(dC,JSON.stringify(i.extra_query)),i.extra_body&&t.setAttribute(fC,JSON.stringify(i.extra_body))),t.setAttribute(uC,JSON.stringify(i))}catch(i){console.debug(`Failed to process inputs for run ${r.id}`,i)}if(r.run.outputs)try{let i=r.run.outputs,n=this.getUnifiedRunTokens(i);if(n&&(t.setAttribute(dv,n[0]),t.setAttribute(fv,n[1]),t.setAttribute(pv,n[0]+n[1])),i&&typeof i=="object"){if(i.model&&t.setAttribute(rC,String(i.model)),i.id&&t.setAttribute(gC,i.id),i.choices&&Array.isArray(i.choices)){let o=i.choices.map(a=>a.finish_reason).filter(a=>a).map(String);o.length>0&&t.setAttribute(cC,o.join(", "))}if(i.service_tier&&t.setAttribute(_C,i.service_tier),i.system_fingerprint&&t.setAttribute(yC,i.system_fingerprint),i.usage_metadata&&typeof i.usage_metadata=="object"){let o=i.usage_metadata;t.setAttribute(hv,JSON.stringify(o)),o.input_token_details&&t.setAttribute(vC,JSON.stringify(o.input_token_details)),o.output_token_details&&t.setAttribute(bC,JSON.stringify(o.output_token_details))}}t.setAttribute(lC,JSON.stringify(i))}catch(i){console.debug(`Failed to process outputs for run ${r.id}`,i)}}getUnifiedRunTokens(t){if(!t)return null;let r=this.extractUnifiedRunTokens(t.usage_metadata);if(r)return r;let i=Object.keys(t);for(let a of i){let s=t[a];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 n=t.generations||[];if(!Array.isArray(n))return null;let o=Array.isArray(n[0])?n.flat():n;for(let a of o)if(typeof a=="object"&&a.message&&typeof a.message=="object"&&a.message.kwargs&&typeof a.message.kwargs=="object"&&(r=this.extractUnifiedRunTokens(a.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 O6=Object.prototype.toString,P6=e=>O6.call(e)==="[object Error]",N6=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 Dv(e){if(!(e&&P6(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:r,stack:i}=e;return r==="Load failed"?i===void 0||"__sentry_captured__"in e:r.startsWith("error sending request for url")?!0:N6.has(r)}function R6(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 Yp(e,t,{min:r=0,allowInfinity:i=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${i?" or Infinity":""}.`);if(!i&&!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 Mv=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 j6(e,t){let r=Math.max(1,e+1),i=t.randomize?Math.random()+1:1,n=Math.round(i*t.minTimeout*t.factor**(r-1));return n=Math.min(n,t.maxTimeout),n}function tO(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function D6({error:e,attemptNumber:t,retriesConsumed:r,startTime:i,options:n}){let o=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(o instanceof Mv)throw o.originalError;let a=Number.isFinite(n.retries)?Math.max(0,n.retries-r):n.retries,s=n.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:o,attemptNumber:t,retriesLeft:a,retriesConsumed:r});if(await n.onFailedAttempt(c),tO(i,s)<=0)throw o;let u=await n.shouldConsumeRetry(c),l=tO(i,s);if(l<=0||a<=0)throw o;if(o instanceof TypeError&&!Dv(o)){if(u)throw o;return n.signal?.throwIfAborted(),!1}if(!await n.shouldRetry(c))throw o;if(!u)return n.signal?.throwIfAborted(),!1;let d=j6(r,n),f=Math.min(d,l);return f>0&&await new Promise((p,m)=>{let h=()=>{clearTimeout(g),n.signal?.removeEventListener("abort",h),m(n.signal.reason)},g=setTimeout(()=>{n.signal?.removeEventListener("abort",h),p()},f);n.unref&&g.unref?.(),n.signal?.addEventListener("abort",h,{once:!0})}),n.signal?.throwIfAborted(),!0}async function zv(e,t={}){if(t={...t},R6(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,Yp("factor",t.factor,{min:0,allowInfinity:!1}),Yp("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Yp("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Yp("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,i=0,n=performance.now();for(;!Number.isFinite(t.retries)||i<=t.retries;){r++;try{t.signal?.throwIfAborted();let o=await e(r);return t.signal?.throwIfAborted(),o}catch(o){await D6({error:o,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var im=tp(nm(),1),dO="default"in im.default?im.default.default:im.default;var Z6=[408,425,429,500,502,503,504],Ul=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 dO({concurrency:this.maxConcurrency}),this.onFailedResponseHook=t?.onFailedResponseHook}call(t,...r){return this.callWithOptions({},t,...r)}callWithOptions(t,r,...i){let n=t.sizeBytes??0;if(this.maxQueueSizeBytes!==void 0&&n>0&&this.queueSizeBytes+n>this.maxQueueSizeBytes)return Promise.reject(new Error(`Queue size limit (${this.maxQueueSizeBytes} bytes) exceeded. Current queue size: ${this.queueSizeBytes} bytes, attempted addition: ${n} bytes.`));n>0&&(this.queueSizeBytes+=n);let o=this.onFailedResponseHook,a=this.queue.add(()=>zv(()=>r(...i).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 u="response"in s?s.response:void 0;if(o&&await o(u))return;let l=u?.status??("status"in s?s.status:void 0);if(l!=null&&(typeof l=="number"||typeof l=="string")&&!Z6.includes(+l))throw s},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return n>0&&(a=a.finally(()=>{this.queueSizeBytes-=n})),t.signal?Promise.race([a,new Promise((s,c)=>{t.signal?.addEventListener("abort",()=>{c(new Error("AbortError"))})})]):a}};function Zv(e){return typeof e?._getType=="function"}function Gv(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}var Kv=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Kv=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),r=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,i=>(+i^r()&15>>+i/4).toString(16))};var G6=/^[a-z][a-z0-9+.-]*:/i,fO=e=>G6.test(e),sr=e=>(sr=Array.isArray,sr(e)),Wv=sr;function Dc(e){return typeof e!="object"?{}:e??{}}function qv(e){if(!e)return!0;for(let t in e)return!1;return!0}function pO(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var mO=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new Mr(`${e} must be an integer`);if(t<0)throw new Mr(`${e} must be a positive integer`);return t};var hO=e=>{try{return JSON.parse(e)}catch{return}};var gO=e=>new Promise(t=>setTimeout(t,e));var Fo="0.0.1";function K6(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var W6=()=>{let e=K6();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Fo,"X-Stainless-OS":yO(Deno.build.os),"X-Stainless-Arch":_O(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Fo,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(e==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Fo,"X-Stainless-OS":yO(globalThis.process.platform??"unknown"),"X-Stainless-Arch":_O(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=q6();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Fo,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Fo,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function q6(){if(typeof navigator>"u"||!navigator)return null;let e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:t,pattern:r}of e){let i=r.exec(navigator.userAgent);if(i){let n=i[1]||0,o=i[2]||0,a=i[3]||0;return{browser:t,version:`${n}.${o}.${a}`}}}return null}var _O=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",yO=e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Android":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Other:${e}`:"Unknown"),J6,vO=()=>J6??=W6();function bO(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Langsmith({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function X6(...e){let t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Jv(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return X6({start(){},async pull(r){let{done:i,value:n}=await t.next();i?r.close():r.enqueue(n)},async cancel(){await t.return?.()}})}async function wO(e){if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),r=t.cancel();t.releaseLock(),await r}var xO=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});var Xv="RFC3986",Yv=e=>String(e),Qv={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:Yv},SO="RFC1738";var om=(e,t)=>(om=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),om(e,t)),mi=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();var eb=1024,kO=(e,t,r,i,n)=>{if(e.length===0)return e;let o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),r==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(s){return"%26%23"+parseInt(s.slice(2),16)+"%3B"});let a="";for(let s=0;s<o.length;s+=eb){let c=o.length>=eb?o.slice(s,s+eb):o,u=[];for(let l=0;l<c.length;++l){let d=c.charCodeAt(l);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||n===SO&&(d===40||d===41)){u[u.length]=c.charAt(l);continue}if(d<128){u[u.length]=mi[d];continue}if(d<2048){u[u.length]=mi[192|d>>6]+mi[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=mi[224|d>>12]+mi[128|d>>6&63]+mi[128|d&63];continue}l+=1,d=65536+((d&1023)<<10|c.charCodeAt(l)&1023),u[u.length]=mi[240|d>>18]+mi[128|d>>12&63]+mi[128|d>>6&63]+mi[128|d&63]}a+=u.join("")}return a};function $O(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function tb(e,t){if(sr(e)){let r=[];for(let i=0;i<e.length;i+=1)r.push(t(e[i]));return r}return t(e)}var IO={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},EO=function(e,t){Array.prototype.push.apply(e,sr(t)?t:[t])},eF,Rt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:kO,encodeValuesOnly:!1,format:Xv,formatter:Yv,indices:!1,serializeDate(e){return(eF??=Function.prototype.call.bind(Date.prototype.toISOString))(e)},skipNulls:!1,strictNullHandling:!1};function tF(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}var rb={};function TO(e,t,r,i,n,o,a,s,c,u,l,d,f,p,m,h,g,_){let v=e,x=_,S=0,k=!1;for(;(x=x.get(rb))!==void 0&&!k;){let j=x.get(e);if(S+=1,typeof j<"u"){if(j===S)throw new RangeError("Cyclic object value");k=!0}typeof x.get(rb)>"u"&&(S=0)}if(typeof u=="function"?v=u(t,v):v instanceof Date?v=f?.(v):r==="comma"&&sr(v)&&(v=tb(v,function(j){return j instanceof Date?f?.(j):j})),v===null){if(o)return c&&!h?c(t,Rt.encoder,g,"key",p):t;v=""}if(tF(v)||$O(v)){if(c){let j=h?t:c(t,Rt.encoder,g,"key",p);return[m?.(j)+"="+m?.(c(v,Rt.encoder,g,"value",p))]}return[m?.(t)+"="+m?.(String(v))]}let T=[];if(typeof v>"u")return T;let A;if(r==="comma"&&sr(v))h&&c&&(v=tb(v,c)),A=[{value:v.length>0?v.join(",")||null:void 0}];else if(sr(u))A=u;else{let j=Object.keys(v);A=l?j.sort(l):j}let b=s?String(t).replace(/\./g,"%2E"):String(t),z=i&&sr(v)&&v.length===1?b+"[]":b;if(n&&sr(v)&&v.length===0)return z+"[]";for(let j=0;j<A.length;++j){let H=A[j],ne=typeof H=="object"&&typeof H.value<"u"?H.value:v[H];if(a&&ne===null)continue;let ye=d&&s?H.replace(/\./g,"%2E"):H,Ce=sr(v)?typeof r=="function"?r(z,ye):z:z+(d?"."+ye:"["+ye+"]");_.set(e,S);let pt=new WeakMap;pt.set(rb,_),EO(T,TO(ne,Ce,r,i,n,o,a,s,r==="comma"&&h&&sr(v)?null:c,u,l,d,f,p,m,h,g,pt))}return T}function rF(e=Rt){if(typeof e.allowEmptyArrays<"u"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys<"u"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");let t=e.charset||Rt.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let r=Xv;if(typeof e.format<"u"){if(!om(Qv,e.format))throw new TypeError("Unknown format option provided.");r=e.format}let i=Qv[r],n=Rt.filter;(typeof e.filter=="function"||sr(e.filter))&&(n=e.filter);let o;if(e.arrayFormat&&e.arrayFormat in IO?o=e.arrayFormat:"indices"in e?o=e.indices?"indices":"repeat":o=Rt.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof e.allowDots>"u"?e.encodeDotInKeys?!0:Rt.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:Rt.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:Rt.allowEmptyArrays,arrayFormat:o,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:Rt.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?Rt.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:Rt.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:Rt.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:Rt.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:Rt.encodeValuesOnly,filter:n,format:r,formatter:i,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:Rt.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:Rt.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:Rt.strictNullHandling}}function AO(e,t={}){let r=e,i=rF(t),n,o;typeof i.filter=="function"?(o=i.filter,r=o("",r)):sr(i.filter)&&(o=i.filter,n=o);let a=[];if(typeof r!="object"||r===null)return"";let s=IO[i.arrayFormat],c=s==="comma"&&i.commaRoundTrip;n||(n=Object.keys(r)),i.sort&&n.sort(i.sort);let u=new WeakMap;for(let f=0;f<n.length;++f){let p=n[f];i.skipNulls&&r[p]===null||EO(a,TO(r[p],p,s,c,i.allowEmptyArrays,i.strictNullHandling,i.skipNulls,i.encodeDotInKeys,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,u))}let l=a.join(i.delimiter),d=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),l.length>0?d+l:""}function CO(e){return AO(e,{arrayFormat:"repeat"})}var sm={off:0,error:200,warn:300,info:400,debug:500},nb=(e,t,r)=>{if(e){if(pO(sm,e))return e;$r(r).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(sm))}`)}};function Fl(){}function am(e,t,r){return!t||sm[e]>sm[r]?Fl:t[e].bind(t)}var iF={error:Fl,warn:Fl,info:Fl,debug:Fl},OO=new WeakMap;function $r(e){let t=e.logger,r=e.logLevel??"off";if(!t)return iF;let i=OO.get(t);if(i&&i[0]===r)return i[1];let n={error:am("error",t,r),warn:am("warn",t,r),info:am("info",t,r),debug:am("debug",t,r)};return OO.set(t,[r,n]),n}var Wi=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,r])=>[t,t.toLowerCase()==="authorization"||t.toLowerCase()==="api-key"||t.toLowerCase()==="x-api-key"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"||t.toLowerCase()==="x-tenant-id"?"***":r]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);async function cm(e,t){let{response:r,requestLogID:i,retryOfRequestLogID:n,startTime:o}=t,a=await(async()=>{if(r.status===204)return null;if(t.options.__binaryResponse)return r;let c=r.headers.get("content-type")?.split(";")[0]?.trim();return c?.includes("application/json")||c?.endsWith("+json")?r.headers.get("content-length")==="0"?void 0:await r.json():await r.text()})();return $r(e).debug(`[${i}] response parsed`,Wi({retryOfRequestLogID:n,url:r.url,status:r.status,body:a,durationMs:Date.now()-o})),a}var oF=function(e,t,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r},PO=function(e,t,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(e):i?i.value:t.get(e)},Bl,os=class e extends Promise{constructor(t,r,i=cm){super(n=>{n(null)}),Object.defineProperty(this,"responsePromise",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"parseResponse",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"parsedPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Bl.set(this,void 0),oF(this,Bl,t,"f")}_thenUnwrap(t){return new e(PO(this,Bl,"f"),this.responsePromise,async(r,i)=>t(await this.parseResponse(r,i),i))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){let[t,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:r}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(PO(this,Bl,"f"),t))),this.parsedPromise}then(t,r){return this.parse().then(t,r)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};Bl=new WeakMap;var aF=function(e,t,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r},sF=function(e,t,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(e):i?i.value:t.get(e)},um,as=class{constructor(t,r,i,n){um.set(this,void 0),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),aF(this,um,t,"f"),this.options=n,this.response=r,this.body=i}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let t=this.nextPageRequestOptions();if(!t)throw new Mr("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await sF(this,um,"f").requestAPIList(this.constructor,t)}async*iterPages(){let t=this;for(yield t;t.hasNextPage();)t=await t.getNextPage(),yield t}async*[(um=new WeakMap,Symbol.asyncIterator)](){for await(let t of this.iterPages())for(let r of t.getPaginatedItems())yield r}},Vl=class extends os{constructor(t,r,i){super(t,r,async(n,o)=>new i(n,o.response,await cm(n,o),o.options))}async*[Symbol.asyncIterator](){let t=await this;for await(let r of t)yield r}},lm=class extends as{constructor(t,r,i,n){super(t,r,i,n),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.items=i||[]}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){let t=this.options.query.offset??0,r=this.getPaginatedItems().length,i=t+r;return{...this.options,query:{...Dc(this.options.query),offset:i}}}},dm=class extends as{constructor(t,r,i,n){super(t,r,i,n),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.items=i||[]}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){let t=this.options.query.offset??0,r=this.getPaginatedItems().length,i=t+r;return{...this.options,query:{...Dc(this.options.query),offset:i}}}};var fm=class extends as{constructor(t,r,i,n){super(t,r,i,n),Object.defineProperty(this,"evaluators",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"total",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.evaluators=i.evaluators||[],this.total=i.total||0}getPaginatedItems(){return this.evaluators??[]}nextPageRequestOptions(){let t=this.options.query.offset??0,r=this.getPaginatedItems().length,i=t+r;return{...this.options,query:{...Dc(this.options.query),offset:i}}}};var hi=class extends as{constructor(t,r,i,n){super(t,r,i,n),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"next_cursor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.items=i.items||[],this.next_cursor=i.next_cursor||""}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){let t=this.next_cursor;return t?{...this.options,body:{...Dc(this.options.body),cursor:t}}:null}},gi=class extends as{constructor(t,r,i,n){super(t,r,i,n),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"next_cursor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.items=i.items||[],this.next_cursor=i.next_cursor||""}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){let t=this.next_cursor;return t?{...this.options,query:{...Dc(this.options.query),cursor:t}}:null}};var ib=()=>{if(typeof File>"u"){let{process:e}=globalThis,t=typeof e?.versions?.node=="string"&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function pm(e,t,r){return ib(),new File(e,t??"unknown_file",r)}function NO(e){return(typeof e=="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}var RO=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function";var jO=e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function",uF=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&jO(e),lF=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function mm(e,t,r){if(ib(),e=await e,uF(e))return e instanceof File?e:pm([await e.arrayBuffer()],e.name);if(lF(e)){let n=await e.blob();return t||=new URL(e.url).pathname.split(/[\\/]/).pop(),pm(await ob(n),t,r)}let i=await ob(e);if(t||=NO(e),!r?.type){let n=i.find(o=>typeof o=="object"&&"type"in o&&o.type);typeof n=="string"&&(r={...r,type:n})}return pm(i,t,r)}async function ob(e){let t=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(jO(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(RO(e))for await(let r of e)t.push(...await ob(r));else{let r=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${r?`; constructor: ${r}`:""}${dF(e)}`)}return t}function dF(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(r=>`"${r}"`).join(", ")}]`}var Oe=class{constructor(t){Object.defineProperty(this,"_client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._client=t}};function MO(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var DO=Object.freeze(Object.create(null)),pF=(e=MO)=>function(r,...i){if(r.length===1)return r[0];let n=!1,o=[],a=r.reduce((l,d,f)=>{/[?#]/.test(d)&&(n=!0);let p=i[f],m=(n?encodeURIComponent:e)(""+p);return f!==i.length&&(p==null||typeof p=="object"&&p.toString===Object.getPrototypeOf(Object.getPrototypeOf(p.hasOwnProperty??DO)??DO)?.toString)&&(m=p+"",o.push({start:l.length+d.length,length:m.length,error:`Value of type ${Object.prototype.toString.call(p).slice(8,-1)} is not a valid path parameter`})),l+d+(f===i.length?"":m)},""),s=a.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,u;for(;(u=c.exec(s))!==null;)o.push({start:u.index,length:u[0].length,error:`Value "${u[0]}" can't be safely passed as a path parameter`});if(o.sort((l,d)=>l.start-d.start),o.length>0){let l=0,d=o.reduce((f,p)=>{let m=" ".repeat(p.start-l),h="^".repeat(p.length);return l=p.start+p.length,f+m+h},"");throw new Mr(`Path parameters result in path with invalid segments:
24
+ ${o.map(f=>f.error).join(`
25
+ `)}
26
+ ${a}
27
+ ${d}`)}return a},Y=pF(MO);var Mc=class extends Oe{create(t,r,i){let{extend_trace_retention:n,...o}=r;return this._client.post(Y`/api/v1/platform/annotation-queues/${t}/items`,{query:{extend_trace_retention:n},body:o,...i})}update(t,r,i){let{queue_id:n,...o}=r;return this._client.patch(Y`/api/v1/platform/annotation-queues/${n}/items/${t}`,{body:o,...i})}list(t,r,i){return this._client.getAPIList(Y`/api/v1/platform/annotation-queues/${t}/items`,gi,{query:r,...i})}createStatus(t,r,i){return this._client.post(Y`/api/v1/platform/annotation-queues/items/${t}/status`,{body:r,...i})}deleteAll(t,r,i){return this._client.post(Y`/api/v1/platform/annotation-queues/${t}/items/delete`,{body:r,...i})}retrieveCount(t,r,i){return this._client.get(Y`/api/v1/platform/annotation-queues/${t}/items/count`,{query:r,...i})}retrievePlacement(t,r,i){let{queue_id:n}=r;return this._client.get(Y`/api/v1/platform/annotation-queues/${n}/items/${t}/placement`,i)}};var zc=class extends Oe{create(t,r,i){let{body:n,extend_trace_retention:o}=r;return this._client.post(Y`/api/v1/annotation-queues/${t}/runs`,{query:{extend_trace_retention:o},body:n,...i})}update(t,r,i){let{queue_id:n,...o}=r;return this._client.patch(Y`/api/v1/annotation-queues/${n}/runs/${t}`,{body:o,...i})}list(t,r={},i){return this._client.get(Y`/api/v1/annotation-queues/${t}/runs`,{query:r,...i})}createByKey(t,r,i){let{body:n,extend_trace_retention:o}=r;return this._client.post(Y`/api/v1/annotation-queues/${t}/runs/by-key`,{query:{extend_trace_retention:o},body:n,...i})}deleteAll(t,r,i){return this._client.post(Y`/api/v1/annotation-queues/${t}/runs/delete`,{body:r,...i})}deleteQueue(t,r,i){let{queue_id:n}=r;return this._client.delete(Y`/api/v1/annotation-queues/${n}/runs/${t}`,i)}};var qi=class extends Oe{constructor(){super(...arguments),Object.defineProperty(this,"runs",{enumerable:!0,configurable:!0,writable:!0,value:new zc(this._client)}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:new Mc(this._client)})}retrieve(t,r){return this._client.get(Y`/api/v1/annotation-queues/${t}`,r)}update(t,r,i){return this._client.patch(Y`/api/v1/annotation-queues/${t}`,{body:r,...i})}delete(t,r){return this._client.delete(Y`/api/v1/annotation-queues/${t}`,r)}annotationQueues(t,r){return this._client.post("/api/v1/annotation-queues",{body:t,...r})}createRunStatus(t,r,i){return this._client.post(Y`/api/v1/annotation-queues/status/${t}`,{body:r,...i})}export(t,r,i){return this._client.post(Y`/api/v1/annotation-queues/${t}/export`,{body:r,...i})}populate(t,r){return this._client.post("/api/v1/annotation-queues/populate",{body:t,...r})}retrieveAnnotationQueues(t={},r){return this._client.getAPIList("/api/v1/annotation-queues",lm,{query:t,...r})}retrieveQueues(t,r){return this._client.get(Y`/api/v1/annotation-queues/${t}/queues`,r)}retrieveRun(t,r,i){let{queue_id:n,...o}=r;return this._client.get(Y`/api/v1/annotation-queues/${n}/run/${t}`,{query:o,...i})}retrieveSize(t,r={},i){return this._client.get(Y`/api/v1/annotation-queues/${t}/size`,{query:r,...i})}retrieveTotalArchived(t,r={},i){return this._client.get(Y`/api/v1/annotation-queues/${t}/total_archived`,{query:r,...i})}retrieveTotalSize(t,r){return this._client.get(Y`/api/v1/annotation-queues/${t}/total_size`,r)}};qi.Runs=zc;qi.Items=Mc;var Lc=class extends Oe{query(t,r,i){return this._client.getAPIList(Y`/api/v2/datasets/${t}/experiment-runs`,hi,{body:r,method:"post",...i})}};var Bo=class extends Oe{constructor(){super(...arguments),Object.defineProperty(this,"experimentRuns",{enumerable:!0,configurable:!0,writable:!0,value:new Lc(this._client)})}};Bo.ExperimentRuns=Lc;var ss=class extends Oe{list(t){return this._client.get("/api/v1/info",t)}};var cs=class extends Oe{retrieve(t,r){return this._client.get(Y`/api/v1/platform/issues/${t}`,r)}list(t={},r){return this._client.getAPIList("/api/v1/platform/issues",dm,{query:t,...r})}};var zO=Symbol("brand.privateNullableHeaders");function*_F(e){if(!e)return;if(zO in e){let{values:i,nulls:n}=e;yield*i.entries();for(let o of n)yield[o,null];return}let t=!1,r;e instanceof Headers?r=e.entries():Wv(e)?r=e:(t=!0,r=Object.entries(e??{}));for(let i of r){let n=i[0];if(typeof n!="string")throw new TypeError("expected header name to be a string");let o=Wv(i[1])?i[1]:[i[1]],a=!1;for(let s of o)s!==void 0&&(t&&!a&&(a=!0,yield[n,null]),yield[n,s])}}var ot=e=>{let t=new Headers,r=new Set;for(let i of e){let n=new Set;for(let[o,a]of _F(i)){let s=o.toLowerCase();n.has(s)||(t.delete(o),n.add(s)),a===null?(t.delete(o),r.add(s)):(t.append(o,a),r.delete(s))}}return{[zO]:!0,values:t,nulls:r}};var us=class extends Oe{create(t,r){return this._client.post("/api/v1/platform/evaluators",{body:t,...r})}retrieve(t,r){return this._client.get(Y`/api/v1/platform/evaluators/${t}`,r)}update(t,r,i){return this._client.patch(Y`/api/v1/platform/evaluators/${t}`,{body:r,...i})}list(t={},r){return this._client.getAPIList("/api/v1/platform/evaluators",fm,{query:t,...r})}delete(t,r={},i){let{delete_run_rules:n}=r??{};return this._client.delete(Y`/api/v1/platform/evaluators/${t}`,{query:{delete_run_rules:n},...i,headers:ot([{Accept:"*/*"},i?.headers])})}bulkDelete(t,r){let{evaluator_ids:i,delete_run_rules:n}=t;return this._client.delete("/api/v1/platform/evaluators",{query:{evaluator_ids:i,delete_run_rules:n},...r})}spend(t,r){return this._client.get("/api/v1/platform/evaluators/spend",{query:t,...r})}};var Uc=class extends Oe{retrieve(t,r,i){let{share_token:n,Accept:o,...a}=r;return this._client.get(Y`/api/v2/public/${n}/run/${t}`,{query:a,...i,headers:ot([{...o!=null?{Accept:o}:void 0},i?.headers])})}query(t,r,i){let{Accept:n,...o}=r;return this._client.post(Y`/api/v2/public/${t}/runs/query`,{body:o,...i,headers:ot([{...n!=null?{Accept:n}:void 0},i?.headers])})}};var Vo=class extends Oe{constructor(){super(...arguments),Object.defineProperty(this,"runs",{enumerable:!0,configurable:!0,writable:!0,value:new Uc(this._client)})}};Vo.Runs=Uc;var Fc=class extends Oe{create(t,r,i){return this._client.post(Y`/api/v2/runs/${t}/share`,{body:r,...i})}delete(t,r,i){return this._client.delete(Y`/api/v2/runs/${t}/share`,{body:r,...i,headers:ot([{Accept:"*/*"},i?.headers])})}};var Ho=class extends Oe{constructor(){super(...arguments),Object.defineProperty(this,"share",{enumerable:!0,configurable:!0,writable:!0,value:new Fc(this._client)}),Object.defineProperty(this,"retrieve",{enumerable:!0,configurable:!0,writable:!0,value:this.retrieveV2}),Object.defineProperty(this,"query",{enumerable:!0,configurable:!0,writable:!0,value:this.queryV2})}getURL(t,r,i){return this._client.get(Y`/api/v2/runs/${t}/url`,{query:r,...i})}queryV2(t,r){let{Accept:i,...n}=t;return this._client.getAPIList("/api/v2/runs/query",hi,{body:n,method:"post",...r,headers:ot([{...i!=null?{Accept:i}:void 0},r?.headers])})}retrieveV2(t,r,i){let{Accept:n,...o}=r;return this._client.get(Y`/api/v2/runs/${t}`,{query:o,...i,headers:ot([{...n!=null?{Accept:n}:void 0},i?.headers])})}};Ho.Share=Fc;var Bc=class extends Oe{create(t,r){return this._client.post("/api/v2/sandboxes/boxes",{body:t,...r})}retrieve(t,r){return this._client.get(Y`/api/v2/sandboxes/boxes/${t}`,r)}update(t,r,i){return this._client.patch(Y`/api/v2/sandboxes/boxes/${t}`,{body:r,...i})}list(t={},r){return this._client.getAPIList("/api/v2/sandboxes/boxes",gi,{query:t,...r})}delete(t,r){return this._client.delete(Y`/api/v2/sandboxes/boxes/${t}`,{...r,headers:ot([{Accept:"*/*"},r?.headers])})}createSnapshot(t,r,i){return this._client.post(Y`/api/v2/sandboxes/boxes/${t}/snapshot`,{body:r,...i})}generateDownloadURL(t,r,i){return this._client.post(Y`/api/v2/sandboxes/boxes/${t}/download-url`,{body:r,...i})}generateServiceURL(t,r,i){return this._client.post(Y`/api/v2/sandboxes/boxes/${t}/service-url`,{body:r,...i})}getStatus(t,r){return this._client.get(Y`/api/v2/sandboxes/boxes/${t}/status`,r)}start(t,r){return this._client.post(Y`/api/v2/sandboxes/boxes/${t}/start`,r)}stop(t,r){return this._client.post(Y`/api/v2/sandboxes/boxes/${t}/stop`,{...r,headers:ot([{Accept:"*/*"},r?.headers])})}};var Vc=class extends Oe{create(t,r){return this._client.post("/api/v2/sandboxes/registries",{body:t,...r})}retrieve(t,r){return this._client.get(Y`/api/v2/sandboxes/registries/${t}`,r)}update(t,r,i){return this._client.patch(Y`/api/v2/sandboxes/registries/${t}`,{body:r,...i})}list(t={},r){return this._client.get("/api/v2/sandboxes/registries",{query:t,...r})}delete(t,r){return this._client.delete(Y`/api/v2/sandboxes/registries/${t}`,{...r,headers:ot([{Accept:"*/*"},r?.headers])})}};var Hc=class extends Oe{create(t,r){return this._client.post("/api/v2/sandboxes/snapshots",{body:t,...r})}retrieve(t,r){return this._client.get(Y`/api/v2/sandboxes/snapshots/${t}`,r)}list(t={},r){return this._client.getAPIList("/api/v2/sandboxes/snapshots",gi,{query:t,...r})}delete(t,r){return this._client.delete(Y`/api/v2/sandboxes/snapshots/${t}`,{...r,headers:ot([{Accept:"*/*"},r?.headers])})}retrieveByName(t,r){return this._client.get(Y`/api/v2/sandboxes/snapshots-by-name/${t}`,r)}};var _i=class extends Oe{constructor(){super(...arguments),Object.defineProperty(this,"boxes",{enumerable:!0,configurable:!0,writable:!0,value:new Bc(this._client)}),Object.defineProperty(this,"registries",{enumerable:!0,configurable:!0,writable:!0,value:new Vc(this._client)}),Object.defineProperty(this,"snapshots",{enumerable:!0,configurable:!0,writable:!0,value:new Hc(this._client)})}};_i.Boxes=Bc;_i.Registries=Vc;_i.Snapshots=Hc;var ls=class extends Oe{listTraces(t,r,i){return this._client.getAPIList(Y`/api/v2/threads/${t}/traces`,gi,{query:r,...i})}query(t,r){return this._client.getAPIList("/api/v2/threads/query",hi,{body:t,method:"post",...r})}stats(t,r,i){return this._client.get(Y`/api/v2/threads/${t}/stats`,{query:r,...i})}};var ds=class extends Oe{listRuns(t,r,i){let{Accept:n,...o}=r;return this._client.get(Y`/api/v2/traces/${t}/runs`,{query:o,...i,headers:ot([{...n!=null?{Accept:n}:void 0},i?.headers])})}query(t,r){return this._client.getAPIList("/api/v2/traces/query",hi,{body:t,method:"post",...r})}};var Zc=e=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[e]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(e)?.trim()||void 0};var kF=function(e,t,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r},LO=function(e,t,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(e):i?i.value:t.get(e)},ab,sb,hm,UO,Be=class{constructor({baseURL:t=Zc("LANGCHAIN_BASE_URL"),apiKey:r=Zc("LANGSMITH_API_KEY")??null,tenantID:i=Zc("LANGSMITH_TENANT_ID")??null,...n}={}){ab.add(this),Object.defineProperty(this,"apiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tenantID",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"baseURL",{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,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"logLevel",{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,"fetch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),hm.set(this,void 0),Object.defineProperty(this,"idempotencyHeader",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"datasets",{enumerable:!0,configurable:!0,writable:!0,value:new Bo(this)}),Object.defineProperty(this,"runs",{enumerable:!0,configurable:!0,writable:!0,value:new Ho(this)}),Object.defineProperty(this,"threads",{enumerable:!0,configurable:!0,writable:!0,value:new ls(this)}),Object.defineProperty(this,"traces",{enumerable:!0,configurable:!0,writable:!0,value:new ds(this)}),Object.defineProperty(this,"onlineEvaluators",{enumerable:!0,configurable:!0,writable:!0,value:new us(this)}),Object.defineProperty(this,"public",{enumerable:!0,configurable:!0,writable:!0,value:new Vo(this)}),Object.defineProperty(this,"annotationQueues",{enumerable:!0,configurable:!0,writable:!0,value:new qi(this)}),Object.defineProperty(this,"info",{enumerable:!0,configurable:!0,writable:!0,value:new ss(this)}),Object.defineProperty(this,"issues",{enumerable:!0,configurable:!0,writable:!0,value:new cs(this)}),Object.defineProperty(this,"sandboxes",{enumerable:!0,configurable:!0,writable:!0,value:new _i(this)});let o={apiKey:r,tenantID:i,...n,baseURL:t||"https://api.smith.langchain.com/"};this.baseURL=o.baseURL,this.timeout=o.timeout??sb.DEFAULT_TIMEOUT,this.logger=o.logger??console;let a="warn";this.logLevel=a,this.logLevel=nb(o.logLevel,"ClientOptions.logLevel",this)??nb(Zc("LANGCHAIN_LOG"),"process.env['LANGCHAIN_LOG']",this)??a,this.fetchOptions=o.fetchOptions,this.maxRetries=o.maxRetries??2,this.fetch=o.fetch??bO(),kF(this,hm,xO,"f");let s=Zc("LANGCHAIN_CUSTOM_HEADERS");if(s){let c={};for(let u of s.split(`
28
+ `)){let l=u.indexOf(":");l>=0&&(c[u.substring(0,l).trim()]=u.substring(l+1).trim())}o.defaultHeaders={...c,...o.defaultHeaders}}this._options=o,this.apiKey=r,this.tenantID=i}withOptions(t){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,tenantID:this.tenantID,...t})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:r}){if(!(this.apiKey&&t.get("x-api-key"))&&!r.has("x-api-key")&&!(this.tenantID&&t.get("x-tenant-id"))&&!r.has("x-tenant-id"))throw new Error('Could not resolve authentication method. Expected either apiKey or tenantID to be set. Or for one of the "X-API-Key" or "X-Tenant-Id" headers to be explicitly omitted')}async authHeaders(t){return ot([await this.apiKeyAuth(t),await this.tenantIDAuth(t)])}async apiKeyAuth(t){if(this.apiKey!=null)return ot([{"X-API-Key":this.apiKey}])}async tenantIDAuth(t){if(this.tenantID!=null)return ot([{"X-Tenant-Id":this.tenantID}])}stringifyQuery(t){return CO(t)}getUserAgent(){return`${this.constructor.name}/JS ${Fo}`}defaultIdempotencyKey(){return`stainless-node-retry-${Kv()}`}makeStatusError(t,r,i,n){return Xt.generate(t,r,i,n)}buildURL(t,r,i){let n=!LO(this,ab,"m",UO).call(this)&&i||this.baseURL,o=fO(t)?new URL(t):new URL(n+(n.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),a=this.defaultQuery(),s=Object.fromEntries(o.searchParams);return(!qv(a)||!qv(s))&&(r={...s,...a,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(t){}async prepareRequest(t,{url:r,options:i}){}get(t,r){return this.methodRequest("get",t,r)}post(t,r){return this.methodRequest("post",t,r)}patch(t,r){return this.methodRequest("patch",t,r)}put(t,r){return this.methodRequest("put",t,r)}delete(t,r){return this.methodRequest("delete",t,r)}methodRequest(t,r,i){return this.request(Promise.resolve(i).then(n=>({method:t,path:r,...n})))}request(t,r=null){return new os(this,this.makeRequest(t,r,void 0))}async makeRequest(t,r,i){let n=await t,o=n.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(n);let{req:a,url:s,timeout:c}=await this.buildRequest(n,{retryCount:o-r});await this.prepareRequest(a,{url:s,options:n});let u="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),l=i===void 0?"":`, retryOf: ${i}`,d=Date.now();if($r(this).debug(`[${u}] sending request`,Wi({retryOfRequestLogID:i,method:n.method,url:s,options:n,headers:a.headers})),n.signal?.aborted)throw new Uo;let f=new AbortController,p=await this.fetchWithTimeout(s,a,c,f).catch(Dl),m=Date.now();if(p instanceof globalThis.Error){let g=`retrying, ${r} attempts remaining`;if(n.signal?.aborted)throw new Uo;let _=KC(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return $r(this).info(`[${u}] connection ${_?"timed out":"failed"} - ${g}`),$r(this).debug(`[${u}] connection ${_?"timed out":"failed"} (${g})`,Wi({retryOfRequestLogID:i,url:s,durationMs:m-d,message:p.message})),this.retryRequest(n,r,i??u);throw $r(this).info(`[${u}] connection ${_?"timed out":"failed"} - error; no more retries left`),$r(this).debug(`[${u}] connection ${_?"timed out":"failed"} (error; no more retries left)`,Wi({retryOfRequestLogID:i,url:s,durationMs:m-d,message:p.message})),_?new Ja:new Ki({cause:p})}let h=`[${u}${l}] ${a.method} ${s} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${m-d}ms`;if(!p.ok){let g=await this.shouldRetry(p);if(r&&g){let T=`retrying, ${r} attempts remaining`;return await wO(p.body),$r(this).info(`${h} - ${T}`),$r(this).debug(`[${u}] response error (${T})`,Wi({retryOfRequestLogID:i,url:p.url,status:p.status,headers:p.headers,durationMs:m-d})),this.retryRequest(n,r,i??u,p.headers)}let _=g?"error; no more retries left":"error; not retryable";$r(this).info(`${h} - ${_}`);let v=await p.text().catch(T=>Dl(T).message),x=hO(v),S=x?void 0:v;throw $r(this).debug(`[${u}] response error (${_})`,Wi({retryOfRequestLogID:i,url:p.url,status:p.status,headers:p.headers,message:S,durationMs:Date.now()-d})),this.makeStatusError(p.status,x,S,p.headers)}return $r(this).info(h),$r(this).debug(`[${u}] response start`,Wi({retryOfRequestLogID:i,url:p.url,status:p.status,headers:p.headers,durationMs:m-d})),{response:p,options:n,controller:f,requestLogID:u,retryOfRequestLogID:i,startTime:d}}getAPIList(t,r,i){return this.requestAPIList(r,i&&"then"in i?i.then(n=>({method:"get",path:t,...n})):{method:"get",path:t,...i})}requestAPIList(t,r){let i=this.makeRequest(r,null,void 0);return new Vl(this,i,t)}async fetchWithTimeout(t,r,i,n){let{signal:o,method:a,...s}=r||{},c=this._makeAbort(n);o&&o.addEventListener("abort",c,{once:!0});let u=setTimeout(c,i),l=globalThis.ReadableStream&&s.body instanceof globalThis.ReadableStream||typeof s.body=="object"&&s.body!==null&&Symbol.asyncIterator in s.body,d={signal:n.signal,...l?{duplex:"half"}:{},method:"GET",...s};a&&(d.method=a.toUpperCase());try{return await this.fetch.call(void 0,t,d)}finally{clearTimeout(u)}}async shouldRetry(t){let r=t.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,r,i,n){let o,a=n?.get("retry-after-ms");if(a){let c=parseFloat(a);Number.isNaN(c)||(o=c)}let s=n?.get("retry-after");if(s&&!o){let c=parseFloat(s);Number.isNaN(c)?o=Date.parse(s)-Date.now():o=c*1e3}if(o===void 0){let c=t.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await gO(o),this.makeRequest(t,r-1,i)}calculateDefaultRetryTimeoutMillis(t,r){let o=r-t,a=Math.min(.5*Math.pow(2,o),16),s=1-Math.random()*.25;return a*s*1e3}async buildRequest(t,{retryCount:r=0}={}){let i={...t},{method:n,path:o,query:a,defaultBaseURL:s}=i,c=this.buildURL(o,a,s);"timeout"in i&&mO("timeout",i.timeout),i.timeout=i.timeout??this.timeout;let{bodyHeaders:u,body:l}=this.buildBody({options:i}),d=await this.buildHeaders({options:t,method:n,bodyHeaders:u,retryCount:r});return{req:{method:n,headers:d,...i.signal&&{signal:i.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:"half"},...l&&{body:l},...this.fetchOptions??{},...i.fetchOptions??{}},url:c,timeout:i.timeout}}async buildHeaders({options:t,method:r,bodyHeaders:i,retryCount:n}){let o={};this.idempotencyHeader&&r!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=t.idempotencyKey);let a=ot([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(n),...t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{},...vO()},await this.authHeaders(t),this._options.defaultHeaders,i,t.headers]);return this.validateHeaders(a),a.values}_makeAbort(t){return()=>t.abort()}buildBody({options:{body:t,headers:r}}){if(!t)return{bodyHeaders:void 0,body:void 0};let i=ot([r]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&i.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:Jv(t)}:typeof t=="object"&&i.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(t)}:LO(this,hm,"f").call(this,{body:t,headers:i})}};sb=Be,hm=new WeakMap,ab=new WeakSet,UO=function(){return this.baseURL!=="https://api.smith.langchain.com/"};Object.defineProperty(Be,"Langsmith",{enumerable:!0,configurable:!0,writable:!0,value:sb});Object.defineProperty(Be,"DEFAULT_TIMEOUT",{enumerable:!0,configurable:!0,writable:!0,value:9e4});Object.defineProperty(Be,"LangsmithError",{enumerable:!0,configurable:!0,writable:!0,value:Mr});Object.defineProperty(Be,"APIError",{enumerable:!0,configurable:!0,writable:!0,value:Xt});Object.defineProperty(Be,"APIConnectionError",{enumerable:!0,configurable:!0,writable:!0,value:Ki});Object.defineProperty(Be,"APIConnectionTimeoutError",{enumerable:!0,configurable:!0,writable:!0,value:Ja});Object.defineProperty(Be,"APIUserAbortError",{enumerable:!0,configurable:!0,writable:!0,value:Uo});Object.defineProperty(Be,"NotFoundError",{enumerable:!0,configurable:!0,writable:!0,value:es});Object.defineProperty(Be,"ConflictError",{enumerable:!0,configurable:!0,writable:!0,value:ts});Object.defineProperty(Be,"RateLimitError",{enumerable:!0,configurable:!0,writable:!0,value:ns});Object.defineProperty(Be,"BadRequestError",{enumerable:!0,configurable:!0,writable:!0,value:Xa});Object.defineProperty(Be,"AuthenticationError",{enumerable:!0,configurable:!0,writable:!0,value:Ya});Object.defineProperty(Be,"InternalServerError",{enumerable:!0,configurable:!0,writable:!0,value:is});Object.defineProperty(Be,"PermissionDeniedError",{enumerable:!0,configurable:!0,writable:!0,value:Qa});Object.defineProperty(Be,"UnprocessableEntityError",{enumerable:!0,configurable:!0,writable:!0,value:rs});Object.defineProperty(Be,"toFile",{enumerable:!0,configurable:!0,writable:!0,value:mm});Be.Datasets=Bo;Be.Runs=Ho;Be.Threads=ls;Be.Traces=ds;Be.OnlineEvaluators=us;Be.Public=Vo;Be.AnnotationQueues=qi;Be.Info=ss;Be.Issues=cs;Be.Sandboxes=_i;var FO=1000000n,$F=new TextEncoder,BO=(e,t)=>{if(t===void 0||t>=1)return!0;if(t<=0)return!1;if(e==null)return!0;let r=Fp($F.encode(e.toLowerCase()))%FO;return Number(r)/Number(FO)<t};var Hl={CLICKHOUSE_ONLY:"clickhouse_only",SMITHDB_ONLY:"smithdb_only",DUAL:"dual"};function VO(e){let t=e??{},r=!!(t.ch_query_enabled??!0),i=!!(t.sdb_query_enabled??!1);return!r&&i?Hl.SMITHDB_ONLY:r&&i?Hl.DUAL:Hl.CLICKHOUSE_ONLY}function _m(e){return`Invalid prompt identifier format: "${e}". Expected one of:
29
+ - "prompt-name" (for private prompts)
30
+ - "owner/prompt-name" (for prompts with explicit owner)
31
+ - "prompt-name:commit-hash" (with commit reference)
32
+ - "owner/prompt-name:commit-hash" (with owner and commit)`}var cb=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}},ub=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 ym(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithNotFoundError"}function HO(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithConflictError"}async function X(e,t,r){let i;if(e.ok){r&&(i=await e.text());return}if(e.status===403)try{(await e.json())?.error==="org_scoped_key_requires_workspace"&&(i="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(i===void 0)try{i=await e.text()}catch{i=""}let n=`Failed to ${t}. Received status [${e.status}]: ${e.statusText}. Message: ${i}`;if(e.status===404)throw new ub(n);if(e.status===409)throw new cb(n);let o=new Error(n);throw o.status=e.status,o}var ZO="ERR_CONFLICTING_ENDPOINTS",gm=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:ZO}),this.name="ConflictingEndpointsError"}};function GO(e){return typeof e=="object"&&e!==null&&e.code===ZO}function cr(e){if(!e||e.split("/").length>2||e.startsWith("/")||e.endsWith("/")||e.split(":").length>2)throw new Error(_m(e));let[t,r]=e.split(":"),i=r||"latest";if(t.includes("/")){let[n,o]=t.split("/",2);if(!n||!o)throw new Error(_m(e));return[n,o,i]}else{if(!t)throw new Error(_m(e));return["-",t,i]}}var IF=10,EF=1e4,KO="created_at";function TF(e){return new Promise(t=>setTimeout(t,e))}function AF(e){return typeof e=="object"&&e!==null&&e.code==="EEXIST"}function WO(e){try{return qa(Mn.join(e,KO)).split(`
33
+ `)}catch{return}}function CF(e){let t=WO(e);if(t&&t[0]&&t[0].trim()){let r=Date.parse(t[0].trim());if(!Number.isNaN(r))return r}return void 0}function OF(e){let t=WO(e);if(t&&t.length>=2&&t[1].trim())return t[1].trim()}async function PF(e){let t=CF(e);return t===void 0||Date.now()-t<=EF?!1:(await Zp(e),!0)}async function qO(e,t){let r=`${e}.oauth.lock.lock`,i=Mn.dirname(r);i&&await Hp(i);let n=globalThis.crypto.randomUUID();for(;;){try{await GC(r)}catch(o){if(!AF(o))throw o;if(!await PF(r)){if(Date.now()>=t)throw new Error("timed out acquiring OAuth refresh lock");await TF(Math.min(IF,Math.max(0,t-Date.now())))}continue}try{await Rc(Mn.join(r,KO),`${new Date().toISOString()}
34
+ ${n}
35
+ `)}catch(o){throw await Zp(r),o}break}return{async release(){OF(r)===n&&await Zp(r)}}}var vm="https://api.smith.langchain.com",NF="langsmith-cli",RF=6e4,jF=1e4,DF=5e3,JO="/.well-known/oauth-authorization-server";function MF(){let e=zl();return e==="browser"||e==="webworker"}function zF(){let e=Ht("LANGSMITH_CONFIG_FILE");if(e)return e;let t=Ht("HOME")??Ht("USERPROFILE");if(t)return Mn.join(t,".langsmith","config.json")}function LF(e){let t=Ht("LANGSMITH_PROFILE");if(t)return t;if(e.current_profile)return e.current_profile;if(e.profiles?.default)return"default"}function UF(){if(MF())return;let e=zF();if(!(!e||!jc(e)))try{let t=JSON.parse(qa(e)),r=LF(t),i=r?t.profiles?.[r]:void 0;return!r||!i?void 0:{configPath:e,config:t,profileName:r,profile:i}}catch{return}}function hn(e){return e!=null&&e.trim()!==""}function Zo(e){return e?.trim().replace(/^["']|["']$/g,"")}function XO(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()+RF}function QO(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 FF(e){let t=QO(e),r=t.endsWith("/api")?t.slice(0,-4):t,i=[];for(let n of[t,`${r}/api`,r])n&&n!=="/api"&&!i.includes(n)&&i.push(n);return i}function BF(e,t){let{issuer:r}=e;if(typeof r!="string"||r.replace(/\/+$/,"")!==t.replace(/\/+$/,""))return!1;let i;try{i=new URL(r)}catch{return!1}for(let n of[e.device_authorization_endpoint,e.token_endpoint]){if(typeof n!="string"||!n)return!1;try{let o=new URL(n);if(o.protocol!==i.protocol||o.host!==i.host)return!1}catch{return!1}}return!0}function VF(e){let t=`${e}${JO}`,r;try{let i=new URL(e);r=`${i.origin}${JO}${i.pathname==="/"?"":i.pathname}`}catch{return[t]}return r===t?[r]:[r,t]}async function HF(e,t,r){let i;try{i=await r(e,{method:"GET",headers:{Accept:"application/json"},signal:AbortSignal.timeout(DF)})}catch{return}if(!i.ok)return;let n;try{n=await i.json()}catch{return}if(!(!n||typeof n!="object"||!BF(n,t)))return n}async function ZF(e,t){for(let r of FF(e))for(let i of VF(r)){let n=await HF(i,r,t);if(n)return n.token_endpoint}return`${QO(e)}/oauth/token`}function GF(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 YO(e){return e.reason??new Error("The operation was aborted.")}async function KF(e,t){if(!t)return e;if(t.aborted)throw YO(t);let r,i=new Promise((n,o)=>{let a=()=>{o(YO(t))};t.addEventListener("abort",a,{once:!0}),r=()=>{t.removeEventListener("abort",a)}});try{return await Promise.race([e,i])}finally{r?.()}}function eP(){let e=UF(),t=e?.profile;if(!e||!t)return{};let r=Zo(t.api_key),i=Zo(t.oauth?.access_token),n=Zo(t.oauth?.refresh_token);return{apiUrl:t.api_url,apiKey:r,workspaceId:t.workspace_id,oauthAccessToken:i,oauthRefreshToken:n,profileAuth:r||i||n?new lb(e):void 0}}var lb=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=WF(this.state.profile);return this.rememberProfileAuthHeader(t),t}async getAuthHeader(t,r){XO(this.state.profile)&&(this.refreshPromise||(this.refreshPromise=this.refreshOAuthToken(t).finally(()=>{this.refreshPromise=void 0})),await KF(this.refreshPromise,r));let i=tP(this.state.profile);return this.rememberProfileAuthHeader(i),i}isProfileAuthorizationHeader(t){return t===this.managedAuthorizationValue}reloadProfile(){try{let t=JSON.parse(qa(this.state.configPath)),r=t.profiles?.[this.state.profileName];return r?(this.state.config=t,this.state.profile=r,r):void 0}catch{return}}async refreshOAuthToken(t){let r=this.state.profile.oauth?.refresh_token;if(!r)return;let i=Zo(this.state.profile.api_url)??vm,n=Date.now()+jF,o;try{if(o=await qO(this.state.configPath,n),this.reloadProfile()&&!XO(this.state.profile))return;let s=new URLSearchParams({grant_type:"refresh_token",client_id:NF,refresh_token:this.state.profile.oauth?.refresh_token??r}),c=await ZF(i,t),u=await t(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString(),signal:AbortSignal.timeout(Math.max(0,n-Date.now()))});if(!u.ok)return;let l=await u.json();if(!l.access_token)return;GF(this.state.profile,l),this.state.config.profiles??={},this.state.config.profiles[this.state.profileName]=this.state.profile,await Rc(this.state.configPath,`${JSON.stringify(this.state.config,null,2)}
36
+ `)}catch{return}finally{await o?.release()}}rememberProfileAuthHeader(t){this.managedAuthorizationValue=t?.name==="Authorization"?t.value:void 0}};function WF(e){let t=Zo(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};if(!Zo(e.oauth?.refresh_token))return tP(e)}function tP(e){let t=Zo(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};let r=Zo(e.api_key);if(r)return{name:"x-api-key",value:r}}var rP="[...]",qF={result:"[Circular]"},wm=[],Gc=[],JF=new TextEncoder;function XF(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function bm(e){return JF.encode(e)}function nP(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 YF(e){return function(t,r){if(e){let i=e.call(this,t,r);if(i!==void 0)return i}return nP(r)}}function iP(e){try{let n=function(l){let d=i(l);return d>r&&(r=d),d+2},o=function(l){return l===0?2:2+l*4},a=function(l){return l===void 0||typeof l=="function"||typeof l=="symbol"},s=function(l){return l===void 0||typeof l=="function"||typeof l=="symbol"?4:c(l)},c=function(l){if(l===null)return 4;if(l===void 0)return 0;let d=typeof l;if(d==="boolean")return 5;if(d==="number")return Number.isFinite(l)?l.toString().length:4;if(d==="bigint")return l.toString().length+2;if(d==="string")return n(l);if(d==="function"||d==="symbol")return 0;let f=l;if(f instanceof Date)return 26;if(f instanceof RegExp)return i(f.toString())+2;if(f instanceof Error){let m=f.name??"",h=f.message??"";return 22+i(m)+i(h)}if(typeof Buffer<"u"&&f instanceof Buffer)return 28+o(f.byteLength);if(ArrayBuffer.isView(f)){if(f instanceof DataView)return 2;let m=f.length??0,g=f instanceof Float32Array||f instanceof Float64Array?30:12;return 2+m*g}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,g]of f){if(a(g))continue;m>0&&(p+=1);let _=typeof h=="string"?h:String(h);p+=i(_)+3,p+=c(g),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 g=0;g<h.length;g++){let _=h[g],v=f[_];a(v)||(m>0&&(p+=1),p+=i(_)+3,p+=c(v),m++)}}return t.delete(f),p},t=new Set,r=0,i=typeof Buffer<"u"&&typeof Buffer.byteLength=="function"?l=>Buffer.byteLength(l,"utf8"):l=>l.length;return{size:c(e),maxStringLen:r}}catch{return{size:ur(e).length,maxStringLen:0}}}function ur(e,t,r,i,n){try{let o=JSON.stringify(e,YF(r),i);return bm(o)}catch(o){if(!o.message?.includes("Converting circular structure to JSON"))return console.warn(`[WARNING]: LangSmith received unserializable value.${t?`
37
+ Context: ${t}`:""}`),bm("[Unserializable]");Ye("SUPPRESS_CIRCULAR_JSON_WARNINGS")!=="true"&&console.warn(`[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. ${t?`
38
+ Context: ${t}`:""}`),typeof n>"u"&&(n=XF()),fb(e,"",0,[],void 0,0,n);let a;try{Gc.length===0?a=JSON.stringify(e,r,i):a=JSON.stringify(e,QF(r),i)}catch{return bm("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;wm.length!==0;){let s=wm.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return bm(a)}}function db(e,t,r,i){var n=Object.getOwnPropertyDescriptor(i,r);n.get!==void 0?n.configurable?(Object.defineProperty(i,r,{value:e}),wm.push([i,r,t,n])):Gc.push([t,r,e]):(i[r]=e,wm.push([i,r,t]))}function fb(e,t,r,i,n,o,a){o+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<i.length;s++)if(i[s]===e){db(qF,e,t,n);return}if(typeof a.depthLimit<"u"&&o>a.depthLimit){db(rP,e,t,n);return}if(typeof a.edgesLimit<"u"&&r+1>a.edgesLimit){db(rP,e,t,n);return}if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)fb(e[s],s,s,i,e,o,a);else{e=nP(e);var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];fb(e[u],u,s,i,e,o,a)}}i.pop()}}function QF(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(Gc.length>0)for(var i=0;i<Gc.length;i++){var n=Gc[i];if(n[1]===t&&n[0]===r){r=n[2],Gc.splice(i,1);break}}return e.call(this,t,r)}}var tB=`
39
+ const { parentPort } = require("worker_threads");
40
+
41
+ const CIRCULAR_REPLACE_NODE = { result: "[Circular]" };
42
+
43
+ function serializeWellKnownTypes(val) {
44
+ if (val && typeof val === "object") {
45
+ if (val instanceof Map) return Object.fromEntries(val);
46
+ if (val instanceof Set) return Array.from(val);
47
+ if (val instanceof Date) return val.toISOString();
48
+ if (val instanceof RegExp) return val.toString();
49
+ if (val instanceof Error) return { name: val.name, message: val.message };
50
+ } else if (typeof val === "bigint") {
51
+ return val.toString();
52
+ }
53
+ return val;
54
+ }
55
+
56
+ function defaultReplacer(_key, val) {
57
+ return serializeWellKnownTypes(val);
58
+ }
59
+
60
+ // Decirculate in-place: replace circular refs with { result: "[Circular]" }
61
+ // then restore after stringify. Mirrors fast-safe-stringify's decirc().
62
+ const restoreStack = [];
63
+ function decirc(val, k, stack, parent) {
64
+ if (typeof val === "object" && val !== null) {
65
+ for (let i = 0; i < stack.length; i++) {
66
+ if (stack[i] === val) {
67
+ const orig = parent[k];
68
+ parent[k] = CIRCULAR_REPLACE_NODE;
69
+ restoreStack.push([parent, k, orig]);
70
+ return;
71
+ }
72
+ }
73
+ stack.push(val);
74
+ if (Array.isArray(val)) {
75
+ for (let i = 0; i < val.length; i++) decirc(val[i], i, stack, val);
76
+ } else {
77
+ const normalized = serializeWellKnownTypes(val);
78
+ // Only recurse into normalized if it's still an object (arrays/objects),
79
+ // else it was replaced with a primitive (e.g. Date -> string).
80
+ if (normalized === val) {
81
+ const keys = Object.keys(val);
82
+ for (let i = 0; i < keys.length; i++) decirc(val[keys[i]], keys[i], stack, val);
83
+ }
84
+ }
85
+ stack.pop();
86
+ }
87
+ }
88
+
89
+ function serialize(obj) {
90
+ try {
91
+ return JSON.stringify(obj, defaultReplacer);
92
+ } catch (e) {
93
+ if (!String(e && e.message).includes("Converting circular structure to JSON")) {
94
+ return "[Unserializable]";
95
+ }
96
+ decirc(obj, "", [], { "": obj });
97
+ try {
98
+ return JSON.stringify(obj, defaultReplacer);
99
+ } catch (_) {
100
+ return "[unable to serialize, circular reference is too complex to analyze]";
101
+ } finally {
102
+ while (restoreStack.length) {
103
+ const [p, k, v] = restoreStack.pop();
104
+ p[k] = v;
105
+ }
106
+ }
107
+ }
108
+ }
109
+
110
+ parentPort.on("message", (msg) => {
111
+ const { id, op, payload } = msg;
112
+ try {
113
+ if (op === "serialize") {
114
+ const str = serialize(payload);
115
+ const buf = Buffer.from(str, "utf8");
116
+ // Slice into its own ArrayBuffer so we can transfer without dragging
117
+ // unrelated bytes from any shared pool buffer.
118
+ const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
119
+ parentPort.postMessage({ id, bytes: ab, length: buf.byteLength }, [ab]);
120
+ } else if (op === "ping") {
121
+ parentPort.postMessage({ id });
122
+ } else {
123
+ parentPort.postMessage({ id, error: "unknown op: " + op });
124
+ }
125
+ } catch (e) {
126
+ parentPort.postMessage({ id, error: String((e && e.message) || e) });
127
+ }
128
+ });
129
+ `,mb=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(tB,{eval:!0});return t.on("message",r=>{let i=this.pending.get(r.id);i&&(this.pending.delete(r.id),r.error?i.reject(new Error(r.error)):r.bytes&&typeof r.length=="number"?i.resolve(new Uint8Array(r.bytes,0,r.length)):i.reject(new Error("worker returned malformed message")))}),t.on("error",r=>{for(let[,i]of this.pending)i.reject(r);this.pending.clear(),this.disabled=!0,this.worker=null}),t.on("exit",r=>{for(let[,i]of this.pending)i.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 i=this.nextId++;return new Promise((n,o)=>{this.pending.set(i,{resolve:n,reject:o});try{this.worker.postMessage({id:i,op:"serialize",payload:t})}catch(a){this.pending.delete(i),o(a)}})}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()}},pb=null;function aP(){return pb===null&&(pb=new mb),pb}var rB=64*1024,nB=2048;function sP(e,t=rB,r=nB){if(e===null||typeof e!="object")return typeof e=="string"&&e.length>=t;let i=[e],n=new Set,o=0;for(;i.length>0;){if(o++>=r)return!1;let a=i.pop();if(a==null)continue;let s=typeof a;if(s==="string"){if(a.length>=t)return!0;continue}if(s!=="object")continue;let c=a;if(n.has(c)||(n.add(c),c instanceof Date||c instanceof RegExp||c instanceof Error||c instanceof ArrayBuffer||ArrayBuffer.isView(c)))continue;if(Array.isArray(c)){for(let l=c.length-1;l>=0;l--)i.push(c[l]);continue}if(c instanceof Map){for(let[,l]of c)i.push(l);continue}if(c instanceof Set){for(let l of c)i.push(l);continue}let u=Object.keys(c);for(let l=u.length-1;l>=0;l--)i.push(c[u[l]])}return!1}function iB(e,t){let[r]=cr(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 cP(e){return typeof e=="string"&&e.length>0&&!e.includes("Z")&&!e.includes("+")&&!e.includes("-",10)?e+"Z":e}function Kc(e){return{...e,start_time:cP(e.start_time),end_time:cP(e.end_time)}}function hb(e,t,r,i){if(r)return e;let n=Wp(),o=t??Tv(),a=e.extra??{},s=a.metadata;return e.extra={...a,runtime:{...n,...a?.runtime},metadata:{...o,...o.revision_id||"revision_id"in e&&e.revision_id?{revision_id:("revision_id"in e?e.revision_id:void 0)??o.revision_id}:{},...s,...i!==void 0?{ls_tracing_sample_rate:i}:{}}},e}var oB=e=>{let t=e?.toString()??Ye("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},aB=e=>{let r=e.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return r==="localhost"||r==="127.0.0.1"||r==="::1"};async function sB(e){let t=[];for await(let r of e)t.push(r);return t}function xm(e){if(e!==void 0)return e.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}var cB=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 uP(e){return typeof e=="number"?Number(e.toFixed(4)):e}function uB(e,t){if(!e)return;let r=u=>u.split(".").map(l=>parseInt(l,10)),[i,n,o]=r(e),[a,s,c]=r(t);if(isNaN(i)||isNaN(n)||isNaN(o)||isNaN(a)||isNaN(s)||isNaN(c)){console.warn(`[LANGSMITH]: Could not parse backend version ${JSON.stringify(e)} for compatibility check.`);return}(i<a||i===a&&n<s||i===a&&n===s&&o<c)&&console.warn(`[LANGSMITH]: Backend version ${JSON.stringify(e)} is older than the minimum version required by this SDK (${JSON.stringify(t)}). Some features may not work as expected. See https://docs.langchain.com/langsmith/smithdb-sdk-migration`)}var lB=24*1024*1024,pP=1024*1024*1024,dB=1e4,fB=100;function mP(e,t){new Headers({[e]:t})}function lP(e){for(let[t,r]of Object.entries(e??{}))mP(t,r)}function dP(e){if(!e)return{};let t=e instanceof Headers?[...e.entries()]:Array.isArray(e)?e.map(([n,o])=>[n,o]):Object.entries(e),r={},i=new Map;for(let[n,o]of t){mP(n,o);let a=n.toLowerCase(),s=i.get(a);s===void 0?(i.set(a,n),r[n]=o):r[s]=o}return r}function pB(e,t,r){let i={...e},n=new Map(Object.keys(i).map(o=>[o.toLowerCase(),o]));for(let[o,a]of Object.entries(t)){let s=o.toLowerCase();i[n.get(s)??o]=a}for(let o of Object.keys(i))r.has(o.toLowerCase())&&delete i[o];return i}var gb=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??pP}peek(){return this.items[0]}push(t){let r,i=new Promise(o=>{r=o}),n=iP(t.item).size;return this.sizeBytes+n>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: ${n} bytes.`),r(),i):(this.items.push({action:t.action,payload:t.item,otelContext:t.otelContext,apiKey:t.apiKey,apiUrl:t.apiUrl,workspaceId:t.workspaceId,itemPromiseResolve:r,itemPromise:i,size:n}),this.sizeBytes+=n,i)}pop({upToSizeBytes:t,upToSize:r}){if(t<1)throw new Error("Number of bytes to pop off may not be less than 1.");let i=[],n=0;for(;n+(this.peek()?.size??0)<t&&this.items.length>0&&i.length<r;){let o=this.items.shift();o&&(i.push(o),n+=o.size,this.sizeBytes-=o.size)}if(i.length===0&&this.items.length>0){let o=this.items.shift();i.push(o),n+=o.size,this.sizeBytes-=o.size}return[i.map(o=>({action:o.action,item:o.payload,otelContext:o.otelContext,apiKey:o.apiKey,apiUrl:o.apiUrl,workspaceId:o.workspaceId,size:o.size})),()=>i.forEach(o=>o.itemPromiseResolve())]}},fi=class e{get tracingMode(){return this._tracingMode}get _fetch(){let t=this.fetchImplementation||CC(this.debug);return(async(r,i)=>{let n,o=this.getProfileManagedAuthorizationHeader(i);return this.apiKey!==void 0?n={name:"x-api-key",value:`${this.apiKey}`}:this.hasExplicitAuthHeader(i,o)||(n=await this.profileAuth?.getAuthHeader(t,i?.signal)),t(r,this.applyCurrentAuthHeaders(i,n,o))})}getProfileManagedAuthorizationHeader(t){if(!t?.headers||!this.profileAuth)return;let r=new Headers(t.headers).get("Authorization");if(hn(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 i=new Headers(t.headers);if(hn(i.get("x-api-key")))return!0;let n=i.get("Authorization");return hn(n)?!this.isProfileManagedAuthorizationHeader(n??"",r):!1}applyCurrentAuthHeaders(t,r,i){if(!r)return t;let n=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(hn(d.get("x-api-key")))return d;let p=d.get("Authorization");return hn(p)&&!this.isProfileManagedAuthorizationHeader(p??"",i)||d.set("Authorization",r.value),d}let f=d.get("Authorization");return hn(f)&&!this.isProfileManagedAuthorizationHeader(f??"",i)||(hn(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:n(new Headers(t.headers))};if(Array.isArray(t.headers))return{...t,headers:n(new Headers(t.headers))};let o={...t.headers??{}},a=d=>Object.keys(o).find(f=>f.toLowerCase()===d),s=d=>{let f=a(d);return f?o[f]:void 0},c=hn(s("x-api-key")),u=s("authorization"),l=hn(u)&&!this.isProfileManagedAuthorizationHeader(u??"",i);if(this.apiKey!==void 0&&r.name==="x-api-key"){let d=a("authorization");return d&&delete o[d],c||(o["x-api-key"]=r.value),{...t,headers:o}}if(r.name==="Authorization"){if(!c&&!l){let d=a("authorization");d&&d!=="Authorization"&&delete o[d],o.Authorization=r.value}return{...t,headers:o}}if(!l){let d=a("authorization");d&&delete o[d],c||(o["x-api-key"]=r.value)}return{...t,headers:o}}_trackDrain(t){this._pendingDrains.add(t),t.finally(()=>{this._pendingDrains.delete(t)})}async _serializeBody(t,r){if(this.manualFlushMode)return ur(t,r);if(!sP(t))return ur(t,r);if(this._serializeWorker===void 0&&(this._serializeWorker=aP()),this._serializeWorker===null)return ur(t,r);try{let i=await this._serializeWorker.serialize(t);return i===null?(this._serializeWorker=null,ur(t,r)):i}catch{return ur(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,"anonymizer",{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,"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,"_fetchOptionsHeaders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_openAPIClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_openAPIClientSignature",{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:Ht("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,"_stainlessVersionsChecked",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),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:Ye("DISABLE_MULTIPART_STREAMING")==="true"}),Object.defineProperty(this,"_multipartDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_runCompressionDisabled",{enumerable:!0,configurable:!0,writable:!0,value:Ye("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:Ht("LANGSMITH_DEBUG")==="true"});let r=e.getDefaultClientConfig();this.tracingSampleRate=oB(t.tracingSamplingRate),this.apiUrl=xm(t.apiUrl??r.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1));let i=xm(t.apiKey??r.apiKey);if(this.apiKey=hn(i)?i:void 0,this.profileAuth=this.apiKey!==void 0?void 0:r.profileAuth,this.webUrl=xm(t.webUrl??r.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=xm(t.workspaceId??r.workspaceId),this.timeout_ms=t.timeout_ms??9e4,this.caller=new Ul({...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=Ye("FAILED_TRACES_DIR")||void 0;let n=Ye("FAILED_TRACES_MAX_MB");if(n){let c=parseInt(n,10);Number.isFinite(c)&&c>0&&(this.failedTracesMaxBytes=c*1024*1024)}let o=t.maxIngestMemoryBytes??pP;this.batchIngestCaller=new Ul({maxRetries:4,maxConcurrency:this.traceBatchConcurrency,maxQueueSizeBytes:o,...t.callerOptions??{},onFailedResponseHook:cB,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??t.anonymizer??r.hideMetadata,this.anonymizer=t.anonymizer,this.omitTracedRuntimeInfo=t.omitTracedRuntimeInfo??!1,this.autoBatchTracing=t.autoBatchTracing??this.autoBatchTracing,this.autoBatchQueue=new gb(o),this.blockOnRootRunFinalization=t.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=t.batchSizeBytesLimit,this.batchSizeLimit=t.batchSizeLimit;let{headers:a,...s}=t.fetchOptions||{};this.fetchOptions=s,this._fetchOptionsHeaders=dP(a),lP(t.headers),this._customHeaders=t.headers??{},this.manualFlushMode=t.manualFlushMode??this.manualFlushMode,this._tracingMode=qp(t.tracingMode),this._tracingMode==="otel"&&(this.langSmithToOTELTranslator=new Xp),this.cachedLSEnvVarsForMetadata=Tv(),t.cache!==void 0&&t.disablePromptCache&&Zt("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?(Zt("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=Kp:this._promptCache=t.cache):t.disablePromptCache||(this._promptCache=Kp)}static getDefaultClientConfig(){let t=eP(),r=Ye("API_KEY"),i=Ye("ENDPOINT"),n=Ye("WORKSPACE_ID"),o=hn(r),a=i??t.apiUrl??vm,s=n??t.workspaceId,c=Ye("HIDE_INPUTS")==="true",u=Ye("HIDE_OUTPUTS")==="true",l=Ye("HIDE_METADATA")==="true";return{apiUrl:a,apiKey:r,webUrl:void 0,hideInputs:c,hideOutputs:u,hideMetadata:l,workspaceId:s,oauthAccessToken:o?void 0:t.oauthAccessToken,oauthRefreshToken:o?void 0:t.oauthRefreshToken,profileAuth:o?void 0:t.profileAuth}}getHostUrl(){return this.webUrl?this.webUrl:aB(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 _sdkControlledHeaders(){let t=new Set;if(this.apiKey!==void 0)t.add("x-api-key");else{let r=this.profileAuth?.currentAuthHeader();r&&t.add(r.name.toLowerCase())}return this.workspaceId&&t.add("x-tenant-id"),t}get _callerHeaders(){return pB(dP(this._customHeaders),this._fetchOptionsHeaders,this._sdkControlledHeaders)}get _mergedHeaders(){let t={"User-Agent":`langsmith-js/${Ml}`,...this._callerHeaders};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 _openAPIClientOptions(){let t={...this._callerHeaders};Object.keys(t).some(n=>n.toLowerCase()==="user-agent")||(t["User-Agent"]=`langsmith-js/${Ml}`);let r=Object.keys(t).find(n=>n.toLowerCase()==="x-api-key"),i=this.apiKey;return i===void 0&&r!==void 0&&(i=t[r]??void 0,delete t[r]),i===void 0&&this.workspaceId===void 0&&(t["X-API-Key"]=null),{apiKey:i,defaultHeaders:Object.keys(t).length>0?t:void 0}}get headers(){return this._customHeaders}set headers(t){lP(t),this._customHeaders=t??{}}_getOpenAPIBaseUrl(){let t=this.apiUrl.replace(/\/$/,"");for(let r of["/api/v1","/api"])if(t.endsWith(r))return t.slice(0,-r.length);return t}get openAPIClient(){let t=this._openAPIClientOptions,r=JSON.stringify([t.apiKey,t.defaultHeaders]);return(this._openAPIClient===void 0||this._openAPIClientSignature!==r)&&(this._openAPIClientSignature=r,this._openAPIClient=this._newOpenAPIClient(t)),this._openAPIClient}_newOpenAPIClient(t=this._openAPIClientOptions){let{method:r,body:i,signal:n,...o}=this.fetchOptions;return new Be({apiKey:t.apiKey,tenantID:this.workspaceId,baseURL:this._getOpenAPIBaseUrl(),timeout:this.timeout_ms,fetch:this._fetch,fetchOptions:o,defaultHeaders:t.defaultHeaders})}_getPlatformEndpointPath(t){return this.apiUrl.slice(-3)!=="/v1"&&this.apiUrl.slice(-4)!=="/v1/"?`/v1/platform/${t}`:`/platform/${t}`}get evaluators(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.onlineEvaluators}get runs(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.runs}get sandboxes(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.sandboxes}get datasets(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.datasets}get annotationQueues(){return this._checkStainlessVersion("0.16.14"),this.openAPIClient.annotationQueues}get threads(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.threads}get traces(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.traces}get public(){return this._checkStainlessVersion("0.16.0"),this.openAPIClient.public}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}async processError(t){if(this.anonymizer==null)return t;let r=await this.anonymizer({error:t});return typeof r?.error=="string"?r.error:t}_filterNewTokenEvents(t){return!t||t.length===0?t:t.map(r=>{if(r.name==="new_token"){let{kwargs:i,...n}=r;return n}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.error!==void 0&&(r.error=await this.processError(r.error)),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 i=r?.toString()??"",n=`${this.apiUrl}${t}?${i}`;return await this.caller.call(async()=>{let a=await this._fetch(n,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,`fetch ${t}`),a})}async _get(t,r){return(await this._getResponse(t,r)).json()}async*_getPaginated(t,r=new URLSearchParams,i){let n=Number(r.get("offset"))||0,o=Number(r.get("limit"))||100;for(;;){r.set("offset",String(n)),r.set("limit",String(o));let a=`${this.apiUrl}${t}?${r}`,s=await this.caller.call(async()=>{let u=await this._fetch(a,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(u,`fetch ${t}`),u}),c=i?i(await s.json()):await s.json();if(c.length===0||(yield c,c.length<o))break;n+=c.length}}async*_getCursorPaginatedList(t,r=null,i="POST",n="runs"){let o=r?{...r}:{};for(;;){let a=JSON.stringify(o),c=await(await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}${t}`,{method:i,headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(l,`fetch ${t}`),l})).json();if(!c||!c[n])break;yield c[n];let u=c.cursors;if(!u||!u.next)break;o.cursor=u.next}}_shouldSample(t){return BO(t,this.tracingSampleRate)}_filterForSampling(t){return t.filter(r=>this._shouldSample(r.trace_id??r.dotted_order?.split(".",1)[0].split("Z")[1]??r.id))}async _getBatchSizeLimitBytes(){let t=await this._ensureServerInfo();return this.batchSizeBytesLimit??t?.batch_ingest_config?.size_limit_bytes??lB}async _getBatchSizeLimit(){let t=await this._ensureServerInfo();return this.batchSizeLimit??t?.batch_ingest_config?.size_limit??fB}async _getDatasetExamplesMultiPartSupport(){return(await this._ensureServerInfo()).instance_flags?.dataset_examples_multipart_enabled??!1}drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r}){let i=[];for(;this.autoBatchQueue.items.length>0;){let[n,o]=this.autoBatchQueue.pop({upToSizeBytes:t,upToSize:r});if(!n.length){o();break}let a=n.reduce((u,l)=>{let d=l.apiUrl??this.apiUrl,f=l.apiKey??this.apiKey,p=l.workspaceId??this.workspaceId,h=l.apiKey===this.apiKey&&l.apiUrl===this.apiUrl&&l.workspaceId===this.workspaceId?"default":`${d}|${f}|${p??""}`;return u[h]||(u[h]=[]),u[h].push(l),u},{}),s=[];for(let[u,l]of Object.entries(a)){let d=u==="default",f=d?[]:u.split("|"),p=f[2],m=this._processBatch(l,{apiUrl:d?void 0:f[0],apiKey:d?void 0:f[1],workspaceId:d||!p?void 0:p});s.push(m)}let c=Promise.all(s).finally(o);i.push(c)}return Promise.all(i)}static async _writeTraceToFallbackDir(t,r,i,n,o){try{let a=typeof r=="string"?Buffer.from(r,"utf8"):Buffer.from(r),s=JSON.stringify({version:1,endpoint:n,headers:i,body_base64:a.toString("base64")}),c=`trace_${Date.now()}_${Ka().slice(0,8)}.json`,u=Mn.join(t,c);if(e._fallbackDirsCreated.has(t)||(await Hp(t),e._fallbackDirsCreated.add(t)),o!==void 0&&o>0)try{let d=(await HC(t)).filter(p=>p.startsWith("trace_")&&p.endsWith(".json")),f=0;for(let p of d){let{size:m}=await ZC(Mn.join(t,p));f+=m}if(f>=o){console.warn(`Could not write trace to fallback dir ${t} as it's already over size limit (${f} bytes >= ${o} bytes). Increase LANGSMITH_FAILED_TRACES_MAX_MB if possible.`);return}}catch{}await Rc(u,s),console.warn(`LangSmith trace upload failed; data saved to ${u} for later replay.`)}catch(a){console.error(`LangSmith tracing error: could not write trace to fallback dir ${t}:`,a)}}async _processBatch(t,r){if(!t.length)return;let i=t.reduce((n,o)=>n+(o.size??0),0);try{if(this.langSmithToOTELTranslator!==void 0){for(let n of t)n.item=await this._maskRunMetadata(n.item);this._sendBatchToOTELTranslator(t)}else{let n={runCreates:t.filter(s=>s.action==="create").map(s=>s.item),runUpdates:t.filter(s=>s.action==="update").map(s=>s.item)},o=await this._ensureServerInfo();if(!this._multipartDisabled&&(o?.batch_ingest_config?.use_multipart_endpoint??!0)){let s=!this._runCompressionDisabled&&o?.instance_flags?.gzip_body_enabled;try{await this.multipartIngestRuns(n,{...r,useGzip:s,sizeBytes:i})}catch(c){if(ym(c))this._multipartDisabled=!0,await this.batchIngestRuns(n,{...r,sizeBytes:i});else throw c}}else await this.batchIngestRuns(n,{...r,sizeBytes:i})}}catch(n){console.error("Error exporting batch:",n)}}_sendBatchToOTELTranslator(t){if(this.langSmithToOTELTranslator!==void 0){let r=new Map,i=[];for(let n of t)n.item.id&&n.otelContext&&(r.set(n.item.id,n.otelContext),n.action==="create"?i.push({operation:"post",id:n.item.id,trace_id:n.item.trace_id??n.item.id,run:n.item}):i.push({operation:"patch",id:n.item.id,trace_id:n.item.trace_id??n.item.id,run:n.item}));this.langSmithToOTELTranslator.exportBatch(i,r)}}async _maskRunMetadata(t){return t.extra?.metadata==null?t:{...t,extra:{...t.extra,metadata:await this.processMetadata(t.extra.metadata)}}}async _mergeRuntimeEnvAndMaskMetadata(t){let r=hb(t,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo,this.tracingSampleRate);return this.omitTracedRuntimeInfo?r:this._maskRunMetadata(r)}async processRunOperation(t){clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,t.item=hb(t.item,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo,this.tracingSampleRate);let r=this.autoBatchQueue.push(t);if(this.manualFlushMode)return r;let i=await this._getBatchSizeLimitBytes(),n=await this._getBatchSizeLimit();return(this.autoBatchQueue.sizeBytes>i||this.autoBatchQueue.items.length>n)&&this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:i,batchSizeLimit:n})),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:i,batchSizeLimit:n}))},this.autoBatchAggregationDelayMs)),r}async _getServerInfo(){let r=await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/info`,{method:"GET",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(dB),...this.fetchOptions});return await X(i,"get server info"),i})).json();return this.debug&&console.log(`
130
+ === LangSmith Server Configuration ===
131
+ `+JSON.stringify(r,null,2)+`
132
+ `),r}_checkStainlessVersion(t){this._stainlessVersionsChecked.has(t)||(this._stainlessVersionsChecked.add(t),this._ensureServerInfo().then(r=>{uB(r?.version,t)}).catch(()=>{}))}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 _supportsSDBQuery(){return(await this._ensureServerInfo()).instance_flags?.sdb_query_enabled===!0}async _checkFeedbackSessionId(){let t="https://docs.langchain.com/langsmith/smithdb-sdk-migration-feedback#feedback-create",r=await this._ensureServerInfo();if(VO(r.instance_flags)===Hl.SMITHDB_ONLY)throw new Error(`sessionId must be provided when creating feedback for a run: this deployment cannot locate the run without it. See ${t}`);Zt(`Creating feedback for a run without sessionId is deprecated and will stop working in a future release. See ${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=Jp(),r=QC();if(this.langSmithToOTELTranslator!==void 0){let i=t.getActiveSpan();if(i)return t.setSpan(r.active(),i)}}async createRun(t,r){if(!this._filterForSampling([t]).length)return;let i={...this._mergedHeaders,"Content-Type":"application/json"},n=t.project_name;delete t.project_name;let o=await this.prepareRunCreateOrUpdateInputs({session_name:n,...t,start_time:t.start_time??Date.now()});if(this.autoBatchTracing&&o.trace_id!==void 0&&o.dotted_order!==void 0){let c=this._cloneCurrentOTELContext();this.processRunOperation({action:"create",item:o,otelContext:c,apiKey:r?.apiKey,apiUrl:r?.apiUrl,workspaceId:r?.workspaceId}).catch(console.error);return}let a=await this._mergeRuntimeEnvAndMaskMetadata(o);r?.apiKey!==void 0&&(i["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(i["x-tenant-id"]=r.workspaceId);let s=ur(a,`Creating run with id: ${a.id}`);await this.caller.call(async()=>{let c=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs`,{method:"POST",headers:i,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await X(c,"create run",!0),c})}async batchIngestRuns({runCreates:t,runUpdates:r},i){if(t===void 0&&r===void 0)return;let n=await Promise.all(t?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]),o=await Promise.all(r?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]);if(n.length>0&&o.length>0){let c=n.reduce((l,d)=>(d.id&&(l[d.id]=d),l),{}),u=[];for(let l of o)l.id!==void 0&&c[l.id]?c[l.id]={...c[l.id],...l}:u.push(l);n=Object.values(c),o=u}let a={post:n,patch:o};if(!a.post.length&&!a.patch.length)return;let s={post:[],patch:[]};for(let c of["post","patch"]){let u=c,l=a[u].reverse(),d=l.pop();for(;d!==void 0;)s[u].push(d),d=l.pop()}if(s.post.length>0||s.patch.length>0){let c=s.post.map(u=>u.id).concat(s.patch.map(u=>u.id)).join(",");await this._postBatchIngestRuns(await this._serializeBody(s,`Ingesting runs with ids: ${c}`),i)}}async _postBatchIngestRuns(t,r){let i={...this._mergedHeaders,"Content-Type":"application/json",Accept:"application/json"};r?.apiKey!==void 0&&(i["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(i["x-tenant-id"]=r.workspaceId),await this.batchIngestCaller.callWithOptions({sizeBytes:r?.sizeBytes},async()=>{let n=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/batch`,{method:"POST",headers:i,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:t});return await X(n,"batch create run",!0),n})}async multipartIngestRuns({runCreates:t,runUpdates:r},i){if(t===void 0&&r===void 0)return;let n={},o=[];for(let d of t??[]){let f=await this.prepareRunCreateOrUpdateInputs(d);f.id!==void 0&&f.attachments!==void 0&&(n[f.id]=f.attachments),delete f.attachments,o.push(f)}let a=[];for(let d of r??[])a.push(await this.prepareRunCreateOrUpdateInputs(d));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 creating a run');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 updating a run');if(o.length>0&&a.length>0){let d=o.reduce((p,m)=>(m.id&&(p[m.id]=m),p),{}),f=[];for(let p of a)p.id!==void 0&&d[p.id]?d[p.id]={...d[p.id],...p}:f.push(p);o=Object.values(d),a=f}if(o.length===0&&a.length===0)return;let u=[],l=[];for(let[d,f]of[["post",o],["patch",a]])for(let p of f){let{inputs:m,outputs:h,events:g,extra:_,error:v,serialized:x,attachments:S,...k}=p,T={inputs:m,outputs:h,events:g,extra:_,error:v,serialized:x},A=await this._serializeBody(k,`Serializing for multipart ingestion of run with id: ${k.id}`);l.push({name:`${d}.${k.id}`,payload:new Blob([A],{type:`application/json; length=${A.length}`})});for(let[b,z]of Object.entries(T)){if(z===void 0)continue;let j=await this._serializeBody(z,`Serializing ${b} for multipart ingestion of run with id: ${k.id}`);l.push({name:`${d}.${k.id}.${b}`,payload:new Blob([j],{type:`application/json; length=${j.length}`})})}if(k.id!==void 0){let b=n[k.id];if(b){delete n[k.id];for(let[z,j]of Object.entries(b)){let H,ne;if(Array.isArray(j)?[H,ne]=j:(H=j.mimeType,ne=j.data),z.includes(".")){console.warn(`Skipping attachment '${z}' for run ${k.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`);continue}l.push({name:`attachment.${k.id}.${z}`,payload:new Blob([ne],{type:`${H}; length=${ne.byteLength}`})})}}}u.push(`trace=${k.trace_id},id=${k.id}`)}await this._sendMultipartRequest(l,u.join("; "),i)}async _createNodeFetchBody(t,r){let i=[];for(let a of t)i.push(new Blob([`--${r}\r
133
+ `])),i.push(new Blob([`Content-Disposition: form-data; name="${a.name}"\r
134
+ `,`Content-Type: ${a.payload.type}\r
135
+ \r
136
+ `])),i.push(a.payload),i.push(new Blob([`\r
137
+ `]));return i.push(new Blob([`--${r}--\r
138
+ `])),await new Blob(i).arrayBuffer()}async _createMultipartStream(t,r){let i=new TextEncoder;return new ReadableStream({async start(o){let a=async s=>{typeof s=="string"?o.enqueue(i.encode(s)):o.enqueue(s)};for(let s of t){await a(`--${r}\r
139
+ `),await a(`Content-Disposition: form-data; name="${s.name}"\r
140
+ `),await a(`Content-Type: ${s.payload.type}\r
141
+ \r
142
+ `);let u=s.payload.stream().getReader();try{let l;for(;!(l=await u.read()).done;)o.enqueue(l.value)}finally{u.releaseLock()}await a(`\r
143
+ `)}await a(`--${r}--\r
144
+ `),o.close()}})}async _sendMultipartRequest(t,r,i){let n="----LangSmithFormBoundary"+Math.random().toString(36).slice(2),o=()=>this._createNodeFetchBody(t,n),a=()=>this._createMultipartStream(t,n),s=async c=>this.batchIngestCaller.callWithOptions({sizeBytes:i?.sizeBytes},async()=>{let u=await c(),l={...this._mergedHeaders,"Content-Type":`multipart/form-data; boundary=${n}`};i?.apiKey!==void 0&&(l["x-api-key"]=i.apiKey),i?.workspaceId!==void 0&&(l["x-tenant-id"]=i.workspaceId);let d=u;i?.useGzip&&typeof u=="object"&&"pipeThrough"in u&&(d=u.pipeThrough(new CompressionStream("gzip")),l["Content-Encoding"]="gzip");let f=await this._fetch(`${i?.apiUrl??this.apiUrl}/runs/multipart`,{method:"POST",headers:l,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,u=!1;AC()&&!this.multipartStreamingDisabled&&zl()!=="bun"?(u=!0,c=await s(a)):c=await s(o),(!this.multipartStreamingDisabled||u)&&c.status===422&&(i?.apiUrl??this.apiUrl)!==vm&&(console.warn(`Streaming multipart upload to ${i?.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(o))}catch(c){if(ym(c))throw c;if(console.warn(`${c.message.trim()}
145
+
146
+ Context: ${r}`),this.failedTracesDir){let u=await this._createNodeFetchBody(t,n).catch(()=>null);u&&await e._writeTraceToFallbackDir(this.failedTracesDir,u,{"Content-Type":`multipart/form-data; boundary=${n}`},"runs/multipart",this.failedTracesMaxBytes)}}}async updateRun(t,r,i){pe(t),r.inputs&&(r.inputs=await this.processInputs(r.inputs)),r.outputs&&(r.outputs=await this.processOutputs(r.outputs)),r.error&&(r.error=await this.processError(r.error)),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 n={...r,id:t};if(!this._filterForSampling([n]).length)return;if(this.autoBatchTracing&&n.trace_id!==void 0&&n.dotted_order!==void 0){let s=this._cloneCurrentOTELContext();if(r.end_time!==void 0&&n.parent_run_id===void 0&&this.blockOnRootRunFinalization&&!this.manualFlushMode){await this.processRunOperation({action:"update",item:n,otelContext:s,apiKey:i?.apiKey,apiUrl:i?.apiUrl,workspaceId:i?.workspaceId}).catch(console.error);return}else this.processRunOperation({action:"update",item:n,otelContext:s,apiKey:i?.apiKey,apiUrl:i?.apiUrl,workspaceId:i?.workspaceId}).catch(console.error);return}let o={...this._mergedHeaders,"Content-Type":"application/json"};i?.apiKey!==void 0&&(o["x-api-key"]=i.apiKey),i?.workspaceId!==void 0&&(o["x-tenant-id"]=i.workspaceId);let a=ur(r.extra?hb(r,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo,this.tracingSampleRate):r,`Serializing payload to update run with id: ${t}`);await this.caller.call(async()=>{let s=await this._fetch(`${i?.apiUrl??this.apiUrl}/runs/${t}`,{method:"PATCH",headers:o,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(s,"update run",!0),s})}async readRun(t,{loadChildRuns:r}={loadChildRuns:!1}){return Zt("readRun() is deprecated and will be removed after Jan 31, 2027. Use client.runs.retrieve() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration-runs#runs-retrieve for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_READ_RUN"}),this._readRun(t,{loadChildRuns:r})}async _readRun(t,{loadChildRuns:r}={loadChildRuns:!1}){pe(t);let i=Kc(await this._get(`/runs/${t}`));return r&&(i=await this._loadChildRuns(i)),i}async getRunUrl({runId:t,run:r,projectOpts:i}){if(Zt("getRunUrl() is deprecated and will be removed after Jan 31, 2027. Use client.runs.getURL() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration-runs#runs-get-url for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_GET_RUN_URL"}),r!==void 0){let n;r.session_id?n=r.session_id:i?.projectName?n=(await this.readProject({projectName:i?.projectName})).id:i?.projectId?n=i?.projectId:n=(await this.readProject({projectName:Ye("PROJECT")||"default"})).id;let o=await this._getTenantId();return`${this.getHostUrl()}/o/${o}/projects/p/${n}/r/${r.id}?poll=true`}else if(t!==void 0){let n=await this._readRun(t);if(!n.app_path)throw new Error(`Run ${t} has no app_path`);return`${this.getHostUrl()}${n.app_path}`}else throw new Error("Must provide either runId or run")}async _loadChildRuns(t){let r=await sB(this._listRuns({isRoot:!1,projectId:t.session_id,traceId:t.trace_id})),i={},n={};r.sort((o,a)=>(o?.dotted_order??"").localeCompare(a?.dotted_order??""));for(let o of r){if(o.parent_run_id===null||o.parent_run_id===void 0)throw new Error(`Child run ${o.id} has no parent`);o.dotted_order?.startsWith(t.dotted_order??"")&&o.id!==t.id&&(o.parent_run_id in i||(i[o.parent_run_id]=[]),i[o.parent_run_id].push(o),n[o.id]=o)}t.child_runs=i[t.id]||[];for(let o in i)o!==t.id&&(n[o].child_runs=i[o]);return t}async*listRuns(t){Zt("listRuns() is deprecated and will be removed after Jan 31, 2027. Use client.runs.query() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration-query-runs#runs-query for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_LIST_RUNS"}),yield*this._listRuns(t)}async*_listRuns(t){let{projectId:r,projectName:i,parentRunId:n,traceId:o,referenceExampleId:a,startTime:s,executionOrder:c,isRoot:u,runType:l,error:d,id:f,query:p,filter:m,traceFilter:h,treeFilter:g,limit:_,select:v,order:x}=t,S=[];if(r&&(S=Array.isArray(r)?r:[r]),i){let b=Array.isArray(i)?i:[i],z=await Promise.all(b.map(j=>this.readProject({projectName:j}).then(H=>H.id)));S.push(...z)}let k=["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"],T={session:S.length?S:null,run_type:l,reference_example:a,query:p,filter:m,trace_filter:h,tree_filter:g,execution_order:c,parent_run:n,start_time:s?s.toISOString():null,error:d,id:f,limit:_,trace:o,select:v||k,is_root:u,order:x};T.select.includes("child_run_ids")&&Zt("Deprecated: 'child_run_ids' in the listRuns select parameter is deprecated and will be removed in a future version.");let A=0;for await(let b of this._getCursorPaginatedList("/runs/query",T)){let z=b.map(Kc);if(_){if(A>=_)break;if(z.length+A>_){yield*z.slice(0,_-A);break}A+=z.length,yield*z}else yield*z}}async*listGroupRuns(t){let{projectId:r,projectName:i,groupBy:n,filter:o,startTime:a,endTime:s,limit:c,offset:u}=t,d={session_id:r||(await this.readProject({projectName:i})).id,group_by:n,filter:o,start_time:a?a.toISOString():null,end_time:s?s.toISOString():null,limit:Number(c)||100},f=Number(u)||0,p="/runs/group",m=`${this.apiUrl}${p}`;for(;;){let h={...d,offset:f},g=Object.fromEntries(Object.entries(h).filter(([T,A])=>A!==void 0)),_=JSON.stringify(g),x=await(await this.caller.call(async()=>{let T=await this._fetch(m,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:_});return await X(T,`Failed to fetch ${p}`),T})).json(),{groups:S,total:k}=x;if(S.length===0)break;for(let T of S)yield T;if(f+=S.length,f>=k)break}}async*readThread(t){Zt("readThread() is deprecated and will be removed after Jan 31, 2027. Use client.threads.listTraces() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration-threads#threads-list-traces for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_READ_THREAD"});let{threadId:r,projectId:i,projectName:n,isRoot:o=!0,limit:a,filter:s,order:c="asc"}=t;if(!i&&!n)throw new Error("threadId requires projectId or projectName");let u=`eq(thread_id, ${JSON.stringify(r)})`,l=s?`and(${u}, ${s})`:u;yield*this._listRuns({projectId:i??void 0,projectName:n??void 0,isRoot:o,limit:a,filter:l,order:c})}async listThreads(t){Zt("listThreads() is deprecated and will be removed after Jan 31, 2027. Use client.threads.query() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration-threads#threads-query for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_LIST_THREADS"});let{projectId:r,projectName:i,limit:n,offset:o=0,filter:a,startTime:s,isRoot:c=!0}=t;if(!r&&!i)throw new Error("Either projectId or projectName must be provided");if(r&&i)throw new Error("Provide exactly one of projectId or projectName");let u=r??(await this.readProject({projectName:i})).id,l=s??new Date(Date.now()-1440*60*1e3),f={session:[u],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:l.toISOString()};a!=null&&(f.filter=a);let p=new Map;for await(let _ of this._getCursorPaginatedList("/runs/query",f))for(let v of _){let x=Kc(v),S=x.thread_id;if(S){let k=p.get(S)??[];k.push(x),p.set(S,k)}}let m=[];for(let[_,v]of p.entries()){v.sort((A,b)=>{let z=A,j=b,H=z.start_time??"",ne=j.start_time??"";if(H!==ne)return H.localeCompare(ne);let ye=z.dotted_order??"",Ce=j.dotted_order??"";return ye.localeCompare(Ce)});let S=[...v.map(A=>A.start_time).filter(Boolean)].sort(),k=S.length?S[0]:"",T=S.length?S[S.length-1]:"";m.push({thread_id:_,runs:v,count:v.length,filter:"",total_tokens:0,total_cost:null,min_start_time:k,max_start_time:T,latency_p50:0,latency_p99:0,feedback_stats:null,first_inputs:"",last_outputs:"",last_error:null})}m.sort((_,v)=>{let x=_.max_start_time??"";return(v.max_start_time??"").localeCompare(x)});let h=o>0?m.slice(o):m;return n!==void 0?h.slice(0,n):h}async getRunStats({id:t,trace:r,parentRun:i,runType:n,projectNames:o,projectIds:a,referenceExampleIds:s,startTime:c,endTime:u,error:l,query:d,filter:f,traceFilter:p,treeFilter:m,isRoot:h,dataSourceType:g}){let _=a||[];if(o&&(_=[...a||[],...await Promise.all(o.map(A=>this.readProject({projectName:A}).then(b=>b.id)))]),_.length===0)throw new Error("At least one of projectNames or projectIds must be provided.");let x=Object.fromEntries(Object.entries({id:t,trace:r,parent_run:i,run_type:n,session:_,reference_example:s,start_time:c,end_time:u,error:l,query:d,filter:f,trace_filter:p,tree_filter:m,is_root:h,data_source_type:g}).filter(([A,b])=>b!==void 0)),S=JSON.stringify(x);return await(await this.caller.call(async()=>{let A=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(A,"get run stats"),A})).json()}async shareRun(t,{shareId:r}={}){Zt("shareRun() is deprecated and will be removed after Jan 31, 2027. Use client.runs.share.create() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration-feedback#share-and-read-public-runs for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_SHARE_RUN"});let i={run_id:t,share_token:r||Ka()};pe(t);let n=JSON.stringify(i),a=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:n});return await X(s,"share run"),s})).json();if(a===null||!("share_token"in a))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${a.share_token}/r`}async unshareRun(t){Zt("unshareRun() is deprecated and will be removed after Jan 31, 2027. Use client.runs.share.delete() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration-feedback#share-and-read-public-runs for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_UNSHARE_RUN"}),pe(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){Zt('readRunSharedLink() is deprecated and will be removed after Jan 31, 2027. Use client.runs.retrieve({ selects: ["SHARE_URL"] }) instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration-feedback#share-and-read-public-runs for the migration guide.',{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_READ_RUN_SHARED_LINK"}),pe(t);let i=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"read run shared link"),n})).json();if(!(i===null||!("share_token"in i)))return`${this.getHostUrl()}/public/${i.share_token}/r`}async listSharedRuns(t,{runIds:r}={}){Zt("listSharedRuns() is deprecated and will be removed after Jan 31, 2027. Use client.public.runs.query() instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration-feedback#share-and-read-public-runs for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_LIST_SHARED_RUNS"});let i=new URLSearchParams({share_token:t});if(r!==void 0)for(let a of r)i.append("id",a);return pe(t),(await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/public/${t}/runs${i}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,"list shared runs"),a})).json()).map(Kc)}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),pe(t);let n=await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(o,"read dataset shared schema"),o})).json();return n.url=`${this.getHostUrl()}/public/${n.share_token}/d`,n}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 i={dataset_id:t};pe(t);let n=JSON.stringify(i),a=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:n});return await X(s,"share dataset"),s})).json();return a.url=`${this.getHostUrl()}/public/${a.share_token}/d`,a}async unshareDataset(t){pe(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 pe(t),await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/public/${t}/datasets`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"read shared dataset"),n})).json()}async listSharedExamples(t,r){let i={};r?.exampleIds&&(i.id=r.exampleIds);let n=new URLSearchParams;Object.entries(i).forEach(([s,c])=>{Array.isArray(c)?c.forEach(u=>n.append(s,u)):n.append(s,c)});let o=await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/public/${t}/examples?${n.toString()}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(s,"list shared examples"),s}),a=await o.json();if(!o.ok)throw"detail"in a?new Error(`Failed to list shared examples.
147
+ Status: ${o.status}
148
+ Message: ${Array.isArray(a.detail)?a.detail.join(`
149
+ `):"Unspecified error"}`):new Error(`Failed to list shared examples: ${o.status} ${o.statusText}`);return a.map(s=>({...s,_hostUrl:this.getHostUrl()}))}async createProject({projectName:t,description:r=null,metadata:i=null,upsert:n=!1,projectExtra:o=null,referenceDatasetId:a=null,numExamples:s=null,numRepetitions:c=null,evaluatorKeys:u=null,tagValueIds:l=null}){let d=n?"?upsert=true":"",f=`${this.apiUrl}/sessions${d}`,p=o||{};i&&(p.metadata=i);let m={name:t,extra:p,description:r};a!==null&&(m.reference_dataset_id=a),s!=null&&(m.num_examples=s),c!=null&&(m.num_repetitions=c),u!=null&&u.length>0&&(m.evaluator_keys=u),l!==null&&(m.tag_value_ids=l);let h=JSON.stringify(m);return await(await this.caller.call(async()=>{let v=await this._fetch(f,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:h});return await X(v,"create project"),v})).json()}async updateProject(t,{name:r=null,description:i=null,metadata:n=null,projectExtra:o=null,endTime:a=null}){let s=`${this.apiUrl}/sessions/${t}`,c=o;n&&(c={...c||{},metadata:n});let u=JSON.stringify({name:r,extra:c,description:i,end_time:a?new Date(a).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:u});return await X(f,"update project"),f})).json()}async hasProject({projectId:t,projectName:r}){let i="/sessions",n=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)pe(t),i+=`/${t}`;else if(r!==void 0)n.append("name",r);else throw new Error("Must provide projectName or projectId");let o=await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${i}?${n}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,"has project"),a});try{let a=await o.json();return o.ok?Array.isArray(a)?a.length>0:!0:!1}catch{return!1}}async readProject({projectId:t,projectName:r,includeStats:i}){let n="/sessions",o=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)pe(t),n+=`/${t}`;else if(r!==void 0)o.append("name",r);else throw new Error("Must provide projectName or projectId");i!==void 0&&o.append("include_stats",i.toString());let a=await this._get(n,o),s;if(Array.isArray(a)){if(a.length===0)throw new Error(`Project[id=${t}, name=${r}] not found`);s=a[0]}else s=a;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 i=await this.readProject({projectId:t,projectName:r}),n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/projects/p/${i.id}`}async getDatasetUrl({datasetId:t,datasetName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");let i=await this.readDataset({datasetId:t,datasetName:r}),n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/datasets/${i.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:i,referenceDatasetId:n,referenceDatasetName:o,includeStats:a,datasetVersion:s,referenceFree:c,metadata:u}={}){let l=new URLSearchParams;if(t!==void 0)for(let d of t)l.append("id",d);if(r!==void 0&&l.append("name",r),i!==void 0&&l.append("name_contains",i),n!==void 0)l.append("reference_dataset",n);else if(o!==void 0){let d=await this.readDataset({datasetName:o});l.append("reference_dataset",d.id)}a!==void 0&&l.append("include_stats",a.toString()),s!==void 0&&l.append("dataset_version",s),c!==void 0&&l.append("reference_free",c.toString()),u!==void 0&&l.append("metadata",JSON.stringify(u));for await(let d of this._getPaginated("/sessions",l))yield*d}async deleteProject({projectId:t,projectName:r}){let i;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?i=(await this.readProject({projectName:r})).id:i=t,pe(i),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/sessions/${i}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,`delete session ${i} (${r})`,!0),n})}async uploadCsv({csvFile:t,fileName:r,inputKeys:i,outputKeys:n,description:o,dataType:a,name:s}){let c=`${this.apiUrl}/datasets/upload`,u=new FormData,l=new Blob([t],{type:"text/csv"});return u.append("file",l,r),i.forEach(p=>{u.append("input_keys",p)}),n.forEach(p=>{u.append("output_keys",p)}),o&&u.append("description",o),a&&u.append("data_type",a),s&&u.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:u});return await X(p,"upload CSV"),p})).json()}async createDataset(t,{description:r,dataType:i,inputsSchema:n,outputsSchema:o,metadata:a,tagValueIds:s}={}){let c={name:t,description:r,extra:{source:"sdk",...a?{metadata:a}:{}}};i&&(c.data_type=i),n&&(c.inputs_schema_definition=n),o&&(c.outputs_schema_definition=o),s!==void 0&&(c.tag_value_ids=s);let u=JSON.stringify(c);return await(await this.caller.call(async()=>{let f=await this._fetch(`${this.apiUrl}/datasets`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await X(f,"create dataset"),f})).json()}async readDataset({datasetId:t,datasetName:r}){let i="/datasets",n=new URLSearchParams({limit:"1"});if(t&&r)throw new Error("Must provide either datasetName or datasetId, not both");if(t)pe(t),i+=`/${t}`;else if(r)n.append("name",r);else throw new Error("Must provide datasetName or datasetId");let o=await this._get(i,n),a;if(Array.isArray(o)){if(o.length===0)throw new Error(`Dataset[id=${t}, name=${r}] not found`);a=o[0]}else a=o;return a}async hasDataset({datasetId:t,datasetName:r}){try{return await this.readDataset({datasetId:t,datasetName:r}),!0}catch(i){if(i instanceof Error&&i.message.toLocaleLowerCase().includes("not found"))return!1;throw i}}async diffDatasetVersions({datasetId:t,datasetName:r,fromVersion:i,toVersion:n}){let o=t;if(o===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");if(o!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");o===void 0&&(o=(await this.readDataset({datasetName:r})).id);let a=new URLSearchParams({from_version:typeof i=="string"?i:i.toISOString(),to_version:typeof n=="string"?n:n.toISOString()});return await this._get(`/datasets/${o}/versions/diff`,a)}async readDatasetOpenaiFinetuning({datasetId:t,datasetName:r}){let i="/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(`${i}/${t}/openai_ft`)).text()).trim().split(`
150
+ `).map(s=>JSON.parse(s))}async*listDatasets({limit:t=100,offset:r=0,datasetIds:i,datasetName:n,datasetNameContains:o,metadata:a}={}){let s="/datasets",c=new URLSearchParams({limit:t.toString(),offset:r.toString()});if(i!==void 0)for(let u of i)c.append("id",u);n!==void 0&&c.append("name",n),o!==void 0&&c.append("name_contains",o),a!==void 0&&c.append("metadata",JSON.stringify(a));for await(let u of this._getPaginated(s,c))yield*u}async updateDataset(t){let{datasetId:r,datasetName:i,...n}=t;if(!r&&!i)throw new Error("Must provide either datasetName or datasetId");let o=r??(await this.readDataset({datasetName:i})).id;pe(o);let a=JSON.stringify(n);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${o}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(c,"update dataset"),c})).json()}async updateDatasetTag(t){let{datasetId:r,datasetName:i,asOf:n,tag:o}=t;if(!r&&!i)throw new Error("Must provide either datasetName or datasetId");let a=r??(await this.readDataset({datasetName:i})).id;pe(a);let s=JSON.stringify({as_of:typeof n=="string"?n:n.toISOString(),tag:o});await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}/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 i="/datasets",n=t;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(r!==void 0&&(n=(await this.readDataset({datasetName:r})).id),n!==void 0)pe(n),i+=`/${n}`;else throw new Error("Must provide datasetName or datasetId");await this.caller.call(async()=>{let o=await this._fetch(this.apiUrl+i,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(o,`delete ${i}`,!0),o})}async createExample(t,r,i){if(fP(t)&&(r!==void 0||i!==void 0))throw new Error("Cannot provide outputs or options when using ExampleCreate object");let n=r?i?.datasetId:t.dataset_id,o=r?i?.datasetName:t.dataset_name;if(n===void 0&&o===void 0)throw new Error("Must provide either datasetName or datasetId");if(n!==void 0&&o!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");n===void 0&&(n=(await this.readDataset({datasetName:o})).id);let a=(r?i?.createdAt:t.created_at)||new Date,s;fP(t)?s=t:s={inputs:t,outputs:r,created_at:a?.toISOString(),id:i?.exampleId,metadata:i?.metadata,split:i?.split,source_run_id:i?.sourceRunId,use_source_run_io:i?.useSourceRunIO,use_source_run_attachments:i?.useSourceRunAttachments,attachments:i?.attachments};let c=await this._uploadExamplesMultipart(n,[s]);return await this.readExample(c.example_ids?.[0]??Ka())}async createExamples(t){if(Array.isArray(t)){if(t.length===0)return[];let v=t,x=v[0].dataset_id,S=v[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 k=await this._uploadExamplesMultipart(x,v);return await Promise.all(k.example_ids.map(A=>this.readExample(A)))}let{inputs:r,outputs:i,metadata:n,splits:o,sourceRunIds:a,useSourceRunIOs:s,useSourceRunAttachments:c,attachments:u,exampleIds:l,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((v,x)=>({dataset_id:p,inputs:v,outputs:i?.[x],metadata:n?.[x],split:o?.[x],id:l?.[x],attachments:u?.[x],source_run_id:a?.[x],use_source_run_io:s?.[x],use_source_run_attachments:c?.[x]})),g=await this._uploadExamplesMultipart(p,h);return await Promise.all(g.example_ids.map(v=>this.readExample(v)))}async createLLMExample(t,r,i){return this.createExample({input:t},{output:r},i)}async createChatExample(t,r,i){let n=t.map(a=>Zv(a)?Gv(a):a),o=Zv(r)?Gv(r):r;return this.createExample({input:n},{output:o},i)}async readExample(t){pe(t);let r=`/examples/${t}`,i=await this._get(r),{attachment_urls:n,...o}=i,a=o;return n&&(a.attachments=Object.entries(n).reduce((s,[c,u])=>(s[c.slice(11)]={presigned_url:u.presigned_url,mime_type:u.mime_type},s),{})),a}async*listExamples({datasetId:t,datasetName:r,exampleIds:i,asOf:n,splits:o,inlineS3Urls:a,metadata:s,limit:c,offset:u,filter:l,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=n?typeof n=="string"?n:n?.toISOString():void 0;m&&p.append("as_of",m);let h=a??!0;if(p.append("inline_s3_urls",h.toString()),i!==void 0)for(let _ of i)p.append("id",_);if(o!==void 0)for(let _ of o)p.append("splits",_);if(s!==void 0){let _=JSON.stringify(s);p.append("metadata",_)}c!==void 0&&p.append("limit",c.toString()),u!==void 0&&p.append("offset",u.toString()),l!==void 0&&p.append("filter",l),d===!0&&["attachment_urls","outputs","metadata"].forEach(_=>p.append("select",_));let g=0;for await(let _ of this._getPaginated("/examples",p)){for(let v of _){let{attachment_urls:x,...S}=v,k=S;x&&(k.attachments=Object.entries(x).reduce((T,[A,b])=>(T[A.slice(11)]={presigned_url:b.presigned_url,mime_type:b.mime_type||void 0},T),{})),yield k,g++}if(c!==void 0&&g>=c)break}}async deleteExample(t){pe(t);let r=`/examples/${t}`;await this.caller.call(async()=>{let i=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,`delete ${r}`,!0),i})}async deleteExamples(t,r){if(t.forEach(i=>pe(i)),r?.hardDelete){let i=this._getPlatformEndpointPath("datasets/examples/delete");await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}${i}`,{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(n,"hard delete examples",!0),n})}else{let i=new URLSearchParams;t.forEach(n=>i.append("example_ids",n)),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/examples?${i.toString()}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"delete examples",!0),n})}}async updateExample(t,r){let i;r?i=t:i=t.id,pe(i);let n;r?n={id:i,...r}:n=t;let o;return n.dataset_id!==void 0?o=n.dataset_id:o=(await this.readExample(i)).dataset_id,this._updateExamplesMultipart(o,[n])}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:i,tag:n}){let o;if(t?o=t:o=(await this.readDataset({datasetName:r})).id,pe(o),i&&n||!i&&!n)throw new Error("Exactly one of asOf and tag must be specified.");let a=new URLSearchParams;return i!==void 0&&a.append("as_of",typeof i=="string"?i:i.toISOString()),n!==void 0&&a.append("tag",n),await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${o}/version?${a.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:i}){let n;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?n=(await this.readDataset({datasetName:r})).id:n=t,pe(n);let o=new URLSearchParams,a=i?typeof i=="string"?i:i?.toISOString():void 0;return a&&o.append("as_of",a),await this._get(`/datasets/${n}/splits`,o)}async updateDatasetSplits({datasetId:t,datasetName:r,splitName:i,exampleIds:n,remove:o=!1}){let a;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?a=(await this.readDataset({datasetName:r})).id:a=t,pe(a);let s={split_name:i,examples:n.map(u=>(pe(u),u)),remove:o},c=JSON.stringify(s);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/datasets/${a}/splits`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await X(u,"update dataset splits",!0),u})}async createFeedback(t,r,i){let{runId:n=null,key:o,score:a,value:s,correction:c,comment:u,sourceInfo:l,feedbackSourceType:d="api",sourceRunId:f,feedbackId:p,feedbackConfig:m,projectId:h,traceId:g,comparativeExperimentId:_,sessionId:v,startTime:x,extendTraceRetention:S}=typeof t=="object"&&t!==null?t:{runId:t,key:r,...i};if(!n&&!h)throw new Error("One of runId or projectId must be provided");if(n&&h)throw new Error("Only one of runId or projectId can be provided");n&&v===void 0&&await this._checkFeedbackSessionId();let k={type:d??"api",metadata:l??{}};f!==void 0&&k?.metadata!==void 0&&!k.metadata.__run&&(k.metadata.__run={run_id:f}),k?.metadata!==void 0&&k.metadata.__run?.run_id!==void 0&&pe(k.metadata.__run.run_id);let T={id:p??Ac(),run_id:n,trace_id:g,key:o,score:uP(a),value:s,correction:c,comment:u,feedback_source:k,comparative_experiment_id:_,feedbackConfig:m,session_id:v??h,start_time:x,extend_trace_retention:S},A=g??n;if(A!=null&&!this._shouldSample(A))return T;let b=JSON.stringify(T),z=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{let j=await this._fetch(z,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:b});return await X(j,"create feedback",!0),j}),T}async updateFeedback(t,{score:r,value:i,correction:n,comment:o}){let a={};r!=null&&(a.score=uP(r)),i!=null&&(a.value=i),n!=null&&(a.correction=n),o!=null&&(a.comment=o),pe(t);let s=JSON.stringify(a);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){pe(t);let r=`/feedback/${t}`;return await this._get(r)}async deleteFeedback(t){pe(t);let r=`/feedback/${t}`;await this.caller.call(async()=>{let i=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,`delete ${r}`,!0),i})}async*listFeedback({runIds:t,feedbackKeys:r,feedbackSourceTypes:i}={}){let n=new URLSearchParams;if(t)for(let o of t)pe(o),n.append("run",o);if(r)for(let o of r)n.append("key",o);if(i)for(let o of i)n.append("source",o);for await(let o of this._getPaginated("/feedback",n))yield*o}async createPresignedFeedbackToken(t,r,{expiration:i,feedbackConfig:n}={}){let o={run_id:t,feedback_key:r,feedback_config:n};i?typeof i=="string"?o.expires_at=i:(i?.hours||i?.minutes||i?.days)&&(o.expires_in=i):o.expires_in={hours:3};let a=JSON.stringify(o);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:a});return await X(c,"create presigned feedback token"),c})).json()}async createComparativeExperiment({name:t,experimentIds:r,referenceDatasetId:i,createdAt:n,description:o,metadata:a,id:s}){if(r.length===0)throw new Error("At least one experiment is required");if(i||(i=(await this.readProject({projectId:r[0]})).reference_dataset_id),!i==null)throw new Error("A reference dataset is required");let c={id:s,name:t,experiment_ids:r,reference_dataset_id:i,description:o,created_at:(n??new Date)?.toISOString(),extra:{}};a&&(c.extra.metadata=a);let u=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:u});return await X(d,"create comparative experiment"),d})).json()}async*listPresignedFeedbackTokens(t){pe(t);let r=new URLSearchParams({run_id:t});for await(let i of this._getPaginated("/feedback/tokens",r))yield*i}_selectEvalResults(t){let r;return"results"in t?r=t.results:Array.isArray(t)?r=t:r=[t],r}async _logEvaluationFeedback(t,r,i,n){let o=this._selectEvalResults(t),a=[];for(let s of o){let c=i||{};s.evaluatorInfo&&(c={...s.evaluatorInfo,...c});let u=null;s.targetRunId?u=s.targetRunId:r&&(u=r.id),a.push(await this.createFeedback(u,s.key,{score:s.score,value:s.value,comment:s.comment,correction:s.correction,sourceInfo:c,sourceRunId:s.sourceRunId,feedbackConfig:s.feedbackConfig,feedbackSourceType:"model",sessionId:r?.session_id??n,startTime:r?.start_time,traceId:u===r?.id?r?.trace_id:void 0}))}return[o,a]}async logEvaluationFeedback(t,r,i,n){if(t!=null&&typeof t=="object"&&"evaluatorResponse"in t){let[a]=await this._logEvaluationFeedback(t.evaluatorResponse,t.run,t.sourceInfo,t.projectId);return a}let[o]=await this._logEvaluationFeedback(t,r,i,n);return o}async createFeedbackConfig(t){let{feedbackKey:r,feedbackConfig:i,isLowerScoreBetter:n=!1}=t,o={feedback_key:r,feedback_config:i,is_lower_score_better:n};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(o)});return await X(s,"create feedback config"),s})).json()}async*listFeedbackConfigs(t={}){let{feedbackKeys:r,nameContains:i,limit:n}=t,o=new URLSearchParams;r&&r.forEach(s=>{o.append("key",s)}),i&&o.append("name_contains",i),o.append("limit",(n!==void 0?Math.min(n,100):100).toString());let a=0;for await(let s of this._getPaginated("/feedback-configs",o))if(yield*s,a+=s.length,n!==void 0&&a>=n)break}async updateFeedbackConfig(t,r={}){let{feedbackConfig:i,isLowerScoreBetter:n}=r,o={feedback_key:t};return i!==void 0&&(o.feedback_config=i),n!==void 0&&(o.is_lower_score_better=n),(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(o)});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 i=await this._fetch(`${this.apiUrl}/feedback-configs?${r}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"delete feedback config",!0),i})}async*listAnnotationQueues(t={}){let{queueIds:r,name:i,nameContains:n,limit:o}=t,a=new URLSearchParams;r&&r.forEach((c,u)=>{pe(c,`queueIds[${u}]`),a.append("ids",c)}),i&&a.append("name",i),n&&a.append("name_contains",n),a.append("limit",(o!==void 0?Math.min(o,100):100).toString());let s=0;for await(let c of this._getPaginated("/annotation-queues",a))if(yield*c,s++,o!==void 0&&s>=o)break}async createAnnotationQueue(t){let{name:r,description:i,queueId:n,rubricInstructions:o,rubricItems:a}=t,s={name:r,description:i,id:n||Ka(),rubric_instructions:o,rubric_items:a},c=JSON.stringify(Object.fromEntries(Object.entries(s).filter(([l,d])=>d!==void 0)));return(await this.caller.call(async()=>{let l=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(l,"create annotation queue"),l})).json()}async readAnnotationQueue(t){return(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"read annotation queue"),i})).json()}async updateAnnotationQueue(t,r){let{name:i,description:n,rubricInstructions:o,rubricItems:a}=r,s={};i!==void 0&&(s.name=i),n!==void 0&&(s.description=n),o!==void 0&&(s.rubric_instructions=o),a!==void 0&&(s.rubric_items=a);let c=JSON.stringify(s);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await X(u,"update annotation queue",!0),u})}async deleteAnnotationQueue(t){await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(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 i=`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}/runs`,n=r.every(s=>typeof s=="string"),o,a;n?(Zt("Passing run IDs as strings to addRunsToAnnotationQueue() is deprecated and will be removed after Jan 31, 2027. Use RunKey[] instead. See https://docs.langchain.com/langsmith/smithdb-sdk-migration-feedback#annotation-queues-add-runs for the migration guide.",{type:"DeprecationWarning",code:"LANGSMITH_DEPRECATED_ADD_RUNS_STRING_IDS"}),o=i,a=JSON.stringify(r.map((s,c)=>pe(s,`runs[${c}]`).toString()))):(o=`${i}/by-key`,a=JSON.stringify(r.map((s,c)=>{let u={run_id:pe(s.runId,`runs[${c}].runId`).toString(),session_id:pe(s.sessionId,`runs[${c}].sessionId`).toString(),start_time:typeof s.startTime=="string"?s.startTime:new Date(s.startTime).toISOString()};return s.sourceProposedExampleId!=null&&(u.source_proposed_example_id=pe(s.sourceProposedExampleId,`runs[${c}].sourceProposedExampleId`).toString()),u}))),await this.caller.call(async()=>{let s=await this._fetch(o,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(s,"add runs to annotation queue",!0),s})}async getRunFromAnnotationQueue(t,r){let i=`/annotation-queues/${pe(t,"queueId")}/run`,o=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${i}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,"get run from annotation queue"),a})).json();return Kc(o)}async*listRunsFromAnnotationQueue(t,r={}){let{status:i,limit:n}=r,o=new URLSearchParams,a=n!==void 0&&Number.isFinite(n)?Math.min(n,100):100;i&&o.append("status",i),o.append("limit",a.toString());let s=0,c=`/annotation-queues/${pe(t,"queueId")}/runs`;for await(let u of this._getPaginated(c,o))for(let l of u)if(yield Kc(l),s++,s>=a)return}async deleteRunFromAnnotationQueue(t,r){await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}/runs/${pe(r,"queueRunId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"delete run from annotation queue",!0),i})}async getSizeFromAnnotationQueue(t){return(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(t,"queueId")}/size`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"get size from annotation queue"),i})).json()}async _currentTenantIsOwner(t){let r=await this._getSettings();return t=="-"||r.tenant_handle===t}async _ownerConflictError(t,r){let i=await this._getSettings();return new Error(`Cannot ${t} for another tenant.
151
+
152
+ Current tenant: ${i.tenant_handle}
153
+
154
+ Requested tenant: ${r}`)}async _getLatestCommitHash(t){let i=await(await this.caller.call(async()=>{let n=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(n,"get latest commit hash"),n})).json();if(i.commits.length!==0)return i.commits[0].commit_hash}async _createCommitTags(t,r,i){let n=typeof i=="string"?[i]:i;await Promise.all(n.map(async o=>this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/${t}/tags`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify({tag_name:o,commit_id:r})});return await X(a,"create commit tag"),a})))}async _likeOrUnlikePrompt(t,r){let[i,n,o]=cr(t),a=JSON.stringify({like:r});return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/likes/${i}/${n}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await X(c,`${r?"like":"unlike"} prompt`),c})).json()}async _getPromptUrl(t){let[r,i,n]=cr(t);if(await this._currentTenantIsOwner(r)){let o=await this._getSettings();return n!=="latest"?`${this.getHostUrl()}/prompts/${i}/${n.substring(0,8)}?organizationId=${o.id}`:`${this.getHostUrl()}/prompts/${i}?organizationId=${o.id}`}else return n!=="latest"?`${this.getHostUrl()}/hub/${r}/${i}/${n.substring(0,8)}`:`${this.getHostUrl()}/hub/${r}/${i}`}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,i,n]=cr(t);for await(let o of this._getPaginated(`/commits/${r}/${i}/`,new URLSearchParams,a=>a.commits))yield*o}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 i of this._getPaginated("/repos",r,n=>n.repos))yield*i}async getPrompt(t){let[r,i,n]=cr(t),a=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{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 a?.repo?a.repo:null}async createPrompt(t,r){let i=await this._getSettings();if(r?.isPublic&&!i.tenant_handle)throw new Error(`Cannot create a public prompt without first
155
+
156
+ creating a LangChain Hub handle.
157
+ You can add a handle by creating a public prompt at:
158
+
159
+ https://smith.langchain.com/prompts`);let[n,o,a]=cr(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError("create a prompt",n);let s={repo_handle:o,...r?.description&&{description:r.description},...r?.readme&&{readme:r.readme},...r?.tags&&{tags:r.tags},is_public:!!r?.isPublic},c=JSON.stringify(s),u=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:l}=await u.json();return l}async createCommit(t,r,i){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[n,o,a]=cr(t),s=i?.parentCommitHash==="latest"||!i?.parentCommitHash?await this._getLatestCommitHash(`${n}/${o}`):i?.parentCommitHash,c={manifest:JSON.parse(JSON.stringify(r)),parent_commit:s,...i?.description!==void 0&&{description:i.description}},u=JSON.stringify(c),d=await(await this.caller.call(async()=>{let p=await this._fetch(`${this.apiUrl}/commits/${n}/${o}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await X(p,"create commit"),p})).json(),f=d.commit??d;return i?.tags&&await this._createCommitTags(`${n}/${o}`,f.id,i.tags),this._getPromptUrl(`${n}/${o}${f.commit_hash?`:${f.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 i=new FormData;for(let a of r){let s=a.id,c={...a.metadata&&{metadata:a.metadata},...a.split&&{split:a.split}},u=ur(c,`Serializing body for example with id: ${s}`),l=new Blob([u],{type:"application/json"});if(i.append(s,l),a.inputs){let d=ur(a.inputs,`Serializing inputs for example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.inputs`,f)}if(a.outputs){let d=ur(a.outputs,`Serializing outputs whle updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.outputs`,f)}if(a.attachments)for(let[d,f]of Object.entries(a.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}`});i.append(`${s}.attachment.${d}`,h)}if(a.attachments_operations){let d=ur(a.attachments_operations,`Serializing attachments while updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.attachments_operations`,f)}}let n=t??r[0]?.dataset_id;return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${n}/examples`)}`,{method:"PATCH",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await X(a,"update examples"),a})).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 i=new FormData;for(let o of r){let a=(o.id??Ka()).toString(),s={created_at:o.created_at,...o.metadata&&{metadata:o.metadata},...o.split&&{split:o.split},...o.source_run_id&&{source_run_id:o.source_run_id},...o.use_source_run_io&&{use_source_run_io:o.use_source_run_io},...o.use_source_run_attachments&&{use_source_run_attachments:o.use_source_run_attachments}},c=ur(s,`Serializing body for uploaded example with id: ${a}`),u=new Blob([c],{type:"application/json"});if(i.append(a,u),o.inputs){let l=ur(o.inputs,`Serializing inputs for uploaded example with id: ${a}`),d=new Blob([l],{type:"application/json"});i.append(`${a}.inputs`,d)}if(o.outputs){let l=ur(o.outputs,`Serializing outputs for uploaded example with id: ${a}`),d=new Blob([l],{type:"application/json"});i.append(`${a}.outputs`,d)}if(o.attachments)for(let[l,d]of Object.entries(o.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}`});i.append(`${a}.attachment.${l}`,m)}}return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${t}/examples`)}`,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await X(o,"upload examples"),o})).json()}async updatePrompt(t,r){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[i,n]=cr(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError("update a prompt",i);let o={};if(r?.description!==void 0&&(o.description=r.description),r?.readme!==void 0&&(o.readme=r.readme),r?.tags!==void 0&&(o.tags=r.tags),r?.isPublic!==void 0&&(o.is_public=r.isPublic),r?.isArchived!==void 0&&(o.is_archived=r.isArchived),Object.keys(o).length===0)throw new Error("No valid update options provided");let a=JSON.stringify(o);return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/repos/${i}/${n}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});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,i,n]=cr(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete a prompt",r);return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(a,"delete prompt"),a})).json()}_getPromptCacheKey(t,r){return`${t}${r?":with_model":""}`}async _fetchPromptFromApi(t,r){let[i,n,o]=cr(t),s=await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/commits/${i}/${n}/${o}${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:i,repo:n,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){iB(t,r?.dangerouslyPullPublicPrompt);let i=this._fetchPromptFromApi.bind(this,t,r);if(!r?.skipCache&&this._promptCache){let n=this._getPromptCacheKey(t,r?.includeModel),o=this._promptCache.get(n,i);if(o)return o;let a=await i();return this._promptCache.set(n,a,i),a}return this._fetchPromptFromApi(t,r)}async _pullPrompt(t,r){let i=await this.pullPromptCommit(t,{includeModel:r?.includeModel,skipCache:r?.skipCache,dangerouslyPullPublicPrompt:r?.dangerouslyPullPublicPrompt});return JSON.stringify(i.manifest)}async pushPrompt(t,r){return await this.promptExists(t)?r&&["description","readme","tags","isPublic"].some(n=>r[n]!==void 0)&&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,tags:r?.commitTags,description:r?.commitDescription}):await this._getPromptUrl(t)}async agentExists(t){let[r,i]=cr(t);return this._repoExists(r,i)}async skillExists(t){let[r,i]=cr(t);return this._repoExists(r,i)}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 i=new URLSearchParams;i.append("repo_type",t),i.append("is_archived",(!!r?.isArchived).toString()),r?.isPublic!==void 0&&i.append("is_public",r.isPublic.toString()),r?.query&&i.append("query",r.query);for await(let n of this._getPaginated("/repos",i,o=>o.repos))yield*n}async _pullDirectory(t,r,i){let[n,o,a]=cr(t),s=i??(a!=="latest"?a:void 0),c=new URL(`${this.apiUrl}${this._getPlatformEndpointPath(`hub/repos/${n}/${o}/directories`)}`);return c.searchParams.set("repo_type",r),s&&c.searchParams.set("commit",s),await(await this.caller.call(async()=>{let l=await this._fetch(c.toString(),{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(l,"pull directory"),l})).json()}async _pushDirectory(t,r,i){if(i.parentCommit!==void 0&&(i.parentCommit.length<8||i.parentCommit.length>64))throw new Error("parent_commit must be 8-64 characters");let[n,o]=cr(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError(`push ${r}`,n);if(await this._repoExists(n,o))(i.description!==void 0||i.readme!==void 0||i.tags!==void 0||i.isPublic!==void 0)&&await this._updateRepoMetadata(n,o,i);else{let f=/^[a-z][a-z0-9-_]*$/;if(!f.test(o))throw new Error(`Invalid repo_handle ${JSON.stringify(o)}: must match ${f}`);await this._createRepo(o,r,i)}let a={files:i.files};i.parentCommit&&(a.parent_commit=i.parentCommit);let u=(await(await this.caller.call(async()=>{let f=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`hub/repos/${n}/${o}/directories/commits`)}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await X(f,`push ${r}`),f})).json()).commit.commit_hash,l=await this._getSettings(),d=new URLSearchParams({organizationId:l.id});return`${this.getHostUrl()}/context/${o}/${u.slice(0,8)}?${d.toString()}`}async _deleteDirectory(t){let[r,i]=cr(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete",r);await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`hub/repos/${r}/${i}/directories`)}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(n,"delete directory"),n})}async _repoExists(t,r){try{return await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await X(i,"check repo exists"),i}),!0}catch(i){if(ym(i))return!1;throw i}}async _createRepo(t,r,i){let n={repo_handle:t,repo_type:r,is_public:!!i.isPublic};i.description!==void 0&&(n.description=i.description),i.readme!==void 0&&(n.readme=i.readme),i.tags!==void 0&&(n.tags=i.tags);try{await this.caller.call(async()=>{let o=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(n)});return await X(o,`create ${r}`),o})}catch(o){if(HO(o))return;throw o}}async _updateRepoMetadata(t,r,i){let n={};i.description!==void 0&&(n.description=i.description),i.readme!==void 0&&(n.readme=i.readme),i.tags!==void 0&&(n.tags=i.tags),i.isPublic!==void 0&&(n.is_public=i.isPublic),Object.keys(n).length!==0&&await this.caller.call(async()=>{let o=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(n)});return await X(o,"update repo metadata"),o})}async clonePublicDataset(t,r={}){let{sourceApiUrl:i=this.apiUrl,datasetName:n}=r,[o,a]=this.parseTokenOrUrl(t,i),s=new e({apiUrl:o,apiKey:"placeholder"}),c=await s.readSharedDataset(a),u=n||c.name;try{if(await this.hasDataset({datasetId:u})){console.log(`Dataset ${u} already exists in your tenant. Skipping.`);return}}catch{}let l=await s.listSharedExamples(a),d=await this.createDataset(u,{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:l.map(f=>f.inputs),outputs:l.flatMap(f=>f.outputs?[f.outputs]:[]),datasetId:d.id})}catch(f){throw console.error(`An error occurred while creating dataset ${u}. You should delete it manually.`),f}}parseTokenOrUrl(t,r,i=2,n="dataset"){try{return pe(t),[r,t]}catch{}try{let a=new URL(t).pathname.split("/").filter(s=>s!=="");if(a.length>=i){let s=a[a.length-i];return[r,s]}else throw new Error(`Invalid public ${n} URL: ${t}`)}catch{throw new Error(`Invalid public ${n} 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 eO()?.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(fi,"_fallbackDirsCreated",{enumerable:!0,configurable:!0,writable:!0,value:new Set});function fP(e){return"dataset_id"in e||"dataset_name"in e}var yi=Symbol.for("lc:context_variables");var Sm=Symbol.for("langsmith:replica_trace_roots");function _b(e,t){if(yi in e)return e[yi][t]}function hP(e,t,r){let i=yi in e?e[yi]:{};i[t]=r,e[yi]=i}var Zl=36,mB="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function gP(e){let r=Object.keys(e).sort().map(i=>`${i}:${e[i]??""}`).join("|");return cv(r,mB)}function hB(e){return e.replace(/[-:.]/g,"")}function yP(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 yb(e,t,r=1){let i=yP(e,r);return{dottedOrder:hB(i)+t,microsecondPrecisionDatestring:i}}var gB=new Set(["projectName","primary","updates","reroot"]);function _B(e){let t={};for(let r of Object.keys(e))r==="primary"&&typeof e[r]!="boolean"||gB.has(r)&&(t[r]=e[r]);return t}var km=class e{constructor(t,r,i,n){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=i,this.replicas=n}static fromHeader(t){let r=t.split(","),i={},n=[],o,a;for(let s of r){let[c,u]=s.split("="),l=decodeURIComponent(u);c==="langsmith-metadata"?i=JSON.parse(l):c==="langsmith-tags"?n=l.split(","):c==="langsmith-project"?o=l:c==="langsmith-replicas"&&(a=JSON.parse(l).map(f=>Array.isArray(f)?f:_B(f)))}return new e(i,n,o,a)}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(",")}};function yB(){let e=Ye("EXCLUDE_INPUTS_ON_PATCH");return e===void 0||e.toLowerCase()==="true"||e==="1"}var zn=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}),vP(t)){Object.assign(this,{...t});return}let r=e.getDefaultConfig(),{metadata:i,...n}=t,o=n.client??e.getSharedClient(),a={...i,...n?.extra?.metadata};if(n.extra={...n.extra,metadata:a},"id"in n&&n.id==null&&delete n.id,Object.assign(this,{...r,...n,client:o}),this.execution_order??=1,this.child_execution_order??=1,this.dotted_order||(this._serialized_start_time=yP(this.start_time,this.execution_order)),this.id||(this.id=Bp(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=xB(this.replicas),!this.dotted_order){let{dottedOrder:s}=yb(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:jl(),child_runs:[],api_url:Ht("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:Ht("LANGCHAIN_API_KEY"),caller_options:{},start_time:t,serialized:{},inputs:{},extra:{}}}static getSharedClient(){return e.sharedClient||(e.sharedClient=new fi),e.sharedClient}createChild(t){let r=this.child_execution_order+1,i=this.replicas?.map(f=>{let{reroot:p,...m}=f;return m}),n=t.replicas??i,o=new e({...t,parent_run:this,project_name:this.project_name,replicas:n,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:r,child_execution_order:r}),a=this.extra?.metadata??{},s=o.extra?.metadata??{};Object.keys(a).length>0&&(o.extra={...o.extra,metadata:{...a,...s}}),yi in this&&(o[yi]=this[yi]);let c=Symbol.for("lc:child_config"),u=t.extra?.[c]??this.extra[c];if(bB(u)){let f={...u},p=vB(f.callbacks)?f.callbacks.copy?.():void 0;p&&(Object.assign(p,{_parentRunId:o.id}),p.handlers?.find(bP)?.updateFromRunTree?.(o),f.callbacks=p),o.extra[c]=f}let l=new Set,d=this;for(;d!=null&&!l.has(d.id);)l.add(d.id),d.child_execution_order=Math.max(d.child_execution_order,r),d=d.parent_run;return this.child_runs.push(o),o}async end(t,r,i=Date.now(),n){this.outputs=this.outputs??t,this.error=this.error??r,this.end_time=this.end_time??i,n&&Object.keys(n).length>0&&(this.extra=this.extra?{...this.extra,metadata:{...this.extra.metadata,...n}}:{metadata:n})}_convertToCreate(t,r,i=!0){let n=t.extra??{};if(n?.runtime?.library===void 0&&(n.runtime||(n.runtime={}),r))for(let[s,c]of Object.entries(r))n.runtime[s]||(n.runtime[s]=c);let o=t.parent_run?.id??t.parent_run_id,a;return i?a=[]:a=t.child_runs.map(s=>this._convertToCreate(s,r,i)),{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:n,serialized:t.serialized,error:t.error,inputs:t.inputs,outputs:t.outputs,session_name:t.project_name,child_runs:a,parent_run_id:o,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 i=r.dotted_order.split("."),n=null;for(let o=0;o<i.length;o++)if(i[o].slice(-Zl)===t){n=o;break}if(n!==null){let o=i.slice(n+1);r.dotted_order=o.join("."),o.length>0?r.trace_id=o[0].slice(-Zl):r.trace_id=r.id}}r.parent_run_id===t&&(r.parent_run_id=void 0)}_setReplicaTraceRoot(t,r){let i=_b(this,Sm)??{};i[t]=r,hP(this,Sm,i);for(let n of this.child_runs)n._setReplicaTraceRoot(t,r)}_remapForProject(t){let{projectName:r,primary:i,runtimeEnv:n,excludeChildRuns:o=!0,reroot:a=!1,distributedParentId:s,apiUrl:c,apiKey:u,workspaceId:l}=t,d=this._convertToCreate(this,n,o);if(i===void 0&&r===this.project_name)return{...d,session_name:r};if(a){if(s)this._sliceParentId(s,d);else if(d.parent_run_id=void 0,d.dotted_order){let x=d.dotted_order.split(".");x.length>0&&(d.dotted_order=x[x.length-1],d.trace_id=d.id)}let v=gP({projectName:r,apiUrl:c,apiKey:u,workspaceId:l});this._setReplicaTraceRoot(v,d.id)}let f;if(!a){let v=_b(this,Sm)??{},x=gP({projectName:r,apiUrl:c,apiKey:u,workspaceId:l});if(f=v[x],f&&(d.trace_id=f,d.dotted_order)){let S=d.dotted_order.split("."),k=null;for(let T=0;T<S.length;T++)if(S[T].slice(-Zl)===f){k=T;break}if(k!==null){let T=S.slice(k);d.dotted_order=T.join(".")}}}if(i)return{...d,session_name:r};let p=d.id,m=Nc(p,r),h;d.trace_id?h=Nc(d.trace_id,r):h=m;let g;d.parent_run_id&&(g=Nc(d.parent_run_id,r));let _;return d.dotted_order&&(_=d.dotted_order.split(".").map(S=>{let k=S.slice(-Zl),T=Nc(k,r);return S.slice(0,-Zl)+T}).join(".")),{...d,id:m,trace_id:h,parent_run_id:g,dotted_order:_,session_name:r}}async postRun(t=!0){this._awaitInputsOnPost&&(this.inputs=await this.inputs);try{let r=Wp();if(this.replicas&&this.replicas.length>0)for(let{projectName:i,primary:n,apiKey:o,apiUrl:a,workspaceId:s,reroot:c,client:u}of this.replicas){let l=this._remapForProject({projectName:i??this.project_name,primary:n,runtimeEnv:r,excludeChildRuns:!0,reroot:c,distributedParentId:this.distributedParentId,apiUrl:a,apiKey:o,workspaceId:s});await(u??this.client).createRun(l,{apiKey:o,apiUrl:a,workspaceId:s})}else{let i=this._convertToCreate(this,r,t);await this.client.createRun(i)}if(!t){Zt("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(let i of this.child_runs)await i.postRun(!1)}this.child_runs=[]}catch(r){console.error(`Error in postRun for run ${this.id}:`,r)}}async patchRun(t){let r=t?.excludeInputs??yB();if(this.replicas&&this.replicas.length>0)for(let{projectName:i,primary:n,apiKey:o,apiUrl:a,workspaceId:s,updates:c,reroot:u,client:l}of this.replicas){let d=this._remapForProject({projectName:i??this.project_name,primary:n,runtimeEnv:void 0,excludeChildRuns:!0,reroot:u,distributedParentId:this.distributedParentId,apiUrl:a,apiKey:o,workspaceId:s}),f={id:d.id,name:d.name,run_type:d.run_type,start_time:d.start_time,outputs:d.outputs,error:d.error,parent_run_id:d.parent_run_id,session_name:d.session_name,reference_example_id:d.reference_example_id,end_time:d.end_time,dotted_order:d.dotted_order,trace_id:d.trace_id,events:d.events,tags:d.tags,extra:d.extra,attachments:this.attachments,...c};r||(f.inputs=d.inputs),await(l??this.client).updateRun(d.id,f,{apiKey:o,apiUrl:a,workspaceId:s})}else try{let i={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};r||(i.inputs=this.inputs),await this.client.updateRun(this.id,i)}catch(i){console.error(`Error in patchRun for run ${this.id}`,i)}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 i=t?.callbacks,n,o,a,s=bv();if(i){let u=i?.getParentRunId?.()??"",l=i?.handlers?.find(d=>d?.name=="langchain_tracer");n=l?.getRun?.(u),o=l?.projectName,a=l?.client,s=s||!!l}return n?new e({name:n.name,id:n.id,trace_id:n.trace_id,dotted_order:n.dotted_order,client:a,tracingEnabled:s,project_name:o,tags:[...new Set((n?.tags??[]).concat(t?.tags??[]))],extra:{metadata:{...n?.extra?.metadata,...t?.metadata}}}).createChild(r):new e({...r,client:a,tracingEnabled:s,project_name:o})}static fromDottedOrder(t){return this.fromHeaders({"langsmith-trace":t})}static fromHeaders(t,r){let i="get"in t&&typeof t.get=="function"?{"langsmith-trace":t.get("langsmith-trace"),baggage:t.get("baggage")}:t,n=i["langsmith-trace"];if(!n||typeof n!="string")return;let o=n.trim(),a=o.split(".").map(l=>{let[d,f]=l.split("Z");return{strTime:d,time:Date.parse(d+"Z"),uuid:f}}),s=a[0].uuid,c={...r,name:r?.name??"parent",run_type:r?.run_type??"chain",start_time:r?.start_time??Date.now(),id:a.at(-1)?.uuid,trace_id:s,dotted_order:o};if(i.baggage&&typeof i.baggage=="string"){let l=km.fromHeader(i.baggage);c.metadata=l.metadata,c.tags=l.tags,c.project_name=l.project_name,c.replicas=l.replicas}let u=new e(c);return u.distributedParentId=u.id,u}toHeaders(t){let r={"langsmith-trace":this.dotted_order,baggage:new km(this.extra?.metadata,this.tags,this.project_name,this.replicas).toHeader()};if(t)for(let[i,n]of Object.entries(r))t.set(i,n);return r}};Object.defineProperty(zn,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function vP(e){return e!=null&&typeof e.createChild=="function"&&typeof e.postRun=="function"}function bP(e){return typeof e=="object"&&e!=null&&typeof e.name=="string"&&e.name==="langchain_tracer"}function _P(e){return Array.isArray(e)&&e.some(t=>bP(t))}function vB(e){return typeof e=="object"&&e!=null&&Array.isArray(e.handlers)}function bB(e){let t=e?.callbacks;return e!=null&&typeof t=="object"&&(_P(t?.handlers)||_P(t))}function wB(){let e=Ht("LANGSMITH_RUNS_ENDPOINTS");if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){let r=[];for(let i of t){if(typeof i!="object"||i===null){console.warn(`Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got ${typeof i}`);continue}if(typeof i.api_url!="string"){console.warn(`Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof i.api_url}`);continue}if(typeof i.api_key!="string"){console.warn(`Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof i.api_key}`);continue}if(i.project_name!==void 0&&i.project_name!==null&&typeof i.project_name!="string"){console.warn(`Invalid project_name type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof i.project_name}`);continue}if(i.primary!==void 0&&typeof i.primary!="boolean"){console.warn(`Invalid primary type in LANGSMITH_RUNS_ENDPOINTS: expected boolean, got ${typeof i.primary}`);continue}r.push({apiUrl:i.api_url.replace(/\/$/,""),apiKey:i.api_key,projectName:i.project_name??void 0,primary:i.primary??void 0})}return r}else if(typeof t=="object"&&t!==null){SB(t);let r=[];for(let[i,n]of Object.entries(t)){let o=i.replace(/\/$/,"");if(typeof n=="string")r.push({apiUrl:o,apiKey:n});else{console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${i}: expected string, got ${typeof n}`);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(GO(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 xB(e){let t=e?e.map(r=>Array.isArray(r)?{projectName:r[0],updates:r[1]}:r):wB();if(t.filter(r=>r.primary===!0).length>1)throw new Error("Only one replica can be marked as primary.");return t}function SB(e){if(Object.keys(e).length>0&&Ye("ENDPOINT"))throw new gm}var wP=C({BaseTracer:()=>Yt,isBaseTracer:()=>fs}),kB=e=>{if(e)return e.events=e.events??[],e.child_runs=e.child_runs??[],e};function bb(e,t){if(e)return new zn({...e,start_time:e._serialized_start_time??e.start_time,parent_run:bb(t),child_runs:e.child_runs.map(r=>bb(r)).filter(r=>r!==void 0),extra:{...e.extra,runtime:Hy()},tracingEnabled:!1})}function vb(e,t){return e&&!Array.isArray(e)&&typeof e=="object"?e:{[t]:e}}function fs(e){return typeof e._addRunToRunMap=="function"}var Yt=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?kB(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`
160
+
161
+ ${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){let{dottedOrder:t,microsecondPrecisionDatestring:r}=yb(new Date(e.start_time).getTime(),e.id,e.execution_order),i={...e},n=this.getRunById(i.parent_run_id);if(i.parent_run_id!==void 0?n?(this._addChildRun(n,i),n.child_execution_order=Math.max(n.child_execution_order,i.child_execution_order),i.trace_id=n.trace_id,n.dotted_order!==void 0&&(i.dotted_order=[n.dotted_order,t].join("."),i._serialized_start_time=r)):i.parent_run_id=void 0:(i.trace_id=i.id,i.dotted_order=t,i._serialized_start_time=r),this.usesRunTreeMap){let o=bb(i,n);o!==void 0&&this.runTreeMap.set(i.id,o)}else this.runMap.set(i.id,i);return i}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,i,n,o,a,s){let c=this._getExecutionOrder(i),u=Date.now(),l=a?{...n,metadata:a}:n,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:{prompts:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:l??{},tags:o||[]};return this._addRunToRunMap(d)}async handleLLMStart(e,t,r,i,n,o,a,s){let c=this.getRunById(r)??this._createRunForLLMStart(e,t,r,i,n,o,a,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}_createRunForChatModelStart(e,t,r,i,n,o,a,s){let c=this._getExecutionOrder(i),u=Date.now(),l=a?{...n,metadata:a}:n,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:{messages:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:l??{},tags:o||[]};return this._addRunToRunMap(d)}async handleChatModelStart(e,t,r,i,n,o,a,s){let c=this.getRunById(r)??this._createRunForChatModelStart(e,t,r,i,n,o,a,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}async handleLLMEnd(e,t,r,i,n){let o=this.getRunById(t);if(!o||o?.run_type!=="llm")throw new Error("No LLM run to end.");return o.end_time=Date.now(),o.outputs=e,o.events.push({name:"end",time:new Date(o.end_time).toISOString()}),o.extra={...o.extra,...n},await this.onLLMEnd?.(o),await this._endTrace(o),o}async handleLLMError(e,t,r,i,n){let o=this.getRunById(t);if(!o||o?.run_type!=="llm")throw new Error("No LLM run to end.");return o.end_time=Date.now(),o.error=this.stringifyError(e),o.events.push({name:"error",time:new Date(o.end_time).toISOString()}),o.extra={...o.extra,...n},await this.onLLMError?.(o),await this._endTrace(o),o}_createRunForChainStart(e,t,r,i,n,o,a,s,c){let u=this._getExecutionOrder(i),l=Date.now(),d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:t,execution_order:u,child_execution_order:u,run_type:a??"chain",child_runs:[],extra:o?{...c,metadata:o}:{...c},tags:n||[]};return this._addRunToRunMap(d)}async handleChainStart(e,t,r,i,n,o,a,s){let c=this.getRunById(r)??this._createRunForChainStart(e,t,r,i,n,o,a,s);return await this.onRunCreate?.(c),await this.onChainStart?.(c),c}async handleChainEnd(e,t,r,i,n){let o=this.getRunById(t);if(!o)throw new Error("No chain run to end.");return o.end_time=Date.now(),o.outputs=vb(e,"output"),o.events.push({name:"end",time:new Date(o.end_time).toISOString()}),n?.inputs!==void 0&&(o.inputs=vb(n.inputs,"input")),await this.onChainEnd?.(o),await this._endTrace(o),o}async handleChainError(e,t,r,i,n){let o=this.getRunById(t);if(!o)throw new Error("No chain run to end.");return o.end_time=Date.now(),o.error=this.stringifyError(e),o.events.push({name:"error",time:new Date(o.end_time).toISOString()}),n?.inputs!==void 0&&(o.inputs=vb(n.inputs,"input")),await this.onChainError?.(o),await this._endTrace(o),o}_createRunForToolStart(e,t,r,i,n,o,a){let s=this._getExecutionOrder(i),c=Date.now(),u={id:r,name:a??e.id[e.id.length-1],parent_run_id:i,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:o?{metadata:o}:{},tags:n||[]};return this._addRunToRunMap(u)}async handleToolStart(e,t,r,i,n,o,a){let s=this.getRunById(r)??this._createRunForToolStart(e,t,r,i,n,o,a);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 i=r;i.actions=i.actions||[],i.actions.push(e),i.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,i,n,o,a){let s=this._getExecutionOrder(i),c=Date.now(),u={id:r,name:a??e.id[e.id.length-1],parent_run_id:i,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:o?{metadata:o}:{},tags:n||[]};return this._addRunToRunMap(u)}async handleRetrieverStart(e,t,r,i,n,o,a){let s=this.getRunById(r)??this._createRunForRetrieverStart(e,t,r,i,n,o,a);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,i,n,o){let a=this.getRunById(r);if(!a||a?.run_type!=="llm")throw new Error('Invalid "runId" provided to "handleLLMNewToken" callback.');return a.events.push({name:"new_token",time:new Date().toISOString(),kwargs:{token:e,idx:t,chunk:o?.chunk}}),await this.onLLMNewToken?.(a,e,{chunk:o?.chunk}),a}};var SP=C({ConsoleCallbackHandler:()=>$m}),kP={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 Ir(e,t){return`${e.open}${t}${e.close}`}function gn(e,t){try{return JSON.stringify(e,null,2)}catch{return t}}function xP(e){return typeof e=="string"?e.trim():e==null?e:gn(e,e.toString())}function Go(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:zr}=kP,$m=class extends Yt{name="console_callback_handler";persistRun(e){return Promise.resolve()}getParents(e){let t=[],r=e;for(;r.parent_run_id;){let i=this.runMap.get(r.parent_run_id);if(i)t.push(i),r=i;else break}return t}getBreadcrumbs(e){let t=[...this.getParents(e).reverse(),e].map((r,i,n)=>{let o=`${r.execution_order}:${r.run_type}:${r.name}`;return i===n.length-1?Ir(kP.bold,o):o}).join(" > ");return Ir(zr.grey,t)}onChainStart(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.green,"[chain/start]")} [${t}] Entering Chain run with input: ${gn(e.inputs,"[inputs]")}`)}onChainEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.cyan,"[chain/end]")} [${t}] [${Go(e)}] Exiting Chain run with output: ${gn(e.outputs,"[outputs]")}`)}onChainError(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.red,"[chain/error]")} [${t}] [${Go(e)}] Chain run errored with error: ${gn(e.error,"[error]")}`)}onLLMStart(e){let t=this.getBreadcrumbs(e),r="prompts"in e.inputs?{prompts:e.inputs.prompts.map(i=>i.trim())}:e.inputs;console.log(`${Ir(zr.green,"[llm/start]")} [${t}] Entering LLM run with input: ${gn(r,"[inputs]")}`)}onLLMEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.cyan,"[llm/end]")} [${t}] [${Go(e)}] Exiting LLM run with output: ${gn(e.outputs,"[response]")}`)}onLLMError(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.red,"[llm/error]")} [${t}] [${Go(e)}] LLM run errored with error: ${gn(e.error,"[error]")}`)}onToolStart(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.green,"[tool/start]")} [${t}] Entering Tool run with input: "${xP(e.inputs.input)}"`)}onToolEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.cyan,"[tool/end]")} [${t}] [${Go(e)}] Exiting Tool run with output: "${xP(e.outputs?.output)}"`)}onToolError(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.red,"[tool/error]")} [${t}] [${Go(e)}] Tool run errored with error: ${gn(e.error,"[error]")}`)}onRetrieverStart(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${gn(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.cyan,"[retriever/end]")} [${t}] [${Go(e)}] Exiting Retriever run with output: ${gn(e.outputs,"[outputs]")}`)}onRetrieverError(e){let t=this.getBreadcrumbs(e);console.log(`${Ir(zr.red,"[retriever/error]")} [${t}] [${Go(e)}] Retriever run errored with error: ${gn(e.error,"[error]")}`)}onAgentAction(e){let t=e,r=this.getBreadcrumbs(e);console.log(`${Ir(zr.blue,"[agent/action]")} [${r}] Agent selected action: ${gn(t.actions[t.actions.length-1],"[action]")}`)}};var wb,Im=()=>{if(wb===void 0){let e=Ot("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"?{blockOnRootRunFinalization:!0}:{};wb=new fi(e)}return wb};var IP=C({LangChainTracer:()=>Ko,OVERRIDABLE_LANGSMITH_INHERITABLE_METADATA_KEYS:()=>Sb}),Sb=new Set(["ls_agent_type"]);function $B(e){let t;for(let r of e)for(let i of r)Le.isInstance(i.message)&&i.message.usage_metadata!==void 0&&(t=kc(t,i.message.usage_metadata));return t}var Ko=class xb extends Yt{fields;name="langchain_tracer";projectName;exampleId;client;replicas;usesRunTreeMap=!0;tracingMetadata;tracingTags=[];constructor(t={}){super(t),this.fields=t;let{exampleId:r,projectName:i,client:n,replicas:o,metadata:a,tags:s}=t;this.projectName=i??jl(),this.replicas=o,this.exampleId=r,this.client=n??Im(),this.tracingMetadata=a?{...a}:void 0,this.tracingTags=s??[];let c=xb.getTraceableRunTree();c&&this.updateFromRunTree(c)}async persistRun(t){}async onRunCreate(t){$P(this,t),t.extra?.lc_defers_inputs||await this.getRunTreeWithTracingConfig(t.id)?.postRun()}async onRunUpdate(t){$P(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 i=$B(r.generations);if(i!==void 0){t.extra=t.extra??{};let n=t.extra.metadata??{};n.usage_metadata=i,t.extra.metadata=n}}}copyWithTracingConfig({metadata:t,tags:r}){let i;if(t===void 0)i=this.tracingMetadata?{...this.tracingMetadata}:void 0;else if(this.tracingMetadata===void 0)i={...t};else{i={...this.tracingMetadata};for(let[a,s]of Object.entries(t))(!Object.prototype.hasOwnProperty.call(i,a)||Sb.has(a))&&(i[a]=s)}let n=r?Array.from(new Set([...this.tracingTags,...r])):[...this.tracingTags],o=new xb({...this.fields,metadata:i,tags:n});return o.runMap=this.runMap,o.runTreeMap=this.runTreeMap,o}_getRunStoreKey(){return this.runTreeMap}getRun(t){return this.runTreeMap.get(t)}updateFromRunTree(t){this.runTreeMap.set(t.id,t);let r=t,i=new Set;for(;r.parent_run&&!(i.has(r.id)||(i.add(r.id),!r.parent_run));)r=r.parent_run;i.clear();let n=[r];for(;n.length>0;){let o=n.shift();!o||i.has(o.id)||(i.add(o.id),this.runTreeMap.set(o.id,o),o.child_runs&&n.push(...o.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 zn({...r,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return kv(!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 $P(e,t){if(e.tracingMetadata){t.extra??={};let r=t.extra.metadata??{},i=!1;for(let[n,o]of Object.entries(e.tracingMetadata))(!Object.prototype.hasOwnProperty.call(r,n)||Sb.has(n))&&r[n]!==o&&(r[n]=o,i=!0);i&&(t.extra.metadata=r)}e.tracingTags.length>0&&(t.tags=Array.from(new Set([...t.tags??[],...e.tracingTags])))}var EP=Symbol.for("ls:tracing_async_local_storage"),Wo=Symbol.for("lc:context_variables"),TP=e=>{globalThis[EP]=e},qo=()=>globalThis[EP];var Em=tp(nm(),1),ps;function IB(){return new("default"in Em.default?Em.default.default:Em.default)({autoStart:!0,concurrency:1})}function EB(){return typeof ps>"u"&&(ps=IB()),ps}async function dt(e,t){if(t===!0){let r=qo();r!==void 0?await r.run(void 0,async()=>e()):await e()}else ps=EB(),ps.add(async()=>{let r=qo();r!==void 0?await r.run(void 0,async()=>e()):await e()})}async function AP(){let e=Im();await Promise.allSettled([typeof ps<"u"?ps.onIdle():Promise.resolve(),e.awaitPendingTraceBatches()])}var CP=C({awaitAllCallbacks:()=>AP,consumeCallback:()=>dt});var OP=e=>e!==void 0?e:!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>Ot(t)==="true");function kb(e){let t=qo();if(t!==void 0)return t.getStore()?.[Wo]?.[e]}var TB=Symbol("lc:configure_hooks"),PP=()=>kb(TB)||[];var NP=C({BaseCallbackManager:()=>RP,BaseRunManager:()=>Kl,CallbackManager:()=>at,CallbackManagerForChainRun:()=>DP,CallbackManagerForLLMRun:()=>Ib,CallbackManagerForRetrieverRun:()=>jP,CallbackManagerForToolRun:()=>MP,ensureHandler:()=>Ji,parseCallbackConfigArg:()=>ms});function $b(e){return e._getRunStoreKey?.()??e}function AB(e,t){return e===t?e:e.copyWithTracingConfig({metadata:t.tracingMetadata,tags:t.tracingTags})}function CB(e,t){let r=new Set(t),i=new Map,n=[],o=s=>{let c=$b(s),u=r.has(s),l=i.get(c);if(l===void 0){i.set(c,{index:n.length,tracer:s,hasInheritable:u}),n.push(s);return}u&&!l.hasInheritable?(l.tracer=s,l.hasInheritable=!0):(u||!l.hasInheritable)&&(l.tracer=AB(l.tracer,s)),n[l.index]=l.tracer};for(let s of e)s instanceof Ko?o(s):n.push(s);for(let s of t)s instanceof Ko&&!i.has($b(s))&&o(s);let a=new Set;return{handlers:n,inheritableHandlers:t.flatMap(s=>{if(!(s instanceof Ko))return[s];let c=$b(s);return a.has(c)?[]:(a.add(c),[i.get(c)?.tracer??s])})}}function ms(e){return e?Array.isArray(e)||"name"in e?{callbacks:e}:e:{}}var RP=class{setHandler(e){return this.setHandlers([e])}},Kl=class{runId;handlers;inheritableHandlers;tags;inheritableTags;metadata;inheritableMetadata;_parentRunId;constructor(e,t,r,i,n,o,a,s){this.runId=e,this.handlers=t,this.inheritableHandlers=r,this.tags=i,this.inheritableTags=n,this.metadata=o,this.inheritableMetadata=a,this._parentRunId=s}get parentRunId(){return this._parentRunId}async handleText(e){await Promise.all(this.handlers.map(t=>dt(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,i,n){await Promise.all(this.handlers.map(o=>dt(async()=>{try{await o.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleCustomEvent: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}},jP=class extends Kl{getChild(e){let t=new at(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=>dt(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=>dt(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)))}},Ib=class extends Kl{async handleLLMNewToken(e,t,r,i,n,o){await Promise.all(this.handlers.map(a=>dt(async()=>{if(!a.ignoreLLM)try{await a.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,o)}catch(s){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMNewToken: ${s}`),a.raiseError)throw s}},a.awaitHandlers)))}async handleChatModelStreamEvent(e){await Promise.all(this.handlers.map(t=>dt(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,i,n){await Promise.all(this.handlers.map(o=>dt(async()=>{if(!o.ignoreLLM)try{await o.handleLLMError?.(e,this.runId,this._parentRunId,this.tags,n)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMError: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}async handleLLMEnd(e,t,r,i,n){await Promise.all(this.handlers.map(o=>dt(async()=>{if(!o.ignoreLLM)try{await o.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags,n)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMEnd: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}},DP=class extends Kl{getChild(e){let t=new at(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,i,n){await Promise.all(this.handlers.map(o=>dt(async()=>{if(!o.ignoreChain)try{await o.handleChainError?.(e,this.runId,this._parentRunId,this.tags,n)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleChainError: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}async handleChainEnd(e,t,r,i,n){await Promise.all(this.handlers.map(o=>dt(async()=>{if(!o.ignoreChain)try{await o.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,n)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleChainEnd: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}async handleAgentAction(e){await Promise.all(this.handlers.map(t=>dt(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=>dt(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)))}},MP=class extends Kl{getChild(e){let t=new at(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=>dt(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=>dt(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=>dt(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)))}},at=class Gl extends RP{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,i=void 0,n=void 0,o=void 0,a=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(u,l)=>{let d=l===0&&i?i:mn();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return fs(f)&&f._createRunForLLMStart(t,[u],d,this._parentRunId,o,this.tags,this.metadata,c),dt(async()=>{try{await f.handleLLMStart?.(t,[u],d,this._parentRunId,o,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 Ib(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChatModelStart(t,r,i=void 0,n=void 0,o=void 0,a=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(u,l)=>{let d=l===0&&i?i:mn();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return fs(f)&&f._createRunForChatModelStart(t,[u],d,this._parentRunId,o,this.tags,this.metadata,c),dt(async()=>{try{if(f.handleChatModelStart)await f.handleChatModelStart?.(t,[u],d,this._parentRunId,o,this.tags,this.metadata,c);else if(f.handleLLMStart){let p=Ic(u);await f.handleLLMStart?.(t,[p],d,this._parentRunId,o,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 Ib(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(t,r,i=mn(),n=void 0,o=void 0,a=void 0,s=void 0,c=void 0,u=void 0){return await Promise.all(this.handlers.map(l=>{if(!l.ignoreChain)return fs(l)&&l._createRunForChainStart(t,r,i,this._parentRunId,this.tags,this.metadata,n,s,u),dt(async()=>{try{await l.handleChainStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,n,s,u)}catch(d){if((l.raiseError?console.error:console.warn)(`Error in handler ${l.constructor.name}, handleChainStart: ${d}`),l.raiseError)throw d}},l.awaitHandlers)})),new DP(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(t,r,i=mn(),n=void 0,o=void 0,a=void 0,s=void 0,c=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreAgent)return fs(u)&&u._createRunForToolStart(t,r,i,this._parentRunId,this.tags,this.metadata,s),dt(async()=>{try{await u.handleToolStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,s,c)}catch(l){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleToolStart: ${l}`),u.raiseError)throw l}},u.awaitHandlers)})),new MP(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(t,r,i=mn(),n=void 0,o=void 0,a=void 0,s=void 0){return await Promise.all(this.handlers.map(c=>{if(!c.ignoreRetriever)return fs(c)&&c._createRunForRetrieverStart(t,r,i,this._parentRunId,this.tags,this.metadata,s),dt(async()=>{try{await c.handleRetrieverStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,s)}catch(u){if((c.raiseError?console.error:console.warn)(`Error in handler ${c.constructor.name}, handleRetrieverStart: ${u}`),c.raiseError)throw u}},c.awaitHandlers)})),new jP(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleCustomEvent(t,r,i,n,o){await Promise.all(this.handlers.map(a=>dt(async()=>{if(!a.ignoreCustomEvent)try{await a.handleCustomEvent?.(t,r,i,this.tags,this.metadata)}catch(s){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleCustomEvent: ${s}`),a.raiseError)throw s}},a.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 i of t)this.addHandler(i,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 i=new Gl(this._parentRunId);for(let n of this.handlers){let o=this.inheritableHandlers.includes(n);i.addHandler(n,o)}for(let n of this.tags){let o=this.inheritableTags.includes(n);i.addTags([n],o)}for(let n of Object.keys(this.metadata)){let o=Object.keys(this.inheritableMetadata).includes(n);i.addMetadata({[n]:this.metadata[n]},o)}for(let n of t)i.handlers.filter(o=>o.name==="console_callback_handler").some(o=>o.name===n.name)||i.addHandler(n,r);return i}static fromHandlers(t){class r extends Sr{name=mn();constructor(){super(),Object.assign(this,t)}}let i=new this;return i.addHandler(new r),i}static configure(t,r,i,n,o,a,s){return this._configureSync(t,r,i,n,o,a,s)}static _configureSync(t,r,i,n,o,a,s){let c;(t||r)&&(Array.isArray(t)||!t?(c=new Gl,c.setHandlers(t?.map(Ji)??[],!0)):c=t,c=c.copy(Array.isArray(r)?r.map(Ji):r?.handlers,!1));let u=Ot("LANGCHAIN_VERBOSE")==="true"||s?.verbose,l=Ko.getTraceableRunTree(),d=l?.tracingEnabled??OP();if(l?.tracingEnabled===!1&&c){let h=c.handlers.filter(g=>g.name==="langchain_tracer");for(let g of h)c.removeHandler(g)}let f=d||(Ot("LANGCHAIN_TRACING")??!1);if(u||f){if(c||(c=new Gl),u&&!c.handlers.some(h=>h.name===$m.prototype.name)){let h=new $m;c.addHandler(h,!0)}if(f&&!c.handlers.some(h=>h.name==="langchain_tracer")&&d){let h=new Ko;c.addHandler(h,!0)}d&&l&&c._parentRunId===void 0&&(c._parentRunId=l.id,c.handlers.find(h=>h.name==="langchain_tracer")?.updateFromRunTree(l))}for(let{contextVar:h,inheritable:g=!0,handlerClass:_,envVar:v}of PP()){let x=v&&Ot(v)==="true"&&_,S,k=h!==void 0?kb(h):void 0;k&&rv(k)?S=k:x&&(S=new _({})),S!==void 0&&(c||(c=new Gl),c.handlers.some(T=>T.name===S.name)||c.addHandler(S,g))}(i||n)&&c&&(c.addTags(i??[]),c.addTags(n??[],!1)),(o||a)&&c&&(c.addMetadata(o??{}),c.addMetadata(a??{},!1));let p=s?.tracerInheritableMetadata,m=s?.tracerInheritableTags;if(c&&(p||m)){let h=new Map,g=_=>{if(!(_ instanceof Ko))return _;let v=h.get(_);if(v!==void 0)return v;let x=_.copyWithTracingConfig({metadata:p,tags:m});return h.set(_,x),x};c.handlers=c.handlers.map(g),c.inheritableHandlers=c.inheritableHandlers.map(g)}if(c){let h=CB(c.handlers,c.inheritableHandlers);c.handlers=h.handlers,c.inheritableHandlers=h.inheritableHandlers}return c}};function Ji(e){return"name"in e?e:Sr.fromMethods(e)}var Eb=class{getStore(){}run(e,t){return t()}enterWith(e){}},OB=new Eb,zP=Symbol.for("lc:child_config"),PB=class{getInstance(){return qo()??OB}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[zP]}runWithConfig(e,t,r){let i=at._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),n=this.getInstance(),o=n.getStore(),a=i?.getParentRunId(),s=i?.handlers?.find(u=>u?.name==="langchain_tracer"),c;return s&&a?c=s.getRunTreeWithTracingConfig(a):r||(c=new zn({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra={...c.extra,[zP]:e}),o!==void 0&&o[Wo]!==void 0&&(c===void 0&&(c={}),c[Wo]=o[Wo]),n.run(c,t)}initializeGlobalInstance(e){qo()===void 0&&TP(e)}},Ue=new PB;var LP=C({AsyncLocalStorageProviderSingleton:()=>Ue,MockAsyncLocalStorage:()=>Eb,_CONTEXT_VARIABLES_KEY:()=>Wo});var NB=new Set(["api_key"]),RB=new Set(["string","number","boolean"]);function jB(e){let t=e.configurable??{},r=e.metadata??{},i={};for(let[n,o]of Object.entries(t))!n.startsWith("__")&&!Object.prototype.hasOwnProperty.call(r,n)&&!NB.has(n)&&RB.has(typeof o)&&(i[n]=o);return Object.keys(i).length>0?i:void 0}async function lr(e){return at._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata,void 0,{tracerInheritableMetadata:e?jB(e):void 0})}function jt(...e){let t={};for(let r of e.filter(i=>!!i))for(let i of Object.keys(r))if(i==="metadata")t[i]={...t[i],...r[i]};else if(i==="tags"){let n=t[i]??[];t[i]=[...new Set(n.concat(r[i]??[]))]}else if(i==="configurable")t[i]={...t[i],...r[i]};else if(i==="timeout")t.timeout===void 0?t.timeout=r.timeout:r.timeout!==void 0&&(t.timeout=Math.min(t.timeout,r.timeout));else if(i==="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(i==="callbacks"){let n=t.callbacks,o=r.callbacks;if(Array.isArray(o))if(!n)t.callbacks=o;else if(Array.isArray(n))t.callbacks=n.concat(o);else{let a=n.copy();for(let s of o)a.addHandler(Ji(s),!0);t.callbacks=a}else if(o)if(!n)t.callbacks=o;else if(Array.isArray(n)){let a=o.copy();for(let s of n)a.addHandler(Ji(s),!0);t.callbacks=a}else t.callbacks=new at(o._parentRunId,{handlers:n.handlers.concat(o.handlers),inheritableHandlers:n.inheritableHandlers.concat(o.inheritableHandlers),tags:Array.from(new Set(n.tags.concat(o.tags))),inheritableTags:Array.from(new Set(n.inheritableTags.concat(o.inheritableTags))),metadata:{...n.metadata,...o.metadata}})}else{let n=i;t[n]=r[n]??t[n]}return t}function Ae(e){let t=Ue.getRunnableConfig(),r={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){let{runId:i,runName:n,...o}=t;r=Object.entries(o).reduce((a,[s,c])=>(c!==void 0&&(a[s]=c),a),r)}if(e&&(r=Object.entries(e).reduce((i,[n,o])=>(o!==void 0&&(i[n]=o),i),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 i=r.timeout,n=AbortSignal.timeout(i);r.metadata||(r.metadata={}),r.metadata.timeoutMs===void 0&&(r.metadata.timeoutMs=i),r.signal!==void 0?"any"in AbortSignal&&(r.signal=AbortSignal.any([r.signal,n])):r.signal=n,delete r.timeout}return r}function Pe(e={},{callbacks:t,maxConcurrency:r,recursionLimit:i,runName:n,configurable:o,runId:a}={}){let s=Ae(e);return t!==void 0&&(delete s.runName,s.callbacks=t),i!==void 0&&(s.recursionLimit=i),r!==void 0&&(s.maxConcurrency=r),n!==void 0&&(s.runName=n),o!==void 0&&(s.configurable={...s.configurable,...o}),a!==void 0&&delete s.runId,s}function Lr(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 rn(e,t){if(t===void 0)return e;let r;return Promise.race([e.catch(i=>{if(!t?.aborted)throw i}),new Promise((i,n)=>{r=()=>{n(Jo(t))},t.addEventListener("abort",r,{once:!0}),t.aborted&&n(Jo(t))})]).finally(()=>t.removeEventListener("abort",r))}function Jo(e){return e?.reason instanceof Error?e.reason:typeof e?.reason=="string"?new Error(e.reason):new Error("Aborted")}var UP=C({AsyncGeneratorWithSetup:()=>Xo,IterableReadableStream:()=>$t,atee:()=>Tm,concat:()=>nn,pipeGeneratorWithSetup:()=>Ab}),$t=class Tb 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 Tb({start(i){return n();function n(){return r.read().then(({done:o,value:a})=>{if(o){i.close();return}return i.enqueue(a),n()})}},cancel(){r.releaseLock()}})}static fromAsyncGenerator(t){return new Tb({async pull(r){let{value:i,done:n}=await t.next();n&&r.close(),r.enqueue(i)},async cancel(r){await t.return(r)}})}};function Tm(e,t=2){let r=Array.from({length:t},()=>[]);return r.map(async function*(n){for(;;)if(n.length===0){let o=await e.next();for(let a of r)a.push(o)}else{if(n[0].done)return;yield n.shift().value}})}function nn(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[i,n]of Object.entries(t))i in r&&!Array.isArray(r[i])?r[i]=nn(r[i],n):r[i]=n;return r}else throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}var Xo=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)=>{Ue.runWithConfig(Lr(e.config),async()=>{this.firstResult=this.signal?rn(e.generator.next(),this.signal):e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(i=>t(void 0),r)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?Ue.runWithConfig(Lr(this.config),this.signal?async()=>rn(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 Ab(e,t,r,i,...n){let o=new Xo({generator:t,startSetup:r,signal:i}),a=await o.setup;return{output:e(o,a,...n),setup:a}}var DB=Object.prototype.hasOwnProperty;function Cm(e,t){return DB.call(e,t)}function Om(e){if(Array.isArray(e)){let r=new Array(e.length);for(let i=0;i<r.length;i++)r[i]=""+i;return r}if(Object.keys)return Object.keys(e);let t=[];for(let r in e)Cm(e,r)&&t.push(r);return t}function on(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Pm(e){let t=0,r=e.length,i;for(;t<r;){if(i=e.charCodeAt(t),i>=48&&i<=57){t++;continue}return!1}return!0}function hs(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function BP(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Am(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(let r=0,i=e.length;r<i;r++)if(Am(e[r]))return!0}else if(typeof e=="object"){let r=Om(e),i=r.length;for(var t=0;t<i;t++)if(Am(e[r[t]]))return!0}}return!1}function FP(e,t){let r=[e];for(let i in t){let n=typeof t[i]=="object"?JSON.stringify(t[i],null,2):t[i];typeof n<"u"&&r.push(`${i}: ${n}`)}return r.join(`
162
+ `)}var VP=class extends Error{name;index;operation;tree;constructor(e,t,r,i,n){super(FP(e,{name:t,index:r,operation:i,tree:n})),this.name=t,this.index=r,this.operation=i,this.tree=n,Object.setPrototypeOf(this,new.target.prototype),this.message=FP(e,{name:t,index:r,operation:i,tree:n})}};var HP=C({JsonPatchError:()=>gt,_areEquals:()=>qc,applyOperation:()=>Yo,applyPatch:()=>Xi,applyReducer:()=>ZP,deepClone:()=>MB,getValueByPointer:()=>Wl,validate:()=>Cb,validator:()=>ql});var gt=VP,MB=on,Wc={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 i=e[t];return delete e[t],{newDocument:r,removed:i}},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 i=e[t];return e[t]=this.value,{newDocument:r,removed:i}},move:function(e,t,r){let i=Wl(r,this.path);i&&(i=on(i));let n=Yo(r,{op:"remove",path:this.from}).removed;return Yo(r,{op:"add",path:this.path,value:n}),{newDocument:r,removed:i}},copy:function(e,t,r){let i=Wl(r,this.from);return Yo(r,{op:"add",path:this.path,value:on(i)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:qc(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},zB={add:function(e,t,r){return Pm(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 i=e[t];return e[t]=this.value,{newDocument:r,removed:i}},move:Wc.move,copy:Wc.copy,test:Wc.test,_get:Wc._get};function Wl(e,t){if(t=="")return e;var r={op:"_get",path:t};return Yo(e,r),r.value}function Yo(e,t,r=!1,i=!0,n=!0,o=0){if(r&&(typeof r=="function"?r(t,0,e,t.path):ql(t,0)),t.path===""){let a={newDocument:e};if(t.op==="add")return a.newDocument=t.value,a;if(t.op==="replace")return a.newDocument=t.value,a.removed=e,a;if(t.op==="move"||t.op==="copy")return a.newDocument=Wl(e,t.from),t.op==="move"&&(a.removed=e),a;if(t.op==="test"){if(a.test=qc(e,t.value),a.test===!1)throw new gt("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return a.newDocument=e,a}else{if(t.op==="remove")return a.removed=e,a.newDocument=null,a;if(t.op==="_get")return t.value=e,a;if(r)throw new gt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,t,e);return a}}else{i||(e=on(e));let a=(t.path||"").split("/"),s=e,c=1,u=a.length,l,d,f;for(typeof r=="function"?f=r:f=ql;;){if(d=a[c],d&&d.indexOf("~")!=-1&&(d=BP(d)),n&&(d=="__proto__"||d=="prototype"&&c>0&&a[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&&l===void 0&&(s[d]===void 0?l=a.slice(0,c).join("/"):c==u-1&&(l=t.path),l!==void 0&&f(t,0,e,l)),c++,Array.isArray(s)){if(d==="-")d=s.length;else{if(r&&!Pm(d))throw new gt("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",o,t,e);Pm(d)&&(d=~~d)}if(c>=u){if(r&&t.op==="add"&&d>s.length)throw new gt("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,t,e);let p=zB[t.op].call(t,s,d,e);if(p.test===!1)throw new gt("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return p}}else if(c>=u){let p=Wc[t.op].call(t,s,d,e);if(p.test===!1)throw new gt("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return p}if(s=s[d],r&&c<u&&(!s||typeof s!="object"))throw new gt("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,t,e)}}}function Xi(e,t,r,i=!0,n=!0){if(r&&!Array.isArray(t))throw new gt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");i||(e=on(e));let o=new Array(t.length);for(let a=0,s=t.length;a<s;a++)o[a]=Yo(e,t[a],r,!0,n,a),e=o[a].newDocument;return o.newDocument=e,o}function ZP(e,t,r){let i=Yo(e,t);if(i.test===!1)throw new gt("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return i.newDocument}function ql(e,t,r,i){if(typeof e!="object"||e===null||Array.isArray(e))throw new gt("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(Wc[e.op]){if(typeof e.path!="string")throw new gt("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new gt('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 gt("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 gt("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")&&Am(e.value))throw new gt("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 n=e.path.split("/").length,o=i.split("/").length;if(n!==o+1&&n!==o)throw new gt("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!==i)throw new gt("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 a=Cb([{op:"_get",path:e.from,value:void 0}],r);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new gt("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new gt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function Cb(e,t,r){try{if(!Array.isArray(e))throw new gt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Xi(on(t),on(e),r||!0);else{r=r||ql;for(var i=0;i<e.length;i++)r(e[i],i,t,void 0)}}catch(n){if(n instanceof gt)return n;throw n}}function qc(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var r=Array.isArray(e),i=Array.isArray(t),n,o,a;if(r&&i){if(o=e.length,o!=t.length)return!1;for(n=o;n--!==0;)if(!qc(e[n],t[n]))return!1;return!0}if(r!=i)return!1;var s=Object.keys(e);if(o=s.length,o!==Object.keys(t).length)return!1;for(n=o;n--!==0;)if(!t.hasOwnProperty(s[n]))return!1;for(n=o;n--!==0;)if(a=s[n],!qc(e[a],t[a]))return!1;return!0}return e!==e&&t!==t}function GP(e,t,r,i,n){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var o=Om(t),a=Om(e),s=!1,c=a.length-1;c>=0;c--){var u=a[c],l=e[u];if(Cm(t,u)&&!(t[u]===void 0&&l!==void 0&&Array.isArray(t)===!1)){var d=t[u];typeof l=="object"&&l!=null&&typeof d=="object"&&d!=null&&Array.isArray(l)===Array.isArray(d)?GP(l,d,r,i+"/"+hs(u),n):l!==d&&(n&&r.push({op:"test",path:i+"/"+hs(u),value:on(l)}),r.push({op:"replace",path:i+"/"+hs(u),value:on(d)}))}else Array.isArray(e)===Array.isArray(t)?(n&&r.push({op:"test",path:i+"/"+hs(u),value:on(l)}),r.push({op:"remove",path:i+"/"+hs(u)}),s=!0):(n&&r.push({op:"test",path:i,value:e}),r.push({op:"replace",path:i,value:t}))}if(!(!s&&o.length==a.length))for(var c=0;c<o.length;c++){var u=o[c];!Cm(e,u)&&t[u]!==void 0&&r.push({op:"add",path:i+"/"+hs(u),value:on(t[u])})}}}function Yi(e,t,r=!1){var i=[];return GP(e,t,i,"",r),i}({...HP});var qP=C({LogStreamCallbackHandler:()=>Rm,RunLog:()=>Nm,RunLogPatch:()=>vi,isLogStreamHandler:()=>Pb}),vi=class{ops;constructor(e){this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),r=Xi({},t);return new Nm({ops:t,state:r[r.length-1].newDocument})}},Nm=class Ob extends vi{state;constructor(t){super(t),this.state=t.state}concat(t){let r=this.ops.concat(t.ops),i=Xi(this.state,t.ops);return new Ob({ops:r,state:i[i.length-1].newDocument})}static fromRunLogPatch(t){let r=Xi({},t.ops);return new Ob({ops:t.ops,state:r[r.length-1].newDocument})}},Pb=e=>e.name==="log_stream_tracer";async function KP(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 WP(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 LB(e){return e!==void 0&&e.message!==void 0}var Rm=class extends Yt{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=$t.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(i=>this.includeTags?.includes(i))!==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(i=>!this.excludeTags?.includes(i))),r}async*tapOutputIterable(e,t){for await(let r of t){if(e!==this.rootId){let i=this.keyMapByRunId[e];i&&await this.writer.write(new vi({ops:[{op:"add",path:`/logs/${i}/streamed_output/-`,value:r}]}))}yield r}}async onRunCreate(e){if(this.rootId===void 0&&(this.rootId=e.id,await this.writer.write(new vi({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 KP(e,this._schemaFormat)),await this.writer.write(new vi({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 KP(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await WP(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 i=new vi({ops:r});await this.writer.write(i)}finally{if(e.id===this.rootId){let t=new vi({ops:[{op:"replace",path:"/final_output",value:await WP(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,r){let i=this.keyMapByRunId[e.id];if(i===void 0)return;let n=e.inputs.messages!==void 0,o;n?LB(r?.chunk)?o=r?.chunk:o=new nt({id:`run-${e.id}`,content:t}):o=t;let a=new vi({ops:[{op:"add",path:`/logs/${i}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${i}/streamed_output/-`,value:o}]});await this.writer.write(a)}};var JP=C({ChatGenerationChunk:()=>Qo,GenerationChunk:()=>Qi,RUN_KEY:()=>gs}),gs="__run",Qi=class XP{text;generationInfo;constructor(t){this.text=t.text,this.generationInfo=t.generationInfo}concat(t){return new XP({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo}})}},Qo=class YP extends Qi{message;constructor(t){super(t),this.message=t.message}concat(t){return new YP({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo},message:this.message.concat(t.message)})}};var UB=Object.prototype.toString,FB=e=>UB.call(e)==="[object Error]",BB=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 QP(e){if(!(e&&FB(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:BB.has(t)}function VB(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 jm(e,t,{min:r=0,allowInfinity:i=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${i?" or Infinity":""}.`);if(!i&&!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 HB=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 ZB(e,t){let r=Math.max(1,e+1),i=t.randomize?Math.random()+1:1,n=Math.round(i*t.minTimeout*t.factor**(r-1));return n=Math.min(n,t.maxTimeout),n}function eN(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function GB({error:e,attemptNumber:t,retriesConsumed:r,startTime:i,options:n}){let o=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(o instanceof HB)throw o.originalError;let a=Number.isFinite(n.retries)?Math.max(0,n.retries-r):n.retries,s=n.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:o,attemptNumber:t,retriesLeft:a,retriesConsumed:r});if(await n.onFailedAttempt(c),eN(i,s)<=0)throw o;let u=await n.shouldConsumeRetry(c),l=eN(i,s);if(l<=0||a<=0)throw o;if(o instanceof TypeError&&!QP(o)){if(u)throw o;return n.signal?.throwIfAborted(),!1}if(!await n.shouldRetry(c))throw o;if(!u)return n.signal?.throwIfAborted(),!1;let d=ZB(r,n),f=typeof o.retryAfterMs=="number"&&o.retryAfterMs>=0?o.retryAfterMs:void 0;f!==void 0&&(d=Math.max(d,f));let p=Math.min(d,l);return p>0&&await new Promise((m,h)=>{let g=()=>{clearTimeout(_),n.signal?.removeEventListener("abort",g),h(n.signal.reason)},_=setTimeout(()=>{n.signal?.removeEventListener("abort",g),m()},p);n.unref&&_.unref?.(),n.signal?.addEventListener("abort",g,{once:!0})}),n.signal?.throwIfAborted(),!0}async function Jl(e,t={}){if(t={...t},VB(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,jm("factor",t.factor,{min:0,allowInfinity:!1}),jm("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),jm("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),jm("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,i=0,n=performance.now();for(;!Number.isFinite(t.retries)||i<=t.retries;){r++;try{t.signal?.throwIfAborted();let o=await e(r);return t.signal?.throwIfAborted(),o}catch(o){await GB({error:o,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Dm=tp(nm(),1),rN=C({AsyncCaller:()=>eo,classifyRateLimitError:()=>sN,parseRetryAfterMs:()=>aN}),KB=[400,401,402,403,404,405,406,407,409,413],WB=6e4,qB=[/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],JB=/(?:try again in|retry after)\s+(\d+(?:\.\d+)?)\s*(milliseconds?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h)\b/i;function nN(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 iN(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 Rb(e){return typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:void 0}function oN(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 XB(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 YB(e){if(e==null)return;let t=JB.exec(e);if(!t)return;let r=Number(t[1]),i=t[2]?.toLowerCase();if(!(Number.isNaN(r)||!i))return i==="ms"||i.startsWith("millisecond")?r:i==="m"||i.startsWith("min")?r*6e4:i==="h"||i.startsWith("hr")||i.startsWith("hour")?r*36e5:r*1e3}function tN(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 Nb(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 aN(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 i=Date.parse(t);if(!Number.isNaN(i)){let n=i-Date.now();return n>0?n:0}}function sN(e){if((nN(e)??iN(e))!==429)return;if(oN(e)==="insufficient_quota")return{action:"stop",reason:"insufficient_quota"};let t=Rb(e);if(t&&qB.some(i=>i.test(t)))return{action:"stop",reason:"quota_message"};let r=aN(XB(e))??YB(t);return r!==void 0?r<=WB?{action:"wait",retryAfterMs:r,reason:"retry_after_hint"}:{action:"capacity",retryAfterMs:r,reason:"retry_after_too_large"}:{action:"capacity",reason:"headerless_429"}}var QB=e=>{if(typeof e!="object"||e===null)return;if(Zy(e)===!1)throw e;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")throw Vi(e,!1);if("code"in e&&typeof e.code=="string"&&e.code==="ECONNABORTED")throw e;let t=nN(e)??iN(e);if(t&&KB.includes(+t))throw Vi(e,!1);if(oN(e)==="insufficient_quota"){let i=tN(e,Rb(e)??"Insufficient quota");throw i.name="InsufficientQuotaError",Nb(i,{action:"stop",reason:"insufficient_quota"}),Vi(i,!1)}let r=sN(e);if(r){if(r.action==="wait"){Nb(e,r),Vi(e,!0);return}let i=tN(e,Rb(e)??"Rate limit exceeded");throw i.name==="Error"&&(i.name=r.action==="stop"?"RateLimitQuotaExhaustedError":"RateLimitCapacityError"),Nb(i,r),Vi(i,r.action!=="stop")}},eo=class{maxConcurrency;maxRetries;onFailedAttempt;queue;constructor(e){this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??QB;let t="default"in Dm.default?Dm.default.default:Dm.default;this.queue=new t({concurrency:this.maxConcurrency})}async call(e,...t){return this.callWithRetries(this.maxRetries,e,t)}callWithRetries(e,t,r){return this.queue.add(()=>Jl(()=>t(...r).catch(i=>{throw i instanceof Error?i:new Error(i)}),{onFailedAttempt:({error:i})=>this.onFailedAttempt?.(i),retries:e,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){let i=e.maxRetries??this.maxRetries;if(e.signal){let n;return Promise.race([this.callWithRetries(i,t,r),new Promise((o,a)=>{n=()=>{a(Jo(e.signal))},e.signal?.addEventListener("abort",n,{once:!0})})]).finally(()=>{e.signal&&n&&e.signal.removeEventListener("abort",n)})}return this.callWithRetries(i,t,r)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}};var cN=C({isSerializableSchema:()=>_s,isStandardJsonSchema:()=>Mm,isStandardSchema:()=>uN});function uN(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 Mm(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 _s(e){return uN(e)&&Mm(e)}var oo={};ni(oo,{$ZodAny:()=>zx,$ZodArray:()=>Fx,$ZodAsyncError:()=>Br,$ZodBase64:()=>Ix,$ZodBase64URL:()=>Ex,$ZodBigInt:()=>vh,$ZodBigIntFormat:()=>Rx,$ZodBoolean:()=>vd,$ZodCIDRv4:()=>kx,$ZodCIDRv6:()=>$x,$ZodCUID:()=>fx,$ZodCUID2:()=>px,$ZodCatch:()=>a0,$ZodCheck:()=>Je,$ZodCheckBigIntFormat:()=>Lw,$ZodCheckEndsWith:()=>Xw,$ZodCheckGreaterThan:()=>nh,$ZodCheckIncludes:()=>qw,$ZodCheckLengthEquals:()=>Zw,$ZodCheckLessThan:()=>rh,$ZodCheckLowerCase:()=>Kw,$ZodCheckMaxLength:()=>Vw,$ZodCheckMaxSize:()=>Uw,$ZodCheckMimeType:()=>ex,$ZodCheckMinLength:()=>Hw,$ZodCheckMinSize:()=>Fw,$ZodCheckMultipleOf:()=>Mw,$ZodCheckNumberFormat:()=>zw,$ZodCheckOverwrite:()=>tx,$ZodCheckProperties:()=>Qw,$ZodCheckProperty:()=>Yw,$ZodCheckRegex:()=>Gw,$ZodCheckSizeEquals:()=>Bw,$ZodCheckStartsWith:()=>Jw,$ZodCheckStringFormat:()=>au,$ZodCheckUpperCase:()=>Ww,$ZodCodec:()=>Sd,$ZodCreditCard:()=>Ax,$ZodCustom:()=>p0,$ZodCustomStringFormat:()=>Px,$ZodCyclicError:()=>$h,$ZodDate:()=>Ux,$ZodDefault:()=>r0,$ZodDiscriminatedUnion:()=>Zx,$ZodE164:()=>Tx,$ZodEmail:()=>ax,$ZodEmoji:()=>lx,$ZodEncodeError:()=>ra,$ZodEnum:()=>Jx,$ZodError:()=>Xb,$ZodExactOptional:()=>e0,$ZodFile:()=>Yx,$ZodFunction:()=>d0,$ZodGUID:()=>ix,$ZodIBAN:()=>Cx,$ZodIPv4:()=>wx,$ZodIPv6:()=>xx,$ZodISODate:()=>yx,$ZodISODateTime:()=>_x,$ZodISODuration:()=>bx,$ZodISOTime:()=>vx,$ZodIntersection:()=>Gx,$ZodJWT:()=>Ox,$ZodKSUID:()=>gx,$ZodLazy:()=>kd,$ZodLiteral:()=>Xx,$ZodMAC:()=>Sx,$ZodMap:()=>Wx,$ZodNaN:()=>s0,$ZodNanoID:()=>dx,$ZodNever:()=>wd,$ZodNonOptional:()=>i0,$ZodNull:()=>Mx,$ZodNullable:()=>t0,$ZodNumber:()=>yh,$ZodNumberFormat:()=>Nx,$ZodObject:()=>HN,$ZodObjectJIT:()=>Bx,$ZodOptional:()=>$s,$ZodPipe:()=>wh,$ZodPrefault:()=>n0,$ZodPreprocess:()=>c0,$ZodPromise:()=>f0,$ZodReadonly:()=>u0,$ZodRealError:()=>Vr,$ZodRecord:()=>Kx,$ZodRegistry:()=>Oh,$ZodSet:()=>qx,$ZodString:()=>ks,$ZodStringFormat:()=>Ze,$ZodSuccess:()=>o0,$ZodSymbol:()=>jx,$ZodTemplateLiteral:()=>l0,$ZodTransform:()=>Qx,$ZodTuple:()=>bh,$ZodType:()=>_e,$ZodULID:()=>mx,$ZodURL:()=>ux,$ZodUUID:()=>ox,$ZodUndefined:()=>Dx,$ZodUnion:()=>xd,$ZodUnknown:()=>bd,$ZodVoid:()=>Lx,$ZodXID:()=>hx,$ZodXor:()=>Vx,$brand:()=>Wb,$constructor:()=>$,$input:()=>_0,$output:()=>g0,Doc:()=>Ss,INVALID:()=>Ar,JSONSchema:()=>OR,JSONSchemaGenerator:()=>dg,NEVER:()=>Kb,TimePrecision:()=>T0,URL_BAD_FORMAT:()=>sx,URL_UNPARSEABLE:()=>md,ZodCompileAsyncError:()=>Un,ZodCompileUnsupportedError:()=>Ne,_any:()=>Z0,_array:()=>J0,_base64:()=>Qh,_base64url:()=>eg,_bigint:()=>z0,_boolean:()=>D0,_catch:()=>n3,_check:()=>hR,_cidrv4:()=>Xh,_cidrv6:()=>Yh,_coercedBigint:()=>L0,_coercedBoolean:()=>M0,_coercedDate:()=>W0,_coercedNumber:()=>C0,_coercedString:()=>k0,_creditCard:()=>I0,_cuid:()=>Hh,_cuid2:()=>Zh,_custom:()=>Y0,_date:()=>K0,_decode:()=>Zm,_decodeAsync:()=>Km,_default:()=>e3,_discriminatedUnion:()=>BZ,_e164:()=>tg,_email:()=>Dh,_emoji:()=>Bh,_encode:()=>Hm,_encodeAsync:()=>Gm,_endsWith:()=>gu,_enum:()=>WZ,_file:()=>X0,_float32:()=>P0,_float64:()=>N0,_gt:()=>wi,_gte:()=>sn,_guid:()=>Mh,_iban:()=>E0,_includes:()=>mu,_int:()=>O0,_int32:()=>R0,_int64:()=>U0,_intersection:()=>VZ,_ipv4:()=>qh,_ipv6:()=>Jh,_isoDate:()=>Pd,_isoDateTime:()=>Od,_isoDuration:()=>Rd,_isoTime:()=>Nd,_jwt:()=>rg,_ksuid:()=>Wh,_lazy:()=>s3,_length:()=>Ps,_literal:()=>JZ,_lowercase:()=>fu,_lt:()=>bi,_lte:()=>an,_mac:()=>$0,_map:()=>GZ,_max:()=>an,_maxLength:()=>Os,_maxSize:()=>oa,_mime:()=>yu,_min:()=>sn,_minLength:()=>io,_minSize:()=>xi,_multipleOf:()=>ia,_nan:()=>q0,_nanoid:()=>Vh,_nativeEnum:()=>qZ,_negative:()=>ig,_never:()=>Dd,_nonnegative:()=>ag,_nonoptional:()=>t3,_nonpositive:()=>og,_normalize:()=>vu,_null:()=>H0,_nullable:()=>QZ,_number:()=>A0,_optional:()=>YZ,_overwrite:()=>Fn,_parse:()=>ru,_parseAsync:()=>nu,_pipe:()=>i3,_positive:()=>ng,_promise:()=>c3,_properties:()=>_u,_property:()=>sg,_readonly:()=>o3,_record:()=>ZZ,_refine:()=>Q0,_regex:()=>du,_safeDecode:()=>qm,_safeDecodeAsync:()=>Xm,_safeEncode:()=>Wm,_safeEncodeAsync:()=>Jm,_safeParse:()=>iu,_safeParseAsync:()=>ou,_set:()=>KZ,_size:()=>Cs,_slugify:()=>Su,_startsWith:()=>hu,_string:()=>S0,_stringFormat:()=>Ns,_stringbool:()=>nS,_success:()=>r3,_superRefine:()=>eS,_symbol:()=>B0,_templateLiteral:()=>a3,_toLowerCase:()=>wu,_toUpperCase:()=>xu,_transform:()=>XZ,_trim:()=>bu,_tuple:()=>HZ,_uint32:()=>j0,_uint64:()=>F0,_ulid:()=>Gh,_undefined:()=>V0,_union:()=>UZ,_unknown:()=>jd,_uppercase:()=>pu,_url:()=>Cd,_uuid:()=>zh,_uuidv4:()=>Lh,_uuidv6:()=>Uh,_uuidv7:()=>Fh,_void:()=>G0,_xid:()=>Kh,_xor:()=>FZ,base64Charset:()=>ph,base64urlCharset:()=>yd,canParseURL:()=>cx,clone:()=>Ie,compile:()=>w0,compileFn:()=>Rh,config:()=>_t,createStandardJSONSchemaMethod:()=>ku,createToJSONSchemaMethod:()=>oS,decode:()=>HV,decodeAsync:()=>GV,describe:()=>tS,encode:()=>VV,encodeAsync:()=>ZV,extractDefs:()=>sa,finalize:()=>ca,flattenError:()=>ad,formatError:()=>sd,getDiscriminatedOption:()=>Hx,globalConfig:()=>Gt,globalRegistry:()=>He,handleUnrepresentable:()=>Dt,initializeContext:()=>aa,isBackEdge:()=>Eh,isRecursiveSchema:()=>Ih,isValidBase64:()=>_d,isValidBase64URL:()=>mh,isValidCIDRv6:()=>fh,isValidCreditCard:()=>hh,isValidIBAN:()=>gh,isValidIPv6:()=>gd,isValidJWT:()=>_h,locales:()=>Ad,memoizer:()=>Ed,mergeValues:()=>su,meta:()=>rS,parse:()=>na,parseAsync:()=>ws,parseURLObject:()=>FN,prettifyError:()=>Qb,process:()=>Ge,processSchema:()=>Ge,regexes:()=>vn,registry:()=>Ph,safeDecode:()=>WV,safeDecodeAsync:()=>JV,safeEncode:()=>KV,safeEncodeAsync:()=>qV,safeParse:()=>zV,safeParseAsync:()=>LV,standardProps:()=>ch,stripTabAndNewline:()=>hd,toDotPath:()=>bN,toJSONSchema:()=>Rs,toZod:()=>Xl,treeifyError:()=>Yb,urlHostnameOk:()=>lh,urlProtocolOk:()=>dh,util:()=>O,validate:()=>cd,validateAsync:()=>ud,validateURL:()=>uh,version:()=>rx,withParser:()=>Nh});var O={};ni(O,{BIGINT_FORMAT_RANGES:()=>rd,CONSTANT_CATCH:()=>Bm,Class:()=>Mb,NUMBER_FORMAT_RANGES:()=>td,aborted:()=>Tr,allowsEval:()=>Ub,assert:()=>iV,assertEqual:()=>eV,assertIs:()=>rV,assertNever:()=>nV,assertNotEqual:()=>tV,assignProp:()=>Qt,attachSchema:()=>Fm,base64ToUint8Array:()=>mN,base64urlToUint8Array:()=>SV,cached:()=>Qc,captureStackTrace:()=>Lm,cleanEnum:()=>xV,cleanRegex:()=>ro,clone:()=>Ie,cloneDef:()=>sV,codePointLength:()=>bs,constantCatch:()=>Zb,createTransparentProxy:()=>pV,defineLazy:()=>zb,defineLazyInternal:()=>$e,derived:()=>EV,esc:()=>Er,escapeRegex:()=>yn,explicitlyAborted:()=>Vb,extend:()=>gV,finalizeIssue:()=>Fr,floatSafeRemainder:()=>Yl,getElementAtPath:()=>cV,getEnumValues:()=>Xc,getLengthableOrigin:()=>id,getParsedType:()=>fV,getSizableOrigin:()=>nd,hexToUint8Array:()=>$V,hide:()=>od,installLazyProp:()=>OV,isObject:()=>vs,isPlainObject:()=>_n,issue:()=>tu,joinValues:()=>I,jsonStringifyReplacer:()=>Yc,members:()=>Hb,merge:()=>yV,mergeDefs:()=>Ln,normalizeParams:()=>F,nullish:()=>zm,numKeys:()=>dV,objectClone:()=>oV,omit:()=>hV,optionalKeys:()=>Bb,own:()=>ta,parsedType:()=>R,partial:()=>vV,pick:()=>mV,prefixIssues:()=>Ur,primitiveTypes:()=>Fb,promiseAllObject:()=>uV,propertyKeyTypes:()=>ed,randomString:()=>lV,rawShape:()=>eu,required:()=>bV,safeExtend:()=>_V,shallowClone:()=>Ql,slugify:()=>Lb,stringifyPrimitive:()=>P,toZod:()=>Xl,uint8ArrayToBase64:()=>hN,uint8ArrayToBase64url:()=>kV,uint8ArrayToHex:()=>IV,unwrapMessage:()=>Jc});function eV(e){return e}function tV(e){return e}function Xl(){return e=>e}function rV(e){}function nV(e){throw new Error("Unexpected value in exhaustive check")}function iV(e){}function Xc(e){let t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,n])=>t.indexOf(+i)===-1).map(([i,n])=>n)}function I(e,t="|"){return e.map(r=>P(r)).join(t)}function Yc(e,t){return typeof t=="bigint"?t.toString():t}var Db=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Qc(e){return new Db(e)}function zm(e){return e==null}function ro(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Yl(e,t){let r=e/t,i=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-i)<n?0:r-i}var lN=Symbol("evaluating");function zb(e,t,r){let i;Object.defineProperty(e,t,{get(){if(i!==lN)return i===void 0&&(i=lN,i=r()),i},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function oV(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Qt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function eu(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function to(e){return eu(e._zod.def)??e._zod.def.shape}function dN(e,t,r){Object.defineProperty(e,t,{get(){let i=r();return Qt(this,t,i),i},enumerable:!0,configurable:!0})}function fN(e,t,r){t in e?Qt(e,t,r):e[t]=r}function ys(e,t,r,i){let n=to(t);for(let o of r){let a=Object.getOwnPropertyDescriptor(n,o);a.enumerable&&(a.get?dN(e,o,()=>{let s=t._zod.def.shape[o];return i?i(s,o):s}):fN(e,o,i?i(a.value,o):a.value))}}function aV(e,t){for(let r of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,r);i.enumerable&&(i.get?dN(e,r,()=>t[r]):fN(e,r,i.value))}}function Ln(...e){let t={};for(let r of e){let i=Object.getOwnPropertyDescriptors(r);Object.assign(t,i)}return Object.defineProperties({},t)}function sV(e){return Ln(e._zod.def)}function cV(e,t){return t?t.reduce((r,i)=>r?.[i],e):e}function uV(e){let t=Object.keys(e),r=t.map(i=>e[i]);return Promise.all(r).then(i=>{let n={};for(let o=0;o<t.length;o++)n[t[o]]=i[o];return n})}function lV(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<e;i++)r+=t[Math.floor(Math.random()*t.length)];return r}function Er(e){return JSON.stringify(e)}function Lb(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Lm="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function vs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ub=Qc(()=>{if(Gt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function _n(e){if(vs(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(vs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Ql(e){return _n(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function dV(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var fV=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}`)}},ed=new Set(["string","number","symbol"]),Fb=new Set(["string","number","bigint","boolean","symbol","undefined"]);function yn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function F(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 pV(e){let t;return new Proxy({},{get(r,i,n){return t??(t=e()),Reflect.get(t,i,n)},set(r,i,n,o){return t??(t=e()),Reflect.set(t,i,n,o)},has(r,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(r,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(r,i,n){return t??(t=e()),Reflect.defineProperty(t,i,n)}})}function P(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Bb(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var td={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]},rd={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function mV(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o={};return ys(o,e,Um(e,t)),Ie(e,Ln(r,{shape:o,checks:[]}))}function Um(e,t){let r=to(e),i=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw new Error(`Unrecognized key: "${String(n)}"`);t[n]&&i.push(n)}return i}function hV(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=new Set(Um(e,t)),a={};return ys(a,e,Reflect.ownKeys(to(e)).filter(s=>!o.has(s))),Ie(e,Ln(r,{shape:a,checks:[]}))}function gV(e,t){if(!_n(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=to(e);for(let o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ie(e,Ln(e._zod.def,{shape:pN(e,t)}))}function pN(e,t){let r={};return ys(r,e,Reflect.ownKeys(to(e))),aV(r,t),r}function _V(e,t){if(!_n(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Ie(e,Ln(e._zod.def,{shape:pN(e,t)}))}function yV(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};ys(r,e,Reflect.ownKeys(to(e))),ys(r,t,Reflect.ownKeys(to(t)));let i=Ln(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ie(e,i)}function vV(e,t,r,i="partial"){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${i}() cannot be used on object schemas containing refinements`);let s=r?new Set(Um(t,r)):void 0,c={};return ys(c,t,Reflect.ownKeys(to(t)),e&&((u,l)=>s&&!s.has(l)?u:new e({type:"optional",innerType:u}))),Ie(t,Ln(t._zod.def,{shape:c,checks:[]}))}function bV(e,t,r){let i=r?new Set(Um(t,r)):void 0,n={};return ys(n,t,Reflect.ownKeys(to(t)),(o,a)=>i&&!i.has(a)?o:new e({type:"nonoptional",innerType:o})),Ie(t,Ln(t._zod.def,{shape:n}))}function Tr(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 Vb(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 Ur(e,t){return t.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(e),r})}function Jc(e){return typeof e=="string"?e:e?.message}function Fm(e,t,r){var i;for(let n=t;n<e.length;n++)(i=e[n]).schema??(i.schema=r)}function Fr(e,t,r){var i;let n=e.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?(i=e).schema??(i.schema=e.inst):e.schema=e.inst);let o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:Jc(e.inst?._zod.def?.error?.(e))??Jc(o?.(e))??Jc(t?.error?.(e))??Jc(r.customError?.(e))??Jc(r.localeError?.(e))??"Invalid input",s={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(s[c]=e[c]);return s.path??(s.path=[]),s.message=a,t?.reportInput&&(s.input=e.input),s}function nd(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var wV=/[\uD800-\uDBFF]/;function bs(e){let t=e.length;if(!wV.test(e))return t;let r=t;for(let i=0;i<t-1;i++)(e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320&&(r--,i++);return r}function id(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function R(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 tu(...e){let[t,r,i]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:i}:{...t}}function xV(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function mN(e){let t=atob(e),r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return r}function hN(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function SV(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return mN(t+r)}function kV(e){return hN(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function $V(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 i=0;i<t.length;i+=2)r[i/2]=Number.parseInt(t.slice(i,i+2),16);return r}function IV(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Mb=class{constructor(...t){}};function Hb(e,t){for(let r in t){let i=Object.getOwnPropertyDescriptor(t,r);i.get?Object.defineProperty(e,r,{...i,enumerable:!1}):TV(e,r,i.value)}}function ta(e,t,r,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:r}),r}function od(e,t,r){return ta(e,t,r,!1)}function EV(e,t){for(let r in e){let i=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return ta(this,r,i(this))},set(n){ta(this,r,n)}})}return t}function TV(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:ta(this,t,r.bind(this))},set(i){ta(this,t,i)}})}function AV(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var jb,ea=!1,CV={configurable:!0,get(){ea=!0}};function $e(e,t,r){let i=Object.getPrototypeOf(e._zod);if(t in i&&jb!==e._zod){jb=void 0;return}jb=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,CV);let n=ea;ea=!1;try{let o=r(this);return ea?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),ea=ea||n,o}catch(o){throw delete this[t],ea=ea||n,o}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function OV(e,t,r,i){let n=AV(e,t);n&&Object.defineProperty(n,t,{configurable:!0,get(){let o={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,o),o.value=r(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:o})}})}var Bm="~constantCatch";function Zb(e){let t=()=>e;return t[Bm]=!0,t}var gN,Kb=Object.freeze({status:"aborted"}),Gb={value:void 0,enumerable:!1},_N="captureStackTrace"in Error?Error:null;function PV(e){let t=_N;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return _N=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function $(e,t,r,i){let n={};function o(f){this.def=f,this.constr=d,this.traits=new Set}o.prototype=n;let a=r,s=a&&new WeakSet;function c(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{Gb.value=new o(p);try{Object.defineProperty(f,"_zod",Gb)}finally{Gb.value=void 0}}if(f._zod.traits.add(e),t(f,p),s){let h=Object.getPrototypeOf(f),g=f._zod.constr.prototype,_=h;for(;_&&_!==g;)_=Object.getPrototypeOf(_);let v=_??h;s.has(v)||(s.add(v),Hb(v,a))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in f||(f[h]=m[h].bind(f)))}let u=i?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let p=i?.Parent?PV(l):this;c(p,f);let m=p._zod.deferred;if(m){for(let g of m)g();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>i?.Parent&&f instanceof i.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Wb=Symbol("zod_brand"),Br=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ra=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(gN=globalThis).__zod_globalConfig??(gN.__zod_globalConfig={});var Gt=globalThis.__zod_globalConfig;function _t(e){return e&&Object.assign(Gt,e),Gt}function NV(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Yc,2)),e.message}function RV(e){this._zod.message=e}var jV={get:NV,set:RV,enumerable:!0,configurable:!0},Jb={value:void 0,enumerable:!1},yN=new WeakSet([Object.prototype,Error.prototype]),vN=(e,t)=>{e.name="$ZodError",Jb.value=t,Object.defineProperty(e,"issues",Jb),Jb.value=void 0,Object.defineProperty(e,"message",jV);let r=Object.getPrototypeOf(e);yN.has(r)||(yN.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}}))},Xb=$("$ZodError",vN),Vr=$("$ZodError",vN,void 0,{Parent:Error});function DV(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function ad(e,t=r=>r.message){let r={},i=[];for(let n of e.issues)n.path.length>0?DV(r,n.path[0],()=>[]).push(t(n)):i.push(t(n));return{formErrors:i,fieldErrors:r}}function sd(e,t=r=>r.message){let r={_errors:[]},i=(n,o=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>i({issues:s},[...o,...a.path]));else if(a.code==="invalid_key")i({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")i({issues:a.issues},[...o,...a.path]);else{let s=[...o,...a.path];if(s.length===0)r._errors.push(t(a));else{let c=r,u=0;for(;u<s.length;){let l=s[u],d=u===s.length-1;if(l==="_errors"){d&&c._errors.push(t(a)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[l];d&&f._errors.push(t(a)),c=f,u++}}}};return i(e),r}function Yb(e,t=r=>r.message){let r={errors:[]},i=(n,o=[])=>{var a;for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(c=>i({issues:c},[...o,...s.path]));else if(s.code==="invalid_key")i({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")i({issues:s.issues},[...o,...s.path]);else{let c=[...o,...s.path];if(c.length===0){r.errors.push(t(s));continue}let u=r,l=0;for(;l<c.length;){let d=c[l],f=l===c.length-1;typeof d=="string"?(u.properties??(u.properties={}),Object.prototype.hasOwnProperty.call(u.properties,d)||Object.defineProperty(u.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),u=u.properties[d]):(u.items??(u.items=[]),(a=u.items)[d]??(a[d]={errors:[]}),u=u.items[d]),f&&u.errors.push(t(s)),l++}}};return i(e),r}function bN(e){let t=[],r=e.map(i=>typeof i=="object"?i.key:i);for(let i of r)typeof i=="number"?t.push(`[${i}]`):typeof i=="symbol"?t.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?t.push(`[${JSON.stringify(i)}]`):(t.length&&t.push("."),t.push(i));return t.join("")}function Qb(e){let t=[],r=[...e.issues].sort((i,n)=>(i.path??[]).length-(n.path??[]).length);for(let i of r)t.push(`\u2716 ${i.message}`),i.path?.length&&t.push(` \u2192 at ${bN(i.path)}`);return t.join(`
163
+ `)}function Vm(e,t){return{callee:t?.callee??e,Err:t?.Err}}var ru=e=>{let t=(r,i,n,o)=>{let a=n?{...n,async:!1}:{async:!1},s=r._zod.run({value:i,issues:[]},a);if(s instanceof Promise)throw new Br;if(s.issues.length){let c=new(o?.Err??e)(s.issues.map(u=>Fr(u,a,_t())));throw Lm(c,o?.callee??t),c}return s.value};return t},na=ru(Vr),nu=e=>{let t=async(r,i,n,o)=>{let a=n?{...n,async:!0}:{async:!0},s=r._zod.run({value:i,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let c=new(o?.Err??e)(s.issues.map(u=>Fr(u,a,_t())));throw Lm(c,o?.callee??t),c}return s.value};return t},ws=nu(Vr),iu=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},n);if(o instanceof Promise)throw new Br;return o.issues.length?wN(e,o.issues,n):{success:!0,data:o.value}},zV=iu(Vr);function wN(e,t,r){let i;return{success:!1,get error(){return i||(i=new e(t.map(n=>Fr(n,r,_t()))),t=void 0,r=void 0),i},set error(n){i=n,t=void 0,r=void 0}}}var ou=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length?wN(e,o.issues,n):{success:!0,data:o.value}},LV=ou(Vr),UV=Symbol.for("zod.compile.invalid"),FV=Symbol.for("zod.compile.fallback"),cd=((e,t,r)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==UV)return!0;if(i.definite===!0&&r===void 0)return!1}return BV(e,t,r)});function BV(e,t,r){let i=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=e._zod.bag.fallbackRun,o;if(n?(i[FV]=!0,o=n({value:t,issues:[]},i)):o=e._zod.run({value:t,issues:[]},i),o instanceof Promise)throw new Br;return o.issues.length===0}var ud=async(e,t,r)=>{let i=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},i);return n instanceof Promise&&(n=await n),n.issues.length===0},Hm=e=>{let t=ru(e),r=(i,n,o,a)=>{let s=o?{...o,direction:"backward"}:{direction:"backward"};return t(i,n,s,Vm(r,a))};return r},VV=Hm(Vr),Zm=e=>{let t=ru(e),r=(i,n,o,a)=>t(i,n,o,Vm(r,a));return r},HV=Zm(Vr),Gm=e=>{let t=nu(e),r=async(i,n,o,a)=>{let s=o?{...o,direction:"backward"}:{direction:"backward"};return await t(i,n,s,Vm(r,a))};return r},ZV=Gm(Vr),Km=e=>{let t=nu(e),r=async(i,n,o,a)=>await t(i,n,o,Vm(r,a));return r},GV=Km(Vr),Wm=e=>(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return iu(e)(t,r,n)},KV=Wm(Vr),qm=e=>(t,r,i)=>iu(e)(t,r,i),WV=qm(Vr),Jm=e=>async(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return ou(e)(t,r,n)},qV=Jm(Vr),Xm=e=>async(t,r,i)=>ou(e)(t,r,i),JV=Xm(Vr);var vn={};ni(vn,{anyString:()=>Iw,base64:()=>_w,base64url:()=>yw,bigint:()=>Tw,boolean:()=>Aw,browserEmail:()=>iH,cidrv4:()=>hw,cidrv6:()=>gw,creditCard:()=>Ym,cuid:()=>tw,cuid2:()=>rw,currencyCode:()=>xw,date:()=>Sw,datetime:()=>$w,domain:()=>bw,duration:()=>cw,e164:()=>ww,email:()=>lw,emoji:()=>dw,extendedDuration:()=>XV,guid:()=>uw,hex:()=>Rw,hostname:()=>vw,html5Email:()=>tH,httpProtocol:()=>ld,iban:()=>Qm,idnEmail:()=>nH,integer:()=>dd,ipv4:()=>fw,ipv6:()=>pw,ksuid:()=>ow,lowercase:()=>Pw,mac:()=>mw,md5_base64:()=>cH,md5_base64url:()=>uH,md5_hex:()=>sH,nanoid:()=>aw,nanoidOfLength:()=>sw,null:()=>Cw,number:()=>no,rfc5322Email:()=>rH,sha1_base64:()=>dH,sha1_base64url:()=>fH,sha1_hex:()=>lH,sha256_base64:()=>mH,sha256_base64url:()=>hH,sha256_hex:()=>pH,sha384_base64:()=>_H,sha384_base64url:()=>yH,sha384_hex:()=>gH,sha512_base64:()=>bH,sha512_base64url:()=>wH,sha512_hex:()=>vH,string:()=>Ew,time:()=>kw,ulid:()=>nw,undefined:()=>Ow,unicodeEmail:()=>xN,uppercase:()=>Nw,uuid:()=>xs,uuid4:()=>YV,uuid6:()=>QV,uuid7:()=>eH,xid:()=>iw});var tw=/^[cC][0-9a-z]{6,}$/,rw=/^[0-9a-z]+$/,nw=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,iw=/^[0-9a-vA-V]{20}$/,ow=/^[A-Za-z0-9]{27}$/,aw=/^[a-zA-Z0-9_-]{21}$/;function sw(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var cw=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,XV=/^[-+]?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)?)??$/,uw=/^([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})$/,xs=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)$/,YV=xs(4),QV=xs(6),eH=xs(7),lw=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,tH=/^[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])?)*$/,rH=/^(([^<>()\[\]\\.,;:\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,}))$/,xN=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,nH=xN,iH=/^[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])?)*$/,oH="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function dw(){return new RegExp(oH,"u")}var fw=/^(?:(?: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])$/,pw=/^(([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}|:))$/,mw=e=>{let t=yn(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},hw=/^((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])$/,gw=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_w=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yw=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,vw=/^(?=.{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])?)*\.?$/,bw=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,ld=/^https?$/,ww=/^\+[1-9]\d{6,14}$/,Ym=/^\d(?:[ -]?\d){11,18}$/,xw=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,Qm=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,SN="(?:(?:\\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])))";function aH(e){return new RegExp(`^${e}$`)}var Sw=aH(SN);function ew(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}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function kw(e){return new RegExp(`^${ew(e)}$`)}function $w(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${ew({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${r}|${ew({precision:e.precision})}`:r;return new RegExp(`^${SN}T(?:${i})$`)}var Iw=/^[\s\S]{0,}$/,Ew=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Tw=/^-?\d+n?$/,dd=/^-?\d+$/,no=/^-?\d+(?:\.\d+)?$/,Aw=/^(?:true|false)$/i,Cw=/^null$/i;var Ow=/^undefined$/i;var Pw=/^[^A-Z]*$/,Nw=/^[^a-z]*$/,Rw=/^[0-9a-fA-F]*$/;function fd(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function pd(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var sH=/^[0-9a-fA-F]{32}$/,cH=fd(22,"=="),uH=pd(22),lH=/^[0-9a-fA-F]{40}$/,dH=fd(27,"="),fH=pd(27),pH=/^[0-9a-fA-F]{64}$/,mH=fd(43,"="),hH=pd(43),gH=/^[0-9a-fA-F]{96}$/,_H=fd(64,""),yH=pd(64),vH=/^[0-9a-fA-F]{128}$/,bH=fd(86,"=="),wH=pd(86);var Je=$("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),jw=e=>{let t=e.value;return!zm(t)&&t.size!==void 0},Dw=e=>{let t=e.value;return!zm(t)&&t.length!==void 0},eh={number:"number",bigint:"bigint",object:"date"},rh=$("$ZodCheckLessThan",(e,t)=>{Je.init(e,t);let r=eh[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:eh[typeof i.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nh=$("$ZodCheckGreaterThan",(e,t)=>{Je.init(e,t);let r=eh[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:eh[typeof i.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Mw=$("$ZodCheckMultipleOf",(e,t)=>{Je.init(e,t),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"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Yl(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})}}),zw=$("$ZodCheckNumberFormat",(e,t)=>{Je.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,o]=td[t.format];e._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}s<n&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Lw=$("$ZodCheckBigIntFormat",(e,t)=>{Je.init(e,t);let[r,i]=rd[t.format];e._zod.check=n=>{let o=n.value;o<r&&n.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),o>i&&n.issues.push({origin:"bigint",input:o,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Uw=$("$ZodCheckMaxSize",(e,t)=>{var r;Je.init(e,t),(r=e._zod.def).when??(r.when=jw),e._zod.check=i=>{let n=i.value;n.size<=t.maximum||i.issues.push({origin:nd(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Fw=$("$ZodCheckMinSize",(e,t)=>{var r;Je.init(e,t),(r=e._zod.def).when??(r.when=jw),e._zod.check=i=>{let n=i.value;n.size>=t.minimum||i.issues.push({origin:nd(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Bw=$("$ZodCheckSizeEquals",(e,t)=>{var r;Je.init(e,t),(r=e._zod.def).when??(r.when=jw),e._zod.check=i=>{let n=i.value,o=n.size;if(o===t.size)return;let a=o>t.size;i.issues.push({origin:nd(n),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Vw=$("$ZodCheckMaxLength",(e,t)=>{var r;Je.init(e,t),(r=e._zod.def).when??(r.when=Dw),e._zod.check=i=>{let n=i.value,o=n.length;if((typeof n=="string"&&o>t.maximum?bs(n):o)<=t.maximum)return;let s=id(n);i.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Hw=$("$ZodCheckMinLength",(e,t)=>{var r;Je.init(e,t),(r=e._zod.def).when??(r.when=Dw),e._zod.check=i=>{let n=i.value,o=n.length;if((typeof n=="string"&&o>=t.minimum&&o<t.minimum*2?bs(n):o)>=t.minimum)return;let s=id(n);i.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Zw=$("$ZodCheckLengthEquals",(e,t)=>{var r;Je.init(e,t),(r=e._zod.def).when??(r.when=Dw),e._zod.check=i=>{let n=i.value,o=n.length,a=typeof n=="string"&&o>=t.length&&o<=t.length*2?bs(n):o;if(a===t.length)return;let s=id(n),c=a>t.length;i.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),au=$("$ZodCheckStringFormat",(e,t)=>{var r,i;Je.init(e,t),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),Gw=$("$ZodCheckRegex",(e,t)=>{au.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})}}),Kw=$("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Pw),au.init(e,t)}),Ww=$("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Nw),au.init(e,t)}),qw=$("$ZodCheckIncludes",(e,t)=>{Je.init(e,t);let r=yn(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=i,e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Jw=$("$ZodCheckStartsWith",(e,t)=>{Je.init(e,t);let r=new RegExp(`^${yn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Xw=$("$ZodCheckEndsWith",(e,t)=>{Je.init(e,t);let r=new RegExp(`.*${yn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});function th(e,t,r){e.issues.length&&t.issues.push(...Ur(r,e.issues))}var Yw=$("$ZodCheckProperty",(e,t)=>{Je.init(e,t),e._zod.check=r=>{let i=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(i instanceof Promise)return i.then(n=>th(n,r,t.property));th(i,r,t.property)}}),Qw=$("$ZodCheckProperties",(e,t)=>{Je.init(e,t),od(e,Symbol.iterator,function*(){yield e});let r;e._zod.check=i=>{if(i.value==null){i.issues.push({expected:"object",code:"invalid_type",input:i.value,inst:e});return}r??(r=Reflect.ownKeys(t.shape).map(a=>[a,t.shape[a]]));let n=i.value,o;for(let[a,s]of r){let c=s._zod.run({value:n[a],issues:[]},{});c instanceof Promise?(o??(o=[]),o.push(c.then(u=>th(u,i,a)))):th(c,i,a)}if(o)return Promise.all(o).then(()=>{})}}),ex=$("$ZodCheckMimeType",(e,t)=>{Je.init(e,t);let r=new Set(t.mime);e._zod.check=i=>{r.has(i.value.type)||i.issues.push({code:"invalid_value",values:t.mime,input:i.value.type,inst:e,continue:!t.abort})}}),tx=$("$ZodCheckOverwrite",(e,t)=>{Je.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Ss=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let i=t.split(`
164
+ `).filter(a=>a),n=Math.min(...i.map(a=>a.length-a.trimStart().length)),o=i.map(a=>a.slice(n)).map(a=>" ".repeat(this.indent*2)+a);for(let a of o)this.content.push(a)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
165
+ ${r.join(`
166
+ `)}
167
+ };`)(...Object.values(this.closed))}};var rx={major:4,minor:6,patch:5};var _e=$("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=rx;let i=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let o of n)for(let a of o._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 o=(s,c,u)=>{if(s.memo)return s;let l=Tr(s),d;for(let f of c){if(f._zod.def.when){if(Vb(s)||!f._zod.def.when(s))continue}else if(l)continue;let p=s.issues.length,m=f._zod.check(s);if(m instanceof Promise&&u?.async===!1)throw new Br;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,s.issues.length!==p&&(Fm(s.issues,p,e),l||(l=Tr(s,p)))});else{if(s.issues.length===p)continue;Fm(s.issues,p,e),l||(l=Tr(s,p))}}return d?d.then(()=>s):s},a=(s,c,u)=>{if(Tr(s))return s.aborted=!0,s;let l=o(c,n,u);if(l instanceof Promise){if(u.async===!1)throw new Br;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){let l=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>a(d,s,c)):a(l,s,c)}let u=e._zod.parse(s,c);if(u instanceof Promise){if(c.async===!1)throw new Br;return u.then(l=>o(l,n,c))}return o(u,n,c)}}},{get"~standard"(){return od(this,"~standard",ch(this))},set"~standard"(e){ta(this,"~standard",e)}}),UN=(e,t)=>e.issues.length?{issues:e.issues.map(r=>Fr(r,t,_t()))}:{value:e.value};async function xH(e,t){let r={async:!0};return UN(await e._zod.run({value:t,issues:[]},r),r)}function ch(e){return{validate:t=>{let r={async:!1};try{let i=e._zod.run({value:t,issues:[]},r);if(!(i instanceof Promise))return UN(i,r)}catch{}return xH(e,t)},vendor:"zod",version:1}}var ks=$("$ZodString",(e,t)=>{_e.init(e,t),e._zod.pattern=t.pattern??Iw,e._zod.parse=(r,i)=>{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}}),Ze=$("$ZodStringFormat",(e,t)=>{au.init(e,t),ks.init(e,t)}),ix=$("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=uw),Ze.init(e,t)}),ox=$("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=xs(i))}else t.pattern??(t.pattern=xs());Ze.init(e,t)}),ax=$("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=lw),Ze.init(e,t)}),sx=1,md=2;function cx(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function uh(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?cx(e)||md:FN(e,t)}function FN(e,t){if(!t.normalize&&t.protocol?.source===ld.source&&!/^https?:\/\//i.test(e))return sx;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??md}return new URL(e)}catch{return md}}var SH=/[\t\n\r]/g;function hd(e){return e.replace(SH,"")}function lh(e,t){return t.lastIndex=0,t.test(e.hostname)}function dh(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var ux=$("$ZodURL",(e,t)=>{Ze.init(e,t),e._zod.check=r=>{try{let i=r.value.trim(),n=uh(i,t);if(n===sx){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(n===md){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(n===!0){r.value=hd(i);return}t.hostname&&!lh(n,t.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&&!dh(n,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?n.href:hd(i);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),lx=$("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=dw()),Ze.init(e,t)}),dx=$("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?aw:sw(t.length)),Ze.init(e,t)}),fx=$("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=tw),Ze.init(e,t)}),px=$("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=rw),Ze.init(e,t)}),mx=$("$ZodULID",(e,t)=>{t.pattern??(t.pattern=nw),Ze.init(e,t)}),hx=$("$ZodXID",(e,t)=>{t.pattern??(t.pattern=iw),Ze.init(e,t)}),gx=$("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ow),Ze.init(e,t)}),_x=$("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=$w(t)),Ze.init(e,t)}),yx=$("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Sw),Ze.init(e,t)}),vx=$("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=kw(t)),Ze.init(e,t)}),bx=$("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=cw),Ze.init(e,t)}),wx=$("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=fw),Ze.init(e,t)}),kH=/^[0-9a-fA-F:.]+$/;function gd(e){return kH.test(e)?cx(`http://[${e}]`):!1}var xx=$("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=pw),Ze.init(e,t),e._zod.check=r=>{gd(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),Sx=$("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=mw(t.delimiter)),Ze.init(e,t)}),kx=$("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=hw),Ze.init(e,t)});function fh(e){let t=e.split("/");if(t.length!==2)return!1;let[r,i]=t;if(!i)return!1;let n=Number(i);return`${n}`!==i||n<0||n>128?!1:gd(r)}var $x=$("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=gw),Ze.init(e,t),e._zod.check=r=>{fh(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function _d(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ph=/^[0-9a-zA-Z+/]*={0,2}$/,Ix=$("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ph),Ze.init(e,t),e._zod.check=r=>{_d(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),yd=/^[A-Za-z0-9_-]*$/;function mh(e){if(!yd.test(e))return!1;let t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return _d(r)}var Ex=$("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=yd),Ze.init(e,t),e._zod.check=r=>{mh(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Tx=$("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ww),Ze.init(e,t)}),$H=/[- ]/g;function IH(e){let t=e.length,r=1,i=0;for(;t;){let n=e.charCodeAt(--t)-48;r^=1,i+=r?[0,2,4,6,8,1,3,5,7,9][n]:n}return i%10===0}function hh(e){return Ym.test(e)?IH(e.replace($H,"")):!1}var Ax=$("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=Ym),Ze.init(e,t),e._zod.check=r=>{hh(r.value)||r.issues.push({code:"invalid_format",format:"credit_card",input:r.value,inst:e,continue:!t.abort})}});function EH(e){let t=0,r=e.length;for(let i=4;i<r;i++){let n=e.charCodeAt(i);t=(n>=65?t*100+(n-55):t*10+(n-48))%97}for(let i=0;i<4;i++){let n=e.charCodeAt(i);t=(n>=65?t*100+(n-55):t*10+(n-48))%97}return t===1}function gh(e){return Qm.test(e)?EH(e):!1}var Cx=$("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=Qm),Ze.init(e,t),e._zod.check=r=>{gh(r.value)||r.issues.push({code:"invalid_format",format:"iban",input:r.value,inst:e,continue:!t.abort})}});function _h(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[i]=r;if(!i)return!1;let n=JSON.parse(atob(i));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}var Ox=$("$ZodJWT",(e,t)=>{Ze.init(e,t),e._zod.check=r=>{_h(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Px=$("$ZodCustomStringFormat",(e,t)=>{Ze.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})}}),yh=$("$ZodNumber",(e,t)=>{_e.init(e,t),e._zod.pattern=no,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let o=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:String(n):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...o?{received:o}:{}}),r}}),Nx=$("$ZodNumberFormat",(e,t)=>{zw.init(e,t),yh.init(e,t)}),vd=$("$ZodBoolean",(e,t)=>{_e.init(e,t),e._zod.pattern=Aw,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=!!r.value}catch{}let n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),vh=$("$ZodBigInt",(e,t)=>{_e.init(e,t),e._zod.pattern=Tw,e._zod.parse=(r,i)=>{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}}),Rx=$("$ZodBigIntFormat",(e,t)=>{Lw.init(e,t),vh.init(e,t)}),jx=$("$ZodSymbol",(e,t)=>{_e.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return typeof n=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),Dx=$("$ZodUndefined",(e,t)=>{_e.init(e,t),e._zod.pattern=Ow,e._zod.values=new Set([void 0]),e._zod.parse=(r,i)=>{let n=r.value;return typeof n>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),Mx=$("$ZodNull",(e,t)=>{_e.init(e,t),e._zod.pattern=Cw,e._zod.values=new Set([null]),e._zod.parse=(r,i)=>{let n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),zx=$("$ZodAny",(e,t)=>{_e.init(e,t),e._zod.parse=r=>r}),bd=$("$ZodUnknown",(e,t)=>{_e.init(e,t),e._zod.parse=r=>r}),wd=$("$ZodNever",(e,t)=>{_e.init(e,t),e._zod.parse=(r,i)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Lx=$("$ZodVoid",(e,t)=>{_e.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return typeof n>"u"||r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),Ux=$("$ZodDate",(e,t)=>{_e.init(e,t),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let n=r.value,o=n instanceof Date;return o&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...o?{received:"Invalid Date"}:{},inst:e}),r}});function $N(e,t,r){e.issues.length&&t.issues.push(...Ur(r,e.issues)),t.value[r]=e.value}var Fx=$("$ZodArray",(e,t)=>{_e.init(e,t);let r=Gt.memoizer;r?.attach(e),e._zod.parse=(i,n)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),i;i.value=r?r.alloc(e,i,Array(o.length),n):Array(o.length);let a=[],s=n?.abortEarly;for(let c=0;c<o.length;c++){let u=o[c],l=t.element._zod.run({value:u,issues:[]},n);if(l instanceof Promise)a.push(l.then(d=>$N(d,i,c)));else if($N(l,i,c),s&&l.issues.length!==0&&Tr(l))break}return a.length?Promise.all(a).then(()=>i):i}});function sh(e,t,r,i,n,o){let a=r in i,s=o==="optional";if(!(!a&&s&&n==="optional")){if(e.issues.length){if(n!==void 0&&s&&!a)return;t.issues.push(...Ur(r,e.issues))}if(!a&&n===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(a||n==="defaulted"&&!s)&&(t.value[r]=void 0):t.value[r]=e.value}}var TH=[];function BN(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),i=r.length?r:TH,n=i.length?[...t,...i]:t;for(let a of n)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(a)}": expected a Zod schema`);let o=Bb(e.shape);return{...e,allKeys:n,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function VN(e,t,r,i,n,o,a){let s=[],c=n.keySet,u=n.catchall._zod,l=u.def.type,d=u.optin,f=u.optout,p=0;for(let m in t){if(a&&r.issues.length!==p){if(Tr(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){l==="never"&&s.push(m);continue}if(l==="never"){s.push(m);continue}let h=u.run({value:t[m],issues:[]},i);h instanceof Promise?e.push(h.then(g=>sh(g,r,m,t,d,f))):sh(h,r,m,t,d,f)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var HN=$("$ZodObject",(e,t)=>{_e.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),i=r?.get?r.get.raw:t.shape??{};if(i){let u=()=>{let l={...i};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=i,Object.defineProperty(t,"shape",{get:u})}let n=Qc(()=>BN(t));$e(e,"propValues",u=>{let l=u.def.shape,d={};for(let f in l){let p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||Qt(d,f,new Set);for(let m of p.values)d[f].add(m);p.optin!==void 0&&d[f].add(void 0)}}return d});let o=vs,a=t.catchall,s,c=Gt.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{s??(s=n.value);let d=u.value;if(!o(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let f=[],p=s.shape,m=l?.abortEarly,h=u.issues.length;for(let g of s.allKeys){if(m&&u.issues.length!==h){if(Tr(u,h))break;h=u.issues.length}if(g==="__proto__")continue;let _=p[g],v=_._zod.optin,x=_._zod.optout,S=_._zod.run({value:d[g],issues:[]},l);S instanceof Promise?f.push(S.then(k=>sh(k,u,g,d,v,x))):sh(S,u,g,d,v,x)}return a?VN(f,d,u,l,n.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),Bx=$("$ZodObjectJIT",(e,t)=>{HN.init(e,t);let r=e._zod.parse,i=Qc(()=>BN(t)),n=Gt.memoizer,o=p=>{let m=i.value,h=m.symbolKeys,g=new Ss(["payload","ctx"],{shape:p,inst:e,memo:n,syms:h}),_=k=>`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`,v=(k,T)=>`
168
+ let ${k}_ab = false;
169
+ for (let i = 0; i < ${k}.issues.length; i++) {
170
+ const iss = ${k}.issues[i];
171
+ iss.path = iss.path ? [${T}, ...iss.path] : [${T}];
172
+ payload.issues.push(iss);
173
+ if (iss.continue !== true) ${k}_ab = true;
174
+ }
175
+ if (${k}_ab && ctx && ctx.abortEarly) {
176
+ payload.value = newResult;
177
+ return payload;
178
+ }`;g.write("const input = payload.value;");let x=Object.create(null),S=0;for(let k of m.allKeys)x[k]=`key_${S++}`;g.write(n?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let k of m.allKeys){if(k==="__proto__")continue;let T=x[k],A=typeof k=="symbol"?`syms[${h.indexOf(k)}]`:Er(k),b=`${A} in input`,z=p[k],j=z?._zod?.optin,H=j!==void 0,ne=z?._zod?.optout==="optional";if(g.write(`const ${T} = ${_(A)};`),H&&ne){let ye=j==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;g.write(`
179
+ const ${T}_present = ${b};
180
+ if (!${T}.issues.length || ${T}_present) {
181
+ if (${T}.issues.length) {${v(T,A)}
182
+ }
183
+
184
+ if (${ye}) {
185
+ newResult[${A}] = ${T}.value;
186
+ }
187
+ }
188
+
189
+ `)}else H?(g.write(`
190
+ if (${T}.issues.length) {${v(T,A)}
191
+ }
192
+ `),j==="defaulted"?g.write(`newResult[${A}] = ${T}.value;`):g.write(`
193
+ if (${T}.value !== undefined || ${b}) {
194
+ newResult[${A}] = ${T}.value;
195
+ }
196
+ `)):g.write(`
197
+ const ${T}_present = ${b};
198
+ if (${T}.issues.length) {${v(T,A)}
199
+ }
200
+ if (!${T}_present && !${T}.issues.length) {
201
+ payload.issues.push({
202
+ code: "invalid_type",
203
+ expected: "nonoptional",
204
+ input: undefined,
205
+ path: [${A}]
206
+ });
207
+ if (ctx && ctx.abortEarly) {
208
+ payload.value = newResult;
209
+ return payload;
210
+ }
211
+ }
212
+
213
+ if (${T}_present) {
214
+ newResult[${A}] = ${T}.value;
215
+ }
216
+
217
+ `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},a,s=vs,c=!Gt.jitless,l=c&&Ub.value,d=t.catchall,f;e._zod.parse=(p,m)=>{f??(f=i.value);let h=p.value;return s(h)?c&&l&&m?.async===!1&&m.jitless!==!0?(a||(a=o(t.shape)),p=a(p,m),d?VN([],h,p,m,f,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p)}});function IN(e,t,r,i){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let n=e.filter(o=>!Tr(o));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(a=>Fr(a,i,_t())))}),t)}var xd=$("$ZodUnion",(e,t)=>{_e.init(e,t),$e(e,"optin",i=>i.def.options.some(n=>n._zod.optin==="defaulted")?"defaulted":i.def.options.some(n=>n._zod.optin!==void 0)?"optional":void 0),$e(e,"optout",i=>i.def.options.some(n=>n._zod.optout==="optional")?"optional":void 0),$e(e,"values",i=>{if(i.def.options.every(n=>n._zod.values))return new Set(i.def.options.flatMap(n=>Array.from(n._zod.values)))}),$e(e,"pattern",i=>{if(i.def.options.every(n=>n._zod.pattern)){let n=i.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>ro(o.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let o=!1,a=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},n);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(s=>IN(s,i,e,n)):IN(a,i,e,n)}});function EN(e,t,r,i){let n=[];for(let o=0;o<e.length;o++)e[o].issues.length===0&&n.push(o);return n.length===1?(t.value=e[n[0]].value,t):(n.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(a=>Fr(a,i,_t())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1,matches:n}),t)}var Vx=$("$ZodXor",(e,t)=>{xd.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let o=!1,a=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},n);c instanceof Promise?(a.push(c),o=!0):a.push(c)}return o?Promise.all(a).then(s=>EN(s,i,e,n)):EN(a,i,e,n)}});function Hx(e,t){let r=e._zod,i=r.bag.optionsMap;i||(i=ZN(r.def),r.bag.optionsMap=i);let n=i.get(t);if(n===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return n}function ZN(e){let t=new Map;for(let r of e.options){let i=r._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let n of i)if(t.has(n)){if(n!==void 0)throw new Error(`Duplicate discriminator value "${String(n)}"`);t.set(n,null)}else t.set(n,r)}return t}var Zx=$("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,xd.init(e,t);let r=e._zod.parse;$e(e,"propValues",n=>{let o={},a=0;for(let s of n.def.options){let c=s._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${n.def.options.indexOf(s)}"`);c[n.def.discriminator]?.has(void 0)&&a++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(o,u)||Qt(o,u,new Set);for(let d of l)o[u].add(d)}}return!n.def.unionFallback&&a>1&&o[n.def.discriminator]?.delete(void 0),o}),t.options.forEach((n,o)=>{let a=eu(n._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});let i=Qc(()=>ZN(t));e._zod.parse=(n,o)=>{let a=n.value;if(!vs(a))return n.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),n;let s=a?.[t.discriminator],c=i.value.get(s);return c&&(s!==void 0||o.direction!=="backward")?c._zod.run(n,o):t.unionFallback||o.direction==="backward"?r(n,o):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter(u=>i.value.get(u)!==null),input:a,path:[t.discriminator],inst:e}),n)}}),Gx=$("$ZodIntersection",(e,t)=>{_e.init(e,t),e._zod.parse=(r,i)=>{let n=r.value,o=t.left._zod.run({value:n,issues:[]},i),a=t.right._zod.run({value:n,issues:[]},i);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,u])=>TN(r,c,u)):TN(r,o,a)}});function su(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(_n(e)&&_n(t)){let r=Object.keys(t),i=Object.keys(e).filter(o=>r.indexOf(o)!==-1),n={...e,...t};Object.prototype.hasOwnProperty.call(n,"__proto__")&&delete n.__proto__;for(let o of i){if(o==="__proto__")continue;let a=su(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};n[o]=a.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let i=0;i<e.length;i++){let n=e[i],o=t[i],a=su(n,o);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function TN(e,t,r){let i=new Map,n,o=new Map,a=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)n??(n=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);o.has(f)||o.set(f,u),d=[f]}else return!1;for(let f of d)i.has(f)||i.set(f,{}),i.get(f)[l]=!0;return!0};for(let u of t.issues)a(u,"l")||e.issues.push(u);for(let u of r.issues)a(u,"r")||e.issues.push(u);let s=[...i].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(s.length){let u=n?s.filter(l=>n.keys.includes(l)):[];u.length&&e.issues.push({...n,keys:u});for(let l of s)!u.includes(l)&&o.has(l)&&e.issues.push(o.get(l))}let c=su(t.value,r.value);if(!c.valid){if(Tr(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var bh=$("$ZodTuple",(e,t)=>{_e.init(e,t);let r=t.items,i=Gt.memoizer;i?.attach(e),e._zod.parse=(n,o)=>{let a=n.value;if(!Array.isArray(a))return n.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=i?i.alloc(e,n,[],o):[];let s=[],c=AN(r,"optin"),u=AN(r,"optout");if(!t.rest){if(a.length<c)return n.issues.push({code:"too_small",minimum:c,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),d=t.rest?o?.abortEarly:void 0,f=!1;for(let p=0;p<r.length;p++){let m=r[p]._zod.run({value:a[p],issues:[]},o);m instanceof Promise?s.push(m.then(h=>{l[p]=h})):(l[p]=m,d&&!f&&m.issues.length&&(f=Tr(m)))}if(t.rest&&!f){let p=r.length-1,m=a.slice(r.length),h=n.issues.length;for(let g of m){if(d&&n.issues.length!==h){if(Tr(n,h))break;h=n.issues.length}p++;let _=t.rest._zod.run({value:g,issues:[]},o);_ instanceof Promise?s.push(_.then(v=>CN(v,n,p))):CN(_,n,p)}}return s.length?Promise.all(s).then(()=>ON(l,n,r,a,u)):ON(l,n,r,a,u)}});function AN(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function CN(e,t,r){e.issues.length&&t.issues.push(...Ur(r,e.issues)),t.value[r]=e.value}function ON(e,t,r,i,n){for(let o=0;o<r.length;o++){let a=e[o],s=o<i.length;if(!s&&o>=n&&r[o]._zod.optin==="optional"){t.value.length=o;break}if(a.issues.length){if(!s&&o>=n){t.value.length=o;break}t.issues.push(...Ur(o,a.issues))}t.value[o]=a.value}for(let o=t.value.length-1;o>=i.length&&(r[o]._zod.optout==="optional"&&t.value[o]===void 0);o--)t.value.length=o;return t}var Kx=$("$ZodRecord",(e,t)=>{_e.init(e,t);let r=Gt.memoizer;r?.attach(e),e._zod.parse=(i,n)=>{let o=i.value;if(!_n(o))return i.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),i;let a=[],s=t.keyType._zod.values;if(s&&!t.partial){i.value=r?r.alloc(e,i,{},n):{};let c=new Set;for(let l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>Fr(m,n,_t())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:o[l],issues:[]},n);p instanceof Promise?a.push(p.then(m=>{m.issues.length&&i.issues.push(...Ur(l,m.issues)),i.value[f]=m.value})):(p.issues.length&&i.issues.push(...Ur(l,p.issues)),i.value[f]=p.value)}let u;for(let l in o)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;i.value[l]=o[l]}else u=u??[],u.push(l);u&&u.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u,continue:!0})}else{i.value=r?r.alloc(e,i,{},n):{};let c;for(let u of Reflect.ownKeys(o)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},n);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&no.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},n);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(l=m)}if(l.issues.length){t.mode==="loose"?i.value[u]=o[u]:s?(c=c??[],c.push(u)):i.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>Fr(m,n,_t())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:o[u],issues:[]},n);p instanceof Promise?a.push(p.then(m=>{m.issues.length&&i.issues.push(...Ur(u,m.issues)),i.value[f]=m.value})):(p.issues.length&&i.issues.push(...Ur(u,p.issues)),i.value[f]=p.value)}c&&c.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c,continue:!0})}return a.length?Promise.all(a).then(()=>i):i}}),Wx=$("$ZodMap",(e,t)=>{_e.init(e,t);let r=Gt.memoizer;r?.attach(e),e._zod.parse=(i,n)=>{let o=i.value;if(!(o instanceof Map))return i.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),i;let a=[];i.value=r?r.alloc(e,i,new Map,n):new Map;let s=n?.abortEarly,c=i.issues.length;for(let[u,l]of o){if(s&&i.issues.length!==c){if(Tr(i,c))break;c=i.issues.length}let d=t.keyType._zod.run({value:u,issues:[]},n),f=t.valueType._zod.run({value:l,issues:[]},n);d instanceof Promise||f instanceof Promise?a.push(Promise.all([d,f]).then(([p,m])=>{PN(p,m,i,u,o,e,n)})):PN(d,f,i,u,o,e,n)}return a.length?Promise.all(a).then(()=>i):i}});function PN(e,t,r,i,n,o,a){e.issues.length&&(ed.has(typeof i)?r.issues.push(...Ur(i,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:o,issues:e.issues.map(s=>Fr(s,a,_t()))})),t.issues.length&&(ed.has(typeof i)?r.issues.push(...Ur(i,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:o,key:i,issues:t.issues.map(s=>Fr(s,a,_t()))})),r.value.set(e.value,t.value)}var qx=$("$ZodSet",(e,t)=>{_e.init(e,t);let r=Gt.memoizer;r?.attach(e),e._zod.parse=(i,n)=>{let o=i.value;if(!(o instanceof Set))return i.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),i;let a=[];i.value=r?r.alloc(e,i,new Set,n):new Set;let s=n?.abortEarly,c=i.issues.length;for(let u of o){if(s&&i.issues.length!==c){if(Tr(i,c))break;c=i.issues.length}let l=t.valueType._zod.run({value:u,issues:[]},n);l instanceof Promise?a.push(l.then(d=>NN(d,i))):NN(l,i)}return a.length?Promise.all(a).then(()=>i):i}});function NN(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Jx=$("$ZodEnum",(e,t)=>{_e.init(e,t);let r=Xc(t.entries),i=new Set(r);e._zod.values=i,$e(e,"pattern",n=>{let o=Xc(n.def.entries).filter(a=>ed.has(typeof a));return new RegExp(o.length?`^(${o.map(a=>yn(a.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let a=n.value;return i.has(a)||n.issues.push({code:"invalid_value",values:r,input:a,inst:e}),n}}),Xx=$("$ZodLiteral",(e,t)=>{_e.init(e,t);let r=new Set(t.values);e._zod.values=r,$e(e,"pattern",i=>{let n=i.def.values;return new RegExp(n.length?`^(${n.map(o=>typeof o=="string"?yn(o):o?yn(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,n)=>{let o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),Yx=$("$ZodFile",(e,t)=>{_e.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return n instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),Qx=$("$ZodTransform",(e,t)=>{_e.init(e,t),e._zod.optin="optional",Gt.memoizer?.guard(e),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new ra(e.constructor.name);let n=t.transform(r.value,r);if(i.async)return(n instanceof Promise?n:Promise.resolve(n)).then(a=>(r.value=a,r));if(n instanceof Promise)throw new Br;return r.value=n,r}});function RN(e,t){return e.value=t.issues.length?void 0:t.value,e}var $s=$("$ZodOptional",(e,t)=>{_e.init(e,t),$e(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",$e(e,"values",r=>{let i=r.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),$e(e,"pattern",r=>{let i=r.def.innerType._zod.pattern;return i?new RegExp(`^(${ro(i.source)})?$`):void 0}),e._zod.parse=(r,i)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let n=t.innerType._zod.run({value:r.value,issues:[]},i);return n instanceof Promise?n.then(o=>RN(r,o)):RN(r,n)}return t.innerType._zod.run(r,i)}}),e0=$("$ZodExactOptional",(e,t)=>{$s.init(e,t),$e(e,"values",r=>r.def.innerType._zod.values),$e(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,i)=>t.innerType._zod.run(r,i)}),t0=$("$ZodNullable",(e,t)=>{_e.init(e,t),$e(e,"optin",r=>r.def.innerType._zod.optin),$e(e,"optout",r=>r.def.innerType._zod.optout),$e(e,"pattern",r=>{let i=r.def.innerType._zod.pattern;return i?new RegExp(`^(${ro(i.source)}|null)$`):void 0}),$e(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,i)=>r.value===null?r:t.innerType._zod.run(r,i)}),r0=$("$ZodDefault",(e,t)=>{_e.init(e,t),e._zod.optin="defaulted",$e(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(o=>jN(o,t)):jN(n,t)}});function jN(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var n0=$("$ZodPrefault",(e,t)=>{_e.init(e,t),e._zod.optin="defaulted",$e(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,i)=>(i.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,i))}),i0=$("$ZodNonOptional",(e,t)=>{_e.init(e,t),$e(e,"values",r=>{let i=r.def.innerType._zod.values;return i?new Set([...i].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,i)=>{let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(o=>DN(o,e)):DN(n,e)}});function DN(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 o0=$("$ZodSuccess",(e,t)=>{_e.init(e,t),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new ra("ZodSuccess");let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(o=>(r.value=o.issues.length===0,r)):(r.value=n.issues.length===0,r)}});function MN(e,t,r,i){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(n=>Fr(n,i,_t()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var a0=$("$ZodCatch",(e,t)=>{_e.init(e,t),$e(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),$e(e,"optout",r=>r.def.innerType._zod.optout),$e(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);let n=t.innerType._zod.run({value:r.value,issues:[]},i);return n instanceof Promise?n.then(o=>MN(r,o,t,i)):MN(r,n,t,i)}}),s0=$("$ZodNaN",(e,t)=>{_e.init(e,t),e._zod.parse=(r,i)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),wh=$("$ZodPipe",(e,t)=>{_e.init(e,t),$e(e,"values",r=>r.def.in._zod.values),$e(e,"optin",r=>r.def.in._zod.optin),$e(e,"optout",r=>r.def.out._zod.optout),$e(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,i)=>{if(i.direction==="backward"){let o=t.out._zod.run(r,i);return o instanceof Promise?o.then(a=>ih(a,t.in,i)):ih(o,t.in,i)}let n=t.in._zod.run(r,i);return n instanceof Promise?n.then(o=>ih(o,t.out,i)):ih(n,t.out,i)}});function ih(e,t,r){return e.issues.some(i=>i.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Sd=$("$ZodCodec",(e,t)=>{_e.init(e,t),$e(e,"values",r=>r.def.in._zod.values),$e(e,"optin",r=>r.def.in._zod.optin),$e(e,"optout",r=>r.def.out._zod.optout),$e(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,i)=>{if((i.direction||"forward")==="forward"){let o=t.in._zod.run(r,i);return o instanceof Promise?o.then(a=>oh(a,t,i)):oh(o,t,i)}else{let o=t.out._zod.run(r,i);return o instanceof Promise?o.then(a=>oh(a,t,i)):oh(o,t,i)}}});function oh(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let n=t.transform(e.value,e);return n instanceof Promise?n.then(o=>ah(e,o,t.out,r)):ah(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(o=>ah(e,o,t.in,r)):ah(e,n,t.in,r)}}function ah(e,t,r,i){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},i)}var c0=$("$ZodPreprocess",(e,t)=>{wh.init(e,t)}),u0=$("$ZodReadonly",(e,t)=>{_e.init(e,t),$e(e,"propValues",r=>r.def.innerType._zod.propValues),$e(e,"values",r=>r.def.innerType._zod.values),$e(e,"optin",r=>r.def.innerType?._zod?.optin),$e(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(zN):zN(n)}});function zN(e){return e.memo||(e.value=Object.freeze(e.value)),e}function AH(e){let t=e._zod.def,r=t.pattern,i=!!t.format?.includes("int"),n,o;for(let s of t.checks??[]){let c=s._zod.def;c.pattern&&(r=c.pattern),i||(i=!!c.format?.includes("int"));let u=c.minimum??c.length,l=c.maximum??c.length;u!==void 0&&(n===void 0||u>n)&&(n=u),l!==void 0&&(o===void 0||l<o)&&(o=l)}if(r)return r.source;if(n!==void 0&&o!==void 0&&n>o)return"(?!)";if(n!==void 0||o!==void 0)return Ew({minimum:n,maximum:o}).source;let a=e._zod.pattern;return(i&&a===no?dd:a)?.source}function nx(e){let t=e._zod.def,r=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let n=i._zod.pattern?.source,o=nx(i);return r&&n&&o&&o!==n?r.replace(ro(n),()=>ro(o)):r}if(t.options){let n=t.options.map(nx);if(n.every(Boolean))return`^(${n.map(o=>ro(o)).join("|")})$`}return AH(e)}var l0=$("$ZodTemplateLiteral",(e,t)=>{_e.init(e,t);let r=[];for(let i of t.parts)if(typeof i=="object"&&i!==null){let n=nx(i);if(!n)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);r.push(ro(n))}else if(i===null||Fb.has(typeof i))r.push(yn(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(i,n)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i)}),d0=$("$ZodFunction",(e,t)=>(_e.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...i){let n=e._def.input?na(e._def.input,i):i,o=Reflect.apply(r,this,n);return e._def.output?na(e._def.output,o):o},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...i){let n=e._def.input?await ws(e._def.input,i):i,o=await Reflect.apply(r,this,n);return e._def.output?await ws(e._def.output,o):o},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(r,i)=>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 i=e.constructor;return Array.isArray(r[0])?new i({type:"function",input:new bh({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new i({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let i=e.constructor;return new i({type:"function",input:e._def.input,output:r})},e)),f0=$("$ZodPromise",(e,t)=>{_e.init(e,t),e._zod.parse=(r,i)=>Promise.resolve(r.value).then(n=>t.innerType._zod.run({value:n,issues:[]},i))}),kd=$("$ZodLazy",(e,t)=>{_e.init(e,t),zb(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),$e(e,"pattern",r=>r.innerType?._zod?.pattern),$e(e,"propValues",r=>r.innerType?._zod?.propValues),$e(e,"optin",r=>r.innerType?._zod?.optin??void 0),$e(e,"optout",r=>r.innerType?._zod?.optout??void 0),e._zod.parse=(r,i)=>e._zod.innerType._zod.run(r,i)}),p0=$("$ZodCustom",(e,t)=>{Je.init(e,t),_e.init(e,t),e._zod.parse=(r,i)=>r,e._zod.check=r=>{let i=r.value,n=t.fn(i);if(n instanceof Promise)return n.then(o=>LN(o,r,i,e));LN(n,r,i,e)}});function LN(e,t,r,i){if(!e){let n={code:"custom",input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(n.params=i._zod.def.params),t.issues.push(tu(n))}}var $h=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},h0="~memo",KN=[];function WN(e){return e!==null&&typeof e=="object"}function m0(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var qN=new WeakMap,cu=0,kh=1,$d=2;function Id(e,t,r){let i=qN.get(e);if(i!==void 0)return i?$d:cu;if(t.has(e))return $d;t.add(e);let n=cu,o=l=>{if(n!==$d&&l?._zod){let d=Id(l,t,r);d>n&&(n=d)}},a=(l,d)=>{let f=cu;for(let p of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,p);if(d&&!m.enumerable)continue;let h=m.get?kh:m.value?._zod?Id(m.value,t,r):cu;h>f&&(f=h)}return f},s=l=>{l>n&&(n=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=eu(c);s(l?a(l,!0):kh),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(let l of c.items)o(l);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(let l of c.options)o(l);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);s(l?Id(l,t,!1):kh);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)o(f);else if(Array.isArray(f))for(let p of f)o(p)}}}return t.delete(e),CH(e,n)}function CH(e,t){return t!==kh&&qN.set(e,t===$d),t}function Ih(e){return Id(e,new Set,!0)!==cu}function OH(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var xh,Sh=[],PH={alloc(e,t,r){let i=xh;if(!i)return r;xh=void 0;let n={value:r,issues:null};return i.set(t.value,n),Sh.push(n),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,i=(n,o)=>{if(o.direction!=="backward"&&Eh(o,n.value))throw new $h;return r(n,o)};e._zod.parse=i,e._zod.run===r&&(e._zod.run=i)})},attach(e){var t;let r,i=!1,n,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let a=e._zod.parse,s=(c,u)=>{if(r===void 0){let _=Id(e,new Set,!1);if(_===cu)return e._zod.parse=a,e._zod.run===s&&(e._zod.run=a),a(c,u);_===$d||i?r=!0:i=!0}let l=c.value;if(!WN(l))return a(c,u);let d=u[h0];d||(d={buckets:new WeakMap,backEdges:void 0},u[h0]=d);let f;n===u?f=o:(f=OH(d,e),n=u,o=f);let p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...m0(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;xh=f;let m=Sh.length,h=a(c,u);xh=void 0;let g=Sh.length>m?Sh.pop():void 0;return h instanceof Promise?h.then(_=>(g&&(g.issues=_.issues.length?m0(_.issues):KN),_)):(g&&(g.issues=h.issues.length?m0(h.issues):KN),h)};e._zod.parse=s,e._zod.run===a&&(e._zod.run=s)})}};function Ed(){return PH}function Eh(e,t){let r=e[h0]?.backEdges;return r!==void 0&&WN(t)&&r.has(t)}var Ad={};ni(Ad,{ar:()=>JN,az:()=>XN,be:()=>QN,bg:()=>e1,bn:()=>t1,ca:()=>r1,ckb:()=>n1,cs:()=>i1,da:()=>o1,de:()=>a1,el:()=>s1,en:()=>Th,eo:()=>c1,es:()=>u1,fa:()=>l1,fi:()=>d1,fr:()=>f1,frCA:()=>p1,gu:()=>m1,he:()=>h1,hi:()=>g1,hr:()=>_1,hu:()=>y1,hy:()=>b1,id:()=>w1,is:()=>x1,it:()=>S1,ja:()=>k1,ka:()=>$1,kh:()=>I1,km:()=>Ah,kn:()=>E1,ko:()=>T1,lt:()=>C1,mk:()=>O1,ms:()=>P1,ne:()=>N1,nl:()=>R1,nn:()=>j1,no:()=>D1,ota:()=>M1,pl:()=>L1,ps:()=>z1,pt:()=>U1,ptBR:()=>F1,ro:()=>B1,ru:()=>H1,sk:()=>Z1,sl:()=>G1,sv:()=>K1,ta:()=>W1,tg:()=>q1,th:()=>J1,tk:()=>X1,tr:()=>Y1,ua:()=>Q1,uk:()=>Ch,ur:()=>eR,uz:()=>tR,vi:()=>rR,yo:()=>oR,zhCN:()=>nR,zhTW:()=>iR});var NH=()=>{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"},map:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(n){return e[n]??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",mac:"\u0639\u0646\u0648\u0627\u0646 MAC",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",credit_card:"\u0631\u0642\u0645 \u0628\u0637\u0627\u0642\u0629 \u0627\u0644\u0627\u0626\u062A\u0645\u0627\u0646",currency_code:"\u0631\u0645\u0632 \u0627\u0644\u0639\u0645\u0644\u0629",iban:"IBAN",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.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 ${n.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 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`}case"invalid_value":return n.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 ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${n.maximum.toString()} ${a.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 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${n.minimum.toString()} ${a.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.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 "${n.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`${r[o.format]??n.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 ${n.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${n.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${n.keys.length>1?"\u0629":""}: ${I(n.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.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 ${n.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function JN(){return{localeError:NH()}}var RH=()=>{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"},map:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??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",credit_card:"kredit kart\u0131 n\xF6mr\u0259si",currency_code:"valyuta kodu",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${n.expected}, daxil olan ${s}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${s}`}case"invalid_value":return n.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${P(n.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${o}${n.maximum.toString()} ${a.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${o}${n.minimum.toString()} ${a.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[o.format]??n.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${n.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${n.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function XN(){return{localeError:RH()}}function YN(e,t,r,i){let n=Math.abs(e),o=n%10,a=n%100;return a>=11&&a<=19?i:o===1?t:o>=2&&o<=4?r:i}var jH=()=>{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"},map:{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(n){return e[n]??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",mac:"MAC \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",credit_card:"\u043D\u0443\u043C\u0430\u0440 \u043A\u0440\u044D\u0434\u044B\u0442\u043D\u0430\u0439 \u043A\u0430\u0440\u0442\u044B",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u044B",iban:"IBAN",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${n.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 ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`}case"invalid_value":return n.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 ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);if(a){let s=Number(n.maximum),c=YN(s,a.unit.one,a.unit.few,a.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 ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${o}${n.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 ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);if(a){let s=Number(n.minimum),c=YN(s,a.unit.one,a.unit.few,a.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 ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${o}${n.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 ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[o.format]??n.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 ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${n.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${n.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 ${n.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function QN(){return{localeError:jH()}}var DH=()=>{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"},map:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(n){return e[n]??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",mac:"MAC \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",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043D\u0430 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u0430 \u043A\u0430\u0440\u0442\u0430",currency_code:"\u043A\u043E\u0434 \u043D\u0430 \u0432\u0430\u043B\u0443\u0442\u0430",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${n.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 ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${n.maximum.toString()} ${a.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 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${n.minimum.toString()} ${a.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;if(o.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 "${o.prefix}"`;if(o.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 "${o.suffix}"`;if(o.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 "${o.includes}"`;if(o.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 ${o.pattern}`;let a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${a} ${r[o.format]??n.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 ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${n.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u043E\u0432\u0435":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${n.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 ${n.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function e1(){return{localeError:DH()}}var MH=()=>{let e={string:{unit:"\u0985\u0995\u09CD\u09B7\u09B0",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},file:{unit:"\u09AC\u09BE\u0987\u099F",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},array:{unit:"\u0986\u0987\u099F\u09C7\u09AE",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},set:{unit:"\u0986\u0987\u099F\u09C7\u09AE",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},map:{unit:"\u098F\u09A8\u09CD\u099F\u09CD\u09B0\u09BF",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"}};function t(n){return e[n]??null}let r={regex:"\u0987\u09A8\u09AA\u09C1\u099F",email:"\u0987\u09AE\u09C7\u0987\u09B2 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",url:"URL",emoji:"\u0987\u09AE\u09CB\u099C\u09BF",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u09A4\u09BE\u09B0\u09BF\u0996 \u0993 \u09B8\u09AE\u09AF\u09BC",date:"ISO \u09A4\u09BE\u09B0\u09BF\u0996",time:"ISO \u09B8\u09AE\u09AF\u09BC",duration:"ISO \u09B8\u09AE\u09AF\u09BC\u0995\u09BE\u09B2",ipv4:"IPv4 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",ipv6:"IPv6 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",mac:"MAC \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",cidrv4:"IPv4 \u09B0\u09C7\u099E\u09CD\u099C",cidrv6:"IPv6 \u09B0\u09C7\u099E\u09CD\u099C",base64:"base64-\u098F\u09A8\u0995\u09CB\u09A1\u09C7\u09A1 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",base64url:"base64url-\u098F\u09A8\u0995\u09CB\u09A1\u09C7\u09A1 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",json_string:"JSON \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",e164:"E.164 \u09A8\u09AE\u09CD\u09AC\u09B0",credit_card:"\u0995\u09CD\u09B0\u09C7\u09A1\u09BF\u099F \u0995\u09BE\u09B0\u09CD\u09A1 \u09A8\u09AE\u09CD\u09AC\u09B0",currency_code:"\u09AE\u09C1\u09A6\u09CD\u09B0\u09BE \u0995\u09CB\u09A1",iban:"IBAN",jwt:"JWT",template_literal:"\u0987\u09A8\u09AA\u09C1\u099F"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return`\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F: \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${o}, \u09AA\u09CD\u09B0\u09BE\u09AA\u09CD\u09A4 ${s}`}case"invalid_value":return n.values.length===1?`\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F: \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${P(n.values[0])}`:`\u0985\u09AC\u09C8\u09A7 \u0985\u09AA\u09B6\u09A8: ${I(n.values," | ")} \u098F\u09B0 \u09AE\u09A7\u09CD\u09AF\u09C7 \u098F\u0995\u099F\u09BF \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u0985\u09A8\u09C7\u0995 \u09AC\u09A1\u09BC: ${n.origin??"\u09AE\u09BE\u09A8"} ${o}${n.maximum.toString()} ${a.unit??"\u098F\u09B2\u09BF\u09AE\u09C7\u09A8\u09CD\u099F"} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09A8\u09C7\u0995 \u09AC\u09A1\u09BC: ${n.origin??"\u09AE\u09BE\u09A8"} ${o}${n.maximum.toString()} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u0985\u09A8\u09C7\u0995 \u099B\u09CB\u099F: ${n.origin} ${o}${n.minimum.toString()} ${a.unit} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09A8\u09C7\u0995 \u099B\u09CB\u099F: ${n.origin} ${o}${n.minimum.toString()} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${o.prefix}" \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B6\u09C1\u09B0\u09C1 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:o.format==="ends_with"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${o.suffix}" \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B6\u09C7\u09B7 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:o.format==="includes"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${o.includes}" \u0985\u09A8\u09CD\u09A4\u09B0\u09CD\u09AD\u09C1\u0995\u09CD\u09A4 \u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7`:o.format==="regex"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: ${o.pattern} \u09AA\u09CD\u09AF\u09BE\u099F\u09BE\u09B0\u09CD\u09A8 \u09AE\u09BF\u09B2\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09AC\u09C8\u09A7 ${r[o.format]??n.format}`}case"not_multiple_of":return`\u0985\u09AC\u09C8\u09A7 \u09A8\u09AE\u09CD\u09AC\u09B0: ${n.divisor} \u098F\u09B0 \u0997\u09C1\u09A3\u09BF\u09A4\u0995 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`;case"unrecognized_keys":return`\u0985\u099A\u09C7\u09A8\u09BE \u0995\u09C0${n.keys.length>1?"\u0997\u09C1\u09B2\u09CB":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u098F \u0985\u09AC\u09C8\u09A7 \u0995\u09C0`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0985\u09AC\u09C8\u09A7 \u09A1\u09BF\u09B8\u0995\u09CD\u09B0\u09BF\u09AE\u09BF\u09A8\u09C7\u099F\u09B0 \u09AE\u09BE\u09A8\u0964 \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${n.options.map(a=>`'${a}'`).join(" | ")}`:"\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F";case"invalid_element":return`${n.origin} \u098F \u0985\u09AC\u09C8\u09A7 \u09AE\u09BE\u09A8`;default:return"\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F"}}};function t1(){return{localeError:MH()}}var zH=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"},map:{unit:"elements",verb:"contenir"}};function t(n){return e[n]??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",mac:"adre\xE7a MAC",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",credit_card:"n\xFAmero de targeta de cr\xE8dit",currency_code:"codi de moneda",iban:"IBAN",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${n.expected}, s'ha rebut ${s}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${s}`}case"invalid_value":return n.values.length===1?`Valor inv\xE0lid: s'esperava ${P(n.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${I(n.values," o ")}`;case"too_big":{let o=n.inclusive?"com a m\xE0xim":"menys de",a=t(n.origin);return a?`Massa gran: s'esperava que ${n.origin??"el valor"} contingu\xE9s ${o} ${n.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${n.origin??"el valor"} fos ${o} ${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?"com a m\xEDnim":"m\xE9s de",a=t(n.origin);return a?`Massa petit: s'esperava que ${n.origin} contingu\xE9s ${o} ${n.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${n.origin} fos ${o} ${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${r[o.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${n.divisor}`;case"unrecognized_keys":return`Clau${n.keys.length>1?"s":""} no reconeguda${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${n.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${n.origin}`;default:return"Entrada inv\xE0lida"}}};function r1(){return{localeError:zH()}}var LH=()=>{let e={string:{unit:"\u067E\u06CC\u062A",verb:"\u0628\u06CE\u062A"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u0628\u06CE\u062A"},array:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"},set:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"},map:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"}};function t(n){return e[n]??null}let r={regex:"regex",email:"\u0626\u06CC\u0645\u06D5\u06CC\u06B5",url:"\u0628\u06D5\u0633\u062A\u06D5\u0631 (URL)",emoji:"\u0626\u06CC\u0645\u06C6\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0695\u06CE\u06A9\u06D5\u0648\u062A \u0648 \u06A9\u0627\u062A",date:"\u0695\u06CE\u06A9\u06D5\u0648\u062A",time:"\u06A9\u0627\u062A",duration:"\u0645\u0627\u0648\u06D5",ipv4:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC IPv4",ipv6:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC IPv6",mac:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC MAC",cidrv4:"\u0645\u06D5\u0648\u062F\u0627\u06CC IPv4",cidrv6:"\u0645\u06D5\u0648\u062F\u0627\u06CC IPv6",base64:"\u062F\u06D5\u0642\u06CC base64",base64url:"\u062F\u06D5\u0642\u06CC base64url",json_string:"\u062F\u06D5\u0642\u06CC JSON",e164:"\u0698\u0645\u0627\u0631\u06D5\u06CC E.164",credit_card:"\u0698\u0645\u0627\u0631\u06D5\u06CC \u06A9\u0627\u0631\u062A\u06CC \u06A9\u0631\u06CE\u062F\u06CC\u062A",currency_code:"\u06A9\u06C6\u062F\u06CC \u062F\u0631\u0627\u0648",iban:"IBAN",jwt:"JWT",template_literal:"\u062A\u06CE\u06A9\u0631\u062F\u06D5"},i={nan:"NaN",string:"\u0646\u0648\u0648\u0633\u06CC\u0646",number:"\u0698\u0645\u0627\u0631\u06D5",boolean:"boolean",array:"array",object:"object",date:"\u0695\u06CE\u06A9\u06D5\u0648\u062A",integer:"\u0698\u0645\u0627\u0631\u06D5",float:"\u0698\u0645\u0627\u0631\u06D5",null:"null",undefined:"undefined",function:"function",symbol:"symbol",unknown:"unknown",promise:"promise",void:"void",never:"never",map:"map",set:"set"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a,c=["\u0627","\u0648","\u06C6","\u0648\u0648","\u06D5","\u06CC","\u06CE"].some(l=>s.endsWith(l))?"\u06CC\u06D5":"\u06D5",u=/^[a-zA-Z]+$/.test(s);return a==="null"||a==="undefined"?"\u062F\u0627\u0648\u0627\u06A9\u0631\u0627\u0648\u06D5":`\u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 ${o} \u0628\u06CE\u062A\u060C \u0628\u06D5\u06B5\u0627\u0645 ${s}${u?"":c}`}case"invalid_value":return n.values.length===1?`\u0628\u06D5\u0647\u0627\u06A9\u06D5 \u0646\u0627\u062F\u0631\u0648\u0648\u0633\u062A\u06D5: \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 ${P(n.values[0])} \u0628\u06CE\u062A`:`\u0647\u06D5\u06B5\u0628\u0698\u0627\u0631\u062F\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 \u06CC\u06D5\u06A9\u06CE\u06A9 \u0628\u06CE\u062A \u0644\u06D5 ${I(n.values,"|")}`;case"too_big":{let o=t(n.origin);return o?`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u0632\u06C6\u0631\u06D5\u0648\u06D5 ${n.maximum.toString()} ${o.unit} ${o.verb}`:`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u0632\u06C6\u0631\u06D5\u0648\u06D5 ${n.maximum.toString()} \u0628\u06CE\u062A`}case"too_small":{let o=t(n.origin);return o?`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u06A9\u06D5\u0645\u06D5\u0648\u06D5 ${n.minimum.toString()} ${o.unit} ${o.verb}`:`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u06A9\u06D5\u0645\u06D5\u0648\u06D5 ${n.minimum.toString()} \u0628\u06CE\u062A`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u062F\u06D5\u0633\u062A\u067E\u06CE\u0628\u06A9\u0627\u062A \u0628\u06D5 "${o.prefix}"`:o.format==="ends_with"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u06A9\u06C6\u062A\u0627\u06CC\u06CC\u0628\u06CE\u062A \u0628\u06D5 "${o.suffix}"`:o.format==="includes"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 "${o.includes}" \u0644\u06D5\u062E\u06C6\u0628\u06AF\u0631\u06CE\u062A`:o.format==="regex"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0644\u06D5\u06AF\u06D5\u06B5 \u067E\u0627\u062A\u06CE\u0631\u0646\u06CC ${o.pattern} \u0628\u06AF\u0648\u0646\u062C\u06CE\u062A`:`\u0628\u06D5\u0647\u0627\u06CC ${r[o.format]??n.format} \u0646\u0627\u062F\u0631\u0648\u0633\u062A\u06D5`}case"not_multiple_of":return`\u0698\u0645\u0627\u0631\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u062F\u06D5\u0628\u06CE\u062A \u0686\u06D5\u0646\u062F \u0647\u06CE\u0646\u062F\u06D5 \u0628\u06CE\u062A \u0628\u06C6 ${n.divisor}`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u0644\u06CC \u0646\u06D5\u0646\u0627\u0633\u0631\u0627\u0648: ${I(n.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u0644\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A \u0644\u06D5 ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0628\u06D5\u0647\u0627\u06CC \u0646\u06D5\u0646\u0627\u0633\u0631\u0627\u0648 \u0647\u06D5\u06CC\u06D5. \u0628\u06D5\u0647\u0627\u06CC \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648: ${n.options.map(a=>`'${a}'`).join(" | ")}`:"\u06CC\u06D5\u06A9\u06AF\u0631\u062A\u0646\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A";case"invalid_element":return`${n.origin} \u0628\u06D5\u0647\u0627\u06A9\u06D5 \u0646\u0627\u062F\u0631\u0648\u0633\u062A\u06D5`;default:return"\u062A\u06CE\u06A9\u0631\u062F\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A"}}};function n1(){return{localeError:LH()}}var UH=()=>{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"},map:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(n){return e[n]??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",mac:"MAC 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",credit_card:"\u010D\xEDslo kreditn\xED karty",currency_code:"k\xF3d m\u011Bny",iban:"IBAN",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${n.expected}, obdr\u017Eeno ${s}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${s}`}case"invalid_value":return n.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${P(n.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${o}${n.maximum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${o}${n.minimum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${r[o.format]??n.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${n.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${I(n.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${n.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${n.origin}`;default:return"Neplatn\xFD vstup"}}};function i1(){return{localeError:UH()}}var FH=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"},map:{unit:"elementer",verb:"indeholdt"}};function t(n){return e[n]??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-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kreditkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Ugyldigt input: forventede instanceof ${n.expected}, fik ${s}`:`Ugyldigt input: forventede ${o}, fik ${s}`}case"invalid_value":return n.values.length===1?`Ugyldig v\xE6rdi: forventede ${P(n.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin),s=i[n.origin]??n.origin;return a?`For stor: forventede ${s??"value"} ${a.verb} ${o} ${n.maximum.toString()} ${a.unit??"elementer"}`:`For stor: forventede ${s??"value"} havde ${o} ${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin),s=i[n.origin]??n.origin;return a?`For lille: forventede ${s} ${a.verb} ${o} ${n.minimum.toString()} ${a.unit}`:`For lille: forventede ${s} havde ${o} ${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??n.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${n.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${n.origin}`;default:return"Ugyldigt input"}}};function o1(){return{localeError:FH()}}var BH=()=>{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"},map:{unit:"Elemente",verb:"zu haben"}};function t(n){return e[n]??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",mac:"MAC-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",credit_card:"Kreditkartennummer",currency_code:"W\xE4hrungscode",iban:"IBAN",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${n.expected}, erhalten ${s}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${s}`}case"invalid_value":return n.values.length===1?`Ung\xFCltige Eingabe: erwartet ${P(n.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${o}${n.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${o}${n.maximum.toString()} ist`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Zu klein: erwartet, dass ${n.origin} ${o}${n.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${n.origin} ${o}${n.minimum.toString()} ist`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${r[o.format]??n.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${n.divisor} sein`;case"unrecognized_keys":return`${n.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${n.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${n.origin}`;default:return"Ung\xFCltige Eingabe"}}};function a1(){return{localeError:BH()}}var VH=()=>{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(n){return e[n]??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",credit_card:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 \u03C0\u03B9\u03C3\u03C4\u03C9\u03C4\u03B9\u03BA\u03AE\u03C2 \u03BA\u03AC\u03C1\u03C4\u03B1\u03C2",currency_code:"\u03BA\u03C9\u03B4\u03B9\u03BA\u03CC\u03C2 \u03BD\u03BF\u03BC\u03AF\u03C3\u03BC\u03B1\u03C4\u03BF\u03C2",iban:"IBAN",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return typeof n.expected=="string"&&/^[A-Z]/.test(n.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 ${n.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 ${o}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`}case"invalid_value":return n.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 ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${n.maximum.toString()} ${a.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 ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${n.minimum.toString()} ${a.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[o.format]??n.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 ${n.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${n.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${n.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${n.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 ${n.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function s1(){return{localeError:VH()}}var HH=()=>{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(o){return e[o]??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",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function n(o,a){return o==="number"&&typeof a=="number"&&!Number.isFinite(a)?String(a):i[o]??o}return o=>{switch(o.code){case"invalid_type":{let a=n(o.expected),s=R(o.input),c=n(s,o.input);return`Invalid input: expected ${a}, received ${c}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${P(o.values[0])}`:`Invalid option: expected one of ${I(o.values,"|")}`;case"too_big":{let a=o.exact?"exactly ":o.inclusive?"<=":"<",s=t(o.origin);return s?`Too big: expected ${o.origin??"value"} to have ${a}${o.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${a}${o.maximum.toString()}`}case"too_small":{let a=o.exact?"exactly ":o.inclusive?">=":">",s=t(o.origin);return s?`Too small: expected ${o.origin} to have ${a}${o.minimum.toString()} ${s.unit}`:`Too small: expected ${o.origin} to be ${a}${o.minimum.toString()}`}case"invalid_format":{let a=o;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]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${I(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(s=>`'${s}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function Th(){return{localeError:HH()}}var ZH=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"},map:{unit:"elementojn",verb:"havi"}};function t(n){return e[n]??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",mac:"MAC-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",credit_card:"kreditkarta numero",currency_code:"valuta kodo",iban:"IBAN",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${n.expected}, ricevi\u011Dis ${s}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${s}`}case"invalid_value":return n.values.length===1?`Nevalida enigo: atendi\u011Dis ${P(n.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${o}${n.maximum.toString()} ${a.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Tro malgranda: atendi\u011Dis ke ${n.origin} havu ${o}${n.minimum.toString()} ${a.unit}`:`Tro malgranda: atendi\u011Dis ke ${n.origin} estu ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${r[o.format]??n.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${n.divisor}`;case"unrecognized_keys":return`Nekonata${n.keys.length>1?"j":""} \u015Dlosilo${n.keys.length>1?"j":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${n.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${n.origin}`;default:return"Nevalida enigo"}}};function c1(){return{localeError:ZH()}}var GH=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(n){return e[n]??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",mac:"direcci\xF3n MAC",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",credit_card:"n\xFAmero de tarjeta de cr\xE9dito",currency_code:"c\xF3digo de moneda",iban:"IBAN",jwt:"JWT",template_literal:"entrada"},i={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 n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${n.expected}, recibido ${s}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${s}`}case"invalid_value":return n.values.length===1?`Entrada inv\xE1lida: se esperaba ${P(n.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin),s=i[n.origin]??n.origin;return a?`Demasiado grande: se esperaba que ${s??"valor"} tuviera ${o}${n.maximum.toString()} ${a.unit??"elementos"}`:`Demasiado grande: se esperaba que ${s??"valor"} fuera ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin),s=i[n.origin]??n.origin;return a?`Demasiado peque\xF1o: se esperaba que ${s} tuviera ${o}${n.minimum.toString()} ${a.unit}`:`Demasiado peque\xF1o: se esperaba que ${s} fuera ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${r[o.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Llave${n.keys.length>1?"s":""} desconocida${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[n.origin]??n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[n.origin]??n.origin}`;default:return"Entrada inv\xE1lida"}}};function u1(){return{localeError:GH()}}var KH=()=>{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"},map:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(n){return e[n]??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",mac:"MAC \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",credit_card:"\u0634\u0645\u0627\u0631\u0647 \u06A9\u0627\u0631\u062A \u0627\u0639\u062A\u0628\u0627\u0631\u06CC",currency_code:"\u06A9\u062F \u0627\u0631\u0632",iban:"IBAN",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${n.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 ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return n.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${P(n.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(n.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${n.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${n.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${o}${n.minimum.toString()} ${a.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${o}${n.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[o.format]??n.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 ${n.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${n.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${I(n.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${n.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 ${n.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function l1(){return{localeError:KH()}}var WH=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},map:{unit:"alkiota",subject:"kuvauksen"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(n){return e[n]??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",mac:"MAC-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",credit_card:"luottokortin numero",currency_code:"valuuttakoodi",iban:"IBAN",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Virheellinen tyyppi: odotettiin instanceof ${n.expected}, oli ${s}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${s}`}case"invalid_value":return n.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${P(n.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Liian suuri: ${a.subject} t\xE4ytyy olla ${o}${n.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Liian pieni: ${a.subject} t\xE4ytyy olla ${o}${n.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${r[o.format]??n.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${n.divisor} monikerta`;case"unrecognized_keys":return`${n.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${I(n.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 d1(){return{localeError:WH()}}var qH=()=>{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(n){return e[n]??null}let r={regex:"expression r\xE9guli\xE8re",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",mac:"adresse MAC",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne de caract\xE8res encod\xE9e en base64",base64url:"cha\xEEne de caract\xE8res encod\xE9e en base64url",json_string:"cha\xEEne de caract\xE8res JSON",e164:"num\xE9ro au format E.164",credit_card:"num\xE9ro de carte de cr\xE9dit",currency_code:"code de devise",iban:"IBAN",jwt:"JWT",template_literal:"entr\xE9e"},i={string:"cha\xEEne de caract\xE8res",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:"record",map:"map",set:"ensemble",file:"fichier",nonoptional:"non optionnel",nan:"NaN",function:"fonction"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Entr\xE9e invalide : instance de ${n.expected} attendu, ${s} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${s} re\xE7u`}case"invalid_value":return n.values.length===1?`Entr\xE9e invalide : ${P(n.values[0])} attendu`:`Option invalide : une valeur parmi ${I(n.values,"|")} attendue`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Trop grand : ${i[n.origin]??"valeur"} doit ${a.verb} ${o}${n.maximum.toString()} ${a.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${i[n.origin]??"valeur"} doit \xEAtre ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Trop petit : ${i[n.origin]??"valeur"} doit ${a.verb} ${o}${n.minimum.toString()} ${a.unit}`:`Trop petit : ${i[n.origin]??"valeur"} doit \xEAtre ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Cha\xEEne de caract\xE8res invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne de caract\xE8res invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne de caract\xE8res invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne de caract\xE8res invalide : doit correspondre au motif ${o.pattern}`:`${r[o.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${I(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};function f1(){return{localeError:qH()}}var JH=()=>{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"},map:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??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",mac:"adresse MAC",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",credit_card:"num\xE9ro de carte de cr\xE9dit",currency_code:"code de devise",iban:"IBAN",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Entr\xE9e invalide : attendu instanceof ${n.expected}, re\xE7u ${s}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${s}`}case"invalid_value":return n.values.length===1?`Entr\xE9e invalide : attendu ${P(n.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"\u2264":"<",a=t(n.origin);return a?`Trop grand : attendu que ${n.origin??"la valeur"} ait ${o}${n.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${n.origin??"la valeur"} soit ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?"\u2265":">",a=t(n.origin);return a?`Trop petit : attendu que ${n.origin} ait ${o}${n.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${n.origin} soit ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${r[o.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${I(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};function p1(){return{localeError:JH()}}var XH=()=>{let e={string:{unit:"\u0A85\u0A95\u0ACD\u0AB7\u0AB0",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},file:{unit:"\u0AAC\u0ABE\u0AAF\u0A9F",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},array:{unit:"\u0A86\u0A87\u0A9F\u0AAE",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},set:{unit:"\u0A86\u0A87\u0A9F\u0AAE",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},map:{unit:"\u0A8F\u0AA8\u0ACD\u0A9F\u0ACD\u0AB0\u0AC0",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"}};function t(n){return e[n]??null}let r={regex:"\u0A87\u0AA8\u0AAA\u0AC1\u0A9F",email:"\u0A88\u0AAE\u0AC7\u0A87\u0AB2 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",url:"URL",emoji:"\u0A87\u0AAE\u0ACB\u0A9C\u0AC0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0AA4\u0ABE\u0AB0\u0AC0\u0A96 \u0A85\u0AA8\u0AC7 \u0AB8\u0AAE\u0AAF",date:"ISO \u0AA4\u0ABE\u0AB0\u0AC0\u0A96",time:"ISO \u0AB8\u0AAE\u0AAF",duration:"ISO \u0A85\u0AB5\u0AA7\u0ABF",ipv4:"IPv4 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",ipv6:"IPv6 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",mac:"MAC \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",cidrv4:"IPv4 \u0AB6\u0ACD\u0AB0\u0AC7\u0AA3\u0AC0",cidrv6:"IPv6 \u0AB6\u0ACD\u0AB0\u0AC7\u0AA3\u0AC0",base64:"base64-\u0A8F\u0AA8\u0ACD\u0A95\u0ACB\u0AA1\u0AC7\u0AA1 \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",base64url:"base64url-\u0A8F\u0AA8\u0ACD\u0A95\u0ACB\u0AA1\u0AC7\u0AA1 \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",json_string:"JSON \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",e164:"E.164 \u0AA8\u0A82\u0AAC\u0AB0",credit_card:"\u0A95\u0ACD\u0AB0\u0AC7\u0AA1\u0ABF\u0A9F \u0A95\u0ABE\u0AB0\u0ACD\u0AA1 \u0AA8\u0A82\u0AAC\u0AB0",currency_code:"\u0A9A\u0AB2\u0AA3 \u0A95\u0ACB\u0AA1",iban:"IBAN",jwt:"JWT",template_literal:"\u0A87\u0AA8\u0AAA\u0AC1\u0A9F"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F: \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${o}, \u0AAA\u0ACD\u0AB0\u0ABE\u0AAA\u0ACD\u0AA4 ${s}`}case"invalid_value":return n.values.length===1?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F: \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${P(n.values[0])}`:`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB5\u0ABF\u0A95\u0AB2\u0ACD\u0AAA: ${I(n.values," | ")} \u0AAE\u0ABE\u0AA7\u0ACD\u0AAF\u0AAE\u0AA5\u0AC0 \u0A8F\u0A95 \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u0A96\u0AC2\u0AAC \u0AAE\u0ACB\u0A9F\u0AC1\u0A82: ${n.origin??"\u0AAE\u0AC2\u0AB2\u0ACD\u0AAF"} ${o}${n.maximum.toString()} ${a.unit??"\u0A8F\u0AB2\u0ABF\u0AAE\u0AC7\u0AA8\u0ACD\u0A9F"} \u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A96\u0AC2\u0AAC \u0AAE\u0ACB\u0A9F\u0AC1\u0A82: ${n.origin??"\u0AAE\u0AC2\u0AB2\u0ACD\u0AAF"} ${o}${n.maximum.toString()} \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u0A96\u0AC2\u0AAC \u0AA8\u0ABE\u0AA8\u0AC1\u0A82: ${n.origin} ${o}${n.minimum.toString()} ${a.unit} \u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A96\u0AC2\u0AAC \u0AA8\u0ABE\u0AA8\u0AC1\u0A82: ${n.origin} ${o}${n.minimum.toString()} \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${o.prefix}" \u0AA5\u0AC0 \u0AB6\u0AB0\u0AC2 \u0AA5\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:o.format==="ends_with"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${o.suffix}" \u0AAA\u0AB0 \u0AB8\u0AAE\u0ABE\u0AAA\u0ACD\u0AA4 \u0AA5\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:o.format==="includes"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${o.includes}" \u0AB6\u0ABE\u0AAE\u0AC7\u0AB2 \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:o.format==="regex"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: \u0AAA\u0AC7\u0A9F\u0AB0\u0ACD\u0AA8 ${o.pattern} \u0AB8\u0ABE\u0AA5\u0AC7 \u0AAE\u0AC7\u0AB3 \u0A96\u0ABE\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF ${r[o.format]??n.format}`}case"not_multiple_of":return`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AA8\u0A82\u0AAC\u0AB0: ${n.divisor} \u0AA8\u0ACB \u0A97\u0AC1\u0AA3\u0ABE\u0A82\u0A95 \u0AB9\u0ACB\u0AB5\u0ACB \u0A9C\u0ACB\u0A88\u0A8F`;case"unrecognized_keys":return`\u0A93\u0AB3\u0A96\u0AC0 \u0AB6\u0A95\u0ABE\u0AA4\u0ABE \u0AA8\u0AB9\u0AC0\u0A82 \u0AA4\u0AC7 \u0A95\u0AC0${n.keys.length>1?"\u0A93":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u0AAE\u0ABE\u0A82 \u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A95\u0AC0`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AA1\u0ABF\u0AB8\u0ACD\u0A95\u0ACD\u0AB0\u0ABF\u0AAE\u0ABF\u0AA8\u0AC7\u0A9F\u0AB0 \u0AAE\u0AC2\u0AB2\u0ACD\u0AAF. \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${n.options.map(a=>`'${a}'`).join(" | ")}`:"\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F";case"invalid_element":return`${n.origin} \u0AAE\u0ABE\u0A82 \u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AAE\u0AC2\u0AB2\u0ACD\u0AAF`;default:return"\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F"}}};function m1(){return{localeError:XH()}}var YH=()=>{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=u=>u?e[u]:void 0,i=u=>{let l=r(u);return l?l.label:u??e.unknown.label},n=u=>`\u05D4${i(u)}`,o=u=>(r(u)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",a=u=>u?t[u]??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"},uuidv4:{label:"UUIDv4",gender:"m"},uuidv6:{label:"UUIDv6",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"},mac:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA MAC",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"},credit_card:{label:"\u05DE\u05E1\u05E4\u05E8 \u05DB\u05E8\u05D8\u05D9\u05E1 \u05D0\u05E9\u05E8\u05D0\u05D9",gender:"m"},currency_code:{label:"\u05E7\u05D5\u05D3 \u05DE\u05D8\u05D1\u05E2",gender:"m"},iban:{label:"IBAN",gender:"m"},jwt:{label:"JWT",gender:"m"},template_literal:{label:"\u05E7\u05DC\u05D8",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 u=>{switch(u.code){case"invalid_type":{let l=u.expected,d=c[l??""]??i(l),f=R(u.input),p=c[f]??e[f]?.label??f;return/^[A-Z]/.test(u.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${u.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(u.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 ${P(u.values[0])}`;let l=u.values.map(p=>P(p));if(u.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 ${l[0]} \u05D0\u05D5 ${l[1]}`;let d=l[l.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 ${l.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let l=a(u.origin),d=n(u.origin??"value");if(u.origin==="string")return`${l?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.maximum.toString()} ${l?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${u.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=u.inclusive?`${u.maximum} ${l?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${u.maximum} ${l?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let f=u.inclusive?"<=":"<",p=o(u.origin??"value");return l?.unit?`${l.longLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.maximum.toString()} ${l.unit}`:`${l?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.maximum.toString()}`}case"too_small":{let l=a(u.origin),d=n(u.origin??"value");if(u.origin==="string")return`${l?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.minimum.toString()} ${l?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${u.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(u.minimum===1&&u.inclusive){let g=(u.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 ${g}`}let h=u.inclusive?`${u.minimum} ${l?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${u.minimum} ${l?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let f=u.inclusive?">=":">",p=o(u.origin??"value");return l?.unit?`${l.shortLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.minimum.toString()} ${l.unit}`:`${l?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.minimum.toString()}`}case"invalid_format":{let l=u;if(l.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${l.prefix}"`;if(l.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${l.suffix}"`;if(l.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${l.includes}"`;if(l.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 ${l.pattern}`;let d=s[l.format],f=d?.label??l.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 ${u.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${u.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${u.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${I(u.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${n(u.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function h1(){return{localeError:YH()}}var QH=()=>{let e={string:{unit:"\u0905\u0915\u094D\u0937\u0930",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},file:{unit:"\u092C\u093E\u0907\u091F\u094D\u0938",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},array:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},set:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},map:{unit:"\u092A\u094D\u0930\u0935\u093F\u0937\u094D\u091F\u093F\u092F\u093E\u0901",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"}};function t(n){return e[n]??null}let r={regex:"\u0907\u0928\u092A\u0941\u091F",email:"\u0908\u092E\u0947\u0932 \u092A\u0924\u093E",url:"URL",emoji:"\u0907\u092E\u094B\u091C\u0940",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0924\u093F\u0925\u093F \u0914\u0930 \u0938\u092E\u092F",date:"ISO \u0924\u093F\u0925\u093F",time:"ISO \u0938\u092E\u092F",duration:"ISO \u0905\u0935\u0927\u093F",ipv4:"IPv4 \u092A\u0924\u093E",ipv6:"IPv6 \u092A\u0924\u093E",mac:"MAC \u092A\u0924\u093E",cidrv4:"IPv4 \u0936\u094D\u0930\u0947\u0923\u0940",cidrv6:"IPv6 \u0936\u094D\u0930\u0947\u0923\u0940",base64:"Base64-\u090F\u0928\u094D\u0915\u094B\u0921\u0947\u0921 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",base64url:"Base64URL-\u090F\u0928\u094D\u0915\u094B\u0921\u0947\u0921 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",json_string:"JSON \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",e164:"E.164 \u0938\u0902\u0916\u094D\u092F\u093E",credit_card:"\u0915\u094D\u0930\u0947\u0921\u093F\u091F \u0915\u093E\u0930\u094D\u0921 \u0938\u0902\u0916\u094D\u092F\u093E",currency_code:"\u092E\u0941\u0926\u094D\u0930\u093E \u0915\u094B\u0921",iban:"IBAN",jwt:"JWT",template_literal:"\u0907\u0928\u092A\u0941\u091F"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${o}, \u092A\u094D\u0930\u093E\u092A\u094D\u0924 ${s}`}case"invalid_value":return n.values.length===1?`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${P(n.values[0])}`:`\u0905\u092E\u093E\u0928\u094D\u092F \u0935\u093F\u0915\u0932\u094D\u092A: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u092E\u093E\u0928\u094B\u0902 \u092E\u0947\u0902 \u0938\u0947 \u090F\u0915 ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u092C\u0939\u0941\u0924 \u092C\u0921\u093C\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${n.origin??"\u092E\u093E\u0928"} \u092E\u0947\u0902 ${o}${n.maximum} ${a.unit} \u0939\u094B\u0902`:`\u092C\u0939\u0941\u0924 \u092C\u0921\u093C\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${n.origin??"\u092E\u093E\u0928"} ${o}${n.maximum} \u0939\u094B`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u092C\u0939\u0941\u0924 \u091B\u094B\u091F\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${n.origin} \u092E\u0947\u0902 ${o}${n.minimum} ${a.unit} \u0939\u094B\u0902`:`\u092C\u0939\u0941\u0924 \u091B\u094B\u091F\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${n.origin} ${o}${n.minimum} \u0939\u094B`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: "${o.prefix}" \u0938\u0947 \u0936\u0941\u0930\u0942 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:o.format==="ends_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: "${o.suffix}" \u092A\u0930 \u0938\u092E\u093E\u092A\u094D\u0924 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:o.format==="includes"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: \u0907\u0938\u092E\u0947\u0902 "${o.includes}" \u0936\u093E\u092E\u093F\u0932 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:o.format==="regex"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: \u092A\u0948\u091F\u0930\u094D\u0928 ${o.pattern} \u0938\u0947 \u092E\u0947\u0932 \u0916\u093E\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:`\u0905\u092E\u093E\u0928\u094D\u092F ${r[o.format]??n.format}`}case"not_multiple_of":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u0902\u0916\u094D\u092F\u093E: \u092F\u0939 ${n.divisor} \u0915\u093E \u0917\u0941\u0923\u091C \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`;case"unrecognized_keys":return`\u0905\u092A\u0930\u093F\u091A\u093F\u0924 \u0915\u0941\u0902\u091C\u0940${n.keys.length>1?"\u092F\u093E\u0901":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0915\u0941\u0902\u091C\u0940: ${n.origin} \u092E\u0947\u0902`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0905\u092E\u093E\u0928\u094D\u092F \u0921\u093F\u0938\u094D\u0915\u094D\u0930\u093F\u092E\u093F\u0928\u0947\u091F\u0930 \u092E\u093E\u0928: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${n.options.map(a=>`'${a}'`).join(" | ")}`:"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F";case"invalid_element":return`\u0905\u092E\u093E\u0928\u094D\u092F \u092E\u093E\u0928: ${n.origin} \u092E\u0947\u0902`;default:return"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F"}}};function g1(){return{localeError:QH()}}var e9=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(n){return e[n]??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",mac:"MAC adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",credit_card:"broj kreditne kartice",currency_code:"kod valute",iban:"IBAN",jwt:"JWT",template_literal:"unos"},i={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 n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${n.expected}, a primljeno je ${s}`:`Neispravan unos: o\u010Dekuje se ${o}, a primljeno je ${s}`}case"invalid_value":return n.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${P(n.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin),s=i[n.origin]??n.origin;return a?`Preveliko: o\u010Dekivano da ${s??"vrijednost"} ima ${o}${n.maximum.toString()} ${a.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${s??"vrijednost"} bude ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin),s=i[n.origin]??n.origin;return a?`Premalo: o\u010Dekivano da ${s} ima ${o}${n.minimum.toString()} ${a.unit}`:`Premalo: o\u010Dekivano da ${s} bude ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${o.prefix}"`:o.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${o.suffix}"`:o.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${o.includes}"`:o.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${o.pattern}`:`Neispravna ${r[o.format]??n.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${n.divisor}`;case"unrecognized_keys":return`Neprepoznat${n.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${I(n.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${i[n.origin]??n.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${i[n.origin]??n.origin}`;default:return"Neispravan unos"}}};function _1(){return{localeError:e9()}}var t9=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"},map:{unit:"elem",verb:"legyen"}};function t(n){return e[n]??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",mac:"MAC 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",credit_card:"hitelk\xE1rtyasz\xE1m",currency_code:"p\xE9nznemk\xF3d",iban:"IBAN",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${n.expected}, a kapott \xE9rt\xE9k ${s}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${s}`}case"invalid_value":return n.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${P(n.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`T\xFAl nagy: ${n.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${n.maximum.toString()} ${a.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${n.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} m\xE9rete t\xFAl kicsi ${o}${n.minimum.toString()} ${a.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} t\xFAl kicsi ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[o.format]??n.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${n.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${n.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${n.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function y1(){return{localeError:t9()}}function v1(e,t,r){return Math.abs(e)===1?t:r}function uu(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 r9=()=>{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"},map:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(n){return e[n]??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",mac:"MAC \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",credit_card:"\u056F\u0580\u0565\u0564\u056B\u057F \u0584\u0561\u0580\u057F\u056B \u0570\u0561\u0574\u0561\u0580",currency_code:"\u0561\u0580\u056A\u0578\u0582\u0575\u0569\u056B \u056F\u0578\u0564",iban:"IBAN",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.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 ${n.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 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`}case"invalid_value":return n.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 ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);if(a){let s=Number(n.maximum),c=v1(s,a.unit.one,a.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 ${uu(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${n.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 ${uu(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);if(a){let s=Number(n.minimum),c=v1(s,a.unit.one,a.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 ${uu(n.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${n.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 ${uu(n.origin)} \u056C\u056B\u0576\u056B ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.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 ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[o.format]??n.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 ${n.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${n.keys.length>1?"\u0576\u0565\u0580":""}. ${I(n.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${uu(n.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 ${uu(n.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function b1(){return{localeError:r9()}}var n9=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"},map:{unit:"item",verb:"memiliki"}};function t(n){return e[n]??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",mac:"alamat MAC",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",credit_card:"nomor kartu kredit",currency_code:"kode mata uang",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Input tidak valid: diharapkan instanceof ${n.expected}, diterima ${s}`:`Input tidak valid: diharapkan ${o}, diterima ${s}`}case"invalid_value":return n.values.length===1?`Input tidak valid: diharapkan ${P(n.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Terlalu besar: diharapkan ${n.origin??"value"} memiliki ${o}${n.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${n.origin??"value"} menjadi ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Terlalu kecil: diharapkan ${n.origin} memiliki ${o}${n.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${n.origin} menjadi ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${r[o.format]??n.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${n.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${n.origin}`;default:return"Input tidak valid"}}};function w1(){return{localeError:n9()}}var i9=()=>{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"},map:{unit:"hluti",verb:"a\xF0 hafa"}};function t(n){return e[n]??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",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",credit_card:"kreditkortan\xFAmer",currency_code:"gjaldmi\xF0ilsk\xF3\xF0i",iban:"IBAN",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera instanceof ${n.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return n.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${P(n.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} hafi ${o}${n.maximum.toString()} ${a.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} s\xE9 ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} hafi ${o}${n.minimum.toString()} ${a.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} s\xE9 ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${r[o.format]??n.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${n.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${n.keys.length>1?"ir lyklar":"ur lykill"}: ${I(n.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${n.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${n.origin}`;default:return"Rangt gildi"}}};function x1(){return{localeError:i9()}}var o9=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"},map:{unit:"elementi",verb:"avere"}};function t(n){return e[n]??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",mac:"indirizzo MAC",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",credit_card:"numero di carta di credito",currency_code:"codice valuta",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Input non valido: atteso instanceof ${n.expected}, ricevuto ${s}`:`Input non valido: atteso ${o}, ricevuto ${s}`}case"invalid_value":return n.values.length===1?`Input non valido: atteso ${P(n.values[0])}`:`Opzione non valida: atteso uno tra ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Troppo grande: ${n.origin??"valore"} deve avere ${o}${n.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${n.origin??"valore"} deve essere ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Troppo piccolo: ${n.origin} deve avere ${o}${n.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${n.origin} deve essere ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Input non valido: ${r[o.format]??n.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${n.divisor}`;case"unrecognized_keys":return`Chiav${n.keys.length>1?"i":"e"} non riconosciut${n.keys.length>1?"e":"a"}: ${I(n.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${n.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${n.origin}`;default:return"Input non valido"}}};function S1(){return{localeError:o9()}}var a9=()=>{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"},map:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(n){return e[n]??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",mac:"MAC\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",credit_card:"\u30AF\u30EC\u30B8\u30C3\u30C8\u30AB\u30FC\u30C9\u756A\u53F7",currency_code:"\u901A\u8CA8\u30B3\u30FC\u30C9",iban:"IBAN",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${n.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: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return n.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${P(n.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${I(n.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=n.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",a=t(n.origin);return a?`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${a.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=n.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",a=t(n.origin);return a?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${a.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[o.format]??n.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${n.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${n.keys.length>1?"\u7FA4":""}: ${I(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function k1(){return{localeError:a9()}}var s9=()=>{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"},map:{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(n){return e[n]??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",mac:"MAC \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",credit_card:"\u10E1\u10D0\u10D9\u10E0\u10D4\u10D3\u10D8\u10E2\u10DD \u10D1\u10D0\u10E0\u10D0\u10D7\u10D8\u10E1 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",currency_code:"\u10D5\u10D0\u10DA\u10E3\u10E2\u10D8\u10E1 \u10D9\u10DD\u10D3\u10D8",iban:"IBAN",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={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 n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.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 ${n.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 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`}case"invalid_value":return n.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 ${P(n.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(n.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${a.verb} ${o}${n.maximum.toString()} ${a.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\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 ${n.origin} ${a.verb} ${o}${n.minimum.toString()} ${a.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 ${n.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.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 "${o.prefix}"-\u10D8\u10D7`:o.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 "${o.suffix}"-\u10D8\u10D7`:o.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 "${o.includes}"-\u10E1`:o.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 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[o.format]??n.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 ${n.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${n.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${n.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 ${n.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function $1(){return{localeError:s9()}}var c9=()=>{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"},map:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(n){return e[n]??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",mac:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 MAC",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",credit_card:"\u179B\u17C1\u1781\u1794\u17D0\u178E\u17D2\u178E\u17A5\u178E\u1791\u17B6\u1793",currency_code:"\u1780\u17BC\u178A\u179A\u17BC\u1794\u17B7\u1799\u1794\u17D0\u178E\u17D2\u178E",iban:"IBAN",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={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 n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.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 ${n.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 ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`}case"invalid_value":return n.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 ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${n.maximum.toString()} ${a.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${o} ${n.minimum.toString()} ${a.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${o} ${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[o.format]??n.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 ${n.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${I(n.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 ${n.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 ${n.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 Ah(){return{localeError:c9()}}function I1(){return Ah()}var u9=()=>{let e={string:{unit:"\u0C85\u0C95\u0CCD\u0CB7\u0CB0\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},file:{unit:"\u0CAC\u0CC8\u0C9F\u0CCD\u200C\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},array:{unit:"\u0CB5\u0CB8\u0CCD\u0CA4\u0CC1\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},set:{unit:"\u0CB5\u0CB8\u0CCD\u0CA4\u0CC1\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},map:{unit:"entries",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"}};function t(n){return e[n]??null}let r={regex:"\u0C87\u0CA8\u0CCD\u0CAA\u0CC1\u0C9F\u0CCD",email:"email \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",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 \u0CA6\u0CBF\u0CA8\u0CBE\u0C82\u0C95\u0CA6 \u0CB8\u0CAE\u0CAF",date:"ISO \u0CA6\u0CBF\u0CA8\u0CBE\u0C82\u0C95",time:"ISO \u0CB8\u0CAE\u0CAF",duration:"ISO \u0C85\u0CB5\u0CA7\u0CBF",ipv4:"IPv4 \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",ipv6:"IPv6 \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",mac:"MAC \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",cidrv4:"IPv4 \u0CB5\u0CCD\u0CAF\u0CBE\u0CAA\u0CCD\u0CA4\u0CBF\u0CAF",cidrv6:"IPv6 \u0CB5\u0CCD\u0CAF\u0CBE\u0CAA\u0CCD\u0CA4\u0CBF\u0CAF",base64:"base64-encoded\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",base64url:"base64url-encoded\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",json_string:"JSON\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",e164:"E.164 \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6",credit_card:"\u0C95\u0CCD\u0CB0\u0CC6\u0CA1\u0CBF\u0C9F\u0CCD \u0C95\u0CBE\u0CB0\u0CCD\u0CA1\u0CCD \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6",currency_code:"\u0C95\u0CB0\u0CC6\u0CA8\u0CCD\u0CB8\u0CBF \u0C95\u0CCB\u0CA1\u0CCD",iban:"IBAN",jwt:"JWT",template_literal:"\u0C87\u0CA8\u0CCD\u0CAA\u0CC1\u0C9F\u0CCD"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${o}, \u0CB8\u0CCD\u0CB5\u0CC0\u0C95\u0CB0\u0CBF\u0CB8\u0CBF\u0CA6\u0CA8\u0CC1 ${s}`}case"invalid_value":return n.values.length===1?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${P(n.values[0])}`:`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C86\u0CAF\u0CCD\u0C95\u0CC6: \u0C87\u0CB5\u0CC1\u0C97\u0CB3\u0CB2\u0CCD\u0CB2\u0CBF \u0C92\u0C82\u0CA6\u0CA8\u0CCD\u0CA8\u0CC1 \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0CA6\u0CCA\u0CA1\u0CCD\u0CA1\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${n.origin??"value"} \u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1 ${o}${n.maximum.toString()} ${a.unit??"\u0C85\u0C82\u0CB6\u0C97\u0CB3\u0CC1"}`:`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0CA6\u0CCA\u0CA1\u0CCD\u0CA1\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${n.origin??"value"} \u0C8E\u0C82\u0CA6\u0CC1 ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0C9A\u0CBF\u0C95\u0CCD\u0C95\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${n.origin} \u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1 ${o}${n.minimum.toString()} ${a.unit}`:`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0C9A\u0CBF\u0C95\u0CCD\u0C95\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${n.origin} \u0C8E\u0C82\u0CA6\u0CC1 ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C87\u0CA6\u0CB0\u0CCA\u0C82\u0CA6\u0CBF\u0C97\u0CC6 \u0CAA\u0CCD\u0CB0\u0CBE\u0CB0\u0C82\u0CAD\u0CBF\u0CB8\u0CAC\u0CC7\u0C95\u0CC1 "${o.prefix}"`:o.format==="ends_with"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C87\u0CA6\u0CB0\u0CCA\u0C82\u0CA6\u0CBF\u0C97\u0CC6 \u0C95\u0CCA\u0CA8\u0CC6\u0C97\u0CCA\u0CB3\u0CCD\u0CB3\u0CAC\u0CC7\u0C95\u0CC1 "${o.suffix}"`:o.format==="includes"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C92\u0CB3\u0C97\u0CCA\u0C82\u0CA1\u0CBF\u0CB0\u0CAC\u0CC7\u0C95\u0CC1 "${o.includes}"`:o.format==="regex"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0CAE\u0CBE\u0CA6\u0CB0\u0CBF\u0C97\u0CC6 \u0CB9\u0CCA\u0C82\u0CA6\u0CBF\u0C95\u0CC6\u0CAF\u0CBE\u0C97\u0CAC\u0CC7\u0C95\u0CC1 ${o.pattern}`:`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF ${r[o.format]??n.format}`}case"not_multiple_of":return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6: \u0CAC\u0CB9\u0CC1\u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6\u0CAF\u0CBE\u0C97\u0CBF\u0CB0\u0CAC\u0CC7\u0C95\u0CC1 ${n.divisor}`;case"unrecognized_keys":return`\u0C97\u0CC1\u0CB0\u0CC1\u0CA4\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CA6 \u0C95\u0CC0 ${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0C95\u0CC0 \u0C87\u0CA8\u0CCD ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CA4\u0CBE\u0CB0\u0CA4\u0CAE\u0CCD\u0CAF \u0CAE\u0CCC\u0CB2\u0CCD\u0CAF. \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${n.options.map(a=>`'${a}'`).join(" | ")}`:"\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD";case"invalid_element":return`\u0CB0\u0CB2\u0CCD\u0CB2\u0CBF \u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CAE\u0CCC\u0CB2\u0CCD\u0CAF ${n.origin}`;default:return"\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD"}}};function E1(){return{localeError:u9()}}var l9=()=>{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"},map:{unit:"\uAC1C",verb:"to have"}};function t(n){return e[n]??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",mac:"MAC \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",credit_card:"\uC2E0\uC6A9\uCE74\uB4DC \uBC88\uD638",currency_code:"\uD1B5\uD654 \uCF54\uB4DC",iban:"IBAN",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${n.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`}case"invalid_value":return n.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${P(n.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${I(n.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=n.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",a=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(n.origin),c=s?.unit??"\uC694\uC18C";return s?`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()}${c} ${o}${a}`:`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()} ${o}${a}`}case"too_small":{let o=n.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",a=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(n.origin),c=s?.unit??"\uC694\uC18C";return s?`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()}${c} ${o}${a}`:`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()} ${o}${a}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[o.format]??n.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${n.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${I(n.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${n.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${n.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function T1(){return{localeError:l9()}}var Td=e=>e.charAt(0).toUpperCase()+e.slice(1);function A1(e){let t=Math.abs(e),r=t%10,i=t%100;return i>=11&&i<=19||r===0?"many":r===1?"one":"few"}var d9=()=>{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(n,o,a,s){let c=e[n]??null;return c===null?c:{unit:c.unit[o],verb:c.verb[s][a?"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",mac:"MAC 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",credit_card:"kredito kortel\u0117s numeris",currency_code:"valiutos kodas",iban:"IBAN",jwt:"JWT",template_literal:"\u012Fvestis"},i={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 n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Gautas tipas ${s}, o tik\u0117tasi - instanceof ${n.expected}`:`Gautas tipas ${s}, o tik\u0117tasi - ${o}`}case"invalid_value":return n.values.length===1?`Privalo b\u016Bti ${P(n.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${I(n.values,"|")} pasirinkim\u0173`;case"too_big":{let o=i[n.origin]??n.origin,a=t(n.origin,A1(Number(n.maximum)),n.inclusive??!1,"smaller");if(a?.verb)return`${Td(o??n.origin??"reik\u0161m\u0117")} ${a.verb} ${n.maximum.toString()} ${a.unit??"element\u0173"}`;let s=n.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${Td(o??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${n.maximum.toString()} ${a?.unit}`}case"too_small":{let o=i[n.origin]??n.origin,a=t(n.origin,A1(Number(n.minimum)),n.inclusive??!1,"bigger");if(a?.verb)return`${Td(o??n.origin??"reik\u0161m\u0117")} ${a.verb} ${n.minimum.toString()} ${a.unit??"element\u0173"}`;let s=n.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${Td(o??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${n.minimum.toString()} ${a?.unit}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${r[o.format]??n.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${n.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${n.keys.length>1?"i":"as"} rakt${n.keys.length>1?"ai":"as"}: ${I(n.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=i[n.origin]??n.origin;return`${Td(o??n.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function C1(){return{localeError:d9()}}var f9=()=>{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"},map:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(n){return e[n]??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",mac:"MAC \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",credit_card:"\u0431\u0440\u043E\u0458 \u043D\u0430 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u0430 \u043A\u0430\u0440\u0442\u0438\u0447\u043A\u0430",currency_code:"\u043A\u043E\u0434 \u043D\u0430 \u0432\u0430\u043B\u0443\u0442\u0430",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${n.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 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${n.maximum.toString()} ${a.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 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${n.minimum.toString()} ${a.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`Invalid ${r[o.format]??n.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 ${n.divisor}`;case"unrecognized_keys":return`${n.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(n.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${n.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 ${n.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function O1(){return{localeError:f9()}}var p9=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"},map:{unit:"elemen",verb:"mempunyai"}};function t(n){return e[n]??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",mac:"alamat MAC",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",credit_card:"nombor kad kredit",currency_code:"kod mata wang",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Input tidak sah: dijangka instanceof ${n.expected}, diterima ${s}`:`Input tidak sah: dijangka ${o}, diterima ${s}`}case"invalid_value":return n.values.length===1?`Input tidak sah: dijangka ${P(n.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Terlalu besar: dijangka ${n.origin??"nilai"} ${a.verb} ${o}${n.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${n.origin??"nilai"} adalah ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Terlalu kecil: dijangka ${n.origin} ${a.verb} ${o}${n.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${n.origin} adalah ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${r[o.format]??n.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${I(n.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${n.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${n.origin}`;default:return"Input tidak sah"}}};function P1(){return{localeError:p9()}}var m9=()=>{let e={string:{unit:"\u0905\u0915\u094D\u0937\u0930",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},file:{unit:"\u092C\u093E\u0907\u091F",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},array:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},set:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},map:{unit:"\u092A\u094D\u0930\u0935\u093F\u0937\u094D\u091F\u093F",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"}};function t(n){return e[n]??null}let r={regex:"\u0907\u0928\u092A\u0941\u091F",email:"\u0907\u092E\u0947\u0932 \u0920\u0947\u0917\u093E\u0928\u093E",url:"URL",emoji:"\u0907\u092E\u094B\u091C\u0940",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u092E\u093F\u0924\u093F \u0930 \u0938\u092E\u092F",date:"ISO \u092E\u093F\u0924\u093F",time:"ISO \u0938\u092E\u092F",duration:"ISO \u0905\u0935\u0927\u093F",ipv4:"IPv4 \u0920\u0947\u0917\u093E\u0928\u093E",ipv6:"IPv6 \u0920\u0947\u0917\u093E\u0928\u093E",mac:"MAC \u0920\u0947\u0917\u093E\u0928\u093E",cidrv4:"IPv4 \u0926\u093E\u092F\u0930\u093E",cidrv6:"IPv6 \u0926\u093E\u092F\u0930\u093E",base64:"base64-\u0907\u0928\u094D\u0915\u094B\u0921 \u0917\u0930\u093F\u090F\u0915\u094B \u0938\u094D\u091F\u094D\u0930\u093F\u0919",base64url:"base64url-\u0907\u0928\u094D\u0915\u094B\u0921 \u0917\u0930\u093F\u090F\u0915\u094B \u0938\u094D\u091F\u094D\u0930\u093F\u0919",json_string:"JSON \u0938\u094D\u091F\u094D\u0930\u093F\u0919",e164:"E.164 \u0928\u092E\u094D\u092C\u0930",credit_card:"\u0915\u094D\u0930\u0947\u0921\u093F\u091F \u0915\u093E\u0930\u094D\u0921 \u0928\u092E\u094D\u092C\u0930",currency_code:"\u092E\u0941\u0926\u094D\u0930\u093E \u0915\u094B\u0921",iban:"IBAN",jwt:"JWT",template_literal:"\u0907\u0928\u092A\u0941\u091F"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${o}, \u092A\u094D\u0930\u093E\u092A\u094D\u0924 ${s}`}case"invalid_value":return n.values.length===1?`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${P(n.values[0])}`:`\u0905\u092E\u093E\u0928\u094D\u092F \u0935\u093F\u0915\u0932\u094D\u092A: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u092E\u093E\u0928\u0939\u0930\u0942 \u092E\u0927\u094D\u092F\u0947 \u090F\u0915 ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u0927\u0947\u0930\u0948 \u0920\u0942\u0932\u094B: ${n.origin??"\u092E\u093E\u0928"} \u092E\u093E ${o}${n.maximum.toString()} ${a.unit} ${a.verb}`:`\u0927\u0947\u0930\u0948 \u0920\u0942\u0932\u094B: ${n.origin??"\u092E\u093E\u0928"} ${o}${n.maximum.toString()} \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u0927\u0947\u0930\u0948 \u0938\u093E\u0928\u094B: ${n.origin} \u092E\u093E ${o}${n.minimum.toString()} ${a.unit} ${a.verb}`:`\u0927\u0947\u0930\u0948 \u0938\u093E\u0928\u094B: ${n.origin} ${o}${n.minimum.toString()} \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${o.prefix}" \u092C\u093E\u091F \u0938\u0941\u0930\u0941 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:o.format==="ends_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${o.suffix}" \u092E\u093E \u0938\u092E\u093E\u092A\u094D\u0924 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:o.format==="includes"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${o.includes}" \u0938\u092E\u093E\u0935\u0947\u0936 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:o.format==="regex"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: \u0922\u093E\u0901\u091A\u093E ${o.pattern} \u0938\u0901\u0917 \u092E\u0947\u0932 \u0916\u093E\u0928\u0941\u092A\u0930\u094D\u091B`:`\u0905\u092E\u093E\u0928\u094D\u092F ${r[o.format]??n.format}`}case"not_multiple_of":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u0902\u0916\u094D\u092F\u093E: ${n.divisor} \u0915\u094B \u0917\u0941\u0923\u091C \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`;case"unrecognized_keys":return`\u0905\u092A\u0930\u093F\u091A\u093F\u0924 \u0915\u0941\u091E\u094D\u091C\u0940${n.keys.length>1?"\u0939\u0930\u0942":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0915\u0941\u091E\u094D\u091C\u0940: ${n.origin} \u092E\u093E`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0905\u092E\u093E\u0928\u094D\u092F \u0921\u093F\u0938\u094D\u0915\u094D\u0930\u093F\u092E\u093F\u0928\u0947\u091F\u0930 \u092E\u093E\u0928: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${n.options.map(a=>`'${a}'`).join(" | ")}`:"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F";case"invalid_element":return`\u0905\u092E\u093E\u0928\u094D\u092F \u092E\u093E\u0928: ${n.origin} \u092E\u093E`;default:return"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F"}}};function N1(){return{localeError:m9()}}var h9=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"},map:{unit:"elementen",verb:"heeft"}};function t(n){return e[n]??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",mac:"MAC-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",credit_card:"creditcardnummer",currency_code:"valutacode",iban:"IBAN",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Ongeldige invoer: verwacht instanceof ${n.expected}, ontving ${s}`:`Ongeldige invoer: verwacht ${o}, ontving ${s}`}case"invalid_value":return n.values.length===1?`Ongeldige invoer: verwacht ${P(n.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin),s=n.origin==="date"?"laat":n.origin==="string"?"lang":"groot";return a?`Te ${s}: verwacht dat ${n.origin??"waarde"} ${o}${n.maximum.toString()} ${a.unit??"elementen"} ${a.verb}`:`Te ${s}: verwacht dat ${n.origin??"waarde"} ${o}${n.maximum.toString()} is`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin),s=n.origin==="date"?"vroeg":n.origin==="string"?"kort":"klein";return a?`Te ${s}: verwacht dat ${n.origin} ${o}${n.minimum.toString()} ${a.unit} ${a.verb}`:`Te ${s}: verwacht dat ${n.origin} ${o}${n.minimum.toString()} is`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${r[o.format]??n.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${n.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${n.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${n.origin}`;default:return"Ongeldige invoer"}}};function R1(){return{localeError:h9()}}var g9=()=>{let e={string:{unit:"teikn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"element",verb:"\xE5 innehalde"},set:{unit:"element",verb:"\xE5 innehalde"},map:{unit:"element",verb:"\xE5 innehalde"}};function t(n){return e[n]??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-varigheit",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkoda streng",base64url:"base64url-enkoda streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kredittkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tal",array:"liste"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Ugyldig input: forventa instanceof ${n.expected}, fekk ${s}`:`Ugyldig input: forventa ${o}, fekk ${s}`}case"invalid_value":return n.values.length===1?`Ugyldig verdi: forventa ${P(n.values[0])}`:`Ugyldig val: forventa eitt av ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`For stor(t): forventa ${n.origin??"value"} til \xE5 ha ${o}${n.maximum.toString()} ${a.unit??"element"}`:`For stor(t): forventa ${n.origin??"value"} til \xE5 ha ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`For lite(n): forventa ${n.origin} til \xE5 ha ${o}${n.minimum.toString()} ${a.unit}`:`For lite(n): forventa ${n.origin} til \xE5 ha ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 slutte med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 innehalde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??n.format}`}case"not_multiple_of":return`Ugyldig tal: m\xE5 vere eit multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjende n\xF8klar":"Ukjend n\xF8kkel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};function j1(){return{localeError:g9()}}var _9=()=>{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"},map:{unit:"elementer",verb:"\xE5 inneholde"}};function t(n){return e[n]??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-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kredittkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Ugyldig input: forventet instanceof ${n.expected}, fikk ${s}`:`Ugyldig input: forventet ${o}, fikk ${s}`}case"invalid_value":return n.values.length===1?`Ugyldig verdi: forventet ${P(n.values[0])}`:`Ugyldig valg: forventet en av ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${o}${n.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`For lite(n): forventet ${n.origin} til \xE5 ha ${o}${n.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${n.origin} til \xE5 ha ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??n.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};function D1(){return{localeError:_9()}}var y9=()=>{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"},map:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??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",mac:"MAC 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",credit_card:"i'tib\xE2r kart\u0131 numaras\u0131",currency_code:"para birimi kodu",iban:"IBAN",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`F\xE2sit giren: umulan instanceof ${n.expected}, al\u0131nan ${s}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${s}`}case"invalid_value":return n.values.length===1?`F\xE2sit giren: umulan ${P(n.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${o}${n.maximum.toString()} ${a.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${o}${n.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${o}${n.minimum.toString()} ${a.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${o}${n.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=n;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[o.format]??n.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${n.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${n.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function M1(){return{localeError:y9()}}var v9=()=>{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"},map:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(n){return e[n]??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",mac:"\u062F MAC \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",credit_card:"\u062F \u06A9\u0631\u06CC\u0689\u06CC\u067C \u06A9\u0627\u0631\u062A \u0634\u0645\u06CC\u0631\u0647",currency_code:"\u062F \u0627\u0633\u0639\u0627\u0631\u0648 \u06A9\u0648\u0689",iban:"IBAN",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${n.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 ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return n.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${P(n.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${I(n.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${n.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${n.maximum.toString()} \u0648\u064A`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${o}${n.minimum.toString()} ${a.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${o}${n.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[o.format]??n.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${n.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${n.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${n.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 ${n.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function z1(){return{localeError:v9()}}var b9=()=>{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"},map:{unit:"element\xF3w",verb:"mie\u0107"}};function t(n){return e[n]??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",mac:"adres MAC",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",credit_card:"numer karty kredytowej",currency_code:"kod waluty",iban:"IBAN",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${n.expected}, otrzymano ${s}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${s}`}case"invalid_value":return n.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${P(n.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${n.maximum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${n.minimum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[o.format]??n.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${n.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${n.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${n.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function L1(){return{localeError:b9()}}var w9=()=>{let e={string:{unit:"caracteres"},file:{unit:"bytes"},array:{unit:"elementos"},set:{unit:"elementos"},map:{unit:"entradas"}};function t(a){return e[a]??null}let r={regex:"a entrada",email:"o endere\xE7o de e-mail",url:"o URL",emoji:"o emoji",uuid:"o UUID",uuidv4:"o UUIDv4",uuidv6:"o UUIDv6",nanoid:"o nanoid",guid:"o GUID",cuid:"o cuid",cuid2:"o cuid2",ulid:"o ULID",xid:"o XID",ksuid:"o KSUID",datetime:"a data e hora ISO",date:"a data ISO",time:"a hora ISO",duration:"a dura\xE7\xE3o ISO",ipv4:"o endere\xE7o IPv4",ipv6:"o endere\xE7o IPv6",mac:"o endere\xE7o MAC",cidrv4:"o intervalo de endere\xE7os IPv4",cidrv6:"o intervalo de endere\xE7os IPv6",base64:"o texto codificado em base64",base64url:"o texto codificado em base64url",json_string:"o texto JSON",e164:"o n\xFAmero E.164",credit_card:"o n\xFAmero de cart\xE3o de cr\xE9dito",currency_code:"o c\xF3digo de moeda",iban:"o IBAN",jwt:"o JWT",template_literal:"a entrada"},i={masculine:{definite:"o",indefinite:"um"},feminine:{definite:"a",indefinite:"uma"}},n={string:{name:"texto",articles:i.masculine},number:{name:"n\xFAmero",articles:i.masculine},int:{name:"n\xFAmero inteiro",articles:i.masculine},boolean:{name:"valor booleano",articles:i.masculine},bigint:{name:"n\xFAmero bigint",articles:i.masculine},symbol:{name:"s\xEDmbolo",articles:i.masculine},undefined:{name:'valor "undefined"',articles:i.masculine},null:{name:'valor "nulo"',articles:i.masculine},never:{name:'valor "never"',articles:i.masculine},void:{name:'valor "void"',articles:i.masculine},date:{name:"data",articles:i.feminine},array:{name:"vetor",articles:i.masculine},object:{name:"objeto",articles:i.masculine},tuple:{name:"tuplo",articles:i.masculine},record:{name:"registo",articles:i.masculine},map:{name:"mapa",articles:i.masculine},set:{name:"conjunto",articles:i.masculine},file:{name:"ficheiro",articles:i.masculine},nonoptional:{name:"valor n\xE3o opcional",articles:i.masculine},nan:{name:'valor "NaN"',articles:i.masculine},function:{name:"fun\xE7\xE3o",articles:i.feminine}};function o(a,s){let c=n[a]??{name:`valor "${a}"`,articles:i.masculine};return`${c.articles[s]} ${c.name}`}return a=>{switch(a.code){case"invalid_type":{let s=o(a.expected,"indefinite"),c=R(a.input),u=o(c,"indefinite");return`Entrada inv\xE1lida: esperava ${s}, recebeu ${u}`}case"invalid_value":return a.values.length===1?`Entrada inv\xE1lida: esperava ${P(a.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperava uma das seguintes op\xE7\xF5es: ${I(a.values,"|")}`;case"too_big":{let s=a.inclusive?"<=":"<",c=t(a.origin);return c?`Demasiado grande: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.maximum.toString()} ${c.unit??"elementos"}`:`Demasiado grande: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.maximum.toString()}`}case"too_small":{let s=a.inclusive?">=":">",c=t(a.origin);return c?`Demasiado pequeno: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.minimum.toString()} ${c.unit??"elementos"}`:`Demasiado pequeno: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.minimum.toString()}`}case"invalid_format":{let s=a;return s.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar por "${s.prefix}"`:s.format==="ends_with"?`Texto inv\xE1lido: deve terminar em "${s.suffix}"`:s.format==="includes"?`Texto inv\xE1lido: deve incluir "${s.includes}"`:s.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${s.pattern}`:`Formato d${r[s.format]??a.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${a.divisor}`;case"unrecognized_keys":{let s=a.keys.length>1?"s":"";return`Chave${s} inv\xE1lida${s}: ${I(a.keys,", ")}`}case"invalid_key":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;case"invalid_union":return a.options&&Array.isArray(a.options)&&a.options.length>0?`Valor de discrimina\xE7\xE3o inv\xE1lido. Esperava ${a.options.map(c=>`'${c}'`).join(" | ")}`:"Entrada inv\xE1lida";case"invalid_element":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;default:return"Entrada inv\xE1lida"}}};function U1(){return{localeError:w9()}}var x9=()=>{let e={string:{unit:"caracteres"},file:{unit:"bytes"},array:{unit:"elementos"},set:{unit:"elementos"},map:{unit:"entradas"}};function t(a){return e[a]??null}let r={regex:"a entrada",email:"o endere\xE7o de e-mail",url:"o URL",emoji:"o emoji",uuid:"o UUID",uuidv4:"o UUIDv4",uuidv6:"o UUIDv6",nanoid:"o nanoid",guid:"o GUID",cuid:"o cuid",cuid2:"o cuid2",ulid:"o ULID",xid:"o XID",ksuid:"o KSUID",datetime:"a data e hora ISO",date:"a data ISO",time:"a hora ISO",duration:"a dura\xE7\xE3o ISO",ipv4:"o endere\xE7o IPv4",ipv6:"o endere\xE7o IPv6",mac:"o endere\xE7o MAC",cidrv4:"a faixa de endere\xE7os IPv4",cidrv6:"a faixa de endere\xE7os IPv6",base64:"o texto codificado em base64",base64url:"o texto codificado em base64url",json_string:"o texto JSON",e164:"o n\xFAmero E.164",credit_card:"o n\xFAmero de cart\xE3o de cr\xE9dito",currency_code:"o c\xF3digo de moeda",iban:"o IBAN",jwt:"o JWT",template_literal:"a entrada"},i={masculine:{definite:"o",indefinite:"um"},feminine:{definite:"a",indefinite:"uma"}},n={string:{name:"texto",articles:i.masculine},number:{name:"n\xFAmero",articles:i.masculine},int:{name:"n\xFAmero inteiro",articles:i.masculine},boolean:{name:"valor booleano",articles:i.masculine},bigint:{name:"n\xFAmero bigint",articles:i.masculine},symbol:{name:"s\xEDmbolo",articles:i.masculine},undefined:{name:'valor "undefined"',articles:i.masculine},null:{name:'valor "nulo"',articles:i.masculine},never:{name:'valor "never"',articles:i.masculine},void:{name:'valor "void"',articles:i.masculine},date:{name:"data",articles:i.feminine},array:{name:"vetor",articles:i.masculine},object:{name:"objeto",articles:i.masculine},tuple:{name:"tupla",articles:i.feminine},record:{name:"registro",articles:i.masculine},map:{name:"mapa",articles:i.masculine},set:{name:"conjunto",articles:i.masculine},file:{name:"arquivo",articles:i.masculine},nonoptional:{name:"valor n\xE3o opcional",articles:i.masculine},nan:{name:'valor "NaN"',articles:i.masculine},function:{name:"fun\xE7\xE3o",articles:i.feminine}};function o(a,s){let c=n[a]??{name:`valor "${a}"`,articles:i.masculine};return`${c.articles[s]} ${c.name}`}return a=>{switch(a.code){case"invalid_type":{let s=o(a.expected,"indefinite"),c=R(a.input),u=o(c,"indefinite");return`Entrada inv\xE1lida: esperava ${s}, recebeu ${u}`}case"invalid_value":return a.values.length===1?`Entrada inv\xE1lida: esperava ${P(a.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperava uma das seguintes op\xE7\xF5es: ${I(a.values,"|")}`;case"too_big":{let s=a.inclusive?"<=":"<",c=t(a.origin);return c?`Grande demais: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.maximum.toString()} ${c.unit??"elementos"}`:`Grande demais: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.maximum.toString()}`}case"too_small":{let s=a.inclusive?">=":">",c=t(a.origin);return c?`Pequeno demais: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.minimum.toString()} ${c.unit??"elementos"}`:`Pequeno demais: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.minimum.toString()}`}case"invalid_format":{let s=a;return s.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${s.prefix}"`:s.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${s.suffix}"`:s.format==="includes"?`Texto inv\xE1lido: deve incluir "${s.includes}"`:s.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${s.pattern}`:`Formato d${r[s.format]??a.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${a.divisor}`;case"unrecognized_keys":{let s=a.keys.length>1?"s":"";return`Chave${s} inv\xE1lida${s}: ${I(a.keys,", ")}`}case"invalid_key":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;case"invalid_union":return a.options&&Array.isArray(a.options)&&a.options.length>0?`Valor de discrimina\xE7\xE3o inv\xE1lido. Esperava ${a.options.map(c=>`'${c}'`).join(" | ")}`:"Entrada inv\xE1lida";case"invalid_element":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;default:return"Entrada inv\xE1lida"}}};function F1(){return{localeError:x9()}}var S9=()=>{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(n){return e[n]??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",credit_card:"num\u0103r de card de credit",currency_code:"cod valutar",iban:"IBAN",jwt:"JWT",template_literal:"intrare"},i={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 n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return`Intrare invalid\u0103: a\u0219teptat ${o}, primit ${s}`}case"invalid_value":return n.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${P(n.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} ${a.verb} ${o}${n.maximum.toString()} ${a.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} s\u0103 fie ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Prea mic: a\u0219teptat ca ${n.origin} ${a.verb} ${o}${n.minimum.toString()} ${a.unit}`:`Prea mic: a\u0219teptat ca ${n.origin} s\u0103 fie ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${o.prefix}"`:o.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${o.suffix}"`:o.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${o.includes}"`:o.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${o.pattern}`:`Format invalid: ${r[o.format]??n.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${n.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${I(n.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${n.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${n.origin}`;default:return"Intrare invalid\u0103"}}};function B1(){return{localeError:S9()}}function V1(e,t,r,i){let n=Math.abs(e),o=n%10,a=n%100;return a>=11&&a<=19?i:o===1?t:o>=2&&o<=4?r:i}var k9=()=>{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"},map:{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(n){return e[n]??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",mac:"MAC \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",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u043E\u0439 \u043A\u0430\u0440\u0442\u044B",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u044B",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${n.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 ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);if(a){let s=Number(n.maximum),c=V1(s,a.unit.one,a.unit.few,a.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 ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${n.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 ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);if(a){let s=Number(n.minimum),c=V1(s,a.unit.one,a.unit.few,a.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 ${n.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${n.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 ${n.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[o.format]??n.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 ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${n.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0438":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${n.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 ${n.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 H1(){return{localeError:k9()}}var $9=()=>{let e={string:{unit:"znakov",verb:"ma\u0165"},file:{unit:"bajtov",verb:"ma\u0165"},array:{unit:"prvkov",verb:"ma\u0165"},set:{unit:"prvkov",verb:"ma\u0165"},map:{unit:"polo\u017Eiek",verb:"ma\u0165"}};function t(n){return e[n]??null}let r={regex:"regul\xE1rny 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:"d\xE1tum a \u010Das vo form\xE1te ISO",date:"d\xE1tum vo form\xE1te ISO",time:"\u010Das vo form\xE1te ISO",duration:"doba trvania ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"re\u0165azec zak\xF3dovan\xFD vo form\xE1te base64",base64url:"re\u0165azec zak\xF3dovan\xFD vo form\xE1te base64url",json_string:"re\u0165azec vo form\xE1te JSON",e164:"\u010D\xEDslo E.164",credit_card:"\u010D\xEDslo kreditnej karty",currency_code:"k\xF3d meny",iban:"IBAN",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"re\u0165azec",function:"funkcia",array:"pole"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 instanceof ${n.expected}, obdr\u017Ean\xE9 ${s}`:`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 ${o}, obdr\u017Ean\xE9 ${s}`}case"invalid_value":return n.values.length===1?`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 ${P(n.values[0])}`:`Neplatn\xFD vstup: o\u010Dak\xE1van\xE1 jedna z hodn\xF4t ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Hodnota je pr\xEDli\u0161 ve\u013Ek\xE1: ${n.origin??"hodnota"} mus\xED ma\u0165 ${o}${n.maximum.toString()} ${a.unit??"prvkov"}`:`Hodnota je pr\xEDli\u0161 ve\u013Ek\xE1: ${n.origin??"hodnota"} mus\xED by\u0165 ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Hodnota je pr\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED ma\u0165 ${o}${n.minimum.toString()} ${a.unit??"prvkov"}`:`Hodnota je pr\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED by\u0165 ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Neplatn\xFD re\u0165azec: mus\xED za\u010D\xEDna\u0165 na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD re\u0165azec: mus\xED kon\u010Di\u0165 na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD re\u0165azec: mus\xED obsahova\u0165 "${o.includes}"`:o.format==="regex"?`Neplatn\xFD re\u0165azec: mus\xED zodpoveda\u0165 vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${r[o.format]??n.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED by\u0165 n\xE1sobkom ${n.divisor}`;case"unrecognized_keys":return`Nezn\xE1me kl\xFA\u010De: ${I(n.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xFA\u010D v ${n.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${n.origin}`;default:return"Neplatn\xFD vstup"}}};function Z1(){return{localeError:$9()}}var I9=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"},map:{unit:"elementov",verb:"imeti"}};function t(n){return e[n]??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",mac:"MAC naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",credit_card:"\u0161tevilka kreditne kartice",currency_code:"koda valute",iban:"IBAN",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${n.expected}, prejeto ${s}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${s}`}case"invalid_value":return n.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${P(n.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} imelo ${o}${n.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Premajhno: pri\u010Dakovano, da bo ${n.origin} imelo ${o}${n.minimum.toString()} ${a.unit}`:`Premajhno: pri\u010Dakovano, da bo ${n.origin} ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${r[o.format]??n.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${n.divisor}`;case"unrecognized_keys":return`Neprepoznan${n.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${I(n.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${n.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${n.origin}`;default:return"Neveljaven vnos"}}};function G1(){return{localeError:I9()}}var E9=()=>{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"},map:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(n){return e[n]??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-adress",ipv6:"IPv6-adress",mac:"MAC-adress",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",credit_card:"kreditkortsnummer",currency_code:"valutakod",iban:"IBAN",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${n.expected}, fick ${s}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${s}`}case"invalid_value":return n.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${P(n.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`F\xF6r stor(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${o}${n.maximum.toString()} ${a.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${n.origin??"v\xE4rdet"} att ha ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${o}${n.minimum.toString()} ${a.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${r[o.format]??n.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${n.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${n.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function K1(){return{localeError:E9()}}var T9=()=>{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"},map:{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(n){return e[n]??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",mac:"MAC \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",credit_card:"\u0B95\u0B9F\u0BA9\u0BCD \u0B85\u0B9F\u0BCD\u0B9F\u0BC8 \u0B8E\u0BA3\u0BCD",currency_code:"\u0BA8\u0BBE\u0BA3\u0BAF\u0B95\u0BCD \u0B95\u0BC1\u0BB1\u0BBF\u0BAF\u0BC0\u0B9F\u0BC1",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.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 ${n.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 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`}case"invalid_value":return n.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 ${P(n.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(n.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\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 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${n.maximum.toString()} ${a.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 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${n.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\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 ${n.origin} ${o}${n.minimum.toString()} ${a.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 ${n.origin} ${o}${n.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.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[o.format]??n.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${n.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${n.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.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`${n.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 W1(){return{localeError:T9()}}var A9=()=>{let e={string:{unit:"\u0430\u043B\u043E\u043C\u0430\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},file:{unit:"\u0431\u0430\u0439\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},array:{unit:"\u0443\u043D\u0441\u0443\u0440",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},set:{unit:"\u0443\u043D\u0441\u0443\u0440",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},map:{unit:"\u0441\u0430\u0431\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0443\u0440\u0443\u0434",email:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 email",url:"URL",emoji:"\u044D\u043C\u043E\u04B7\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0441\u0430\u043D\u0430\u0432\u0443 \u0432\u0430\u049B\u0442\u0438 ISO",date:"\u0441\u0430\u043D\u0430\u0438 ISO",time:"\u0432\u0430\u049B\u0442\u0438 ISO",duration:"\u0434\u0430\u0432\u043E\u043C\u043D\u043E\u043A\u0438\u0438 ISO",ipv4:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv4",ipv6:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv6",mac:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 MAC",cidrv4:"\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv4",cidrv6:"\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv6",base64:"\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64",base64url:"\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64url",json_string:"\u0441\u0430\u0442\u0440\u0438 JSON",e164:"\u0440\u0430\u049B\u0430\u043C\u0438 E.164",credit_card:"\u0440\u0430\u049B\u0430\u043C\u0438 \u043A\u043E\u0440\u0442\u0438 \u043A\u0440\u0435\u0434\u0438\u0442\u04E3",currency_code:"\u0440\u0430\u043C\u0437\u0438 \u0430\u0441\u044A\u043E\u0440",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0443\u0440\u0443\u0434"},i={nan:"NaN",number:"\u0440\u0430\u049B\u0430\u043C",string:"\u0441\u0430\u0442\u0440",array:"\u043C\u0430\u0441\u0441\u0438\u0432",object:"\u043E\u0431\u044A\u0435\u043A\u0442",date:"\u0441\u0430\u043D\u0430"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return`\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${o} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442, ${s} \u0433\u0438\u0440\u0438\u0444\u0442\u0430 \u0448\u0443\u0434`}case"invalid_value":return n.values.length===1?`\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${P(n.values[0])} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`:`\u0418\u043D\u0442\u0438\u0445\u043E\u0431\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u044F\u043A\u0435 \u0430\u0437 ${I(n.values,"|")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${n.origin??"\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${o}${n.maximum.toString()} ${a.unit} ${a.verb}`:`\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${n.origin??"\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${o}${n.maximum.toString()} \u0431\u043E\u0448\u0430\u0434`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${n.origin} \u0431\u043E\u044F\u0434 ${o}${n.minimum.toString()} ${a.unit} ${a.verb}`:`\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${n.origin} \u0431\u043E\u044F\u0434 ${o}${n.minimum.toString()} \u0431\u043E\u0448\u0430\u0434`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${o.prefix}" \u043E\u0493\u043E\u0437 \u0448\u0430\u0432\u0430\u0434`:o.format==="ends_with"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${o.suffix}" \u0430\u043D\u04B7\u043E\u043C \u0451\u0431\u0430\u0434`:o.format==="includes"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 "${o.includes}"-\u0440\u043E \u0434\u0430\u0440 \u0431\u0430\u0440 \u0433\u0438\u0440\u0430\u0434`:o.format==="regex"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 \u043D\u0430\u043C\u0443\u043D\u0430\u0438 ${o.pattern} \u043C\u0443\u0432\u043E\u0444\u0438\u049B\u0430\u0442 \u043A\u0443\u043D\u0430\u0434`:`${r[o.format]??n.format}-\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442`}case"not_multiple_of":return`\u0420\u0430\u049B\u0430\u043C\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 ${n.divisor} \u0431\u0435 \u0431\u0430\u049B\u0438\u044F \u0442\u0430\u049B\u0441\u0438\u043C \u0448\u0430\u0432\u0430\u0434`;case"unrecognized_keys":return`\u041A\u0430\u043B\u0438\u0434${n.keys.length>1?"\u04B3\u043E\u0438":"\u0438"} \u043D\u043E\u043C\u0430\u044A\u043B\u0443\u043C: ${I(n.keys,", ")}`;case"invalid_key":return`\u041A\u0430\u043B\u0438\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442\u0438 \u0434\u0438\u0441\u043A\u0440\u0438\u043C\u0438\u043D\u0430\u0442\u043E\u0440: ${n.options.map(a=>`'${a}'`).join(" | ")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`:"\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442";case"invalid_element":return`\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${n.origin}`;default:return"\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442"}}};function q1(){return{localeError:A9()}}var C9=()=>{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"},map:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(n){return e[n]??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",mac:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 MAC",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)",credit_card:"\u0E2B\u0E21\u0E32\u0E22\u0E40\u0E25\u0E02\u0E1A\u0E31\u0E15\u0E23\u0E40\u0E04\u0E23\u0E14\u0E34\u0E15",currency_code:"\u0E23\u0E2B\u0E31\u0E2A\u0E2A\u0E01\u0E38\u0E25\u0E40\u0E07\u0E34\u0E19",iban:"IBAN",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={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 n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.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 ${n.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 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`}case"invalid_value":return n.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",a=t(n.origin);return a?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${n.maximum.toString()} ${a.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",a=t(n.origin);return a?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${n.minimum.toString()} ${a.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.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 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[o.format]??n.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 ${n.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(n.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.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 ${n.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function J1(){return{localeError:C9()}}var O9=()=>{let e={string:{unit:"simwol",verb:"bolmaly"},file:{unit:"ba\xFDt",verb:"bolmaly"},array:{unit:"elementler",verb:"bolmaly"},set:{unit:"elementler",verb:"bolmaly"},map:{unit:"elementler",verb:"bolmaly"}};function t(n){return e[n]??null}let r={regex:"giri\u015F",email:"e-po\xE7ta salgysy",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 sene we wagt",date:"ISO sene",time:"ISO wagt",duration:"ISO wagt aralygy",ipv4:"IPv4 salgysy",ipv6:"IPv6 salgysy",mac:"MAC salgysy",cidrv4:"IPv4 aralygy",cidrv6:"IPv6 aralygy",base64:"base64 bilen \u015Fifrlenen setir",base64url:"base64url bilen \u015Fifrlenen setir",json_string:"JSON setiri",e164:"E.164 nomeri",credit_card:"kredit kartyny\u0148 nomeri",currency_code:"wal\xFDuta kody",iban:"IBAN",jwt:"JWT",template_literal:"\u015Fablon"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return`N\xE4dogry baha: gara\u015Fylan ${o} \xFDerine ${s} alyndy`}case"invalid_value":return n.values.length===1?`N\xE4dogry baha: ${P(n.values[0])} bolmaly`:`N\xE4dogry sa\xFDlaw: a\u015Fakdakylardan biri bolmaly: ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Has uly: gara\u015Fyl\xFDan ${n.origin??"baha"} ${o} ${n.maximum.toString()} ${a.unit??"element"}`:`Has uly: gara\u015Fyl\xFDan ${n.origin??"baha"} ${o} ${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Has ki\xE7i: gara\u015Fyl\xFDan ${n.origin} ${o} ${n.minimum.toString()} ${a.unit}`:`Has ki\xE7i: gara\u015Fyl\xFDan ${n.origin} ${o} ${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`N\xE4dogry setir: "${o.prefix}" bilen ba\u015Flamaly`:o.format==="ends_with"?`N\xE4dogry setir: "${o.suffix}" bilen gutarmaly`:o.format==="includes"?`N\xE4dogry setir: "${o.includes}" saklamaly`:o.format==="regex"?`N\xE4dogry setir: ${o.pattern} nusga la\xFDyk bolmaly`:`N\xE4dogry ${r[o.format]??n.format}`}case"not_multiple_of":return`N\xE4dogry san: ${n.divisor} bilen galyndysyz b\xF6l\xFCnmeli`;case"unrecognized_keys":return`Tanalma\xFDan a\xE7ar${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7inde n\xE4dogry a\xE7ar`;case"invalid_union":return"N\xE4dogry baha";case"invalid_element":return`${n.origin} i\xE7inde n\xE4dogry baha`;default:return"N\xE4dogry baha"}}};function X1(){return{localeError:O9()}}var P9=()=>{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"},map:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(n){return e[n]??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",mac:"MAC 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",credit_card:"kredi kart\u0131 numaras\u0131",currency_code:"para birimi kodu",iban:"IBAN",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${n.expected}, al\u0131nan ${s}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${s}`}case"invalid_value":return n.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${P(n.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${o}${n.maximum.toString()} ${a.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${o}${n.minimum.toString()} ${a.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[o.format]??n.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${n.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${n.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function Y1(){return{localeError:P9()}}var N9=()=>{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"},map:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(n){return e[n]??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",mac:"\u0430\u0434\u0440\u0435\u0441\u0430 MAC",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",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u043E\u0457 \u043A\u0430\u0440\u0442\u043A\u0438",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u0438",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.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 ${n.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 ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`}case"invalid_value":return n.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 ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\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 ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${a.verb} ${o}${n.maximum.toString()} ${a.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 ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} ${a.verb} ${o}${n.minimum.toString()} ${a.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} \u0431\u0443\u0434\u0435 ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[o.format]??n.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 ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0456":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${n.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 ${n.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 Ch(){return{localeError:N9()}}function Q1(){return Ch()}var R9=()=>{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"},map:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(n){return e[n]??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",mac:"\u0627\u06CC\u0645 \u0627\u06D2 \u0633\u06CC \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",credit_card:"\u06A9\u0631\u06CC\u0688\u0679 \u06A9\u0627\u0631\u0688 \u0646\u0645\u0628\u0631",currency_code:"\u06A9\u0631\u0646\u0633\u06CC \u06A9\u0648\u0688",iban:"IBAN",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${n.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: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return n.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${P(n.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${I(n.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${n.maximum.toString()} ${a.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${n.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u06D2 ${o}${n.minimum.toString()} ${a.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u0627 ${o}${n.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[o.format]??n.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${n.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${n.keys.length>1?"\u0632":""}: ${I(n.keys,"\u060C ")}`;case"invalid_key":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function eR(){return{localeError:R9()}}var j9=()=>{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(n){return e[n]??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",credit_card:"kredit karta raqami",currency_code:"valyuta kodi",iban:"IBAN",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${n.expected}, qabul qilingan ${s}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${s}`}case"invalid_value":return n.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${P(n.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Juda katta: kutilgan ${n.origin??"qiymat"} ${o}${n.maximum.toString()} ${a.unit} ${a.verb}`:`Juda katta: kutilgan ${n.origin??"qiymat"} ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Juda kichik: kutilgan ${n.origin} ${o}${n.minimum.toString()} ${a.unit} ${a.verb}`:`Juda kichik: kutilgan ${n.origin} ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[o.format]??n.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${n.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${n.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function tR(){return{localeError:j9()}}var D9=()=>{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"},map:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(n){return e[n]??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",mac:"\u0111\u1ECBa ch\u1EC9 MAC",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",credit_card:"s\u1ED1 th\u1EBB t\xEDn d\u1EE5ng",currency_code:"m\xE3 ti\u1EC1n t\u1EC7",iban:"IBAN",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${n.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`}case"invalid_value":return n.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${P(n.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(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${a.verb} ${o}${n.maximum.toString()} ${a.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${a.verb} ${o}${n.minimum.toString()} ${a.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${r[o.format]??n.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 ${n.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${I(n.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.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 ${n.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function rR(){return{localeError:D9()}}var M9=()=>{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"},map:{unit:"\u9879",verb:"\u5305\u542B"}};function t(n){return e[n]??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",mac:"MAC\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",credit_card:"\u4FE1\u7528\u5361\u53F7",currency_code:"\u8D27\u5E01\u4EE3\u7801",iban:"IBAN",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${n.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`}case"invalid_value":return n.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${P(n.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${o}${n.maximum.toString()} ${a.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${o}${n.minimum.toString()} ${a.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${r[o.format]??n.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${n.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${n.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function nR(){return{localeError:M9()}}var z9=()=>{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"},map:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(n){return e[n]??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",mac:"MAC \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",credit_card:"\u4FE1\u7528\u5361\u865F",currency_code:"\u8CA8\u5E63\u4EE3\u78BC",iban:"IBAN",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${n.expected}\uFF0C\u4F46\u6536\u5230 ${s}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${s}`}case"invalid_value":return n.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${P(n.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${o}${n.maximum.toString()} ${a.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${o}${n.minimum.toString()} ${a.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${r[o.format]??n.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${n.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${n.keys.length>1?"\u5011":""}\uFF1A${I(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function iR(){return{localeError:z9()}}var L9=()=>{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"},map:{unit:"nkan",verb:"n\xED"}};function t(n){return e[n]??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",mac:"\xE0d\xEDr\u1EB9\u0301s\xEC MAC",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",credit_card:"n\u1ECDmba kaadi gbese",currency_code:"koodu ow\xF3",iban:"IBAN",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return n=>{switch(n.code){case"invalid_type":{let o=i[n.expected]??n.expected,a=R(n.input),s=i[a]??a;return/^[A-Z]/.test(n.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${n.expected}, \xE0m\u1ECD\u0300 a r\xED ${s}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${s}`}case"invalid_value":return n.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${P(n.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${I(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",a=t(n.origin);return a?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin??"iye"} ${a.verb} ${o}${n.maximum} ${a.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${n.maximum}`}case"too_small":{let o=n.inclusive?">=":">",a=t(n.origin);return a?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin} ${a.verb} ${o}${n.minimum} ${a.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${n.minimum}`}case"invalid_format":{let o=n;return o.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 "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${r[o.format]??n.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 ${n.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${I(n.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.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 ${n.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function oR(){return{localeError:L9()}}var aR,g0=Symbol("ZodOutput"),_0=Symbol("ZodInput"),Oh=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let i=r[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.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 i={...this.get(r)??{}};delete i.id;let n={...i,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Ph(){return new Oh}(aR=globalThis).__zod_globalRegistry??(aR.__zod_globalRegistry=Ph());var He=globalThis.__zod_globalRegistry;var Ar=Symbol.for("zod.compile.invalid"),sR=Symbol.for("zod.compile.fallback"),Un=class extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}},Ne=class extends Error{constructor(t,r=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=r}};function F9(e,t){try{return Rh(e,{assertOnly:!0})}catch{return t}}function w0(e,t){try{let r=Rh(e),i=Nh(e,r);return i._zod.bag.validator=F9(e,r),i}catch(r){if(t?.strict)throw r;return e}}function Nh(e,t){if(Ih(e))throw new Ne("a schema whose subtree contains a reference cycle");let r=Ie(e),i=e._zod.run,n=i.__originalRun??i,o=(a,s)=>{if(s?.async||s?.direction==="backward"||s?.skipChecks||s?.[sR]||s&&Eh(s,a.value))return n(a,s);let c=t(a.value);return c!==Ar?(a.value=c,a):(s&&(s[sR]=!0),n(a,s))};return o.__originalRun=n,r._zod.bag.fallbackRun=n,r._zod.bag.validator=t,r._zod.run=o,i.__originalRun||B9(r,e,t),r}function B9(e,t,r){let i=e,n=t;if(typeof n.safeParse=="function"){let o=n.safeParse;i.safeParse=(a,s)=>{let c=r(a);return c!==Ar?{success:!0,data:c}:o(a,s)}}if(typeof n.parse=="function"){let o=n.parse;i.parse=(a,s)=>{let c=r(a);return c!==Ar?c:o(a,s)}}}function Rh(e,t){let r=!0;try{r=Ih(e)}catch{}if(r)throw new Ne("a schema whose subtree contains a reference cycle");let i={constants:new Map,constantCounter:0,varCounter:0,definite:!0},n=new Ss(["input"]),o=ft(n,i,e,"input",!t?.assertOnly);n.write(o===null?"return true;":`return ${o};`);let a=["INVALID",...i.constants.keys()],s=[Ar,...i.constants.values()],c=n.content.join(`
218
+ `),u=t?.debug?a.length>0?`// Constants: ${a.join(", ")}
219
+ ${c}`:c:"",l=Function,d=`return (input) => {
220
+ ${c}
221
+ }`,f;try{f=new l(...a,d)(...s)}catch(p){throw new Ne(`this schema (generated code failed to evaluate: ${p.message})`)}return t?.debug&&(f.code=u),f.definite=i.definite,f}function fe(e,t){for(let[i,n]of e.constants)if(n===t)return i;let r=`c${e.constantCounter++}`;return e.constants.set(r,t),r}function Ts(e,t){return e.definite=!1,fe(e,t)}function ce(e){return`v${e.varCounter++}`}function V9(e,t){let r=e._zod.run({value:t,issues:[]},{});if(r&&typeof r.then=="function")return Ar;let i=r;return i.issues.length===0?i.value:Ar}function dr(e,t,r,i,n=!0){let o=e.content.length,a=t.constants.size,s=t.constantCounter,c=t.varCounter;try{return ft(e,t,r,i,n)}catch(u){if(!(u instanceof Ne)||!u.islandable)throw u;if(e.content.length=o,t.constants.size>a){let l=Array.from(t.constants.keys()).slice(a);for(let d of l)t.constants.delete(d)}return t.constantCounter=s,t.varCounter=c,H9(e,t,r,i)}}function H9(e,t,r,i){t.definite=!1;let n=fe(t,r),o=fe(t,V9),a=ce(t);return e.write(`const ${a} = ${o}(${n}, ${i});`),e.write(`if (${a} === INVALID) return INVALID;`),a}var Z9=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function G9(e,t,r,i){let n=r._zod.def.checks;if(!n||n.length===0)return i;let o=i;for(let a of n){let s=a._zod.def;if(s.when&&!Z9.has(s.check))throw new Ne('check with a custom "when" condition');switch(s.check){case"greater_than":K9(e,t,s,o);break;case"less_than":W9(e,t,s,o);break;case"multiple_of":q9(e,t,s,o);break;case"number_format":pR(e,s,o);break;case"min_length":{let c=Is(s.minimum,"min_length"),u=y0(e,t,o,`${o}.length >= ${c} && ${o}.length < ${s.minimum*2}`);e.write(`if (${u} < ${c}) return INVALID;`);break}case"max_length":{let c=Is(s.maximum,"max_length"),u=y0(e,t,o,`${o}.length > ${c}`);e.write(`if (${u} > ${c}) return INVALID;`);break}case"length_equals":{let c=Is(s.length,"length_equals"),u=y0(e,t,o,`${o}.length >= ${c} && ${o}.length <= ${s.length*2}`);e.write(`if (${u} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${o}.size < ${Is(s.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${Is(s.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${Is(s.size,"size_equals")}) return INVALID;`);break;case"string_format":o=mR(e,t,s,o);break;case"custom":o=tZ(e,t,a,o);break;case"bigint_format":J9(e,s,o);break;case"mime_type":X9(e,t,s,o);break;case"property":Q9(e,t,s,o);break;case"properties":Y9(e,t,s,o);break;case"overwrite":{let c=ce(t);eZ(e,t,a,o,c),o=c;break}default:throw new Ne(`check type ${s.check}`)}}return o}function y0(e,t,r,i){let n=fe(t,bs),o=ce(t);return e.write(`const ${o} = typeof ${r} === "string" && ${i} ? ${n}(${r}) : ${r}.length;`),o}function Is(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new Ne(`${t} bound of type ${typeof e}`);return`${e}`}function fR(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new Ne("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new Ne("comparison check with Invalid Date bound");return fe(e,t)}throw new Ne(`comparison check bound of type ${typeof t}`)}function K9(e,t,r,i){let n=r.inclusive?"<":"<=";e.write(`if (${i} ${n} ${fR(t,r.value)}) return INVALID;`)}function W9(e,t,r,i){let n=r.inclusive?">":">=";e.write(`if (${i} ${n} ${fR(t,r.value)}) return INVALID;`)}function q9(e,t,r,i){if(typeof r.value=="bigint"){if(r.value===BigInt(0))throw new Ne("multiple_of check with a zero divisor");e.write(`if (${i} % ${r.value}n !== 0n) return INVALID;`)}else{let n=fe(t,Yl);e.write(`if (${n}(${i}, ${Is(r.value,"multiple_of")}) !== 0) return INVALID;`)}}function pR(e,t,r){let i=t.format;switch(i){case"safeint":e.write(`if (!Number.isSafeInteger(${r})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${r}) || ${r} < -2147483648 || ${r} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${r}) || ${r} < 0 || ${r} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${r}) || ${r} < -3.4028234663852886e38 || ${r} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${r})) return INVALID;`);break;default:throw new Ne(`number format ${i}`)}}function J9(e,t,r){let i=t.format;if(i)switch(i){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break;default:throw new Ne(`bigint format ${i}`)}}function X9(e,t,r,i){let n=r.mime;if(n&&n.length>0){let o=fe(t,new Set(n));e.write(`if (!${o}.has(${i}.type)) return INVALID;`)}}function Y9(e,t,r,i){if(r.when)throw new Ne('check with a custom "when" condition');e.write(`if (${i} == null) return INVALID;`);let n=r.shape;for(let o of Reflect.ownKeys(n)){let a=typeof o=="symbol"?fe(t,o):Er(o),s=ce(t);e.write(`const ${s} = ${i}[${a}];`),dr(e,t,n[o],s,!1)}}function Q9(e,t,r,i){let n=`${i}[${JSON.stringify(r.property)}]`;ft(e,t,r.schema,n)}function eZ(e,t,r,i,n){let o=r._zod.def.tx;if(!o)throw new Ne("overwrite check without a transform function");if(As(o))throw new Un("z.compile: async overwrite transforms are not supported");let a=fe(t,o);e.write(`const ${n} = ${a}(${i});`)}function v0(){throw new Br}function x0(e){this.issues.push(e)}function tZ(e,t,r,i){let n=r._zod.def;if(n.fn){if(As(n.fn))throw new Un("z.compile: async .refine() predicates are not supported");let o=Ts(t,n.fn),a=fe(t,v0),s=ce(t);return e.write(`const ${s} = ${o}(${i});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`),i}if(r._zod.check){if(As(r._zod.check))throw new Un("z.compile: async .superRefine() / check functions are not supported");let o=r._zod.check,s=Ts(t,u=>{let l={value:u,issues:[],addIssue:x0};return o(l)instanceof Promise&&v0(),l.issues.length===0?l.value:Ar}),c=ce(t);return e.write(`const ${c} = ${s}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new Ne("custom check without a predicate or check function")}var rZ=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function mR(e,t,r,i,n=!0){let o=r.format;if(o==="base64"){let u=fe(t,_d);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(o==="base64url"){let u=fe(t,mh);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(o==="jwt"){let u=fe(t,_h),l=fe(t,r.alg??null);return e.write(`if (!${u}(${i}, ${l})) return INVALID;`),i}if(o==="ipv6"){let u=fe(t,gd);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(o==="cidrv6"){let u=fe(t,fh);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(o==="credit_card"){let u=fe(t,hh);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(o==="iban"){let u=fe(t,gh);return e.write(`if (!${u}(${i})) return INVALID;`),i}let a=r;if(o==="url"||o==="httpurl"||a.normalize||a.hostname!==void 0||a.protocol!==void 0){let u=fe(t,uh),l=fe(t,r),d=ce(t),f=ce(t);if(e.write(`const ${d} = ${i}.trim();`),e.write(`const ${f} = ${u}(${d}, ${l});`),e.write(`if (typeof ${f} === "number") return INVALID;`),a.hostname!==void 0){let h=fe(t,lh);e.write(`if (!${h}(${f}, ${l}.hostname)) return INVALID;`)}if(a.protocol!==void 0){let h=fe(t,dh);e.write(`if (!${h}(${f}, ${l}.protocol)) return INVALID;`)}if(!n)return null;let p=ce(t),m=a.normalize?`${f}.href`:`${fe(t,hd)}(${d})`;return e.write(`const ${p} = ${m};`),p}let s=r.fn;if(s){if(As(s))throw new Ne(`async string format ${o}`);let u=fe(t,s);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(rZ.has(o)&&r.pattern){let u=fe(t,r.pattern);return e.write(`${u}.lastIndex = 0;`),e.write(`if (!${u}.test(${i})) return INVALID;`),i}let c=r.format;switch(c){case"regex":throw new Ne("regex format without a pattern");case"lowercase":e.write(`if (${i} !== ${i}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${i} !== ${i}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${i}.includes(${Er(r.includes)})) return INVALID;`);break;case"starts_with":{let u=r.prefix;e.write(`if (${i}.slice(0, ${u.length}) !== ${Er(u)}) return INVALID;`);break}case"ends_with":{let u=r.suffix;e.write(`if (${i}.slice(-${u.length}) !== ${Er(u)}) return INVALID;`);break}default:throw new Ne(`string format ${c}`)}return i}function ft(e,t,r,i,n=!0){let o=r._zod.def,a=o.type;if(o.coerce)throw new Ne(`coercion (z.coerce.${a}())`);let s=n||!!o.checks?.length,c;switch(a){case"string":c=nZ(e,t,r,i,s);break;case"number":c=iZ(e,r,i);break;case"boolean":c=oZ(e,i);break;case"bigint":c=aZ(e,r,i);break;case"symbol":c=sZ(e,i);break;case"undefined":c=cZ(e,i);break;case"null":c=uZ(e,i);break;case"any":case"unknown":c=i;break;case"never":e.write("return INVALID;"),c=i;break;case"void":c=lZ(e,i);break;case"nan":c=dZ(e,i);break;case"date":c=fZ(e,i);break;case"object":c=pZ(e,t,r,i,s);break;case"optional":c=mZ(e,t,r,i,s);break;case"nullable":c=_Z(e,t,r,i,s);break;case"array":c=yZ(e,t,r,i,s);break;case"literal":c=vZ(e,t,r,i);break;case"enum":c=bZ(e,t,r,i);break;case"readonly":{let u=uR(e,t,r,i),l=ce(t);e.write(`const ${l} = Object.freeze(${u});`),c=l;break}case"success":uR(e,t,r,i),c="true";break;case"default":case"prefault":c=wZ(e,t,r,i);break;case"nonoptional":c=xZ(e,t,r,i);break;case"tuple":c=SZ(e,t,r,i);break;case"union":c=kZ(e,t,r,i);break;case"intersection":c=EZ(e,t,r,i);break;case"record":c=TZ(e,t,r,i);break;case"map":c=CZ(e,t,r,i);break;case"set":c=OZ(e,t,r,i);break;case"file":c=PZ(e,i);break;case"template_literal":c=NZ(e,t,r,i);break;case"lazy":c=RZ(e,t,r,i);break;case"pipe":c=jZ(e,t,r,i);break;case"custom":c=DZ(e,t,r,i);break;case"transform":c=LZ(e,t,r,i);break;case"catch":c=zZ(e,t,r,i);break;default:throw new Ne(`schema type ${a}`)}return c===null?null:G9(e,t,r,c)}function nZ(e,t,r,i,n=!0){e.write(`if (typeof ${i} !== "string") return INVALID;`);let o=r._zod.def;return o.format===void 0?i:mR(e,t,o,i,n)}function iZ(e,t,r){e.write(`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return INVALID;`);let i=t._zod.def;return i.check==="number_format"&&i.format&&pR(e,{format:i.format},r),r}function oZ(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function aZ(e,t,r){e.write(`if (typeof ${r} !== "bigint") return INVALID;`);let i=t._zod.def;if(i.format)switch(i.format){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break}return r}function sZ(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function cZ(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function uZ(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function lZ(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function dZ(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function fZ(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function pZ(e,t,r,i,n=!0){let o=r._zod.def;e.write(`if (typeof ${i} !== "object" || ${i} === null || Array.isArray(${i})) return INVALID;`);let a=o.shape,s=Object.keys(a),c=Object.getOwnPropertySymbols(a),u=c.length?[...s,...c]:s,l=v=>typeof v=="symbol"?fe(t,v):Er(v),d=v=>typeof v=="symbol"?`[${l(v)}]`:Er(v),f=a;if(s.includes("__proto__"))throw new Ne('object shape key "__proto__"');let p=new Map;for(let v of u){let x=f[v],S=l(v),k=ce(t);if(e.write(`const ${k} = ${i}[${S}];`),x._zod.optin!==void 0){let T=ce(t);e.write(`let ${T} = (() => {`),e.indented(A=>{let b=dr(A,t,x,k);A.write(`return ${b};`)}),e.write("})();"),x._zod.optout==="optional"?(e.write(`if (${T} === INVALID) {`),e.indented(A=>{A.write(`if (${S} in ${i}) return INVALID;`),A.write(`${T} = undefined;`)}),e.write("}")):e.write(`if (${T} === INVALID) return INVALID;`),p.set(v,T)}else{gZ(x)&&e.write(`if (!(${S} in ${i})) return INVALID;`);let T=dr(e,t,x,k,n);T!==null&&p.set(v,T)}}let m=o.catchall,h="none";if(m){let v=m._zod.def.type;if(v==="never"){let x=s.map(S=>`k !== ${Er(S)}`).join(" && ")||"true";e.write(`for (const k in ${i}) {`),e.indented(S=>{S.write(`if (${x}) return INVALID;`)}),e.write("}")}else(v==="unknown"||v==="any")&&!m._zod.def.checks?.length?h="passthrough":h="schema"}let g=ce(t),_=u.some(v=>cR(f[v])||b0(f[v]));if(!n){if(h==="schema"){let v=s.length>0?fe(t,new Set(s)):null;e.write(`for (const k in ${i}) {`),e.indented(x=>{x.write('if (k === "__proto__") continue;'),v&&x.write(`if (${v}.has(k)) continue;`);let S=ce(t);x.write(`const ${S} = ${i}[k];`),dr(x,t,m,S,!1)}),e.write("}")}return null}if(_){e.write(`const ${g} = {};`);for(let v of u){let x=l(v),S=p.get(v);b0(f[v])?e.write(`if (${x} in ${i}) ${g}[${x}] = ${S};`):cR(f[v])?e.write(`if (${S} !== undefined || ${x} in ${i}) ${g}[${x}] = ${S};`):e.write(`${g}[${x}] = ${S};`)}}else{let v=u.map(x=>`${d(x)}: ${p.get(x)}`).join(", ");e.write(`const ${g} = { ${v} };`)}if(h!=="none"){let v=s.length>0?fe(t,new Set(s)):null;e.write(`for (const k in ${i}) {`),e.indented(x=>{if(x.write('if (k === "__proto__") continue;'),v&&x.write(`if (${v}.has(k)) continue;`),h==="passthrough")x.write(`${g}[k] = ${i}[k];`);else{let S=ce(t);x.write(`const ${S} = ${i}[k];`);let k=dr(x,t,m,S);x.write(`${g}[k] = ${k};`)}}),e.write("}")}return g}function mZ(e,t,r,i,n=!0){let o=r._zod.def;if(hZ(r))return ft(e,t,o.innerType,i,n);if(o.innerType._zod.optin==="defaulted"){let s=ce(t),c=ce(t);return e.write(`let ${s};`),e.write(`if (${i} === undefined) {`),e.indented(u=>{u.write(`const ${c} = (() => {`),u.indented(l=>{let d=ft(l,t,o.innerType,i);l.write(`return ${d};`)}),u.write("})();"),u.write(`if (${c} !== INVALID) ${s} = ${c};`)}),e.write("} else {"),e.indented(u=>{let l=ft(u,t,o.innerType,i);u.write(`${s} = ${l};`)}),e.write("}"),s}let a=n?ce(t):null;return a&&e.write(`let ${a};`),e.write(`if (${i} !== undefined) {`),e.indented(s=>{let c=ft(s,t,o.innerType,i,n);a&&c!==null&&s.write(`${a} = ${c};`)}),e.write("}"),a}function hZ(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function gZ(e){return e._zod.optin===void 0&&Es(e)}function Es(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Es(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Es(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Es):!0;case"intersection":return!t.left||!t.right?!0:Es(t.left)&&Es(t.right);case"pipe":return t.in?Es(t.in):!0;default:return!0}}function b0(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function cR(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&lu(e)}function lu(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?lu(t.innerType):!0;case"union":return t.options?t.options.some(lu):!0;case"intersection":return!t.left||!t.right||lu(t.left)||lu(t.right);case"pipe":return t.out?lu(t.out):!0;default:return!0}}function _Z(e,t,r,i,n=!0){let o=r._zod.def,a=n?ce(t):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${i} !== null) {`),e.indented(s=>{let c=ft(s,t,o.innerType,i,n);a&&c!==null&&s.write(`${a} = ${c};`)}),e.write("}"),a}function yZ(e,t,r,i,n=!0){let o=r._zod.def;e.write(`if (!Array.isArray(${i})) return INVALID;`);let a=n?ce(t):null,s=ce(t),c=ce(t);return a&&e.write(`const ${a} = new Array(${i}.length);`),e.write(`for (let ${s} = 0; ${s} < ${i}.length; ${s}++) {`),e.indented(u=>{u.write(`const ${c} = ${i}[${s}];`);let l=dr(u,t,o.element,c,n);a&&l!==null&&u.write(`${a}[${s}] = ${l};`)}),e.write("}"),a}function vZ(e,t,r,i){let o=r._zod.def.values;if(o.length!==1){let s=fe(t,new Set(o));return e.write(`if (!${s}.has(${i})) return INVALID;`),i}let a=o[0];if(typeof a=="number"&&Number.isNaN(a)){let s=fe(t,new Set(o));return e.write(`if (!${s}.has(${i})) return INVALID;`),i}if(typeof a=="string")e.write(`if (${i} !== ${Er(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${i} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${i} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${i} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${i} !== ${a}n) return INVALID;`);else throw new Ne(`literal type ${typeof a}`);return i}function bZ(e,t,r,i){let n=r._zod.values;if(!n)throw new Ne("enum schema without enumerated values");let o=fe(t,n);return e.write(`if (!${o}.has(${i})) return INVALID;`),i}function uR(e,t,r,i){let n=r._zod.def;return ft(e,t,n.innerType,i)}function wZ(e,t,r,i){let n=r._zod.def,a=Object.getOwnPropertyDescriptor(r._zod.def,"defaultValue")?()=>r._zod.def.defaultValue:void 0;if(r._zod.def.type==="prefault"){if(!a)return ft(e,t,n.innerType,i);let c=fe(t,a),u=ce(t);return e.write(`let ${u} = ${i};`),e.write(`if (${i} === undefined) ${u} = ${c}();`),ft(e,t,n.innerType,u)}let s=ce(t);if(a){let c=fe(t,a),u=fe(t,Ql);e.write(`let ${s};`),e.write(`if (${i} === undefined) {`),e.indented(l=>{l.write(`${s} = ${u}(${c}());`)}),e.write("} else {"),e.indented(l=>{let d=ft(l,t,n.innerType,i);l.write(`${s} = ${d} === undefined ? ${u}(${c}()) : ${d};`)}),e.write("}")}else e.write(`let ${s};`),e.write(`if (${i} !== undefined) {`),e.indented(c=>{let u=ft(c,t,n.innerType,i);c.write(`${s} = ${u};`)}),e.write("}");return s}function xZ(e,t,r,i){let n=r._zod.def,o=ft(e,t,n.innerType,i),a=ce(t);return e.write(`const ${a} = ${o};`),e.write(`if (${a} === undefined) return INVALID;`),a}function SZ(e,t,r,i){let n=r._zod.def,o=n.items,a=n.rest;e.write(`if (!Array.isArray(${i})) return INVALID;`);let s=lR(o,"optin"),c=lR(o,"optout");a?e.write(`if (${i}.length < ${s}) return INVALID;`):e.write(`if (${i}.length < ${s} || ${i}.length > ${o.length}) return INVALID;`);let u=ce(t);e.write(`const ${u} = [];`);for(let l=0;l<o.length;l++){let d=o[l];if(l>=c)e.write(`if (${u}.length === ${l}) {`),e.indented(f=>{f.write(`if (${l} < ${i}.length) {`),f.indented(p=>{let m=ce(t);p.write(`const ${m} = ${i}[${l}];`);let h=dr(p,t,d,m);p.write(`${u}[${l}] = ${h};`)}),f.write("} else {"),f.indented(p=>{if(b0(d)){p.write(`${u}.length = ${l};`);return}let m=ce(t),h=ce(t);p.write(`const ${m} = undefined;`),p.write(`const ${h} = (() => {`),p.indented(g=>{let _=dr(g,t,d,m);g.write(`return ${_};`)}),p.write("})();"),p.write(`if (${h} === INVALID || ${h} === undefined) ${u}.length = ${l};`),p.write(`else ${u}[${l}] = ${h};`)}),f.write("}")}),e.write("}");else{let f=ce(t);e.write(`const ${f} = ${i}[${l}];`);let p=dr(e,t,d,f);e.write(`${u}[${l}] = ${p};`)}}if(a){let l=ce(t),d=ce(t);e.write(`for (let ${l} = ${o.length}; ${l} < ${i}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${i}[${l}];`);let p=dr(f,t,a,d);f.write(`${u}[${l}] = ${p};`)}),e.write("}")}return u}function lR(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function kZ(e,t,r,i){let n=r._zod.def,o=n.options;if(n.discriminator)return $Z(e,t,n,i);if(n.inclusive===!1)throw new Ne("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),i;if(o.length===1)return ft(e,t,o[0],i);if(o.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){let c=new Set(o.flatMap(l=>l._zod.def.values)),u=fe(t,c);return e.write(`if (!${u}.has(${i})) return INVALID;`),i}let s=ce(t);e.write(`let ${s};`);for(let c=0;c<o.length;c++){let u=o[c];c===0?e.write(`${s} = (() => {`):e.write(`if (${s} === INVALID) ${s} = (() => {`),e.indented(l=>{let d=ft(l,t,u,i);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${s} === INVALID) return INVALID;`),s}function $Z(e,t,r,i){if(r.unionFallback)throw new Ne("discriminated union with unionFallback");if(r.options.length===0)return e.write("return INVALID;"),i;let n=ce(t),o=ce(t);e.write(`const ${n} = ${i}?.[${Er(r.discriminator)}];`),e.write(`let ${o};`);let a=!0,s=new Set;for(let c of r.options){let u=c._zod.propValues?.[r.discriminator];if(!u||u.size===0)throw new Ne("discriminated union option without static discriminator values");for(let f of u){if(s.has(f))throw new Ne(`duplicate discriminator value ${String(f)}`);s.add(f)}let l=Array.from(u,f=>IZ(t,n,f)),d=a?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{let p=ft(f,t,c,i);f.write(`${o} = ${p};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),o}function IZ(e,t,r){if(typeof r=="string")return`${t} === ${Er(r)}`;if(typeof r=="number")return Number.isNaN(r)?`Number.isNaN(${t})`:`${t} === ${r}`;if(typeof r=="boolean")return`${t} === ${r}`;if(r===null)return`${t} === null`;if(r===void 0)return`${t} === undefined`;if(typeof r=="bigint")return`${t} === ${r}n`;if(typeof r=="symbol"){let i=fe(e,r);return`${t} === ${i}`}throw new Ne(`literal discriminator value ${String(r)}`)}function EZ(e,t,r,i){let n=r._zod.def;t.definite=!1;let o=dr(e,t,n.left,i),a=dr(e,t,n.right,i),s=fe(t,su),c=ce(t);return e.write(`const ${c} = ${s}(${o}, ${a});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function TZ(e,t,r,i){let n=r._zod.def,o=fe(t,_n);e.write(`if (!${o}(${i})) return INVALID;`);let a=ce(t),s=ce(t),c=ce(t);e.write(`const ${a} = {};`);let u=n,l=u.partial?void 0:n.keyType._zod.values;if(l){let p=[];for(let h of l){if(!(typeof h=="string"||typeof h=="number"||typeof h=="symbol"))throw new Ne(`record key value ${String(h)}`);let g=typeof h=="number"?h.toString():h;if(g==="__proto__")throw new Ne('record key "__proto__"');p.push(g);let _=fe(t,h),v=ft(e,t,n.keyType,_),x=ce(t);e.write(`const ${x} = ${i}[${AZ(t,g)}];`);let S=dr(e,t,n.valueType,x);e.write(`${a}[${v}] = ${S};`)}let m=fe(t,new Set(p));return e.write(`for (const ${s} in ${i}) {`),e.indented(h=>{h.write(`if (${m}.has(${s})) continue;`),u.mode==="loose"?h.write(`if (${s} !== "__proto__") ${a}[${s}] = ${i}[${s}];`):h.write("return INVALID;")}),e.write("}"),a}let d=n.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){let p=n.mode==="loose",m=Rh(n.keyType);m.definite===!1&&(t.definite=!1);let h=fe(t,m),g=fe(t,no),_=ce(t);return dR(e,t,i,s,v=>{v.write(`let ${_} = ${h}(${s});`),v.write(`if (${_} === INVALID && typeof ${s} === "string" && ${g}.test(${s})) ${_} = ${h}(Number(${s}));`),p?v.write(`if (${_} === INVALID) { ${a}[${s}] = ${i}[${s}]; continue; }`):v.write(`if (${_} === INVALID) return INVALID;`),v.write(`if (${_} === "__proto__") continue;`);let x=ce(t);v.write(`const ${x} = ${i}[${s}];`);let S=dr(v,t,n.valueType,x);v.write(`${a}[${_}] = ${S};`)}),a}return dR(e,t,i,s,p=>{p.write(`const ${c} = ${i}[${s}];`);let m=dr(p,t,n.valueType,c);p.write(`${a}[${s}] = ${m};`)},"return INVALID;"),a}function dR(e,t,r,i,n,o){let a=fe(t,Object.prototype.propertyIsEnumerable),s=ce(t),c=ce(t),u=ce(t);e.write(`const ${s} = Object.getOwnPropertySymbols(${r});`),e.write(`const ${c} = Object.getOwnPropertyNames(${r});`),e.write(`for (let ${u} = 0; ${u} < ${c}.length; ${u}++) {`),e.indented(l=>{l.write(`const ${i} = ${c}[${u}];`),l.write(`if (${i} === "__proto__" || !${a}.call(${r}, ${i})) continue;`),n(l)}),e.write("}"),e.write(`for (let ${u} = 0; ${u} < ${s}.length; ${u}++) {`),e.indented(l=>{l.write(`const ${i} = ${s}[${u}];`),l.write(`if (!${a}.call(${r}, ${i})) continue;`),o?l.write(o):n(l)}),e.write("}")}function AZ(e,t){return typeof t=="string"?Er(t):fe(e,t)}function CZ(e,t,r,i){let n=r._zod.def;e.write(`if (!(${i} instanceof Map)) return INVALID;`);let o=ce(t),a=ce(t),s=ce(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${a}, ${s}] of ${i}) {`),e.indented(c=>{let u=ft(c,t,n.keyType,a),l=ft(c,t,n.valueType,s);c.write(`${o}.set(${u}, ${l});`)}),e.write("}"),o}function OZ(e,t,r,i){let n=r._zod.def;e.write(`if (!(${i} instanceof Set)) return INVALID;`);let o=ce(t),a=ce(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${a} of ${i}) {`),e.indented(s=>{let c=ft(s,t,n.valueType,a);s.write(`${o}.add(${c});`)}),e.write("}"),o}function PZ(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function NZ(e,t,r,i){e.write(`if (typeof ${i} !== "string") return INVALID;`);let n=r._zod.pattern;if(n){let o=fe(t,n);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${i})) return INVALID;`)}return i}function RZ(e,t,r,i){let n=r._zod.def,o=Ts(t,n.getter),a=fe(t,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(c=>{c.write(`const inner = ${o}();`),c.write(`${a}.parser = function(input) {`),c.indented(u=>{u.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),u.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");let s=ce(t);return e.write(`const ${s} = ${a}.parser(${i});`),e.write(`if (${s} === INVALID) return INVALID;`),s}function jZ(e,t,r,i){let n=r._zod.def,o=ft(e,t,n.in,i);if(n.transform){if(As(n.transform))throw new Un("z.compile: async transforms in pipes are not supported");let a=n.transform,c=Ts(t,l=>{let d={value:l,issues:[],addIssue:x0},f=a(l,d);return f instanceof Promise?Ar:d.issues.length===0?f:Ar}),u=ce(t);return e.write(`const ${u} = ${c}(${o});`),e.write(`if (${u} === INVALID) return INVALID;`),ft(e,t,n.out,u)}else return ft(e,t,n.out,o)}function As(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function DZ(e,t,r,i){let n=r._zod.def;if(n.fn){if(As(n.fn))throw new Un("z.compile: async custom predicates are not supported");let o=Ts(t,n.fn),a=fe(t,v0),s=ce(t);e.write(`const ${s} = ${o}(${i});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`)}else throw new Ne("custom schema without a predicate function");return i}function MZ(e,t,r){let i=e._zod.run({value:r,issues:[]},{});if(i&&typeof i.then=="function")return Ar;let n=i;return n.issues.length===0?n.value:t()}function zZ(e,t,r,i){let n=r._zod.def;if(!n.catchValue[Bm])throw new Ne("catch with a callback (only a constant catch value compiles)",!1);let o=ce(t);e.write(`let ${o} = (() => {`),e.indented(u=>{let l=dr(u,t,n.innerType,i);u.write(`return ${l};`)}),e.write("})();");let a=fe(t,n.innerType),s=Ts(t,n.catchValue),c=fe(t,MZ);return e.write(`if (${o} === INVALID) {`),e.indented(u=>{u.write(`${o} = ${c}(${a}, ${s}, ${i});`),u.write(`if (${o} === INVALID) return INVALID;`)}),e.write("}"),o}function LZ(e,t,r,i){let n=r._zod.def;if(n.transform){if(As(n.transform))throw new Un("z.compile: async transforms are not supported");let o=n.transform,s=Ts(t,u=>{let l={value:u,issues:[],addIssue:x0},d=o(u,l);return d instanceof Promise?Ar:l.issues.length===0?d:Ar}),c=ce(t);return e.write(`const ${c} = ${s}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return i}function jh(e){return e.checks&&(e.checks=[...e.checks]),e}function S0(e,t){return new e(jh({type:"string",...F(t)}))}function k0(e,t){return new e(jh({type:"string",coerce:!0,...F(t)}))}function Dh(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...F(t)})}function Mh(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...F(t)})}function zh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...F(t)})}function Lh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...F(t)})}function Uh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...F(t)})}function Fh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...F(t)})}function Cd(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...F(t)})}function Bh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...F(t)})}function Vh(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...F(t)})}function Hh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...F(t)})}function Zh(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...F(t)})}function Gh(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...F(t)})}function Kh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...F(t)})}function Wh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...F(t)})}function qh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...F(t)})}function Jh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...F(t)})}function $0(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...F(t)})}function Xh(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...F(t)})}function Yh(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...F(t)})}function Qh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...F(t)})}function eg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...F(t)})}function tg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...F(t)})}function I0(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...F(t)})}function E0(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...F(t)})}function rg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...F(t)})}var T0={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Od(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...F(t)})}function Pd(e,t){return new e({type:"string",format:"date",check:"string_format",...F(t)})}function Nd(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...F(t)})}function Rd(e,t){return new e({type:"string",format:"duration",check:"string_format",...F(t)})}function A0(e,t){return new e(jh({type:"number",checks:[],...F(t)}))}function C0(e,t){return new e(jh({type:"number",coerce:!0,checks:[],...F(t)}))}function O0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...F(t)})}function P0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...F(t)})}function N0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...F(t)})}function R0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...F(t)})}function j0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...F(t)})}function D0(e,t){return new e({type:"boolean",...F(t)})}function M0(e,t){return new e({type:"boolean",coerce:!0,...F(t)})}function z0(e,t){return new e({type:"bigint",...F(t)})}function L0(e,t){return new e({type:"bigint",coerce:!0,...F(t)})}function U0(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...F(t)})}function F0(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...F(t)})}function B0(e,t){return new e({type:"symbol",...F(t)})}function V0(e,t){return new e({type:"undefined",...F(t)})}function H0(e,t){return new e({type:"null",...F(t)})}function Z0(e){return new e({type:"any"})}function jd(e){return new e({type:"unknown"})}function Dd(e,t){return new e({type:"never",...F(t)})}function G0(e,t){return new e({type:"void",...F(t)})}function K0(e,t){return new e({type:"date",...F(t)})}function W0(e,t){return new e({type:"date",coerce:!0,...F(t)})}function q0(e,t){return new e({type:"nan",...F(t)})}function bi(e,t){return new rh({check:"less_than",...F(t),value:e,inclusive:!1})}function an(e,t){return new rh({check:"less_than",...F(t),value:e,inclusive:!0})}function wi(e,t){return new nh({check:"greater_than",...F(t),value:e,inclusive:!1})}function sn(e,t){return new nh({check:"greater_than",...F(t),value:e,inclusive:!0})}function ng(e){return wi(0,e)}function ig(e){return bi(0,e)}function og(e){return an(0,e)}function ag(e){return sn(0,e)}function ia(e,t){return new Mw({check:"multiple_of",...F(t),value:e})}function oa(e,t){return new Uw({check:"max_size",...F(t),maximum:e})}function xi(e,t){return new Fw({check:"min_size",...F(t),minimum:e})}function Cs(e,t){return new Bw({check:"size_equals",...F(t),size:e})}function Os(e,t){return new Vw({check:"max_length",...F(t),maximum:e})}function io(e,t){return new Hw({check:"min_length",...F(t),minimum:e})}function Ps(e,t){return new Zw({check:"length_equals",...F(t),length:e})}function du(e,t){return new Gw({check:"string_format",format:"regex",...F(t),pattern:e})}function fu(e){return new Kw({check:"string_format",format:"lowercase",...F(e)})}function pu(e){return new Ww({check:"string_format",format:"uppercase",...F(e)})}function mu(e,t){return new qw({check:"string_format",format:"includes",...F(t),includes:e})}function hu(e,t){return new Jw({check:"string_format",format:"starts_with",...F(t),prefix:e})}function gu(e,t){return new Xw({check:"string_format",format:"ends_with",...F(t),suffix:e})}function sg(e,t,r){return new Yw({check:"property",property:e,schema:t,...F(r)})}function _u(e,t){return new Qw({check:"properties",shape:e,...F(t)})}function yu(e,t){return new ex({check:"mime_type",mime:e,...F(t)})}function Fn(e){return new tx({check:"overwrite",tx:e})}function vu(e){return Fn(t=>t.normalize(e))}function bu(){return Fn(e=>e.trim())}function wu(){return Fn(e=>e.toLowerCase())}function xu(){return Fn(e=>e.toUpperCase())}function Su(){return Fn(e=>Lb(e))}function J0(e,t,r){return new e({type:"array",element:t,...F(r)})}function UZ(e,t,r){return new e({type:"union",options:t,...F(r)})}function FZ(e,t,r){return new e({type:"union",options:t,inclusive:!1,...F(r)})}function BZ(e,t,r,i){return new e({type:"union",options:r,discriminator:t,...F(i)})}function VZ(e,t,r){return new e({type:"intersection",left:t,right:r})}function HZ(e,t,r,i){let n=r instanceof _e,o=n?i:r,a=n?r:null;return new e({type:"tuple",items:t,rest:a,...F(o)})}function ZZ(e,t,r,i){return new e({type:"record",keyType:t,valueType:r,...F(i)})}function GZ(e,t,r,i){return new e({type:"map",keyType:t,valueType:r,...F(i)})}function KZ(e,t,r){return new e({type:"set",valueType:t,...F(r)})}function WZ(e,t,r){let i=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:i,...F(r)})}function qZ(e,t,r){return new e({type:"enum",entries:t,...F(r)})}function JZ(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...F(r)})}function X0(e,t){return new e({type:"file",...F(t)})}function XZ(e,t){return new e({type:"transform",transform:t})}function YZ(e,t){return new e({type:"optional",innerType:t})}function QZ(e,t){return new e({type:"nullable",innerType:t})}function e3(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Ql(r)}})}function t3(e,t,r){return new e({type:"nonoptional",innerType:t,...F(r)})}function r3(e,t){return new e({type:"success",innerType:t})}function n3(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:Zb(r)})}function i3(e,t,r){return new e({type:"pipe",in:t,out:r})}function o3(e,t){return new e({type:"readonly",innerType:t})}function a3(e,t,r){return new e({type:"template_literal",parts:t,...F(r)})}function s3(e,t){return new e({type:"lazy",getter:t})}function c3(e,t){return new e({type:"promise",innerType:t})}function Y0(e,t,r){let i=F(r);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function Q0(e,t,r){return new e({type:"custom",check:"custom",fn:t,...F(r)})}function eS(e,t){let r=hR(i=>(i.addIssue=n=>{if(typeof n=="string")i.issues.push(tu(n,i.value,r._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=i.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),i.issues.push(tu(o))}},e(i.value,i)),t);return r}function hR(e,t){let r=new Je({check:"custom",...F(t)});return r._zod.check=e,r}function tS(e){let t=new Je({check:"describe"});return t._zod.onattach=[r=>{let i=He.get(r)??{};He.add(r,{...i,description:e})}],t._zod.check=()=>{},t}function rS(e){let t=new Je({check:"meta"});return t._zod.onattach=[r=>{let i=He.get(r)??{};He.add(r,{...i,...e})}],t._zod.check=()=>{},t}function nS(e,t){let r=F(t),i=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(i=i.map(p=>typeof p=="string"?p.toLowerCase():p),n=n.map(p=>typeof p=="string"?p.toLowerCase():p));let o=new Set(i),a=new Set(n),s=e.Codec??Sd,c=e.Boolean??vd,u=e.String??ks,l=new u({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),f=new s({type:"pipe",in:l,out:d,transform:((p,m)=>{let h=p;return r.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:a.has(h)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:m.value,inst:f,continue:!1}),{})}),reverseTransform:((p,m)=>p===!0?i[0]||"true":n[0]||"false"),error:r.error});return f._zod.bag.truthy=i,f._zod.bag.falsy=n,f._zod.bag.case=r.case??"insensitive",f}function Ns(e,t,r,i={}){let n=F(i),o={check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(o.pattern=r),new e(o)}function Md(e,...t){for(let r of t)for(let i of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,i)&&Qt(e,i,r[i]);return e}function aa(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??He,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Dt(e,t,r,i,n){let o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:i.path,message:n}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(n);return Object.assign(r,o),!0}function Ge(e,t,r={path:[],schemaPath:[]}){var i;let n=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,l);else{let f=a.schema,p=t.processors[n.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(a.ref||(a.ref=d),Ge(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Md(a.schema,c),t.io==="input"&&Cr(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((i=a.schema).default??(i.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function gR(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function sa(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let c=i.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(s,a[0])}}let n=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=p,{defId:p,ref:`${f("__shared")}#/${s}/${gR(p)}`}}let c="#",u=`${c}/${s}/`;if(a[1]===r&&!a[1].schema.id)return{ref:c};let l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+gR(l)}},o=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:u}=n(a);s.def={...s.schema},u&&(s.defId=u);let l=s.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
222
+
223
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){o(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){o(a);continue}}if(e.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}s.count>1&&e.reused==="ref"&&o(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function vR(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let i of t){if(!i||typeof i!="object")return;vR(i);let n=Object.keys(i);if(n.length!==1||n[0]!=="type")return;let o=i.type;for(let a of Array.isArray(o)?o:[o]){if(typeof a!="string")return;r.includes(a)||r.push(a)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var bR=new Set(["type","properties","required","additionalProperties"]),_R=["oneOf","anyOf"];function yR(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function iS(e){let t=[];for(let o of e){if(typeof o!="object"||o.type!=="object")return null;for(let a in o)if(!bR.has(a))return null;t.push(o)}let r={},i=new Set;for(let o of t){for(let a in o.properties){if(Object.prototype.hasOwnProperty.call(r,a))continue;let s=[];for(let u of t){let l=u.properties?.[a]??yR(u);l!=null&&(s.some(d=>JSON.stringify(d)===JSON.stringify(l))||s.push(l))}let c=s.length===1?s[0]:iS(s)??{allOf:s};Qt(r,a,c)}for(let a of o.required??[])i.add(a)}let n={type:"object",properties:r};if(i.size&&(n.required=[...i]),t.every(o=>o.additionalProperties===!1))n.additionalProperties=!1;else{let o=[];for(let a of t){let s=yR(a);s&&!o.some(c=>JSON.stringify(c)===JSON.stringify(s))&&o.push(s)}o.length===1?n.additionalProperties=o[0]:o.length>1&&(n.additionalProperties={allOf:o})}return n}function u3(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of bR)if(n in e)return;let r=t.filter(n=>_R.some(o=>Array.isArray(n[o]))),i=null;if(!r.length)i=iS(t);else{let n=r[0],o=_R.find(c=>Array.isArray(n[c]));if(Object.keys(n).length!==1)return;let a=t.filter(c=>c!==n),s=n[o].map(c=>iS([...a,c]));if(s.some(c=>!c))return;i={[o]:s}}i&&(delete e.allOf,Md(e,i))}function ca(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){i(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")?(u.allOf=u.allOf??[],u.allOf.push(m)):Md(u,m),Md(u,l),s._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(m.$ref&&p.def)for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}let f=s._zod.parent;if(f&&f!==d){i(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())i(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())vR(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=s.get(l);d?d.push(u):s.set(l,[u])}for(let c of e.intersections)for(let u of s.get(c)??[])u3(u)}}let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$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");n.$id=e.external.uri(s)}Md(n,r.defId?r.schema:r.def??r.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&n.id===o&&delete n.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Qt(a,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?n.$defs=a:n.definitions=a);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:ku(t,"input",e.processors),output:ku(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Cr(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Cr(i.element,r);if(i.type==="set")return Cr(i.valueType,r);if(i.type==="lazy")return Cr(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return Cr(i.innerType,r);if(i.type==="intersection")return Cr(i.left,r)||Cr(i.right,r);if(i.type==="record"||i.type==="map")return Cr(i.keyType,r)||Cr(i.valueType,r);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Cr(i.in,r)||Cr(i.out,r);if(i.type==="object"){for(let n in i.shape)if(Cr(i.shape[n],r))return!0;return!1}if(i.type==="union"){for(let n of i.options)if(Cr(n,r))return!0;return!1}if(i.type==="tuple"){for(let n of i.items)if(Cr(n,r))return!0;return!!(i.rest&&Cr(i.rest,r))}return!1}var oS=(e,t={})=>r=>{let i=aa({...r,processors:t});return Ge(e,i),sa(i,e),ca(i,e)},ku=(e,t,r={})=>i=>{let{libraryOptions:n,target:o}=i??{},a=aa({...n??{},target:o,io:t,processors:r});return Ge(e,a),sa(a,e),ca(a,e)};var $u=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Iu=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},wR=(e,t)=>{$u(e,"minimum",t),Iu(e,"maximum",t)},$R=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},IR=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},ER=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},TR=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},xR=(e,t)=>$u(e,"minimum",t.minimum),SR=(e,t)=>Iu(e,"maximum",t.maximum),kR=e=>(t,r)=>{TR(t,r.format);let[i,n]=e[r.format];$u(t,"minimum",i),Iu(t,"maximum",n)},l3={greater_than:(e,t)=>$u(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Iu(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>$R(e,t.value),number_format:kR(td),bigint_format:kR(rd),min_length:xR,max_length:SR,length_equals:(e,t)=>wR(e,t.length),min_size:xR,max_size:SR,size_equals:(e,t)=>wR(e,t.size),string_format:(e,t)=>{TR(e,t.format),t.pattern&&IR(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>ER(e,t.mime)};function Mt(e){let t={},r=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let o of i)l3[o._zod.def.check]?.(t,o._zod.def);let n=e._zod.bag;n.minimum!==void 0&&$u(t,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&$u(t,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&Iu(t,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&Iu(t,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&$R(t,n.multipleOf),n.format!==void 0&&(t.format??(t.format=n.format),n.format.includes("int")&&(t.isInt=!0)),n.mime&&ER(t,n.mime);for(let o of n.patterns??[])IR(t,o);return t}var d3={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},f3=new Map([[ph,_w],[yd,yw]]),AR=e=>f3.get(e)??e,cS=(e,t,r,i)=>{let n=r;n.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:u,laxFormat:l}=Mt(e);if(typeof o=="number"&&(n.minLength=o),typeof a=="number"&&(n.maxLength=a),s&&(n.format=d3[s]??s,n.format===""&&delete n.format,(s==="time"||l)&&delete n.format),u&&(n.contentEncoding=u),c&&c.size>0){let d=[...c].map(AR);d.length===1?n.pattern=d[0].source:d.length>1&&(n.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},uS=(e,t,r,i)=>{let n=r,{minimum:o,maximum:a,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=Mt(e);n.type=l?"integer":"number";let d=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(a??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(n.minimum=u,n.exclusiveMinimum=!0):n.exclusiveMinimum=u:typeof o=="number"&&(n.minimum=o),f?p?(n.maximum=c,n.exclusiveMaximum=!0):n.exclusiveMaximum=c:typeof a=="number"&&(n.maximum=a),s){let m=new Set;for(let _ of s)Number.isFinite(_)&&_!==0?m.add(Math.abs(_)):Dt(e,t,n,i,`A multipleOf divisor of ${_} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(n.multipleOf=h),g.length&&(n.allOf=[...n.allOf??[],...g.map(_=>({multipleOf:_}))])}},lS=(e,t,r,i)=>{r.type="boolean"},dS=(e,t,r,i)=>{Dt(e,t,r,i,"BigInt cannot be represented in JSON Schema")},fS=(e,t,r,i)=>{Dt(e,t,r,i,"Symbols cannot be represented in JSON Schema")},pS=(e,t,r,i)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},mS=(e,t,r,i)=>{Dt(e,t,r,i,"Undefined cannot be represented in JSON Schema")},hS=(e,t,r,i)=>{Dt(e,t,r,i,"Void cannot be represented in JSON Schema")},gS=(e,t,r,i)=>{r.not={}},_S=(e,t,r,i)=>{},yS=(e,t,r,i)=>{},vS=(e,t,r,i)=>{Dt(e,t,r,i,"Date cannot be represented in JSON Schema")},bS=(e,t,r,i)=>{let n=e._zod.def,o=Xc(n.entries);if(o.length===0){r.not={};return}o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),r.enum=o},wS=(e,t,r,i)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let o=[];for(let a of n.values)if(a===void 0){if(Dt(e,t,r,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(Dt(e,t,r,i,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),o.every(a=>typeof a=="boolean")&&(r.type="boolean"),o.every(a=>a===null)&&(r.type="null"),r.enum=o},xS=(e,t,r,i)=>{Dt(e,t,r,i,"NaN cannot be represented in JSON Schema")},SS=(e,t,r,i)=>{let n=r,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=o.source},kS=(e,t,r,i)=>{let n=r;n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:o,maximum:a,mime:s}=Mt(e);o!==void 0&&(n.minLength=o),a!==void 0&&(n.maxLength=a),s&&(s.length===0?n.not={}:s.length===1?n.contentMediaType=s[0]:n.anyOf=s.map(c=>({contentMediaType:c})))},$S=(e,t,r,i)=>{r.type="boolean"},IS=(e,t,r,i)=>{Dt(e,t,r,i,"Custom types cannot be represented in JSON Schema")},ES=(e,t,r,i)=>{Dt(e,t,r,i,"Function types cannot be represented in JSON Schema")},TS=(e,t,r,i)=>{Dt(e,t,r,i,"Transforms cannot be represented in JSON Schema")},AS=(e,t,r,i)=>{Dt(e,t,r,i,"Map cannot be represented in JSON Schema")},CS=(e,t,r,i)=>{Dt(e,t,r,i,"Set cannot be represented in JSON Schema")},OS=(e,t,r,i)=>{let n=r,o=e._zod.def,{minimum:a,maximum:s}=Mt(e);typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=Ge(o.element,t,{...i,path:[...i.path,"items"]})};function zd(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?zd(t.out):t.type==="catch"?zd(t.innerType):e._zod.optin}var PS=(e,t,r,i)=>{let n=r,o=e._zod.def,a=o.shape;if(Object.getOwnPropertySymbols(a).length&&Dt(e,t,n,i,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let u in a)Qt(n.properties,u,Ge(a[u],t,{...i,path:[...i.path,"properties",u]}));let c=[];for(let u of Object.keys(a)){let l=o.shape[u];(t.io==="input"?zd(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(n.required=c),o.catchall?._zod.def.type==="never"?n.additionalProperties=!1:o.catchall?o.catchall&&(n.additionalProperties=Ge(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},ug=(e,t,r,i)=>{let n=e._zod.def,o=n.inclusive===!1,a=n.options.map((s,c)=>Ge(s,t,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=a:r.anyOf=a},NS=(e,t,r,i)=>{let n=e._zod.def,o=Ge(n.left,t,{...i,path:[...i.path,"allOf",0]}),a=Ge(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=c,t.intersections.push(c)},RS=(e,t,r,i)=>{let n=r,o=e._zod.def;n.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((h,g)=>Ge(h,t,{...i,path:[...i.path,a,g]})),u=o.rest?Ge(o.rest,t,{...i,path:[...i.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,l=o.items.length;for(;l>0;){let h=o.items[l-1];if(!(t.io==="input"?zd(h)!==void 0:h._zod.optout==="optional"))break;l--}let d=o.items.length,f=!o.rest;t.target==="draft-2020-12"?(n.prefixItems=c,f?n.items=!1:u&&(n.items=u),l>0&&(n.minItems=l),f&&(n.maxItems=d)):t.target==="openapi-3.0"?(n.items={anyOf:c},u&&n.items.anyOf.push(u),l>0&&(n.minItems=l),f&&(n.maxItems=d)):(n.items=c,f?n.additionalItems=!1:u&&(n.additionalItems=u),l>0&&(n.minItems=l),f&&(n.maxItems=d));let{minimum:p,maximum:m}=Mt(e);typeof p=="number"&&(n.minItems=p),typeof m=="number"&&(n.maxItems=m)};function aS(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let h=aS(e,m,r);return h===m?t:h}for(let m of["anyOf","oneOf"]){let h=t[m];if(!Array.isArray(h))continue;let g=h.map(_=>aS(e,_,r));g.some((_,v)=>_!==h[v])&&(t={...t,[m]:g})}let i=Array.isArray(t.type)?t.type:[t.type],n=!i.includes("string")&&i.some(m=>m==="number"||m==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!o?.some(m=>typeof m=="number"))return t;let{minimum:a,maximum:s,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(m=>typeof m=="number"?String(m):m):typeof p.const=="number"&&(p.const=String(p.const)),n&&(p.type="string",o||(p.pattern=(i.includes("number")?no:dd).source)),p}var sS=new WeakMap;function p3(e){let t=new Map;for(let i of e.seen.values())i.def&&!t.has(i.schema)&&t.set(i.schema,i);let r=new Map;for(let i of sS.get(e)??[]){let n=e.seen.get(i),o=(n?.def??n?.schema)?.propertyNames;if(!o||o===!0||r.has(o))continue;let a=aS(t,o,new Set);a!==o&&r.set(o,a)}if(r.size)for(let i of e.seen.values())for(let n of[i.schema,i.def]){let o=n&&r.get(n.propertyNames);o&&(n.propertyNames=o)}}var jS=(e,t,r,i)=>{let n=r,o=e._zod.def;n.type="object";let a=o.keyType,s=Mt(a).patterns;if(o.mode==="loose"&&s&&s.size>0){let l=Ge(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});n.patternProperties={};for(let d of s)Qt(n.patternProperties,AR(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=Ge(o.keyType,t,{...i,path:[...i.path,"propertyNames"]});let l=sS.get(t);l||(l=[],sS.set(t,l),t.deferred.push(()=>p3(t))),l.push(e)}n.additionalProperties=Ge(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=a._zod.values,u=t.io==="input"&&zd(o.valueType)!==void 0;if(c&&!o.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(n.required=l.map(String))}},DS=(e,t,r,i)=>{let n=e._zod.def,o=Ge(n.innerType,t,i),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},MS=(e,t,r,i)=>{let n=e._zod.def;Ge(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType},zS=Symbol();function CR(e,t,r,i,n){let o=!1,a=JSON.stringify(e,(s,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(Dt(t,r,i,n,"BigInt defaults cannot be represented in JSON Schema"),zS):JSON.parse(a)}var LS=(e,t,r,i)=>{let n=e._zod.def;Ge(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType;let a=CR(n.defaultValue,e,t,r,i);a!==zS&&(r.default=a)},US=(e,t,r,i)=>{let n=e._zod.def;Ge(n.innerType,t,i);let o=t.seen.get(e);if(o.ref=n.innerType,t.io!=="input")return;let a=CR(n.defaultValue,e,t,r,i);a!==zS&&(r._prefault=a)},FS=(e,t,r,i)=>{let n=e._zod.def;Ge(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{Dt(e,t,r,i,"Dynamic catch values are not supported in JSON Schema");return}r.default=a},BS=(e,t,r,i)=>{let n=e._zod.def,o=n.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?o?n.out:n.in:n.out;Ge(a,t,i);let s=t.seen.get(e);s.ref=a},VS=(e,t,r,i)=>{let n=e._zod.def;Ge(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType,r.readOnly=!0},HS=(e,t,r,i)=>{let n=e._zod.def;Ge(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType},lg=(e,t,r,i)=>{let n=e._zod.def;Ge(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType},ZS=(e,t,r,i)=>{let n=e._zod.innerType;Ge(n,t,i);let o=t.seen.get(e);o.ref=n},cg={string:cS,number:uS,boolean:lS,bigint:dS,symbol:fS,null:pS,undefined:mS,void:hS,never:gS,any:_S,unknown:yS,date:vS,enum:bS,literal:wS,nan:xS,template_literal:SS,file:kS,success:$S,custom:IS,function:ES,transform:TS,map:AS,set:CS,array:OS,object:PS,union:ug,intersection:NS,tuple:RS,record:jS,nullable:DS,nonoptional:MS,default:LS,prefault:US,catch:FS,pipe:BS,readonly:VS,promise:HS,optional:lg,lazy:ZS};function Rs(e,t){if("_idmap"in e){let i=e,n=aa({...t,processors:cg}),o={};for(let c of i._idmap.entries()){let[u,l]=c;Ge(l,n)}let a={},s={registry:i,uri:t?.uri,defs:o};n.external=s;for(let c of i._idmap.entries()){let[u,l]=c;sa(n,l),Qt(a,u,ca(n,l))}if(Object.keys(o).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let r=aa({...t,processors:cg});return Ge(e,r),sa(r,e),ca(r,e)}var dg=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=aa({processors:cg,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 Ge(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)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,sa(this.ctx,t);let i=ca(this.ctx,t),{"~standard":n,...o}=i;return o}};var OR={};function et(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 yt(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 PR(e){return et(e)&&console.warn("[WARNING] Attempting to use Zod 4 schema in a context where Zod 3 schema is expected. This may cause unexpected behavior."),yt(e)}function Hr(e){return!e||typeof e!="object"||Array.isArray(e)?!1:!!(et(e)||yt(e))}function GS(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 KS(e){return et(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 NR(e){return!!(GS(e)||KS(e))}async function pg(e,t){if(et(e))try{return{success:!0,data:await ws(e,t)}}catch(r){return{success:!1,error:r}}if(yt(e))return await e.safeParseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}async function ua(e,t){if(et(e))return await ws(e,t);if(yt(e))return await e.parseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function RR(e,t){if(et(e))try{return{success:!0,data:na(e,t)}}catch(r){return{success:!1,error:r}}if(yt(e))return e.safeParse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function la(e,t){if(et(e))return na(e,t);if(yt(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function so(e){if(et(e))return He.get(e)?.description;if(yt(e)||"description"in e&&typeof e.description=="string")return e.description}function jR(e){if(!Hr(e))return!1;if(yt(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(et(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 Tu(e){return Hr(e)?yt(e)?e._def.typeName==="ZodString":et(e)?e._zod.def.type==="string":!1:!1}function Ld(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 bn(e){return et(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 Ud(e){return et(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 WS(e){return et(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 qS(e){return et(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 fr(e){return!!(Ld(e)||bn(e))}function ao(e){if(yt(e))return e.shape;if(et(e))return e._zod.def.shape;throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function mg(e,t){if(yt(e))return e.extend(t);if(et(e))return O.extend(e,t);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function da(e){if(yt(e))return e.partial();if(et(e))return O.partial($s,e,void 0);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Eu(e,t=!1){if(Ld(e))return e.strict();if(bn(e)){let r=e._zod.def.shape;if(t)for(let[o,a]of Object.entries(e._zod.def.shape)){if(bn(a))r[o]=Eu(a,t);else if(Ud(a)){let c=a._zod.def.element;bn(c)&&(c=Eu(c,t)),r[o]=Ie(a,{...a._zod.def,element:c})}else r[o]=a;let s=He.get(a);s&&He.add(r[o],s)}let i=Ie(e,{...e._zod.def,shape:r,catchall:Dd(wd)}),n=He.get(e);return n&&He.add(i,n),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function fg(e,t=!1){if(Ld(e))return e.passthrough();if(bn(e)){let r=e._zod.def.shape;if(t)for(let[o,a]of Object.entries(e._zod.def.shape)){if(bn(a))r[o]=fg(a,t);else if(Ud(a)){let c=a._zod.def.element;bn(c)&&(c=fg(c,t)),r[o]=Ie(a,{...a._zod.def,element:c})}else r[o]=a;let s=He.get(a);s&&He.add(r[o],s)}let i=Ie(e,{...e._zod.def,shape:r,catchall:jd(bd)}),n=He.get(e);return n&&He.add(i,n),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function hg(e){if(yt(e))try{let t=e.parse(void 0);return()=>t}catch{return}if(et(e))try{let t=na(e,void 0);return()=>t}catch{return}}function h3(e){return yt(e)&&"typeName"in e._def&&e._def.typeName==="ZodEffects"}function g3(e){return et(e)&&e._zod.def.type==="pipe"}function js(e,t,r){let i=r.get(e);if(i!==void 0)return i;if(yt(e))return h3(e)?js(e._def.schema,t,r):e;if(et(e)){let n=e;if(g3(e)&&(n=js(e._zod.def.in,t,r)),t){if(bn(n)){let a={};for(let[s,c]of Object.entries(n._zod.def.shape))a[s]=js(c,t,r);n=Ie(n,{...n._zod.def,shape:a})}else if(Ud(n)){let a=js(n._zod.def.element,t,r);n=Ie(n,{...n._zod.def,element:a})}else if(WS(n)){let a=js(n._zod.def.innerType,t,r);n=Ie(n,{...n._zod.def,innerType:a})}else if(qS(n)){let a=js(n._zod.def.innerType,t,r);n=Ie(n,{...n._zod.def,innerType:a})}}let o=He.get(e);return o&&He.add(n,o),r.set(e,n),n}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function gg(e,t=!1){return js(e,t,new WeakMap)}function DR(e,t){if(yt(e)){let r=ao(e),i={};for(let[n,o]of Object.entries(r))t(n,o)?i[n]=o.optional():i[n]=o;return e.extend(i)}if(et(e)){let r=ao(e),i={...e._zod.def.shape};for(let[a,s]of Object.entries(r))t(a,s)&&(i[a]=new $s({type:"optional",innerType:s}));let n=Ie(e,{...e._zod.def,shape:i}),o=He.get(e);return o&&He.add(n,o),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function _g(e){return e instanceof Error&&(e.constructor.name==="ZodError"||e.constructor.name==="$ZodError")}var XS=Symbol("Let zodToJsonSchema decide on which parser to use"),JS={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"},YS=e=>typeof e=="string"?{...JS,name:e}:{...JS,...e};var QS=e=>{let t=YS(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(([i,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,i],jsonSchema:void 0}]))}};var Fd=(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 st(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?Fd(t,e.currentPath):t.join("/")}}function yg(e,t,r,i){i?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Fe(e,t,r,i,n){e[t]=r,yg(e,t,i,n)}var Kt={};ni(Kt,{BRAND:()=>B3,DIRTY:()=>Ds,EMPTY_PATH:()=>b3,INVALID:()=>le,NEVER:()=>IG,OK:()=>pr,ParseStatus:()=>er,Schema:()=>Ee,ZodAny:()=>ma,ZodArray:()=>fo,ZodBigInt:()=>zs,ZodBoolean:()=>Ls,ZodBranded:()=>Vd,ZodCatch:()=>Js,ZodDate:()=>Us,ZodDefault:()=>qs,ZodDiscriminatedUnion:()=>wg,ZodEffects:()=>Sn,ZodEnum:()=>Ks,ZodError:()=>Zr,ZodFirstPartyTypeKind:()=>U,ZodFunction:()=>Sg,ZodIntersection:()=>Hs,ZodIssueCode:()=>L,ZodLazy:()=>Zs,ZodLiteral:()=>Gs,ZodMap:()=>Ru,ZodNaN:()=>Du,ZodNativeEnum:()=>Ws,ZodNever:()=>Bn,ZodNull:()=>Bs,ZodNullable:()=>$i,ZodNumber:()=>Ms,ZodObject:()=>Gr,ZodOptional:()=>wn,ZodParsedType:()=>J,ZodPipeline:()=>Hd,ZodPromise:()=>ha,ZodReadonly:()=>Xs,ZodRecord:()=>xg,ZodSchema:()=>Ee,ZodSet:()=>ju,ZodString:()=>pa,ZodSymbol:()=>Pu,ZodTransformer:()=>Sn,ZodTuple:()=>ki,ZodType:()=>Ee,ZodUndefined:()=>Fs,ZodUnion:()=>Vs,ZodUnknown:()=>lo,ZodVoid:()=>Nu,addIssueToContext:()=>Z,any:()=>X3,array:()=>tG,bigint:()=>G3,boolean:()=>KR,coerce:()=>$G,custom:()=>HR,date:()=>K3,datetimeRegex:()=>BR,defaultErrorMap:()=>co,discriminatedUnion:()=>oG,effect:()=>_G,enum:()=>mG,function:()=>dG,getErrorMap:()=>Au,getParsedType:()=>Si,instanceof:()=>H3,intersection:()=>aG,isAborted:()=>vg,isAsync:()=>Cu,isDirty:()=>bg,isValid:()=>fa,late:()=>V3,lazy:()=>fG,literal:()=>pG,makeIssue:()=>Bd,map:()=>uG,nan:()=>Z3,nativeEnum:()=>hG,never:()=>Q3,null:()=>J3,nullable:()=>vG,number:()=>GR,object:()=>rG,objectUtil:()=>ek,oboolean:()=>kG,onumber:()=>SG,optional:()=>yG,ostring:()=>xG,pipeline:()=>wG,preprocess:()=>bG,promise:()=>gG,quotelessJson:()=>_3,record:()=>cG,set:()=>lG,setErrorMap:()=>v3,strictObject:()=>nG,string:()=>ZR,symbol:()=>W3,transformer:()=>_G,tuple:()=>sG,undefined:()=>q3,union:()=>iG,unknown:()=>Y3,util:()=>Me,void:()=>eG});var Me;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{let o={};for(let a of n)o[a]=a;return o},e.getValidEnumValues=n=>{let o=e.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),a={};for(let s of o)a[s]=n[s];return e.objectValues(a)},e.objectValues=n=>e.objectKeys(n).map(function(o){return n[o]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let o=[];for(let a in n)Object.prototype.hasOwnProperty.call(n,a)&&o.push(a);return o},e.find=(n,o)=>{for(let a of n)if(o(a))return a},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function i(n,o=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}e.joinValues=i,e.jsonStringifyReplacer=(n,o)=>typeof o=="bigint"?o.toString():o})(Me||(Me={}));var ek;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(ek||(ek={}));var J=Me.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Si=e=>{switch(typeof e){case"undefined":return J.undefined;case"string":return J.string;case"number":return Number.isNaN(e)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(e)?J.array:e===null?J.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?J.promise:typeof Map<"u"&&e instanceof Map?J.map:typeof Set<"u"&&e instanceof Set?J.set:typeof Date<"u"&&e instanceof Date?J.date:J.object;default:return J.unknown}};var L=Me.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"]),_3=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Zr=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};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(o){return o.message},i={_errors:[]},n=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)i._errors.push(r(a));else{let s=i,c=0;for(;c<a.path.length;){let u=a.path[c],l=c===a.path.length-1;if(u==="_errors"){l&&s._errors.push(r(a)),c++;continue}Object.prototype.hasOwnProperty.call(s,u)||(u==="__proto__"?Object.defineProperty(s,u,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):s[u]={_errors:[]}),s=s[u],l&&s._errors.push(r(a)),c++}}};return n(this),i}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,Me.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),i=[];for(let n of this.issues)if(n.path.length>0){let o=n.path[0];r[o]=r[o]||[],r[o].push(t(n))}else i.push(t(n));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};Zr.create=e=>new Zr(e);var y3=(e,t)=>{let r;switch(e.code){case L.invalid_type:e.received===J.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case L.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Me.jsonStringifyReplacer)}`;break;case L.unrecognized_keys:r=`Unrecognized key(s) in object: ${Me.joinValues(e.keys,", ")}`;break;case L.invalid_union:r="Invalid input";break;case L.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Me.joinValues(e.options)}`;break;case L.invalid_enum_value:r=`Invalid enum value. Expected ${Me.joinValues(e.options)}, received '${e.received}'`;break;case L.invalid_arguments:r="Invalid function arguments";break;case L.invalid_return_type:r="Invalid function return type";break;case L.invalid_date:r="Invalid date";break;case L.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}"`:Me.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case L.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 L.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 L.custom:r="Invalid input";break;case L.invalid_intersection_types:r="Intersection results could not be merged";break;case L.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case L.not_finite:r="Number must be finite";break;default:r=t.defaultError,Me.assertNever(e)}return{message:r}},co=y3;var MR=co;function v3(e){MR=e}function Au(){return MR}var Bd=e=>{let{data:t,path:r,errorMaps:i,issueData:n}=e,o=[...r,...n.path||[]],a={...n,path:o};if(n.message!==void 0)return{...n,path:o,message:n.message};let s="",c=i.filter(u=>!!u).slice().reverse();for(let u of c)s=u(a,{data:t,defaultError:s}).message;return{...n,path:o,message:s}},b3=[];function Z(e,t){let r=Au(),i=Bd({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===co?void 0:co].filter(n=>!!n)});e.common.issues.push(i)}var er=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 i=[];for(let n of r){if(n.status==="aborted")return le;n.status==="dirty"&&t.dirty(),i.push(n.value)}return{status:t.value,value:i}}static async mergeObjectAsync(t,r){let i=[];for(let n of r){let o=await n.key,a=await n.value;i.push({key:o,value:a})}return e.mergeObjectSync(t,i)}static mergeObjectSync(t,r){let i={};for(let n of r){let{key:o,value:a}=n;if(o.status==="aborted"||a.status==="aborted")return le;o.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||n.alwaysSet)&&(i[o.value]=a.value)}return{status:t.value,value:i}}},le=Object.freeze({status:"aborted"}),Ds=e=>({status:"dirty",value:e}),pr=e=>({status:"valid",value:e}),vg=e=>e.status==="aborted",bg=e=>e.status==="dirty",fa=e=>e.status==="valid",Cu=e=>typeof Promise<"u"&&e instanceof Promise;var ie;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(ie||(ie={}));var xn=class{constructor(t,r,i,n){this._cachedPath=[],this.parent=t,this.data=r,this._path=i,this._key=n}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}},zR=(e,t)=>{if(fa(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 Zr(e.common.issues);return this._error=r,this._error}}};function be(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:i,description:n}=e;if(t&&(r||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(a,s)=>{let{message:c}=e;return a.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??i??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:n}}var Ee=class{get description(){return this._def.description}_getType(t){return Si(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Si(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new er,ctx:{common:t.parent.common,data:t.data,parsedType:Si(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Cu(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 i=this.safeParse(t,r);if(i.success)return i.data;throw i.error}safeParse(t,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Si(t)},n=this._parseSync({data:t,path:i.path,parent:i});return zR(i,n)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Si(t)};if(!this["~standard"].async)try{let i=this._parseSync({data:t,path:[],parent:r});return fa(i)?{value:i.value}:{issues:r.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(i=>fa(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(t,r){let i=await this.safeParseAsync(t,r);if(i.success)return i.data;throw i.error}async safeParseAsync(t,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Si(t)},n=this._parse({data:t,path:i.path,parent:i}),o=await(Cu(n)?n:Promise.resolve(n));return zR(i,o)}refine(t,r){let i=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,o)=>{let a=t(n),s=()=>o.addIssue({code:L.custom,...i(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(t,r){return this._refinement((i,n)=>t(i)?!0:(n.addIssue(typeof r=="function"?r(i,n):r),!1))}_refinement(t){return new Sn({schema:this,typeName:U.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 wn.create(this,this._def)}nullable(){return $i.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return fo.create(this)}promise(){return ha.create(this,this._def)}or(t){return Vs.create([this,t],this._def)}and(t){return Hs.create(this,t,this._def)}transform(t){return new Sn({...be(this._def),schema:this,typeName:U.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new qs({...be(this._def),innerType:this,defaultValue:r,typeName:U.ZodDefault})}brand(){return new Vd({typeName:U.ZodBranded,type:this,...be(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Js({...be(this._def),innerType:this,catchValue:r,typeName:U.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Hd.create(this,t)}readonly(){return Xs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},w3=/^c[^\s-]{8,}$/i,x3=/^[0-9a-z]+$/,S3=/^[0-9A-HJKMNP-TV-Z]{26}$/i,k3=/^[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,$3=/^[a-z0-9_-]{21}$/i,I3=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,E3=/^[-+]?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)?)??$/,T3=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,A3="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",tk,C3=/^(?:(?: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])$/,O3=/^(?:(?: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])$/,P3=/^(([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]))$/,N3=/^(([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])$/,R3=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,j3=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,UR="((\\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])))",D3=new RegExp(`^${UR}$`);function FR(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 M3(e){return new RegExp(`^${FR(e)}$`)}function BR(e){let t=`${UR}T${FR(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 z3(e,t){return!!((t==="v4"||!t)&&C3.test(e)||(t==="v6"||!t)&&P3.test(e))}function L3(e,t){if(!I3.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)}catch{return!1}}function U3(e,t){return!!((t==="v4"||!t)&&O3.test(e)||(t==="v6"||!t)&&N3.test(e))}var pa=class e extends Ee{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==J.string){let o=this._getOrReturnCtx(t);return Z(o,{code:L.invalid_type,expected:J.string,received:o.parsedType}),le}let i=new er,n;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(n=this._getOrReturnCtx(t,n),Z(n,{code:L.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="max")t.data.length>o.value&&(n=this._getOrReturnCtx(t,n),Z(n,{code:L.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="length"){let a=t.data.length>o.value,s=t.data.length<o.value;(a||s)&&(n=this._getOrReturnCtx(t,n),a?Z(n,{code:L.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&Z(n,{code:L.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),i.dirty())}else if(o.kind==="email")T3.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"email",code:L.invalid_string,message:o.message}),i.dirty());else if(o.kind==="emoji")tk||(tk=new RegExp(A3,"u")),tk.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"emoji",code:L.invalid_string,message:o.message}),i.dirty());else if(o.kind==="uuid")k3.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"uuid",code:L.invalid_string,message:o.message}),i.dirty());else if(o.kind==="nanoid")$3.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"nanoid",code:L.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid")w3.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"cuid",code:L.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid2")x3.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"cuid2",code:L.invalid_string,message:o.message}),i.dirty());else if(o.kind==="ulid")S3.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"ulid",code:L.invalid_string,message:o.message}),i.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),Z(n,{validation:"url",code:L.invalid_string,message:o.message}),i.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"regex",code:L.invalid_string,message:o.message}),i.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(n=this._getOrReturnCtx(t,n),Z(n,{code:L.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),i.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(n=this._getOrReturnCtx(t,n),Z(n,{code:L.invalid_string,validation:{startsWith:o.value},message:o.message}),i.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(n=this._getOrReturnCtx(t,n),Z(n,{code:L.invalid_string,validation:{endsWith:o.value},message:o.message}),i.dirty()):o.kind==="datetime"?BR(o).test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{code:L.invalid_string,validation:"datetime",message:o.message}),i.dirty()):o.kind==="date"?D3.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{code:L.invalid_string,validation:"date",message:o.message}),i.dirty()):o.kind==="time"?M3(o).test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{code:L.invalid_string,validation:"time",message:o.message}),i.dirty()):o.kind==="duration"?E3.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"duration",code:L.invalid_string,message:o.message}),i.dirty()):o.kind==="ip"?z3(t.data,o.version)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"ip",code:L.invalid_string,message:o.message}),i.dirty()):o.kind==="jwt"?L3(t.data,o.alg)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"jwt",code:L.invalid_string,message:o.message}),i.dirty()):o.kind==="cidr"?U3(t.data,o.version)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"cidr",code:L.invalid_string,message:o.message}),i.dirty()):o.kind==="base64"?R3.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"base64",code:L.invalid_string,message:o.message}),i.dirty()):o.kind==="base64url"?j3.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"base64url",code:L.invalid_string,message:o.message}),i.dirty()):Me.assertNever(o);return{status:i.value,value:t.data}}_regex(t,r,i){return this.refinement(n=>t.test(n),{validation:r,code:L.invalid_string,...ie.errToObj(i)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ie.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ie.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ie.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ie.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ie.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ie.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ie.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ie.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ie.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ie.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ie.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ie.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ie.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,...ie.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,...ie.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...ie.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...ie.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...ie.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...ie.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...ie.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...ie.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...ie.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...ie.errToObj(r)})}nonempty(t){return this.min(1,ie.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}};pa.create=e=>new pa({checks:[],typeName:U.ZodString,coerce:e?.coerce??!1,...be(e)});function F3(e,t){let r=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,n=r>i?r:i,o=Number.parseInt(e.toFixed(n).replace(".","")),a=Number.parseInt(t.toFixed(n).replace(".",""));return o%a/10**n}var Ms=class e extends Ee{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)!==J.number){let o=this._getOrReturnCtx(t);return Z(o,{code:L.invalid_type,expected:J.number,received:o.parsedType}),le}let i,n=new er;for(let o of this._def.checks)o.kind==="int"?Me.isInteger(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{code:L.invalid_type,expected:"integer",received:"float",message:o.message}),n.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(i=this._getOrReturnCtx(t,i),Z(i,{code:L.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(i=this._getOrReturnCtx(t,i),Z(i,{code:L.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()):o.kind==="multipleOf"?F3(t.data,o.value)!==0&&(i=this._getOrReturnCtx(t,i),Z(i,{code:L.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{code:L.not_finite,message:o.message}),n.dirty()):Me.assertNever(o);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,ie.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ie.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ie.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ie.toString(r))}setLimit(t,r,i,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:ie.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ie.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ie.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ie.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ie.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ie.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ie.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:ie.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ie.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ie.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"&&Me.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(t===null||i.value<t)&&(t=i.value)}return Number.isFinite(r)&&Number.isFinite(t)}};Ms.create=e=>new Ms({checks:[],typeName:U.ZodNumber,coerce:e?.coerce||!1,...be(e)});var zs=class e extends Ee{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)!==J.bigint)return this._getInvalidInput(t);let i,n=new er;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(i=this._getOrReturnCtx(t,i),Z(i,{code:L.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(i=this._getOrReturnCtx(t,i),Z(i,{code:L.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(i=this._getOrReturnCtx(t,i),Z(i,{code:L.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):Me.assertNever(o);return{status:n.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return Z(r,{code:L.invalid_type,expected:J.bigint,received:r.parsedType}),le}gte(t,r){return this.setLimit("min",t,!0,ie.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ie.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ie.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ie.toString(r))}setLimit(t,r,i,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:ie.toString(n)}]})}_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:ie.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ie.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ie.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ie.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ie.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}};zs.create=e=>new zs({checks:[],typeName:U.ZodBigInt,coerce:e?.coerce??!1,...be(e)});var Ls=class extends Ee{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==J.boolean){let i=this._getOrReturnCtx(t);return Z(i,{code:L.invalid_type,expected:J.boolean,received:i.parsedType}),le}return pr(t.data)}};Ls.create=e=>new Ls({typeName:U.ZodBoolean,coerce:e?.coerce||!1,...be(e)});var Us=class e extends Ee{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==J.date){let o=this._getOrReturnCtx(t);return Z(o,{code:L.invalid_type,expected:J.date,received:o.parsedType}),le}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return Z(o,{code:L.invalid_date}),le}let i=new er,n;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(n=this._getOrReturnCtx(t,n),Z(n,{code:L.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),i.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(n=this._getOrReturnCtx(t,n),Z(n,{code:L.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),i.dirty()):Me.assertNever(o);return{status:i.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:ie.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:ie.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}};Us.create=e=>new Us({checks:[],coerce:e?.coerce||!1,typeName:U.ZodDate,...be(e)});var Pu=class extends Ee{_parse(t){if(this._getType(t)!==J.symbol){let i=this._getOrReturnCtx(t);return Z(i,{code:L.invalid_type,expected:J.symbol,received:i.parsedType}),le}return pr(t.data)}};Pu.create=e=>new Pu({typeName:U.ZodSymbol,...be(e)});var Fs=class extends Ee{_parse(t){if(this._getType(t)!==J.undefined){let i=this._getOrReturnCtx(t);return Z(i,{code:L.invalid_type,expected:J.undefined,received:i.parsedType}),le}return pr(t.data)}};Fs.create=e=>new Fs({typeName:U.ZodUndefined,...be(e)});var Bs=class extends Ee{_parse(t){if(this._getType(t)!==J.null){let i=this._getOrReturnCtx(t);return Z(i,{code:L.invalid_type,expected:J.null,received:i.parsedType}),le}return pr(t.data)}};Bs.create=e=>new Bs({typeName:U.ZodNull,...be(e)});var ma=class extends Ee{constructor(){super(...arguments),this._any=!0}_parse(t){return pr(t.data)}};ma.create=e=>new ma({typeName:U.ZodAny,...be(e)});var lo=class extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(t){return pr(t.data)}};lo.create=e=>new lo({typeName:U.ZodUnknown,...be(e)});var Bn=class extends Ee{_parse(t){let r=this._getOrReturnCtx(t);return Z(r,{code:L.invalid_type,expected:J.never,received:r.parsedType}),le}};Bn.create=e=>new Bn({typeName:U.ZodNever,...be(e)});var Nu=class extends Ee{_parse(t){if(this._getType(t)!==J.undefined){let i=this._getOrReturnCtx(t);return Z(i,{code:L.invalid_type,expected:J.void,received:i.parsedType}),le}return pr(t.data)}};Nu.create=e=>new Nu({typeName:U.ZodVoid,...be(e)});var fo=class e extends Ee{_parse(t){let{ctx:r,status:i}=this._processInputParams(t),n=this._def;if(r.parsedType!==J.array)return Z(r,{code:L.invalid_type,expected:J.array,received:r.parsedType}),le;if(n.exactLength!==null){let a=r.data.length>n.exactLength.value,s=r.data.length<n.exactLength.value;(a||s)&&(Z(r,{code:a?L.too_big:L.too_small,minimum:s?n.exactLength.value:void 0,maximum:a?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(Z(r,{code:L.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(Z(r,{code:L.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((a,s)=>n.type._parseAsync(new xn(r,a,r.path,s)))).then(a=>er.mergeArray(i,a));let o=[...r.data].map((a,s)=>n.type._parseSync(new xn(r,a,r.path,s)));return er.mergeArray(i,o)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:ie.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:ie.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:ie.toString(r)}})}nonempty(t){return this.min(1,t)}};fo.create=(e,t)=>new fo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:U.ZodArray,...be(t)});function Ou(e){if(e instanceof Gr){let t={};for(let r in e.shape){let i=e.shape[r];t[r]=wn.create(Ou(i))}return new Gr({...e._def,shape:()=>t})}else return e instanceof fo?new fo({...e._def,type:Ou(e.element)}):e instanceof wn?wn.create(Ou(e.unwrap())):e instanceof $i?$i.create(Ou(e.unwrap())):e instanceof ki?ki.create(e.items.map(t=>Ou(t))):e}var Gr=class e extends Ee{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=Me.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==J.object){let u=this._getOrReturnCtx(t);return Z(u,{code:L.invalid_type,expected:J.object,received:u.parsedType}),le}let{status:i,ctx:n}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof Bn&&this._def.unknownKeys==="strip"))for(let u in n.data)a.includes(u)||s.push(u);let c=[];for(let u of a){let l=o[u],d=n.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new xn(n,d,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof Bn){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")s.length>0&&(Z(n,{code:L.unrecognized_keys,keys:s}),i.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of s){let d=n.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new xn(n,d,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,f=await l.value;u.push({key:d,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>er.mergeObjectSync(i,u)):er.mergeObjectSync(i,c)}get shape(){return this._def.shape()}strict(t){return ie.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,i)=>{let n=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:ie.errToObj(t).message??n}:{message:n}}}:{}})}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:U.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let i of Me.objectKeys(t))t[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let i of Me.objectKeys(this.shape))t[i]||(r[i]=this.shape[i]);return new e({...this._def,shape:()=>r})}deepPartial(){return Ou(this)}partial(t){let r={};for(let i of Me.objectKeys(this.shape)){let n=this.shape[i];t&&!t[i]?r[i]=n:r[i]=n.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let i of Me.objectKeys(this.shape))if(t&&!t[i])r[i]=this.shape[i];else{let o=this.shape[i];for(;o instanceof wn;)o=o._def.innerType;r[i]=o}return new e({...this._def,shape:()=>r})}keyof(){return VR(Me.objectKeys(this.shape))}};Gr.create=(e,t)=>new Gr({shape:()=>e,unknownKeys:"strip",catchall:Bn.create(),typeName:U.ZodObject,...be(t)});Gr.strictCreate=(e,t)=>new Gr({shape:()=>e,unknownKeys:"strict",catchall:Bn.create(),typeName:U.ZodObject,...be(t)});Gr.lazycreate=(e,t)=>new Gr({shape:e,unknownKeys:"strip",catchall:Bn.create(),typeName:U.ZodObject,...be(t)});var Vs=class extends Ee{_parse(t){let{ctx:r}=this._processInputParams(t),i=this._def.options;function n(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(s=>new Zr(s.ctx.common.issues));return Z(r,{code:L.invalid_union,unionErrors:a}),le}if(r.common.async)return Promise.all(i.map(async o=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(n);{let o,a=[];for(let c of i){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let s=a.map(c=>new Zr(c));return Z(r,{code:L.invalid_union,unionErrors:s}),le}}get options(){return this._def.options}};Vs.create=(e,t)=>new Vs({options:e,typeName:U.ZodUnion,...be(t)});var uo=e=>e instanceof Zs?uo(e.schema):e instanceof Sn?uo(e.innerType()):e instanceof Gs?[e.value]:e instanceof Ks?e.options:e instanceof Ws?Me.objectValues(e.enum):e instanceof qs?uo(e._def.innerType):e instanceof Fs?[void 0]:e instanceof Bs?[null]:e instanceof wn?[void 0,...uo(e.unwrap())]:e instanceof $i?[null,...uo(e.unwrap())]:e instanceof Vd||e instanceof Xs?uo(e.unwrap()):e instanceof Js?uo(e._def.innerType):[],wg=class e extends Ee{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==J.object)return Z(r,{code:L.invalid_type,expected:J.object,received:r.parsedType}),le;let i=this.discriminator,n=r.data[i],o=this.optionsMap.get(n);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(Z(r,{code:L.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),le)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,i){let n=new Map;for(let o of r){let a=uo(o.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of a){if(n.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);n.set(s,o)}}return new e({typeName:U.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...be(i)})}};function rk(e,t){let r=Si(e),i=Si(t);if(e===t)return{valid:!0,data:e};if(r===J.object&&i===J.object){let n=Me.objectKeys(t),o=Me.objectKeys(e).filter(s=>n.indexOf(s)!==-1),a={...e,...t};Object.prototype.hasOwnProperty.call(a,"__proto__")&&delete a.__proto__;for(let s of o){if(s==="__proto__")continue;let c=rk(e[s],t[s]);if(!c.valid)return{valid:!1};a[s]=c.data}return{valid:!0,data:a}}else if(r===J.array&&i===J.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let o=0;o<e.length;o++){let a=e[o],s=t[o],c=rk(a,s);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===J.date&&i===J.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Hs=class extends Ee{_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=(o,a)=>{if(vg(o)||vg(a))return le;let s=rk(o.value,a.value);return s.valid?((bg(o)||bg(a))&&r.dirty(),{status:r.value,value:s.data}):(Z(i,{code:L.invalid_intersection_types}),le)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([o,a])=>n(o,a)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};Hs.create=(e,t,r)=>new Hs({left:e,right:t,typeName:U.ZodIntersection,...be(r)});var ki=class e extends Ee{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==J.array)return Z(i,{code:L.invalid_type,expected:J.array,received:i.parsedType}),le;if(i.data.length<this._def.items.length)return Z(i,{code:L.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),le;!this._def.rest&&i.data.length>this._def.items.length&&(Z(i,{code:L.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...i.data].map((a,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new xn(i,a,i.path,s)):null}).filter(a=>!!a);return i.common.async?Promise.all(o).then(a=>er.mergeArray(r,a)):er.mergeArray(r,o)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};ki.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ki({items:e,typeName:U.ZodTuple,rest:null,...be(t)})};var xg=class e extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==J.object)return Z(i,{code:L.invalid_type,expected:J.object,received:i.parsedType}),le;let n=[],o=this._def.keyType,a=this._def.valueType;for(let s in i.data)n.push({key:o._parse(new xn(i,s,i.path,s)),value:a._parse(new xn(i,i.data[s],i.path,s)),alwaysSet:s in i.data});return i.common.async?er.mergeObjectAsync(r,n):er.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,i){return r instanceof Ee?new e({keyType:t,valueType:r,typeName:U.ZodRecord,...be(i)}):new e({keyType:pa.create(),valueType:t,typeName:U.ZodRecord,...be(r)})}},Ru=class extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==J.map)return Z(i,{code:L.invalid_type,expected:J.map,received:i.parsedType}),le;let n=this._def.keyType,o=this._def.valueType,a=[...i.data.entries()].map(([s,c],u)=>({key:n._parse(new xn(i,s,i.path,[u,"key"])),value:o._parse(new xn(i,c,i.path,[u,"value"]))}));if(i.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of a){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return le;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of a){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return le;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};Ru.create=(e,t,r)=>new Ru({valueType:t,keyType:e,typeName:U.ZodMap,...be(r)});var ju=class e extends Ee{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==J.set)return Z(i,{code:L.invalid_type,expected:J.set,received:i.parsedType}),le;let n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(Z(i,{code:L.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(Z(i,{code:L.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let o=this._def.valueType;function a(c){let u=new Set;for(let l of c){if(l.status==="aborted")return le;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...i.data.values()].map((c,u)=>o._parse(new xn(i,c,i.path,u)));return i.common.async?Promise.all(s).then(c=>a(c)):a(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:ie.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:ie.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};ju.create=(e,t)=>new ju({valueType:e,minSize:null,maxSize:null,typeName:U.ZodSet,...be(t)});var Sg=class e extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==J.function)return Z(r,{code:L.invalid_type,expected:J.function,received:r.parsedType}),le;function i(s,c){return Bd({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Au(),co].filter(u=>!!u),issueData:{code:L.invalid_arguments,argumentsError:c}})}function n(s,c){return Bd({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Au(),co].filter(u=>!!u),issueData:{code:L.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof ha){let s=this;return pr(async function(...c){let u=new Zr([]),l=await s._def.args.parseAsync(c,o).catch(p=>{throw u.addIssue(i(c,p)),u}),d=await Reflect.apply(a,this,l);return await s._def.returns._def.type.parseAsync(d,o).catch(p=>{throw u.addIssue(n(d,p)),u})})}else{let s=this;return pr(function(...c){let u=s._def.args.safeParse(c,o);if(!u.success)throw new Zr([i(c,u.error)]);let l=Reflect.apply(a,this,u.data),d=s._def.returns.safeParse(l,o);if(!d.success)throw new Zr([n(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:ki.create(t).rest(lo.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,i){return new e({args:t||ki.create([]).rest(lo.create()),returns:r||lo.create(),typeName:U.ZodFunction,...be(i)})}},Zs=class extends Ee{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})}};Zs.create=(e,t)=>new Zs({getter:e,typeName:U.ZodLazy,...be(t)});var Gs=class extends Ee{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return Z(r,{received:r.data,code:L.invalid_literal,expected:this._def.value}),le}return{status:"valid",value:t.data}}get value(){return this._def.value}};Gs.create=(e,t)=>new Gs({value:e,typeName:U.ZodLiteral,...be(t)});function VR(e,t){return new Ks({values:e,typeName:U.ZodEnum,...be(t)})}var Ks=class e extends Ee{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),i=this._def.values;return Z(r,{expected:Me.joinValues(i),received:r.parsedType,code:L.invalid_type}),le}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),i=this._def.values;return Z(r,{received:r.data,code:L.invalid_enum_value,options:i}),le}return pr(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(i=>!t.includes(i)),{...this._def,...r})}};Ks.create=VR;var Ws=class extends Ee{_parse(t){let r=Me.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(t);if(i.parsedType!==J.string&&i.parsedType!==J.number){let n=Me.objectValues(r);return Z(i,{expected:Me.joinValues(n),received:i.parsedType,code:L.invalid_type}),le}if(this._cache||(this._cache=new Set(Me.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let n=Me.objectValues(r);return Z(i,{received:i.data,code:L.invalid_enum_value,options:n}),le}return pr(t.data)}get enum(){return this._def.values}};Ws.create=(e,t)=>new Ws({values:e,typeName:U.ZodNativeEnum,...be(t)});var ha=class extends Ee{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==J.promise&&r.common.async===!1)return Z(r,{code:L.invalid_type,expected:J.promise,received:r.parsedType}),le;let i=r.parsedType===J.promise?r.data:Promise.resolve(r.data);return pr(i.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ha.create=(e,t)=>new ha({type:e,typeName:U.ZodPromise,...be(t)});var Sn=class extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===U.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=this._def.effect||null,o={addIssue:a=>{Z(i,a),a.fatal?r.abort():r.dirty()},get path(){return i.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let a=n.transform(i.data,o);if(i.common.async)return Promise.resolve(a).then(async s=>{if(r.value==="aborted")return le;let c=await this._def.schema._parseAsync({data:s,path:i.path,parent:i});return c.status==="aborted"?le:c.status==="dirty"?Ds(c.value):r.value==="dirty"?Ds(c.value):c});{if(r.value==="aborted")return le;let s=this._def.schema._parseSync({data:a,path:i.path,parent:i});return s.status==="aborted"?le:s.status==="dirty"?Ds(s.value):r.value==="dirty"?Ds(s.value):s}}if(n.type==="refinement"){let a=s=>{let c=n.refinement(s,o);if(i.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(i.common.async===!1){let s=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?le:(s.status==="dirty"&&r.dirty(),a(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(s=>s.status==="aborted"?le:(s.status==="dirty"&&r.dirty(),a(s.value).then(()=>({status:r.value,value:s.value}))))}if(n.type==="transform")if(i.common.async===!1){let a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!fa(a))return le;let s=n.transform(a.value,o);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:i.data,path:i.path,parent:i}).then(a=>fa(a)?Promise.resolve(n.transform(a.value,o)).then(s=>({status:r.value,value:s})):le);Me.assertNever(n)}};Sn.create=(e,t,r)=>new Sn({schema:e,typeName:U.ZodEffects,effect:t,...be(r)});Sn.createWithPreprocess=(e,t,r)=>new Sn({schema:t,effect:{type:"preprocess",transform:e},typeName:U.ZodEffects,...be(r)});var wn=class extends Ee{_parse(t){return this._getType(t)===J.undefined?pr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};wn.create=(e,t)=>new wn({innerType:e,typeName:U.ZodOptional,...be(t)});var $i=class extends Ee{_parse(t){return this._getType(t)===J.null?pr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};$i.create=(e,t)=>new $i({innerType:e,typeName:U.ZodNullable,...be(t)});var qs=class extends Ee{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return r.parsedType===J.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};qs.create=(e,t)=>new qs({innerType:e,typeName:U.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...be(t)});var Js=class extends Ee{_parse(t){let{ctx:r}=this._processInputParams(t),i={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Cu(n)?n.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Zr(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Zr(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};Js.create=(e,t)=>new Js({innerType:e,typeName:U.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...be(t)});var Du=class extends Ee{_parse(t){if(this._getType(t)!==J.nan){let i=this._getOrReturnCtx(t);return Z(i,{code:L.invalid_type,expected:J.nan,received:i.parsedType}),le}return{status:"valid",value:t.data}}};Du.create=e=>new Du({typeName:U.ZodNaN,...be(e)});var B3=Symbol("zod_brand"),Vd=class extends Ee{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},Hd=class e extends Ee{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?le:o.status==="dirty"?(r.dirty(),Ds(o.value)):this._def.out._parseAsync({data:o.value,path:i.path,parent:i})})();{let n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?le:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(t,r){return new e({in:t,out:r,typeName:U.ZodPipeline})}},Xs=class extends Ee{_parse(t){let r=this._def.innerType._parse(t),i=n=>(fa(n)&&(n.value=Object.freeze(n.value)),n);return Cu(r)?r.then(n=>i(n)):i(r)}unwrap(){return this._def.innerType}};Xs.create=(e,t)=>new Xs({innerType:e,typeName:U.ZodReadonly,...be(t)});function LR(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function HR(e,t={},r){return e?ma.create().superRefine((i,n)=>{let o=e(i);if(o instanceof Promise)return o.then(a=>{if(!a){let s=LR(t,i),c=s.fatal??r??!0;n.addIssue({code:"custom",...s,fatal:c})}});if(!o){let a=LR(t,i),s=a.fatal??r??!0;n.addIssue({code:"custom",...a,fatal:s})}}):ma.create()}var V3={object:Gr.lazycreate},U;(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"})(U||(U={}));var H3=(e,t={message:`Input not instance of ${e.name}`})=>HR(r=>r instanceof e,t),ZR=pa.create,GR=Ms.create,Z3=Du.create,G3=zs.create,KR=Ls.create,K3=Us.create,W3=Pu.create,q3=Fs.create,J3=Bs.create,X3=ma.create,Y3=lo.create,Q3=Bn.create,eG=Nu.create,tG=fo.create,rG=Gr.create,nG=Gr.strictCreate,iG=Vs.create,oG=wg.create,aG=Hs.create,sG=ki.create,cG=xg.create,uG=Ru.create,lG=ju.create,dG=Sg.create,fG=Zs.create,pG=Gs.create,mG=Ks.create,hG=Ws.create,gG=ha.create,_G=Sn.create,yG=wn.create,vG=$i.create,bG=Sn.createWithPreprocess,wG=Hd.create,xG=()=>ZR().optional(),SG=()=>GR().optional(),kG=()=>KR().optional(),$G={string:(e=>pa.create({...e,coerce:!0})),number:(e=>Ms.create({...e,coerce:!0})),boolean:(e=>Ls.create({...e,coerce:!0})),bigint:(e=>zs.create({...e,coerce:!0})),date:(e=>Us.create({...e,coerce:!0}))};var IG=le;function nk(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==U.ZodAny&&(r.items=de(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Fe(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Fe(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Fe(r,"minItems",e.exactLength.value,e.exactLength.message,t),Fe(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function ik(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let i of e.checks)switch(i.kind){case"min":t.target==="jsonSchema7"?i.inclusive?Fe(r,"minimum",i.value,i.message,t):Fe(r,"exclusiveMinimum",i.value,i.message,t):(i.inclusive||(r.exclusiveMinimum=!0),Fe(r,"minimum",i.value,i.message,t));break;case"max":t.target==="jsonSchema7"?i.inclusive?Fe(r,"maximum",i.value,i.message,t):Fe(r,"exclusiveMaximum",i.value,i.message,t):(i.inclusive||(r.exclusiveMaximum=!0),Fe(r,"maximum",i.value,i.message,t));break;case"multipleOf":Fe(r,"multipleOf",i.value,i.message,t)}return r}function ok(){return{type:"boolean"}}function Zd(e,t){return de(e.type._def,t)}var ak=(e,t)=>de(e.innerType._def,t);function kg(e,t,r){let i=r??t.dateStrategy;if(Array.isArray(i))return{anyOf:i.map(n=>kg(e,t,n))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return EG(e,t)}}var EG=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let i of e.checks)switch(i.kind){case"min":Fe(r,"minimum",i.value,i.message,t);break;case"max":Fe(r,"maximum",i.value,i.message,t)}return r};function sk(e,t){return{...de(e.innerType._def,t),default:e.defaultValue()}}function ck(e,t){return t.effectStrategy==="input"?de(e.schema._def,t):st(t)}function uk(e){return{type:"string",enum:Array.from(e.values)}}var TG=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function lk(e,t){let r=[de(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),de(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),i=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return r.forEach(o=>{if(TG(o))n.push(...o.allOf),o.unevaluatedProperties===void 0&&(i=void 0);else{let a=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:s,...c}=o;a=c}else i=void 0;n.push(a)}}),n.length?{allOf:n,...i}:void 0}function dk(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 fk,kn={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:()=>(fk===void 0&&(fk=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),fk),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 Gd(e,t){let r={type:"string"};if(e.checks)for(let i of e.checks)switch(i.kind){case"min":Fe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":Fe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":Vn(r,"email",i.message,t);break;case"format:idn-email":Vn(r,"idn-email",i.message,t);break;case"pattern:zod":Or(r,kn.email,i.message,t)}break;case"url":Vn(r,"uri",i.message,t);break;case"uuid":Vn(r,"uuid",i.message,t);break;case"regex":Or(r,i.regex,i.message,t);break;case"cuid":Or(r,kn.cuid,i.message,t);break;case"cuid2":Or(r,kn.cuid2,i.message,t);break;case"startsWith":Or(r,RegExp(`^${pk(i.value,t)}`),i.message,t);break;case"endsWith":Or(r,RegExp(`${pk(i.value,t)}$`),i.message,t);break;case"datetime":Vn(r,"date-time",i.message,t);break;case"date":Vn(r,"date",i.message,t);break;case"time":Vn(r,"time",i.message,t);break;case"duration":Vn(r,"duration",i.message,t);break;case"length":Fe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t),Fe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":Or(r,RegExp(pk(i.value,t)),i.message,t);break;case"ip":i.version!=="v6"&&Vn(r,"ipv4",i.message,t),i.version!=="v4"&&Vn(r,"ipv6",i.message,t);break;case"base64url":Or(r,kn.base64url,i.message,t);break;case"jwt":Or(r,kn.jwt,i.message,t);break;case"cidr":i.version!=="v6"&&Or(r,kn.ipv4Cidr,i.message,t),i.version!=="v4"&&Or(r,kn.ipv6Cidr,i.message,t);break;case"emoji":Or(r,kn.emoji(),i.message,t);break;case"ulid":Or(r,kn.ulid,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":Vn(r,"binary",i.message,t);break;case"contentEncoding:base64":Fe(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":Or(r,kn.base64,i.message,t)}break;case"nanoid":Or(r,kn.nanoid,i.message,t)}return r}function pk(e,t){return t.patternStrategy==="escape"?CG(e):e}var AG=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function CG(e){let t="";for(let r=0;r<e.length;r++)AG.has(e[r])||(t+="\\"),t+=e[r];return t}function Vn(e,t,r,i){e.format||e.anyOf?.some(n=>n.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&i.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&&i.errorMessages&&{errorMessage:{format:r}}})):Fe(e,"format",t,r,i)}function Or(e,t,r,i){e.pattern||e.allOf?.some(n=>n.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&i.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:WR(t,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):Fe(e,"pattern",WR(t,i),r,i)}function WR(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")},i=r.i?e.source.toLowerCase():e.source,n="",o=!1,a=!1,s=!1;for(let c=0;c<i.length;c++){if(o){n+=i[c],o=!1;continue}if(r.i){if(a){if(i[c].match(/[a-z]/)){s?(n+=i[c],n+=`${i[c-2]}-${i[c]}`.toUpperCase(),s=!1):i[c+1]==="-"&&i[c+2]?.match(/[a-z]/)?(n+=i[c],s=!0):n+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){n+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){n+=`(^|(?<=[\r
224
+ ]))`;continue}else if(i[c]==="$"){n+=`($|(?=[\r
225
+ ]))`;continue}}if(r.s&&i[c]==="."){n+=a?`${i[c]}\r
226
+ `:`[${i[c]}\r
227
+ ]`;continue}n+=i[c],i[c]==="\\"?o=!0:a&&i[c]==="]"?a=!1:!a&&i[c]==="["&&(a=!0)}try{new RegExp(n)}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 n}function Kd(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===U.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((i,n)=>({...i,[n]:de(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??st(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:de(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===U.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=Gd(e.keyType._def,t);return{...r,propertyNames:n}}else{if(e.keyType?._def.typeName===U.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===U.ZodBranded&&e.keyType._def.type._def.typeName===U.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=Zd(e.keyType._def,t);return{...r,propertyNames:n}}}return r}function mk(e,t){return t.mapStrategy==="record"?Kd(e,t):{type:"array",maxItems:125,items:{type:"array",items:[de(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||st(t),de(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||st(t)],minItems:2,maxItems:2}}}function hk(e){let t=e.values,r=Object.keys(e.values).filter(n=>typeof t[t[n]]!="number").map(n=>t[n]),i=Array.from(new Set(r.map(n=>typeof n)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function gk(e){return e.target==="openAi"?void 0:{not:st({...e,currentPath:[...e.currentPath,"not"]})}}function _k(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Mu={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function yk(e,t){if(t.target==="openApi3")return qR(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(i=>i._def.typeName in Mu&&(!i._def.checks||!i._def.checks.length))){let i=r.reduce((n,o)=>{let a=Mu[o._def.typeName];return a&&!n.includes(a)?[...n,a]:n},[]);return{type:i.length>1?i:i[0]}}else if(r.every(i=>i._def.typeName==="ZodLiteral"&&!i.description)){let i=r.reduce((n,o)=>{let a=typeof o._def.value;switch(a){case"string":case"number":case"boolean":return[...n,a];case"bigint":return[...n,"integer"];case"object":return o._def.value===null?[...n,"null"]:n;default:return n}},[]);if(i.length===r.length){let n=i.filter((o,a,s)=>s.indexOf(o)===a);return{type:n.length>1?n:n[0],enum:r.reduce((o,a)=>o.includes(a._def.value)?o:[...o,a._def.value],[])}}}else if(r.every(i=>i._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((i,n)=>[...i,...n._def.values.filter(o=>!i.includes(o))],[])};return qR(e,t)}var qR=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((i,n)=>de(i._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(i=>!!i&&(!t.strictUnions||typeof i=="object"&&Object.keys(i).length>0));return r.length?{anyOf:r}:void 0};function vk(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:Mu[e.innerType._def.typeName],nullable:!0}:{type:[Mu[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let i=de(e.innerType._def,{...t,currentPath:[...t.currentPath]});return i&&"$ref"in i?{allOf:[i],nullable:!0}:i&&{...i,nullable:!0}}let r=de(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function bk(e,t){let r={type:"number"};if(!e.checks)return r;for(let i of e.checks)switch(i.kind){case"int":r.type="integer",yg(r,"type",i.message,t);break;case"min":t.target==="jsonSchema7"?i.inclusive?Fe(r,"minimum",i.value,i.message,t):Fe(r,"exclusiveMinimum",i.value,i.message,t):(i.inclusive||(r.exclusiveMinimum=!0),Fe(r,"minimum",i.value,i.message,t));break;case"max":t.target==="jsonSchema7"?i.inclusive?Fe(r,"maximum",i.value,i.message,t):Fe(r,"exclusiveMaximum",i.value,i.message,t):(i.inclusive||(r.exclusiveMaximum=!0),Fe(r,"maximum",i.value,i.message,t));break;case"multipleOf":Fe(r,"multipleOf",i.value,i.message,t)}return r}function wk(e,t){let r=t.target==="openAi",i={type:"object",properties:{}},n=[],o=e.shape();for(let s in o){let c=o[s];if(c===void 0||c._def===void 0)continue;let u=PG(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=de(c._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});l!==void 0&&(i.properties[s]=l,u||n.push(s))}n.length&&(i.required=n);let a=OG(e,t);return a!==void 0&&(i.additionalProperties=a),i}function OG(e,t){if(e.catchall._def.typeName!=="ZodNever")return de(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 PG(e){try{return e.isOptional()}catch{return!0}}var xk=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return de(e.innerType._def,t);let r=de(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:st(t)},r]}:st(t)};var Sk=(e,t)=>{if(t.pipeStrategy==="input")return de(e.in._def,t);if(t.pipeStrategy==="output")return de(e.out._def,t);let r=de(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,de(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(i=>i!==void 0)}};function kk(e,t){return de(e.type._def,t)}function $k(e,t){let r={type:"array",uniqueItems:!0,items:de(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Fe(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Fe(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}function Ik(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,i)=>de(r._def,{...t,currentPath:[...t.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[]),additionalItems:de(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,i)=>de(r._def,{...t,currentPath:[...t.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[])}}function Ek(e){return{not:st(e)}}function Tk(e){return st(e)}var Ak=(e,t)=>de(e.innerType._def,t);var Ck=(e,t,r)=>{switch(t){case U.ZodString:return Gd(e,r);case U.ZodNumber:return bk(e,r);case U.ZodObject:return wk(e,r);case U.ZodBigInt:return ik(e,r);case U.ZodBoolean:return ok();case U.ZodDate:return kg(e,r);case U.ZodUndefined:return Ek(r);case U.ZodNull:return _k(r);case U.ZodArray:return nk(e,r);case U.ZodUnion:case U.ZodDiscriminatedUnion:return yk(e,r);case U.ZodIntersection:return lk(e,r);case U.ZodTuple:return Ik(e,r);case U.ZodRecord:return Kd(e,r);case U.ZodLiteral:return dk(e,r);case U.ZodEnum:return uk(e);case U.ZodNativeEnum:return hk(e);case U.ZodNullable:return vk(e,r);case U.ZodOptional:return xk(e,r);case U.ZodMap:return mk(e,r);case U.ZodSet:return $k(e,r);case U.ZodLazy:return()=>e.getter()._def;case U.ZodPromise:return kk(e,r);case U.ZodNaN:case U.ZodNever:return gk(r);case U.ZodEffects:return ck(e,r);case U.ZodAny:return st(r);case U.ZodUnknown:return Tk(r);case U.ZodDefault:return sk(e,r);case U.ZodBranded:return Zd(e,r);case U.ZodReadonly:return Ak(e,r);case U.ZodCatch:return ak(e,r);case U.ZodPipeline:return Sk(e,r);case U.ZodFunction:case U.ZodVoid:case U.ZodSymbol:return;default:return(i=>{})(t)}};function de(e,t,r=!1){let i=t.seen.get(e);if(t.override){let s=t.override?.(e,t,i,r);if(s!==XS)return s}if(i&&!r){let s=NG(i,t);if(s!==void 0)return s}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let o=Ck(e,e.typeName,t),a=typeof o=="function"?de(o(),t):o;if(a&&RG(e,t,a),t.postProcess){let s=t.postProcess(a,e,t);return n.jsonSchema=a,s}return n.jsonSchema=a,a}var NG=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Fd(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,i)=>t.currentPath[i]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),st(t)):t.$refStrategy==="seen"?st(t):void 0}},RG=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var Ok=(e,t)=>{let r=QS(t),i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[u,l])=>({...c,[u]:de(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??st(r)}),{}):void 0,n=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=de(e._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??st(r),a=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;a!==void 0&&(o.title=a),r.flags.hasReferencedOpenAiAnyType&&(i||(i={}),i[r.openAiAnyTypeName]||(i[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=n===void 0?i?{...o,[r.definitionPath]:i}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...i,[n]:o}};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 Ii(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let i=e.length;if(i!==t.length)return!1;for(let n=0;n<i;n++)if(!Ii(e[n],t[n]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let a of i)if(!Ii(e[a],t[a]))return!1;return!0}return e===t}function cn(e){return encodeURI(jG(e))}function jG(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var DG={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},MG={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},zG={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},LG=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 Hn(e,t=Object.create(null),r=LG,i=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let o=e.$id||e.id;if(o){let a=new URL(o,r.href);a.hash.length>1?t[a.href]=e:(a.hash="",i===""?r=a:Hn(e,t,r))}}else if(e!==!0&&e!==!1)return t;let n=r.href+(i?"#"+i:"");if(t[n]!==void 0)throw new Error(`Duplicate schema URI "${n}".`);if(t[n]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:n}),e.$ref&&e.__absolute_ref__===void 0){let o=new URL(e.$ref,r.href);o.hash=o.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:o.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let o=new URL(e.$recursiveRef,r.href);o.hash=o.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:o.href})}if(e.$anchor){let o=new URL("#"+e.$anchor,r.href);t[o.href]=e}for(let o in e){if(zG[o])continue;let a=`${i}/${cn(o)}`,s=e[o];if(Array.isArray(s)){if(DG[o]){let c=s.length;for(let u=0;u<c;u++)Hn(s[u],t,r,`${a}/${u}`)}}else if(MG[o])for(let c in s)Hn(s[c],t,r,`${a}/${cn(c)}`);else Hn(s,t,r,a)}return t}var UG=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,FG=[0,31,28,31,30,31,30,31,31,30,31,30,31],BG=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,VG=/^(?=.{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,HG=/^(?:[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,ZG=/^(?:(?:[^\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,GG=/^(?:(?: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,KG=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,WG=/^(?:\/(?:[^~/]|~0|~1)*)*$/,qG=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,JG=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,XG=e=>{if(e[0]==='"')return!1;let[t,r,...i]=e.split("@");return!t||!r||i.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(n=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},YG=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,QG=/^((([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,e5=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 Ei(e){return e.test.bind(e)}var Pk={date:JR,time:XR.bind(void 0,!1),"date-time":n5,duration:e5,uri:a5,"uri-reference":Ei(HG),"uri-template":Ei(ZG),url:Ei(GG),email:XG,hostname:Ei(VG),ipv4:Ei(YG),ipv6:Ei(QG),regex:c5,uuid:Ei(KG),"json-pointer":Ei(WG),"json-pointer-uri-fragment":Ei(qG),"relative-json-pointer":Ei(JG)};function t5(e){return e%4===0&&(e%100!==0||e%400===0)}function JR(e){let t=e.match(UG);if(!t)return!1;let r=+t[1],i=+t[2],n=+t[3];return i>=1&&i<=12&&n>=1&&n<=(i==2&&t5(r)?29:FG[i])}function XR(e,t){let r=t.match(BG);if(!r)return!1;let i=+r[1],n=+r[2],o=+r[3],a=!!r[5];return(i<=23&&n<=59&&o<=59||i==23&&n==59&&o==60)&&(!e||a)}var r5=/t|\s/i;function n5(e){let t=e.split(r5);return t.length==2&&JR(t[0])&&XR(!0,t[1])}var i5=/\/|:/,o5=/^(?:[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 a5(e){return i5.test(e)&&o5.test(e)}var s5=/[^\\]\\Z/;function c5(e){if(s5.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}var YR;(function(e){e[e.Flag=1]="Flag",e[e.Basic=2]="Basic",e[e.Detailed=4]="Detailed"})(YR||(YR={}));function QR(e){let t=0,r=e.length,i=0,n;for(;i<r;)t++,n=e.charCodeAt(i++),n>=55296&&n<=56319&&i<r&&(n=e.charCodeAt(i),(n&64512)==56320&&i++);return t}function tt(e,t,r="2019-09",i=Hn(t),n=!0,o=null,a="#",s="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:a,keyword:"false",keywordLocation:a,error:"False boolean schema."}]};let u=typeof e,l;switch(u){case"boolean":case"number":case"string":l=u;break;case"object":e===null?l="null":Array.isArray(e)?l="array":l="object";break;default:throw new Error(`Instances of "${u}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:h,enum:g,required:_,not:v,anyOf:x,allOf:S,oneOf:k,if:T,then:A,else:b,format:z,properties:j,patternProperties:H,additionalProperties:ne,unevaluatedProperties:ye,minProperties:Ce,maxProperties:pt,propertyNames:xe,dependentRequired:V,dependentSchemas:ee,dependencies:oe,prefixItems:ae,items:je,additionalItems:Jr,unevaluatedItems:$o,contains:Io,minContains:On,maxContains:w,minItems:y,maxItems:D,uniqueItems:E,minimum:De,maximum:We,exclusiveMinimum:At,exclusiveMaximum:bt,multipleOf:rr,minLength:dn,maxLength:wt,pattern:ri,__absolute_ref__:pc,__absolute_recursive_ref__:ep}=t,q=[];if(p===!0&&o===null&&(o=t),f==="#"){let me=o===null?i[ep]:o,se=`${s}/$recursiveRef`,ve=tt(e,o===null?t:o,r,i,n,me,a,se,c);ve.valid||q.push({instanceLocation:a,keyword:"$recursiveRef",keywordLocation:se,error:"A subschema had errors."},...ve.errors)}if(d!==void 0){let se=i[pc||d];if(se===void 0){let W=`Unresolved $ref "${d}".`;throw pc&&pc!==d&&(W+=` Absolute URI "${pc}".`),W+=`
228
+ Known schemas:
229
+ - ${Object.keys(i).join(`
230
+ - `)}`,new Error(W)}let ve=`${s}/$ref`,te=tt(e,se,r,i,n,o,a,ve,c);if(te.valid||q.push({instanceLocation:a,keyword:"$ref",keywordLocation:ve,error:"A subschema had errors."},...te.errors),r==="4"||r==="7")return{valid:q.length===0,errors:q}}if(Array.isArray(m)){let me=m.length,se=!1;for(let ve=0;ve<me;ve++)if(l===m[ve]||m[ve]==="integer"&&l==="number"&&e%1===0&&e===e){se=!0;break}se||q.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m.join('", "')}".`})}else m==="integer"?(l!=="number"||e%1||e!==e)&&q.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`}):m!==void 0&&l!==m&&q.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`});if(h!==void 0&&(l==="object"||l==="array"?Ii(e,h)||q.push({instanceLocation:a,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&q.push({instanceLocation:a,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),g!==void 0&&(l==="object"||l==="array"?g.some(me=>Ii(e,me))||q.push({instanceLocation:a,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`}):g.some(me=>e===me)||q.push({instanceLocation:a,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`})),v!==void 0){let me=`${s}/not`;tt(e,v,r,i,n,o,a,me).valid&&q.push({instanceLocation:a,keyword:"not",keywordLocation:me,error:'Instance matched "not" schema.'})}let Oa=[];if(x!==void 0){let me=`${s}/anyOf`,se=q.length,ve=!1;for(let te=0;te<x.length;te++){let W=x[te],ge=Object.create(c),he=tt(e,W,r,i,n,p===!0?o:null,a,`${me}/${te}`,ge);q.push(...he.errors),ve=ve||he.valid,he.valid&&Oa.push(ge)}ve?q.length=se:q.splice(se,0,{instanceLocation:a,keyword:"anyOf",keywordLocation:me,error:"Instance does not match any subschemas."})}if(S!==void 0){let me=`${s}/allOf`,se=q.length,ve=!0;for(let te=0;te<S.length;te++){let W=S[te],ge=Object.create(c),he=tt(e,W,r,i,n,p===!0?o:null,a,`${me}/${te}`,ge);q.push(...he.errors),ve=ve&&he.valid,he.valid&&Oa.push(ge)}ve?q.length=se:q.splice(se,0,{instanceLocation:a,keyword:"allOf",keywordLocation:me,error:"Instance does not match every subschema."})}if(k!==void 0){let me=`${s}/oneOf`,se=q.length,ve=k.filter((te,W)=>{let ge=Object.create(c),he=tt(e,te,r,i,n,p===!0?o:null,a,`${me}/${W}`,ge);return q.push(...he.errors),he.valid&&Oa.push(ge),he.valid}).length;ve===1?q.length=se:q.splice(se,0,{instanceLocation:a,keyword:"oneOf",keywordLocation:me,error:`Instance does not match exactly one subschema (${ve} matches).`})}if((l==="object"||l==="array")&&Object.assign(c,...Oa),T!==void 0){let me=`${s}/if`;if(tt(e,T,r,i,n,o,a,me,c).valid){if(A!==void 0){let ve=tt(e,A,r,i,n,o,a,`${s}/then`,c);ve.valid||q.push({instanceLocation:a,keyword:"if",keywordLocation:me,error:'Instance does not match "then" schema.'},...ve.errors)}}else if(b!==void 0){let ve=tt(e,b,r,i,n,o,a,`${s}/else`,c);ve.valid||q.push({instanceLocation:a,keyword:"if",keywordLocation:me,error:'Instance does not match "else" schema.'},...ve.errors)}}if(l==="object"){if(_!==void 0)for(let te of _)te in e||q.push({instanceLocation:a,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${te}".`});let me=Object.keys(e);if(Ce!==void 0&&me.length<Ce&&q.push({instanceLocation:a,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${Ce} properties.`}),pt!==void 0&&me.length>pt&&q.push({instanceLocation:a,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${pt} properties.`}),xe!==void 0){let te=`${s}/propertyNames`;for(let W in e){let ge=`${a}/${cn(W)}`,he=tt(W,xe,r,i,n,o,ge,te);he.valid||q.push({instanceLocation:a,keyword:"propertyNames",keywordLocation:te,error:`Property name "${W}" does not match schema.`},...he.errors)}}if(V!==void 0){let te=`${s}/dependantRequired`;for(let W in V)if(W in e){let ge=V[W];for(let he of ge)he in e||q.push({instanceLocation:a,keyword:"dependentRequired",keywordLocation:te,error:`Instance has "${W}" but does not have "${he}".`})}}if(ee!==void 0)for(let te in ee){let W=`${s}/dependentSchemas`;if(te in e){let ge=tt(e,ee[te],r,i,n,o,a,`${W}/${cn(te)}`,c);ge.valid||q.push({instanceLocation:a,keyword:"dependentSchemas",keywordLocation:W,error:`Instance has "${te}" but does not match dependant schema.`},...ge.errors)}}if(oe!==void 0){let te=`${s}/dependencies`;for(let W in oe)if(W in e){let ge=oe[W];if(Array.isArray(ge))for(let he of ge)he in e||q.push({instanceLocation:a,keyword:"dependencies",keywordLocation:te,error:`Instance has "${W}" but does not have "${he}".`});else{let he=tt(e,ge,r,i,n,o,a,`${te}/${cn(W)}`);he.valid||q.push({instanceLocation:a,keyword:"dependencies",keywordLocation:te,error:`Instance has "${W}" but does not match dependant schema.`},...he.errors)}}}let se=Object.create(null),ve=!1;if(j!==void 0){let te=`${s}/properties`;for(let W in j){if(!(W in e))continue;let ge=`${a}/${cn(W)}`,he=tt(e[W],j[W],r,i,n,o,ge,`${te}/${cn(W)}`);if(he.valid)c[W]=se[W]=!0;else if(ve=n,q.push({instanceLocation:a,keyword:"properties",keywordLocation:te,error:`Property "${W}" does not match schema.`},...he.errors),ve)break}}if(!ve&&H!==void 0){let te=`${s}/patternProperties`;for(let W in H){let ge=new RegExp(W,"u"),he=H[W];for(let jr in e){if(!ge.test(jr))continue;let JE=`${a}/${cn(jr)}`,XE=tt(e[jr],he,r,i,n,o,JE,`${te}/${cn(W)}`);XE.valid?c[jr]=se[jr]=!0:(ve=n,q.push({instanceLocation:a,keyword:"patternProperties",keywordLocation:te,error:`Property "${jr}" matches pattern "${W}" but does not match associated schema.`},...XE.errors))}}}if(!ve&&ne!==void 0){let te=`${s}/additionalProperties`;for(let W in e){if(se[W])continue;let ge=`${a}/${cn(W)}`,he=tt(e[W],ne,r,i,n,o,ge,te);he.valid?c[W]=!0:(ve=n,q.push({instanceLocation:a,keyword:"additionalProperties",keywordLocation:te,error:`Property "${W}" does not match additional properties schema.`},...he.errors))}}else if(!ve&&ye!==void 0){let te=`${s}/unevaluatedProperties`;for(let W in e)if(!c[W]){let ge=`${a}/${cn(W)}`,he=tt(e[W],ye,r,i,n,o,ge,te);he.valid?c[W]=!0:q.push({instanceLocation:a,keyword:"unevaluatedProperties",keywordLocation:te,error:`Property "${W}" does not match unevaluated properties schema.`},...he.errors)}}}else if(l==="array"){D!==void 0&&e.length>D&&q.push({instanceLocation:a,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${D}).`}),y!==void 0&&e.length<y&&q.push({instanceLocation:a,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${y}).`});let me=e.length,se=0,ve=!1;if(ae!==void 0){let te=`${s}/prefixItems`,W=Math.min(ae.length,me);for(;se<W;se++){let ge=tt(e[se],ae[se],r,i,n,o,`${a}/${se}`,`${te}/${se}`);if(c[se]=!0,!ge.valid&&(ve=n,q.push({instanceLocation:a,keyword:"prefixItems",keywordLocation:te,error:"Items did not match schema."},...ge.errors),ve))break}}if(je!==void 0){let te=`${s}/items`;if(Array.isArray(je)){let W=Math.min(je.length,me);for(;se<W;se++){let ge=tt(e[se],je[se],r,i,n,o,`${a}/${se}`,`${te}/${se}`);if(c[se]=!0,!ge.valid&&(ve=n,q.push({instanceLocation:a,keyword:"items",keywordLocation:te,error:"Items did not match schema."},...ge.errors),ve))break}}else for(;se<me;se++){let W=tt(e[se],je,r,i,n,o,`${a}/${se}`,te);if(c[se]=!0,!W.valid&&(ve=n,q.push({instanceLocation:a,keyword:"items",keywordLocation:te,error:"Items did not match schema."},...W.errors),ve))break}if(!ve&&Jr!==void 0){let W=`${s}/additionalItems`;for(;se<me;se++){let ge=tt(e[se],Jr,r,i,n,o,`${a}/${se}`,W);c[se]=!0,ge.valid||(ve=n,q.push({instanceLocation:a,keyword:"additionalItems",keywordLocation:W,error:"Items did not match additional items schema."},...ge.errors))}}}if(Io!==void 0)if(me===0&&On===void 0)q.push({instanceLocation:a,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(On!==void 0&&me<On)q.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${me}) than minContains (${On}).`});else{let te=`${s}/contains`,W=q.length,ge=0;for(let he=0;he<me;he++){let jr=tt(e[he],Io,r,i,n,o,`${a}/${he}`,te);jr.valid?(c[he]=!0,ge++):q.push(...jr.errors)}ge>=(On||0)&&(q.length=W),On===void 0&&w===void 0&&ge===0?q.splice(W,0,{instanceLocation:a,keyword:"contains",keywordLocation:te,error:"Array does not contain item matching schema."}):On!==void 0&&ge<On?q.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${On} items matching schema. Only ${ge} items were found.`}):w!==void 0&&ge>w&&q.push({instanceLocation:a,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${w} items matching schema. ${ge} items were found.`})}if(!ve&&$o!==void 0){let te=`${s}/unevaluatedItems`;for(se;se<me;se++){if(c[se])continue;let W=tt(e[se],$o,r,i,n,o,`${a}/${se}`,te);c[se]=!0,W.valid||q.push({instanceLocation:a,keyword:"unevaluatedItems",keywordLocation:te,error:"Items did not match unevaluated items schema."},...W.errors)}}if(E)for(let te=0;te<me;te++){let W=e[te],ge=typeof W=="object"&&W!==null;for(let he=0;he<me;he++){if(te===he)continue;let jr=e[he];(W===jr||ge&&(typeof jr=="object"&&jr!==null)&&Ii(W,jr))&&(q.push({instanceLocation:a,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${te} and ${he}.`}),te=Number.MAX_SAFE_INTEGER,he=Number.MAX_SAFE_INTEGER)}}}else if(l==="number"){if(r==="4"?(De!==void 0&&(At===!0&&e<=De||e<De)&&q.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${At?"or equal to ":""} ${De}.`}),We!==void 0&&(bt===!0&&e>=We||e>We)&&q.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${bt?"or equal to ":""} ${We}.`})):(De!==void 0&&e<De&&q.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${De}.`}),We!==void 0&&e>We&&q.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${We}.`}),At!==void 0&&e<=At&&q.push({instanceLocation:a,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${At}.`}),bt!==void 0&&e>=bt&&q.push({instanceLocation:a,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${bt}.`})),rr!==void 0){let me=e%rr;Math.abs(0-me)>=11920929e-14&&Math.abs(rr-me)>=11920929e-14&&q.push({instanceLocation:a,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${rr}.`})}}else if(l==="string"){let me=dn===void 0&&wt===void 0?0:QR(e);dn!==void 0&&me<dn&&q.push({instanceLocation:a,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${me} < ${dn}).`}),wt!==void 0&&me>wt&&q.push({instanceLocation:a,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${me} > ${wt}).`}),ri!==void 0&&!new RegExp(ri,"u").test(e)&&q.push({instanceLocation:a,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),z!==void 0&&Pk[z]&&!Pk[z](e)&&q.push({instanceLocation:a,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${z}".`})}return{valid:q.length===0,errors:q}}var $g=class{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",i=!0){this.schema=t,this.draft=r,this.shortCircuit=i,this.lookup=Hn(t)}validate(t){return tt(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),Hn(t,this.lookup)}};var tj=C({Validator:()=>$g,deepCompareStrict:()=>Ii,toJsonSchema:()=>zt,validatesOnlyStrings:()=>zu}),ej=new WeakMap;function zt(e,t){let r=!t&&e!=null&&typeof e=="object";if(r){let n=ej.get(e);if(n)return n}let i;if(Mm(e)&&!et(e))i=e["~standard"].jsonSchema.input({target:"draft-07"});else if(et(e)){let n=gg(e,!0);if(bn(n)){let o=Eu(n,!0);i=Rs(o,t)}else i=Rs(e,t)}else yt(e)?i=Ok(e):i=e;return r&&i!=null&&typeof i=="object"&&ej.set(e,i),i}function zu(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=>zu(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=>zu(r))}if("not"in e)return!1;if("$ref"in e&&typeof e.$ref=="string"){let t=e.$ref,r=Hn(e);return r[t]?zu(r[t]):!1}return!1}function Wd(e){return e?e.lc_runnable:!1}var rj=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,i=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||i.some(n=>this.includeTags?.includes(n))),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&&i.every(n=>!this.excludeTags?.includes(n))),r}},nj=e=>btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function Nk(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}var u5=["*","_","`"];function l5(e){let t="";for(let[r,i]of Object.entries(e))t+=` classDef ${r} ${i};
231
+ `;return t}function ij(e,t,r){let{firstNode:i,lastNode:n,nodeColors:o,withStyles:a=!0,curveStyle:s="linear",wrapLabelNWords:c=9}=r??{},u=a?`%%{init: {'flowchart': {'curve': '${s}'}}}%%
232
+ graph TD;
233
+ `:`graph TD;
234
+ `;if(a){let m="default",h={[m]:"{0}({1})"};i!==void 0&&(h[i]="{0}([{1}]):::first"),n!==void 0&&(h[n]="{0}([{1}]):::last");for(let[g,_]of Object.entries(e)){let v=_.name.split(":").pop()??"",x=u5.some(k=>v.startsWith(k)&&v.endsWith(k))?`<p>${v}</p>`:v;Object.keys(_.metadata??{}).length&&(x+=`<hr/><small><em>${Object.entries(_.metadata??{}).map(([k,T])=>`${k} = ${T}`).join(`
235
+ `)}</em></small>`);let S=(h[g]??h[m]).replace("{0}",Nk(g)).replace("{1}",x);u+=` ${S}
236
+ `}}let l={};for(let m of t){let h=m.source.split(":"),g=m.target.split(":"),_=h.filter((v,x)=>v===g[x]).join(":");l[_]||(l[_]=[]),l[_].push(m)}let d=new Set;function f(m){return[...m].sort((h,g)=>h.split(":").length-g.split(":").length)}function p(m,h){let g=m.length===1&&m[0].source===m[0].target;if(h&&!g){let v=h.split(":").pop();if(d.has(h))throw new Error(`Found duplicate subgraph '${v}' 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),u+=` subgraph ${v}
237
+ `}let _=f(Object.keys(l).filter(v=>v.startsWith(`${h}:`)&&v!==h&&v.split(":").length===h.split(":").length+1));for(let v of _)p(l[v],v);for(let v of m){let{source:x,target:S,data:k,conditional:T}=v,A="";if(k!==void 0){let b=k,z=b.split(" ");z.length>c&&(b=Array.from({length:Math.ceil(z.length/c)},(j,H)=>z.slice(H*c,(H+1)*c).join(" ")).join("&nbsp;<br>&nbsp;")),A=T?` -. &nbsp;${b}&nbsp; .-> `:` -- &nbsp;${b}&nbsp; --> `}else A=T?" -.-> ":" --> ";u+=` ${Nk(x)}${A}${Nk(S)};
238
+ `}h&&!g&&(u+=` end
239
+ `)}p(l[""]??[],"");for(let m in l)!m.includes(":")&&m!==""&&p(l[m],m);return a&&(u+=l5(o??{})),u}async function oj(e,t){let r=t?.backgroundColor??"white",i=t?.imageType??"png",n=nj(e);r!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(r)||(r=`!${r}`));let o=`https://mermaid.ink/img/${n}?bgColor=${r}&type=${i}`,a=await fetch(o);if(!a.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${a.status}`,`Status text: ${a.statusText}`].join(`
240
+ `));return await a.blob()}var cj=C({Graph:()=>Ys});function d5(e,t){if(e!==void 0&&!Fi(e))return e;if(Wd(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 f5(e){return Wd(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...zt(e.data.schema),title:e.data.name}}}var Ys=class uj{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,i)=>{t[r.id]=Fi(r.id)?i:r.id}),{nodes:Object.values(this.nodes).map(r=>({id:t[r.id],...f5(r)})),edges:this.edges.map(r=>{let i={source:t[r.source],target:t[r.target]};return typeof r.data<"u"&&(i.data=r.data),typeof r.conditional<"u"&&(i.conditional=r.conditional),i})}}addNode(t,r,i){if(r!==void 0&&this.nodes[r]!==void 0)throw new Error(`Node with id ${r} already exists`);let n=r??Do(),o={id:n,data:t,name:d5(r,t),metadata:i};return this.nodes[n]=o,o}removeNode(t){delete this.nodes[t.id],this.edges=this.edges.filter(r=>r.source!==t.id&&r.target!==t.id)}addEdge(t,r,i,n){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 o={source:t.id,target:r.id,data:i,conditional:n};return this.edges.push(o),o}firstNode(){return aj(this)}lastNode(){return sj(this)}extend(t,r=""){let i=r;Object.values(t.nodes).map(c=>c.id).every(Fi)&&(i="");let n=c=>i?`${i}:${c}`:c;Object.entries(t.nodes).forEach(([c,u])=>{this.nodes[n(c)]={...u,id:n(c)}});let o=t.edges.map(c=>({...c,source:n(c.source),target:n(c.target)}));this.edges=[...this.edges,...o];let a=t.firstNode(),s=t.lastNode();return[a?{id:n(a.id),data:a.data}:void 0,s?{id:n(s.id),data:s.data}:void 0]}trimFirstNode(){let t=this.firstNode();t&&aj(this,[t.id])&&this.removeNode(t)}trimLastNode(){let t=this.lastNode();t&&sj(this,[t.id])&&this.removeNode(t)}reid(){let t=Object.fromEntries(Object.values(this.nodes).map(n=>[n.id,n.name])),r=new Map;Object.values(t).forEach(n=>{r.set(n,(r.get(n)||0)+1)});let i=n=>{let o=t[n];return Fi(n)&&r.get(o)===1?o:n};return new uj({nodes:Object.fromEntries(Object.entries(this.nodes).map(([n,o])=>[i(n),{...o,id:i(n)}])),edges:this.edges.map(n=>({...n,source:i(n.source),target:i(n.target)}))})}drawMermaid(t){let{withStyles:r,curveStyle:i,nodeColors:n={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:o}=t??{},a=this.reid(),s=a.firstNode(),c=a.lastNode();return ij(a.nodes,a.edges,{firstNode:s?.id,lastNode:c?.id,withStyles:r,curveStyle:i,nodeColors:n,wrapLabelNWords:o})}async drawMermaidPng(t){let r=this.drawMermaid(t);return oj(r,{backgroundColor:t?.backgroundColor})}};function aj(e,t=[]){let r=new Set(e.edges.filter(n=>!t.includes(n.source)).map(n=>n.target)),i=[];for(let n of Object.values(e.nodes))!t.includes(n.id)&&!r.has(n.id)&&i.push(n);return i.length===1?i[0]:void 0}function sj(e,t=[]){let r=new Set(e.edges.filter(n=>!t.includes(n.target)).map(n=>n.source)),i=[];for(let n of Object.values(e.nodes))!t.includes(n.id)&&!r.has(n.id)&&i.push(n);return i.length===1?i[0]:void 0}function Ig({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 lj=e=>e.name==="event_stream_tracer",dj=class extends Yt{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=$t.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(i=>this.includeTags?.includes(i))!==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(i=>!this.excludeTags?.includes(i))),r}async*tapOutputIterable(e,t){let r=await t.next();if(r.done)return;let i=this.runInfoMap.get(e);if(i===void 0){yield r.value;return}function n(a,s){return a==="llm"&&typeof s=="string"?new Qi({text:s}):s}let o=this.tappedPromises.get(e);if(o===void 0){let a;o=new Promise(s=>{a=s}),this.tappedPromises.set(e,o);try{let s={event:`on_${i.runType}_stream`,run_id:e,name:i.name,tags:i.tags,metadata:i.metadata,data:{}};await this.send({...s,data:{chunk:n(i.runType,r.value)}},i),yield r.value;for await(let c of t)i.runType!=="tool"&&i.runType!=="retriever"&&await this.send({...s,data:{chunk:n(i.runType,c)}},i),yield c}finally{a?.()}}else{yield r.value;for await(let a of t)yield a}}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=Ig(e),r=e.inputs.messages!==void 0?"chat_model":"llm",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,i);let n=`on_${r}_start`;await this.send({event:n,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}async onLLMNewToken(e,t,r){let i=this.runInfoMap.get(e.id),n,o;if(i===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(i.runType==="chat_model")o="on_chat_model_stream",r?.chunk===void 0?n=new nt({content:t,id:`run-${e.id}`}):n=r.chunk.message;else if(i.runType==="llm")o="on_llm_stream",r?.chunk===void 0?n=new Qi({text:t}):n=r.chunk;else throw new Error(`Unexpected run type ${i.runType}`);await this.send({event:o,data:{chunk:n},run_id:e.id,name:i.name,tags:i.tags,metadata:i.metadata},i)}}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 i=e.outputs?.generations,n;if(t.runType==="chat_model"){for(let o of i??[]){if(n!==void 0)break;n=o[0]?.message}r="on_chat_model_end"}else if(t.runType==="llm")n={generations:i?.map(o=>o.map(a=>({text:a.text,generationInfo:a.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:n,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){let t=Ig(e),r=e.run_type??"chain",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type},n={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(n={},i.inputs={}):e.inputs.input!==void 0?(n.input=e.inputs.input,i.inputs=e.inputs.input):(n.input=e.inputs,i.inputs=e.inputs),this.runInfoMap.set(e.id,i),await this.send({event:`on_${r}_start`,data:n,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}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`,i=e.inputs??t.inputs??{},n={output:e.outputs?.output??e.outputs,input:i};i.input&&Object.keys(i).length===1&&(n.input=i.input,t.inputs=i.input),await this.sendEndEvent({event:r,data:n,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){let t=Ig(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=Ig(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 i=this.runInfoMap.get(r);if(i===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:i.tags,metadata:i.metadata,data:t},i)}async finish(){let e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}};var Rk=class extends Yt{name="RootListenersTracer";rootId;config;argOnStart;argOnEnd;argOnError;constructor({config:e,onStart:t,onEnd:r,onError:i}){super({_awaitHandler:!0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=i}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 fj(e){let t=new TextEncoder,r=new ReadableStream({async start(i){for await(let n of e)i.enqueue(t.encode(`event: data
241
+ data: ${JSON.stringify(n)}
242
+
243
+ `));i.enqueue(t.encode(`event: end
244
+
245
+ `)),i.close()}});return $t.fromReadableStream(r)}function jk(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.iterator]=="function"&&typeof e.next=="function"}var pj=e=>e!=null&&typeof e=="object"&&"next"in e&&typeof e.next=="function";function Eg(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function"}function Dk(e){return e!=null&&typeof e=="object"&&typeof e.next=="function"}async function mj(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*Mk(e,t){for(;;){let{value:r,done:i}=Ue.runWithConfig(Lr(e),t.next.bind(t),!0);if(i)break;yield r}}async function*Tg(e,t){let r=t[Symbol.asyncIterator]();for(;;){let{value:i,done:n}=await Ue.runWithConfig(Lr(e),r.next.bind(t),!0);if(n)break;yield i}}function It(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}var ue=class extends xt{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 Cg({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new $n({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new zk({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(Ae);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(([i])=>i!=="runId"));return Array.from({length:t},(i,n)=>Ae(n===0?e:r))}return Array.from({length:t},()=>Ae(e))}async batch(e,t,r){let i=this._getOptionsList(t??{},e.length),n=i[0]?.maxConcurrency??r?.maxConcurrency,o=new eo({maxConcurrency:n,onFailedAttempt:s=>{throw s}}),a=e.map((s,c)=>o.call(async()=>{try{return await this.invoke(s,i[c])}catch(u){if(r?.returnExceptions)return u;throw u}}));return Promise.all(a)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){let r=Ae(t),i=new Xo({generator:this._streamIterator(e,r),config:r});return await i.setup,$t.fromAsyncGenerator(i)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=Ae(e):t=Ae({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 i=Ae(r),n=await(await lr(i))?.handleChainStart(this.toJSON(),It(t,"input"),i.runId,i?.runType,void 0,void 0,i?.runName??this.getName());delete i.runId;let o;try{let a=e.call(this,t,i,n);o=await rn(a,i.signal)}catch(a){throw await n?.handleChainError(a),a}return await n?.handleChainEnd(It(o,"output")),o}async _batchWithConfig(e,t,r,i){let n=this._getOptionsList(r??{},t.length),o=await Promise.all(n.map(lr)),a=await Promise.all(o.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),It(t[u],"input"),n[u].runId,n[u].runType,void 0,void 0,n[u].runName??this.getName());return delete n[u].runId,l})),s;try{let c=e.call(this,t,n,a,i);s=await rn(c,n?.[0]?.signal)}catch(c){throw await Promise.all(a.map(u=>u?.handleChainError(c))),c}return await Promise.all(a.map(c=>c?.handleChainEnd(It(s,"output")))),s}_concatOutputChunks(e,t){return nn(e,t)}async*_transformStreamWithConfig(e,t,r){let i,n=!0,o,a=!0,s=Ae(r),c=await lr(s),u=this;async function*l(){for await(let f of e){if(n)if(i===void 0)i=f;else try{i=u._concatOutputChunks(i,f)}catch{i=void 0,n=!1}yield f}}let d;try{let f=await Ab(t.bind(this),l(),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(lj),m=f.output;p!==void 0&&d!==void 0&&(m=p.tapOutputIterable(d.runId,m));let h=d?.handlers.find(Pb);h!==void 0&&d!==void 0&&(m=h.tapOutputIterable(d.runId,m));for await(let g of m)if(yield g,a)if(o===void 0)o=g;else try{o=this._concatOutputChunks(o,g)}catch{o=void 0,a=!1}}catch(f){throw await d?.handleChainError(f,void 0,void 0,void 0,{inputs:It(i,"input")}),f}await d?.handleChainEnd(o??{},void 0,void 0,void 0,{inputs:It(i,"input")})}getGraph(e){let t=new Ys,r=t.addNode({name:`${this.getName()}Input`,schema:Kt.any()}),i=t.addNode(this),n=t.addNode({name:`${this.getName()}Output`,schema:Kt.any()});return t.addEdge(r,i),t.addEdge(i,n),t}pipe(e){return new un({first:this,last:mt(e)})}pick(e){return this.pipe(new Lk(e))}assign(e){return this.pipe(new Jd(new ga({steps:e})))}async*transform(e,t){let r;for await(let i of e)r===void 0?r=i:r=this._concatOutputChunks(r,i);yield*this._streamIterator(r,Ae(t))}async*streamLog(e,t,r){let i=new Rm({...r,autoClose:!1,_schemaFormat:"original"}),n=Ae(t);yield*this._streamLog(e,i,n)}async*_streamLog(e,t,r){let{callbacks:i}=r;if(i===void 0)r.callbacks=[t];else if(Array.isArray(i))r.callbacks=i.concat([t]);else{let s=i.copy();s.addHandler(t,!0),r.callbacks=s}let n=this.stream(e,r);async function o(){try{let s=await n;for await(let c of s){let u=new vi({ops:[{op:"add",path:"/streamed_output/-",value:c}]});await t.writer.write(u)}}finally{await t.writer.close()}}let a=o();try{for await(let s of t)yield s}finally{await a}}streamEvents(e,t,r){let i;if(t.version==="v1")i=this._streamEventsV1(e,t,r);else if(t.version==="v2")i=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"?fj(i):$t.fromAsyncGenerator(i)}async*_streamEventsV2(e,t,r){let i=new dj({...r,autoClose:!1}),n=Ae(t),o=n.runId??mn();n.runId=o;let a=n.callbacks;if(a===void 0)n.callbacks=[i];else if(Array.isArray(a))n.callbacks=a.concat(i);else{let p=a.copy();p.addHandler(i,!0),n.callbacks=p}let s=new AbortController,c=this;async function u(){let p;try{if(n.signal)if("any"in AbortSignal)p=AbortSignal.any([s.signal,n.signal]);else{let g=new AbortController;n.signal.addEventListener("abort",()=>g.abort(),{once:!0}),s.signal.addEventListener("abort",()=>g.abort(),{once:!0}),p=g.signal}else p=s.signal;let m=await c.stream(e,{...n,signal:p}),h=i.tapOutputIterable(o,m);for await(let g of h)if(s.signal.aborted)break}finally{await i.finish()}}let l=u(),d=!1,f;try{for await(let p of i){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 l}}async*_streamEventsV1(e,t,r){let i,n=!1,o=Ae(t),a=o.tags??[],s=o.metadata??{},c=o.runName??this.getName(),u=new Rm({...r,autoClose:!1,_schemaFormat:"streaming_events"}),l=new rj({...r}),d=this._streamLog(e,u,o);for await(let p of d){if(i?i=i.concat(p):i=Nm.fromRunLogPatch(p),i.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!n){n=!0;let _={...i.state},v={run_id:_.id,event:`on_${_.type}_start`,name:c,tags:a,metadata:s,data:{input:e}};l.includeEvent(v,_.type)&&(yield v)}let m=p.ops.filter(_=>_.path.startsWith("/logs/")).map(_=>_.path.split("/")[2]),h=[...new Set(m)];for(let _ of h){let v,x={},S=i.state.logs[_];if(S.end_time===void 0?S.streamed_output.length>0?v="stream":v="start":v="end",v==="start")S.inputs!==void 0&&(x.input=S.inputs);else if(v==="end")S.inputs!==void 0&&(x.input=S.inputs),x.output=S.final_output;else if(v==="stream"){let k=S.streamed_output.length;if(k!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${k} instead. Encountered in: "${S.name}"`);x={chunk:S.streamed_output[0]},S.streamed_output=[]}yield{event:`on_${S.type}_${v}`,name:S.name,run_id:S.id,tags:S.tags,metadata:S.metadata,data:x}}let{state:g}=i;if(g.streamed_output.length>0){let _=g.streamed_output.length;if(_!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${_} instead. Encountered in: "${g.name}"`);let v={chunk:g.streamed_output[0]};g.streamed_output=[];let x={event:`on_${g.type}_stream`,run_id:g.id,tags:a,metadata:s,name:c,data:v};l.includeEvent(x,g.type)&&(yield x)}}let f=i?.state;if(f!==void 0){let p={event:`on_${f.type}_end`,name:c,run_id:f.id,tags:a,metadata:s,data:{output:f.final_output}};l.includeEvent(p,f.type)&&(yield p)}}static isRunnable(e){return Wd(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new $n({bound:this,config:{},configFactories:[i=>({callbacks:[new Rk({config:i,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return h5(this,e)}},$n=class hj extends ue{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=jt(this.config,...t);return jt(r,...this.configFactories?await Promise.all(this.configFactories.map(async i=>await i(r))):[])}withConfig(t){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...t}})}withRetry(t){return new Cg({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,i){let n=Array.isArray(r)?await Promise.all(r.map(async o=>this._mergeConfig(Ae(o),this.kwargs))):await this._mergeConfig(Ae(r),this.kwargs);return this.bound.batch(t,n,i)}_concatOutputChunks(t,r){return this.bound._concatOutputChunks(t,r)}async*_streamIterator(t,r){yield*this.bound._streamIterator(t,await this._mergeConfig(Ae(r),this.kwargs))}async stream(t,r){return this.bound.stream(t,await this._mergeConfig(Ae(r),this.kwargs))}async*transform(t,r){yield*this.bound.transform(t,await this._mergeConfig(Ae(r),this.kwargs))}streamEvents(t,r,i){let n=this,o=async function*(){yield*n.bound.streamEvents(t,{...await n._mergeConfig(Ae(r),n.kwargs),version:r.version},i)};return $t.fromAsyncGenerator(o())}static isRunnableBinding(t){return t.bound&&ue.isRunnable(t.bound)}withListeners({onStart:t,onEnd:r,onError:i}){return new hj({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[n=>({callbacks:[new Rk({config:n,onStart:t,onEnd:r,onError:i})]})]})}},gj=class _j extends ue{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,i){return this.bound.batch(t,Pe(r,{callbacks:i?.getChild()}))}withListeners({onStart:t,onEnd:r,onError:i}){return new _j({bound:this.bound.withListeners({onStart:t,onEnd:r,onError:i})})}},Cg=class extends $n{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 i=e>1?`retry:attempt:${e}`:void 0;return Pe(t,{callbacks:r?.getChild(i)})}async _invoke(e,t,r){return Jl(i=>super.invoke(e,this._patchConfigForRetry(i,t,r)),{onFailedAttempt:({error:i})=>this.onFailedAttempt(i,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,i){let n={};try{await Jl(async o=>{let a=e.map((d,f)=>f).filter(d=>n[d.toString()]===void 0||n[d.toString()]instanceof Error),s=a.map(d=>e[d]),c=a.map(d=>this._patchConfigForRetry(o,t?.[d],r?.[d])),u=await super.batch(s,c,{...i,returnExceptions:!0}),l;for(let d=0;d<u.length;d+=1){let f=u[d],p=a[d];f instanceof Error&&l===void 0&&(l=f,l.input=s[d]),n[p.toString()]=f}if(l)throw l;return u},{onFailedAttempt:({error:o})=>this.onFailedAttempt(o,o.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(o){if(i?.returnExceptions!==!0)throw o}return Object.keys(n).sort((o,a)=>parseInt(o,10)-parseInt(a,10)).map(o=>n[parseInt(o,10)])}async batch(e,t,r){return this._batchWithConfig(this._batch.bind(this),e,t,r)}},un=class qd extends ue{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 i=Ae(r),n=await(await lr(i))?.handleChainStart(this.toJSON(),It(t,"input"),i.runId,void 0,void 0,void 0,i?.runName);delete i.runId;let o=t,a;try{let s=[this.first,...this.middle];for(let c=0;c<s.length;c+=1){let u=s[c].invoke(o,Pe(i,{callbacks:n?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`)}));o=await rn(u,i.signal)}if(i.signal?.aborted)throw Jo(i.signal);a=await this.last.invoke(o,Pe(i,{callbacks:n?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(s){throw await n?.handleChainError(s),s}return await n?.handleChainEnd(It(a,"output")),a}async batch(t,r,i){let n=this._getOptionsList(r??{},t.length),o=await Promise.all(n.map(lr)),a=await Promise.all(o.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),It(t[u],"input"),n[u].runId,void 0,void 0,void 0,n[u].runName);return delete n[u].runId,l})),s=t;try{for(let c=0;c<this.steps.length;c+=1){let u=this.steps[c].batch(s,a.map((l,d)=>{let f=l?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`);return Pe(n[d],{callbacks:f})}),i);s=await rn(u,n[0]?.signal)}}catch(c){throw await Promise.all(a.map(u=>u?.handleChainError(c))),c}return await Promise.all(a.map(c=>c?.handleChainEnd(It(s,"output")))),s}_concatOutputChunks(t,r){return this.last._concatOutputChunks(t,r)}async*_streamIterator(t,r){let i=await lr(r),{runId:n,...o}=r??{},a=await i?.handleChainStart(this.toJSON(),It(t,"input"),n,void 0,void 0,void 0,o?.runName),s=[this.first,...this.middle,this.last],c=!0,u;async function*l(){yield t}try{let d=s[0].transform(l(),Pe(o,{callbacks:a?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let f=1;f<s.length;f+=1)d=await s[f].transform(d,Pe(o,{callbacks:a?.getChild(this.omitSequenceTags?void 0:`seq:step:${f+1}`)}));for await(let f of d)if(r?.signal?.throwIfAborted(),yield f,c)if(u===void 0)u=f;else try{u=this._concatOutputChunks(u,f)}catch{u=void 0,c=!1}}catch(d){throw await a?.handleChainError(d),d}await a?.handleChainEnd(It(u,"output"))}getGraph(t){let r=new Ys,i=null;return this.steps.forEach((n,o)=>{let a=n.getGraph(t);o!==0&&a.trimFirstNode(),o!==this.steps.length-1&&a.trimLastNode(),r.extend(a);let s=a.firstNode();if(!s)throw new Error(`Runnable ${n} has no first node`);i&&r.addEdge(i,s),i=a.lastNode()}),r}pipe(t){return qd.isRunnableSequence(t)?new qd({first:this.first,middle:this.middle.concat([this.last,t.first,...t.middle]),last:t.last,name:this.name??t.name}):new qd({first:this.first,middle:[...this.middle,this.last],last:mt(t),name:this.name})}static isRunnableSequence(t){return Array.isArray(t.middle)&&ue.isRunnable(t)}static from([t,...r],i){let n={};return typeof i=="string"?n.name=i:i!==void 0&&(n=i),new qd({...n,first:mt(t),middle:r.slice(0,-1).map(mt),last:mt(r[r.length-1])})}},ga=class yj extends ue{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,i]of Object.entries(t.steps))this.steps[r]=mt(i)}static from(t){return new yj({steps:t})}async invoke(t,r){let i=Ae(r),n=await(await lr(i))?.handleChainStart(this.toJSON(),{input:t},i.runId,void 0,void 0,void 0,i?.runName);delete i.runId;let o={};try{let a=Object.entries(this.steps).map(async([s,c])=>{o[s]=await c.invoke(t,Pe(i,{callbacks:n?.getChild(`map:key:${s}`)}))});await rn(Promise.all(a),i.signal)}catch(a){throw await n?.handleChainError(a),a}return await n?.handleChainEnd(o),o}async*_transform(t,r,i){let n={...this.steps},o=Tm(t,Object.keys(n).length),a=new Map(Object.entries(n).map(([s,c],u)=>{let l=c.transform(o[u],Pe(i,{callbacks:r?.getChild(`map:key:${s}`)}));return[s,l.next().then(d=>({key:s,gen:l,result:d}))]}));for(;a.size;){let s=Promise.race(a.values()),{key:c,result:u,gen:l}=await rn(s,i?.signal);a.delete(c),u.done||(yield{[c]:u.value},a.set(c,l.next().then(d=>({key:c,gen:l,result:d}))))}}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*i(){yield t}let n=Ae(r),o=new Xo({generator:this.transform(i(),n),config:n});return await o.setup,$t.fromAsyncGenerator(o)}},p5=class vj extends ue{lc_serializable=!1;lc_namespace=["langchain_core","runnables"];func;constructor(t){if(super(t),!Vp(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[i]=this._getOptionsList(r??{},1),n=await lr(i),o=this.func(Pe(i,{callbacks:n}),t);return rn(o,i?.signal)}async*_streamIterator(t,r){let[i]=this._getOptionsList(r??{},1),n=await this.invoke(t,r);if(Eg(n)){for await(let o of n)i?.signal?.throwIfAborted(),yield o;return}if(pj(n)){for(;;){i?.signal?.throwIfAborted();let o=n.next();if(o.done)break;yield o.value}return}yield n}static from(t){return new vj({func:t})}};function m5(e){if(Vp(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var mr=class bj extends ue{static lc_name(){return"RunnableLambda"}lc_namespace=["langchain_core","runnables"];func;constructor(t){if(Vp(t.func))return p5.from(t.func);super(t),m5(t.func),this.func=t.func}static from(t){return new bj({func:t})}async _invoke(t,r,i){return new Promise((n,o)=>{let a=Pe(r,{callbacks:i?.getChild(),recursionLimit:(r?.recursionLimit??25)-1});Ue.runWithConfig(Lr(a),async()=>{try{let s=await this.func(t,{...a});if(s&&ue.isRunnable(s)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");s=await s.invoke(t,{...a,recursionLimit:(a.recursionLimit??25)-1})}else if(Eg(s)){let c;for await(let u of Tg(a,s))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}s=c}else if(jk(s)){let c;for(let u of Mk(a,s))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}s=c}n(s)}catch(s){o(s)}})})}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async*_transform(t,r,i){let n;for await(let s of t)if(n===void 0)n=s;else try{n=this._concatOutputChunks(n,s)}catch{n=s}let o=Pe(i,{callbacks:r?.getChild(),recursionLimit:(i?.recursionLimit??25)-1}),a=await new Promise((s,c)=>{Ue.runWithConfig(Lr(o),async()=>{try{s(await this.func(n,{...o,config:o}))}catch(u){c(u)}})});if(a&&ue.isRunnable(a)){if(i?.recursionLimit===0)throw new Error("Recursion limit reached.");let s=await a.stream(n,o);for await(let c of s)yield c}else if(Eg(a))for await(let s of Tg(o,a))i?.signal?.throwIfAborted(),yield s;else if(jk(a))for(let s of Mk(o,a))i?.signal?.throwIfAborted(),yield s;else yield a}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*i(){yield t}let n=Ae(r),o=new Xo({generator:this.transform(i(),n),config:n});return await o.setup,$t.fromAsyncGenerator(o)}},wj=class extends ga{},zk=class extends ue{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=Ae(t),i=await lr(r),{runId:n,...o}=r,a=await i?.handleChainStart(this.toJSON(),It(e,"input"),n,void 0,void 0,void 0,o?.runName),s=Pe(o,{callbacks:a?.getChild()});return await Ue.runWithConfig(s,async()=>{let c;for(let u of this.runnables()){r?.signal?.throwIfAborted();try{let l=await u.invoke(e,s);return await a?.handleChainEnd(It(l,"output")),l}catch(l){c===void 0&&(c=l)}}throw c===void 0?new Error("No error stored at end of fallback."):(await a?.handleChainError(c),c)})}async*_streamIterator(e,t){let r=Ae(t),i=await lr(r),{runId:n,...o}=r,a=await i?.handleChainStart(this.toJSON(),It(e,"input"),n,void 0,void 0,void 0,o?.runName),s,c;for(let l of this.runnables()){r?.signal?.throwIfAborted();let d=Pe(o,{callbacks:a?.getChild()});try{let f=await l.stream(e,d);c=Tg(d,f);break}catch(f){s===void 0&&(s=f)}}if(c===void 0){let l=s??new Error("No error stored at end of fallback.");throw await a?.handleChainError(l),l}let u;try{for await(let l of c){yield l;try{u=u===void 0?u:this._concatOutputChunks(u,l)}catch{u=void 0}}}catch(l){throw await a?.handleChainError(l),l}await a?.handleChainEnd(It(u,"output"))}async batch(e,t,r){if(r?.returnExceptions)throw new Error("Not implemented.");let i=this._getOptionsList(t??{},e.length),n=await Promise.all(i.map(s=>lr(s))),o=await Promise.all(n.map(async(s,c)=>{let u=await s?.handleChainStart(this.toJSON(),It(e[c],"input"),i[c].runId,void 0,void 0,void 0,i[c].runName);return delete i[c].runId,u})),a;for(let s of this.runnables()){i[0].signal?.throwIfAborted();try{let c=await s.batch(e,o.map((u,l)=>Pe(i[l],{callbacks:u?.getChild()})),r);return await Promise.all(o.map((u,l)=>u?.handleChainEnd(It(c[l],"output")))),c}catch(c){a===void 0&&(a=c)}}throw a?(await Promise.all(o.map(s=>s?.handleChainError(a))),a):new Error("No error stored at end of fallbacks.")}};function mt(e){if(typeof e=="function")return new mr({func:e});if(ue.isRunnable(e))return e;if(!Array.isArray(e)&&typeof e=="object"){let t={};for(let[r,i]of Object.entries(e))t[r]=mt(i);return new ga({steps:t})}else throw new Error(`Expected a Runnable, function or object.
246
+ Instead got an unsupported type.`)}var Jd=class extends ue{static lc_name(){return"RunnableAssign"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;mapper;constructor(e){e instanceof ga&&(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 i=this.mapper.getStepsKeys(),[n,o]=Tm(e),a=this.mapper.transform(o,Pe(r,{callbacks:t?.getChild()})),s=a.next();for await(let c of n){if(typeof c!="object"||Array.isArray(c))throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof c}`);let u=Object.fromEntries(Object.entries(c).filter(([l])=>!i.includes(l)));Object.keys(u).length>0&&(yield u)}yield(await s).value;for await(let c of a)yield c}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let i=Ae(t),n=new Xo({generator:this.transform(r(),i),config:i});return await n.setup,$t.fromAsyncGenerator(n)}},Lk=class extends ue{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 i=Ae(t),n=new Xo({generator:this.transform(r(),i),config:i});return await n.setup,$t.fromAsyncGenerator(n)}},Ag=class extends $n{name;description;schema;constructor(e){let t=un.from([mr.from(async r=>{let i;if(zo(r))try{i=await ua(this.schema,r.args)}catch{throw new Sc("Received tool input did not match expected schema",JSON.stringify(r.args))}else i=r;return i}).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 h5(e,t){let r=t.name??e.getName(),i=t.description??so(t.schema);return Tu(t.schema)?new Ag({name:r,description:i,schema:Kt.object({input:Kt.string()}).transform(n=>n.input),bound:e}):new Ag({name:r,description:i,schema:t.schema,bound:e})}var Og=(e,t)=>{let r=[...new Set(t?.map(n=>{if(typeof n=="string")return n;let o=new n({});if(!("getType"in o)||typeof o.getType!="function")throw new Error("Invalid type provided.");return o.getType()}))],i=e.getType();return r.some(n=>n===i)};function Ij(e,t){return Array.isArray(e)?xj(e,t):mr.from(r=>xj(r,e))}function xj(e,t={}){let{includeNames:r,excludeNames:i,includeTypes:n,excludeTypes:o,includeIds:a,excludeIds:s}=t,c=[];for(let u of e)if(!(i&&u.name&&i.includes(u.name))){{if(o&&Og(u,o))continue;if(s&&u.id&&s.includes(u.id))continue}n||a||r?(r&&u.name&&r.some(l=>l===u.name)||n&&Og(u,n)||a&&u.id&&a.some(l=>l===u.id))&&c.push(u):c.push(u)}return c}function Ej(e){return Array.isArray(e)?Sj(e):mr.from(Sj)}function Sj(e){if(!e.length)return[];let t=[];for(let r of e){let i=r,n=t.pop();if(!n)t.push(i);else if(i.getType()==="tool"||i.getType()!==n.getType())t.push(n,i);else{let o=Ga(n),a=Ga(i),s=o.concat(a);typeof o.content=="string"&&typeof a.content=="string"&&(s.content=`${o.content}
247
+ ${a.content}`),t.push(_5(s))}}return t}function Tj(e,t){if(Array.isArray(e)){let r=e;if(!t)throw new Error("Options parameter is required when providing messages.");return kj(r,t)}else{let r=e;return mr.from(i=>kj(i,r)).withConfig({runName:"trim_messages"})}}async function kj(e,t){let{maxTokens:r,tokenCounter:i,strategy:n="last",allowPartial:o=!1,endOn:a,startOn:s,includeSystem:c=!1,textSplitter:u}=t;if(s&&n==="first")throw new Error("`startOn` should only be specified if `strategy` is 'last'.");if(c&&n==="first")throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");let l;"getNumTokens"in i?l=async f=>(await Promise.all(f.map(p=>i.getNumTokens(p.content)))).reduce((p,m)=>p+m,0):l=async f=>i(f);let d=Fk;if(u&&("splitText"in u?d=u.splitText.bind(u):d=async f=>u(f)),n==="first")return Aj(e,{maxTokens:r,tokenCounter:l,textSplitter:d,partialStrategy:o?"first":void 0,endOn:a});if(n==="last")return g5(e,{maxTokens:r,tokenCounter:l,textSplitter:d,allowPartial:o,includeSystem:c,startOn:s,endOn:a});throw new Error(`Unrecognized strategy: '${n}'. Must be one of 'first' or 'last'.`)}async function Aj(e,t){let{maxTokens:r,tokenCounter:i,textSplitter:n,partialStrategy:o,endOn:a}=t,s=[...e],c=0;for(let u=0;u<s.length;u+=1)if(await i(u>0?s.slice(0,-u):s)<=r){c=s.length-u;break}if(c<s.length&&o){let u=!1;if(Array.isArray(s[c].content)){let l=s[c];if(typeof l.content=="string")throw new Error("Expected content to be an array.");let d=l.content.length,f=o==="last"?[...l.content].reverse():l.content;for(let p=1;p<=d;p+=1){let m=o==="first"?f.slice(0,p):f.slice(-p),h=Object.fromEntries(Object.entries(l).filter(([v])=>v!=="type"&&!v.startsWith("lc_"))),g=Uk(l.getType(),{...h,content:m}),_=[...s.slice(0,c),g];if(await i(_)<=r)s=_,c+=1,u=!0;else break}u&&o==="last"&&(l.content=[...f].reverse())}if(!u){let l=s[c],d;if(Array.isArray(l.content)&&l.content.some(f=>typeof f=="string"||f.type==="text")?d=l.content.find(f=>f.type==="text"&&f.text)?.text:typeof l.content=="string"&&(d=l.content),d){let f=await n(d),p=f.length;o==="last"&&f.reverse();for(let m=0;m<p-1;m+=1)if(f.pop(),l.content=f.join(""),await i([...s.slice(0,c),l])<=r){o==="last"&&(l.content=[...f].reverse().join("")),s=[...s.slice(0,c),l],c+=1;break}}}}if(a){let u=Array.isArray(a)?a:[a];for(;c>0&&!Og(s[c-1],u);)c-=1}return s.slice(0,c)}async function g5(e,t){let{allowPartial:r=!1,includeSystem:i=!1,endOn:n,startOn:o,...a}=t,s=e.map(l=>{let d=Object.fromEntries(Object.entries(l).filter(([f])=>f!=="type"&&!f.startsWith("lc_")));return Uk(l.getType(),d,Hi(l))});if(n){let l=Array.isArray(n)?n:[n];for(;s.length>0&&!Og(s[s.length-1],l);)s=s.slice(0,-1)}let c=i&&s[0]?.getType()==="system",u=c?s.slice(0,1).concat(s.slice(1).reverse()):s.reverse();return u=await Aj(u,{...a,partialStrategy:r?"last":void 0,endOn:o}),c?[u[0],...u.slice(1).reverse()]:u.reverse()}var $j={human:{message:ht,messageChunk:Za},ai:{message:Le,messageChunk:nt},system:{message:xr,messageChunk:Zi},developer:{message:xr,messageChunk:Zi},tool:{message:Pt,messageChunk:xc},function:{message:Va,messageChunk:Ha},generic:{message:Dn,messageChunk:Ba},remove:{message:tn,messageChunk:tn}};function Uk(e,t,r){let i,n;switch(e){case"human":r?i=new Za(t):n=new ht(t);break;case"ai":if(r){let o={...t};"tool_calls"in o&&(o={...o,tool_call_chunks:o.tool_calls?.map(a=>({...a,type:"tool_call_chunk",index:void 0,args:JSON.stringify(a.args)}))}),i=new nt(o)}else n=new Le(t);break;case"system":r?i=new Zi(t):n=new xr(t);break;case"developer":r?i=new Zi({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}}):n=new xr({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}});break;case"tool":if("tool_call_id"in t)r?i=new xc(t):n=new Pt(t);else throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");break;case"function":if(r)i=new Ha(t);else{if(!t.name)throw new Error("FunctionMessage must have a 'name' field");n=new Va(t)}break;case"generic":if("role"in t)r?i=new Ba(t):n=new Dn(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&&i)return i;if(n)return n;throw new Error(`Unrecognized message type ${e}`)}function _5(e){let t=e.getType(),r,i=Object.fromEntries(Object.entries(e).filter(([n])=>!["type","tool_call_chunks"].includes(n)&&!n.startsWith("lc_")));if(t in $j&&(r=Uk(t,i)),!r)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys($j)}`);return r}function Fk(e){let t=e.split(`
248
+ `);return Promise.resolve([...t.slice(0,-1).map(r=>`${r}
249
+ `),t[t.length-1]])}var Cj=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"];var Oj=["image","video","audio","text-plain","file"];var Pj=["text","reasoning",...Cj,...Oj];var Nj=C({AIMessage:()=>Le,AIMessageChunk:()=>nt,BaseMessage:()=>ze,BaseMessageChunk:()=>Vt,ChatMessage:()=>Dn,ChatMessageChunk:()=>Ba,DEFAULT_MERGE_IGNORE_KEYS:()=>qy,FunctionMessage:()=>Va,FunctionMessageChunk:()=>Ha,HumanMessage:()=>ht,HumanMessageChunk:()=>Za,KNOWN_BLOCK_TYPES:()=>Pj,RemoveMessage:()=>tn,SystemMessage:()=>xr,SystemMessageChunk:()=>Zi,ToolMessage:()=>Pt,ToolMessageChunk:()=>xc,_isMessageFieldWithRole:()=>Op,_mergeDicts:()=>ut,_mergeLists:()=>Mo,_mergeObj:()=>Cp,_mergeStatus:()=>Ap,coerceMessageLikeToMessage:()=>Nt,collapseToolCallChunks:()=>Np,convertToChunk:()=>Ga,convertToOpenAIImageBlock:()=>$p,convertToProviderContentBlock:()=>KT,defaultTextSplitter:()=>Fk,defaultToolCallParser:()=>Cl,filterMessages:()=>Ij,getBufferString:()=>Ic,iife:()=>VA,isAIMessage:()=>$c,isAIMessageChunk:()=>NA,isBase64ContentBlock:()=>wc,isBaseMessage:()=>lt,isBaseMessageChunk:()=>Hi,isChatMessage:()=>jA,isChatMessageChunk:()=>DA,isDataContentBlock:()=>ui,isDirectToolOutput:()=>Al,isFunctionMessage:()=>MA,isFunctionMessageChunk:()=>zA,isHumanMessage:()=>LA,isHumanMessageChunk:()=>UA,isIDContentBlock:()=>kp,isMessage:()=>Tp,isOpenAIToolCallArray:()=>uA,isPlainTextContentBlock:()=>ZT,isSystemMessage:()=>FA,isSystemMessageChunk:()=>BA,isToolMessage:()=>Ol,isToolMessageChunk:()=>Jy,isURLContentBlock:()=>bc,mapChatMessagesToStoredMessages:()=>ZA,mapStoredMessageToChatMessage:()=>Pl,mapStoredMessagesToChatMessages:()=>HA,mergeContent:()=>or,mergeMessageRuns:()=>Ej,mergeResponseMetadata:()=>Pp,mergeUsageMetadata:()=>kc,parseBase64DataUrl:()=>Tl,parseMimeType:()=>GT,trimMessages:()=>Tj});var Rj=C({BaseChatMessageHistory:()=>Bk,BaseListChatMessageHistory:()=>Pg,InMemoryChatMessageHistory:()=>y5}),Bk=class extends xt{async addMessages(e){for(let t of e)await this.addMessage(t)}},Pg=class extends xt{addUserMessage(e){return this.addMessage(new ht(e))}addAIMessage(e){return this.addMessage(new Le(e))}async addMessages(e){for(let t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}},y5=class extends Pg{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 ln=class{pageContent;metadata;id;constructor(e){this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};var Vk=class extends ue{lc_namespace=["langchain_core","documents","transformers"];invoke(e,t){return this.transformDocuments(e)}},jj=class extends Vk{async transformDocuments(e){let t=[];for(let r of e){let i=await this._transformDocument(r);t.push(i)}return t}};var Dj=C({BaseDocumentTransformer:()=>Vk,Document:()=>ln,MappingDocumentTransformer:()=>jj});var Mj=C({BaseDocumentLoader:()=>Hk}),Hk=class{};var zj=C({LangSmithLoader:()=>v5}),v5=class extends Hk{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 fi(e?.clientConfig),this.contentKey=e.contentKey?e.contentKey.split("."):[],this.formatContent=e.formatContent??b5,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 o of this.contentKey)r=r[o];let i=this.formatContent(r),n=t;["created_at","modified_at"].forEach(o=>{o in n&&typeof n[o]=="object"&&(n[o]=n[o].toString())}),e.push({pageContent:i,metadata:n})}return e}};function b5(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}var Lj=C({Embeddings:()=>Ng}),Ng=class{caller;constructor(e){this.caller=new eo(e??{})}};var Lu=class extends xt{lc_namespace=["langchain_core","example_selectors","base"]};var Zk=class{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}},Uj=class extends Zk{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 Fj(e){return e._modelType()==="base_llm"}function Bj(e){return e._modelType()==="base_chat_model"}function Vj(e){return e.split(/\n| /).length}var Hj=class Zj extends Lu{examples=[];examplePrompt;getTextLength=Vj;maxLength=2048;exampleTextLengths=[];constructor(t){super(t),this.examplePrompt=t.examplePrompt,this.maxLength=t.maxLength??2048,this.getTextLength=t.getTextLength??Vj}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:i,examplePrompt:n}=r;return(await Promise.all(i.map(o=>n.format(o)))).map(o=>this.getTextLength(o))}async selectExamples(t){let r=Object.values(t).join(" "),i=this.maxLength-this.getTextLength(r),n=0,o=[];for(;i>0&&n<this.examples.length;){let a=i-this.exampleTextLengths[n];if(a<0)break;o.push(this.examples[n]),i=a,n+=1}return o}static async fromExamples(t,r){let i=new Zj(r);return await Promise.all(t.map(n=>i.addExample(n))),i}};function Gk(e){return Object.keys(e).sort().map(t=>e[t])}var Gj=class Kj extends Lu{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=Gk((this.inputKeys??Object.keys(t)).reduce((i,n)=>({...i,[n]:t[n]}),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new ln({pageContent:r,metadata:t})])}async selectExamples(t){let r=Gk((this.inputKeys??Object.keys(t)).reduce((n,o)=>({...n,[o]:t[o]}),{})).join(" "),i=(await this.vectorStoreRetriever.invoke(r)).map(n=>n.metadata);return this.exampleKeys?i.map(n=>this.exampleKeys.reduce((o,a)=>({...o,[a]:n[a]}),{})):i}static async fromExamples(t,r,i,n={}){let o=n.inputKeys??null,a=t.map(c=>Gk(o?o.reduce((u,l)=>({...u,[l]:c[l]}),{}):c).join(" ")),s=await i.fromTexts(a,t,r,n);return new Kj({vectorStore:s,k:n.k??4,exampleKeys:n.exampleKeys,inputKeys:n.inputKeys})}};var Wj=C({BaseExampleSelector:()=>Lu,BasePromptSelector:()=>Zk,ConditionalPromptSelector:()=>Uj,LengthBasedExampleSelector:()=>Hj,SemanticSimilarityExampleSelector:()=>Gj,isChatModel:()=>Bj,isLLM:()=>Fj});var Xd="10f90ea3-90a4-4962-bf75-83a0f3c1c62a",qj=class extends xt{lc_namespace=["langchain","recordmanagers"]};var Kk=class{uid;hash_;contentHash;metadataHash;pageContent;metadata;keyEncoder=vc;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 ln({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){let t=this.keyEncoder(e);return hc(t,Xd)}_hashNestedDictToUUID(e){let t=JSON.stringify(e,Object.keys(e).sort()),r=this.keyEncoder(t);return hc(r,Xd)}};function Wk(e,t){let r=[],i=[];return t.forEach(n=>{i.push(n),i.length>=e&&(r.push(i),i=[])}),i.length>0&&r.push(i),r}function qk(e){let t=new Set,r=[];for(let i of e){if(!i.hash_)throw new Error("Hashed document does not have a hash");t.has(i.hash_)||(t.add(i.hash_),r.push(i))}return r}function Jk(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 Xk=e=>"load"in e&&typeof e.load=="function"&&"loadAndSplit"in e&&typeof e.loadAndSplit=="function";async function Jj(e){let{docsSource:t,recordManager:r,vectorStore:i,options:n}=e,{batchSize:o=100,cleanup:a,sourceIdKey:s,cleanupBatchSize:c=1e3,forceUpdate:u=!1}=n??{};if(a==="incremental"&&!s)throw new Error("sourceIdKey is required when cleanup mode is incremental. Please provide through 'options.sourceIdKey'.");let l=Xk(t)?await t.load():t,d=Jk(s??null),f=await r.getTime(),p=0,m=0,h=0,g=0,_=Wk(o??100,l);for(let v of _){let x=qk(v.map(j=>Kk.fromDocument(j))),S=x.map(j=>d(j));a==="incremental"&&x.forEach((j,H)=>{if(S[H]===null)throw new Error("sourceIdKey must be provided when cleanup is incremental")});let k=await r.exists(x.map(j=>j.uid)),T=[],A=[],b=[],z=new Set;if(x.forEach((j,H)=>{if(k[H])if(u)z.add(j.uid);else{b.push(j.uid);return}T.push(j.uid),A.push(j.toDocument())}),b.length>0&&(await r.update(b,{timeAtLeast:f}),g+=b.length),A.length>0&&(await i.addDocuments(A,{ids:T}),p+=A.length-z.size,h+=z.size),await r.update(x.map(j=>j.uid),{timeAtLeast:f,groupIds:S}),a==="incremental"){S.forEach(H=>{if(!H)throw new Error("Source id cannot be null")});let j=await r.listKeys({before:f,groupIds:S});j.length>0&&(await i.delete({ids:j}),await r.deleteKeys(j),m+=j.length)}}if(a==="full"){let v=await r.listKeys({before:f,limit:c});for(;v.length>0;)await i.delete({ids:v}),await r.deleteKeys(v),m+=v.length,v=await r.listKeys({before:f,limit:c})}return{numAdded:p,numDeleted:m,numUpdated:h,numSkipped:g}}var Xj=C({RecordManager:()=>qj,UUIDV5_NAMESPACE:()=>Xd,_HashedDocument:()=>Kk,_batch:()=>Wk,_deduplicateInOrder:()=>qk,_getSourceIdAssigner:()=>Jk,_isBaseDocumentLoader:()=>Xk,index:()=>Jj});var Yj=C({BasePromptValue:()=>Rg,ChatPromptValue:()=>Qd,ImagePromptValue:()=>Yk,StringPromptValue:()=>Yd}),Rg=class extends xt{},Yd=class extends Rg{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 ht(this.value)]}},Qd=class extends Rg{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 Ic(this.messages)}toChatMessages(){return this.messages}},Yk=class extends Rg{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 ht({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}};var rD=tp(tD(),1),T5=Object.defineProperty,A5=(e,t,r)=>t in e?T5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,C5=(e,t,r)=>(A5(e,typeof t!="symbol"?t+"":t,r),r);function O5(e,t){let r=Array.from({length:e.length},(i,n)=>({start:n,end:n+1}));for(;r.length>1;){let i=null;for(let n=0;n<r.length-1;n++){let o=e.slice(r[n].start,r[n+1].end),a=t.get(o.join(","));a!=null&&(i==null||a<i[0])&&(i=[a,n])}if(i!=null){let n=i[1];r[n]={start:r[n].start,end:r[n+1].end},r.splice(n+1,1)}else break}return r}function P5(e,t){return e.length===1?[t.get(e.join(","))]:O5(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(r=>r!=null)}function N5(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var e$=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(`
250
+ `).filter(Boolean).reduce((i,n)=>{let[o,a,...s]=n.split(" "),c=Number.parseInt(a,10);return s.forEach((u,l)=>i[u]=c+l),i},{});for(let[i,n]of Object.entries(r)){let o=rD.default.toByteArray(i);this.rankMap.set(o.join(","),n),this.textMap.set(n,o)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((i,[n,o])=>(i[o]=this.textEncoder.encode(n),i),{})}encode(e,t=[],r="all"){let i=new RegExp(this.patStr,"ug"),n=e$.specialTokenRegex(Object.keys(this.specialTokens)),o=[],a=new Set(t==="all"?Object.keys(this.specialTokens):t),s=new Set(r==="all"?Object.keys(this.specialTokens).filter(u=>!a.has(u)):r);if(s.size>0){let u=e$.specialTokenRegex([...s]),l=e.match(u);if(l!=null)throw new Error(`The text contains a special token that is not allowed: ${l[0]}`)}let c=0;for(;;){let u=null,l=c;for(;n.lastIndex=l,u=n.exec(e),!(u==null||a.has(u[0]));)l=u.index+1;let d=u?.index??e.length;for(let p of e.substring(c,d).matchAll(i)){let m=this.textEncoder.encode(p[0]),h=this.rankMap.get(m.join(","));if(h!=null){o.push(h);continue}o.push(...P5(m,this.rankMap))}if(u==null)break;let f=this.specialTokens[u[0]];o.push(f),c=u.index+u[0].length}return o}decode(e){let t=[],r=0;for(let o=0;o<e.length;++o){let a=e[o],s=this.textMap.get(a)??this.inverseSpecialTokens[a];s!=null&&(t.push(s),r+=s.length)}let i=new Uint8Array(r),n=0;for(let o of t)i.set(o,n),n+=o.length;return this.textDecoder.decode(i)}},Dg=e$;C5(Dg,"specialTokenRegex",e=>new RegExp(e.map(t=>N5(t)).join("|"),"g"));function t$(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 nD=C({encodingForModel:()=>zg,getEncoding:()=>iD}),Mg={},R5=new eo({});async function iD(e){return e in Mg||(Mg[e]=R5.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(t=>t.json()).then(t=>new Dg(t)).catch(t=>{throw delete Mg[e],t})),await Mg[e]}async function zg(e){return iD(t$(e))}var oD=C({BaseLangChain:()=>Ug,BaseLanguageModel:()=>ef,calculateMaxTokens:()=>M5,getEmbeddingContextSize:()=>j5,getModelContextSize:()=>aD,getModelNameForTiktoken:()=>Lg,isOpenAITool:()=>D5}),Lg=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,j5=e=>e==="text-embedding-ada-002"?8191:2046,aD=e=>{switch(Lg(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 D5(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 M5=async({prompt:e,modelName:t})=>{let r;try{r=(await zg(Lg(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 aD(t)-r},z5=()=>!1,Ug=class extends ue{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??z5(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{},this._addVersion("@langchain/core","1.2.11")}_addVersion(e,t){let r=this.metadata?.versions;this.metadata={...this.metadata,versions:{...typeof r=="object"&&r!==null?r:{},[e]:t}}}},ef=class extends Ug{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:t,...r}){let{cache:i,...n}=r;super({callbacks:e??t,...n}),typeof i=="object"?this.cache=i:i?this.cache=ev.global():this.cache=void 0,this.caller=new eo(r??{})}_encoding;async getNumTokens(e){let t;typeof e=="string"?t=e:t=e.map(i=>typeof i=="string"?i:i.type==="text"&&"text"in i?i.text:"").join("");let r=Math.ceil(t.length/4);if(!this._encoding)try{this._encoding=await zg("modelName"in this?Lg(this.modelName):"gpt2")}catch(i){console.warn("Failed to calculate number of tokens, falling back to approximate count",i)}if(this._encoding)try{r=this._encoding.encode(t).length}catch(i){console.warn("Failed to calculate number of tokens, falling back to approximate count",i)}return r}static _convertInputToPromptValue(e){return typeof e=="string"?new Yd(e):Array.isArray(e)?new Qd(e.map(Nt)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){let r={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()};return Object.entries(r).filter(([i,n])=>n!==void 0).map(([i,n])=>`${i}:${JSON.stringify(n)}`).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:i,response_format:n,...o}=e;return o}};var po=class extends ue{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=Ae(t);return this.func&&await this.func(e,r),this._callWithConfig(i=>Promise.resolve(i),e,r)}async*transform(e,t){let r=Ae(t),i,n=!0;for await(let o of this._transformStreamWithConfig(e,a=>a,r))if(yield o,n)if(i===void 0)i=o;else try{i=nn(i,o)}catch{i=void 0,n=!1}this.func&&i!==void 0&&await this.func(i,r)}static assign(e){return new Jd(new ga({steps:e}))}};var sD=class extends ue{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:i}=e,n=this.runnables[r];if(n===void 0)throw new Error(`No runnable associated with key "${r}".`);return n.invoke(i,Ae(t))}async batch(e,t,r){let i=e.map(l=>l.key),n=e.map(l=>l.input);if(i.find(l=>this.runnables[l]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");let o=i.map(l=>this.runnables[l]),a=this._getOptionsList(t??{},e.length),s=a[0]?.maxConcurrency??r?.maxConcurrency,c=s&&s>0?s:e.length,u=[];for(let l=0;l<n.length;l+=c){let d=n.slice(l,l+c).map((p,m)=>o[m].invoke(p,a[m])),f=await Promise.all(d);u.push(f)}return u.flat()}async stream(e,t){let{key:r,input:i}=e,n=this.runnables[r];if(n===void 0)throw new Error(`No runnable associated with key "${r}".`);return n.stream(i,t)}};var cD=class extends ue{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(([i,n])=>[mt(i),mt(n)]),r=mt(e[e.length-1]);return new this({branches:t,default:r})}async _invoke(e,t,r){let i;for(let n=0;n<this.branches.length;n+=1){let[o,a]=this.branches[n];if(await o.invoke(e,Pe(t,{callbacks:r?.getChild(`condition:${n+1}`)}))){i=await a.invoke(e,Pe(t,{callbacks:r?.getChild(`branch:${n+1}`)}));break}}return i||(i=await this.default.invoke(e,Pe(t,{callbacks:r?.getChild("branch:default")}))),i}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){let r=await(await lr(t))?.handleChainStart(this.toJSON(),It(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName),i,n=!0,o;try{for(let a=0;a<this.branches.length;a+=1){let[s,c]=this.branches[a];if(await s.invoke(e,Pe(t,{callbacks:r?.getChild(`condition:${a+1}`)}))){o=await c.stream(e,Pe(t,{callbacks:r?.getChild(`branch:${a+1}`)}));for await(let u of o)if(yield u,n)if(i===void 0)i=u;else try{i=nn(i,u)}catch{i=void 0,n=!1}break}}if(o===void 0){o=await this.default.stream(e,Pe(t,{callbacks:r?.getChild("branch:default")}));for await(let a of o)if(yield a,n)if(i===void 0)i=a;else try{i=nn(i,a)}catch{i=void 0,n=!1}}}catch(a){throw await r?.handleChainError(a),a}await r?.handleChainEnd(i??{})}};var uD=class extends $n{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let t=mr.from((o,a)=>this._enterHistory(o,a??{})).withConfig({runName:"loadHistory"}),r=e.historyMessagesKey??e.inputMessagesKey;r&&(t=po.assign({[r]:t}).withConfig({runName:"insertHistory"}));let i=t.pipe(e.runnable.withListeners({onEnd:(o,a)=>this._exitHistory(o,a??{})})).withConfig({runName:"RunnableWithMessageHistory"}),n=e.config??{};super({...e,config:n,bound:i}),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)&&!lt(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 ht(t)];if(Array.isArray(t))return t;if(lt(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
251
+ Got ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(!Array.isArray(e)&&!lt(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 Le(t)];if(Array.isArray(t))return t;if(lt(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,i;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?i=e.inputs[0]:i=e.inputs;let n=this._getInputMessages(i);if(this.historyMessagesKey===void 0){let s=await r.getMessages();n=n.slice(s.length)}let o=e.outputs;if(!o)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);let a=this._getOutputMessages(o);await r.addMessages([...n,...a])}async _mergeConfig(...e){let t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){let i={[this.inputMessagesKey??"input"]:"foo"};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
252
+ eg. chain.invoke(${JSON.stringify(i)}, ${JSON.stringify({configurable:{sessionId:"123"}})})`)}let{sessionId:r}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(r),t}};var lD=C({RouterRunnable:()=>sD,Runnable:()=>ue,RunnableAssign:()=>Jd,RunnableBinding:()=>$n,RunnableBranch:()=>cD,RunnableEach:()=>gj,RunnableLambda:()=>mr,RunnableMap:()=>ga,RunnableParallel:()=>wj,RunnablePassthrough:()=>po,RunnablePick:()=>Lk,RunnableRetry:()=>Cg,RunnableSequence:()=>un,RunnableToolLike:()=>Ag,RunnableWithFallbacks:()=>zk,RunnableWithMessageHistory:()=>uD,_coerceToRunnable:()=>mt,ensureConfig:()=>Ae,getCallbackManagerForConfig:()=>lr,mergeConfigs:()=>jt,patchConfig:()=>Pe,pickRunnableConfigKeys:()=>Lr,raceWithSignal:()=>rn});var dD=C({applyPatch:()=>Xi,compare:()=>Yi});var Uu=class extends ue{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,i)=>this.parseResult([{text:r}],i?.callbacks),e,{...t,runType:"parser"}):this._callWithConfig(async(r,i)=>this.parseResult([{message:r,text:this._baseMessageToString(r)}],i?.callbacks),e,{...t,runType:"parser"})}},Zn=class extends Uu{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")}},hr=class extends Error{llmOutput;observation;sendToLLM;constructor(e,t,r,i=!1){if(super(e),this.llmOutput=t,this.observation=r,this.sendToLLM=i,i&&(r===void 0||t===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");Bi(this,"OUTPUT_PARSING_FAILURE")}};var mo=class extends Zn{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"})}},Ai=class extends mo{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let t,r;for await(let i of e){if(typeof i!="string"&&typeof i.content!="string")throw new Error("Cannot handle non-string output.");let n;if(Hi(i)){if(typeof i.content!="string")throw new Error("Cannot handle non-string message output.");n=new Qo({message:i,text:i.content})}else if(lt(i)){if(typeof i.content!="string")throw new Error("Cannot handle non-string message output.");n=new Qo({message:Ga(i),text:i.content})}else n=new Qi({text:i});r===void 0?r=n:r=r.concat(n);let o=await this.parsePartialResult([r]);o!=null&&!Ii(o,t)&&(this.diff?yield this._diff(t,o):yield o,t=o)}}getFormatInstructions(){return""}};var fD=class extends mo{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 Fu=class extends mo{re;async*_transform(e){let t="";for await(let r of e)if(typeof r=="string"?t+=r:t+=r.content,this.re){let i=[...t.matchAll(this.re)];if(i.length>1){let n=0;for(let o of i.slice(0,-1))yield[o[1]],n+=(o.index??0)+o[0].length;t=t.slice(n)}}else{let i=await this.parse(t);if(i.length>1){for(let n of i.slice(0,-1))yield[n];t=i[i.length-1]}}for(let r of await this.parse(t))yield[r]}},pD=class extends Fu{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 hr(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},mD=class extends Fu{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 hr(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){throw Object.getPrototypeOf(t)===hr.prototype?t:new hr(`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\`)`}},hD=class extends Fu{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:
253
+
254
+ 1. foo
255
+
256
+ 2. bar
257
+
258
+ 3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},gD=class extends Fu{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:
259
+
260
+ 1. foo
261
+
262
+ 2. bar
263
+
264
+ 3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}};var _D=class extends mo{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 Fg=class extends Ai{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?Yi(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return Fa(e[0].text)}async parse(e){return Fa(e,JSON.parse)}getFormatInstructions(){return""}_baseMessageToString(e){return e.text}};var Bg=class extends Zn{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=Fa(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 hr(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}getFormatInstructions(){return""}};var tf=class extends Zn{schema;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=Kt.object(Object.fromEntries(Object.entries(e).map(([r,i])=>[r,Kt.string().describe(i)])));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.
265
+
266
+ "JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
267
+
268
+ For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
269
+ 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.
270
+ 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.
271
+
272
+ 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!
273
+
274
+ Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
275
+ \`\`\`json
276
+ ${JSON.stringify(zt(this.schema))}
277
+ \`\`\`
278
+ `}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,(i,n)=>`"${n.replace(/\n/g,"\\n")}"`).replace(/\n/g,"");return await ua(this.schema,JSON.parse(r))}catch(t){throw new hr(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}},r$=class extends tf{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:
279
+ \`\`\`json
280
+ ${this._schemaToInstruction(zt(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}
281
+ \`\`\``}_schemaToInstruction(e,t=2){let r=e;if("type"in r){let i=!1,n;if(Array.isArray(r.type)){let s=r.type.findIndex(c=>c==="null");s!==-1&&(i=!0,r.type.splice(s,1)),n=r.type.join(" | ")}else n=r.type;if(r.type==="object"&&r.properties){let s=r.description?` // ${r.description}`:"";return`{
282
+ ${Object.entries(r.properties).map(([c,u])=>{let l=r.required?.includes(c)?"":" (optional)";return`${" ".repeat(t)}"${c}": ${this._schemaToInstruction(u,t+2)}${l}`}).join(`
283
+ `)}
284
+ ${" ".repeat(t-2)}}${s}`}if(r.type==="array"&&r.items){let s=r.description?` // ${r.description}`:"";return`array[
285
+ ${" ".repeat(t)}${this._schemaToInstruction(r.items,t+2)}
286
+ ${" ".repeat(t-2)}] ${s}`}let o=i?" (nullable)":"",a=r.description?` // ${r.description}`:"";return`${n}${a}${o}`}if("anyOf"in r)return r.anyOf.map(i=>this._schemaToInstruction(i,t)).join(`
287
+ ${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=Kt.object(Object.fromEntries(Object.entries(e).map(([r,i])=>[r,Kt.string().describe(i)])));return new this(t)}},yD=class extends Zn{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new r$(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(r){throw new hr(`Failed to parse. Text: "${e}". Error: ${r}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}};var L5=function(){let e={};e.parser=function(w,y){return new r(w,y)},e.SAXParser=r,e.SAXStream=u,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(w,y){if(!(this instanceof r))return new r(w,y);var D=this;n(D),D.q=D.c="",D.bufferCheckPosition=e.MAX_BUFFER_LENGTH,D.opt=y||{},D.opt.lowercase=D.opt.lowercase||D.opt.lowercasetags,D.looseCase=D.opt.lowercase?"toLowerCase":"toUpperCase",D.tags=[],D.closed=D.closedRoot=D.sawRoot=!1,D.tag=D.error=null,D.strict=!!w,D.noscript=!!(w||D.opt.noscript),D.state=b.BEGIN,D.strictEntities=D.opt.strictEntities,D.ENTITIES=D.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),D.attribList=[],D.opt.xmlns&&(D.ns=Object.create(m)),D.trackPosition=D.opt.position!==!1,D.trackPosition&&(D.position=D.line=D.column=0),j(D,"onready")}Object.create||(Object.create=function(w){function y(){}return y.prototype=w,new y}),Object.keys||(Object.keys=function(w){var y=[];for(var D in w)w.hasOwnProperty(D)&&y.push(D);return y});function i(w){for(var y=Math.max(e.MAX_BUFFER_LENGTH,10),D=0,E=0,De=t.length;E<De;E++){var We=w[t[E]].length;if(We>y)switch(t[E]){case"textNode":ne(w);break;case"cdata":H(w,"oncdata",w.cdata),w.cdata="";break;case"script":H(w,"onscript",w.script),w.script="";break;default:Ce(w,"Max buffer length exceeded: "+t[E])}D=Math.max(D,We)}w.bufferCheckPosition=e.MAX_BUFFER_LENGTH-D+w.position}function n(w){for(var y=0,D=t.length;y<D;y++)w[t[y]]=""}function o(w){ne(w),w.cdata!==""&&(H(w,"oncdata",w.cdata),w.cdata=""),w.script!==""&&(H(w,"onscript",w.script),w.script="")}r.prototype={end:function(){pt(this)},write:On,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){o(this)}};var a=ReadableStream;a||(a=function(){});var s=e.EVENTS.filter(function(w){return w!=="error"&&w!=="end"});function c(w,y){return new u(w,y)}function u(w,y){if(!(this instanceof u))return new u(w,y);a.apply(this),this._parser=new r(w,y),this.writable=!0,this.readable=!0;var D=this;this._parser.onend=function(){D.emit("end")},this._parser.onerror=function(E){D.emit("error",E),D._parser.error=null},this._decoder=null,s.forEach(function(E){Object.defineProperty(D,"on"+E,{get:function(){return D._parser["on"+E]},set:function(De){if(!De)return D.removeAllListeners(E),D._parser["on"+E]=De,De;D.on(E,De)},enumerable:!0,configurable:!1})})}u.prototype=Object.create(a.prototype,{constructor:{value:u}}),u.prototype.write=function(w){return this._parser.write(w.toString()),this.emit("data",w),!0},u.prototype.end=function(w){return w&&w.length&&this.write(w),this._parser.end(),!0},u.prototype.on=function(w,y){var D=this;return!D._parser["on"+w]&&s.indexOf(w)!==-1&&(D._parser["on"+w]=function(){var E=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);E.splice(0,0,w),D.emit.apply(D,E)}),a.prototype.on.call(D,w,y)};var l="[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]/,g=/[:_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-]/,_=/[#:_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]/,v=/[#:_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(w){return w===" "||w===`
288
+ `||w==="\r"||w===" "}function S(w){return w==='"'||w==="'"}function k(w){return w===">"||x(w)}function T(w,y){return w.test(y)}function A(w,y){return!T(w,y)}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(w){var y=e.ENTITIES[w],D=typeof y=="number"?String.fromCharCode(y):y;e.ENTITIES[w]=D});for(var z in e.STATE)e.STATE[e.STATE[z]]=z;b=e.STATE;function j(w,y,D){w[y]&&w[y](D)}function H(w,y,D){w.textNode&&ne(w),j(w,y,D)}function ne(w){w.textNode=ye(w.opt,w.textNode),w.textNode&&j(w,"ontext",w.textNode),w.textNode=""}function ye(w,y){return w.trim&&(y=y.trim()),w.normalize&&(y=y.replace(/\s+/g," ")),y}function Ce(w,y){return ne(w),w.trackPosition&&(y+=`
289
+ Line: `+w.line+`
290
+ Column: `+w.column+`
291
+ Char: `+w.c),y=new Error(y),w.error=y,j(w,"onerror",y),w}function pt(w){return w.sawRoot&&!w.closedRoot&&xe(w,"Unclosed root tag"),w.state!==b.BEGIN&&w.state!==b.BEGIN_WHITESPACE&&w.state!==b.TEXT&&Ce(w,"Unexpected end"),ne(w),w.c="",w.closed=!0,j(w,"onend"),r.call(w,w.strict,w.opt),w}function xe(w,y){if(typeof w!="object"||!(w instanceof r))throw new Error("bad call to strictFail");w.strict&&Ce(w,y)}function V(w){w.strict||(w.tagName=w.tagName[w.looseCase]());var y=w.tags[w.tags.length-1]||w,D=w.tag={name:w.tagName,attributes:{}};w.opt.xmlns&&(D.ns=y.ns),w.attribList.length=0,H(w,"onopentagstart",D)}function ee(w,y){var D=w.indexOf(":")<0?["",w]:w.split(":"),E=D[0],De=D[1];return y&&w==="xmlns"&&(E="xmlns",De=""),{prefix:E,local:De}}function oe(w){if(w.strict||(w.attribName=w.attribName[w.looseCase]()),w.attribList.indexOf(w.attribName)!==-1||w.tag.attributes.hasOwnProperty(w.attribName)){w.attribName=w.attribValue="";return}if(w.opt.xmlns){var y=ee(w.attribName,!0),D=y.prefix,E=y.local;if(D==="xmlns")if(E==="xml"&&w.attribValue!==f)xe(w,"xml: prefix must be bound to "+f+`
292
+ Actual: `+w.attribValue);else if(E==="xmlns"&&w.attribValue!==p)xe(w,"xmlns: prefix must be bound to "+p+`
293
+ Actual: `+w.attribValue);else{var De=w.tag,We=w.tags[w.tags.length-1]||w;De.ns===We.ns&&(De.ns=Object.create(We.ns)),De.ns[E]=w.attribValue}w.attribList.push([w.attribName,w.attribValue])}else w.tag.attributes[w.attribName]=w.attribValue,H(w,"onattribute",{name:w.attribName,value:w.attribValue});w.attribName=w.attribValue=""}function ae(w,y){if(w.opt.xmlns){var D=w.tag,E=ee(w.tagName);D.prefix=E.prefix,D.local=E.local,D.uri=D.ns[E.prefix]||"",D.prefix&&!D.uri&&(xe(w,"Unbound namespace prefix: "+JSON.stringify(w.tagName)),D.uri=E.prefix);var De=w.tags[w.tags.length-1]||w;D.ns&&De.ns!==D.ns&&Object.keys(D.ns).forEach(function(Oa){H(w,"onopennamespace",{prefix:Oa,uri:D.ns[Oa]})});for(var We=0,At=w.attribList.length;We<At;We++){var bt=w.attribList[We],rr=bt[0],dn=bt[1],wt=ee(rr,!0),ri=wt.prefix,pc=wt.local,ep=ri===""?"":D.ns[ri]||"",q={name:rr,value:dn,prefix:ri,local:pc,uri:ep};ri&&ri!=="xmlns"&&!ep&&(xe(w,"Unbound namespace prefix: "+JSON.stringify(ri)),q.uri=ri),w.tag.attributes[rr]=q,H(w,"onattribute",q)}w.attribList.length=0}w.tag.isSelfClosing=!!y,w.sawRoot=!0,w.tags.push(w.tag),H(w,"onopentag",w.tag),y||(!w.noscript&&w.tagName.toLowerCase()==="script"?w.state=b.SCRIPT:w.state=b.TEXT,w.tag=null,w.tagName=""),w.attribName=w.attribValue="",w.attribList.length=0}function je(w){if(!w.tagName){xe(w,"Weird empty close tag."),w.textNode+="</>",w.state=b.TEXT;return}if(w.script){if(w.tagName!=="script"){w.script+="</"+w.tagName+">",w.tagName="",w.state=b.SCRIPT;return}H(w,"onscript",w.script),w.script=""}var y=w.tags.length,D=w.tagName;w.strict||(D=D[w.looseCase]());for(var E=D;y--&&w.tags[y].name!==E;)xe(w,"Unexpected close tag");if(y<0){xe(w,"Unmatched closing tag: "+w.tagName),w.textNode+="</"+w.tagName+">",w.state=b.TEXT;return}w.tagName=D;for(var De=w.tags.length;De-- >y;){var We=w.tag=w.tags.pop();w.tagName=w.tag.name,H(w,"onclosetag",w.tagName);var At={};for(var bt in We.ns)At[bt]=We.ns[bt];var rr=w.tags[w.tags.length-1]||w;w.opt.xmlns&&We.ns!==rr.ns&&Object.keys(We.ns).forEach(function(dn){var wt=We.ns[dn];H(w,"onclosenamespace",{prefix:dn,uri:wt})})}y===0&&(w.closedRoot=!0),w.tagName=w.attribValue=w.attribName="",w.attribList.length=0,w.state=b.TEXT}function Jr(w){var y=w.entity,D=y.toLowerCase(),E,De="";return w.ENTITIES[y]?w.ENTITIES[y]:w.ENTITIES[D]?w.ENTITIES[D]:(y=D,y.charAt(0)==="#"&&(y.charAt(1)==="x"?(y=y.slice(2),E=parseInt(y,16),De=E.toString(16)):(y=y.slice(1),E=parseInt(y,10),De=E.toString(10))),y=y.replace(/^0+/,""),isNaN(E)||De.toLowerCase()!==y?(xe(w,"Invalid character entity"),"&"+w.entity+";"):String.fromCodePoint(E))}function $o(w,y){y==="<"?(w.state=b.OPEN_WAKA,w.startTagPosition=w.position):x(y)||(xe(w,"Non-whitespace before first tag."),w.textNode=y,w.state=b.TEXT)}function Io(w,y){var D="";return y<w.length&&(D=w.charAt(y)),D}function On(w){var y=this;if(this.error)throw this.error;if(y.closed)return Ce(y,"Cannot write after close. Assign an onready handler.");if(w===null)return pt(y);typeof w=="object"&&(w=w.toString());for(var D=0,E="";E=Io(w,D++),y.c=E,!!E;)switch(y.trackPosition&&(y.position++,E===`
294
+ `?(y.line++,y.column=0):y.column++),y.state){case b.BEGIN:if(y.state=b.BEGIN_WHITESPACE,E==="\uFEFF")continue;$o(y,E);continue;case b.BEGIN_WHITESPACE:$o(y,E);continue;case b.TEXT:if(y.sawRoot&&!y.closedRoot){for(var De=D-1;E&&E!=="<"&&E!=="&";)E=Io(w,D++),E&&y.trackPosition&&(y.position++,E===`
295
+ `?(y.line++,y.column=0):y.column++);y.textNode+=w.substring(De,D-1)}E==="<"&&!(y.sawRoot&&y.closedRoot&&!y.strict)?(y.state=b.OPEN_WAKA,y.startTagPosition=y.position):(!x(E)&&(!y.sawRoot||y.closedRoot)&&xe(y,"Text data outside of root node."),E==="&"?y.state=b.TEXT_ENTITY:y.textNode+=E);continue;case b.SCRIPT:E==="<"?y.state=b.SCRIPT_ENDING:y.script+=E;continue;case b.SCRIPT_ENDING:E==="/"?y.state=b.CLOSE_TAG:(y.script+="<"+E,y.state=b.SCRIPT);continue;case b.OPEN_WAKA:if(E==="!")y.state=b.SGML_DECL,y.sgmlDecl="";else if(!x(E))if(T(h,E))y.state=b.OPEN_TAG,y.tagName=E;else if(E==="/")y.state=b.CLOSE_TAG,y.tagName="";else if(E==="?")y.state=b.PROC_INST,y.procInstName=y.procInstBody="";else{if(xe(y,"Unencoded <"),y.startTagPosition+1<y.position){var We=y.position-y.startTagPosition;E=new Array(We).join(" ")+E}y.textNode+="<"+E,y.state=b.TEXT}continue;case b.SGML_DECL:(y.sgmlDecl+E).toUpperCase()===l?(H(y,"onopencdata"),y.state=b.CDATA,y.sgmlDecl="",y.cdata=""):y.sgmlDecl+E==="--"?(y.state=b.COMMENT,y.comment="",y.sgmlDecl=""):(y.sgmlDecl+E).toUpperCase()===d?(y.state=b.DOCTYPE,(y.doctype||y.sawRoot)&&xe(y,"Inappropriately located doctype declaration"),y.doctype="",y.sgmlDecl=""):E===">"?(H(y,"onsgmldeclaration",y.sgmlDecl),y.sgmlDecl="",y.state=b.TEXT):(S(E)&&(y.state=b.SGML_DECL_QUOTED),y.sgmlDecl+=E);continue;case b.SGML_DECL_QUOTED:E===y.q&&(y.state=b.SGML_DECL,y.q=""),y.sgmlDecl+=E;continue;case b.DOCTYPE:E===">"?(y.state=b.TEXT,H(y,"ondoctype",y.doctype),y.doctype=!0):(y.doctype+=E,E==="["?y.state=b.DOCTYPE_DTD:S(E)&&(y.state=b.DOCTYPE_QUOTED,y.q=E));continue;case b.DOCTYPE_QUOTED:y.doctype+=E,E===y.q&&(y.q="",y.state=b.DOCTYPE);continue;case b.DOCTYPE_DTD:y.doctype+=E,E==="]"?y.state=b.DOCTYPE:S(E)&&(y.state=b.DOCTYPE_DTD_QUOTED,y.q=E);continue;case b.DOCTYPE_DTD_QUOTED:y.doctype+=E,E===y.q&&(y.state=b.DOCTYPE_DTD,y.q="");continue;case b.COMMENT:E==="-"?y.state=b.COMMENT_ENDING:y.comment+=E;continue;case b.COMMENT_ENDING:E==="-"?(y.state=b.COMMENT_ENDED,y.comment=ye(y.opt,y.comment),y.comment&&H(y,"oncomment",y.comment),y.comment=""):(y.comment+="-"+E,y.state=b.COMMENT);continue;case b.COMMENT_ENDED:E!==">"?(xe(y,"Malformed comment"),y.comment+="--"+E,y.state=b.COMMENT):y.state=b.TEXT;continue;case b.CDATA:E==="]"?y.state=b.CDATA_ENDING:y.cdata+=E;continue;case b.CDATA_ENDING:E==="]"?y.state=b.CDATA_ENDING_2:(y.cdata+="]"+E,y.state=b.CDATA);continue;case b.CDATA_ENDING_2:E===">"?(y.cdata&&H(y,"oncdata",y.cdata),H(y,"onclosecdata"),y.cdata="",y.state=b.TEXT):E==="]"?y.cdata+="]":(y.cdata+="]]"+E,y.state=b.CDATA);continue;case b.PROC_INST:E==="?"?y.state=b.PROC_INST_ENDING:x(E)?y.state=b.PROC_INST_BODY:y.procInstName+=E;continue;case b.PROC_INST_BODY:if(!y.procInstBody&&x(E))continue;E==="?"?y.state=b.PROC_INST_ENDING:y.procInstBody+=E;continue;case b.PROC_INST_ENDING:E===">"?(H(y,"onprocessinginstruction",{name:y.procInstName,body:y.procInstBody}),y.procInstName=y.procInstBody="",y.state=b.TEXT):(y.procInstBody+="?"+E,y.state=b.PROC_INST_BODY);continue;case b.OPEN_TAG:T(g,E)?y.tagName+=E:(V(y),E===">"?ae(y):E==="/"?y.state=b.OPEN_TAG_SLASH:(x(E)||xe(y,"Invalid character in tag name"),y.state=b.ATTRIB));continue;case b.OPEN_TAG_SLASH:E===">"?(ae(y,!0),je(y)):(xe(y,"Forward-slash in opening tag not followed by >"),y.state=b.ATTRIB);continue;case b.ATTRIB:if(x(E))continue;E===">"?ae(y):E==="/"?y.state=b.OPEN_TAG_SLASH:T(h,E)?(y.attribName=E,y.attribValue="",y.state=b.ATTRIB_NAME):xe(y,"Invalid attribute name");continue;case b.ATTRIB_NAME:E==="="?y.state=b.ATTRIB_VALUE:E===">"?(xe(y,"Attribute without value"),y.attribValue=y.attribName,oe(y),ae(y)):x(E)?y.state=b.ATTRIB_NAME_SAW_WHITE:T(g,E)?y.attribName+=E:xe(y,"Invalid attribute name");continue;case b.ATTRIB_NAME_SAW_WHITE:if(E==="=")y.state=b.ATTRIB_VALUE;else{if(x(E))continue;xe(y,"Attribute without value"),y.tag.attributes[y.attribName]="",y.attribValue="",H(y,"onattribute",{name:y.attribName,value:""}),y.attribName="",E===">"?ae(y):T(h,E)?(y.attribName=E,y.state=b.ATTRIB_NAME):(xe(y,"Invalid attribute name"),y.state=b.ATTRIB)}continue;case b.ATTRIB_VALUE:if(x(E))continue;S(E)?(y.q=E,y.state=b.ATTRIB_VALUE_QUOTED):(xe(y,"Unquoted attribute value"),y.state=b.ATTRIB_VALUE_UNQUOTED,y.attribValue=E);continue;case b.ATTRIB_VALUE_QUOTED:if(E!==y.q){E==="&"?y.state=b.ATTRIB_VALUE_ENTITY_Q:y.attribValue+=E;continue}oe(y),y.q="",y.state=b.ATTRIB_VALUE_CLOSED;continue;case b.ATTRIB_VALUE_CLOSED:x(E)?y.state=b.ATTRIB:E===">"?ae(y):E==="/"?y.state=b.OPEN_TAG_SLASH:T(h,E)?(xe(y,"No whitespace between attributes"),y.attribName=E,y.attribValue="",y.state=b.ATTRIB_NAME):xe(y,"Invalid attribute name");continue;case b.ATTRIB_VALUE_UNQUOTED:if(!k(E)){E==="&"?y.state=b.ATTRIB_VALUE_ENTITY_U:y.attribValue+=E;continue}oe(y),E===">"?ae(y):y.state=b.ATTRIB;continue;case b.CLOSE_TAG:if(y.tagName)E===">"?je(y):T(g,E)?y.tagName+=E:y.script?(y.script+="</"+y.tagName,y.tagName="",y.state=b.SCRIPT):(x(E)||xe(y,"Invalid tagname in closing tag"),y.state=b.CLOSE_TAG_SAW_WHITE);else{if(x(E))continue;A(h,E)?y.script?(y.script+="</"+E,y.state=b.SCRIPT):xe(y,"Invalid tagname in closing tag."):y.tagName=E}continue;case b.CLOSE_TAG_SAW_WHITE:if(x(E))continue;E===">"?je(y):xe(y,"Invalid characters in closing tag");continue;case b.TEXT_ENTITY:case b.ATTRIB_VALUE_ENTITY_Q:case b.ATTRIB_VALUE_ENTITY_U:var At,bt;switch(y.state){case b.TEXT_ENTITY:At=b.TEXT,bt="textNode";break;case b.ATTRIB_VALUE_ENTITY_Q:At=b.ATTRIB_VALUE_QUOTED,bt="attribValue";break;case b.ATTRIB_VALUE_ENTITY_U:At=b.ATTRIB_VALUE_UNQUOTED,bt="attribValue"}if(E===";")if(y.opt.unparsedEntities){var rr=Jr(y);y.entity="",y.state=At,y.write(rr)}else y[bt]+=Jr(y),y.entity="",y.state=At;else T(y.entity.length?v:_,E)?y.entity+=E:(xe(y,"Invalid character in entity name"),y[bt]+="&"+y.entity+E,y.entity="",y.state=At);continue;default:throw new Error(y,"Unknown state: "+y.state)}return y.position>=y.bufferCheckPosition&&i(y),y}return String.fromCodePoint||(function(){var w=String.fromCharCode,y=Math.floor,D=function(){var E=16384,De=[],We,At,bt=-1,rr=arguments.length;if(!rr)return"";for(var dn="";++bt<rr;){var wt=Number(arguments[bt]);if(!isFinite(wt)||wt<0||wt>1114111||y(wt)!==wt)throw RangeError("Invalid code point: "+wt);wt<=65535?De.push(wt):(wt-=65536,We=(wt>>10)+55296,At=wt%1024+56320,De.push(We,At)),(bt+1===rr||De.length>E)&&(dn+=w.apply(null,De),De.length=0)}return dn};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:D,configurable:!0,writable:!0}):String.fromCodePoint=D})(),e},vD=L5();var Vg=`The output should be formatted as a XML file.
296
+ 1. Output should conform to the tags below.
297
+ 2. If tags are not given, make them on your own.
298
+ 3. Remember to always open and close all the tags.
299
+
300
+ As an example, for the tags ["foo", "bar", "baz"]:
301
+ 1. String "<foo>
302
+ <bar>
303
+ <baz></baz>
304
+ </bar>
305
+ </foo>" is a well-formatted instance of the schema.
306
+ 2. String "<foo>
307
+ <bar>
308
+ </foo>" is a badly-formatted instance.
309
+ 3. String "<foo>
310
+ <tag>
311
+ </tag>
312
+ </foo>" is a badly-formatted instance.
313
+
314
+ Here are the output tags:
315
+ \`\`\`
316
+ {tags}
317
+ \`\`\``,bD=class extends Ai{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?Yi(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return Hg(e[0].text)}async parse(e){return Hg(e)}getFormatInstructions(){return this.tags&&this.tags.length>0?Vg.replace("{tags}",this.tags?.join(", ")??""):Vg}},U5=e=>e.split(`
318
+ `).map(t=>t.replace(/^\s+/,"")).join(`
319
+ `).trim(),wD=e=>{if(Object.keys(e).length===0)return{};let t={};return e.children.length>0?(t[e.name]=e.children.map(wD),t):(t[e.name]=e.text??void 0,t)};function Hg(e){let t=U5(e),r=vD.parser(!0),i={},n=[];r.onopentag=s=>{let c={name:s.name,attributes:s.attributes,children:[],text:"",isSelfClosing:s.isSelfClosing};n.length>0?n[n.length-1].children.push(c):i=c,s.isSelfClosing||n.push(c)},r.onclosetag=()=>{if(n.length>0){let s=n.pop();n.length===0&&s&&(i=s)}},r.ontext=s=>{if(n.length>0){let c=n[n.length-1];c.text+=s}},r.onattribute=s=>{if(n.length>0){let c=n[n.length-1];c.attributes[s.name]=s.value}};let o=/```(xml)?(.*)```/s.exec(t),a=o?o[2]:t;return r.write(a).close(),i&&i.name==="?xml"&&(i=i.children[0]),wD(i)}var xD=C({AsymmetricStructuredOutputParser:()=>yD,BaseCumulativeTransformOutputParser:()=>Ai,BaseLLMOutputParser:()=>Uu,BaseOutputParser:()=>Zn,BaseTransformOutputParser:()=>mo,BytesOutputParser:()=>fD,CommaSeparatedListOutputParser:()=>pD,CustomListOutputParser:()=>mD,JsonMarkdownStructuredOutputParser:()=>r$,JsonOutputParser:()=>Fg,ListOutputParser:()=>Fu,MarkdownListOutputParser:()=>gD,NumberedListOutputParser:()=>hD,OutputParserException:()=>hr,StandardSchemaOutputParser:()=>Bg,StringOutputParser:()=>_D,StructuredOutputParser:()=>tf,XMLOutputParser:()=>bD,XML_FORMAT_INSTRUCTIONS:()=>Vg,parseJsonMarkdown:()=>Fa,parsePartialJson:()=>jn,parseXMLMarkdown:()=>Hg});var SD=C({extendInteropZodObject:()=>mg,getInteropZodDefaultGetter:()=>hg,getInteropZodObjectShape:()=>ao,getSchemaDescription:()=>so,interopParse:()=>la,interopParseAsync:()=>ua,interopSafeParse:()=>RR,interopSafeParseAsync:()=>pg,interopZodObjectMakeFieldsOptional:()=>DR,interopZodObjectPartial:()=>da,interopZodObjectPassthrough:()=>fg,interopZodObjectStrict:()=>Eu,interopZodTransformInputSchema:()=>gg,isInteropZodError:()=>_g,isInteropZodLiteral:()=>NR,isInteropZodObject:()=>fr,isInteropZodSchema:()=>Hr,isShapelessZodSchema:()=>jR,isSimpleStringZodSchema:()=>Tu,isZodArrayV4:()=>Ud,isZodLiteralV3:()=>GS,isZodLiteralV4:()=>KS,isZodNullableV4:()=>qS,isZodObjectV3:()=>Ld,isZodObjectV4:()=>bn,isZodOptionalV4:()=>WS,isZodSchema:()=>PR,isZodSchemaV3:()=>yt,isZodSchemaV4:()=>et});function n$(e,t){if(e.function===void 0)return;let r;if(t?.partial)try{r=jn(e.function.arguments??"{}")}catch{return}else try{r=JSON.parse(e.function.arguments)}catch(n){throw new hr([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${n.message}`].join(`
320
+ `))}let i={name:e.function.name,args:r,type:"tool_call"};return t?.returnId&&(i.id=e.id),i}function kD(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 $D(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}var i$=class extends Ai{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,i;if($c(r)&&r.tool_calls?.length?i=r.tool_calls.map(o=>{let{id:a,...s}=o;return this.returnId?{id:a,...s}:s}):r.additional_kwargs.tool_calls!==void 0&&(i=JSON.parse(JSON.stringify(r.additional_kwargs.tool_calls)).map(o=>n$(o,{returnId:this.returnId,partial:t}))),!i)return[];let n=[];for(let o of i)if(o!==void 0){let a={type:o.name,args:o.args,id:o.id};n.push(a)}return n}},Zg=class extends i${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 hr(`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 pg(this.zodSchema,e);if(t.success)return t.data;throw new hr(`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(i=>i.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(i=>i.args)),this.returnSingle?r[0]:r}async parseResult(e){let t=(await super.parsePartialResult(e,!1)).filter(i=>i.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(i=>i.args)),this.returnSingle?this._validateResult(r[0]):await Promise.all(r.map(i=>this._validateResult(i)))}};var ID=C({assembleStructuredOutputPipeline:()=>o$,createContentParser:()=>F5,createFunctionCallingParser:()=>B5});function F5(e){return Hr(e)?tf.fromZodSchema(e):_s(e)?Bg.fromSerializableSchema(e):new Fg}function B5(e,t,r){let i=r??Zg;return Hr(e)?new i({returnSingle:!0,keyName:t,zodSchema:e}):_s(e)?new i({returnSingle:!0,keyName:t,serializableSchema:e}):new i({returnSingle:!0,keyName:t})}function o$(e,t,r,i){if(!r){let c=e.pipe(t);return i?c.withConfig({runName:i}):c}let n=po.assign({parsed:(c,u)=>t.invoke(c.raw,u)}),o=po.assign({parsed:()=>null}),a=n.withFallbacks({fallbacks:[o]}),s=un.from([{raw:e},a]);return i?s.withConfig({runName:i}):s}var TD=C({ChatModelStream:()=>_a,ReasoningContentStream:()=>OD,TextContentStream:()=>AD,ToolCallsStream:()=>CD,UsageMetadataStream:()=>PD}),V5=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 H5(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 rf(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 ED(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 Gg(e){if(e==null||typeof e!="object")return!1;let t=e.type;return t==="reasoning"||t==="thinking"}function Bu(e){if(e)return{...e,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,total_tokens:e.total_tokens??0}}function Z5(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 G5(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 i=t.args??t.input;return{...t,type:"tool_call",name:r,args:Z5(i)}}var AD=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 i=rf(r);i?.type==="text-delta"&&(t+=i.text,yield t)}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let r of e.iterate()){let i=rf(r);i?.type==="text-delta"&&(yield i.text)}}return t()}then(e,t){return(async()=>{let r="";for await(let i of this)r+=i;return r})().then(e,t)}},CD=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 i of this)r.push(i);return r})().then(e,t)}},OD=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="",r=!1;for await(let i of e.iterate())if(i.event==="content-block-start"){if(!Gg(i.content)){if(r)return;continue}r=!0;let n=ED(i.content);if(n==null||n.length===0)continue;t+=n,yield t}else if(i.event==="content-block-delta"){let n=rf(i);if(n?.type!=="reasoning-delta")continue;r=!0;let o=n.reasoning;if(o==null||o.length===0)continue;t+=o,yield t}else{if(i.event==="content-block-finish"&&Gg(i.content))return;if(i.event==="message-finish")return}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){let r=!1;for await(let i of e.iterate())if(i.event==="content-block-start"){if(!Gg(i.content)){if(r)return;continue}r=!0;let n=ED(i.content);n!=null&&n.length>0&&(yield n)}else if(i.event==="content-block-delta"){let n=rf(i);if(n?.type!=="reasoning-delta")continue;r=!0;let o=n.reasoning;o!=null&&o.length>0&&(yield o)}else{if(i.event==="content-block-finish"&&Gg(i.content))return;if(i.event==="message-finish")return}}return t()}then(e,t){return(async()=>{let r="";for await(let i of this)r+=i;return r})().then(e,t)}},PD=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 i=Bu(r.usage);i&&(yield i)}else if(r.event==="message-start"&&r.usage){let i=Bu(r.usage);i&&(yield i)}else if(r.event==="message-finish"&&r.usage){let i=Bu(r.usage);i&&(yield i)}}return t()}then(e,t){return(async()=>{let r;for await(let i of this)r=i;return r})().then(e,t)}},_a=class{_buffer;constructor(e){this._buffer=new V5,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 AD(this._buffer)}get toolCalls(){return new CD(this._buffer)}get reasoning(){return new OD(this._buffer)}get usage(){return new PD(this._buffer)}get output(){return this._assembleMessage()}then(e,t){return this._assembleMessage().then(e,t)}async _assembleMessage(){let e=[],t,r,i={},n;for await(let a of this._buffer.iterate())switch(a.event){case"message-start":t=a.id??t,a.usage&&(r=Bu(a.usage));break;case"content-block-start":e[a.index]=a.content;break;case"content-block-delta":{let s=e[a.index],c=rf(a);s&&c&&(e[a.index]=H5(s,c));break}case"content-block-finish":e[a.index]=a.content;break;case"usage":r=Bu(a.usage);break;case"message-finish":n=a.reason,a.usage&&(r=Bu(a.usage)),a.responseMetadata&&(i={...i,...a.responseMetadata})}let o=e.filter(a=>a!=null).map(G5);return new Le({id:t,content:o,usage_metadata:r,response_metadata:{...i,...n?{finish_reason:n}:{},output_version:"v1"}})}};var RD=C({convertChunksToEvents:()=>a$,finalizeContentBlock:()=>Kg}),K5={wav:"audio/wav",mp3:"audio/mpeg",flac:"audio/flac",opus:"audio/opus",aac:"audio/aac",pcm16:"audio/pcm"},W5={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif"};function ND(e){let t=0;for(let r of e.keys())r>=t&&(t=r+1);return t}function jD(e){let t=e.additional_kwargs;return t!=null&&typeof t=="object"?t:{}}function q5(e){let t=jD(e).tool_outputs;if(!Array.isArray(t))return[];let r=[];for(let i of t){if(i==null||typeof i!="object")continue;let n=i;if(n.type!=="image_generation_call")continue;let o=typeof n.result=="string"?n.result:void 0,a=typeof n.url=="string"?n.url:void 0;if(o==null&&a==null)continue;let s=typeof n.output_format=="string"?n.output_format.toLowerCase():void 0,c=(s!=null?W5[s]:void 0)??"image/png";r.push({type:"image",...typeof n.id=="string"?{id:n.id}:{},...a!=null?{url:a}:{},...o!=null?{data:o}:{},mimeType:c})}return r}function J5(e){let t=jD(e).audio;if(t==null||typeof t!="object")return;let r=t,i=typeof r.data=="string"?r.data:void 0,n=typeof r.url=="string"?r.url:void 0,o=typeof r.transcript=="string"?r.transcript:void 0;if(i==null&&n==null&&o==null)return;let a=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=a??(s!=null?K5[s]:void 0)??(i!=null?"audio/wav":"audio/pcm");return{...typeof r.id=="string"?{id:r.id}:{},...i!=null?{data:i}:{},...n!=null?{url:n}:{},...o!=null?{transcript:o}:{},mimeType:c}}async function*a$(e,t){let r=new Map,i=!1,n,o,a=new Set;for await(let s of e){t?.signal?.throwIfAborted();let c=s.message,u=!1;if(!i){i=!0;let f={event:"message-start",id:c.id??void 0};nt.isInstance(c)&&c.usage_metadata&&(f.usage=c.usage_metadata,n={...c.usage_metadata},u=!0),yield f}let l=c.content;if(typeof l=="string"){if(l!==""){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??"")+l},yield{event:"content-block-delta",index:0,delta:{type:"text-delta",text:l}}}}else if(Array.isArray(l))for(let f of l){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=Y5(f);m.accumulated=X5(m.accumulated,h),yield{event:"content-block-delta",index:p,delta:h}}}if(nt.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=J5(c);if(d!=null){if(o==null){let p=ND(r);o={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(o.index);if(f!=null){let p=f.accumulated;d.id!=null&&o.id==null&&(o.id=d.id,p.id=d.id),d.transcript!=null&&(o.transcript+=d.transcript,p.transcript=o.transcript,yield{event:"content-block-delta",index:o.index,delta:{type:"block-delta",fields:{type:"audio",transcript:o.transcript}}}),d.data!=null&&d.data.length>0&&(p.data=(p.data??"")+d.data,yield{event:"content-block-delta",index:o.index,delta:{type:"data-delta",data:d.data,encoding:"base64"}})}}for(let f of q5(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&&a.has(m))continue;m!=null&&a.add(m);let h=ND(r);r.set(h,{type:"image",accumulated:f}),yield{event:"content-block-start",index:h,content:f}}if(!u&&nt.isInstance(c)&&c.usage_metadata){let f=c.usage_metadata;n?n={input_tokens:n.input_tokens+f.input_tokens,output_tokens:n.output_tokens+f.output_tokens,total_tokens:n.total_tokens+f.total_tokens}:n={...f},yield{event:"usage",usage:{...n}}}}for(let[s,c]of r)yield{event:"content-block-finish",index:s,content:Kg(c.accumulated)};yield{event:"message-finish",reason:"stop",...n?{usage:n}:{}}}function X5(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 Y5(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 Kg(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 DD=e=>e();function nf(e){let t=e.constructor;return new t({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var MD=C({BaseChatModel:()=>ya,SimpleChatModel:()=>Q5});function s$(e){let t=[];for(let r of e){let i=r;if(Array.isArray(r.content))for(let n=0;n<r.content.length;n++){let o=r.content[n];(bc(o)||wc(o))&&i===r&&(i=new r.constructor({...i,content:[...r.content.slice(0,n),$p(o),...r.content.slice(n+1)]}))}t.push(i)}return t}var ya=class Ci extends ef{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(t){super(t),this.outputVersion=DD(()=>{let r=t.outputVersion??Ot("LC_OUTPUT_VERSION");return r&&["v0","v1"].includes(r)?r:"v0"})}_separateRunnableConfigFromCallOptionsCompat(t){let[r,i]=super._separateRunnableConfigFromCallOptions(t);return i.signal=r.signal,[r,i]}async invoke(t,r){let i=Ci._convertInputToPromptValue(t);return(await this.generatePrompt([i],r,r?.callbacks)).generations[0][0].message}async*_streamResponseChunks(t,r,i){throw new Error("Not implemented.")}async*_streamChatModelEvents(t,r,i){let n=this._streamResponseChunks(t,r,i);yield*a$(n,{signal:r.signal})}streamEvents(t,r,i){if(r?.version==="v1"||r?.version==="v2")return super.streamEvents(t,r,i);let n=Ci._convertInputToPromptValue(t).toChatMessages(),[,o]=this._separateRunnableConfigFromCallOptionsCompat(r),a=this._streamChatModelEvents(n,o);return new _a(a)}streamV2(t,r){return this.streamEvents(t,r)}async*_streamIterator(t,r){if(this._streamResponseChunks===Ci.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,r);else{let i=Ci._convertInputToPromptValue(t).toChatMessages(),[n,o]=this._separateRunnableConfigFromCallOptionsCompat(r),a={...n.metadata,...this.getLsParamsWithDefaults(o)},s=this._getInvocationParamsForTracing(o),c=await at.configure(n.callbacks,this.callbacks,n.tags,this.tags,a,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),u={options:this._getCallOptionsForTracing(o,s),invocation_params:s,batch_size:1},l=o.outputVersion??this.outputVersion,d=await c?.handleChatModelStart(this.toJSON(),[s$(i)],n.runId,void 0,u,void 0,void 0,n.runName),f;try{for await(let m of this._streamResponseChunks(i,o,d?.[0])){if(o.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},l==="v1"?yield nf(m.message):yield m.message,f?f=f.concat(m):f=m}o.signal?.throwIfAborted()}catch(m){throw await Promise.all((d??[]).map(h=>h?.handleLLMError(m))),m}let p;f&&nt.isInstance(f.message)&&f.message.usage_metadata!==void 0&&(p={tokenUsage:{promptTokens:f.message.usage_metadata.input_tokens,completionTokens:f.message.usage_metadata.output_tokens,totalTokens:f.message.usage_metadata.total_tokens}}),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,i,n){let o=t.map(p=>p.map(Nt)),a;if(n!==void 0&&n.length===o.length)a=n;else{let p={...i.metadata,...this.getLsParamsWithDefaults(r)},m=this._getInvocationParamsForTracing(r),h=await at.configure(i.callbacks,this.callbacks,i.tags,this.tags,p,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(m)}),g={options:this._getCallOptionsForTracing(r,m),invocation_params:m,batch_size:1};a=await h?.handleChatModelStart(this.toJSON(),o.map(s$),i.runId,void 0,g,void 0,void 0,i.runName)}let s=r.outputVersion??this.outputVersion,c=[],u=[],l=!!a?.[0].handlers.find(tv),d=!!a?.[0].handlers.find(Nl);if(l&&!this.disableStreaming&&o.length===1&&(this._streamChatModelEvents!==Ci.prototype._streamChatModelEvents||this._streamResponseChunks!==Ci.prototype._streamResponseChunks))try{let p=!1,m=a?.[0],h=this._streamChatModelEvents(o[0],r),g=await new _a({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(g.id==null){let x=a?.at(0)?.runId;x!=null&&g._updateId(`run-${x}`)}let _={text:g.text,message:g};c.push([_]);let v=g.usage_metadata!==void 0?{tokenUsage:{promptTokens:g.usage_metadata.input_tokens,completionTokens:g.usage_metadata.output_tokens,totalTokens:g.usage_metadata.total_tokens}}:void 0;await a?.[0].handleLLMEnd({generations:c,llmOutput:v})}catch(p){throw await a?.[0].handleLLMError(p),p}else if(d&&!this.disableStreaming&&o.length===1&&this._streamResponseChunks!==Ci.prototype._streamResponseChunks)try{let p=await this._streamResponseChunks(o[0],r,a?.[0]),m;for await(let g of p){if(r.signal?.aborted){let _=m?.message;throw new Sp("Model invocation was aborted.",_)}if(g.message.id==null){let _=a?.at(0)?.runId;_!=null&&g.message._updateId(`run-${_}`)}m===void 0?m=g:m=nn(m,g)}if(r.signal?.aborted){let g=m?.message;throw new Sp("Model invocation was aborted.",g)}if(m===void 0)throw new Error("Received empty response from chat model call.");s==="v1"&&(m.message=nf(m.message)),c.push([m]);let h;nt.isInstance(m.message)&&m.message.usage_metadata!==void 0&&(h={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}}),await a?.[0].handleLLMEnd({generations:c,llmOutput:h})}catch(p){throw await a?.[0].handleLLMError(p),p}else{let p=await Promise.allSettled(o.map(async(m,h)=>{let g=await this._generate(m,{...r,promptIndex:h},a?.[h]);if(s==="v1")for(let _ of g.generations)_.message=nf(_.message);return g}));await Promise.all(p.map(async(m,h)=>{if(m.status==="fulfilled"){let g=m.value;for(let _ of g.generations){if(_.message.id==null){let v=a?.at(0)?.runId;v!=null&&_.message._updateId(`run-${v}`)}_.message.response_metadata={..._.generationInfo,..._.message.response_metadata}}return g.generations.length===1&&(g.generations[0].message.response_metadata={...g.llmOutput,...g.generations[0].message.response_metadata}),c[h]=g.generations,u[h]=g.llmOutput,a?.[h]?.handleLLMEnd({generations:[g.generations],llmOutput:g.llmOutput})}else return await a?.[h]?.handleLLMError(m.reason),Promise.reject(m.reason)}))}let f={generations:c,llmOutput:u.length?this._combineLLMOutput?.(...u):void 0};return Object.defineProperty(f,gs,{value:a?{runIds:a?.map(p=>p.runId)}:void 0,configurable:!0}),f}async _generateCached({messages:t,cache:r,llmStringKey:i,parsedOptions:n,handledOptions:o}){let a=t.map(_=>_.map(Nt)),s={...o.metadata,...this.getLsParamsWithDefaults(n)},c=this._getInvocationParamsForTracing(n),u=await at.configure(o.callbacks,this.callbacks,o.tags,this.tags,s,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(c)}),l={options:this._getCallOptionsForTracing(n,c),invocation_params:c,batch_size:1},d=await u?.handleChatModelStart(this.toJSON(),a.map(s$),o.runId,void 0,l,void 0,void 0,o.runName),f=[],p=(await Promise.allSettled(a.map(async(_,v)=>{let x=Ci._convertInputToPromptValue(_).toString(),S=await r.lookup(x,i);return S==null&&f.push(v),S}))).map((_,v)=>({result:_,runManager:d?.[v]})).filter(({result:_})=>_.status==="fulfilled"&&_.value!=null||_.status==="rejected"),m=n.outputVersion??this.outputVersion,h=[];await Promise.all(p.map(async({result:_,runManager:v},x)=>{if(_.status==="fulfilled"){let S=_.value;return h[x]=S.map(k=>("message"in k&&lt(k.message)&&$c(k.message)&&(k.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},m==="v1"&&(k.message=nf(k.message))),k.generationInfo={...k.generationInfo,tokenUsage:{}},k)),S.length&&await v?.handleLLMNewToken(S[0].text),v?.handleLLMEnd({generations:[S]},void 0,void 0,void 0,{cached:!0})}else return await v?.handleLLMError(_.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(_.reason)}));let g={generations:h,missingPromptIndices:f,startedRunManagers:d};return Object.defineProperty(g,gs,{value:d?{runIds:d?.map(_=>_.runId)}:void 0,configurable:!0}),g}async generate(t,r,i){let n;Array.isArray(r)?n={stop:r}:n=r;let o=t.map(m=>m.map(Nt)),[a,s]=this._separateRunnableConfigFromCallOptionsCompat(n);if(a.callbacks=a.callbacks??i,!this.cache)return this._generateUncached(o,s,a);let{cache:c}=this,u=this._getSerializedCacheKeyParametersForCall(s),{generations:l,missingPromptIndices:d,startedRunManagers:f}=await this._generateCached({messages:o,cache:c,llmStringKey:u,parsedOptions:s,handledOptions:a}),p={};if(d.length>0){let m=await this._generateUncached(d.map(h=>o[h]),s,a,f!==void 0?d.map(h=>f?.[h]):void 0);await Promise.all(m.generations.map(async(h,g)=>{let _=d[g];l[_]=h;let v=Ci._convertInputToPromptValue(o[_]).toString();return c.update(v,u,h)})),p=m.llmOutput??{}}return{generations:l,llmOutput:p}}_getInvocationParamsForTracing(t){return this.invocationParams(t)}_getCallOptionsForTracing(t,r){return t}invocationParams(t){return{}}_modelType(){return"base_chat_model"}async generatePrompt(t,r,i){let n=t.map(o=>o.toChatMessages());return this.generate(n,r,i)}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 i=t,n=r?.name,o=so(i)??"A function available to call.",a=r?.method,s=r?.includeRaw;if(a==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let c=n??"extract";!Hr(i)&&!_s(i)&&"name"in i&&(c=i.name);let u=Hr(i)||_s(i)?zt(i):i,l=[{type:"function",function:{name:c,description:o,parameters:u}}],d=this.bindTools(l),f=mr.from(p=>{if(!nt.isInstance(p))throw new Error("Input is not an AIMessageChunk.");if(!p.tool_calls||p.tool_calls.length===0)throw new Error("No tool calls found in the response.");let m=p.tool_calls.find(h=>h.name===c);if(!m)throw new Error(`No tool call found with name ${c}.`);return m.args});return o$(d,f,s,s?"StructuredOutputRunnable":"StructuredOutput")}},Q5=class extends ya{async _generate(e,t,r){let i=await this._call(e,t,r),n=new Le(i);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 zD=C({convertOpenAICompletionsStream:()=>e8});async function*e8(e,t={}){let r=t.streamUsage??!0,i=t.provider??"openai",n=t.mapChunk,o=new Map,a=new Map,s=0,c=!1,u,l,d,f=!1,p=(m,h)=>{let g=a.get(m);if(g!==void 0)return{index:g,isNew:!1};let _=s++;return a.set(m,_),o.set(_,{...h}),{index:_,isNew:!0}};for await(let m of e){n&&(m=n(m)),c||(c=!0,yield{event:"message-start",id:m.id}),!f&&(m.model||m.service_tier)&&(f=!0,yield{event:"provider",provider:i,name:"stream_metadata",payload:{model:m.model,service_tier:m.service_tier}}),m.usage&&r&&(u=i8(m.usage),yield{event:"usage",usage:u});let h=m.x_groq?.usage;h&&r&&(u=r8(h),yield{event:"usage",usage:u});let g=m.choices?.[0];if(!g)continue;g.finish_reason!=null&&(l=n8(g.finish_reason),d=o8(m,g));let{delta:_}=g;if(!_)continue;let v=t8(_);if(v){let{index:x,isNew:S}=p("reasoning",{type:"reasoning",reasoning:""});S&&(yield{event:"content-block-start",index:x,content:{type:"reasoning",reasoning:""}});let k=o.get(x);k.reasoning=(k.reasoning??"")+v,yield{event:"content-block-delta",index:x,delta:{type:"reasoning-delta",reasoning:v}}}if(_.content){let{index:x,isNew:S}=p("text",{type:"text",text:""});S&&(yield{event:"content-block-start",index:x,content:{type:"text",text:""}});let k=o.get(x);k.text=(k.text??"")+_.content,yield{event:"content-block-delta",index:x,delta:{type:"text-delta",text:_.content}}}if(Array.isArray(_.tool_calls))for(let x of _.tool_calls){let S=x.index??0,{index:k,isNew:T}=p(`tool:${S}`,{type:"tool_call_chunk",id:x.id,name:x.function?.name,args:"",index:S});T&&(yield{event:"content-block-start",index:k,content:{type:"tool_call_chunk",id:x.id,name:x.function?.name,args:"",index:S}});let A=o.get(k);x.id!=null&&(A.id=x.id),x.function?.name!=null&&(A.name=x.function.name);let b=x.function?.arguments??"";A.args=(A.args??"")+b,yield{event:"content-block-delta",index:k,delta:{type:"block-delta",fields:{type:"tool_call_chunk",...A.id!=null?{id:A.id}:{},...A.name!=null?{name:A.name}:{},args:A.args}}}}if(_.audio){let{index:x,isNew:S}=p("audio",{type:"audio",id:_.audio.id,data:"",mimeType:"audio/pcm",transcript:_.audio.transcript??""});S&&(yield{event:"content-block-start",index:x,content:{type:"audio",id:_.audio.id,data:"",mimeType:"audio/pcm",transcript:_.audio.transcript??""}});let k=o.get(x);_.audio.transcript&&(k.transcript=(k.transcript??"")+_.audio.transcript,yield{event:"content-block-delta",index:x,delta:{type:"block-delta",fields:{type:"audio",transcript:k.transcript}}}),_.audio.data&&(k.data=(k.data??"")+_.audio.data,yield{event:"content-block-delta",index:x,delta:{type:"data-delta",data:_.audio.data,encoding:"base64"}})}_.function_call&&(yield{event:"provider",provider:i,name:"function_call",payload:_.function_call}),g.logprobs&&(yield{event:"provider",provider:i,name:"logprobs",payload:g.logprobs})}for(let[m,h]of o)yield{event:"content-block-finish",index:m,content:Kg(h)};yield{event:"message-finish",reason:l,...u?{usage:u}:{},...d?{responseMetadata:d}:{}}}function t8(e){let t=e.reasoning_content??e.reasoning;return typeof t=="string"&&t.length>0?t:void 0}function r8(e){return{input_tokens:e.prompt_tokens??0,output_tokens:e.completion_tokens??0,total_tokens:e.total_tokens??0}}function n8(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 i8(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 o8(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 LD=C({});var UD=C({BaseLLM:()=>FD,LLM:()=>Wg}),FD=class of extends ef{lc_namespace=["langchain","llms",this._llmType()];async invoke(t,r){let i=of._convertInputToPromptValue(t);return(await this.generatePrompt([i],r,r?.callbacks)).generations[0][0].text}async*_streamResponseChunks(t,r,i){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(t){let[r,i]=super._separateRunnableConfigFromCallOptions(t);return i.signal=r.signal,[r,i]}async*_streamIterator(t,r){if(this._streamResponseChunks===of.prototype._streamResponseChunks)yield this.invoke(t,r);else{let i=of._convertInputToPromptValue(t),[n,o]=this._separateRunnableConfigFromCallOptionsCompat(r),a=this.invocationParams(o),s=await at.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(a)}),c={options:o,invocation_params:a,batch_size:1},u=await s?.handleLLMStart(this.toJSON(),[i.toString()],n.runId,void 0,c,void 0,void 0,n.runName),l=new Qi({text:""});try{for await(let d of this._streamResponseChunks(i.toString(),o,u?.[0]))l?l=l.concat(d):l=d,typeof d.text=="string"&&(yield d.text)}catch(d){throw await Promise.all((u??[]).map(f=>f?.handleLLMError(d))),d}await Promise.all((u??[]).map(d=>d?.handleLLMEnd({generations:[[l]]})))}}async generatePrompt(t,r,i){let n=t.map(o=>o.toString());return this.generate(n,r,i)}invocationParams(t){return{}}_flattenLLMResult(t){let r=[];for(let i=0;i<t.generations.length;i+=1){let n=t.generations[i];if(i===0)r.push({generations:[n],llmOutput:t.llmOutput});else{let o=t.llmOutput?{...t.llmOutput,tokenUsage:{}}:void 0;r.push({generations:[n],llmOutput:o})}}return r}async _generateUncached(t,r,i,n){let o;if(n!==void 0&&n.length===t.length)o=n;else{let u=this.invocationParams(r),l=await at.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(u)}),d={options:r,invocation_params:u,batch_size:t.length};o=await l?.handleLLMStart(this.toJSON(),t,i.runId,void 0,d,void 0,void 0,i?.runName)}let a=!!o?.[0].handlers.find(Nl),s;if(a&&t.length===1&&this._streamResponseChunks!==of.prototype._streamResponseChunks)try{let u=await this._streamResponseChunks(t[0],r,o?.[0]),l;for await(let d of u)l===void 0?l=d:l=nn(l,d);if(l===void 0)throw new Error("Received empty response from chat model call.");s={generations:[[l]],llmOutput:{}},await o?.[0].handleLLMEnd(s)}catch(u){throw await o?.[0].handleLLMError(u),u}else{try{s=await this._generate(t,r,o?.[0])}catch(l){throw await Promise.all((o??[]).map(d=>d?.handleLLMError(l))),l}let u=this._flattenLLMResult(s);await Promise.all((o??[]).map((l,d)=>l?.handleLLMEnd(u[d])))}let c=o?.map(u=>u.runId)||void 0;return Object.defineProperty(s,gs,{value:c?{runIds:c}:void 0,configurable:!0}),s}async _generateCached({prompts:t,cache:r,llmStringKey:i,parsedOptions:n,handledOptions:o,runId:a}){let s=this.invocationParams(n),c=await at.configure(o.callbacks,this.callbacks,o.tags,this.tags,o.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),u={options:n,invocation_params:s,batch_size:t.length},l=await c?.handleLLMStart(this.toJSON(),t,a,void 0,u,void 0,void 0,o?.runName),d=[],f=(await Promise.allSettled(t.map(async(h,g)=>{let _=await r.lookup(h,i);return _==null&&d.push(g),_}))).map((h,g)=>({result:h,runManager:l?.[g]})).filter(({result:h})=>h.status==="fulfilled"&&h.value!=null||h.status==="rejected"),p=[];await Promise.all(f.map(async({result:h,runManager:g},_)=>{if(h.status==="fulfilled"){let v=h.value;return p[_]=v.map(x=>(x.generationInfo={...x.generationInfo,tokenUsage:{}},x)),v.length&&await g?.handleLLMNewToken(v[0].text),g?.handleLLMEnd({generations:[v]},void 0,void 0,void 0,{cached:!0})}else return await g?.handleLLMError(h.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(h.reason)}));let m={generations:p,missingPromptIndices:d,startedRunManagers:l};return Object.defineProperty(m,gs,{value:l?{runIds:l?.map(h=>h.runId)}:void 0,configurable:!0}),m}async generate(t,r,i){if(!Array.isArray(t))throw new Error("Argument 'prompts' is expected to be a string[]");let n;Array.isArray(r)?n={stop:r}:n=r;let[o,a]=this._separateRunnableConfigFromCallOptionsCompat(n);if(o.callbacks=o.callbacks??i,!this.cache)return this._generateUncached(t,a,o);let{cache:s}=this,c=this._getSerializedCacheKeyParametersForCall(a),{generations:u,missingPromptIndices:l,startedRunManagers:d}=await this._generateCached({prompts:t,cache:s,llmStringKey:c,parsedOptions:a,handledOptions:o,runId:o.runId}),f={};if(l.length>0){let p=await this._generateUncached(l.map(m=>t[m]),a,o,d!==void 0?l.map(m=>d?.[m]):void 0);await Promise.all(p.generations.map(async(m,h)=>{let g=l[h];return u[g]=m,s.update(t[g],c,m)})),f=p.llmOutput??{}}return{generations:u,llmOutput:f}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},Wg=class extends FD{async _generate(e,t,r){return{generations:await Promise.all(e.map((i,n)=>this._call(i,{...t,promptIndex:n},r).then(o=>[{text:o}])))}}};var BD=C({});var VD=C({BaseMemory:()=>a8,getInputValue:()=>s8,getOutputValue:()=>c8,getPromptInputKey:()=>u8}),a8=class{},HD=(e,t)=>{if(t!==void 0)return e[t];let r=Object.keys(e);if(r.length===1)return e[r[0]]},s8=(e,t)=>{let r=HD(e,t);if(!r){let i=Object.keys(e);throw new Error(`input values have ${i.length} keys, you must specify an input key or pass only 1 key as input`)}return r},c8=(e,t)=>{let r=HD(e,t);if(!r&&r!==""){let i=Object.keys(e);throw new Error(`output values have ${i.length} keys, you must specify an output key or pass only 1 key as output`)}return r};function u8(e,t){let r=Object.keys(e).filter(i=>!t.includes(i)&&i!=="stop");if(r.length!==1)throw new Error(`One input key expected, but got ${r.length}`);return r[0]}var c$=class extends Uu{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)}`)}},u$=class extends Ai{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 c$(e)}_diff(e,t){if(t)return Yi(e??{},t)}async parsePartialResult(e){let t=e[0];if(!t.message)return;let{message:r}=t,i=r.additional_kwargs.function_call;if(i)return this.argsOnly?jn(i.arguments):{...i,arguments:jn(i.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""}},ZD=class extends Uu{static lc_name(){return"JsonKeyOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser=new u$;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 GD=C({JsonKeyOutputFunctionsParser:()=>ZD,JsonOutputFunctionsParser:()=>u$,OutputFunctionsParser:()=>c$});var KD=C({JsonOutputKeyToolsParser:()=>Zg,JsonOutputToolsParser:()=>i$,convertLangChainToolCallToOpenAI:()=>kD,makeInvalidToolCall:()=>$D,parseToolCall:()=>n$});var Oi=class extends ue{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[i,n]of Object.entries(t))typeof n=="string"?r[i]=n:r[i]=await n();return{...r,...e}}async invoke(e,t){let r={...this.metadata,...t?.metadata},i=[...this.tags??[],...t?.tags??[]];return this._callWithConfig(n=>this.formatPromptValue(n),e,{...t,tags:i,metadata:r,runType:"prompt"})}};var ho=class extends Oi{async formatPromptValue(e){let t=await this.format(e);return new Yd(t)}};var l8=Object.prototype.toString,Hu=Array.isArray||function(t){return l8.call(t)==="[object Array]"};function d$(e){return typeof e=="function"}function d8(e){return Hu(e)?"array":typeof e}function l$(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function WD(e,t){return e!=null&&typeof e=="object"&&t in e}function f8(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var p8=RegExp.prototype.test;function m8(e,t){return p8.call(e,t)}var h8=/\S/;function g8(e){return!m8(h8,e)}var _8={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function y8(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return _8[r]})}var v8=/\s*/,b8=/\s+/,qD=/\s*=/,w8=/\s*\}/,x8=/#|\^|\/|>|\{|&|=|!/;function S8(e,t){if(!e)return[];var r=!1,i=[],n=[],o=[],a=!1,s=!1,c="",u=0;function l(){if(a&&!s)for(;o.length;)delete n[o.pop()];else o=[];a=!1,s=!1}var d,f,p;function m(b){if(typeof b=="string"&&(b=b.split(b8,2)),!Hu(b)||b.length!==2)throw new Error("Invalid tags: "+b);d=new RegExp(l$(b[0])+"\\s*"),f=new RegExp("\\s*"+l$(b[1])),p=new RegExp("\\s*"+l$("}"+b[1]))}m(t||En.tags);for(var h=new sf(e),g,_,v,x,S,k;!h.eos();){if(g=h.pos,v=h.scanUntil(d),v)for(var T=0,A=v.length;T<A;++T)x=v.charAt(T),g8(x)?(o.push(n.length),c+=x):(s=!0,r=!0,c+=" "),n.push(["text",x,g,g+1]),g+=1,x===`
321
+ `&&(l(),c="",u=0,r=!1);if(!h.scan(d))break;if(a=!0,_=h.scan(x8)||"name",h.scan(v8),_==="="?(v=h.scanUntil(qD),h.scan(qD),h.scanUntil(f)):_==="{"?(v=h.scanUntil(p),h.scan(w8),h.scanUntil(f),_="&"):v=h.scanUntil(f),!h.scan(f))throw new Error("Unclosed tag at "+h.pos);if(_==">"?S=[_,v,g,h.pos,c,u,r]:S=[_,v,g,h.pos],u++,n.push(S),_==="#"||_==="^")i.push(S);else if(_==="/"){if(k=i.pop(),!k)throw new Error('Unopened section "'+v+'" at '+g);if(k[1]!==v)throw new Error('Unclosed section "'+k[1]+'" at '+g)}else _==="name"||_==="{"||_==="&"?s=!0:_==="="&&m(v)}if(l(),k=i.pop(),k)throw new Error('Unclosed section "'+k[1]+'" at '+h.pos);return $8(k8(n))}function k8(e){for(var t=[],r,i,n=0,o=e.length;n<o;++n)r=e[n],r&&(r[0]==="text"&&i&&i[0]==="text"?(i[1]+=r[1],i[3]=r[3]):(t.push(r),i=r));return t}function $8(e){for(var t=[],r=t,i=[],n,o,a=0,s=e.length;a<s;++a)switch(n=e[a],n[0]){case"#":case"^":r.push(n),i.push(n),r=n[4]=[];break;case"/":o=i.pop(),o[5]=n[2],r=i.length>0?i[i.length-1][4]:t;break;default:r.push(n)}return t}function sf(e){this.string=e,this.tail=e,this.pos=0}sf.prototype.eos=function(){return this.tail===""};sf.prototype.scan=function(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var i=r[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i};sf.prototype.scanUntil=function(t){var r=this.tail.search(t),i;switch(r){case-1:i=this.tail,this.tail="";break;case 0:i="";break;default:i=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=i.length,i};function Vu(e,t){this.view=e,this.cache={".":this.view},this.parent=t}Vu.prototype.push=function(t){return new Vu(t,this)};Vu.prototype.lookup=function(t){var r=this.cache,i;if(r.hasOwnProperty(t))i=r[t];else{for(var n=this,o,a,s,c=!1;n;){if(t.indexOf(".")>0)for(o=n.view,a=t.split("."),s=0;o!=null&&s<a.length;)s===a.length-1&&(c=WD(o,a[s])||f8(o,a[s])),o=o[a[s++]];else o=n.view[t],c=WD(n.view,t);if(c){i=o;break}n=n.parent}r[t]=i}return d$(i)&&(i=i.call(this.view)),i};function Pr(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}Pr.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};Pr.prototype.parse=function(t,r){var i=this.templateCache,n=t+":"+(r||En.tags).join(":"),o=typeof i<"u",a=o?i.get(n):void 0;return a==null&&(a=S8(t,r),o&&i.set(n,a)),a};Pr.prototype.render=function(t,r,i,n){var o=this.getConfigTags(n),a=this.parse(t,o),s=r instanceof Vu?r:new Vu(r,void 0);return this.renderTokens(a,s,i,t,n)};Pr.prototype.renderTokens=function(t,r,i,n,o){for(var a="",s,c,u,l=0,d=t.length;l<d;++l)u=void 0,s=t[l],c=s[0],c==="#"?u=this.renderSection(s,r,i,n,o):c==="^"?u=this.renderInverted(s,r,i,n,o):c===">"?u=this.renderPartial(s,r,i,o):c==="&"?u=this.unescapedValue(s,r):c==="name"?u=this.escapedValue(s,r,o):c==="text"&&(u=this.rawValue(s)),u!==void 0&&(a+=u);return a};Pr.prototype.renderSection=function(t,r,i,n,o){var a=this,s="",c=r.lookup(t[1]);function u(f){return a.render(f,r,i,o)}if(c){if(Hu(c))for(var l=0,d=c.length;l<d;++l)s+=this.renderTokens(t[4],r.push(c[l]),i,n,o);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")s+=this.renderTokens(t[4],r.push(c),i,n,o);else if(d$(c)){if(typeof n!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(r.view,n.slice(t[3],t[5]),u),c!=null&&(s+=c)}else s+=this.renderTokens(t[4],r,i,n,o);return s}};Pr.prototype.renderInverted=function(t,r,i,n,o){var a=r.lookup(t[1]);if(!a||Hu(a)&&a.length===0)return this.renderTokens(t[4],r,i,n,o)};Pr.prototype.indentPartial=function(t,r,i){for(var n=r.replace(/[^ \t]/g,""),o=t.split(`
322
+ `),a=0;a<o.length;a++)o[a].length&&(a>0||!i)&&(o[a]=n+o[a]);return o.join(`
323
+ `)};Pr.prototype.renderPartial=function(t,r,i,n){if(i){var o=this.getConfigTags(n),a=d$(i)?i(t[1]):i[t[1]];if(a!=null){var s=t[6],c=t[5],u=t[4],l=a;c==0&&u&&(l=this.indentPartial(a,u,s));var d=this.parse(l,o);return this.renderTokens(d,r,i,l,n)}}};Pr.prototype.unescapedValue=function(t,r){var i=r.lookup(t[1]);if(i!=null)return i};Pr.prototype.escapedValue=function(t,r,i){var n=this.getConfigEscape(i)||En.escape,o=r.lookup(t[1]);if(o!=null)return typeof o=="number"&&n===En.escape?String(o):n(o)};Pr.prototype.rawValue=function(t){return t[1]};Pr.prototype.getConfigTags=function(t){return Hu(t)?t:t&&typeof t=="object"?t.tags:void 0};Pr.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!Hu(t))return t.escape};var En={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){af.templateCache=e},get templateCache(){return af.templateCache}},af=new Pr;En.clearCache=function(){return af.clearCache()};En.parse=function(t,r){return af.parse(t,r)};En.render=function(t,r,i,n){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+d8(t)+'" was given as the first argument for mustache#render(template, view, partials)');return af.render(t,r,i,n)};En.escape=y8;En.Scanner=sf;En.Context=Vu;En.Writer=Pr;var f$=En;var I8={escape:e=>e},ec=e=>{let t=e.split(""),r=[],i=(o,a)=>{for(let s=a;s<t.length;s+=1)if(o.includes(t[s]))return s;return-1},n=0;for(;n<t.length;)if(t[n]==="{"&&n+1<t.length&&t[n+1]==="{")r.push({type:"literal",text:"{"}),n+=2;else if(t[n]==="}"&&n+1<t.length&&t[n+1]==="}")r.push({type:"literal",text:"}"}),n+=2;else if(t[n]==="{"){let o=i("}",n);if(o<0)throw new Error("Unclosed '{' in template.");r.push({type:"variable",name:t.slice(n+1,o).join("")}),n=o+1}else{if(t[n]==="}")throw new Error("Single '}' in template.");{let o=i("{}",n),a=(o<0?t.slice(n):t.slice(n,o)).join("");r.push({type:"literal",text:a}),n=o<0?t.length:o}}return r},JD=(e,t=[])=>{let r=[];for(let i of e)if(i[0]==="name"){let n=i[1].includes(".")?i[1].split(".")[0]:i[1];r.push({type:"variable",name:n})}else if(["#","&","^",">"].includes(i[0])){if(r.push({type:"variable",name:i[1]}),i[0]==="#"&&i.length>4&&Array.isArray(i[4])){let n=[...t,i[1]],o=JD(i[4],n);r.push(...o)}}else r.push({type:"literal",text:i[1]});return r},Zu=e=>{let t=f$.parse(e);return JD(t)},p$=(e,t)=>ec(e).reduce((r,i)=>{if(i.type==="variable"){if(i.name in t)return r+(typeof t[i.name]=="string"?t[i.name]:JSON.stringify(t[i.name]));throw new Error(`(f-string) Missing value for input ${i.name}`)}return r+i.text},""),m$=(e,t)=>f$.render(e,t,void 0,I8),cf={"f-string":p$,mustache:m$},h$={"f-string":ec,mustache:Zu},gr=(e,t,r)=>{try{return cf[t](e,r)}catch(i){throw Bi(i,"INVALID_PROMPT_INPUT")}},tc=(e,t)=>h$[t](e),go=(e,t,r)=>{if(!(t in cf)){let i=Object.keys(cf);throw new Error(`Invalid template format. Got \`${t}\`;
324
+ should be one of ${i}`)}try{let i=Object.fromEntries(r.map(n=>[n,"foo"]));Array.isArray(e)?e.forEach(n=>{if(n.type==="text"&&"text"in n&&typeof n.text=="string")gr(n.text,t,i);else if(n.type==="image_url"){if(typeof n.image_url=="string")gr(n.image_url,t,i);else if(typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url&&typeof n.image_url.url=="string"){let o=n.image_url.url;gr(o,t,i)}}else throw new Error(`Invalid message template received. ${JSON.stringify(n,null,2)}`)}):gr(e,t,i)}catch(i){throw new Error(`Invalid prompt schema: ${i.message}`)}};var Gn=class uf extends ho{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))),go(this.template,this.templateFormat,r)}}_getPromptType(){return"prompt"}async format(t){let r=await this.mergePartialAndUserVariables(t);return gr(this.template,this.templateFormat,r)}static fromExamples(t,r,i,n=`
325
+
326
+ `,o=""){let a=[o,...t,r].join(n);return new uf({inputVariables:i,template:a})}static fromTemplate(t,r){let{templateFormat:i="f-string",...n}=r??{},o=new Set;return tc(t,i).forEach(a=>{a.type==="variable"&&o.add(a.name)}),new uf({inputVariables:[...o],templateFormat:i,template:t,...n})}async partial(t){let r=this.inputVariables.filter(o=>!(o in t)),i={...this.partialVariables??{},...t},n={...this,inputVariables:r,partialVariables:i};return new uf(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 uf({inputVariables:t.input_variables,template:t.template,templateFormat:t.template_format})}};var Gu=class XD extends Oi{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))),go([{type:"image_url",image_url:this.template}],this.templateFormat,r)}}_getPromptType(){return"prompt"}async partial(t){let r=this.inputVariables.filter(o=>!(o in t)),i={...this.partialVariables??{},...t},n={...this,inputVariables:r,partialVariables:i};return new XD(n)}async format(t){let r={};for(let[a,s]of Object.entries(this.template))typeof s=="string"?r[a]=gr(s,this.templateFormat,t):r[a]=s;let i=t.url||r.url,n=t.detail||r.detail;if(!i)throw new Error("Must provide either an image URL.");if(typeof i!="string")throw new Error("url must be a string.");let o={url:i};return n&&(o.detail=n),o}async formatPromptValue(t){let r=await this.format(t);return new Yk(r)}};var lf=class extends ue{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=g$(e.template,t);super({inputVariables:r,...e}),this.template=e.template,this.templateFormat=t,this.inputVariables=r}async format(e){return _$(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}};function g$(e,t){let r=[];for(let i of Object.values(e))if(typeof i=="string")tc(i,t).forEach(n=>{n.type==="variable"&&r.push(n.name)});else if(Array.isArray(i))for(let n of i)typeof n=="string"?tc(n,t).forEach(o=>{o.type==="variable"&&r.push(o.name)}):typeof n=="object"&&r.push(...g$(n,t));else typeof i=="object"&&i!==null&&r.push(...g$(i,t));return Array.from(new Set(r))}function _$(e,t,r){let i={};for(let[n,o]of Object.entries(e))if(typeof o=="string")i[n]=gr(o,r,t);else if(Array.isArray(o)){let a=[];for(let s of o)typeof s=="string"?a.push(gr(s,r,t)):typeof s=="object"&&a.push(_$(s,t,r));i[n]=a}else typeof o=="object"&&o!==null?i[n]=_$(o,t,r):i[n]=o;return i}var df=class extends ue{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;async invoke(e,t){return this._callWithConfig(r=>this.formatMessages(r),e,{...t,runType:"prompt"})}},Jg=class extends df{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 i=new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);throw i.name="InputFormatError",i}let r;try{Array.isArray(t)?r=t.map(Nt):r=[Nt(t)]}catch(i){let n=typeof t=="string"?t:JSON.stringify(t,null,2),o=new Error([`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages or coerceable values as input.`,`Received value: ${n}`,`Additional message: ${i.message}`].join(`
327
+
328
+ `));throw o.name="InputFormatError",o.lc_error_code=i.lc_error_code,o}return r}},y$=class extends df{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)]}},ff=class extends Oi{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){let t=await this.formatMessages(e);return new Qd(t)}},v$=class extends y${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 Dn(await this.prompt.format(e),this.role)}static fromTemplate(e,t,r){return new this(Gn.fromTemplate(e,{templateFormat:r?.templateFormat}),t)}};function E8(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).length===1&&"text"in e&&typeof e.text=="string"}function T8(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 b$=class extends df{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(i=>{"inputVariables"in i&&(r=r.concat(i.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(Gn.fromTemplate(e,t));let r=[];for(let i of e)if(typeof i=="string")r.push(Gn.fromTemplate(i,t));else if(i!==null)if(E8(i)){let n="";typeof i.text=="string"&&(n=i.text??"");let o={...t,additionalContentFields:i};r.push(Gn.fromTemplate(n,o))}else if(T8(i)){let n=i.image_url??"",o,a=[];if(typeof n=="string"){let s;t?.templateFormat==="mustache"?s=Zu(n):s=ec(n);let c=s.flatMap(u=>u.type==="variable"?[u.name]:[]);if((c?.length??0)>0){if(c.length>1)throw new Error(`Only one format variable allowed per image template.
329
+ Got: ${c}
330
+ From: ${n}`);a=[c[0]]}else a=[];n={url:n},o=new Gu({template:n,inputVariables:a,templateFormat:t?.templateFormat,additionalContentFields:i})}else if(typeof n=="object"){if("url"in n){let s;t?.templateFormat==="mustache"?s=Zu(n.url):s=ec(n.url),a=s.flatMap(c=>c.type==="variable"?[c.name]:[])}else a=[];o=new Gu({template:n,inputVariables:a,templateFormat:t?.templateFormat,additionalContentFields:i})}else throw new Error("Invalid image template");r.push(o)}else typeof i=="object"&&r.push(new lf({template:i,templateFormat:t?.templateFormat}));return new this({prompt:r,additionalOptions:t})}async format(e){if(this.prompt instanceof ho){let t=await this.prompt.format(e);return this.createMessage(t)}else{let t=[];for(let r of this.prompt){let i={};if(!("inputVariables"in r))throw new Error(`Prompt ${r} does not have inputVariables defined.`);for(let n of r.inputVariables)i||(i={[n]:e[n]}),i={...i,[n]:e[n]};if(r instanceof ho){let n=await r.format(i),o;"additionalContentFields"in r&&(o=r.additionalContentFields),n!==""&&t.push({...o,type:"text",text:n})}else if(r instanceof Gu){let n=await r.format(i),o;"additionalContentFields"in r&&(o=r.additionalContentFields),t.push({...o,type:"image_url",image_url:n})}else if(r instanceof lf){let n=await r.format(i),o;"additionalContentFields"in r&&(o=r.additionalContentFields),t.push({...o,...n})}}return this.createMessage(t)}}async formatMessages(e){return[await this.format(e)]}},Xg=class extends b${static _messageClass(){return ht}static lc_name(){return"HumanMessagePromptTemplate"}},w$=class extends b${static _messageClass(){return Le}static lc_name(){return"AIMessagePromptTemplate"}},x$=class extends b${static _messageClass(){return xr}static lc_name(){return"SystemMessagePromptTemplate"}};function A8(e){return typeof e.formatMessages=="function"}function C8(e,t){if(A8(e)||lt(e))return e;if(Array.isArray(e)&&e[0]==="placeholder"){let n=e[1];if(t?.templateFormat==="mustache"&&typeof n=="string"&&n.slice(0,2)==="{{"&&n.slice(-2)==="}}")return new Jg({variableName:n.slice(2,-2),optional:!0});if(typeof n=="string"&&n[0]==="{"&&n[n.length-1]==="}")return new Jg({variableName:n.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=Nt(e),i;if(typeof r.content=="string"?i=r.content:i=r.content.map(n=>"text"in n?{...n,text:n.text}:"image_url"in n?{...n,image_url:n.image_url}:n),r._getType()==="human")return Xg.fromTemplate(i,t);if(r._getType()==="ai")return w$.fromTemplate(i,t);if(r._getType()==="system")return x$.fromTemplate(i,t);if(Dn.isInstance(r))return v$.fromTemplate(r.content,r.role,t);throw new Error(`Could not coerce message prompt template from input. Received message type: "${r._getType()}".`)}function O8(e){return e.constructor.lc_name()==="MessagesPlaceholder"}var Ku=class qg extends ff{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 ze))for(let c of s.inputVariables)r.add(c);let i=this.inputVariables,n=new Set(this.partialVariables?i.concat(Object.keys(this.partialVariables)):i),o=new Set([...n].filter(s=>!r.has(s)));if(o.size>0)throw new Error(`Input variables \`${[...o]}\` are not used in any of the prompt messages.`);let a=new Set([...r].filter(s=>!n.has(s)));if(a.size>0)throw new Error(`Input variables \`${[...a]}\` 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 i=>{if(i.type!=="image_url")return i;let n="";typeof i.image_url=="string"?n=i.image_url:typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url&&typeof i.image_url.url=="string"&&(n=i.image_url.url);let o=await Gn.fromTemplate(n,{templateFormat:this.templateFormat}).format(r);return typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url?i.image_url.url=o:i.image_url=o,i}))),t}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),i=[];for(let n of this.promptMessages)if(n instanceof ze)i.push(await this._parseImagePrompts(n,r));else{let o;this.templateFormat==="mustache"?o={...r}:o=n.inputVariables.reduce((s,c)=>{if(!(c in r)&&!(O8(n)&&n.optional))throw Bi(new Error(`Missing value for input variable \`${c.toString()}\``),"INVALID_PROMPT_INPUT");return s[c]=r[c],s},{});let a=await n.formatMessages(o);i=i.concat(a)}return i}async partial(t){let r=this.inputVariables.filter(o=>!(o in t)),i={...this.partialVariables??{},...t},n={...this,inputVariables:r,partialVariables:i};return new qg(n)}static fromTemplate(t,r){let i=new Xg({prompt:Gn.fromTemplate(t,r)});return this.fromMessages([i])}static fromMessages(t,r){let i=t.reduce((a,s)=>a.concat(s instanceof qg?s.promptMessages:[C8(s,r)]),[]),n=t.reduce((a,s)=>s instanceof qg?Object.assign(a,s.partialVariables):a,Object.create(null)),o=new Set;for(let a of i)if(!(a instanceof ze))for(let s of a.inputVariables)s in n||o.add(s);return new this({...r,inputVariables:[...o],promptMessages:i,partialVariables:n,templateFormat:r?.templateFormat})}};var YD=class S$ extends ho{lc_serializable=!1;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
331
+
332
+ `;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))),go(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(o=>!(o in t)),i={...this.partialVariables??{},...t},n={...this,inputVariables:r,partialVariables:i};return new S$(n)}async format(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r),n=await Promise.all(i.map(a=>this.examplePrompt.format(a))),o=[this.prefix,...n,this.suffix].join(this.exampleSeparator);return gr(o,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 i=await Gn.deserialize(r),n;if(Array.isArray(t.examples))n=t.examples;else throw new Error("Invalid examples format. Only list or string are supported.");return new S$({inputVariables:t.input_variables,examplePrompt:i,examples:n,exampleSeparator:t.example_separator,prefix:t.prefix,suffix:t.suffix,templateFormat:t.template_format})}},QD=class eM extends ff{lc_serializable=!0;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
333
+
334
+ `;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??`
335
+
336
+ `,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))),go(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),i=await this.getExamples(r);i=i.map(o=>{let a={};return this.examplePrompt.inputVariables.forEach(s=>{a[s]=o[s]}),a});let n=[];for(let o of i){let a=await this.examplePrompt.formatMessages(o);n.push(...a)}return n}async format(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r),n=(await Promise.all(i.map(a=>this.examplePrompt.formatMessages(a)))).flat().map(a=>a.content),o=[this.prefix,...n,this.suffix].join(this.exampleSeparator);return gr(o,this.templateFormat,r)}async partial(t){let r=this.inputVariables.filter(o=>!(o in t)),i={...this.partialVariables??{},...t},n={...this,inputVariables:r,partialVariables:i};return new eM(n)}};var tM=class Yg extends Oi{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(i=>i.name),r=this.pipelinePrompts.map(i=>i.prompt.inputVariables.filter(n=>!t.includes(n))).flat();return[...new Set(r)]}static extractRequiredInputValues(t,r){return r.reduce((i,n)=>(i[n]=t[n],i),{})}async formatPipelinePrompts(t){let r=await this.mergePartialAndUserVariables(t);for(let{name:i,prompt:n}of this.pipelinePrompts){let o=Yg.extractRequiredInputValues(r,n.inputVariables);n instanceof Ku?r[i]=await n.formatMessages(o):r[i]=await n.format(o)}return Yg.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(i=>!(i in t)),r.partialVariables={...this.partialVariables??{},...t},new Yg(r)}serialize(){throw new Error("Not implemented.")}_getPromptType(){return"pipeline"}};function rM(e){return typeof e=="object"&&e!=null&&"withStructuredOutput"in e&&typeof e.withStructuredOutput=="function"}function P8(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 nM=class iM extends Ku{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(rM(t))return super.pipe(t.withStructuredOutput(this.schema));if(P8(t)&&rM(t.bound))return super.pipe(new $n({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,i){return iM.fromMessages(t,{schema:r,method:i})}};var oM=C({AIMessagePromptTemplate:()=>w$,BaseChatPromptTemplate:()=>ff,BaseMessagePromptTemplate:()=>df,BaseMessageStringPromptTemplate:()=>y$,BasePromptTemplate:()=>Oi,BaseStringPromptTemplate:()=>ho,ChatMessagePromptTemplate:()=>v$,ChatPromptTemplate:()=>Ku,DEFAULT_FORMATTER_MAPPING:()=>cf,DEFAULT_PARSER_MAPPING:()=>h$,DictPromptTemplate:()=>lf,FewShotChatMessagePromptTemplate:()=>QD,FewShotPromptTemplate:()=>YD,HumanMessagePromptTemplate:()=>Xg,ImagePromptTemplate:()=>Gu,MessagesPlaceholder:()=>Jg,PipelinePromptTemplate:()=>tM,PromptTemplate:()=>Gn,StructuredPrompt:()=>nM,SystemMessagePromptTemplate:()=>x$,checkValidTemplate:()=>go,interpolateFString:()=>p$,interpolateMustache:()=>m$,parseFString:()=>ec,parseMustache:()=>Zu,parseTemplate:()=>tc,renderTemplate:()=>gr});var aM=C({BaseDocumentCompressor:()=>N8}),N8=class{static isBaseDocumentCompressor(e){return e?.compressDocuments!==void 0}};var sM=C({BaseRetriever:()=>pf}),pf=class extends ue{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=Ae(ms(t)),i=await(await at.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 n=await this._getRelevantDocuments(e,i);return await i?.handleRetrieverEnd(n),n}catch(n){throw await i?.handleRetrieverError(n),n}}};var cM=C({BaseStore:()=>uM,InMemoryStore:()=>R8}),uM=class extends xt{},R8=class extends uM{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 Kn={and:"and",or:"or",not:"not"},Re={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte"},Qg=class{},e_=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")}},t_=class extends e_{},lM=class extends t_{comparator;attribute;value;exprName="Comparison";constructor(e,t,r){super(),this.comparator=e,this.attribute=t,this.value=r}},dM=class extends t_{operator;args;exprName="Operation";constructor(e,t){super(),this.operator=e,this.args=t}},fM=class extends e_{query;filter;exprName="StructuredQuery";constructor(e,t){super(),this.query=e,this.filter=t}};function k$(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Kr(e){return e?typeof e=="string"&&e.length>0||typeof e=="function"?!1:k$(e)&&Object.keys(e).length===0:!0}function $$(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 I$(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 E$(e){return typeof e=="string"&&(Number.isNaN(parseFloat(e))||parseFloat(e).toString()!==e)}function T$(e){return typeof e=="boolean"}function Wu(e){let t;if(E$(e))t=e;else if($$(e))t=parseInt(e,10);else if(I$(e))t=parseFloat(e);else if(T$(e))t=!!e;else throw new Error("Unsupported value type");return t}var mf=class extends Qg{},pM=class extends mf{allowedOperators;allowedComparators;constructor(e){super(),this.allowedOperators=e?.allowedOperators??[Kn.and,Kn.or],this.allowedComparators=e?.allowedComparators??[Re.eq,Re.ne,Re.gt,Re.gte,Re.lt,Re.lte]}formatFunction(e){if(e in Re){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 Kn){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)]:Wu(e.value)}}}visitStructuredQuery(e){let t={};return e.filter&&(t={filter:e.filter.accept(this)}),t}mergeFilters(e,t,r="and",i=!1){if(!(Kr(e)&&Kr(t))){if(Kr(e)||r==="replace")return Kr(t)?void 0:t;if(Kr(t))return i?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 mM=class extends mf{allowedOperators=[Kn.and,Kn.or];allowedComparators=[Re.eq,Re.ne,Re.gt,Re.gte,Re.lt,Re.lte];formatFunction(){throw new Error("Not implemented")}getAllowedComparatorsForType(e){switch(e){case"string":return[Re.eq,Re.ne,Re.gt,Re.gte,Re.lt,Re.lte];case"number":return[Re.eq,Re.ne,Re.gt,Re.gte,Re.lt,Re.lte];case"boolean":return[Re.eq,Re.ne];default:throw new Error(`Unsupported data type: ${e}`)}}getComparatorFunction(e){switch(e){case Re.eq:return(t,r)=>t===r;case Re.ne:return(t,r)=>t!==r;case Re.gt:return(t,r)=>t>r;case Re.gte:return(t,r)=>t>=r;case Re.lt:return(t,r)=>t<r;case Re.lte:return(t,r)=>t<=r;default:throw new Error("Unknown comparator")}}getOperatorFunction(e){switch(e){case Kn.and:return(t,r)=>t&&r;case Kn.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 i=this.getOperatorFunction(t);return n=>r?r.reduce((o,a)=>{let s=a.accept(this);if(typeof s=="function")return i(o,s(n));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:i}=e,n=[Re.ne];if(this.allowedComparators.includes(t)){if(!this.getAllowedComparatorsForType(typeof i).includes(t))throw new Error(`'${t}' comparator not allowed to be used with ${typeof i}`);let o=this.getComparatorFunction(t);return a=>{let s=a.metadata[r];return s===void 0?!!n.includes(t):o(s,Wu(i))}}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(!(Kr(e)&&Kr(t))){if(Kr(e)||r==="replace")return Kr(t)?void 0:t;if(Kr(t))return r==="and"?void 0:e;if(r==="and")return i=>e(i)&&t(i);if(r==="or")return i=>e(i)||t(i);throw new Error("Unknown merge type")}}};var hM=C({BaseTranslator:()=>mf,BasicTranslator:()=>pM,Comparators:()=>Re,Comparison:()=>lM,Expression:()=>e_,FilterDirective:()=>t_,FunctionalTranslator:()=>mM,Operation:()=>dM,Operators:()=>Kn,StructuredQuery:()=>fM,Visitor:()=>Qg,castValue:()=>Wu,isBoolean:()=>T$,isFilterEmpty:()=>Kr,isFloat:()=>I$,isInt:()=>$$,isObject:()=>k$,isString:()=>E$});function hf(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 gM(e,t,r){return e==null?!1:Object.entries(t).every(([i,n])=>r(e[i],n))}function _M(e,t,r){return e==null?!1:gM(e,t,r)}function yM(e){return e.content.find(t=>t.type==="text")?.text}function j8(e,t,r){if(t.id!==void 0&&e.id!==t.id||t.text!==void 0&&yM(e)!==t.text)return!1;if(t.toolCalls!==void 0){let i=e.tool_calls??[];if(i.length!==t.toolCalls.length)return!1;for(let n=0;n<t.toolCalls.length;n++){let o=i[n],a=t.toolCalls[n];if(o?.name!==a.name||!r(o.args,a.args))return!1}}return!(t.usage!==void 0&&!_M(e.usage_metadata,t.usage,r)||t.responseMetadata!==void 0&&!gM(e.response_metadata,t.responseMetadata,r))}function gf(e,t,r){return{pass:!1,message:()=>`${r.matcherHint(t)}
337
+
338
+ Expected: ChatModelStream (return value of model.streamEvents("Hello"))
339
+ Received: ${r.printReceived(e)}`,actual:e,expected:"ChatModelStream"}}function _f(e,t){return t?!e:e}async function D8(e,t){let{isNot:r,utils:i}=this,n="toHaveStreamText";if(!hf(e))return gf(e,n,i);let o=await e.text;return{pass:_f(o===t,r),message:()=>`${i.matcherHint(n,void 0,void 0,{isNot:r})}
340
+
341
+ Expected stream text: ${r?"not ":""}${i.printExpected(t)}
342
+ Received stream text: ${i.printReceived(o)}`,actual:o,expected:t}}async function M8(e,t){let{isNot:r,utils:i}=this,n="toHaveStreamReasoning";if(!hf(e))return gf(e,n,i);let o=await e.reasoning;return{pass:_f(o===t,r),message:()=>`${i.matcherHint(n,void 0,void 0,{isNot:r})}
343
+
344
+ Expected stream reasoning: ${r?"not ":""}${i.printExpected(t)}
345
+ Received stream reasoning: ${i.printReceived(o)}`,actual:o,expected:t}}async function z8(e,t){let{isNot:r,utils:i}=this,n="toHaveStreamToolCalls";if(!hf(e))return gf(e,n,i);let o=await e.toolCalls,a=o.length===t.length&&t.every((s,c)=>{let u=o[c];return u?.name===s.name&&this.equals(u.args,s.args)});return a=_f(a,r),{pass:a,message:()=>`${i.matcherHint(n,void 0,void 0,{isNot:r})}
346
+
347
+ Expected stream tool calls: ${i.printExpected(t)}
348
+ Received stream tool calls: ${i.printReceived(o.map(s=>({name:s.name,args:s.args})))}`,actual:o.map(s=>({name:s.name,args:s.args})),expected:t}}async function L8(e,t){let{isNot:r,utils:i}=this,n="toHaveStreamUsage";if(!hf(e))return gf(e,n,i);let o=await e.usage;return{pass:_f(_M(o,t,this.equals),r),message:()=>`${i.matcherHint(n,void 0,void 0,{isNot:r})}
349
+
350
+ Expected stream usage: ${i.printExpected(t)}
351
+ Received stream usage: ${i.printReceived(o)}`,actual:o,expected:t}}async function U8(e,t){let{isNot:r,utils:i}=this,n="toHaveStreamOutput";if(!hf(e))return gf(e,n,i);let o=await e.output;return{pass:_f(j8(o,t,this.equals),r),message:()=>`${i.matcherHint(n,void 0,void 0,{isNot:r})}
352
+
353
+ Expected stream output: ${i.printExpected(t)}
354
+ Received stream output: ${i.printReceived({id:o.id,text:yM(o),tool_calls:o.tool_calls?.map(a=>({name:a.name,args:a.args})),usage_metadata:o.usage_metadata,response_metadata:o.response_metadata})}`,actual:o,expected:t}}var qu={toHaveStreamText:D8,toHaveStreamReasoning:M8,toHaveStreamToolCalls:z8,toHaveStreamUsage:L8,toHaveStreamOutput:U8};function yf(e){return ze.isInstance(e)?e.constructor.name||e.type:typeof e}function r_(e,t){return function(r,i){let{isNot:n,utils:o}=this;if(!t(r))return{pass:!1,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
355
+
356
+ Expected: ${n?"not ":""}${e}
357
+ Received: ${yf(r)}`,actual:yf(r),expected:e};if(i===void 0)return{pass:!0,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
358
+
359
+ Expected: not ${e}
360
+ Received: ${e}`};let a=r;return typeof i=="string"?{pass:a.content===i,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
361
+
362
+ Expected: ${e} with content ${o.printExpected(i)}
363
+ Received: ${e} with content ${o.printReceived(a.content)}`,actual:a.content,expected:i}:{pass:Object.entries(i).every(([s,c])=>this.equals(a[s],c)),message:()=>{let s={};for(let c of Object.keys(i))s[c]=a[c];return`${o.matcherHint(`toBe${e}`,void 0,void 0)}
364
+
365
+ Expected: ${e} matching ${o.printExpected(i)}
366
+ Received: ${e} with ${o.printReceived(s)}`},actual:(()=>{let s={};for(let c of Object.keys(i))s[c]=a[c];return s})(),expected:i}}}var A$=r_("HumanMessage",ht.isInstance),C$=r_("AIMessage",Le.isInstance),O$=r_("SystemMessage",xr.isInstance),P$=r_("ToolMessage",Pt.isInstance);function N$(e,t){let{isNot:r,utils:i}=this;if(!Le.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
367
+
368
+ Expected: AIMessage
369
+ Received: ${yf(e)}`};let n=e.tool_calls??[];if(n.length!==t.length)return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
370
+
371
+ Expected ${r?"not ":""}${t.length} tool call(s), received ${n.length}`,actual:n.length,expected:t.length};let o=t.filter(a=>!n.some(s=>Object.entries(a).every(([c,u])=>this.equals(s[c],u))));return o.length>0?{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
372
+
373
+ Could not find matching tool call(s) for:
374
+ ${i.printExpected(o)}
375
+ Received tool calls: ${i.printReceived(n.map(a=>({name:a.name,id:a.id,args:a.args})))}`,actual:n.map(a=>({name:a.name,id:a.id,args:a.args})),expected:t}:{pass:!0,message:()=>`${i.matcherHint("toHaveToolCalls")}
376
+
377
+ Expected AIMessage not to have matching tool calls`}}function R$(e,t){let{isNot:r,utils:i}=this;if(!Le.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCallCount")}
378
+
379
+ Expected: AIMessage
380
+ Received: ${yf(e)}`};let n=e.tool_calls?.length??0;return{pass:n===t,message:()=>`${i.matcherHint("toHaveToolCallCount")}
381
+
382
+ Expected ${r?"not ":""}${t} tool call(s)
383
+ Received: ${n}`,actual:n,expected:t}}function j$(e,t){let{isNot:r,utils:i}=this;if(!Le.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toContainToolCall")}
384
+
385
+ Expected: AIMessage
386
+ Received: ${yf(e)}`};let n=e.tool_calls??[];return{pass:n.some(o=>Object.entries(t).every(([a,s])=>this.equals(o[a],s))),message:()=>`${i.matcherHint("toContainToolCall")}
387
+
388
+ Expected AIMessage ${r?"not ":""}to contain a tool call matching ${i.printExpected(t)}
389
+ Received tool calls: ${i.printReceived(n.map(o=>({name:o.name,id:o.id})))}`,actual:n.map(o=>({name:o.name,id:o.id})),expected:t}}function D$(e,t){let{isNot:r,utils:i}=this;if(!Array.isArray(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolMessages")}
390
+
391
+ Expected an array of messages
392
+ Received: ${typeof e}`};let n=e.filter(Pt.isInstance);if(n.length!==t.length)return{pass:!1,message:()=>`${i.matcherHint("toHaveToolMessages")}
393
+
394
+ Expected ${r?"not ":""}${t.length} tool message(s), found ${n.length}`,actual:n.length,expected:t.length};for(let o=0;o<t.length;o++)if(!Object.entries(t[o]).every(([a,s])=>this.equals(n[o][a],s)))return{pass:!1,message:()=>{let a={};for(let s of Object.keys(t[o]))a[s]=n[o][s];return`${i.matcherHint("toHaveToolMessages")}
395
+
396
+ Tool message at index ${o} did not match:
397
+ Expected: ${i.printExpected(t[o])}
398
+ Received: ${i.printReceived(a)}`},actual:n[o],expected:t[o]};return{pass:!0,message:()=>`${i.matcherHint("toHaveToolMessages")}
399
+
400
+ Expected messages not to contain matching tool messages`}}function M$(e,t){let{isNot:r,utils:i}=this,n=e?.__interrupt__;if(!(Array.isArray(n)&&n.length>0))return{pass:!1,message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
401
+
402
+ Expected result ${r?"not ":""}to have been interrupted
403
+ Received __interrupt__: ${i.printReceived(n)}`};if(t===void 0)return{pass:!0,message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
404
+
405
+ Expected result not to have been interrupted
406
+ Received ${n.length} interrupt(s)`};let o=n[0]?.value;return{pass:this.equals(o,t),message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
407
+
408
+ Expected interrupt value: ${i.printExpected(t)}
409
+ Received interrupt value: ${i.printReceived(o)}`,actual:o,expected:t}}function z$(e,t){let{isNot:r,utils:i}=this,n=e?.structuredResponse;return n===void 0?{pass:!1,message:()=>`${i.matcherHint("toHaveStructuredResponse")}
410
+
411
+ Expected result ${r?"not ":""}to have a structured response
412
+ Received structuredResponse: undefined`}:t===void 0?{pass:!0,message:()=>`${i.matcherHint("toHaveStructuredResponse")}
413
+
414
+ Expected result not to have a structured response`}:{pass:Object.entries(t).every(([o,a])=>this.equals(n[o],a)),message:()=>`${i.matcherHint("toHaveStructuredResponse")}
415
+
416
+ Expected structured response: ${i.printExpected(t)}
417
+ Received structured response: ${i.printReceived(n)}`,actual:n,expected:t}}var vM={toBeHumanMessage:A$,toBeAIMessage:C$,toBeSystemMessage:O$,toBeToolMessage:P$,toHaveToolCalls:N$,toHaveToolCallCount:R$,toContainToolCall:j$,toHaveToolMessages:D$,toHaveBeenInterrupted:M$,toHaveStructuredResponse:z$,...qu};function F8(e){return e.map(t=>t.text).filter(Boolean).join("-")}var bM=0;function B8(){return bM+=1,`fake_tc_${bM}`}var L$=class wM extends ya{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}):ze.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??B8(),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],i=new wM;return i.queue=this.queue,i._alwaysThrowError=this._alwaysThrowError,i._structuredResponseValue=this._structuredResponseValue,i._tools=r,i._state=this._state,i.withConfig({})}withStructuredOutput(t,r){let{_structuredResponseValue:i}=this;return mr.from(async()=>i)}async _generate(t,r,i){this._state.calls.push({messages:[...t],options:r});let n=this._state.callIndex;if(this._state.callIndex+=1,this._alwaysThrowError)throw this._alwaysThrowError;let o=this.queue[n];if(!o)throw new Error(`FakeModel: no response queued for invocation ${n} (${this.queue.length} total queued).`);if(o.kind==="error")throw o.error;if(o.kind==="factory"){let s=o.factory(t);if(!ze.isInstance(s))throw s;return{generations:[{text:"",message:s}]}}if(o.kind==="message")return{generations:[{text:"",message:o.message}]};let a=F8(t);return{generations:[{text:a,message:new Le({content:a,id:n.toString(),tool_calls:o.toolCalls.length>0?o.toolCalls.map(s=>({...s,type:"tool_call"})):void 0})}],llmOutput:{}}}};function xM(){return new L$}function n_(e){return{async*[Symbol.asyncIterator](){for(let t of e)yield t}}}function i_(e="test-model"){let t=vf(e),r=t[t.length-1];return t[t.length-1]={...r,usage:{prompt_tokens:10,completion_tokens:2,total_tokens:12}},t}function vf(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 o_(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 a_(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 s_(e){let t=new TextEncoder;return new Response(new ReadableStream({start(r){for(let i of e)r.enqueue(t.encode(`data: ${JSON.stringify(i)}
418
+
419
+ `));r.close()}}),{status:200,headers:{"Content-Type":"text/event-stream"}})}var SM=C({FakeBuiltModel:()=>L$,asAsyncIterable:()=>n_,fakeModel:()=>xM,langchainMatchers:()=>vM,openAIReasoningTextChunks:()=>o_,openAITextOnlyChunks:()=>vf,openAITextOnlyChunksWithUsage:()=>i_,openAIToolCallChunks:()=>a_,sseResponseFromOpenAIChunks:()=>s_,streamMatchers:()=>qu,toBeAIMessage:()=>C$,toBeHumanMessage:()=>A$,toBeSystemMessage:()=>O$,toBeToolMessage:()=>P$,toContainToolCall:()=>j$,toHaveBeenInterrupted:()=>M$,toHaveStructuredResponse:()=>z$,toHaveToolCallCount:()=>R$,toHaveToolCalls:()=>N$,toHaveToolMessages:()=>D$});function bf(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function wf(e){return e!==void 0&&ue.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function xf(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(Hr(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 Sf(e){return xf(e)||wf(e)||bf(e)}var Tn={};ni(Tn,{$brand:()=>Wb,$input:()=>_0,$output:()=>g0,INVALID:()=>Ar,NEVER:()=>Kb,TimePrecision:()=>T0,ZodAny:()=>sI,ZodArray:()=>dI,ZodBase64:()=>I_,ZodBase64URL:()=>E_,ZodBigInt:()=>tl,ZodBigIntFormat:()=>C_,ZodBoolean:()=>el,ZodCIDRv4:()=>k_,ZodCIDRv6:()=>$_,ZodCUID:()=>__,ZodCUID2:()=>y_,ZodCatch:()=>PI,ZodCodec:()=>Nf,ZodCompileAsyncError:()=>Un,ZodCompileUnsupportedError:()=>Ne,ZodCreditCard:()=>Q$,ZodCustom:()=>Rf,ZodCustomStringFormat:()=>oc,ZodDate:()=>Ef,ZodDefault:()=>II,ZodDiscriminatedUnion:()=>pI,ZodE164:()=>T_,ZodEmail:()=>p_,ZodEmoji:()=>h_,ZodEnum:()=>Xu,ZodError:()=>V8,ZodExactOptional:()=>R_,ZodFile:()=>xI,ZodFirstPartyTypeKind:()=>GI,ZodFunction:()=>BI,ZodGUID:()=>m_,ZodIBAN:()=>eI,ZodIPv4:()=>x_,ZodIPv6:()=>S_,ZodISODate:()=>ba,ZodISODateTime:()=>va,ZodISODuration:()=>xa,ZodISOTime:()=>wa,ZodInstanceOf:()=>ZI,ZodIntersection:()=>mI,ZodIssueCode:()=>G8,ZodJWT:()=>A_,ZodKSUID:()=>w_,ZodLazy:()=>LI,ZodLiteral:()=>wI,ZodMAC:()=>Y$,ZodMap:()=>vI,ZodNaN:()=>RI,ZodNanoID:()=>g_,ZodNever:()=>uI,ZodNonOptional:()=>j_,ZodNull:()=>oI,ZodNullable:()=>$I,ZodNumber:()=>Qu,ZodNumberFormat:()=>ac,ZodObject:()=>Af,ZodOptional:()=>Of,ZodPipe:()=>Pf,ZodPrefault:()=>TI,ZodPreprocess:()=>jI,ZodPromise:()=>FI,ZodReadonly:()=>DI,ZodRealError:()=>Wr,ZodRecord:()=>Ju,ZodSet:()=>bI,ZodString:()=>Yu,ZodStringFormat:()=>Ke,ZodSuccess:()=>OI,ZodSymbol:()=>nI,ZodTemplateLiteral:()=>zI,ZodTransform:()=>SI,ZodTuple:()=>gI,ZodType:()=>we,ZodULID:()=>v_,ZodURL:()=>If,ZodUUID:()=>Pi,ZodUndefined:()=>iI,ZodUnion:()=>Cf,ZodUnknown:()=>cI,ZodVoid:()=>lI,ZodXID:()=>b_,ZodXor:()=>fI,_ZodString:()=>f_,_default:()=>EI,_function:()=>j4,any:()=>f4,array:()=>Tf,base64:()=>GM,base64url:()=>KM,bigint:()=>s4,boolean:()=>rI,catch:()=>NI,check:()=>D4,cidrv4:()=>HM,cidrv6:()=>ZM,clone:()=>Ie,codec:()=>O4,coerce:()=>WI,compile:()=>w0,config:()=>_t,core:()=>oo,creditCard:()=>qM,cuid:()=>DM,cuid2:()=>MM,currencyCode:()=>t4,custom:()=>M4,date:()=>m4,decode:()=>Z$,decodeAsync:()=>K$,deepPartial:()=>J4,describe:()=>z4,discriminatedUnion:()=>b4,e164:()=>WM,email:()=>IM,emoji:()=>RM,encode:()=>H$,encodeAsync:()=>G$,endsWith:()=>gu,enum:()=>P_,exactOptional:()=>kI,file:()=>E4,flattenError:()=>ad,float32:()=>n4,float64:()=>i4,formatError:()=>sd,fromJSONSchema:()=>W4,function:()=>j4,getDiscriminatedOption:()=>Hx,getErrorMap:()=>W8,globalRegistry:()=>He,gt:()=>wi,gte:()=>sn,guid:()=>EM,hash:()=>r4,hex:()=>e4,hostname:()=>QM,httpUrl:()=>NM,iban:()=>JM,includes:()=>mu,input:()=>Y4,instanceof:()=>U4,int:()=>l_,int32:()=>o4,int64:()=>c4,intersection:()=>hI,invertCodec:()=>P4,ipv4:()=>FM,ipv6:()=>VM,iso:()=>jf,json:()=>B4,jwt:()=>XM,keyof:()=>h4,ksuid:()=>UM,lazy:()=>UI,length:()=>Ps,literal:()=>I4,locales:()=>Ad,looseObject:()=>y4,looseRecord:()=>x4,lowercase:()=>fu,lt:()=>bi,lte:()=>an,mac:()=>BM,map:()=>S4,maxLength:()=>Os,maxSize:()=>oa,memoizer:()=>Ed,meta:()=>L4,mime:()=>yu,minLength:()=>io,minSize:()=>xi,multipleOf:()=>ia,nan:()=>C4,nanoid:()=>jM,nativeEnum:()=>$4,negative:()=>ig,never:()=>O_,nonnegative:()=>ag,nonoptional:()=>CI,nonpositive:()=>og,normalize:()=>vu,null:()=>aI,nullable:()=>$f,nullish:()=>T4,number:()=>tI,object:()=>g4,optional:()=>nc,output:()=>Q4,overwrite:()=>Fn,parse:()=>U$,parseAsync:()=>F$,partialRecord:()=>w4,pipe:()=>d_,positive:()=>ng,prefault:()=>AI,preprocess:()=>V4,prettifyError:()=>Qb,promise:()=>R4,properties:()=>_u,property:()=>sg,readonly:()=>MI,record:()=>yI,refine:()=>VI,regex:()=>du,regexes:()=>vn,registry:()=>Ph,safeDecode:()=>q$,safeDecodeAsync:()=>X$,safeEncode:()=>W$,safeEncodeAsync:()=>J$,safeParse:()=>B$,safeParseAsync:()=>V$,set:()=>k4,setErrorMap:()=>K8,size:()=>Cs,slugify:()=>Su,startsWith:()=>hu,strictObject:()=>_4,string:()=>kf,stringFormat:()=>YM,stringbool:()=>F4,success:()=>A4,superRefine:()=>HI,symbol:()=>l4,templateLiteral:()=>N4,toJSONSchema:()=>Rs,toLowerCase:()=>wu,toUpperCase:()=>xu,toZod:()=>Xl,transform:()=>N_,treeifyError:()=>Yb,trim:()=>bu,tuple:()=>_I,uint32:()=>a4,uint64:()=>u4,ulid:()=>zM,undefined:()=>d4,union:()=>rl,unknown:()=>rc,uppercase:()=>pu,url:()=>PM,util:()=>O,uuid:()=>TM,uuidv4:()=>AM,uuidv6:()=>CM,uuidv7:()=>OM,validate:()=>cd,validateAsync:()=>ud,void:()=>p4,withParser:()=>Nh,xid:()=>LM,xor:()=>v4});var nl={};ni(nl,{ZodAny:()=>sI,ZodArray:()=>dI,ZodBase64:()=>I_,ZodBase64URL:()=>E_,ZodBigInt:()=>tl,ZodBigIntFormat:()=>C_,ZodBoolean:()=>el,ZodCIDRv4:()=>k_,ZodCIDRv6:()=>$_,ZodCUID:()=>__,ZodCUID2:()=>y_,ZodCatch:()=>PI,ZodCodec:()=>Nf,ZodCreditCard:()=>Q$,ZodCustom:()=>Rf,ZodCustomStringFormat:()=>oc,ZodDate:()=>Ef,ZodDefault:()=>II,ZodDiscriminatedUnion:()=>pI,ZodE164:()=>T_,ZodEmail:()=>p_,ZodEmoji:()=>h_,ZodEnum:()=>Xu,ZodExactOptional:()=>R_,ZodFile:()=>xI,ZodFunction:()=>BI,ZodGUID:()=>m_,ZodIBAN:()=>eI,ZodIPv4:()=>x_,ZodIPv6:()=>S_,ZodISODate:()=>ba,ZodISODateTime:()=>va,ZodISODuration:()=>xa,ZodISOTime:()=>wa,ZodInstanceOf:()=>ZI,ZodIntersection:()=>mI,ZodJWT:()=>A_,ZodKSUID:()=>w_,ZodLazy:()=>LI,ZodLiteral:()=>wI,ZodMAC:()=>Y$,ZodMap:()=>vI,ZodNaN:()=>RI,ZodNanoID:()=>g_,ZodNever:()=>uI,ZodNonOptional:()=>j_,ZodNull:()=>oI,ZodNullable:()=>$I,ZodNumber:()=>Qu,ZodNumberFormat:()=>ac,ZodObject:()=>Af,ZodOptional:()=>Of,ZodPipe:()=>Pf,ZodPrefault:()=>TI,ZodPreprocess:()=>jI,ZodPromise:()=>FI,ZodReadonly:()=>DI,ZodRecord:()=>Ju,ZodSet:()=>bI,ZodString:()=>Yu,ZodStringFormat:()=>Ke,ZodSuccess:()=>OI,ZodSymbol:()=>nI,ZodTemplateLiteral:()=>zI,ZodTransform:()=>SI,ZodTuple:()=>gI,ZodType:()=>we,ZodULID:()=>v_,ZodURL:()=>If,ZodUUID:()=>Pi,ZodUndefined:()=>iI,ZodUnion:()=>Cf,ZodUnknown:()=>cI,ZodVoid:()=>lI,ZodXID:()=>b_,ZodXor:()=>fI,_ZodString:()=>f_,_default:()=>EI,_function:()=>j4,any:()=>f4,array:()=>Tf,base64:()=>GM,base64url:()=>KM,bigint:()=>s4,boolean:()=>rI,catch:()=>NI,check:()=>D4,cidrv4:()=>HM,cidrv6:()=>ZM,codec:()=>O4,creditCard:()=>qM,cuid:()=>DM,cuid2:()=>MM,currencyCode:()=>t4,custom:()=>M4,date:()=>m4,describe:()=>z4,discriminatedUnion:()=>b4,e164:()=>WM,email:()=>IM,emoji:()=>RM,enum:()=>P_,exactOptional:()=>kI,file:()=>E4,float32:()=>n4,float64:()=>i4,function:()=>j4,guid:()=>EM,hash:()=>r4,hex:()=>e4,hostname:()=>QM,httpUrl:()=>NM,iban:()=>JM,instanceof:()=>U4,int:()=>l_,int32:()=>o4,int64:()=>c4,intersection:()=>hI,invertCodec:()=>P4,ipv4:()=>FM,ipv6:()=>VM,json:()=>B4,jwt:()=>XM,keyof:()=>h4,ksuid:()=>UM,lazy:()=>UI,literal:()=>I4,looseObject:()=>y4,looseRecord:()=>x4,mac:()=>BM,map:()=>S4,meta:()=>L4,nan:()=>C4,nanoid:()=>jM,nativeEnum:()=>$4,never:()=>O_,nonoptional:()=>CI,null:()=>aI,nullable:()=>$f,nullish:()=>T4,number:()=>tI,object:()=>g4,optional:()=>nc,partialRecord:()=>w4,pipe:()=>d_,prefault:()=>AI,preprocess:()=>V4,promise:()=>R4,readonly:()=>MI,record:()=>yI,refine:()=>VI,set:()=>k4,strictObject:()=>_4,string:()=>kf,stringFormat:()=>YM,stringbool:()=>F4,success:()=>A4,superRefine:()=>HI,symbol:()=>l4,templateLiteral:()=>N4,transform:()=>N_,tuple:()=>_I,uint32:()=>a4,uint64:()=>u4,ulid:()=>zM,undefined:()=>d4,union:()=>rl,unknown:()=>rc,url:()=>PM,uuid:()=>TM,uuidv4:()=>AM,uuidv6:()=>CM,uuidv7:()=>OM,void:()=>p4,xid:()=>LM,xor:()=>v4});var c_={};ni(c_,{endsWith:()=>gu,gt:()=>wi,gte:()=>sn,includes:()=>mu,length:()=>Ps,lowercase:()=>fu,lt:()=>bi,lte:()=>an,maxLength:()=>Os,maxSize:()=>oa,mime:()=>yu,minLength:()=>io,minSize:()=>xi,multipleOf:()=>ia,negative:()=>ig,nonnegative:()=>ag,nonpositive:()=>og,normalize:()=>vu,overwrite:()=>Fn,positive:()=>ng,properties:()=>_u,property:()=>sg,regex:()=>du,size:()=>Cs,slugify:()=>Su,startsWith:()=>hu,toLowerCase:()=>wu,toUpperCase:()=>xu,trim:()=>bu,uppercase:()=>pu});var kM=new WeakSet([Object.prototype,Error.prototype]);function u_(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=r(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var $M=(e,t)=>{Xb.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);kM.has(r)||(kM.add(r),u_(r,"format",i=>n=>sd(i,n)),u_(r,"flatten",i=>n=>ad(i,n)),u_(r,"addIssue",i=>n=>{i.issues.push(n),i.message=JSON.stringify(i.issues,Yc,2)}),u_(r,"addIssues",i=>n=>{i.issues.push(...n),i.message=JSON.stringify(i.issues,Yc,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},V8=$("ZodError",$M),Wr=$("ZodError",$M,void 0,{Parent:Error});var U$=ru(Wr),F$=nu(Wr),B$=iu(Wr),V$=ou(Wr),H$=Hm(Wr),Z$=Zm(Wr),G$=Gm(Wr),K$=Km(Wr),W$=Wm(Wr),q$=qm(Wr),J$=Jm(Wr),X$=Xm(Wr);function Z8(){Gt.localeError||_t(Th())}function ic(){Gt.memoizer||_t({memoizer:Ed()})}var we=$("ZodType",(e,t)=>(Z8(),_e.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(O.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Ie(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(VI(e,t))},superRefine(e,t){return this.check(HI(e,t))},overwrite(e){return this.check(Fn(e))},optional(){return nc(this)},exactOptional(){return kI(this)},nullable(){return $f(this)},nullish(){return nc($f(this))},nonoptional(e){return CI(this,e)},array(){return Tf(this)},or(e){return rl([this,e])},and(e){return hI(this,e)},transform(e){return d_(this,N_(e))},default(e){return EI(this,e)},prefault(e){return AI(this,e)},catch(e){return NI(this,e)},pipe(e){return d_(this,e)},readonly(){return MI(this)},describe(e){let t=this.clone();return He.add(t,{description:e}),t},meta(...e){if(e.length===0)return He.get(this);let t=this.clone();return He.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return O.hide(this,"~standard",{...ch(this),jsonSchema:{input:ku(this,"input"),output:ku(this,"output")}})},set"~standard"(e){O.own(this,"~standard",e)},parse:function e(t,r){return U$(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await F$(this,t,r,{callee:e})},safeParse(e,t){return B$(this,e,t)},async safeParseAsync(e,t){return V$(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){O.own(this,"spa",e)},validate(e,t){return cd(this,e,t)},validateAsync(e,t){return ud(this,e,t)},encode:function e(t,r){return H$(this,t,r,{callee:e})},decode:function e(t,r){return Z$(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await G$(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await K$(this,t,r,{callee:e})},safeEncode(e,t){return W$(this,e,t)},safeDecode(e,t){return q$(this,e,t)},async safeEncodeAsync(e,t){return J$(this,e,t)},async safeDecodeAsync(e,t){return X$(this,e,t)},toJSONSchema(e){return oS(this,{})(e)},get description(){return He.get(this)?.description},get _def(){return this._zod.def}}),f_=$("_ZodString",(e,t)=>{ks.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>cS(e,r,i,n)},O.derived({format:e=>Mt(e).format??null,minLength:e=>Mt(e).minimum??null,maxLength:e=>Mt(e).maximum??null},{regex(...e){return this.check(du(...e))},includes(...e){return this.check(mu(...e))},startsWith(...e){return this.check(hu(...e))},endsWith(...e){return this.check(gu(...e))},min(...e){return this.check(io(...e))},max(...e){return this.check(Os(...e))},length(...e){return this.check(Ps(...e))},nonempty(...e){return this.check(io(1,...e))},lowercase(e){return this.check(fu(e))},uppercase(e){return this.check(pu(e))},trim(){return this.check(bu())},normalize(...e){return this.check(vu(...e))},toLowerCase(){return this.check(wu())},toUpperCase(){return this.check(xu())},slugify(){return this.check(Su())}})),Yu=$("ZodString",(e,t)=>{ks.init(e,t),f_.init(e,t)},{email(e){return this.check(Dh(p_,e))},url(e){return this.check(Cd(If,e))},jwt(e){return this.check(rg(A_,e))},emoji(e){return this.check(Bh(h_,e))},guid(e){return this.check(Mh(m_,e))},uuid(e){return this.check(zh(Pi,e))},uuidv4(e){return this.check(Lh(Pi,e))},uuidv6(e){return this.check(Uh(Pi,e))},uuidv7(e){return this.check(Fh(Pi,e))},nanoid(e){return this.check(Vh(g_,e))},cuid(e){return this.check(Hh(__,e))},cuid2(e){return this.check(Zh(y_,e))},ulid(e){return this.check(Gh(v_,e))},base64(e){return this.check(Qh(I_,e))},base64url(e){return this.check(eg(E_,e))},xid(e){return this.check(Kh(b_,e))},ksuid(e){return this.check(Wh(w_,e))},ipv4(e){return this.check(qh(x_,e))},ipv6(e){return this.check(Jh(S_,e))},cidrv4(e){return this.check(Xh(k_,e))},cidrv6(e){return this.check(Yh($_,e))},e164(e){return this.check(tg(T_,e))},datetime(e){return this.check(Od(va,e))},date(e){return this.check(Pd(ba,e))},time(e){return this.check(Nd(wa,e))},duration(e){return this.check(Rd(xa,e))}});function kf(e){return S0(Yu,e)}var Ke=$("ZodStringFormat",(e,t)=>{Ze.init(e,t),f_.init(e,t)}),va=$("ZodISODateTime",(e,t)=>{_x.init(e,t),Ke.init(e,t)}),ba=$("ZodISODate",(e,t)=>{yx.init(e,t),Ke.init(e,t)}),wa=$("ZodISOTime",(e,t)=>{vx.init(e,t),Ke.init(e,t)}),xa=$("ZodISODuration",(e,t)=>{bx.init(e,t),Ke.init(e,t)}),p_=$("ZodEmail",(e,t)=>{ax.init(e,t),Ke.init(e,t)});function IM(e){return Dh(p_,e)}var m_=$("ZodGUID",(e,t)=>{ix.init(e,t),Ke.init(e,t)});function EM(e){return Mh(m_,e)}var Pi=$("ZodUUID",(e,t)=>{ox.init(e,t),Ke.init(e,t)});function TM(e){return zh(Pi,e)}function AM(e){return Lh(Pi,e)}function CM(e){return Uh(Pi,e)}function OM(e){return Fh(Pi,e)}var If=$("ZodURL",(e,t)=>{ux.init(e,t),Ke.init(e,t)});function PM(e){return Cd(If,e)}function NM(e){return Cd(If,{protocol:ld,hostname:bw,...O.normalizeParams(e)})}var h_=$("ZodEmoji",(e,t)=>{lx.init(e,t),Ke.init(e,t)});function RM(e){return Bh(h_,e)}var g_=$("ZodNanoID",(e,t)=>{dx.init(e,t),Ke.init(e,t)});function jM(e){return Vh(g_,e)}var __=$("ZodCUID",(e,t)=>{fx.init(e,t),Ke.init(e,t)});function DM(e){return Hh(__,e)}var y_=$("ZodCUID2",(e,t)=>{px.init(e,t),Ke.init(e,t)});function MM(e){return Zh(y_,e)}var v_=$("ZodULID",(e,t)=>{mx.init(e,t),Ke.init(e,t)});function zM(e){return Gh(v_,e)}var b_=$("ZodXID",(e,t)=>{hx.init(e,t),Ke.init(e,t)});function LM(e){return Kh(b_,e)}var w_=$("ZodKSUID",(e,t)=>{gx.init(e,t),Ke.init(e,t)});function UM(e){return Wh(w_,e)}var x_=$("ZodIPv4",(e,t)=>{wx.init(e,t),Ke.init(e,t)});function FM(e){return qh(x_,e)}var Y$=$("ZodMAC",(e,t)=>{Sx.init(e,t),Ke.init(e,t)});function BM(e){return $0(Y$,e)}var S_=$("ZodIPv6",(e,t)=>{xx.init(e,t),Ke.init(e,t)});function VM(e){return Jh(S_,e)}var k_=$("ZodCIDRv4",(e,t)=>{kx.init(e,t),Ke.init(e,t)});function HM(e){return Xh(k_,e)}var $_=$("ZodCIDRv6",(e,t)=>{$x.init(e,t),Ke.init(e,t)});function ZM(e){return Yh($_,e)}var I_=$("ZodBase64",(e,t)=>{Ix.init(e,t),Ke.init(e,t)});function GM(e){return Qh(I_,e)}var E_=$("ZodBase64URL",(e,t)=>{Ex.init(e,t),Ke.init(e,t)});function KM(e){return eg(E_,e)}var T_=$("ZodE164",(e,t)=>{Tx.init(e,t),Ke.init(e,t)});function WM(e){return tg(T_,e)}var Q$=$("ZodCreditCard",(e,t)=>{Ax.init(e,t),Ke.init(e,t)});function qM(e){return I0(Q$,e)}var eI=$("ZodIBAN",(e,t)=>{Cx.init(e,t),Ke.init(e,t)});function JM(e){return E0(eI,e)}var A_=$("ZodJWT",(e,t)=>{Ox.init(e,t),Ke.init(e,t)});function XM(e){return rg(A_,e)}var oc=$("ZodCustomStringFormat",(e,t)=>{Px.init(e,t),Ke.init(e,t)});function YM(e,t,r={}){return Ns(oc,e,t,r)}function QM(e){return Ns(oc,"hostname",vw,e)}function e4(e){return Ns(oc,"hex",Rw,e)}function t4(e){return Ns(oc,"currency_code",xw,e)}function r4(e,t){let r=t?.enc??"hex",i=`${e}_${r}`,n=vn[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return Ns(oc,i,n,t)}var Qu=$("ZodNumber",(e,t)=>{yh.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>uS(e,r,i,n),e.isFinite=!0},O.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Mt(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Mt(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Mt(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Mt(e).format??null},{gt(e,t){return this.check(wi(e,t))},gte(e,t){return this.check(sn(e,t))},min(e,t){return this.check(sn(e,t))},lt(e,t){return this.check(bi(e,t))},lte(e,t){return this.check(an(e,t))},max(e,t){return this.check(an(e,t))},int(e){return this.check(l_(e))},safe(e){return this.check(l_(e))},positive(e){return this.check(wi(0,e))},nonnegative(e){return this.check(sn(0,e))},negative(e){return this.check(bi(0,e))},nonpositive(e){return this.check(an(0,e))},multipleOf(e,t){return this.check(ia(e,t))},step(e,t){return this.check(ia(e,t))},finite(){return this}}));function tI(e){return A0(Qu,e)}var ac=$("ZodNumberFormat",(e,t)=>{Nx.init(e,t),Qu.init(e,t)});function l_(e){return O0(ac,e)}function n4(e){return P0(ac,e)}function i4(e){return N0(ac,e)}function o4(e){return R0(ac,e)}function a4(e){return j0(ac,e)}var el=$("ZodBoolean",(e,t)=>{vd.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>lS(e,r,i,n)});function rI(e){return D0(el,e)}var tl=$("ZodBigInt",(e,t)=>{vh.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>dS(e,r,i,n)},O.derived({minValue:e=>Mt(e).minimum??null,maxValue:e=>Mt(e).maximum??null,format:e=>Mt(e).format??null},{gte(e,t){return this.check(sn(e,t))},min(e,t){return this.check(sn(e,t))},gt(e,t){return this.check(wi(e,t))},lt(e,t){return this.check(bi(e,t))},lte(e,t){return this.check(an(e,t))},max(e,t){return this.check(an(e,t))},positive(e){return this.check(wi(BigInt(0),e))},negative(e){return this.check(bi(BigInt(0),e))},nonpositive(e){return this.check(an(BigInt(0),e))},nonnegative(e){return this.check(sn(BigInt(0),e))},multipleOf(e,t){return this.check(ia(e,t))}}));function s4(e){return z0(tl,e)}var C_=$("ZodBigIntFormat",(e,t)=>{Rx.init(e,t),tl.init(e,t)});function c4(e){return U0(C_,e)}function u4(e){return F0(C_,e)}var nI=$("ZodSymbol",(e,t)=>{jx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>fS(e,r,i,n)});function l4(e){return B0(nI,e)}var iI=$("ZodUndefined",(e,t)=>{Dx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>mS(e,r,i,n)});function d4(e){return V0(iI,e)}var oI=$("ZodNull",(e,t)=>{Mx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pS(e,r,i,n)});function aI(e){return H0(oI,e)}var sI=$("ZodAny",(e,t)=>{zx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>_S(e,r,i,n)});function f4(){return Z0(sI)}var cI=$("ZodUnknown",(e,t)=>{bd.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>yS(e,r,i,n)});function rc(){return jd(cI)}var uI=$("ZodNever",(e,t)=>{wd.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>gS(e,r,i,n)});function O_(e){return Dd(uI,e)}var lI=$("ZodVoid",(e,t)=>{Lx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>hS(e,r,i,n)});function p4(e){return G0(lI,e)}var Ef=$("ZodDate",(e,t)=>{Ux.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>vS(e,r,i,n),e.min=(r,i)=>e.check(sn(r,i)),e.max=(r,i)=>e.check(an(r,i))},O.derived({minDate:e=>{let{minimum:t}=Mt(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=Mt(e);return t?new Date(t):null}},{}));function m4(e){return K0(Ef,e)}var dI=$("ZodArray",(e,t)=>{ic(),Fx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>OS(e,r,i,n),e.element=t.element},{min(e,t){return this.check(io(e,t))},nonempty(e){return this.check(io(1,e))},max(e,t){return this.check(Os(e,t))},length(e,t){return this.check(Ps(e,t))},unwrap(){return this.element}});function Tf(e,t){return J0(dI,e,t)}function h4(e){let t=e._zod.def.shape;return P_(Object.keys(t))}var Af=$("ZodObject",(e,t)=>{ic(),Bx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>PS(e,r,i,n),O.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return P_(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(O.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(O.mergeDefs(this._zod.def,{catchall:rc()}))},loose(){return this.clone(O.mergeDefs(this._zod.def,{catchall:rc()}))},strict(){return this.clone(O.mergeDefs(this._zod.def,{catchall:O_()}))},strip(){return this.clone(O.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return O.extend(this,e)},safeExtend(e){return O.safeExtend(this,e)},merge(e){return O.merge(this,e)},pick(e){return O.pick(this,e)},omit(e){return O.omit(this,e)},partial(...e){return O.partial(Of,this,e[0])},exactPartial(...e){return O.partial(R_,this,e[0],"exactPartial")},required(...e){return O.required(j_,this,e[0])}});function g4(e,t){let r={type:"object",shape:e??{},...O.normalizeParams(t)};return new Af(r)}function _4(e,t){return new Af({type:"object",shape:e,catchall:O_(),...O.normalizeParams(t)})}function y4(e,t){return new Af({type:"object",shape:e,catchall:rc(),...O.normalizeParams(t)})}var Cf=$("ZodUnion",(e,t)=>{xd.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ug(e,r,i,n),e.options=t.options});function rl(e,t){return new Cf({type:"union",options:e,...O.normalizeParams(t)})}var fI=$("ZodXor",(e,t)=>{Cf.init(e,t),Vx.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ug(e,r,i,n),e.options=t.options});function v4(e,t){return new fI({type:"union",options:e,inclusive:!1,...O.normalizeParams(t)})}var pI=$("ZodDiscriminatedUnion",(e,t)=>{Cf.init(e,t),Zx.init(e,t)});function b4(e,t,r){return new pI({type:"union",options:t,discriminator:e,...O.normalizeParams(r)})}var mI=$("ZodIntersection",(e,t)=>{Gx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>NS(e,r,i,n)});function hI(e,t){return new mI({type:"intersection",left:e,right:t})}var gI=$("ZodTuple",(e,t)=>{ic(),bh.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>RS(e,r,i,n)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Of({type:"optional",innerType:t}))})}});function _I(e,t,r){let i=t instanceof _e,n=i?r:t,o=i?t:null;return new gI({type:"tuple",items:e,rest:o,...O.normalizeParams(n)})}var Ju=$("ZodRecord",(e,t)=>{ic(),Kx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>jS(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType});function yI(e,t,r){return!t||!t._zod?new Ju({type:"record",keyType:kf(),valueType:e,...O.normalizeParams(t)}):new Ju({type:"record",keyType:e,valueType:t,...O.normalizeParams(r)})}function w4(e,t,r){return new Ju({type:"record",keyType:e,valueType:t,...O.normalizeParams(r),partial:!0})}function x4(e,t,r){return new Ju({type:"record",keyType:e,valueType:t,mode:"loose",...O.normalizeParams(r)})}var vI=$("ZodMap",(e,t)=>{ic(),Wx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>AS(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(xi(...r)),e.nonempty=r=>e.check(xi(1,r)),e.max=(...r)=>e.check(oa(...r)),e.size=(...r)=>e.check(Cs(...r))});function S4(e,t,r){return new vI({type:"map",keyType:e,valueType:t,...O.normalizeParams(r)})}var bI=$("ZodSet",(e,t)=>{ic(),qx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>CS(e,r,i,n),e.min=(...r)=>e.check(xi(...r)),e.nonempty=r=>e.check(xi(1,r)),e.max=(...r)=>e.check(oa(...r)),e.size=(...r)=>e.check(Cs(...r))});function k4(e,t){return new bI({type:"set",valueType:e,...O.normalizeParams(t)})}var Xu=$("ZodEnum",(e,t)=>{Jx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(i,n,o)=>bS(e,i,n,o),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(i,n)=>{let o={};for(let a of i)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Xu({...t,checks:[],...O.normalizeParams(n),entries:o})},e.exclude=(i,n)=>{let o={...t.entries};for(let a of i)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new Xu({...t,checks:[],...O.normalizeParams(n),entries:o})}});function P_(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Xu({type:"enum",entries:r,...O.normalizeParams(t)})}function $4(e,t){return new Xu({type:"enum",entries:e,...O.normalizeParams(t)})}var wI=$("ZodLiteral",(e,t)=>{Xx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>wS(e,r,i,n),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 I4(e,t){return new wI({type:"literal",values:Array.isArray(e)?e:[e],...O.normalizeParams(t)})}var xI=$("ZodFile",(e,t)=>{Yx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>kS(e,r,i,n),e.min=(r,i)=>e.check(xi(r,i)),e.max=(r,i)=>e.check(oa(r,i)),e.mime=(r,i)=>e.check(yu(Array.isArray(r)?r:[r],i))});function E4(e){return X0(xI,e)}var SI=$("ZodTransform",(e,t)=>{ic(),Qx.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>TS(e,r,i,n),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new ra(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(O.issue(o,r.value,t));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=e),r.issues.push(O.issue(a))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(o=>(r.value=o,r)):(r.value=n,r)}});function N_(e){return new SI({type:"transform",transform:e})}var Of=$("ZodOptional",(e,t)=>{$s.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>lg(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function nc(e){return new Of({type:"optional",innerType:e})}var R_=$("ZodExactOptional",(e,t)=>{e0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>lg(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function kI(e){return new R_({type:"optional",innerType:e})}var $I=$("ZodNullable",(e,t)=>{t0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>DS(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function $f(e){return new $I({type:"nullable",innerType:e})}function T4(e){return nc($f(e))}var II=$("ZodDefault",(e,t)=>{r0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>LS(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function EI(e,t){return new II({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():O.shallowClone(t)}})}var TI=$("ZodPrefault",(e,t)=>{n0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>US(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function AI(e,t){return new TI({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():O.shallowClone(t)}})}var j_=$("ZodNonOptional",(e,t)=>{i0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>MS(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function CI(e,t){return new j_({type:"nonoptional",innerType:e,...O.normalizeParams(t)})}var OI=$("ZodSuccess",(e,t)=>{o0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>$S(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function A4(e){return new OI({type:"success",innerType:e})}var PI=$("ZodCatch",(e,t)=>{a0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>FS(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function NI(e,t){return new PI({type:"catch",innerType:e,catchValue:typeof t=="function"?t:O.constantCatch(t)})}var RI=$("ZodNaN",(e,t)=>{s0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>xS(e,r,i,n)});function C4(e){return q0(RI,e)}var Pf=$("ZodPipe",(e,t)=>{wh.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>BS(e,r,i,n),e.in=t.in,e.out=t.out});function d_(e,t){return new Pf({type:"pipe",in:e,out:t})}var Nf=$("ZodCodec",(e,t)=>{Pf.init(e,t),Sd.init(e,t)});function O4(e,t,r){return new Nf({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function P4(e){let t=e._zod.def;return new Nf({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var jI=$("ZodPreprocess",(e,t)=>{Pf.init(e,t),c0.init(e,t)}),DI=$("ZodReadonly",(e,t)=>{u0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>VS(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function MI(e){return new DI({type:"readonly",innerType:e})}var zI=$("ZodTemplateLiteral",(e,t)=>{l0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>SS(e,r,i,n)});function N4(e,t){return new zI({type:"template_literal",parts:e,...O.normalizeParams(t)})}var LI=$("ZodLazy",(e,t)=>{kd.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ZS(e,r,i,n),e.unwrap=()=>e._zod.def.getter()});function UI(e){return new LI({type:"lazy",getter:e})}var FI=$("ZodPromise",(e,t)=>{f0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>HS(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function R4(e){return new FI({type:"promise",innerType:e})}var BI=$("ZodFunction",(e,t)=>{d0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ES(e,r,i,n)});function j4(e){return new BI({type:"function",input:Array.isArray(e?.input)?_I(e?.input):e?.input??Tf(rc()),output:e?.output??rc()})}var Rf=$("ZodCustom",(e,t)=>{p0.init(e,t),we.init(e,t),e._zod.processJSONSchema=(r,i,n)=>IS(e,r,i,n)});function D4(e){let t=new Je({check:"custom"});return t._zod.check=e,t}function M4(e,t){return Y0(Rf,e??(()=>!0),t)}function VI(e,t={}){return Q0(Rf,e,t)}function HI(e,t){return eS(e,t)}var z4=tS,L4=rS,ZI=$("ZodInstanceOf",(e,t)=>{Rf.init(e,t)},{properties(e,t){return this.check(_u(e,t))}});function U4(e,t={}){let r=new ZI({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...O.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var F4=(...e)=>nS({Codec:Nf,Boolean:el,String:Yu},...e);function B4(e){let t=UI(()=>rl([kf(e),tI(),rI(),aI(),Tf(t),yI(kf(),t)]));return t}function V4(e,t){return new jI({type:"pipe",in:N_(e),out:t})}var G8={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 K8(e){_t({customError:e})}function W8(){return _t().customError}var GI;GI||(GI={});var jf={};ni(jf,{ZodISODate:()=>ba,ZodISODateTime:()=>va,ZodISODuration:()=>xa,ZodISOTime:()=>wa,date:()=>J8,datetime:()=>q8,duration:()=>Y8,time:()=>X8});function q8(e){return Od(va,e)}function J8(e){return Pd(ba,e)}function X8(e){return Nd(wa,e)}function Y8(e){return Rd(xa,e)}var K={...nl,...c_,iso:jf},Q8=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 eK(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 H4(e,t){return e.map((r,i)=>i<t?r:r.optional())}function tK(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function rK(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 i=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let n=r[1]===void 0?void 0:tK(r[1]);if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function nK(e,t){return K.transform(i=>i).check(i=>{let n=i.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let o=Object.getOwnPropertyNames(n);if(t.minProperties!==void 0&&o.length<t.minProperties&&i.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:n,inst:e,continue:!0}),t.maxProperties!==void 0&&o.length>t.maxProperties&&i.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:n,inst:e,continue:!0}),t.keySchema)for(let a of o){let s=t.keySchema.safeParse(a);s.success||i.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function KI(e,t){if(e===null)return"z";let r=typeof e;if(r!=="object"){if(r==="number"&&Number.isNaN(e))return null;let i=String(e);return`${r[0]}${i.length}:${i}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let o=[];for(let a of e){let s=KI(a,t);if(s===null)return null;o.push(s)}return`a${o.length}:[${o.join(",")}]`}let i=Object.keys(e).sort(),n=[];for(let o of i){let a=KI(e[o],t);if(a===null)return null;n.push(`${o.length}:${o}=${a}`)}return`o${n.length}:{${n.join(",")}}`}finally{t.delete(e)}}var iK=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),oK=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Df(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Df):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,r])=>iK.has(t)?Df(r):!oK.has(t)||typeof r!="object"||r===null?!1:Object.values(r).some(Df))}function Z4(e){return e===1?"element":"elements"}function aK(e,t){return K.transform(i=>i).check(i=>{let n=i.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let o=new Map;for(let a=0;a<n.length;a++){let s=KI(n[a],new Set);if(s===null)continue;let c=o.get(s);if(c===void 0){o.set(s,a);continue}i.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${c}`,input:n,path:[a],continue:!0})}}if(t.containsSchema){let o=t.minContains??1,a=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let c of n)if(t.containsSchema.safeParse(c).success&&++s>=a)break;s<o&&i.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${Z4(o)}; found ${s}`,input:n,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&i.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${Z4(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function G4(e,t){if(e!==!1)return e===void 0||e===!0?K.any():Nr(e,t)}var sK=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function K4(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return K.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 n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return K.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let o=rK(n,t),a=Nr(o,t);return t.refs.set(n,a),t.processing.delete(n),a}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return K.null();if(n.length===0)return K.never();if(n.length===1)return K.literal(n[0]);if(n.every(a=>typeof a=="string"))return K.enum(n);let o=n.map(a=>K.literal(a));return o.length<2?o[0]:K.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return K.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(o=>{let a={...e,type:o};return K4(a,t)});return n.length===0?K.never():n.length===1?n[0]:K.union(n)}if(!r)return K.any();let i;switch(r){case"string":{let n=K.string();if(e.format){let o=e.format;o==="email"?n=n.check(K.email()):o==="uri"||o==="uri-reference"?n=n.check(K.url()):o==="uuid"||o==="guid"?n=n.check(K.uuid()):o==="date-time"?n=n.check(K.iso.datetime({offset:!0})):o==="date"?n=n.check(K.iso.date()):o==="time"?n=n.check(K.regex(sK)):o==="duration"?n=n.check(K.iso.duration()):o==="hostname"?n=n.check(K.hostname()):o==="ipv4"?n=n.check(K.ipv4()):o==="ipv6"?n=n.check(K.ipv6()):o==="mac"?n=n.check(K.mac()):o==="cidr"?n=n.check(K.cidrv4()):o==="cidr-v6"?n=n.check(K.cidrv6()):o==="base64"?n=n.check(K.base64()):o==="base64url"?n=n.check(K.base64url()):o==="e164"?n=n.check(K.e164()):o==="credit_card"?n=n.check(K.creditCard()):o==="iban"?n=n.check(K.iban()):o==="jwt"?n=n.check(K.jwt()):o==="emoji"?n=n.check(K.emoji()):o==="nanoid"?n=n.check(K.nanoid()):o==="cuid"?n=n.check(K.cuid()):o==="cuid2"?n=n.check(K.cuid2()):o==="ulid"?n=n.check(K.ulid()):o==="xid"?n=n.check(K.xid()):o==="ksuid"&&(n=n.check(K.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),i=n;break}case"number":case"integer":{let n=r==="integer"?K.number().int():K.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),i=n;break}case"boolean":{i=K.boolean();break}case"null":{i=K.null();break}case"object":{let n={},o=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?Nr(e.additionalProperties,t):void 0;for(let[d,f]of Object.entries(o)){let p=Nr(f,t);Qt(n,d,a.has(d)?p:p.optional())}if(e.patternProperties){let d=e.patternProperties,f=Object.keys(d),p=[];for(let h of f){let g=Nr(d[h],t),_=K.string().regex(new RegExp(h));p.push(K.looseRecord(_,g))}let m=[];if(Object.keys(n).length>0&&m.push(K.object(n).passthrough()),m.push(...p),m.length===0)i=K.object({}).passthrough();else if(m.length===1)i=m[0];else{let h=K.intersection(m[0],m[1]);for(let g=2;g<m.length;g++)h=K.intersection(h,m[g]);i=h}if(e.additionalProperties===!1){let h=Object.keys(n),g=f.map(v=>new RegExp(v)),_=i;i=i.check(v=>{if(!_n(v.value))return;let x=[];for(let S of Object.keys(v.value))h.includes(S)||g.some(k=>k.test(S))||x.push(S);x.length&&v.issues.push({code:"unrecognized_keys",keys:x,input:v.value,inst:_})})}}else{let d=K.object(n);e.additionalProperties===!1?i=d.strict():s?i=d.catchall(s):i=d.passthrough()}let c=e.propertyNames!==void 0&&e.propertyNames!==!0,u=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||u!==void 0||l!==void 0){let d;if(c){let f=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=Nr(f,t)}i=nK(i,{keySchema:d,minProperties:u,maxProperties:l})}break}case"array":{let n=e.prefixItems,o=e.items;if(n&&Array.isArray(n)){let a=typeof e.minItems=="number"?e.minItems:0,s=n.map(d=>Nr(d,t)),c=H4(s,a),u=Array.isArray(o)?void 0:G4(o,t),l=K.tuple(c);i=u?l.rest(u):l,typeof e.minItems=="number"&&(i=i.check(K.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(K.maxLength(e.maxItems)))}else if(Array.isArray(o)){let a=typeof e.minItems=="number"?e.minItems:0,s=o.map(d=>Nr(d,t)),c=H4(s,a),u=G4(e.additionalItems,t),l=K.tuple(c);i=u?l.rest(u):l,typeof e.minItems=="number"&&(i=i.check(K.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(K.maxLength(e.maxItems)))}else if(o!==void 0){let a=Nr(o,t),s=K.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=K.array(K.any());(e.uniqueItems===!0||e.contains!==void 0)&&(i=aK(i,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?Nr(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return i}function Nr(e,t){if(typeof e=="boolean")return e?K.any():K.never();let r=K4(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>Nr(u,t)),c=K.union(s);r=i?K.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>Nr(u,t)),c=K.xor(s);r=i?K.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=i?r:K.any();else{let s=i?r:Nr(e.allOf[0],t),c=i?0:1;for(let u=c;u<e.allOf.length;u++)s=K.intersection(s,Nr(e.allOf[u],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=K.nullable(r)),e.readOnly===!0&&(r=K.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(n[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(n[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!Df(e.propertyNames)&&(n.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(n[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!Df(e.contains)&&(n.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(n[s]=e[s])}for(let s of Object.keys(e))Q8.has(s)||Qt(n,s,e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function W4(e,t){if(typeof e=="boolean")return e?K.any():K.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 i=eK(r,t?.defaultTarget),n=r.$defs||r.definitions||{},o={version:i,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??He};return Nr(r,o)}var q4=Symbol("z.visit/resolving");function Mf(e,t){let r=typeof t=="function"?t:(a,s)=>{let c=t[a._zod.def.type];return c?c(a,s):a},i=new Map;function n(a){let s=i.get(a);if(s===q4)return new kd({type:"lazy",getter:()=>i.get(a)});if(s!==void 0)return s;i.set(a,q4);let c=o(a),u=r(c,c!==a);return i.set(a,u),u}function o(a){let s=a._zod.def,c=s.type;switch(c){case"object":{let u=s.shape,l=Object.keys(u),d=!1,f={};for(let m of l){let h=n(u[m]);h!==u[m]&&(d=!0),f[m]=h}let p=s.catchall;return s.catchall&&(p=n(s.catchall),p!==s.catchall&&(d=!0)),d?Ie(a,{...s,shape:f,catchall:p}):a}case"array":{let u=n(s.element);return u===s.element?a:Ie(a,{...s,element:u})}case"tuple":{let u=s.items,l=!1,d=[];for(let p of u){let m=n(p);m!==p&&(l=!0),d.push(m)}let f=s.rest;return s.rest&&(f=n(s.rest),f!==s.rest&&(l=!0)),l?Ie(a,{...s,items:d,rest:f}):a}case"record":case"map":{let u=n(s.keyType),l=n(s.valueType);return u===s.keyType&&l===s.valueType?a:Ie(a,{...s,keyType:u,valueType:l})}case"set":{let u=n(s.valueType);return u===s.valueType?a:Ie(a,{...s,valueType:u})}case"union":{let u=s.options,l=!1,d=[];for(let f of u){let p=n(f);p!==f&&(l=!0),d.push(p)}return l?Ie(a,{...s,options:d}):a}case"intersection":{let u=n(s.left),l=n(s.right);return u===s.left&&l===s.right?a:Ie(a,{...s,left:u,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let u=n(s.innerType);return u===s.innerType?a:Ie(a,{...s,innerType:u})}case"pipe":{let u=n(s.in),l=n(s.out);return u===s.in&&l===s.out?a:Ie(a,{...s,in:u,out:l})}case"function":{let u=n(s.input),l=n(s.output);return u===s.input&&l===s.output?a:Ie(a,{...s,input:u,output:l})}case"lazy":{let u=s.getter,{_cachedInner:l,...d}=s;return Ie(a,{...d,getter:()=>n(u())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return n(e)}function J4(e){return Mf(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:rl(r.options)}})}function cK(e,t){if(!t?.length)return e;let r=e._zod.def;return Ie(e,Ln(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function X4(e){return cK(e.out,e.checks)}function uK(e){return e.in._zod.traits.has("$ZodTransform")?X4(e):e.in}function Y4(e){return Mf(e,{pipe:t=>uK(t._zod.def),default:(t,r)=>r?nc(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function Q4(e){return Mf(e,{pipe:t=>X4(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var WI={};ni(WI,{bigint:()=>pK,boolean:()=>fK,date:()=>mK,number:()=>dK,string:()=>lK});function lK(e){return k0(Yu,e)}function dK(e){return C0(Qu,e)}function fK(e){return M0(el,e)}function pK(e){return L0(tl,e)}function mK(e){return W0(Ef,e)}var ez=C({BaseToolkit:()=>hK,DynamicStructuredTool:()=>nz,DynamicTool:()=>rz,StructuredTool:()=>zf,Tool:()=>tz,ToolInputParsingException:()=>Sc,isLangChainTool:()=>Sf,isRunnableToolLike:()=>wf,isStructuredTool:()=>bf,isStructuredToolParams:()=>xf,tool:()=>gK}),zf=class extends Ug{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,i=Ae(jt(this.defaultConfig,t));return zo(e)?(r=e.args,i={...i,toolCall:e}):r=e,this.call(r,i)}async call(e,t,r){let i=zo(e)?e.args:e,n;if(Hr(this.schema))try{n=await ua(this.schema,i)}catch(p){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
420
+ Details: ${p.message}`),_g(p)&&(m=`${m}
421
+
422
+ ${Tn.prettifyError(p)}`),new Sc(m,JSON.stringify(e))}else{let p=tt(i,this.schema);if(!p.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
423
+ Details: ${p.errors.map(h=>`${h.keywordLocation}: ${h.error}`).join(`
424
+ `)}`),new Sc(m,JSON.stringify(e))}n=i}let o=ms(t),a=at.configure(o.callbacks,this.callbacks,o.tags||r,this.tags,o.metadata,this.metadata,{verbose:this.verbose}),s;zo(e)&&(s=e.id),!s&&fA(o)&&(s=o.toolCall.id);let c=await a?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),o.runId,void 0,void 0,void 0,o.runName,s);delete o.runId;let u;try{let p=await this._call(n,c,o);u=Dk(p)?await mj(p,async m=>{try{await c?.handleToolEvent(m)}catch(h){await c?.handleToolError(h)}}):p}catch(p){throw await c?.handleToolError(p),p}let l,d;if(this.responseFormat==="content_and_artifact")if(Array.isArray(u)&&u.length===2)[l,d]=u;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
425
+ Result: ${JSON.stringify(u)}`);else l=u;let f=yK({content:l,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},tz=class extends zf{schema=Kt.object({input:Kt.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)}},rz=class extends tz{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=ms(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},nz=class extends zf{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 i=ms(t);return i.runName===void 0&&(i.runName=this.name),super.call(e,i,r)}_call(e,t,r){return this.func(e,t,r)}},hK=class{getTools(){return this.tools}};function gK(e,t){let r=Tu(t.schema),i=zu(t.schema);if(!t.schema||r||i)return new rz({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(a,s,c)=>new Promise((u,l)=>{let d=Pe(c,{callbacks:s?.getChild()});Ue.runWithConfig(Lr(d),async()=>{try{u(e(a,d))}catch(f){l(f)}})})});let n=t.schema,o=t.description??t.schema.description??`${t.name} tool`;return new nz({...t,description:o,schema:n,func:async(a,s,c)=>new Promise((u,l)=>{let d,f=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{f(),l(Jo(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let p=Pe(c,{callbacks:s?.getChild()});Ue.runWithConfig(Lr(p),async()=>{try{let m=await e(a,p);if(Dk(m)){u(m);return}if(c?.signal?.aborted){f();return}f(),u(m)}catch(m){f(),l(m)}})})})}function _K(e){return typeof e=="object"&&e!==null&&"type"in e}function yK(e){let{content:t,artifact:r,toolCallId:i,metadata:n}=e;return i&&!Al(t)?typeof t=="string"||Array.isArray(t)&&t.every(_K)?new Pt({status:"success",content:t,artifact:r,tool_call_id:i,name:e.name,metadata:n}):new Pt({status:"success",content:vK(t),artifact:r,tool_call_id:i,name:e.name,metadata:n}):t}function vK(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}var iz=C({RunCollectorCallbackHandler:()=>bK}),bK=class extends Yt{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 oz=C({});var az=C({chunkArray:()=>wK}),wK=(e,t)=>e.reduce((r,i,n)=>{let o=Math.floor(n/t);return r[o]=(r[o]||[]).concat([i]),r},[]);var sz=C({context:()=>xK});function xK(e,...t){let r=e.raw,i="";for(let n=0;n<r.length;n++){let o=r[n].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(i+=o,n<t.length){let a=SK(t[n],i);i+=typeof a=="string"?a:JSON.stringify(a)}}return i=kK(i),i=i.trim(),i=i.replace(/\\n/g,`
426
+ `),i}function SK(e,t){if(typeof e!="string"||!e.includes(`
427
+ `))return e;let r=t.slice(t.lastIndexOf(`
428
+ `)+1).match(/^(\s+)/);if(r){let i=r[1];return e.replace(/\n/g,`
429
+ ${i}`)}return e}function kK(e){let t=e.split(`
430
+ `),r=null;for(let i of t){let n=i.match(/^(\s+)\S+/);if(n){let o=n[1].length;r===null?r=o:r=Math.min(r,o)}}return r===null?e:t.map(i=>i[0]===" "||i[0]===" "?i.slice(r):i).join(`
431
+ `)}var cz=C({EventStreamContentType:()=>$K,convertEventStreamToIterableReadableDataStream:()=>EK,getBytes:()=>uz,getLines:()=>lz,getMessages:()=>dz}),$K="text/event-stream";async function uz(e,t){if(e instanceof ReadableStream){let r=e.getReader();for(;;){let i=await r.read();if(i.done){t(new Uint8Array,!0);break}t(i.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(`
432
+ `))}}function lz(e){let t,r,i,n=!1;return function(a,s){if(s){e(a,0,!0);return}t===void 0?(t=a,r=0,i=-1):t=IK(t,a);let c=t.length,u=0;for(;r<c;){n&&(t[r]===10&&(u=++r),n=!1);let l=-1;for(;r<c&&l===-1;++r)switch(t[r]){case 58:i===-1&&(i=r-u);break;case 13:n=!0;case 10:l=r}if(l===-1)break;e(t.subarray(u,l),i),u=r,i=-1}u===c?t=void 0:u!==0&&(t=t.subarray(u),r-=u)}}function dz(e,t,r){let i=qI(),n=new TextDecoder;return function(a,s,c){if(c){TK(i)||(e?.(i),i=qI());return}if(a.length===0)e?.(i),i=qI();else if(s>0){let u=n.decode(a.subarray(0,s)),l=s+(a[s+1]===32?2:1),d=n.decode(a.subarray(l));switch(u){case"data":i.data=i.data?i.data+`
433
+ `+d:d;break;case"event":i.event=d;break;case"id":t?.(i.id=d);break;case"retry":{let f=parseInt(d,10);Number.isNaN(f)||r?.(i.retry=f);break}}}}}function IK(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function qI(){return{data:"",event:"",id:"",retry:void 0}}function EK(e,t){let r=new ReadableStream({async start(i){let n=dz(a=>{if(a.event==="error")throw new Error(a.data??"Unspecified event streaming error.");a.event==="metadata"?t?.(a):a.data&&i.enqueue(a.data)});await uz(e,lz((a,s,c)=>{n(a,s,c),c&&i.close()}))}});return $t.fromReadableStream(r)}function TK(e){return e.data===""&&e.event===""&&e.id===""&&e.retry===void 0}var fz=C({});var pz=C({convertToOpenAIFunction:()=>mz,convertToOpenAITool:()=>AK,isLangChainTool:()=>Sf,isRunnableToolLike:()=>wf,isStructuredTool:()=>bf,isStructuredToolParams:()=>xf});function mz(e,t){let r=typeof t=="number"?void 0:t;return{name:e.name,description:e.description,parameters:zt(e.schema),...r?.strict!==void 0?{strict:r.strict}:{}}}function AK(e,t){let r=typeof t=="number"?void 0:t,i;return Sf(e)?i={type:"function",function:mz(e)}:i=e,r?.strict!==void 0&&(i.function.strict=r.strict),i}var hz=C({DEFAULT_LANGSMITH_GATEWAY:()=>gz,resolveLangSmithGatewayConfig:()=>DK}),CK="LANGSMITH_GATEWAY",OK="LANGSMITH_GATEWAY_API_KEY",PK="LANGSMITH_API_KEY",gz="https://gateway.smith.langchain.com",NK=["true","1","yes"],RK=["false","0","no"];function jK(e){let t=Ot(CK);if(!(!t||RK.includes(t.toLowerCase())))return`${NK.includes(t.toLowerCase())?gz:t.replace(/\/+$/,"")}/${e}`}function DK({baseURL:e,providerPath:t}){if(e!==void 0)return{baseURL:e};let r=jK(t);return r===void 0?{}:{baseURL:r,apiKey:Ot(OK)||Ot(PK)}}function D_(e,t){let r=0,i=0,n=0;for(let o=0;o<e.length;o++)r+=e[o]*t[o],i+=e[o]*e[o],n+=t[o]*t[o];return r/(Math.sqrt(i)*Math.sqrt(n))}function _z(e,t){let r=0;for(let i=0;i<e.length;i++)r+=e[i]*t[i];return r}function MK(e,t){let r=0;for(let i=0;i<e.length;i++)r+=(e[i]-t[i])*(e[i]-t[i]);return r}function yz(e,t){return Math.sqrt(MK(e,t))}var vz=C({cosineSimilarity:()=>JI,euclideanDistance:()=>UK,innerProduct:()=>LK,matrixFunc:()=>M_,maximalMarginalRelevance:()=>FK,normalize:()=>zK});function M_(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(i=>t.map(n=>r(i,n)).map(n=>Number.isNaN(n)?0:n))}function zK(e,t=!1){let r=BK(e);return e.map(i=>i.map(n=>t?1-n/r:n/r))}function JI(e,t){return M_(e,t,D_)}function LK(e,t){return M_(e,t,_z)}function UK(e,t){return M_(e,t,yz)}function FK(e,t,r=.5,i=4){if(Math.min(i,t.length)<=0)return[];let n=JI(Array.isArray(e[0])?e:[e],t)[0],o=bz(n).maxIndex,a=[t[o]],s=[o];for(;s.length<Math.min(i,t.length);){let c=-1/0,u=-1,l=JI(t,a);n.forEach((d,f)=>{if(s.includes(f))return;let p=Math.max(...l[f]),m=r*d-(1-r)*p;m>c&&(c=m,u=f)}),a.push(t[u]),s.push(u)}return s}function bz(e){if(e.length===0)return{maxIndex:-1,maxValue:NaN};let t=e[0],r=0;for(let i=1;i<e.length;i+=1)e[i]>t&&(r=i,t=e[i]);return{maxIndex:r,maxValue:t}}function BK(e){return e.reduce((t,r)=>Math.max(t,bz(r).maxValue),0)}var wz=C({isCloudMetadata:()=>XI,isLocalhost:()=>YI,isPrivateIp:()=>Iz,isSafeUrl:()=>JK,isSameOrigin:()=>XK,validateSafeUrl:()=>Ez}),VK=["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"],HK=["169.254.169.254","169.254.170.2","100.100.100.200"],ZK=["metadata.google.internal","metadata","instance-data"],GK=["localhost","localhost.localdomain"],KK=/^(?:(?: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 xz(e){return KK.test(e)}function z_(e){return $z(e)!==null}function Sz(e){return xz(e)||z_(e)}function kz(e){if(xz(e))return e.split(".").map(t=>parseInt(t,10));if(z_(e)){let t=$z(e);if(!t)return null;let r=t.split(":"),i=[];for(let n of r)i.push(parseInt(n,16));return i}return null}function $z(e){if(!e||typeof e!="string"||!e.includes(":")||!/^[0-9a-fA-F:]+$/.test(e))return null;let t=e;if(t.includes("::")){let i=t.split("::");if(i.length>2)return null;let[n,o]=i,a=n?n.split(":"):[],s=o?o.split(":"):[],c=8-(a.length+s.length);if(c<0)return null;let u=Array(c).fill("0");t=[...a,...u,...s].filter(l=>l!=="").join(":")}let r=t.split(":");if(r.length!==8)return null;for(let i of r)if(i.length===0||i.length>4||!/^[0-9a-fA-F]+$/.test(i))return null;return r.map(i=>i.padStart(4,"0").toLowerCase()).join(":")}function WK(e){let[t,r]=e.split("/");if(!t||!r)return null;let i=kz(t);if(!i)return null;let n=parseInt(r,10);if(isNaN(n))return null;let o=z_(t);return o&&n>128||!o&&n>32?null:{addr:i,prefixLen:n,isIpv6:o}}function qK(e,t){let r=kz(e);if(!r)return!1;let i=WK(t);if(!i)return!1;let n=z_(e);if(n!==i.isIpv6)return!1;let{addr:o,prefixLen:a}=i;if(n)for(let s=0;s<Math.ceil(a/16);s++){let c=65535<<16-Math.min(16,a-s*16)&65535;if((r[s]&c)!==(o[s]&c))return!1}else for(let s=0;s<Math.ceil(a/8);s++){let c=255<<8-Math.min(8,a-s*8)&255;if((r[s]&c)!==(o[s]&c))return!1}return!0}function Iz(e){if(!Sz(e))return!1;for(let t of VK)if(qK(e,t))return!0;return!1}function XI(e,t){if(HK.includes(t||""))return!0;let r=e.toLowerCase();return!!ZK.includes(r)}function YI(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!!GK.includes(r)}function Ez(e,t){let r=t?.allowPrivate??!1,i=t?.allowHttp??!1;try{let n;try{n=new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}let o=n.hostname;if(!o)throw new Error("URL missing hostname.");if(XI(o))throw new Error(`URL points to cloud metadata endpoint: ${o}`);if(YI(o)){if(!r)throw new Error(`URL points to localhost: ${o}`);return e}let a=n.protocol;if(a!=="http:"&&a!=="https:")throw new Error(`Invalid URL scheme: ${a}. Only http and https are allowed.`);if(a==="http:"&&!i)throw new Error("HTTP scheme not allowed. Use HTTPS or set allowHttp: true.");if(Sz(o)){let s=o;if(YI(o,s)){if(!r)throw new Error(`URL points to localhost: ${o}`);return e}if(XI(o,s))throw new Error(`URL resolves to cloud metadata IP: ${s} (${o})`);if(Iz(s)&&!r)throw new Error(`URL resolves to private IP: ${s} (${o}). Set allowPrivate: true to allow.`);return e}return e}catch(n){throw n&&typeof n=="object"&&"message"in n?n:new Error(`URL validation failed: ${n}`)}}function JK(e,t){try{return Ez(e,t),!0}catch{return!1}}function XK(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}var Tz=C({SaveableVectorStore:()=>YK,VectorStore:()=>U_,VectorStoreRetriever:()=>L_}),L_=class extends pf{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)}},U_=class extends xt{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,i=void 0){return(await this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)).map(n=>n[0])}async similaritySearchWithScore(e,t=4,r=void 0,i=void 0){return this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)}static fromTexts(e,t,r,i){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,i,n,o){if(typeof e=="number")return new L_({vectorStore:this,k:e,filter:t,tags:[...i??[],this._vectorstoreType()],metadata:n,verbose:o,callbacks:r});{let a={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 L_({...a,searchKwargs:e.searchKwargs}):new L_({...a})}}},YK=class extends U_{static load(e,t){throw new Error("Not implemented")}};var Az=class extends ya{_combineLLMOutput(){return[]}_llmType(){return"fake"}async _generate(e,t,r){if(t?.stop?.length)return{generations:[{message:new Le(t.stop[0]),text:t.stop[0]}]};let i=e.map(n=>typeof n.content=="string"?n.content:JSON.stringify(n.content,null,2)).join(`
434
+ `);return await r?.handleLLMNewToken(i),{generations:[{message:new Le(i),text:i}],llmOutput:{}}}},Cz=class Oz extends ya{sleep=50;responses=[];chunks=[];toolStyle="openai";thrownErrorString;tools=[];constructor({sleep:t=50,responses:r=[],chunks:i=[],toolStyle:n="openai",thrownErrorString:o,...a}){super(a),this.sleep=t,this.responses=r,this.chunks=i,this.toolStyle=n,this.thrownErrorString=o}_llmType(){return"fake"}bindTools(t){let r=[...this.tools,...t],i=r.map(a=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:a.name,description:a.description,parameters:zt(a.schema)}};case"anthropic":return{name:a.name,description:a.description,input_schema:zt(a.schema)};case"bedrock":return{toolSpec:{name:a.name,description:a.description,inputSchema:zt(a.schema)}};case"google":return{name:a.name,description:a.description,parameters:zt(a.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),n=this.toolStyle==="google"?[{functionDeclarations:i}]:i,o=new Oz({sleep:this.sleep,responses:this.responses,chunks:this.chunks,toolStyle:this.toolStyle,thrownErrorString:this.thrownErrorString});return o.tools=r,o.withConfig({tools:n})}async _generate(t,r,i){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let n=this.responses?.[0]?.content??t[0].content??"";return{generations:[{text:"",message:new Le({content:n,tool_calls:this.chunks?.[0]?.tool_calls})}]}}async*_streamResponseChunks(t,r,i){if(this.thrownErrorString)throw new Error(this.thrownErrorString);if(this.chunks?.length){for(let a of this.chunks){let s=new Qo({message:new nt({content:a.content,tool_calls:a.tool_calls,additional_kwargs:a.additional_kwargs??{}}),text:a.content?.toString()??""});if(r.signal?.aborted)break;yield s,await i?.handleLLMNewToken(a.content,void 0,void 0,void 0,void 0,{chunk:s})}return}let n=this.responses?.[0]??new Le(typeof t[0].content=="string"?t[0].content:""),o=typeof n.content=="string"?n.content:"";for(let a of o){await new Promise(c=>setTimeout(c,this.sleep));let s=new Qo({message:new nt({content:a}),text:a});if(r.signal?.aborted)break;yield s,await i?.handleLLMNewToken(a,void 0,void 0,void 0,void 0,{chunk:s})}}},Pz=class Nz extends ya{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:i,emitCustomEvent:n,generationInfo:o}=t;this.responses=r,this.sleep=i,this.emitCustomEvent=n??this.emitCustomEvent,this.generationInfo=o}_combineLLMOutput(){return[]}_llmType(){return"fake-list"}async _generate(t,r,i){if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);if(this.emitCustomEvent&&await i?.handleCustomEvent("some_test_event",{someval:!0}),r?.stop?.length)return{generations:[this._formatGeneration(r.stop[0])]};{let n=this._currentResponse();return this._incrementResponse(),{generations:[this._formatGeneration(n)],llmOutput:{}}}}_formatGeneration(t){return{message:new Le(t),text:t}}async*_streamResponseChunks(t,r,i){let n=this._currentResponse();this._incrementResponse(),this.emitCustomEvent&&await i?.handleCustomEvent("some_test_event",{someval:!0});let o=[...n];for(let a=0;a<o.length;a++){let s=o[a],c=a===o.length-1;if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);let u=this._createResponseChunk(s,c?this.generationInfo:void 0);if(r.signal?.aborted)break;yield u,i?.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 Qo({message:new nt({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],i=r.map(a=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:a.name,description:a.description,parameters:zt(a.schema)}};case"anthropic":return{name:a.name,description:a.description,input_schema:zt(a.schema)};case"bedrock":return{toolSpec:{name:a.name,description:a.description,inputSchema:zt(a.schema)}};case"google":return{name:a.name,description:a.description,parameters:zt(a.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),n=this.toolStyle==="google"?[{functionDeclarations:i}]:i,o=new Nz({responses:this.responses,sleep:this.sleep,emitCustomEvent:this.emitCustomEvent,generationInfo:this.generationInfo});return o.tools=r,o.toolStyle=this.toolStyle,o.i=this.i,o.withConfig({tools:n})}withStructuredOutput(t,r){return mr.from(async i=>{let n=await this.invoke(i);if(n.tool_calls?.[0]?.args)return n.tool_calls[0].args;if(typeof n.content=="string")return JSON.parse(n.content);throw new Error("No structured output found")})}};var Rz=class extends Ng{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,i=r===0?0:this.vectorSize-r,n=t.length+i;t=t.padEnd(n," ");let o=t.length/this.vectorSize,a=[];for(let s=0;s<t.length;s+=o)a.push(t.slice(s,s+o));return a.map(s=>{let c=0;for(let u=0;u<s.length;u+=1)c+=s===" "?0:s.charCodeAt(u);return c%26/26})}},jz=class extends Ng{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 Dz=class extends Wg{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 i=this.response??e;return await r?.handleLLMNewToken(i),i}},Mz=class extends Wg{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 i=this.responses?.[0];this.responses=this.responses?.slice(1);for(let n of i??e)await new Promise(o=>setTimeout(o,this.sleep)),yield{text:n,generationInfo:{}},await r?.handleLLMNewToken(n)}};var zz=class extends Bk{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 ht(e))}async addAIMessage(e){this.messages.push(new Le(e))}async clear(){this.messages=[]}},Lz=class extends Pg{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async addMessage(e){this.messages.push(e)}async getMessages(){return this.messages}},Uz=class extends Yt{name="fake_tracer";runs=[];constructor(){super()}persistRun(e){return this.runs.push(e),Promise.resolve()}};var Fz=class extends Zn{lc_namespace=["tests","fake"];getFormatInstructions(){return""}async parse(e){return e.split(",").map(t=>t.trim())}};var Bz=class extends pf{lc_namespace=["test","fake"];output=[new ln({pageContent:"foo"}),new ln({pageContent:"bar"})];constructor(e){super(),this.output=e?.output??this.output}async _getRelevantDocuments(e){return this.output}};var Vz=class extends ue{lc_namespace=["tests","fake"];returnOptions;constructor(e){super(e),this.returnOptions=e.returnOptions}async invoke(e,t){return this.returnOptions?t??{}:{input:e}}};var Hz=class extends zf{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 Zz=class extends Yt{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 Gz=class Kz extends U_{memoryVectors=[];similarity;_vectorstoreType(){return"memory"}constructor(t,{similarity:r,...i}={}){super(t,i),this.similarity=r??D_}async addDocuments(t){let r=t.map(({pageContent:i})=>i);return this.addVectors(await this.embeddings.embedDocuments(r),t)}async addVectors(t,r){let i=t.map((n,o)=>({content:r[o].pageContent,embedding:n,metadata:r[o].metadata}));this.memoryVectors=this.memoryVectors.concat(i)}async similaritySearchVectorWithScore(t,r,i){let n=a=>i?i(new ln({metadata:a.metadata,pageContent:a.content})):!0,o=this.memoryVectors.filter(n);return o.map((a,s)=>({similarity:this.similarity(t,a.embedding),index:s})).sort((a,s)=>a.similarity>s.similarity?-1:0).slice(0,r).map(a=>[new ln({metadata:o[a.index].metadata,pageContent:o[a.index].content}),a.similarity])}static async fromTexts(t,r,i,n){let o=[];for(let a=0;a<t.length;a+=1){let s=Array.isArray(r)?r[a]:r,c=new ln({pageContent:t[a],metadata:s});o.push(c)}return Kz.fromDocuments(o,i,n)}static async fromDocuments(t,r,i){let n=new this(r,i);return await n.addDocuments(t),n}static async fromExistingIndex(t,r){return new this(t,r)}};var Wz=C({FakeChatMessageHistory:()=>zz,FakeChatModel:()=>Az,FakeEmbeddings:()=>jz,FakeLLM:()=>Dz,FakeListChatMessageHistory:()=>Lz,FakeListChatModel:()=>Pz,FakeRetriever:()=>Bz,FakeRunnable:()=>Vz,FakeSplitIntoListParser:()=>Fz,FakeStreamingChatModel:()=>Cz,FakeStreamingLLM:()=>Mz,FakeTool:()=>Hz,FakeTracer:()=>Uz,FakeVectorStore:()=>Gz,SingleRunExtractor:()=>Zz,SyntheticEmbeddings:()=>Rz,asAsyncIterable:()=>n_,openAIReasoningTextChunks:()=>o_,openAITextOnlyChunks:()=>vf,openAITextOnlyChunksWithUsage:()=>i_,openAIToolCallChunks:()=>a_,sseResponseFromOpenAIChunks:()=>s_,streamMatchers:()=>qu});var qz=C({agents:()=>zT,caches:()=>GA,callbacks__base:()=>JA,callbacks__manager:()=>NP,callbacks__promises:()=>CP,chat_history:()=>Rj,document_loaders__base:()=>Mj,document_loaders__langsmith:()=>zj,documents:()=>Dj,embeddings:()=>Lj,errors:()=>BT,example_selectors:()=>Wj,index:()=>MT,indexing:()=>Xj,language_models__base:()=>oD,language_models__chat_models:()=>MD,language_models__compat:()=>RD,language_models__event:()=>LD,language_models__llms:()=>UD,language_models__openai_completions_stream:()=>zD,language_models__profile:()=>BD,language_models__stream:()=>TD,language_models__structured_output:()=>ID,load__serializable:()=>TT,memory:()=>VD,messages:()=>Nj,messages__tool:()=>dA,output_parsers:()=>xD,output_parsers__openai_functions:()=>GD,output_parsers__openai_tools:()=>KD,outputs:()=>JP,prompt_values:()=>Yj,prompts:()=>oM,retrievers:()=>sM,retrievers__document_compressors:()=>aM,runnables:()=>lD,runnables__graph:()=>cj,singletons:()=>LP,stores:()=>cM,structured_query:()=>hM,testing:()=>SM,tools:()=>ez,tracers__base:()=>wP,tracers__console:()=>SP,tracers__log_stream:()=>qP,tracers__run_collector:()=>iz,tracers__tracer_langchain:()=>IP,types__stream:()=>oz,utils__async_caller:()=>rN,utils__chunk_array:()=>az,utils__context:()=>sz,utils__env:()=>CT,utils__event_source_parse:()=>cz,utils__format:()=>fz,utils__function_calling:()=>pz,utils__gateway:()=>hz,utils__hash:()=>LT,utils__json_patch:()=>dD,utils__json_schema:()=>tj,utils__math:()=>vz,utils__ssrf:()=>wz,utils__standard_schema:()=>cN,utils__stream:()=>UP,utils__testing:()=>Wz,utils__tiktoken:()=>nD,utils__types:()=>SD,utils__uuid:()=>bT,vectorstores:()=>Tz});var QK=50;function eW(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,[i,n])=>(r[n]=i,r),{})}async function F_(e){let{optionalImportsMap:t,optionalImportEntrypoints:r,importMap:i,secretsMap:n,secretsFromEnv:o,path:a,depth:s,maxDepth:c}=this,u=a.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)=>F_.call({...this,path:[...a,`${p}`],depth:s+1},f)));let l=e;if(By(l))return vp(l);if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="secret"){let[f]=l.id;if(f in n)return n[f];if(o){let p=Ot(f);if(p)return p}throw new Error(`Missing secret "${f}" at ${u}`)}if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="not_implemented"){let f=JSON.stringify(l);throw new Error(`Trying to load an object that doesn't implement serialization: ${u} -> ${f}`)}if("lc"in l&&"type"in l&&"id"in l&&"kwargs"in l&&l.lc===1&&l.type==="constructor"){let f=l,p=JSON.stringify(f),[m,...h]=f.id.slice().reverse(),g=h.reverse(),_={langchain_core:qz,langchain:i},v=null,x=[g.join("/")];g[0]==="langchain_community"&&x.push(["langchain",...g.slice(1)].join("/"));let S=x.find(b=>b in t);if(DT.concat(r).includes(g.join("/"))||S)if(S!==void 0)v=await t[S];else throw new Error(`Missing key "${g.join("/")}" for ${u} in load(optionalImportsMap={})`);else{let b;if(g[0]==="langchain"||g[0]==="langchain_core")b=_[g[0]],g.shift();else throw new Error(`Invalid namespace: ${u} -> ${p}`);if(g.length===0)throw new Error(`Invalid namespace: ${u} -> ${p}`);let z;do{if(z=g.join("__"),z in b)break;g.pop()}while(g.length>0);z in b&&(v=b[z])}if(typeof v!="object"||v===null)throw new Error(`Invalid namespace: ${u} -> ${p}`);let k=v[m]??Object.values(v).find(b=>typeof b=="function"&&yc(b)===m);if(typeof k!="function")throw new Error(`Invalid identifer: ${u} -> ${p}`);let T=await F_.call({...this,path:[...a,"kwargs"],depth:s+1},f.kwargs),A=new k(_p(T,$T,eW(k)));return Object.defineProperty(A.constructor,"name",{value:m}),A}let d={};for(let[f,p]of Object.entries(l))d[f]=await F_.call({...this,path:[...a,f],depth:s+1},p);return d}async function Jz(e,t){let r=JSON.parse(e),i={optionalImportsMap:t?.optionalImportsMap??{},optionalImportEntrypoints:t?.optionalImportEntrypoints??[],secretsMap:t?.secretsMap??{},secretsFromEnv:t?.secretsFromEnv??!1,importMap:t?.importMap??{},path:["$"],depth:0,maxDepth:t?.maxDepth??QK};return F_.call(i,r)}function tW(e){return e!==null&&e.lc===1&&e.type==="constructor"&&Array.isArray(e.id)}function rW(e){return e.lc===2&&e.type==="undefined"}function nW(e){return e.lc===2&&e.type==="delta_snapshot"&&Object.prototype.hasOwnProperty.call(e,"value")}function iW(e){return e.lc===2&&e.type==="constructor"}function Lf(e,t){return Array.isArray(e.id)&&e.id.length===1&&e.id[0]===t}function Uf(e){return e.method===void 0||e.method===null}function QI(e){return Array.isArray(e.args)&&e.args.length===1&&Array.isArray(e.args[0])}function oW(e){return e.every(t=>typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=255)}function aW(e){if(Lf(e,"Set")&&Uf(e))return QI(e)?new Set(e.args[0]):void 0;if(Lf(e,"Map")&&Uf(e))return!QI(e)||!e.args[0].every(t=>Array.isArray(t)&&t.length===2)?void 0:new Map(e.args[0]);if(Lf(e,"RegExp")&&Uf(e)){if(!Array.isArray(e.args)||e.args.length!==2||typeof e.args[0]!="string"||typeof e.args[1]!="string")return;try{return new RegExp(e.args[0],e.args[1])}catch{return}}if(Lf(e,"Error")&&Uf(e))return!Array.isArray(e.args)||e.args.length!==1||typeof e.args[0]!="string"?void 0:new Error(e.args[0]);if(Lf(e,"Uint8Array")&&(Uf(e)||e.method==="from"))return!QI(e)||!oW(e.args[0])?void 0:new Uint8Array(e.args[0])}async function eE(e){if(e&&typeof e=="object"){if(Array.isArray(e))return await Promise.all(e.map(t=>eE(t)));{let t={};for(let[r,i]of Object.entries(e))t[r]=await eE(i);return rW(t)?void 0:nW(t)?new gc(t.value):iW(t)?aW(t)??t:tW(t)?Jz(JSON.stringify(t)):t}}return e}function B_(e,t,r,i){return{lc:2,type:"constructor",id:[e.name],method:t??null,args:r??[],kwargs:i??{}}}function sW(e){return e===void 0?{lc:2,type:"undefined"}:e instanceof gc?{lc:2,type:"delta_snapshot",value:e.value}:e instanceof Set||e instanceof Map?B_(e.constructor,void 0,[Array.from(e)]):e instanceof RegExp?B_(RegExp,void 0,[e.source,e.flags]):e instanceof Error?B_(Error,void 0,[e.message]):e?.lg_name==="Send"?{node:e.node,args:e.args,...e.timeout!==void 0?{timeout:e.timeout}:{}}:e instanceof Uint8Array?B_(Uint8Array,"from",[Array.from(e)]):e}var V_=class{_dumps(e){return new TextEncoder().encode(xT(e,(t,r)=>sW(r)))}async dumpsTyped(e){return e instanceof Uint8Array?["bytes",e]:["json",this._dumps(e)]}async _loads(e){return eE(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 tE(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]=tE(e[r]));return t}function sc(){return{v:4,id:Il(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:tE(e.versions_seen??{})}}var H_=class{serde=new V_;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 i={},n={},o=new Set(r);for(let c of r)i[c]=[];let a=(await this.getTuple(t))?.parentConfig;for(;a!=null&&o.size>0;){let c=await this.getTuple(a);if(c===void 0)break;if(c.pendingWrites&&c.pendingWrites.length>0){let u={};for(let l of c.pendingWrites){let d=l[1];o.has(d)&&(u[d]??=[]).push(l)}for(let l of Object.keys(u)){let d=u[l];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)i[l].push(d[f])}}for(let u of Array.from(o))Object.prototype.hasOwnProperty.call(c.checkpoint.channel_values,u)&&(n[u]=c.checkpoint.channel_values[u],o.delete(u));a=c.parentConfig}let s={};for(let c of r){let u={writes:i[c].slice().reverse()};Object.prototype.hasOwnProperty.call(n,c)&&(u.seed=n[c]),s[c]=u}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 Z_(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):String(e).localeCompare(String(t))}function Ff(...e){return e.reduce((t,r,i)=>i===0?r:Z_(t,r)>=0?t:r)}var Bf={[Dy]:-1,[Ua]:-2,[My]:-3,[zy]:-4},rE=new Set(["thread_id","checkpoint_id","checkpoint_ns","checkpoint_map","langgraph_step","langgraph_node","langgraph_triggers","langgraph_path","langgraph_checkpoint_ns"]);function G_(e){return e.configurable?.checkpoint_id||e.configurable?.thread_ts||""}var cW=new Set(["__proto__","constructor","prototype"]);function tr(e,t,r={}){let{allowEmpty:i=!1}=r;if(typeof t!="string"){let n=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 ${n}). This guard protects MemorySaver from prototype pollution.`)}if(!i&&t==="")throw new Error(`Invalid configurable value for key "${e}": empty string is not permitted as an in-memory storage key.`);if(cW.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 il(e,t,r){return JSON.stringify([e,t,r])}function uW(e){let[t,r,i]=JSON.parse(e);return{threadId:t,checkpointNamespace:r,checkpointId:i}}var Xz=class extends H_{storage=Object.create(null);writes=Object.create(null);constructor(e){super(e)}async _migratePendingSends(e,t,r,i){let n=e,o=il(t,r,i),a=await Promise.all(Object.values(this.writes[o]??{}).filter(([s,c])=>c===El).map(async([s,c,u])=>await this.serde.loadsTyped("json",u)));n.channel_values??={},n.channel_values[El]=a,n.channel_versions??={},n.channel_versions[El]=Object.keys(n.channel_versions).length>0?Ff(...Object.values(n.channel_versions)):this.getNextVersion(void 0)}async getTuple(e){let t=e.configurable?.thread_id,r=e.configurable?.checkpoint_ns??"",i=G_(e);if(t!==void 0&&tr("thread_id",t),tr("checkpoint_ns",r,{allowEmpty:!0}),i&&tr("checkpoint_id",i),i){let n=this.storage[t]?.[r]?.[i];if(n!==void 0){let[o,a,s]=n,c=il(t,r,i),u=await this.serde.loadsTyped("json",o);u.v<4&&s!==void 0&&await this._migratePendingSends(u,t,r,s);let l=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:u,metadata:await this.serde.loadsTyped("json",a),pendingWrites:l};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}else{let n=this.storage[t]?.[r];if(n!==void 0){i=Object.keys(n).sort((f,p)=>p.localeCompare(f))[0];let[o,a,s]=n[i],c=il(t,r,i),u=await this.serde.loadsTyped("json",o);u.v<4&&s!==void 0&&await this._migratePendingSends(u,t,r,s);let l=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:i,checkpoint_ns:r}},checkpoint:u,metadata:await this.serde.loadsTyped("json",a),pendingWrites:l};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:i,filter:n}=t??{};e.configurable?.thread_id!==void 0&&tr("thread_id",e.configurable.thread_id),e.configurable?.checkpoint_ns!==void 0&&tr("checkpoint_ns",e.configurable.checkpoint_ns,{allowEmpty:!0}),e.configurable?.checkpoint_id&&tr("checkpoint_id",e.configurable.checkpoint_id),r?.configurable?.checkpoint_id&&tr("checkpoint_id",r.configurable.checkpoint_id);let o=e.configurable?.thread_id?[e.configurable?.thread_id]:Object.keys(this.storage),a=e.configurable?.checkpoint_ns,s=e.configurable?.checkpoint_id;for(let c of o)for(let u of Object.keys(this.storage[c]??{})){if(a!==void 0&&u!==a)continue;let l=this.storage[c]?.[u]??{},d=Object.entries(l).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 g=await this.serde.loadsTyped("json",m);if(n&&!Object.entries(n).every(([T,A])=>g[T]===A))continue;if(i!==void 0){if(i<=0)break;i-=1}let _=il(c,u,f),v=Object.values(this.writes[_]||{}),x=await Promise.all(v.map(async([T,A,b])=>[T,A,await this.serde.loadsTyped("json",b)])),S=await this.serde.loadsTyped("json",p);S.v<4&&h!==void 0&&await this._migratePendingSends(S,c,u,h);let k={config:{configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:f}},checkpoint:S,metadata:g,pendingWrites:x};h!==void 0&&(k.parentConfig={configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:h}}),yield k}}}async put(e,t,r){let i=Wn(t),n=e.configurable?.thread_id,o=e.configurable?.checkpoint_ns??"";if(n===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" } })');tr("thread_id",n),tr("checkpoint_ns",o,{allowEmpty:!0}),tr("checkpoint_id",t.id),this.storage[n]||(this.storage[n]=Object.create(null)),this.storage[n][o]||(this.storage[n][o]=Object.create(null));let[[,a],[,s]]=await Promise.all([this.serde.dumpsTyped(i),this.serde.dumpsTyped(r)]);return this.storage[n][o][t.id]=[a,s,e.configurable?.checkpoint_id],{configurable:{thread_id:n,checkpoint_ns:o,checkpoint_id:t.id}}}async putWrites(e,t,r){let i=e.configurable?.thread_id,n=e.configurable?.checkpoint_ns,o=e.configurable?.checkpoint_id;if(i===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(o===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "checkpoint_id" field in its "configurable" property.');tr("thread_id",i),tr("checkpoint_ns",n,{allowEmpty:!0}),tr("checkpoint_id",o),tr("task_id",r);let a=il(i,n,o),s=this.writes[a];this.writes[a]===void 0&&(this.writes[a]=Object.create(null)),await Promise.all(t.map(async([c,u],l)=>{let[,d]=await this.serde.dumpsTyped(u),f=[r,Bf[c]||l],p=`${f[0]},${f[1]}`;f[1]>=0&&s&&p in s||(this.writes[a][p]=[r,c,d])}))}async deleteThread(e){tr("thread_id",e),delete this.storage[e];for(let t of Object.keys(this.writes))uW(t).threadId===e&&delete this.writes[t]}async getDeltaChannelHistory(e){let{config:t,channels:r}=e;if(r.length===0)return{};let i=t.configurable?.thread_id,n=t.configurable?.checkpoint_ns??"",o=G_(t);i!==void 0&&tr("thread_id",i),tr("checkpoint_ns",n,{allowEmpty:!0});let a=this.storage[i]?.[n]??{},s=[],c=(o?a[o]:void 0)?.[2];for(;c!==void 0;){let p=a[c];if(p===void 0)break;s.push(c),c=p[2]}let u={},l={},d=new Set(r);for(let p of r)u[p]=[];for(let p of s){if(d.size===0)break;let m=a[p],h=m!==void 0?await this.serde.loadsTyped("json",m[0]):void 0,g={},_=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&&(g[S]=h.channel_values[S],_.add(S));let v=il(i,n,p),x=Object.entries(this.writes[v]??{});x.sort(([S],[k])=>{let[T,A]=S.split(","),[b,z]=k.split(",");return T!==b?T<b?1:-1:Number(z)-Number(A)});for(let[,[S,k,T]]of x)d.has(k)&&u[k].push([S,k,await this.serde.loadsTyped("json",T)]);for(let S of _)l[S]=g[S],d.delete(S)}let f={};for(let p of r){let m={writes:u[p].slice().reverse()};Object.prototype.hasOwnProperty.call(l,p)&&(m.seed=l[p]),f[p]=m}return f}};var ol=class extends Error{constructor(e){super(e),this.name="InvalidNamespaceError"}};function lW(e){if(e.length===0)throw new ol("Namespace cannot be empty.");for(let t of e){if(typeof t!="string")throw new ol(`Invalid namespace label '${t}' found in ${e}. Namespace labels must be strings, but got ${typeof t}.`);if(t.includes("."))throw new ol(`Invalid namespace label '${t}' found in ${e}. Namespace labels cannot contain periods ('.').`);if(t==="")throw new ol(`Namespace labels cannot be empty strings. Got ${t} in ${e}`)}if(e[0]==="langgraph")throw new ol(`Root label for namespace cannot be "langgraph". Got: ${e}`)}var al=class{async get(e,t){return(await this.batch([{namespace:e,key:t}]))[0]}async search(e,t={}){let{filter:r,limit:i=10,offset:n=0,query:o}=t;return(await this.batch([{namespacePrefix:e,filter:r,limit:i,offset:n,query:o}]))[0]}async put(e,t,r,i){lW(e),await this.batch([{namespace:e,key:t,value:r,index:i}])}async delete(e,t){await this.batch([{namespace:e,key:t,value:null}])}async listNamespaces(e={}){let{prefix:t,suffix:r,maxDepth:i,limit:n=100,offset:o=0}=e,a=[];return t&&a.push({matchType:"prefix",path:t}),r&&a.push({matchType:"suffix",path:r}),(await this.batch([{matchConditions:a.length?a:void 0,maxDepth:i,limit:n,offset:o}]))[0]}start(){}stop(){}};var dW=e=>"lg_name"in e&&e.lg_name==="AsyncBatchedStore"?e.store:e,K_=class extends al{lg_name="AsyncBatchedStore";store;queue=new Map;nextKey=0;running=!1;processingTask=null;constructor(e){super(),this.store=dW(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:i=10,offset:n=0,query:o}=t||{};return this.enqueueOperation({namespacePrefix:e,filter:r,limit:i,offset:n,query:o})}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 i=this.nextKey;this.nextKey+=1,this.queue.set(i,{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:i})=>i),r=await this.store.batch(t);e.forEach(({resolve:i},n)=>{i(r[Array.from(e.keys()).indexOf(n)])})}catch(t){e.forEach(({reject:r})=>{r(t)})}}}toJSON(){return{queue:this.queue,nextKey:this.nextKey,running:this.running,store:"[LangGraphStore]"}}};function Vf(e){if(!e)return[];let t=[],r=[],i=0;for(;i<e.length;){let n=e[i];if(n==="["){r.length&&(t.push(r.join("")),r=[]);let o=1,a=["["];for(i+=1;i<e.length&&o>0;)e[i]==="["?o+=1:e[i]==="]"&&(o-=1),a.push(e[i]),i+=1;t.push(a.join(""));continue}else if(n==="{"){r.length&&(t.push(r.join("")),r=[]);let o=1,a=["{"];for(i+=1;i<e.length&&o>0;)e[i]==="{"?o+=1:e[i]==="}"&&(o-=1),a.push(e[i]),i+=1;t.push(a.join(""));continue}else n==="."?r.length&&(t.push(r.join("")),r=[]):r.push(n);i+=1}return r.length&&t.push(r.join("")),t}function fW(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 Yz(e,t){return fW(t)?Object.keys(t).filter(r=>r.startsWith("$")).every(r=>{let i=t[r];switch(r){case"$eq":return e===i;case"$ne":return e!==i;case"$gt":return Number(e)>Number(i);case"$gte":return Number(e)>=Number(i);case"$lt":return Number(e)<Number(i);case"$lte":return Number(e)<=Number(i);case"$in":return Array.isArray(i)?i.includes(e):!1;case"$nin":return Array.isArray(i)?!i.includes(e):!0;default:return!1}}):e===t}function Qz(e,t){if(!t||t==="$")return[JSON.stringify(e,null,2)];let r=Array.isArray(t)?t:Vf(t);function i(n,o,a){if(a>=o.length)return typeof n=="string"||typeof n=="number"||typeof n=="boolean"?[String(n)]:n==null?[]:Array.isArray(n)||typeof n=="object"?[JSON.stringify(n,null,2)]:[];let s=o[a],c=[];if(a===0&&s==="$"&&c.push(JSON.stringify(n,null,2)),s.startsWith("[")&&s.endsWith("]")){if(!Array.isArray(n))return[];let u=s.slice(1,-1);if(u==="*")for(let l of n)c.push(...i(l,o,a+1));else try{let l=parseInt(u,10);l<0&&(l=n.length+l),l>=0&&l<n.length&&c.push(...i(n[l],o,a+1))}catch{return[]}}else if(s.startsWith("{")&&s.endsWith("}")){if(typeof n!="object"||n===null)return[];let u=s.slice(1,-1).split(",").map(l=>l.trim());for(let l of u){let d=Vf(l);if(d.length){let f=n;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(n))for(let u of n)c.push(...i(u,o,a+1));else if(typeof n=="object"&&n!==null)for(let u of Object.values(n))c.push(...i(u,o,a+1))}else typeof n=="object"&&n!==null&&s in n&&c.push(...i(n[s],o,a+1));return c}return i(e,r,0)}var eL=class extends al{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]:Vf(t)])})}async batch(e){let t=[],r=new Map,i=new Map;for(let n=0;n<e.length;n+=1){let o=e[n];if("key"in o&&"namespace"in o&&!("value"in o))t.push(this.getOperation(o));else if("namespacePrefix"in o){let a=this.filterItems(o);i.set(n,[o,a]),t.push(null)}else if("value"in o){let a=`${o.namespace.join(":")}:${o.key}`;r.set(a,o),t.push(null)}else"matchConditions"in o&&t.push(this.listNamespacesOperation(o))}if(i.size>0)if(this._indexConfig?.embeddings){let n=new Set;for(let[s]of i.values())s.query&&n.add(s.query);let o=n.size>0?await Promise.all(Array.from(n).map(s=>this._indexConfig.embeddings.embedQuery(s))):[],a=Object.fromEntries(Array.from(n).map((s,c)=>[s,o[c]]));for(let[s,[c,u]]of i.entries())if(c.query&&a[c.query]){let l=a[c.query];t[s]=this.scoreResults(u,l,c.offset??0,c.limit??10)}else t[s]=this.paginateResults(u.map(l=>({...l,score:void 0})),c.offset??0,c.limit??10)}else for(let[n,[o,a]]of i.entries())t[n]=this.paginateResults(a.map(s=>({...s,score:void 0})),o.offset??0,o.limit??10);if(r.size>0&&this._indexConfig?.embeddings){let n=this.extractTexts(Array.from(r.values()));if(Object.keys(n).length>0){let o=await this._indexConfig.embeddings.embedDocuments(Object.keys(n));this.insertVectors(n,o)}}for(let n of r.values())this.putOperation(n);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 i=new Date;if(r.has(e.key)){let n=r.get(e.key);n.value=e.value,n.updatedAt=i}else r.set(e.key,{value:e.value,key:e.key,namespace:e.namespace,createdAt:i,updatedAt:i})}}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(i=>this.doesMatch(i,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,i)=>r.join(":").localeCompare(i.join(":"))),t.slice(e.offset??0,(e.offset??0)+(e.limit??t.length))}doesMatch(e,t){let{matchType:r,path:i}=e;if(r==="prefix")return i.length>t.length?!1:i.every((n,o)=>{let a=t[o];return n==="*"||a===n});if(r==="suffix")return i.length>t.length?!1:i.every((n,o)=>{let a=t[t.length-i.length+o];return n==="*"||a===n});throw new Error(`Unsupported match type: ${r}`)}filterItems(e){let t=[];for(let[i,n]of this.data.entries())i.startsWith(e.namespacePrefix.join(":"))&&t.push(...n.values());let r=t;return e.filter&&(r=t.filter(i=>Object.entries(e.filter).every(([n,o])=>Yz(i.value[n],o)))),r}scoreResults(e,t,r=0,i=10){let n=[],o=[],a=[];for(let l of e){let d=this.getVectors(l);if(d.length)for(let f of d)n.push(l),o.push(f);else a.push(l)}let s=this.cosineSimilarity(t,o).map((l,d)=>[l,n[d]]).sort((l,d)=>d[0]-l[0]),c=new Set,u=[];for(let[l,d]of s){let f=`${d.namespace.join(":")}:${d.key}`;if(c.has(f))continue;let p=c.size;if(p>=r+i)break;if(p<r){c.add(f);continue}c.add(f),u.push([l,d])}if(a.length&&u.length<i)for(let l of a.slice(0,i-u.length)){let d=`${l.namespace.join(":")}:${l.key}`;c.has(d)||(c.add(d),u.push([void 0,l]))}return u.map(([l,d])=>({...d,score:l}))}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 i=r.index===null||r.index===void 0?this._indexConfig.__tokenizedFields??[]:r.index.map(n=>[n,Vf(n)]);for(let[n,o]of i){let a=Qz(r.value,o);a.length&&(a.length>1?a.forEach((s,c)=>{t[s]||(t[s]=[]),t[s].push([r.namespace,r.key,`${n}.${c}`])}):(t[a[0]]||(t[a[0]]=[]),t[a[0]].push([r.namespace,r.key,n])))}}return t}insertVectors(e,t){for(let[r,i]of Object.entries(e)){let n=t.shift();if(!n)throw new Error(`No embedding found for text: ${r}`);for(let[o,a,s]of i){let c=o.join(":");this.vectors.has(c)||this.vectors.set(c,new Map);let u=this.vectors.get(c);u.has(a)||u.set(a,new Map),u.get(a).set(s,n)}}}getVectors(e){let t=e.namespace.join(":"),r=e.key;if(!this.vectors.has(t))return[];let i=this.vectors.get(t);if(!i.has(r))return[];let n=i.get(r),o=Array.from(n.values());return o.length?o:[]}cosineSimilarity(e,t){if(!t.length)return[];let r=t.map(o=>o.reduce((a,s,c)=>a+s*e[c],0)),i=Math.sqrt(e.reduce((o,a)=>o+a*a,0)),n=t.map(o=>Math.sqrt(o.reduce((a,s)=>a+s*s,0)));return r.map((o,a)=>{let s=n[a];return i&&s?o/(i*s):0})}get indexConfig(){return this._indexConfig}};var W_=class{serde=new V_;constructor(e){this.serde=e||this.serde}};var pW=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function An(e){return e!=null&&e.lc_graph_name==="DeltaChannel"}function iE(e){return e!=null&&e.lg_is_channel===!0}var Et=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(e){if(e.name===Ve.unminifiable_name)return!1;throw e}}equals(e){return this===e}},nE=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function sl(e){if(e[nE]===!0)return e;let t={};for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=e[r];iE(i)&&(t[r]=i)}return Object.assign(t,{[nE]:!0}),t}function q_(e,t){let r=sl(e),i={};for(let n in r){if(!Object.prototype.hasOwnProperty.call(r,n))continue;let o=t.channel_values[n];i[n]=r[n].fromCheckpoint(o)}return Object.assign(i,{[nE]:!0}),i}function oE(e,t){if(!pW.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 J_(e,t){let r=new Set,i=QE();for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let o=e[n];if(!An(o)||!o.isAvailable())continue;let[a,s]=t[n]??[0,0];(a>=o.snapshotFrequency||s>=i)&&r.add(n)}return r}function qn(e,t,r,i){let n=i?.channelsToSnapshot??new Set,{updatedChannels:o,getNextVersion:a}=i??{},s,c=e.channel_versions;if(t===void 0)s=e.channel_values;else{s={},c={...e.channel_versions};for(let u in t){if(!Object.prototype.hasOwnProperty.call(t,u))continue;let l=t[u];if(n.has(u)){a!==void 0&&(o===void 0||!o.has(u))&&(c[u]=a(c[u])),s[u]=new gc(l.get());continue}if(!An(l))try{s[u]=l.checkpoint()}catch(d){if(d.name!==Ve.unminifiable_name)throw d}}}return{v:4,id:i?.id??Il(r),ts:new Date().toISOString(),channel_values:s,channel_versions:c,versions_seen:e.versions_seen}}async function cl(e,t,r){let i=q_(e,t),{saver:n,config:o}=r??{},a=sl(e),s=[];for(let u in a)Object.prototype.hasOwnProperty.call(a,u)&&An(a[u])&&!Object.prototype.hasOwnProperty.call(t.channel_values,u)&&s.push(u);if(s.length===0||n===void 0||o===void 0)return i;let c=await n.getDeltaChannelHistory({config:o,channels:s});for(let u of s){let l=c[u];if(l===void 0)continue;let d=a[u].fromCheckpoint(l.seed);d.replayWrites(l.writes),i[u]=d}return i}var mW=e=>e!=null&&e.lc_graph_name==="BinaryOperatorAggregate",_o=class tL extends Et{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 tL(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 n=r[0],[o,a]=Pn(n);o?this.value=a:this.value=n,r=r.slice(1)}let i=!1;for(let n of r)if(Da(n)){if(i)throw new Se("Can receive only one Overwrite value per step.");let[,o]=Pn(n);this.value=o,i=!0;continue}else!i&&this.value!==void 0&&(this.value=this.operator(this.value,n));return!0}get(){if(this.value===void 0)throw new Ve;return this.value}checkpoint(){if(this.value===void 0)throw new Ve;return this.value}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:mW(t)?this.operator===t.operator:!1}};var Jn=class rL extends Et{lc_graph_name="LastValue";value=[];constructor(t){super(),this.initialValueFactory=t,t&&(this.value=[t()])}fromCheckpoint(t){let r=new rL(this.initialValueFactory);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0)return!1;if(t.length!==1)throw new Se("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 Ve;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Ve;return this.value[0]}isAvailable(){return this.value.length!==0}},aE=class nL extends Et{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint(t){let r=new nL;if(typeof t<"u"){let[i,n]=t;r.value=[i],r.finished=n}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 Ve;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 X_=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"}},Hf=function(e){return e?Y_(e):new Jn};Hf.Root=e=>new X_(e);function Y_(e){return typeof e=="object"&&e&&"reducer"in e&&e.reducer?new _o(e.reducer,e.default):typeof e=="object"&&e&&"value"in e&&e.value?new _o(e.value,e.default):new Jn}var hW=["tags","metadata","callbacks","configurable"],gW=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal","heartbeat","executionInfo","serverInfo","control"],_W=25,yW=new Set(["thread_id","checkpoint_id","checkpoint_ns","task_id","run_id","assistant_id","graph_id"]);function vW(e,t){if(!e)return t;let r=t??{};for(let i of yW){if(i in r)continue;let n=e[i];n!==void 0&&(r[i]=n)}return r}function iL(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 bW(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 i=e.copy();for(let n of t)i.addHandler(Ji(n),!0);return i}if(Array.isArray(e)){let i=t.copy();for(let n of e)i.addHandler(Ji(n),!0);return i}let r=i=>i.filter((n,o)=>i.findIndex(a=>a===n||a.name==="StreamMessagesHandler"&&n.name==="StreamMessagesHandler")===o);return new at(t._parentRunId,{handlers:r(e.handlers.concat(t.handlers)),inheritableHandlers:r(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 wW(e){let t;for(let o=e.length-1;o>=0;o-=1)if(e[o]!==void 0){t=e[o];break}let r=t?.configurable?.thread_id!==void 0,i=e.some(o=>o?.configurable?.[_r]!==void 0),n=Ue.getRunnableConfig()?.configurable?.[_r]!==void 0;return r&&!i&&!n}function ul(...e){let t={tags:[],metadata:{},callbacks:void 0,recursionLimit:_W,configurable:{}},r=wW(e),i=Ue.getRunnableConfig();if(i!==void 0){for(let[n,o]of Object.entries(i))if(o!==void 0){if(n==="configurable"&&r)continue;if(hW.includes(n)){let a;Array.isArray(o)?a=[...o]:typeof o=="object"?n==="callbacks"&&"copy"in o&&typeof o.copy=="function"?a=o.copy():a={...o}:a=o,t[n]=a}else t[n]=o}}for(let n of e)if(n!==void 0)for(let[o,a]of Object.entries(n))a===void 0||!gW.includes(o)||(o==="configurable"?t.configurable={...t.configurable,...a}:o==="metadata"?t.metadata={...t.metadata,...a}:o==="tags"?t.tags=[...t.tags??[],...a]:o==="callbacks"?t.callbacks=bW(t.callbacks,a):t[o]=a);return t.metadata=vW(t.configurable,t.metadata)??{},t}function xW(e){let t=e??Ue.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(`
435
+ `));return t?.store}function SW(e){let t=e??Ue.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(`
436
+ `));return t?.writer||t?.configurable?.writer}function Q_(){return Ue.getRunnableConfig()}function kW(e){let t=e??Ue.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(`
437
+ `));if(t.configurable?.__pregel_scratchpad?.currentTaskInput===void 0)throw new Error("BUG: internal scratchpad not initialized.");return t.configurable[yr].currentTaskInput}function ey(e){return e.split("|").filter(t=>!t.match(/^\d+$/)).map(t=>t.split(":")[0]).join("|")}function oL(e){let t=e.split("|");for(;t.length>1&&t[t.length-1].match(/^\d+$/);)t.pop();return t.slice(0,-1).join("|")}var sE=class{#e=void 0;requestDrain(e="shutdown"){this.#e=e}get drainRequested(){return this.#e!==void 0}get drainReason(){return this.#e}};var cE=["values","updates","messages","tools","custom","tasks"];function ll(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 $W(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 i=r,n=typeof i.langgraph_node=="string"?i.langgraph_node:void 0,o=typeof i.run_id=="string"?i.run_id:void 0;return{data:o!=null&&t!=null&&typeof t=="object"?{...t,run_id:o}:t,node:n}}function uE({namespace:e,mode:t,payload:r,seq:i}){let n=Date.now(),o={type:"event"};switch(t){case"messages":{let{data:a,node:s}=$W(r);return[{...o,seq:i,method:"messages",params:{namespace:e,timestamp:n,...s?{node:s}:{},data:a}}]}case"tools":return[{...o,seq:i,method:"tools",params:{namespace:e,timestamp:n,data:IW(r)}}];case"checkpoints":return ll(r)?[{...o,seq:i,method:"checkpoints",params:{namespace:e,timestamp:n,data:r}}]:[];case"values":return[{...o,seq:i,method:"values",params:{namespace:e,timestamp:n,data:r}}];case"updates":{let a=EW(r);return[{...o,seq:i,method:"updates",params:{namespace:e,timestamp:n,...typeof a.node=="string"?{node:a.node}:{},data:a}}]}case"custom":{let a=typeof r=="object"&&r!==null&&!Array.isArray(r)&&"name"in r?r:{payload:r};return[{...o,seq:i,method:"custom",params:{namespace:e,timestamp:n,data:a}}]}case"tasks":return[{...o,seq:i,method:"tasks",params:{namespace:e,timestamp:n,data:r}}];default:return[]}}function IW(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 i=t.error;return{event:"tool-error",tool_call_id:r,message:typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"?i.message:String(i??"unknown error")}}default:return{event:"tool-error",tool_call_id:"",message:`Unknown tool event: ${String(t.event)}`}}}function EW(e){if(typeof e!="object"||e===null)return{values:{}};let t=Object.entries(e);if(t.length===0)return{values:{}};let[r,i]=t[0];return{node:r,values:typeof i=="object"&&i!==null?i:{value:i}}}var lE=Symbol.for("langgraph.stream_channel"),Cn=class dE{[lE]=!0;channelName;#e=[];#t=[];#n=!1;#o;#i;constructor(t){this.channelName=t}static local(){return new dE}static remote(t){return new dE(t)}static isInstance(t){return typeof t=="object"&&t!==null&&lE in t&&t[lE]===!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.#o)throw this.#o;return{value:void 0,done:!0}}await new Promise(i=>this.#t.push(i))}}}}toAsyncIterable(t=0){return{[Symbol.asyncIterator]:()=>this.iterate(t)}}toEventStream(t={}){let r=new TextEncoder,i=this.iterate(t.startAt),n=t.event??this.channelName,o=t.serialize??(a=>JSON.stringify(a)??"null");return new ReadableStream({async pull(a){try{let s=await i.next();if(s.done){a.close();return}let c=[];n!=null&&c.push(`event: ${n}`);for(let u of o(s.value).split(/\r\n|\r|\n/))c.push(`data: ${u}`);a.enqueue(r.encode(`${c.join(`
438
+ `)}
439
+
440
+ `))}catch(s){a.error(s)}},async cancel(){await i.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.#o=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 aL(e){return Cn.isInstance(e)}var TW="custom:";function AW(e){return`${TW}${e}`}function CW(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}var ty=Symbol("resolveValues"),fE=Symbol("rejectValues"),sL=class{_events=Cn.local();_discoveries=Cn.local();#e=0;#t=!1;#n;#o=!1;#i=[];#r=[];#s=[];#a=new Map;#u=new Map;#c=[];#l=[];register(e,t){this.#a.set(Tt(e),t)}addTransformer(e){let t=this._events.size;this.#r.push(e),e.onRegister&&e.onRegister({push:(r,i)=>this.push(r,i)});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(aL(r)){if(this.#s.push(r),typeof r.channelName!="string")continue;let i=AW(r.channelName);r._wire(n=>{this._events.push({type:"event",seq:this.#e++,method:i,params:{namespace:this.#i,timestamp:Date.now(),data:n}})});continue}CW(r)&&this.#l.push({name:t,promise:Promise.resolve(r)})}}push(e,t){t.method==="values"&&this.#u.set(Tt(e),t.params.data);let r=this.#i;this.#i=e;let i=!0;for(let n of this.#r)n.process(t)||(i=!1);this.#i=r,i&&this._events.push({...t,seq:this.#e++})}close(){this.#t=!0;for(let[r,i]of this.#u.entries()){let n=r?r.split("\0"):[];this.#a.get(Tt(n))?.[ty](i)}let e=[];for(let r of this.#r){let i=r.finalize?.();i!=null&&typeof i.then=="function"&&e.push(i)}for(let r of this.#s)r._close();let t=this.#l;t.length===0&&e.length===0?(this._events.close(),this._discoveries.close()):Promise.allSettled([...e,...t.map(async({name:r,promise:i})=>{try{let n=await i;this._events.done||this._events.push({type:"event",seq:this.#e++,method:"custom",params:{namespace:[],timestamp:Date.now(),data:{name:r,payload:n}}})}catch{}})]).then(()=>{this._events.close(),this._discoveries.close()});for(let r of this.#a.values())r[ty](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.#a.values())t[fE](e)}markInterrupted(e){this.#o=!0,this.#c.push(...e)}get interrupted(){return this.#o}get interrupts(){return this.#c}subscribeEvents(e,t=0){let r=this._events.iterate(t);return{async next(){for(;;){let i=await r.next();if(i.done||Ni(i.value.params.namespace,e))return i}}}}};async function cL(e,t){let r=0;try{for await(let i of e){let[n,o,a]=i;if(o==="values"&&Ma(a)){let c=a[qe];t.markInterrupted(c.map(u=>({interruptId:u.id??"",payload:u.value})))}let s=uE({namespace:n,mode:o,payload:a,seq:r});r+=s.length;for(let c of s)t.push(n,c)}}catch(i){t.fail(i);return}t.close()}function Tt(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 ry(e,t,r=0){return{[Symbol.asyncIterator](){let i=e.iterate(r);return{async next(){for(;;){let n=await i.next();if(n.done)return{value:void 0,done:!0};if(Ni(n.value.namespace,t))return{value:n.value,done:!1}}}}}}}var uL="root";function OW(e){if(e.length===0)return uL;let t=e[e.length-1],r=t.indexOf(":");return r===-1?t:t.slice(0,r)}function PW(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Ri(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function NW(e){if(!Ri(e)||e.event!=="started")return;let t=e.cause;if(Ri(t)&&typeof t.type=="string")return t}function RW(e){if(Ri(e)&&"result"in e&&typeof e.name=="string"&&typeof e.id=="string"&&!e.name.startsWith("__"))return{name:e.name,id:e.id}}function pE(e={}){let t=e.rootGraphName??uL,r=e.initialStatus??"running",i=e.emitRootOnRegister??!0,n=e.getGraphName??OW,o=e.serializeError??PW,a=e.getTerminalStatusOverride,s=Cn.local(),c=new Map,u=new Map,l=new Map,d=new Map,f=new Set,p=[],m,h=0,g=!1,_=V=>{if(V.length===0)return t;let ee=l.get(Tt(V));return typeof ee=="string"&&ee.length>0?ee:n(V)},v=(V,ee)=>{let oe=Tt(V);if(l.has(oe))return;let ae=(Ri(ee)&&Ri(ee.metadata)?ee.metadata:void 0)?.lc_agent_name;l.set(oe,typeof ae=="string"?ae:void 0)},x=V=>{if(!Ri(V))return;let ee=V.id;if(typeof ee!="string")return;let oe=V.input,ae;if(Ri(oe)&&Ri(oe.tool_call)){let je=oe.tool_call.id;typeof je=="string"&&(ae=je)}else if(Array.isArray(oe)){for(let je of oe)if(Ri(je)&&typeof je.id=="string"){ae=je.id;break}}ae!=null&&d.set(ee,ae)},S=V=>{if(V.length===0)return;let ee=l.get(Tt(V));if(typeof ee!="string"||ee.length===0)return;let oe=V[V.length-1],ae=oe.indexOf(":");if(ae===-1)return;let je=oe.slice(ae+1);if(je.length===0)return;let Jr=d.get(je);if(!(typeof Jr!="string"||Jr.length===0))return{type:"toolCall",tool_call_id:Jr}},k=V=>u.get(Tt(V))??S(V),T=(V,ee,oe)=>{let ae=Tt(V),je=c.get(ae),Jr=je?.graphName??_(V);if(je!=null&&je.status===ee&&je.graphName===Jr&&oe?.error==null)return;je==null?(je={namespace:V,graphName:Jr,status:ee},c.set(ae,je)):je.status=ee;let $o={event:ee,graph_name:Jr,...oe?.cause!=null?{cause:oe.cause}:{},...oe?.error!=null?{error:oe.error}:{}},Io=Date.now();if(s.push({namespace:V,timestamp:Io,...$o}),!(V.length===0&&!i)&&m!=null){h+=1;try{m.push(V,{type:"event",seq:0,method:"lifecycle",params:{namespace:V,timestamp:Io,data:$o}})}finally{h-=1}}},A=V=>{let ee=Tt(V),oe=c.get(ee);return oe==null&&(oe={namespace:V,graphName:_(V),status:void 0},c.set(ee,oe)),oe},b=()=>{if(p.length===0)return;let V=p.splice(0,p.length);for(let ee of V){let oe=Tt(ee.namespace),ae=c.get(oe);ae==null||ae.status!=="started"||T(ee.namespace,"completed")}},z=V=>{let ee=Tt(V.namespace),oe=c.get(ee);oe==null||oe.status!=="started"||p.some(ae=>Tt(ae.namespace)===ee)||p.push(V)},j=(V,ee)=>{for(let oe=p.length-1;oe>=0;oe-=1){let ae=p[oe];ae.source.type==="node"&&ae.source.node===ee&&Tt(ae.source.parent)===Tt(V)&&p.splice(oe,1)}},H=V=>{for(let ee=1;ee<=V.length;ee+=1){let oe=V.slice(0,ee),ae=Tt(oe);if(c.has(ae))continue;A(oe);let je=k(oe);T(oe,"started",je!=null?{cause:je}:void 0)}},ne=()=>f.size>0?"interrupted":"completed",ye=V=>{for(let ee of c.values())ee.namespace.length!==0&&ee.status==="started"&&T(ee.namespace,V);T([],V),s.close()},Ce=async()=>{if(a==null)return ne();try{return await a()??ne()}catch{return ne()}},pt=(V,ee)=>{let oe=`${ee}:`;for(let ae of c.values()){if(ae.namespace.length!==V.length+1||ae.status!=="started"||!Ni(ae.namespace,V))continue;let je=ae.namespace[ae.namespace.length-1];if(je===ee||je.startsWith(oe))return ae.namespace}},xe=(V,ee)=>{let oe=[...V,`${ee.name}:${ee.id}`];return c.get(Tt(oe))?.status==="started"?oe:void 0};return{__native:!0,init(){return{_lifecycleLog:s,lifecycle:ry(s,[],0)}},onRegister(V){m=V,A([]),i&&T([],r)},process(V){let ee=V.params.namespace;if(h>0)return!0;let oe=V.method==="tasks"?RW(V.params.data):void 0;if(oe!=null?j(ee,oe.name):V.method==="tasks"&&(v(ee,V.params.data),x(V.params.data)),b(),V.method==="lifecycle"){let ae=NW(V.params.data);return ae!=null&&u.set(Tt(ee),ae),H(ee),!1}if(H(ee),V.method==="input"&&Ri(V.params.data)&&V.params.data.event==="requested"){let ae=V.params.data.id;typeof ae=="string"&&f.add(ae)}if(oe!=null){let ae=xe(ee,oe);ae!=null&&z({namespace:ae,source:{type:"task"}})}if(V.method==="updates"){let ae=V.params.node;if(typeof ae=="string"&&!ae.startsWith("__")){let je=pt(ee,ae);je!=null&&z({namespace:je,source:{type:"node",parent:ee,node:ae}})}}return!0},finalize(){if(!g){if(g=!0,b(),a==null){ye(ne());return}return Ce().then(ye).catch(V=>{s.fail(V)})}},fail(V){if(g)return;g=!0;let ee=o(V);for(let oe of c.values())oe.namespace.length!==0&&oe.status==="started"&&T(oe.namespace,"failed");T([],"failed",{error:ee}),s.fail(V)}}}function dl(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 Zf(e,t){let r=Cn.local(),i=new Map,n=new Set;return{init:()=>({messages:r.toAsyncIterable()}),process(o){if(o.method!=="messages"||!Ni(o.params.namespace,e)||o.params.namespace.length!==e.length+1||t!==void 0&&o.params.node!==t)return!0;let a=o.params.data;switch(a.event){case"message-start":{let s=dl(a);if(a.role==="tool"){n.add(s);break}let c=Cn.local(),u=Object.assign(new _a(c.toAsyncIterable()),{namespace:o.params.namespace,node:o.params.node});i.set(s,{source:c,stream:u}),c.push(a),r.push(u);break}case"content-block-start":case"content-block-delta":case"content-block-finish":if(n.has(dl(a)))break;i.get(dl(a))?.source.push(a);break;case"message-finish":{let s=dl(a);if(n.delete(s))break;let c=i.get(s);c&&(c.source.push(a),c.source.close(),i.delete(s));break}case"error":if(n.has(dl(a)))break;i.get(dl(a))?.source.push(a);break}return!0},finalize(){for(let[o,a]of i)a.source.push({event:"message-finish"}),a.source.close(),i.delete(o);n.clear(),r.close()},fail(o){for(let[a,s]of i)s.source.fail(o),i.delete(a);n.clear(),r.fail(o)}}}function Gf(e,t,r=0){let i=t.length+1;return{[Symbol.asyncIterator](){let n=e.iterate(r);return{async next(){for(;;){let o=await n.next();if(o.done)return{value:void 0,done:!0};let{ns:a,stream:s}=o.value;if(a.length===i&&Ni(a,t))return{value:s,done:!1}}}}}}}function mE(e,t){let{createStream:r}=t,i=new Set;return{__native:!0,init(){return{_discoveries:e._discoveries,subgraphs:Gf(e._discoveries,[],0)}},process(n){let o=n.params.namespace;if(o.length===0)return!0;let a=o.slice(0,1),s=Tt(a);if(i.has(s))return!0;i.add(s);let c=r(a,e._discoveries.size,e._events.size);return e.register(a,c),e._discoveries.push({ns:a,stream:c}),!0}}}function hE(e){let t=Cn.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 ny(e){return"__native"in e&&e.__native===!0}var lL=Symbol("setValuesLog"),dL=Symbol("setMessagesIterable"),gE=Symbol("setLifecycleIterable"),_E=Symbol("setSubgraphsIterable"),jW={[Symbol.asyncIterator](){return{next:()=>Promise.resolve({value:void 0,done:!0})}}},yE=class{path;extensions;_mux;#e;#t;#n;#o;#i;#r;#s;#a;#u;#c;constructor(e,t,r=0,i=0,n,o){this.path=e,this._mux=t,this.#t=r,this.#e=i,this.extensions=n??{},this.#n=o??new AbortController,this.#r=new Promise((a,s)=>{this.#o=a,this.#i=s}),this.#r.catch(()=>{})}[Symbol.asyncIterator](){return this._mux.subscribeEvents(this.path,this.#e)}get subgraphs(){return this.#c?this.#c:Gf(this._mux._discoveries,this.path,this.#t)}get values(){let e=this.#s,t=this.#r,r=this._mux,i=this.#e,n=this.path,o=e?e.toAsyncIterable():{[Symbol.asyncIterator]:()=>{let a=r.subscribeEvents(n,i);return{async next(){for(;;){let s=await a.next();if(s.done)return{value:void 0,done:!0};if(s.value.method==="values"&&s.value.params.namespace.length===n.length)return{value:s.value.params.data,done:!1}}}}}};return{[Symbol.asyncIterator]:()=>o[Symbol.asyncIterator](),then:t.then.bind(t)}}get messages(){if(this.#a)return this.#a;let e=Zf(this.path),t=e.init();return this._mux.addTransformer(e),this.#a=t.messages,this.#a}get lifecycle(){return this.#u??jW}messagesFrom(e){let t=Zf(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}[ty](e){this.#o?.(e),this.#o=void 0}[fE](e){this.#i?.(e),this.#i=void 0}[lL](e){this.#s=e}[dL](e){this.#a=e}[gE](e){this.#u=e}[_E](e){this.#c=e}},fL=class extends yE{name;index;constructor(e,t,r=0,i=0,n,o){super(e,t,r,i,n,o);let a=e[e.length-1]??"",s=a.lastIndexOf(":");if(s>=0){this.name=a.slice(0,s);let c=a.slice(s+1);this.index=/^\d+$/.test(c)?Number(c):0}else this.name=a,this.index=0}};function vE(e,t=[],r){let{abortController:i}=r instanceof AbortController?{abortController:r}:r??{},n=new sL,o=pE(),a=o.init(),s=a._lifecycleLog,c=mE(n,{createStream:(_,v,x)=>{let S=new fL(_,n,v,x);return S[_E](Gf(n._discoveries,_,v)),S[gE](ry(s,_,s.size)),S}}),u=c.init();n.addTransformer(c),n.addTransformer(o);let l=hE([]),d=Zf([]);n.addTransformer(l),n.addTransformer(d);let f={},p=[];for(let _ of t){let v=_();n.addTransformer(v);let x=v.init();ny(v)?p.push(x):Object.assign(f,x),typeof x=="object"&&x!==null&&!ny(v)&&n.wireChannels(x)}let m=new yE([],n,0,0,f,i);for(let _ of p)Object.assign(m,_);let h=l.init();m[lL](h._valuesLog);let g=d.init();return m[dL](g.messages),m[gE](a.lifecycle),m[_E](u.subgraphs),n.register([],m),cL(e,n).catch(_=>{}),m}var B=e=>BigInt(e),Xe=(e,t=0)=>new DataView(e.buffer,e.byteOffset+t,e.byteLength-t),gL=B("0x9E3779B1"),_L=B("0x85EBCA77"),DW=B("0xC2B2AE3D"),Sa=B("0x9E3779B185EBCA87"),cc=B("0xC2B2AE3D27D4EB4F"),yL=B("0x165667B19E3779F9"),xE=B("0x85EBCA77C2B2AE63"),MW=B("0x27D4EB2F165667C5"),zW=B("0x165667919E3779F9"),LW=B("0x9FB21C651E98DF25"),UW=e=>{let t=e.length;if(t%2!==0)throw new Error("String should have an even number of characters");let r=t/2,i=new Uint8Array(r),n=0,o=0;for(;o<r;){let a=e.slice(n,n+=2);i[o]=Number.parseInt(a,16),o+=1}return Xe(i)},ji=UW("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),fl=(B(1)<<B(128))-B(1),Te=(B(1)<<B(64))-B(1),sy=(B(1)<<B(32))-B(1),yo=64,vL=yo/8,FW=8,iy=4;function pl(e){if(!e)throw new Error("Assert failed")}function BW(e){let t=new DataView(new ArrayBuffer(8));return t.setBigUint64(0,e,!0),t.getBigUint64(0,!1)}function VW(e){let t=e;return t=(t&B(65535))<<B(16)|(t&B(4294901760))>>B(16),t=(t&B(16711935))<<B(8)|(t&B(4278255360))>>B(8),t}function HW(e,t){return(e&sy)*(t&sy)&Te}function ZW(e,t){return(e<<t|e>>B(32)-t)&sy}function bL(e,t,r){for(let i=0;i<vL;i+=1){let n=t.getBigUint64(i*8,!0),o=n^r.getBigUint64(i*8,!0);e[i^1]+=n,e[i]+=HW(o,o>>B(32))}return e}function pL(e,t,r,i){for(let n=0;n<i;n+=1)bL(e,Xe(t,n*yo),Xe(r,n*8));return e}function GW(e,t){for(let r=0;r<vL;r+=1){let i=t.getBigUint64(r*8,!0),n=e[r];n=bE(n,B(47)),n^=i,n*=gL,e[r]=n&Te}return e}function oy(e,t){return wL(e[0]^t.getBigUint64(0,!0),e[1]^t.getBigUint64(FW,!0))}function mL(e,t,r){let i=r;return i+=oy(e.slice(0),Xe(t,0*iy)),i+=oy(e.slice(2),Xe(t,4*iy)),i+=oy(e.slice(4),Xe(t,8*iy)),i+=oy(e.slice(6),Xe(t,12*iy)),Di(i&Te)}function KW(e,t,r,i,n){let o=e,a=Math.floor((r.byteLength-yo)/8),s=yo*a,c=Math.floor((t.byteLength-1)/s);for(let u=0;u<c;u+=1)o=pL(o,Xe(t,u*s),r,a),o=n(o,Xe(r,r.byteLength-yo));{let u=Math.floor((t.byteLength-1-s*c)/yo);o=pL(o,Xe(t,c*s),r,u),o=i(o,Xe(t,t.byteLength-yo),Xe(r,r.byteLength-yo-7))}return o}function WW(e,t){let r=new BigUint64Array([DW,Sa,cc,yL,xE,_L,MW,gL]);pl(e.byteLength>128),r=KW(r,e,t,bL,GW),pl(r.length*8===64);{let i=mL(r,Xe(t,11),B(e.byteLength)*Sa&Te);return mL(r,Xe(t,t.byteLength-yo-11),~(B(e.byteLength)*cc)&Te)<<B(64)|i}}function wL(e,t){let r=e*t&fl;return r&Te^r>>B(64)}function hL(e,t,r){return wL((e.getBigUint64(0,!0)^t.getBigUint64(0,!0)+r)&Te,(e.getBigUint64(8,!0)^t.getBigUint64(8,!0)-r)&Te)}function ay(e,t,r,i,n){let o=e&Te,a=e>>B(64)&Te;return o+=hL(t,i,n),o^=r.getBigUint64(0,!0)+r.getBigUint64(8,!0),o&=Te,a+=hL(r,Xe(i,16),n),a^=t.getBigUint64(0,!0)+t.getBigUint64(8,!0),a&=Te,a<<B(64)|o}function Di(e){let t=e;return t^=t>>B(37),t*=zW,t&=Te,t^=t>>B(32),t}function cy(e){let t=e;return t^=t>>B(33),t*=cc,t&=Te,t^=t>>B(29),t*=yL,t&=Te,t^=t>>B(32),t}function qW(e,t,r){let i=e.byteLength;pl(i>0&&i<=3);let n=B(e.getUint8(i-1))|B(i<<8)|B(e.getUint8(0)<<16)|B(e.getUint8(i>>1)<<24),o=(n^(B(t.getUint32(0,!0))^B(t.getUint32(4,!0)))+r)&Te,a=(B(t.getUint32(8,!0))^B(t.getUint32(12,!0)))-r;return(cy((ZW(VW(n),B(13))^a)&Te)&Te)<<B(64)|cy(o)}function bE(e,t){return e^e>>t}function JW(e,t,r){let i=e.byteLength;pl(i>=4&&i<=8);{let n=e.getUint32(0,!0),o=e.getUint32(i-4,!0),a=((B(n)|B(o)<<B(32))^(t.getBigUint64(16,!0)^t.getBigUint64(24,!0))+r&Te)*(Sa+(B(i)<<B(2)))&fl;return a+=(a&Te)<<B(65),a&=fl,a^=a>>B(67),bE(bE(a&Te,B(35))*LW&Te,B(28))|Di(a>>B(64))<<B(64)}}function XW(e,t,r){let i=e.byteLength;pl(i>=9&&i<=16);{let n=(t.getBigUint64(32,!0)^t.getBigUint64(40,!0))+r&Te,o=(t.getBigUint64(48,!0)^t.getBigUint64(56,!0))-r&Te,a=e.getBigUint64(0,!0),s=e.getBigUint64(i-8,!0),c=(a^s^n)*Sa,u=(c&Te)+(B(i-1)<<B(54));c=c&(fl^Te)|u,s^=o,c+=s+(s&sy)*(_L-B(1))<<B(64),c&=fl,c^=BW(c>>B(64));let l=(c&Te)*cc;return l+=(c>>B(64))*cc<<B(64),l&=fl,Di(l&Te)|Di(l>>B(64))<<B(64)}}function YW(e,t){let r=e.byteLength;return pl(r<=16),r>8?XW(e,ji,t):r>=4?JW(e,ji,t):r>0?qW(e,ji,t):cy(t^ji.getBigUint64(64,!0)^ji.getBigUint64(72,!0))|cy(t^ji.getBigUint64(80,!0)^ji.getBigUint64(88,!0))<<B(64)}function wE(e){return~e+B(1)&Te}function QW(e,t,r){let i=B(e.byteLength)*Sa&Te,n=B(e.byteLength-1)/B(32);for(;n>=0;){let s=Number(n);i=ay(i,Xe(e,16*s),Xe(e,e.byteLength-16*(s+1)),Xe(t,32*s),r),n-=B(1)}let o=i+(i>>B(64))&Te;o=Di(o);let a=(i&Te)*Sa+(i>>B(64))*xE+(B(e.byteLength)-r&Te)*cc;return a&=Te,a=wE(Di(a)),o|a<<B(64)}function eq(e,t,r){let i=B(e.byteLength)*Sa&Te;for(let a=32;a<160;a+=32)i=ay(i,Xe(e,a-32),Xe(e,a-16),Xe(t,a-32),r);i=Di(i&Te)|Di(i>>B(64))<<B(64);for(let a=160;a<=e.byteLength;a+=32)i=ay(i,Xe(e,a-32),Xe(e,a-16),Xe(t,3+a-160),r);i=ay(i,Xe(e,e.byteLength-16),Xe(e,e.byteLength-32),Xe(t,103),wE(r));let n=i+(i>>B(64))&Te;n=Di(n);let o=(i&Te)*Sa+(i>>B(64))*xE+(B(e.byteLength)-r&Te)*cc;return o&=Te,o=wE(Di(o)),n|o<<B(64)}function Mi(e,t=B(0)){let r=new TextEncoder,i=Xe(typeof e=="string"?r.encode(e):e),n=i.byteLength,o=a=>a.toString(16).padStart(32,"0");return n<=16?o(YW(i,t)):n<=128?o(QW(i,ji,t)):n<=240?o(eq(i,ji,t)):o(WW(i,ji))}function uy(e){return/^[0-9a-f]{32}$/.test(e)}function SE(e){let t=Ue.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 za("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=r[yr];i.interruptCounter+=1;let n=i.interruptCounter;if(i.resume.length>0&&n<i.resume.length)return r[nr]?.([[vr,i.resume]]),i.resume[n];if(i.nullResume!==void 0){if(i.resume.length!==n)throw new Error(`Resume length mismatch: ${i.resume.length} !== ${n}`);let a=i.consumeNullResume();return i.resume.push(a),r[nr]?.([[vr,i.resume]]),a}let o=r[Xr]?.split("|");throw new Li([{id:o?Mi(o.join("|")):void 0,value:e}])}var Wt=class extends ue{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((i,n)=>{let o=Pe(t,{callbacks:r?.getChild()});Ue.runWithConfig(o,async()=>{try{i(await this.func(e,o))}catch(a){n(a)}})})}async invoke(e,t){let r,i=ul(t),n=jt(this.config,i);return this.trace?r=await this._callWithConfig(this._tracedInvoke,e,n):r=await Ue.runWithConfig(n,async()=>this.func(e,n)),ue.isRunnable(r)&&this.recurse?await Ue.runWithConfig(n,async()=>r.invoke(e,n)):r}};function*zi(e,t){if(t===void 0)yield*e;else for(let r of e)yield[t,r]}async function Xn(e){let t=[];for await(let r of await e)t.push(r);return t}function ka(e){let t=[];for(let r of e)t.push(r);return t}function uc(e,t){return e?"configurable"in e?{...e,configurable:{...e.configurable,...t}}:{...e,configurable:t}:{configurable:t}}function kE(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(async function*(){}).constructor}function $E(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(function*(){}).constructor}function tq(e){return typeof e=="object"&&e?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var qr={[Symbol.for("LG_PASSTHROUGH")]:!0};function ly(e){return typeof e=="object"&&e?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var IE=Symbol("IS_WRITER"),vt=class TE extends Wt{writes;constructor(t,r){let i=`ChannelWrite<${t.map(n=>Ct(n)?n.node:"channel"in n?n.channel:"...").join(",")}>`;super({writes:t,name:i,tags:r,trace:!1,func:async(n,o)=>this._write(n,o??{})}),this.writes=t}async _write(t,r){let i=this.writes.map(n=>EE(n)&&ly(n.value)?{mapper:n.mapper,value:t}:dy(n)&&ly(n.value)?{channel:n.channel,value:t,skipNone:n.skipNone,mapper:n.mapper}:n);return await TE.doWrite(r,i),t}static async doWrite(t,r){for(let o of r){if(dy(o)){if(o.channel==="__pregel_tasks")throw new Se("Cannot write to the reserved channel TASKS");if(ly(o.value))throw new Se("PASSTHROUGH value must be replaced")}if(EE(o)&&ly(o.value))throw new Se("PASSTHROUGH value must be replaced")}let i=[];for(let o of r)if(Ct(o))i.push([si,o]);else if(EE(o)){let a=await o.mapper.invoke(o.value,t);a!=null&&a.length>0&&i.push(...a)}else if(dy(o)){let a=o.mapper!==void 0?await o.mapper.invoke(o.value,t):o.value;if(tq(a)||o.skipNone&&a===void 0)continue;i.push([o.channel,a])}else throw new Error(`Invalid write entry: ${JSON.stringify(o)}`);let n=t.configurable?.[nr];n(i)}static isWriter(t){return t instanceof TE||IE in t&&!!t[IE]}static registerWriter(t){return Object.defineProperty(t,IE,{value:!0})}};function dy(e){return e!==void 0&&typeof e.channel=="string"}function EE(e){return e!==void 0&&!dy(e)&&ue.isRunnable(e.mapper)}var xL=class SL extends Wt{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor(t,r,i=!1){super({trace:!1,func:(n,o)=>SL.doRead(o,this.channel,this.fresh,this.mapper)}),this.fresh=i,this.mapper=r,this.channel=t,this.name=Array.isArray(t)?`ChannelRead<${t.join(",")}>`:`ChannelRead<${t}>`}static doRead(t,r,i,n){let o=t.configurable?.[_r];if(!o)throw new Error("Runnable is not configured with a read function. Make sure to call in the context of a Pregel process");return n?n(o(r,i)):o(r,i)}},ml=new po,Yn=class Kf extends $n{lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=ml;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;timeout;subgraphs;ends;isErrorHandler;errorHandlerNode;constructor(t){let{channels:r,triggers:i,mapper:n,writers:o,bound:a,kwargs:s,metadata:c,retryPolicy:u,cachePolicy:l,timeout:d,tags:f,subgraphs:p,ends:m,isErrorHandler:h,errorHandlerNode:g}=t,_=[...t.config?.tags?t.config.tags:[],...f??[]];super({...t,bound:t.bound??ml,config:{...t.config?t.config:{},tags:_}}),this.channels=r,this.triggers=i,this.mapper=n,this.writers=o??this.writers,this.bound=a??this.bound,this.kwargs=s??this.kwargs,this.metadata=c??this.metadata,this.tags=_,this.retryPolicy=u,this.cachePolicy=l,this.timeout=d,this.subgraphs=p,this.ends=m,this.isErrorHandler=h,this.errorHandlerNode=g}getWriters(){let t=[...this.writers];for(;t.length>1&&t[t.length-1]instanceof vt&&t[t.length-2]instanceof vt;){let r=t.slice(-2),i=r[0].writes.concat(r[1].writes);t[t.length-2]=new vt(i,r[0].config?.tags),t.pop()}return t}getNode(){let t=this.getWriters();if(!(this.bound===ml&&t.length===0))return this.bound===ml&&t.length===1?t[0]:this.bound===ml?new un({first:t[0],middle:t.slice(1,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):t.length>0?new un({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 Kf({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 vt.isWriter(t)?new Kf({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===ml?new Kf({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:mt(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy,timeout:this.timeout}):new Kf({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 rq(e){return"steps"in e&&Array.isArray(e.steps)}function Wf(e){return"lg_is_pregel"in e&&e.lg_is_pregel===!0}function fy(e){let t=[e];for(let r of t){if(Wf(r))return r;rq(r)&&t.push(...r.steps)}}function lc(e,t,r=!0,i=!1){try{return e[t].get()}catch(n){if(n.name===Ve.unminifiable_name){if(i)return n;if(r)return null}throw n}}function Qn(e,t,r=!0){if(Array.isArray(t)){let i={};for(let n of t)try{i[n]=lc(e,n,!r)}catch(o){if(o.name===Ve.unminifiable_name)continue}return i}else return lc(e,t)}function*kL(e,t){if(e.graph===Dr.PARENT)throw new Se("There is no parent graph.");if(e.goto){let r;Array.isArray(e.goto)?r=e.goto:r=[e.goto];for(let i of r)if(Ct(i))yield[wr,si,i];else if(typeof i=="string")yield[wr,`branch:to:${i}`,"__start__"];else throw new Error(`In Command.send, expected Send or string, got ${typeof i}`)}if(e.resume)if(typeof e.resume=="object"&&Object.keys(e.resume).length&&Object.keys(e.resume).every(uy))for(let[r,i]of Object.entries(e.resume)){let n=t.filter(o=>o[0]===r&&o[1]==="__resume__").map(o=>o[2]).slice(0,1)??[];n.push(i),yield[r,vr,n]}else yield[wr,vr,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,i]of e.update)yield[wr,r,i];else for(let[r,i]of Object.entries(e.update))yield[wr,r,i]}}function*py(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*my(e,t,r){Array.isArray(e)?(t===!0||t.find(([i,n])=>e.includes(i)))&&(yield Qn(r,e)):(t===!0||t.some(([i,n])=>i===e))&&(yield lc(r,e))}function*$L(e,t,r){let i=t.filter(([s,c])=>(s.config===void 0||!s.config.tags?.includes("langsmith:hidden"))&&c[0][0]!=="__error__"&&c[0][0]!=="__interrupt__");if(!i.length)return;let n;i.some(([s])=>s.writes.some(([c,u])=>c==="__return__"))?n=i.flatMap(([s])=>s.writes.filter(([c,u])=>c===Oo).map(([c,u])=>[s.name,u])):Array.isArray(e)?n=i.flatMap(([s])=>{let{writes:c}=s,u={};for(let[l]of c)e.includes(l)&&(u[l]=(u[l]||0)+1);return Object.values(u).some(l=>l>1)?c.filter(([l])=>e.includes(l)).map(([l,d])=>[s.name,{[l]:d}]):[[s.name,Object.fromEntries(c.filter(([l])=>e.includes(l)))]]}):n=i.flatMap(([s])=>s.writes.filter(([c,u])=>c===e).map(([c,u])=>[s.name,u]));let o={};for(let[s,c]of n)s in o||(o[s]=[]),o[s].push(c);let a={};for(let s in o)if(o[s].length===1){let[c]=o[s];a[s]=c}else a[s]=o[s];r&&(a.__metadata__={cached:r}),yield a}function hy(e){let t=typeof e[rt];if(t==="number")return 0;if(t==="string")return"";for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=typeof e[r];if(i==="number")return 0;if(i==="string")return"";break}}function hl(e,t){if(Object.keys(e).length>0){let r=hy(t);return Object.fromEntries(Object.entries(t).filter(([i,n])=>n>(e[i]??r)))}else return t}function IL(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}function Lt(e,t){return e===null?{configurable:t}:e?.configurable===void 0?{...e,configurable:t}:{...e,configurable:{...e.configurable,...t}}}function $a(e,t){let r=t?.parents??{};return Object.keys(r).length>0?Lt(e,{[ir]:{...r,[e.configurable?.checkpoint_ns??""]:e.configurable?.checkpoint_id}}):e}function Ia(...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,i=()=>{let o=t.find(a=>a.aborted)?.reason;r.abort(o),t.forEach(a=>a.removeEventListener("abort",i))};t.forEach(o=>o.addEventListener("abort",i,{once:!0}));let n=t.find(o=>o.aborted);return n&&r.abort(n.reason),{signal:r.signal,dispose:()=>{t.forEach(o=>o.removeEventListener("abort",i))}}}var EL=class{func;name;input;retry;cache;timeout;callbacks;__lg_type="call";constructor({func:e,name:t,input:r,retry:i,cache:n,timeout:o,callbacks:a}){this.func=e,this.name=t,this.input=r,this.retry=i,this.cache=n,this.timeout=o,this.callbacks=a}};function TL(e){return typeof e=="object"&&e!==null&&"__lg_type"in e&&e.__lg_type==="call"}function AL(e,t){return new un({name:e,first:new Wt({func:r=>t(...r),name:e,trace:!1,recurse:!1}),last:new vt([{channel:Oo,value:qr}],[kt])})}function CL(e,t){return new Wt({func:(r,i)=>t(r,i),name:e,trace:!1,recurse:!1})}function OL({func:e,name:t,cache:r,retry:i,timeout:n},...o){let a=Ue.getRunnableConfig();if(typeof a.configurable?.__pregel_call=="function")return a.configurable[ai](e,t,o,{retry:i,cache:r,timeout:n,callbacks:a.callbacks});throw new Error("Async local storage not initialized. Please call initializeAsyncLocalStorageSingleton() before using this function.")}var PL=e=>e!==void 0?e+1:1;function nq(e,t){if(t==null)return!1;for(let r of e)if(t[r])return!0;return!1}function iq(e){let t;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t==null?t=e[r]:t=Ff(t,e[r]));return t}function qf(e,t,r){let i=hy(e.channel_versions),n=e.versions_seen.__interrupt__??{},o=!1;if((e.channel_versions.__start__??i)>(n.__start__??i))o=!0;else for(let s in e.channel_versions)if(Object.prototype.hasOwnProperty.call(e.channel_versions,s)&&e.channel_versions[s]>(n[s]??i)){o=!0;break}let a=r.some(s=>t==="*"?!s.config?.tags?.includes(kt):t.includes(s.name));return o&&a}function gl(e,t,r,i,n=!1){let o=new Set;if(Array.isArray(i))o=new Set(i.filter(s=>r.writes.some(([c,u])=>c===s)));else{for(let[s]of r.writes)if(s===i){o=new Set([s]);break}o=o||new Set}let a;if(n&&o.size>0){let s=Object.fromEntries(Object.entries(t).filter(([d,f])=>o.has(d))),c=new Set;for(let d in s){if(!Object.prototype.hasOwnProperty.call(s,d))continue;let f=s[d];An(f)&&f.isAvailable()&&c.add(d)}let u=qn(e,s,-1,{channelsToSnapshot:c}),l=q_(s,u);Rr(Wn(u),l,[r],void 0,void 0),a=Qn({...t,...l},i)}else a=Qn(t,i);return a}function gy(e,t,r){for(let[i,n]of r)if(["__pregel_push","__pregel_tasks"].includes(i)&&n!=null){if(!Ct(n))throw new Se(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(n)}`);if(!(n.node in t))throw new Se(`Invalid node name "${n.node}" in Send packet`)}e(r)}var oq=new Set([xl,br,vr,qe,Oo,To,vl]),aq=new Set(rT);function Rr(e,t,r,i,n){let o=new Map;for(let m of r)o.set(m,m.path?.slice(0,3)||[]);r.sort((m,h)=>{let g=o.get(m),_=o.get(h);for(let v=0;v<Math.min(g.length,_.length);v+=1){if(g[v]<_[v])return-1;if(g[v]>_[v])return 1}return g.length-_.length});let a=sl(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]),aq.has(h)||c.add(h)}let u=iq(e.channel_versions),l=!1;for(let m of c)m in a&&a[m].consume()&&i!==void 0&&(e.channel_versions[m]=i(u),l=!0);let d={},f={};for(let m of r){let h=m.id??"";for(let[g,_]of m.writes)oq.has(g)||g in a&&(d[g]??=[],d[g].push(_),f[g]??=[],f[g].push(h))}for(let[m,h]of Object.entries(d)){if(h.length<2||a[m]?.lc_graph_name!=="DeltaChannel")continue;let g=f[m],_=h.map((v,x)=>({val:v,taskId:g[x]}));_.sort((v,x)=>v.taskId<x.taskId?-1:v.taskId>x.taskId?1:0),d[m]=_.map(v=>v.val)}u!=null&&i!=null&&(u=l?i(u):u);let p=new Set;for(let[m,h]of Object.entries(d))if(m in a){let g=a[m],_;try{_=g.update(h)}catch(v){if(v.name===Se.unminifiable_name){let x=new Se(`Invalid update for channel "${m}" with values ${JSON.stringify(h)}: ${v.message}`);throw x.lc_error_code=v.lc_error_code,x}else throw v}_&&i!==void 0&&(e.channel_versions[m]=i(u),g.isAvailable()&&p.add(m))}if(s)for(let m in a){if(!Object.prototype.hasOwnProperty.call(a,m))continue;let h=a[m];h.isAvailable()&&!p.has(m)&&h.update([])&&i!==void 0&&(e.channel_versions[m]=i(u),h.isAvailable()&&p.add(m))}if(s&&!nq(p,n))for(let m in a){if(!Object.prototype.hasOwnProperty.call(a,m))continue;let h=a[m];h.finish()&&i!==void 0&&(e.channel_versions[m]=i(u),h.isAvailable()&&p.add(m))}return p}function*sq(e,t,r){if(r.updatedChannels!=null&&r.triggerToNodes!=null){let i=new Set;for(let n of r.updatedChannels){let o=r.triggerToNodes[n];for(let a of o??[])i.add(a)}yield*[...i].sort();return}if(!(()=>{for(let i in e.channel_versions)if(e.channel_versions[i]!==null)return!1;return!0})())for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(yield i)}function cq(e){let t,r=new Map,i=new Set;if(e)for(let[n,o,a]of e){if(n==="00000000-0000-0000-0000-000000000000"&&o==="__resume__"&&t===void 0&&(t=a),o==="__resume__"&&n!=="00000000-0000-0000-0000-000000000000"){let s=r.get(n);s||(s=[],r.set(n,s)),s.push(a)}o!=="__error__"&&i.add(n)}return{nullResume:t,resumeByTaskId:r,successfulWriteTaskIds:i}}function Ea(e,t,r,i,n,o,a){let s={},c=a.pendingWritesIndex?a:{...a,pendingWritesIndex:cq(t)},u=i[si];if(u?.isAvailable()){let l=u.get().length;for(let d=0;d<l;d+=1){let f=yy([br,d],e,t,r,i,n,o,c);f!==void 0&&(s[f.id]=f)}}for(let l of sq(e,r,c)){let d=yy([ip,l],e,t,r,i,n,o,c);d!==void 0&&(s[d.id]=d)}return s}function yy(e,t,r,i,n,o,a,s){let{step:c,checkpointer:u,manager:l}=s,d=o.configurable??{},f=d.checkpoint_ns??"";if(e[0]==="__pregel_push"&&TL(e[e.length-1])){let p=e[e.length-1],m=AL(p.name,p.func),h=[br],g=f===""?p.name:`${f}|${p.name}`,_=ci(JSON.stringify([g,c.toString(),p.name,br,e[1],e[2]]),t.id),v=`${g}:${_}`,x=[...e.slice(0,3),!0],S={langgraph_step:c,langgraph_node:p.name,langgraph_triggers:h,langgraph_path:x,langgraph_checkpoint_ns:v,checkpoint_ns:v};if(a){let k=[],T={checkpointId:t.id,checkpointNs:v,taskId:_,threadId:d.thread_id,runId:o.runId!=null?String(o.runId):void 0,nodeAttempt:1};return{name:p.name,input:p.input,proc:m,writes:k,config:{...Pe(jt(o,{metadata:S,store:s.store??o.store}),{runName:p.name,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[mc]:_,[nr]:A=>gy(b=>k.push(...b),i,A),[_r]:(A,b=!1)=>gl(t,n,{name:p.name,writes:k,triggers:h,path:x},A,b),[fn]:u??d.__pregel_checkpointer,[ir]:{...d[ir],[f]:t.id},[yr]:_y({pendingWrites:r??[],taskId:_,currentTaskInput:p.input,resumeMap:o.configurable?.[ja],namespaceHash:Mi(v),pendingWritesIndex:s.pendingWritesIndex}),[Ao]:t.channel_values[Po],checkpoint_id:void 0,checkpoint_ns:v}}),executionInfo:T},triggers:h,retry_policy:p.retry,cache_key:p.cache?{key:Mi((p.cache.keyFunc??JSON.stringify)([p.input])),ns:[rp,p.name??"__dynamic__"],ttl:p.cache.ttl}:void 0,id:_,path:x,writers:[],timeout:p.timeout}}else return{id:_,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(!n.__pregel_tasks?.isAvailable())return;let m=n[si].get();if(p<0||p>=m.length)return;let h=op(m[p])&&!Ct(m[p])?new Na(m[p].node,m[p].args,m[p].timeout!==void 0?{timeout:m[p].timeout}:void 0):m[p];if(!op(h)){console.warn(`Ignoring invalid packet ${JSON.stringify(h)} in pending sends.`);return}if(!(h.node in i)){console.warn(`Ignoring unknown node name ${h.node} in pending sends.`);return}let g=[br],_=f===""?h.node:`${f}|${h.node}`,v=ci(JSON.stringify([_,c.toString(),h.node,br,p.toString()]),t.id),x=`${_}:${v}`,S={langgraph_step:c,langgraph_node:h.node,langgraph_triggers:g,langgraph_path:e.slice(0,3),langgraph_checkpoint_ns:x,checkpoint_ns:x};if(a){let k=i[h.node],T=k.getNode();if(T!==void 0){k.metadata!==void 0&&(S={...S,...k.metadata});let A=[],b={checkpointId:t.id,checkpointNs:x,taskId:v,threadId:d.thread_id,runId:o.runId!=null?String(o.runId):void 0,nodeAttempt:1};return{name:h.node,input:h.args,proc:T,subgraphs:k.subgraphs,writes:A,config:{...Pe(jt(o,{metadata:S,tags:k.tags,store:s.store??o.store}),{runName:h.node,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[mc]:v,[nr]:z=>gy(j=>A.push(...j),i,z),[_r]:(z,j=!1)=>gl(t,n,{name:h.node,writes:A,triggers:g,path:e},z,j),[fn]:u??d.__pregel_checkpointer,[ir]:{...d[ir],[f]:t.id},[yr]:_y({pendingWrites:r??[],taskId:v,currentTaskInput:h.args,resumeMap:o.configurable?.[ja],namespaceHash:Mi(x),pendingWritesIndex:s.pendingWritesIndex}),[Ao]:t.channel_values[Po],checkpoint_id:void 0,checkpoint_ns:x}}),executionInfo:b},triggers:g,retry_policy:k.retryPolicy,cache_key:k.cachePolicy?{key:Mi((k.cachePolicy.keyFunc??JSON.stringify)([h.args])),ns:[rp,k.name??"__dynamic__",h.node],ttl:k.cachePolicy.ttl}:void 0,id:v,path:e,writers:k.getWriters(),timeout:h.timeout??k.timeout}}}else return{id:v,name:h.node,interrupts:[],path:e}}else if(e[0]==="__pregel_pull"){let p=e[1].toString(),m=i[p];if(m===void 0)return;if(r?.length){let v=f===""?p:`${f}|${p}`,x=ci(JSON.stringify([v,c.toString(),p,ip,p]),t.id);if(s.pendingWritesIndex?s.pendingWritesIndex.successfulWriteTaskIds.has(x):r.some(S=>S[0]===x&&S[1]!=="__error__"))return}let h=hy(t.channel_versions);if(h===void 0)return;let g=t.versions_seen[p]??{},_=m.triggers.find(v=>n[v].isAvailable()?(t.channel_versions[v]??h)>(g[v]??h):!1);if(_!==void 0){let v=uq(m,n,a);if(v===void 0)return;let x=f===""?p:`${f}|${p}`,S=ci(JSON.stringify([x,c.toString(),p,ip,[_]]),t.id),k=`${x}:${S}`,T={langgraph_step:c,langgraph_node:p,langgraph_triggers:[_],langgraph_path:e,langgraph_checkpoint_ns:k,checkpoint_ns:k};if(a){let A=m.getNode();if(A!==void 0){m.metadata!==void 0&&(T={...T,...m.metadata});let b=[],z={checkpointId:t.id,checkpointNs:k,taskId:S,threadId:d.thread_id,runId:o.runId!=null?String(o.runId):void 0,nodeAttempt:1};return{name:p,input:v,proc:A,subgraphs:m.subgraphs,writes:b,config:{...Pe(jt(o,{metadata:T,tags:m.tags,store:s.store??o.store}),{runName:p,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[mc]:S,[nr]:j=>gy(H=>{b.push(...H)},i,j),[_r]:(j,H=!1)=>gl(t,n,{name:p,writes:b,triggers:[_],path:e},j,H),[fn]:u??d.__pregel_checkpointer,[ir]:{...d[ir],[f]:t.id},[yr]:_y({pendingWrites:r??[],taskId:S,currentTaskInput:v,resumeMap:o.configurable?.[ja],namespaceHash:Mi(k),pendingWritesIndex:s.pendingWritesIndex}),[Ao]:t.channel_values[Po],checkpoint_id:void 0,checkpoint_ns:k}}),executionInfo:z},triggers:[_],retry_policy:m.retryPolicy,cache_key:m.cachePolicy?{key:Mi((m.cachePolicy.keyFunc??JSON.stringify)([v])),ns:[rp,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 NL(e,t,r,i,n,o,a,s,c){let{step:u,checkpointer:l,manager:d}=c,f=o[t];if(f===void 0)return;let p=f.getNode();if(p===void 0)return;let m=s.configurable??{},h=m.checkpoint_ns??"",g=[br],_=h===""?t:`${h}|${t}`,v=ci(JSON.stringify([_,u.toString(),t,br,"node_error_handler",e.id]),i.id),x=`${_}:${v}`,S=[br,String(e.name),t,!1],k={langgraph_step:u,langgraph_node:t,langgraph_triggers:g,langgraph_path:S,langgraph_checkpoint_ns:x,checkpoint_ns:x};f.metadata!==void 0&&(k={...k,...f.metadata});let T=[],A={checkpointId:i.id,checkpointNs:x,taskId:v,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:T,config:{...Pe(jt(s,{metadata:k,tags:f.tags,store:c.store??s.store}),{runName:t,callbacks:d?.getChild(`graph:step:${u}`),configurable:{[mc]:v,[nr]:b=>gy(z=>T.push(...z),o,b),[_r]:(b,z=!1)=>gl(i,a,{name:t,writes:T,triggers:g,path:S},b,z),[fn]:l??m.__pregel_checkpointer,[ir]:{...m[ir],[h]:i.id},[yr]:_y({pendingWrites:n??[],taskId:v,currentTaskInput:e.input,resumeMap:s.configurable?.[ja],namespaceHash:Mi(x)}),[Ao]:i.channel_values[Po],[wl]:new lp(String(e.name),r),checkpoint_id:void 0,checkpoint_ns:x}}),executionInfo:A},triggers:g,retry_policy:f.retryPolicy,cache_key:void 0,id:v,path:S,writers:f.getWriters()}}function uq(e,t,r){let i;if(typeof e.channels=="object"&&!Array.isArray(e.channels)){i={};for(let[n,o]of Object.entries(e.channels))if(e.triggers.includes(o))try{i[n]=lc(t,o,!1)}catch(a){if(a.name===Ve.unminifiable_name)return;throw a}else if(o in t)try{i[n]=lc(t,o,!1)}catch(a){if(a.name===Ve.unminifiable_name)continue;throw a}}else if(Array.isArray(e.channels)){let n=!1;for(let o of e.channels)try{i=lc(t,o,!1),n=!0;break}catch(a){if(a.name===Ve.unminifiable_name)continue;throw a}if(!n)return}else throw new Error(`Invalid channels type, expected list or dict, got ${e.channels}`);return r&&e.mapper!==void 0&&(i=e.mapper(i)),i}function RL(e,t){if(typeof e.args!="object"||e.args===null)return e;let r={};for(let[i,n]of Object.entries(e.args)){let o=t[i];(!o||o.lc_graph_name!=="UntrackedValue")&&(r[i]=n)}return new Na(e.node,r)}function _y({pendingWrites:e,taskId:t,currentTaskInput:r,resumeMap:i,namespaceHash:n,pendingWritesIndex:o}){let a=o?o.nullResume:e.find(([c,u])=>c==="00000000-0000-0000-0000-000000000000"&&u==="__resume__")?.[2],s={callCounter:0,interruptCounter:-1,resume:(()=>{let c=o?(o.resumeByTaskId.get(t)??[]).flat():e.filter(([u,l])=>u===t&&l==="__resume__").flatMap(([u,l,d])=>d);if(i!=null&&n in i){let u=i[n];c.push(u)}return c})(),nullResume:a,subgraphCounter:0,currentTaskInput:r,consumeNullResume:()=>{if(s.nullResume)return delete s.nullResume,e.splice(e.findIndex(([c,u])=>c==="00000000-0000-0000-0000-000000000000"&&u==="__resume__"),1),a}};return s}var Jf={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},Xf=(e,t)=>`${e.start}${t}${e.end}`;function lq(e){if(e==null)return;let t={};if(e.metadata!=null)for(let[i,n]of Object.entries(e.metadata))rE.has(i)||(t[i]=n);let r=iL(e.tags);return r!=null&&(t.tags=r),Object.keys(t).length>0?t:void 0}function*vy(e){for(let{id:t,name:r,input:i,config:n,triggers:o,writes:a}of e){if(n?.tags?.includes("langsmith:hidden"))continue;let s={id:t,name:r,input:i,triggers:o,interrupts:a.filter(([u,l])=>u===t&&l==="__interrupt__").map(([,u])=>u)},c=lq(n);c!=null&&(s.metadata=c),yield s}}function dq(e){return typeof e!="object"||e===null?!1:"$writes"in e&&Array.isArray(e.$writes)}function jL(e){let t={};for(let[r,i]of e){let n=String(r);if(n in t){let o=dq(t[n])?t[n].$writes:[t[n]];o.push(i),t[n]={$writes:o}}else t[n]=i}return t}function*DL(e,t){for(let[{id:r,name:i,config:n},o]of e)n?.tags?.includes("langsmith:hidden")||(yield{id:r,name:i,result:jL(o.filter(([a])=>Array.isArray(t)?t.includes(a):a===t)),interrupts:o.filter(a=>a[0]===qe).map(a=>a[1])})}function*ML(e,t,r,i,n,o,a,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 u=e.configurable?.checkpoint_ns,l={};for(let d of n){if(!(d.subgraphs?.length?d.subgraphs:[d.proc]).find(fy))continue;let f=`${d.name}:${d.id}`;u&&(f=`${u}|${f}`),l[d.id]={configurable:{thread_id:e.configurable?.thread_id,checkpoint_ns:f}}}yield{config:c(e),values:Qn(t,r),metadata:i,next:n.map(d=>d.name),tasks:AE(n,o,l,s),parentConfig:a?c(a):void 0}}function AE(e,t,r,i){return e.map(n=>{let o=t.find(([u,l])=>u===n.id&&l==="__error__")?.[2],a=t.filter(([u,l])=>u===n.id&&l==="__interrupt__").map(([,,u])=>u),s=(()=>{if(o||a.length||!t.length)return;let u=t.findIndex(([l,d])=>l===n.id&&d==="__return__");if(u>=0)return t[u][2];if(typeof i=="string")return t.find(([l,d])=>l===n.id&&d===i)?.[2];if(Array.isArray(i)){let l=t.filter(([d,f])=>d===n.id&&i.includes(f)).map(([,d,f])=>[d,f]);return l.length?jL(l):void 0}})();if(o)return{id:n.id,name:n.name,path:n.path,error:o,interrupts:a,result:s};let c=r?.[n.id];return{id:n.id,name:n.name,path:n.path,interrupts:a,...c!==void 0?{state:c}:{},result:s}})}function zL(e,t,r){console.log([`${Xf(Jf.blue,`[${e}:checkpoint]`)}`,`\x1B[1m State at the end of step ${e}:\x1B[0m
441
+ `,JSON.stringify(Qn(t,r),null,2)].join(""))}function Yf(e,t){let r=t.length;console.log([`${Xf(Jf.blue,`[${e}:tasks]`)}`,`\x1B[1m Starting step ${e} with ${r} task${r===1?"":"s"}:\x1B[0m
442
+ `,t.map(i=>`- ${Xf(Jf.green,String(i.name))} -> ${JSON.stringify(i.input,null,2)}`).join(`
443
+ `)].join(""))}function LL(e,t,r){let i={};for(let[n,o]of t)r.includes(n)&&(i[n]||(i[n]=[]),i[n].push(o));console.log([`${Xf(Jf.blue,`[${e}:writes]`)}`,`\x1B[1m Finished step ${e} with writes to ${Object.keys(i).length} channel${Object.keys(i).length!==1?"s":""}:\x1B[0m
444
+ `,Object.entries(i).map(([n,o])=>`- ${Xf(Jf.yellow,n)} -> ${o.map(a=>JSON.stringify(a)).join(", ")}`).join(`
445
+ `)].join(""))}var by=class extends $t{_abortController;_innerReader;constructor(e,t){let r=e.getReader(),i=t??new AbortController;super({start(n){return o();function o(){return r.read().then(({done:a,value:s})=>{if(a){n.close();return}return n.enqueue(s),o()})}}}),this._abortController=i,this._innerReader=r}async cancel(e){this._abortController.abort(e),this._innerReader.releaseLock()}get signal(){return this._abortController.signal}},OE=class extends $t{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(e){let t,r=new Promise(i=>{t=i});super({start:i=>{t(i)}}),r.then(i=>{this.controller=i}),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}}},BL=class extends Sr{name="StreamToolsHandler";awaitHandlers=!0;streamFn;runs={};constructor(e){super(),this.streamFn=e}handleToolStart(e,t,r,i,n,o,a,s){if(!o||n&&n.includes("langsmith:hidden"))return;let c=o.langgraph_checkpoint_ns?.split("|")??[],u={ns:c,toolCallId:s,toolName:a??"unknown",input:t};this.runs[r]=u,this.streamFn([c,"tools",{event:"on_tool_start",toolCallId:u.toolCallId,name:u.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 fq(e){return JSON.stringify(e,function(t,r){let i=this[t];if(i!=null&&typeof i=="object"&&"toDict"in i&&typeof i.toDict=="function"){let{type:n,data:o}=i.toDict();return{...o,type:n}}return r})}function pq(e){return e instanceof Error?{error:e.name,message:e.message}:{error:"Error",message:JSON.stringify(e)}}function PE(e){return typeof e!="object"||e==null?!1:"configurable"in e&&typeof e.configurable=="object"&&e.configurable!=null}function CE(e){return!PE(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 UL(e){if(PE(e)){let t=Object.fromEntries(Object.entries(e.configurable).filter(([i])=>!i.startsWith("__"))),r={...e,configurable:t};return delete r.callbacks,r}return e}function FL(e){let t={...e,checkpoint:CE(e.config),parent_checkpoint:CE(e.parentConfig),config:UL(e.config),parent_config:UL(e.parentConfig),tasks:e.tasks.map(r=>{if(PE(r.state)){let i=CE(r.state);if(i!=null){let n={...r,checkpoint:i};return delete n.state,n}}return r})};return delete t.parentConfig,t}function VL(e){let t=new TextEncoder;return new ReadableStream({async start(r){let i=n=>{r.enqueue(t.encode(`event: ${n.event}
446
+ data: ${fq(n.data)}
447
+
448
+ `))};try{for await(let n of e){let[o,a,s]=n,c=s;if(a==="debug"){let u=s;u.type==="checkpoint"&&(c={...u,payload:FL(u.payload)})}a==="checkpoints"&&(c=FL(s)),i({event:o?.length?`${a}|${o.join("|")}`:a,data:c})}}catch(n){i({event:"error",data:pq(n)})}r.close()}})}function HL(...e){return new OE({passthroughFn:t=>{let r=t[1]==="checkpoints"&&ll(t[2]);for(let i of e)(i.modes.has(t[1])||r)&&i.push(t)},modes:new Set(e.flatMap(t=>Array.from(t.modes)))})}var ZL=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 i=[];for await(let n of t.list(r,{before:{configurable:{checkpoint_id:this.checkpointId}},limit:1}))i.push(n);return i.length>0?i[0]:void 0}return await t.getTuple(r)??void 0}};var wy=Symbol.for("INPUT_DONE"),NE=Symbol.for("INPUT_RESUMING"),mq=25;function GL(e){if(!(e==null||typeof e!="object")){if(ze.isInstance(e)){let t=e;t.id==null&&(t.id=Do(),t.lc_kwargs!=null&&(t.lc_kwargs.id=t.id));return}if(Array.isArray(e)){for(let t of e)GL(t);return}}}function KL(e){return e===void 0||e===""?[]:e.split("|")}function hq(e){if(!e)return[];let t="";for(let r of Object.keys(e))r!==""&&r.length>t.length&&(t=r);return KL(t)}var gq=class extends W_{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}},WL=class qL{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(i=>(this.checkpointerPromises.delete(r),i),i=>{throw i});this.checkpointerPromises.add(r)}async _awaitCheckpointerPromises(){await Promise.all([...this.checkpointerPromises])}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,i=this.input===null||this.input===void 0,n=Ft(this.input)&&this.input.resume!=null,o=this.input===NE,a=!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||i||n||o||a)}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=PL,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 gq(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:i}=t;i!==void 0&&r.configurable?.__pregel_stream!==void 0&&(i=HL(i,r.configurable[bl]));let n=r.configurable?!("checkpoint_id"in r.configurable):!0,o=r.configurable?.[yr];r.configurable&&o&&(o.subgraphCounter>0&&(r=Lt(r,{[Xr]:[r.configurable[Xr],o.subgraphCounter.toString()].join("|")})),o.subgraphCounter+=1);let a=r.configurable?.checkpoint_id,s=_r in(r.configurable??{});!s&&r.configurable?.checkpoint_ns!==void 0&&r.configurable?.checkpoint_ns!==""&&(r=Lt(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=Lt(r,{checkpoint_id:r.configurable[ir][r.configurable?.checkpoint_ns]}));let u=KL(r.configurable?.checkpoint_ns),l;t.checkpointer?c.configurable?.checkpoint_id?l=await t.checkpointer.getTuple(c):r.configurable?.__pregel_replay_state?(l=await r.configurable[np].getCheckpoint(r.configurable?.checkpoint_ns??"",t.checkpointer,c),r.configurable&&delete r.configurable[Ra]):l=await t.checkpointer.getTuple(c):l=void 0;let d=l!==void 0;l||(l={config:r,checkpoint:sc(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]}),c={...r,...l.config,configurable:{checkpoint_ns:"",...r.configurable,...l.config.configurable}};let f=l.parentConfig,p=Wn(l.checkpoint),m={...l.metadata},h=l.pendingWrites??[],g=r.configurable?.checkpoint_ns,_=r.configurable?.[ir];typeof g=="string"&&g!==""&&typeof _=="object"&&_!==null&&g in _&&h.length>0&&(h=h.filter(([,j])=>j!==vr));let v=!1,x=c.configurable?.thread_id,S=c.configurable?.checkpoint_ns??"";t.checkpointer&&a&&typeof x=="string"&&(v=(await t.checkpointer.getTuple({configurable:{thread_id:x,checkpoint_ns:S}}))?.config.configurable?.checkpoint_id===a&&m.source!=="update"&&m.source!=="fork");let k=await cl(t.channelSpecs,p,{saver:t.checkpointer,config:c}),T=(m.step??0)+1,A=T+(r.recursionLimit??mq)+1,b={...p.channel_versions},z=t.store?new K_(t.store):void 0;return z&&await z.start(),new qL({input:t.input,config:r,checkpointer:t.checkpointer,checkpoint:p,checkpointMetadata:m,checkpointConfig:c,prevCheckpointConfig:f,checkpointNamespace:u,channels:k,isNested:s,resumeAtHead:v,manager:t.manager,skipDoneTasks:n,step:T,stop:A,checkpointPreviousVersions:b,checkpointPendingWrites:h,outputKeys:t.outputKeys??[],streamKeys:t.streamKeys??[],nodes:t.nodes,stream:i,store:z,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 i=r;if(i.length===0)return;i.every(([c])=>c in Bf)&&(i=Array.from(new Map(i.map(c=>[c[0],c])).values()));let n=!1;for(let c in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,c)&&this.channels[c].lc_graph_name==="UntrackedValue"){n=!0;break}let o=i;n&&(o=i.filter(([c])=>{let u=this.channels[c];return!u||u.lc_graph_name!=="UntrackedValue"}).map(([c,u])=>c==="__pregel_tasks"&&Ct(u)?[c,RL(u,this.channels)]:[c,u])),this.checkpointPendingWrites=this.checkpointPendingWrites.filter(c=>c[0]!==t);for(let[c,u]of o)this.checkpointPendingWrites.push([t,c,u]);for(let[c,u]of o){let l=this.channels[c];l!=null&&An(l)&&GL(u)}let a=Lt(this.checkpointConfig,{[Xr]:this.config.configurable?.checkpoint_ns??"",[Co]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null&&this._trackCheckpointerPromise(this.checkpointer.putWrites(a,o,t)),this.tasks&&this._outputWrites(t,i),!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,i=!1){let n=this.tasks[t];if(n!==void 0){if(n.config!==void 0&&(n.config.tags??[]).includes("langsmith:hidden"))return;if(r.length>0)if(r[0][0]==="__interrupt__"){if(n.path?.[0]==="__pregel_push"&&n.path?.[n.path.length-1]===!0)return;let o=r.filter(a=>a[0]===qe).flatMap(a=>a[1]);this._emit([["updates",{[qe]:o}],["values",{[qe]:o}]])}else r[0][0]!=="__error__"&&this._emit(ka(zi($L(this.outputKeys,[[n,r]],i),"updates")));i||this._emit(ka(zi(DL([[n,r]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let t=[],r=([a,s])=>`ns:${a.join(",")}|key:${s}`,i=[],n={};for(let a of Object.values(this.tasks))a.cache_key!=null&&!a.writes.length&&(i.push([a.cache_key.ns,a.cache_key.key]),n[r([a.cache_key.ns,a.cache_key.key])]=a);if(i.length===0)return[];let o=await this.cache.get(i);for(let{key:a,value:s}of o){let c=n[r(a)];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(![wy,NE].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(n=>n.writes.length>0)){let n=Object.values(this.tasks),o=n.flatMap(s=>s.writes);this.updatedChannels=Rr(this.checkpoint,this.channels,n,this.checkpointerGetNextVersion,this.triggerToNodes);for(let[s,c]of o){let u=this.channels[s];u!=null&&An(u)&&Da(c)&&this._deltaChannelsWithOverwrite.add(s)}let a=await Xn(zi(my(this.outputKeys,o,this.channels),"values"));if(this._exitDeltaWrites!==void 0)for(let[s,c,u]of this.checkpointPendingWrites){let l=this.channels[c];l!=null&&An(l)&&this._exitDeltaWrites.push([this.step,s,c,u])}if(this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),this.durability==="sync"&&await this._awaitCheckpointerPromises(),this._emitValuesWithCheckpointMeta(a),qf(this.checkpoint,this.interruptAfter,n))throw this.status="interrupt_after",new Li;this.config.configurable?.__pregel_resuming!==void 0&&delete this.config.configurable?.[Ra]}else return!1}if(this.step>this.stop)return this.status="out_of_steps",!1;this.tasks=Ea(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 i=Object.values(this.tasks);if(this.checkpointer&&(this.stream.modes.has("checkpoints")||this.stream.modes.has("debug"))&&this._emit(await Xn(zi(ML(this.checkpointConfig,this.channels,this.streamKeys,this.checkpointMetadata,i,this.checkpointPendingWrites,this.prevCheckpointConfig,this.outputKeys),"checkpoints"))),i.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[n,o,a]of this.checkpointPendingWrites){if(o==="__error__"||o==="__error_source_node__"||o==="__interrupt__"||o==="__resume__")continue;let s=i.find(c=>c.id===n);s&&s.writes.push([o,a])}this._resumeErrorHandlersIfApplicable(),i=Object.values(this.tasks);for(let n of i)n.writes.length>0&&this._outputWrites(n.id,n.writes,!0)}if(i.every(n=>n.writes.length>0))return this.tick({inputKeys:r});if(qf(this.checkpoint,this.interruptBefore,i))throw this.status="interrupt_before",new Li;if(this.stream.modes.has("tasks")||this.stream.modes.has("debug")){let n=await Xn(zi(vy(i),"tasks"));this._emit(n)}return!0}async finishAndHandleError(t){this.durability==="exit"&&(!this.isNested||typeof t<"u"||this.checkpointNamespace.every(i=>!i.includes(":")))&&(await this._putExitDeltaWrites(),this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites());let r=this._suppressInterrupt(t);return(r||t===void 0)&&(this.output=Qn(this.channels,this.outputKeys)),r&&(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some(i=>i.writes.length>0)&&(this.updatedChannels=Rr(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emitValuesWithCheckpointMeta(ka(zi(my(this.outputKeys,Object.values(this.tasks).flatMap(i=>i.writes),this.channels),"values")))),Ui(t)&&!t.interrupts.length&&this._emit([["updates",{[qe]:[]}],["values",{[qe]:[]}]],this.#e())),r}async acceptPush(t,r,i){if(this.interruptAfter?.length>0&&qf(this.checkpoint,this.interruptAfter,[t])){this.toInterrupt.push(t);return}let n=yy([br,t.path??[],r,t.id,i],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(!n)return;if(this.interruptBefore?.length>0&&qf(this.checkpoint,this.interruptBefore,[n])){this.toInterrupt.push(n);return}(this.stream.modes.has("tasks")||this.stream.modes.has("debug"))&&this._emit(ka(zi(vy([n]),"tasks"))),this.debug&&Yf(this.step,[n]),this.tasks[n.id]=n,this.skipDoneTasks&&this._matchWrites({[n.id]:n});let o=await this._matchCachedWrites();for(let{task:a}of o)this._outputWrites(a.id,a.writes,!0);return n}getErrorHandlerNode(t){return this.nodes[t]?.errorHandlerNode}isErrorHandlerNode(t){return this.nodes[t]?.isErrorHandler===!0}scheduleErrorHandler(t,r){let i=this.getErrorHandlerNode(String(t.name));if(!i)return;let n=NL(t,i,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(n!==void 0)return this.tasks[n.id]=n,this._emit(ka(zi(vy([n]),"tasks"))),this.debug&&Yf(this.step,[n]),n}_resumeErrorHandlersIfApplicable(){let t=new Map;for(let[r,i]of this.checkpointPendingWrites){if(i!=="__error_source_node__")continue;let n=this.checkpointPendingWrites.find(([s,c])=>s===r&&c==="__error__");if(n===void 0)continue;let o=n[2],a=new Error(o?.message??String(o));o?.name&&(a.name=o.name),t.set(r,a)}for(let[r,i]of t){let n=this.tasks[r];n!==void 0&&this.getErrorHandlerNode(String(n.name))&&(n.writes.length===0&&n.writes.push([To,{message:i.message,name:i.name}]),this.scheduleErrorHandler(n,i))}}_suppressInterrupt(t){return Ui(t)&&!this.isNested}async _first(t){let{configurable:r}=this.config,i=r?.[yr];if(i&&i.nullResume!==void 0&&this.putWrites(wr,[[vr,i.nullResume]]),Ft(this.input)){let u=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume=="object"&&Object.keys(this.input.resume).every(uy)&&(this.config.configurable??={},this.config.configurable[ja]=this.input.resume),u&&this.checkpointer==null)throw new Error("Cannot use Command(resume=...) without checkpointer");let l={};for(let[d,f,p]of kL(this.input,this.checkpointPendingWrites))l[d]??=[],l[d].push([f,p]);if(Object.keys(l).length===0)throw new pp("Received empty Command input");for(let[d,f]of Object.entries(l))this.putWrites(d,f)}let n=(this.checkpointPendingWrites??[]).filter(u=>u[0]===wr).map(u=>u.slice(1));n.length>0&&Rr(this.checkpoint,this.channels,[{name:oi,writes:n,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let o=Ft(this.input),a=o&&n.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||!(o&&this.input.resume!=null||r?.__pregel_resuming===!0||this.resumeAtHead));s&&(this.checkpointPendingWrites=this.checkpointPendingWrites.filter(u=>u[1]!==vr));let c=this.isResuming;if(c||a){let u={...this.checkpoint.versions_seen[qe]};for(let d in this.channels)Object.prototype.hasOwnProperty.call(this.channels,d)&&this.checkpoint.channel_versions[d]!==void 0&&(u[d]=this.checkpoint.channel_versions[d]);this.checkpoint.versions_seen[qe]=u,s&&this.checkpointMetadata.source!=="update"&&this.checkpointMetadata.source!=="fork"&&(this.checkpointPendingWrites=this.checkpointPendingWrites.filter(d=>d[1]!==qe),await this._putCheckpoint({source:"fork"}));let l=await Xn(zi(my(this.outputKeys,!0,this.channels),"values"));c?this.input=NE:a&&(await this._putCheckpoint({source:"input"}),this.input=wy),this._emitValuesWithCheckpointMeta(l)}else{let u=await Xn(py(t,this.input));if(u.length>0){let l=Ea(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=Rr(this.checkpoint,this.channels,Object.values(l).concat([{name:oi,writes:u,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes);let d=u.filter(([f])=>{let p=this.channels[f];return p!=null&&An(p)});for(let[f,p]of d)Da(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,wr,f,p]);else this.checkpointer!=null&&this.putWrites(wr,d);await this._putCheckpoint({source:"input"}),this.input=wy}else if("__pregel_resuming"in(this.config.configurable??{}))this.input=wy;else throw new pp(`Received no input writes for ${JSON.stringify(t,null,2)}`)}if(!this.isNested){let u;if(s){let l=this.checkpoint.id;(this.checkpointMetadata.source==="update"||this.checkpointMetadata.source==="fork")&&this.prevCheckpointConfig&&(l=this.prevCheckpointConfig.configurable?.checkpoint_id??l),u=new ZL(l)}this.config=Lt(this.config,{[Ra]:this.isResuming,[np]:u})}}#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=hq(this.config.configurable?.[ir]);return r.length>0?r:t}_emit(t,r=this.checkpointNamespace){for(let[i,n]of t)if(this.stream.modes.has(i)&&this.stream.push([r,i,n]),(i==="checkpoints"||i==="tasks")&&this.stream.modes.has("debug")){let o=i==="checkpoints"?this.step-1:this.step,a=new Date().toISOString(),s=i==="checkpoints"?"checkpoint":typeof n=="object"&&n!=null&&"result"in n?"task_result":"task";this.stream.push([r,"debug",{step:o,type:s,timestamp:a,payload:n}])}}_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[i,n]of t)i==="values"&&r?.checkpoint!=null&&!this.stream.modes.has("checkpoints")&&this.stream.push([this.checkpointNamespace,"checkpoints",r.checkpoint]),this.stream.modes.has(i)&&this.stream.push([this.checkpointNamespace,i,n])}_putCheckpoint(t){let r=this.checkpointMetadata===t,i=this.checkpointer!=null&&(this.durability!=="exit"||r),n=c=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=Lt(this.checkpointConfig,{[Xr]:this.config.configurable?.checkpoint_ns??""});let u={...this.checkpoint.channel_versions},l=hl(this.checkpointPreviousVersions,u);this.checkpointPreviousVersions=u,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:Wn(c),metadata:{...this.checkpointMetadata},newVersions:l}),this.checkpointConfig={...this.checkpointConfig,configurable:{...this.checkpointConfig.configurable,checkpoint_id:this.checkpoint.id}}},o;if(r)o={...this.checkpointMetadata.counters_since_delta_snapshot??{}};else{let c=this.checkpointMetadata.counters_since_delta_snapshot??{};o={};let u=this.updatedChannels??new Set;for(let l in this.channels){if(!Object.prototype.hasOwnProperty.call(this.channels,l)||!An(this.channels[l]))continue;let[d,f]=c[l]??[0,0];o[l]=[u.has(l)?d+1:d,f+1]}this.checkpointMetadata={...t,step:this.step,parents:this.config.configurable?.checkpoint_map??{}}}let a=i?J_(this.channels,o):new Set;if(i)for(let c of this._deltaChannelsWithOverwrite)a.add(c);this.checkpoint=qn(this.checkpoint,i?this.channels:void 0,this.step,{id:r?this.checkpoint.id:void 0,channelsToSnapshot:a,updatedChannels:this.updatedChannels,getNextVersion:i?c=>this.checkpointerGetNextVersion(c):void 0});for(let c of a)o[c]=[0,0],this._deltaChannelsWithOverwrite.delete(c);let s={};for(let c in o){if(!Object.prototype.hasOwnProperty.call(o,c))continue;let[u,l]=o[c];(u!==0||l!==0)&&(s[c]=[u,l])}Object.keys(s).length>0?this.checkpointMetadata.counters_since_delta_snapshot=s:delete this.checkpointMetadata.counters_since_delta_snapshot,i&&n(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=J_(this.channels,t);for(let c of this._deltaChannelsWithOverwrite)r.add(c);let i=this._exitDeltaWrites.filter(([,,c])=>!r.has(c));if(i.length===0)return;let n;if(this._hasPersistedParent)n=this._initialCheckpointConfig;else{let c=sc();c.id=this.checkpointIdSaved??c.id,c.ts=new Date().toISOString();let u=Lt(this._initialCheckpointConfig,{[Co]:void 0});n=Lt(this._initialCheckpointConfig,{[Co]:c.id}),this._trackCheckpointerPromise(this.checkpointer.put(u,c,{source:"loop",step:-2,parents:{}},{})),this.checkpointConfig=n}let o=Lt(n,{[Xr]:this.config.configurable?.checkpoint_ns??"",[Co]:n.configurable?.[Co]}),a=new Map,s=[];for(let[c,u,l,d]of i){let f=`${c}\0${u}`,p=a.get(f);p===void 0&&(p=[],a.set(f,p),s.push({key:f,step:c,tid:u})),p.push([l,d])}for(let{key:c,step:u,tid:l}of s){let d=oE(u,l);this._trackCheckpointerPromise(this.checkpointer.putWrites(o,a.get(c),d))}}_flushPendingWrites(){if(this.checkpointer==null||this.checkpointPendingWrites.length===0)return;let t=Lt(this.checkpointConfig,{[Xr]:this.config.configurable?.checkpoint_ns??"",[Co]:this.checkpoint.id}),r={};for(let[i,n,o]of this.checkpointPendingWrites)r[i]??=[],r[i].push([n,o]);for(let[i,n]of Object.entries(r))this._trackCheckpointerPromise(this.checkpointer.putWrites(t,n,i))}_matchWrites(t){for(let[r,i,n]of this.checkpointPendingWrites){if(i==="__error__"||i==="__interrupt__"||i==="__resume__")continue;let o=Object.values(t).find(a=>a.id===r);o&&o.writes.push([i,n])}for(let r of Object.values(t))r.writes.length>0&&this._outputWrites(r.id,r.writes,!0)}};function _q(e){return lt(e?.message)}function JL(e,t,r){if(!e)return;let i=e.langgraph_checkpoint_ns,n=e.checkpoint_ns,o=i??n;if(o)return[o.split("|"),{tags:t,name:r,...e}]}var XL=class extends Sr{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(e){super(),this.streamFn=e}_emit(e,t,r,i=!1){if(i&&t.id!==void 0&&this.seen[t.id]!==void 0)return;let n=t.id;r!=null&&(Ol(t)?n??=`run-${r}-tool-${t.tool_call_id}`:((n==null||n===`run-${r}`)&&(n=this.stableMessageIdMap[r]??n??`run-${r}`),this.stableMessageIdMap[r]??=n)),n!==t.id&&(t.id=n,t.lc_kwargs.id=n),t.id!=null&&(this.seen[t.id]=t),this.streamFn([e[0],"messages",[t,e[1]]])}handleChatModelStart(e,t,r,i,n,o,a,s){a&&(!o||!o.includes("langsmith:nostream")&&!o.includes("nostream"))&&(this.metadatas[r]=JL(a,o,s))}handleLLMNewToken(e,t,r,i,n,o){let a=o?.chunk;this.emittedChatModelRunIds[r]=!0,this.metadatas[r]!==void 0&&(_q(a)?this._emit(this.metadatas[r],a.message,r):this._emit(this.metadatas[r],new nt({content:e}),r))}handleLLMEnd(e,t){if(this.metadatas[t]!==void 0){if(!this.emittedChatModelRunIds[t]){let r=e.generations?.[0]?.[0];lt(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,i,n,o,a,s){if(o!==void 0&&s===o.langgraph_node&&(n===void 0||!n.includes("langsmith:hidden"))&&(this.metadatas[r]=JL(o,n,s),typeof t=="object")){for(let c of Object.values(t))if((lt(c)||Hi(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(lt(u)||Hi(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r!==void 0){if(lt(e))this._emit(r,e,t,!0);else if(Array.isArray(e))for(let i of e)lt(i)&&this._emit(r,i,t,!0);else if(e!=null&&typeof e=="object"){for(let i of Object.values(e))if(lt(i))this._emit(r,i,t,!0);else if(Array.isArray(i))for(let n of i)lt(n)&&this._emit(r,n,t,!0)}}}handleChainError(e,t){delete this.metadatas[t]}};function YL(e){if("response_metadata"in e&&typeof e.response_metadata=="object"&&e.response_metadata!=null)return e.response_metadata}function QL(e){if("usage_metadata"in e&&typeof e.usage_metadata=="object"&&e.usage_metadata!=null)return e.usage_metadata}function yq(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 vq(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 eU=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&&(Pt.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 i=r!=null?{...e[1],run_id:r}:e[1];this.streamFn([e[0],"messages",[t,i]])}emitFinalMessage(e,t,r,i=!1){let n=t.id??(r!=null?this.stableMessageIdMap[r]:void 0);if(i&&n!=null&&this.seen[n]!==void 0)return;let o=this.normalizeMessageId(t,r),a=t.type==="human"?"human":t.type==="system"?"system":t.type==="tool"?"tool":"ai",s=a==="tool"&&Pt.isInstance(t)?t.tool_call_id:void 0;this.emit(e,{event:"message-start",...o!=null?{id:o}:{},...a!=="ai"?{role:a}:{},...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,u)=>{let l=typeof c.index=="number"?c.index:u;this.emit(e,{event:"content-block-start",index:l,content:yq(c)},r);let d=vq({...c,index:l});d!=null&&this.emit(e,d,r),this.emit(e,{event:"content-block-finish",index:l,content:c},r)}),this.emit(e,{event:"message-finish",...QL(t)!=null?{usage:QL(t)}:{},...YL(t)!=null?{responseMetadata:YL(t)}:{}},r)}handleChatModelStart(e,t,r,i,n,o,a,s){a&&(!o||!o.includes("langsmith:nostream")&&!o.includes("nostream"))&&(this.metadatas[r]=[a.langgraph_checkpoint_ns.split("|"),{tags:o,name:s,...a}])}handleLLMNewToken(){}handleChatModelStreamEvent(e,t){let r=this.metadatas[t];if(r===void 0)return;let i=e;if(e.event==="message-start"){this.streamedRunIds.add(t);let n=e.id??`run-${t}`;this.seen[n]=!0,this.stableMessageIdMap[t]??=n,e.id==null&&(i={...e,id:n})}this.emit(r,i,t)}handleLLMEnd(e,t){let r=this.metadatas[t];if(r===void 0)return;let i=e.generations?.[0]?.[0],n=ze.isInstance(i?.message)?i.message:void 0;if(n!=null)if(this.streamedRunIds.has(t)){let o=this.normalizeMessageId(n,t);o!=null&&(this.seen[o]=n)}else this.emitFinalMessage(r,n,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,i,n,o,a,s){if(o!==void 0&&s===o.langgraph_node&&(n===void 0||!n.includes("langsmith:hidden"))&&(this.metadatas[r]=[o.langgraph_checkpoint_ns.split("|"),{tags:n,name:s,...o}],typeof t=="object")){for(let c of Object.values(t))if((ze.isInstance(c)||Vt.isInstance(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(ze.isInstance(u)||Vt.isInstance(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r===void 0)return;let i=n=>{ze.isInstance(n)&&!Pt.isInstance(n)&&this.emitFinalMessage(r,n,t,!0)};if(ze.isInstance(e))i(e);else if(Array.isArray(e))for(let n of e)i(n);else if(e!=null&&typeof e=="object")for(let n of Object.values(e))if(Array.isArray(n))for(let o of n)i(o);else i(n);delete this.stableMessageIdMap[t]}handleChainError(e,t){delete this.metadatas[t],delete this.stableMessageIdMap[t]}};var bq=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}},wq=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 xq(e,t,r,i){let n=e.configurable??{},o={},a=n[nr];typeof a=="function"&&(o[nr]=u=>{if(t.active)return u&&u.length&&t.autoTouch(),a(u)});let s=n[ai];typeof s=="function"&&(o[ai]=(...u)=>{if(!t.active)throw new Error(`Node "${i}" attempt was cancelled after its timeout fired`);return t.autoTouch(),s(...u)});let c={...Object.keys(o).length>0?Lt(e,o):e};if(c.heartbeat=()=>{r.idleTimeout!==void 0&&t.touch()},typeof c.writer=="function"){let u=c.writer;c.writer=(l=>{if(t.active)return t.autoTouch(),u(l)})}if((r.refreshOn??"auto")==="auto"&&r.idleTimeout!==void 0){let u=new wq(t),l=c.callbacks;if(l===void 0)c.callbacks=[u];else if(Array.isArray(l))c.callbacks=[...l,u];else{let d=l.copy();d.addHandler(u,!0),c.callbacks=d}}return c}async function tU(e,t,r,i){let n=new bq(r.refreshOn??"auto"),o=new AbortController,{signal:a,dispose:s}=Ia(t.signal,o.signal),c=xq({...t,signal:a},n,r,String(e.name)),u=Date.now(),l=i(c).then(_=>({type:"ok",value:_}),_=>({type:"err",error:_})),d,f,p=()=>{d!==void 0&&clearTimeout(d),f!==void 0&&clearTimeout(f)},m=new Promise(_=>{if(r.runTimeout!==void 0&&(d=setTimeout(()=>_({type:"timeout",kind:"run"}),r.runTimeout)),r.idleTimeout!==void 0){let v=r.idleTimeout,x=()=>{let S=n.lastProgress+v-Date.now();S<=0?_({type:"timeout",kind:"idle"}):f=setTimeout(x,S)};f=setTimeout(x,v)}}),h;try{h=await Promise.race([l,m])}finally{p()}if(h.type!=="timeout"){let _=Date.now();r.runTimeout!==void 0&&_-u>=r.runTimeout?h={type:"timeout",kind:"run"}:r.idleTimeout!==void 0&&_-n.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 g=Date.now()-u;throw n.close(),e.writes.splice(0,e.writes.length),o.abort(),s?.(),new fp({node:String(e.name),elapsed:g,kind:h.kind,runTimeout:r.runTimeout,idleTimeout:r.idleTimeout})}var Sq=[400,401,402,403,404,405,406,407,409],kq=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&&Sq.includes(+t)||e?.error?.code==="insufficient_quota")};async function xy(e,t,r,i){let n=e.retry_policy??t,o=0,a,s,c=e.config??{};r&&(c=Lt(c,r)),c={...c,signal:i};let u=Date.now();for(c.executionInfo!=null&&(c.executionInfo={...c.executionInfo,nodeFirstAttemptTime:u});!i?.aborted;){e.writes.splice(0,e.writes.length),a=void 0;try{e.timeout!==void 0?s=await tU(e,c,e.timeout,l=>e.proc.invoke(e.input,l)):s=await e.proc.invoke(e.input,c);break}catch(l){if(a=l,a.pregelTaskId=e.id,Cy(a)){let h=c?.configurable?.checkpoint_ns,g=a.command;if(g.graph===h){for(let _ of e.writers)await _.invoke(g,c);a=void 0;break}else if(g.graph===Dr.PARENT){let _=oL(h);a.command=new Dr({...a.command,graph:_})}}if(No(a)||n===void 0||(o+=1,o>=(n.maxAttempts??3))||!(n.retryOn??kq)(a))break;let d=n.initialInterval??500,f=Math.min(n.maxInterval??128e3,d*(n.backoffFactor??2)**(o-1)),p=n.jitter??!0?f+Math.random()*1e3:f;await new Promise(h=>setTimeout(h,p));let m=a.name??a.constructor.unminifiable_name??a.constructor.name;(n?.logWarning??!0)&&console.log(`Retrying task "${String(e.name)}" after ${p.toFixed(2)}ms (attempt ${o}) after ${m}: ${a}`),c=Lt(c,{[Ra]:!0}),c.executionInfo!=null&&(c.executionInfo={...c.executionInfo,nodeAttempt:o+1,nodeFirstAttemptTime:u})}}return{task:e,result:s,error:a,signalAborted:i?.aborted}}var RE=Symbol.for("promiseAdded");function $q(){let e={next:()=>{},wait:Promise.resolve(RE)};function t(r){e.next=()=>{e.wait=new Promise(t),r(RE)}}return e.wait=new Promise(t),e}var rU=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:i,maxConcurrency:n}=e,o=new Set,a,s=new AbortController,c=s.signal,u=t?AbortSignal.timeout(t):void 0,l=Object.values(this.loop.tasks),d=l.filter(h=>h.writes.length===0),{signals:f,disposeCombinedSignal:p}=this._initializeAbortSignals({exceptionSignal:c,stepTimeoutSignal:u,signal:e.signal}),m=this._executeTasksWithRetry(d,{signals:f,retryPolicy:r,maxConcurrency:n});for await(let{task:h,error:g,signalAborted:_}of m)this._commit(h,g),!(g!==void 0&&this.handledExceptions.has(g))&&(Ui(g)||No(g)&&!Ui(a)?a=g:g&&(o.size===0||!_)&&(s.abort(),o.add(g)));if(p?.(),i?.(this.loop.step,l.map(h=>h.writes).flat()),o.size===1)throw Array.from(o)[0];if(o.size>1)throw new AggregateError(Array.from(o),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(Ui(a)||cp(a)||No(a)&&this.loop.isNested)throw a}_initializeAbortSignals({exceptionSignal:e,stepTimeoutSignal:t,signal:r}){let i=this.loop.config.configurable?.__pregel_abort_signals??{},n=i.externalAbortSignal??r,o=t??i.timeoutAbortSignal,{signal:a,dispose:s}=Ia(n,o,e),c={externalAbortSignal:n,timeoutAbortSignal:o,composedAbortSignal:a};return this.loop.config=Lt(this.loop.config,{[tT]:c}),{signals:c,disposeCombinedSignal:s}}async*_executeTasksWithRetry(e,t){let{retryPolicy:r,maxConcurrency:i,signals:n}=t??{},o=$q(),a={},s={executingTasksMap:a,barrier:o,retryPolicy:r,scheduleTask:async(f,p,m)=>this.loop.acceptPush(f,p,m)};if(n?.composedAbortSignal?.aborted)throw new Error("Abort");let c=0,u,l=Ia(n?.externalAbortSignal,n?.timeoutAbortSignal),d=l.signal?new Promise((f,p)=>{u=()=>p(new Error("Abort")),l.signal?.addEventListener("abort",u,{once:!0})}):void 0;for(;(c===0||Object.keys(a).length>0)&&e.length;){for(;Object.values(a).length<(i??e.length)&&c<e.length;c+=1){let g=e[c];a[g.id]=xy(g,r,{[ai]:jE?.bind(s,this,g)},n?.composedAbortSignal).catch(_=>({task:g,error:_,signalAborted:n?.composedAbortSignal?.aborted}))}let f=await Promise.race([...Object.values(a),...d?[d]:[],o.wait]);if(f===RE)continue;let p=f,{task:m,error:h}=p;if(h!==void 0&&!No(h)&&!this.loop.isErrorHandlerNode(String(m.name))&&this.loop.getErrorHandlerNode(String(m.name))!==void 0){let g=this.loop.scheduleErrorHandler(m,h);g!==void 0&&(a[g.id]=xy(g,r,{[ai]:jE?.bind(s,this,g)},n?.composedAbortSignal).catch(_=>({task:g,error:_,signalAborted:n?.composedAbortSignal?.aborted})),o.next())}yield p,u!=null&&(l.signal?.removeEventListener("abort",u),l.dispose?.()),delete a[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(n=>[qe,n]),i=e.writes.filter(n=>n[0]===vr);i.length&&r.push(...i),this.loop.putWrites(e.id,r)}}else cp(t)?e.writes.length&&this.loop.putWrites(e.id,e.writes):No(t)&&e.writes.length?this.loop.putWrites(e.id,e.writes):(e.writes.push([To,{message:t.message,name:t.name}]),this._shouldRouteToErrorHandler(e)&&(e.writes.push([vl,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([xl,null]),this.loop.putWrites(e.id,e.writes)}};async function jE(e,t,r,i,n,o={}){let a=t.config?.configurable?.[yr];if(!a)throw new Error(`BUG: No scratchpad found on task ${t.name}__${t.id}`);let s=a.callCounter;a.callCounter+=1;let c=new EL({func:r,name:i,input:n,cache:o.cache,retry:o.retry,timeout:o.timeout,callbacks:o.callbacks}),u=await this.scheduleTask(t,s,c);if(!u)return;let l=this.executingTasksMap[u.id];if(l!==void 0)return l;if(u.writes.length>0){let d=u.writes.filter(([p])=>p===Oo),f=u.writes.filter(([p])=>p===To);if(d.length>0){if(d.length===1)return Promise.resolve(d[0][1]);throw new Error(`BUG: multiple returns found for task ${u.name}__${u.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 ${u.name}__${u.id}`)}return}else{let d=xy(u,o.retry,{[ai]:jE.bind(this,e,u)});return this.executingTasksMap[u.id]=d,this.barrier.next(),d.then(({result:f,error:p})=>p?Promise.reject(p):f)}}var vo=class extends Error{constructor(e){super(e),this.name="GraphValidationError"}};function nU({nodes:e,channels:t,inputChannels:r,outputChannels:i,streamChannels:n,interruptAfterNodes:o,interruptBeforeNodes:a}){if(!t)throw new vo("Channels not provided");let s=new Set,c=new Set;for(let[u,l]of Object.entries(e)){if(u==="__interrupt__")throw new vo(`"Node name ${qe} is reserved"`);if(l.constructor===Yn)l.triggers.forEach(d=>s.add(d));else throw new vo(`Invalid node type ${typeof l}, expected PregelNode`)}for(let u of s)if(!(u in t))throw new vo(`Subscribed channel '${String(u)}' not in channels`);if(Array.isArray(r)){if(r.every(u=>!s.has(u)))throw new vo(`None of the input channels ${r} are subscribed to by any node`)}else if(!s.has(r))throw new vo(`Input channel ${String(r)} is not subscribed to by any node`);Array.isArray(i)?i.forEach(u=>c.add(u)):c.add(i),n&&!Array.isArray(n)?c.add(n):Array.isArray(n)&&n.forEach(u=>c.add(u));for(let u of c)if(!(u in t))throw new vo(`Output channel '${String(u)}' not in channels`);if(o&&o!=="*"){for(let u of o)if(!(u in e))throw new vo(`Node ${String(u)} not in nodes`)}if(a&&a!=="*"){for(let u of a)if(!(u in e))throw new vo(`Node ${String(u)} not in nodes`)}}function DE(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`)}function Iq(e){return Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1])}var ME=class iU extends Et{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 iU({unique:this.unique,accumulate:this.accumulate});return typeof t>"u"?r:Iq(t)?(r.seen=new Set(t[0]),r.values=[...t[1]],r):(r.values=[...t],this.unique&&(r.seen=new Set(r.values)),r)}update(t){let r=!1;this.accumulate||(r=this.values.length>0,this.values=[]);let i=t.flat();if(i.length>0)if(this.unique)for(let n of i)this.seen.has(n)||(r=!0,this.seen.add(n),this.values.push(n));else r=!0,this.values.push(...i);return r}get(){if(this.values.length===0)throw new Ve;return this.values}checkpoint(){return this.unique?[[...this.seen],[...this.values]]:[...this.values]}isAvailable(){return this.values.length!==0}};function Eq(e){let t=new TextEncoder;return new ReadableStream({async start(r){try{for await(let i of e){let n=i.params.namespace,o=n.length?`${i.method}|${n.join("|")}`:i.method;r.enqueue(t.encode(`event: ${o}
449
+ data: ${JSON.stringify(i.params.data??{})}
450
+
451
+ `))}}catch(i){r.enqueue(t.encode(`event: error
452
+ data: ${JSON.stringify({message:String(i)})}
453
+
454
+ `))}finally{r.close()}}})}var oU=class{static subscribeTo(e,t){let{key:r,tags:i}={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 n;return typeof e=="string"?r?n={[r]:e}:n=[e]:n=Object.fromEntries(e.map(o=>[o,o])),new Yn({channels:n,triggers:Array.isArray(e)?e:[e],tags:i})}static writeTo(e,t){let r=[];for(let i of e)r.push({channel:i,value:qr,skipNone:!1});for(let[i,n]of Object.entries(t??{}))ue.isRunnable(n)||typeof n=="function"?r.push({channel:i,value:qr,skipNone:!0,mapper:mt(n)}):r.push({channel:i,value:n,skipNone:!1});return new vt(r)}},Tq=class extends ue{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)}},Sy=class extends Tq{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 '${si}' is reserved and cannot be used in the graph.`);this.channels[si]=new ME({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,i=jt(this.config,r),n=[...this.streamTransformers,...t??[]];return new this.constructor({...this,config:i,streamTransformers:n})}validate(){nU({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,i]of Object.entries(this.nodes)){if(e!==void 0&&!e.startsWith(r))continue;let n=i.subgraphs?.length?i.subgraphs:[i.bound];for(let o of n){let a=fy(o);if(a!==void 0){if(r===e){yield[r,a];return}if(e===void 0&&(yield[r,a]),t){let s=e;e!==void 0&&(s=e.slice(r.length+1));for(let[c,u]of a.getSubgraphs(s,t))yield[`${r}|${c}`,u]}}}}}async*getSubgraphsAsync(e,t){yield*this.getSubgraphs(e,t)}async _prepareStateSnapshot({config:e,saved:t,subgraphCheckpointer:r,applyPendingWrites:i=!1}){if(t===void 0)return{values:{},next:[],config:e,tasks:[]};let n=await cl(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===wr).map(([f,p,m])=>[String(p),m]);d.length>0&&Rr(t.checkpoint,n,[{name:oi,writes:d,triggers:[]}],void 0,this.triggerToNodes)}let o=Object.values(Ea(t.checkpoint,t.pendingWrites,this.nodes,n,t.config,!0,{step:(t.metadata?.step??-1)+1,store:this.store})),a=await Xn(this.getSubgraphsAsync()),s=t.config.configurable?.checkpoint_ns??"",c={};for(let d of o){let f=a.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:{[fn]:r,thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}},h=f[1];c[d.id]=await h.getState(m,{subgraphs:!0})}}if(i&&t.pendingWrites?.length){let d=Object.fromEntries(o.map(p=>[p.id,p]));for(let[p,m,h]of t.pendingWrites)["__error__","__interrupt__",Ua].includes(m)||p in d&&d[p].writes.push([String(m),h]);let f=o.filter(p=>p.writes.length>0);f.length>0&&Rr(t.checkpoint,n,f,void 0,this.triggerToNodes)}let u=t?.metadata;u&&t?.config?.configurable?.thread_id&&(u={...u,thread_id:t.config.configurable.thread_id});let l=o.filter(d=>d.writes.length===0).map(d=>d.name);return{values:Qn(n,this.streamChannelsAsIs),next:l,tasks:AE(o,t?.pendingWrites??[],c,this.streamChannelsAsIs),metadata:u,config:$a(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 za("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_read===void 0&&e.configurable?.__pregel_checkpointer===void 0){let a=ey(i);for await(let[s,c]of this.getSubgraphsAsync(a,!0))if(s===a)return await c.getState(uc(e,{[fn]:r}),{subgraphs:t?.subgraphs})}let n=jt(this.config,e),o=await r.getTuple(e);return await this._prepareStateSnapshot({config:n,saved:o,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 za("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=ey(i);for await(let[a,s]of this.getSubgraphsAsync(o,!0))if(a===o){yield*s.getStateHistory(uc(e,{[fn]:r}),t);return}}let n=jt(this.config,e,{configurable:{checkpoint_ns:i}});for await(let o of r.list(n,t))yield this._prepareStateSnapshot({config:o.config,saved:o})}async bulkUpdateState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new za("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});if(t.length===0)throw new Error("No supersteps provided");if(t.some(a=>a.updates.length===0))throw new Error("No updates provided");let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=ey(i);for await(let[,s]of this.getSubgraphsAsync(a,!0))return await s.bulkUpdateState(uc(e,{[fn]:r}),t);throw new Error(`Subgraph "${a}" not found`)}let n=async(a,s)=>{let c=this.config?jt(this.config,a):a,u=await r.getTuple(c),l=u!==void 0?Wn(u.checkpoint):sc(),d={...u?.checkpoint.channel_versions},f=u?.metadata?.step??-1,p=uc(c,{checkpoint_ns:c.configurable?.checkpoint_ns??""}),m=c.metadata??{};u?.config.configurable&&(p=uc(c,u.config.configurable),m={...u.metadata,...m});let{values:h,asNode:g}=s[0];if(h==null&&g===void 0){if(s.length>1)throw new Se("Cannot create empty checkpoint with multiple updates");return $a(await r.put(p,qn(l,void 0,f),{source:"update",step:f+1,parents:u?.metadata?.parents??{}},{}),u?u.metadata:void 0)}let _=await cl(this.channels,l,{saver:r,config:u?.config??p});if(h===null&&g==="__end__"){if(s.length>1)throw new Se("Cannot apply multiple updates when clearing state");if(u){let A=Ea(l,u.pendingWrites||[],this.nodes,_,u.config,!0,{step:(u.metadata?.step??-1)+1,checkpointer:r,store:this.store}),b=(u.pendingWrites||[]).filter(z=>z[0]===wr).map(z=>z.slice(1));b.length>0&&Rr(l,_,[{name:oi,writes:b,triggers:[]}],r.getNextVersion.bind(r),this.triggerToNodes);for(let[z,j,H]of u.pendingWrites||[])["__error__","__interrupt__",Ua].includes(j)||z in A&&A[z].writes.push([j,H]);Rr(l,_,Object.values(A),r.getNextVersion.bind(r),this.triggerToNodes)}return $a(await r.put(p,qn(l,_,f),{...m,source:"update",step:f+1,parents:u?.metadata?.parents??{}},hl(d,l.channel_versions)),u?u.metadata:void 0)}if(g==="__copy__"){if(s.length>1)throw new Se("Cannot copy checkpoint with multiple updates");if(u==null)throw new Se("Cannot copy a non-existent checkpoint");let A=j=>!Array.isArray(j)||j.length===0?!1:j.every(H=>Array.isArray(H)&&H.length===2),b=qn(l,void 0,f),z=await r.put(u.parentConfig??uc(u.config,{checkpoint_id:void 0}),b,{source:"fork",step:f+1,parents:u.metadata?.parents??{}},{});if(A(h)){let j=Ea(b,u.pendingWrites,this.nodes,_,z,!1,{step:f+2}),H=Object.values(j).reduce((ye,{name:Ce,id:pt})=>(ye[Ce]??=[],ye[Ce].push({id:pt}),ye),{}),ne=h.reduce((ye,Ce)=>{let[pt,xe]=Ce;ye[xe]??=[];let V=ye[xe].length,ee=H[xe]?.[V]?.id;return ye[xe].push({values:pt,asNode:xe,taskId:ee}),ye},{});return n($a(z,u.metadata),Object.values(ne).flat())}return $a(z,u.metadata)}if(g==="__input__"){if(s.length>1)throw new Se("Cannot apply multiple updates when updating as input");let A=await Xn(py(this.inputChannels,h));if(A.length===0)throw new Se(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);Rr(l,_,[{name:oi,writes:A,triggers:[]}],r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let b=u?.metadata?.step!=null?u.metadata.step+1:-1,z=await r.put(p,qn(l,_,b),{source:"input",step:b,parents:u?.metadata?.parents??{}},hl(d,l.channel_versions));return await r.putWrites(z,A,ci(oi,l.id)),$a(z,u?u.metadata:void 0)}if(c.configurable?.checkpoint_id===void 0&&u?.pendingWrites!==void 0&&u.pendingWrites.length>0){let A=Ea(l,u.pendingWrites,this.nodes,_,u.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(u.metadata?.step??-1)+1}),b=(u.pendingWrites??[]).filter(j=>j[0]===wr).map(j=>j.slice(1));b.length>0&&Rr(u.checkpoint,_,[{name:oi,writes:b,triggers:[]}],void 0,this.triggerToNodes);for(let[j,H,ne]of u.pendingWrites)["__error__","__interrupt__",Ua].includes(H)||A[j]===void 0||A[j].writes.push([H,ne]);let z=Object.values(A).filter(j=>j.writes.length>0);z.length>0&&Rr(l,_,z,void 0,this.triggerToNodes)}let v=Object.values(l.versions_seen).map(A=>Object.values(A)).flat().find(A=>!!A),x=[];if(s.length===1){let{values:A,asNode:b,taskId:z}=s[0];if(b===void 0&&Object.keys(this.nodes).length===1)[b]=Object.keys(this.nodes);else if(b===void 0&&v===void 0)typeof this.inputChannels=="string"&&this.nodes[this.inputChannels]!==void 0&&(b=this.inputChannels);else if(b===void 0){let j=Object.entries(l.versions_seen).map(([H,ne])=>Object.values(ne).map(ye=>[ye,H])).flat().filter(([H,ne])=>ne!==qe).sort(([H],[ne])=>Z_(H,ne));j&&(j.length===1?b=j[0][1]:j[j.length-1][0]!==j[j.length-2][0]&&(b=j[j.length-1][1]))}if(b===void 0)throw new Se('Ambiguous update, specify "asNode"');x.push({values:A,asNode:b,taskId:z})}else for(let{asNode:A,values:b,taskId:z}of s){if(A==null)throw new Se('"asNode" is required when applying multiple updates');x.push({values:b,asNode:A,taskId:z})}let S=[];for(let{asNode:A,values:b,taskId:z}of x){if(this.nodes[A]===void 0)throw new Se(`Node "${A.toString()}" does not exist`);let j=this.nodes[A].getWriters();if(!j.length)throw new Se(`No writers found for node "${A.toString()}"`);S.push({name:A,input:b,proc:j.length>1?un.from(j,{omitSequenceTags:!0}):j[0],writes:[],triggers:[qe],id:z??ci("__interrupt__",l.id),writers:[]})}for(let A of S)await A.proc.invoke(A.input,Pe({...c,store:c?.store??this.store},{runName:c.runName??`${this.getName()}UpdateState`,configurable:{[nr]:b=>A.writes.push(...b),[_r]:(b,z=!1)=>gl(l,_,A,b,z)}}));for(let A of S){let b=A.writes.filter(z=>z[0]!==br);u!==void 0&&b.length>0&&await r.putWrites(p,b,A.id)}Rr(l,_,S,r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let k=hl(d,l.channel_versions),T=await r.put(p,qn(l,_,f+1),{source:"update",step:f+1,parents:u?.metadata?.parents??{}},k);for(let A of S){let b=A.writes.filter(z=>z[0]===br);b.length>0&&await r.putWrites(T,b,A.id)}return $a(T,u?u.metadata:void 0)},o=e;for(let{updates:a}of t)o=await n(o,a);return o}async updateState(e,t,r){return this.bulkUpdateState(e,[{updates:[{values:t,asNode:r}]}])}_defaults(e){let{debug:t,streamMode:r,inputKeys:i,outputKeys:n,interruptAfter:o,interruptBefore:a,...s}=e,c=!0,u=t!==void 0?t:this.debug,l=n;l===void 0?l=this.streamChannelsAsIs:DE(l,this.channels);let d=i;d===void 0?d=this.inputChannels:DE(d,this.channels);let f=a??this.interruptBefore??[],p=o??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[fn];else{if(this.checkpointer===!0)throw new Error("checkpointer: true cannot be used for root graphs.");h=this.checkpointer}let g=e.store??this.store,_=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 v=(()=>{if(e.checkpointDuring!=null)return e.checkpointDuring===!1?"exit":"async"})(),x=e.durability??v??e?.configurable?.__pregel_durability??"async";return[u,m,d,l,s,f,p,h,g,c,_,x]}async stream(e,t){let r=new AbortController,i=Q_()?.configurable;i?.__pregel_read!==void 0&&t?.configurable?.__pregel_read===void 0&&(t={...t,configurable:{...i,...t?.configurable}});let n={recursionLimit:this.config?.recursionLimit,...t,signal:Ia(t?.signal,r.signal).signal},o=await super.stream(e,n);return new by(t?.encoding==="text/event-stream"?VL(o):o,r)}async#e(e,t){let{version:r,encoding:i,transformers:n,...o}=t,a={recursionLimit:this.config?.recursionLimit,...o,configurable:{...this.config?.configurable,...o?.configurable},version:r,streamMode:cE,subgraphs:!0,encoding:void 0},s=this.stream(e,a),c=vE({[Symbol.asyncIterator]:async function*(){let u=await s;for await(let l of u)yield l}},[...this.streamTransformers??[],...n??[]]);if(i==="text/event-stream"){let u=new AbortController;return u.signal.addEventListener("abort",()=>c.abort(u.signal.reason),{once:!0}),new by(Eq(c),u)}return c}streamEvents(e,t,r){if(t.version==="v3")return this.#e(e,t);let i=new AbortController,n={recursionLimit:this.config?.recursionLimit,...t,signal:Ia(t?.signal,i.signal).signal};return new by(super.streamEvents(e,n,r),i)}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,i=t?.subgraphs,n=t?.version==="v3",o=ul(this.config,t);if(o.recursionLimit===void 0||o.recursionLimit<1)throw new Error('Passed "recursionLimit" must be at least 1.');if(this.checkpointer!==void 0&&this.checkpointer!==!1&&o.configurable===void 0)throw new Error('Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"');let a=await this._validateInput(e),{runId:s,...c}=o,[u,l,,d,f,p,m,h,g,_,v,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 OE({modes:new Set(l)});if(this.checkpointer===!0){f.configurable??={};let ne=f.configurable.checkpoint_ns??"";f.configurable[Xr]=ne.split("|").map(ye=>ye.split(":")[0]).join("|")}if(l.includes("messages")){let ne=n?new eU(Ce=>S.push(Ce)):new XL(Ce=>S.push(Ce)),{callbacks:ye}=f;if(ye===void 0)f.callbacks=[ne];else if(Array.isArray(ye))f.callbacks=ye.concat(ne);else{let Ce=ye.copy();Ce.addHandler(ne,!0),f.callbacks=Ce}}if(l.includes("tools")){let ne=new BL(Ce=>S.push(Ce)),{callbacks:ye}=f;if(ye===void 0)f.callbacks=[ne];else if(Array.isArray(ye))f.callbacks=ye.concat(ne);else{let Ce=ye.copy();Ce.addHandler(ne,!0),f.callbacks=Ce}}f.writer??=ne=>{if(!l.includes("custom"))return;let ye=Q_()?.configurable?.[Xr]?.split("|").slice(0,-1);S.push([ye??[],"custom",ne])},f.interrupt??=this.userInterrupt??SE,f.serverInfo==null&&(f.serverInfo=Aq(f)),f.control??=new sE;let k={tracerInheritableMetadata:Pq(f)},T=await(await at._configureSync(f?.callbacks,void 0,f?.tags,void 0,f?.metadata,void 0,k))?.handleChainStart(this.toJSON(),IL(e,"input"),s,void 0,void 0,void 0,f?.runName??this.getName()),A=sl(this.channels),b,z,H=(async()=>{try{b=await WL.initialize({input:a,config:f,checkpointer:h,nodes:this.nodes,channelSpecs:A,outputKeys:d,streamKeys:this.streamChannelsAsIs,store:g,cache:v,stream:S,interruptAfter:m,interruptBefore:p,manager:T,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:x});let ne=new rU({loop:b,nodeFinished:f.configurable?.[eT]});t?.subgraphs&&(b.config.configurable={...b.config.configurable,[bl]:b.stream}),await this._runLoop({loop:b,runner:ne,debug:u,config:f}),x==="sync"&&await Promise.all(b?.checkpointerPromises??[])}catch(ne){z=ne}finally{try{b&&(await b.store?.stop(),await b.cache?.stop()),await Promise.all(b?.checkpointerPromises??[])}catch(ne){z=z??ne}z?(await new Promise(ne=>{queueMicrotask(ne)}),S.error(z)):S.close()}})();try{for await(let ne of S){if(ne===void 0)throw new Error("Data structure error.");let[ye,Ce,pt]=ne,xe="version"in(t??{});if(l.includes(Ce)||Ce==="checkpoints"&&ll(pt)&&(n||xe&&i&&l.includes("values"))){if(r==="text/event-stream"){i?yield[ye,Ce,pt]:yield[null,Ce,pt];continue}i&&!_?yield[ye,Ce,pt]:_?i?yield[ye,pt]:yield pt:yield[Ce,pt]}}}catch(ne){throw await T?.handleChainError(z),ne}finally{await H}await T?.handleChainEnd(b?.output??{},s,void 0,void 0,void 0)}async invoke(e,t){let r=t?.streamMode??"values",i={...t,outputKeys:t?.outputKeys??this.outputChannels,streamMode:r,encoding:void 0},n=[],o=await this.stream(e,i),a=[],s;for await(let c of o)r==="values"?Ma(c)?a.push(c[qe]):s=c:n.push(c);if(r==="values"){if(a.length>0){let c=a.flat(1);if(s==null)return{[qe]:c};if(typeof s=="object")return{...s,[qe]:c}}return s}return n}async _runLoop(e){let{loop:t,runner:r,debug:i,config:n}=e,o;try{for(;await t.tick({inputKeys:this.inputChannels});){for(let{task:a}of await t._matchCachedWrites())t._outputWrites(a.id,a.writes,!0);i&&zL(t.checkpointMetadata.step,t.channels,this.streamChannelsList),i&&Yf(t.step,Object.values(t.tasks)),await r.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(a,s)=>{i&&LL(a,s,this.streamChannelsList)},maxConcurrency:n.maxConcurrency,signal:n.signal})}if(t.status==="draining")throw t.control==null?new Error("Draining status requires run control"):new sp(t.control.drainReason??"shutdown");if(t.status==="out_of_steps")throw new Ay([`Recursion limit of ${n.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(a){if(o=a,!await t.finishAndHandleError(o))throw a}finally{o===void 0&&await t.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};function Aq(e){let t=e.metadata??{},r=e.configurable??{},i=r.assistant_id??t.assistant_id,n=r.graph_id??t.graph_id,o=r.langgraph_auth_user,a;if(o!=null&&typeof o=="object"&&"identity"in o&&(a=o),i!=null||n!=null||a!=null)return{assistantId:i!=null?String(i):"",graphId:n!=null?String(n):"",user:a}}var Cq=new Set(["key","token","secret","password","auth"]);function Oq(e,t){let r=e.toLowerCase(),i=!1;for(let n of Cq)if(r.includes(n)){i=!0;break}return e.startsWith("__")||!(typeof t=="string"||typeof t=="number"||typeof t=="boolean")||i}function Pq(e){let t=e.configurable;if(!t)return;let r=e.context,i={};for(let[n,o]of Object.entries(t)){if(r!=null&&Object.prototype.hasOwnProperty.call(r,n)&&Object.is(r[n],o)){n.startsWith("__")||(i[n]=void 0);continue}Oq(n,o)||(i[n]=o)}return Object.keys(i).length>0?i:void 0}var ei=class aU extends Et{lc_graph_name="EphemeralValue";guard;value=[];constructor(t=!0){super(),this.guard=t}fromCheckpoint(t){let r=new aU(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 Se("EphemeralValue can only receive one value per step.");return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Ve;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Ve;return this.value[0]}isAvailable(){return this.value.length!==0}};var zE=class{path;ends;constructor(e){ue.isRunnable(e.path)?this.path=e.path:this.path=mt(e.path),this.ends=Array.isArray(e.pathMap)?e.pathMap.reduce((t,r)=>(t[r]=r,t),{}):e.pathMap}run(e,t){return vt.registerWriter(new Wt({name:"<branch_run>",trace:!1,func:async(r,i)=>{try{return await this._route(r,i,e,t)}catch(n){throw n.name===up.unminifiable_name&&console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
455
+ NodeInterrupt should only be thrown inside a node, not in edge conditions.`),n}}}))}async _route(e,t,r,i){let n=await this.path.invoke(i?i(t):e,t);Array.isArray(n)||(n=[n]);let o;if(this.ends?o=n.map(a=>Ct(a)?a:this.ends[a]):o=n,o.some(a=>!a))throw new Error("Branch condition returned unknown or null destination");if(o.filter(Ct).some(a=>a.node==="__end__"))throw new Se("Cannot send a packet to the END node");return await r(o,t)??e}},LE=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(i){return i.length>=1&&typeof i[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[i,n,o]of r){for(let s of["|",":"])if(i.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."),i in this.nodes)throw new Error(`Node \`${i}\` already present.`);if(i==="__end__")throw new Error(`Node \`${i}\` is reserved.`);let a=mt(n);this.nodes[i]={runnable:a,metadata:o?.metadata,subgraphs:Wf(a)?[a]:o?.subgraphs,ends:o?.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 i=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."),ue.isRunnable(i.path)||(i.path=mt(i.path));let n=i.path.getName()==="RunnableLambda"?"condition":i.path.getName();if(this.branches[i.source]&&this.branches[i.source][n])throw new Error(`Condition \`${n}\` already present for node \`${e}\``);return this.branches[i.source]??={},this.branches[i.source][n]=new zE(i),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(rt,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,ct)}compile({checkpointer:e,interruptBefore:t,interruptAfter:r,name:i,transformers:n}={}){this.validate([...Array.isArray(t)?t:[],...Array.isArray(r)?r:[]]);let o=new UE({builder:this,checkpointer:e,interruptAfter:r,interruptBefore:t,autoValidate:!1,nodes:{},channels:{[rt]:new ei,[ct]:new ei},inputChannels:rt,outputChannels:ct,streamChannels:[],streamMode:"values",name:i,streamTransformers:n});for(let[a,s]of Object.entries(this.nodes))o.attachNode(a,s);for(let[a,s]of this.edges)o.attachEdge(a,s);for(let[a,s]of Object.entries(this.branches))for(let[c,u]of Object.entries(s))o.attachBranch(a,c,u);return o.validate()}validate(e){let t=new Set([...this.allEdges].map(([i,n])=>i));for(let[i]of Object.entries(this.branches))t.add(i);for(let i of t)if(i!=="__start__"&&!(i in this.nodes))throw new Error(`Found edge starting at unknown node \`${i}\``);let r=new Set([...this.allEdges].map(([i,n])=>n));for(let[i,n]of Object.entries(this.branches))for(let o of Object.values(n))if(o.ends!=null)for(let a of Object.values(o.ends))r.add(a);else{r.add(ct);for(let a of Object.keys(this.nodes))a!==i&&r.add(a)}for(let i of Object.values(this.nodes))for(let n of i.ends??[])r.add(n);if(Object.values(this.nodes).some(i=>i.isErrorHandler))for(let i of Object.keys(this.nodes))r.add(i);for(let i of Object.keys(this.nodes))if(!this.nodes[i].isErrorHandler&&!r.has(i))throw new Oy([`Node \`${i}\` 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(`
456
+ `),{lc_error_code:"UNREACHABLE_NODE"});for(let i of r)if(i!=="__end__"&&!(i in this.nodes))throw new Error(`Found edge ending at unknown node \`${i}\``);if(e){for(let i of e)if(!(i in this.nodes))throw new Error(`Interrupt node \`${i}\` is not present`)}this.compiled=!0}},UE=class extends Sy{builder;constructor({builder:e,...t}){super(t),this.builder=e}withConfig(e){return super.withConfig(e)}attachNode(e,t){this.channels[e]=new ei,this.nodes[e]=new Yn({channels:[],triggers:[],metadata:t.metadata,subgraphs:t.subgraphs,ends:t.ends}).pipe(t.runnable).pipe(new vt([{channel:e,value:qr}],[kt])),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 vt([{channel:ct,value:qr}],[kt]))}else this.nodes[t].triggers.push(e),this.nodes[t].channels.push(e)}attachBranch(e,t,r){e==="__start__"&&!this.nodes.__start__&&(this.nodes[rt]=oU.subscribeTo(rt,{tags:[kt]})),this.nodes[e].pipe(r.run(n=>new vt(n.map(o=>Ct(o)?o:{channel:o==="__end__"?ct:`branch:${e}:${t}:${o}`,value:qr}),[kt])));let i=r.ends?Object.values(r.ends):Object.keys(this.nodes);for(let n of i)if(n!=="__end__"){let o=`branch:${e}:${t}:${n}`;this.channels[o]=new ei,this.nodes[n].triggers.push(o),this.nodes[n].channels.push(o)}}async getGraphAsync(e){let t=e?.xray,r=new Ys,i={[rt]:r.addNode({schema:Tn.any()},rt)},n={},o={};t&&(o=Object.fromEntries((await Xn(this.getSubgraphsAsync())).filter(u=>sU(u[1]))));let a=[];function s(u,l,d,f=!1){if(l==="__end__"&&n.__end__===void 0&&(n[ct]=r.addNode({schema:Tn.any()},ct)),i[u]!==void 0){if(n[l]===void 0)throw new Error(`End node ${l} not found!`);return a.push({src:u,dest:l,conditional:f}),r.addEdge(i[u],n[l],d!==l?d:void 0,f)}}for(let[u,l]of Object.entries(this.builder.nodes)){let d=Ut(u),f=l.runnable,p=l.metadata??{};if(this.interruptBefore?.includes(u)&&this.interruptAfter?.includes(u)?p.__interrupt="before,after":this.interruptBefore?.includes(u)?p.__interrupt="before":this.interruptAfter?.includes(u)&&(p.__interrupt="after"),t){let m=typeof t=="number"?t-1:t,h=o[u]!==void 0?await o[u].getGraphAsync({...e,xray:m}):f.getGraph(e);if(h.trimFirstNode(),h.trimLastNode(),Object.keys(h.nodes).length>1){let v=function(S){return S?S.lc_runnable:!1},x=function(S,k){if(S!==void 0&&!Fi(S))return S;if(v(k))try{let T=k.getName();return T=T.startsWith("Runnable")?T.slice(8):T,T}catch{return k.getName()}else return k.name??"UnknownSchema"},[g,_]=r.extend(h,d);if(g===void 0)throw new Error(`Could not extend subgraph "${u}" due to missing entrypoint.`);_!==void 0&&(i[d]={name:x(_.id,_.data),..._}),n[d]={name:x(g.id,g.data),...g}}else{let g=r.addNode(f,d,p);i[d]=g,n[d]=g}}else{let m=r.addNode(f,d,p);i[d]=m,n[d]=m}}let c=[...this.builder.allEdges].sort(([u],[l])=>u<l?-1:l>u?1:0);for(let[u,l]of c)s(Ut(u),Ut(l));for(let[u,l]of Object.entries(this.builder.branches)){let d={...Object.fromEntries(Object.keys(this.builder.nodes).filter(f=>f!==u).map(f=>[Ut(f),Ut(f)])),[ct]:ct};for(let f of Object.values(l)){let p;f.ends!==void 0?p=f.ends:p=d;for(let[m,h]of Object.entries(p))s(Ut(u),Ut(h),m,!0)}}for(let[u,l]of Object.entries(this.builder.nodes))if(l.ends!==void 0)for(let d of l.ends)s(Ut(u),Ut(d),void 0,!0);return cU(this.builder.nodes,a,s),r}getGraph(e){let t=e?.xray,r=new Ys,i={[rt]:r.addNode({schema:Tn.any()},rt)},n={},o={};t&&(o=Object.fromEntries(ka(this.getSubgraphs()).filter(u=>sU(u[1]))));let a=[];function s(u,l,d,f=!1){if(l==="__end__"&&n.__end__===void 0&&(n[ct]=r.addNode({schema:Tn.any()},ct)),i[u]!==void 0){if(n[l]===void 0)throw new Error(`End node ${l} not found!`);return a.push({src:u,dest:l,conditional:f}),r.addEdge(i[u],n[l],d!==l?d:void 0,f)}}for(let[u,l]of Object.entries(this.builder.nodes)){let d=Ut(u),f=l.runnable,p=l.metadata??{};if(this.interruptBefore?.includes(u)&&this.interruptAfter?.includes(u)?p.__interrupt="before,after":this.interruptBefore?.includes(u)?p.__interrupt="before":this.interruptAfter?.includes(u)&&(p.__interrupt="after"),t){let m=typeof t=="number"?t-1:t,h=o[u]!==void 0?o[u].getGraph({...e,xray:m}):f.getGraph(e);if(h.trimFirstNode(),h.trimLastNode(),Object.keys(h.nodes).length>1){let v=function(S){return S?S.lc_runnable:!1},x=function(S,k){if(S!==void 0&&!Fi(S))return S;if(v(k))try{let T=k.getName();return T=T.startsWith("Runnable")?T.slice(8):T,T}catch{return k.getName()}else return k.name??"UnknownSchema"},[g,_]=r.extend(h,d);if(g===void 0)throw new Error(`Could not extend subgraph "${u}" due to missing entrypoint.`);_!==void 0&&(i[d]={name:x(_.id,_.data),..._}),n[d]={name:x(g.id,g.data),...g}}else{let g=r.addNode(f,d,p);i[d]=g,n[d]=g}}else{let m=r.addNode(f,d,p);i[d]=m,n[d]=m}}let c=[...this.builder.allEdges].sort(([u],[l])=>u<l?-1:l>u?1:0);for(let[u,l]of c)s(Ut(u),Ut(l));for(let[u,l]of Object.entries(this.builder.branches)){let d={...Object.fromEntries(Object.keys(this.builder.nodes).filter(f=>f!==u).map(f=>[Ut(f),Ut(f)])),[ct]:ct};for(let f of Object.values(l)){let p;f.ends!==void 0?p=f.ends:p=d;for(let[m,h]of Object.entries(p))s(Ut(u),Ut(h),m,!0)}}for(let[u,l]of Object.entries(this.builder.nodes))if(l.ends!==void 0)for(let d of l.ends)s(Ut(u),Ut(d),void 0,!0);return cU(this.builder.nodes,a,s),r}};function sU(e){return typeof e.attachNode=="function"&&typeof e.attachEdge=="function"}function Ut(e){return e==="subgraph"?`"${e}"`:e}function cU(e,t,r){let i=new Set(t.map(o=>o.src)),n=[...new Set(t.filter(o=>!o.conditional&&o.dest!=="__end__").map(o=>o.dest))].sort();for(let o of n){if(i.has(o))continue;let a=Object.keys(e).find(s=>Ut(s)===o);a!==void 0&&e[a]?.isErrorHandler||r(o,ct)}}function bo(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function FE(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function Nq(e){return bo(e)&&FE(e)}function Ta(e){if(FE(e))try{return e["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function wo(e){if(e!=null&&bo(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 i=r.value;return()=>i}}}catch{}}var Rq=e=>e!=null&&e.lc_graph_name==="DeltaChannel",ky=class uU extends Et{lc_graph_name="DeltaChannel";value;reducer;snapshotFrequency;initialValueFactory;constructor(t,r){super();let i=r?.snapshotFrequency??1e3;if(!Number.isInteger(i)||i<=0)throw new Error(`snapshotFrequency must be a positive integer, got ${i}`);this.reducer=t,this.snapshotFrequency=i,this.initialValueFactory=r?.initialValueFactory??(()=>[]),this.value=void 0}fromCheckpoint(t){let r=new uU(this.reducer,{snapshotFrequency:this.snapshotFrequency,initialValueFactory:this.initialValueFactory});return t===void 0?r.value=this.initialValueFactory():Ly(t)?r.value=t.value:r.value=t,r}replayWrites(t){let r=t.map(a=>a[2]);if(r.length===0)return;let i=this.value,n=0;for(let a=0;a<r.length;a+=1){let[s,c]=Pn(r[a]);s&&(i=c??this.initialValueFactory(),n=a+1)}let o=r.slice(n);this.value=o.length>0?this.reducer(i,o):i}update(t){if(t.length===0)return!1;let r,i=!1;for(let o of t)if(Da(o)){if(i)throw new Se("Can receive only one Overwrite value per step.");i=!0,[,r]=Pn(o)}if(i)return this.value=r??this.initialValueFactory(),!0;let n=this.value===void 0?this.initialValueFactory():this.value;return this.value=this.reducer(n,t),!0}get(){if(this.value===void 0)throw new Ve;return this.value}checkpoint(){}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:!Rq(t)||this.snapshotFrequency!==t.snapshotFrequency?!1:this.reducer===t.reducer}};var BE=Symbol.for("langgraph.channel.missing"),$y=class lU extends Et{lc_graph_name="UntrackedValue";guard;_value=BE;initialValueFactory;constructor(t){super(),this.guard=t?.guard??!0,this.initialValueFactory=t?.initialValueFactory,this.initialValueFactory&&(this._value=this.initialValueFactory())}fromCheckpoint(t){return new lU({guard:this.guard,initialValueFactory:this.initialValueFactory})}update(t){if(t.length===0)return!1;if(t.length!==1&&this.guard)throw new Se("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===BE)throw new Ve;return this._value}checkpoint(){}isAvailable(){return this._value!==BE}};var Aa=(e,t)=>e.size===t.size&&[...e].every(r=>t.has(r)),VE=class dU extends Et{lc_graph_name="NamedBarrierValue";names;seen;constructor(t){super(),this.names=t,this.seen=new Set}fromCheckpoint(t){let r=new dU(this.names);return typeof t<"u"&&(r.seen=new Set(t)),r}update(t){let r=!1;for(let i of t)if(this.names.has(i))this.seen.has(i)||(this.seen.add(i),r=!0);else throw new Se(`Value ${JSON.stringify(i)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!Aa(this.names,this.seen))throw new Ve}checkpoint(){return[...this.seen]}consume(){return this.seen&&this.names&&Aa(this.seen,this.names)?(this.seen=new Set,!0):!1}isAvailable(){return!!this.names&&Aa(this.names,this.seen)}},HE=class fU extends Et{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 fU(this.names);if(typeof t<"u"){let[i,n]=t;r.seen=new Set(i),r.finished=n}return r}update(t){let r=!1;for(let i of t)if(this.names.has(i)&&!this.seen.has(i))this.seen.add(i),r=!0;else if(!this.names.has(i))throw new Se(`Value ${JSON.stringify(i)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!this.finished||!Aa(this.names,this.seen))throw new Ve}checkpoint(){return[[...this.seen],this.finished]}consume(){return this.finished&&this.seen&&this.names&&Aa(this.seen,this.names)?(this.seen=new Set,this.finished=!1,!0):!1}finish(){return!this.finished&&this.names&&Aa(this.names,this.seen)?(this.finished=!0,!0):!1}isAvailable(){return this.finished&&!!this.names&&Aa(this.names,this.seen)}};var ZE=Symbol.for("langgraph.state.reduced_value"),xo=class{[ZE]=!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&&ZE in e&&e[ZE]===!0}};var pU=Symbol.for("langgraph.state.untracked_value"),dc=class{[pU]=!0;schema;guard;constructor(e,t){this.schema=e,this.guard=t?.guard??!0}static isInstance(e){return typeof e=="object"&&e!==null&&pU in e}};var GE=Symbol.for("langgraph.state.delta_value"),So=class{[GE]=!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&&GE in e&&e[GE]===!0}};var KE=Symbol.for("langgraph.state.state_schema"),ti=class{[KE]=!0;constructor(e){this.fields=e}getChannels(){let e={};for(let[t,r]of Object.entries(this.fields))if(So.isInstance(r)){let i=wo(r.valueSchema);e[t]=new ky(r.reducer,{snapshotFrequency:r.snapshotFrequency,initialValueFactory:i})}else if(xo.isInstance(r)){let i=wo(r.valueSchema);e[t]=new _o(r.reducer,i)}else if(dc.isInstance(r)){let i=r.schema?wo(r.schema):void 0;e[t]=new $y({guard:r.guard,initialValueFactory:i})}else if(bo(r))e[t]=new Jn(wo(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,i]of Object.entries(this.fields)){let n;if(So.isInstance(i)||xo.isInstance(i)?(n=Ta(i.valueSchema),i.jsonSchemaExtra&&(n={...n??{},...i.jsonSchemaExtra})):dc.isInstance(i)?n=i.schema?Ta(i.schema):void 0:bo(i)&&(n=Ta(i)),n){e[r]=n;let o=!1;So.isInstance(i)||xo.isInstance(i)?o=wo(i.valueSchema)!==void 0:dc.isInstance(i)?o=i.schema?wo(i.schema)!==void 0:!1:o=wo(i)!==void 0,o||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 i;So.isInstance(r)||xo.isInstance(r)?(i=Ta(r.inputSchema),r.jsonSchemaExtra&&(i={...i??{},...r.jsonSchemaExtra})):dc.isInstance(r)?i=r.schema?Ta(r.schema):void 0:bo(r)&&(i=Ta(r)),i&&(e[t]=i)}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,i]of Object.entries(e)){let n=this.fields[r];if(n===void 0){t[r]=i;continue}let o;if(So.isInstance(n)||xo.isInstance(n)){let[a,s]=Pn(i);if(a){o=n.valueSchema;let c=await o["~standard"].validate(s);if(c.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(c.issues)}`);t[r]={[ii]:c.value};continue}o=n.inputSchema}else dc.isInstance(n)?o=n.schema:bo(n)&&(o=n);if(o){let a=await o["~standard"].validate(i);if(a.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(a.issues)}`);t[r]=a.value}else t[r]=i}return t}static isInstance(e){return typeof e=="object"&&e!==null&&KE in e&&e[KE]===!0}};var jq="__remove_all__";function Ca(e,t){let r=Array.isArray(e)?e:[e],i=Array.isArray(t)?t:[t],n=r.map(Nt),o=i.map(Nt);for(let l of n)(l.id===null||l.id===void 0)&&(l.id=Do(),l.lc_kwargs.id=l.id);let a;for(let l=0;l<o.length;l+=1){let d=o[l];(d.id===null||d.id===void 0)&&(d.id=Do(),d.lc_kwargs.id=d.id),tn.isInstance(d)&&d.id==="__remove_all__"&&(a=l)}if(a!=null)return o.slice(a+1);let s=[...n],c=new Map(s.map((l,d)=>[l.id,d])),u=new Set;for(let l of o){let d=c.get(l.id);if(d!==void 0)tn.isInstance(l)?u.add(l.id):(u.delete(l.id),s[d]=l);else{if(tn.isInstance(l))throw new Error(`Attempting to delete a message with an ID that doesn't exist ('${l.id}')`);c.set(l.id,s.length),s.push(l)}}return s.filter(l=>!u.has(l.id))}function WE(e,t){let r=[];for(let s of t)Array.isArray(s)?r.push(...s):r.push(s);let i=e.length>0&&ze.isInstance(e[0])?e:e.map(Nt),n=r.map(Nt),o=new Map;for(let s=0;s<i.length;s+=1){let c=i[s].id;c!=null&&o.set(c,s)}let a=[...i];for(let s of n){let c=s.id;tn.isInstance(s)&&c==="__remove_all__"?(a.length=0,o.clear()):c==null?a.push(s):tn.isInstance(s)?o.has(c)&&(a[o.get(c)]=null,o.delete(c)):o.has(c)?a[o.get(c)]=s:(o.set(c,a.length),a.push(s))}return a.filter(s=>s!==null)}var mU=Tn.custom().default(()=>[]),hU=Tn.custom(),Dq=new xo(mU,{inputSchema:hU,reducer:Ca,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}}),Mq=new So(mU,{inputSchema:hU,reducer:WE,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var zq=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=ao(e);for(let[i,n]of Object.entries(r)){let o=this.get(n);o?.reducer?t[i]=new _o(o.reducer.fn,o.default):t[i]=new Jn(o?.default)}return t}getExtendedChannelSchemas(e,t){if(Object.keys(t).length===0)return e;let r=Object.entries(t).filter(([,o])=>o===!0).sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>`${o}:${a}`).join("|"),i=this._extensionCache.get(r)??new Map;if(i.has(e))return i.get(e);let n=e;if(t.withReducerSchema||t.withJsonSchemaExtrasAsDescription){let o=Object.entries(ao(e)).map(([a,s])=>{let c=this.get(s),u=t.withReducerSchema?c?.reducer?.schema??s:s;if(t.withJsonSchemaExtrasAsDescription&&c?.jsonSchemaExtra){let l=so(u)??so(s),d=JSON.stringify({...c.jsonSchemaExtra,description:l});u=u.describe(`lg:${d}`)}return[a,u]});n=mg(e,Object.fromEntries(o)),yt(n)&&(n._def.unknownKeys="strip")}return t.asPartial&&(n=da(n)),i.set(e,n),this._extensionCache.set(r,i),n}},Qf=new zq;function gU(e,t){if(t.reducer&&!t.default){let r=hg(e);r!=null&&(t.default=r)}if(t.reducer){let r=Object.assign(e,{lg_reducer_schema:t.reducer?.schema??e});return Qf.extend(r,()=>t),r}else return Qf.extend(e,()=>t),e}function fc(e){return e==null?!1:!!(ti.isInstance(e)||fr(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"||iE(t)))}function _U(e){if(typeof e!="object"||e==null)return!1;let t=e,r="state"in t&&fc(t.state),i="stateSchema"in t&&fc(t.stateSchema),n="input"in t&&fc(t.input);return!(!r&&!i&&!n||"input"in t&&t.input!=null&&!fc(t.input)||"output"in t&&t.output!=null&&!fc(t.output))}var ko="__root__",_l="__default_error_handler__",Iy=Symbol.for("langgraph.state.partial"),qE=class extends LE{channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=Qf;_configSchema;_configRuntimeSchema;_interrupt;_writer;_nodeDefaults={};constructor(e,t){super();let r=this._normalizeToStateGraphInit(e,t),i=r.state??r.stateSchema??r.input;if(!i)throw new Sl;let n=this._getChannelsFromSchema(i);this._schemaDefinition=n,ti.isInstance(i)?this._schemaRuntimeDefinition=i:fr(i)&&(this._schemaRuntimeDefinition=i),r.input?ti.isInstance(r.input)?this._inputRuntimeDefinition=r.input:fr(r.input)?this._inputRuntimeDefinition=r.input:this._inputRuntimeDefinition=Iy:this._inputRuntimeDefinition=Iy,r.output?ti.isInstance(r.output)?this._outputRuntimeDefinition=r.output:fr(r.output)?this._outputRuntimeDefinition=r.output:this._outputRuntimeDefinition=this._schemaRuntimeDefinition:this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let o=r.input?this._getChannelsFromSchema(r.input):n,a=r.output?this._getChannelsFromSchema(r.output):n;this._inputDefinition=o,this._outputDefinition=a,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),r.context&&fr(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=Eo(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 Wt({func:(t,r)=>{let i=r?.configurable?.[wl];return e(t,i,r)},name:_l,trace:!1}),metadata:void 0,input:this._schemaDefinition,retryPolicy:void 0,cachePolicy:void 0,isErrorHandler:!0}}_normalizeToStateGraphInit(e,t){if(_U(e)){if(fr(t)||X_.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(fc(e)){if(fr(t)||X_.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(Uq(e))return{state:Lq(e.channels)};throw new Sl}_getChannelsFromSchema(e){if(ti.isInstance(e))return e.getChannels();if(fr(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 Sl("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 i;if(typeof r=="function"?i=r():i=r,this.channels[t]!==void 0){if(!this.channels[t].equals(i)&&i.lc_graph_name!=="LastValue")throw new Error(`Channel "${t}" already exists with a different type.`)}else this.channels[t]=i}}}addNode(...e){function t(i){return i.length>=1&&typeof i[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]).map(([i,n])=>[i,n]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[i,n,o]of r){if(i in this.channels)throw new Error(`${i} 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(i.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."),i in this.nodes)throw new Error(`Node \`${i}\` already present.`);if(i==="__end__"||i==="__start__")throw new Error(`Node \`${i}\` is reserved.`);let a=this._schemaDefinition;o?.input!==void 0&&(a=this._getChannelsFromSchema(o.input)),this._addSchema(a);let s;ue.isRunnable(n)?s=n:typeof n=="function"?s=new Wt({func:n,name:i,trace:!1}):s=mt(n);let c=o?.cachePolicy,u;c!==void 0&&(u=typeof c=="boolean"?c?{}:!1:c);let l;if(o?.errorHandler!==void 0){if(l=`__error_handler__${i}`,l in this.nodes)throw new Error(`Cannot add error handler to node \`${i}\`: the reserved name \`${l}\` 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=o.errorHandler,p={runnable:new Wt({func:(m,h)=>{let g=h?.configurable?.[wl];return f(m,g,h)},name:l,trace:!1}),metadata:void 0,input:a??this._schemaDefinition,retryPolicy:void 0,cachePolicy:void 0,isErrorHandler:!0};this.nodes[l]=p}let d={runnable:s,retryPolicy:o?.retryPolicy,cachePolicy:u,timeout:Eo(o?.timeout),metadata:o?.metadata,input:a??this._schemaDefinition,subgraphs:Wf(s)?[s]:o?.subgraphs,ends:o?.ends,defer:o?.defer,errorHandlerNode:l};this.nodes[i]=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(i=>i===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[i,n,o]of t){if(i in this.nodes)throw new Error(`Node names must be unique: node with the name "${i}" already exists.`);let a=i;this.addNode(i,n,o),r!=null&&this.addEdge(r,a),r=a}return this}compile({checkpointer:e,store:t,cache:r,interruptBefore:i,interruptAfter:n,name:o,description:a,transformers:s}={}){let c=this._createDefaultErrorHandlerSpec();if(c!==void 0){if(_l in this.nodes)throw new Error(`Cannot apply a default error handler: the reserved node name \`${_l}\` is already in use. setNodeDefaults({ errorHandler }) registers a node with that name; rename the conflicting node.`);this.nodes[_l]=c}try{return this._compileResolved({checkpointer:e,store:t,cache:r,interruptBefore:i,interruptAfter:n,name:o,description:a,transformers:s,defaultErrorHandlerNode:c!==void 0?_l:void 0})}finally{c!==void 0&&delete this.nodes[_l]}}_compileResolved({checkpointer:e,store:t,cache:r,interruptBefore:i,interruptAfter:n,name:o,description:a,transformers:s,defaultErrorHandlerNode:c}){this.validate([...Array.isArray(i)?i:[],...Array.isArray(n)?n:[]]);let u=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),l=u.length===1&&u[0]===ko?ko:u,d=Object.keys(this.channels),f=d.length===1&&d[0]===ko?ko:d,p=this._interrupt,m=new vU({builder:this,checkpointer:e,interruptAfter:n,interruptBefore:i,autoValidate:!1,nodes:{},channels:{...this.channels,[rt]:new ei},inputChannels:rt,outputChannels:l,streamChannels:f,streamMode:"updates",store:t,cache:r,name:o,description:a,userInterrupt:p,streamTransformers:s});m.attachNode(rt);let h=this._nodeDefaults,g=h.retryPolicy!==void 0||h.cachePolicy!==void 0||h.timeout!==void 0||c!==void 0;for(let[_,v]of Object.entries(this.nodes)){let x=v.isErrorHandler===!0,S=g?{...v,retryPolicy:v.retryPolicy??h.retryPolicy,cachePolicy:x||v.cachePolicy===!1?void 0:v.cachePolicy??h.cachePolicy,timeout:v.timeout??h.timeout,errorHandlerNode:!x&&c!==void 0&&v.errorHandlerNode===void 0?c:v.errorHandlerNode}:v;m.attachNode(_,S)}m.attachBranch(rt,Ty,yU(),{withReader:!1});for(let[_]of Object.entries(this.nodes))m.attachBranch(_,Ty,yU(),{withReader:!1});for(let[_,v]of this.edges)m.attachEdge(_,v);for(let[_,v]of this.waitingEdges)m.attachEdge(_,v);for(let[_,v]of Object.entries(this.branches))for(let[x,S]of Object.entries(v))m.attachBranch(_,x,S);return m.validate()}};function Lq(e){let t={};for(let[r,i]of Object.entries(e))r===ko?t[r]=Y_(i):t[r]=Y_(i);return t}var vU=class extends UE{description;_metaRegistry=Qf;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 i(c){if(Ft(c))return c.graph===Dr.PARENT?null:c._updateAsTuples();if(Array.isArray(c)&&c.length>0&&c.some(u=>Ft(u))){let u=[];for(let l of c)if(Ft(l)){if(l.graph===Dr.PARENT)continue;u.push(...l._updateAsTuples())}else u.push([ko,l]);return u}else if(c!=null)return[[ko,c]];return null}let n=e,o=async c=>{if(c==null||c.length===0)return c;let u=this.builder._schemaRuntimeDefinition;if(ti.isInstance(u)){let l=new Set(u.getChannelKeys());return Promise.all(c.map(async([d,f])=>{if(!l.has(d))return[d,f];let p=await u.validateInput({[d]:f});return[d,Object.prototype.hasOwnProperty.call(p,d)?p[d]:f]}))}if(fr(u)){let l=new Set(Object.keys(ao(u)));if(c.filter(([p])=>l.has(p)).length===0)return c;let d=da(this._metaRegistry.getExtendedChannelSchemas(u,{withReducerSchema:!0})),f=da(u);return c.map(([p,m])=>{if(!l.has(p))return[p,m];let[h,g]=Pn(m);if(h){let v=la(f,{[p]:g});return[p,Object.prototype.hasOwnProperty.call(v,p)?{[ii]:v[p]}:m]}let _=la(d,{[p]:m});return[p,Object.prototype.hasOwnProperty.call(_,p)?_[p]:m]})}return c};async function a(c){if(c){if(Ft(c))return c.graph===Dr.PARENT?null:o(c._updateAsTuples().filter(([u])=>r.includes(u)));if(Array.isArray(c)&&c.length>0&&c.some(Ft)){let u=[];for(let l of c)if(Ft(l)){if(l.graph===Dr.PARENT)continue;u.push(...l._updateAsTuples().filter(([d])=>r.includes(d)))}else{let d=await a(l);d&&u.push(...d??[])}return o(u)}else{if(typeof c=="object"&&!Array.isArray(c))return o(Object.entries(c).filter(([u])=>r.includes(u)));{let u=Array.isArray(c)?"array":typeof c;throw new Se(`Expected node "${n.toString()}" to return an object or an array containing at least one Command object, received ${u}`,{lc_error_code:"INVALID_GRAPH_NODE_RETURN_VALUE"})}}}else return null}let s=[{value:qr,mapper:new Wt({func:r.length&&r[0]===ko?i:a,trace:!1,recurse:!1})}];if(e==="__start__")this.nodes[e]=new Yn({tags:[kt],triggers:[rt],channels:[rt],writers:[new vt(s,[kt])]});else{let c=t?.input??this.builder._schemaDefinition,u=Object.fromEntries(Object.keys(this.builder._schemaDefinitions.get(c)).map(m=>[m,m])),l=Object.keys(u).length===1&&ko in u,d=`branch:to:${e}`;this.channels[d]=t?.defer?new aE:new ei(!1);let f=t?.cachePolicy,p=f===!1?void 0:f;this.nodes[e]=new Yn({triggers:[d],channels:l?Object.keys(u):u,writers:[new vt(s,[kt])],mapper:l?void 0:m=>Object.fromEntries(Object.entries(m).filter(([h])=>h in u)),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 vt([{channel:`branch:to:${t}`,value:null}],[kt]));else if(Array.isArray(e)){let r=`join:${e.join("+")}:${t}`;this.channels[r]=this.builder.nodes[t].defer?new HE(new Set(e)):new VE(new Set(e)),this.nodes[t].triggers.push(r);for(let i of e)this.nodes[i].writers.push(new vt([{channel:r,value:i}],[kt]))}}}attachBranch(e,t,r,i={withReader:!0}){let n=async(o,a)=>{let s=o.filter(u=>u!==ct);if(!s.length)return;let c=s.map(u=>Ct(u)?u:{channel:u==="__end__"?u:`branch:to:${u}`,value:e});await vt.doWrite({...a,tags:(a.tags??[]).concat([kt])},c)};this.nodes[e].writers.push(r.run(n,i.withReader?o=>xL.doRead(o,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(ti.isInstance(t)){if(Ft(e)){let n=e;return e.update&&(n.update=await t.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),n}return await t.validateInput(e)}if(t===Iy&&ti.isInstance(r)){if(Ft(e)){let n=e;return e.update&&(n.update=await r.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),n}return await r.validateInput(e)}let i=(()=>{let n=o=>{if(o!=null)return this._metaRegistry.getExtendedChannelSchemas(o,{withReducerSchema:!0})};if(fr(t))return n(t);if(t===Iy)return fr(r)?da(n(r)):void 0})();if(Ft(e)){let n=e;if(e.update&&i!=null){let o=Array.isArray(e.update)?Object.fromEntries(e.update):e.update,a=la(i,o);n.update=Object.fromEntries(Object.keys(o).map(s=>[s,a[s]]))}return n}return i!=null?la(i,e):e}isInterrupted(e){return Ma(e)}async _validateContext(e){let t=this.builder._configRuntimeSchema;return fr(t)&&la(t,e),e}};function Uq(e){return typeof e=="object"&&e!==null&&e.channels!==void 0}function Fq(e){if(Ct(e))return[e];let t=[];Ft(e)?t.push(e):Array.isArray(e)&&t.push(...e.filter(Ft));let r=[];for(let i of t){if(i.graph===Dr.PARENT)throw new dp(i);Ct(i.goto)||typeof i.goto=="string"?r.push(i.goto):Array.isArray(i.goto)&&r.push(...i.goto)}return r}function yU(){return new zE({path:new Wt({func:Fq,tags:[kt],trace:!1,recurse:!1,name:"<control_branch>"})})}var Bq=class extends qE{constructor(){super({channels:{__root__:{reducer:Ca,default:()=>[]}}})}};function Vq(e,t){let{stateKey:r,...i}=t??{},n=ul(i),o=r??"messages";r===null&&(o=void 0);let a=Nt(e);if(!a.id)throw new Error("Message ID is required.");let s=Array.isArray(n.callbacks)?n.callbacks:typeof n.callbacks<"u"?n.callbacks.handlers:[],c=s.find(l=>"name"in l&&l.name==="StreamMessagesHandler"),u=s.find(l=>"name"in l&&l.name==="StreamProtocolMessagesHandler");if(c||u){let l=n.metadata??{},d=(l.langgraph_checkpoint_ns??"").split("|");c?c._emit([d,l],a,void 0,!1):u&&u.emitFinalMessage([d,l],a,void 0,!1)}return o&&n.configurable?.__pregel_send?.([[o,a]]),a}function Hq(e,t){let r=typeof e=="string"?{name:e,retry:void 0,cachePolicy:void 0,timeout:void 0}:e,{name:i,retry:n}=r,o=Eo(r.timeout);if(kE(t)||$E(t))throw new Error("Generators are disallowed as tasks. For streaming responses, use config.write.");let a=r.cachePolicy??("cache"in r?r.cache:void 0),s;return typeof a=="boolean"?s=a?{}:void 0:s=a,(...c)=>OL({func:t,name:i,retry:n,cache:s,timeout:o},...c)}var bU=function(t,r){let{name:i,checkpointer:n,store:o,cache:a}=typeof t=="string"?{name:t,checkpointer:void 0,store:void 0}:t,s=Eo(typeof t=="string"?void 0:t.timeout);if(kE(r)||$E(r))throw new Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let c="updates",u=CL(i,r);function l(m){return typeof m=="object"&&m!==null&&"__lg_type"in m&&m.__lg_type==="__pregel_final"}let d=new Wt({name:"pluckReturnValue",func:m=>l(m)?m.value:m}),f=new Wt({name:"pluckSaveValue",func:m=>l(m)?m.save:m}),p=new Yn({bound:u,triggers:[rt],channels:[rt],timeout:s,writers:[new vt([{channel:ct,value:qr,mapper:d},{channel:Po,value:qr,mapper:f}],[kt])]});return new Sy({name:i,checkpointer:n,nodes:{[i]:p},channels:{[rt]:new ei,[ct]:new Jn,[Po]:new Jn},inputChannels:rt,outputChannels:ct,streamChannels:ct,streamMode:c,store:o,cache:a})};bU.final=function({value:t,save:r}){return{value:t,save:r,__lg_type:"__pregel_final"}};function Zq(){return Ue.getRunnableConfig().configurable?.[Ao]}var Gq=Hf.Root({messages:Hf({reducer:Ca,default:()=>[]})}),wU={reducer:{fn:Ca},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},Kq=Kt.object({messages:gU(Kt.custom(),wU)});function Wq(e){let t=Ue.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{rt as a,ct as b,qe as c,Ey as d,nT as e,Na as f,Ct as g,kU as h,Ma as i,Dr as j,Ft as k,pn as l,ap as m,Ay as n,za as o,sp as p,cp as q,Li as r,up as s,lp as t,IU as u,dp as v,Cy as w,No as x,Ui as y,fp as z,EU as A,pp as B,Ve as C,Se as D,TU as E,Oy as F,AU as G,Sl as H,CU as I,jT as J,Ot as K,Vi as L,Zy as M,n2 as N,ui as O,GT as P,Tl as Q,KT as R,lt as S,Pt as T,xc as U,Le as V,$c as W,nt as X,Dn as Y,Ba as Z,Ha as _,Za as $,Zi as aa,VA as ba,lr as ca,Qo as da,_s as ea,na as fa,Oh as ga,Ph as ha,Rs as ia,et as ja,yt as ka,Hr as la,so as ma,hg as na,U as oa,Kt as pa,zt as qa,mr as ra,Ng as sa,D5 as ta,ef as ua,Fg as va,n$ as wa,kD as xa,$D as ya,F5 as za,B5 as Aa,o$ as Ba,_a as Ca,Kg as Da,ya as Ea,e8 as Fa,x$ as Ga,Ku as Ha,Sf as Ia,U$ as Ja,Tn as Ka,gK as La,wK as Ma,AK as Na,DK as Oa,sc as Pa,Wn as Qa,H_ as Ra,Xz as Sa,al as Ta,K_ as Ua,eL as Va,Et as Wa,_o as Xa,Hf as Ya,xW as Za,SW as _a,Q_ as $a,kW as ab,sE as bb,cE as cb,ll as db,uE as eb,Cn as fb,ry as gb,pE as hb,Zf as ib,Gf as jb,mE as kb,hE as lb,ny as mb,yE as nb,fL as ob,vE as pb,SE as qb,Wt as rb,LE as sb,bo as tb,Nq as ub,Ta as vb,wo as wb,ky as xb,$y as yb,xo as zb,dc as Ab,So as Bb,ti as Cb,jq as Db,Ca as Eb,WE as Fb,Dq as Gb,Mq as Hb,Qf as Ib,gU as Jb,qE as Kb,vU as Lb,Bq as Mb,Vq as Nb,Hq as Ob,bU as Pb,Zq as Qb,Gq as Rb,wU as Sb,Kq as Tb,Wq as Ub};