mcp-music-studio 0.4.0 → 0.4.2

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.
package/README.md CHANGED
@@ -43,6 +43,7 @@ Write code → hear it play → edit in a live REPL.
43
43
  - **72 drum machine banks** + **128 GM instruments** + built-in synths
44
44
  - **Full effects chain** — filters, reverb, delay, FM synthesis
45
45
  - **Editable REPL** — users can tweak the code and hear changes instantly
46
+ - **Live visuals** — add `.pianoroll()` / `.scope()` / `.spectrum()` to animate behind the code (native strudel.cc overlay)
46
47
  - **Record & download** — capture live audio and export as WAV
47
48
  - **`get-strudel-guide`** — 7 reference topics (mini-notation, sounds, effects, patterns, genres, tips, advanced)
48
49
 
package/dist/mcp-app.html CHANGED
@@ -228,7 +228,7 @@ X:`),l=o.length;return l===0&&(l=1),l};var r=a.TuneBook=function(s){var o=t(s);t
228
228
  `)}
229
229
  `):`${a.join(`
230
230
  `)}
231
- ${n}`}function _3(e){const t=y3(e),n={};return e.swing!==void 0&&(n.swing=e.swing),{...t,abcNotation:e.abcNotation?w3(e.abcNotation,e):void 0,synthOptions:n}}function k3(e){const t=e.numberOfChannels,n=e.sampleRate,a=e.length,r=2,s=a*t*r,o=44,l=new ArrayBuffer(o+s),h=new DataView(l);sr(h,0,"RIFF"),h.setUint32(4,36+s,!0),sr(h,8,"WAVE"),sr(h,12,"fmt "),h.setUint32(16,16,!0),h.setUint16(20,1,!0),h.setUint16(22,t,!0),h.setUint32(24,n,!0),h.setUint32(28,n*t*r,!0),h.setUint16(32,t*r,!0),h.setUint16(34,16,!0),sr(h,36,"data"),h.setUint32(40,s,!0);const g=Array.from({length:t},(u,i)=>e.getChannelData(i));let p=44;for(let u=0;u<a;u++)for(let i=0;i<t;i++){const v=Math.max(-1,Math.min(1,g[i][u]));h.setInt16(p,v<0?v*32768:v*32767,!0),p+=2}const d=new Uint8Array(l);let f="";const c=8192;for(let u=0;u<d.length;u+=c)f+=String.fromCharCode(...d.subarray(u,u+c));return btoa(f)}function sr(e,t,n){for(let a=0;a<n.length;a++)e.setUint8(t+a,n.charCodeAt(a))}const C3="0.4.0",he={visualObj:null,synthControl:null,currentInstrument:du,currentStyle:"",currentAbc:null,highlightedEls:[]},or=document.querySelector(".main"),zc=document.getElementById("status"),St=document.getElementById("sheet-music"),ya=document.getElementById("audio-controls"),gu=document.getElementById("instrument-selector"),vu=document.getElementById("style-selector"),Tr=document.getElementById("toolbar");"audioSession"in navigator&&(navigator.audioSession.type="playback");const x3={onEvent(e){if(he.highlightedEls.forEach(t=>t.classList.remove("note-playing")),he.highlightedEls=[],!!e.elements){for(const t of e.elements)for(const n of t)n.classList.add("note-playing"),he.highlightedEls.push(n);he.highlightedEls.length>0&&he.highlightedEls[0].scrollIntoView({behavior:"smooth",block:"nearest"})}},onFinished(){he.highlightedEls.forEach(e=>e.classList.remove("note-playing")),he.highlightedEls=[]}},Tt=document.createElement("select");Tt.id="instrument-select";Tt.className="control-select";for(const e of Object.keys(jt)){const t=document.createElement("option");t.value=e,t.textContent=e,e===he.currentInstrument&&(t.selected=!0),Tt.appendChild(t)}Tt.addEventListener("change",()=>{he.currentInstrument=Tt.value,he.visualObj&&he.synthControl&&S3()});async function S3(){var e;if(!(!he.synthControl||!((e=he.visualObj)!=null&&e[0])))try{const n={program:jt[he.currentInstrument]??0};await he.synthControl.setTune(he.visualObj[0],!1,n)}catch(t){console.error("Failed to apply settings:",t)}}const Er=document.createElement("label");Er.className="control-label";Er.htmlFor="instrument-select";Er.textContent="Instrument";gu.appendChild(Er);gu.appendChild(Tt);const ht=document.createElement("select");ht.id="style-select";ht.className="control-select";const bi=document.createElement("option");bi.value="";bi.textContent="No style (melody only)";ht.appendChild(bi);for(const e of Object.keys(vi)){const t=document.createElement("option");t.value=e,t.textContent=e.charAt(0).toUpperCase()+e.slice(1),ht.appendChild(t)}ht.addEventListener("change",()=>{he.currentStyle=ht.value,he.currentAbc&&mu(he.currentAbc)});const Ar=document.createElement("label");Ar.className="control-label";Ar.htmlFor="style-select";Ar.textContent="Style";vu.appendChild(Ar);vu.appendChild(ht);let lr=null;const Ht=document.createElement("button");Ht.className="toolbar-btn";Ht.textContent="⛶";Ht.title="Toggle fullscreen";Ht.setAttribute("aria-label","Toggle fullscreen");Ht.addEventListener("click",()=>{lr==null||lr.requestDisplayMode({mode:"fullscreen"})});Tr.appendChild(Ht);const Ve=document.createElement("button");Ve.className="toolbar-btn";Ve.textContent="↓";Ve.title="Download audio (WAV)";Ve.setAttribute("aria-label","Download audio as WAV");Ve.disabled=!0;Tr.appendChild(Ve);let Sa=!1,Ta=!1;function T3(e){if(!e)return"music";const t=e.match(/T:\s*(.+)/);return t?t[1].trim().replace(/[^a-zA-Z0-9_-]/g,"_"):"music"}Ve.addEventListener("click",async()=>{var n;if(!he.synthControl)return;const e=he.synthControl.midiBuffer,t=(n=e==null?void 0:e.getAudioBuffer)==null?void 0:n.call(e);if(!t){st("Play first to generate audio",!0);return}Ve.disabled=!0,Ve.textContent="...";try{const a=k3(t),r=T3(he.currentAbc);await et.downloadFile({contents:[{type:"resource",resource:{uri:`file:///${r}.wav`,mimeType:"audio/wav",blob:a}}]})}catch(a){st(`Download failed: ${a.message}`,!0)}finally{Ve.disabled=!1,Ve.textContent="↓"}});const je=document.createElement("button");je.className="toolbar-btn";je.textContent="↗";je.title="Send this ABC to chat";je.setAttribute("aria-label","Send this ABC notation to the chat");je.disabled=!0;je.hidden=!0;Tr.appendChild(je);je.addEventListener("click",async()=>{if(he.currentAbc){je.disabled=!0,je.textContent="...";try{await et.sendMessage({role:"user",content:[{type:"text",text:"Here's my ABC notation:\n```\n"+he.currentAbc+"\n```"}]})}catch(e){st(`Send failed: ${e.message}`,!0)}finally{je.disabled=!1,je.textContent="↗"}}});function st(e,t=!1){zc.textContent=e,zc.classList.toggle("error",t)}function E3(e){if(st(e),!he.visualObj){const t=document.createElement("div");t.className="loading-skeleton",t.setAttribute("role","status"),t.setAttribute("aria-live","polite");const n=document.createElement("span");n.className="spinner",n.setAttribute("aria-hidden","true");const a=document.createElement("span");a.textContent=e,t.append(n,a),St.replaceChildren(t)}}async function mu(e,t){var n;try{st("Rendering..."),he.synthControl&&he.synthControl.pause(),he.currentAbc=e,St.innerHTML="",ya.innerHTML="";const a=pu(e,he.currentStyle);if(he.visualObj=cr.renderAbc(St,a,{responsive:"resize",add_classes:!0}),!he.visualObj||he.visualObj.length===0)throw new Error("Failed to parse music notation");if(!cr.synth.supportsAudio())throw new Error("Audio not supported in this browser");he.synthControl=new cr.synth.SynthController,he.synthControl.load(ya,x3,{displayLoop:!0,displayPlay:!0,displayProgress:!0,displayWarp:!0});const s={program:jt[he.currentInstrument]??0,...t};await he.synthControl.setTune(he.visualObj[0],!1,s),Tr.classList.add("visible"),Ve.disabled=!Sa,je.disabled=!Ta,(n=he.synthControl.play())==null||n.then(()=>st("Playing...")).catch(o=>{console.debug("Autoplay blocked:",o),st("Click ▶ to play")})}catch(a){console.error("Render error:",a),st(`Error: ${a.message}`,!0),ya.innerHTML=""}}const et=new Ag({name:"Music Studio",version:C3});lr=et;et.ontoolinput=e=>{console.info("Received tool input:",e);const t=_3(e.arguments??{});he.currentInstrument=t.instrument,Tt.value=t.instrument,he.currentStyle=t.style,ht.value=t.style,t.abcNotation?mu(t.abcNotation,t.synthOptions).catch(console.error):st("No ABC notation provided",!0)};let zt=null,Ea="";et.ontoolinputpartial=e=>{var a,r;const t=(a=e.arguments)==null?void 0:a.abcNotation;if(!t)return;he.currentAbc=t;const n=(r=e.arguments)==null?void 0:r.style;if(n&&mi(n)&&he.currentStyle!==n&&(he.currentStyle=n,ht.value=n),!t.match(/K:[^\n]+/)){E3("Composing…");return}t!==Ea&&(Ea=t,zt&&clearTimeout(zt),zt=setTimeout(()=>{try{const s=pu(t,he.currentStyle);cr.renderAbc(St,s,{responsive:"resize",add_classes:!0}),St.scrollTop=St.scrollHeight;const o=St.closest(".sheet-section");o&&(o.scrollTop=o.scrollHeight),st("Composing...")}catch{}},150))};et.onerror=console.error;function bu(){var e;try{(e=he.synthControl)==null||e.pause()}catch{}he.highlightedEls.forEach(t=>t.classList.remove("note-playing")),he.highlightedEls=[]}function yu(){zt&&(clearTimeout(zt),zt=null),Ea=""}et.ontoolcancelled=e=>{bu(),yu();const t=e!=null&&e.reason?` (${e.reason})`:"";st(`Composition cancelled${t}.`)};et.onteardown=()=>(bu(),yu(),{});function wu(e){var t;e.theme&&Tg(e.theme),(t=e.styles)!=null&&t.variables&&Eg(e.styles.variables),e.safeAreaInsets&&(or.style.paddingTop=`${e.safeAreaInsets.top}px`,or.style.paddingRight=`${e.safeAreaInsets.right}px`,or.style.paddingBottom=`${e.safeAreaInsets.bottom}px`,or.style.paddingLeft=`${e.safeAreaInsets.left}px`)}et.onhostcontextchanged=wu;et.connect().then(()=>{var t,n;Sa=!!((t=et.getHostCapabilities())!=null&&t.downloadFile),Sa||(Ve.hidden=!0,Ve.disabled=!0,Ve.title="Audio download isn't supported by this host"),Ta=!!((n=et.getHostCapabilities())!=null&&n.message),Ta?je.hidden=!1:(je.disabled=!0,je.title="Sending to chat isn't supported by this host");const e=et.getHostContext();e&&wu(e)});</script>
231
+ ${n}`}function _3(e){const t=y3(e),n={};return e.swing!==void 0&&(n.swing=e.swing),{...t,abcNotation:e.abcNotation?w3(e.abcNotation,e):void 0,synthOptions:n}}function k3(e){const t=e.numberOfChannels,n=e.sampleRate,a=e.length,r=2,s=a*t*r,o=44,l=new ArrayBuffer(o+s),h=new DataView(l);sr(h,0,"RIFF"),h.setUint32(4,36+s,!0),sr(h,8,"WAVE"),sr(h,12,"fmt "),h.setUint32(16,16,!0),h.setUint16(20,1,!0),h.setUint16(22,t,!0),h.setUint32(24,n,!0),h.setUint32(28,n*t*r,!0),h.setUint16(32,t*r,!0),h.setUint16(34,16,!0),sr(h,36,"data"),h.setUint32(40,s,!0);const g=Array.from({length:t},(u,i)=>e.getChannelData(i));let p=44;for(let u=0;u<a;u++)for(let i=0;i<t;i++){const v=Math.max(-1,Math.min(1,g[i][u]));h.setInt16(p,v<0?v*32768:v*32767,!0),p+=2}const d=new Uint8Array(l);let f="";const c=8192;for(let u=0;u<d.length;u+=c)f+=String.fromCharCode(...d.subarray(u,u+c));return btoa(f)}function sr(e,t,n){for(let a=0;a<n.length;a++)e.setUint8(t+a,n.charCodeAt(a))}const C3="0.4.2",he={visualObj:null,synthControl:null,currentInstrument:du,currentStyle:"",currentAbc:null,highlightedEls:[]},or=document.querySelector(".main"),zc=document.getElementById("status"),St=document.getElementById("sheet-music"),ya=document.getElementById("audio-controls"),gu=document.getElementById("instrument-selector"),vu=document.getElementById("style-selector"),Tr=document.getElementById("toolbar");"audioSession"in navigator&&(navigator.audioSession.type="playback");const x3={onEvent(e){if(he.highlightedEls.forEach(t=>t.classList.remove("note-playing")),he.highlightedEls=[],!!e.elements){for(const t of e.elements)for(const n of t)n.classList.add("note-playing"),he.highlightedEls.push(n);he.highlightedEls.length>0&&he.highlightedEls[0].scrollIntoView({behavior:"smooth",block:"nearest"})}},onFinished(){he.highlightedEls.forEach(e=>e.classList.remove("note-playing")),he.highlightedEls=[]}},Tt=document.createElement("select");Tt.id="instrument-select";Tt.className="control-select";for(const e of Object.keys(jt)){const t=document.createElement("option");t.value=e,t.textContent=e,e===he.currentInstrument&&(t.selected=!0),Tt.appendChild(t)}Tt.addEventListener("change",()=>{he.currentInstrument=Tt.value,he.visualObj&&he.synthControl&&S3()});async function S3(){var e;if(!(!he.synthControl||!((e=he.visualObj)!=null&&e[0])))try{const n={program:jt[he.currentInstrument]??0};await he.synthControl.setTune(he.visualObj[0],!1,n)}catch(t){console.error("Failed to apply settings:",t)}}const Er=document.createElement("label");Er.className="control-label";Er.htmlFor="instrument-select";Er.textContent="Instrument";gu.appendChild(Er);gu.appendChild(Tt);const ht=document.createElement("select");ht.id="style-select";ht.className="control-select";const bi=document.createElement("option");bi.value="";bi.textContent="No style (melody only)";ht.appendChild(bi);for(const e of Object.keys(vi)){const t=document.createElement("option");t.value=e,t.textContent=e.charAt(0).toUpperCase()+e.slice(1),ht.appendChild(t)}ht.addEventListener("change",()=>{he.currentStyle=ht.value,he.currentAbc&&mu(he.currentAbc)});const Ar=document.createElement("label");Ar.className="control-label";Ar.htmlFor="style-select";Ar.textContent="Style";vu.appendChild(Ar);vu.appendChild(ht);let lr=null;const Ht=document.createElement("button");Ht.className="toolbar-btn";Ht.textContent="⛶";Ht.title="Toggle fullscreen";Ht.setAttribute("aria-label","Toggle fullscreen");Ht.addEventListener("click",()=>{lr==null||lr.requestDisplayMode({mode:"fullscreen"})});Tr.appendChild(Ht);const Ve=document.createElement("button");Ve.className="toolbar-btn";Ve.textContent="↓";Ve.title="Download audio (WAV)";Ve.setAttribute("aria-label","Download audio as WAV");Ve.disabled=!0;Tr.appendChild(Ve);let Sa=!1,Ta=!1;function T3(e){if(!e)return"music";const t=e.match(/T:\s*(.+)/);return t?t[1].trim().replace(/[^a-zA-Z0-9_-]/g,"_"):"music"}Ve.addEventListener("click",async()=>{var n;if(!he.synthControl)return;const e=he.synthControl.midiBuffer,t=(n=e==null?void 0:e.getAudioBuffer)==null?void 0:n.call(e);if(!t){st("Play first to generate audio",!0);return}Ve.disabled=!0,Ve.textContent="...";try{const a=k3(t),r=T3(he.currentAbc);await et.downloadFile({contents:[{type:"resource",resource:{uri:`file:///${r}.wav`,mimeType:"audio/wav",blob:a}}]})}catch(a){st(`Download failed: ${a.message}`,!0)}finally{Ve.disabled=!1,Ve.textContent="↓"}});const je=document.createElement("button");je.className="toolbar-btn";je.textContent="↗";je.title="Send this ABC to chat";je.setAttribute("aria-label","Send this ABC notation to the chat");je.disabled=!0;je.hidden=!0;Tr.appendChild(je);je.addEventListener("click",async()=>{if(he.currentAbc){je.disabled=!0,je.textContent="...";try{await et.sendMessage({role:"user",content:[{type:"text",text:"Here's my ABC notation:\n```\n"+he.currentAbc+"\n```"}]})}catch(e){st(`Send failed: ${e.message}`,!0)}finally{je.disabled=!1,je.textContent="↗"}}});function st(e,t=!1){zc.textContent=e,zc.classList.toggle("error",t)}function E3(e){if(st(e),!he.visualObj){const t=document.createElement("div");t.className="loading-skeleton",t.setAttribute("role","status"),t.setAttribute("aria-live","polite");const n=document.createElement("span");n.className="spinner",n.setAttribute("aria-hidden","true");const a=document.createElement("span");a.textContent=e,t.append(n,a),St.replaceChildren(t)}}async function mu(e,t){var n;try{st("Rendering..."),he.synthControl&&he.synthControl.pause(),he.currentAbc=e,St.innerHTML="",ya.innerHTML="";const a=pu(e,he.currentStyle);if(he.visualObj=cr.renderAbc(St,a,{responsive:"resize",add_classes:!0}),!he.visualObj||he.visualObj.length===0)throw new Error("Failed to parse music notation");if(!cr.synth.supportsAudio())throw new Error("Audio not supported in this browser");he.synthControl=new cr.synth.SynthController,he.synthControl.load(ya,x3,{displayLoop:!0,displayPlay:!0,displayProgress:!0,displayWarp:!0});const s={program:jt[he.currentInstrument]??0,...t};await he.synthControl.setTune(he.visualObj[0],!1,s),Tr.classList.add("visible"),Ve.disabled=!Sa,je.disabled=!Ta,(n=he.synthControl.play())==null||n.then(()=>st("Playing...")).catch(o=>{console.debug("Autoplay blocked:",o),st("Click ▶ to play")})}catch(a){console.error("Render error:",a),st(`Error: ${a.message}`,!0),ya.innerHTML=""}}const et=new Ag({name:"Music Studio",version:C3});lr=et;et.ontoolinput=e=>{console.info("Received tool input:",e);const t=_3(e.arguments??{});he.currentInstrument=t.instrument,Tt.value=t.instrument,he.currentStyle=t.style,ht.value=t.style,t.abcNotation?mu(t.abcNotation,t.synthOptions).catch(console.error):st("No ABC notation provided",!0)};let zt=null,Ea="";et.ontoolinputpartial=e=>{var a,r;const t=(a=e.arguments)==null?void 0:a.abcNotation;if(!t)return;he.currentAbc=t;const n=(r=e.arguments)==null?void 0:r.style;if(n&&mi(n)&&he.currentStyle!==n&&(he.currentStyle=n,ht.value=n),!t.match(/K:[^\n]+/)){E3("Composing…");return}t!==Ea&&(Ea=t,zt&&clearTimeout(zt),zt=setTimeout(()=>{try{const s=pu(t,he.currentStyle);cr.renderAbc(St,s,{responsive:"resize",add_classes:!0}),St.scrollTop=St.scrollHeight;const o=St.closest(".sheet-section");o&&(o.scrollTop=o.scrollHeight),st("Composing...")}catch{}},150))};et.onerror=console.error;function bu(){var e;try{(e=he.synthControl)==null||e.pause()}catch{}he.highlightedEls.forEach(t=>t.classList.remove("note-playing")),he.highlightedEls=[]}function yu(){zt&&(clearTimeout(zt),zt=null),Ea=""}et.ontoolcancelled=e=>{bu(),yu();const t=e!=null&&e.reason?` (${e.reason})`:"";st(`Composition cancelled${t}.`)};et.onteardown=()=>(bu(),yu(),{});function wu(e){var t;e.theme&&Tg(e.theme),(t=e.styles)!=null&&t.variables&&Eg(e.styles.variables),e.safeAreaInsets&&(or.style.paddingTop=`${e.safeAreaInsets.top}px`,or.style.paddingRight=`${e.safeAreaInsets.right}px`,or.style.paddingBottom=`${e.safeAreaInsets.bottom}px`,or.style.paddingLeft=`${e.safeAreaInsets.left}px`)}et.onhostcontextchanged=wu;et.connect().then(()=>{var t,n;Sa=!!((t=et.getHostCapabilities())!=null&&t.downloadFile),Sa||(Ve.hidden=!0,Ve.disabled=!0,Ve.title="Audio download isn't supported by this host"),Ta=!!((n=et.getHostCapabilities())!=null&&n.message),Ta?je.hidden=!1:(je.disabled=!0,je.title="Sending to chat isn't supported by this host");const e=et.getHostContext();e&&wu(e)});</script>
232
232
  <style rel="stylesheet" crossorigin>.abcjs-inline-audio{height:26px;padding:0 5px;border-radius:3px;background-color:#424242;display:flex;align-items:center;box-sizing:border-box}.abcjs-inline-audio.abcjs-disabled{opacity:.5}.abcjs-inline-audio .abcjs-btn{display:block;width:28px;height:34px;margin-right:2px;padding:7px 4px;background:none!important;border:1px solid transparent;box-sizing:border-box;line-height:1}.abcjs-btn g{fill:#f4f4f4;stroke:#f4f4f4}.abcjs-inline-audio .abcjs-btn:hover g{fill:#ccc;stroke:#ccc}.abcjs-inline-audio .abcjs-midi-selection.abcjs-pushed,.abcjs-inline-audio .abcjs-midi-loop.abcjs-pushed,.abcjs-inline-audio .abcjs-midi-reset.abcjs-pushed{border:1px solid #cccccc;background-color:#666;box-sizing:border-box}.abcjs-inline-audio .abcjs-midi-start .abcjs-pause-svg,.abcjs-inline-audio .abcjs-midi-start .abcjs-loading-svg,.abcjs-inline-audio .abcjs-midi-start.abcjs-pushed .abcjs-play-svg,.abcjs-inline-audio .abcjs-midi-start.abcjs-loading .abcjs-play-svg{display:none}.abcjs-inline-audio .abcjs-midi-start.abcjs-pushed .abcjs-pause-svg{display:block}.abcjs-inline-audio .abcjs-midi-progress-background{background-color:#424242;height:10px;border-radius:5px;border:2px solid #cccccc;margin:0 8px 0 15px;position:relative;flex:1;padding:0;box-sizing:border-box}.abcjs-inline-audio .abcjs-midi-progress-indicator{width:20px;margin-left:-10px;height:14px;background-color:#f4f4f4;position:absolute;display:inline-block;border-radius:6px;top:-4px;left:0;box-sizing:border-box}.abcjs-inline-audio .abcjs-midi-clock{margin-left:4px;margin-top:1px;margin-right:2px;display:inline-block;font-family:sans-serif;font-size:16px;box-sizing:border-box;color:#f4f4f4}.abcjs-inline-audio .abcjs-tempo-wrapper{font-size:10px;color:#f4f4f4;box-sizing:border-box;display:flex;align-items:center}.abcjs-inline-audio .abcjs-midi-tempo{border-radius:2px;border:none;margin:0 2px 0 4px;width:42px;padding-left:2px;box-sizing:border-box}.abcjs-inline-audio .abcjs-loading .abcjs-loading-svg{display:inherit}.abcjs-inline-audio .abcjs-loading{outline:none;animation-name:abcjs-spin;animation-duration:1s;animation-iteration-count:infinite;animation-timing-function:linear}.abcjs-inline-audio .abcjs-loading-svg circle{stroke:#f4f4f4}@keyframes abcjs-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.abcjs-large .abcjs-inline-audio{height:52px}.abcjs-large .abcjs-btn{width:56px;height:52px;font-size:28px;padding:6px 8px}.abcjs-large .abcjs-midi-progress-background{height:20px;border:4px solid #cccccc}.abcjs-large .abcjs-midi-progress-indicator{height:28px;top:-8px;width:40px}.abcjs-large .abcjs-midi-clock{font-size:32px;margin-right:10px;margin-left:10px;margin-top:-1px}.abcjs-large .abcjs-midi-tempo{font-size:20px;width:50px}.abcjs-large .abcjs-tempo-wrapper{font-size:20px}.abcjs-css-warning{display:none}*{box-sizing:border-box}html,body{font-family:system-ui,-apple-system,sans-serif;font-size:1rem}code{font-size:1em}:root{--color-bg: #ffffff;--color-text: #1f2937;--color-text-muted: #6b7280;--color-primary: #2563eb;--color-success: #10b981;--color-danger: #ef4444;--color-card-bg: #f9fafb;--color-border: #e5e7eb}@media(prefers-color-scheme:dark){:root{--color-bg: #111827;--color-text: #f9fafb;--color-text-muted: #9ca3af;--color-primary: #3b82f6;--color-success: #34d399;--color-danger: #f87171;--color-card-bg: #1f2937;--color-border: #374151}}:root[data-theme=dark]{--color-bg: #111827;--color-text: #f9fafb;--color-text-muted: #9ca3af;--color-primary: #3b82f6;--color-success: #34d399;--color-danger: #f87171;--color-card-bg: #1f2937;--color-border: #374151}:root[data-theme=light]{--color-bg: #ffffff;--color-text: #1f2937;--color-text-muted: #6b7280;--color-primary: #2563eb;--color-success: #10b981;--color-danger: #ef4444;--color-card-bg: #f9fafb;--color-border: #e5e7eb}html,body{margin:0;padding:0;background:var(--color-bg);color:var(--color-text)}.main{width:100%;margin:0 auto;padding:8px;display:flex;flex-direction:column;gap:8px}.header{display:flex;flex-direction:column;gap:6px}#audio-controls:empty{display:none}#audio-controls:not(:empty)~#status{display:none}.audio-controls{width:100%}.audio-controls .abcjs-inline-audio{border-radius:8px}.audio-controls .abcjs-inline-audio .abcjs-midi-loop.abcjs-pushed{background-color:var(--color-success)!important;border-color:var(--color-success)!important}.status{font-size:.875rem;color:var(--color-text-muted)}.status.error{color:var(--color-danger)}.toolbar{display:none;flex-wrap:wrap;gap:8px}.toolbar.visible{display:flex}.toolbar-group{display:flex;align-items:center;gap:6px;flex:1;min-width:140px}.control-label{font-size:.75rem;color:var(--color-text-muted);white-space:nowrap;text-transform:uppercase;letter-spacing:.05em}.control-select{flex:1;padding:5px 8px;border:1px solid var(--color-border);border-radius:6px;background:var(--color-card-bg);color:var(--color-text);font-size:.8125rem;cursor:pointer;min-width:0}.control-select:focus{outline:2px solid var(--color-primary);outline-offset:-1px}.toolbar-btn{padding:5px 10px;border:1px solid var(--color-border);border-radius:6px;background:var(--color-card-bg);color:var(--color-text);font-size:1rem;cursor:pointer;line-height:1}.toolbar-btn:hover{background:var(--color-border)}.toolbar-btn:disabled{opacity:.4;cursor:default}.toolbar-btn:disabled:hover{background:var(--color-card-bg)}.loading-skeleton{display:flex;align-items:center;justify-content:center;gap:10px;min-height:160px;color:var(--color-text-muted);font-size:.875rem}.spinner{width:18px;height:18px;border:2px solid var(--color-border);border-top-color:var(--color-primary);border-radius:50%;animation:spinner-rotate .7s linear infinite}@keyframes spinner-rotate{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.spinner{animation-duration:2s}}.note-playing path,.note-playing circle,.note-playing ellipse,.note-playing polygon{fill:var(--color-primary)!important;stroke:var(--color-primary)!important;stroke-width:1.5px;transition:fill .08s ease}.note-playing path[stroke]{stroke:var(--color-primary)!important}.sheet-section{background:var(--color-card-bg);border-radius:8px;padding:16px;border:1px solid var(--color-border);min-height:200px;max-height:80vh;overflow-y:auto;scroll-behavior:smooth}.sheet-section .sheet-music-container{width:100%;overflow-x:auto}</style>
233
233
  </head>
234
234
  <body>
package/dist/server.js CHANGED
@@ -52759,6 +52759,14 @@ function advertiseUiExtension(rawServer) {
52759
52759
  });
52760
52760
  }
52761
52761
  var SERVER_INSTRUCTIONS = "Music Studio renders music in interactive widgets. Two creative modes: " + "play-sheet-music (write ABC notation → sheet music + multi-instrument audio) and " + "play-live-pattern (write Strudel/TidalCycles code → an editable live-coding REPL). " + "Before composing, consult the reference tools: get-music-guide (ABC — start with " + "topic 'genres' for templates, 'styles' for accompaniment presets, 'instruments' for the list) " + "or get-strudel-guide (Strudel — 'genres', 'sounds', 'effects'). Use search-music-docs only " + "when the curated guides don't cover something. For ABC accompaniment, include chord symbols " + '("C", "Am7") above the notes and set a style.';
52762
+ var WEBSITE_URL = "https://mcp-music-studio.linxule.workers.dev";
52763
+ var LOGO_URL = "https://raw.githubusercontent.com/linxule/mcp-music-studio/main/assets/icons/logo-256.png";
52764
+ var SERVER_ICONS = [
52765
+ { src: LOGO_URL, mimeType: "image/png", sizes: ["256x256"] }
52766
+ ];
52767
+ var WORKER_SERVER_ICONS = [
52768
+ { src: `${WEBSITE_URL}/icon.png`, mimeType: "image/png", sizes: ["256x256"] }
52769
+ ];
52762
52770
  var PLAY_TOOL_ANNOTATIONS = {
52763
52771
  readOnlyHint: true,
52764
52772
  destructiveHint: false,
@@ -52807,7 +52815,7 @@ var playSheetInputSchema = exports_external.object({
52807
52815
  swing: exports_external.number().min(0).max(100).optional().describe("Swing percentage (0-100). 0=straight, 33=light swing, 66=heavy swing. Great for jazz and blues."),
52808
52816
  transpose: exports_external.number().min(-12).max(12).optional().describe("Transpose by semitones (-12 to 12). Positive=higher, negative=lower.")
52809
52817
  });
52810
- var PLAY_LIVE_BASE_DESCRIPTION = "Live-code music patterns using TidalCycles mini-notation in JavaScript. " + "Layer drums, synths, and bass with stack(). Choose from 72 drum machine banks, " + "128 GM instruments, built-in synths, and a full effects chain. " + "Patterns play in a REPL the user can edit directly. " + "Use get-strudel-guide for genre templates, sound references, and advanced features " + "like visualization, arrangement, and sample loading.";
52818
+ var PLAY_LIVE_BASE_DESCRIPTION = "Live-code music patterns using TidalCycles mini-notation in JavaScript. " + "Layer drums, synths, and bass with stack(). Choose from 72 drum machine banks, " + "128 GM instruments, built-in synths, and a full effects chain. " + "Patterns play in a REPL the user can edit directly. " + "Add .pianoroll() to a pattern to show a live piano-roll animation in the widget " + "(or .punchcard()/.scope()/.spectrum() — use one visual per pattern). " + "Use get-strudel-guide for genre templates, sound references, and advanced features " + "like visualization, arrangement, and sample loading.";
52811
52819
  var PLAY_LIVE_EXT_APPS_SUFFIX = `
52812
52820
 
52813
52821
  The Strudel REPL renders inline with an editable code editor, ` + "visualizations, and playback controls.";
@@ -54068,22 +54076,37 @@ Fills: .every(8, s("bd sd [sd sd] [sd sd sd sd]"))`,
54068
54076
  advanced: `# Strudel Advanced Features
54069
54077
 
54070
54078
  ## Visualization
54071
- Add to any pattern to see it visually.
54072
-
54073
- .pianoroll() scrolling piano roll (best for melodies)
54074
- .pianoroll({cycles:4}) show 4 cycles
54075
- .scope() oscilloscope (time-domain waveform)
54076
- .fscope() frequency spectrum
54077
- .spiral() circular spiral display
54079
+ Add ONE visualization method to a pattern to see it animate live in the widget.
54080
+ The animation renders BEHIND the code (like strudel.cc) and appears automatically
54081
+ when your pattern includes a visual — the user can also toggle it with the
54082
+ "Visuals" button. This works inline in ext-apps hosts (Claude Desktop) encourage it!
54083
+
54084
+ .pianoroll() scrolling piano roll (best for melodies/chords)
54085
+ .pianoroll({ cycles: 4 }) show 4 cycles at once
54086
+ .punchcard() grid of note blocks (good for drums/rhythm)
54087
+ .scope() oscilloscope — time-domain waveform (needs audio playing)
54088
+ .spectrum() frequency-spectrum analyzer (needs audio playing)
54089
+ .pitchwheel() notes arranged around a color wheel
54090
+ .spiral() spiral display
54078
54091
 
54079
54092
  Example:
54080
54093
  note("c3 e3 g3 c4").s("sawtooth").lpf(2000).pianoroll()
54081
54094
 
54082
- **Note:** Visualization works in browser mode (--render-mode browser) and
54083
- standalone Strudel.cc. In ext-apps (Claude Desktop inline widget), the
54084
- visualization canvas is hidden for layout reasons the code editor takes
54085
- priority. Audio and the editable REPL still work; only the visual display
54086
- is suppressed. If you want visualization, suggest the user open in browser.
54095
+ ### pianoroll options
54096
+ .pianoroll({ cycles: 4, playhead: 0.5, vertical: 0, labels: 1, fold: 0 })
54097
+ cycles how many cycles are visible at once (default 4)
54098
+ playhead position of the now-line, 0–1 (default 0.5)
54099
+ vertical 1 = scroll vertically instead of horizontally
54100
+ labels 1 = draw note-name labels
54101
+ fold 1 = collapse unused pitch rows
54102
+
54103
+ ### Important: one visual per pattern
54104
+ All visuals share a single canvas, so use only ONE visualization method per
54105
+ pattern. Two at once (e.g. .scope().pianoroll()) makes them fight over the same
54106
+ surface. .scope()/.spectrum() animate only while audio is playing;
54107
+ .pianoroll()/.punchcard() animate from the pattern's note schedule. Tip: the
54108
+ pianoroll updates live as the user edits and re-runs (Ctrl+Enter) — a great way
54109
+ to *see* what the code is doing.
54087
54110
 
54088
54111
  ## Loading Extra Samples
54089
54112
  Load additional sample packs at runtime:
@@ -54376,7 +54399,7 @@ async function openStrudelInBrowser(options, outputDir) {
54376
54399
  }
54377
54400
 
54378
54401
  // src/version.ts
54379
- var VERSION = "0.4.0";
54402
+ var VERSION = "0.4.2";
54380
54403
 
54381
54404
  // server.ts
54382
54405
  var DIST_DIR = import.meta.filename.endsWith(".ts") ? path3.join(import.meta.dirname, "dist") : import.meta.dirname;
@@ -54399,7 +54422,12 @@ async function handleGetStrudelGuide({
54399
54422
  function createServer(options) {
54400
54423
  const defaultRenderMode = options?.defaultRenderMode ?? "auto";
54401
54424
  const outputDir = options?.outputDir;
54402
- const server = new McpServer({ name: "Music Studio", version: VERSION }, { instructions: SERVER_INSTRUCTIONS });
54425
+ const server = new McpServer({
54426
+ name: "Music Studio",
54427
+ version: VERSION,
54428
+ icons: SERVER_ICONS,
54429
+ websiteUrl: WEBSITE_URL
54430
+ }, { instructions: SERVER_INSTRUCTIONS });
54403
54431
  advertiseUiExtension(server.server);
54404
54432
  registerMusicPrompts(server);
54405
54433
  const inlineMode = defaultRenderMode === "auto";
@@ -12,6 +12,29 @@ export declare function advertiseUiExtension(rawServer: {
12
12
  registerCapabilities(capabilities: unknown): void;
13
13
  }): void;
14
14
  export declare const SERVER_INSTRUCTIONS: string;
15
+ export declare const WEBSITE_URL = "https://mcp-music-studio.linxule.workers.dev";
16
+ /** Canonical square icon, served from the repo via GitHub raw (direct bytes). */
17
+ export declare const LOGO_URL = "https://raw.githubusercontent.com/linxule/mcp-music-studio/main/assets/icons/logo-256.png";
18
+ /**
19
+ * serverInfo.icons for the LOCAL (stdio) server. Plain (non-`as const`) array so
20
+ * it stays assignable to the SDK's mutable `Icon[]`, and structurally typed so it
21
+ * satisfies either transport's separately-bundled McpServer.
22
+ */
23
+ export declare const SERVER_ICONS: {
24
+ src: string;
25
+ mimeType: string;
26
+ sizes: string[];
27
+ }[];
28
+ /**
29
+ * serverInfo.icons for the WORKER (remote). Uses the worker's own /icon.png
30
+ * (same-origin as /mcp, direct bytes — no 301) so clients that restrict icon URLs
31
+ * to the server's domain accept it.
32
+ */
33
+ export declare const WORKER_SERVER_ICONS: {
34
+ src: string;
35
+ mimeType: string;
36
+ sizes: string[];
37
+ }[];
15
38
  export declare const PLAY_TOOL_ANNOTATIONS: {
16
39
  readonly readOnlyHint: true;
17
40
  readonly destructiveHint: false;
@@ -1 +1 @@
1
- export declare const VERSION = "0.4.0";
1
+ export declare const VERSION = "0.4.2";
@@ -5,9 +5,9 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <meta name="color-scheme" content="light dark">
7
7
  <title>Strudel Live Pattern</title>
8
- <script type="module" crossorigin>var Zo=Object.defineProperty;var xo=(e,t,n)=>t in e?Zo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var H=(e,t,n)=>xo(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();function f(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const l=i.prototype,h=Object.keys(l);for(let m=0;m<h.length;m++){const g=h[m];g in a||(a[g]=l[g].bind(a))}}const r=(n==null?void 0:n.Parent)??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const l=n!=null&&n.Parent?new s:this;o(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>{var c,l;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(l=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:l.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class ye extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Rn extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const $n={};function ue(e){return $n}function In(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function ht(e,t){return typeof t=="bigint"?t.toString():t}function nt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function kt(e){return e==null}function St(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Oo(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){const c=o.match(/\d?e-(\d?)/);c!=null&&c[1]&&(r=Number.parseInt(c[1]))}const s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return i%a/10**s}const en=Symbol("evaluating");function T(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==en)return o===void 0&&(o=en,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function _e(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pe(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function tn(e){return JSON.stringify(e)}function No(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Pn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ao=nt(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function ke(e){if(Pe(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Pe(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function En(e){return ke(e)?{...e}:Array.isArray(e)?[...e]:e}const qo=new Set(["string","number","symbol"]);function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function he(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(o._zod.parent=e),o}function b(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0: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 Mo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const jo={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]};function Do(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=pe(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return _e(this,"shape",i),i},checks:[]});return he(e,s)}function Uo(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=pe(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return _e(this,"shape",i),i},checks:[]});return he(e,s)}function Lo(e,t){if(!ke(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=pe(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return _e(this,"shape",s),s}});return he(e,r)}function Fo(e,t){if(!ke(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=pe(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return _e(this,"shape",o),o}});return he(e,n)}function Ho(e,t){const n=pe(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return _e(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return he(e,n)}function Jo(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=pe(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(const l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return _e(this,"shape",c),c},checks:[]});return he(t,i)}function Bo(e,t,n){const o=pe(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)s[i]=new e({type:"nonoptional",innerType:r[i]});return _e(this,"shape",s),s}});return he(t,o)}function be(e,t=0){var n;if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(((n=e.issues[o])==null?void 0:n.continue)!==!0)return!0;return!1}function ve(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function Ue(e){return typeof e=="string"?e:e==null?void 0:e.message}function le(e,t,n){var r,s,i,a,c,l;const o={...e,path:e.path??[]};if(!e.message){const h=Ue((i=(s=(r=e.inst)==null?void 0:r._zod.def)==null?void 0:s.error)==null?void 0:i.call(s,e))??Ue((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??Ue((c=n.customError)==null?void 0:c.call(n,e))??Ue((l=n.localeError)==null?void 0:l.call(n,e))??"Invalid input";o.message=h}return delete o.inst,delete o.continue,t!=null&&t.reportInput||delete o.input,o}function zt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ee(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const Cn=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ht,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Zn=f("$ZodError",Cn),xn=f("$ZodError",Cn,{Parent:Error});function Vo(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function Wo(e,t=n=>n.message){const n={_errors:[]},o=r=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>o({issues:i}));else if(s.code==="invalid_key")o({issues:s.issues});else if(s.code==="invalid_element")o({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return o(e),n}const Tt=e=>(t,n,o,r)=>{const s=o?Object.assign(o,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new ye;if(i.issues.length){const a=new((r==null?void 0:r.Err)??e)(i.issues.map(c=>le(c,s,ue())));throw Pn(a,r==null?void 0:r.callee),a}return i.value},Rt=e=>async(t,n,o,r)=>{const s=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new((r==null?void 0:r.Err)??e)(i.issues.map(c=>le(c,s,ue())));throw Pn(a,r==null?void 0:r.callee),a}return i.value},ot=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new ye;return s.issues.length?{success:!1,error:new(e??Zn)(s.issues.map(i=>le(i,r,ue())))}:{success:!0,data:s.value}},On=ot(xn),rt=e=>async(t,n,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>le(i,r,ue())))}:{success:!0,data:s.value}},Ko=rt(xn),Go=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Tt(e)(t,n,r)},Qo=e=>(t,n,o)=>Tt(e)(t,n,o),Yo=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Rt(e)(t,n,r)},Xo=e=>async(t,n,o)=>Rt(e)(t,n,o),er=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ot(e)(t,n,r)},tr=e=>(t,n,o)=>ot(e)(t,n,o),nr=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return rt(e)(t,n,r)},or=e=>async(t,n,o)=>rt(e)(t,n,o),rr=/^[cC][^\s-]{8,}$/,sr=/^[0-9a-z]+$/,ir=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ar=/^[0-9a-vA-V]{20}$/,cr=/^[A-Za-z0-9]{27}$/,ur=/^[a-zA-Z0-9_-]{21}$/,lr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,dr=/^([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})$/,nn=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)$/,pr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,hr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function fr(){return new RegExp(hr,"u")}const mr=/^(?:(?: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])$/,gr=/^(([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}|:))$/,_r=/^((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])$/,br=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,vr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Nn=/^[A-Za-z0-9_-]*$/,yr=/^\+[1-9]\d{6,14}$/,An="(?:(?:\\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])))",wr=new RegExp(`^${An}$`);function qn(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function kr(e){return new RegExp(`^${qn(e)}$`)}function Sr(e){const t=qn({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${An}T(?:${o})$`)}const zr=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Tr=/^-?\d+$/,Mn=/^-?\d+(?:\.\d+)?$/,Rr=/^(?:true|false)$/i,$r=/^null$/i,Ir=/^undefined$/i,Pr=/^[^A-Z]*$/,Er=/^[^a-z]*$/,W=f("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),jn={number:"number",bigint:"bigint",object:"date"},Dn=f("$ZodCheckLessThan",(e,t)=>{W.init(e,t);const n=jn[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Un=f("$ZodCheckGreaterThan",(e,t)=>{W.init(e,t);const n=jn[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Cr=f("$ZodCheckMultipleOf",(e,t)=>{W.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Oo(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Zr=f("$ZodCheckNumberFormat",(e,t)=>{var i;W.init(e,t),t.format=t.format||"float64";const n=(i=t.format)==null?void 0:i.includes("int"),o=n?"int":"number",[r,s]=jo[t.format];e._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=r,c.maximum=s,n&&(c.pattern=Tr)}),e._zod.check=a=>{const c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}c<r&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),xr=f("$ZodCheckMaxLength",(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!kt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;if(r.length<=t.maximum)return;const i=zt(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Or=f("$ZodCheckMinLength",(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!kt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const i=zt(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Nr=f("$ZodCheckLengthEquals",(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!kt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,s=r.length;if(s===t.length)return;const i=zt(r),a=s>t.length;o.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),st=f("$ZodCheckStringFormat",(e,t)=>{var n,o;W.init(e,t),e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Ar=f("$ZodCheckRegex",(e,t)=>{st.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),qr=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Pr),st.init(e,t)}),Mr=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Er),st.init(e,t)}),jr=f("$ZodCheckIncludes",(e,t)=>{W.init(e,t);const n=Se(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Dr=f("$ZodCheckStartsWith",(e,t)=>{W.init(e,t);const n=new RegExp(`^${Se(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Ur=f("$ZodCheckEndsWith",(e,t)=>{W.init(e,t);const n=new RegExp(`.*${Se(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),Lr=f("$ZodCheckOverwrite",(e,t)=>{W.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Fr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
8
+ <script type="module" crossorigin>var Lo=Object.defineProperty;var Fo=(e,t,n)=>t in e?Lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var H=(e,t,n)=>Fo(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();function f(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const l=i.prototype,h=Object.keys(l);for(let m=0;m<h.length;m++){const g=h[m];g in a||(a[g]=l[g].bind(a))}}const r=(n==null?void 0:n.Parent)??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const l=n!=null&&n.Parent?new s:this;o(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>{var c,l;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(l=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:l.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class ke extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Cn extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Zn={};function le(e){return Zn}function xn(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function _t(e,t){return typeof t=="bigint"?t.toString():t}function it(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function $t(e){return e==null}function It(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ho(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){const c=o.match(/\d?e-(\d?)/);c!=null&&c[1]&&(r=Number.parseInt(c[1]))}const s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return i%a/10**s}const sn=Symbol("evaluating");function T(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==sn)return o===void 0&&(o=sn,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function be(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function he(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function an(e){return JSON.stringify(e)}function Jo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const On="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Bo=it(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function ze(e){if(Ce(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Ce(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Nn(e){return ze(e)?{...e}:Array.isArray(e)?[...e]:e}const Vo=new Set(["string","number","symbol"]);function Te(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fe(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(o._zod.parent=e),o}function b(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0: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 Wo(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Ko={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]};function Go(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=he(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return be(this,"shape",i),i},checks:[]});return fe(e,s)}function Qo(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=he(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return be(this,"shape",i),i},checks:[]});return fe(e,s)}function Yo(e,t){if(!ze(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=he(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return be(this,"shape",s),s}});return fe(e,r)}function Xo(e,t){if(!ze(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=he(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return be(this,"shape",o),o}});return fe(e,n)}function er(e,t){const n=he(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return be(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return fe(e,n)}function tr(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=he(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(const l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return be(this,"shape",c),c},checks:[]});return fe(t,i)}function nr(e,t,n){const o=he(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)s[i]=new e({type:"nonoptional",innerType:r[i]});return be(this,"shape",s),s}});return fe(t,o)}function ve(e,t=0){var n;if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(((n=e.issues[o])==null?void 0:n.continue)!==!0)return!0;return!1}function ye(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function Fe(e){return typeof e=="string"?e:e==null?void 0:e.message}function de(e,t,n){var r,s,i,a,c,l;const o={...e,path:e.path??[]};if(!e.message){const h=Fe((i=(s=(r=e.inst)==null?void 0:r._zod.def)==null?void 0:s.error)==null?void 0:i.call(s,e))??Fe((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??Fe((c=n.customError)==null?void 0:c.call(n,e))??Fe((l=n.localeError)==null?void 0:l.call(n,e))??"Invalid input";o.message=h}return delete o.inst,delete o.continue,t!=null&&t.reportInput||delete o.input,o}function Pt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ze(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const An=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,_t,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},qn=f("$ZodError",An),Mn=f("$ZodError",An,{Parent:Error});function or(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function rr(e,t=n=>n.message){const n={_errors:[]},o=r=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>o({issues:i}));else if(s.code==="invalid_key")o({issues:s.issues});else if(s.code==="invalid_element")o({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return o(e),n}const Et=e=>(t,n,o,r)=>{const s=o?Object.assign(o,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new ke;if(i.issues.length){const a=new((r==null?void 0:r.Err)??e)(i.issues.map(c=>de(c,s,le())));throw On(a,r==null?void 0:r.callee),a}return i.value},Ct=e=>async(t,n,o,r)=>{const s=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new((r==null?void 0:r.Err)??e)(i.issues.map(c=>de(c,s,le())));throw On(a,r==null?void 0:r.callee),a}return i.value},at=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new ke;return s.issues.length?{success:!1,error:new(e??qn)(s.issues.map(i=>de(i,r,le())))}:{success:!0,data:s.value}},jn=at(Mn),ct=e=>async(t,n,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>de(i,r,le())))}:{success:!0,data:s.value}},sr=ct(Mn),ir=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Et(e)(t,n,r)},ar=e=>(t,n,o)=>Et(e)(t,n,o),cr=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Ct(e)(t,n,r)},ur=e=>async(t,n,o)=>Ct(e)(t,n,o),lr=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return at(e)(t,n,r)},dr=e=>(t,n,o)=>at(e)(t,n,o),pr=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ct(e)(t,n,r)},hr=e=>async(t,n,o)=>ct(e)(t,n,o),fr=/^[cC][^\s-]{8,}$/,mr=/^[0-9a-z]+$/,gr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,_r=/^[0-9a-vA-V]{20}$/,br=/^[A-Za-z0-9]{27}$/,vr=/^[a-zA-Z0-9_-]{21}$/,yr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,wr=/^([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})$/,cn=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)$/,kr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Sr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function zr(){return new RegExp(Sr,"u")}const Tr=/^(?:(?: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])$/,Rr=/^(([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}|:))$/,$r=/^((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])$/,Ir=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Pr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Dn=/^[A-Za-z0-9_-]*$/,Er=/^\+[1-9]\d{6,14}$/,Un="(?:(?:\\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])))",Cr=new RegExp(`^${Un}$`);function Ln(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Zr(e){return new RegExp(`^${Ln(e)}$`)}function xr(e){const t=Ln({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${Un}T(?:${o})$`)}const Or=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Nr=/^-?\d+$/,Fn=/^-?\d+(?:\.\d+)?$/,Ar=/^(?:true|false)$/i,qr=/^null$/i,Mr=/^undefined$/i,jr=/^[^A-Z]*$/,Dr=/^[^a-z]*$/,W=f("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Hn={number:"number",bigint:"bigint",object:"date"},Jn=f("$ZodCheckLessThan",(e,t)=>{W.init(e,t);const n=Hn[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Bn=f("$ZodCheckGreaterThan",(e,t)=>{W.init(e,t);const n=Hn[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ur=f("$ZodCheckMultipleOf",(e,t)=>{W.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Ho(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Lr=f("$ZodCheckNumberFormat",(e,t)=>{var i;W.init(e,t),t.format=t.format||"float64";const n=(i=t.format)==null?void 0:i.includes("int"),o=n?"int":"number",[r,s]=Ko[t.format];e._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=r,c.maximum=s,n&&(c.pattern=Nr)}),e._zod.check=a=>{const c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}c<r&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Fr=f("$ZodCheckMaxLength",(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!$t(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;if(r.length<=t.maximum)return;const i=Pt(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Hr=f("$ZodCheckMinLength",(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!$t(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const i=Pt(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Jr=f("$ZodCheckLengthEquals",(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!$t(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,s=r.length;if(s===t.length)return;const i=Pt(r),a=s>t.length;o.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),ut=f("$ZodCheckStringFormat",(e,t)=>{var n,o;W.init(e,t),e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Br=f("$ZodCheckRegex",(e,t)=>{ut.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Vr=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=jr),ut.init(e,t)}),Wr=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Dr),ut.init(e,t)}),Kr=f("$ZodCheckIncludes",(e,t)=>{W.init(e,t);const n=Te(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Gr=f("$ZodCheckStartsWith",(e,t)=>{W.init(e,t);const n=new RegExp(`^${Te(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Qr=f("$ZodCheckEndsWith",(e,t)=>{W.init(e,t);const n=new RegExp(`.*${Te(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),Yr=f("$ZodCheckOverwrite",(e,t)=>{W.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Xr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
9
9
  `).filter(i=>i),r=Math.min(...o.map(i=>i.length-i.trimStart().length)),s=o.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this==null?void 0:this.args,r=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,r.join(`
10
- `))}}const Hr={major:4,minor:3,patch:6},C=f("$ZodType",(e,t)=>{var r;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Hr;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const s of o)for(const i of s._zod.onattach)i(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(r=e._zod.deferred)==null||r.push(()=>{e._zod.run=e._zod.parse});else{const s=(a,c,l)=>{let h=be(a),m;for(const g of c){if(g._zod.def.when){if(!g._zod.def.when(a))continue}else if(h)continue;const _=a.issues.length,v=g._zod.check(a);if(v instanceof Promise&&(l==null?void 0:l.async)===!1)throw new ye;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,a.issues.length!==_&&(h||(h=be(a,_)))});else{if(a.issues.length===_)continue;h||(h=be(a,_))}}return m?m.then(()=>a):a},i=(a,c,l)=>{if(be(a))return a.aborted=!0,a;const h=s(c,o,l);if(h instanceof Promise){if(l.async===!1)throw new ye;return h.then(m=>e._zod.parse(m,l))}return e._zod.parse(h,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const h=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return h instanceof Promise?h.then(m=>i(m,a,c)):i(h,a,c)}const l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new ye;return l.then(h=>s(h,o,c))}return s(l,o,c)}}T(e,"~standard",()=>({validate:s=>{var i;try{const a=On(e,s);return a.success?{value:a.data}:{issues:(i=a.error)==null?void 0:i.issues}}catch{return Ko(e,s).then(c=>{var l;return c.success?{value:c.data}:{issues:(l=c.error)==null?void 0:l.issues}})}},vendor:"zod",version:1}))}),$t=f("$ZodString",(e,t)=>{var n;C.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??zr(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),x=f("$ZodStringFormat",(e,t)=>{st.init(e,t),$t.init(e,t)}),Jr=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=dr),x.init(e,t)}),Br=f("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=nn(o))}else t.pattern??(t.pattern=nn());x.init(e,t)}),Vr=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=pr),x.init(e,t)}),Wr=f("$ZodURL",(e,t)=>{x.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Kr=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=fr()),x.init(e,t)}),Gr=f("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ur),x.init(e,t)}),Qr=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=rr),x.init(e,t)}),Yr=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=sr),x.init(e,t)}),Xr=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ir),x.init(e,t)}),es=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ar),x.init(e,t)}),ts=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=cr),x.init(e,t)}),ns=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Sr(t)),x.init(e,t)}),os=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=wr),x.init(e,t)}),rs=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=kr(t)),x.init(e,t)}),ss=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=lr),x.init(e,t)}),is=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=mr),x.init(e,t),e._zod.bag.format="ipv4"}),as=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=gr),x.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),cs=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=_r),x.init(e,t)}),us=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=br),x.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,s]=o;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ln(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ls=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=vr),x.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ln(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function ds(e){if(!Nn.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ln(n)}const ps=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Nn),x.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{ds(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),hs=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=yr),x.init(e,t)});function fs(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const ms=f("$ZodJWT",(e,t)=>{x.init(e,t),e._zod.check=n=>{fs(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Fn=f("$ZodNumber",(e,t)=>{C.init(e,t),e._zod.pattern=e._zod.bag.pattern??Mn,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),gs=f("$ZodNumberFormat",(e,t)=>{Zr.init(e,t),Fn.init(e,t)}),_s=f("$ZodBoolean",(e,t)=>{C.init(e,t),e._zod.pattern=Rr,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),bs=f("$ZodUndefined",(e,t)=>{C.init(e,t),e._zod.pattern=Ir,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,o)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),vs=f("$ZodNull",(e,t)=>{C.init(e,t),e._zod.pattern=$r,e._zod.values=new Set([null]),e._zod.parse=(n,o)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),ys=f("$ZodUnknown",(e,t)=>{C.init(e,t),e._zod.parse=n=>n}),ws=f("$ZodNever",(e,t)=>{C.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function on(e,t,n){e.issues.length&&t.issues.push(...ve(n,e.issues)),t.value[n]=e.value}const ks=f("$ZodArray",(e,t)=>{C.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const s=[];for(let i=0;i<r.length;i++){const a=r[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?s.push(c.then(l=>on(l,n,i))):on(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function Ke(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(...ve(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function Hn(e){var o,r,s,i;const t=Object.keys(e.shape);for(const a of t)if(!((i=(s=(r=(o=e.shape)==null?void 0:o[a])==null?void 0:r._zod)==null?void 0:s.traits)!=null&&i.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=Mo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Jn(e,t,n,o,r,s){const i=[],a=r.keySet,c=r.catchall._zod,l=c.def.type,h=c.optout==="optional";for(const m in t){if(a.has(m))continue;if(l==="never"){i.push(m);continue}const g=c.run({value:t[m],issues:[]},o);g instanceof Promise?e.push(g.then(_=>Ke(_,n,m,t,h))):Ke(g,n,m,t,h)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const Ss=f("$ZodObject",(e,t)=>{C.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const o=nt(()=>Hn(t));T(e._zod,"propValues",()=>{const a=t.shape,c={};for(const l in a){const h=a[l]._zod;if(h.values){c[l]??(c[l]=new Set);for(const m of h.values)c[l].add(m)}}return c});const r=Pe,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=o.value);const l=a.value;if(!r(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};const h=[],m=i.shape;for(const g of i.keys){const _=m[g],v=_._zod.optout==="optional",y=_._zod.run({value:l[g],issues:[]},c);y instanceof Promise?h.push(y.then(I=>Ke(I,a,g,l,v))):Ke(y,a,g,l,v)}return s?Jn(h,l,a,c,o.value,e):h.length?Promise.all(h).then(()=>a):a}}),zs=f("$ZodObjectJIT",(e,t)=>{Ss.init(e,t);const n=e._zod.parse,o=nt(()=>Hn(t)),r=g=>{var re;const _=new Fr(["shape","payload","ctx"]),v=o.value,y=G=>{const D=tn(G);return`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`};_.write("const input = payload.value;");const I=Object.create(null);let K=0;for(const G of v.keys)I[G]=`key_${K++}`;_.write("const newResult = {};");for(const G of v.keys){const D=I[G],B=tn(G),N=g[G],se=((re=N==null?void 0:N._zod)==null?void 0:re.optout)==="optional";_.write(`const ${D} = ${y(G)};`),se?_.write(`
10
+ `))}}const es={major:4,minor:3,patch:6},C=f("$ZodType",(e,t)=>{var r;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=es;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const s of o)for(const i of s._zod.onattach)i(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(r=e._zod.deferred)==null||r.push(()=>{e._zod.run=e._zod.parse});else{const s=(a,c,l)=>{let h=ve(a),m;for(const g of c){if(g._zod.def.when){if(!g._zod.def.when(a))continue}else if(h)continue;const _=a.issues.length,v=g._zod.check(a);if(v instanceof Promise&&(l==null?void 0:l.async)===!1)throw new ke;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,a.issues.length!==_&&(h||(h=ve(a,_)))});else{if(a.issues.length===_)continue;h||(h=ve(a,_))}}return m?m.then(()=>a):a},i=(a,c,l)=>{if(ve(a))return a.aborted=!0,a;const h=s(c,o,l);if(h instanceof Promise){if(l.async===!1)throw new ke;return h.then(m=>e._zod.parse(m,l))}return e._zod.parse(h,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const h=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return h instanceof Promise?h.then(m=>i(m,a,c)):i(h,a,c)}const l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new ke;return l.then(h=>s(h,o,c))}return s(l,o,c)}}T(e,"~standard",()=>({validate:s=>{var i;try{const a=jn(e,s);return a.success?{value:a.data}:{issues:(i=a.error)==null?void 0:i.issues}}catch{return sr(e,s).then(c=>{var l;return c.success?{value:c.data}:{issues:(l=c.error)==null?void 0:l.issues}})}},vendor:"zod",version:1}))}),Zt=f("$ZodString",(e,t)=>{var n;C.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Or(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),x=f("$ZodStringFormat",(e,t)=>{ut.init(e,t),Zt.init(e,t)}),ts=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=wr),x.init(e,t)}),ns=f("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=cn(o))}else t.pattern??(t.pattern=cn());x.init(e,t)}),os=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=kr),x.init(e,t)}),rs=f("$ZodURL",(e,t)=>{x.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ss=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=zr()),x.init(e,t)}),is=f("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=vr),x.init(e,t)}),as=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=fr),x.init(e,t)}),cs=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=mr),x.init(e,t)}),us=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=gr),x.init(e,t)}),ls=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_r),x.init(e,t)}),ds=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=br),x.init(e,t)}),ps=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=xr(t)),x.init(e,t)}),hs=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Cr),x.init(e,t)}),fs=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Zr(t)),x.init(e,t)}),ms=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=yr),x.init(e,t)}),gs=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Tr),x.init(e,t),e._zod.bag.format="ipv4"}),_s=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Rr),x.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),bs=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=$r),x.init(e,t)}),vs=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ir),x.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,s]=o;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Vn(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ys=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Pr),x.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Vn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function ws(e){if(!Dn.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Vn(n)}const ks=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Dn),x.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{ws(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ss=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Er),x.init(e,t)});function zs(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const Ts=f("$ZodJWT",(e,t)=>{x.init(e,t),e._zod.check=n=>{zs(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Wn=f("$ZodNumber",(e,t)=>{C.init(e,t),e._zod.pattern=e._zod.bag.pattern??Fn,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),Rs=f("$ZodNumberFormat",(e,t)=>{Lr.init(e,t),Wn.init(e,t)}),$s=f("$ZodBoolean",(e,t)=>{C.init(e,t),e._zod.pattern=Ar,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Is=f("$ZodUndefined",(e,t)=>{C.init(e,t),e._zod.pattern=Mr,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,o)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),Ps=f("$ZodNull",(e,t)=>{C.init(e,t),e._zod.pattern=qr,e._zod.values=new Set([null]),e._zod.parse=(n,o)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),Es=f("$ZodUnknown",(e,t)=>{C.init(e,t),e._zod.parse=n=>n}),Cs=f("$ZodNever",(e,t)=>{C.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function un(e,t,n){e.issues.length&&t.issues.push(...ye(n,e.issues)),t.value[n]=e.value}const Zs=f("$ZodArray",(e,t)=>{C.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const s=[];for(let i=0;i<r.length;i++){const a=r[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?s.push(c.then(l=>un(l,n,i))):un(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function Ye(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(...ye(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function Kn(e){var o,r,s,i;const t=Object.keys(e.shape);for(const a of t)if(!((i=(s=(r=(o=e.shape)==null?void 0:o[a])==null?void 0:r._zod)==null?void 0:s.traits)!=null&&i.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=Wo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Gn(e,t,n,o,r,s){const i=[],a=r.keySet,c=r.catchall._zod,l=c.def.type,h=c.optout==="optional";for(const m in t){if(a.has(m))continue;if(l==="never"){i.push(m);continue}const g=c.run({value:t[m],issues:[]},o);g instanceof Promise?e.push(g.then(_=>Ye(_,n,m,t,h))):Ye(g,n,m,t,h)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const xs=f("$ZodObject",(e,t)=>{C.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const o=it(()=>Kn(t));T(e._zod,"propValues",()=>{const a=t.shape,c={};for(const l in a){const h=a[l]._zod;if(h.values){c[l]??(c[l]=new Set);for(const m of h.values)c[l].add(m)}}return c});const r=Ce,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=o.value);const l=a.value;if(!r(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};const h=[],m=i.shape;for(const g of i.keys){const _=m[g],v=_._zod.optout==="optional",y=_._zod.run({value:l[g],issues:[]},c);y instanceof Promise?h.push(y.then(I=>Ye(I,a,g,l,v))):Ye(y,a,g,l,v)}return s?Gn(h,l,a,c,o.value,e):h.length?Promise.all(h).then(()=>a):a}}),Os=f("$ZodObjectJIT",(e,t)=>{xs.init(e,t);const n=e._zod.parse,o=it(()=>Kn(t)),r=g=>{var re;const _=new Xr(["shape","payload","ctx"]),v=o.value,y=G=>{const D=an(G);return`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`};_.write("const input = payload.value;");const I=Object.create(null);let K=0;for(const G of v.keys)I[G]=`key_${K++}`;_.write("const newResult = {};");for(const G of v.keys){const D=I[G],B=an(G),N=g[G],se=((re=N==null?void 0:N._zod)==null?void 0:re.optout)==="optional";_.write(`const ${D} = ${y(G)};`),se?_.write(`
11
11
  if (${D}.issues.length) {
12
12
  if (${B} in input) {
13
13
  payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
@@ -41,15 +41,15 @@
41
41
  newResult[${B}] = ${D}.value;
42
42
  }
43
43
 
44
- `)}_.write("payload.value = newResult;"),_.write("return payload;");const O=_.compile();return(G,D)=>O(g,G,D)};let s;const i=Pe,a=!$n.jitless,l=a&&Ao.value,h=t.catchall;let m;e._zod.parse=(g,_)=>{m??(m=o.value);const v=g.value;return i(v)?a&&l&&(_==null?void 0:_.async)===!1&&_.jitless!==!0?(s||(s=r(t.shape)),g=s(g,_),h?Jn([],v,g,_,m,e):g):n(g,_):(g.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),g)}});function rn(e,t,n,o){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const r=e.filter(s=>!be(s));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>le(i,o,ue())))}),t)}const Bn=f("$ZodUnion",(e,t)=>{C.init(e,t),T(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),T(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),T(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),T(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>St(s.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,s)=>{if(n)return o(r,s);let i=!1;const a=[];for(const c of t.options){const l=c._zod.run({value:r.value,issues:[]},s);if(l instanceof Promise)a.push(l),i=!0;else{if(l.issues.length===0)return l;a.push(l)}}return i?Promise.all(a).then(c=>rn(c,r,e,s)):rn(a,r,e,s)}}),Ts=f("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Bn.init(e,t);const n=e._zod.parse;T(e._zod,"propValues",()=>{const r={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){r[a]||(r[a]=new Set);for(const l of c)r[a].add(l)}}return r});const o=nt(()=>{var i;const r=t.options,s=new Map;for(const a of r){const c=(i=a._zod.propValues)==null?void 0:i[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const l of c){if(s.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);s.set(l,a)}}return s});e._zod.parse=(r,s)=>{const i=r.value;if(!Pe(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),r;const a=o.value.get(i==null?void 0:i[t.discriminator]);return a?a._zod.run(r,s):t.unionFallback?n(r,s):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),r)}}),Rs=f("$ZodIntersection",(e,t)=>{C.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,s=t.left._zod.run({value:r,issues:[]},o),i=t.right._zod.run({value:r,issues:[]},o);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,l])=>sn(n,c,l)):sn(n,s,i)}});function ft(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(ke(e)&&ke(t)){const n=Object.keys(t),o=Object.keys(e).filter(s=>n.indexOf(s)!==-1),r={...e,...t};for(const s of o){const i=ft(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const r=e[o],s=t[o],i=ft(r,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function sn(e,t,n){const o=new Map;let r;for(const a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);const s=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&r&&e.issues.push({...r,keys:s}),be(e))return e;const i=ft(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const $s=f("$ZodRecord",(e,t)=>{C.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!ke(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const l of i)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);const h=t.valueType._zod.run({value:r[l],issues:[]},o);h instanceof Promise?s.push(h.then(m=>{m.issues.length&&n.issues.push(...ve(l,m.issues)),n.value[l]=m.value})):(h.issues.length&&n.issues.push(...ve(l,h.issues)),n.value[l]=h.value)}let c;for(const l in r)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(r)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Mn.test(a)&&c.issues.length){const m=t.keyType._zod.run({value:Number(a),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(c=m)}if(c.issues.length){t.mode==="loose"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(m=>le(m,o,ue())),input:a,path:[a],inst:e});continue}const h=t.valueType._zod.run({value:r[a],issues:[]},o);h instanceof Promise?s.push(h.then(m=>{m.issues.length&&n.issues.push(...ve(a,m.issues)),n.value[c.value]=m.value})):(h.issues.length&&n.issues.push(...ve(a,h.issues)),n.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Is=f("$ZodEnum",(e,t)=>{C.init(e,t);const n=In(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>qo.has(typeof r)).map(r=>typeof r=="string"?Se(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return o.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),Ps=f("$ZodLiteral",(e,t)=>{if(C.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?Se(o):o?Se(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,r)=>{const s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}}),Es=f("$ZodTransform",(e,t)=>{C.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Rn(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(n.value=i,n));if(r instanceof Promise)throw new ye;return n.value=r,n}});function an(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Vn=f("$ZodOptional",(e,t)=>{C.init(e,t),e._zod.optin="optional",e._zod.optout="optional",T(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),T(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${St(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>an(s,n.value)):an(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Cs=f("$ZodExactOptional",(e,t)=>{Vn.init(e,t),T(e._zod,"values",()=>t.innerType._zod.values),T(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),Zs=f("$ZodNullable",(e,t)=>{C.init(e,t),T(e._zod,"optin",()=>t.innerType._zod.optin),T(e._zod,"optout",()=>t.innerType._zod.optout),T(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${St(n.source)}|null)$`):void 0}),T(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),xs=f("$ZodDefault",(e,t)=>{C.init(e,t),e._zod.optin="optional",T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>cn(s,t)):cn(r,t)}});function cn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Os=f("$ZodPrefault",(e,t)=>{C.init(e,t),e._zod.optin="optional",T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),Ns=f("$ZodNonOptional",(e,t)=>{C.init(e,t),T(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>un(s,e)):un(r,e)}});function un(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const As=f("$ZodCatch",(e,t)=>{C.init(e,t),T(e._zod,"optin",()=>t.innerType._zod.optin),T(e._zod,"optout",()=>t.innerType._zod.optout),T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>le(i,o,ue()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>le(s,o,ue()))},input:n.value}),n.issues=[]),n)}}),qs=f("$ZodPipe",(e,t)=>{C.init(e,t),T(e._zod,"values",()=>t.in._zod.values),T(e._zod,"optin",()=>t.in._zod.optin),T(e._zod,"optout",()=>t.out._zod.optout),T(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const s=t.out._zod.run(n,o);return s instanceof Promise?s.then(i=>Le(i,t.in,o)):Le(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>Le(s,t.out,o)):Le(r,t.out,o)}});function Le(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ms=f("$ZodReadonly",(e,t)=>{C.init(e,t),T(e._zod,"propValues",()=>t.innerType._zod.propValues),T(e._zod,"values",()=>t.innerType._zod.values),T(e._zod,"optin",()=>{var n,o;return(o=(n=t.innerType)==null?void 0:n._zod)==null?void 0:o.optin}),T(e._zod,"optout",()=>{var n,o;return(o=(n=t.innerType)==null?void 0:n._zod)==null?void 0:o.optout}),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(ln):ln(r)}});function ln(e){return e.value=Object.freeze(e.value),e}const js=f("$ZodCustom",(e,t)=>{W.init(e,t),C.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(s=>dn(s,n,o,e));dn(r,n,o,e)}});function dn(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(Ee(r))}}var pn;class Ds{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Us(){return new Ds}(pn=globalThis).__zod_globalRegistry??(pn.__zod_globalRegistry=Us());const Ie=globalThis.__zod_globalRegistry;function Ls(e,t){return new e({type:"string",...b(t)})}function Fs(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(t)})}function hn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(t)})}function Hs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(t)})}function Js(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(t)})}function Bs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(t)})}function Vs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(t)})}function Ws(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(t)})}function Ks(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(t)})}function Gs(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(t)})}function Qs(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(t)})}function Ys(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(t)})}function Xs(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(t)})}function ei(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(t)})}function ti(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(t)})}function ni(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(t)})}function oi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(t)})}function ri(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(t)})}function si(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(t)})}function ii(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(t)})}function ai(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(t)})}function ci(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(t)})}function ui(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(t)})}function li(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(t)})}function di(e,t){return new e({type:"string",format:"date",check:"string_format",...b(t)})}function pi(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(t)})}function hi(e,t){return new e({type:"string",format:"duration",check:"string_format",...b(t)})}function fi(e,t){return new e({type:"number",checks:[],...b(t)})}function mi(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(t)})}function gi(e,t){return new e({type:"boolean",...b(t)})}function _i(e,t){return new e({type:"undefined",...b(t)})}function bi(e,t){return new e({type:"null",...b(t)})}function vi(e){return new e({type:"unknown"})}function yi(e,t){return new e({type:"never",...b(t)})}function fn(e,t){return new Dn({check:"less_than",...b(t),value:e,inclusive:!1})}function lt(e,t){return new Dn({check:"less_than",...b(t),value:e,inclusive:!0})}function mn(e,t){return new Un({check:"greater_than",...b(t),value:e,inclusive:!1})}function dt(e,t){return new Un({check:"greater_than",...b(t),value:e,inclusive:!0})}function gn(e,t){return new Cr({check:"multiple_of",...b(t),value:e})}function Wn(e,t){return new xr({check:"max_length",...b(t),maximum:e})}function Ge(e,t){return new Or({check:"min_length",...b(t),minimum:e})}function Kn(e,t){return new Nr({check:"length_equals",...b(t),length:e})}function wi(e,t){return new Ar({check:"string_format",format:"regex",...b(t),pattern:e})}function ki(e){return new qr({check:"string_format",format:"lowercase",...b(e)})}function Si(e){return new Mr({check:"string_format",format:"uppercase",...b(e)})}function zi(e,t){return new jr({check:"string_format",format:"includes",...b(t),includes:e})}function Ti(e,t){return new Dr({check:"string_format",format:"starts_with",...b(t),prefix:e})}function Ri(e,t){return new Ur({check:"string_format",format:"ends_with",...b(t),suffix:e})}function Te(e){return new Lr({check:"overwrite",tx:e})}function $i(e){return Te(t=>t.normalize(e))}function Ii(){return Te(e=>e.trim())}function Pi(){return Te(e=>e.toLowerCase())}function Ei(){return Te(e=>e.toUpperCase())}function Ci(){return Te(e=>No(e))}function Zi(e,t,n){return new e({type:"array",element:t,...b(n)})}function xi(e,t,n){const o=b(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Oi(e,t,n){return new e({type:"custom",check:"custom",fn:t,...b(n)})}function Ni(e){const t=Ai(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Ee(o,n.value,t._zod.def));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(Ee(r))}},e(n.value,n)));return t}function Ai(e,t){const n=new W({check:"custom",...b(t)});return n._zod.check=e,n}function Gn(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??Ie,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function M(e,t,n={path:[],schemaPath:[]}){var h,m;var o;const r=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=(m=(h=e._zod).toJSONSchema)==null?void 0:m.call(h);if(a)i.schema=a;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,g);else{const v=i.schema,y=t.processors[r.type];if(!y)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);y(e,t,v,g)}const _=e._zod.parent;_&&(i.ref||(i.ref=_),M(_,t,g),t.seen.get(_).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&J(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Qn(e,t){var i,a,c,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const h of e.seen.entries()){const m=(i=e.metadataRegistry.get(h[0]))==null?void 0:i.id;if(m){const g=o.get(m);if(g&&g!==h[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(m,h[0])}}const r=h=>{var y;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const I=(y=e.external.registry.get(h[0]))==null?void 0:y.id,K=e.external.uri??(re=>re);if(I)return{ref:K(I)};const O=h[1].defId??h[1].schema.id??`schema${e.counter++}`;return h[1].defId=O,{defId:O,ref:`${K("__shared")}#/${m}/${O}`}}if(h[1]===n)return{ref:"#"};const _=`#/${m}/`,v=h[1].schema.id??`__schema${e.counter++}`;return{defId:v,ref:_+v}},s=h=>{if(h[1].schema.$ref)return;const m=h[1],{ref:g,defId:_}=r(h);m.def={...m.schema},_&&(m.defId=_);const v=m.schema;for(const y in v)delete v[y];v.$ref=g};if(e.cycles==="throw")for(const h of e.seen.entries()){const m=h[1];if(m.cycle)throw new Error(`Cycle detected: #/${(a=m.cycle)==null?void 0:a.join("/")}/<root>
44
+ `)}_.write("payload.value = newResult;"),_.write("return payload;");const O=_.compile();return(G,D)=>O(g,G,D)};let s;const i=Ce,a=!Zn.jitless,l=a&&Bo.value,h=t.catchall;let m;e._zod.parse=(g,_)=>{m??(m=o.value);const v=g.value;return i(v)?a&&l&&(_==null?void 0:_.async)===!1&&_.jitless!==!0?(s||(s=r(t.shape)),g=s(g,_),h?Gn([],v,g,_,m,e):g):n(g,_):(g.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),g)}});function ln(e,t,n,o){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const r=e.filter(s=>!ve(s));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>de(i,o,le())))}),t)}const Qn=f("$ZodUnion",(e,t)=>{C.init(e,t),T(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),T(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),T(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),T(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>It(s.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,s)=>{if(n)return o(r,s);let i=!1;const a=[];for(const c of t.options){const l=c._zod.run({value:r.value,issues:[]},s);if(l instanceof Promise)a.push(l),i=!0;else{if(l.issues.length===0)return l;a.push(l)}}return i?Promise.all(a).then(c=>ln(c,r,e,s)):ln(a,r,e,s)}}),Ns=f("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Qn.init(e,t);const n=e._zod.parse;T(e._zod,"propValues",()=>{const r={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){r[a]||(r[a]=new Set);for(const l of c)r[a].add(l)}}return r});const o=it(()=>{var i;const r=t.options,s=new Map;for(const a of r){const c=(i=a._zod.propValues)==null?void 0:i[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const l of c){if(s.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);s.set(l,a)}}return s});e._zod.parse=(r,s)=>{const i=r.value;if(!Ce(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),r;const a=o.value.get(i==null?void 0:i[t.discriminator]);return a?a._zod.run(r,s):t.unionFallback?n(r,s):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),r)}}),As=f("$ZodIntersection",(e,t)=>{C.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,s=t.left._zod.run({value:r,issues:[]},o),i=t.right._zod.run({value:r,issues:[]},o);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,l])=>dn(n,c,l)):dn(n,s,i)}});function bt(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(ze(e)&&ze(t)){const n=Object.keys(t),o=Object.keys(e).filter(s=>n.indexOf(s)!==-1),r={...e,...t};for(const s of o){const i=bt(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const r=e[o],s=t[o],i=bt(r,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function dn(e,t,n){const o=new Map;let r;for(const a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);const s=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&r&&e.issues.push({...r,keys:s}),ve(e))return e;const i=bt(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const qs=f("$ZodRecord",(e,t)=>{C.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!ze(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const l of i)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);const h=t.valueType._zod.run({value:r[l],issues:[]},o);h instanceof Promise?s.push(h.then(m=>{m.issues.length&&n.issues.push(...ye(l,m.issues)),n.value[l]=m.value})):(h.issues.length&&n.issues.push(...ye(l,h.issues)),n.value[l]=h.value)}let c;for(const l in r)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(r)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Fn.test(a)&&c.issues.length){const m=t.keyType._zod.run({value:Number(a),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(c=m)}if(c.issues.length){t.mode==="loose"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(m=>de(m,o,le())),input:a,path:[a],inst:e});continue}const h=t.valueType._zod.run({value:r[a],issues:[]},o);h instanceof Promise?s.push(h.then(m=>{m.issues.length&&n.issues.push(...ye(a,m.issues)),n.value[c.value]=m.value})):(h.issues.length&&n.issues.push(...ye(a,h.issues)),n.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Ms=f("$ZodEnum",(e,t)=>{C.init(e,t);const n=xn(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>Vo.has(typeof r)).map(r=>typeof r=="string"?Te(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return o.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),js=f("$ZodLiteral",(e,t)=>{if(C.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?Te(o):o?Te(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,r)=>{const s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}}),Ds=f("$ZodTransform",(e,t)=>{C.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Cn(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(n.value=i,n));if(r instanceof Promise)throw new ke;return n.value=r,n}});function pn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Yn=f("$ZodOptional",(e,t)=>{C.init(e,t),e._zod.optin="optional",e._zod.optout="optional",T(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),T(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${It(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>pn(s,n.value)):pn(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Us=f("$ZodExactOptional",(e,t)=>{Yn.init(e,t),T(e._zod,"values",()=>t.innerType._zod.values),T(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),Ls=f("$ZodNullable",(e,t)=>{C.init(e,t),T(e._zod,"optin",()=>t.innerType._zod.optin),T(e._zod,"optout",()=>t.innerType._zod.optout),T(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${It(n.source)}|null)$`):void 0}),T(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),Fs=f("$ZodDefault",(e,t)=>{C.init(e,t),e._zod.optin="optional",T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>hn(s,t)):hn(r,t)}});function hn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Hs=f("$ZodPrefault",(e,t)=>{C.init(e,t),e._zod.optin="optional",T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),Js=f("$ZodNonOptional",(e,t)=>{C.init(e,t),T(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>fn(s,e)):fn(r,e)}});function fn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Bs=f("$ZodCatch",(e,t)=>{C.init(e,t),T(e._zod,"optin",()=>t.innerType._zod.optin),T(e._zod,"optout",()=>t.innerType._zod.optout),T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>de(i,o,le()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>de(s,o,le()))},input:n.value}),n.issues=[]),n)}}),Vs=f("$ZodPipe",(e,t)=>{C.init(e,t),T(e._zod,"values",()=>t.in._zod.values),T(e._zod,"optin",()=>t.in._zod.optin),T(e._zod,"optout",()=>t.out._zod.optout),T(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const s=t.out._zod.run(n,o);return s instanceof Promise?s.then(i=>He(i,t.in,o)):He(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>He(s,t.out,o)):He(r,t.out,o)}});function He(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ws=f("$ZodReadonly",(e,t)=>{C.init(e,t),T(e._zod,"propValues",()=>t.innerType._zod.propValues),T(e._zod,"values",()=>t.innerType._zod.values),T(e._zod,"optin",()=>{var n,o;return(o=(n=t.innerType)==null?void 0:n._zod)==null?void 0:o.optin}),T(e._zod,"optout",()=>{var n,o;return(o=(n=t.innerType)==null?void 0:n._zod)==null?void 0:o.optout}),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(mn):mn(r)}});function mn(e){return e.value=Object.freeze(e.value),e}const Ks=f("$ZodCustom",(e,t)=>{W.init(e,t),C.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(s=>gn(s,n,o,e));gn(r,n,o,e)}});function gn(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(Ze(r))}}var _n;class Gs{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Qs(){return new Gs}(_n=globalThis).__zod_globalRegistry??(_n.__zod_globalRegistry=Qs());const Ee=globalThis.__zod_globalRegistry;function Ys(e,t){return new e({type:"string",...b(t)})}function Xs(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(t)})}function bn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(t)})}function ei(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(t)})}function ti(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(t)})}function ni(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(t)})}function oi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(t)})}function ri(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(t)})}function si(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(t)})}function ii(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(t)})}function ai(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(t)})}function ci(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(t)})}function ui(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(t)})}function li(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(t)})}function di(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(t)})}function pi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(t)})}function hi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(t)})}function fi(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(t)})}function mi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(t)})}function gi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(t)})}function _i(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(t)})}function bi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(t)})}function vi(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(t)})}function yi(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(t)})}function wi(e,t){return new e({type:"string",format:"date",check:"string_format",...b(t)})}function ki(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(t)})}function Si(e,t){return new e({type:"string",format:"duration",check:"string_format",...b(t)})}function zi(e,t){return new e({type:"number",checks:[],...b(t)})}function Ti(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(t)})}function Ri(e,t){return new e({type:"boolean",...b(t)})}function $i(e,t){return new e({type:"undefined",...b(t)})}function Ii(e,t){return new e({type:"null",...b(t)})}function Pi(e){return new e({type:"unknown"})}function Ei(e,t){return new e({type:"never",...b(t)})}function vn(e,t){return new Jn({check:"less_than",...b(t),value:e,inclusive:!1})}function ft(e,t){return new Jn({check:"less_than",...b(t),value:e,inclusive:!0})}function yn(e,t){return new Bn({check:"greater_than",...b(t),value:e,inclusive:!1})}function mt(e,t){return new Bn({check:"greater_than",...b(t),value:e,inclusive:!0})}function wn(e,t){return new Ur({check:"multiple_of",...b(t),value:e})}function Xn(e,t){return new Fr({check:"max_length",...b(t),maximum:e})}function Xe(e,t){return new Hr({check:"min_length",...b(t),minimum:e})}function eo(e,t){return new Jr({check:"length_equals",...b(t),length:e})}function Ci(e,t){return new Br({check:"string_format",format:"regex",...b(t),pattern:e})}function Zi(e){return new Vr({check:"string_format",format:"lowercase",...b(e)})}function xi(e){return new Wr({check:"string_format",format:"uppercase",...b(e)})}function Oi(e,t){return new Kr({check:"string_format",format:"includes",...b(t),includes:e})}function Ni(e,t){return new Gr({check:"string_format",format:"starts_with",...b(t),prefix:e})}function Ai(e,t){return new Qr({check:"string_format",format:"ends_with",...b(t),suffix:e})}function $e(e){return new Yr({check:"overwrite",tx:e})}function qi(e){return $e(t=>t.normalize(e))}function Mi(){return $e(e=>e.trim())}function ji(){return $e(e=>e.toLowerCase())}function Di(){return $e(e=>e.toUpperCase())}function Ui(){return $e(e=>Jo(e))}function Li(e,t,n){return new e({type:"array",element:t,...b(n)})}function Fi(e,t,n){const o=b(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Hi(e,t,n){return new e({type:"custom",check:"custom",fn:t,...b(n)})}function Ji(e){const t=Bi(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Ze(o,n.value,t._zod.def));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(Ze(r))}},e(n.value,n)));return t}function Bi(e,t){const n=new W({check:"custom",...b(t)});return n._zod.check=e,n}function to(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??Ee,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function j(e,t,n={path:[],schemaPath:[]}){var h,m;var o;const r=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=(m=(h=e._zod).toJSONSchema)==null?void 0:m.call(h);if(a)i.schema=a;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,g);else{const v=i.schema,y=t.processors[r.type];if(!y)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);y(e,t,v,g)}const _=e._zod.parent;_&&(i.ref||(i.ref=_),j(_,t,g),t.seen.get(_).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&J(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function no(e,t){var i,a,c,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const h of e.seen.entries()){const m=(i=e.metadataRegistry.get(h[0]))==null?void 0:i.id;if(m){const g=o.get(m);if(g&&g!==h[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(m,h[0])}}const r=h=>{var y;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const I=(y=e.external.registry.get(h[0]))==null?void 0:y.id,K=e.external.uri??(re=>re);if(I)return{ref:K(I)};const O=h[1].defId??h[1].schema.id??`schema${e.counter++}`;return h[1].defId=O,{defId:O,ref:`${K("__shared")}#/${m}/${O}`}}if(h[1]===n)return{ref:"#"};const _=`#/${m}/`,v=h[1].schema.id??`__schema${e.counter++}`;return{defId:v,ref:_+v}},s=h=>{if(h[1].schema.$ref)return;const m=h[1],{ref:g,defId:_}=r(h);m.def={...m.schema},_&&(m.defId=_);const v=m.schema;for(const y in v)delete v[y];v.$ref=g};if(e.cycles==="throw")for(const h of e.seen.entries()){const m=h[1];if(m.cycle)throw new Error(`Cycle detected: #/${(a=m.cycle)==null?void 0:a.join("/")}/<root>
45
45
 
46
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of e.seen.entries()){const m=h[1];if(t===h[0]){s(h);continue}if(e.external){const _=(c=e.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&_){s(h);continue}}if((l=e.metadataRegistry.get(h[0]))==null?void 0:l.id){s(h);continue}if(m.cycle){s(h);continue}if(m.count>1&&e.reused==="ref"){s(h);continue}}}function Yn(e,t){var i,a,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=l=>{const h=e.seen.get(l);if(h.ref===null)return;const m=h.def??h.schema,g={...m},_=h.ref;if(h.ref=null,_){o(_);const y=e.seen.get(_),I=y.schema;if(I.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(m.allOf=m.allOf??[],m.allOf.push(I)):Object.assign(m,I),Object.assign(m,g),l._zod.parent===_)for(const O in m)O==="$ref"||O==="allOf"||O in g||delete m[O];if(I.$ref&&y.def)for(const O in m)O==="$ref"||O==="allOf"||O in y.def&&JSON.stringify(m[O])===JSON.stringify(y.def[O])&&delete m[O]}const v=l._zod.parent;if(v&&v!==_){o(v);const y=e.seen.get(v);if(y!=null&&y.schema.$ref&&(m.$ref=y.schema.$ref,y.def))for(const I in m)I==="$ref"||I==="allOf"||I in y.def&&JSON.stringify(m[I])===JSON.stringify(y.def[I])&&delete m[I]}e.override({zodSchema:l,jsonSchema:m,path:h.path??[]})};for(const l of[...e.seen.entries()].reverse())o(l[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,(i=e.external)!=null&&i.uri){const l=(a=e.external.registry.get(t))==null?void 0:a.id;if(!l)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(l)}Object.assign(r,n.def??n.schema);const s=((c=e.external)==null?void 0:c.defs)??{};for(const l of e.seen.entries()){const h=l[1];h.def&&h.defId&&(s[h.defId]=h.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?r.$defs=s:r.definitions=s);try{const l=JSON.parse(JSON.stringify(r));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:Qe(t,"input",e.processors),output:Qe(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function J(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return J(o.element,n);if(o.type==="set")return J(o.valueType,n);if(o.type==="lazy")return J(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return J(o.innerType,n);if(o.type==="intersection")return J(o.left,n)||J(o.right,n);if(o.type==="record"||o.type==="map")return J(o.keyType,n)||J(o.valueType,n);if(o.type==="pipe")return J(o.in,n)||J(o.out,n);if(o.type==="object"){for(const r in o.shape)if(J(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(J(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(J(r,n))return!0;return!!(o.rest&&J(o.rest,n))}return!1}const qi=(e,t={})=>n=>{const o=Gn({...n,processors:t});return M(e,o),Qn(o,e),Yn(o,e)},Qe=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=Gn({...r??{},target:s,io:t,processors:n});return M(e,i),Qn(i,e),Yn(i,e)},Mi={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ji=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof i=="number"&&(r.maxLength=i),a&&(r.format=Mi[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),l&&(r.contentEncoding=l),c&&c.size>0){const h=[...c];h.length===1?r.pattern=h[0].source:h.length>1&&(r.allOf=[...h.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Di=(e,t,n,o)=>{const r=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:h}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=h,r.exclusiveMinimum=!0):r.exclusiveMinimum=h),typeof s=="number"&&(r.minimum=s,typeof h=="number"&&t.target!=="draft-04"&&(h>=s?delete r.minimum:delete r.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l),typeof i=="number"&&(r.maximum=i,typeof l=="number"&&t.target!=="draft-04"&&(l<=i?delete r.maximum:delete r.exclusiveMaximum)),typeof c=="number"&&(r.multipleOf=c)},Ui=(e,t,n,o)=>{n.type="boolean"},Li=(e,t,n,o)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Fi=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Hi=(e,t,n,o)=>{n.not={}},Ji=(e,t,n,o)=>{},Bi=(e,t,n,o)=>{const r=e._zod.def,s=In(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Vi=(e,t,n,o)=>{const r=e._zod.def,s=[];for(const i of r.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s},Wi=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ki=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Gi=(e,t,n,o)=>{const r=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(r.minItems=i),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=M(s.element,t,{...o,path:[...o.path,"items"]})},Qi=(e,t,n,o)=>{var l;const r=n,s=e._zod.def;r.type="object",r.properties={};const i=s.shape;for(const h in i)r.properties[h]=M(i[h],t,{...o,path:[...o.path,"properties",h]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(h=>{const m=s.shape[h]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));c.size>0&&(r.required=Array.from(c)),((l=s.catchall)==null?void 0:l._zod.def.type)==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=M(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},Yi=(e,t,n,o)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((a,c)=>M(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},Xi=(e,t,n,o)=>{const r=e._zod.def,s=M(r.left,t,{...o,path:[...o.path,"allOf",0]}),i=M(r.right,t,{...o,path:[...o.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c},ea=(e,t,n,o)=>{const r=n,s=e._zod.def;r.type="object";const i=s.keyType,a=i._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=M(s.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(const m of c)r.patternProperties[m.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=M(s.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=M(s.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const l=i._zod.values;if(l){const h=[...l].filter(m=>typeof m=="string"||typeof m=="number");h.length>0&&(r.required=h)}},ta=(e,t,n,o)=>{const r=e._zod.def,s=M(r.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},na=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},oa=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},ra=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},sa=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},ia=(e,t,n,o)=>{const r=e._zod.def,s=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;M(s,t,o);const i=t.seen.get(e);i.ref=s},aa=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},Xn=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType};function It(e){return!!e._zod}function eo(e,t){return It(e)?On(e,t):e.safeParse(t)}function ca(e){var n,o;if(!e)return;let t;if(It(e)?t=(o=(n=e._zod)==null?void 0:n.def)==null?void 0:o.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function ua(e){var r;if(It(e)){const i=(r=e._zod)==null?void 0:r.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const o=e.value;if(o!==void 0)return o}const la=f("ZodISODateTime",(e,t)=>{ns.init(e,t),A.init(e,t)});function to(e){return li(la,e)}const da=f("ZodISODate",(e,t)=>{os.init(e,t),A.init(e,t)});function pa(e){return di(da,e)}const ha=f("ZodISOTime",(e,t)=>{rs.init(e,t),A.init(e,t)});function fa(e){return pi(ha,e)}const ma=f("ZodISODuration",(e,t)=>{ss.init(e,t),A.init(e,t)});function ga(e){return hi(ma,e)}const _a=(e,t)=>{Zn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Wo(e,n)},flatten:{value:n=>Vo(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ht,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ht,2)}},isEmpty:{get(){return e.issues.length===0}}})},ee=f("ZodError",_a,{Parent:Error}),ba=Tt(ee),va=Rt(ee),ya=ot(ee),wa=rt(ee),ka=Go(ee),Sa=Qo(ee),za=Yo(ee),Ta=Xo(ee),Ra=er(ee),$a=tr(ee),Ia=nr(ee),Pa=or(ee),Z=f("ZodType",(e,t)=>(C.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Qe(e,"input"),output:Qe(e,"output")}}),e.toJSONSchema=qi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(pe(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),e.with=e.check,e.clone=(n,o)=>he(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>ba(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>ya(e,n,o),e.parseAsync=async(n,o)=>va(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>wa(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>ka(e,n,o),e.decode=(n,o)=>Sa(e,n,o),e.encodeAsync=async(n,o)=>za(e,n,o),e.decodeAsync=async(n,o)=>Ta(e,n,o),e.safeEncode=(n,o)=>Ra(e,n,o),e.safeDecode=(n,o)=>$a(e,n,o),e.safeEncodeAsync=async(n,o)=>Ia(e,n,o),e.safeDecodeAsync=async(n,o)=>Pa(e,n,o),e.refine=(n,o)=>e.check(wc(n,o)),e.superRefine=n=>e.check(kc(n)),e.overwrite=n=>e.check(Te(n)),e.optional=()=>q(e),e.exactOptional=()=>cc(e),e.nullable=()=>vn(e),e.nullish=()=>q(vn(e)),e.nonoptional=n=>fc(e,n),e.array=()=>w(e),e.or=n=>S([e,n]),e.and=n=>Pt(e,n),e.transform=n=>_t(e,co(n)),e.default=n=>dc(e,n),e.prefault=n=>hc(e,n),e.catch=n=>gc(e,n),e.pipe=n=>_t(e,n),e.readonly=()=>vc(e),e.describe=n=>{const o=e.clone();return Ie.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){var n;return(n=Ie.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Ie.get(e);const o=e.clone();return Ie.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),no=f("_ZodString",(e,t)=>{$t.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(o,r,s)=>ji(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(wi(...o)),e.includes=(...o)=>e.check(zi(...o)),e.startsWith=(...o)=>e.check(Ti(...o)),e.endsWith=(...o)=>e.check(Ri(...o)),e.min=(...o)=>e.check(Ge(...o)),e.max=(...o)=>e.check(Wn(...o)),e.length=(...o)=>e.check(Kn(...o)),e.nonempty=(...o)=>e.check(Ge(1,...o)),e.lowercase=o=>e.check(ki(o)),e.uppercase=o=>e.check(Si(o)),e.trim=()=>e.check(Ii()),e.normalize=(...o)=>e.check($i(...o)),e.toLowerCase=()=>e.check(Pi()),e.toUpperCase=()=>e.check(Ei()),e.slugify=()=>e.check(Ci())}),Ea=f("ZodString",(e,t)=>{$t.init(e,t),no.init(e,t),e.email=n=>e.check(Fs(Ca,n)),e.url=n=>e.check(Ws(Za,n)),e.jwt=n=>e.check(ui(Va,n)),e.emoji=n=>e.check(Ks(xa,n)),e.guid=n=>e.check(hn(_n,n)),e.uuid=n=>e.check(Hs(Fe,n)),e.uuidv4=n=>e.check(Js(Fe,n)),e.uuidv6=n=>e.check(Bs(Fe,n)),e.uuidv7=n=>e.check(Vs(Fe,n)),e.nanoid=n=>e.check(Gs(Oa,n)),e.guid=n=>e.check(hn(_n,n)),e.cuid=n=>e.check(Qs(Na,n)),e.cuid2=n=>e.check(Ys(Aa,n)),e.ulid=n=>e.check(Xs(qa,n)),e.base64=n=>e.check(ii(Ha,n)),e.base64url=n=>e.check(ai(Ja,n)),e.xid=n=>e.check(ei(Ma,n)),e.ksuid=n=>e.check(ti(ja,n)),e.ipv4=n=>e.check(ni(Da,n)),e.ipv6=n=>e.check(oi(Ua,n)),e.cidrv4=n=>e.check(ri(La,n)),e.cidrv6=n=>e.check(si(Fa,n)),e.e164=n=>e.check(ci(Ba,n)),e.datetime=n=>e.check(to(n)),e.date=n=>e.check(pa(n)),e.time=n=>e.check(fa(n)),e.duration=n=>e.check(ga(n))});function d(e){return Ls(Ea,e)}const A=f("ZodStringFormat",(e,t)=>{x.init(e,t),no.init(e,t)}),Ca=f("ZodEmail",(e,t)=>{Vr.init(e,t),A.init(e,t)}),_n=f("ZodGUID",(e,t)=>{Jr.init(e,t),A.init(e,t)}),Fe=f("ZodUUID",(e,t)=>{Br.init(e,t),A.init(e,t)}),Za=f("ZodURL",(e,t)=>{Wr.init(e,t),A.init(e,t)}),xa=f("ZodEmoji",(e,t)=>{Kr.init(e,t),A.init(e,t)}),Oa=f("ZodNanoID",(e,t)=>{Gr.init(e,t),A.init(e,t)}),Na=f("ZodCUID",(e,t)=>{Qr.init(e,t),A.init(e,t)}),Aa=f("ZodCUID2",(e,t)=>{Yr.init(e,t),A.init(e,t)}),qa=f("ZodULID",(e,t)=>{Xr.init(e,t),A.init(e,t)}),Ma=f("ZodXID",(e,t)=>{es.init(e,t),A.init(e,t)}),ja=f("ZodKSUID",(e,t)=>{ts.init(e,t),A.init(e,t)}),Da=f("ZodIPv4",(e,t)=>{is.init(e,t),A.init(e,t)}),Ua=f("ZodIPv6",(e,t)=>{as.init(e,t),A.init(e,t)}),La=f("ZodCIDRv4",(e,t)=>{cs.init(e,t),A.init(e,t)}),Fa=f("ZodCIDRv6",(e,t)=>{us.init(e,t),A.init(e,t)}),Ha=f("ZodBase64",(e,t)=>{ls.init(e,t),A.init(e,t)}),Ja=f("ZodBase64URL",(e,t)=>{ps.init(e,t),A.init(e,t)}),Ba=f("ZodE164",(e,t)=>{hs.init(e,t),A.init(e,t)}),Va=f("ZodJWT",(e,t)=>{ms.init(e,t),A.init(e,t)}),oo=f("ZodNumber",(e,t)=>{Fn.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Di(e,o,r),e.gt=(o,r)=>e.check(mn(o,r)),e.gte=(o,r)=>e.check(dt(o,r)),e.min=(o,r)=>e.check(dt(o,r)),e.lt=(o,r)=>e.check(fn(o,r)),e.lte=(o,r)=>e.check(lt(o,r)),e.max=(o,r)=>e.check(lt(o,r)),e.int=o=>e.check(bn(o)),e.safe=o=>e.check(bn(o)),e.positive=o=>e.check(mn(0,o)),e.nonnegative=o=>e.check(dt(0,o)),e.negative=o=>e.check(fn(0,o)),e.nonpositive=o=>e.check(lt(0,o)),e.multipleOf=(o,r)=>e.check(gn(o,r)),e.step=(o,r)=>e.check(gn(o,r)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function k(e){return fi(oo,e)}const Wa=f("ZodNumberFormat",(e,t)=>{gs.init(e,t),oo.init(e,t)});function bn(e){return mi(Wa,e)}const Ka=f("ZodBoolean",(e,t)=>{_s.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ui(e,n,o)});function E(e){return gi(Ka,e)}const Ga=f("ZodUndefined",(e,t)=>{bs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Fi(e,n)});function mt(e){return _i(Ga,e)}const Qa=f("ZodNull",(e,t)=>{vs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Li(e,n,o)});function ro(e){return bi(Qa,e)}const Ya=f("ZodUnknown",(e,t)=>{ys.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ji()});function P(){return vi(Ya)}const Xa=f("ZodNever",(e,t)=>{ws.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Hi(e,n,o)});function ec(e){return yi(Xa,e)}const tc=f("ZodArray",(e,t)=>{ks.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Gi(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(Ge(n,o)),e.nonempty=n=>e.check(Ge(1,n)),e.max=(n,o)=>e.check(Wn(n,o)),e.length=(n,o)=>e.check(Kn(n,o)),e.unwrap=()=>e.element});function w(e,t){return Zi(tc,e,t)}const so=f("ZodObject",(e,t)=>{zs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Qi(e,n,o,r),T(e,"shape",()=>t.shape),e.keyof=()=>Y(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:P()}),e.loose=()=>e.clone({...e._zod.def,catchall:P()}),e.strict=()=>e.clone({...e._zod.def,catchall:ec()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Lo(e,n),e.safeExtend=n=>Fo(e,n),e.merge=n=>Ho(e,n),e.pick=n=>Do(e,n),e.omit=n=>Uo(e,n),e.partial=(...n)=>Jo(uo,e,n[0]),e.required=(...n)=>Bo(lo,e,n[0])});function p(e,t){const n={type:"object",shape:e??{},...b(t)};return new so(n)}function V(e,t){return new so({type:"object",shape:e,catchall:P(),...b(t)})}const io=f("ZodUnion",(e,t)=>{Bn.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Yi(e,n,o,r),e.options=t.options});function S(e,t){return new io({type:"union",options:e,...b(t)})}const nc=f("ZodDiscriminatedUnion",(e,t)=>{io.init(e,t),Ts.init(e,t)});function ao(e,t,n){return new nc({type:"union",options:t,discriminator:e,...b(n)})}const oc=f("ZodIntersection",(e,t)=>{Rs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xi(e,n,o,r)});function Pt(e,t){return new oc({type:"intersection",left:e,right:t})}const rc=f("ZodRecord",(e,t)=>{$s.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ea(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function $(e,t,n){return new rc({type:"record",keyType:e,valueType:t,...b(n)})}const gt=f("ZodEnum",(e,t)=>{Is.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Bi(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const s={};for(const i of o)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new gt({...t,checks:[],...b(r),entries:s})},e.exclude=(o,r)=>{const s={...t.entries};for(const i of o)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new gt({...t,checks:[],...b(r),entries:s})}});function Y(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new gt({type:"enum",entries:n,...b(t)})}const sc=f("ZodLiteral",(e,t)=>{Ps.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Vi(e,n,o),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 u(e,t){return new sc({type:"literal",values:Array.isArray(e)?e:[e],...b(t)})}const ic=f("ZodTransform",(e,t)=>{Es.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ki(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Rn(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Ee(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(Ee(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function co(e){return new ic({type:"transform",transform:e})}const uo=f("ZodOptional",(e,t)=>{Vn.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xn(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function q(e){return new uo({type:"optional",innerType:e})}const ac=f("ZodExactOptional",(e,t)=>{Cs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xn(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function cc(e){return new ac({type:"optional",innerType:e})}const uc=f("ZodNullable",(e,t)=>{Zs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ta(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function vn(e){return new uc({type:"nullable",innerType:e})}const lc=f("ZodDefault",(e,t)=>{xs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>oa(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function dc(e,t){return new lc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():En(t)}})}const pc=f("ZodPrefault",(e,t)=>{Os.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ra(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function hc(e,t){return new pc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():En(t)}})}const lo=f("ZodNonOptional",(e,t)=>{Ns.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>na(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function fc(e,t){return new lo({type:"nonoptional",innerType:e,...b(t)})}const mc=f("ZodCatch",(e,t)=>{As.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>sa(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function gc(e,t){return new mc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const _c=f("ZodPipe",(e,t)=>{qs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ia(e,n,o,r),e.in=t.in,e.out=t.out});function _t(e,t){return new _c({type:"pipe",in:e,out:t})}const bc=f("ZodReadonly",(e,t)=>{Ms.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>aa(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new bc({type:"readonly",innerType:e})}const po=f("ZodCustom",(e,t)=>{js.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wi(e,n)});function yc(e,t){return xi(po,e??(()=>!0),t)}function wc(e,t={}){return Oi(po,e,t)}function kc(e){return Ni(e)}function ho(e,t){return _t(co(e),t)}const me="io.modelcontextprotocol/related-task",it="2.0",U=yc(e=>e!==null&&(typeof e=="object"||typeof e=="function")),fo=S([d(),k().int()]),mo=d();V({ttl:S([k(),ro()]).optional(),pollInterval:k().optional()});const Sc=p({ttl:k().optional()}),zc=p({taskId:d()}),Et=V({progressToken:fo.optional(),[me]:zc.optional()}),X=p({_meta:Et.optional()}),Ze=X.extend({task:Sc.optional()}),Tc=e=>Ze.safeParse(e).success,L=p({method:d(),params:X.loose().optional()}),te=p({_meta:Et.optional()}),ne=p({method:d(),params:te.loose().optional()}),F=V({_meta:Et.optional()}),xe=S([d(),k().int()]),go=p({jsonrpc:u(it),id:xe,...L.shape}).strict(),yn=e=>go.safeParse(e).success,_o=p({jsonrpc:u(it),...ne.shape}).strict(),Rc=e=>_o.safeParse(e).success,Ct=p({jsonrpc:u(it),id:xe,result:F}).strict(),He=e=>Ct.safeParse(e).success;var R;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(R||(R={}));const Zt=p({jsonrpc:u(it),id:xe.optional(),error:p({code:k().int(),message:d(),data:P().optional()})}).strict(),$c=e=>Zt.safeParse(e).success,Ic=S([go,_o,Ct,Zt]);S([Ct,Zt]);const xt=F.strict(),Pc=te.extend({requestId:xe.optional(),reason:d().optional()}),Ot=ne.extend({method:u("notifications/cancelled"),params:Pc}),Ec=p({src:d(),mimeType:d().optional(),sizes:w(d()).optional(),theme:Y(["light","dark"]).optional()}),Oe=p({icons:w(Ec).optional()}),ze=p({name:d(),title:d().optional()}),at=ze.extend({...ze.shape,...Oe.shape,version:d(),websiteUrl:d().optional(),description:d().optional()}),Cc=Pt(p({applyDefaults:E().optional()}),$(d(),P())),Zc=ho(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Pt(p({form:Cc.optional(),url:U.optional()}),$(d(),P()).optional())),xc=V({list:U.optional(),cancel:U.optional(),requests:V({sampling:V({createMessage:U.optional()}).optional(),elicitation:V({create:U.optional()}).optional()}).optional()}),Oc=V({list:U.optional(),cancel:U.optional(),requests:V({tools:V({call:U.optional()}).optional()}).optional()}),Nc=p({experimental:$(d(),U).optional(),sampling:p({context:U.optional(),tools:U.optional()}).optional(),elicitation:Zc.optional(),roots:p({listChanged:E().optional()}).optional(),tasks:xc.optional()}),Ac=X.extend({protocolVersion:d(),capabilities:Nc,clientInfo:at}),qc=L.extend({method:u("initialize"),params:Ac}),Mc=p({experimental:$(d(),U).optional(),logging:U.optional(),completions:U.optional(),prompts:p({listChanged:E().optional()}).optional(),resources:p({subscribe:E().optional(),listChanged:E().optional()}).optional(),tools:p({listChanged:E().optional()}).optional(),tasks:Oc.optional()}),jc=F.extend({protocolVersion:d(),capabilities:Mc,serverInfo:at,instructions:d().optional()}),Dc=ne.extend({method:u("notifications/initialized"),params:te.optional()}),ct=L.extend({method:u("ping"),params:X.optional()}),Uc=p({progress:k(),total:q(k()),message:q(d())}),Lc=p({...te.shape,...Uc.shape,progressToken:fo}),Nt=ne.extend({method:u("notifications/progress"),params:Lc}),Fc=X.extend({cursor:mo.optional()}),Ne=L.extend({params:Fc.optional()}),Ae=F.extend({nextCursor:mo.optional()}),Hc=Y(["working","input_required","completed","failed","cancelled"]),qe=p({taskId:d(),status:Hc,ttl:S([k(),ro()]),createdAt:d(),lastUpdatedAt:d(),pollInterval:q(k()),statusMessage:q(d())}),At=F.extend({task:qe}),Jc=te.merge(qe),Ye=ne.extend({method:u("notifications/tasks/status"),params:Jc}),qt=L.extend({method:u("tasks/get"),params:X.extend({taskId:d()})}),Mt=F.merge(qe),jt=L.extend({method:u("tasks/result"),params:X.extend({taskId:d()})});F.loose();const Dt=Ne.extend({method:u("tasks/list")}),Ut=Ae.extend({tasks:w(qe)}),Lt=L.extend({method:u("tasks/cancel"),params:X.extend({taskId:d()})}),Bc=F.merge(qe),bo=p({uri:d(),mimeType:q(d()),_meta:$(d(),P()).optional()}),vo=bo.extend({text:d()}),Ft=d().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),yo=bo.extend({blob:Ft}),Me=Y(["user","assistant"]),Re=p({audience:w(Me).optional(),priority:k().min(0).max(1).optional(),lastModified:to({offset:!0}).optional()}),wo=p({...ze.shape,...Oe.shape,uri:d(),description:q(d()),mimeType:q(d()),annotations:Re.optional(),_meta:q(V({}))}),Vc=p({...ze.shape,...Oe.shape,uriTemplate:d(),description:q(d()),mimeType:q(d()),annotations:Re.optional(),_meta:q(V({}))}),Wc=Ne.extend({method:u("resources/list")}),ko=Ae.extend({resources:w(wo)}),Kc=Ne.extend({method:u("resources/templates/list")}),Gc=Ae.extend({resourceTemplates:w(Vc)}),Ht=X.extend({uri:d()}),Qc=Ht,Yc=L.extend({method:u("resources/read"),params:Qc}),So=F.extend({contents:w(S([vo,yo]))}),Xc=ne.extend({method:u("notifications/resources/list_changed"),params:te.optional()}),eu=Ht,tu=L.extend({method:u("resources/subscribe"),params:eu}),nu=Ht,ou=L.extend({method:u("resources/unsubscribe"),params:nu}),ru=te.extend({uri:d()}),su=ne.extend({method:u("notifications/resources/updated"),params:ru}),iu=p({name:d(),description:q(d()),required:q(E())}),au=p({...ze.shape,...Oe.shape,description:q(d()),arguments:q(w(iu)),_meta:q(V({}))}),cu=Ne.extend({method:u("prompts/list")}),uu=Ae.extend({prompts:w(au)}),lu=X.extend({name:d(),arguments:$(d(),d()).optional()}),du=L.extend({method:u("prompts/get"),params:lu}),Jt=p({type:u("text"),text:d(),annotations:Re.optional(),_meta:$(d(),P()).optional()}),Bt=p({type:u("image"),data:Ft,mimeType:d(),annotations:Re.optional(),_meta:$(d(),P()).optional()}),Vt=p({type:u("audio"),data:Ft,mimeType:d(),annotations:Re.optional(),_meta:$(d(),P()).optional()}),pu=p({type:u("tool_use"),name:d(),id:d(),input:$(d(),P()),_meta:$(d(),P()).optional()}),zo=p({type:u("resource"),resource:S([vo,yo]),annotations:Re.optional(),_meta:$(d(),P()).optional()}),To=wo.extend({type:u("resource_link")}),je=S([Jt,Bt,Vt,To,zo]),hu=p({role:Me,content:je}),fu=F.extend({description:d().optional(),messages:w(hu)}),mu=ne.extend({method:u("notifications/prompts/list_changed"),params:te.optional()}),gu=p({title:d().optional(),readOnlyHint:E().optional(),destructiveHint:E().optional(),idempotentHint:E().optional(),openWorldHint:E().optional()}),_u=p({taskSupport:Y(["required","optional","forbidden"]).optional()}),Wt=p({...ze.shape,...Oe.shape,description:d().optional(),inputSchema:p({type:u("object"),properties:$(d(),U).optional(),required:w(d()).optional()}).catchall(P()),outputSchema:p({type:u("object"),properties:$(d(),U).optional(),required:w(d()).optional()}).catchall(P()).optional(),annotations:gu.optional(),execution:_u.optional(),_meta:$(d(),P()).optional()}),Ro=Ne.extend({method:u("tools/list")}),bu=Ae.extend({tools:w(Wt)}),ut=F.extend({content:w(je).default([]),structuredContent:$(d(),P()).optional(),isError:E().optional()});ut.or(F.extend({toolResult:P()}));const vu=Ze.extend({name:d(),arguments:$(d(),P()).optional()}),$o=L.extend({method:u("tools/call"),params:vu}),yu=ne.extend({method:u("notifications/tools/list_changed"),params:te.optional()});p({autoRefresh:E().default(!0),debounceMs:k().int().nonnegative().default(300)});const Io=Y(["debug","info","notice","warning","error","critical","alert","emergency"]),wu=X.extend({level:Io}),ku=L.extend({method:u("logging/setLevel"),params:wu}),Su=te.extend({level:Io,logger:d().optional(),data:P()}),zu=ne.extend({method:u("notifications/message"),params:Su}),Tu=p({name:d().optional()}),Ru=p({hints:w(Tu).optional(),costPriority:k().min(0).max(1).optional(),speedPriority:k().min(0).max(1).optional(),intelligencePriority:k().min(0).max(1).optional()}),$u=p({mode:Y(["auto","required","none"]).optional()}),Iu=p({type:u("tool_result"),toolUseId:d().describe("The unique identifier for the corresponding tool call."),content:w(je).default([]),structuredContent:p({}).loose().optional(),isError:E().optional(),_meta:$(d(),P()).optional()}),Pu=ao("type",[Jt,Bt,Vt]),Xe=ao("type",[Jt,Bt,Vt,pu,Iu]),Eu=p({role:Me,content:S([Xe,w(Xe)]),_meta:$(d(),P()).optional()}),Cu=Ze.extend({messages:w(Eu),modelPreferences:Ru.optional(),systemPrompt:d().optional(),includeContext:Y(["none","thisServer","allServers"]).optional(),temperature:k().optional(),maxTokens:k().int(),stopSequences:w(d()).optional(),metadata:U.optional(),tools:w(Wt).optional(),toolChoice:$u.optional()}),Zu=L.extend({method:u("sampling/createMessage"),params:Cu}),xu=F.extend({model:d(),stopReason:q(Y(["endTurn","stopSequence","maxTokens"]).or(d())),role:Me,content:Pu}),Ou=F.extend({model:d(),stopReason:q(Y(["endTurn","stopSequence","maxTokens","toolUse"]).or(d())),role:Me,content:S([Xe,w(Xe)])}),Nu=p({type:u("boolean"),title:d().optional(),description:d().optional(),default:E().optional()}),Au=p({type:u("string"),title:d().optional(),description:d().optional(),minLength:k().optional(),maxLength:k().optional(),format:Y(["email","uri","date","date-time"]).optional(),default:d().optional()}),qu=p({type:Y(["number","integer"]),title:d().optional(),description:d().optional(),minimum:k().optional(),maximum:k().optional(),default:k().optional()}),Mu=p({type:u("string"),title:d().optional(),description:d().optional(),enum:w(d()),default:d().optional()}),ju=p({type:u("string"),title:d().optional(),description:d().optional(),oneOf:w(p({const:d(),title:d()})),default:d().optional()}),Du=p({type:u("string"),title:d().optional(),description:d().optional(),enum:w(d()),enumNames:w(d()).optional(),default:d().optional()}),Uu=S([Mu,ju]),Lu=p({type:u("array"),title:d().optional(),description:d().optional(),minItems:k().optional(),maxItems:k().optional(),items:p({type:u("string"),enum:w(d())}),default:w(d()).optional()}),Fu=p({type:u("array"),title:d().optional(),description:d().optional(),minItems:k().optional(),maxItems:k().optional(),items:p({anyOf:w(p({const:d(),title:d()}))}),default:w(d()).optional()}),Hu=S([Lu,Fu]),Ju=S([Du,Uu,Hu]),Bu=S([Ju,Nu,Au,qu]),Vu=Ze.extend({mode:u("form").optional(),message:d(),requestedSchema:p({type:u("object"),properties:$(d(),Bu),required:w(d()).optional()})}),Wu=Ze.extend({mode:u("url"),message:d(),elicitationId:d(),url:d().url()}),Ku=S([Vu,Wu]),Gu=L.extend({method:u("elicitation/create"),params:Ku}),Qu=te.extend({elicitationId:d()}),Yu=ne.extend({method:u("notifications/elicitation/complete"),params:Qu}),Xu=F.extend({action:Y(["accept","decline","cancel"]),content:ho(e=>e===null?void 0:e,$(d(),S([d(),k(),E(),w(d())])).optional())}),el=p({type:u("ref/resource"),uri:d()}),tl=p({type:u("ref/prompt"),name:d()}),nl=X.extend({ref:S([tl,el]),argument:p({name:d(),value:d()}),context:p({arguments:$(d(),d()).optional()}).optional()}),ol=L.extend({method:u("completion/complete"),params:nl}),rl=F.extend({completion:V({values:w(d()).max(100),total:q(k().int()),hasMore:q(E())})}),sl=p({uri:d().startsWith("file://"),name:d().optional(),_meta:$(d(),P()).optional()}),il=L.extend({method:u("roots/list"),params:X.optional()}),al=F.extend({roots:w(sl)}),cl=ne.extend({method:u("notifications/roots/list_changed"),params:te.optional()});S([ct,qc,ol,ku,du,cu,Wc,Kc,Yc,tu,ou,$o,Ro,qt,jt,Dt,Lt]);S([Ot,Nt,Dc,cl,Ye]);S([xt,xu,Ou,Xu,al,Mt,Ut,At]);S([ct,Zu,Gu,il,qt,jt,Dt,Lt]);S([Ot,Nt,zu,su,Xc,yu,mu,Ye,Yu]);S([xt,jc,rl,fu,uu,ko,Gc,So,ut,bu,Mt,Ut,At]);class z extends Error{constructor(t,n,o){super(`MCP error ${t}: ${n}`),this.code=t,this.data=o,this.name="McpError"}static fromError(t,n,o){if(t===R.UrlElicitationRequired&&o){const r=o;if(r.elicitations)return new ul(r.elicitations,n)}return new z(t,n,o)}}class ul extends z{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(R.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function fe(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function wn(e){const t=ca(e),n=t==null?void 0:t.method;if(!n)throw new Error("Schema is missing a method literal");const o=ua(n);if(typeof o!="string")throw new Error("Schema method literal must be a string");return o}function kn(e,t){const n=eo(e,t);if(!n.success)throw n.error;return n.data}const ll=6e4;class dl{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ot,n=>{this._oncancel(n)}),this.setNotificationHandler(Nt,n=>{this._onprogress(n)}),this.setRequestHandler(ct,n=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(qt,async(n,o)=>{const r=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!r)throw new z(R.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(jt,async(n,o)=>{const r=async()=>{var a;const s=n.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(s,o.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,h=l.id,m=this._requestResolvers.get(h);if(m)if(this._requestResolvers.delete(h),c.type==="response")m(l);else{const g=l,_=new z(g.error.code,g.error.message,g.error.data);m(_)}else{const g=c.type==="response"?"Response":"Error";this._onerror(new Error(`${g} handler missing for request ${h}`))}continue}await((a=this._transport)==null?void 0:a.send(c.message,{relatedRequestId:o.requestId}))}}const i=await this._taskStore.getTask(s,o.sessionId);if(!i)throw new z(R.InvalidParams,`Task not found: ${s}`);if(!fe(i.status))return await this._waitForTaskUpdate(s,o.signal),await r();if(fe(i.status)){const c=await this._taskStore.getTaskResult(s,o.sessionId);return this._clearTaskQueue(s),{...c,_meta:{...c._meta,[me]:{taskId:s}}}}return await r()};return await r()}),this.setRequestHandler(Dt,async(n,o)=>{var r;try{const{tasks:s,nextCursor:i}=await this._taskStore.listTasks((r=n.params)==null?void 0:r.cursor,o.sessionId);return{tasks:s,nextCursor:i,_meta:{}}}catch(s){throw new z(R.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(Lt,async(n,o)=>{try{const r=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!r)throw new z(R.InvalidParams,`Task not found: ${n.params.taskId}`);if(fe(r.status))throw new z(R.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",o.sessionId),this._clearTaskQueue(n.params.taskId);const s=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!s)throw new z(R.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...s}}catch(r){throw r instanceof z?r:new z(R.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;const n=this._requestHandlerAbortControllers.get(t.params.requestId);n==null||n.abort(t.params.reason)}_setupTimeout(t,n,o,r,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(r,n),startTime:Date.now(),timeout:n,maxTotalTimeout:o,resetTimeoutOnProgress:s,onTimeout:r})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const o=Date.now()-n.startTime;if(n.maxTotalTimeout&&o>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),z.fromError(R.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:o});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){var s,i,a;if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const n=(s=this.transport)==null?void 0:s.onclose;this._transport.onclose=()=>{n==null||n(),this._onclose()};const o=(i=this.transport)==null?void 0:i.onerror;this._transport.onerror=c=>{o==null||o(c),this._onerror(c)};const r=(a=this._transport)==null?void 0:a.onmessage;this._transport.onmessage=(c,l)=>{r==null||r(c,l),He(c)||$c(c)?this._onresponse(c):yn(c)?this._onrequest(c,l):Rc(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var o;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const r of this._requestHandlerAbortControllers.values())r.abort();this._requestHandlerAbortControllers.clear();const n=z.fromError(R.ConnectionClosed,"Connection closed");this._transport=void 0,(o=this.onclose)==null||o.call(this);for(const r of t.values())r(n)}_onerror(t){var n;(n=this.onerror)==null||n.call(this,t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(o=>this._onerror(new Error(`Uncaught error in notification handler: ${o}`)))}_onrequest(t,n){var h,m,g,_;const o=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,r=this._transport,s=(g=(m=(h=t.params)==null?void 0:h._meta)==null?void 0:m[me])==null?void 0:g.taskId;if(o===void 0){const v={jsonrpc:"2.0",id:t.id,error:{code:R.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:v,timestamp:Date.now()},r==null?void 0:r.sessionId).catch(y=>this._onerror(new Error(`Failed to enqueue error response: ${y}`))):r==null||r.send(v).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);const a=Tc(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,r==null?void 0:r.sessionId):void 0,l={signal:i.signal,sessionId:r==null?void 0:r.sessionId,_meta:(_=t.params)==null?void 0:_._meta,sendNotification:async v=>{if(i.signal.aborted)return;const y={relatedRequestId:t.id};s&&(y.relatedTask={taskId:s}),await this.notification(v,y)},sendRequest:async(v,y,I)=>{var re;if(i.signal.aborted)throw new z(R.ConnectionClosed,"Request was cancelled");const K={...I,relatedRequestId:t.id};s&&!K.relatedTask&&(K.relatedTask={taskId:s});const O=((re=K.relatedTask)==null?void 0:re.taskId)??s;return O&&c&&await c.updateTaskStatus(O,"input_required"),await this.request(v,y,K)},authInfo:n==null?void 0:n.authInfo,requestId:t.id,requestInfo:n==null?void 0:n.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a==null?void 0:a.ttl,closeSSEStream:n==null?void 0:n.closeSSEStream,closeStandaloneSSEStream:n==null?void 0:n.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>o(t,l)).then(async v=>{if(i.signal.aborted)return;const y={result:v,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:y,timestamp:Date.now()},r==null?void 0:r.sessionId):await(r==null?void 0:r.send(y))},async v=>{if(i.signal.aborted)return;const y={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(v.code)?v.code:R.InternalError,message:v.message??"Internal error",...v.data!==void 0&&{data:v.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:y,timestamp:Date.now()},r==null?void 0:r.sessionId):await(r==null?void 0:r.send(y))}).catch(v=>this._onerror(new Error(`Failed to send response: ${v}`))).finally(()=>{this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...o}=t.params,r=Number(n),s=this._progressHandlers.get(r);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const i=this._responseHandlers.get(r),a=this._timeoutInfo.get(r);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(c){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(c);return}s(o)}_onresponse(t){const n=Number(t.id),o=this._requestResolvers.get(n);if(o){if(this._requestResolvers.delete(n),He(t))o(t);else{const i=new z(t.error.code,t.error.message,t.error.data);o(i)}return}const r=this._responseHandlers.get(n);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let s=!1;if(He(t)&&t.result&&typeof t.result=="object"){const i=t.result;if(i.task&&typeof i.task=="object"){const a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,n))}}if(s||this._progressHandlers.delete(n),He(t))r(t);else{const i=z.fromError(t.error.code,t.error.message,t.error.data);r(i)}}get transport(){return this._transport}async close(){var t;await((t=this._transport)==null?void 0:t.close())}async*requestStream(t,n,o){var i,a;const{task:r}=o??{};if(!r){try{yield{type:"result",result:await this.request(t,n,o)}}catch(c){yield{type:"error",error:c instanceof z?c:new z(R.InternalError,String(c))}}return}let s;try{const c=await this.request(t,At,o);if(c.task)s=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new z(R.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:s},o);if(yield{type:"taskStatus",task:l},fe(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},n,o)}:l.status==="failed"?yield{type:"error",error:new z(R.InternalError,`Task ${s} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new z(R.InternalError,`Task ${s} was cancelled`)});return}if(l.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},n,o)};return}const h=l.pollInterval??((i=this._options)==null?void 0:i.defaultTaskPollInterval)??1e3;await new Promise(m=>setTimeout(m,h)),(a=o==null?void 0:o.signal)==null||a.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof z?c:new z(R.InternalError,String(c))}}}request(t,n,o){const{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=o??{};return new Promise((l,h)=>{var O,re,G,D,B;const m=N=>{h(N)};if(!this._transport){m(new Error("Not connected"));return}if(((O=this._options)==null?void 0:O.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(N){m(N);return}(re=o==null?void 0:o.signal)==null||re.throwIfAborted();const g=this._requestMessageId++,_={...t,jsonrpc:"2.0",id:g};o!=null&&o.onprogress&&(this._progressHandlers.set(g,o.onprogress),_.params={...t.params,_meta:{...((G=t.params)==null?void 0:G._meta)||{},progressToken:g}}),a&&(_.params={..._.params,task:a}),c&&(_.params={..._.params,_meta:{...((D=_.params)==null?void 0:D._meta)||{},[me]:c}});const v=N=>{var oe;this._responseHandlers.delete(g),this._progressHandlers.delete(g),this._cleanupTimeout(g),(oe=this._transport)==null||oe.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:g,reason:String(N)}},{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i}).catch(Co=>this._onerror(new Error(`Failed to send cancellation: ${Co}`)));const se=N instanceof z?N:new z(R.RequestTimeout,String(N));h(se)};this._responseHandlers.set(g,N=>{var se;if(!((se=o==null?void 0:o.signal)!=null&&se.aborted)){if(N instanceof Error)return h(N);try{const oe=eo(n,N.result);oe.success?l(oe.data):h(oe.error)}catch(oe){h(oe)}}}),(B=o==null?void 0:o.signal)==null||B.addEventListener("abort",()=>{var N;v((N=o==null?void 0:o.signal)==null?void 0:N.reason)});const y=(o==null?void 0:o.timeout)??ll,I=()=>v(z.fromError(R.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(g,y,o==null?void 0:o.maxTotalTimeout,I,(o==null?void 0:o.resetTimeoutOnProgress)??!1);const K=c==null?void 0:c.taskId;if(K){const N=se=>{const oe=this._responseHandlers.get(g);oe?oe(se):this._onerror(new Error(`Response handler missing for side-channeled request ${g}`))};this._requestResolvers.set(g,N),this._enqueueTaskMessage(K,{type:"request",message:_,timestamp:Date.now()}).catch(se=>{this._cleanupTimeout(g),h(se)})}else this._transport.send(_,{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i}).catch(N=>{this._cleanupTimeout(g),h(N)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},Mt,n)}async getTaskResult(t,n,o){return this.request({method:"tasks/result",params:t},n,o)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},Ut,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},Bc,n)}async notification(t,n){var a,c,l,h;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const o=(a=n==null?void 0:n.relatedTask)==null?void 0:a.taskId;if(o){const m={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[me]:n.relatedTask}}};await this._enqueueTaskMessage(o,{type:"notification",message:m,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(n!=null&&n.relatedRequestId)&&!(n!=null&&n.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var g,_;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let m={...t,jsonrpc:"2.0"};n!=null&&n.relatedTask&&(m={...m,params:{...m.params,_meta:{...((g=m.params)==null?void 0:g._meta)||{},[me]:n.relatedTask}}}),(_=this._transport)==null||_.send(m,n).catch(v=>this._onerror(v))});return}let i={...t,jsonrpc:"2.0"};n!=null&&n.relatedTask&&(i={...i,params:{...i.params,_meta:{...((h=i.params)==null?void 0:h._meta)||{},[me]:n.relatedTask}}}),await this._transport.send(i,n)}setRequestHandler(t,n){const o=wn(t);this.assertRequestHandlerCapability(o),this._requestHandlers.set(o,(r,s)=>{const i=kn(t,r);return Promise.resolve(n(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const o=wn(t);this._notificationHandlers.set(o,r=>{const s=kn(t,r);return Promise.resolve(n(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,o){var s;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=(s=this._options)==null?void 0:s.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,o,r)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const o=await this._taskMessageQueue.dequeueAll(t,n);for(const r of o)if(r.type==="request"&&yn(r.message)){const s=r.message.id,i=this._requestResolvers.get(s);i?(i(new z(R.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n){var r,s;let o=((r=this._options)==null?void 0:r.defaultTaskPollInterval)??1e3;try{const i=await((s=this._taskStore)==null?void 0:s.getTask(t));i!=null&&i.pollInterval&&(o=i.pollInterval)}catch{}return new Promise((i,a)=>{if(n.aborted){a(new z(R.InvalidRequest,"Request cancelled"));return}const c=setTimeout(i,o);n.addEventListener("abort",()=>{clearTimeout(c),a(new z(R.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const o=this._taskStore;if(!o)throw new Error("No task store configured");return{createTask:async r=>{if(!t)throw new Error("No request provided");return await o.createTask(r,t.id,{method:t.method,params:t.params},n)},getTask:async r=>{const s=await o.getTask(r,n);if(!s)throw new z(R.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(r,s,i)=>{await o.storeTaskResult(r,s,i,n);const a=await o.getTask(r,n);if(a){const c=Ye.parse({method:"notifications/tasks/status",params:a});await this.notification(c),fe(a.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>o.getTaskResult(r,n),updateTaskStatus:async(r,s,i)=>{const a=await o.getTask(r,n);if(!a)throw new z(R.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(fe(a.status))throw new z(R.InvalidParams,`Cannot update task "${r}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await o.updateTaskStatus(r,s,i,n);const c=await o.getTask(r,n);if(c){const l=Ye.parse({method:"notifications/tasks/status",params:c});await this.notification(l),fe(c.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>o.listTasks(r,n)}}}var pl="2026-01-26",hl="ui/notifications/tool-input-partial";class fl{constructor(t=window.parent,n){H(this,"eventTarget");H(this,"eventSource");H(this,"messageListener");H(this,"onclose");H(this,"onerror");H(this,"onmessage");H(this,"sessionId");H(this,"setProtocolVersion");this.eventTarget=t,this.eventSource=n,this.messageListener=o=>{var s,i,a;if(n&&o.source!==this.eventSource){console.debug("Ignoring message from unknown source",o);return}let r=Ic.safeParse(o.data);r.success?(console.debug("Parsed message",r.data),(s=this.onmessage)==null||s.call(this,r.data)):((i=o.data)==null?void 0:i.jsonrpc)!=="2.0"?console.debug("Ignoring non-JSON-RPC message",r.error.message,o):(console.error("Failed to parse message",r.error.message,o),(a=this.onerror)==null||a.call(this,Error("Invalid JSON-RPC message received: "+r.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==hl&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){var t;window.removeEventListener("message",this.messageListener),(t=this.onclose)==null||t.call(this)}}var ml=S([u("light"),u("dark")]).describe("Color theme preference for the host environment."),Ce=S([u("inline"),u("fullscreen"),u("pip")]).describe("Display mode for UI presentation."),gl=S([u("--color-background-primary"),u("--color-background-secondary"),u("--color-background-tertiary"),u("--color-background-inverse"),u("--color-background-ghost"),u("--color-background-info"),u("--color-background-danger"),u("--color-background-success"),u("--color-background-warning"),u("--color-background-disabled"),u("--color-text-primary"),u("--color-text-secondary"),u("--color-text-tertiary"),u("--color-text-inverse"),u("--color-text-ghost"),u("--color-text-info"),u("--color-text-danger"),u("--color-text-success"),u("--color-text-warning"),u("--color-text-disabled"),u("--color-border-primary"),u("--color-border-secondary"),u("--color-border-tertiary"),u("--color-border-inverse"),u("--color-border-ghost"),u("--color-border-info"),u("--color-border-danger"),u("--color-border-success"),u("--color-border-warning"),u("--color-border-disabled"),u("--color-ring-primary"),u("--color-ring-secondary"),u("--color-ring-inverse"),u("--color-ring-info"),u("--color-ring-danger"),u("--color-ring-success"),u("--color-ring-warning"),u("--font-sans"),u("--font-mono"),u("--font-weight-normal"),u("--font-weight-medium"),u("--font-weight-semibold"),u("--font-weight-bold"),u("--font-text-xs-size"),u("--font-text-sm-size"),u("--font-text-md-size"),u("--font-text-lg-size"),u("--font-heading-xs-size"),u("--font-heading-sm-size"),u("--font-heading-md-size"),u("--font-heading-lg-size"),u("--font-heading-xl-size"),u("--font-heading-2xl-size"),u("--font-heading-3xl-size"),u("--font-text-xs-line-height"),u("--font-text-sm-line-height"),u("--font-text-md-line-height"),u("--font-text-lg-line-height"),u("--font-heading-xs-line-height"),u("--font-heading-sm-line-height"),u("--font-heading-md-line-height"),u("--font-heading-lg-line-height"),u("--font-heading-xl-line-height"),u("--font-heading-2xl-line-height"),u("--font-heading-3xl-line-height"),u("--border-radius-xs"),u("--border-radius-sm"),u("--border-radius-md"),u("--border-radius-lg"),u("--border-radius-xl"),u("--border-radius-full"),u("--border-width-regular"),u("--shadow-hairline"),u("--shadow-sm"),u("--shadow-md"),u("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),_l=$(gl.describe(`Style variables for theming MCP apps.
46
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of e.seen.entries()){const m=h[1];if(t===h[0]){s(h);continue}if(e.external){const _=(c=e.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&_){s(h);continue}}if((l=e.metadataRegistry.get(h[0]))==null?void 0:l.id){s(h);continue}if(m.cycle){s(h);continue}if(m.count>1&&e.reused==="ref"){s(h);continue}}}function oo(e,t){var i,a,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=l=>{const h=e.seen.get(l);if(h.ref===null)return;const m=h.def??h.schema,g={...m},_=h.ref;if(h.ref=null,_){o(_);const y=e.seen.get(_),I=y.schema;if(I.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(m.allOf=m.allOf??[],m.allOf.push(I)):Object.assign(m,I),Object.assign(m,g),l._zod.parent===_)for(const O in m)O==="$ref"||O==="allOf"||O in g||delete m[O];if(I.$ref&&y.def)for(const O in m)O==="$ref"||O==="allOf"||O in y.def&&JSON.stringify(m[O])===JSON.stringify(y.def[O])&&delete m[O]}const v=l._zod.parent;if(v&&v!==_){o(v);const y=e.seen.get(v);if(y!=null&&y.schema.$ref&&(m.$ref=y.schema.$ref,y.def))for(const I in m)I==="$ref"||I==="allOf"||I in y.def&&JSON.stringify(m[I])===JSON.stringify(y.def[I])&&delete m[I]}e.override({zodSchema:l,jsonSchema:m,path:h.path??[]})};for(const l of[...e.seen.entries()].reverse())o(l[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,(i=e.external)!=null&&i.uri){const l=(a=e.external.registry.get(t))==null?void 0:a.id;if(!l)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(l)}Object.assign(r,n.def??n.schema);const s=((c=e.external)==null?void 0:c.defs)??{};for(const l of e.seen.entries()){const h=l[1];h.def&&h.defId&&(s[h.defId]=h.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?r.$defs=s:r.definitions=s);try{const l=JSON.parse(JSON.stringify(r));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:et(t,"input",e.processors),output:et(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function J(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return J(o.element,n);if(o.type==="set")return J(o.valueType,n);if(o.type==="lazy")return J(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return J(o.innerType,n);if(o.type==="intersection")return J(o.left,n)||J(o.right,n);if(o.type==="record"||o.type==="map")return J(o.keyType,n)||J(o.valueType,n);if(o.type==="pipe")return J(o.in,n)||J(o.out,n);if(o.type==="object"){for(const r in o.shape)if(J(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(J(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(J(r,n))return!0;return!!(o.rest&&J(o.rest,n))}return!1}const Vi=(e,t={})=>n=>{const o=to({...n,processors:t});return j(e,o),no(o,e),oo(o,e)},et=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=to({...r??{},target:s,io:t,processors:n});return j(e,i),no(i,e),oo(i,e)},Wi={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ki=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof i=="number"&&(r.maxLength=i),a&&(r.format=Wi[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),l&&(r.contentEncoding=l),c&&c.size>0){const h=[...c];h.length===1?r.pattern=h[0].source:h.length>1&&(r.allOf=[...h.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Gi=(e,t,n,o)=>{const r=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:h}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=h,r.exclusiveMinimum=!0):r.exclusiveMinimum=h),typeof s=="number"&&(r.minimum=s,typeof h=="number"&&t.target!=="draft-04"&&(h>=s?delete r.minimum:delete r.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l),typeof i=="number"&&(r.maximum=i,typeof l=="number"&&t.target!=="draft-04"&&(l<=i?delete r.maximum:delete r.exclusiveMaximum)),typeof c=="number"&&(r.multipleOf=c)},Qi=(e,t,n,o)=>{n.type="boolean"},Yi=(e,t,n,o)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Xi=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},ea=(e,t,n,o)=>{n.not={}},ta=(e,t,n,o)=>{},na=(e,t,n,o)=>{const r=e._zod.def,s=xn(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},oa=(e,t,n,o)=>{const r=e._zod.def,s=[];for(const i of r.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s},ra=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},sa=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},ia=(e,t,n,o)=>{const r=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(r.minItems=i),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=j(s.element,t,{...o,path:[...o.path,"items"]})},aa=(e,t,n,o)=>{var l;const r=n,s=e._zod.def;r.type="object",r.properties={};const i=s.shape;for(const h in i)r.properties[h]=j(i[h],t,{...o,path:[...o.path,"properties",h]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(h=>{const m=s.shape[h]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));c.size>0&&(r.required=Array.from(c)),((l=s.catchall)==null?void 0:l._zod.def.type)==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=j(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},ca=(e,t,n,o)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((a,c)=>j(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},ua=(e,t,n,o)=>{const r=e._zod.def,s=j(r.left,t,{...o,path:[...o.path,"allOf",0]}),i=j(r.right,t,{...o,path:[...o.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c},la=(e,t,n,o)=>{const r=n,s=e._zod.def;r.type="object";const i=s.keyType,a=i._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=j(s.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(const m of c)r.patternProperties[m.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=j(s.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=j(s.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const l=i._zod.values;if(l){const h=[...l].filter(m=>typeof m=="string"||typeof m=="number");h.length>0&&(r.required=h)}},da=(e,t,n,o)=>{const r=e._zod.def,s=j(r.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},pa=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},ha=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},fa=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},ma=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},ga=(e,t,n,o)=>{const r=e._zod.def,s=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;j(s,t,o);const i=t.seen.get(e);i.ref=s},_a=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},ro=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType};function xt(e){return!!e._zod}function so(e,t){return xt(e)?jn(e,t):e.safeParse(t)}function ba(e){var n,o;if(!e)return;let t;if(xt(e)?t=(o=(n=e._zod)==null?void 0:n.def)==null?void 0:o.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function va(e){var r;if(xt(e)){const i=(r=e._zod)==null?void 0:r.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const o=e.value;if(o!==void 0)return o}const ya=f("ZodISODateTime",(e,t)=>{ps.init(e,t),A.init(e,t)});function io(e){return yi(ya,e)}const wa=f("ZodISODate",(e,t)=>{hs.init(e,t),A.init(e,t)});function ka(e){return wi(wa,e)}const Sa=f("ZodISOTime",(e,t)=>{fs.init(e,t),A.init(e,t)});function za(e){return ki(Sa,e)}const Ta=f("ZodISODuration",(e,t)=>{ms.init(e,t),A.init(e,t)});function Ra(e){return Si(Ta,e)}const $a=(e,t)=>{qn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>rr(e,n)},flatten:{value:n=>or(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,_t,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,_t,2)}},isEmpty:{get(){return e.issues.length===0}}})},ee=f("ZodError",$a,{Parent:Error}),Ia=Et(ee),Pa=Ct(ee),Ea=at(ee),Ca=ct(ee),Za=ir(ee),xa=ar(ee),Oa=cr(ee),Na=ur(ee),Aa=lr(ee),qa=dr(ee),Ma=pr(ee),ja=hr(ee),Z=f("ZodType",(e,t)=>(C.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:et(e,"input"),output:et(e,"output")}}),e.toJSONSchema=Vi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(he(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),e.with=e.check,e.clone=(n,o)=>fe(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>Ia(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Ea(e,n,o),e.parseAsync=async(n,o)=>Pa(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>Ca(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>Za(e,n,o),e.decode=(n,o)=>xa(e,n,o),e.encodeAsync=async(n,o)=>Oa(e,n,o),e.decodeAsync=async(n,o)=>Na(e,n,o),e.safeEncode=(n,o)=>Aa(e,n,o),e.safeDecode=(n,o)=>qa(e,n,o),e.safeEncodeAsync=async(n,o)=>Ma(e,n,o),e.safeDecodeAsync=async(n,o)=>ja(e,n,o),e.refine=(n,o)=>e.check(Cc(n,o)),e.superRefine=n=>e.check(Zc(n)),e.overwrite=n=>e.check($e(n)),e.optional=()=>q(e),e.exactOptional=()=>bc(e),e.nullable=()=>zn(e),e.nullish=()=>q(zn(e)),e.nonoptional=n=>zc(e,n),e.array=()=>w(e),e.or=n=>S([e,n]),e.and=n=>Ot(e,n),e.transform=n=>wt(e,fo(n)),e.default=n=>wc(e,n),e.prefault=n=>Sc(e,n),e.catch=n=>Rc(e,n),e.pipe=n=>wt(e,n),e.readonly=()=>Pc(e),e.describe=n=>{const o=e.clone();return Ee.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){var n;return(n=Ee.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Ee.get(e);const o=e.clone();return Ee.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),ao=f("_ZodString",(e,t)=>{Zt.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Ki(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(Ci(...o)),e.includes=(...o)=>e.check(Oi(...o)),e.startsWith=(...o)=>e.check(Ni(...o)),e.endsWith=(...o)=>e.check(Ai(...o)),e.min=(...o)=>e.check(Xe(...o)),e.max=(...o)=>e.check(Xn(...o)),e.length=(...o)=>e.check(eo(...o)),e.nonempty=(...o)=>e.check(Xe(1,...o)),e.lowercase=o=>e.check(Zi(o)),e.uppercase=o=>e.check(xi(o)),e.trim=()=>e.check(Mi()),e.normalize=(...o)=>e.check(qi(...o)),e.toLowerCase=()=>e.check(ji()),e.toUpperCase=()=>e.check(Di()),e.slugify=()=>e.check(Ui())}),Da=f("ZodString",(e,t)=>{Zt.init(e,t),ao.init(e,t),e.email=n=>e.check(Xs(Ua,n)),e.url=n=>e.check(ri(La,n)),e.jwt=n=>e.check(vi(oc,n)),e.emoji=n=>e.check(si(Fa,n)),e.guid=n=>e.check(bn(kn,n)),e.uuid=n=>e.check(ei(Je,n)),e.uuidv4=n=>e.check(ti(Je,n)),e.uuidv6=n=>e.check(ni(Je,n)),e.uuidv7=n=>e.check(oi(Je,n)),e.nanoid=n=>e.check(ii(Ha,n)),e.guid=n=>e.check(bn(kn,n)),e.cuid=n=>e.check(ai(Ja,n)),e.cuid2=n=>e.check(ci(Ba,n)),e.ulid=n=>e.check(ui(Va,n)),e.base64=n=>e.check(gi(ec,n)),e.base64url=n=>e.check(_i(tc,n)),e.xid=n=>e.check(li(Wa,n)),e.ksuid=n=>e.check(di(Ka,n)),e.ipv4=n=>e.check(pi(Ga,n)),e.ipv6=n=>e.check(hi(Qa,n)),e.cidrv4=n=>e.check(fi(Ya,n)),e.cidrv6=n=>e.check(mi(Xa,n)),e.e164=n=>e.check(bi(nc,n)),e.datetime=n=>e.check(io(n)),e.date=n=>e.check(ka(n)),e.time=n=>e.check(za(n)),e.duration=n=>e.check(Ra(n))});function d(e){return Ys(Da,e)}const A=f("ZodStringFormat",(e,t)=>{x.init(e,t),ao.init(e,t)}),Ua=f("ZodEmail",(e,t)=>{os.init(e,t),A.init(e,t)}),kn=f("ZodGUID",(e,t)=>{ts.init(e,t),A.init(e,t)}),Je=f("ZodUUID",(e,t)=>{ns.init(e,t),A.init(e,t)}),La=f("ZodURL",(e,t)=>{rs.init(e,t),A.init(e,t)}),Fa=f("ZodEmoji",(e,t)=>{ss.init(e,t),A.init(e,t)}),Ha=f("ZodNanoID",(e,t)=>{is.init(e,t),A.init(e,t)}),Ja=f("ZodCUID",(e,t)=>{as.init(e,t),A.init(e,t)}),Ba=f("ZodCUID2",(e,t)=>{cs.init(e,t),A.init(e,t)}),Va=f("ZodULID",(e,t)=>{us.init(e,t),A.init(e,t)}),Wa=f("ZodXID",(e,t)=>{ls.init(e,t),A.init(e,t)}),Ka=f("ZodKSUID",(e,t)=>{ds.init(e,t),A.init(e,t)}),Ga=f("ZodIPv4",(e,t)=>{gs.init(e,t),A.init(e,t)}),Qa=f("ZodIPv6",(e,t)=>{_s.init(e,t),A.init(e,t)}),Ya=f("ZodCIDRv4",(e,t)=>{bs.init(e,t),A.init(e,t)}),Xa=f("ZodCIDRv6",(e,t)=>{vs.init(e,t),A.init(e,t)}),ec=f("ZodBase64",(e,t)=>{ys.init(e,t),A.init(e,t)}),tc=f("ZodBase64URL",(e,t)=>{ks.init(e,t),A.init(e,t)}),nc=f("ZodE164",(e,t)=>{Ss.init(e,t),A.init(e,t)}),oc=f("ZodJWT",(e,t)=>{Ts.init(e,t),A.init(e,t)}),co=f("ZodNumber",(e,t)=>{Wn.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Gi(e,o,r),e.gt=(o,r)=>e.check(yn(o,r)),e.gte=(o,r)=>e.check(mt(o,r)),e.min=(o,r)=>e.check(mt(o,r)),e.lt=(o,r)=>e.check(vn(o,r)),e.lte=(o,r)=>e.check(ft(o,r)),e.max=(o,r)=>e.check(ft(o,r)),e.int=o=>e.check(Sn(o)),e.safe=o=>e.check(Sn(o)),e.positive=o=>e.check(yn(0,o)),e.nonnegative=o=>e.check(mt(0,o)),e.negative=o=>e.check(vn(0,o)),e.nonpositive=o=>e.check(ft(0,o)),e.multipleOf=(o,r)=>e.check(wn(o,r)),e.step=(o,r)=>e.check(wn(o,r)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function k(e){return zi(co,e)}const rc=f("ZodNumberFormat",(e,t)=>{Rs.init(e,t),co.init(e,t)});function Sn(e){return Ti(rc,e)}const sc=f("ZodBoolean",(e,t)=>{$s.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Qi(e,n,o)});function E(e){return Ri(sc,e)}const ic=f("ZodUndefined",(e,t)=>{Is.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xi(e,n)});function vt(e){return $i(ic,e)}const ac=f("ZodNull",(e,t)=>{Ps.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Yi(e,n,o)});function uo(e){return Ii(ac,e)}const cc=f("ZodUnknown",(e,t)=>{Es.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ta()});function P(){return Pi(cc)}const uc=f("ZodNever",(e,t)=>{Cs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ea(e,n,o)});function lc(e){return Ei(uc,e)}const dc=f("ZodArray",(e,t)=>{Zs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ia(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(Xe(n,o)),e.nonempty=n=>e.check(Xe(1,n)),e.max=(n,o)=>e.check(Xn(n,o)),e.length=(n,o)=>e.check(eo(n,o)),e.unwrap=()=>e.element});function w(e,t){return Li(dc,e,t)}const lo=f("ZodObject",(e,t)=>{Os.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>aa(e,n,o,r),T(e,"shape",()=>t.shape),e.keyof=()=>Y(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:P()}),e.loose=()=>e.clone({...e._zod.def,catchall:P()}),e.strict=()=>e.clone({...e._zod.def,catchall:lc()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Yo(e,n),e.safeExtend=n=>Xo(e,n),e.merge=n=>er(e,n),e.pick=n=>Go(e,n),e.omit=n=>Qo(e,n),e.partial=(...n)=>tr(mo,e,n[0]),e.required=(...n)=>nr(go,e,n[0])});function p(e,t){const n={type:"object",shape:e??{},...b(t)};return new lo(n)}function V(e,t){return new lo({type:"object",shape:e,catchall:P(),...b(t)})}const po=f("ZodUnion",(e,t)=>{Qn.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ca(e,n,o,r),e.options=t.options});function S(e,t){return new po({type:"union",options:e,...b(t)})}const pc=f("ZodDiscriminatedUnion",(e,t)=>{po.init(e,t),Ns.init(e,t)});function ho(e,t,n){return new pc({type:"union",options:t,discriminator:e,...b(n)})}const hc=f("ZodIntersection",(e,t)=>{As.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ua(e,n,o,r)});function Ot(e,t){return new hc({type:"intersection",left:e,right:t})}const fc=f("ZodRecord",(e,t)=>{qs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>la(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function $(e,t,n){return new fc({type:"record",keyType:e,valueType:t,...b(n)})}const yt=f("ZodEnum",(e,t)=>{Ms.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(o,r,s)=>na(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const s={};for(const i of o)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new yt({...t,checks:[],...b(r),entries:s})},e.exclude=(o,r)=>{const s={...t.entries};for(const i of o)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new yt({...t,checks:[],...b(r),entries:s})}});function Y(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new yt({type:"enum",entries:n,...b(t)})}const mc=f("ZodLiteral",(e,t)=>{js.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>oa(e,n,o),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 u(e,t){return new mc({type:"literal",values:Array.isArray(e)?e:[e],...b(t)})}const gc=f("ZodTransform",(e,t)=>{Ds.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>sa(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Cn(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Ze(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(Ze(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function fo(e){return new gc({type:"transform",transform:e})}const mo=f("ZodOptional",(e,t)=>{Yn.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ro(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function q(e){return new mo({type:"optional",innerType:e})}const _c=f("ZodExactOptional",(e,t)=>{Us.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ro(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function bc(e){return new _c({type:"optional",innerType:e})}const vc=f("ZodNullable",(e,t)=>{Ls.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>da(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function zn(e){return new vc({type:"nullable",innerType:e})}const yc=f("ZodDefault",(e,t)=>{Fs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ha(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function wc(e,t){return new yc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Nn(t)}})}const kc=f("ZodPrefault",(e,t)=>{Hs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>fa(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Sc(e,t){return new kc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Nn(t)}})}const go=f("ZodNonOptional",(e,t)=>{Js.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>pa(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function zc(e,t){return new go({type:"nonoptional",innerType:e,...b(t)})}const Tc=f("ZodCatch",(e,t)=>{Bs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ma(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Rc(e,t){return new Tc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const $c=f("ZodPipe",(e,t)=>{Vs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ga(e,n,o,r),e.in=t.in,e.out=t.out});function wt(e,t){return new $c({type:"pipe",in:e,out:t})}const Ic=f("ZodReadonly",(e,t)=>{Ws.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>_a(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Pc(e){return new Ic({type:"readonly",innerType:e})}const _o=f("ZodCustom",(e,t)=>{Ks.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ra(e,n)});function Ec(e,t){return Fi(_o,e??(()=>!0),t)}function Cc(e,t={}){return Hi(_o,e,t)}function Zc(e){return Ji(e)}function bo(e,t){return wt(fo(e),t)}const ge="io.modelcontextprotocol/related-task",lt="2.0",U=Ec(e=>e!==null&&(typeof e=="object"||typeof e=="function")),vo=S([d(),k().int()]),yo=d();V({ttl:S([k(),uo()]).optional(),pollInterval:k().optional()});const xc=p({ttl:k().optional()}),Oc=p({taskId:d()}),Nt=V({progressToken:vo.optional(),[ge]:Oc.optional()}),X=p({_meta:Nt.optional()}),Oe=X.extend({task:xc.optional()}),Nc=e=>Oe.safeParse(e).success,L=p({method:d(),params:X.loose().optional()}),te=p({_meta:Nt.optional()}),ne=p({method:d(),params:te.loose().optional()}),F=V({_meta:Nt.optional()}),Ne=S([d(),k().int()]),wo=p({jsonrpc:u(lt),id:Ne,...L.shape}).strict(),Tn=e=>wo.safeParse(e).success,ko=p({jsonrpc:u(lt),...ne.shape}).strict(),Ac=e=>ko.safeParse(e).success,At=p({jsonrpc:u(lt),id:Ne,result:F}).strict(),Be=e=>At.safeParse(e).success;var R;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(R||(R={}));const qt=p({jsonrpc:u(lt),id:Ne.optional(),error:p({code:k().int(),message:d(),data:P().optional()})}).strict(),qc=e=>qt.safeParse(e).success,Mc=S([wo,ko,At,qt]);S([At,qt]);const Mt=F.strict(),jc=te.extend({requestId:Ne.optional(),reason:d().optional()}),jt=ne.extend({method:u("notifications/cancelled"),params:jc}),Dc=p({src:d(),mimeType:d().optional(),sizes:w(d()).optional(),theme:Y(["light","dark"]).optional()}),Ae=p({icons:w(Dc).optional()}),Re=p({name:d(),title:d().optional()}),dt=Re.extend({...Re.shape,...Ae.shape,version:d(),websiteUrl:d().optional(),description:d().optional()}),Uc=Ot(p({applyDefaults:E().optional()}),$(d(),P())),Lc=bo(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Ot(p({form:Uc.optional(),url:U.optional()}),$(d(),P()).optional())),Fc=V({list:U.optional(),cancel:U.optional(),requests:V({sampling:V({createMessage:U.optional()}).optional(),elicitation:V({create:U.optional()}).optional()}).optional()}),Hc=V({list:U.optional(),cancel:U.optional(),requests:V({tools:V({call:U.optional()}).optional()}).optional()}),Jc=p({experimental:$(d(),U).optional(),sampling:p({context:U.optional(),tools:U.optional()}).optional(),elicitation:Lc.optional(),roots:p({listChanged:E().optional()}).optional(),tasks:Fc.optional()}),Bc=X.extend({protocolVersion:d(),capabilities:Jc,clientInfo:dt}),Vc=L.extend({method:u("initialize"),params:Bc}),Wc=p({experimental:$(d(),U).optional(),logging:U.optional(),completions:U.optional(),prompts:p({listChanged:E().optional()}).optional(),resources:p({subscribe:E().optional(),listChanged:E().optional()}).optional(),tools:p({listChanged:E().optional()}).optional(),tasks:Hc.optional()}),Kc=F.extend({protocolVersion:d(),capabilities:Wc,serverInfo:dt,instructions:d().optional()}),Gc=ne.extend({method:u("notifications/initialized"),params:te.optional()}),pt=L.extend({method:u("ping"),params:X.optional()}),Qc=p({progress:k(),total:q(k()),message:q(d())}),Yc=p({...te.shape,...Qc.shape,progressToken:vo}),Dt=ne.extend({method:u("notifications/progress"),params:Yc}),Xc=X.extend({cursor:yo.optional()}),qe=L.extend({params:Xc.optional()}),Me=F.extend({nextCursor:yo.optional()}),eu=Y(["working","input_required","completed","failed","cancelled"]),je=p({taskId:d(),status:eu,ttl:S([k(),uo()]),createdAt:d(),lastUpdatedAt:d(),pollInterval:q(k()),statusMessage:q(d())}),Ut=F.extend({task:je}),tu=te.merge(je),tt=ne.extend({method:u("notifications/tasks/status"),params:tu}),Lt=L.extend({method:u("tasks/get"),params:X.extend({taskId:d()})}),Ft=F.merge(je),Ht=L.extend({method:u("tasks/result"),params:X.extend({taskId:d()})});F.loose();const Jt=qe.extend({method:u("tasks/list")}),Bt=Me.extend({tasks:w(je)}),Vt=L.extend({method:u("tasks/cancel"),params:X.extend({taskId:d()})}),nu=F.merge(je),So=p({uri:d(),mimeType:q(d()),_meta:$(d(),P()).optional()}),zo=So.extend({text:d()}),Wt=d().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),To=So.extend({blob:Wt}),De=Y(["user","assistant"]),Ie=p({audience:w(De).optional(),priority:k().min(0).max(1).optional(),lastModified:io({offset:!0}).optional()}),Ro=p({...Re.shape,...Ae.shape,uri:d(),description:q(d()),mimeType:q(d()),annotations:Ie.optional(),_meta:q(V({}))}),ou=p({...Re.shape,...Ae.shape,uriTemplate:d(),description:q(d()),mimeType:q(d()),annotations:Ie.optional(),_meta:q(V({}))}),ru=qe.extend({method:u("resources/list")}),$o=Me.extend({resources:w(Ro)}),su=qe.extend({method:u("resources/templates/list")}),iu=Me.extend({resourceTemplates:w(ou)}),Kt=X.extend({uri:d()}),au=Kt,cu=L.extend({method:u("resources/read"),params:au}),Io=F.extend({contents:w(S([zo,To]))}),uu=ne.extend({method:u("notifications/resources/list_changed"),params:te.optional()}),lu=Kt,du=L.extend({method:u("resources/subscribe"),params:lu}),pu=Kt,hu=L.extend({method:u("resources/unsubscribe"),params:pu}),fu=te.extend({uri:d()}),mu=ne.extend({method:u("notifications/resources/updated"),params:fu}),gu=p({name:d(),description:q(d()),required:q(E())}),_u=p({...Re.shape,...Ae.shape,description:q(d()),arguments:q(w(gu)),_meta:q(V({}))}),bu=qe.extend({method:u("prompts/list")}),vu=Me.extend({prompts:w(_u)}),yu=X.extend({name:d(),arguments:$(d(),d()).optional()}),wu=L.extend({method:u("prompts/get"),params:yu}),Gt=p({type:u("text"),text:d(),annotations:Ie.optional(),_meta:$(d(),P()).optional()}),Qt=p({type:u("image"),data:Wt,mimeType:d(),annotations:Ie.optional(),_meta:$(d(),P()).optional()}),Yt=p({type:u("audio"),data:Wt,mimeType:d(),annotations:Ie.optional(),_meta:$(d(),P()).optional()}),ku=p({type:u("tool_use"),name:d(),id:d(),input:$(d(),P()),_meta:$(d(),P()).optional()}),Po=p({type:u("resource"),resource:S([zo,To]),annotations:Ie.optional(),_meta:$(d(),P()).optional()}),Eo=Ro.extend({type:u("resource_link")}),Ue=S([Gt,Qt,Yt,Eo,Po]),Su=p({role:De,content:Ue}),zu=F.extend({description:d().optional(),messages:w(Su)}),Tu=ne.extend({method:u("notifications/prompts/list_changed"),params:te.optional()}),Ru=p({title:d().optional(),readOnlyHint:E().optional(),destructiveHint:E().optional(),idempotentHint:E().optional(),openWorldHint:E().optional()}),$u=p({taskSupport:Y(["required","optional","forbidden"]).optional()}),Xt=p({...Re.shape,...Ae.shape,description:d().optional(),inputSchema:p({type:u("object"),properties:$(d(),U).optional(),required:w(d()).optional()}).catchall(P()),outputSchema:p({type:u("object"),properties:$(d(),U).optional(),required:w(d()).optional()}).catchall(P()).optional(),annotations:Ru.optional(),execution:$u.optional(),_meta:$(d(),P()).optional()}),Co=qe.extend({method:u("tools/list")}),Iu=Me.extend({tools:w(Xt)}),ht=F.extend({content:w(Ue).default([]),structuredContent:$(d(),P()).optional(),isError:E().optional()});ht.or(F.extend({toolResult:P()}));const Pu=Oe.extend({name:d(),arguments:$(d(),P()).optional()}),Zo=L.extend({method:u("tools/call"),params:Pu}),Eu=ne.extend({method:u("notifications/tools/list_changed"),params:te.optional()});p({autoRefresh:E().default(!0),debounceMs:k().int().nonnegative().default(300)});const xo=Y(["debug","info","notice","warning","error","critical","alert","emergency"]),Cu=X.extend({level:xo}),Zu=L.extend({method:u("logging/setLevel"),params:Cu}),xu=te.extend({level:xo,logger:d().optional(),data:P()}),Ou=ne.extend({method:u("notifications/message"),params:xu}),Nu=p({name:d().optional()}),Au=p({hints:w(Nu).optional(),costPriority:k().min(0).max(1).optional(),speedPriority:k().min(0).max(1).optional(),intelligencePriority:k().min(0).max(1).optional()}),qu=p({mode:Y(["auto","required","none"]).optional()}),Mu=p({type:u("tool_result"),toolUseId:d().describe("The unique identifier for the corresponding tool call."),content:w(Ue).default([]),structuredContent:p({}).loose().optional(),isError:E().optional(),_meta:$(d(),P()).optional()}),ju=ho("type",[Gt,Qt,Yt]),nt=ho("type",[Gt,Qt,Yt,ku,Mu]),Du=p({role:De,content:S([nt,w(nt)]),_meta:$(d(),P()).optional()}),Uu=Oe.extend({messages:w(Du),modelPreferences:Au.optional(),systemPrompt:d().optional(),includeContext:Y(["none","thisServer","allServers"]).optional(),temperature:k().optional(),maxTokens:k().int(),stopSequences:w(d()).optional(),metadata:U.optional(),tools:w(Xt).optional(),toolChoice:qu.optional()}),Lu=L.extend({method:u("sampling/createMessage"),params:Uu}),Fu=F.extend({model:d(),stopReason:q(Y(["endTurn","stopSequence","maxTokens"]).or(d())),role:De,content:ju}),Hu=F.extend({model:d(),stopReason:q(Y(["endTurn","stopSequence","maxTokens","toolUse"]).or(d())),role:De,content:S([nt,w(nt)])}),Ju=p({type:u("boolean"),title:d().optional(),description:d().optional(),default:E().optional()}),Bu=p({type:u("string"),title:d().optional(),description:d().optional(),minLength:k().optional(),maxLength:k().optional(),format:Y(["email","uri","date","date-time"]).optional(),default:d().optional()}),Vu=p({type:Y(["number","integer"]),title:d().optional(),description:d().optional(),minimum:k().optional(),maximum:k().optional(),default:k().optional()}),Wu=p({type:u("string"),title:d().optional(),description:d().optional(),enum:w(d()),default:d().optional()}),Ku=p({type:u("string"),title:d().optional(),description:d().optional(),oneOf:w(p({const:d(),title:d()})),default:d().optional()}),Gu=p({type:u("string"),title:d().optional(),description:d().optional(),enum:w(d()),enumNames:w(d()).optional(),default:d().optional()}),Qu=S([Wu,Ku]),Yu=p({type:u("array"),title:d().optional(),description:d().optional(),minItems:k().optional(),maxItems:k().optional(),items:p({type:u("string"),enum:w(d())}),default:w(d()).optional()}),Xu=p({type:u("array"),title:d().optional(),description:d().optional(),minItems:k().optional(),maxItems:k().optional(),items:p({anyOf:w(p({const:d(),title:d()}))}),default:w(d()).optional()}),el=S([Yu,Xu]),tl=S([Gu,Qu,el]),nl=S([tl,Ju,Bu,Vu]),ol=Oe.extend({mode:u("form").optional(),message:d(),requestedSchema:p({type:u("object"),properties:$(d(),nl),required:w(d()).optional()})}),rl=Oe.extend({mode:u("url"),message:d(),elicitationId:d(),url:d().url()}),sl=S([ol,rl]),il=L.extend({method:u("elicitation/create"),params:sl}),al=te.extend({elicitationId:d()}),cl=ne.extend({method:u("notifications/elicitation/complete"),params:al}),ul=F.extend({action:Y(["accept","decline","cancel"]),content:bo(e=>e===null?void 0:e,$(d(),S([d(),k(),E(),w(d())])).optional())}),ll=p({type:u("ref/resource"),uri:d()}),dl=p({type:u("ref/prompt"),name:d()}),pl=X.extend({ref:S([dl,ll]),argument:p({name:d(),value:d()}),context:p({arguments:$(d(),d()).optional()}).optional()}),hl=L.extend({method:u("completion/complete"),params:pl}),fl=F.extend({completion:V({values:w(d()).max(100),total:q(k().int()),hasMore:q(E())})}),ml=p({uri:d().startsWith("file://"),name:d().optional(),_meta:$(d(),P()).optional()}),gl=L.extend({method:u("roots/list"),params:X.optional()}),_l=F.extend({roots:w(ml)}),bl=ne.extend({method:u("notifications/roots/list_changed"),params:te.optional()});S([pt,Vc,hl,Zu,wu,bu,ru,su,cu,du,hu,Zo,Co,Lt,Ht,Jt,Vt]);S([jt,Dt,Gc,bl,tt]);S([Mt,Fu,Hu,ul,_l,Ft,Bt,Ut]);S([pt,Lu,il,gl,Lt,Ht,Jt,Vt]);S([jt,Dt,Ou,mu,uu,Eu,Tu,tt,cl]);S([Mt,Kc,fl,zu,vu,$o,iu,Io,ht,Iu,Ft,Bt,Ut]);class z extends Error{constructor(t,n,o){super(`MCP error ${t}: ${n}`),this.code=t,this.data=o,this.name="McpError"}static fromError(t,n,o){if(t===R.UrlElicitationRequired&&o){const r=o;if(r.elicitations)return new vl(r.elicitations,n)}return new z(t,n,o)}}class vl extends z{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(R.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function me(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Rn(e){const t=ba(e),n=t==null?void 0:t.method;if(!n)throw new Error("Schema is missing a method literal");const o=va(n);if(typeof o!="string")throw new Error("Schema method literal must be a string");return o}function $n(e,t){const n=so(e,t);if(!n.success)throw n.error;return n.data}const yl=6e4;class wl{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(jt,n=>{this._oncancel(n)}),this.setNotificationHandler(Dt,n=>{this._onprogress(n)}),this.setRequestHandler(pt,n=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Lt,async(n,o)=>{const r=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!r)throw new z(R.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(Ht,async(n,o)=>{const r=async()=>{var a;const s=n.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(s,o.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,h=l.id,m=this._requestResolvers.get(h);if(m)if(this._requestResolvers.delete(h),c.type==="response")m(l);else{const g=l,_=new z(g.error.code,g.error.message,g.error.data);m(_)}else{const g=c.type==="response"?"Response":"Error";this._onerror(new Error(`${g} handler missing for request ${h}`))}continue}await((a=this._transport)==null?void 0:a.send(c.message,{relatedRequestId:o.requestId}))}}const i=await this._taskStore.getTask(s,o.sessionId);if(!i)throw new z(R.InvalidParams,`Task not found: ${s}`);if(!me(i.status))return await this._waitForTaskUpdate(s,o.signal),await r();if(me(i.status)){const c=await this._taskStore.getTaskResult(s,o.sessionId);return this._clearTaskQueue(s),{...c,_meta:{...c._meta,[ge]:{taskId:s}}}}return await r()};return await r()}),this.setRequestHandler(Jt,async(n,o)=>{var r;try{const{tasks:s,nextCursor:i}=await this._taskStore.listTasks((r=n.params)==null?void 0:r.cursor,o.sessionId);return{tasks:s,nextCursor:i,_meta:{}}}catch(s){throw new z(R.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(Vt,async(n,o)=>{try{const r=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!r)throw new z(R.InvalidParams,`Task not found: ${n.params.taskId}`);if(me(r.status))throw new z(R.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",o.sessionId),this._clearTaskQueue(n.params.taskId);const s=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!s)throw new z(R.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...s}}catch(r){throw r instanceof z?r:new z(R.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;const n=this._requestHandlerAbortControllers.get(t.params.requestId);n==null||n.abort(t.params.reason)}_setupTimeout(t,n,o,r,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(r,n),startTime:Date.now(),timeout:n,maxTotalTimeout:o,resetTimeoutOnProgress:s,onTimeout:r})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const o=Date.now()-n.startTime;if(n.maxTotalTimeout&&o>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),z.fromError(R.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:o});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){var s,i,a;if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const n=(s=this.transport)==null?void 0:s.onclose;this._transport.onclose=()=>{n==null||n(),this._onclose()};const o=(i=this.transport)==null?void 0:i.onerror;this._transport.onerror=c=>{o==null||o(c),this._onerror(c)};const r=(a=this._transport)==null?void 0:a.onmessage;this._transport.onmessage=(c,l)=>{r==null||r(c,l),Be(c)||qc(c)?this._onresponse(c):Tn(c)?this._onrequest(c,l):Ac(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var o;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const r of this._requestHandlerAbortControllers.values())r.abort();this._requestHandlerAbortControllers.clear();const n=z.fromError(R.ConnectionClosed,"Connection closed");this._transport=void 0,(o=this.onclose)==null||o.call(this);for(const r of t.values())r(n)}_onerror(t){var n;(n=this.onerror)==null||n.call(this,t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(o=>this._onerror(new Error(`Uncaught error in notification handler: ${o}`)))}_onrequest(t,n){var h,m,g,_;const o=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,r=this._transport,s=(g=(m=(h=t.params)==null?void 0:h._meta)==null?void 0:m[ge])==null?void 0:g.taskId;if(o===void 0){const v={jsonrpc:"2.0",id:t.id,error:{code:R.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:v,timestamp:Date.now()},r==null?void 0:r.sessionId).catch(y=>this._onerror(new Error(`Failed to enqueue error response: ${y}`))):r==null||r.send(v).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);const a=Nc(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,r==null?void 0:r.sessionId):void 0,l={signal:i.signal,sessionId:r==null?void 0:r.sessionId,_meta:(_=t.params)==null?void 0:_._meta,sendNotification:async v=>{if(i.signal.aborted)return;const y={relatedRequestId:t.id};s&&(y.relatedTask={taskId:s}),await this.notification(v,y)},sendRequest:async(v,y,I)=>{var re;if(i.signal.aborted)throw new z(R.ConnectionClosed,"Request was cancelled");const K={...I,relatedRequestId:t.id};s&&!K.relatedTask&&(K.relatedTask={taskId:s});const O=((re=K.relatedTask)==null?void 0:re.taskId)??s;return O&&c&&await c.updateTaskStatus(O,"input_required"),await this.request(v,y,K)},authInfo:n==null?void 0:n.authInfo,requestId:t.id,requestInfo:n==null?void 0:n.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a==null?void 0:a.ttl,closeSSEStream:n==null?void 0:n.closeSSEStream,closeStandaloneSSEStream:n==null?void 0:n.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>o(t,l)).then(async v=>{if(i.signal.aborted)return;const y={result:v,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:y,timestamp:Date.now()},r==null?void 0:r.sessionId):await(r==null?void 0:r.send(y))},async v=>{if(i.signal.aborted)return;const y={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(v.code)?v.code:R.InternalError,message:v.message??"Internal error",...v.data!==void 0&&{data:v.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:y,timestamp:Date.now()},r==null?void 0:r.sessionId):await(r==null?void 0:r.send(y))}).catch(v=>this._onerror(new Error(`Failed to send response: ${v}`))).finally(()=>{this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...o}=t.params,r=Number(n),s=this._progressHandlers.get(r);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const i=this._responseHandlers.get(r),a=this._timeoutInfo.get(r);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(c){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(c);return}s(o)}_onresponse(t){const n=Number(t.id),o=this._requestResolvers.get(n);if(o){if(this._requestResolvers.delete(n),Be(t))o(t);else{const i=new z(t.error.code,t.error.message,t.error.data);o(i)}return}const r=this._responseHandlers.get(n);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let s=!1;if(Be(t)&&t.result&&typeof t.result=="object"){const i=t.result;if(i.task&&typeof i.task=="object"){const a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,n))}}if(s||this._progressHandlers.delete(n),Be(t))r(t);else{const i=z.fromError(t.error.code,t.error.message,t.error.data);r(i)}}get transport(){return this._transport}async close(){var t;await((t=this._transport)==null?void 0:t.close())}async*requestStream(t,n,o){var i,a;const{task:r}=o??{};if(!r){try{yield{type:"result",result:await this.request(t,n,o)}}catch(c){yield{type:"error",error:c instanceof z?c:new z(R.InternalError,String(c))}}return}let s;try{const c=await this.request(t,Ut,o);if(c.task)s=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new z(R.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:s},o);if(yield{type:"taskStatus",task:l},me(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},n,o)}:l.status==="failed"?yield{type:"error",error:new z(R.InternalError,`Task ${s} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new z(R.InternalError,`Task ${s} was cancelled`)});return}if(l.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},n,o)};return}const h=l.pollInterval??((i=this._options)==null?void 0:i.defaultTaskPollInterval)??1e3;await new Promise(m=>setTimeout(m,h)),(a=o==null?void 0:o.signal)==null||a.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof z?c:new z(R.InternalError,String(c))}}}request(t,n,o){const{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=o??{};return new Promise((l,h)=>{var O,re,G,D,B;const m=N=>{h(N)};if(!this._transport){m(new Error("Not connected"));return}if(((O=this._options)==null?void 0:O.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(N){m(N);return}(re=o==null?void 0:o.signal)==null||re.throwIfAborted();const g=this._requestMessageId++,_={...t,jsonrpc:"2.0",id:g};o!=null&&o.onprogress&&(this._progressHandlers.set(g,o.onprogress),_.params={...t.params,_meta:{...((G=t.params)==null?void 0:G._meta)||{},progressToken:g}}),a&&(_.params={..._.params,task:a}),c&&(_.params={..._.params,_meta:{...((D=_.params)==null?void 0:D._meta)||{},[ge]:c}});const v=N=>{var oe;this._responseHandlers.delete(g),this._progressHandlers.delete(g),this._cleanupTimeout(g),(oe=this._transport)==null||oe.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:g,reason:String(N)}},{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i}).catch(Uo=>this._onerror(new Error(`Failed to send cancellation: ${Uo}`)));const se=N instanceof z?N:new z(R.RequestTimeout,String(N));h(se)};this._responseHandlers.set(g,N=>{var se;if(!((se=o==null?void 0:o.signal)!=null&&se.aborted)){if(N instanceof Error)return h(N);try{const oe=so(n,N.result);oe.success?l(oe.data):h(oe.error)}catch(oe){h(oe)}}}),(B=o==null?void 0:o.signal)==null||B.addEventListener("abort",()=>{var N;v((N=o==null?void 0:o.signal)==null?void 0:N.reason)});const y=(o==null?void 0:o.timeout)??yl,I=()=>v(z.fromError(R.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(g,y,o==null?void 0:o.maxTotalTimeout,I,(o==null?void 0:o.resetTimeoutOnProgress)??!1);const K=c==null?void 0:c.taskId;if(K){const N=se=>{const oe=this._responseHandlers.get(g);oe?oe(se):this._onerror(new Error(`Response handler missing for side-channeled request ${g}`))};this._requestResolvers.set(g,N),this._enqueueTaskMessage(K,{type:"request",message:_,timestamp:Date.now()}).catch(se=>{this._cleanupTimeout(g),h(se)})}else this._transport.send(_,{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i}).catch(N=>{this._cleanupTimeout(g),h(N)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},Ft,n)}async getTaskResult(t,n,o){return this.request({method:"tasks/result",params:t},n,o)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},Bt,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},nu,n)}async notification(t,n){var a,c,l,h;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const o=(a=n==null?void 0:n.relatedTask)==null?void 0:a.taskId;if(o){const m={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[ge]:n.relatedTask}}};await this._enqueueTaskMessage(o,{type:"notification",message:m,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(n!=null&&n.relatedRequestId)&&!(n!=null&&n.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var g,_;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let m={...t,jsonrpc:"2.0"};n!=null&&n.relatedTask&&(m={...m,params:{...m.params,_meta:{...((g=m.params)==null?void 0:g._meta)||{},[ge]:n.relatedTask}}}),(_=this._transport)==null||_.send(m,n).catch(v=>this._onerror(v))});return}let i={...t,jsonrpc:"2.0"};n!=null&&n.relatedTask&&(i={...i,params:{...i.params,_meta:{...((h=i.params)==null?void 0:h._meta)||{},[ge]:n.relatedTask}}}),await this._transport.send(i,n)}setRequestHandler(t,n){const o=Rn(t);this.assertRequestHandlerCapability(o),this._requestHandlers.set(o,(r,s)=>{const i=$n(t,r);return Promise.resolve(n(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const o=Rn(t);this._notificationHandlers.set(o,r=>{const s=$n(t,r);return Promise.resolve(n(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,o){var s;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=(s=this._options)==null?void 0:s.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,o,r)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const o=await this._taskMessageQueue.dequeueAll(t,n);for(const r of o)if(r.type==="request"&&Tn(r.message)){const s=r.message.id,i=this._requestResolvers.get(s);i?(i(new z(R.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n){var r,s;let o=((r=this._options)==null?void 0:r.defaultTaskPollInterval)??1e3;try{const i=await((s=this._taskStore)==null?void 0:s.getTask(t));i!=null&&i.pollInterval&&(o=i.pollInterval)}catch{}return new Promise((i,a)=>{if(n.aborted){a(new z(R.InvalidRequest,"Request cancelled"));return}const c=setTimeout(i,o);n.addEventListener("abort",()=>{clearTimeout(c),a(new z(R.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const o=this._taskStore;if(!o)throw new Error("No task store configured");return{createTask:async r=>{if(!t)throw new Error("No request provided");return await o.createTask(r,t.id,{method:t.method,params:t.params},n)},getTask:async r=>{const s=await o.getTask(r,n);if(!s)throw new z(R.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(r,s,i)=>{await o.storeTaskResult(r,s,i,n);const a=await o.getTask(r,n);if(a){const c=tt.parse({method:"notifications/tasks/status",params:a});await this.notification(c),me(a.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>o.getTaskResult(r,n),updateTaskStatus:async(r,s,i)=>{const a=await o.getTask(r,n);if(!a)throw new z(R.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(me(a.status))throw new z(R.InvalidParams,`Cannot update task "${r}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await o.updateTaskStatus(r,s,i,n);const c=await o.getTask(r,n);if(c){const l=tt.parse({method:"notifications/tasks/status",params:c});await this.notification(l),me(c.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>o.listTasks(r,n)}}}var kl="2026-01-26",Sl="ui/notifications/tool-input-partial";class zl{constructor(t=window.parent,n){H(this,"eventTarget");H(this,"eventSource");H(this,"messageListener");H(this,"onclose");H(this,"onerror");H(this,"onmessage");H(this,"sessionId");H(this,"setProtocolVersion");this.eventTarget=t,this.eventSource=n,this.messageListener=o=>{var s,i,a;if(n&&o.source!==this.eventSource){console.debug("Ignoring message from unknown source",o);return}let r=Mc.safeParse(o.data);r.success?(console.debug("Parsed message",r.data),(s=this.onmessage)==null||s.call(this,r.data)):((i=o.data)==null?void 0:i.jsonrpc)!=="2.0"?console.debug("Ignoring non-JSON-RPC message",r.error.message,o):(console.error("Failed to parse message",r.error.message,o),(a=this.onerror)==null||a.call(this,Error("Invalid JSON-RPC message received: "+r.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==Sl&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){var t;window.removeEventListener("message",this.messageListener),(t=this.onclose)==null||t.call(this)}}var Tl=S([u("light"),u("dark")]).describe("Color theme preference for the host environment."),xe=S([u("inline"),u("fullscreen"),u("pip")]).describe("Display mode for UI presentation."),Rl=S([u("--color-background-primary"),u("--color-background-secondary"),u("--color-background-tertiary"),u("--color-background-inverse"),u("--color-background-ghost"),u("--color-background-info"),u("--color-background-danger"),u("--color-background-success"),u("--color-background-warning"),u("--color-background-disabled"),u("--color-text-primary"),u("--color-text-secondary"),u("--color-text-tertiary"),u("--color-text-inverse"),u("--color-text-ghost"),u("--color-text-info"),u("--color-text-danger"),u("--color-text-success"),u("--color-text-warning"),u("--color-text-disabled"),u("--color-border-primary"),u("--color-border-secondary"),u("--color-border-tertiary"),u("--color-border-inverse"),u("--color-border-ghost"),u("--color-border-info"),u("--color-border-danger"),u("--color-border-success"),u("--color-border-warning"),u("--color-border-disabled"),u("--color-ring-primary"),u("--color-ring-secondary"),u("--color-ring-inverse"),u("--color-ring-info"),u("--color-ring-danger"),u("--color-ring-success"),u("--color-ring-warning"),u("--font-sans"),u("--font-mono"),u("--font-weight-normal"),u("--font-weight-medium"),u("--font-weight-semibold"),u("--font-weight-bold"),u("--font-text-xs-size"),u("--font-text-sm-size"),u("--font-text-md-size"),u("--font-text-lg-size"),u("--font-heading-xs-size"),u("--font-heading-sm-size"),u("--font-heading-md-size"),u("--font-heading-lg-size"),u("--font-heading-xl-size"),u("--font-heading-2xl-size"),u("--font-heading-3xl-size"),u("--font-text-xs-line-height"),u("--font-text-sm-line-height"),u("--font-text-md-line-height"),u("--font-text-lg-line-height"),u("--font-heading-xs-line-height"),u("--font-heading-sm-line-height"),u("--font-heading-md-line-height"),u("--font-heading-lg-line-height"),u("--font-heading-xl-line-height"),u("--font-heading-2xl-line-height"),u("--font-heading-3xl-line-height"),u("--border-radius-xs"),u("--border-radius-sm"),u("--border-radius-md"),u("--border-radius-lg"),u("--border-radius-xl"),u("--border-radius-full"),u("--border-width-regular"),u("--shadow-hairline"),u("--shadow-sm"),u("--shadow-md"),u("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),$l=$(Rl.describe(`Style variables for theming MCP apps.
47
47
 
48
48
  Individual style keys are optional - hosts may provide any subset of these values.
49
49
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
50
50
 
51
51
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
52
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),S([d(),mt()]).describe(`Style variables for theming MCP apps.
52
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),S([d(),vt()]).describe(`Style variables for theming MCP apps.
53
53
 
54
54
  Individual style keys are optional - hosts may provide any subset of these values.
55
55
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
@@ -61,10 +61,10 @@ Individual style keys are optional - hosts may provide any subset of these value
61
61
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
62
62
 
63
63
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
64
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);p({method:u("ui/open-link"),params:p({url:d().describe("URL to open in the host's browser")})});var bl=p({isError:E().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),vl=p({isError:E().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),yl=p({isError:E().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();p({method:u("ui/notifications/sandbox-proxy-ready"),params:p({})});var Kt=p({connectDomains:w(d()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
64
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);p({method:u("ui/open-link"),params:p({url:d().describe("URL to open in the host's browser")})});var Il=p({isError:E().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),Pl=p({isError:E().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),El=p({isError:E().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();p({method:u("ui/notifications/sandbox-proxy-ready"),params:p({})});var en=p({connectDomains:w(d()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
65
65
 
66
66
  - Maps to CSP \`connect-src\` directive
67
- - Empty or omitted → no network connections (secure default)`),resourceDomains:w(d()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:w(d()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:w(d()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Gt=p({camera:p({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:p({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:p({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:p({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});p({method:u("ui/notifications/size-changed"),params:p({width:k().optional().describe("New width in pixels."),height:k().optional().describe("New height in pixels.")})});var wl=p({method:u("ui/notifications/tool-input"),params:p({arguments:$(d(),P().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),kl=p({method:u("ui/notifications/tool-input-partial"),params:p({arguments:$(d(),P().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),Sl=p({method:u("ui/notifications/tool-cancelled"),params:p({reason:d().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),zl=p({fonts:d().optional()}),Tl=p({variables:_l.optional().describe("CSS variables for theming the app."),css:zl.optional().describe("CSS blocks that apps can inject.")}),Rl=p({method:u("ui/resource-teardown"),params:p({})});$(d(),P());var Sn=p({text:p({}).optional().describe("Host supports text content blocks."),image:p({}).optional().describe("Host supports image content blocks."),audio:p({}).optional().describe("Host supports audio content blocks."),resource:p({}).optional().describe("Host supports resource content blocks."),resourceLink:p({}).optional().describe("Host supports resource link content blocks."),structuredContent:p({}).optional().describe("Host supports structured content.")}),$l=p({experimental:p({}).optional().describe("Experimental features (structure TBD)."),openLinks:p({}).optional().describe("Host supports opening external URLs."),downloadFile:p({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:p({listChanged:E().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:p({listChanged:E().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:p({}).optional().describe("Host accepts log messages."),sandbox:p({permissions:Gt.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Kt.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Sn.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Sn.optional().describe("Host supports receiving content messages (ui/message) from the view.")}),Il=p({experimental:p({}).optional().describe("Experimental features (structure TBD)."),tools:p({listChanged:E().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:w(Ce).optional().describe("Display modes the app supports.")});p({method:u("ui/notifications/initialized"),params:p({}).optional()});p({csp:Kt.optional().describe("Content Security Policy configuration for UI resources."),permissions:Gt.optional().describe("Sandbox permissions requested by the UI resource."),domain:d().optional().describe(`Dedicated origin for view sandbox.
67
+ - Empty or omitted → no network connections (secure default)`),resourceDomains:w(d()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:w(d()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:w(d()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),tn=p({camera:p({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:p({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:p({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:p({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});p({method:u("ui/notifications/size-changed"),params:p({width:k().optional().describe("New width in pixels."),height:k().optional().describe("New height in pixels.")})});var Cl=p({method:u("ui/notifications/tool-input"),params:p({arguments:$(d(),P().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),Zl=p({method:u("ui/notifications/tool-input-partial"),params:p({arguments:$(d(),P().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),xl=p({method:u("ui/notifications/tool-cancelled"),params:p({reason:d().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),Ol=p({fonts:d().optional()}),Nl=p({variables:$l.optional().describe("CSS variables for theming the app."),css:Ol.optional().describe("CSS blocks that apps can inject.")}),Al=p({method:u("ui/resource-teardown"),params:p({})});$(d(),P());var In=p({text:p({}).optional().describe("Host supports text content blocks."),image:p({}).optional().describe("Host supports image content blocks."),audio:p({}).optional().describe("Host supports audio content blocks."),resource:p({}).optional().describe("Host supports resource content blocks."),resourceLink:p({}).optional().describe("Host supports resource link content blocks."),structuredContent:p({}).optional().describe("Host supports structured content.")}),ql=p({experimental:p({}).optional().describe("Experimental features (structure TBD)."),openLinks:p({}).optional().describe("Host supports opening external URLs."),downloadFile:p({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:p({listChanged:E().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:p({listChanged:E().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:p({}).optional().describe("Host accepts log messages."),sandbox:p({permissions:tn.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:en.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:In.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:In.optional().describe("Host supports receiving content messages (ui/message) from the view.")}),Ml=p({experimental:p({}).optional().describe("Experimental features (structure TBD)."),tools:p({listChanged:E().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:w(xe).optional().describe("Display modes the app supports.")});p({method:u("ui/notifications/initialized"),params:p({}).optional()});p({csp:en.optional().describe("Content Security Policy configuration for UI resources."),permissions:tn.optional().describe("Sandbox permissions requested by the UI resource."),domain:d().optional().describe(`Dedicated origin for view sandbox.
68
68
 
69
69
  Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
70
70
 
@@ -78,12 +78,12 @@ Boolean requesting whether a visible border and background is provided by the ho
78
78
 
79
79
  - \`true\`: request visible border + background
80
80
  - \`false\`: request no visible border + background
81
- - omitted: host decides border`)});p({method:u("ui/request-display-mode"),params:p({mode:Ce.describe("The display mode being requested.")})});var Pl=p({mode:Ce.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),El=S([u("model"),u("app")]).describe("Tool visibility scope - who can access the tool.");p({resourceUri:d().optional(),visibility:w(El).optional().describe(`Who can access this tool. Default: ["model", "app"]
81
+ - omitted: host decides border`)});p({method:u("ui/request-display-mode"),params:p({mode:xe.describe("The display mode being requested.")})});var jl=p({mode:xe.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),Dl=S([u("model"),u("app")]).describe("Tool visibility scope - who can access the tool.");p({resourceUri:d().optional(),visibility:w(Dl).optional().describe(`Who can access this tool. Default: ["model", "app"]
82
82
  - "model": Tool visible to and callable by the agent
83
- - "app": Tool callable by the app from this server only`)});p({mimeTypes:w(d()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});p({method:u("ui/download-file"),params:p({contents:w(S([zo,To])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});p({method:u("ui/message"),params:p({role:u("user").describe('Message role, currently only "user" is supported.'),content:w(je).describe("Message content blocks (text, image, etc.).")})});p({method:u("ui/notifications/sandbox-resource-ready"),params:p({html:d().describe("HTML content to load into the inner iframe."),sandbox:d().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Kt.optional().describe("CSP configuration from resource metadata."),permissions:Gt.optional().describe("Sandbox permissions from resource metadata.")})});var Cl=p({method:u("ui/notifications/tool-result"),params:ut.describe("Standard MCP tool execution result.")}),Po=p({toolInfo:p({id:xe.optional().describe("JSON-RPC id of the tools/call request."),tool:Wt.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:ml.optional().describe("Current color theme preference."),styles:Tl.optional().describe("Style configuration for theming the app."),displayMode:Ce.optional().describe("How the UI is currently displayed."),availableDisplayModes:w(Ce).optional().describe("Display modes the host supports."),containerDimensions:S([p({height:k().describe("Fixed container height in pixels.")}),p({maxHeight:S([k(),mt()]).optional().describe("Maximum container height in pixels.")})]).and(S([p({width:k().describe("Fixed container width in pixels.")}),p({maxWidth:S([k(),mt()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
84
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:d().optional().describe("User's language and region preference in BCP 47 format."),timeZone:d().optional().describe("User's timezone in IANA format."),userAgent:d().optional().describe("Host application identifier."),platform:S([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p({touch:E().optional().describe("Whether the device supports touch input."),hover:E().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p({top:k().describe("Top safe area inset in pixels."),right:k().describe("Right safe area inset in pixels."),bottom:k().describe("Bottom safe area inset in pixels."),left:k().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),Zl=p({method:u("ui/notifications/host-context-changed"),params:Po.describe("Partial context update containing only changed fields.")});p({method:u("ui/update-model-context"),params:p({content:w(je).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:$(d(),P().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});p({method:u("ui/initialize"),params:p({appInfo:at.describe("App identification (name and version)."),appCapabilities:Il.describe("Features and capabilities this app provides."),protocolVersion:d().describe("Protocol version this app supports.")})});var xl=p({protocolVersion:d().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:at.describe("Host application identification and version."),hostCapabilities:$l.describe("Features and capabilities provided by the host."),hostContext:Po.describe("Rich context about the host environment.")}).passthrough();class Ol extends dl{constructor(n,o={},r={autoResize:!0}){super(r);H(this,"_appInfo");H(this,"_capabilities");H(this,"options");H(this,"_hostCapabilities");H(this,"_hostInfo");H(this,"_hostContext");H(this,"sendOpenLink",this.openLink);this._appInfo=n,this._capabilities=o,this.options=r,this.setRequestHandler(ct,s=>(console.log("Received ping:",s.params),{})),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(n){this.setNotificationHandler(wl,o=>n(o.params))}set ontoolinputpartial(n){this.setNotificationHandler(kl,o=>n(o.params))}set ontoolresult(n){this.setNotificationHandler(Cl,o=>n(o.params))}set ontoolcancelled(n){this.setNotificationHandler(Sl,o=>n(o.params))}set onhostcontextchanged(n){this.setNotificationHandler(Zl,o=>{this._hostContext={...this._hostContext,...o.params},n(o.params)})}set onteardown(n){this.setRequestHandler(Rl,(o,r)=>n(o.params,r))}set oncalltool(n){this.setRequestHandler($o,(o,r)=>n(o.params,r))}set onlisttools(n){this.setRequestHandler(Ro,(o,r)=>n(o.params,r))}assertCapabilityForMethod(n){}assertRequestHandlerCapability(n){switch(n){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${n})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${n} registered`)}}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(n,o){if(typeof n=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${n}"). Did you mean: callServerTool({ name: "${n}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:n},ut,o)}async readServerResource(n,o){return await this.request({method:"resources/read",params:n},So,o)}async listServerResources(n,o){return await this.request({method:"resources/list",params:n},ko,o)}sendMessage(n,o){return this.request({method:"ui/message",params:n},yl,o)}sendLog(n){return this.notification({method:"notifications/message",params:n})}updateModelContext(n,o){return this.request({method:"ui/update-model-context",params:n},xt,o)}openLink(n,o){return this.request({method:"ui/open-link",params:n},bl,o)}downloadFile(n,o){return this.request({method:"ui/download-file",params:n},vl,o)}requestDisplayMode(n,o){return this.request({method:"ui/request-display-mode",params:n},Pl,o)}sendSizeChanged(n){return this.notification({method:"ui/notifications/size-changed",params:n})}setupSizeChangedNotifications(){let n=!1,o=0,r=0,s=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1;let a=document.documentElement,c=a.style.width,l=a.style.height;a.style.width="fit-content",a.style.height="max-content";let h=a.getBoundingClientRect();a.style.width=c,a.style.height=l;let m=window.innerWidth-a.clientWidth,g=Math.ceil(h.width+m),_=Math.ceil(h.height);(g!==o||_!==r)&&(o=g,r=_,this.sendSizeChanged({width:g,height:_}))}))};s();let i=new ResizeObserver(s);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(n=new fl(window.parent,window.parent),o){var r;if(this.transport)throw Error("App is already connected. Call close() before connecting again.");await super.connect(n);try{let s=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:pl}},xl,o);if(s===void 0)throw Error(`Server sent invalid initialize result: ${s}`);this._hostCapabilities=s.hostCapabilities,this._hostInfo=s.hostInfo,this._hostContext=s.hostContext,await this.notification({method:"ui/notifications/initialized"}),(r=this.options)!=null&&r.autoResize&&this.setupSizeChangedNotifications()}catch(s){throw this.close(),s}}}function Nl(e){const t=e.numberOfChannels,n=e.sampleRate,o=e.length,r=2,s=o*t*r,i=44,a=new ArrayBuffer(i+s),c=new DataView(a);Je(c,0,"RIFF"),c.setUint32(4,36+s,!0),Je(c,8,"WAVE"),Je(c,12,"fmt "),c.setUint32(16,16,!0),c.setUint16(20,1,!0),c.setUint16(22,t,!0),c.setUint32(24,n,!0),c.setUint32(28,n*t*r,!0),c.setUint16(32,t*r,!0),c.setUint16(34,16,!0),Je(c,36,"data"),c.setUint32(40,s,!0);const l=Array.from({length:t},(v,y)=>e.getChannelData(y));let h=44;for(let v=0;v<o;v++)for(let y=0;y<t;y++){const I=Math.max(-1,Math.min(1,l[y][v]));c.setInt16(h,I<0?I*32768:I*32767,!0),h+=2}const m=new Uint8Array(a);let g="";const _=8192;for(let v=0;v<m.length;v+=_)g+=String.fromCharCode(...m.subarray(v,v+_));return btoa(g)}function Je(e,t,n){for(let o=0;o<n.length;o++)e.setUint8(t+o,n.charCodeAt(o))}const Al="0.4.0",ql="https://unpkg.com/@strudel/repl@1.3.0",ae=new Ol({name:"Strudel Live Pattern",version:Al}),bt=document.getElementById("play-btn"),de=document.getElementById("record-btn"),ge=document.getElementById("download-btn"),Be=document.getElementById("send-btn"),Ml=document.getElementById("fullscreen-btn"),zn=document.getElementById("status"),vt=document.getElementById("strudel-container");let ie=null,Qt="",Yt=!1,Tn=!1,yt=!1,wt=null,Q=null,we=[],$e=!1,ce=null,Ve=null,We=null;"audioSession"in navigator&&(navigator.audioSession.type="playback");function De(){return(ie==null?void 0:ie.editor)??null}function jl(){var t;const e=De();try{if(typeof(e==null?void 0:e.getCode)=="function")return e.getCode();if(typeof(e==null?void 0:e.code)=="string")return e.code;const n=(e==null?void 0:e.editor)??(e==null?void 0:e.view),o=(t=n==null?void 0:n.state)==null?void 0:t.doc;if(o&&typeof o.toString=="function")return o.toString()}catch{}return Qt}let et=!1;async function Dl(){if(!Tn)return new Promise((e,t)=>{const n=document.createElement("script");n.src=ql,n.onload=async()=>{Tn=!0;try{const o=window.strudel;o!=null&&o.prebake&&await o.prebake(),et=!1}catch{et=!0}e()},n.onerror=()=>t(new Error("Failed to load Strudel REPL")),document.head.appendChild(n)})}function j(e,t="normal"){zn.textContent=e,zn.className=`status ${t}`}function tt(e){Yt=e,bt.classList.toggle("playing",e),bt.textContent=e?"Playing":"Play",$e||j(e?"Playing...":"Ready",e?"playing":"normal")}function Ul(e,t){const n=t/60/4,o=Math.round(n*1e4)/1e4;return/setcps\s*\(/.test(e)?e.replace(/setcps\s*\([^)]*\)/,`setcps(${o})`):`setcps(${o})
85
- ${e}`}function Ll(e=8e3){return new Promise((t,n)=>{const o=Date.now(),r=()=>{const s=De();s!=null&&s.setCode?t(s):Date.now()-o>e?n(new Error("Strudel editor did not initialize")):setTimeout(r,150)};r()})}function pt(){if(document.querySelectorAll("body > canvas").forEach(e=>{const t=e.style;t.position==="fixed"&&(t.display="none")}),ie!=null&&ie.nextElementSibling){const e=ie.nextElementSibling;e.querySelector(".cm-editor")&&(e.style.minHeight="200px",e.style.flex="1")}}function Fl(){var e,t,n;try{const o=(e=window.getAudioContext)==null?void 0:e.call(window);if(!o)return null;const r=o.createMediaStreamDestination(),s=(t=window.getSuperdoughAudioController)==null?void 0:t.call(window),i=(n=s==null?void 0:s.output)==null?void 0:n.destinationGain;return i!=null&&i.connect?(i.connect(r),Ve=i,We=r,r.stream):null}catch{return null}}function Hl(){if(ce||(ce=Fl()),!ce){j("Recording not available","error");return}we=[];try{Q=new MediaRecorder(ce,{mimeType:MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm"})}catch{j("Recording not supported","error");return}Q.ondataavailable=e=>{e.data.size>0&&we.push(e.data)},Q.onstop=()=>{ge.disabled=we.length===0},Q.start(100),$e=!0,de.classList.add("recording"),de.textContent="Stop Rec",j("Recording...","playing")}function Xt(){(Q==null?void 0:Q.state)==="recording"&&Q.stop(),$e=!1,de.classList.remove("recording"),de.textContent="Record",Yt?j("Playing...","playing"):j("Ready","normal")}async function Jl(){var e;if(we.length!==0){if(!yt){j("Download not supported on this host","error");return}ge.disabled=!0,ge.textContent="...";try{const n=await new Blob(we,{type:"audio/webm"}).arrayBuffer(),o=(e=window.getAudioContext)==null?void 0:e.call(window);if(!o)throw new Error("No audio context");const r=await o.decodeAudioData(n),s=Nl(r);await ae.downloadFile({contents:[{type:"resource",resource:{uri:"file:///strudel-recording.wav",mimeType:"audio/wav",blob:s}}]})}catch(t){j(`Download failed: ${t.message}`,"error")}finally{ge.textContent="↓",ge.disabled=we.length===0}}}function Bl(){vt.replaceChildren(),ie=null;const e=document.createElement("div");e.className="cdn-error";const t=document.createElement("p");t.textContent="Couldn't load the Strudel player (network or CDN issue).",e.appendChild(t);const n=document.createElement("button");n.className="retry-btn",n.textContent="Retry loading",n.setAttribute("aria-label","Retry loading Strudel player"),n.addEventListener("click",()=>{wt&&Eo(wt)}),e.appendChild(n),vt.appendChild(e)}async function Eo(e){const t=e.code;if(!t)return;wt=e;const n=e.bpm,o=e.autoplay;try{j("Loading Strudel...");try{await Dl()}catch{j("Failed to load Strudel — click Retry","error"),Bl();return}let r=t;if(n&&(r=Ul(r,n)),Qt=r,!ie){const a=document.createElement("strudel-editor");vt.replaceChildren(a),ie=a}j("Initializing...");const s=await Ll();pt(),setTimeout(pt,500),setTimeout(pt,1500),s.setCode(r),de.disabled=!1;const i=et?" (soundfonts unavailable — audio may be silent)":"";if(o!==!1)try{s.evaluate(r,!0),tt(!0),et&&j(`Playing...${i}`,"playing")}catch{j(`Click Play to start${i}`,"normal")}else j(`Ready — click Play or Ctrl+Enter${i}`,"normal")}catch(r){j(`Error: ${r.message}`,"error")}}bt.addEventListener("click",()=>{const e=De();if(e)try{Yt?($e&&Xt(),e.stop(),tt(!1)):(e.evaluate(Qt,!0),tt(!0))}catch(t){j(`Playback error: ${t.message}`,"error")}});de.addEventListener("click",()=>{$e?Xt():Hl()});ge.addEventListener("click",()=>{Jl()});Be.addEventListener("click",async()=>{const e=jl().trim();if(e){Be.disabled=!0;try{await ae.sendMessage({role:"user",content:[{type:"text",text:"Here's my edited Strudel pattern:\n```\n"+e+"\n```"}]})}catch(t){j(`Send failed: ${t.message}`,"error")}finally{Be.disabled=!1}}});Ml.addEventListener("click",()=>{ae.requestDisplayMode({mode:"fullscreen"})});ae.ontoolinput=e=>{Eo(e.arguments??{})};ae.ontoolinputpartial=e=>{var o;const t=(o=e.arguments)==null?void 0:o.code;if(!t)return;j("Composing pattern...");const n=De();n!=null&&n.setCode&&n.setCode(t)};ae.ontoolcancelled=e=>{const t=e!=null&&e.reason?` (${e.reason})`:"";j(`Generation cancelled${t}.`,"normal")};ae.onteardown=()=>{var e;try{$e&&Xt(),(Q==null?void 0:Q.state)==="recording"&&Q.stop(),Q=null;const t=De();if((e=t==null?void 0:t.stop)==null||e.call(t),tt(!1),Ve&&We)try{Ve.disconnect(We)}catch{}Ve=null,We=null,ce==null||ce.getTracks().forEach(n=>n.stop()),ce=null}catch{}return{}};ae.onerror=console.error;ae.connect().then(()=>{const e=ae.getHostCapabilities();yt=!!(e!=null&&e.downloadFile),yt||(ge.hidden=!0,de.hidden=!0,de.title="Recording export not supported on this host"),e!=null&&e.message&&(Be.hidden=!1)});</script>
86
- <style rel="stylesheet" crossorigin>:root{color-scheme:light dark;--bg: #ffffff;--surface: #f8f9fa;--border: #e0e0e0;--text: #1a1a1a;--text-secondary: #666;--accent: #7c3aed;--accent-hover: #6d28d9;--success: #10b981;--error: #ef4444}@media(prefers-color-scheme:dark){:root{--bg: #1a1a1a;--surface: #252525;--border: #333;--text: #e0e0e0;--text-secondary: #999;--accent: #a78bfa;--accent-hover: #8b5cf6}}*{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;font-family:system-ui,-apple-system,sans-serif;background:var(--bg);color:var(--text)}.main{display:flex;flex-direction:column;height:100%;min-height:200px}.header{padding:8px 12px;border-bottom:1px solid var(--border);background:var(--surface);flex-shrink:0}.toolbar{display:flex;align-items:center;gap:8px}.control-btn{padding:6px 16px;border:1px solid var(--border);border-radius:6px;background:var(--surface);color:var(--text);cursor:pointer;font-size:13px;font-weight:500;transition:all .15s}.control-btn:hover{border-color:var(--accent);color:var(--accent)}.control-btn.playing{background:var(--accent);color:#fff;border-color:var(--accent)}.control-btn.recording{background:var(--error);color:#fff;border-color:var(--error)}.control-btn:disabled{opacity:.4;cursor:default}.control-btn:disabled:hover{border-color:var(--border);color:var(--text)}.status{font-size:12px;color:var(--text-secondary);margin-left:auto}.status.playing{color:var(--success)}.status.error{color:var(--error)}.repl-section{flex:1;overflow:auto;min-height:350px}.strudel-container{width:100%;min-height:350px}.cdn-error{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;min-height:350px;padding:24px;text-align:center;color:var(--text-secondary)}.cdn-error .retry-btn{padding:8px 20px;border:1px solid var(--accent);border-radius:6px;background:var(--surface);color:var(--accent);cursor:pointer;font-size:14px;font-weight:500}.cdn-error .retry-btn:hover{background:var(--accent);color:#fff}body>canvas[style*=position]{display:none!important}strudel-editor{display:block;width:100%}.strudel-container>div:has(.cm-editor){min-height:350px!important;width:100%!important}.cm-editor{min-height:350px!important}.cm-scroller{min-height:300px!important;overflow:auto!important}</style>
83
+ - "app": Tool callable by the app from this server only`)});p({mimeTypes:w(d()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});p({method:u("ui/download-file"),params:p({contents:w(S([Po,Eo])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});p({method:u("ui/message"),params:p({role:u("user").describe('Message role, currently only "user" is supported.'),content:w(Ue).describe("Message content blocks (text, image, etc.).")})});p({method:u("ui/notifications/sandbox-resource-ready"),params:p({html:d().describe("HTML content to load into the inner iframe."),sandbox:d().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:en.optional().describe("CSP configuration from resource metadata."),permissions:tn.optional().describe("Sandbox permissions from resource metadata.")})});var Ul=p({method:u("ui/notifications/tool-result"),params:ht.describe("Standard MCP tool execution result.")}),Oo=p({toolInfo:p({id:Ne.optional().describe("JSON-RPC id of the tools/call request."),tool:Xt.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Tl.optional().describe("Current color theme preference."),styles:Nl.optional().describe("Style configuration for theming the app."),displayMode:xe.optional().describe("How the UI is currently displayed."),availableDisplayModes:w(xe).optional().describe("Display modes the host supports."),containerDimensions:S([p({height:k().describe("Fixed container height in pixels.")}),p({maxHeight:S([k(),vt()]).optional().describe("Maximum container height in pixels.")})]).and(S([p({width:k().describe("Fixed container width in pixels.")}),p({maxWidth:S([k(),vt()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
84
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:d().optional().describe("User's language and region preference in BCP 47 format."),timeZone:d().optional().describe("User's timezone in IANA format."),userAgent:d().optional().describe("Host application identifier."),platform:S([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p({touch:E().optional().describe("Whether the device supports touch input."),hover:E().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p({top:k().describe("Top safe area inset in pixels."),right:k().describe("Right safe area inset in pixels."),bottom:k().describe("Bottom safe area inset in pixels."),left:k().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),Ll=p({method:u("ui/notifications/host-context-changed"),params:Oo.describe("Partial context update containing only changed fields.")});p({method:u("ui/update-model-context"),params:p({content:w(Ue).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:$(d(),P().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});p({method:u("ui/initialize"),params:p({appInfo:dt.describe("App identification (name and version)."),appCapabilities:Ml.describe("Features and capabilities this app provides."),protocolVersion:d().describe("Protocol version this app supports.")})});var Fl=p({protocolVersion:d().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:dt.describe("Host application identification and version."),hostCapabilities:ql.describe("Features and capabilities provided by the host."),hostContext:Oo.describe("Rich context about the host environment.")}).passthrough();class Hl extends wl{constructor(n,o={},r={autoResize:!0}){super(r);H(this,"_appInfo");H(this,"_capabilities");H(this,"options");H(this,"_hostCapabilities");H(this,"_hostInfo");H(this,"_hostContext");H(this,"sendOpenLink",this.openLink);this._appInfo=n,this._capabilities=o,this.options=r,this.setRequestHandler(pt,s=>(console.log("Received ping:",s.params),{})),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(n){this.setNotificationHandler(Cl,o=>n(o.params))}set ontoolinputpartial(n){this.setNotificationHandler(Zl,o=>n(o.params))}set ontoolresult(n){this.setNotificationHandler(Ul,o=>n(o.params))}set ontoolcancelled(n){this.setNotificationHandler(xl,o=>n(o.params))}set onhostcontextchanged(n){this.setNotificationHandler(Ll,o=>{this._hostContext={...this._hostContext,...o.params},n(o.params)})}set onteardown(n){this.setRequestHandler(Al,(o,r)=>n(o.params,r))}set oncalltool(n){this.setRequestHandler(Zo,(o,r)=>n(o.params,r))}set onlisttools(n){this.setRequestHandler(Co,(o,r)=>n(o.params,r))}assertCapabilityForMethod(n){}assertRequestHandlerCapability(n){switch(n){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${n})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${n} registered`)}}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(n,o){if(typeof n=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${n}"). Did you mean: callServerTool({ name: "${n}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:n},ht,o)}async readServerResource(n,o){return await this.request({method:"resources/read",params:n},Io,o)}async listServerResources(n,o){return await this.request({method:"resources/list",params:n},$o,o)}sendMessage(n,o){return this.request({method:"ui/message",params:n},El,o)}sendLog(n){return this.notification({method:"notifications/message",params:n})}updateModelContext(n,o){return this.request({method:"ui/update-model-context",params:n},Mt,o)}openLink(n,o){return this.request({method:"ui/open-link",params:n},Il,o)}downloadFile(n,o){return this.request({method:"ui/download-file",params:n},Pl,o)}requestDisplayMode(n,o){return this.request({method:"ui/request-display-mode",params:n},jl,o)}sendSizeChanged(n){return this.notification({method:"ui/notifications/size-changed",params:n})}setupSizeChangedNotifications(){let n=!1,o=0,r=0,s=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1;let a=document.documentElement,c=a.style.width,l=a.style.height;a.style.width="fit-content",a.style.height="max-content";let h=a.getBoundingClientRect();a.style.width=c,a.style.height=l;let m=window.innerWidth-a.clientWidth,g=Math.ceil(h.width+m),_=Math.ceil(h.height);(g!==o||_!==r)&&(o=g,r=_,this.sendSizeChanged({width:g,height:_}))}))};s();let i=new ResizeObserver(s);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(n=new zl(window.parent,window.parent),o){var r;if(this.transport)throw Error("App is already connected. Call close() before connecting again.");await super.connect(n);try{let s=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:kl}},Fl,o);if(s===void 0)throw Error(`Server sent invalid initialize result: ${s}`);this._hostCapabilities=s.hostCapabilities,this._hostInfo=s.hostInfo,this._hostContext=s.hostContext,await this.notification({method:"ui/notifications/initialized"}),(r=this.options)!=null&&r.autoResize&&this.setupSizeChangedNotifications()}catch(s){throw this.close(),s}}}function Jl(e){const t=e.numberOfChannels,n=e.sampleRate,o=e.length,r=2,s=o*t*r,i=44,a=new ArrayBuffer(i+s),c=new DataView(a);Ve(c,0,"RIFF"),c.setUint32(4,36+s,!0),Ve(c,8,"WAVE"),Ve(c,12,"fmt "),c.setUint32(16,16,!0),c.setUint16(20,1,!0),c.setUint16(22,t,!0),c.setUint32(24,n,!0),c.setUint32(28,n*t*r,!0),c.setUint16(32,t*r,!0),c.setUint16(34,16,!0),Ve(c,36,"data"),c.setUint32(40,s,!0);const l=Array.from({length:t},(v,y)=>e.getChannelData(y));let h=44;for(let v=0;v<o;v++)for(let y=0;y<t;y++){const I=Math.max(-1,Math.min(1,l[y][v]));c.setInt16(h,I<0?I*32768:I*32767,!0),h+=2}const m=new Uint8Array(a);let g="";const _=8192;for(let v=0;v<m.length;v+=_)g+=String.fromCharCode(...m.subarray(v,v+_));return btoa(g)}function Ve(e,t,n){for(let o=0;o<n.length;o++)e.setUint8(t+o,n.charCodeAt(o))}const Bl="0.4.2",Vl="https://unpkg.com/@strudel/repl@1.3.0",ae=new Hl({name:"Strudel Live Pattern",version:Bl}),kt=document.getElementById("play-btn"),pe=document.getElementById("record-btn"),_e=document.getElementById("download-btn"),Ke=document.getElementById("send-btn"),Wl=document.getElementById("fullscreen-btn"),St=document.getElementById("viz-btn"),ot=document.querySelector(".repl-section"),We=document.getElementById("test-canvas"),Pn=document.getElementById("status"),zt=document.getElementById("strudel-container");let ie=null,nn="",on=!1,En=!1,ce=!1,No=!1,we=null;const Ao=/\.(pianoroll|punchcard|wordfall|spiral|pitchwheel|tscope|scope|fscope|spectrum)\s*\(/;let Tt=!1,Rt=null,Q=null,Se=[],Pe=!1,ue=null,Ge=null,Qe=null;"audioSession"in navigator&&(navigator.audioSession.type="playback");function Le(){return(ie==null?void 0:ie.editor)??null}function qo(){var t;const e=Le();try{if(typeof(e==null?void 0:e.getCode)=="function")return e.getCode();if(typeof(e==null?void 0:e.code)=="string")return e.code;const n=(e==null?void 0:e.editor)??(e==null?void 0:e.view),o=(t=n==null?void 0:n.state)==null?void 0:t.doc;if(o&&typeof o.toString=="function")return o.toString()}catch{}return nn}let rt=!1;async function Kl(){if(!En)return new Promise((e,t)=>{const n=document.createElement("script");n.src=Vl,n.onload=async()=>{En=!0;try{const o=window.strudel;o!=null&&o.prebake&&await o.prebake(),rt=!1}catch{rt=!0}e()},n.onerror=()=>t(new Error("Failed to load Strudel REPL")),document.head.appendChild(n)})}function M(e,t="normal"){Pn.textContent=e,Pn.className=`status ${t}`}function st(e){on=e,kt.classList.toggle("playing",e),kt.textContent=e?"Playing":"Play",Pe||M(e?"Playing...":"Ready",e?"playing":"normal")}function Gl(e,t){const n=t/60/4,o=Math.round(n*1e4)/1e4;return/setcps\s*\(/.test(e)?e.replace(/setcps\s*\([^)]*\)/,`setcps(${o})`):`setcps(${o})
85
+ ${e}`}function Ql(e=8e3){return new Promise((t,n)=>{const o=Date.now(),r=()=>{const s=Le();s!=null&&s.setCode?t(s):Date.now()-o>e?n(new Error("Strudel editor did not initialize")):setTimeout(r,150)};r()})}function gt(){if(document.querySelectorAll("body > canvas").forEach(e=>{if(e.id==="test-canvas")return;const t=e.style;t.position==="fixed"&&(t.display="none")}),ie!=null&&ie.nextElementSibling){const e=ie.nextElementSibling;e.querySelector(".cm-editor")&&(e.style.minHeight="200px",e.style.flex="1")}}function Mo(){if(!ce)return;const e=ot.clientWidth,t=ot.clientHeight;if(e===0||t===0)return;const n=window.devicePixelRatio||1,o=Math.round(e*n),r=Math.round(t*n);We.width!==o&&(We.width=o),We.height!==r&&(We.height=r)}function jo(){ot.classList.toggle("viz-on",ce),St.classList.toggle("active",ce),St.setAttribute("aria-pressed",String(ce)),ce&&requestAnimationFrame(Mo)}function Yl(){var e,t,n;try{const o=(e=window.getAudioContext)==null?void 0:e.call(window);if(!o)return null;const r=o.createMediaStreamDestination(),s=(t=window.getSuperdoughAudioController)==null?void 0:t.call(window),i=(n=s==null?void 0:s.output)==null?void 0:n.destinationGain;return i!=null&&i.connect?(i.connect(r),Ge=i,Qe=r,r.stream):null}catch{return null}}function Xl(){if(ue||(ue=Yl()),!ue){M("Recording not available","error");return}Se=[];try{Q=new MediaRecorder(ue,{mimeType:MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm"})}catch{M("Recording not supported","error");return}Q.ondataavailable=e=>{e.data.size>0&&Se.push(e.data)},Q.onstop=()=>{_e.disabled=Se.length===0},Q.start(100),Pe=!0,pe.classList.add("recording"),pe.textContent="Stop Rec",M("Recording...","playing")}function rn(){(Q==null?void 0:Q.state)==="recording"&&Q.stop(),Pe=!1,pe.classList.remove("recording"),pe.textContent="Record",on?M("Playing...","playing"):M("Ready","normal")}async function ed(){var e;if(Se.length!==0){if(!Tt){M("Download not supported on this host","error");return}_e.disabled=!0,_e.textContent="...";try{const n=await new Blob(Se,{type:"audio/webm"}).arrayBuffer(),o=(e=window.getAudioContext)==null?void 0:e.call(window);if(!o)throw new Error("No audio context");const r=await o.decodeAudioData(n),s=Jl(r);await ae.downloadFile({contents:[{type:"resource",resource:{uri:"file:///strudel-recording.wav",mimeType:"audio/wav",blob:s}}]})}catch(t){M(`Download failed: ${t.message}`,"error")}finally{_e.textContent="↓",_e.disabled=Se.length===0}}}function td(){zt.replaceChildren(),ie=null;const e=document.createElement("div");e.className="cdn-error";const t=document.createElement("p");t.textContent="Couldn't load the Strudel player (network or CDN issue).",e.appendChild(t);const n=document.createElement("button");n.className="retry-btn",n.textContent="Retry loading",n.setAttribute("aria-label","Retry loading Strudel player"),n.addEventListener("click",()=>{Rt&&Do(Rt)}),e.appendChild(n),zt.appendChild(e)}async function Do(e){const t=e.code;if(!t)return;Rt=e;const n=e.bpm,o=e.autoplay;try{M("Loading Strudel...");try{await Kl()}catch{M("Failed to load Strudel — click Retry","error"),td();return}let r=t;if(n&&(r=Gl(r,n)),nn=r,!No){const a=r.replace(/(^|[^:])\/\/.*$/gm,"$1");ce=Ao.test(a),jo()}if(!ie){const a=document.createElement("strudel-editor");zt.replaceChildren(a),ie=a}M("Initializing...");const s=await Ql();gt(),setTimeout(gt,500),setTimeout(gt,1500),s.setCode(r),pe.disabled=!1;const i=rt?" (soundfonts unavailable — audio may be silent)":"";if(o!==!1)try{s.evaluate(r,!0),st(!0),rt&&M(`Playing...${i}`,"playing")}catch{M(`Click Play to start${i}`,"normal")}else M(`Ready — click Play or Ctrl+Enter${i}`,"normal")}catch(r){M(`Error: ${r.message}`,"error")}}kt.addEventListener("click",()=>{const e=Le();if(e)try{on?(Pe&&rn(),e.stop(),st(!1)):(e.evaluate(nn,!0),st(!0))}catch(t){M(`Playback error: ${t.message}`,"error")}});pe.addEventListener("click",()=>{Pe?rn():Xl()});_e.addEventListener("click",()=>{ed()});Ke.addEventListener("click",async()=>{const e=qo().trim();if(e){Ke.disabled=!0;try{await ae.sendMessage({role:"user",content:[{type:"text",text:"Here's my edited Strudel pattern:\n```\n"+e+"\n```"}]})}catch(t){M(`Send failed: ${t.message}`,"error")}finally{Ke.disabled=!1}}});Wl.addEventListener("click",()=>{ae.requestDisplayMode({mode:"fullscreen"})});St.addEventListener("click",()=>{if(!ce&&!Ao.test(qo())){M("Add .scope(), .pianoroll() or .spectrum() to the pattern to see visuals","normal");return}No=!0,ce=!ce,jo()});we=new ResizeObserver(()=>Mo());we.observe(ot);ae.ontoolinput=e=>{Do(e.arguments??{})};ae.ontoolinputpartial=e=>{var o;const t=(o=e.arguments)==null?void 0:o.code;if(!t)return;M("Composing pattern...");const n=Le();n!=null&&n.setCode&&n.setCode(t)};ae.ontoolcancelled=e=>{const t=e!=null&&e.reason?` (${e.reason})`:"";M(`Generation cancelled${t}.`,"normal")};ae.onteardown=()=>{var e;try{Pe&&rn(),(Q==null?void 0:Q.state)==="recording"&&Q.stop(),Q=null;const t=Le();if((e=t==null?void 0:t.stop)==null||e.call(t),st(!1),Ge&&Qe)try{Ge.disconnect(Qe)}catch{}Ge=null,Qe=null,ue==null||ue.getTracks().forEach(n=>n.stop()),ue=null,we==null||we.disconnect(),we=null}catch{}return{}};ae.onerror=console.error;ae.connect().then(()=>{const e=ae.getHostCapabilities();Tt=!!(e!=null&&e.downloadFile),Tt||(_e.hidden=!0,pe.hidden=!0,pe.title="Recording export not supported on this host"),e!=null&&e.message&&(Ke.hidden=!1)});</script>
86
+ <style rel="stylesheet" crossorigin>:root{color-scheme:light dark;--bg: #ffffff;--surface: #f8f9fa;--border: #e0e0e0;--text: #1a1a1a;--text-secondary: #666;--accent: #7c3aed;--accent-hover: #6d28d9;--success: #10b981;--error: #ef4444}@media(prefers-color-scheme:dark){:root{--bg: #1a1a1a;--surface: #252525;--border: #333;--text: #e0e0e0;--text-secondary: #999;--accent: #a78bfa;--accent-hover: #8b5cf6}}*{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;font-family:system-ui,-apple-system,sans-serif;background:var(--bg);color:var(--text)}.main{display:flex;flex-direction:column;height:100%;min-height:200px}.header{padding:8px 12px;border-bottom:1px solid var(--border);background:var(--surface);flex-shrink:0}.toolbar{display:flex;align-items:center;gap:8px}.control-btn{padding:6px 16px;border:1px solid var(--border);border-radius:6px;background:var(--surface);color:var(--text);cursor:pointer;font-size:13px;font-weight:500;transition:all .15s}.control-btn:hover{border-color:var(--accent);color:var(--accent)}.control-btn.playing{background:var(--accent);color:#fff;border-color:var(--accent)}.control-btn.recording{background:var(--error);color:#fff;border-color:var(--error)}.control-btn.active{background:var(--accent);color:#fff;border-color:var(--accent)}.control-btn:disabled{opacity:.4;cursor:default}.control-btn:disabled:hover{border-color:var(--border);color:var(--text)}.status{font-size:12px;color:var(--text-secondary);margin-left:auto}.status.playing{color:var(--success)}.status.error{color:var(--error)}.repl-section{flex:1;position:relative;overflow:hidden;min-height:350px}.viz-canvas{display:none;position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;z-index:0;pointer-events:none;background:#14111d}.strudel-container{position:relative;z-index:1;width:100%;height:100%;overflow:auto;min-height:350px}.repl-section.viz-on .viz-canvas{display:block}.repl-section.viz-on .strudel-container>div{height:100%!important;background-color:transparent!important}.repl-section.viz-on .cm-editor{height:100%!important;background-color:transparent!important}.repl-section.viz-on .cm-scroller{height:100%!important;background-color:#14111d80!important}.repl-section.viz-on .cm-gutters{background-color:#14111d4d!important}.repl-section.viz-on .cm-content{text-shadow:0 1px 2px rgba(0,0,0,.95)}.cdn-error{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;min-height:350px;padding:24px;text-align:center;color:var(--text-secondary)}.cdn-error .retry-btn{padding:8px 20px;border:1px solid var(--accent);border-radius:6px;background:var(--surface);color:var(--accent);cursor:pointer;font-size:14px;font-weight:500}.cdn-error .retry-btn:hover{background:var(--accent);color:#fff}body>canvas[style*=position]:not(#test-canvas){display:none!important}strudel-editor{display:block;width:100%}.strudel-container>div:has(.cm-editor){min-height:350px!important;width:100%!important}.cm-editor{min-height:350px!important}.cm-scroller{min-height:300px!important;overflow:auto!important}</style>
87
87
  </head>
88
88
  <body>
89
89
  <main class="main">
@@ -93,12 +93,22 @@ ${e}`}function Ll(e=8e3){return new Promise((t,n)=>{const o=Date.now(),r=()=>{co
93
93
  <button id="record-btn" class="control-btn" title="Record audio" aria-label="Record audio" disabled>Record</button>
94
94
  <button id="download-btn" class="control-btn" title="Download recording" aria-label="Download recording" disabled>↓</button>
95
95
  <button id="send-btn" class="control-btn" title="Send current pattern to chat" aria-label="Send current pattern to chat" hidden>Send to chat</button>
96
+ <button id="viz-btn" class="control-btn" title="Toggle visuals" aria-label="Toggle visuals" aria-pressed="false">Visuals</button>
96
97
  <button id="fullscreen-btn" class="control-btn" title="Toggle fullscreen" aria-label="Toggle fullscreen">⛶</button>
97
98
  <span id="status" class="status" role="status" aria-live="polite">Ready</span>
98
99
  </div>
99
100
  </header>
100
101
 
101
102
  <section class="repl-section">
103
+ <!--
104
+ Viz canvas as a BACKDROP behind the code (native strudel.cc look). It's
105
+ pre-created in STATIC HTML so Strudel's getDrawContext() finds it by id and
106
+ reuses it, instead of prepending a position:fixed canvas to <body>. Hidden
107
+ until a pattern includes a viz method (.pianoroll() etc.) or the user
108
+ toggles "Visuals"; the code editor sits on top with a translucent scrim.
109
+ JS owns the DPR-correct backing size.
110
+ -->
111
+ <canvas id="test-canvas" class="viz-canvas"></canvas>
102
112
  <div id="strudel-container" class="strudel-container">
103
113
  <!-- strudel-editor web component will be created here -->
104
114
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-music-studio",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "description": "Two-mode MCP music studio: scored composition (ABC notation) and live performance (Strudel). Interactive ext-apps UI with sheet music rendering, 30+ instruments, style presets, and live coding REPL.",
6
6
  "keywords": [