@opentiny/next-sdk 0.1.15-beta.1 → 0.1.15

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 (40) hide show
  1. package/agent/AgentModelProvider.ts +1 -490
  2. package/agent/type.ts +2 -8
  3. package/dist/WebMcpClient.d.ts +26 -165
  4. package/dist/WebMcpServer.d.ts +147 -36
  5. package/dist/agent/AgentModelProvider.d.ts +1 -35
  6. package/dist/agent/type.d.ts +2 -8
  7. package/dist/index.es.dev.js +11175 -14893
  8. package/dist/index.es.js +18206 -20985
  9. package/dist/index.js +320 -2411
  10. package/dist/index.umd.dev.js +11200 -14918
  11. package/dist/index.umd.js +71 -111
  12. package/dist/{mcpsdk@1.24.3.dev.js → mcpsdk@1.23.0.dev.js} +6652 -8271
  13. package/dist/{mcpsdk@1.24.3.es.dev.js → mcpsdk@1.23.0.es.dev.js} +6641 -8260
  14. package/dist/mcpsdk@1.23.0.es.js +15584 -0
  15. package/dist/mcpsdk@1.23.0.js +43 -0
  16. package/dist/transport/ExtensionPageServerTransport.d.ts +2 -1
  17. package/dist/webagent.dev.js +19914 -23355
  18. package/dist/webagent.es.dev.js +19889 -23330
  19. package/dist/webagent.es.js +15583 -18140
  20. package/dist/webagent.js +65 -105
  21. package/dist/webmcp-full.dev.js +7263 -8880
  22. package/dist/webmcp-full.es.dev.js +7261 -8878
  23. package/dist/webmcp-full.es.js +9267 -10421
  24. package/dist/webmcp-full.js +32 -32
  25. package/dist/webmcp.dev.js +22 -14
  26. package/dist/webmcp.es.dev.js +20 -12
  27. package/dist/webmcp.es.js +179 -172
  28. package/dist/webmcp.js +1 -1
  29. package/dist/zod@3.25.76.dev.js +32 -30
  30. package/dist/zod@3.25.76.es.dev.js +30 -28
  31. package/dist/zod@3.25.76.es.js +145 -143
  32. package/dist/zod@3.25.76.js +1 -1
  33. package/package.json +8 -9
  34. package/transport/ExtensionPageServerTransport.ts +4 -2
  35. package/agent/utils/generateReActPrompt.ts +0 -55
  36. package/agent/utils/parseReActAction.ts +0 -34
  37. package/dist/agent/utils/generateReActPrompt.d.ts +0 -9
  38. package/dist/agent/utils/parseReActAction.d.ts +0 -14
  39. package/dist/mcpsdk@1.24.3.es.js +0 -16781
  40. package/dist/mcpsdk@1.24.3.js +0 -43
package/dist/webmcp.js CHANGED
@@ -1 +1 @@
1
- (function(p,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("ajv"),require("@modelcontextprotocol/sdk/types.js"),require("@modelcontextprotocol/sdk/client/index.js"),require("@modelcontextprotocol/sdk/client/sse.js"),require("@modelcontextprotocol/sdk/client/streamableHttp.js"),require("@modelcontextprotocol/sdk/client/websocket.js"),require("@modelcontextprotocol/sdk/client/auth.js"),require("@modelcontextprotocol/sdk/server/mcp.js"),require("zod"),require("@modelcontextprotocol/sdk/shared/uriTemplate.js"),require("@modelcontextprotocol/sdk/server/completable.js"),require("@modelcontextprotocol/sdk/shared/metadataUtils.js")):typeof define=="function"&&define.amd?define(["exports","ajv","@modelcontextprotocol/sdk/types.js","@modelcontextprotocol/sdk/client/index.js","@modelcontextprotocol/sdk/client/sse.js","@modelcontextprotocol/sdk/client/streamableHttp.js","@modelcontextprotocol/sdk/client/websocket.js","@modelcontextprotocol/sdk/client/auth.js","@modelcontextprotocol/sdk/server/mcp.js","zod","@modelcontextprotocol/sdk/shared/uriTemplate.js","@modelcontextprotocol/sdk/server/completable.js","@modelcontextprotocol/sdk/shared/metadataUtils.js"],O):(p=typeof globalThis<"u"?globalThis:p||self,O(p.WebMCP={},p.MCPSDK,p.MCPSDK,p.MCPSDK,p.MCPSDK,p.MCPSDK,p.websocket_js,p.MCPSDK,p.MCPSDK,p.Zod,p.MCPSDK,p.MCPSDK,p.MCPSDK))})(this,(function(p,O,w,F,N,z,oe,he,$,fe,pe,xe,_e){"use strict";function W(){const r=["224340fQYLJj","function","onmessage","port2","341XVdnBD","313767JEBgqL","950bpstaX","1354759gUhUbE","wRKyh","onclose","2044SvCTUj","endpoint","24msSkHx","164VuWYGY","mOWMr","EkZCC","addEventListener","postMessage","120705iyGzUz","8878392ivIdKn","close","_listen","3619482FaLQHc","start","_endpoint","kgkem","bzNYT","MessageChannel transport error: ","stringify","onmessageerror","HvyCv","undefined","Jwyua","message","_globalObject","parse","authInfo","thraG","220pGvxgp","_port","EGhzU","onerror","data","MhriV"];return W=function(){return r},W()}(function(r,e){const t=y,n=y,s=r();for(;;)try{if(parseInt(t(417))/1*(parseInt(t(421))/2)+parseInt(t(433))/3+parseInt(t(424))/4*(-parseInt(n(429))/5)+parseInt(n(423))/6*(-parseInt(n(418))/7)+-parseInt(n(430))/8+-parseInt(t(416))/9*(-parseInt(t(405))/10)+-parseInt(t(415))/11*(-parseInt(t(411))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(W,650197);const ie=()=>{const r=y,e={EGhzU:function(t,n){return t!==n},kIrDB:"undefined",llYQe:function(t,n){return t!==n},PZfJg:function(t,n){return t(n)},Jwyua:"return this"};return typeof globalThis<"u"?globalThis:e[r(407)](typeof window,e.kIrDB)?window:e.llYQe(typeof global,e.kIrDB)?global:typeof self!==r(398)?self:e.PZfJg(Function,e[r(399)])()},ve=(r,e,t)=>{const n=y,s=y,o={};o[n(410)]=s(398),o.dBkaX=function(i,l){return i===l},o[s(393)]="function";const a=o;typeof window!==a[s(410)]?r.postMessage(e,"*",t):s(428)in r&&a.dBkaX(typeof r.postMessage,a[n(393)])&&r.postMessage(e,t)},ge=(r,e)=>{const t=y,n=y,s={};s.MbsGh="addEventListener",s.PPniK=function(a,i){return a===i},s[t(419)]=n(412),s[n(404)]="onmessage",s[t(397)]="undefined";const o=s;o.MbsGh in r&&o.PPniK(typeof r[t(427)],o.wRKyh)?r[t(427)](t(400),e):o.thraG in r&&typeof r[n(413)]!==o[n(397)]&&(r.onmessage=e)};class A{constructor(e){const t=y;this[t(406)]=e}async start(){const e=y,t=y;this[e(406)]&&(this[e(406)][e(413)]=n=>{var s,o;const a=e,i=t;try{const l=w.JSONRPCMessageSchema[a(402)](n.data[a(400)]);(s=this[a(413)])==null||s.call(this,l,n[i(409)].extra)}catch(l){const c=new Error("MessageChannel failed to parse message: "+l);(o=this[i(408)])==null||o.call(this,c)}},this._port[e(396)]=n=>{var s;const o=t,a=t,i=new Error(o(394)+JSON[a(395)](n));(s=this.onerror)==null||s.call(this,i)},this[e(406)][e(434)]())}async send(e,t){const n={lEyuq:function(s){return s()},YihNw:function(s,o){return s(o)}};return new Promise((s,o)=>{var a;const i=y,l=y;try{const c={};c[i(403)]=t?.[i(403)];const d={};d[l(400)]=e,d.extra=c,this[l(406)]&&this[i(406)].postMessage(d),n.lEyuq(s)}catch(c){const d=c instanceof Error?c:new Error(n.YihNw(String,c));(a=this[l(408)])==null||a.call(this,d),o(d)}})}async close(){var e,t;const n=y,s=y;(e=this._port)==null||e[n(431)](),this._port=void 0,(t=this[s(420)])==null||t.call(this)}}class ee extends A{constructor(e,t=ie()){const n=y,s=y,o={EkZCC:function(i,l,c,d){return i(l,c,d)}};super(),this[n(391)]=e,this[s(401)]=t;const a=new MessageChannel;this[s(406)]=a.port1,o[s(426)](ve,this[n(401)],{endpoint:this[s(391)]},[a[s(414)]])}}class te extends A{constructor(e,t=ie()){const n=y,s={mOWMr:function(o,a){return o===a},kgkem:function(o,a,i){return o(a,i)}};super(),this._endpoint=e,this._globalObject=t,this[n(432)]=new Promise(o=>{const a=n,i=n;s[a(392)](ge,this[i(401)],l=>{const c=i,d=i;l.data&&s[c(425)](l.data[d(422)],this[d(391)])&&(this[d(406)]=l.ports[-1*4852+1*1601+3251],o())})})}async listen(){return this[y(432)]}}function y(r,e){const t=W();return y=function(n,s){return n=n-(17*-491+-669+9407),t[n]},y(r,e)}const me=()=>{const r=new MessageChannel;return[new A(r.port1),new A(r.port2)]};(function(r,e){const t=m,n=m,s=r();for(;;)try{if(parseInt(t(355))/1+-parseInt(t(356))/2*(-parseInt(t(373))/3)+-parseInt(t(337))/4+parseInt(n(357))/5+-parseInt(n(389))/6*(-parseInt(t(396))/7)+parseInt(n(325))/8*(parseInt(t(382))/9)+-parseInt(t(366))/10===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(B,-763475+-52067*10+1724410);const be=async(r,e,t)=>{var n;const s=m,o=m,a={};a[s(345)]="tools/list",a.rqstG="tools/call",a.WqUnk="resources/list",a[s(329)]=o(358),a[s(365)]=s(335),a.ookoz="resources/unsubscribe",a[s(385)]=s(340),a.VTIWq="prompts/list",a.SkoRK=s(376),a.QUtUV=s(388),a.XtowM=o(332);const i=a,{id:l,method:c,params:d}=t;let u={};switch(c){case i[o(345)]:u=await e.listTools(d);break;case i.rqstG:u=await e.callTool(d);break;case i[s(334)]:u=await e[s(350)](d);break;case i[o(329)]:u=await e.listResourceTemplates(d);break;case s(372):u=await e[s(383)](d);break;case i.HgYgW:u=await e.subscribeResource(d);break;case i.ookoz:u=await e.unsubscribeResource(d);break;case i[s(385)]:u=await e.getPrompt(d);break;case i.VTIWq:u=await e.listPrompts(d);break;case i[s(344)]:u=await e[s(376)]();break;case i.QUtUV:u=await e.complete(d);break;case s(390):u=await e[s(336)](d?.level);break}const h={};h[s(361)]=u,h[s(394)]=i[s(364)],h.id=l,await((n=r?.transport)==null?void 0:n[s(392)](h))},we=async(r,e,t)=>{var n;const s=m,o=m,a={};a.jQBBS="sampling/createMessage",a.EZqgC="elicitation/create",a[s(370)]=o(376),a.aVeaL=o(332);const i=a,{id:l,method:c,params:d}=t;let u={};switch(c){case s(368):const f={};f.method=c,f[o(367)]=d,u=await e.request(f,w.ListRootsResultSchema);break;case i[o(391)]:const _={};_.method=c,_[o(367)]=d,u=await e[o(381)](_,w.CreateMessageResultSchema);break;case i.EZqgC:const x={};x.method=c,x.params=d,u=await e.request(x,w.ElicitResultSchema);break;case i[o(370)]:const v={};v.method=c,u=await e[o(381)](v,w.EmptyResultSchema);break}const h={};return h[o(361)]=u,h.jsonrpc=i[o(387)],h.id=l,await((n=r?.[s(371)])==null?void 0:n.send(h)),u},ye=(r,e)=>{const t=m,n={gXsjT:function(o,a){return o===a},oegpC:t(351),lZOUC:function(o,a,i,l){return o(a,i,l)},ifIKG:"2.0"},s=r._onrequest;r._onrequest=async(o,a)=>{var i,l,c,d,u;const h=t,f=t,{id:_,method:x}=o;try{n[h(333)](x,n.oegpC)?await s[h(386)](r,o,a):await n.lZOUC(be,r,e,o)}catch(v){const{code:g,message:R,data:P}=v;try{if(g){const I={};I.code=g,I.message=R,I.data=P;const k={};k.error=I,k[h(394)]=n[f(331)],k.id=_,await((i=r?.transport)==null?void 0:i.send(k))}else(c=(l=r?.[f(371)])==null?void 0:l.onerror)==null||c.call(l,v)}catch(I){(u=(d=r?.[h(371)])==null?void 0:d.onerror)==null||u.call(d,I)}}}},Ce=(r,e)=>{const t=m,n=m,s={};s[t(363)]=function(a,i){return a!==i},s[t(398)]=t(353),s.hzhyg="notifications/cancelled";const o=s;r._onnotification=async a=>{var i,l;const c=t,d=n,{method:u,params:h}=a;if(o[c(363)](u,o[d(398)])&&(o[c(363)](u,o.hzhyg)||h?.forward))try{await e.notification(a)}catch(f){(l=(i=r?.transport)==null?void 0:i.onerror)==null||l.call(i,f)}}},Ie=(r,e)=>async t=>{var n,s,o,a,i;const l=m,c=m,d={};d.SEmWX=l(332);const u=d;try{return await we(r,e,t)}catch(h){const{code:f,message:_,data:x}=h;try{if(f){const v={};v[c(377)]=f,v.message=_,v.data=x;const g={};g[c(348)]=v,g.jsonrpc=u[l(338)],g.id=t.id,await((n=r?.transport)==null?void 0:n[c(392)](g))}else(o=(s=r?.transport)==null?void 0:s[c(339)])==null||o.call(s,h)}catch(v){(i=(a=r?.[l(371)])==null?void 0:a[c(339)])==null||i.call(a,v)}}},Se=(r,e)=>async t=>{var n,s,o;const a=m,i=m,l={};l.dtUgZ=function(h,f){return h!==f},l.jgCIb=a(353),l.uUjKY="2.0";const c=l,{method:d,params:u}=t;if(c.dtUgZ(d,c.jgCIb)&&(d!==a(400)||u?.forward))try{const h={...t};h[a(394)]=c[i(352)],await((n=e?.[a(371)])==null?void 0:n[a(392)](h))}catch(h){(o=(s=r?.[a(371)])==null?void 0:s[i(339)])==null||o.call(s,h)}};function m(r,e){const t=B();return m=function(n,s){return n=n-(-1017+-1439*-1+-97),t[n]},m(r,e)}const Re=(r,e)=>async t=>{var n,s,o,a,i,l;const c=m,d=m,u={};u[c(401)]=d(332);const h=u;try{await((n=e?.transport)==null?void 0:n.send(t))}catch(f){const{code:_,message:x,data:v}=f;try{if(_){const g={};g.code=_,g[c(399)]=x,g.data=v;const R={};R[c(348)]=g,R[c(394)]=h.OhJjz,R.id=t.id,await((s=r?.[c(371)])==null?void 0:s.send(R))}else(a=(o=r?.transport)==null?void 0:o[d(339)])==null||a.call(o,f)}catch(g){(l=(i=r?.transport)==null?void 0:i.onerror)==null||l.call(i,g)}}},ne=()=>{const r=m,e=m,t={vnkqu:function(c,d){return c!==d},wxDWr:function(c,d){return c(d)},GdkkV:function(c,d){return c===d}},n=[],s=(c,d)=>{const u=m,h=m;if(d){const f=[];for(const _ of n)try{f.push(_(c,d))}catch{}for(const _ of f)if(t[u(379)](_,null))return _}else for(const f of n)try{t[h(343)](f,c)}catch{}},o=c=>{const d=m;t[d(384)](typeof c,d(369))&&!n.includes(c)&&n.push(c)},a=c=>{const d=n.indexOf(c);d!==-1&&n.splice(d,1*-6854+-264+7119)},i=()=>{const c=m;n[c(374)]=7102*1+5522+-526*24},l={};return l[r(346)]=s,l[e(330)]=o,l.removeListener=a,l[r(359)]=i,l},Te=r=>{const e=m,t=m,n={xwPeb:function(s){return s()},Mfvzm:function(s){return s()}};{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[e(326)](ne);r._onresponse=s,r[e(395)]=o,r.removeResponseListener=a,r.clearResponseListener=i}{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[t(326)](ne);r[t(328)]=s,r.addRequestListener=o,r[t(354)]=a,r[t(341)]=i}{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[e(375)](ne);r[e(342)]=s,r[e(327)]=o,r.removeNotificationListener=a,r.clearNotificationListener=i}};function B(){const r=["uUjKY","notifications/initialized","removeRequestListener","96194JysfjF","36346SGEWAV","1357830AJaOeY","resources/templates/list","clearListener","iQqcJ","result","tqDZP","sSeCz","XtowM","HgYgW","3913230mjiatC","params","roots/list","function","bfmJT","transport","resources/read","27FNuDmk","length","Mfvzm","ping","code","_onresponse","vnkqu","cjSoZ","request","9gIMIPC","readResource","GdkkV","ptMjy","call","aVeaL","completion/complete","5035122lFbpzR","logging/setLevel","jQBBS","send","_requestHandlers","jsonrpc","addResponseListener","7SpcenI","ElOQH","MDIkN","message","notifications/cancelled","OhJjz","clear","672216JzFEyR","xwPeb","addNotificationListener","fallbackRequestHandler","sYzPD","addListener","ifIKG","2.0","gXsjT","WqUnk","resources/subscribe","setLoggingLevel","2491772kFUWFh","SEmWX","onerror","prompts/get","clearRequestListener","fallbackNotificationHandler","wxDWr","SkoRK","uTeHc","handleListener","Zybtx","error","originalOnResponse","listResources","initialize"];return B=function(){return r},B()}const ke=(r,{beforeInit:e,afterInit:t}={})=>{const n=m,s=m,o={tqDZP:function(i,l){return i===l},cjSoZ:"function",iQqcJ:n(378),Zybtx:function(i,l){return i(l)},ElOQH:function(i){return i()}},a=new Map(r._notificationHandlers);r[n(393)][n(402)](),r._notificationHandlers[n(402)](),o.tqDZP(typeof e,o[n(380)])&&e(),o[n(362)](r._onresponse.name,o[n(360)])&&(r[s(349)]=r._onresponse),o[n(347)](Te,r),r.addResponseListener(i=>{const l=s;r.originalOnResponse[l(386)](r,i)}),o.tqDZP(typeof t,o[s(380)])&&o[n(397)](t),r[s(327)](i=>{const{method:l}=i,c=a.get(l);o.tqDZP(typeof c,o.cjSoZ)&&c(i)})},Pe=q,qe=q;(function(r,e){const t=q,n=q,s=r();for(;;)try{if(-parseInt(t(393))/1+parseInt(t(397))/2*(-parseInt(t(400))/3)+-parseInt(n(398))/4+parseInt(t(390))/5*(parseInt(n(388))/6)+-parseInt(t(389))/7+-parseInt(t(402))/8*(-parseInt(n(395))/9)+parseInt(n(399))/10*(parseInt(n(385))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Z,-1*-881393+2*180895+1*-644809);function q(r,e){const t=Z();return q=function(n,s){return n=n-(-1861+-499*4+4241),t[n]},q(r,e)}function Z(){const r=["toString","getRandomValues","2101mUsYMI","EQHzo","padStart","30UvDAkd","1609706yzlqYx","974735GrhZVO","randomUUID","REzPF","562771BvAnoG","dHTfU","2047455boiYXf","randomBytes","14664qHAdbF","3772144jLpQch","52310AkWksx","318MkjaVb","from","40WRwnSc"];return Z=function(){return r},Z()}const Le=()=>{const r=q,e=q,t={};t.REzPF=function(s,o){return s&o},t.suJHI=function(s,o){return s===o},t[r(386)]=function(s,o){return s&o},t[e(394)]="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";const n=t;return n.suJHI(typeof crypto,"object")&&crypto.randomUUID?crypto[e(391)]():n.dHTfU.replace(/[xy]/g,s=>{const o=r,a=r,i=n[o(392)](crypto[o(384)](new Uint8Array(8663+2*-4331))[741*2+-1385*-2+4252*-1],15);return(n.suJHI(s,"x")?i:n[a(386)](i,-4377+4*1095)|5079+461*-11).toString(9449+4*-461+-7589)})},Me=r=>{const e=q,t=q,n=new Uint8Array(r);return crypto.getRandomValues(n),Array[e(401)](n,s=>s[t(403)](-3*1739+-6509+2*5871)[e(387)](2,"0")).join("")},U={};U[Pe(391)]=Le,U[qe(396)]=Me;const S=L;(function(r,e){const t=L,n=L,s=r();for(;;)try{if(parseInt(t(521))/1*(parseInt(n(499))/2)+parseInt(n(543))/3*(parseInt(n(514))/4)+parseInt(t(502))/5*(parseInt(n(539))/6)+parseInt(t(553))/7+parseInt(t(516))/8*(-parseInt(t(518))/9)+-parseInt(t(531))/10+-parseInt(t(545))/11*(parseInt(t(541))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Y,1472653*1+-2*-897917+-2275789);const He=(r,e)=>{const t=L,n=L,s={FyYHt:function(l,c,d){return l(c,d)},Fxtoq:function(l,c,d){return l(c,d)}};ye(r,e),Ce(r,e);const o=Ie(e,r),a=s[t(510)](Re,e,r),i=s[n(549)](Se,e,r);e[n(537)](o),e[t(519)](a),e.addNotificationListener(i),r[n(556)]=()=>{const l=n;e.removeRequestListener(o),e[l(530)](a),e[l(529)](i)}},se=(r,e,t)=>{const n=L,s={pMiva:function(i,l){return i instanceof l},TeTEy:n(546),fyZbd:function(i,l,c){return i(l,c)}},o=()=>{var i;const l=n;s.pMiva(t,N.SSEClientTransport)&&((i=t._eventSource)==null||i.addEventListener(s[l(547)],()=>{var c;const d=l;(c=t[d(509)])==null||c[d(546)]()})),He(r,e)},a={};a.afterInit=o,s.fyZbd(ke,e,a)},ae=(r,e=U.randomUUID())=>{const t=L,n=L,s={OfssH:function(d,u,h){return d(u,h)}},o={};o[t(528)]=e;const a=o,i={};i[t(528)]=e;const l={};l[n(558)]=i,l[t(534)]=t(524);const c={requestInit:l,eventSourceInit:{async fetch(d,u){const h=t,f=n,_=new Headers(u?.[h(558)]||{});Object.entries(a)[f(498)](([v,g])=>{_[f(527)](v,g)});const x={...u};return x[f(558)]=_,s.OfssH(fetch,d,x)},withCredentials:!0}};return r&&(c.requestInit[t(558)].Authorization=t(533)+r,a.Authorization="Bearer "+r),c},ce=(r,e=U[S(517)]())=>{const t=S,n=S,s={};s.nwQhY="include";const o=s,a={};a["stream-session-id"]=e;const i={};i.headers=a,i.credentials=o[t(520)];const l={};l[t(544)]=i;const c=l;return r&&(c.requestInit.headers[n(552)]=n(533)+r),c},re=async(r,e,t)=>{const n=S,s=S,o={CFfFC:function(i){return i()},egwVO:function(i,l,c,d){return i(l,c,d)}},a=o.CFfFC(t);try{return await r[n(538)](a),a}catch(i){if(i instanceof he.UnauthorizedError){const l=await e();return await a[s(505)](l),await o[n(525)](re,r,e,t)}else throw i}};function L(r,e){const t=Y();return L=function(n,s){return n=n-498,t[n]},L(r,e)}const le=(r,e)=>{const t=S,n=S,s={};s.RsKXs=function(a,i){return a in i},s.PBhps="waitForOAuthCode",s[t(535)]="function",s[t(507)]="waitForOAuthCode need to be provided when authProvider is provided";const o=s;if(o.RsKXs(o[n(551)],r))return r[n(523)];if(typeof e===o.yTKoP)return e;throw new Error(o.RZhOv)},Ue=async r=>{const e=S,t=S,n={TFSRn:function(b,M,H){return b(M,H)},HwvVa:"mcp-sse-proxy-client",ufTHS:function(b){return b()},WIVYl:function(b,M,H,V){return b(M,H,V)},jniGY:"sessionId"},{client:s,url:o,token:a,sessionId:i,authProvider:l,requestInit:c,eventSourceInit:d,waitForOAuthCode:u}=r,h={};h.authProvider=l,h.requestInit=c,h.eventSourceInit=d;const f=h,_=i||U.randomUUID(),x=n[e(506)](ae,a,_);if(c){const b={...x.requestInit,...c};b.headers={...x[e(544)].headers,...c.headers},f.requestInit=b}else f[t(544)]=x.requestInit;if(d){const b={...x[e(559)],...d};f.eventSourceInit=b}else f.eventSourceInit=x.eventSourceInit;const v={};v.listChanged=!0;const g={};g.roots=v,g.sampling={},g[e(511)]={};const R=g,P={};P[t(536)]=n.HwvVa,P.version=e(526);const I={};I.capabilities=R;const k=new F.Client(P,I),j=()=>new N.SSEClientTransport(new URL(o),f);let T=n[t(504)](j);if(l){const b=n[e(506)](le,l,u);T=await n[t(513)](re,k,b,j)}else await k[e(538)](T);n[t(513)](se,k,s,T),T[t(557)]=T[t(542)].searchParams[t(532)](n.jniGY);const E={};return E.transport=T,E.sessionId=T[e(557)],E};function Y(){const r=["ufTHS","finishAuth","TFSRn","RZhOv","Vajmx","_eventSource","FyYHt","elicitation","transport","WIVYl","13320uyrBtN","sampling","8WTwLJD","randomUUID","6438654bkJHij","addResponseListener","nwQhY","11721GVgRMJ","?sessionId=","waitForOAuthCode","include","egwVO","1.0.0","set","sse-session-id","removeNotificationListener","removeResponseListener","11838520fNkjrV","get","Bearer ","credentials","yTKoP","name","addRequestListener","connect","18VhCgQv","mcp-socket-proxy-client","2819364JNqkQZ","_endpoint","699JyrxCR","requestInit","44ofbsvb","close","TeTEy","QgzDy","Fxtoq","roots","PBhps","Authorization","11309130xGCFwl","&token=","version","onclose","sessionId","headers","eventSourceInit","forEach","62FcOkCa","mcp-stream-proxy-client","zXcpO","1794855cQEXDT","biJOc"];return Y=function(){return r},Y()}const Ee=async r=>{const e=S,t=S,n={Vajmx:e(500),biJOc:function(b){return b()},zXcpO:function(b,M,H){return b(M,H)},zDnjZ:function(b,M,H,V){return b(M,H,V)},FQMAh:function(b,M,H,V){return b(M,H,V)}},{client:s,url:o,token:a,sessionId:i,authProvider:l,requestInit:c,reconnectionOptions:d,waitForOAuthCode:u}=r,h={};h.authProvider=l,h.requestInit=c,h.reconnectionOptions=d;const f=h,_=i||U.randomUUID(),x=ce(a,_);if(c){const b={...x.requestInit,...c};b.headers={...x.requestInit.headers,...c.headers},f[e(544)]=b}else f.requestInit=x.requestInit;const v={};v.listChanged=!0;const g={};g[t(550)]=v,g.sampling={},g.elicitation={};const R=g,P={};P[e(536)]=n[t(508)],P[e(555)]="1.0.0";const I={};I.capabilities=R;const k=new F.Client(P,I),j=()=>new z.StreamableHTTPClientTransport(new URL(o),f);let T=n[e(503)](j);if(l){const b=n[e(501)](le,l,u);T=await n.zDnjZ(re,k,b,j)}else await k.connect(T);n.FQMAh(se,k,s,T);const E={};return E.transport=T,E[t(557)]=T.sessionId,E},Oe=async r=>{const e=S,t=S,n={QgzDy:e(540),jkaVB:function(g,R,P,I){return g(R,P,I)}},{client:s,url:o,token:a,sessionId:i}=r,l={};l.listChanged=!0;const c={};c[e(550)]=l,c[e(515)]={},c[t(511)]={};const d=c,u={};u.name=n[t(548)],u[t(555)]=t(526);const h={};h.capabilities=d;const f=new F.Client(u,h),_=i||U[t(517)](),x=new oe.WebSocketClientTransport(new URL(o+e(522)+_+t(554)+a));await f.connect(x),n.jkaVB(se,f,s,x);const v={};return v[e(512)]=x,v[t(557)]=_,v},D=C,J=C;function C(r,e){const t=G();return C=function(n,s){return n=n-(-16761+51*337),t[n]},C(r,e)}(function(r,e){const t=C,n=C,s=r();for(;;)try{if(-parseInt(t(440))/1+-parseInt(t(458))/2*(parseInt(t(448))/3)+-parseInt(t(451))/4*(parseInt(n(449))/5)+-parseInt(n(455))/6+-parseInt(t(427))/7+-parseInt(n(438))/8*(parseInt(n(459))/9)+parseInt(t(430))/10*(parseInt(n(436))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(G,-220880+1*-333337+-2*-384996);function G(){const r=["650XPHLhD","redirectToAuthorization","10856jPvMVb","GET","qcFPW","_redirectUrl","2187414WnlGuZ","resolve","tokens","3976YyOqUl","27ejNHsa","Content-Type","waitForOAuthCode","2903796yvWZFa","_clientMetadata","application/x-www-form-urlencoded","10beEWJk","json","code","_callBackPromise","reject","saveClientInformation","20776349mLNCcF","_codeVerifier","629912aTknXq","_tokens","52074GwcpRo","state","_state","_redirectCallback","_clientInformation","redirect_uris","Failed to redirect: ","clientInformation","381aduWsB"];return G=function(){return r},G()}const Fe=()=>U.randomBytes(3485*1+-261+-3184);class Ne{constructor(e){const t=C,n=C;this._callBackPromise={};const{clientMetadata:s,state:o,redirectCallback:a,getAuthCodeByState:i,waitForOAuthCode:l}=e;this[t(428)]=s,this[t(454)]=s[t(445)][0],this._state=o||Fe(),this._redirectCallback=a||this.redirectCallbackFunction,this._getAuthCodeByState=i||this.getAuthCodeByStateFunction,this[n(426)]=l||this.waitForOAuthCodeFunction()}async redirectCallbackFunction(e){var t,n,s,o,a,i;const l=C,c=C,d={qITTp:function(_,x,v){return _(x,v)},qcFPW:l(452)},u=await d.qITTp(fetch,e,{method:d[l(453)]});!u.ok&&((n=(t=this._callBackPromise).reject)==null||n.call(t,c(446)+u.statusText));const h=await this._getAuthCodeByState(this[c(454)],this[l(442)]);if(!h.ok){(o=(s=this[l(433)]).reject)==null||o.call(s,"Failed to fetch auth code: "+h.statusText);return}const f=await h[l(431)]();(i=(a=this[c(433)])[l(456)])==null||i.call(a,f[l(432)])}async getAuthCodeByStateFunction(e,t){const n=C,s=C,o={};o.tuSmb=n(429);const a=o,i={};i[n(460)]=a.tuSmb;const l={};return l[s(441)]=t,fetch(e,{method:"POST",headers:i,body:new URLSearchParams(l)})}waitForOAuthCodeFunction(){const e=C,t=this[e(433)];return()=>new Promise((n,s)=>{const o=e;t.resolve=n,t[o(434)]=s})}get redirectUrl(){return this[C(454)]}get clientMetadata(){return this._clientMetadata}state(){return this._state}[D(447)](){return this[D(444)]}[J(435)](e){const t=D;this[t(444)]=e}[J(457)](){return this[J(439)]}saveTokens(e){this._tokens=e}[J(450)](e){this[D(443)](e)}saveCodeVerifier(e){this._codeVerifier=e}codeVerifier(){if(!this[D(437)])throw new Error("No code verifier saved");return this._codeVerifier}}(function(r,e){for(var t=Q,n=Q,s=r();;)try{var o=parseInt(t(361))/1*(parseInt(n(363))/2)+-parseInt(t(358))/3+parseInt(t(359))/4*(parseInt(t(357))/5)+parseInt(n(354))/6*(parseInt(t(360))/7)+parseInt(n(362))/8+parseInt(n(364))/9+-parseInt(n(356))/10*(parseInt(t(355))/11);if(o===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(K,-73523*-3+1*-407717+530518);function K(){var r=["40ecBYYe","1095owKKYD","486870YOVwZy","5752xWiyTO","561484biNVMw","1fWJmxQ","1866064SPnyhb","1109522vMiuMX","1602351pPEGwH","12sVyMLL","2573296LTwOhv"];return K=function(){return r},K()}function Q(r,e){var t=K();return Q=function(n,s){n=n-(-1*-642+503*-5+2227);var o=t[n];return o},Q(r,e)}class De{constructor(e,t){const n={name:"web-mcp-server",version:"1.0.0"},s={prompts:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},tools:{listChanged:!0},completions:{},logging:{}};this.server=new $.McpServer(e||n,t||{capabilities:s}),this.server.server.oninitialized=()=>{this.oninitialized?.()},this.server.server.onclose=()=>{this.onclose?.()},this.server.server.onerror=o=>{this.onerror?.(o)},this.server.server.setRequestHandler(w.SetLevelRequestSchema,async()=>({}))}async connect(e){return typeof e.start=="function"?(this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0):(this.transport=new te(e),await this.transport.listen()),await this.server.connect(this.transport),this.transport}async close(){await this.server.close()}registerTool(e,t,n){return this.server.registerTool(e,t,n)}registerPrompt(e,t,n){return this.server.registerPrompt(e,t,n)}registerResource(e,t,n,s){return typeof t=="string"?this.server.registerResource(e,t,n,s):this.server.registerResource(e,t,n,s)}isConnected(){return this.server.isConnected()}sendResourceListChanged(){this.server.sendResourceListChanged()}sendToolListChanged(){this.server.sendToolListChanged()}sendPromptListChanged(){this.server.sendPromptListChanged()}getClientCapabilities(){return this.server.server.getClientCapabilities()}getClientVersion(){return this.server.server.getClientVersion()}async ping(){return await this.server.server.ping()}async createMessage(e,t){return await this.server.server.createMessage(e,t)}async elicitInput(e,t){return await this.server.server.elicitInput(e,t)}async listRoots(e,t){return await this.server.server.listRoots(e,t)}async sendLoggingMessage(e){return await this.server.server.sendLoggingMessage(e)}async sendResourceUpdated(e){return await this.server.server.sendResourceUpdated(e)}request(e,t,n){return this.server.server.request(e,t,n)}async notification(e,t){return await this.server.server.notification(e,t)}setRequestHandler(e,t){this.server.server.setRequestHandler(e,t)}removeRequestHandler(e){this.server.server.removeRequestHandler(e)}setNotificationHandler(e,t){this.server.server.setNotificationHandler(e,t)}removeNotificationHandler(e){this.server.server.removeNotificationHandler(e)}onSubscribe(e){this.server.server.setRequestHandler(w.SubscribeRequestSchema,e)}onUnsubscribe(e){this.server.server.setRequestHandler(w.UnsubscribeRequestSchema,e)}onSetLogLevel(e){this.server.server.setRequestHandler(w.SetLevelRequestSchema,e)}onListResources(e){this.server.server.setRequestHandler(w.ListResourcesRequestSchema,e)}onRootsListChanged(e){this.server.server.setNotificationHandler(w.RootsListChangedNotificationSchema,e)}async onPagehide(e){e.persisted||this.transport&&typeof this.transport.close=="function"&&await this.transport.close()}}const je=(r,e)=>new te(r,e),Ve=()=>me(),ze=r=>r instanceof te,We=r=>r instanceof $.McpServer;class Ae{constructor(e,t){const n={name:"web-mcp-client",version:"1.0.0"},s={roots:{listChanged:!0},sampling:{},elicitation:{}};this.client=new F.Client(e||n,t||{capabilities:s}),this.client.onclose=()=>{this.onclose?.()},this.client.onerror=o=>{this.onerror?.(o)}}async connect(e){if(typeof e.start=="function")return this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0,await this.client.connect(this.transport),{transport:this.transport,sessionId:this.transport.sessionId};const{url:t,token:n,sessionId:s,type:o,agent:a,onError:i}=e;if(a===!0){const d={client:this.client,url:t,token:n,sessionId:s};let u;return await(async()=>{const{transport:f,sessionId:_}=o==="sse"?await Ue(d):o==="socket"?await Oe(d):await Ee(d);f.onerror=async x=>{i?.(x)},u={transport:f,sessionId:_}})(),u}const l=new URL(t);let c;if(o==="channel"&&(c=new ee(t),await this.client.connect(c)),o==="sse"){const d=ae(n,s);c=new N.SSEClientTransport(l,d),await this.client.connect(c)}if(o==="socket"&&(c=new oe.WebSocketClientTransport(new URL(`${t}?sessionId=${s}&token=${n}`)),c.sessionId=s,await this.client.connect(c)),typeof c>"u"){const d=ce(n,s);c=new z.StreamableHTTPClientTransport(l,d),await this.client.connect(c)}return this.transport=c,{transport:this.transport,sessionId:this.transport.sessionId}}async close(){await this.client.close()}getServerCapabilities(){return this.client.getServerCapabilities()}getServerVersion(){return this.client.getServerVersion()}getInstructions(){return this.client.getInstructions()}async ping(e){return await this.client.ping(e)}async complete(e,t){return await this.client.complete(e,t)}async setLoggingLevel(e,t){return await this.client.setLoggingLevel(e,t)}async getPrompt(e,t){return await this.client.getPrompt(e,t)}async listPrompts(e,t){return await this.client.listPrompts(e,t)}async listResources(e,t){return await this.client.listResources(e,t)}async listResourceTemplates(e,t){return await this.client.listResourceTemplates(e,t)}async readResource(e,t){return await this.client.readResource(e,t)}async subscribeResource(e,t){return await this.client.subscribeResource(e,t)}async unsubscribeResource(e,t){return await this.client.unsubscribeResource(e,t)}async callTool(e,t){return await this.client.callTool(e,w.CallToolResultSchema,t)}async listTools(e,t){return await this.client.listTools(e,t)}async sendRootsListChanged(){return await this.client.sendRootsListChanged()}request(e,t,n){return this.client.request(e,t,n)}async notification(e,t){return await this.client.notification(e,t)}setRequestHandler(e,t){this.client.setRequestHandler(e,t)}removeRequestHandler(e){this.client.removeRequestHandler(e)}setNotificationHandler(e,t){this.client.setNotificationHandler(e,t)}removeNotificationHandler(e){this.client.removeNotificationHandler(e)}onElicit(e){this.client.setRequestHandler(w.ElicitRequestSchema,e)}onCreateMessage(e){this.client.setRequestHandler(w.CreateMessageRequestSchema,e)}onListRoots(e){this.client.setRequestHandler(w.ListRootsRequestSchema,e)}onToolListChanged(e){this.client.setNotificationHandler(w.ToolListChangedNotificationSchema,e)}onPromptListChanged(e){this.client.setNotificationHandler(w.PromptListChangedNotificationSchema,e)}onResourceListChanged(e){this.client.setNotificationHandler(w.ResourceListChangedNotificationSchema,e)}onResourceUpdated(e){this.client.setNotificationHandler(w.ResourceUpdatedNotificationSchema,e)}onLoggingMessage(e){this.client.setNotificationHandler(w.LoggingMessageNotificationSchema,e)}async onPagehide(e){e.persisted||(de(this.transport)?await this.transport.terminateSession():this.transport&&typeof this.transport.close=="function"&&await this.transport.close())}}const Be=(r,e)=>new N.SSEClientTransport(r,e),Ze=(r,e)=>new z.StreamableHTTPClientTransport(r,e),Ye=(r,e)=>new ee(r,e),Je=r=>r instanceof N.SSEClientTransport,de=r=>r instanceof z.StreamableHTTPClientTransport,Ge=r=>r instanceof ee,Ke=r=>r instanceof F.Client,Qe=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)}),X=(r,e,t)=>{window.postMessage({type:r,direction:t,data:e},"*")},ue=(r,e,t)=>{const n=async function(s){s.source===window&&s.data.type===r&&s.data.direction===t&&await e(s.data.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)};class Xe{constructor(e=null){this._isStarted=!1,this._isClosed=!1,this._lastRegistration=null,this.sessionId=e||Qe(),this._messageListener1=ue("sidepanel-ready-to-page",()=>{this._lastRegistration&&this._isStarted&&this.notifyRegistration(this._lastRegistration).catch(t=>{console.error("【Page Svr Transport】 notifyRegistration失败:",t)})},"content->page"),this._messageListener2=ue("mcp-client-to-server-to-page",t=>{if(t.sessionId!==this.sessionId)return;console.log("【Page Svr Transport】 即将处理 mcpMessage",t.mcpMessage);const n=w.JSONRPCMessageSchema.parse(t.mcpMessage);this.onmessage?.(n),t.mcpMessage.params?.name&&X("update-page-app-message",{status:"run",message:t.mcpMessage.params?.name},"page->content")},"content->page")}_throwError(e,t){if(e()){const n=new Error(t);throw console.log(t,n),this.onerror&&this.onerror(n),n}}async start(){if(!this._isStarted){if(this._isClosed)throw new Error("【Page Svr Transport】 已关闭,无法重新启动");this._isStarted=!0}}async send(e,t){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法发送消息"),this._throwError(()=>this._isClosed,"【Page Svr Transport】 已关闭,无法发送消息"),X("mcp-server-to-client-from-page",{sessionId:this.sessionId,mcpMessage:e},"page->content"),"result"in e&&e.result?.content&&X("update-page-app-message",{status:"ready",message:""},"page->content")}async notifyRegistration(e){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法注册消息"),this._lastRegistration=e;try{X("mcp-server-register-from-page",{sessionId:this.sessionId,serverInfo:{...e,url:window.location.origin,title:document.title}},"page->content")}catch(t){this._throwError(()=>!0,"【Page Svr Transport】 注册 server 失败"+String(t))}}async close(){if(!this._isClosed)try{this._messageListener1&&this._messageListener1(),this._messageListener2&&this._messageListener2(),this._isClosed=!0,this._isStarted=!1,this.onclose&&this.onclose()}catch(e){this._throwError(()=>!0,"【Page Svr Transport】 关闭时发生错误"+String(e))}}}p.Ajv=O,Object.defineProperty(p,"ResourceTemplate",{enumerable:!0,get:()=>$.ResourceTemplate}),Object.defineProperty(p,"z",{enumerable:!0,get:()=>fe.z}),Object.defineProperty(p,"UriTemplate",{enumerable:!0,get:()=>pe.UriTemplate}),Object.defineProperty(p,"completable",{enumerable:!0,get:()=>xe.completable}),Object.defineProperty(p,"getDisplayName",{enumerable:!0,get:()=>_e.getDisplayName}),p.AuthClientProvider=Ne,p.ExtensionPageServerTransport=Xe,p.WebMcpClient=Ae,p.WebMcpServer=De,p.createMessageChannelClientTransport=Ye,p.createMessageChannelPairTransport=Ve,p.createMessageChannelServerTransport=je,p.createSSEClientTransport=Be,p.createStreamableHTTPClientTransport=Ze,p.isMcpClient=Ke,p.isMcpServer=We,p.isMessageChannelClientTransport=Ge,p.isMessageChannelServerTransport=ze,p.isSSEClientTransport=Je,p.isStreamableHTTPClientTransport=de,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(p,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("ajv"),require("@modelcontextprotocol/sdk/types.js"),require("@modelcontextprotocol/sdk/client/index.js"),require("@modelcontextprotocol/sdk/client/sse.js"),require("@modelcontextprotocol/sdk/client/streamableHttp.js"),require("@modelcontextprotocol/sdk/client/websocket.js"),require("@modelcontextprotocol/sdk/client/auth.js"),require("@modelcontextprotocol/sdk/server/mcp.js"),require("zod"),require("@modelcontextprotocol/sdk/shared/uriTemplate.js"),require("@modelcontextprotocol/sdk/server/completable.js"),require("@modelcontextprotocol/sdk/shared/metadataUtils.js")):typeof define=="function"&&define.amd?define(["exports","ajv","@modelcontextprotocol/sdk/types.js","@modelcontextprotocol/sdk/client/index.js","@modelcontextprotocol/sdk/client/sse.js","@modelcontextprotocol/sdk/client/streamableHttp.js","@modelcontextprotocol/sdk/client/websocket.js","@modelcontextprotocol/sdk/client/auth.js","@modelcontextprotocol/sdk/server/mcp.js","zod","@modelcontextprotocol/sdk/shared/uriTemplate.js","@modelcontextprotocol/sdk/server/completable.js","@modelcontextprotocol/sdk/shared/metadataUtils.js"],O):(p=typeof globalThis<"u"?globalThis:p||self,O(p.WebMCP={},p.MCPSDK,p.MCPSDK,p.MCPSDK,p.MCPSDK,p.MCPSDK,p.websocket_js,p.MCPSDK,p.MCPSDK,p.Zod,p.MCPSDK,p.MCPSDK,p.MCPSDK))})(this,function(p,O,w,F,N,z,oe,he,$,fe,pe,xe,_e){"use strict";function W(){const r=["224340fQYLJj","function","onmessage","port2","341XVdnBD","313767JEBgqL","950bpstaX","1354759gUhUbE","wRKyh","onclose","2044SvCTUj","endpoint","24msSkHx","164VuWYGY","mOWMr","EkZCC","addEventListener","postMessage","120705iyGzUz","8878392ivIdKn","close","_listen","3619482FaLQHc","start","_endpoint","kgkem","bzNYT","MessageChannel transport error: ","stringify","onmessageerror","HvyCv","undefined","Jwyua","message","_globalObject","parse","authInfo","thraG","220pGvxgp","_port","EGhzU","onerror","data","MhriV"];return W=function(){return r},W()}(function(r,e){const t=y,n=y,s=r();for(;;)try{if(parseInt(t(417))/1*(parseInt(t(421))/2)+parseInt(t(433))/3+parseInt(t(424))/4*(-parseInt(n(429))/5)+parseInt(n(423))/6*(-parseInt(n(418))/7)+-parseInt(n(430))/8+-parseInt(t(416))/9*(-parseInt(t(405))/10)+-parseInt(t(415))/11*(-parseInt(t(411))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(W,650197);const ie=()=>{const r=y,e={EGhzU:function(t,n){return t!==n},kIrDB:"undefined",llYQe:function(t,n){return t!==n},PZfJg:function(t,n){return t(n)},Jwyua:"return this"};return typeof globalThis<"u"?globalThis:e[r(407)](typeof window,e.kIrDB)?window:e.llYQe(typeof global,e.kIrDB)?global:typeof self!==r(398)?self:e.PZfJg(Function,e[r(399)])()},ve=(r,e,t)=>{const n=y,s=y,o={};o[n(410)]=s(398),o.dBkaX=function(i,c){return i===c},o[s(393)]="function";const a=o;typeof window!==a[s(410)]?r.postMessage(e,"*",t):s(428)in r&&a.dBkaX(typeof r.postMessage,a[n(393)])&&r.postMessage(e,t)},ge=(r,e)=>{const t=y,n=y,s={};s.MbsGh="addEventListener",s.PPniK=function(a,i){return a===i},s[t(419)]=n(412),s[n(404)]="onmessage",s[t(397)]="undefined";const o=s;o.MbsGh in r&&o.PPniK(typeof r[t(427)],o.wRKyh)?r[t(427)](t(400),e):o.thraG in r&&typeof r[n(413)]!==o[n(397)]&&(r.onmessage=e)};class A{constructor(e){const t=y;this[t(406)]=e}async start(){const e=y,t=y;this[e(406)]&&(this[e(406)][e(413)]=n=>{var s,o;const a=e,i=t;try{const c=w.JSONRPCMessageSchema[a(402)](n.data[a(400)]);(s=this[a(413)])==null||s.call(this,c,n[i(409)].extra)}catch(c){const l=new Error("MessageChannel failed to parse message: "+c);(o=this[i(408)])==null||o.call(this,l)}},this._port[e(396)]=n=>{var s;const o=t,a=t,i=new Error(o(394)+JSON[a(395)](n));(s=this.onerror)==null||s.call(this,i)},this[e(406)][e(434)]())}async send(e,t){const n={lEyuq:function(s){return s()},YihNw:function(s,o){return s(o)}};return new Promise((s,o)=>{var a;const i=y,c=y;try{const l={};l[i(403)]=t==null?void 0:t[i(403)];const d={};d[c(400)]=e,d.extra=l,this[c(406)]&&this[i(406)].postMessage(d),n.lEyuq(s)}catch(l){const d=l instanceof Error?l:new Error(n.YihNw(String,l));(a=this[c(408)])==null||a.call(this,d),o(d)}})}async close(){var e,t;const n=y,s=y;(e=this._port)==null||e[n(431)](),this._port=void 0,(t=this[s(420)])==null||t.call(this)}}class ee extends A{constructor(e,t=ie()){const n=y,s=y,o={EkZCC:function(i,c,l,d){return i(c,l,d)}};super(),this[n(391)]=e,this[s(401)]=t;const a=new MessageChannel;this[s(406)]=a.port1,o[s(426)](ve,this[n(401)],{endpoint:this[s(391)]},[a[s(414)]])}}class te extends A{constructor(e,t=ie()){const n=y,s={mOWMr:function(o,a){return o===a},kgkem:function(o,a,i){return o(a,i)}};super(),this._endpoint=e,this._globalObject=t,this[n(432)]=new Promise(o=>{const a=n,i=n;s[a(392)](ge,this[i(401)],c=>{const l=i,d=i;c.data&&s[l(425)](c.data[d(422)],this[d(391)])&&(this[d(406)]=c.ports[-1*4852+1*1601+3251],o())})})}async listen(){return this[y(432)]}}function y(r,e){const t=W();return y=function(n,s){return n=n-(17*-491+-669+9407),t[n]},y(r,e)}const be=()=>{const r=new MessageChannel;return[new A(r.port1),new A(r.port2)]};(function(r,e){const t=b,n=b,s=r();for(;;)try{if(parseInt(t(355))/1+-parseInt(t(356))/2*(-parseInt(t(373))/3)+-parseInt(t(337))/4+parseInt(n(357))/5+-parseInt(n(389))/6*(-parseInt(t(396))/7)+parseInt(n(325))/8*(parseInt(t(382))/9)+-parseInt(t(366))/10===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(B,-763475+-52067*10+1724410);const me=async(r,e,t)=>{var n;const s=b,o=b,a={};a[s(345)]="tools/list",a.rqstG="tools/call",a.WqUnk="resources/list",a[s(329)]=o(358),a[s(365)]=s(335),a.ookoz="resources/unsubscribe",a[s(385)]=s(340),a.VTIWq="prompts/list",a.SkoRK=s(376),a.QUtUV=s(388),a.XtowM=o(332);const i=a,{id:c,method:l,params:d}=t;let u={};switch(l){case i[o(345)]:u=await e.listTools(d);break;case i.rqstG:u=await e.callTool(d);break;case i[s(334)]:u=await e[s(350)](d);break;case i[o(329)]:u=await e.listResourceTemplates(d);break;case s(372):u=await e[s(383)](d);break;case i.HgYgW:u=await e.subscribeResource(d);break;case i.ookoz:u=await e.unsubscribeResource(d);break;case i[s(385)]:u=await e.getPrompt(d);break;case i.VTIWq:u=await e.listPrompts(d);break;case i[s(344)]:u=await e[s(376)]();break;case i.QUtUV:u=await e.complete(d);break;case s(390):u=await e[s(336)](d==null?void 0:d.level);break}const h={};h[s(361)]=u,h[s(394)]=i[s(364)],h.id=c,await((n=r==null?void 0:r.transport)==null?void 0:n[s(392)](h))},we=async(r,e,t)=>{var n;const s=b,o=b,a={};a.jQBBS="sampling/createMessage",a.EZqgC="elicitation/create",a[s(370)]=o(376),a.aVeaL=o(332);const i=a,{id:c,method:l,params:d}=t;let u={};switch(l){case s(368):const f={};f.method=l,f[o(367)]=d,u=await e.request(f,w.ListRootsResultSchema);break;case i[o(391)]:const _={};_.method=l,_[o(367)]=d,u=await e[o(381)](_,w.CreateMessageResultSchema);break;case i.EZqgC:const x={};x.method=l,x.params=d,u=await e.request(x,w.ElicitResultSchema);break;case i[o(370)]:const v={};v.method=l,u=await e[o(381)](v,w.EmptyResultSchema);break}const h={};return h[o(361)]=u,h.jsonrpc=i[o(387)],h.id=c,await((n=r==null?void 0:r[s(371)])==null?void 0:n.send(h)),u},ye=(r,e)=>{const t=b,n={gXsjT:function(o,a){return o===a},oegpC:t(351),lZOUC:function(o,a,i,c){return o(a,i,c)},ifIKG:"2.0"},s=r._onrequest;r._onrequest=async(o,a)=>{var i,c,l,d,u;const h=t,f=t,{id:_,method:x}=o;try{n[h(333)](x,n.oegpC)?await s[h(386)](r,o,a):await n.lZOUC(me,r,e,o)}catch(v){const{code:g,message:R,data:P}=v;try{if(g){const I={};I.code=g,I.message=R,I.data=P;const k={};k.error=I,k[h(394)]=n[f(331)],k.id=_,await((i=r==null?void 0:r.transport)==null?void 0:i.send(k))}else(l=(c=r==null?void 0:r[f(371)])==null?void 0:c.onerror)==null||l.call(c,v)}catch(I){(u=(d=r==null?void 0:r[h(371)])==null?void 0:d.onerror)==null||u.call(d,I)}}}},Ce=(r,e)=>{const t=b,n=b,s={};s[t(363)]=function(a,i){return a!==i},s[t(398)]=t(353),s.hzhyg="notifications/cancelled";const o=s;r._onnotification=async a=>{var i,c;const l=t,d=n,{method:u,params:h}=a;if(o[l(363)](u,o[d(398)])&&(o[l(363)](u,o.hzhyg)||h!=null&&h.forward))try{await e.notification(a)}catch(f){(c=(i=r==null?void 0:r.transport)==null?void 0:i.onerror)==null||c.call(i,f)}}},Ie=(r,e)=>async t=>{var n,s,o,a,i;const c=b,l=b,d={};d.SEmWX=c(332);const u=d;try{return await we(r,e,t)}catch(h){const{code:f,message:_,data:x}=h;try{if(f){const v={};v[l(377)]=f,v.message=_,v.data=x;const g={};g[l(348)]=v,g.jsonrpc=u[c(338)],g.id=t.id,await((n=r==null?void 0:r.transport)==null?void 0:n[l(392)](g))}else(o=(s=r==null?void 0:r.transport)==null?void 0:s[l(339)])==null||o.call(s,h)}catch(v){(i=(a=r==null?void 0:r[c(371)])==null?void 0:a[l(339)])==null||i.call(a,v)}}},Se=(r,e)=>async t=>{var n,s,o;const a=b,i=b,c={};c.dtUgZ=function(h,f){return h!==f},c.jgCIb=a(353),c.uUjKY="2.0";const l=c,{method:d,params:u}=t;if(l.dtUgZ(d,l.jgCIb)&&(d!==a(400)||u!=null&&u.forward))try{const h={...t};h[a(394)]=l[i(352)],await((n=e==null?void 0:e[a(371)])==null?void 0:n[a(392)](h))}catch(h){(o=(s=r==null?void 0:r[a(371)])==null?void 0:s[i(339)])==null||o.call(s,h)}};function b(r,e){const t=B();return b=function(n,s){return n=n-(9*-113+-1439*-1+-97),t[n]},b(r,e)}const Re=(r,e)=>async t=>{var n,s,o,a,i,c;const l=b,d=b,u={};u[l(401)]=d(332);const h=u;try{await((n=e==null?void 0:e.transport)==null?void 0:n.send(t))}catch(f){const{code:_,message:x,data:v}=f;try{if(_){const g={};g.code=_,g[l(399)]=x,g.data=v;const R={};R[l(348)]=g,R[l(394)]=h.OhJjz,R.id=t.id,await((s=r==null?void 0:r[l(371)])==null?void 0:s.send(R))}else(a=(o=r==null?void 0:r.transport)==null?void 0:o[d(339)])==null||a.call(o,f)}catch(g){(c=(i=r==null?void 0:r.transport)==null?void 0:i.onerror)==null||c.call(i,g)}}},ne=()=>{const r=b,e=b,t={vnkqu:function(l,d){return l!==d},wxDWr:function(l,d){return l(d)},GdkkV:function(l,d){return l===d}},n=[],s=(l,d)=>{const u=b,h=b;if(d){const f=[];for(const _ of n)try{f.push(_(l,d))}catch{}for(const _ of f)if(t[u(379)](_,null))return _}else for(const f of n)try{t[h(343)](f,l)}catch{}},o=l=>{const d=b;t[d(384)](typeof l,d(369))&&!n.includes(l)&&n.push(l)},a=l=>{const d=n.indexOf(l);d!==-1&&n.splice(d,1*-6854+8*-33+7119)},i=()=>{const l=b;n[l(374)]=7102*1+5522+-526*24},c={};return c[r(346)]=s,c[e(330)]=o,c.removeListener=a,c[r(359)]=i,c},Te=r=>{const e=b,t=b,n={xwPeb:function(s){return s()},Mfvzm:function(s){return s()}};{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[e(326)](ne);r._onresponse=s,r[e(395)]=o,r.removeResponseListener=a,r.clearResponseListener=i}{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[t(326)](ne);r[t(328)]=s,r.addRequestListener=o,r[t(354)]=a,r[t(341)]=i}{const{handleListener:s,addListener:o,removeListener:a,clearListener:i}=n[e(375)](ne);r[e(342)]=s,r[e(327)]=o,r.removeNotificationListener=a,r.clearNotificationListener=i}};function B(){const r=["uUjKY","notifications/initialized","removeRequestListener","96194JysfjF","36346SGEWAV","1357830AJaOeY","resources/templates/list","clearListener","iQqcJ","result","tqDZP","sSeCz","XtowM","HgYgW","3913230mjiatC","params","roots/list","function","bfmJT","transport","resources/read","27FNuDmk","length","Mfvzm","ping","code","_onresponse","vnkqu","cjSoZ","request","9gIMIPC","readResource","GdkkV","ptMjy","call","aVeaL","completion/complete","5035122lFbpzR","logging/setLevel","jQBBS","send","_requestHandlers","jsonrpc","addResponseListener","7SpcenI","ElOQH","MDIkN","message","notifications/cancelled","OhJjz","clear","672216JzFEyR","xwPeb","addNotificationListener","fallbackRequestHandler","sYzPD","addListener","ifIKG","2.0","gXsjT","WqUnk","resources/subscribe","setLoggingLevel","2491772kFUWFh","SEmWX","onerror","prompts/get","clearRequestListener","fallbackNotificationHandler","wxDWr","SkoRK","uTeHc","handleListener","Zybtx","error","originalOnResponse","listResources","initialize"];return B=function(){return r},B()}const ke=(r,{beforeInit:e,afterInit:t}={})=>{const n=b,s=b,o={tqDZP:function(i,c){return i===c},cjSoZ:"function",iQqcJ:n(378),Zybtx:function(i,c){return i(c)},ElOQH:function(i){return i()}},a=new Map(r._notificationHandlers);r[n(393)][n(402)](),r._notificationHandlers[n(402)](),o.tqDZP(typeof e,o[n(380)])&&e(),o[n(362)](r._onresponse.name,o[n(360)])&&(r[s(349)]=r._onresponse),o[n(347)](Te,r),r.addResponseListener(i=>{const c=s;r.originalOnResponse[c(386)](r,i)}),o.tqDZP(typeof t,o[s(380)])&&o[n(397)](t),r[s(327)](i=>{const{method:c}=i,l=a.get(c);o.tqDZP(typeof l,o.cjSoZ)&&l(i)})},Pe=q,qe=q;(function(r,e){const t=q,n=q,s=r();for(;;)try{if(-parseInt(t(393))/1+parseInt(t(397))/2*(-parseInt(t(400))/3)+-parseInt(n(398))/4+parseInt(t(390))/5*(parseInt(n(388))/6)+-parseInt(t(389))/7+-parseInt(t(402))/8*(-parseInt(n(395))/9)+parseInt(n(399))/10*(parseInt(n(385))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Z,-1*-881393+2*180895+1*-644809);function q(r,e){const t=Z();return q=function(n,s){return n=n-(-1861+-499*4+4241),t[n]},q(r,e)}function Z(){const r=["toString","getRandomValues","2101mUsYMI","EQHzo","padStart","30UvDAkd","1609706yzlqYx","974735GrhZVO","randomUUID","REzPF","562771BvAnoG","dHTfU","2047455boiYXf","randomBytes","14664qHAdbF","3772144jLpQch","52310AkWksx","318MkjaVb","from","40WRwnSc"];return Z=function(){return r},Z()}const Le=()=>{const r=q,e=q,t={};t.REzPF=function(s,o){return s&o},t.suJHI=function(s,o){return s===o},t[r(386)]=function(s,o){return s&o},t[e(394)]="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";const n=t;return n.suJHI(typeof crypto,"object")&&crypto.randomUUID?crypto[e(391)]():n.dHTfU.replace(/[xy]/g,s=>{const o=r,a=r,i=n[o(392)](crypto[o(384)](new Uint8Array(-25*-62+7113+2*-4331))[741*2+-1385*-2+4252*-1],8648+-107*62+-1999);return(n.suJHI(s,"x")?i:n[a(386)](i,-4377+4*1095)|5079+461*-11).toString(9449+4*-461+-7589)})},Me=r=>{const e=q,t=q,n=new Uint8Array(r);return crypto.getRandomValues(n),Array[e(401)](n,s=>s[t(403)](-3*1739+-6509+2*5871)[e(387)](2,"0")).join("")},U={};U[Pe(391)]=Le,U[qe(396)]=Me;const S=L;(function(r,e){const t=L,n=L,s=r();for(;;)try{if(parseInt(t(521))/1*(parseInt(n(499))/2)+parseInt(n(543))/3*(parseInt(n(514))/4)+parseInt(t(502))/5*(parseInt(n(539))/6)+parseInt(t(553))/7+parseInt(t(516))/8*(-parseInt(t(518))/9)+-parseInt(t(531))/10+-parseInt(t(545))/11*(parseInt(t(541))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Y,1472653*1+-2*-897917+-2275789);const He=(r,e)=>{const t=L,n=L,s={FyYHt:function(c,l,d){return c(l,d)},Fxtoq:function(c,l,d){return c(l,d)}};ye(r,e),Ce(r,e);const o=Ie(e,r),a=s[t(510)](Re,e,r),i=s[n(549)](Se,e,r);e[n(537)](o),e[t(519)](a),e.addNotificationListener(i),r[n(556)]=()=>{const c=n;e.removeRequestListener(o),e[c(530)](a),e[c(529)](i)}},se=(r,e,t)=>{const n=L,s={pMiva:function(i,c){return i instanceof c},TeTEy:n(546),fyZbd:function(i,c,l){return i(c,l)}},o=()=>{var i;const c=n;s.pMiva(t,N.SSEClientTransport)&&((i=t._eventSource)==null||i.addEventListener(s[c(547)],()=>{var l;const d=c;(l=t[d(509)])==null||l[d(546)]()})),He(r,e)},a={};a.afterInit=o,s.fyZbd(ke,e,a)},ae=(r,e=U.randomUUID())=>{const t=L,n=L,s={OfssH:function(d,u,h){return d(u,h)}},o={};o[t(528)]=e;const a=o,i={};i[t(528)]=e;const c={};c[n(558)]=i,c[t(534)]=t(524);const l={requestInit:c,eventSourceInit:{async fetch(d,u){const h=t,f=n,_=new Headers((u==null?void 0:u[h(558)])||{});Object.entries(a)[f(498)](([v,g])=>{_[f(527)](v,g)});const x={...u};return x[f(558)]=_,s.OfssH(fetch,d,x)},withCredentials:!0}};return r&&(l.requestInit[t(558)].Authorization=t(533)+r,a.Authorization="Bearer "+r),l},ce=(r,e=U[S(517)]())=>{const t=S,n=S,s={};s.nwQhY="include";const o=s,a={};a["stream-session-id"]=e;const i={};i.headers=a,i.credentials=o[t(520)];const c={};c[t(544)]=i;const l=c;return r&&(l.requestInit.headers[n(552)]=n(533)+r),l},re=async(r,e,t)=>{const n=S,s=S,o={CFfFC:function(i){return i()},egwVO:function(i,c,l,d){return i(c,l,d)}},a=o.CFfFC(t);try{return await r[n(538)](a),a}catch(i){if(i instanceof he.UnauthorizedError){const c=await e();return await a[s(505)](c),await o[n(525)](re,r,e,t)}else throw i}};function L(r,e){const t=Y();return L=function(n,s){return n=n-(74*-67+-8341+-73*-189),t[n]},L(r,e)}const le=(r,e)=>{const t=S,n=S,s={};s.RsKXs=function(a,i){return a in i},s.PBhps="waitForOAuthCode",s[t(535)]="function",s[t(507)]="waitForOAuthCode need to be provided when authProvider is provided";const o=s;if(o.RsKXs(o[n(551)],r))return r[n(523)];if(typeof e===o.yTKoP)return e;throw new Error(o.RZhOv)},Ue=async r=>{const e=S,t=S,n={TFSRn:function(m,M,H){return m(M,H)},HwvVa:"mcp-sse-proxy-client",ufTHS:function(m){return m()},WIVYl:function(m,M,H,V){return m(M,H,V)},jniGY:"sessionId"},{client:s,url:o,token:a,sessionId:i,authProvider:c,requestInit:l,eventSourceInit:d,waitForOAuthCode:u}=r,h={};h.authProvider=c,h.requestInit=l,h.eventSourceInit=d;const f=h,_=i||U.randomUUID(),x=n[e(506)](ae,a,_);if(l){const m={...x.requestInit,...l};m.headers={...x[e(544)].headers,...l.headers},f.requestInit=m}else f[t(544)]=x.requestInit;if(d){const m={...x[e(559)],...d};f.eventSourceInit=m}else f.eventSourceInit=x.eventSourceInit;const v={};v.listChanged=!0;const g={};g.roots=v,g.sampling={},g[e(511)]={};const R=g,P={};P[t(536)]=n.HwvVa,P.version=e(526);const I={};I.capabilities=R;const k=new F.Client(P,I),j=()=>new N.SSEClientTransport(new URL(o),f);let T=n[t(504)](j);if(c){const m=n[e(506)](le,c,u);T=await n[t(513)](re,k,m,j)}else await k[e(538)](T);n[t(513)](se,k,s,T),T[t(557)]=T[t(542)].searchParams[t(532)](n.jniGY);const E={};return E.transport=T,E.sessionId=T[e(557)],E};function Y(){const r=["ufTHS","finishAuth","TFSRn","RZhOv","Vajmx","_eventSource","FyYHt","elicitation","transport","WIVYl","13320uyrBtN","sampling","8WTwLJD","randomUUID","6438654bkJHij","addResponseListener","nwQhY","11721GVgRMJ","?sessionId=","waitForOAuthCode","include","egwVO","1.0.0","set","sse-session-id","removeNotificationListener","removeResponseListener","11838520fNkjrV","get","Bearer ","credentials","yTKoP","name","addRequestListener","connect","18VhCgQv","mcp-socket-proxy-client","2819364JNqkQZ","_endpoint","699JyrxCR","requestInit","44ofbsvb","close","TeTEy","QgzDy","Fxtoq","roots","PBhps","Authorization","11309130xGCFwl","&token=","version","onclose","sessionId","headers","eventSourceInit","forEach","62FcOkCa","mcp-stream-proxy-client","zXcpO","1794855cQEXDT","biJOc"];return Y=function(){return r},Y()}const Ee=async r=>{const e=S,t=S,n={Vajmx:e(500),biJOc:function(m){return m()},zXcpO:function(m,M,H){return m(M,H)},zDnjZ:function(m,M,H,V){return m(M,H,V)},FQMAh:function(m,M,H,V){return m(M,H,V)}},{client:s,url:o,token:a,sessionId:i,authProvider:c,requestInit:l,reconnectionOptions:d,waitForOAuthCode:u}=r,h={};h.authProvider=c,h.requestInit=l,h.reconnectionOptions=d;const f=h,_=i||U.randomUUID(),x=ce(a,_);if(l){const m={...x.requestInit,...l};m.headers={...x.requestInit.headers,...l.headers},f[e(544)]=m}else f.requestInit=x.requestInit;const v={};v.listChanged=!0;const g={};g[t(550)]=v,g.sampling={},g.elicitation={};const R=g,P={};P[e(536)]=n[t(508)],P[e(555)]="1.0.0";const I={};I.capabilities=R;const k=new F.Client(P,I),j=()=>new z.StreamableHTTPClientTransport(new URL(o),f);let T=n[e(503)](j);if(c){const m=n[e(501)](le,c,u);T=await n.zDnjZ(re,k,m,j)}else await k.connect(T);n.FQMAh(se,k,s,T);const E={};return E.transport=T,E[t(557)]=T.sessionId,E},Oe=async r=>{const e=S,t=S,n={QgzDy:e(540),jkaVB:function(g,R,P,I){return g(R,P,I)}},{client:s,url:o,token:a,sessionId:i}=r,c={};c.listChanged=!0;const l={};l[e(550)]=c,l[e(515)]={},l[t(511)]={};const d=l,u={};u.name=n[t(548)],u[t(555)]=t(526);const h={};h.capabilities=d;const f=new F.Client(u,h),_=i||U[t(517)](),x=new oe.WebSocketClientTransport(new URL(o+e(522)+_+t(554)+a));await f.connect(x),n.jkaVB(se,f,s,x);const v={};return v[e(512)]=x,v[t(557)]=_,v},D=C,J=C;function C(r,e){const t=G();return C=function(n,s){return n=n-(-16761+51*337),t[n]},C(r,e)}(function(r,e){const t=C,n=C,s=r();for(;;)try{if(-parseInt(t(440))/1+-parseInt(t(458))/2*(parseInt(t(448))/3)+-parseInt(t(451))/4*(parseInt(n(449))/5)+-parseInt(n(455))/6+-parseInt(t(427))/7+-parseInt(n(438))/8*(parseInt(n(459))/9)+parseInt(t(430))/10*(parseInt(n(436))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(G,-220880+1*-333337+-2*-384996);function G(){const r=["650XPHLhD","redirectToAuthorization","10856jPvMVb","GET","qcFPW","_redirectUrl","2187414WnlGuZ","resolve","tokens","3976YyOqUl","27ejNHsa","Content-Type","waitForOAuthCode","2903796yvWZFa","_clientMetadata","application/x-www-form-urlencoded","10beEWJk","json","code","_callBackPromise","reject","saveClientInformation","20776349mLNCcF","_codeVerifier","629912aTknXq","_tokens","52074GwcpRo","state","_state","_redirectCallback","_clientInformation","redirect_uris","Failed to redirect: ","clientInformation","381aduWsB"];return G=function(){return r},G()}const Fe=()=>U.randomBytes(3485*1+-261+-3184);class Ne{constructor(e){const t=C,n=C;this._callBackPromise={};const{clientMetadata:s,state:o,redirectCallback:a,getAuthCodeByState:i,waitForOAuthCode:c}=e;this[t(428)]=s,this[t(454)]=s[t(445)][0],this._state=o||Fe(),this._redirectCallback=a||this.redirectCallbackFunction,this._getAuthCodeByState=i||this.getAuthCodeByStateFunction,this[n(426)]=c||this.waitForOAuthCodeFunction()}async redirectCallbackFunction(e){var t,n,s,o,a,i;const c=C,l=C,d={qITTp:function(_,x,v){return _(x,v)},qcFPW:c(452)},u=await d.qITTp(fetch,e,{method:d[c(453)]});!u.ok&&((n=(t=this._callBackPromise).reject)==null||n.call(t,l(446)+u.statusText));const h=await this._getAuthCodeByState(this[l(454)],this[c(442)]);if(!h.ok){(o=(s=this[c(433)]).reject)==null||o.call(s,"Failed to fetch auth code: "+h.statusText);return}const f=await h[c(431)]();(i=(a=this[l(433)])[c(456)])==null||i.call(a,f[c(432)])}async getAuthCodeByStateFunction(e,t){const n=C,s=C,o={};o.tuSmb=n(429);const a=o,i={};i[n(460)]=a.tuSmb;const c={};return c[s(441)]=t,fetch(e,{method:"POST",headers:i,body:new URLSearchParams(c)})}waitForOAuthCodeFunction(){const e=C,t=this[e(433)];return()=>new Promise((n,s)=>{const o=e;t.resolve=n,t[o(434)]=s})}get redirectUrl(){return this[C(454)]}get clientMetadata(){return this._clientMetadata}state(){return this._state}[D(447)](){return this[D(444)]}[J(435)](e){const t=D;this[t(444)]=e}[J(457)](){return this[J(439)]}saveTokens(e){this._tokens=e}[J(450)](e){this[D(443)](e)}saveCodeVerifier(e){this._codeVerifier=e}codeVerifier(){if(!this[D(437)])throw new Error("No code verifier saved");return this._codeVerifier}}(function(r,e){for(var t=Q,n=Q,s=r();;)try{var o=parseInt(t(361))/1*(parseInt(n(363))/2)+-parseInt(t(358))/3+parseInt(t(359))/4*(parseInt(t(357))/5)+parseInt(n(354))/6*(parseInt(t(360))/7)+parseInt(n(362))/8+parseInt(n(364))/9+-parseInt(n(356))/10*(parseInt(t(355))/11);if(o===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(K,-73523*-3+1*-407717+530518);function K(){var r=["40ecBYYe","1095owKKYD","486870YOVwZy","5752xWiyTO","561484biNVMw","1fWJmxQ","1866064SPnyhb","1109522vMiuMX","1602351pPEGwH","12sVyMLL","2573296LTwOhv"];return K=function(){return r},K()}function Q(r,e){var t=K();return Q=function(n,s){n=n-(-1*-642+503*-5+2227);var o=t[n];return o},Q(r,e)}class De{constructor(e,t){const n={name:"web-mcp-server",version:"1.0.0"},s={prompts:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},tools:{listChanged:!0},completions:{},logging:{}};this.server=new $.McpServer(e||n,t||{capabilities:s}),this.server.server.oninitialized=()=>{var o;(o=this.oninitialized)==null||o.call(this)},this.server.server.onclose=()=>{var o;(o=this.onclose)==null||o.call(this)},this.server.server.onerror=o=>{var a;(a=this.onerror)==null||a.call(this,o)},this.server.server.setRequestHandler(w.SetLevelRequestSchema,async()=>({}))}async connect(e){return typeof e.start=="function"?(this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0):(this.transport=new te(e),await this.transport.listen()),await this.server.connect(this.transport),this.transport}async close(){await this.server.close()}registerTool(e,t,n){return this.server.registerTool(e,t,n)}registerPrompt(e,t,n){return this.server.registerPrompt(e,t,n)}registerResource(e,t,n,s){return typeof t=="string"?this.server.registerResource(e,t,n,s):this.server.registerResource(e,t,n,s)}isConnected(){return this.server.isConnected()}sendResourceListChanged(){this.server.sendResourceListChanged()}sendToolListChanged(){this.server.sendToolListChanged()}sendPromptListChanged(){this.server.sendPromptListChanged()}getClientCapabilities(){return this.server.server.getClientCapabilities()}getClientVersion(){return this.server.server.getClientVersion()}async ping(){return await this.server.server.ping()}async createMessage(e,t){return await this.server.server.createMessage(e,t)}async elicitInput(e,t){return await this.server.server.elicitInput(e,t)}async listRoots(e,t){return await this.server.server.listRoots(e,t)}async sendLoggingMessage(e){return await this.server.server.sendLoggingMessage(e)}async sendResourceUpdated(e){return await this.server.server.sendResourceUpdated(e)}request(e,t,n){return this.server.server.request(e,t,n)}async notification(e,t){return await this.server.server.notification(e,t)}setRequestHandler(e,t){this.server.server.setRequestHandler(e,t)}removeRequestHandler(e){this.server.server.removeRequestHandler(e)}setNotificationHandler(e,t){this.server.server.setNotificationHandler(e,t)}removeNotificationHandler(e){this.server.server.removeNotificationHandler(e)}onSubscribe(e){this.server.server.setRequestHandler(w.SubscribeRequestSchema,e)}onUnsubscribe(e){this.server.server.setRequestHandler(w.UnsubscribeRequestSchema,e)}onSetLogLevel(e){this.server.server.setRequestHandler(w.SetLevelRequestSchema,e)}onListResources(e){this.server.server.setRequestHandler(w.ListResourcesRequestSchema,e)}onRootsListChanged(e){this.server.server.setNotificationHandler(w.RootsListChangedNotificationSchema,e)}async onPagehide(e){e.persisted||this.transport&&typeof this.transport.close=="function"&&await this.transport.close()}}const je=(r,e)=>new te(r,e),Ve=()=>be(),ze=r=>r instanceof te,We=r=>r instanceof $.McpServer;class Ae{constructor(e,t){const n={name:"web-mcp-client",version:"1.0.0"},s={roots:{listChanged:!0},sampling:{},elicitation:{}};this.client=new F.Client(e||n,t||{capabilities:s}),this.client.onclose=()=>{var o;(o=this.onclose)==null||o.call(this)},this.client.onerror=o=>{var a;(a=this.onerror)==null||a.call(this,o)}}async connect(e){if(typeof e.start=="function")return this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0,await this.client.connect(this.transport),{transport:this.transport,sessionId:this.transport.sessionId};const{url:t,token:n,sessionId:s,type:o,agent:a,onError:i}=e;if(a===!0){const d={client:this.client,url:t,token:n,sessionId:s};let u;return await(async()=>{const{transport:f,sessionId:_}=o==="sse"?await Ue(d):o==="socket"?await Oe(d):await Ee(d);f.onerror=async x=>{i==null||i(x)},u={transport:f,sessionId:_}})(),u}const c=new URL(t);let l;if(o==="channel"&&(l=new ee(t),await this.client.connect(l)),o==="sse"){const d=ae(n,s);l=new N.SSEClientTransport(c,d),await this.client.connect(l)}if(o==="socket"&&(l=new oe.WebSocketClientTransport(new URL(`${t}?sessionId=${s}&token=${n}`)),l.sessionId=s,await this.client.connect(l)),typeof l>"u"){const d=ce(n,s);l=new z.StreamableHTTPClientTransport(c,d),await this.client.connect(l)}return this.transport=l,{transport:this.transport,sessionId:this.transport.sessionId}}async close(){await this.client.close()}getServerCapabilities(){return this.client.getServerCapabilities()}getServerVersion(){return this.client.getServerVersion()}getInstructions(){return this.client.getInstructions()}async ping(e){return await this.client.ping(e)}async complete(e,t){return await this.client.complete(e,t)}async setLoggingLevel(e,t){return await this.client.setLoggingLevel(e,t)}async getPrompt(e,t){return await this.client.getPrompt(e,t)}async listPrompts(e,t){return await this.client.listPrompts(e,t)}async listResources(e,t){return await this.client.listResources(e,t)}async listResourceTemplates(e,t){return await this.client.listResourceTemplates(e,t)}async readResource(e,t){return await this.client.readResource(e,t)}async subscribeResource(e,t){return await this.client.subscribeResource(e,t)}async unsubscribeResource(e,t){return await this.client.unsubscribeResource(e,t)}async callTool(e,t){return await this.client.callTool(e,w.CallToolResultSchema,t)}async listTools(e,t){return await this.client.listTools(e,t)}async sendRootsListChanged(){return await this.client.sendRootsListChanged()}request(e,t,n){return this.client.request(e,t,n)}async notification(e,t){return await this.client.notification(e,t)}setRequestHandler(e,t){this.client.setRequestHandler(e,t)}removeRequestHandler(e){this.client.removeRequestHandler(e)}setNotificationHandler(e,t){this.client.setNotificationHandler(e,t)}removeNotificationHandler(e){this.client.removeNotificationHandler(e)}onElicit(e){this.client.setRequestHandler(w.ElicitRequestSchema,e)}onCreateMessage(e){this.client.setRequestHandler(w.CreateMessageRequestSchema,e)}onListRoots(e){this.client.setRequestHandler(w.ListRootsRequestSchema,e)}onToolListChanged(e){this.client.setNotificationHandler(w.ToolListChangedNotificationSchema,e)}onPromptListChanged(e){this.client.setNotificationHandler(w.PromptListChangedNotificationSchema,e)}onResourceListChanged(e){this.client.setNotificationHandler(w.ResourceListChangedNotificationSchema,e)}onResourceUpdated(e){this.client.setNotificationHandler(w.ResourceUpdatedNotificationSchema,e)}onLoggingMessage(e){this.client.setNotificationHandler(w.LoggingMessageNotificationSchema,e)}async onPagehide(e){e.persisted||(de(this.transport)?await this.transport.terminateSession():this.transport&&typeof this.transport.close=="function"&&await this.transport.close())}}const Be=(r,e)=>new N.SSEClientTransport(r,e),Ze=(r,e)=>new z.StreamableHTTPClientTransport(r,e),Ye=(r,e)=>new ee(r,e),Je=r=>r instanceof N.SSEClientTransport,de=r=>r instanceof z.StreamableHTTPClientTransport,Ge=r=>r instanceof ee,Ke=r=>r instanceof F.Client,Qe=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)}),X=(r,e,t)=>{window.postMessage({type:r,direction:t,data:e},"*")},ue=(r,e,t)=>{const n=async function(s){s.source===window&&s.data.type===r&&s.data.direction===t&&await e(s.data.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)};class Xe{constructor(e=null,t){this._isStarted=!1,this._isClosed=!1,this._lastRegistration=null,this.sessionId=e||Qe(),this.tabId=t,this._messageListener1=ue("sidepanel-ready-to-page",()=>{this._lastRegistration&&this._isStarted&&this.notifyRegistration(this._lastRegistration).catch(n=>{console.error("【Page Svr Transport】 notifyRegistration失败:",n)})},"content->page"),this._messageListener2=ue("mcp-client-to-server-to-page",n=>{var a,i,c;if(n.sessionId!==this.sessionId||n.tabId!==this.tabId)return;console.log("【Page Svr Transport】 即将处理 mcpMessage",n.mcpMessage);const s=w.JSONRPCMessageSchema.parse(n.mcpMessage);(a=this.onmessage)==null||a.call(this,s),((i=n.mcpMessage.params)==null?void 0:i.name)&&X("update-page-app-message",{status:"run",message:(c=n.mcpMessage.params)==null?void 0:c.name},"page->content")},"content->page")}_throwError(e,t){if(e()){const n=new Error(t);throw console.log(t,n),this.onerror&&this.onerror(n),n}}async start(){if(!this._isStarted){if(this._isClosed)throw new Error("【Page Svr Transport】 已关闭,无法重新启动");this._isStarted=!0}}async send(e,t){var n;this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法发送消息"),this._throwError(()=>this._isClosed,"【Page Svr Transport】 已关闭,无法发送消息"),X("mcp-server-to-client-from-page",{sessionId:this.sessionId,mcpMessage:e},"page->content"),"result"in e&&((n=e.result)!=null&&n.content)&&X("update-page-app-message",{status:"ready",message:""},"page->content")}async notifyRegistration(e){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法注册消息"),this._lastRegistration=e;try{X("mcp-server-register-from-page",{sessionId:this.sessionId,serverInfo:{...e,url:window.location.origin,title:document.title}},"page->content")}catch(t){this._throwError(()=>!0,"【Page Svr Transport】 注册 server 失败"+String(t))}}async close(){if(!this._isClosed)try{this._messageListener1&&this._messageListener1(),this._messageListener2&&this._messageListener2(),this._isClosed=!0,this._isStarted=!1,this.onclose&&this.onclose()}catch(e){this._throwError(()=>!0,"【Page Svr Transport】 关闭时发生错误"+String(e))}}}p.Ajv=O,Object.defineProperty(p,"ResourceTemplate",{enumerable:!0,get:()=>$.ResourceTemplate}),Object.defineProperty(p,"z",{enumerable:!0,get:()=>fe.z}),Object.defineProperty(p,"UriTemplate",{enumerable:!0,get:()=>pe.UriTemplate}),Object.defineProperty(p,"completable",{enumerable:!0,get:()=>xe.completable}),Object.defineProperty(p,"getDisplayName",{enumerable:!0,get:()=>_e.getDisplayName}),p.AuthClientProvider=Ne,p.ExtensionPageServerTransport=Xe,p.WebMcpClient=Ae,p.WebMcpServer=De,p.createMessageChannelClientTransport=Ye,p.createMessageChannelPairTransport=Ve,p.createMessageChannelServerTransport=je,p.createSSEClientTransport=Be,p.createStreamableHTTPClientTransport=Ze,p.isMcpClient=Ke,p.isMcpServer=We,p.isMessageChannelClientTransport=Ge,p.isMessageChannelServerTransport=ze,p.isSSEClientTransport=Je,p.isStreamableHTTPClientTransport=de,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.Zod = {}));
3
- })(this, (function(exports2) {
3
+ })(this, function(exports2) {
4
4
  "use strict";
5
5
  var util;
6
6
  (function(util2) {
@@ -468,7 +468,7 @@
468
468
  var errorUtil;
469
469
  (function(errorUtil2) {
470
470
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
471
- errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
471
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message == null ? void 0 : message.message;
472
472
  })(errorUtil || (errorUtil = {}));
473
473
  class ParseInputLazyPath {
474
474
  constructor(parent, value, path, key) {
@@ -582,10 +582,10 @@
582
582
  const ctx = {
583
583
  common: {
584
584
  issues: [],
585
- async: params?.async ?? false,
586
- contextualErrorMap: params?.errorMap
585
+ async: (params == null ? void 0 : params.async) ?? false,
586
+ contextualErrorMap: params == null ? void 0 : params.errorMap
587
587
  },
588
- path: params?.path || [],
588
+ path: (params == null ? void 0 : params.path) || [],
589
589
  schemaErrorMap: this._def.errorMap,
590
590
  parent: null,
591
591
  data,
@@ -595,6 +595,7 @@
595
595
  return handleResult(ctx, result);
596
596
  }
597
597
  "~validate"(data) {
598
+ var _a, _b;
598
599
  const ctx = {
599
600
  common: {
600
601
  issues: [],
@@ -615,7 +616,7 @@
615
616
  issues: ctx.common.issues
616
617
  };
617
618
  } catch (err) {
618
- if (err?.message?.toLowerCase()?.includes("encountered")) {
619
+ if ((_b = (_a = err == null ? void 0 : err.message) == null ? void 0 : _a.toLowerCase()) == null ? void 0 : _b.includes("encountered")) {
619
620
  this["~standard"].async = true;
620
621
  }
621
622
  ctx.common = {
@@ -640,10 +641,10 @@
640
641
  const ctx = {
641
642
  common: {
642
643
  issues: [],
643
- contextualErrorMap: params?.errorMap,
644
+ contextualErrorMap: params == null ? void 0 : params.errorMap,
644
645
  async: true
645
646
  },
646
- path: params?.path || [],
647
+ path: (params == null ? void 0 : params.path) || [],
647
648
  schemaErrorMap: this._def.errorMap,
648
649
  parent: null,
649
650
  data,
@@ -874,7 +875,7 @@
874
875
  const decoded = JSON.parse(atob(base64));
875
876
  if (typeof decoded !== "object" || decoded === null)
876
877
  return false;
877
- if ("typ" in decoded && decoded?.typ !== "JWT")
878
+ if ("typ" in decoded && (decoded == null ? void 0 : decoded.typ) !== "JWT")
878
879
  return false;
879
880
  if (!decoded.alg)
880
881
  return false;
@@ -1263,10 +1264,10 @@
1263
1264
  }
1264
1265
  return this._addCheck({
1265
1266
  kind: "datetime",
1266
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
1267
- offset: options?.offset ?? false,
1268
- local: options?.local ?? false,
1269
- ...errorUtil.errToObj(options?.message)
1267
+ precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
1268
+ offset: (options == null ? void 0 : options.offset) ?? false,
1269
+ local: (options == null ? void 0 : options.local) ?? false,
1270
+ ...errorUtil.errToObj(options == null ? void 0 : options.message)
1270
1271
  });
1271
1272
  }
1272
1273
  date(message) {
@@ -1282,8 +1283,8 @@
1282
1283
  }
1283
1284
  return this._addCheck({
1284
1285
  kind: "time",
1285
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
1286
- ...errorUtil.errToObj(options?.message)
1286
+ precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
1287
+ ...errorUtil.errToObj(options == null ? void 0 : options.message)
1287
1288
  });
1288
1289
  }
1289
1290
  duration(message) {
@@ -1300,8 +1301,8 @@
1300
1301
  return this._addCheck({
1301
1302
  kind: "includes",
1302
1303
  value,
1303
- position: options?.position,
1304
- ...errorUtil.errToObj(options?.message)
1304
+ position: options == null ? void 0 : options.position,
1305
+ ...errorUtil.errToObj(options == null ? void 0 : options.message)
1305
1306
  });
1306
1307
  }
1307
1308
  startsWith(value, message) {
@@ -1436,7 +1437,7 @@
1436
1437
  return new ZodString({
1437
1438
  checks: [],
1438
1439
  typeName: ZodFirstPartyTypeKind.ZodString,
1439
- coerce: params?.coerce ?? false,
1440
+ coerce: (params == null ? void 0 : params.coerce) ?? false,
1440
1441
  ...processCreateParams(params)
1441
1442
  });
1442
1443
  };
@@ -1676,7 +1677,7 @@
1676
1677
  return new ZodNumber({
1677
1678
  checks: [],
1678
1679
  typeName: ZodFirstPartyTypeKind.ZodNumber,
1679
- coerce: params?.coerce || false,
1680
+ coerce: (params == null ? void 0 : params.coerce) || false,
1680
1681
  ...processCreateParams(params)
1681
1682
  });
1682
1683
  };
@@ -1848,7 +1849,7 @@
1848
1849
  return new ZodBigInt({
1849
1850
  checks: [],
1850
1851
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
1851
- coerce: params?.coerce ?? false,
1852
+ coerce: (params == null ? void 0 : params.coerce) ?? false,
1852
1853
  ...processCreateParams(params)
1853
1854
  });
1854
1855
  };
@@ -1873,7 +1874,7 @@
1873
1874
  ZodBoolean.create = (params) => {
1874
1875
  return new ZodBoolean({
1875
1876
  typeName: ZodFirstPartyTypeKind.ZodBoolean,
1876
- coerce: params?.coerce || false,
1877
+ coerce: (params == null ? void 0 : params.coerce) || false,
1877
1878
  ...processCreateParams(params)
1878
1879
  });
1879
1880
  };
@@ -1981,7 +1982,7 @@
1981
1982
  ZodDate.create = (params) => {
1982
1983
  return new ZodDate({
1983
1984
  checks: [],
1984
- coerce: params?.coerce || false,
1985
+ coerce: (params == null ? void 0 : params.coerce) || false,
1985
1986
  typeName: ZodFirstPartyTypeKind.ZodDate,
1986
1987
  ...processCreateParams(params)
1987
1988
  });
@@ -2355,7 +2356,8 @@
2355
2356
  unknownKeys: "strict",
2356
2357
  ...message !== void 0 ? {
2357
2358
  errorMap: (issue, ctx) => {
2358
- const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2359
+ var _a, _b;
2360
+ const defaultError = ((_b = (_a = this._def).errorMap) == null ? void 0 : _b.call(_a, issue, ctx).message) ?? ctx.defaultError;
2359
2361
  if (issue.code === "unrecognized_keys")
2360
2362
  return {
2361
2363
  message: errorUtil.errToObj(message).message ?? defaultError
@@ -3906,14 +3908,14 @@
3906
3908
  const onumber = () => numberType().optional();
3907
3909
  const oboolean = () => booleanType().optional();
3908
3910
  const coerce = {
3909
- string: ((arg) => ZodString.create({ ...arg, coerce: true })),
3910
- number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
3911
- boolean: ((arg) => ZodBoolean.create({
3911
+ string: (arg) => ZodString.create({ ...arg, coerce: true }),
3912
+ number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
3913
+ boolean: (arg) => ZodBoolean.create({
3912
3914
  ...arg,
3913
3915
  coerce: true
3914
- })),
3915
- bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
3916
- date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
3916
+ }),
3917
+ bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
3918
+ date: (arg) => ZodDate.create({ ...arg, coerce: true })
3917
3919
  };
3918
3920
  const NEVER = INVALID;
3919
3921
  const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -4034,4 +4036,4 @@
4034
4036
  }, Symbol.toStringTag, { value: "Module" }));
4035
4037
  exports2.z = z;
4036
4038
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
4037
- }));
4039
+ });
@@ -464,7 +464,7 @@ const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
464
464
  var errorUtil;
465
465
  (function(errorUtil2) {
466
466
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
467
- errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
467
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message == null ? void 0 : message.message;
468
468
  })(errorUtil || (errorUtil = {}));
469
469
  class ParseInputLazyPath {
470
470
  constructor(parent, value, path, key) {
@@ -578,10 +578,10 @@ class ZodType {
578
578
  const ctx = {
579
579
  common: {
580
580
  issues: [],
581
- async: params?.async ?? false,
582
- contextualErrorMap: params?.errorMap
581
+ async: (params == null ? void 0 : params.async) ?? false,
582
+ contextualErrorMap: params == null ? void 0 : params.errorMap
583
583
  },
584
- path: params?.path || [],
584
+ path: (params == null ? void 0 : params.path) || [],
585
585
  schemaErrorMap: this._def.errorMap,
586
586
  parent: null,
587
587
  data,
@@ -591,6 +591,7 @@ class ZodType {
591
591
  return handleResult(ctx, result);
592
592
  }
593
593
  "~validate"(data) {
594
+ var _a, _b;
594
595
  const ctx = {
595
596
  common: {
596
597
  issues: [],
@@ -611,7 +612,7 @@ class ZodType {
611
612
  issues: ctx.common.issues
612
613
  };
613
614
  } catch (err) {
614
- if (err?.message?.toLowerCase()?.includes("encountered")) {
615
+ if ((_b = (_a = err == null ? void 0 : err.message) == null ? void 0 : _a.toLowerCase()) == null ? void 0 : _b.includes("encountered")) {
615
616
  this["~standard"].async = true;
616
617
  }
617
618
  ctx.common = {
@@ -636,10 +637,10 @@ class ZodType {
636
637
  const ctx = {
637
638
  common: {
638
639
  issues: [],
639
- contextualErrorMap: params?.errorMap,
640
+ contextualErrorMap: params == null ? void 0 : params.errorMap,
640
641
  async: true
641
642
  },
642
- path: params?.path || [],
643
+ path: (params == null ? void 0 : params.path) || [],
643
644
  schemaErrorMap: this._def.errorMap,
644
645
  parent: null,
645
646
  data,
@@ -870,7 +871,7 @@ function isValidJWT(jwt, alg) {
870
871
  const decoded = JSON.parse(atob(base64));
871
872
  if (typeof decoded !== "object" || decoded === null)
872
873
  return false;
873
- if ("typ" in decoded && decoded?.typ !== "JWT")
874
+ if ("typ" in decoded && (decoded == null ? void 0 : decoded.typ) !== "JWT")
874
875
  return false;
875
876
  if (!decoded.alg)
876
877
  return false;
@@ -1259,10 +1260,10 @@ class ZodString extends ZodType {
1259
1260
  }
1260
1261
  return this._addCheck({
1261
1262
  kind: "datetime",
1262
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
1263
- offset: options?.offset ?? false,
1264
- local: options?.local ?? false,
1265
- ...errorUtil.errToObj(options?.message)
1263
+ precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
1264
+ offset: (options == null ? void 0 : options.offset) ?? false,
1265
+ local: (options == null ? void 0 : options.local) ?? false,
1266
+ ...errorUtil.errToObj(options == null ? void 0 : options.message)
1266
1267
  });
1267
1268
  }
1268
1269
  date(message) {
@@ -1278,8 +1279,8 @@ class ZodString extends ZodType {
1278
1279
  }
1279
1280
  return this._addCheck({
1280
1281
  kind: "time",
1281
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
1282
- ...errorUtil.errToObj(options?.message)
1282
+ precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
1283
+ ...errorUtil.errToObj(options == null ? void 0 : options.message)
1283
1284
  });
1284
1285
  }
1285
1286
  duration(message) {
@@ -1296,8 +1297,8 @@ class ZodString extends ZodType {
1296
1297
  return this._addCheck({
1297
1298
  kind: "includes",
1298
1299
  value,
1299
- position: options?.position,
1300
- ...errorUtil.errToObj(options?.message)
1300
+ position: options == null ? void 0 : options.position,
1301
+ ...errorUtil.errToObj(options == null ? void 0 : options.message)
1301
1302
  });
1302
1303
  }
1303
1304
  startsWith(value, message) {
@@ -1432,7 +1433,7 @@ ZodString.create = (params) => {
1432
1433
  return new ZodString({
1433
1434
  checks: [],
1434
1435
  typeName: ZodFirstPartyTypeKind.ZodString,
1435
- coerce: params?.coerce ?? false,
1436
+ coerce: (params == null ? void 0 : params.coerce) ?? false,
1436
1437
  ...processCreateParams(params)
1437
1438
  });
1438
1439
  };
@@ -1672,7 +1673,7 @@ ZodNumber.create = (params) => {
1672
1673
  return new ZodNumber({
1673
1674
  checks: [],
1674
1675
  typeName: ZodFirstPartyTypeKind.ZodNumber,
1675
- coerce: params?.coerce || false,
1676
+ coerce: (params == null ? void 0 : params.coerce) || false,
1676
1677
  ...processCreateParams(params)
1677
1678
  });
1678
1679
  };
@@ -1844,7 +1845,7 @@ ZodBigInt.create = (params) => {
1844
1845
  return new ZodBigInt({
1845
1846
  checks: [],
1846
1847
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
1847
- coerce: params?.coerce ?? false,
1848
+ coerce: (params == null ? void 0 : params.coerce) ?? false,
1848
1849
  ...processCreateParams(params)
1849
1850
  });
1850
1851
  };
@@ -1869,7 +1870,7 @@ class ZodBoolean extends ZodType {
1869
1870
  ZodBoolean.create = (params) => {
1870
1871
  return new ZodBoolean({
1871
1872
  typeName: ZodFirstPartyTypeKind.ZodBoolean,
1872
- coerce: params?.coerce || false,
1873
+ coerce: (params == null ? void 0 : params.coerce) || false,
1873
1874
  ...processCreateParams(params)
1874
1875
  });
1875
1876
  };
@@ -1977,7 +1978,7 @@ class ZodDate extends ZodType {
1977
1978
  ZodDate.create = (params) => {
1978
1979
  return new ZodDate({
1979
1980
  checks: [],
1980
- coerce: params?.coerce || false,
1981
+ coerce: (params == null ? void 0 : params.coerce) || false,
1981
1982
  typeName: ZodFirstPartyTypeKind.ZodDate,
1982
1983
  ...processCreateParams(params)
1983
1984
  });
@@ -2351,7 +2352,8 @@ class ZodObject extends ZodType {
2351
2352
  unknownKeys: "strict",
2352
2353
  ...message !== void 0 ? {
2353
2354
  errorMap: (issue, ctx) => {
2354
- const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2355
+ var _a, _b;
2356
+ const defaultError = ((_b = (_a = this._def).errorMap) == null ? void 0 : _b.call(_a, issue, ctx).message) ?? ctx.defaultError;
2355
2357
  if (issue.code === "unrecognized_keys")
2356
2358
  return {
2357
2359
  message: errorUtil.errToObj(message).message ?? defaultError
@@ -3902,14 +3904,14 @@ const ostring = () => stringType().optional();
3902
3904
  const onumber = () => numberType().optional();
3903
3905
  const oboolean = () => booleanType().optional();
3904
3906
  const coerce = {
3905
- string: ((arg) => ZodString.create({ ...arg, coerce: true })),
3906
- number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
3907
- boolean: ((arg) => ZodBoolean.create({
3907
+ string: (arg) => ZodString.create({ ...arg, coerce: true }),
3908
+ number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
3909
+ boolean: (arg) => ZodBoolean.create({
3908
3910
  ...arg,
3909
3911
  coerce: true
3910
- })),
3911
- bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
3912
- date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
3912
+ }),
3913
+ bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
3914
+ date: (arg) => ZodDate.create({ ...arg, coerce: true })
3913
3915
  };
3914
3916
  const NEVER = INVALID;
3915
3917
  const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({