diff --git "a/assets/ArtifactWorkspace-B0cn_MPJ.js" "b/assets/ArtifactWorkspace-B0cn_MPJ.js" new file mode 100644--- /dev/null +++ "b/assets/ArtifactWorkspace-B0cn_MPJ.js" @@ -0,0 +1,128 @@ +var oh=Object.defineProperty;var ah=(e,t,r)=>t in e?oh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var le=(e,t,r)=>ah(e,typeof t!="symbol"?t+"":t,r);import{d as gr,r as kt,j as b,z as G,N as Bl,E as Dt,X as ih,C as ch}from"./index-DZOh80ST.js";import{u as Jl,P as Ql,b as Yl,M as lh,R as uh,W as dh,d as ta,A as fh,n as hh,L as ph,N as Xl,O as mh}from"./chatLaunch-P864fVYq.js";import"./katex.min-BSBacQyE.js";import{H as Ps,a as Rs,b as Ts}from"./hover-card-3XmFti8s.js";import{u as Bn}from"./useQuery-CVOBkrbl.js";import{f as gh,p as _h}from"./github-D-bCneJx.js";import{G as ra}from"./github-BOMgyYmx.js";import{r as yh,a as vh,P as eu}from"./PaperPreviewLink-DQek16Uq.js";import{M as $h,r as wh,d as bh}from"./index-kh2MpWDP.js";import{c as bc}from"./chat-BDl8ZdDW.js";import{F as Sh}from"./file-text-DJ9lFUt6.js";import{E as Eh}from"./external-link-Dijt2GWb.js";/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kh=gr("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sc=gr("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const tu=gr("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ph=gr("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rh=gr("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Th=gr("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ch=gr("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);function Cs({selection:e,editable:t=!1,onRemove:r}){const n=kt.useId(),s=kt.useRef(null),[o,a]=kt.useState(!1),[i,c]=kt.useState(!1),l=`Selection · Page ${e.page}`;return kt.useEffect(()=>{const d=s.current;!d||o||c(d.scrollHeight>d.clientHeight+1)},[o,e.text]),b.jsxs("div",{className:`chat-paper-selection${t?" is-editable":""}`,children:[b.jsxs("div",{className:"chat-paper-selection-header",children:[b.jsx("span",{className:"chat-paper-selection-label",children:l}),b.jsxs("div",{className:"chat-paper-selection-actions",children:[(i||o)&&b.jsx("button",{type:"button",className:"chat-paper-selection-toggle","aria-expanded":o,"aria-controls":n,onClick:()=>a(d=>!d),children:o?"Collapse":"Expand"}),t&&r&&b.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:r,children:"Remove"})]})]}),b.jsx("blockquote",{id:n,ref:s,className:`chat-paper-selection-quote${o?" is-expanded":""}`,children:e.text})]})}const jh=hh(),HT=({onSend:e,busy:t,placeholder:r,autoFocus:n,draft:s,onDraftChange:o,onStop:a,models:i=[],selectedModel:c,onModelChange:l,disabled:d=!1,describedBy:h,paperMentionsEnabled:m=!1,paperSelectionEnabled:g=!0,webSearchAvailable:y=!1,webSearchEnabled:_=!1,onWebSearchChange:v,reasoningEffort:f="low",onReasoningEffortChange:$})=>{const[E,T]=kt.useState(jh),k=s??E,x=kt.useRef(null),[M,L]=kt.useState(0),F=H=>{s||T(H),o==null||o(H)},V=Jl({draft:k,onChange:F,enabled:m,textareaRef:x});kt.useEffect(()=>{const H=x.current;H&&(H.style.height="auto",H.style.height=`${Math.min(H.scrollHeight,200)}px`)},[k.text]),kt.useEffect(()=>{var H;n&&((H=x.current)==null||H.focus())},[n]);const Z=()=>{const H=k.text.length-k.text.trimStart().length,ie=k.text.trim(),ke=!!k.paperSelection&&!g;if(!ie||t||d||ke)return;const ye=H+ie.length,ct={text:ie,paperMentions:k.paperMentions.filter(Oe=>Oe.start>=H&&Oe.end<=ye).map(Oe=>({...Oe,start:Oe.start-H,end:Oe.end-H})),...k.paperSelection?{paperSelection:k.paperSelection}:{}};e(ct)},B=!!k.paperSelection&&!g,re=!!k.text.trim()&&!B;return b.jsxs("div",{className:"chat-composer",children:[k.paperSelection&&b.jsx(Cs,{selection:k.paperSelection,editable:!0,onRemove:()=>{var H;F({text:k.text,paperMentions:k.paperMentions}),(H=x.current)==null||H.focus()}}),B&&b.jsx("div",{className:"chat-paper-selection-disabled",role:"status",children:"Paper selection is currently disabled. Remove the selected passage or wait for the feature to recover."}),b.jsxs("div",{className:"chat-composer-textarea-wrap",children:[b.jsx(Ql,{text:k.text,mentions:k.paperMentions,scrollTop:M}),b.jsx("textarea",{ref:x,rows:1,value:k.text,placeholder:r||(k.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:H=>V.updateText(H.target.value,H.target.selectionStart),onSelect:H=>V.refresh(H.currentTarget.selectionStart),onClick:H=>V.refresh(H.currentTarget.selectionStart),onScroll:H=>L(H.currentTarget.scrollTop),onBlur:H=>{var ie,ke;(ke=(ie=H.relatedTarget)==null?void 0:ie.closest)!=null&&ke.call(ie,".chat-paper-picker")||window.setTimeout(V.close,0)},onKeyDown:H=>{V.keyDown(H)||H.key==="Enter"&&!H.shiftKey&&!H.nativeEvent.isComposing&&(H.preventDefault(),Z())},role:"combobox","aria-expanded":V.open,"aria-controls":V.open?V.pickerId:void 0,"aria-activedescendant":V.open&&V.results.length?`${V.optionIdPrefix}-${V.activeIndex}`:void 0,"aria-autocomplete":"list","aria-describedby":[h,V.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),b.jsx(Yl,{open:V.open,query:V.query,results:V.results,activeIndex:V.activeIndex,loading:V.loading,error:V.error,onSelect:V.select,id:V.pickerId,optionIdPrefix:V.optionIdPrefix})]}),V.message&&b.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:V.message}),b.jsxs("div",{className:"chat-composer-row",children:[b.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&b.jsx(lh,{models:i,selectedModel:c,onModelChange:l,disabled:t}),$&&b.jsx(uh,{value:f,onChange:$,disabled:t}),y&&v&&b.jsx(dh,{enabled:_,onChange:v,disabled:t}),b.jsx("span",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]}),b.jsx("button",{type:"button",className:`chat-send${t||re?" chat-send-on":""}`,onClick:t?a:Z,disabled:d||(t?!a:!re),"aria-label":t?"Stop generating":"Send message",children:t?a?b.jsx("span",{"aria-hidden":"true",children:"■"}):b.jsx(ta,{light:!0}):b.jsx(fh,{})})]})]})},Js=new Map,ru=e=>{if(!e)return Promise.resolve();const t=Js.get(e);if(t)return t;const r=new Promise(n=>{const s=new Image;s.onload=()=>{n()},s.onerror=()=>{Js.delete(e),n()},s.src=e});return Js.set(e,r),r},Nh=new Set(["huggingface.co","www.huggingface.co"]),Ih=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function Oh(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!Nh.has(t.hostname))return null;const r=t.pathname.split("/").filter(Boolean),n=r[0]==="datasets"?"dataset":"model",s=n==="dataset"?r.slice(1):r;if(s.length!==2||n==="model"&&Ih.has(s[0])||s.some(l=>!l||l==="."||l===".."))return null;const o=s.join("/"),a=s.map(encodeURIComponent).join("/"),i=n==="dataset"?`datasets/${a}`:a,c=n==="dataset"?"datasets":"models";return{type:n,repoId:o,url:`https://huggingface.co/${i}`,thumbnailUrl:`https://cdn-thumbnails.huggingface.co/social-thumbnails/${c}/${a}.png`}}const xh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Ah=({repo:e})=>{const[t,r]=G.useState(!1);return b.jsxs("div",{className:"hf-preview-card",children:[t?b.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):b.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:e.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>r(!0)}),b.jsxs("div",{className:"hf-preview-meta",children:[b.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",e.type]}),b.jsx("strong",{children:e.repoId}),b.jsx("span",{children:"huggingface.co"})]})]})},Mh=({repo:e,children:t})=>{const[r,n]=G.useState(!1),s=G.useRef(null),o=G.useCallback(()=>{ru(e.thumbnailUrl)},[e.thumbnailUrl]);return G.useEffect(()=>{const a=s.current;if(!a||typeof IntersectionObserver>"u")return;const i=new IntersectionObserver(([c])=>{c.isIntersecting&&(o(),i.disconnect())},{rootMargin:"200px"});return i.observe(a),()=>i.disconnect()},[o]),b.jsxs(Ps,{open:r,onOpenChange:a=>{(!a||!xh())&&n(a)},openDelay:150,closeDelay:100,children:[b.jsx(Rs,{asChild:!0,children:b.jsx("a",{ref:s,className:"chat-paper-link chat-hf-link",href:e.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:o,onFocus:o,children:t})}),b.jsx(Ts,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:b.jsx(Ah,{repo:e})})]})},zh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,qh=({repo:e,preview:t,unavailable:r})=>{const[n,s]=G.useState(!1),o=!!(t!=null&&t.avatarUrl)&&!n;return b.jsxs("div",{className:"github-preview-card",children:[o?b.jsx("img",{className:"github-preview-image","data-testid":"github-preview-image",src:t==null?void 0:t.avatarUrl,alt:"",loading:"eager",decoding:"async",onError:()=>s(!0)}):b.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:b.jsx(ra,{})}),b.jsxs("div",{className:"github-preview-meta",children:[b.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),b.jsx("strong",{children:e.repoId}),(t==null?void 0:t.description)&&b.jsx("span",{className:"github-preview-description",children:t.description}),t?b.jsxs("span",{className:"github-preview-stats",children:[t.language&&b.jsxs(b.Fragment,{children:[t.language," · "]}),"★ ",t.stars.toLocaleString()," · ⑂ ",t.forks.toLocaleString(),t.archived&&b.jsx(b.Fragment,{children:" · Archived"})]}):b.jsx("span",{children:r?"Preview unavailable":"Loading preview…"})]})]})},Dh=({repo:e,children:t})=>{var l;const[r,n]=G.useState(!1),[s,o]=G.useState(!1),a=G.useRef(null),i=G.useCallback(()=>o(!0),[]),c=Bn({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:d})=>gh(e,d),enabled:r||s,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return G.useEffect(()=>{const d=a.current;if(!d||typeof IntersectionObserver>"u")return;const h=new IntersectionObserver(([m])=>{m.isIntersecting&&(i(),h.disconnect())},{rootMargin:"200px"});return h.observe(d),()=>h.disconnect()},[i]),G.useEffect(()=>{var d;(d=c.data)!=null&&d.avatarUrl&&ru(c.data.avatarUrl)},[(l=c.data)==null?void 0:l.avatarUrl]),b.jsxs(Ps,{open:r,onOpenChange:d=>{(!d||!zh())&&n(d)},openDelay:150,closeDelay:100,children:[b.jsx(Rs,{asChild:!0,children:b.jsxs("a",{ref:a,className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:i,onFocus:i,children:[b.jsx(ra,{"aria-hidden":"true"}),t]})}),b.jsx(Ts,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:b.jsx(qh,{repo:e,preview:c.data,unavailable:c.isError})})]})},Uh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function Fh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const Lh=({citation:e})=>{const[t,r]=G.useState(!1),[n,s]=G.useState(!1),o=e.thumbnail_url,a=e.favicon_url;return b.jsxs("div",{className:"web-preview-card",children:[o&&!t&&b.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>r(!0)}),b.jsxs("div",{className:"web-preview-meta",children:[b.jsxs("div",{className:"web-preview-source",children:[a&&!n&&b.jsx("img",{src:a,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>s(!0)}),b.jsx("span",{children:Fh(e.url??"")}),e.published&&b.jsxs(b.Fragment,{children:[b.jsx("span",{"aria-hidden":"true",children:"·"}),b.jsx("time",{children:e.published.slice(0,10)})]})]}),b.jsx("strong",{children:e.title}),e.excerpt&&b.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()})]})]})},Vh=({citation:e,children:t})=>{const[r,n]=G.useState(!1),s=e.url??"";return b.jsxs(Ps,{open:r,onOpenChange:o=>{(!o||!Uh())&&n(o)},openDelay:150,closeDelay:100,children:[b.jsx(Rs,{asChild:!0,children:b.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),b.jsx(Ts,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:b.jsx(Lh,{citation:e})})]})},Hh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Zh=e=>e==="semantic_scholar"?"Semantic Scholar":"External paper",Kh=({citation:e})=>{var t,r;return b.jsxs("div",{className:"external-paper-preview-card",children:[b.jsxs("div",{className:"external-paper-preview-source",children:[b.jsx("span",{children:Zh(e.provider)}),e.published&&b.jsxs(b.Fragment,{children:[b.jsx("span",{"aria-hidden":"true",children:"·"}),b.jsx("time",{children:e.published.slice(0,10)})]})]}),b.jsx("strong",{children:e.title}),(((t=e.authors)==null?void 0:t.length)??0)>0&&b.jsx("p",{className:"external-paper-preview-authors",children:(r=e.authors)==null?void 0:r.join(", ")}),e.excerpt&&b.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()}),e.citation_count!==null&&e.citation_count!==void 0&&b.jsxs("span",{className:"external-paper-preview-citations",children:[e.citation_count.toLocaleString()," citations"]})]})},Gh=({citation:e,children:t})=>{const[r,n]=G.useState(!1);return b.jsxs(Ps,{open:r,onOpenChange:s=>{(!s||!Hh())&&n(s)},openDelay:150,closeDelay:100,children:[b.jsx(Rs,{asChild:!0,children:b.jsx("a",{href:e.url??"",className:"chat-external-paper-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),b.jsx(Ts,{className:"external-paper-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:b.jsx(Kh,{citation:e})})]})};function Wh(e){const t=[];let r=0,n=null;for(const s of e.match(/.*(?:\n|$)/g)??[]){if(!s)continue;const o=s.endsWith(` +`)?s.slice(0,-1):s;if(n){const c=o.match(/^ {0,3}(`+|~+)[ \t]*$/);c&&c[1][0]===n.marker&&c[1].length>=n.length&&(t.push({start:n.start,end:r+s.length}),n=null),r+=s.length;continue}const a=o.match(/^ {0,3}(`{3,}|~{3,})/);if(a){n={marker:a[1][0],length:a[1].length,start:r},r+=s.length;continue}let i=0;for(;it>=r.start&&t=0&&e[n]==="\\";n-=1)r+=1;return r%2===0}function Pc(e,t,r,n){const s=[];let o=0;for(;on.name),published:t.metadata.published,conference:t.metadata.conference,citationCount:t.metadata.citation_count,tasks:t.metadata.tasks};if(r)return{routeId:e,title:r.title,arxivId:r.arxiv_id??null,source:r.arxiv_id?"arxiv":"external",sourceUrl:r.source_url,thumbnailUrl:r.thumbnail_url??null,authors:r.authors??[],published:r.published??null,conference:r.conference??null,citationCount:r.citation_count??null,tasks:[]}}const nu=({routeId:e,paper:t,citation:r,className:n="chat-paper-link",children:s})=>b.jsx(eu,{routeId:e,initialData:Jh(e,t,r),className:n,target:"_blank",children:s});function Qh(e){const t=e.lastIndexOf("[");if(t===-1)return e;const r=e.slice(t);return/^\[[^\]]*(\]\(?[^)\s]*)?$/.test(r)?e.slice(0,t):e}const Yh=e=>e.startsWith("paper:")?e:bh(e);function Xh(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const mo=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=Bh(t?Qh(e):e);return b.jsx($h,{remarkPlugins:[wh,vh],rehypePlugins:[yh],urlTransform:Yh,components:{a:({href:a,children:i})=>{if(a!=null&&a.startsWith("paper:")){const d=a.slice(6);return!r[d]&&!(n!=null&&n[d])?b.jsx("span",{className:"chat-invalid-citation",children:i}):b.jsx(nu,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?Oh(a):null;if(c)return b.jsx(Mh,{repo:c,children:i});const l=a?_h(a):null;return l?b.jsx(Dh,{repo:l,children:i}):a&&Xh(a)?b.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[b.jsx(ra,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?s[a].source_type==="paper"?b.jsx(Gh,{citation:s[a],children:i}):b.jsx(Vh,{citation:s[a],children:i}):a!=null&&a.startsWith("https://")?b.jsx("a",{href:a,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:i}):b.jsx("span",{children:i})}},children:o})},ep=Object.freeze({status:"aborted"});function z(e,t,r){function n(i,c){var l;Object.defineProperty(i,"_zod",{value:i._zod??{},enumerable:!1}),(l=i._zod).traits??(l.traits=new Set),i._zod.traits.add(e),t(i,c);for(const d in a.prototype)d in i||Object.defineProperty(i,d,{value:a.prototype[d].bind(i)});i._zod.constr=a,i._zod.def=c}const s=(r==null?void 0:r.Parent)??Object;class o extends s{}Object.defineProperty(o,"name",{value:e});function a(i){var c;const l=r!=null&&r.Parent?new o:this;n(l,i),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:i=>{var c,l;return r!=null&&r.Parent&&i instanceof r.Parent?!0:(l=(c=i==null?void 0:i._zod)==null?void 0:c.traits)==null?void 0:l.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class fn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const su={};function Kt(e){return su}function tp(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,s])=>t.indexOf(+n)===-1).map(([n,s])=>s)}function rp(e,t){return typeof t=="bigint"?t.toString():t}function na(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function sa(e){return e==null}function oa(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function np(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}function Te(e,t,r){Object.defineProperty(e,t,{get(){{const n=r();return e[t]=n,n}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function js(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Kr(e){return JSON.stringify(e)}const ou=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function is(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const sp=na(()=>{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 cs(e){if(is(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(is(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const op=new Set(["string","number","symbol"]);function yn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _r(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r!=null&&r.parent)&&(n._zod.parent=e),n}function te(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 ap(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const ip={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 cp(e,t){const r={},n=e._zod.def;for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(r[s]=n.shape[s])}return _r(e,{...e._zod.def,shape:r,checks:[]})}function lp(e,t){const r={...e._zod.def.shape},n=e._zod.def;for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return _r(e,{...e._zod.def,shape:r,checks:[]})}function up(e,t){if(!cs(t))throw new Error("Invalid input to extend: expected a plain object");const r={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return js(this,"shape",n),n},checks:[]};return _r(e,r)}function dp(e,t){return _r(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return js(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function fp(e,t,r){const n=t._zod.def.shape,s={...n};if(r)for(const o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=e?new e({type:"optional",innerType:n[o]}):n[o])}else for(const o in n)s[o]=e?new e({type:"optional",innerType:n[o]}):n[o];return _r(t,{...t._zod.def,shape:s,checks:[]})}function hp(e,t,r){const n=t._zod.def.shape,s={...n};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=new e({type:"nonoptional",innerType:n[o]}))}else for(const o in n)s[o]=new e({type:"nonoptional",innerType:n[o]});return _r(t,{...t._zod.def,shape:s,checks:[]})}function tn(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function On(e){return typeof e=="string"?e:e==null?void 0:e.message}function Gt(e,t,r){var s,o,a,i,c,l;const n={...e,path:e.path??[]};if(!e.message){const d=On((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??On((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??On((c=r.customError)==null?void 0:c.call(r,e))??On((l=r.localeError)==null?void 0:l.call(r,e))??"Invalid input";n.message=d}return delete n.inst,delete n.continue,t!=null&&t.reportInput||delete n.input,n}function aa(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function hn(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const au=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,rp,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},iu=z("$ZodError",au),cu=z("$ZodError",au,{Parent:Error});function pp(e,t=r=>r.message){const r={},n=[];for(const s of e.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(t(s))):n.push(t(s));return{formErrors:n,fieldErrors:r}}function mp(e,t){const r=t||function(o){return o.message},n={_errors:[]},s=o=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(i=>s({issues:i}));else if(a.code==="invalid_key")s({issues:a.issues});else if(a.code==="invalid_element")s({issues:a.issues});else if(a.path.length===0)n._errors.push(r(a));else{let i=n,c=0;for(;c(t,r,n,s)=>{const o=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new fn;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Gt(c,o,Kt())));throw ou(i,s==null?void 0:s.callee),i}return a.value},_p=e=>async(t,r,n,s)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Gt(c,o,Kt())));throw ou(i,s==null?void 0:s.callee),i}return a.value},lu=e=>(t,r,n)=>{const s=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new fn;return o.issues.length?{success:!1,error:new(e??iu)(o.issues.map(a=>Gt(a,s,Kt())))}:{success:!0,data:o.value}},uu=lu(cu),du=e=>async(t,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>Gt(a,s,Kt())))}:{success:!0,data:o.value}},yp=du(cu),vp=/^[cC][^\s-]{8,}$/,$p=/^[0-9a-z]+$/,wp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bp=/^[0-9a-vA-V]{20}$/,Sp=/^[A-Za-z0-9]{27}$/,Ep=/^[a-zA-Z0-9_-]{21}$/,kp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Pp=/^([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})$/,Rc=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)$/,Rp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Tp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Cp(){return new RegExp(Tp,"u")}const jp=/^(?:(?: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])$/,Np=/^(([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})$/,Ip=/^((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])$/,Op=/^(([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])$/,xp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fu=/^[A-Za-z0-9_-]*$/,Ap=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Mp=/^\+(?:[0-9]){6,14}[0-9]$/,hu="(?:(?:\\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])))",zp=new RegExp(`^${hu}$`);function pu(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 qp(e){return new RegExp(`^${pu(e)}$`)}function Dp(e){const t=pu({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${hu}T(?:${n})$`)}const Up=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}$`)},Fp=/^\d+$/,Lp=/^-?\d+(?:\.\d+)?/i,Vp=/true|false/i,Hp=/null/i,Zp=/undefined/i,Kp=/^[^A-Z]*$/,Gp=/^[^a-z]*$/,it=z("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),mu={number:"number",bigint:"bigint",object:"date"},gu=z("$ZodCheckLessThan",(e,t)=>{it.init(e,t);const r=mu[typeof t.value];e._zod.onattach.push(n=>{const s=n._zod.bag,o=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value{(t.inclusive?n.value<=t.value:n.value{it.init(e,t);const r=mu[typeof t.value];e._zod.onattach.push(n=>{const s=n._zod.bag,o=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wp=z("$ZodCheckMultipleOf",(e,t)=>{it.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):np(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Bp=z("$ZodCheckNumberFormat",(e,t)=>{var a;it.init(e,t),t.format=t.format||"float64";const r=(a=t.format)==null?void 0:a.includes("int"),n=r?"int":"number",[s,o]=ip[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=s,c.maximum=o,r&&(c.pattern=Fp)}),e._zod.check=i=>{const c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:"invalid_type",input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}co&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inst:e})}}),Jp=z("$ZodCheckMaxLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!sa(s)&&s.length!==void 0}),e._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum{const s=n.value;if(s.length<=t.maximum)return;const a=aa(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Qp=z("$ZodCheckMinLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!sa(s)&&s.length!==void 0}),e._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const s=n.value;if(s.length>=t.minimum)return;const a=aa(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Yp=z("$ZodCheckLengthEquals",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!sa(s)&&s.length!==void 0}),e._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=n=>{const s=n.value,o=s.length;if(o===t.length)return;const a=aa(s),i=o>t.length;n.issues.push({origin:a,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ns=z("$ZodCheckStringFormat",(e,t)=>{var r,n;it.init(e,t),e._zod.onattach.push(s=>{const o=s._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Xp=z("$ZodCheckRegex",(e,t)=>{Ns.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),em=z("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Kp),Ns.init(e,t)}),tm=z("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Gp),Ns.init(e,t)}),rm=z("$ZodCheckIncludes",(e,t)=>{it.init(e,t);const r=yn(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),nm=z("$ZodCheckStartsWith",(e,t)=>{it.init(e,t);const r=new RegExp(`^${yn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),sm=z("$ZodCheckEndsWith",(e,t)=>{it.init(e,t);const r=new RegExp(`.*${yn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),om=z("$ZodCheckOverwrite",(e,t)=>{it.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class am{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 n=t.split(` +`).filter(a=>a),s=Math.min(...n.map(a=>a.length-a.trimStart().length)),o=n.map(a=>a.slice(s)).map(a=>" ".repeat(this.indent*2)+a);for(const a of o)this.content.push(a)}compile(){const t=Function,r=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new t(...r,s.join(` +`))}}const im={major:4,minor:0,patch:0},Ee=z("$ZodType",(e,t)=>{var s;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=im;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const a of o._zod.onattach)a(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),(s=e._zod.deferred)==null||s.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,i,c)=>{let l=tn(a),d;for(const h of i){if(h._zod.def.when){if(!h._zod.def.when(a))continue}else if(l)continue;const m=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new fn;if(d||g instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await g,a.issues.length!==m&&(l||(l=tn(a,m)))});else{if(a.issues.length===m)continue;l||(l=tn(a,m))}}return d?d.then(()=>a):a};e._zod.run=(a,i)=>{const c=e._zod.parse(a,i);if(c instanceof Promise){if(i.async===!1)throw new fn;return c.then(l=>o(l,n,i))}return o(c,n,i)}}e["~standard"]={validate:o=>{var a;try{const i=uu(e,o);return i.success?{value:i.data}:{issues:(a=i.error)==null?void 0:a.issues}}catch{return yp(e,o).then(c=>{var l;return c.success?{value:c.data}:{issues:(l=c.error)==null?void 0:l.issues}})}},vendor:"zod",version:1}}),ia=z("$ZodString",(e,t)=>{var r;Ee.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??Up(e._zod.bag),e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),je=z("$ZodStringFormat",(e,t)=>{Ns.init(e,t),ia.init(e,t)}),cm=z("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Pp),je.init(e,t)}),lm=z("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Rc(n))}else t.pattern??(t.pattern=Rc());je.init(e,t)}),um=z("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Rp),je.init(e,t)}),dm=z("$ZodURL",(e,t)=>{je.init(e,t),e._zod.check=r=>{try{const n=r.value,s=new URL(n),o=s.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Ap.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),fm=z("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Cp()),je.init(e,t)}),hm=z("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ep),je.init(e,t)}),pm=z("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=vp),je.init(e,t)}),mm=z("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=$p),je.init(e,t)}),gm=z("$ZodULID",(e,t)=>{t.pattern??(t.pattern=wp),je.init(e,t)}),_m=z("$ZodXID",(e,t)=>{t.pattern??(t.pattern=bp),je.init(e,t)}),ym=z("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Sp),je.init(e,t)}),vm=z("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Dp(t)),je.init(e,t)}),$m=z("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=zp),je.init(e,t)}),wm=z("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=qp(t)),je.init(e,t)}),bm=z("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=kp),je.init(e,t)}),Sm=z("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=jp),je.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),Em=z("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Np),je.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),km=z("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ip),je.init(e,t)}),Pm=z("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Op),je.init(e,t),e._zod.check=r=>{const[n,s]=r.value.split("/");try{if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function yu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Rm=z("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xp),je.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{yu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Tm(e){if(!fu.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return yu(r)}const Cm=z("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=fu),je.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{Tm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),jm=z("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Mp),je.init(e,t)});function Nm(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const Im=z("$ZodJWT",(e,t)=>{je.init(e,t),e._zod.check=r=>{Nm(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),vu=z("$ZodNumber",(e,t)=>{Ee.init(e,t),e._zod.pattern=e._zod.bag.pattern??Lp,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;const o=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...o?{received:o}:{}}),r}}),Om=z("$ZodNumber",(e,t)=>{Bp.init(e,t),vu.init(e,t)}),xm=z("$ZodBoolean",(e,t)=>{Ee.init(e,t),e._zod.pattern=Vp,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),r}}),Am=z("$ZodUndefined",(e,t)=>{Ee.init(e,t),e._zod.pattern=Zp,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(r,n)=>{const s=r.value;return typeof s>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:s,inst:e}),r}}),Mm=z("$ZodNull",(e,t)=>{Ee.init(e,t),e._zod.pattern=Hp,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{const s=r.value;return s===null||r.issues.push({expected:"null",code:"invalid_type",input:s,inst:e}),r}}),zm=z("$ZodAny",(e,t)=>{Ee.init(e,t),e._zod.parse=r=>r}),qm=z("$ZodUnknown",(e,t)=>{Ee.init(e,t),e._zod.parse=r=>r}),Dm=z("$ZodNever",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Tc(e,t,r){e.issues.length&&t.issues.push(...lr(r,e.issues)),t.value[r]=e.value}const Um=z("$ZodArray",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);const o=[];for(let a=0;aTc(l,r,a))):Tc(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function xn(e,t,r){e.issues.length&&t.issues.push(...lr(r,e.issues)),t.value[r]=e.value}function Cc(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...lr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const Fm=z("$ZodObject",(e,t)=>{Ee.init(e,t);const r=na(()=>{const h=Object.keys(t.shape);for(const g of h)if(!(t.shape[g]instanceof Ee))throw new Error(`Invalid element at key "${g}": expected a Zod schema`);const m=ap(t.shape);return{shape:t.shape,keys:h,keySet:new Set(h),numKeys:h.length,optionalKeys:new Set(m)}});Te(e._zod,"propValues",()=>{const h=t.shape,m={};for(const g in h){const y=h[g]._zod;if(y.values){m[g]??(m[g]=new Set);for(const _ of y.values)m[g].add(_)}}return m});const n=h=>{const m=new am(["shape","payload","ctx"]),g=r.value,y=$=>{const E=Kr($);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};m.write("const input = payload.value;");const _=Object.create(null);let v=0;for(const $ of g.keys)_[$]=`key_${v++}`;m.write("const newResult = {}");for(const $ of g.keys)if(g.optionalKeys.has($)){const E=_[$];m.write(`const ${E} = ${y($)};`);const T=Kr($);m.write(` + if (${E}.issues.length) { + if (input[${T}] === undefined) { + if (${T} in input) { + newResult[${T}] = undefined; + } + } else { + payload.issues = payload.issues.concat( + ${E}.issues.map((iss) => ({ + ...iss, + path: iss.path ? [${T}, ...iss.path] : [${T}], + })) + ); + } + } else if (${E}.value === undefined) { + if (${T} in input) newResult[${T}] = undefined; + } else { + newResult[${T}] = ${E}.value; + } + `)}else{const E=_[$];m.write(`const ${E} = ${y($)};`),m.write(` + if (${E}.issues.length) payload.issues = payload.issues.concat(${E}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${Kr($)}, ...iss.path] : [${Kr($)}] + })));`),m.write(`newResult[${Kr($)}] = ${E}.value`)}m.write("payload.value = newResult;"),m.write("return payload;");const f=m.compile();return($,E)=>f(h,$,E)};let s;const o=is,a=!su.jitless,c=a&&sp.value,l=t.catchall;let d;e._zod.parse=(h,m)=>{d??(d=r.value);const g=h.value;if(!o(g))return h.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),h;const y=[];if(a&&c&&(m==null?void 0:m.async)===!1&&m.jitless!==!0)s||(s=n(t.shape)),h=s(h,m);else{h.value={};const E=d.shape;for(const T of d.keys){const k=E[T],x=k._zod.run({value:g[T],issues:[]},m),M=k._zod.optin==="optional"&&k._zod.optout==="optional";x instanceof Promise?y.push(x.then(L=>M?Cc(L,h,T,g):xn(L,h,T))):M?Cc(x,h,T,g):xn(x,h,T)}}if(!l)return y.length?Promise.all(y).then(()=>h):h;const _=[],v=d.keySet,f=l._zod,$=f.def.type;for(const E of Object.keys(g)){if(v.has(E))continue;if($==="never"){_.push(E);continue}const T=f.run({value:g[E],issues:[]},m);T instanceof Promise?y.push(T.then(k=>xn(k,h,E))):xn(T,h,E)}return _.length&&h.issues.push({code:"unrecognized_keys",keys:_,input:g,inst:e}),y.length?Promise.all(y).then(()=>h):h}});function jc(e,t,r,n){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(o=>Gt(o,n,Kt())))}),t}const $u=z("$ZodUnion",(e,t)=>{Ee.init(e,t),Te(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Te(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Te(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Te(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>oa(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let s=!1;const o=[];for(const a of t.options){const i=a._zod.run({value:r.value,issues:[]},n);if(i instanceof Promise)o.push(i),s=!0;else{if(i.issues.length===0)return i;o.push(i)}}return s?Promise.all(o).then(a=>jc(a,r,e,n)):jc(o,r,e,n)}}),Lm=z("$ZodDiscriminatedUnion",(e,t)=>{$u.init(e,t);const r=e._zod.parse;Te(e._zod,"propValues",()=>{const s={};for(const o of t.options){const a=o._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[i,c]of Object.entries(a)){s[i]||(s[i]=new Set);for(const l of c)s[i].add(l)}}return s});const n=na(()=>{const s=t.options,o=new Map;for(const a of s){const i=a._zod.propValues[t.discriminator];if(!i||i.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const c of i){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,a)}}return o});e._zod.parse=(s,o)=>{const a=s.value;if(!is(a))return s.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),s;const i=n.value.get(a==null?void 0:a[t.discriminator]);return i?i._zod.run(s,o):t.unionFallback?r(s,o):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:a,path:[t.discriminator],inst:e}),s)}}),Vm=z("$ZodIntersection",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value,o=t.left._zod.run({value:s,issues:[]},n),a=t.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,l])=>Nc(r,c,l)):Nc(r,o,a)}});function go(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(cs(e)&&cs(t)){const r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),s={...e,...t};for(const o of n){const a=go(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};s[o]=a.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!cs(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;const o=[];if(t.keyType._zod.values){const a=t.keyType._zod.values;r.value={};for(const c of a)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const l=t.valueType._zod.run({value:s[c],issues:[]},n);l instanceof Promise?o.push(l.then(d=>{d.issues.length&&r.issues.push(...lr(c,d.issues)),r.value[c]=d.value})):(l.issues.length&&r.issues.push(...lr(c,l.issues)),r.value[c]=l.value)}let i;for(const c in s)a.has(c)||(i=i??[],i.push(c));i&&i.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:i})}else{r.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__")continue;const i=t.keyType._zod.run({value:a,issues:[]},n);if(i instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(i.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:i.issues.map(l=>Gt(l,n,Kt())),input:a,path:[a],inst:e}),r.value[i.value]=i.value;continue}const c=t.valueType._zod.run({value:s[a],issues:[]},n);c instanceof Promise?o.push(c.then(l=>{l.issues.length&&r.issues.push(...lr(a,l.issues)),r.value[i.value]=l.value})):(c.issues.length&&r.issues.push(...lr(a,c.issues)),r.value[i.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),Zm=z("$ZodEnum",(e,t)=>{Ee.init(e,t);const r=tp(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>op.has(typeof n)).map(n=>typeof n=="string"?yn(n):n.toString()).join("|")})$`),e._zod.parse=(n,s)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),Km=z("$ZodLiteral",(e,t)=>{Ee.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?yn(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{const s=r.value;return e._zod.values.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),Gm=z("$ZodTransform",(e,t)=>{Ee.init(e,t),e._zod.parse=(r,n)=>{const s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(a=>(r.value=a,r));if(s instanceof Promise)throw new fn;return r.value=s,r}}),Wm=z("$ZodOptional",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Te(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${oa(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),Bm=z("$ZodNullable",(e,t)=>{Ee.init(e,t),Te(e._zod,"optin",()=>t.innerType._zod.optin),Te(e._zod,"optout",()=>t.innerType._zod.optout),Te(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${oa(r.source)}|null)$`):void 0}),Te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Jm=z("$ZodDefault",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",Te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>Ic(o,t)):Ic(s,t)}});function Ic(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Qm=z("$ZodPrefault",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",Te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Ym=z("$ZodNonOptional",(e,t)=>{Ee.init(e,t),Te(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>Oc(o,e)):Oc(s,e)}});function Oc(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 Xm=z("$ZodCatch",(e,t)=>{Ee.init(e,t),e._zod.optin="optional",Te(e._zod,"optout",()=>t.innerType._zod.optout),Te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(a=>Gt(a,n,Kt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>Gt(o,n,Kt()))},input:r.value}),r.issues=[]),r)}}),eg=z("$ZodPipe",(e,t)=>{Ee.init(e,t),Te(e._zod,"values",()=>t.in._zod.values),Te(e._zod,"optin",()=>t.in._zod.optin),Te(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{const s=t.in._zod.run(r,n);return s instanceof Promise?s.then(o=>xc(o,t,n)):xc(s,t,n)}});function xc(e,t,r){return tn(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const tg=z("$ZodReadonly",(e,t)=>{Ee.init(e,t),Te(e._zod,"propValues",()=>t.innerType._zod.propValues),Te(e._zod,"values",()=>t.innerType._zod.values),Te(e._zod,"optin",()=>t.innerType._zod.optin),Te(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(Ac):Ac(s)}});function Ac(e){return e.value=Object.freeze(e.value),e}const rg=z("$ZodCustom",(e,t)=>{it.init(e,t),Ee.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then(o=>Mc(o,r,n,e));Mc(s,r,n,e)}});function Mc(e,t,r,n){if(!e){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),t.issues.push(hn(s))}}class ng{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){const n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}}function sg(){return new ng}const An=sg();function og(e,t){return new e({type:"string",...te(t)})}function ag(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...te(t)})}function zc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...te(t)})}function ig(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...te(t)})}function cg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...te(t)})}function lg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...te(t)})}function ug(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...te(t)})}function wu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...te(t)})}function dg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...te(t)})}function fg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...te(t)})}function hg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...te(t)})}function pg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...te(t)})}function mg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...te(t)})}function gg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...te(t)})}function _g(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...te(t)})}function yg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...te(t)})}function vg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...te(t)})}function $g(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...te(t)})}function wg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...te(t)})}function bg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...te(t)})}function Sg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...te(t)})}function Eg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...te(t)})}function kg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...te(t)})}function Pg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...te(t)})}function Rg(e,t){return new e({type:"string",format:"date",check:"string_format",...te(t)})}function Tg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...te(t)})}function Cg(e,t){return new e({type:"string",format:"duration",check:"string_format",...te(t)})}function jg(e,t){return new e({type:"number",checks:[],...te(t)})}function Ng(e,t){return new e({type:"number",coerce:!0,checks:[],...te(t)})}function Ig(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...te(t)})}function Og(e,t){return new e({type:"boolean",...te(t)})}function xg(e,t){return new e({type:"undefined",...te(t)})}function Ag(e,t){return new e({type:"null",...te(t)})}function Mg(e){return new e({type:"any"})}function zg(e){return new e({type:"unknown"})}function qg(e,t){return new e({type:"never",...te(t)})}function qc(e,t){return new gu({check:"less_than",...te(t),value:e,inclusive:!1})}function Qs(e,t){return new gu({check:"less_than",...te(t),value:e,inclusive:!0})}function Dc(e,t){return new _u({check:"greater_than",...te(t),value:e,inclusive:!1})}function Ys(e,t){return new _u({check:"greater_than",...te(t),value:e,inclusive:!0})}function Uc(e,t){return new Wp({check:"multiple_of",...te(t),value:e})}function bu(e,t){return new Jp({check:"max_length",...te(t),maximum:e})}function ls(e,t){return new Qp({check:"min_length",...te(t),minimum:e})}function Su(e,t){return new Yp({check:"length_equals",...te(t),length:e})}function Dg(e,t){return new Xp({check:"string_format",format:"regex",...te(t),pattern:e})}function Ug(e){return new em({check:"string_format",format:"lowercase",...te(e)})}function Fg(e){return new tm({check:"string_format",format:"uppercase",...te(e)})}function Lg(e,t){return new rm({check:"string_format",format:"includes",...te(t),includes:e})}function Vg(e,t){return new nm({check:"string_format",format:"starts_with",...te(t),prefix:e})}function Hg(e,t){return new sm({check:"string_format",format:"ends_with",...te(t),suffix:e})}function vn(e){return new om({check:"overwrite",tx:e})}function Zg(e){return vn(t=>t.normalize(e))}function Kg(){return vn(e=>e.trim())}function Gg(){return vn(e=>e.toLowerCase())}function Wg(){return vn(e=>e.toUpperCase())}function Bg(e,t,r){return new e({type:"array",element:t,...te(r)})}function Jg(e,t,r){const n=te(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Qg(e,t,r){return new e({type:"custom",check:"custom",fn:t,...te(r)})}const Yg=z("ZodISODateTime",(e,t)=>{vm.init(e,t),Ie.init(e,t)});function Eu(e){return Pg(Yg,e)}const Xg=z("ZodISODate",(e,t)=>{$m.init(e,t),Ie.init(e,t)});function e_(e){return Rg(Xg,e)}const t_=z("ZodISOTime",(e,t)=>{wm.init(e,t),Ie.init(e,t)});function r_(e){return Tg(t_,e)}const n_=z("ZodISODuration",(e,t)=>{bm.init(e,t),Ie.init(e,t)});function s_(e){return Cg(n_,e)}const o_=(e,t)=>{iu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>mp(e,r)},flatten:{value:r=>pp(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},Is=z("ZodError",o_,{Parent:Error}),a_=gp(Is),i_=_p(Is),c_=lu(Is),l_=du(Is),Ce=z("ZodType",(e,t)=>(Ee.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>_r(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>a_(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>c_(e,r,n),e.parseAsync=async(r,n)=>i_(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>l_(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(ty(r,n)),e.superRefine=r=>e.check(ry(r)),e.overwrite=r=>e.check(vn(r)),e.optional=()=>Ne(e),e.nullable=()=>Vc(e),e.nullish=()=>Ne(Vc(e)),e.nonoptional=r=>G_(e,r),e.array=()=>K(e),e.or=r=>_e([e,r]),e.and=r=>ua(e,r),e.transform=r=>$o(e,ju(r)),e.default=r=>H_(e,r),e.prefault=r=>K_(e,r),e.catch=r=>B_(e,r),e.pipe=r=>$o(e,r),e.readonly=()=>Y_(e),e.describe=r=>{const n=e.clone();return An.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=An.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return An.get(e);const n=e.clone();return An.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ku=z("_ZodString",(e,t)=>{ia.init(e,t),Ce.init(e,t);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Dg(...n)),e.includes=(...n)=>e.check(Lg(...n)),e.startsWith=(...n)=>e.check(Vg(...n)),e.endsWith=(...n)=>e.check(Hg(...n)),e.min=(...n)=>e.check(ls(...n)),e.max=(...n)=>e.check(bu(...n)),e.length=(...n)=>e.check(Su(...n)),e.nonempty=(...n)=>e.check(ls(1,...n)),e.lowercase=n=>e.check(Ug(n)),e.uppercase=n=>e.check(Fg(n)),e.trim=()=>e.check(Kg()),e.normalize=(...n)=>e.check(Zg(...n)),e.toLowerCase=()=>e.check(Gg()),e.toUpperCase=()=>e.check(Wg())}),u_=z("ZodString",(e,t)=>{ia.init(e,t),ku.init(e,t),e.email=r=>e.check(ag(d_,r)),e.url=r=>e.check(wu(Pu,r)),e.jwt=r=>e.check(kg(R_,r)),e.emoji=r=>e.check(dg(h_,r)),e.guid=r=>e.check(zc(Fc,r)),e.uuid=r=>e.check(ig(Mn,r)),e.uuidv4=r=>e.check(cg(Mn,r)),e.uuidv6=r=>e.check(lg(Mn,r)),e.uuidv7=r=>e.check(ug(Mn,r)),e.nanoid=r=>e.check(fg(p_,r)),e.guid=r=>e.check(zc(Fc,r)),e.cuid=r=>e.check(hg(m_,r)),e.cuid2=r=>e.check(pg(g_,r)),e.ulid=r=>e.check(mg(__,r)),e.base64=r=>e.check(bg(E_,r)),e.base64url=r=>e.check(Sg(k_,r)),e.xid=r=>e.check(gg(y_,r)),e.ksuid=r=>e.check(_g(v_,r)),e.ipv4=r=>e.check(yg($_,r)),e.ipv6=r=>e.check(vg(w_,r)),e.cidrv4=r=>e.check($g(b_,r)),e.cidrv6=r=>e.check(wg(S_,r)),e.e164=r=>e.check(Eg(P_,r)),e.datetime=r=>e.check(Eu(r)),e.date=r=>e.check(e_(r)),e.time=r=>e.check(r_(r)),e.duration=r=>e.check(s_(r))});function R(e){return og(u_,e)}const Ie=z("ZodStringFormat",(e,t)=>{je.init(e,t),ku.init(e,t)}),d_=z("ZodEmail",(e,t)=>{um.init(e,t),Ie.init(e,t)}),Fc=z("ZodGUID",(e,t)=>{cm.init(e,t),Ie.init(e,t)}),Mn=z("ZodUUID",(e,t)=>{lm.init(e,t),Ie.init(e,t)}),Pu=z("ZodURL",(e,t)=>{dm.init(e,t),Ie.init(e,t)});function f_(e){return wu(Pu,e)}const h_=z("ZodEmoji",(e,t)=>{fm.init(e,t),Ie.init(e,t)}),p_=z("ZodNanoID",(e,t)=>{hm.init(e,t),Ie.init(e,t)}),m_=z("ZodCUID",(e,t)=>{pm.init(e,t),Ie.init(e,t)}),g_=z("ZodCUID2",(e,t)=>{mm.init(e,t),Ie.init(e,t)}),__=z("ZodULID",(e,t)=>{gm.init(e,t),Ie.init(e,t)}),y_=z("ZodXID",(e,t)=>{_m.init(e,t),Ie.init(e,t)}),v_=z("ZodKSUID",(e,t)=>{ym.init(e,t),Ie.init(e,t)}),$_=z("ZodIPv4",(e,t)=>{Sm.init(e,t),Ie.init(e,t)}),w_=z("ZodIPv6",(e,t)=>{Em.init(e,t),Ie.init(e,t)}),b_=z("ZodCIDRv4",(e,t)=>{km.init(e,t),Ie.init(e,t)}),S_=z("ZodCIDRv6",(e,t)=>{Pm.init(e,t),Ie.init(e,t)}),E_=z("ZodBase64",(e,t)=>{Rm.init(e,t),Ie.init(e,t)}),k_=z("ZodBase64URL",(e,t)=>{Cm.init(e,t),Ie.init(e,t)}),P_=z("ZodE164",(e,t)=>{jm.init(e,t),Ie.init(e,t)}),R_=z("ZodJWT",(e,t)=>{Im.init(e,t),Ie.init(e,t)}),ca=z("ZodNumber",(e,t)=>{vu.init(e,t),Ce.init(e,t),e.gt=(n,s)=>e.check(Dc(n,s)),e.gte=(n,s)=>e.check(Ys(n,s)),e.min=(n,s)=>e.check(Ys(n,s)),e.lt=(n,s)=>e.check(qc(n,s)),e.lte=(n,s)=>e.check(Qs(n,s)),e.max=(n,s)=>e.check(Qs(n,s)),e.int=n=>e.check(Lc(n)),e.safe=n=>e.check(Lc(n)),e.positive=n=>e.check(Dc(0,n)),e.nonnegative=n=>e.check(Ys(0,n)),e.negative=n=>e.check(qc(0,n)),e.nonpositive=n=>e.check(Qs(0,n)),e.multipleOf=(n,s)=>e.check(Uc(n,s)),e.step=(n,s)=>e.check(Uc(n,s)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function fe(e){return jg(ca,e)}const T_=z("ZodNumberFormat",(e,t)=>{Om.init(e,t),ca.init(e,t)});function Lc(e){return Ig(T_,e)}const C_=z("ZodBoolean",(e,t)=>{xm.init(e,t),Ce.init(e,t)});function ve(e){return Og(C_,e)}const j_=z("ZodUndefined",(e,t)=>{Am.init(e,t),Ce.init(e,t)});function _o(e){return xg(j_,e)}const N_=z("ZodNull",(e,t)=>{Mm.init(e,t),Ce.init(e,t)});function I_(e){return Ag(N_,e)}const O_=z("ZodAny",(e,t)=>{zm.init(e,t),Ce.init(e,t)});function la(){return Mg(O_)}const x_=z("ZodUnknown",(e,t)=>{qm.init(e,t),Ce.init(e,t)});function Se(){return zg(x_)}const A_=z("ZodNever",(e,t)=>{Dm.init(e,t),Ce.init(e,t)});function yo(e){return qg(A_,e)}const M_=z("ZodArray",(e,t)=>{Um.init(e,t),Ce.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(ls(r,n)),e.nonempty=r=>e.check(ls(1,r)),e.max=(r,n)=>e.check(bu(r,n)),e.length=(r,n)=>e.check(Su(r,n)),e.unwrap=()=>e.element});function K(e,t){return Bg(M_,e,t)}const Ru=z("ZodObject",(e,t)=>{Fm.init(e,t),Ce.init(e,t),Te(e,"shape",()=>t.shape),e.keyof=()=>lt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Se()}),e.loose=()=>e.clone({...e._zod.def,catchall:Se()}),e.strict=()=>e.clone({...e._zod.def,catchall:yo()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>up(e,r),e.merge=r=>dp(e,r),e.pick=r=>cp(e,r),e.omit=r=>lp(e,r),e.partial=(...r)=>fp(Nu,e,r[0]),e.required=(...r)=>hp(Iu,e,r[0])});function A(e,t){const r={type:"object",get shape(){return js(this,"shape",{...e}),this.shape},...te(t)};return new Ru(r)}function Be(e,t){return new Ru({type:"object",get shape(){return js(this,"shape",{...e}),this.shape},catchall:Se(),...te(t)})}const Tu=z("ZodUnion",(e,t)=>{$u.init(e,t),Ce.init(e,t),e.options=t.options});function _e(e,t){return new Tu({type:"union",options:e,...te(t)})}const z_=z("ZodDiscriminatedUnion",(e,t)=>{Tu.init(e,t),Lm.init(e,t)});function Cu(e,t,r){return new z_({type:"union",options:t,discriminator:e,...te(r)})}const q_=z("ZodIntersection",(e,t)=>{Vm.init(e,t),Ce.init(e,t)});function ua(e,t){return new q_({type:"intersection",left:e,right:t})}const D_=z("ZodRecord",(e,t)=>{Hm.init(e,t),Ce.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function $e(e,t,r){return new D_({type:"record",keyType:e,valueType:t,...te(r)})}const vo=z("ZodEnum",(e,t)=>{Zm.init(e,t),Ce.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,s)=>{const o={};for(const a of n)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new vo({...t,checks:[],...te(s),entries:o})},e.exclude=(n,s)=>{const o={...t.entries};for(const a of n)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new vo({...t,checks:[],...te(s),entries:o})}});function lt(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new vo({type:"enum",entries:r,...te(t)})}const U_=z("ZodLiteral",(e,t)=>{Km.init(e,t),Ce.init(e,t),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 N(e,t){return new U_({type:"literal",values:Array.isArray(e)?e:[e],...te(t)})}const F_=z("ZodTransform",(e,t)=>{Gm.init(e,t),Ce.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(hn(o,r.value,t));else{const a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),a.continue??(a.continue=!0),r.issues.push(hn(a))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function ju(e){return new F_({type:"transform",transform:e})}const Nu=z("ZodOptional",(e,t)=>{Wm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ne(e){return new Nu({type:"optional",innerType:e})}const L_=z("ZodNullable",(e,t)=>{Bm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Vc(e){return new L_({type:"nullable",innerType:e})}const V_=z("ZodDefault",(e,t)=>{Jm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function H_(e,t){return new V_({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Z_=z("ZodPrefault",(e,t)=>{Qm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function K_(e,t){return new Z_({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Iu=z("ZodNonOptional",(e,t)=>{Ym.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function G_(e,t){return new Iu({type:"nonoptional",innerType:e,...te(t)})}const W_=z("ZodCatch",(e,t)=>{Xm.init(e,t),Ce.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function B_(e,t){return new W_({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const J_=z("ZodPipe",(e,t)=>{eg.init(e,t),Ce.init(e,t),e.in=t.in,e.out=t.out});function $o(e,t){return new J_({type:"pipe",in:e,out:t})}const Q_=z("ZodReadonly",(e,t)=>{tg.init(e,t),Ce.init(e,t)});function Y_(e){return new Q_({type:"readonly",innerType:e})}const Ou=z("ZodCustom",(e,t)=>{rg.init(e,t),Ce.init(e,t)});function X_(e){const t=new it({check:"custom"});return t._zod.check=e,t}function ey(e,t){return Jg(Ou,e??(()=>!0),t)}function ty(e,t={}){return Qg(Ou,e,t)}function ry(e){const t=X_(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(hn(n,r.value,t._zod.def));else{const s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),r.issues.push(hn(s))}},e(r.value,r)));return t}function xu(e,t){return $o(ju(e),t)}const ny={custom:"custom"};function sy(e){return Ng(ca,e)}const Os="2025-11-25",oy=[Os,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],nr="io.modelcontextprotocol/related-task",xs="2.0",Ue=ey(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Au=_e([R(),fe().int()]),Mu=R();Be({ttl:fe().optional(),pollInterval:fe().optional()});const ay=A({ttl:fe().optional()}),iy=A({taskId:R()}),da=Be({progressToken:Au.optional(),[nr]:iy.optional()}),ut=A({_meta:da.optional()}),$n=ut.extend({task:ay.optional()}),cy=e=>$n.safeParse(e).success,Je=A({method:R(),params:ut.loose().optional()}),ht=A({_meta:da.optional()}),pt=A({method:R(),params:ht.loose().optional()}),Qe=Be({_meta:da.optional()}),wn=_e([R(),fe().int()]),zu=A({jsonrpc:N(xs),id:wn,...Je.shape}).strict(),wo=e=>zu.safeParse(e).success,qu=A({jsonrpc:N(xs),...pt.shape}).strict(),ly=e=>qu.safeParse(e).success,fa=A({jsonrpc:N(xs),id:wn,result:Qe}).strict(),Qr=e=>fa.safeParse(e).success;var ae;(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"})(ae||(ae={}));const ha=A({jsonrpc:N(xs),id:wn.optional(),error:A({code:fe().int(),message:R(),data:Se().optional()})}).strict(),uy=e=>ha.safeParse(e).success,Jn=_e([zu,qu,fa,ha]);_e([fa,ha]);const kr=Qe.strict(),dy=ht.extend({requestId:wn.optional(),reason:R().optional()}),pa=pt.extend({method:N("notifications/cancelled"),params:dy}),fy=A({src:R(),mimeType:R().optional(),sizes:K(R()).optional(),theme:lt(["light","dark"]).optional()}),bn=A({icons:K(fy).optional()}),Ir=A({name:R(),title:R().optional()}),As=Ir.extend({...Ir.shape,...bn.shape,version:R(),websiteUrl:R().optional(),description:R().optional()}),hy=ua(A({applyDefaults:ve().optional()}),$e(R(),Se())),py=xu(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ua(A({form:hy.optional(),url:Ue.optional()}),$e(R(),Se()).optional())),my=Be({list:Ue.optional(),cancel:Ue.optional(),requests:Be({sampling:Be({createMessage:Ue.optional()}).optional(),elicitation:Be({create:Ue.optional()}).optional()}).optional()}),gy=Be({list:Ue.optional(),cancel:Ue.optional(),requests:Be({tools:Be({call:Ue.optional()}).optional()}).optional()}),_y=A({experimental:$e(R(),Ue).optional(),sampling:A({context:Ue.optional(),tools:Ue.optional()}).optional(),elicitation:py.optional(),roots:A({listChanged:ve().optional()}).optional(),tasks:my.optional(),extensions:$e(R(),Ue).optional()}),yy=ut.extend({protocolVersion:R(),capabilities:_y,clientInfo:As}),vy=Je.extend({method:N("initialize"),params:yy}),$y=A({experimental:$e(R(),Ue).optional(),logging:Ue.optional(),completions:Ue.optional(),prompts:A({listChanged:ve().optional()}).optional(),resources:A({subscribe:ve().optional(),listChanged:ve().optional()}).optional(),tools:A({listChanged:ve().optional()}).optional(),tasks:gy.optional(),extensions:$e(R(),Ue).optional()}),Du=Qe.extend({protocolVersion:R(),capabilities:$y,serverInfo:As,instructions:R().optional()}),Uu=pt.extend({method:N("notifications/initialized"),params:ht.optional()}),wy=e=>Uu.safeParse(e).success,Ms=Je.extend({method:N("ping"),params:ut.optional()}),by=A({progress:fe(),total:Ne(fe()),message:Ne(R())}),Sy=A({...ht.shape,...by.shape,progressToken:Au}),ma=pt.extend({method:N("notifications/progress"),params:Sy}),Ey=ut.extend({cursor:Mu.optional()}),Sn=Je.extend({params:Ey.optional()}),En=Qe.extend({nextCursor:Mu.optional()}),ky=lt(["working","input_required","completed","failed","cancelled"]),kn=A({taskId:R(),status:ky,ttl:_e([fe(),I_()]),createdAt:R(),lastUpdatedAt:R(),pollInterval:Ne(fe()),statusMessage:Ne(R())}),pn=Qe.extend({task:kn}),Py=ht.merge(kn),us=pt.extend({method:N("notifications/tasks/status"),params:Py}),ga=Je.extend({method:N("tasks/get"),params:ut.extend({taskId:R()})}),_a=Qe.merge(kn),ya=Je.extend({method:N("tasks/result"),params:ut.extend({taskId:R()})});Qe.loose();const va=Sn.extend({method:N("tasks/list")}),$a=En.extend({tasks:K(kn)}),wa=Je.extend({method:N("tasks/cancel"),params:ut.extend({taskId:R()})}),Ry=Qe.merge(kn),Fu=A({uri:R(),mimeType:Ne(R()),_meta:$e(R(),Se()).optional()}),Lu=Fu.extend({text:R()}),ba=R().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Vu=Fu.extend({blob:ba}),Pn=lt(["user","assistant"]),zr=A({audience:K(Pn).optional(),priority:fe().min(0).max(1).optional(),lastModified:Eu({offset:!0}).optional()}),Hu=A({...Ir.shape,...bn.shape,uri:R(),description:Ne(R()),mimeType:Ne(R()),size:Ne(fe()),annotations:zr.optional(),_meta:Ne(Be({}))}),Ty=A({...Ir.shape,...bn.shape,uriTemplate:R(),description:Ne(R()),mimeType:Ne(R()),annotations:zr.optional(),_meta:Ne(Be({}))}),Zu=Sn.extend({method:N("resources/list")}),Sa=En.extend({resources:K(Hu)}),Ku=Sn.extend({method:N("resources/templates/list")}),Ea=En.extend({resourceTemplates:K(Ty)}),ka=ut.extend({uri:R()}),Cy=ka,Gu=Je.extend({method:N("resources/read"),params:Cy}),Pa=Qe.extend({contents:K(_e([Lu,Vu]))}),Ra=pt.extend({method:N("notifications/resources/list_changed"),params:ht.optional()}),jy=ka,Ny=Je.extend({method:N("resources/subscribe"),params:jy}),Iy=ka,Oy=Je.extend({method:N("resources/unsubscribe"),params:Iy}),xy=ht.extend({uri:R()}),Ay=pt.extend({method:N("notifications/resources/updated"),params:xy}),My=A({name:R(),description:Ne(R()),required:Ne(ve())}),zy=A({...Ir.shape,...bn.shape,description:Ne(R()),arguments:Ne(K(My)),_meta:Ne(Be({}))}),Wu=Sn.extend({method:N("prompts/list")}),Ta=En.extend({prompts:K(zy)}),qy=ut.extend({name:R(),arguments:$e(R(),R()).optional()}),Dy=Je.extend({method:N("prompts/get"),params:qy}),Ca=A({type:N("text"),text:R(),annotations:zr.optional(),_meta:$e(R(),Se()).optional()}),ja=A({type:N("image"),data:ba,mimeType:R(),annotations:zr.optional(),_meta:$e(R(),Se()).optional()}),Na=A({type:N("audio"),data:ba,mimeType:R(),annotations:zr.optional(),_meta:$e(R(),Se()).optional()}),Uy=A({type:N("tool_use"),name:R(),id:R(),input:$e(R(),Se()),_meta:$e(R(),Se()).optional()}),Bu=A({type:N("resource"),resource:_e([Lu,Vu]),annotations:zr.optional(),_meta:$e(R(),Se()).optional()}),Ju=Hu.extend({type:N("resource_link")}),Rn=_e([Ca,ja,Na,Ju,Bu]),Fy=A({role:Pn,content:Rn}),Qu=Qe.extend({description:R().optional(),messages:K(Fy)}),Ia=pt.extend({method:N("notifications/prompts/list_changed"),params:ht.optional()}),Ly=A({title:R().optional(),readOnlyHint:ve().optional(),destructiveHint:ve().optional(),idempotentHint:ve().optional(),openWorldHint:ve().optional()}),Vy=A({taskSupport:lt(["required","optional","forbidden"]).optional()}),Oa=A({...Ir.shape,...bn.shape,description:R().optional(),inputSchema:A({type:N("object"),properties:$e(R(),Ue).optional(),required:K(R()).optional()}).catchall(Se()),outputSchema:A({type:N("object"),properties:$e(R(),Ue).optional(),required:K(R()).optional()}).catchall(Se()).optional(),annotations:Ly.optional(),execution:Vy.optional(),_meta:$e(R(),Se()).optional()}),Hy=Sn.extend({method:N("tools/list")}),xa=En.extend({tools:K(Oa)}),ur=Qe.extend({content:K(Rn).default([]),structuredContent:$e(R(),Se()).optional(),isError:ve().optional()});ur.or(Qe.extend({toolResult:Se()}));const Zy=$n.extend({name:R(),arguments:$e(R(),Se()).optional()}),Yu=Je.extend({method:N("tools/call"),params:Zy}),Aa=pt.extend({method:N("notifications/tools/list_changed"),params:ht.optional()}),Ky=A({autoRefresh:ve().default(!0),debounceMs:fe().int().nonnegative().default(300)}),Xu=lt(["debug","info","notice","warning","error","critical","alert","emergency"]),Gy=ut.extend({level:Xu}),Wy=Je.extend({method:N("logging/setLevel"),params:Gy}),By=ht.extend({level:Xu,logger:R().optional(),data:Se()}),ed=pt.extend({method:N("notifications/message"),params:By}),Jy=A({name:R().optional()}),Qy=A({hints:K(Jy).optional(),costPriority:fe().min(0).max(1).optional(),speedPriority:fe().min(0).max(1).optional(),intelligencePriority:fe().min(0).max(1).optional()}),Yy=A({mode:lt(["auto","required","none"]).optional()}),Xy=A({type:N("tool_result"),toolUseId:R().describe("The unique identifier for the corresponding tool call."),content:K(Rn).default([]),structuredContent:A({}).loose().optional(),isError:ve().optional(),_meta:$e(R(),Se()).optional()}),ev=Cu("type",[Ca,ja,Na]),ds=Cu("type",[Ca,ja,Na,Uy,Xy]),tv=A({role:Pn,content:_e([ds,K(ds)]),_meta:$e(R(),Se()).optional()}),rv=$n.extend({messages:K(tv),modelPreferences:Qy.optional(),systemPrompt:R().optional(),includeContext:lt(["none","thisServer","allServers"]).optional(),temperature:fe().optional(),maxTokens:fe().int(),stopSequences:K(R()).optional(),metadata:Ue.optional(),tools:K(Oa).optional(),toolChoice:Yy.optional()}),Ma=Je.extend({method:N("sampling/createMessage"),params:rv}),td=Qe.extend({model:R(),stopReason:Ne(lt(["endTurn","stopSequence","maxTokens"]).or(R())),role:Pn,content:ev}),rd=Qe.extend({model:R(),stopReason:Ne(lt(["endTurn","stopSequence","maxTokens","toolUse"]).or(R())),role:Pn,content:_e([ds,K(ds)])}),nv=A({type:N("boolean"),title:R().optional(),description:R().optional(),default:ve().optional()}),sv=A({type:N("string"),title:R().optional(),description:R().optional(),minLength:fe().optional(),maxLength:fe().optional(),format:lt(["email","uri","date","date-time"]).optional(),default:R().optional()}),ov=A({type:lt(["number","integer"]),title:R().optional(),description:R().optional(),minimum:fe().optional(),maximum:fe().optional(),default:fe().optional()}),av=A({type:N("string"),title:R().optional(),description:R().optional(),enum:K(R()),default:R().optional()}),iv=A({type:N("string"),title:R().optional(),description:R().optional(),oneOf:K(A({const:R(),title:R()})),default:R().optional()}),cv=A({type:N("string"),title:R().optional(),description:R().optional(),enum:K(R()),enumNames:K(R()).optional(),default:R().optional()}),lv=_e([av,iv]),uv=A({type:N("array"),title:R().optional(),description:R().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:A({type:N("string"),enum:K(R())}),default:K(R()).optional()}),dv=A({type:N("array"),title:R().optional(),description:R().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:A({anyOf:K(A({const:R(),title:R()}))}),default:K(R()).optional()}),fv=_e([uv,dv]),hv=_e([cv,lv,fv]),pv=_e([hv,nv,sv,ov]),mv=$n.extend({mode:N("form").optional(),message:R(),requestedSchema:A({type:N("object"),properties:$e(R(),pv),required:K(R()).optional()})}),gv=$n.extend({mode:N("url"),message:R(),elicitationId:R(),url:R().url()}),_v=_e([mv,gv]),nd=Je.extend({method:N("elicitation/create"),params:_v}),yv=ht.extend({elicitationId:R()}),vv=pt.extend({method:N("notifications/elicitation/complete"),params:yv}),sd=Qe.extend({action:lt(["accept","decline","cancel"]),content:xu(e=>e===null?void 0:e,$e(R(),_e([R(),fe(),ve(),K(R())])).optional())}),$v=A({type:N("ref/resource"),uri:R()}),wv=A({type:N("ref/prompt"),name:R()}),bv=ut.extend({ref:_e([wv,$v]),argument:A({name:R(),value:R()}),context:A({arguments:$e(R(),R()).optional()}).optional()}),Sv=Je.extend({method:N("completion/complete"),params:bv}),od=Qe.extend({completion:Be({values:K(R()).max(100),total:Ne(fe().int()),hasMore:Ne(ve())})}),Ev=A({uri:R().startsWith("file://"),name:R().optional(),_meta:$e(R(),Se()).optional()}),kv=Je.extend({method:N("roots/list"),params:ut.optional()}),Pv=Qe.extend({roots:K(Ev)}),Rv=pt.extend({method:N("notifications/roots/list_changed"),params:ht.optional()});_e([Ms,vy,Sv,Wy,Dy,Wu,Zu,Ku,Gu,Ny,Oy,Yu,Hy,ga,ya,va,wa]);_e([pa,ma,Uu,Rv,us]);_e([kr,td,rd,sd,Pv,_a,$a,pn]);_e([Ms,Ma,nd,kv,ga,ya,va,wa]);_e([pa,ma,ed,Ay,Ra,Aa,Ia,us,vv]);_e([kr,Du,od,Qu,Ta,Sa,Ea,Pa,ur,xa,_a,$a,pn]);class se extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===ae.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new Tv(s.elicitations,r)}return new se(t,r,n)}}class Tv extends se{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(ae.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function za(e){return!!e._zod}function Ut(e,t){return za(e)?uu(e,t):e.safeParse(t)}function ad(e){var r,n;if(!e)return;let t;if(za(e)?t=(n=(r=e._zod)==null?void 0:r.def)==null?void 0:n.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function id(e){var s;if(za(e)){const a=(s=e._zod)==null?void 0:s.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}const n=e.value;if(n!==void 0)return n}function Qt(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Hc(e){const t=ad(e),r=t==null?void 0:t.method;if(!r)throw new Error("Schema is missing a method literal");const n=id(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Zc(e,t){const r=Ut(e,t);if(!r.success)throw r.error;return r.data}const Cv=6e4;class cd{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(pa,r=>{this._oncancel(r)}),this.setNotificationHandler(ma,r=>{this._onprogress(r)}),this.setRequestHandler(Ms,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ga,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new se(ae.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(ya,async(r,n)=>{const s=async()=>{var i;const o=r.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,d=l.id,h=this._requestResolvers.get(d);if(h)if(this._requestResolvers.delete(d),c.type==="response")h(l);else{const m=l,g=new se(m.error.code,m.error.message,m.error.data);h(g)}else{const m=c.type==="response"?"Response":"Error";this._onerror(new Error(`${m} handler missing for request ${d}`))}continue}await((i=this._transport)==null?void 0:i.send(c.message,{relatedRequestId:n.requestId}))}}const a=await this._taskStore.getTask(o,n.sessionId);if(!a)throw new se(ae.InvalidParams,`Task not found: ${o}`);if(!Qt(a.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(Qt(a.status)){const c=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[nr]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(va,async(r,n)=>{var s;try{const{tasks:o,nextCursor:a}=await this._taskStore.listTasks((s=r.params)==null?void 0:s.cursor,n.sessionId);return{tasks:o,nextCursor:a,_meta:{}}}catch(o){throw new se(ae.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(wa,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new se(ae.InvalidParams,`Task not found: ${r.params.taskId}`);if(Qt(s.status))throw new se(ae.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);const o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new se(ae.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof se?s:new se(ae.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;const r=this._requestHandlerAbortControllers.get(t.params.requestId);r==null||r.abort(t.params.reason)}_setupTimeout(t,r,n,s,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(t){const r=this._timeoutInfo.get(t);if(!r)return!1;const n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),se.fromError(ae.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){const r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){var o,a,i;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 r=(o=this.transport)==null?void 0:o.onclose;this._transport.onclose=()=>{r==null||r(),this._onclose()};const n=(a=this.transport)==null?void 0:a.onerror;this._transport.onerror=c=>{n==null||n(c),this._onerror(c)};const s=(i=this._transport)==null?void 0:i.onmessage;this._transport.onmessage=(c,l)=>{s==null||s(c,l),Qr(c)||uy(c)?this._onresponse(c):wo(c)?this._onrequest(c,l):ly(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var n;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const r=se.fromError(ae.ConnectionClosed,"Connection closed");this._transport=void 0,(n=this.onclose)==null||n.call(this);for(const s of t.values())s(r)}_onerror(t){var r;(r=this.onerror)==null||r.call(this,t)}_onnotification(t){const r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){var d,h,m,g;const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,s=this._transport,o=(m=(h=(d=t.params)==null?void 0:d._meta)==null?void 0:h[nr])==null?void 0:m.taskId;if(n===void 0){const y={jsonrpc:"2.0",id:t.id,error:{code:ae.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:y,timestamp:Date.now()},s==null?void 0:s.sessionId).catch(_=>this._onerror(new Error(`Failed to enqueue error response: ${_}`))):s==null||s.send(y).catch(_=>this._onerror(new Error(`Failed to send an error response: ${_}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);const i=cy(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,s==null?void 0:s.sessionId):void 0,l={signal:a.signal,sessionId:s==null?void 0:s.sessionId,_meta:(g=t.params)==null?void 0:g._meta,sendNotification:async y=>{if(a.signal.aborted)return;const _={relatedRequestId:t.id};o&&(_.relatedTask={taskId:o}),await this.notification(y,_)},sendRequest:async(y,_,v)=>{var E;if(a.signal.aborted)throw new se(ae.ConnectionClosed,"Request was cancelled");const f={...v,relatedRequestId:t.id};o&&!f.relatedTask&&(f.relatedTask={taskId:o});const $=((E=f.relatedTask)==null?void 0:E.taskId)??o;return $&&c&&await c.updateTaskStatus($,"input_required"),await this.request(y,_,f)},authInfo:r==null?void 0:r.authInfo,requestId:t.id,requestInfo:r==null?void 0:r.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:i==null?void 0:i.ttl,closeSSEStream:r==null?void 0:r.closeSSEStream,closeStandaloneSSEStream:r==null?void 0:r.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,l)).then(async y=>{if(a.signal.aborted)return;const _={result:y,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:_,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(_))},async y=>{if(a.signal.aborted)return;const _={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(y.code)?y.code:ae.InternalError,message:y.message??"Internal error",...y.data!==void 0&&{data:y.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:_,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(_))}).catch(y=>this._onerror(new Error(`Failed to send response: ${y}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===a&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:r,...n}=t.params,s=Number(r),o=this._progressHandlers.get(s);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const a=this._responseHandlers.get(s),i=this._timeoutInfo.get(s);if(i&&a&&i.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),a(c);return}o(n)}_onresponse(t){const r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Qr(t))n(t);else{const a=new se(t.error.code,t.error.message,t.error.data);n(a)}return}const s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(Qr(t)&&t.result&&typeof t.result=="object"){const a=t.result;if(a.task&&typeof a.task=="object"){const i=a.task;typeof i.taskId=="string"&&(o=!0,this._taskProgressTokens.set(i.taskId,r))}}if(o||this._progressHandlers.delete(r),Qr(t))s(t);else{const a=se.fromError(t.error.code,t.error.message,t.error.data);s(a)}}get transport(){return this._transport}async close(){var t;await((t=this._transport)==null?void 0:t.close())}async*requestStream(t,r,n){var a,i;const{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(t,r,n)}}catch(c){yield{type:"error",error:c instanceof se?c:new se(ae.InternalError,String(c))}}return}let o;try{const c=await this.request(t,pn,n);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new se(ae.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:l},Qt(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:l.status==="failed"?yield{type:"error",error:new se(ae.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new se(ae.InternalError,`Task ${o} was cancelled`)});return}if(l.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}const d=l.pollInterval??((a=this._options)==null?void 0:a.defaultTaskPollInterval)??1e3;await new Promise(h=>setTimeout(h,d)),(i=n==null?void 0:n.signal)==null||i.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof se?c:new se(ae.InternalError,String(c))}}}request(t,r,n){const{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a,task:i,relatedTask:c}=n??{};return new Promise((l,d)=>{var $,E,T,k,x;const h=M=>{d(M)};if(!this._transport){h(new Error("Not connected"));return}if((($=this._options)==null?void 0:$.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),i&&this.assertTaskCapability(t.method)}catch(M){h(M);return}(E=n==null?void 0:n.signal)==null||E.throwIfAborted();const m=this._requestMessageId++,g={...t,jsonrpc:"2.0",id:m};n!=null&&n.onprogress&&(this._progressHandlers.set(m,n.onprogress),g.params={...t.params,_meta:{...((T=t.params)==null?void 0:T._meta)||{},progressToken:m}}),i&&(g.params={...g.params,task:i}),c&&(g.params={...g.params,_meta:{...((k=g.params)==null?void 0:k._meta)||{},[nr]:c}});const y=M=>{var F;this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),(F=this._transport)==null||F.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(M)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(V=>this._onerror(new Error(`Failed to send cancellation: ${V}`)));const L=M instanceof se?M:new se(ae.RequestTimeout,String(M));d(L)};this._responseHandlers.set(m,M=>{var L;if(!((L=n==null?void 0:n.signal)!=null&&L.aborted)){if(M instanceof Error)return d(M);try{const F=Ut(r,M.result);F.success?l(F.data):d(F.error)}catch(F){d(F)}}}),(x=n==null?void 0:n.signal)==null||x.addEventListener("abort",()=>{var M;y((M=n==null?void 0:n.signal)==null?void 0:M.reason)});const _=(n==null?void 0:n.timeout)??Cv,v=()=>y(se.fromError(ae.RequestTimeout,"Request timed out",{timeout:_}));this._setupTimeout(m,_,n==null?void 0:n.maxTotalTimeout,v,(n==null?void 0:n.resetTimeoutOnProgress)??!1);const f=c==null?void 0:c.taskId;if(f){const M=L=>{const F=this._responseHandlers.get(m);F?F(L):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,M),this._enqueueTaskMessage(f,{type:"request",message:g,timestamp:Date.now()}).catch(L=>{this._cleanupTimeout(m),d(L)})}else this._transport.send(g,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(M=>{this._cleanupTimeout(m),d(M)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},_a,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},$a,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Ry,r)}async notification(t,r){var i,c,l,d;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const n=(i=r==null?void 0:r.relatedTask)==null?void 0:i.taskId;if(n){const h={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[nr]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:h,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(r!=null&&r.relatedRequestId)&&!(r!=null&&r.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var m,g;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let h={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(h={...h,params:{...h.params,_meta:{...((m=h.params)==null?void 0:m._meta)||{},[nr]:r.relatedTask}}}),(g=this._transport)==null||g.send(h,r).catch(y=>this._onerror(y))});return}let a={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(a={...a,params:{...a.params,_meta:{...((d=a.params)==null?void 0:d._meta)||{},[nr]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){const n=Hc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=Zc(t,s);return Promise.resolve(r(a,o))})}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,r){const n=Hc(t);this._notificationHandlers.set(n,s=>{const o=Zc(t,s);return Promise.resolve(r(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){var o;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const s=(o=this._options)==null?void 0:o.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,s)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){const n=await this._taskMessageQueue.dequeueAll(t,r);for(const s of n)if(s.type==="request"&&wo(s.message)){const o=s.message.id,a=this._requestResolvers.get(o);a?(a(new se(ae.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){var s,o;let n=((s=this._options)==null?void 0:s.defaultTaskPollInterval)??1e3;try{const a=await((o=this._taskStore)==null?void 0:o.getTask(t));a!=null&&a.pollInterval&&(n=a.pollInterval)}catch{}return new Promise((a,i)=>{if(r.aborted){i(new se(ae.InvalidRequest,"Request cancelled"));return}const c=setTimeout(a,n);r.addEventListener("abort",()=>{clearTimeout(c),i(new se(ae.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){const n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!t)throw new Error("No request provided");return await n.createTask(s,t.id,{method:t.method,params:t.params},r)},getTask:async s=>{const o=await n.getTask(s,r);if(!o)throw new se(ae.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(s,o,a)=>{await n.storeTaskResult(s,o,a,r);const i=await n.getTask(s,r);if(i){const c=us.parse({method:"notifications/tasks/status",params:i});await this.notification(c),Qt(i.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,o,a)=>{const i=await n.getTask(s,r);if(!i)throw new se(ae.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(Qt(i.status))throw new se(ae.InvalidParams,`Cannot update task "${s}" from terminal status "${i.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,o,a,r);const c=await n.getTask(s,r);if(c){const l=us.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Qt(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function Kc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function jv(e,t){const r={...e};for(const n in t){const s=n,o=t[s];if(o===void 0)continue;const a=r[s];Kc(a)&&Kc(o)?r[s]={...a,...o}:r[s]=o}return r}(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});class Nv extends cd{constructor(){super(...arguments);le(this,"_registeredMethods",new Set);le(this,"_eventSlots",new Map);le(this,"setRequestHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setRequestHandler"),super.setRequestHandler(r,n)});le(this,"setNotificationHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setNotificationHandler"),super.setNotificationHandler(r,n)});le(this,"replaceRequestHandler",(r,n)=>{let s=r.shape.method.value;this._registeredMethods.add(s),super.setRequestHandler(r,n)})}onEventDispatch(r,n){}_ensureEventSlot(r){let n=this._eventSlots.get(r);if(!n){let s=this.eventSchemas[r];if(!s)throw Error(`Unknown event: ${String(r)}`);n={listeners:[]},this._eventSlots.set(r,n);let o=s.shape.method.value;this._registeredMethods.add(o);let a=n;super.setNotificationHandler(s,i=>{var l;let c=i.params;this.onEventDispatch(r,c),(l=a.onHandler)==null||l.call(a,c);for(let d of[...a.listeners])d(c)})}return n}setEventHandler(r,n){let s=this._ensureEventSlot(r);s.onHandler&&n&&console.warn(`[MCP Apps] on${String(r)} handler replaced. Use addEventListener("${String(r)}", …) to add multiple listeners without replacing.`),s.onHandler=n}getEventHandler(r){var n;return(n=this._eventSlots.get(r))==null?void 0:n.onHandler}addEventListener(r,n){this._ensureEventSlot(r).listeners.push(n)}removeEventListener(r,n){let s=this._eventSlots.get(r);if(!s)return;let o=s.listeners.indexOf(n);o!==-1&&s.listeners.splice(o,1)}warnIfRequestHandlerReplaced(r,n,s){n&&s&&console.warn(`[MCP Apps] ${r} handler replaced. Previous handler will no longer be called.`)}_assertMethodNotRegistered(r,n){let s=r.shape.method.value;if(this._registeredMethods.has(s))throw Error(`Handler for "${s}" already registered (via ${n}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(s)}}var ld="2026-01-26",Iv="ui/notifications/tool-input-partial",Ov=_e([N("light"),N("dark")]).describe("Color theme preference for the host environment."),mn=_e([N("inline"),N("fullscreen"),N("pip")]).describe("Display mode for UI presentation."),xv=_e([N("--color-background-primary"),N("--color-background-secondary"),N("--color-background-tertiary"),N("--color-background-inverse"),N("--color-background-ghost"),N("--color-background-info"),N("--color-background-danger"),N("--color-background-success"),N("--color-background-warning"),N("--color-background-disabled"),N("--color-text-primary"),N("--color-text-secondary"),N("--color-text-tertiary"),N("--color-text-inverse"),N("--color-text-ghost"),N("--color-text-info"),N("--color-text-danger"),N("--color-text-success"),N("--color-text-warning"),N("--color-text-disabled"),N("--color-border-primary"),N("--color-border-secondary"),N("--color-border-tertiary"),N("--color-border-inverse"),N("--color-border-ghost"),N("--color-border-info"),N("--color-border-danger"),N("--color-border-success"),N("--color-border-warning"),N("--color-border-disabled"),N("--color-ring-primary"),N("--color-ring-secondary"),N("--color-ring-inverse"),N("--color-ring-info"),N("--color-ring-danger"),N("--color-ring-success"),N("--color-ring-warning"),N("--font-sans"),N("--font-mono"),N("--font-weight-normal"),N("--font-weight-medium"),N("--font-weight-semibold"),N("--font-weight-bold"),N("--font-text-xs-size"),N("--font-text-sm-size"),N("--font-text-md-size"),N("--font-text-lg-size"),N("--font-heading-xs-size"),N("--font-heading-sm-size"),N("--font-heading-md-size"),N("--font-heading-lg-size"),N("--font-heading-xl-size"),N("--font-heading-2xl-size"),N("--font-heading-3xl-size"),N("--font-text-xs-line-height"),N("--font-text-sm-line-height"),N("--font-text-md-line-height"),N("--font-text-lg-line-height"),N("--font-heading-xs-line-height"),N("--font-heading-sm-line-height"),N("--font-heading-md-line-height"),N("--font-heading-lg-line-height"),N("--font-heading-xl-line-height"),N("--font-heading-2xl-line-height"),N("--font-heading-3xl-line-height"),N("--border-radius-xs"),N("--border-radius-sm"),N("--border-radius-md"),N("--border-radius-lg"),N("--border-radius-xl"),N("--border-radius-full"),N("--border-width-regular"),N("--shadow-hairline"),N("--shadow-sm"),N("--shadow-md"),N("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Av=$e(xv.describe(`Style variables for theming MCP apps. + +Individual style keys are optional - hosts may provide any subset of these values. +Values are strings containing CSS values (colors, sizes, font stacks, etc.). + +Note: This type uses \`Record\` rather than \`Partial>\` +for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),_e([R(),_o()]).describe(`Style variables for theming MCP apps. + +Individual style keys are optional - hosts may provide any subset of these values. +Values are strings containing CSS values (colors, sizes, font stacks, etc.). + +Note: This type uses \`Record\` rather than \`Partial>\` +for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps. + +Individual style keys are optional - hosts may provide any subset of these values. +Values are strings containing CSS values (colors, sizes, font stacks, etc.). + +Note: This type uses \`Record\` rather than \`Partial>\` +for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Mv=A({method:N("ui/open-link"),params:A({url:R().describe("URL to open in the host's browser")})});A({isError:ve().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();A({isError:ve().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();A({isError:ve().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var zv=A({method:N("ui/notifications/sandbox-proxy-ready"),params:A({})}),qa=A({connectDomains:K(R()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). + +- Maps to CSP \`connect-src\` directive +- Empty or omitted → no network connections (secure default)`),resourceDomains:K(R()).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:K(R()).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:K(R()).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'`)")}),Da=A({camera:A({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:A({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:A({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:A({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),qv=A({method:N("ui/notifications/size-changed"),params:A({width:fe().optional().describe("New width in pixels."),height:fe().optional().describe("New height in pixels.")})});A({method:N("ui/notifications/tool-input"),params:A({arguments:$e(R(),Se().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});A({method:N("ui/notifications/tool-input-partial"),params:A({arguments:$e(R(),Se().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});A({method:N("ui/notifications/tool-cancelled"),params:A({reason:R().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var Dv=A({fonts:R().optional()}),Uv=A({variables:Av.optional().describe("CSS variables for theming the app."),css:Dv.optional().describe("CSS blocks that apps can inject.")});A({method:N("ui/resource-teardown"),params:A({})});var Fv=$e(R(),Se()),Gc=A({text:A({}).optional().describe("Host supports text content blocks."),image:A({}).optional().describe("Host supports image content blocks."),audio:A({}).optional().describe("Host supports audio content blocks."),resource:A({}).optional().describe("Host supports resource content blocks."),resourceLink:A({}).optional().describe("Host supports resource link content blocks."),structuredContent:A({}).optional().describe("Host supports structured content.")}),Lv=A({method:N("ui/notifications/request-teardown"),params:A({}).optional()}),Vv=A({experimental:$e(R(),$e(R(),la()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:A({}).optional().describe("Host supports opening external URLs."),downloadFile:A({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:A({listChanged:ve().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:A({listChanged:ve().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:A({}).optional().describe("Host accepts log messages."),sandbox:A({permissions:Da.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:qa.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Gc.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Gc.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:A({tools:A({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),Hv=A({experimental:$e(R(),$e(R(),la()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:A({listChanged:ve().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:K(mn).optional().describe("Display modes the app supports.")}),Zv=A({method:N("ui/notifications/initialized"),params:A({}).optional()});A({csp:qa.optional().describe("Content Security Policy configuration for UI resources."),permissions:Da.optional().describe("Sandbox permissions requested by the UI resource."),domain:R().optional().describe(`Dedicated origin for view sandbox. + +Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists. + +**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include: +- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`) +- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`) + +If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:ve().optional().describe(`Visual boundary preference - true if view prefers a visible border. + +Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary. + +- \`true\`: request visible border + background +- \`false\`: request no visible border + background +- omitted: host decides border`)});var Wc=A({method:N("ui/request-display-mode"),params:A({mode:mn.describe("The display mode being requested.")})});A({mode:mn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var Kv=_e([N("model"),N("app")]).describe("Tool visibility scope - who can access the tool.");A({resourceUri:R().optional(),visibility:K(Kv).optional().describe(`Who can access this tool. Default: ["model", "app"] +- "model": Tool visible to and callable by the agent +- "app": Tool callable by the app from this server only`),csp:yo().optional(),permissions:yo().optional()});A({mimeTypes:K(R()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var Gv=A({method:N("ui/download-file"),params:A({contents:K(_e([Bu,Ju])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Wv=A({method:N("ui/message"),params:A({role:N("user").describe('Message role, currently only "user" is supported.'),content:K(Rn).describe("Message content blocks (text, image, etc.).")})});A({method:N("ui/notifications/sandbox-resource-ready"),params:A({html:R().describe("HTML content to load into the inner iframe."),sandbox:R().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:qa.optional().describe("CSP configuration from resource metadata."),permissions:Da.optional().describe("Sandbox permissions from resource metadata.")})});A({method:N("ui/notifications/tool-result"),params:ur.describe("Standard MCP tool execution result.")});var ud=A({toolInfo:A({id:wn.optional().describe("JSON-RPC id of the tools/call request."),tool:Oa.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Ov.optional().describe("Current color theme preference."),styles:Uv.optional().describe("Style configuration for theming the app."),displayMode:mn.optional().describe("How the UI is currently displayed."),availableDisplayModes:K(mn).optional().describe("Display modes the host supports."),containerDimensions:_e([A({height:fe().describe("Fixed container height in pixels.")}),A({maxHeight:_e([fe(),_o()]).optional().describe("Maximum container height in pixels.")})]).and(_e([A({width:fe().describe("Fixed container width in pixels.")}),A({maxWidth:_e([fe(),_o()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other +container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:R().optional().describe("User's language and region preference in BCP 47 format."),timeZone:R().optional().describe("User's timezone in IANA format."),userAgent:R().optional().describe("Host application identifier."),platform:_e([N("web"),N("desktop"),N("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:A({touch:ve().optional().describe("Whether the device supports touch input."),hover:ve().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:A({top:fe().describe("Top safe area inset in pixels."),right:fe().describe("Right safe area inset in pixels."),bottom:fe().describe("Bottom safe area inset in pixels."),left:fe().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();A({method:N("ui/notifications/host-context-changed"),params:ud.describe("Partial context update containing only changed fields.")});var Bv=A({method:N("ui/update-model-context"),params:A({content:K(Rn).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:$e(R(),Se().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Jv=A({method:N("ui/initialize"),params:A({appInfo:As.describe("App identification (name and version)."),appCapabilities:Hv.describe("Features and capabilities this app provides."),protocolVersion:R().describe("Protocol version this app supports.")})});A({protocolVersion:R().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:As.describe("Host application identification and version."),hostCapabilities:Vv.describe("Features and capabilities provided by the host."),hostContext:ud.describe("Rich context about the host environment.")}).passthrough();class Qv{constructor(t=window.parent,r){le(this,"eventTarget");le(this,"eventSource");le(this,"messageListener");le(this,"onclose");le(this,"onerror");le(this,"onmessage");le(this,"sessionId");le(this,"setProtocolVersion");this.eventTarget=t,this.eventSource=r,this.messageListener=n=>{var o,a,i;if(r&&n.source!==this.eventSource){console.debug("Ignoring message from unknown source",n);return}let s=Jn.safeParse(n.data);s.success?(console.debug("Parsed message",s.data),(o=this.onmessage)==null||o.call(this,s.data)):((a=n.data)==null?void 0:a.jsonrpc)!=="2.0"?console.debug("Ignoring non-JSON-RPC message",s.error.message,n):(console.error("Failed to parse message",s.error.message,n),(i=this.onerror)==null||i.call(this,Error("Invalid JSON-RPC message received: "+s.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,r){t.method!==Iv&&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 Yv=[ld];class Xv extends Nv{constructor(r,n,s,o){super(o);le(this,"_client");le(this,"_hostInfo");le(this,"_capabilities");le(this,"_appCapabilities");le(this,"_hostContext",{});le(this,"_appInfo");le(this,"_initializedReceived",!1);le(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);le(this,"replaceRequestHandler",(r,n)=>{this._baseReplaceRequestHandler(r,(s,o)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${s.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),n(s,o)))});le(this,"eventSchemas",{sizechange:qv,sandboxready:zv,initialized:Zv,requestteardown:Lv,loggingmessage:ed});le(this,"onping");le(this,"_onmessage");le(this,"_onopenlink");le(this,"_ondownloadfile");le(this,"_onrequestdisplaymode");le(this,"_onupdatemodelcontext");le(this,"_oncalltool");le(this,"_onlistresources");le(this,"_onlistresourcetemplates");le(this,"_onreadresource");le(this,"_onlistprompts");le(this,"sendResourceTeardown",this.teardownResource);this._client=r,this._hostInfo=n,this._capabilities=s,this.addEventListener("initialized",()=>{this._initializedReceived=!0}),this._hostContext=(o==null?void 0:o.hostContext)||{},this.setRequestHandler(Jv,a=>this._oninitialize(a)),this.setRequestHandler(Ms,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(Wc,a=>({mode:this._hostContext.displayMode??"inline"}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(r){this.setEventHandler("sizechange",r)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(r){this.setEventHandler("sandboxready",r)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(r){this.setEventHandler("initialized",r)}get onmessage(){return this._onmessage}set onmessage(r){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,r),this._onmessage=r,this.replaceRequestHandler(Wv,async(n,s)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(n.params,s)})}get onopenlink(){return this._onopenlink}set onopenlink(r){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,r),this._onopenlink=r,this.replaceRequestHandler(Mv,async(n,s)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(n.params,s)})}get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(r){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,r),this._ondownloadfile=r,this.replaceRequestHandler(Gv,async(n,s)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(n.params,s)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(r){this.setEventHandler("requestteardown",r)}get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(r){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,r),this._onrequestdisplaymode=r,this.replaceRequestHandler(Wc,async(n,s)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(n.params,s)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(r){this.setEventHandler("loggingmessage",r)}get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(r){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,r),this._onupdatemodelcontext=r,this.replaceRequestHandler(Bv,async(n,s)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(n.params,s)})}get oncalltool(){return this._oncalltool}set oncalltool(r){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,r),this._oncalltool=r,this.replaceRequestHandler(Yu,async(n,s)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,s)})}set oncreatesamplingmessage(r){this.setRequestHandler(Ma,async(n,s)=>r(n.params,s))}sendToolListChanged(r={}){return this.notification({method:"notifications/tools/list_changed",params:r})}get onlistresources(){return this._onlistresources}set onlistresources(r){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,r),this._onlistresources=r,this.replaceRequestHandler(Zu,async(n,s)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(n.params,s)})}get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(r){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,r),this._onlistresourcetemplates=r,this.replaceRequestHandler(Ku,async(n,s)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(n.params,s)})}get onreadresource(){return this._onreadresource}set onreadresource(r){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,r),this._onreadresource=r,this.replaceRequestHandler(Gu,async(n,s)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(n.params,s)})}sendResourceListChanged(r={}){return this.notification({method:"notifications/resources/list_changed",params:r})}get onlistprompts(){return this._onlistprompts}set onlistprompts(r){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,r),this._onlistprompts=r,this.replaceRequestHandler(Wu,async(n,s)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(n.params,s)})}sendPromptListChanged(r={}){return this.notification({method:"notifications/prompts/list_changed",params:r})}assertCapabilityForMethod(r){}assertRequestHandlerCapability(r){}assertNotificationCapability(r){}assertTaskCapability(r){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(r){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(r){let n=r.params.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=r.params.appCapabilities,this._appInfo=r.params.appInfo,{protocolVersion:Yv.includes(n)?n:ld,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(r){let n={},s=!1;for(let o of Object.keys(r)){let a=this._hostContext[o],i=r[o];e$(a,i)||(n[o]=i,s=!0)}s&&(this._hostContext=r,this.sendHostContextChange(n))}sendHostContextChange(r){return this.notification({method:"ui/notifications/host-context-changed",params:r})}sendToolInput(r){return this.notification({method:"ui/notifications/tool-input",params:r})}sendToolInputPartial(r){return this.notification({method:"ui/notifications/tool-input-partial",params:r})}sendToolResult(r){return this.notification({method:"ui/notifications/tool-result",params:r})}sendToolCancelled(r){return this.notification({method:"ui/notifications/tool-cancelled",params:r})}sendSandboxResourceReady(r){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:r})}teardownResource(r,n){return this.request({method:"ui/resource-teardown",params:r},Fv,n)}callTool(r,n){return this.request({method:"tools/call",params:r},ur,n)}listTools(r,n){return this.request({method:"tools/list",params:r},xa,n)}async connect(r){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let n=this._client.getServerCapabilities();if(!n)throw Error("Client server capabilities not available");n.tools&&(this.oncalltool=async(s,o)=>this._client.request({method:"tools/call",params:s},ur,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(Aa,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},Sa,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},Ea,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},Pa,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(Ra,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},Ta,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(Ia,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function e$(e,t){return JSON.stringify(e)===JSON.stringify(t)}const t$={x:0,y:0,width:1024,height:768},bo=28,r$=12,n$=.9;function Ft(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function dd(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}function So(e){if(Array.isArray(e))return e.map(So);const t=dd(e);return t?Object.fromEntries(Object.entries(t).map(([r,n])=>[r,(r==="text"||r==="originalText")&&typeof n=="string"?n.replace(/\\r\\n|\\n|\\r/gu,` +`):So(n)])):e}function s$(e){return e.type==="text"&&typeof(e.text??e.originalText)=="string"}function fd(e){const t=String(e.text??e.originalText??""),r=Ft(e.fontSize)??20,n=t.length*r*n$,s=Ft(e.width);return Math.max(s&&s>0?s:0,n)}function o$(e){for(const t of e){if(t.type!=="cameraUpdate")continue;const r=Ft(t.width),n=Ft(t.height);if(!(!r||r<=0||!n||n<=0))return{x:Ft(t.x)??0,y:Ft(t.y)??0,width:r,height:n}}return t$}function a$(e,t){const r=Ft(e.x);if(r===void 0)return!1;const n=fd(e),s=t.x+bo,o=t.x+t.width-bo;return ro+1}function i$(e,t){const r={...e},n=Ft(r.fontSize)??20;let s=fd(r);const o=Math.max(1,t.width-bo*2);if(s>o){const a=o/s;r.fontSize=Math.max(r$,n*a),typeof r.height=="number"&&(r.height*=Number(r.fontSize)/n),s=Math.min(o,s*(Number(r.fontSize)/n))}return r.width=s,r.autoResize=!1,r.textAlign="left",r.x=t.x+(t.width-s)/2,r}function c$(e){const r=So(e).map(dd);if(r.some(o=>o===void 0))return e;const n=r,s=o$(n);return n.map(o=>!s$(o)||!a$(o,s)?o:i$(o,s))}var Eo={exports:{}},hd={},jt={},Yt={},Tn={},ge={},gn={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor($){if(super(),!e.IDENTIFIER.test($))throw new Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor($){super(),this._items=typeof $=="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((E,T)=>`${E}${T}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((E,T)=>(T instanceof r&&(E[T.str]=(E[T.str]||0)+1),E),{})}}e._Code=n,e.nil=new n("");function s(f,...$){const E=[f[0]];let T=0;for(;T<$.length;)i(E,$[T]),E.push(f[++T]);return new n(E)}e._=s;const o=new n("+");function a(f,...$){const E=[g(f[0])];let T=0;for(;T<$.length;)E.push(o),i(E,$[T]),E.push(o,g(f[++T]));return c(E),new n(E)}e.str=a;function i(f,$){$ instanceof n?f.push(...$._items):$ instanceof r?f.push($):f.push(h($))}e.addCodeArg=i;function c(f){let $=1;for(;${if(h.scopePath===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return(0,t._)`${l}${h.scopePath}`})}scopeCode(l=this._values,d,h){return this._reduceValues(l,m=>{if(m.value===void 0)throw new Error(`CodeGen: name "${m}" has no value`);return m.value.code},d,h)}_reduceValues(l,d,h={},m){let g=t.nil;for(const y in l){const _=l[y];if(!_)continue;const v=h[y]=h[y]||new Map;_.forEach(f=>{if(v.has(f))return;v.set(f,n.Started);let $=d(f);if($){const E=this.opts.es5?e.varKinds.var:e.varKinds.const;g=(0,t._)`${g}${E} ${f} = ${$};${this.opts._n}`}else if($=m==null?void 0:m(f))g=(0,t._)`${g}${$}${this.opts._n}`;else throw new r(f);v.set(f,n.Completed)})}return g}}e.ValueScope=i})(ko);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=gn,r=ko;var n=gn;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=ko;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,P){super(),this.varKind=u,this.name=p,this.rhs=P}render({es5:u,_n:p}){const P=u?r.varKinds.var:this.varKind,q=this.rhs===void 0?"":` = ${this.rhs}`;return`${P} ${this.name}${q};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=H(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,P){super(),this.lhs=u,this.rhs=p,this.sideEffects=P}render({_n:u}){return`${this.lhs} = ${this.rhs};`+u}optimizeNames(u,p){if(!(this.lhs instanceof t.Name&&!u[this.lhs.str]&&!this.sideEffects))return this.rhs=H(this.rhs,u,p),this}get names(){const u=this.lhs instanceof t.Name?{}:{...this.lhs.names};return re(u,this.rhs)}}class c extends i{constructor(u,p,P,q){super(u,P,q),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class h extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class m extends o{constructor(u){super(),this.code=u}render({_n:u}){return`${this.code};`+u}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(u,p){return this.code=H(this.code,u,p),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class g extends o{constructor(u=[]){super(),this.nodes=u}render(u){return this.nodes.reduce((p,P)=>p+P.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const P=u[p].optimizeNodes();Array.isArray(P)?u.splice(p,1,...P):P?u[p]=P:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:P}=this;let q=P.length;for(;q--;){const D=P[q];D.optimizeNames(u,p)||(ie(u,D.names),P.splice(q,1))}return P.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>B(u,p.names),{})}}class y extends g{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class _ extends g{}class v extends y{}v.kind="else";class f extends y{constructor(u,p){super(p),this.condition=u}render(u){let p=`if(${this.condition})`+super.render(u);return this.else&&(p+="else "+this.else.render(u)),p}optimizeNodes(){super.optimizeNodes();const u=this.condition;if(u===!0)return this.nodes;let p=this.else;if(p){const P=p.optimizeNodes();p=this.else=Array.isArray(P)?new v(P):P}if(p)return u===!1?p instanceof f?p:p.nodes:this.nodes.length?this:new f(ke(u),p instanceof f?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var P;if(this.else=(P=this.else)===null||P===void 0?void 0:P.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=H(this.condition,u,p),this}get names(){const u=super.names;return re(u,this.condition),this.else&&B(u,this.else.names),u}}f.kind="if";class $ extends y{}$.kind="for";class E extends ${constructor(u){super(),this.iteration=u}render(u){return`for(${this.iteration})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iteration=H(this.iteration,u,p),this}get names(){return B(super.names,this.iteration.names)}}class T extends ${constructor(u,p,P,q){super(),this.varKind=u,this.name=p,this.from=P,this.to=q}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:P,from:q,to:D}=this;return`for(${p} ${P}=${q}; ${P}<${D}; ${P}++)`+super.render(u)}get names(){const u=re(super.names,this.from);return re(u,this.to)}}class k extends ${constructor(u,p,P,q){super(),this.loop=u,this.varKind=p,this.name=P,this.iterable=q}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=H(this.iterable,u,p),this}get names(){return B(super.names,this.iterable.names)}}class x extends y{constructor(u,p,P){super(),this.name=u,this.args=p,this.async=P}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}x.kind="func";class M extends g{render(u){return"return "+super.render(u)}}M.kind="return";class L extends y{render(u){let p="try"+super.render(u);return this.catch&&(p+=this.catch.render(u)),this.finally&&(p+=this.finally.render(u)),p}optimizeNodes(){var u,p;return super.optimizeNodes(),(u=this.catch)===null||u===void 0||u.optimizeNodes(),(p=this.finally)===null||p===void 0||p.optimizeNodes(),this}optimizeNames(u,p){var P,q;return super.optimizeNames(u,p),(P=this.catch)===null||P===void 0||P.optimizeNames(u,p),(q=this.finally)===null||q===void 0||q.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&B(u,this.catch.names),this.finally&&B(u,this.finally.names),u}}class F extends y{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}F.kind="catch";class V extends y{render(u){return"finally"+super.render(u)}}V.kind="finally";class Z{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` +`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new _]}toString(){return this._root.render(this.opts)}name(u){return this._scope.name(u)}scopeName(u){return this._extScope.name(u)}scopeValue(u,p){const P=this._extScope.value(u,p);return(this._values[P.prefix]||(this._values[P.prefix]=new Set)).add(P),P}getScopeValue(u,p){return this._extScope.getValue(u,p)}scopeRefs(u){return this._extScope.scopeRefs(u,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(u,p,P,q){const D=this._scope.toName(p);return P!==void 0&&q&&(this._constants[D.str]=P),this._leafNode(new a(u,D,P)),D}const(u,p,P){return this._def(r.varKinds.const,u,p,P)}let(u,p,P){return this._def(r.varKinds.let,u,p,P)}var(u,p,P){return this._def(r.varKinds.var,u,p,P)}assign(u,p,P){return this._leafNode(new i(u,p,P))}add(u,p){return this._leafNode(new c(u,e.operators.ADD,p))}code(u){return typeof u=="function"?u():u!==t.nil&&this._leafNode(new m(u)),this}object(...u){const p=["{"];for(const[P,q]of u)p.length>1&&p.push(","),p.push(P),(P!==q||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,q));return p.push("}"),new t._Code(p)}if(u,p,P){if(this._blockNode(new f(u)),p&&P)this.code(p).else().code(P).endIf();else if(p)this.code(p).endIf();else if(P)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new f(u))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(f,v)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new E(u),p)}forRange(u,p,P,q,D=this.opts.es5?r.varKinds.var:r.varKinds.let){const X=this._scope.toName(u);return this._for(new T(D,X,p,P),()=>q(X))}forOf(u,p,P,q=r.varKinds.const){const D=this._scope.toName(u);if(this.opts.es5){const X=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${X}.length`,Y=>{this.var(D,(0,t._)`${X}[${Y}]`),P(D)})}return this._for(new k("of",q,D,p),()=>P(D))}forIn(u,p,P,q=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,P);const D=this._scope.toName(u);return this._for(new k("in",q,D,p),()=>P(D))}endFor(){return this._endBlockNode($)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new M;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(M)}try(u,p,P){if(!p&&!P)throw new Error('CodeGen: "try" without "catch" and "finally"');const q=new L;if(this._blockNode(q),this.code(u),p){const D=this.name("e");this._currNode=q.catch=new F(D),p(D)}return P&&(this._currNode=q.finally=new V,this.code(P)),this._endBlockNode(F,V)}throw(u){return this._leafNode(new h(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const P=this._nodes.length-p;if(P<0||u!==void 0&&P!==u)throw new Error(`CodeGen: wrong number of nodes: ${P} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,P,q){return this._blockNode(new x(u,p,P)),q&&this.code(q).endFunc(),this}endFunc(){return this._endBlockNode(x)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const P=this._currNode;if(P instanceof u||p&&P instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof f))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=Z;function B(S,u){for(const p in u)S[p]=(S[p]||0)+(u[p]||0);return S}function re(S,u){return u instanceof t._CodeOrName?B(S,u.names):S}function H(S,u,p){if(S instanceof t.Name)return P(S);if(!q(S))return S;return new t._Code(S._items.reduce((D,X)=>(X instanceof t.Name&&(X=P(X)),X instanceof t._Code?D.push(...X._items):D.push(X),D),[]));function P(D){const X=p[D.str];return X===void 0||u[D.str]!==1?D:(delete u[D.str],X)}function q(D){return D instanceof t._Code&&D._items.some(X=>X instanceof t.Name&&u[X.str]===1&&p[X.str]!==void 0)}}function ie(S,u){for(const p in u)S[p]=(S[p]||0)-(u[p]||0)}function ke(S){return typeof S=="boolean"||typeof S=="number"||S===null?!S:(0,t._)`!${C(S)}`}e.not=ke;const ye=w(e.operators.AND);function ct(...S){return S.reduce(ye)}e.and=ct;const Oe=w(e.operators.OR);function O(...S){return S.reduce(Oe)}e.or=O;function w(S){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${S} ${C(p)}`}function C(S){return S instanceof t.Name?S:(0,t._)`(${S})`}})(ge);var J={};Object.defineProperty(J,"__esModule",{value:!0});J.checkStrictMode=J.getErrorPath=J.Type=J.useFunc=J.setEvaluated=J.evaluatedPropsToName=J.mergeEvaluated=J.eachItem=J.unescapeJsonPointer=J.escapeJsonPointer=J.escapeFragment=J.unescapeFragment=J.schemaRefOrVal=J.schemaHasRulesButRef=J.schemaHasRules=J.checkUnknownRules=J.alwaysValidSchema=J.toHash=void 0;const we=ge,l$=gn;function u$(e){const t={};for(const r of e)t[r]=!0;return t}J.toHash=u$;function d$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(pd(e,t),!md(t,e.self.RULES.all))}J.alwaysValidSchema=d$;function pd(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;const s=n.RULES.keywords;for(const o in t)s[o]||yd(e,`unknown keyword: "${o}"`)}J.checkUnknownRules=pd;function md(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}J.schemaHasRules=md;function f$(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}J.schemaHasRulesButRef=f$;function h$({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,we._)`${r}`}return(0,we._)`${e}${t}${(0,we.getProperty)(n)}`}J.schemaRefOrVal=h$;function p$(e){return gd(decodeURIComponent(e))}J.unescapeFragment=p$;function m$(e){return encodeURIComponent(Ua(e))}J.escapeFragment=m$;function Ua(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}J.escapeJsonPointer=Ua;function gd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}J.unescapeJsonPointer=gd;function g$(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}J.eachItem=g$;function Bc({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof we.Name?(o instanceof we.Name?e(s,o,a):t(s,o,a),a):o instanceof we.Name?(t(s,a,o),o):r(o,a);return i===we.Name&&!(c instanceof we.Name)?n(s,c):c}}J.mergeEvaluated={props:Bc({mergeNames:(e,t,r)=>e.if((0,we._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,we._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,we._)`${r} || {}`).code((0,we._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,we._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,we._)`${r} || {}`),Fa(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:_d}),items:Bc({mergeNames:(e,t,r)=>e.if((0,we._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,we._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,we._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,we._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function _d(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,we._)`{}`);return t!==void 0&&Fa(e,r,t),r}J.evaluatedPropsToName=_d;function Fa(e,t,r){Object.keys(r).forEach(n=>e.assign((0,we._)`${t}${(0,we.getProperty)(n)}`,!0))}J.setEvaluated=Fa;const Jc={};function _$(e,t){return e.scopeValue("func",{ref:t,code:Jc[t.code]||(Jc[t.code]=new l$._Code(t.code))})}J.useFunc=_$;var Po;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Po||(J.Type=Po={}));function y$(e,t,r){if(e instanceof we.Name){const n=t===Po.Num;return r?n?(0,we._)`"[" + ${e} + "]"`:(0,we._)`"['" + ${e} + "']"`:n?(0,we._)`"/" + ${e}`:(0,we._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,we.getProperty)(e).toString():"/"+Ua(e)}J.getErrorPath=y$;function yd(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}J.checkStrictMode=yd;var Tt={};Object.defineProperty(Tt,"__esModule",{value:!0});const Xe=ge,v$={data:new Xe.Name("data"),valCxt:new Xe.Name("valCxt"),instancePath:new Xe.Name("instancePath"),parentData:new Xe.Name("parentData"),parentDataProperty:new Xe.Name("parentDataProperty"),rootData:new Xe.Name("rootData"),dynamicAnchors:new Xe.Name("dynamicAnchors"),vErrors:new Xe.Name("vErrors"),errors:new Xe.Name("errors"),this:new Xe.Name("this"),self:new Xe.Name("self"),scope:new Xe.Name("scope"),json:new Xe.Name("json"),jsonPos:new Xe.Name("jsonPos"),jsonLen:new Xe.Name("jsonLen"),jsonPart:new Xe.Name("jsonPart")};Tt.default=v$;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=ge,r=J,n=Tt;e.keywordError={message:({keyword:v})=>(0,t.str)`must pass "${v}" keyword validation`},e.keyword$DataError={message:({keyword:v,schemaType:f})=>f?(0,t.str)`"${v}" keyword must be ${f} ($data)`:(0,t.str)`"${v}" keyword is invalid ($data)`};function s(v,f=e.keywordError,$,E){const{it:T}=v,{gen:k,compositeRule:x,allErrors:M}=T,L=h(v,f,$);E??(x||M)?c(k,L):l(T,(0,t._)`[${L}]`)}e.reportError=s;function o(v,f=e.keywordError,$){const{it:E}=v,{gen:T,compositeRule:k,allErrors:x}=E,M=h(v,f,$);c(T,M),k||x||l(E,n.default.vErrors)}e.reportExtraError=o;function a(v,f){v.assign(n.default.errors,f),v.if((0,t._)`${n.default.vErrors} !== null`,()=>v.if(f,()=>v.assign((0,t._)`${n.default.vErrors}.length`,f),()=>v.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:v,keyword:f,schemaValue:$,data:E,errsCount:T,it:k}){if(T===void 0)throw new Error("ajv implementation error");const x=v.name("err");v.forRange("i",T,n.default.errors,M=>{v.const(x,(0,t._)`${n.default.vErrors}[${M}]`),v.if((0,t._)`${x}.instancePath === undefined`,()=>v.assign((0,t._)`${x}.instancePath`,(0,t.strConcat)(n.default.instancePath,k.errorPath))),v.assign((0,t._)`${x}.schemaPath`,(0,t.str)`${k.errSchemaPath}/${f}`),k.opts.verbose&&(v.assign((0,t._)`${x}.schema`,$),v.assign((0,t._)`${x}.data`,E))})}e.extendErrors=i;function c(v,f){const $=v.const("err",f);v.if((0,t._)`${n.default.vErrors} === null`,()=>v.assign(n.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${n.default.vErrors}.push(${$})`),v.code((0,t._)`${n.default.errors}++`)}function l(v,f){const{gen:$,validateName:E,schemaEnv:T}=v;T.$async?$.throw((0,t._)`new ${v.ValidationError}(${f})`):($.assign((0,t._)`${E}.errors`,f),$.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function h(v,f,$){const{createErrors:E}=v.it;return E===!1?(0,t._)`{}`:m(v,f,$)}function m(v,f,$={}){const{gen:E,it:T}=v,k=[g(T,$),y(v,$)];return _(v,f,k),E.object(...k)}function g({errorPath:v},{instancePath:f}){const $=f?(0,t.str)`${v}${(0,r.getErrorPath)(f,r.Type.Str)}`:v;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function y({keyword:v,it:{errSchemaPath:f}},{schemaPath:$,parentSchema:E}){let T=E?f:(0,t.str)`${f}/${v}`;return $&&(T=(0,t.str)`${T}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,T]}function _(v,{params:f,message:$},E){const{keyword:T,data:k,schemaValue:x,it:M}=v,{opts:L,propertyName:F,topSchemaRef:V,schemaPath:Z}=M;E.push([d.keyword,T],[d.params,typeof f=="function"?f(v):f||(0,t._)`{}`]),L.messages&&E.push([d.message,typeof $=="function"?$(v):$]),L.verbose&&E.push([d.schema,x],[d.parentSchema,(0,t._)`${V}${Z}`],[n.default.data,k]),F&&E.push([d.propertyName,F])}})(Tn);var Qc;function $$(){if(Qc)return Yt;Qc=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.boolOrEmptySchema=Yt.topBoolOrEmptySchema=void 0;const e=Tn,t=ge,r=Tt,n={message:"boolean schema is false"};function s(i){const{gen:c,schema:l,validateName:d}=i;l===!1?a(i,!1):typeof l=="object"&&l.$async===!0?c.return(r.default.data):(c.assign((0,t._)`${d}.errors`,null),c.return(!0))}Yt.topBoolOrEmptySchema=s;function o(i,c){const{gen:l,schema:d}=i;d===!1?(l.var(c,!1),a(i)):l.var(c,!0)}Yt.boolOrEmptySchema=o;function a(i,c){const{gen:l,data:d}=i,h={gen:l,keyword:"false schema",data:d,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:i};(0,e.reportError)(h,n,void 0,c)}return Yt}var qe={},dr={};Object.defineProperty(dr,"__esModule",{value:!0});dr.getRules=dr.isJSONType=void 0;const w$=["string","number","integer","boolean","null","object","array"],b$=new Set(w$);function S$(e){return typeof e=="string"&&b$.has(e)}dr.isJSONType=S$;function E$(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}dr.getRules=E$;var It={};Object.defineProperty(It,"__esModule",{value:!0});It.shouldUseRule=It.shouldUseGroup=It.schemaHasRulesForType=void 0;function k$({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&vd(e,n)}It.schemaHasRulesForType=k$;function vd(e,t){return t.rules.some(r=>$d(e,r))}It.shouldUseGroup=vd;function $d(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}It.shouldUseRule=$d;Object.defineProperty(qe,"__esModule",{value:!0});qe.reportTypeError=qe.checkDataTypes=qe.checkDataType=qe.coerceAndCheckDataType=qe.getJSONTypes=qe.getSchemaTypes=qe.DataType=void 0;const P$=dr,R$=It,T$=Tn,ue=ge,wd=J;var Tr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Tr||(qe.DataType=Tr={}));function C$(e){const t=bd(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}qe.getSchemaTypes=C$;function bd(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(P$.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}qe.getJSONTypes=bd;function j$(e,t){const{gen:r,data:n,opts:s}=e,o=N$(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,R$.schemaHasRulesForType)(e,t[0]));if(a){const i=La(t,n,s.strictNumbers,Tr.Wrong);r.if(i,()=>{o.length?I$(e,t,o):Va(e)})}return a}qe.coerceAndCheckDataType=j$;const Sd=new Set(["string","number","integer","boolean","null"]);function N$(e,t){return t?e.filter(r=>Sd.has(r)||t==="array"&&r==="array"):[]}function I$(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,ue._)`typeof ${s}`),i=n.let("coerced",(0,ue._)`undefined`);o.coerceTypes==="array"&&n.if((0,ue._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,ue._)`${s}[0]`).assign(a,(0,ue._)`typeof ${s}`).if(La(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,ue._)`${i} !== undefined`);for(const l of r)(Sd.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Va(e),n.endIf(),n.if((0,ue._)`${i} !== undefined`,()=>{n.assign(s,i),O$(e,i)});function c(l){switch(l){case"string":n.elseIf((0,ue._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,ue._)`"" + ${s}`).elseIf((0,ue._)`${s} === null`).assign(i,(0,ue._)`""`);return;case"number":n.elseIf((0,ue._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,ue._)`+${s}`);return;case"integer":n.elseIf((0,ue._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,ue._)`+${s}`);return;case"boolean":n.elseIf((0,ue._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,ue._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,ue._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,ue._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,ue._)`[${s}]`)}}}function O$({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ue._)`${t} !== undefined`,()=>e.assign((0,ue._)`${t}[${r}]`,n))}function Ro(e,t,r,n=Tr.Correct){const s=n===Tr.Correct?ue.operators.EQ:ue.operators.NEQ;let o;switch(e){case"null":return(0,ue._)`${t} ${s} null`;case"array":o=(0,ue._)`Array.isArray(${t})`;break;case"object":o=(0,ue._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,ue._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,ue._)`typeof ${t} ${s} ${e}`}return n===Tr.Correct?o:(0,ue.not)(o);function a(i=ue.nil){return(0,ue.and)((0,ue._)`typeof ${t} == "number"`,i,r?(0,ue._)`isFinite(${t})`:ue.nil)}}qe.checkDataType=Ro;function La(e,t,r,n){if(e.length===1)return Ro(e[0],t,r,n);let s;const o=(0,wd.toHash)(e);if(o.array&&o.object){const a=(0,ue._)`typeof ${t} != "object"`;s=o.null?a:(0,ue._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=ue.nil;o.number&&delete o.integer;for(const a in o)s=(0,ue.and)(s,Ro(a,t,r,n));return s}qe.checkDataTypes=La;const x$={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ue._)`{type: ${e}}`:(0,ue._)`{type: ${t}}`};function Va(e){const t=A$(e);(0,T$.reportError)(t,x$)}qe.reportTypeError=Va;function A$(e){const{gen:t,data:r,schema:n}=e,s=(0,wd.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Gr={},Yc;function M$(){if(Yc)return Gr;Yc=1,Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.assignDefaults=void 0;const e=ge,t=J;function r(s,o){const{properties:a,items:i}=s.schema;if(o==="object"&&a)for(const c in a)n(s,c,a[c].default);else o==="array"&&Array.isArray(i)&&i.forEach((c,l)=>n(s,l,c.default))}Gr.assignDefaults=r;function n(s,o,a){const{gen:i,compositeRule:c,data:l,opts:d}=s;if(a===void 0)return;const h=(0,e._)`${l}${(0,e.getProperty)(o)}`;if(c){(0,t.checkStrictMode)(s,`default is ignored for: ${h}`);return}let m=(0,e._)`${h} === undefined`;d.useDefaults==="empty"&&(m=(0,e._)`${m} || ${h} === null || ${h} === ""`),i.if(m,(0,e._)`${h} = ${(0,e.stringify)(a)}`)}return Gr}var gt={},pe={};Object.defineProperty(pe,"__esModule",{value:!0});pe.validateUnion=pe.validateArray=pe.usePattern=pe.callValidateCode=pe.schemaProperties=pe.allSchemaProperties=pe.noPropertyInData=pe.propertyInData=pe.isOwnProperty=pe.hasPropFunc=pe.reportMissingProp=pe.checkMissingProp=pe.checkReportMissingProp=void 0;const Pe=ge,Ha=J,At=Tt,z$=J;function q$(e,t){const{gen:r,data:n,it:s}=e;r.if(Ka(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Pe._)`${t}`},!0),e.error()})}pe.checkReportMissingProp=q$;function D$({gen:e,data:t,it:{opts:r}},n,s){return(0,Pe.or)(...n.map(o=>(0,Pe.and)(Ka(e,t,o,r.ownProperties),(0,Pe._)`${s} = ${o}`)))}pe.checkMissingProp=D$;function U$(e,t){e.setParams({missingProperty:t},!0),e.error()}pe.reportMissingProp=U$;function Ed(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Pe._)`Object.prototype.hasOwnProperty`})}pe.hasPropFunc=Ed;function Za(e,t,r){return(0,Pe._)`${Ed(e)}.call(${t}, ${r})`}pe.isOwnProperty=Za;function F$(e,t,r,n){const s=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} !== undefined`;return n?(0,Pe._)`${s} && ${Za(e,t,r)}`:s}pe.propertyInData=F$;function Ka(e,t,r,n){const s=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} === undefined`;return n?(0,Pe.or)(s,(0,Pe.not)(Za(e,t,r))):s}pe.noPropertyInData=Ka;function kd(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}pe.allSchemaProperties=kd;function L$(e,t){return kd(t).filter(r=>!(0,Ha.alwaysValidSchema)(e,t[r]))}pe.schemaProperties=L$;function V$({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Pe._)`${e}, ${t}, ${n}${s}`:t,h=[[At.default.instancePath,(0,Pe.strConcat)(At.default.instancePath,o)],[At.default.parentData,a.parentData],[At.default.parentDataProperty,a.parentDataProperty],[At.default.rootData,At.default.rootData]];a.opts.dynamicRef&&h.push([At.default.dynamicAnchors,At.default.dynamicAnchors]);const m=(0,Pe._)`${d}, ${r.object(...h)}`;return c!==Pe.nil?(0,Pe._)`${i}.call(${c}, ${m})`:(0,Pe._)`${i}(${m})`}pe.callValidateCode=V$;const H$=(0,Pe._)`new RegExp`;function Z$({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Pe._)`${s.code==="new RegExp"?H$:(0,z$.useFunc)(e,s)}(${r}, ${n})`})}pe.usePattern=Z$;function K$(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,Pe._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Ha.Type.Num},o),t.if((0,Pe.not)(o),i)})}}pe.validateArray=K$;function G$(e){const{gen:t,schema:r,keyword:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Ha.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,Pe._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Pe.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}pe.validateUnion=G$;var Xc;function W$(){if(Xc)return gt;Xc=1,Object.defineProperty(gt,"__esModule",{value:!0}),gt.validateKeywordUsage=gt.validSchemaType=gt.funcKeywordCode=gt.macroKeywordCode=void 0;const e=ge,t=Tt,r=pe,n=Tn;function s(m,g){const{gen:y,keyword:_,schema:v,parentSchema:f,it:$}=m,E=g.macro.call($.self,v,f,$),T=l(y,_,E);$.opts.validateSchema!==!1&&$.self.validateSchema(E,!0);const k=y.name("valid");m.subschema({schema:E,schemaPath:e.nil,errSchemaPath:`${$.errSchemaPath}/${_}`,topSchemaRef:T,compositeRule:!0},k),m.pass(k,()=>m.error(!0))}gt.macroKeywordCode=s;function o(m,g){var y;const{gen:_,keyword:v,schema:f,parentSchema:$,$data:E,it:T}=m;c(T,g);const k=!E&&g.compile?g.compile.call(T.self,f,$,T):g.validate,x=l(_,v,k),M=_.let("valid");m.block$data(M,L),m.ok((y=g.valid)!==null&&y!==void 0?y:M);function L(){if(g.errors===!1)Z(),g.modifying&&a(m),B(()=>m.error());else{const re=g.async?F():V();g.modifying&&a(m),B(()=>i(m,re))}}function F(){const re=_.let("ruleErrs",null);return _.try(()=>Z((0,e._)`await `),H=>_.assign(M,!1).if((0,e._)`${H} instanceof ${T.ValidationError}`,()=>_.assign(re,(0,e._)`${H}.errors`),()=>_.throw(H))),re}function V(){const re=(0,e._)`${x}.errors`;return _.assign(re,null),Z(e.nil),re}function Z(re=g.async?(0,e._)`await `:e.nil){const H=T.opts.passContext?t.default.this:t.default.self,ie=!("compile"in g&&!E||g.schema===!1);_.assign(M,(0,e._)`${re}${(0,r.callValidateCode)(m,x,H,ie)}`,g.modifying)}function B(re){var H;_.if((0,e.not)((H=g.valid)!==null&&H!==void 0?H:M),re)}}gt.funcKeywordCode=o;function a(m){const{gen:g,data:y,it:_}=m;g.if(_.parentData,()=>g.assign(y,(0,e._)`${_.parentData}[${_.parentDataProperty}]`))}function i(m,g){const{gen:y}=m;y.if((0,e._)`Array.isArray(${g})`,()=>{y.assign(t.default.vErrors,(0,e._)`${t.default.vErrors} === null ? ${g} : ${t.default.vErrors}.concat(${g})`).assign(t.default.errors,(0,e._)`${t.default.vErrors}.length`),(0,n.extendErrors)(m)},()=>m.error())}function c({schemaEnv:m},g){if(g.async&&!m.$async)throw new Error("async keyword in sync schema")}function l(m,g,y){if(y===void 0)throw new Error(`keyword "${g}" failed to compile`);return m.scopeValue("keyword",typeof y=="function"?{ref:y}:{ref:y,code:(0,e.stringify)(y)})}function d(m,g,y=!1){return!g.length||g.some(_=>_==="array"?Array.isArray(m):_==="object"?m&&typeof m=="object"&&!Array.isArray(m):typeof m==_||y&&typeof m>"u")}gt.validSchemaType=d;function h({schema:m,opts:g,self:y,errSchemaPath:_},v,f){if(Array.isArray(v.keyword)?!v.keyword.includes(f):v.keyword!==f)throw new Error("ajv implementation error");const $=v.dependencies;if($!=null&&$.some(E=>!Object.prototype.hasOwnProperty.call(m,E)))throw new Error(`parent schema must have dependencies of ${f}: ${$.join(",")}`);if(v.validateSchema&&!v.validateSchema(m[f])){const T=`keyword "${f}" value is invalid at path "${_}": `+y.errorsText(v.validateSchema.errors);if(g.validateSchema==="log")y.logger.error(T);else throw new Error(T)}}return gt.validateKeywordUsage=h,gt}var Nt={},el;function B$(){if(el)return Nt;el=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.extendSubschemaMode=Nt.extendSubschemaData=Nt.getSubschema=void 0;const e=ge,t=J;function r(o,{keyword:a,schemaProp:i,schema:c,schemaPath:l,errSchemaPath:d,topSchemaRef:h}){if(a!==void 0&&c!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(a!==void 0){const m=o.schema[a];return i===void 0?{schema:m,schemaPath:(0,e._)`${o.schemaPath}${(0,e.getProperty)(a)}`,errSchemaPath:`${o.errSchemaPath}/${a}`}:{schema:m[i],schemaPath:(0,e._)`${o.schemaPath}${(0,e.getProperty)(a)}${(0,e.getProperty)(i)}`,errSchemaPath:`${o.errSchemaPath}/${a}/${(0,t.escapeFragment)(i)}`}}if(c!==void 0){if(l===void 0||d===void 0||h===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:l,topSchemaRef:h,errSchemaPath:d}}throw new Error('either "keyword" or "schema" must be passed')}Nt.getSubschema=r;function n(o,a,{dataProp:i,dataPropType:c,data:l,dataTypes:d,propertyName:h}){if(l!==void 0&&i!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:m}=a;if(i!==void 0){const{errorPath:y,dataPathArr:_,opts:v}=a,f=m.let("data",(0,e._)`${a.data}${(0,e.getProperty)(i)}`,!0);g(f),o.errorPath=(0,e.str)`${y}${(0,t.getErrorPath)(i,c,v.jsPropertySyntax)}`,o.parentDataProperty=(0,e._)`${i}`,o.dataPathArr=[..._,o.parentDataProperty]}if(l!==void 0){const y=l instanceof e.Name?l:m.let("data",l,!0);g(y),h!==void 0&&(o.propertyName=h)}d&&(o.dataTypes=d);function g(y){o.data=y,o.dataLevel=a.dataLevel+1,o.dataTypes=[],a.definedProperties=new Set,o.parentData=a.data,o.dataNames=[...a.dataNames,y]}}Nt.extendSubschemaData=n;function s(o,{jtdDiscriminator:a,jtdMetadata:i,compositeRule:c,createErrors:l,allErrors:d}){c!==void 0&&(o.compositeRule=c),l!==void 0&&(o.createErrors=l),d!==void 0&&(o.allErrors=d),o.jtdDiscriminator=a,o.jtdMetadata=i}return Nt.extendSubschemaMode=s,Nt}var Ge={},zs=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!e(t[s],r[s]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var a=o[s];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r},Pd={exports:{}},Lt=Pd.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};Qn(t,n,s,e,"",e)};Lt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Lt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Lt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Lt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Qn(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var h=n[d];if(Array.isArray(h)){if(d in Lt.arrayKeywords)for(var m=0;mt+=Rd(n)),t===1/0))return 1/0}return t}function Td(e,t="",r){r!==!1&&(t=Cr(t));const n=e.parse(t);return Cd(e,n)}Ge.getFullPath=Td;function Cd(e,t){return e.serialize(t).split("#")[0]+"#"}Ge._getFullPath=Cd;const sw=/#\/?$/;function Cr(e){return e?e.replace(sw,""):""}Ge.normalizeId=Cr;function ow(e,t,r){return r=Cr(r),e.resolve(t,r)}Ge.resolveUrl=ow;const aw=/^[a-z_][-a-z0-9._]*$/i;function iw(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Cr(e[r]||t),o={"":s},a=Td(n,s,!1),i={},c=new Set;return ew(e,{allKeys:!0},(h,m,g,y)=>{if(y===void 0)return;const _=a+m;let v=o[y];typeof h[r]=="string"&&(v=f.call(this,h[r])),$.call(this,h.$anchor),$.call(this,h.$dynamicAnchor),o[m]=v;function f(E){const T=this.opts.uriResolver.resolve;if(E=Cr(v?T(v,E):E),c.has(E))throw d(E);c.add(E);let k=this.refs[E];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?l(h,k.schema,E):E!==Cr(_)&&(E[0]==="#"?(l(h,i[E],E),i[E]=h):this.refs[E]=_),E}function $(E){if(typeof E=="string"){if(!aw.test(E))throw new Error(`invalid anchor "${E}"`);f.call(this,`#${E}`)}}}),i;function l(h,m,g){if(m!==void 0&&!X$(h,m))throw d(g)}function d(h){return new Error(`reference "${h}" resolves to more than one schema`)}}Ge.getSchemaRefs=iw;var tl;function qs(){if(tl)return jt;tl=1,Object.defineProperty(jt,"__esModule",{value:!0}),jt.getData=jt.KeywordCxt=jt.validateFunctionCode=void 0;const e=$$(),t=qe,r=It,n=qe,s=M$(),o=W$(),a=B$(),i=ge,c=Tt,l=Ge,d=J,h=Tn;function m(j){if(k(j)&&(M(j),T(j))){v(j);return}g(j,()=>(0,e.topBoolOrEmptySchema)(j))}jt.validateFunctionCode=m;function g({gen:j,validateName:I,schema:U,schemaEnv:W,opts:ee},ce){ee.code.es5?j.func(I,(0,i._)`${c.default.data}, ${c.default.valCxt}`,W.$async,()=>{j.code((0,i._)`"use strict"; ${$(U,ee)}`),_(j,ee),j.code(ce)}):j.func(I,(0,i._)`${c.default.data}, ${y(ee)}`,W.$async,()=>j.code($(U,ee)).code(ce))}function y(j){return(0,i._)`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${j.dynamicRef?(0,i._)`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}function _(j,I){j.if(c.default.valCxt,()=>{j.var(c.default.instancePath,(0,i._)`${c.default.valCxt}.${c.default.instancePath}`),j.var(c.default.parentData,(0,i._)`${c.default.valCxt}.${c.default.parentData}`),j.var(c.default.parentDataProperty,(0,i._)`${c.default.valCxt}.${c.default.parentDataProperty}`),j.var(c.default.rootData,(0,i._)`${c.default.valCxt}.${c.default.rootData}`),I.dynamicRef&&j.var(c.default.dynamicAnchors,(0,i._)`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{j.var(c.default.instancePath,(0,i._)`""`),j.var(c.default.parentData,(0,i._)`undefined`),j.var(c.default.parentDataProperty,(0,i._)`undefined`),j.var(c.default.rootData,c.default.data),I.dynamicRef&&j.var(c.default.dynamicAnchors,(0,i._)`{}`)})}function v(j){const{schema:I,opts:U,gen:W}=j;g(j,()=>{U.$comment&&I.$comment&&re(j),V(j),W.let(c.default.vErrors,null),W.let(c.default.errors,0),U.unevaluated&&f(j),L(j),H(j)})}function f(j){const{gen:I,validateName:U}=j;j.evaluated=I.const("evaluated",(0,i._)`${U}.evaluated`),I.if((0,i._)`${j.evaluated}.dynamicProps`,()=>I.assign((0,i._)`${j.evaluated}.props`,(0,i._)`undefined`)),I.if((0,i._)`${j.evaluated}.dynamicItems`,()=>I.assign((0,i._)`${j.evaluated}.items`,(0,i._)`undefined`))}function $(j,I){const U=typeof j=="object"&&j[I.schemaId];return U&&(I.code.source||I.code.process)?(0,i._)`/*# sourceURL=${U} */`:i.nil}function E(j,I){if(k(j)&&(M(j),T(j))){x(j,I);return}(0,e.boolOrEmptySchema)(j,I)}function T({schema:j,self:I}){if(typeof j=="boolean")return!j;for(const U in j)if(I.RULES.all[U])return!0;return!1}function k(j){return typeof j.schema!="boolean"}function x(j,I){const{schema:U,gen:W,opts:ee}=j;ee.$comment&&U.$comment&&re(j),Z(j),B(j);const ce=W.const("_errs",c.default.errors);L(j,ce),W.var(I,(0,i._)`${ce} === ${c.default.errors}`)}function M(j){(0,d.checkUnknownRules)(j),F(j)}function L(j,I){if(j.opts.jtd)return ke(j,[],!1,I);const U=(0,t.getSchemaTypes)(j.schema),W=(0,t.coerceAndCheckDataType)(j,U);ke(j,U,!W,I)}function F(j){const{schema:I,errSchemaPath:U,opts:W,self:ee}=j;I.$ref&&W.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(I,ee.RULES)&&ee.logger.warn(`$ref: keywords ignored in schema at path "${U}"`)}function V(j){const{schema:I,opts:U}=j;I.default!==void 0&&U.useDefaults&&U.strictSchema&&(0,d.checkStrictMode)(j,"default is ignored in the schema root")}function Z(j){const I=j.schema[j.opts.schemaId];I&&(j.baseId=(0,l.resolveUrl)(j.opts.uriResolver,j.baseId,I))}function B(j){if(j.schema.$async&&!j.schemaEnv.$async)throw new Error("async schema in sync schema")}function re({gen:j,schemaEnv:I,schema:U,errSchemaPath:W,opts:ee}){const ce=U.$comment;if(ee.$comment===!0)j.code((0,i._)`${c.default.self}.logger.log(${ce})`);else if(typeof ee.$comment=="function"){const xe=(0,i.str)`${W}/$comment`,tt=j.scopeValue("root",{ref:I.root});j.code((0,i._)`${c.default.self}.opts.$comment(${ce}, ${xe}, ${tt}.schema)`)}}function H(j){const{gen:I,schemaEnv:U,validateName:W,ValidationError:ee,opts:ce}=j;U.$async?I.if((0,i._)`${c.default.errors} === 0`,()=>I.return(c.default.data),()=>I.throw((0,i._)`new ${ee}(${c.default.vErrors})`)):(I.assign((0,i._)`${W}.errors`,c.default.vErrors),ce.unevaluated&&ie(j),I.return((0,i._)`${c.default.errors} === 0`))}function ie({gen:j,evaluated:I,props:U,items:W}){U instanceof i.Name&&j.assign((0,i._)`${I}.props`,U),W instanceof i.Name&&j.assign((0,i._)`${I}.items`,W)}function ke(j,I,U,W){const{gen:ee,schema:ce,data:xe,allErrors:tt,opts:Fe,self:Le}=j,{RULES:Ae}=Le;if(ce.$ref&&(Fe.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(ce,Ae))){ee.block(()=>q(j,"$ref",Ae.all.$ref.definition));return}Fe.jtd||ct(j,I),ee.block(()=>{for(const Ye of Ae.rules)Et(Ye);Et(Ae.post)});function Et(Ye){(0,r.shouldUseGroup)(ce,Ye)&&(Ye.type?(ee.if((0,n.checkDataType)(Ye.type,xe,Fe.strictNumbers)),ye(j,Ye),I.length===1&&I[0]===Ye.type&&U&&(ee.else(),(0,n.reportTypeError)(j)),ee.endIf()):ye(j,Ye),tt||ee.if((0,i._)`${c.default.errors} === ${W||0}`))}}function ye(j,I){const{gen:U,schema:W,opts:{useDefaults:ee}}=j;ee&&(0,s.assignDefaults)(j,I.type),U.block(()=>{for(const ce of I.rules)(0,r.shouldUseRule)(W,ce)&&q(j,ce.keyword,ce.definition,I.type)})}function ct(j,I){j.schemaEnv.meta||!j.opts.strictTypes||(Oe(j,I),j.opts.allowUnionTypes||O(j,I),w(j,j.dataTypes))}function Oe(j,I){if(I.length){if(!j.dataTypes.length){j.dataTypes=I;return}I.forEach(U=>{S(j.dataTypes,U)||p(j,`type "${U}" not allowed by context "${j.dataTypes.join(",")}"`)}),u(j,I)}}function O(j,I){I.length>1&&!(I.length===2&&I.includes("null"))&&p(j,"use allowUnionTypes to allow union type keyword")}function w(j,I){const U=j.self.RULES.all;for(const W in U){const ee=U[W];if(typeof ee=="object"&&(0,r.shouldUseRule)(j.schema,ee)){const{type:ce}=ee.definition;ce.length&&!ce.some(xe=>C(I,xe))&&p(j,`missing type "${ce.join(",")}" for keyword "${W}"`)}}}function C(j,I){return j.includes(I)||I==="number"&&j.includes("integer")}function S(j,I){return j.includes(I)||I==="integer"&&j.includes("number")}function u(j,I){const U=[];for(const W of j.dataTypes)S(I,W)?U.push(W):I.includes("integer")&&W==="number"&&U.push("integer");j.dataTypes=U}function p(j,I){const U=j.schemaEnv.baseId+j.errSchemaPath;I+=` at "${U}" (strictTypes)`,(0,d.checkStrictMode)(j,I,j.opts.strictTypes)}class P{constructor(I,U,W){if((0,o.validateKeywordUsage)(I,U,W),this.gen=I.gen,this.allErrors=I.allErrors,this.keyword=W,this.data=I.data,this.schema=I.schema[W],this.$data=U.$data&&I.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(I,this.schema,W,this.$data),this.schemaType=U.schemaType,this.parentSchema=I.schema,this.params={},this.it=I,this.def=U,this.$data)this.schemaCode=I.gen.const("vSchema",Y(this.$data,I));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,U.schemaType,U.allowUndefined))throw new Error(`${W} value must be ${JSON.stringify(U.schemaType)}`);("code"in U?U.trackErrors:U.errors!==!1)&&(this.errsCount=I.gen.const("_errs",c.default.errors))}result(I,U,W){this.failResult((0,i.not)(I),U,W)}failResult(I,U,W){this.gen.if(I),W?W():this.error(),U?(this.gen.else(),U(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(I,U){this.failResult((0,i.not)(I),void 0,U)}fail(I){if(I===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(I),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(I){if(!this.$data)return this.fail(I);const{schemaCode:U}=this;this.fail((0,i._)`${U} !== undefined && (${(0,i.or)(this.invalid$data(),I)})`)}error(I,U,W){if(U){this.setParams(U),this._error(I,W),this.setParams({});return}this._error(I,W)}_error(I,U){(I?h.reportExtraError:h.reportError)(this,this.def.error,U)}$dataError(){(0,h.reportError)(this,this.def.$dataError||h.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,h.resetErrorsCount)(this.gen,this.errsCount)}ok(I){this.allErrors||this.gen.if(I)}setParams(I,U){U?Object.assign(this.params,I):this.params=I}block$data(I,U,W=i.nil){this.gen.block(()=>{this.check$data(I,W),U()})}check$data(I=i.nil,U=i.nil){if(!this.$data)return;const{gen:W,schemaCode:ee,schemaType:ce,def:xe}=this;W.if((0,i.or)((0,i._)`${ee} === undefined`,U)),I!==i.nil&&W.assign(I,!0),(ce.length||xe.validateSchema)&&(W.elseIf(this.invalid$data()),this.$dataError(),I!==i.nil&&W.assign(I,!1)),W.else()}invalid$data(){const{gen:I,schemaCode:U,schemaType:W,def:ee,it:ce}=this;return(0,i.or)(xe(),tt());function xe(){if(W.length){if(!(U instanceof i.Name))throw new Error("ajv implementation error");const Fe=Array.isArray(W)?W:[W];return(0,i._)`${(0,n.checkDataTypes)(Fe,U,ce.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}function tt(){if(ee.validateSchema){const Fe=I.scopeValue("validate$data",{ref:ee.validateSchema});return(0,i._)`!${Fe}(${U})`}return i.nil}}subschema(I,U){const W=(0,a.getSubschema)(this.it,I);(0,a.extendSubschemaData)(W,this.it,I),(0,a.extendSubschemaMode)(W,I);const ee={...this.it,...W,items:void 0,props:void 0};return E(ee,U),ee}mergeEvaluated(I,U){const{it:W,gen:ee}=this;W.opts.unevaluated&&(W.props!==!0&&I.props!==void 0&&(W.props=d.mergeEvaluated.props(ee,I.props,W.props,U)),W.items!==!0&&I.items!==void 0&&(W.items=d.mergeEvaluated.items(ee,I.items,W.items,U)))}mergeValidEvaluated(I,U){const{it:W,gen:ee}=this;if(W.opts.unevaluated&&(W.props!==!0||W.items!==!0))return ee.if(U,()=>this.mergeEvaluated(I,i.Name)),!0}}jt.KeywordCxt=P;function q(j,I,U,W){const ee=new P(j,U,I);"code"in U?U.code(ee,W):ee.$data&&U.validate?(0,o.funcKeywordCode)(ee,U):"macro"in U?(0,o.macroKeywordCode)(ee,U):(U.compile||U.validate)&&(0,o.funcKeywordCode)(ee,U)}const D=/^\/(?:[^~]|~0|~1)*$/,X=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Y(j,{dataLevel:I,dataNames:U,dataPathArr:W}){let ee,ce;if(j==="")return c.default.rootData;if(j[0]==="/"){if(!D.test(j))throw new Error(`Invalid JSON-pointer: ${j}`);ee=j,ce=c.default.rootData}else{const Le=X.exec(j);if(!Le)throw new Error(`Invalid JSON-pointer: ${j}`);const Ae=+Le[1];if(ee=Le[2],ee==="#"){if(Ae>=I)throw new Error(Fe("property/index",Ae));return W[I-Ae]}if(Ae>I)throw new Error(Fe("data",Ae));if(ce=U[I-Ae],!ee)return ce}let xe=ce;const tt=ee.split("/");for(const Le of tt)Le&&(ce=(0,i._)`${ce}${(0,i.getProperty)((0,d.unescapeJsonPointer)(Le))}`,xe=(0,i._)`${xe} && ${ce}`);return xe;function Fe(Le,Ae){return`Cannot access ${Le} ${Ae} levels up, current level is ${I}`}}return jt.getData=Y,jt}var zn={},rl;function Ga(){if(rl)return zn;rl=1,Object.defineProperty(zn,"__esModule",{value:!0});class e extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return zn.default=e,zn}var qr={};Object.defineProperty(qr,"__esModule",{value:!0});const Xs=Ge;let cw=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Xs.resolveUrl)(t,r,n),this.missingSchema=(0,Xs.normalizeId)((0,Xs.getFullPath)(t,this.missingRef))}};qr.default=cw;var ot={};Object.defineProperty(ot,"__esModule",{value:!0});ot.resolveSchema=ot.getCompilingSchema=ot.resolveRef=ot.compileSchema=ot.SchemaEnv=void 0;const _t=ge,lw=Ga(),Xt=Tt,wt=Ge,nl=J,uw=qs();let Ds=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,wt.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}};ot.SchemaEnv=Ds;function Wa(e){const t=jd.call(this,e);if(t)return t;const r=(0,wt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new _t.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:lw.default,code:(0,_t._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:Xt.default.data,parentData:Xt.default.parentData,parentDataProperty:Xt.default.parentDataProperty,dataNames:[Xt.default.data],dataPathArr:[_t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,_t.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:_t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,_t._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,uw.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const h=a.toString();d=`${a.scopeRefs(Xt.default.scope)}return ${h}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const g=new Function(`${Xt.default.self}`,`${Xt.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:g}),g.errors=null,g.schema=e.schema,g.schemaEnv=e,e.$async&&(g.$async=!0),this.opts.code.source===!0&&(g.source={validateName:c,validateCode:h,scopeValues:a._values}),this.opts.unevaluated){const{props:y,items:_}=l;g.evaluated={props:y instanceof _t.Name?void 0:y,items:_ instanceof _t.Name?void 0:_,dynamicProps:y instanceof _t.Name,dynamicItems:_ instanceof _t.Name},g.source&&(g.source.evaluated=(0,_t.stringify)(g.evaluated))}return e.validate=g,e}catch(h){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),h}finally{this._compilations.delete(e)}}ot.compileSchema=Wa;function dw(e,t,r){var n;r=(0,wt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=pw.call(this,e,r);if(o===void 0){const a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new Ds({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=fw.call(this,o)}ot.resolveRef=dw;function fw(e){return(0,wt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Wa.call(this,e)}function jd(e){for(const t of this._compilations)if(hw(t,e))return t}ot.getCompilingSchema=jd;function hw(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function pw(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Us.call(this,e,t)}function Us(e,t){const r=this.opts.uriResolver.parse(t),n=(0,wt._getFullPath)(this.opts.uriResolver,r);let s=(0,wt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return eo.call(this,r,e);const o=(0,wt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Us.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:eo.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Wa.call(this,a),o===(0,wt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,wt.resolveUrl)(this.opts.uriResolver,s,l)),new Ds({schema:i,schemaId:c,root:e,baseId:s})}return eo.call(this,r,a)}}ot.resolveSchema=Us;const mw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function eo(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(const i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;const c=r[(0,nl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!mw.has(i)&&l&&(t=(0,wt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,nl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,wt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Us.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Ds({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const gw="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",_w="Meta-schema for $data reference (JSON AnySchema extension proposal)",yw="object",vw=["$data"],$w={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},ww=!1,bw={$id:gw,description:_w,type:yw,required:vw,properties:$w,additionalProperties:ww};var Ba={},Fs={exports:{}};const Sw=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Nd=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),Ja=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Id=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Ew=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Od(e){let t="",r=0,n=0;for(n=0;n=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}const kw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function sl(e){return e.length=0,!0}function Pw(e,t,r){if(e.length){const n=Od(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function Rw(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=Pw;for(let c=0;c7){r.error=!0;break}c>0&&e[c-1]===":"&&(o=!0),n.push(":");continue}else if(l==="%"){if(!i(s,n,r))break;i=sl}else{s.push(l);continue}}return s.length&&(i===sl?r.zone=s.join(""):a?n.push(s.join("")):n.push(Od(s))),r.address=n.join(""),r}function xd(e){if(Tw(e,":")<2)return{host:e,isIPV6:!1};const t=Rw(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:n}}}function Tw(e,t){let r=0;for(let n=0;njw[n])}function Ow(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function hs(e,t){const r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let s=!1,o=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);const a=e.match(l0);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match(u0);if(i!==null){const l=i[1],d=l.replace(/[\t\n\r]/g,"");d.length>=2&&(d.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",s=!0):l.length!==d.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",s=!0))}const c=e.match(c0);if(c){n.scheme=c[1],n.userinfo=c[3],n.host=c[4],n.port=parseInt(c[5],10),n.path=c[6]||"",n.query=c[7],n.fragment=c[8],isNaN(n.port)&&(n.port=c[5]);const l=d0(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(r0(n.host)===!1){const m=Jw(n.host);n.host=m.host.toLowerCase(),o=m.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");const d=Fd(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&n0(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(h){n.error=n.error||"Host's domain name can not be converted to ASCII: "+h}if((!d||d&&!d.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=t0(unescape(n.host),o))),n.path&&(n.path=Xw(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}d&&d.parse&&d.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:s}}function ps(e,t){return hs(e,t).parsed}function f0(e,t){return Vd(e,t).normalized}function Vd(e,t){const{parsed:r,malformedAuthorityOrPort:n}=hs(e,t);return{normalized:n?e:fr(r,t),malformedAuthorityOrPort:n}}function ol(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=Vd(e,t);return n?void 0:r}if(typeof e=="object")return fr(e,t)}const Ya={SCHEMES:s0,normalize:o0,resolve:a0,resolveComponent:Ld,equal:i0,serialize:fr,parse:ps};Fs.exports=Ya;Fs.exports.default=Ya;Fs.exports.fastUri=Ya;var Hd=Fs.exports;Object.defineProperty(Ba,"__esModule",{value:!0});const Zd=Hd;Zd.code='require("ajv/dist/runtime/uri").default';Ba.default=Zd;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=qs();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=ge;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Ga(),s=qr,o=dr,a=ot,i=ge,c=Ge,l=qe,d=J,h=bw,m=Ba,g=(O,w)=>new RegExp(O,w);g.code="new RegExp";const y=["removeAdditional","useDefaults","coerceTypes"],_=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),v={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},f={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function E(O){var w,C,S,u,p,P,q,D,X,Y,j,I,U,W,ee,ce,xe,tt,Fe,Le,Ae,Et,Ye,Wt,Bt;const mt=O.strict,Jt=(w=O.code)===null||w===void 0?void 0:w.optimize,Hr=Jt===!0||Jt===void 0?1:Jt||0,Zr=(S=(C=O.code)===null||C===void 0?void 0:C.regExp)!==null&&S!==void 0?S:g,Bs=(u=O.uriResolver)!==null&&u!==void 0?u:m.default;return{strictSchema:(P=(p=O.strictSchema)!==null&&p!==void 0?p:mt)!==null&&P!==void 0?P:!0,strictNumbers:(D=(q=O.strictNumbers)!==null&&q!==void 0?q:mt)!==null&&D!==void 0?D:!0,strictTypes:(Y=(X=O.strictTypes)!==null&&X!==void 0?X:mt)!==null&&Y!==void 0?Y:"log",strictTuples:(I=(j=O.strictTuples)!==null&&j!==void 0?j:mt)!==null&&I!==void 0?I:"log",strictRequired:(W=(U=O.strictRequired)!==null&&U!==void 0?U:mt)!==null&&W!==void 0?W:!1,code:O.code?{...O.code,optimize:Hr,regExp:Zr}:{optimize:Hr,regExp:Zr},loopRequired:(ee=O.loopRequired)!==null&&ee!==void 0?ee:$,loopEnum:(ce=O.loopEnum)!==null&&ce!==void 0?ce:$,meta:(xe=O.meta)!==null&&xe!==void 0?xe:!0,messages:(tt=O.messages)!==null&&tt!==void 0?tt:!0,inlineRefs:(Fe=O.inlineRefs)!==null&&Fe!==void 0?Fe:!0,schemaId:(Le=O.schemaId)!==null&&Le!==void 0?Le:"$id",addUsedSchema:(Ae=O.addUsedSchema)!==null&&Ae!==void 0?Ae:!0,validateSchema:(Et=O.validateSchema)!==null&&Et!==void 0?Et:!0,validateFormats:(Ye=O.validateFormats)!==null&&Ye!==void 0?Ye:!0,unicodeRegExp:(Wt=O.unicodeRegExp)!==null&&Wt!==void 0?Wt:!0,int32range:(Bt=O.int32range)!==null&&Bt!==void 0?Bt:!0,uriResolver:Bs}}class T{constructor(w={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,w=this.opts={...w,...E(w)};const{es5:C,lines:S}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:_,es5:C,lines:S}),this.logger=B(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),k.call(this,v,w,"NOT SUPPORTED"),k.call(this,f,w,"DEPRECATED","warn"),this._metaOpts=V.call(this),w.formats&&L.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&F.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),M.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:S}=this.opts;let u=h;S==="id"&&(u={...h},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[S],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){let S;if(typeof w=="string"){if(S=this.getSchema(w),!S)throw new Error(`no schema with key or ref "${w}"`)}else S=this.compile(w);const u=S(C);return"$async"in S||(this.errors=S.errors),u}compile(w,C){const S=this._addSchema(w,C);return S.validate||this._compileSchemaEnv(S)}compileAsync(w,C){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:S}=this.opts;return u.call(this,w,C);async function u(Y,j){await p.call(this,Y.$schema);const I=this._addSchema(Y,j);return I.validate||P.call(this,I)}async function p(Y){Y&&!this.getSchema(Y)&&await u.call(this,{$ref:Y},!0)}async function P(Y){try{return this._compileSchemaEnv(Y)}catch(j){if(!(j instanceof s.default))throw j;return q.call(this,j),await D.call(this,j.missingSchema),P.call(this,Y)}}function q({missingSchema:Y,missingRef:j}){if(this.refs[Y])throw new Error(`AnySchema ${Y} is loaded but ${j} cannot be resolved`)}async function D(Y){const j=await X.call(this,Y);this.refs[Y]||await p.call(this,j.$schema),this.refs[Y]||this.addSchema(j,Y,C)}async function X(Y){const j=this._loading[Y];if(j)return j;try{return await(this._loading[Y]=S(Y))}finally{delete this._loading[Y]}}}addSchema(w,C,S,u=this.opts.validateSchema){if(Array.isArray(w)){for(const P of w)this.addSchema(P,void 0,S,u);return this}let p;if(typeof w=="object"){const{schemaId:P}=this.opts;if(p=w[P],p!==void 0&&typeof p!="string")throw new Error(`schema ${P} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,S,C,u,!0),this}addMetaSchema(w,C,S=this.opts.validateSchema){return this.addSchema(w,C,!0,S),this}validateSchema(w,C){if(typeof w=="boolean")return!0;let S;if(S=w.$schema,S!==void 0&&typeof S!="string")throw new Error("$schema must be a string");if(S=S||this.opts.defaultMeta||this.defaultMeta(),!S)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(S,w);if(!u&&C){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let C;for(;typeof(C=x.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:S}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:S});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const C=x.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let S=w[this.opts.schemaId];return S&&(S=(0,c.normalizeId)(S),delete this.schemas[S],delete this.refs[S]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const C of w)this.addKeyword(C);return this}addKeyword(w,C){let S;if(typeof w=="string")S=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=S);else if(typeof w=="object"&&C===void 0){if(C=w,S=C.keyword,Array.isArray(S)&&!S.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(H.call(this,S,C),!C)return(0,d.eachItem)(S,p=>ie.call(this,p)),this;ye.call(this,C);const u={...C,type:(0,l.getJSONTypes)(C.type),schemaType:(0,l.getJSONTypes)(C.schemaType)};return(0,d.eachItem)(S,u.type.length===0?p=>ie.call(this,p,u):p=>u.type.forEach(P=>ie.call(this,p,u,P))),this}getKeyword(w){const C=this.RULES.all[w];return typeof C=="object"?C.definition:!!C}removeKeyword(w){const{RULES:C}=this;delete C.keywords[w],delete C.all[w];for(const S of C.rules){const u=S.rules.findIndex(p=>p.keyword===w);u>=0&&S.rules.splice(u,1)}return this}addFormat(w,C){return typeof C=="string"&&(C=new RegExp(C)),this.formats[w]=C,this}errorsText(w=this.errors,{separator:C=", ",dataVar:S="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${S}${u.instancePath} ${u.message}`).reduce((u,p)=>u+C+p)}$dataMetaSchema(w,C){const S=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of C){const p=u.split("/").slice(1);let P=w;for(const q of p)P=P[q];for(const q in S){const D=S[q];if(typeof D!="object")continue;const{$data:X}=D.definition,Y=P[q];X&&Y&&(P[q]=Oe(Y))}}return w}_removeAllSchemas(w,C){for(const S in w){const u=w[S];(!C||C.test(S))&&(typeof u=="string"?delete w[S]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[S]))}}_addSchema(w,C,S,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let P;const{schemaId:q}=this.opts;if(typeof w=="object")P=w[q];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let D=this._cache.get(w);if(D!==void 0)return D;S=(0,c.normalizeId)(P||S);const X=c.getSchemaRefs.call(this,w,S);return D=new a.SchemaEnv({schema:w,schemaId:q,meta:C,baseId:S,localRefs:X}),this._cache.set(D.schema,D),p&&!S.startsWith("#")&&(S&&this._checkUnique(S),this.refs[S]=D),u&&this.validateSchema(w,!0),D}_checkUnique(w){if(this.schemas[w]||this.refs[w])throw new Error(`schema with key or id "${w}" already exists`)}_compileSchemaEnv(w){if(w.meta?this._compileMetaSchema(w):a.compileSchema.call(this,w),!w.validate)throw new Error("ajv implementation error");return w.validate}_compileMetaSchema(w){const C=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=C}}}T.ValidationError=n.default,T.MissingRefError=s.default,e.default=T;function k(O,w,C,S="error"){for(const u in O){const p=u;p in w&&this.logger[S](`${C}: option ${u}. ${O[p]}`)}}function x(O){return O=(0,c.normalizeId)(O),this.schemas[O]||this.refs[O]}function M(){const O=this.opts.schemas;if(O)if(Array.isArray(O))this.addSchema(O);else for(const w in O)this.addSchema(O[w],w)}function L(){for(const O in this.opts.formats){const w=this.opts.formats[O];w&&this.addFormat(O,w)}}function F(O){if(Array.isArray(O)){this.addVocabulary(O);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in O){const C=O[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function V(){const O={...this.opts};for(const w of y)delete O[w];return O}const Z={log(){},warn(){},error(){}};function B(O){if(O===!1)return Z;if(O===void 0)return console;if(O.log&&O.warn&&O.error)return O;throw new Error("logger must implement log, warn and error methods")}const re=/^[a-z_$][a-z0-9_$:-]*$/i;function H(O,w){const{RULES:C}=this;if((0,d.eachItem)(O,S=>{if(C.keywords[S])throw new Error(`Keyword ${S} is already defined`);if(!re.test(S))throw new Error(`Keyword ${S} has invalid name`)}),!!w&&w.$data&&!("code"in w||"validate"in w))throw new Error('$data keyword must have "code" or "validate" function')}function ie(O,w,C){var S;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let P=u?p.post:p.rules.find(({type:D})=>D===C);if(P||(P={type:C,rules:[]},p.rules.push(P)),p.keywords[O]=!0,!w)return;const q={keyword:O,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?ke.call(this,P,q,w.before):P.rules.push(q),p.all[O]=q,(S=w.implements)===null||S===void 0||S.forEach(D=>this.addKeyword(D))}function ke(O,w,C){const S=O.rules.findIndex(u=>u.keyword===C);S>=0?O.rules.splice(S,0,w):(O.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function ye(O){let{metaSchema:w}=O;w!==void 0&&(O.$data&&this.opts.$data&&(w=Oe(w)),O.validateSchema=this.compile(w,!0))}const ct={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oe(O){return{anyOf:[O,ct]}}})(hd);var Xa={},ei={},ti={};Object.defineProperty(ti,"__esModule",{value:!0});const h0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ti.default=h0;var hr={};Object.defineProperty(hr,"__esModule",{value:!0});hr.callRef=hr.getValidate=void 0;const p0=qr,al=pe,nt=ge,yr=Tt,il=ot,qn=J,m0={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return h();const d=il.resolveRef.call(c,l,s,r);if(d===void 0)throw new p0.default(n.opts.uriResolver,s,r);if(d instanceof il.SchemaEnv)return m(d);return g(d);function h(){if(o===l)return Xn(e,a,o,o.$async);const y=t.scopeValue("root",{ref:l});return Xn(e,(0,nt._)`${y}.validate`,l,l.$async)}function m(y){const _=Kd(e,y);Xn(e,_,y,y.$async)}function g(y){const _=t.scopeValue("schema",i.code.source===!0?{ref:y,code:(0,nt.stringify)(y)}:{ref:y}),v=t.name("valid"),f=e.subschema({schema:y,dataTypes:[],schemaPath:nt.nil,topSchemaRef:_,errSchemaPath:r},v);e.mergeEvaluated(f),e.ok(v)}}};function Kd(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,nt._)`${r.scopeValue("wrapper",{ref:t})}.validate`}hr.getValidate=Kd;function Xn(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?yr.default.this:nt.nil;n?d():h();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const y=s.let("valid");s.try(()=>{s.code((0,nt._)`await ${(0,al.callValidateCode)(e,t,l)}`),g(t),a||s.assign(y,!0)},_=>{s.if((0,nt._)`!(${_} instanceof ${o.ValidationError})`,()=>s.throw(_)),m(_),a||s.assign(y,!1)}),e.ok(y)}function h(){e.result((0,al.callValidateCode)(e,t,l),()=>g(t),()=>m(t))}function m(y){const _=(0,nt._)`${y}.errors`;s.assign(yr.default.vErrors,(0,nt._)`${yr.default.vErrors} === null ? ${_} : ${yr.default.vErrors}.concat(${_})`),s.assign(yr.default.errors,(0,nt._)`${yr.default.vErrors}.length`)}function g(y){var _;if(!o.opts.unevaluated)return;const v=(_=r==null?void 0:r.validate)===null||_===void 0?void 0:_.evaluated;if(o.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(o.props=qn.mergeEvaluated.props(s,v.props,o.props));else{const f=s.var("props",(0,nt._)`${y}.evaluated.props`);o.props=qn.mergeEvaluated.props(s,f,o.props,nt.Name)}if(o.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(o.items=qn.mergeEvaluated.items(s,v.items,o.items));else{const f=s.var("items",(0,nt._)`${y}.evaluated.items`);o.items=qn.mergeEvaluated.items(s,f,o.items,nt.Name)}}}hr.callRef=Xn;hr.default=m0;Object.defineProperty(ei,"__esModule",{value:!0});const g0=ti,_0=hr,y0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",g0.default,_0.default];ei.default=y0;var ri={},ni={};Object.defineProperty(ni,"__esModule",{value:!0});const ms=ge,Mt=ms.operators,gs={maximum:{okStr:"<=",ok:Mt.LTE,fail:Mt.GT},minimum:{okStr:">=",ok:Mt.GTE,fail:Mt.LT},exclusiveMaximum:{okStr:"<",ok:Mt.LT,fail:Mt.GTE},exclusiveMinimum:{okStr:">",ok:Mt.GT,fail:Mt.LTE}},v0={message:({keyword:e,schemaCode:t})=>(0,ms.str)`must be ${gs[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ms._)`{comparison: ${gs[e].okStr}, limit: ${t}}`},$0={keyword:Object.keys(gs),type:"number",schemaType:"number",$data:!0,error:v0,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ms._)`${r} ${gs[t].fail} ${n} || isNaN(${r})`)}};ni.default=$0;var si={};Object.defineProperty(si,"__esModule",{value:!0});const rn=ge,w0={message:({schemaCode:e})=>(0,rn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,rn._)`{multipleOf: ${e}}`},b0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:w0,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,rn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,rn._)`${a} !== parseInt(${a})`;e.fail$data((0,rn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};si.default=b0;var oi={},ai={};Object.defineProperty(ai,"__esModule",{value:!0});function Gd(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,sr._)`{limit: ${e}}`},P0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:k0,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?sr.operators.GT:sr.operators.LT,a=s.opts.unicode===!1?(0,sr._)`${r}.length`:(0,sr._)`${(0,S0.useFunc)(e.gen,E0.default)}(${r})`;e.fail$data((0,sr._)`${a} ${o} ${n}`)}};oi.default=P0;var ii={};Object.defineProperty(ii,"__esModule",{value:!0});const R0=pe,T0=J,Pr=ge,C0={message:({schemaCode:e})=>(0,Pr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Pr._)`{pattern: ${e}}`},j0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:C0,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:c}=a.opts.code,l=c.code==="new RegExp"?(0,Pr._)`new RegExp`:(0,T0.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Pr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Pr._)`!${d}`)}else{const c=(0,R0.usePattern)(e,s);e.fail$data((0,Pr._)`!${c}.test(${r})`)}}};ii.default=j0;var ci={};Object.defineProperty(ci,"__esModule",{value:!0});const nn=ge,N0={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,nn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,nn._)`{limit: ${e}}`},I0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:N0,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?nn.operators.GT:nn.operators.LT;e.fail$data((0,nn._)`Object.keys(${r}).length ${s} ${n}`)}};ci.default=I0;var li={};Object.defineProperty(li,"__esModule",{value:!0});const Wr=pe,sn=ge,O0=J,x0={message:({params:{missingProperty:e}})=>(0,sn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,sn._)`{missingProperty: ${e}}`},A0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:x0,code(e){const{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;const c=r.length>=i.loopRequired;if(a.allErrors?l():d(),i.strictRequired){const g=e.parentSchema.properties,{definedProperties:y}=e.it;for(const _ of r)if((g==null?void 0:g[_])===void 0&&!y.has(_)){const v=a.schemaEnv.baseId+a.errSchemaPath,f=`required property "${_}" is not defined at "${v}" (strictRequired)`;(0,O0.checkStrictMode)(a,f,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(sn.nil,h);else for(const g of r)(0,Wr.checkReportMissingProp)(e,g)}function d(){const g=t.let("missing");if(c||o){const y=t.let("valid",!0);e.block$data(y,()=>m(g,y)),e.ok(y)}else t.if((0,Wr.checkMissingProp)(e,r,g)),(0,Wr.reportMissingProp)(e,g),t.else()}function h(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0,Wr.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error())})}function m(g,y){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(y,(0,Wr.propertyInData)(t,s,g,i.ownProperties)),t.if((0,sn.not)(y),()=>{e.error(),t.break()})},sn.nil)}}};li.default=A0;var ui={};Object.defineProperty(ui,"__esModule",{value:!0});const on=ge,M0={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,on.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,on._)`{limit: ${e}}`},z0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:M0,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?on.operators.GT:on.operators.LT;e.fail$data((0,on._)`${r}.length ${s} ${n}`)}};ui.default=z0;var di={},Cn={};Object.defineProperty(Cn,"__esModule",{value:!0});const Wd=zs;Wd.code='require("ajv/dist/runtime/equal").default';Cn.default=Wd;Object.defineProperty(di,"__esModule",{value:!0});const to=qe,He=ge,q0=J,D0=Cn,U0={message:({params:{i:e,j:t}})=>(0,He.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,He._)`{i: ${e}, j: ${t}}`},F0={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:U0,code(e){const{gen:t,data:r,$data:n,schema:s,parentSchema:o,schemaCode:a,it:i}=e;if(!n&&!s)return;const c=t.let("valid"),l=o.items?(0,to.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,He._)`${a} === false`),e.ok(c);function d(){const y=t.let("i",(0,He._)`${r}.length`),_=t.let("j");e.setParams({i:y,j:_}),t.assign(c,!0),t.if((0,He._)`${y} > 1`,()=>(h()?m:g)(y,_))}function h(){return l.length>0&&!l.some(y=>y==="object"||y==="array")}function m(y,_){const v=t.name("item"),f=(0,to.checkDataTypes)(l,v,i.opts.strictNumbers,to.DataType.Wrong),$=t.const("indices",(0,He._)`{}`);t.for((0,He._)`;${y}--;`,()=>{t.let(v,(0,He._)`${r}[${y}]`),t.if(f,(0,He._)`continue`),l.length>1&&t.if((0,He._)`typeof ${v} == "string"`,(0,He._)`${v} += "_"`),t.if((0,He._)`typeof ${$}[${v}] == "number"`,()=>{t.assign(_,(0,He._)`${$}[${v}]`),e.error(),t.assign(c,!1).break()}).code((0,He._)`${$}[${v}] = ${y}`)})}function g(y,_){const v=(0,q0.useFunc)(t,D0.default),f=t.name("outer");t.label(f).for((0,He._)`;${y}--;`,()=>t.for((0,He._)`${_} = ${y}; ${_}--;`,()=>t.if((0,He._)`${v}(${r}[${y}], ${r}[${_}])`,()=>{e.error(),t.assign(c,!1).break(f)})))}}};di.default=F0;var fi={};Object.defineProperty(fi,"__esModule",{value:!0});const Co=ge,L0=J,V0=Cn,H0={message:"must be equal to constant",params:({schemaCode:e})=>(0,Co._)`{allowedValue: ${e}}`},Z0={keyword:"const",$data:!0,error:H0,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Co._)`!${(0,L0.useFunc)(t,V0.default)}(${r}, ${s})`):e.fail((0,Co._)`${o} !== ${r}`)}};fi.default=Z0;var hi={};Object.defineProperty(hi,"__esModule",{value:!0});const Xr=ge,K0=J,G0=Cn,W0={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Xr._)`{allowedValues: ${e}}`},B0={keyword:"enum",schemaType:"array",$data:!0,error:W0,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e;if(!n&&s.length===0)throw new Error("enum must have non-empty array");const i=s.length>=a.opts.loopEnum;let c;const l=()=>c??(c=(0,K0.useFunc)(t,G0.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,h);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const g=t.const("vSchema",o);d=(0,Xr.or)(...s.map((y,_)=>m(g,_)))}e.pass(d);function h(){t.assign(d,!1),t.forOf("v",o,g=>t.if((0,Xr._)`${l()}(${r}, ${g})`,()=>t.assign(d,!0).break()))}function m(g,y){const _=s[y];return typeof _=="object"&&_!==null?(0,Xr._)`${l()}(${r}, ${g}[${y}])`:(0,Xr._)`${r} === ${_}`}}};hi.default=B0;Object.defineProperty(ri,"__esModule",{value:!0});const J0=ni,Q0=si,Y0=oi,X0=ii,eb=ci,tb=li,rb=ui,nb=di,sb=fi,ob=hi,ab=[J0.default,Q0.default,Y0.default,X0.default,eb.default,tb.default,rb.default,nb.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},sb.default,ob.default];ri.default=ab;var pi={},Dr={};Object.defineProperty(Dr,"__esModule",{value:!0});Dr.validateAdditionalItems=void 0;const or=ge,jo=J,ib={message:({params:{len:e}})=>(0,or.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,or._)`{limit: ${e}}`},cb={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:ib,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,jo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Bd(e,n)}};function Bd(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,or._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,or._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,jo.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,or._)`${i} <= ${t.length}`);r.if((0,or.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:jo.Type.Num},l),a.allErrors||r.if((0,or.not)(l),()=>r.break())})}}Dr.validateAdditionalItems=Bd;Dr.default=cb;var mi={},Ur={};Object.defineProperty(Ur,"__esModule",{value:!0});Ur.validateTuple=void 0;const cl=ge,es=J,lb=pe,ub={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Jd(e,"additionalItems",t);r.items=!0,!(0,es.alwaysValidSchema)(r,t)&&e.ok((0,lb.validateArray)(e))}};function Jd(e,t,r=e.schema){const{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==!0&&(i.items=es.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,cl._)`${o}.length`);r.forEach((h,m)=>{(0,es.alwaysValidSchema)(i,h)||(n.if((0,cl._)`${l} > ${m}`,()=>e.subschema({keyword:a,schemaProp:m,dataProp:m},c)),e.ok(c))});function d(h){const{opts:m,errSchemaPath:g}=i,y=r.length,_=y===h.minItems&&(y===h.maxItems||h[t]===!1);if(m.strictTuples&&!_){const v=`"${a}" is ${y}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0,es.checkStrictMode)(i,v,m.strictTuples)}}}Ur.validateTuple=Jd;Ur.default=ub;Object.defineProperty(mi,"__esModule",{value:!0});const db=Ur,fb={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,db.validateTuple)(e,"items")};mi.default=fb;var gi={};Object.defineProperty(gi,"__esModule",{value:!0});const ll=ge,hb=J,pb=pe,mb=Dr,gb={message:({params:{len:e}})=>(0,ll.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ll._)`{limit: ${e}}`},_b={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:gb,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,hb.alwaysValidSchema)(n,t)&&(s?(0,mb.validateAdditionalItems)(e,s):e.ok((0,pb.validateArray)(e)))}};gi.default=_b;var _i={};Object.defineProperty(_i,"__esModule",{value:!0});const dt=ge,Dn=J,yb={message:({params:{min:e,max:t}})=>t===void 0?(0,dt.str)`must contain at least ${e} valid item(s)`:(0,dt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,dt._)`{minContains: ${e}}`:(0,dt._)`{minContains: ${e}, maxContains: ${t}}`},vb={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:yb,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,dt._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Dn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Dn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Dn.alwaysValidSchema)(o,r)){let _=(0,dt._)`${d} >= ${a}`;i!==void 0&&(_=(0,dt._)`${_} && ${d} <= ${i}`),e.pass(_);return}o.items=!0;const h=t.name("valid");i===void 0&&a===1?g(h,()=>t.if(h,()=>t.break())):a===0?(t.let(h,!0),i!==void 0&&t.if((0,dt._)`${s}.length > 0`,m)):(t.let(h,!1),m()),e.result(h,()=>e.reset());function m(){const _=t.name("_valid"),v=t.let("count",0);g(_,()=>t.if(_,()=>y(v)))}function g(_,v){t.forRange("i",0,d,f=>{e.subschema({keyword:"contains",dataProp:f,dataPropType:Dn.Type.Num,compositeRule:!0},_),v()})}function y(_){t.code((0,dt._)`${_}++`),i===void 0?t.if((0,dt._)`${_} >= ${a}`,()=>t.assign(h,!0).break()):(t.if((0,dt._)`${_} > ${i}`,()=>t.assign(h,!1).break()),a===1?t.assign(h,!0):t.if((0,dt._)`${_} >= ${a}`,()=>t.assign(h,!0)))}}};_i.default=vb;var Qd={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=ge,r=J,n=pe;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const h=l===1?"property":"properties";return(0,t.str)`must have ${h} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:h}})=>(0,t._)`{property: ${c}, + missingProperty: ${h}, + depsCount: ${l}, + deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const h in c){if(h==="__proto__")continue;const m=Array.isArray(c[h])?l:d;m[h]=c[h]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:h,it:m}=c;if(Object.keys(l).length===0)return;const g=d.let("missing");for(const y in l){const _=l[y];if(_.length===0)continue;const v=(0,n.propertyInData)(d,h,y,m.opts.ownProperties);c.setParams({property:y,depsCount:_.length,deps:_.join(", ")}),m.allErrors?d.if(v,()=>{for(const f of _)(0,n.checkReportMissingProp)(c,f)}):(d.if((0,t._)`${v} && (${(0,n.checkMissingProp)(c,_,g)})`),(0,n.reportMissingProp)(c,g),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:h,keyword:m,it:g}=c,y=d.name("valid");for(const _ in l)(0,r.alwaysValidSchema)(g,l[_])||(d.if((0,n.propertyInData)(d,h,_,g.opts.ownProperties),()=>{const v=c.subschema({keyword:m,schemaProp:_},y);c.mergeValidEvaluated(v,y)},()=>d.var(y,!0)),c.ok(y))}e.validateSchemaDeps=i,e.default=s})(Qd);var yi={};Object.defineProperty(yi,"__esModule",{value:!0});const Yd=ge,$b=J,wb={message:"property name must be valid",params:({params:e})=>(0,Yd._)`{propertyName: ${e.propertyName}}`},bb={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:wb,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,$b.alwaysValidSchema)(s,r))return;const o=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},o),t.if((0,Yd.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};yi.default=bb;var Ls={};Object.defineProperty(Ls,"__esModule",{value:!0});const Un=pe,vt=ge,Sb=Tt,Fn=J,Eb={message:"must NOT have additional properties",params:({params:e})=>(0,vt._)`{additionalProperty: ${e.additionalProperty}}`},kb={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Eb,code(e){const{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,Fn.alwaysValidSchema)(a,r))return;const l=(0,Un.allSchemaProperties)(n.properties),d=(0,Un.allSchemaProperties)(n.patternProperties);h(),e.ok((0,vt._)`${o} === ${Sb.default.errors}`);function h(){t.forIn("key",s,v=>{!l.length&&!d.length?y(v):t.if(m(v),()=>y(v))})}function m(v){let f;if(l.length>8){const $=(0,Fn.schemaRefOrVal)(a,n.properties,"properties");f=(0,Un.isOwnProperty)(t,$,v)}else l.length?f=(0,vt.or)(...l.map($=>(0,vt._)`${v} === ${$}`)):f=vt.nil;return d.length&&(f=(0,vt.or)(f,...d.map($=>(0,vt._)`${(0,Un.usePattern)(e,$)}.test(${v})`))),(0,vt.not)(f)}function g(v){t.code((0,vt._)`delete ${s}[${v}]`)}function y(v){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){g(v);return}if(r===!1){e.setParams({additionalProperty:v}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Fn.alwaysValidSchema)(a,r)){const f=t.name("valid");c.removeAdditional==="failing"?(_(v,f,!1),t.if((0,vt.not)(f),()=>{e.reset(),g(v)})):(_(v,f),i||t.if((0,vt.not)(f),()=>t.break()))}}function _(v,f,$){const E={keyword:"additionalProperties",dataProp:v,dataPropType:Fn.Type.Str};$===!1&&Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(E,f)}}};Ls.default=kb;var vi={};Object.defineProperty(vi,"__esModule",{value:!0});const Pb=qs(),ul=pe,ro=J,dl=Ls,Rb={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&dl.default.code(new Pb.KeywordCxt(o,dl.default,"additionalProperties"));const a=(0,ul.allSchemaProperties)(r);for(const h of a)o.definedProperties.add(h);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=ro.mergeEvaluated.props(t,(0,ro.toHash)(a),o.props));const i=a.filter(h=>!(0,ro.alwaysValidSchema)(o,r[h]));if(i.length===0)return;const c=t.name("valid");for(const h of i)l(h)?d(h):(t.if((0,ul.propertyInData)(t,s,h,o.opts.ownProperties)),d(h),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(h),e.ok(c);function l(h){return o.opts.useDefaults&&!o.compositeRule&&r[h].default!==void 0}function d(h){e.subschema({keyword:"properties",schemaProp:h,dataProp:h},c)}}};vi.default=Rb;var $i={};Object.defineProperty($i,"__esModule",{value:!0});const fl=pe,Ln=ge,hl=J,pl=J,Tb={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,data:n,parentSchema:s,it:o}=e,{opts:a}=o,i=(0,fl.allSchemaProperties)(r),c=i.filter(_=>(0,hl.alwaysValidSchema)(o,r[_]));if(i.length===0||c.length===i.length&&(!o.opts.unevaluated||o.props===!0))return;const l=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==!0&&!(o.props instanceof Ln.Name)&&(o.props=(0,pl.evaluatedPropsToName)(t,o.props));const{props:h}=o;m();function m(){for(const _ of i)l&&g(_),o.allErrors?y(_):(t.var(d,!0),y(_),t.if(d))}function g(_){for(const v in l)new RegExp(_).test(v)&&(0,hl.checkStrictMode)(o,`property ${v} matches pattern ${_} (use allowMatchingProperties)`)}function y(_){t.forIn("key",n,v=>{t.if((0,Ln._)`${(0,fl.usePattern)(e,_)}.test(${v})`,()=>{const f=c.includes(_);f||e.subschema({keyword:"patternProperties",schemaProp:_,dataProp:v,dataPropType:pl.Type.Str},d),o.opts.unevaluated&&h!==!0?t.assign((0,Ln._)`${h}[${v}]`,!0):!f&&!o.allErrors&&t.if((0,Ln.not)(d),()=>t.break())})})}}};$i.default=Tb;var wi={};Object.defineProperty(wi,"__esModule",{value:!0});const Cb=J,jb={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,Cb.alwaysValidSchema)(n,r)){e.fail();return}const s=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),e.failResult(s,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};wi.default=jb;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});const Nb=pe,Ib={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Nb.validateUnion,error:{message:"must match a schema in anyOf"}};bi.default=Ib;var Si={};Object.defineProperty(Si,"__esModule",{value:!0});const ts=ge,Ob=J,xb={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ts._)`{passingSchemas: ${e.passing}}`},Ab={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:xb,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,h)=>{let m;(0,Ob.alwaysValidSchema)(s,d)?t.var(c,!0):m=e.subschema({keyword:"oneOf",schemaProp:h,compositeRule:!0},c),h>0&&t.if((0,ts._)`${c} && ${a}`).assign(a,!1).assign(i,(0,ts._)`[${i}, ${h}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,h),m&&e.mergeEvaluated(m,ts.Name)})})}}};Si.default=Ab;var Ei={};Object.defineProperty(Ei,"__esModule",{value:!0});const Mb=J,zb={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");const s=t.name("valid");r.forEach((o,a)=>{if((0,Mb.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};Ei.default=zb;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});const _s=ge,Xd=J,qb={message:({params:e})=>(0,_s.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,_s._)`{failingKeyword: ${e.ifClause}}`},Db={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:qb,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Xd.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=ml(n,"then"),o=ml(n,"else");if(!s&&!o)return;const a=t.let("valid",!0),i=t.name("_valid");if(c(),e.reset(),s&&o){const d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,l("then",d),l("else",d))}else s?t.if(i,l("then")):t.if((0,_s.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,h){return()=>{const m=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(m,a),h?t.assign(h,(0,_s._)`${d}`):e.setParams({ifClause:d})}}}};function ml(e,t){const r=e.schema[t];return r!==void 0&&!(0,Xd.alwaysValidSchema)(e,r)}ki.default=Db;var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});const Ub=J,Fb={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,Ub.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Pi.default=Fb;Object.defineProperty(pi,"__esModule",{value:!0});const Lb=Dr,Vb=mi,Hb=Ur,Zb=gi,Kb=_i,Gb=Qd,Wb=yi,Bb=Ls,Jb=vi,Qb=$i,Yb=wi,Xb=bi,eS=Si,tS=Ei,rS=ki,nS=Pi;function sS(e=!1){const t=[Yb.default,Xb.default,eS.default,tS.default,rS.default,nS.default,Wb.default,Bb.default,Gb.default,Jb.default,Qb.default];return e?t.push(Vb.default,Zb.default):t.push(Lb.default,Hb.default),t.push(Kb.default),t}pi.default=sS;var Ri={},Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});const Me=ge,oS={message:({schemaCode:e})=>(0,Me.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Me._)`{format: ${e}}`},aS={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:oS,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:h}=i;if(!c.validateFormats)return;s?m():g();function m(){const y=r.scopeValue("formats",{ref:h.formats,code:c.code.formats}),_=r.const("fDef",(0,Me._)`${y}[${a}]`),v=r.let("fType"),f=r.let("format");r.if((0,Me._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(v,(0,Me._)`${_}.type || "string"`).assign(f,(0,Me._)`${_}.validate`),()=>r.assign(v,(0,Me._)`"string"`).assign(f,_)),e.fail$data((0,Me.or)($(),E()));function $(){return c.strictSchema===!1?Me.nil:(0,Me._)`${a} && !${f}`}function E(){const T=d.$async?(0,Me._)`(${_}.async ? await ${f}(${n}) : ${f}(${n}))`:(0,Me._)`${f}(${n})`,k=(0,Me._)`(typeof ${f} == "function" ? ${T} : ${f}.test(${n}))`;return(0,Me._)`${f} && ${f} !== true && ${v} === ${t} && !${k}`}}function g(){const y=h.formats[o];if(!y){$();return}if(y===!0)return;const[_,v,f]=E(y);_===t&&e.pass(T());function $(){if(c.strictSchema===!1){h.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function E(k){const x=k instanceof RegExp?(0,Me.regexpCode)(k):c.code.formats?(0,Me._)`${c.code.formats}${(0,Me.getProperty)(o)}`:void 0,M=r.scopeValue("formats",{key:o,ref:k,code:x});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,Me._)`${M}.validate`]:["string",k,M]}function T(){if(typeof y=="object"&&!(y instanceof RegExp)&&y.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Me._)`await ${f}(${n})`}return typeof v=="function"?(0,Me._)`${f}(${n})`:(0,Me._)`${f}.test(${n})`}}}};Ti.default=aS;Object.defineProperty(Ri,"__esModule",{value:!0});const iS=Ti,cS=[iS.default];Ri.default=cS;var Or={};Object.defineProperty(Or,"__esModule",{value:!0});Or.contentVocabulary=Or.metadataVocabulary=void 0;Or.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Or.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Xa,"__esModule",{value:!0});const lS=ei,uS=ri,dS=pi,fS=Ri,gl=Or,hS=[lS.default,uS.default,(0,dS.default)(),fS.default,gl.metadataVocabulary,gl.contentVocabulary];Xa.default=hS;var Ci={},Vs={};Object.defineProperty(Vs,"__esModule",{value:!0});Vs.DiscrError=void 0;var _l;(function(e){e.Tag="tag",e.Mapping="mapping"})(_l||(Vs.DiscrError=_l={}));Object.defineProperty(Ci,"__esModule",{value:!0});const Sr=ge,No=Vs,yl=ot,pS=qr,mS=J,gS={message:({params:{discrError:e,tagName:t}})=>e===No.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Sr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},_S={keyword:"discriminator",type:"object",schemaType:"object",error:gS,code(e){const{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),l=t.const("tag",(0,Sr._)`${r}${(0,Sr.getProperty)(i)}`);t.if((0,Sr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:No.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const g=m();t.if(!1);for(const y in g)t.elseIf((0,Sr._)`${l} === ${y}`),t.assign(c,h(g[y]));t.else(),e.error(!1,{discrError:No.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function h(g){const y=t.name("valid"),_=e.subschema({keyword:"oneOf",schemaProp:g},y);return e.mergeEvaluated(_,Sr.Name),y}function m(){var g;const y={},_=f(s);let v=!0;for(let T=0;Tthis.addVocabulary(y)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const y=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(y,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=qs();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=ge;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var h=Ga();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return h.default}});var m=qr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(Eo,Eo.exports);var kS=Eo.exports;const PS=Bl(kS);var Io={exports:{}},ef={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(Z,B){return{validate:Z,compare:B}}e.fullFormats={date:t(o,a),time:t(c(!0),l),"date-time":t(m(!0),g),"iso-time":t(c(),d),"iso-date-time":t(m(),y),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:f,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:V,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:E,int32:{type:"number",validate:x},int64:{type:"number",validate:M},float:{type:"number",validate:L},double:{type:"number",validate:L},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,a),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,g),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,d),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,y),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function r(Z){return Z%4===0&&(Z%100!==0||Z%400===0)}const n=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,s=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(Z){const B=n.exec(Z);if(!B)return!1;const re=+B[1],H=+B[2],ie=+B[3];return H>=1&&H<=12&&ie>=1&&ie<=(H===2&&r(re)?29:s[H])}function a(Z,B){if(Z&&B)return Z>B?1:Z23||w>59||Z&&!ct)return!1;if(ie<=23&&ke<=59&&ye<60)return!0;const C=ke-w*Oe,S=ie-O*Oe-(C<0?1:0);return(S===23||S===-1)&&(C===59||C===-1)&&ye<61}}function l(Z,B){if(!(Z&&B))return;const re=new Date("2020-01-01T"+Z).valueOf(),H=new Date("2020-01-01T"+B).valueOf();if(re&&H)return re-H}function d(Z,B){if(!(Z&&B))return;const re=i.exec(Z),H=i.exec(B);if(re&&H)return Z=re[1]+re[2]+re[3],B=H[1]+H[2]+H[3],Z>B?1:Z=T}function M(Z){return Number.isInteger(Z)}function L(){return!0}const F=/[^\\]\\Z/;function V(Z){if(F.test(Z))return!1;try{return new RegExp(Z),!0}catch{return!1}}})(ef);var tf={},Oo={exports:{}},rf={},St={},xr={},jn={},he={},_n={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor($){if(super(),!e.IDENTIFIER.test($))throw new Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor($){super(),this._items=typeof $=="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((E,T)=>`${E}${T}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((E,T)=>(T instanceof r&&(E[T.str]=(E[T.str]||0)+1),E),{})}}e._Code=n,e.nil=new n("");function s(f,...$){const E=[f[0]];let T=0;for(;T<$.length;)i(E,$[T]),E.push(f[++T]);return new n(E)}e._=s;const o=new n("+");function a(f,...$){const E=[g(f[0])];let T=0;for(;T<$.length;)E.push(o),i(E,$[T]),E.push(o,g(f[++T]));return c(E),new n(E)}e.str=a;function i(f,$){$ instanceof n?f.push(...$._items):$ instanceof r?f.push($):f.push(h($))}e.addCodeArg=i;function c(f){let $=1;for(;${if(h.scopePath===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return(0,t._)`${l}${h.scopePath}`})}scopeCode(l=this._values,d,h){return this._reduceValues(l,m=>{if(m.value===void 0)throw new Error(`CodeGen: name "${m}" has no value`);return m.value.code},d,h)}_reduceValues(l,d,h={},m){let g=t.nil;for(const y in l){const _=l[y];if(!_)continue;const v=h[y]=h[y]||new Map;_.forEach(f=>{if(v.has(f))return;v.set(f,n.Started);let $=d(f);if($){const E=this.opts.es5?e.varKinds.var:e.varKinds.const;g=(0,t._)`${g}${E} ${f} = ${$};${this.opts._n}`}else if($=m==null?void 0:m(f))g=(0,t._)`${g}${$}${this.opts._n}`;else throw new r(f);v.set(f,n.Completed)})}return g}}e.ValueScope=i})(xo);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=_n,r=xo;var n=_n;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=xo;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,P){super(),this.varKind=u,this.name=p,this.rhs=P}render({es5:u,_n:p}){const P=u?r.varKinds.var:this.varKind,q=this.rhs===void 0?"":` = ${this.rhs}`;return`${P} ${this.name}${q};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=H(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,P){super(),this.lhs=u,this.rhs=p,this.sideEffects=P}render({_n:u}){return`${this.lhs} = ${this.rhs};`+u}optimizeNames(u,p){if(!(this.lhs instanceof t.Name&&!u[this.lhs.str]&&!this.sideEffects))return this.rhs=H(this.rhs,u,p),this}get names(){const u=this.lhs instanceof t.Name?{}:{...this.lhs.names};return re(u,this.rhs)}}class c extends i{constructor(u,p,P,q){super(u,P,q),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class h extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class m extends o{constructor(u){super(),this.code=u}render({_n:u}){return`${this.code};`+u}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(u,p){return this.code=H(this.code,u,p),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class g extends o{constructor(u=[]){super(),this.nodes=u}render(u){return this.nodes.reduce((p,P)=>p+P.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const P=u[p].optimizeNodes();Array.isArray(P)?u.splice(p,1,...P):P?u[p]=P:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:P}=this;let q=P.length;for(;q--;){const D=P[q];D.optimizeNames(u,p)||(ie(u,D.names),P.splice(q,1))}return P.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>B(u,p.names),{})}}class y extends g{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class _ extends g{}class v extends y{}v.kind="else";class f extends y{constructor(u,p){super(p),this.condition=u}render(u){let p=`if(${this.condition})`+super.render(u);return this.else&&(p+="else "+this.else.render(u)),p}optimizeNodes(){super.optimizeNodes();const u=this.condition;if(u===!0)return this.nodes;let p=this.else;if(p){const P=p.optimizeNodes();p=this.else=Array.isArray(P)?new v(P):P}if(p)return u===!1?p instanceof f?p:p.nodes:this.nodes.length?this:new f(ke(u),p instanceof f?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var P;if(this.else=(P=this.else)===null||P===void 0?void 0:P.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=H(this.condition,u,p),this}get names(){const u=super.names;return re(u,this.condition),this.else&&B(u,this.else.names),u}}f.kind="if";class $ extends y{}$.kind="for";class E extends ${constructor(u){super(),this.iteration=u}render(u){return`for(${this.iteration})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iteration=H(this.iteration,u,p),this}get names(){return B(super.names,this.iteration.names)}}class T extends ${constructor(u,p,P,q){super(),this.varKind=u,this.name=p,this.from=P,this.to=q}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:P,from:q,to:D}=this;return`for(${p} ${P}=${q}; ${P}<${D}; ${P}++)`+super.render(u)}get names(){const u=re(super.names,this.from);return re(u,this.to)}}class k extends ${constructor(u,p,P,q){super(),this.loop=u,this.varKind=p,this.name=P,this.iterable=q}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=H(this.iterable,u,p),this}get names(){return B(super.names,this.iterable.names)}}class x extends y{constructor(u,p,P){super(),this.name=u,this.args=p,this.async=P}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}x.kind="func";class M extends g{render(u){return"return "+super.render(u)}}M.kind="return";class L extends y{render(u){let p="try"+super.render(u);return this.catch&&(p+=this.catch.render(u)),this.finally&&(p+=this.finally.render(u)),p}optimizeNodes(){var u,p;return super.optimizeNodes(),(u=this.catch)===null||u===void 0||u.optimizeNodes(),(p=this.finally)===null||p===void 0||p.optimizeNodes(),this}optimizeNames(u,p){var P,q;return super.optimizeNames(u,p),(P=this.catch)===null||P===void 0||P.optimizeNames(u,p),(q=this.finally)===null||q===void 0||q.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&B(u,this.catch.names),this.finally&&B(u,this.finally.names),u}}class F extends y{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}F.kind="catch";class V extends y{render(u){return"finally"+super.render(u)}}V.kind="finally";class Z{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` +`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new _]}toString(){return this._root.render(this.opts)}name(u){return this._scope.name(u)}scopeName(u){return this._extScope.name(u)}scopeValue(u,p){const P=this._extScope.value(u,p);return(this._values[P.prefix]||(this._values[P.prefix]=new Set)).add(P),P}getScopeValue(u,p){return this._extScope.getValue(u,p)}scopeRefs(u){return this._extScope.scopeRefs(u,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(u,p,P,q){const D=this._scope.toName(p);return P!==void 0&&q&&(this._constants[D.str]=P),this._leafNode(new a(u,D,P)),D}const(u,p,P){return this._def(r.varKinds.const,u,p,P)}let(u,p,P){return this._def(r.varKinds.let,u,p,P)}var(u,p,P){return this._def(r.varKinds.var,u,p,P)}assign(u,p,P){return this._leafNode(new i(u,p,P))}add(u,p){return this._leafNode(new c(u,e.operators.ADD,p))}code(u){return typeof u=="function"?u():u!==t.nil&&this._leafNode(new m(u)),this}object(...u){const p=["{"];for(const[P,q]of u)p.length>1&&p.push(","),p.push(P),(P!==q||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,q));return p.push("}"),new t._Code(p)}if(u,p,P){if(this._blockNode(new f(u)),p&&P)this.code(p).else().code(P).endIf();else if(p)this.code(p).endIf();else if(P)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new f(u))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(f,v)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new E(u),p)}forRange(u,p,P,q,D=this.opts.es5?r.varKinds.var:r.varKinds.let){const X=this._scope.toName(u);return this._for(new T(D,X,p,P),()=>q(X))}forOf(u,p,P,q=r.varKinds.const){const D=this._scope.toName(u);if(this.opts.es5){const X=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${X}.length`,Y=>{this.var(D,(0,t._)`${X}[${Y}]`),P(D)})}return this._for(new k("of",q,D,p),()=>P(D))}forIn(u,p,P,q=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,P);const D=this._scope.toName(u);return this._for(new k("in",q,D,p),()=>P(D))}endFor(){return this._endBlockNode($)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new M;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(M)}try(u,p,P){if(!p&&!P)throw new Error('CodeGen: "try" without "catch" and "finally"');const q=new L;if(this._blockNode(q),this.code(u),p){const D=this.name("e");this._currNode=q.catch=new F(D),p(D)}return P&&(this._currNode=q.finally=new V,this.code(P)),this._endBlockNode(F,V)}throw(u){return this._leafNode(new h(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const P=this._nodes.length-p;if(P<0||u!==void 0&&P!==u)throw new Error(`CodeGen: wrong number of nodes: ${P} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,P,q){return this._blockNode(new x(u,p,P)),q&&this.code(q).endFunc(),this}endFunc(){return this._endBlockNode(x)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const P=this._currNode;if(P instanceof u||p&&P instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof f))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=Z;function B(S,u){for(const p in u)S[p]=(S[p]||0)+(u[p]||0);return S}function re(S,u){return u instanceof t._CodeOrName?B(S,u.names):S}function H(S,u,p){if(S instanceof t.Name)return P(S);if(!q(S))return S;return new t._Code(S._items.reduce((D,X)=>(X instanceof t.Name&&(X=P(X)),X instanceof t._Code?D.push(...X._items):D.push(X),D),[]));function P(D){const X=p[D.str];return X===void 0||u[D.str]!==1?D:(delete u[D.str],X)}function q(D){return D instanceof t._Code&&D._items.some(X=>X instanceof t.Name&&u[X.str]===1&&p[X.str]!==void 0)}}function ie(S,u){for(const p in u)S[p]=(S[p]||0)-(u[p]||0)}function ke(S){return typeof S=="boolean"||typeof S=="number"||S===null?!S:(0,t._)`!${C(S)}`}e.not=ke;const ye=w(e.operators.AND);function ct(...S){return S.reduce(ye)}e.and=ct;const Oe=w(e.operators.OR);function O(...S){return S.reduce(Oe)}e.or=O;function w(S){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${S} ${C(p)}`}function C(S){return S instanceof t.Name?S:(0,t._)`(${S})`}})(he);var Q={};Object.defineProperty(Q,"__esModule",{value:!0});Q.checkStrictMode=Q.getErrorPath=Q.Type=Q.useFunc=Q.setEvaluated=Q.evaluatedPropsToName=Q.mergeEvaluated=Q.eachItem=Q.unescapeJsonPointer=Q.escapeJsonPointer=Q.escapeFragment=Q.unescapeFragment=Q.schemaRefOrVal=Q.schemaHasRulesButRef=Q.schemaHasRules=Q.checkUnknownRules=Q.alwaysValidSchema=Q.toHash=void 0;const be=he,RS=_n;function TS(e){const t={};for(const r of e)t[r]=!0;return t}Q.toHash=TS;function CS(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(nf(e,t),!sf(t,e.self.RULES.all))}Q.alwaysValidSchema=CS;function nf(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;const s=n.RULES.keywords;for(const o in t)s[o]||cf(e,`unknown keyword: "${o}"`)}Q.checkUnknownRules=nf;function sf(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}Q.schemaHasRules=sf;function jS(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}Q.schemaHasRulesButRef=jS;function NS({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,be._)`${r}`}return(0,be._)`${e}${t}${(0,be.getProperty)(n)}`}Q.schemaRefOrVal=NS;function IS(e){return of(decodeURIComponent(e))}Q.unescapeFragment=IS;function OS(e){return encodeURIComponent(ji(e))}Q.escapeFragment=OS;function ji(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Q.escapeJsonPointer=ji;function of(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Q.unescapeJsonPointer=of;function xS(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}Q.eachItem=xS;function vl({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof be.Name?(o instanceof be.Name?e(s,o,a):t(s,o,a),a):o instanceof be.Name?(t(s,a,o),o):r(o,a);return i===be.Name&&!(c instanceof be.Name)?n(s,c):c}}Q.mergeEvaluated={props:vl({mergeNames:(e,t,r)=>e.if((0,be._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,be._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,be._)`${r} || {}`).code((0,be._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,be._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,be._)`${r} || {}`),Ni(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:af}),items:vl({mergeNames:(e,t,r)=>e.if((0,be._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,be._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,be._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,be._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function af(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,be._)`{}`);return t!==void 0&&Ni(e,r,t),r}Q.evaluatedPropsToName=af;function Ni(e,t,r){Object.keys(r).forEach(n=>e.assign((0,be._)`${t}${(0,be.getProperty)(n)}`,!0))}Q.setEvaluated=Ni;const $l={};function AS(e,t){return e.scopeValue("func",{ref:t,code:$l[t.code]||($l[t.code]=new RS._Code(t.code))})}Q.useFunc=AS;var Ao;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Ao||(Q.Type=Ao={}));function MS(e,t,r){if(e instanceof be.Name){const n=t===Ao.Num;return r?n?(0,be._)`"[" + ${e} + "]"`:(0,be._)`"['" + ${e} + "']"`:n?(0,be._)`"/" + ${e}`:(0,be._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,be.getProperty)(e).toString():"/"+ji(e)}Q.getErrorPath=MS;function cf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}Q.checkStrictMode=cf;var Ct={};Object.defineProperty(Ct,"__esModule",{value:!0});const et=he,zS={data:new et.Name("data"),valCxt:new et.Name("valCxt"),instancePath:new et.Name("instancePath"),parentData:new et.Name("parentData"),parentDataProperty:new et.Name("parentDataProperty"),rootData:new et.Name("rootData"),dynamicAnchors:new et.Name("dynamicAnchors"),vErrors:new et.Name("vErrors"),errors:new et.Name("errors"),this:new et.Name("this"),self:new et.Name("self"),scope:new et.Name("scope"),json:new et.Name("json"),jsonPos:new et.Name("jsonPos"),jsonLen:new et.Name("jsonLen"),jsonPart:new et.Name("jsonPart")};Ct.default=zS;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=he,r=Q,n=Ct;e.keywordError={message:({keyword:v})=>(0,t.str)`must pass "${v}" keyword validation`},e.keyword$DataError={message:({keyword:v,schemaType:f})=>f?(0,t.str)`"${v}" keyword must be ${f} ($data)`:(0,t.str)`"${v}" keyword is invalid ($data)`};function s(v,f=e.keywordError,$,E){const{it:T}=v,{gen:k,compositeRule:x,allErrors:M}=T,L=h(v,f,$);E??(x||M)?c(k,L):l(T,(0,t._)`[${L}]`)}e.reportError=s;function o(v,f=e.keywordError,$){const{it:E}=v,{gen:T,compositeRule:k,allErrors:x}=E,M=h(v,f,$);c(T,M),k||x||l(E,n.default.vErrors)}e.reportExtraError=o;function a(v,f){v.assign(n.default.errors,f),v.if((0,t._)`${n.default.vErrors} !== null`,()=>v.if(f,()=>v.assign((0,t._)`${n.default.vErrors}.length`,f),()=>v.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:v,keyword:f,schemaValue:$,data:E,errsCount:T,it:k}){if(T===void 0)throw new Error("ajv implementation error");const x=v.name("err");v.forRange("i",T,n.default.errors,M=>{v.const(x,(0,t._)`${n.default.vErrors}[${M}]`),v.if((0,t._)`${x}.instancePath === undefined`,()=>v.assign((0,t._)`${x}.instancePath`,(0,t.strConcat)(n.default.instancePath,k.errorPath))),v.assign((0,t._)`${x}.schemaPath`,(0,t.str)`${k.errSchemaPath}/${f}`),k.opts.verbose&&(v.assign((0,t._)`${x}.schema`,$),v.assign((0,t._)`${x}.data`,E))})}e.extendErrors=i;function c(v,f){const $=v.const("err",f);v.if((0,t._)`${n.default.vErrors} === null`,()=>v.assign(n.default.vErrors,(0,t._)`[${$}]`),(0,t._)`${n.default.vErrors}.push(${$})`),v.code((0,t._)`${n.default.errors}++`)}function l(v,f){const{gen:$,validateName:E,schemaEnv:T}=v;T.$async?$.throw((0,t._)`new ${v.ValidationError}(${f})`):($.assign((0,t._)`${E}.errors`,f),$.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function h(v,f,$){const{createErrors:E}=v.it;return E===!1?(0,t._)`{}`:m(v,f,$)}function m(v,f,$={}){const{gen:E,it:T}=v,k=[g(T,$),y(v,$)];return _(v,f,k),E.object(...k)}function g({errorPath:v},{instancePath:f}){const $=f?(0,t.str)`${v}${(0,r.getErrorPath)(f,r.Type.Str)}`:v;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,$)]}function y({keyword:v,it:{errSchemaPath:f}},{schemaPath:$,parentSchema:E}){let T=E?f:(0,t.str)`${f}/${v}`;return $&&(T=(0,t.str)`${T}${(0,r.getErrorPath)($,r.Type.Str)}`),[d.schemaPath,T]}function _(v,{params:f,message:$},E){const{keyword:T,data:k,schemaValue:x,it:M}=v,{opts:L,propertyName:F,topSchemaRef:V,schemaPath:Z}=M;E.push([d.keyword,T],[d.params,typeof f=="function"?f(v):f||(0,t._)`{}`]),L.messages&&E.push([d.message,typeof $=="function"?$(v):$]),L.verbose&&E.push([d.schema,x],[d.parentSchema,(0,t._)`${V}${Z}`],[n.default.data,k]),F&&E.push([d.propertyName,F])}})(jn);Object.defineProperty(xr,"__esModule",{value:!0});xr.boolOrEmptySchema=xr.topBoolOrEmptySchema=void 0;const qS=jn,DS=he,US=Ct,FS={message:"boolean schema is false"};function LS(e){const{gen:t,schema:r,validateName:n}=e;r===!1?lf(e,!1):typeof r=="object"&&r.$async===!0?t.return(US.default.data):(t.assign((0,DS._)`${n}.errors`,null),t.return(!0))}xr.topBoolOrEmptySchema=LS;function VS(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),lf(e)):r.var(t,!0)}xr.boolOrEmptySchema=VS;function lf(e,t){const{gen:r,data:n}=e,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,qS.reportError)(s,FS,void 0,t)}var De={},pr={};Object.defineProperty(pr,"__esModule",{value:!0});pr.getRules=pr.isJSONType=void 0;const HS=["string","number","integer","boolean","null","object","array"],ZS=new Set(HS);function KS(e){return typeof e=="string"&&ZS.has(e)}pr.isJSONType=KS;function GS(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}pr.getRules=GS;var Ot={};Object.defineProperty(Ot,"__esModule",{value:!0});Ot.shouldUseRule=Ot.shouldUseGroup=Ot.schemaHasRulesForType=void 0;function WS({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&uf(e,n)}Ot.schemaHasRulesForType=WS;function uf(e,t){return t.rules.some(r=>df(e,r))}Ot.shouldUseGroup=uf;function df(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Ot.shouldUseRule=df;Object.defineProperty(De,"__esModule",{value:!0});De.reportTypeError=De.checkDataTypes=De.checkDataType=De.coerceAndCheckDataType=De.getJSONTypes=De.getSchemaTypes=De.DataType=void 0;const BS=pr,JS=Ot,QS=jn,de=he,ff=Q;var jr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(jr||(De.DataType=jr={}));function YS(e){const t=hf(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}De.getSchemaTypes=YS;function hf(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(BS.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}De.getJSONTypes=hf;function XS(e,t){const{gen:r,data:n,opts:s}=e,o=eE(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,JS.schemaHasRulesForType)(e,t[0]));if(a){const i=Ii(t,n,s.strictNumbers,jr.Wrong);r.if(i,()=>{o.length?tE(e,t,o):Oi(e)})}return a}De.coerceAndCheckDataType=XS;const pf=new Set(["string","number","integer","boolean","null"]);function eE(e,t){return t?e.filter(r=>pf.has(r)||t==="array"&&r==="array"):[]}function tE(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,de._)`typeof ${s}`),i=n.let("coerced",(0,de._)`undefined`);o.coerceTypes==="array"&&n.if((0,de._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,de._)`${s}[0]`).assign(a,(0,de._)`typeof ${s}`).if(Ii(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,de._)`${i} !== undefined`);for(const l of r)(pf.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Oi(e),n.endIf(),n.if((0,de._)`${i} !== undefined`,()=>{n.assign(s,i),rE(e,i)});function c(l){switch(l){case"string":n.elseIf((0,de._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,de._)`"" + ${s}`).elseIf((0,de._)`${s} === null`).assign(i,(0,de._)`""`);return;case"number":n.elseIf((0,de._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,de._)`+${s}`);return;case"integer":n.elseIf((0,de._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,de._)`+${s}`);return;case"boolean":n.elseIf((0,de._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,de._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,de._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,de._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,de._)`[${s}]`)}}}function rE({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,de._)`${t} !== undefined`,()=>e.assign((0,de._)`${t}[${r}]`,n))}function Mo(e,t,r,n=jr.Correct){const s=n===jr.Correct?de.operators.EQ:de.operators.NEQ;let o;switch(e){case"null":return(0,de._)`${t} ${s} null`;case"array":o=(0,de._)`Array.isArray(${t})`;break;case"object":o=(0,de._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,de._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,de._)`typeof ${t} ${s} ${e}`}return n===jr.Correct?o:(0,de.not)(o);function a(i=de.nil){return(0,de.and)((0,de._)`typeof ${t} == "number"`,i,r?(0,de._)`isFinite(${t})`:de.nil)}}De.checkDataType=Mo;function Ii(e,t,r,n){if(e.length===1)return Mo(e[0],t,r,n);let s;const o=(0,ff.toHash)(e);if(o.array&&o.object){const a=(0,de._)`typeof ${t} != "object"`;s=o.null?a:(0,de._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=de.nil;o.number&&delete o.integer;for(const a in o)s=(0,de.and)(s,Mo(a,t,r,n));return s}De.checkDataTypes=Ii;const nE={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,de._)`{type: ${e}}`:(0,de._)`{type: ${t}}`};function Oi(e){const t=sE(e);(0,QS.reportError)(t,nE)}De.reportTypeError=Oi;function sE(e){const{gen:t,data:r,schema:n}=e,s=(0,ff.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Hs={};Object.defineProperty(Hs,"__esModule",{value:!0});Hs.assignDefaults=void 0;const vr=he,oE=Q;function aE(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)wl(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>wl(e,o,s.default))}Hs.assignDefaults=aE;function wl(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,vr._)`${o}${(0,vr.getProperty)(t)}`;if(s){(0,oE.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,vr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,vr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,vr._)`${i} = ${(0,vr.stringify)(r)}`)}var Rt={},me={};Object.defineProperty(me,"__esModule",{value:!0});me.validateUnion=me.validateArray=me.usePattern=me.callValidateCode=me.schemaProperties=me.allSchemaProperties=me.noPropertyInData=me.propertyInData=me.isOwnProperty=me.hasPropFunc=me.reportMissingProp=me.checkMissingProp=me.checkReportMissingProp=void 0;const Re=he,xi=Q,zt=Ct,iE=Q;function cE(e,t){const{gen:r,data:n,it:s}=e;r.if(Mi(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Re._)`${t}`},!0),e.error()})}me.checkReportMissingProp=cE;function lE({gen:e,data:t,it:{opts:r}},n,s){return(0,Re.or)(...n.map(o=>(0,Re.and)(Mi(e,t,o,r.ownProperties),(0,Re._)`${s} = ${o}`)))}me.checkMissingProp=lE;function uE(e,t){e.setParams({missingProperty:t},!0),e.error()}me.reportMissingProp=uE;function mf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Re._)`Object.prototype.hasOwnProperty`})}me.hasPropFunc=mf;function Ai(e,t,r){return(0,Re._)`${mf(e)}.call(${t}, ${r})`}me.isOwnProperty=Ai;function dE(e,t,r,n){const s=(0,Re._)`${t}${(0,Re.getProperty)(r)} !== undefined`;return n?(0,Re._)`${s} && ${Ai(e,t,r)}`:s}me.propertyInData=dE;function Mi(e,t,r,n){const s=(0,Re._)`${t}${(0,Re.getProperty)(r)} === undefined`;return n?(0,Re.or)(s,(0,Re.not)(Ai(e,t,r))):s}me.noPropertyInData=Mi;function gf(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}me.allSchemaProperties=gf;function fE(e,t){return gf(t).filter(r=>!(0,xi.alwaysValidSchema)(e,t[r]))}me.schemaProperties=fE;function hE({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Re._)`${e}, ${t}, ${n}${s}`:t,h=[[zt.default.instancePath,(0,Re.strConcat)(zt.default.instancePath,o)],[zt.default.parentData,a.parentData],[zt.default.parentDataProperty,a.parentDataProperty],[zt.default.rootData,zt.default.rootData]];a.opts.dynamicRef&&h.push([zt.default.dynamicAnchors,zt.default.dynamicAnchors]);const m=(0,Re._)`${d}, ${r.object(...h)}`;return c!==Re.nil?(0,Re._)`${i}.call(${c}, ${m})`:(0,Re._)`${i}(${m})`}me.callValidateCode=hE;const pE=(0,Re._)`new RegExp`;function mE({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Re._)`${s.code==="new RegExp"?pE:(0,iE.useFunc)(e,s)}(${r}, ${n})`})}me.usePattern=mE;function gE(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,Re._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:xi.Type.Num},o),t.if((0,Re.not)(o),i)})}}me.validateArray=gE;function _E(e){const{gen:t,schema:r,keyword:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,xi.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,Re._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Re.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}me.validateUnion=_E;Object.defineProperty(Rt,"__esModule",{value:!0});Rt.validateKeywordUsage=Rt.validSchemaType=Rt.funcKeywordCode=Rt.macroKeywordCode=void 0;const rt=he,ar=Ct,yE=me,vE=jn;function $E(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=_f(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:rt.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}Rt.macroKeywordCode=$E;function wE(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;SE(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=_f(n,s,l),h=n.let("valid");e.block$data(h,m),e.ok((r=t.valid)!==null&&r!==void 0?r:h);function m(){if(t.errors===!1)_(),t.modifying&&bl(e),v(()=>e.error());else{const f=t.async?g():y();t.modifying&&bl(e),v(()=>bE(e,f))}}function g(){const f=n.let("ruleErrs",null);return n.try(()=>_((0,rt._)`await `),$=>n.assign(h,!1).if((0,rt._)`${$} instanceof ${c.ValidationError}`,()=>n.assign(f,(0,rt._)`${$}.errors`),()=>n.throw($))),f}function y(){const f=(0,rt._)`${d}.errors`;return n.assign(f,null),_(rt.nil),f}function _(f=t.async?(0,rt._)`await `:rt.nil){const $=c.opts.passContext?ar.default.this:ar.default.self,E=!("compile"in t&&!i||t.schema===!1);n.assign(h,(0,rt._)`${f}${(0,yE.callValidateCode)(e,d,$,E)}`,t.modifying)}function v(f){var $;n.if((0,rt.not)(($=t.valid)!==null&&$!==void 0?$:h),f)}}Rt.funcKeywordCode=wE;function bl(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,rt._)`${n.parentData}[${n.parentDataProperty}]`))}function bE(e,t){const{gen:r}=e;r.if((0,rt._)`Array.isArray(${t})`,()=>{r.assign(ar.default.vErrors,(0,rt._)`${ar.default.vErrors} === null ? ${t} : ${ar.default.vErrors}.concat(${t})`).assign(ar.default.errors,(0,rt._)`${ar.default.vErrors}.length`),(0,vE.extendErrors)(e)},()=>e.error())}function SE({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function _f(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,rt.stringify)(r)})}function EE(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}Rt.validSchemaType=EE;function kE({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");const a=s.dependencies;if(a!=null&&a.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){const c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Rt.validateKeywordUsage=kE;var Zt={};Object.defineProperty(Zt,"__esModule",{value:!0});Zt.extendSubschemaMode=Zt.extendSubschemaData=Zt.getSubschema=void 0;const Pt=he,yf=Q;function PE(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0,Pt._)`${e.schemaPath}${(0,Pt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,Pt._)`${e.schemaPath}${(0,Pt.getProperty)(t)}${(0,Pt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,yf.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Zt.getSubschema=PE;function RE(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:h}=t,m=i.let("data",(0,Pt._)`${t.data}${(0,Pt.getProperty)(r)}`,!0);c(m),e.errorPath=(0,Pt.str)`${l}${(0,yf.getErrorPath)(r,n,h.jsPropertySyntax)}`,e.parentDataProperty=(0,Pt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof Pt.Name?s:i.let("data",s,!0);c(l),a!==void 0&&(e.propertyName=a)}o&&(e.dataTypes=o);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}Zt.extendSubschemaData=RE;function TE(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}Zt.extendSubschemaMode=TE;var We={},vf={exports:{}},Vt=vf.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};rs(t,n,s,e,"",e)};Vt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Vt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Vt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Vt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function rs(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var h=n[d];if(Array.isArray(h)){if(d in Vt.arrayKeywords)for(var m=0;mt+=$f(n)),t===1/0))return 1/0}return t}function wf(e,t="",r){r!==!1&&(t=Nr(t));const n=e.parse(t);return bf(e,n)}We.getFullPath=wf;function bf(e,t){return e.serialize(t).split("#")[0]+"#"}We._getFullPath=bf;const zE=/#\/?$/;function Nr(e){return e?e.replace(zE,""):""}We.normalizeId=Nr;function qE(e,t,r){return r=Nr(r),e.resolve(t,r)}We.resolveUrl=qE;const DE=/^[a-z_][-a-z0-9._]*$/i;function UE(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Nr(e[r]||t),o={"":s},a=wf(n,s,!1),i={},c=new Set;return OE(e,{allKeys:!0},(h,m,g,y)=>{if(y===void 0)return;const _=a+m;let v=o[y];typeof h[r]=="string"&&(v=f.call(this,h[r])),$.call(this,h.$anchor),$.call(this,h.$dynamicAnchor),o[m]=v;function f(E){const T=this.opts.uriResolver.resolve;if(E=Nr(v?T(v,E):E),c.has(E))throw d(E);c.add(E);let k=this.refs[E];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?l(h,k.schema,E):E!==Nr(_)&&(E[0]==="#"?(l(h,i[E],E),i[E]=h):this.refs[E]=_),E}function $(E){if(typeof E=="string"){if(!DE.test(E))throw new Error(`invalid anchor "${E}"`);f.call(this,`#${E}`)}}}),i;function l(h,m,g){if(m!==void 0&&!IE(h,m))throw d(g)}function d(h){return new Error(`reference "${h}" resolves to more than one schema`)}}We.getSchemaRefs=UE;Object.defineProperty(St,"__esModule",{value:!0});St.getData=St.KeywordCxt=St.validateFunctionCode=void 0;const Sf=xr,Sl=De,zi=Ot,ys=De,FE=Hs,an=Rt,no=Zt,ne=he,oe=Ct,LE=We,xt=Q,Br=jn;function VE(e){if(Pf(e)&&(Rf(e),kf(e))){KE(e);return}Ef(e,()=>(0,Sf.topBoolOrEmptySchema)(e))}St.validateFunctionCode=VE;function Ef({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,ne._)`${oe.default.data}, ${oe.default.valCxt}`,n.$async,()=>{e.code((0,ne._)`"use strict"; ${El(r,s)}`),ZE(e,s),e.code(o)}):e.func(t,(0,ne._)`${oe.default.data}, ${HE(s)}`,n.$async,()=>e.code(El(r,s)).code(o))}function HE(e){return(0,ne._)`{${oe.default.instancePath}="", ${oe.default.parentData}, ${oe.default.parentDataProperty}, ${oe.default.rootData}=${oe.default.data}${e.dynamicRef?(0,ne._)`, ${oe.default.dynamicAnchors}={}`:ne.nil}}={}`}function ZE(e,t){e.if(oe.default.valCxt,()=>{e.var(oe.default.instancePath,(0,ne._)`${oe.default.valCxt}.${oe.default.instancePath}`),e.var(oe.default.parentData,(0,ne._)`${oe.default.valCxt}.${oe.default.parentData}`),e.var(oe.default.parentDataProperty,(0,ne._)`${oe.default.valCxt}.${oe.default.parentDataProperty}`),e.var(oe.default.rootData,(0,ne._)`${oe.default.valCxt}.${oe.default.rootData}`),t.dynamicRef&&e.var(oe.default.dynamicAnchors,(0,ne._)`${oe.default.valCxt}.${oe.default.dynamicAnchors}`)},()=>{e.var(oe.default.instancePath,(0,ne._)`""`),e.var(oe.default.parentData,(0,ne._)`undefined`),e.var(oe.default.parentDataProperty,(0,ne._)`undefined`),e.var(oe.default.rootData,oe.default.data),t.dynamicRef&&e.var(oe.default.dynamicAnchors,(0,ne._)`{}`)})}function KE(e){const{schema:t,opts:r,gen:n}=e;Ef(e,()=>{r.$comment&&t.$comment&&Cf(e),QE(e),n.let(oe.default.vErrors,null),n.let(oe.default.errors,0),r.unevaluated&&GE(e),Tf(e),ek(e)})}function GE(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,ne._)`${r}.evaluated`),t.if((0,ne._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,ne._)`${e.evaluated}.props`,(0,ne._)`undefined`)),t.if((0,ne._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,ne._)`${e.evaluated}.items`,(0,ne._)`undefined`))}function El(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,ne._)`/*# sourceURL=${r} */`:ne.nil}function WE(e,t){if(Pf(e)&&(Rf(e),kf(e))){BE(e,t);return}(0,Sf.boolOrEmptySchema)(e,t)}function kf({schema:e,self:t}){if(typeof e=="boolean")return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function Pf(e){return typeof e.schema!="boolean"}function BE(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Cf(e),YE(e),XE(e);const o=n.const("_errs",oe.default.errors);Tf(e,o),n.var(t,(0,ne._)`${o} === ${oe.default.errors}`)}function Rf(e){(0,xt.checkUnknownRules)(e),JE(e)}function Tf(e,t){if(e.opts.jtd)return kl(e,[],!1,t);const r=(0,Sl.getSchemaTypes)(e.schema),n=(0,Sl.coerceAndCheckDataType)(e,r);kl(e,r,!n,t)}function JE(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,xt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function QE(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,xt.checkStrictMode)(e,"default is ignored in the schema root")}function YE(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,LE.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function XE(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Cf({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,ne._)`${oe.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,ne.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,ne._)`${oe.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function ek(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,ne._)`${oe.default.errors} === 0`,()=>t.return(oe.default.data),()=>t.throw((0,ne._)`new ${s}(${oe.default.vErrors})`)):(t.assign((0,ne._)`${n}.errors`,oe.default.vErrors),o.unevaluated&&tk(e),t.return((0,ne._)`${oe.default.errors} === 0`))}function tk({gen:e,evaluated:t,props:r,items:n}){r instanceof ne.Name&&e.assign((0,ne._)`${t}.props`,r),n instanceof ne.Name&&e.assign((0,ne._)`${t}.items`,n)}function kl(e,t,r,n){const{gen:s,schema:o,data:a,allErrors:i,opts:c,self:l}=e,{RULES:d}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,xt.schemaHasRulesButRef)(o,d))){s.block(()=>If(e,"$ref",d.all.$ref.definition));return}c.jtd||rk(e,t),s.block(()=>{for(const m of d.rules)h(m);h(d.post)});function h(m){(0,zi.shouldUseGroup)(o,m)&&(m.type?(s.if((0,ys.checkDataType)(m.type,a,c.strictNumbers)),Pl(e,m),t.length===1&&t[0]===m.type&&r&&(s.else(),(0,ys.reportTypeError)(e)),s.endIf()):Pl(e,m),i||s.if((0,ne._)`${oe.default.errors} === ${n||0}`))}}function Pl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,FE.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,zi.shouldUseRule)(n,o)&&If(e,o.keyword,o.definition,t.type)})}function rk(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(nk(e,t),e.opts.allowUnionTypes||sk(e,t),ok(e,e.dataTypes))}function nk(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{jf(e.dataTypes,r)||qi(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),ik(e,t)}}function sk(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&qi(e,"use allowUnionTypes to allow union type keyword")}function ok(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,zi.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>ak(t,a))&&qi(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function ak(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function jf(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function ik(e,t){const r=[];for(const n of e.dataTypes)jf(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function qi(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,xt.checkStrictMode)(e,t,e.opts.strictTypes)}class Nf{constructor(t,r,n){if((0,an.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,xt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Of(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,an.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",oe.default.errors))}result(t,r,n){this.failResult((0,ne.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,ne.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:r}=this;this.fail((0,ne._)`${r} !== undefined && (${(0,ne.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?Br.reportExtraError:Br.reportError)(this,this.def.error,r)}$dataError(){(0,Br.reportError)(this,this.def.$dataError||Br.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Br.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=ne.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=ne.nil,r=ne.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,ne.or)((0,ne._)`${s} === undefined`,r)),t!==ne.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==ne.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,ne.or)(a(),i());function a(){if(n.length){if(!(r instanceof ne.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,ne._)`${(0,ys.checkDataTypes)(c,r,o.opts.strictNumbers,ys.DataType.Wrong)}`}return ne.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,ne._)`!${c}(${r})`}return ne.nil}}subschema(t,r){const n=(0,no.getSubschema)(this.it,t);(0,no.extendSubschemaData)(n,this.it,t),(0,no.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return WE(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=xt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=xt.mergeEvaluated.items(s,t.items,n.items,r)))}mergeValidEvaluated(t,r){const{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(t,ne.Name)),!0}}St.KeywordCxt=Nf;function If(e,t,r,n){const s=new Nf(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,an.funcKeywordCode)(s,r):"macro"in r?(0,an.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,an.funcKeywordCode)(s,r)}const ck=/^\/(?:[^~]|~0|~1)*$/,lk=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Of(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return oe.default.rootData;if(e[0]==="/"){if(!ck.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=oe.default.rootData}else{const l=lk.exec(e);if(!l)throw new Error(`Invalid JSON-pointer: ${e}`);const d=+l[1];if(s=l[2],s==="#"){if(d>=t)throw new Error(c("property/index",d));return n[t-d]}if(d>t)throw new Error(c("data",d));if(o=r[t-d],!s)return o}let a=o;const i=s.split("/");for(const l of i)l&&(o=(0,ne._)`${o}${(0,ne.getProperty)((0,xt.unescapeJsonPointer)(l))}`,a=(0,ne._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}St.getData=Of;var Nn={};Object.defineProperty(Nn,"__esModule",{value:!0});class uk extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}Nn.default=uk;var Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});const so=We;class dk extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,so.resolveUrl)(t,r,n),this.missingSchema=(0,so.normalizeId)((0,so.getFullPath)(t,this.missingRef))}}Fr.default=dk;var at={};Object.defineProperty(at,"__esModule",{value:!0});at.resolveSchema=at.getCompilingSchema=at.resolveRef=at.compileSchema=at.SchemaEnv=void 0;const yt=he,fk=Nn,er=Ct,bt=We,Rl=Q,hk=St;class Zs{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,bt.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}}at.SchemaEnv=Zs;function Di(e){const t=xf.call(this,e);if(t)return t;const r=(0,bt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new yt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:fk.default,code:(0,yt._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:er.default.data,parentData:er.default.parentData,parentDataProperty:er.default.parentDataProperty,dataNames:[er.default.data],dataPathArr:[yt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,yt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:yt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,yt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,hk.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const h=a.toString();d=`${a.scopeRefs(er.default.scope)}return ${h}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const g=new Function(`${er.default.self}`,`${er.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:g}),g.errors=null,g.schema=e.schema,g.schemaEnv=e,e.$async&&(g.$async=!0),this.opts.code.source===!0&&(g.source={validateName:c,validateCode:h,scopeValues:a._values}),this.opts.unevaluated){const{props:y,items:_}=l;g.evaluated={props:y instanceof yt.Name?void 0:y,items:_ instanceof yt.Name?void 0:_,dynamicProps:y instanceof yt.Name,dynamicItems:_ instanceof yt.Name},g.source&&(g.source.evaluated=(0,yt.stringify)(g.evaluated))}return e.validate=g,e}catch(h){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),h}finally{this._compilations.delete(e)}}at.compileSchema=Di;function pk(e,t,r){var n;r=(0,bt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=_k.call(this,e,r);if(o===void 0){const a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new Zs({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=mk.call(this,o)}at.resolveRef=pk;function mk(e){return(0,bt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Di.call(this,e)}function xf(e){for(const t of this._compilations)if(gk(t,e))return t}at.getCompilingSchema=xf;function gk(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function _k(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Ks.call(this,e,t)}function Ks(e,t){const r=this.opts.uriResolver.parse(t),n=(0,bt._getFullPath)(this.opts.uriResolver,r);let s=(0,bt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return oo.call(this,r,e);const o=(0,bt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Ks.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:oo.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Di.call(this,a),o===(0,bt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,bt.resolveUrl)(this.opts.uriResolver,s,l)),new Zs({schema:i,schemaId:c,root:e,baseId:s})}return oo.call(this,r,a)}}at.resolveSchema=Ks;const yk=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function oo(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(const i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;const c=r[(0,Rl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!yk.has(i)&&l&&(t=(0,bt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Rl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,bt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Ks.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Zs({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const vk="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",$k="Meta-schema for $data reference (JSON AnySchema extension proposal)",wk="object",bk=["$data"],Sk={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},Ek=!1,kk={$id:vk,description:$k,type:wk,required:bk,properties:Sk,additionalProperties:Ek};var Ui={};Object.defineProperty(Ui,"__esModule",{value:!0});const Af=Hd;Af.code='require("ajv/dist/runtime/uri").default';Ui.default=Af;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=St;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=he;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Nn,s=Fr,o=pr,a=at,i=he,c=We,l=De,d=Q,h=kk,m=Ui,g=(O,w)=>new RegExp(O,w);g.code="new RegExp";const y=["removeAdditional","useDefaults","coerceTypes"],_=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),v={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},f={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function E(O){var w,C,S,u,p,P,q,D,X,Y,j,I,U,W,ee,ce,xe,tt,Fe,Le,Ae,Et,Ye,Wt,Bt;const mt=O.strict,Jt=(w=O.code)===null||w===void 0?void 0:w.optimize,Hr=Jt===!0||Jt===void 0?1:Jt||0,Zr=(S=(C=O.code)===null||C===void 0?void 0:C.regExp)!==null&&S!==void 0?S:g,Bs=(u=O.uriResolver)!==null&&u!==void 0?u:m.default;return{strictSchema:(P=(p=O.strictSchema)!==null&&p!==void 0?p:mt)!==null&&P!==void 0?P:!0,strictNumbers:(D=(q=O.strictNumbers)!==null&&q!==void 0?q:mt)!==null&&D!==void 0?D:!0,strictTypes:(Y=(X=O.strictTypes)!==null&&X!==void 0?X:mt)!==null&&Y!==void 0?Y:"log",strictTuples:(I=(j=O.strictTuples)!==null&&j!==void 0?j:mt)!==null&&I!==void 0?I:"log",strictRequired:(W=(U=O.strictRequired)!==null&&U!==void 0?U:mt)!==null&&W!==void 0?W:!1,code:O.code?{...O.code,optimize:Hr,regExp:Zr}:{optimize:Hr,regExp:Zr},loopRequired:(ee=O.loopRequired)!==null&&ee!==void 0?ee:$,loopEnum:(ce=O.loopEnum)!==null&&ce!==void 0?ce:$,meta:(xe=O.meta)!==null&&xe!==void 0?xe:!0,messages:(tt=O.messages)!==null&&tt!==void 0?tt:!0,inlineRefs:(Fe=O.inlineRefs)!==null&&Fe!==void 0?Fe:!0,schemaId:(Le=O.schemaId)!==null&&Le!==void 0?Le:"$id",addUsedSchema:(Ae=O.addUsedSchema)!==null&&Ae!==void 0?Ae:!0,validateSchema:(Et=O.validateSchema)!==null&&Et!==void 0?Et:!0,validateFormats:(Ye=O.validateFormats)!==null&&Ye!==void 0?Ye:!0,unicodeRegExp:(Wt=O.unicodeRegExp)!==null&&Wt!==void 0?Wt:!0,int32range:(Bt=O.int32range)!==null&&Bt!==void 0?Bt:!0,uriResolver:Bs}}class T{constructor(w={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,w=this.opts={...w,...E(w)};const{es5:C,lines:S}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:_,es5:C,lines:S}),this.logger=B(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),k.call(this,v,w,"NOT SUPPORTED"),k.call(this,f,w,"DEPRECATED","warn"),this._metaOpts=V.call(this),w.formats&&L.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&F.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),M.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:S}=this.opts;let u=h;S==="id"&&(u={...h},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[S],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){let S;if(typeof w=="string"){if(S=this.getSchema(w),!S)throw new Error(`no schema with key or ref "${w}"`)}else S=this.compile(w);const u=S(C);return"$async"in S||(this.errors=S.errors),u}compile(w,C){const S=this._addSchema(w,C);return S.validate||this._compileSchemaEnv(S)}compileAsync(w,C){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:S}=this.opts;return u.call(this,w,C);async function u(Y,j){await p.call(this,Y.$schema);const I=this._addSchema(Y,j);return I.validate||P.call(this,I)}async function p(Y){Y&&!this.getSchema(Y)&&await u.call(this,{$ref:Y},!0)}async function P(Y){try{return this._compileSchemaEnv(Y)}catch(j){if(!(j instanceof s.default))throw j;return q.call(this,j),await D.call(this,j.missingSchema),P.call(this,Y)}}function q({missingSchema:Y,missingRef:j}){if(this.refs[Y])throw new Error(`AnySchema ${Y} is loaded but ${j} cannot be resolved`)}async function D(Y){const j=await X.call(this,Y);this.refs[Y]||await p.call(this,j.$schema),this.refs[Y]||this.addSchema(j,Y,C)}async function X(Y){const j=this._loading[Y];if(j)return j;try{return await(this._loading[Y]=S(Y))}finally{delete this._loading[Y]}}}addSchema(w,C,S,u=this.opts.validateSchema){if(Array.isArray(w)){for(const P of w)this.addSchema(P,void 0,S,u);return this}let p;if(typeof w=="object"){const{schemaId:P}=this.opts;if(p=w[P],p!==void 0&&typeof p!="string")throw new Error(`schema ${P} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,S,C,u,!0),this}addMetaSchema(w,C,S=this.opts.validateSchema){return this.addSchema(w,C,!0,S),this}validateSchema(w,C){if(typeof w=="boolean")return!0;let S;if(S=w.$schema,S!==void 0&&typeof S!="string")throw new Error("$schema must be a string");if(S=S||this.opts.defaultMeta||this.defaultMeta(),!S)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(S,w);if(!u&&C){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let C;for(;typeof(C=x.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:S}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:S});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const C=x.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);let S=w[this.opts.schemaId];return S&&(S=(0,c.normalizeId)(S),delete this.schemas[S],delete this.refs[S]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const C of w)this.addKeyword(C);return this}addKeyword(w,C){let S;if(typeof w=="string")S=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=S);else if(typeof w=="object"&&C===void 0){if(C=w,S=C.keyword,Array.isArray(S)&&!S.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(H.call(this,S,C),!C)return(0,d.eachItem)(S,p=>ie.call(this,p)),this;ye.call(this,C);const u={...C,type:(0,l.getJSONTypes)(C.type),schemaType:(0,l.getJSONTypes)(C.schemaType)};return(0,d.eachItem)(S,u.type.length===0?p=>ie.call(this,p,u):p=>u.type.forEach(P=>ie.call(this,p,u,P))),this}getKeyword(w){const C=this.RULES.all[w];return typeof C=="object"?C.definition:!!C}removeKeyword(w){const{RULES:C}=this;delete C.keywords[w],delete C.all[w];for(const S of C.rules){const u=S.rules.findIndex(p=>p.keyword===w);u>=0&&S.rules.splice(u,1)}return this}addFormat(w,C){return typeof C=="string"&&(C=new RegExp(C)),this.formats[w]=C,this}errorsText(w=this.errors,{separator:C=", ",dataVar:S="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${S}${u.instancePath} ${u.message}`).reduce((u,p)=>u+C+p)}$dataMetaSchema(w,C){const S=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of C){const p=u.split("/").slice(1);let P=w;for(const q of p)P=P[q];for(const q in S){const D=S[q];if(typeof D!="object")continue;const{$data:X}=D.definition,Y=P[q];X&&Y&&(P[q]=Oe(Y))}}return w}_removeAllSchemas(w,C){for(const S in w){const u=w[S];(!C||C.test(S))&&(typeof u=="string"?delete w[S]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[S]))}}_addSchema(w,C,S,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let P;const{schemaId:q}=this.opts;if(typeof w=="object")P=w[q];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let D=this._cache.get(w);if(D!==void 0)return D;S=(0,c.normalizeId)(P||S);const X=c.getSchemaRefs.call(this,w,S);return D=new a.SchemaEnv({schema:w,schemaId:q,meta:C,baseId:S,localRefs:X}),this._cache.set(D.schema,D),p&&!S.startsWith("#")&&(S&&this._checkUnique(S),this.refs[S]=D),u&&this.validateSchema(w,!0),D}_checkUnique(w){if(this.schemas[w]||this.refs[w])throw new Error(`schema with key or id "${w}" already exists`)}_compileSchemaEnv(w){if(w.meta?this._compileMetaSchema(w):a.compileSchema.call(this,w),!w.validate)throw new Error("ajv implementation error");return w.validate}_compileMetaSchema(w){const C=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=C}}}T.ValidationError=n.default,T.MissingRefError=s.default,e.default=T;function k(O,w,C,S="error"){for(const u in O){const p=u;p in w&&this.logger[S](`${C}: option ${u}. ${O[p]}`)}}function x(O){return O=(0,c.normalizeId)(O),this.schemas[O]||this.refs[O]}function M(){const O=this.opts.schemas;if(O)if(Array.isArray(O))this.addSchema(O);else for(const w in O)this.addSchema(O[w],w)}function L(){for(const O in this.opts.formats){const w=this.opts.formats[O];w&&this.addFormat(O,w)}}function F(O){if(Array.isArray(O)){this.addVocabulary(O);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in O){const C=O[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function V(){const O={...this.opts};for(const w of y)delete O[w];return O}const Z={log(){},warn(){},error(){}};function B(O){if(O===!1)return Z;if(O===void 0)return console;if(O.log&&O.warn&&O.error)return O;throw new Error("logger must implement log, warn and error methods")}const re=/^[a-z_$][a-z0-9_$:-]*$/i;function H(O,w){const{RULES:C}=this;if((0,d.eachItem)(O,S=>{if(C.keywords[S])throw new Error(`Keyword ${S} is already defined`);if(!re.test(S))throw new Error(`Keyword ${S} has invalid name`)}),!!w&&w.$data&&!("code"in w||"validate"in w))throw new Error('$data keyword must have "code" or "validate" function')}function ie(O,w,C){var S;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let P=u?p.post:p.rules.find(({type:D})=>D===C);if(P||(P={type:C,rules:[]},p.rules.push(P)),p.keywords[O]=!0,!w)return;const q={keyword:O,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?ke.call(this,P,q,w.before):P.rules.push(q),p.all[O]=q,(S=w.implements)===null||S===void 0||S.forEach(D=>this.addKeyword(D))}function ke(O,w,C){const S=O.rules.findIndex(u=>u.keyword===C);S>=0?O.rules.splice(S,0,w):(O.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function ye(O){let{metaSchema:w}=O;w!==void 0&&(O.$data&&this.opts.$data&&(w=Oe(w)),O.validateSchema=this.compile(w,!0))}const ct={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oe(O){return{anyOf:[O,ct]}}})(rf);var Fi={},Li={},Vi={};Object.defineProperty(Vi,"__esModule",{value:!0});const Pk={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Vi.default=Pk;var mr={};Object.defineProperty(mr,"__esModule",{value:!0});mr.callRef=mr.getValidate=void 0;const Rk=Fr,Tl=me,st=he,$r=Ct,Cl=at,Vn=Q,Tk={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return h();const d=Cl.resolveRef.call(c,l,s,r);if(d===void 0)throw new Rk.default(n.opts.uriResolver,s,r);if(d instanceof Cl.SchemaEnv)return m(d);return g(d);function h(){if(o===l)return ns(e,a,o,o.$async);const y=t.scopeValue("root",{ref:l});return ns(e,(0,st._)`${y}.validate`,l,l.$async)}function m(y){const _=Mf(e,y);ns(e,_,y,y.$async)}function g(y){const _=t.scopeValue("schema",i.code.source===!0?{ref:y,code:(0,st.stringify)(y)}:{ref:y}),v=t.name("valid"),f=e.subschema({schema:y,dataTypes:[],schemaPath:st.nil,topSchemaRef:_,errSchemaPath:r},v);e.mergeEvaluated(f),e.ok(v)}}};function Mf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,st._)`${r.scopeValue("wrapper",{ref:t})}.validate`}mr.getValidate=Mf;function ns(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?$r.default.this:st.nil;n?d():h();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const y=s.let("valid");s.try(()=>{s.code((0,st._)`await ${(0,Tl.callValidateCode)(e,t,l)}`),g(t),a||s.assign(y,!0)},_=>{s.if((0,st._)`!(${_} instanceof ${o.ValidationError})`,()=>s.throw(_)),m(_),a||s.assign(y,!1)}),e.ok(y)}function h(){e.result((0,Tl.callValidateCode)(e,t,l),()=>g(t),()=>m(t))}function m(y){const _=(0,st._)`${y}.errors`;s.assign($r.default.vErrors,(0,st._)`${$r.default.vErrors} === null ? ${_} : ${$r.default.vErrors}.concat(${_})`),s.assign($r.default.errors,(0,st._)`${$r.default.vErrors}.length`)}function g(y){var _;if(!o.opts.unevaluated)return;const v=(_=r==null?void 0:r.validate)===null||_===void 0?void 0:_.evaluated;if(o.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(o.props=Vn.mergeEvaluated.props(s,v.props,o.props));else{const f=s.var("props",(0,st._)`${y}.evaluated.props`);o.props=Vn.mergeEvaluated.props(s,f,o.props,st.Name)}if(o.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(o.items=Vn.mergeEvaluated.items(s,v.items,o.items));else{const f=s.var("items",(0,st._)`${y}.evaluated.items`);o.items=Vn.mergeEvaluated.items(s,f,o.items,st.Name)}}}mr.callRef=ns;mr.default=Tk;Object.defineProperty(Li,"__esModule",{value:!0});const Ck=Vi,jk=mr,Nk=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Ck.default,jk.default];Li.default=Nk;var Hi={},Zi={};Object.defineProperty(Zi,"__esModule",{value:!0});const vs=he,qt=vs.operators,$s={maximum:{okStr:"<=",ok:qt.LTE,fail:qt.GT},minimum:{okStr:">=",ok:qt.GTE,fail:qt.LT},exclusiveMaximum:{okStr:"<",ok:qt.LT,fail:qt.GTE},exclusiveMinimum:{okStr:">",ok:qt.GT,fail:qt.LTE}},Ik={message:({keyword:e,schemaCode:t})=>(0,vs.str)`must be ${$s[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,vs._)`{comparison: ${$s[e].okStr}, limit: ${t}}`},Ok={keyword:Object.keys($s),type:"number",schemaType:"number",$data:!0,error:Ik,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,vs._)`${r} ${$s[t].fail} ${n} || isNaN(${r})`)}};Zi.default=Ok;var Ki={};Object.defineProperty(Ki,"__esModule",{value:!0});const cn=he,xk={message:({schemaCode:e})=>(0,cn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,cn._)`{multipleOf: ${e}}`},Ak={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:xk,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,cn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,cn._)`${a} !== parseInt(${a})`;e.fail$data((0,cn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};Ki.default=Ak;var Gi={},Wi={};Object.defineProperty(Wi,"__esModule",{value:!0});function zf(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,ir._)`{limit: ${e}}`},Dk={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:qk,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?ir.operators.GT:ir.operators.LT,a=s.opts.unicode===!1?(0,ir._)`${r}.length`:(0,ir._)`${(0,Mk.useFunc)(e.gen,zk.default)}(${r})`;e.fail$data((0,ir._)`${a} ${o} ${n}`)}};Gi.default=Dk;var Bi={};Object.defineProperty(Bi,"__esModule",{value:!0});const Uk=me,Fk=Q,Rr=he,Lk={message:({schemaCode:e})=>(0,Rr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Rr._)`{pattern: ${e}}`},Vk={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Lk,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:c}=a.opts.code,l=c.code==="new RegExp"?(0,Rr._)`new RegExp`:(0,Fk.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Rr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Rr._)`!${d}`)}else{const c=(0,Uk.usePattern)(e,s);e.fail$data((0,Rr._)`!${c}.test(${r})`)}}};Bi.default=Vk;var Ji={};Object.defineProperty(Ji,"__esModule",{value:!0});const ln=he,Hk={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,ln.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,ln._)`{limit: ${e}}`},Zk={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Hk,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?ln.operators.GT:ln.operators.LT;e.fail$data((0,ln._)`Object.keys(${r}).length ${s} ${n}`)}};Ji.default=Zk;var Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});const Jr=me,un=he,Kk=Q,Gk={message:({params:{missingProperty:e}})=>(0,un.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,un._)`{missingProperty: ${e}}`},Wk={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Gk,code(e){const{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;const c=r.length>=i.loopRequired;if(a.allErrors?l():d(),i.strictRequired){const g=e.parentSchema.properties,{definedProperties:y}=e.it;for(const _ of r)if((g==null?void 0:g[_])===void 0&&!y.has(_)){const v=a.schemaEnv.baseId+a.errSchemaPath,f=`required property "${_}" is not defined at "${v}" (strictRequired)`;(0,Kk.checkStrictMode)(a,f,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(un.nil,h);else for(const g of r)(0,Jr.checkReportMissingProp)(e,g)}function d(){const g=t.let("missing");if(c||o){const y=t.let("valid",!0);e.block$data(y,()=>m(g,y)),e.ok(y)}else t.if((0,Jr.checkMissingProp)(e,r,g)),(0,Jr.reportMissingProp)(e,g),t.else()}function h(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0,Jr.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error())})}function m(g,y){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(y,(0,Jr.propertyInData)(t,s,g,i.ownProperties)),t.if((0,un.not)(y),()=>{e.error(),t.break()})},un.nil)}}};Qi.default=Wk;var Yi={};Object.defineProperty(Yi,"__esModule",{value:!0});const dn=he,Bk={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,dn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,dn._)`{limit: ${e}}`},Jk={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Bk,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?dn.operators.GT:dn.operators.LT;e.fail$data((0,dn._)`${r}.length ${s} ${n}`)}};Yi.default=Jk;var Xi={},In={};Object.defineProperty(In,"__esModule",{value:!0});const qf=zs;qf.code='require("ajv/dist/runtime/equal").default';In.default=qf;Object.defineProperty(Xi,"__esModule",{value:!0});const ao=De,Ze=he,Qk=Q,Yk=In,Xk={message:({params:{i:e,j:t}})=>(0,Ze.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Ze._)`{i: ${e}, j: ${t}}`},eP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Xk,code(e){const{gen:t,data:r,$data:n,schema:s,parentSchema:o,schemaCode:a,it:i}=e;if(!n&&!s)return;const c=t.let("valid"),l=o.items?(0,ao.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,Ze._)`${a} === false`),e.ok(c);function d(){const y=t.let("i",(0,Ze._)`${r}.length`),_=t.let("j");e.setParams({i:y,j:_}),t.assign(c,!0),t.if((0,Ze._)`${y} > 1`,()=>(h()?m:g)(y,_))}function h(){return l.length>0&&!l.some(y=>y==="object"||y==="array")}function m(y,_){const v=t.name("item"),f=(0,ao.checkDataTypes)(l,v,i.opts.strictNumbers,ao.DataType.Wrong),$=t.const("indices",(0,Ze._)`{}`);t.for((0,Ze._)`;${y}--;`,()=>{t.let(v,(0,Ze._)`${r}[${y}]`),t.if(f,(0,Ze._)`continue`),l.length>1&&t.if((0,Ze._)`typeof ${v} == "string"`,(0,Ze._)`${v} += "_"`),t.if((0,Ze._)`typeof ${$}[${v}] == "number"`,()=>{t.assign(_,(0,Ze._)`${$}[${v}]`),e.error(),t.assign(c,!1).break()}).code((0,Ze._)`${$}[${v}] = ${y}`)})}function g(y,_){const v=(0,Qk.useFunc)(t,Yk.default),f=t.name("outer");t.label(f).for((0,Ze._)`;${y}--;`,()=>t.for((0,Ze._)`${_} = ${y}; ${_}--;`,()=>t.if((0,Ze._)`${v}(${r}[${y}], ${r}[${_}])`,()=>{e.error(),t.assign(c,!1).break(f)})))}}};Xi.default=eP;var ec={};Object.defineProperty(ec,"__esModule",{value:!0});const qo=he,tP=Q,rP=In,nP={message:"must be equal to constant",params:({schemaCode:e})=>(0,qo._)`{allowedValue: ${e}}`},sP={keyword:"const",$data:!0,error:nP,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,qo._)`!${(0,tP.useFunc)(t,rP.default)}(${r}, ${s})`):e.fail((0,qo._)`${o} !== ${r}`)}};ec.default=sP;var tc={};Object.defineProperty(tc,"__esModule",{value:!0});const en=he,oP=Q,aP=In,iP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,en._)`{allowedValues: ${e}}`},cP={keyword:"enum",schemaType:"array",$data:!0,error:iP,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e;if(!n&&s.length===0)throw new Error("enum must have non-empty array");const i=s.length>=a.opts.loopEnum;let c;const l=()=>c??(c=(0,oP.useFunc)(t,aP.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,h);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const g=t.const("vSchema",o);d=(0,en.or)(...s.map((y,_)=>m(g,_)))}e.pass(d);function h(){t.assign(d,!1),t.forOf("v",o,g=>t.if((0,en._)`${l()}(${r}, ${g})`,()=>t.assign(d,!0).break()))}function m(g,y){const _=s[y];return typeof _=="object"&&_!==null?(0,en._)`${l()}(${r}, ${g}[${y}])`:(0,en._)`${r} === ${_}`}}};tc.default=cP;Object.defineProperty(Hi,"__esModule",{value:!0});const lP=Zi,uP=Ki,dP=Gi,fP=Bi,hP=Ji,pP=Qi,mP=Yi,gP=Xi,_P=ec,yP=tc,vP=[lP.default,uP.default,dP.default,fP.default,hP.default,pP.default,mP.default,gP.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},_P.default,yP.default];Hi.default=vP;var rc={},Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});Lr.validateAdditionalItems=void 0;const cr=he,Do=Q,$P={message:({params:{len:e}})=>(0,cr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,cr._)`{limit: ${e}}`},wP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:$P,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Do.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Df(e,n)}};function Df(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,cr._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,cr._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Do.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,cr._)`${i} <= ${t.length}`);r.if((0,cr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Do.Type.Num},l),a.allErrors||r.if((0,cr.not)(l),()=>r.break())})}}Lr.validateAdditionalItems=Df;Lr.default=wP;var nc={},Vr={};Object.defineProperty(Vr,"__esModule",{value:!0});Vr.validateTuple=void 0;const jl=he,ss=Q,bP=me,SP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Uf(e,"additionalItems",t);r.items=!0,!(0,ss.alwaysValidSchema)(r,t)&&e.ok((0,bP.validateArray)(e))}};function Uf(e,t,r=e.schema){const{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==!0&&(i.items=ss.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,jl._)`${o}.length`);r.forEach((h,m)=>{(0,ss.alwaysValidSchema)(i,h)||(n.if((0,jl._)`${l} > ${m}`,()=>e.subschema({keyword:a,schemaProp:m,dataProp:m},c)),e.ok(c))});function d(h){const{opts:m,errSchemaPath:g}=i,y=r.length,_=y===h.minItems&&(y===h.maxItems||h[t]===!1);if(m.strictTuples&&!_){const v=`"${a}" is ${y}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0,ss.checkStrictMode)(i,v,m.strictTuples)}}}Vr.validateTuple=Uf;Vr.default=SP;Object.defineProperty(nc,"__esModule",{value:!0});const EP=Vr,kP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,EP.validateTuple)(e,"items")};nc.default=kP;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});const Nl=he,PP=Q,RP=me,TP=Lr,CP={message:({params:{len:e}})=>(0,Nl.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Nl._)`{limit: ${e}}`},jP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:CP,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,PP.alwaysValidSchema)(n,t)&&(s?(0,TP.validateAdditionalItems)(e,s):e.ok((0,RP.validateArray)(e)))}};sc.default=jP;var oc={};Object.defineProperty(oc,"__esModule",{value:!0});const ft=he,Hn=Q,NP={message:({params:{min:e,max:t}})=>t===void 0?(0,ft.str)`must contain at least ${e} valid item(s)`:(0,ft.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,ft._)`{minContains: ${e}}`:(0,ft._)`{minContains: ${e}, maxContains: ${t}}`},IP={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:NP,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,ft._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Hn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Hn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Hn.alwaysValidSchema)(o,r)){let _=(0,ft._)`${d} >= ${a}`;i!==void 0&&(_=(0,ft._)`${_} && ${d} <= ${i}`),e.pass(_);return}o.items=!0;const h=t.name("valid");i===void 0&&a===1?g(h,()=>t.if(h,()=>t.break())):a===0?(t.let(h,!0),i!==void 0&&t.if((0,ft._)`${s}.length > 0`,m)):(t.let(h,!1),m()),e.result(h,()=>e.reset());function m(){const _=t.name("_valid"),v=t.let("count",0);g(_,()=>t.if(_,()=>y(v)))}function g(_,v){t.forRange("i",0,d,f=>{e.subschema({keyword:"contains",dataProp:f,dataPropType:Hn.Type.Num,compositeRule:!0},_),v()})}function y(_){t.code((0,ft._)`${_}++`),i===void 0?t.if((0,ft._)`${_} >= ${a}`,()=>t.assign(h,!0).break()):(t.if((0,ft._)`${_} > ${i}`,()=>t.assign(h,!1).break()),a===1?t.assign(h,!0):t.if((0,ft._)`${_} >= ${a}`,()=>t.assign(h,!0)))}}};oc.default=IP;var Ff={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=he,r=Q,n=me;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const h=l===1?"property":"properties";return(0,t.str)`must have ${h} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:h}})=>(0,t._)`{property: ${c}, + missingProperty: ${h}, + depsCount: ${l}, + deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const h in c){if(h==="__proto__")continue;const m=Array.isArray(c[h])?l:d;m[h]=c[h]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:h,it:m}=c;if(Object.keys(l).length===0)return;const g=d.let("missing");for(const y in l){const _=l[y];if(_.length===0)continue;const v=(0,n.propertyInData)(d,h,y,m.opts.ownProperties);c.setParams({property:y,depsCount:_.length,deps:_.join(", ")}),m.allErrors?d.if(v,()=>{for(const f of _)(0,n.checkReportMissingProp)(c,f)}):(d.if((0,t._)`${v} && (${(0,n.checkMissingProp)(c,_,g)})`),(0,n.reportMissingProp)(c,g),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:h,keyword:m,it:g}=c,y=d.name("valid");for(const _ in l)(0,r.alwaysValidSchema)(g,l[_])||(d.if((0,n.propertyInData)(d,h,_,g.opts.ownProperties),()=>{const v=c.subschema({keyword:m,schemaProp:_},y);c.mergeValidEvaluated(v,y)},()=>d.var(y,!0)),c.ok(y))}e.validateSchemaDeps=i,e.default=s})(Ff);var ac={};Object.defineProperty(ac,"__esModule",{value:!0});const Lf=he,OP=Q,xP={message:"property name must be valid",params:({params:e})=>(0,Lf._)`{propertyName: ${e.propertyName}}`},AP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:xP,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,OP.alwaysValidSchema)(s,r))return;const o=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},o),t.if((0,Lf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};ac.default=AP;var Gs={};Object.defineProperty(Gs,"__esModule",{value:!0});const Zn=me,$t=he,MP=Ct,Kn=Q,zP={message:"must NOT have additional properties",params:({params:e})=>(0,$t._)`{additionalProperty: ${e.additionalProperty}}`},qP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:zP,code(e){const{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,Kn.alwaysValidSchema)(a,r))return;const l=(0,Zn.allSchemaProperties)(n.properties),d=(0,Zn.allSchemaProperties)(n.patternProperties);h(),e.ok((0,$t._)`${o} === ${MP.default.errors}`);function h(){t.forIn("key",s,v=>{!l.length&&!d.length?y(v):t.if(m(v),()=>y(v))})}function m(v){let f;if(l.length>8){const $=(0,Kn.schemaRefOrVal)(a,n.properties,"properties");f=(0,Zn.isOwnProperty)(t,$,v)}else l.length?f=(0,$t.or)(...l.map($=>(0,$t._)`${v} === ${$}`)):f=$t.nil;return d.length&&(f=(0,$t.or)(f,...d.map($=>(0,$t._)`${(0,Zn.usePattern)(e,$)}.test(${v})`))),(0,$t.not)(f)}function g(v){t.code((0,$t._)`delete ${s}[${v}]`)}function y(v){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){g(v);return}if(r===!1){e.setParams({additionalProperty:v}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Kn.alwaysValidSchema)(a,r)){const f=t.name("valid");c.removeAdditional==="failing"?(_(v,f,!1),t.if((0,$t.not)(f),()=>{e.reset(),g(v)})):(_(v,f),i||t.if((0,$t.not)(f),()=>t.break()))}}function _(v,f,$){const E={keyword:"additionalProperties",dataProp:v,dataPropType:Kn.Type.Str};$===!1&&Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(E,f)}}};Gs.default=qP;var ic={};Object.defineProperty(ic,"__esModule",{value:!0});const DP=St,Il=me,io=Q,Ol=Gs,UP={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Ol.default.code(new DP.KeywordCxt(o,Ol.default,"additionalProperties"));const a=(0,Il.allSchemaProperties)(r);for(const h of a)o.definedProperties.add(h);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=io.mergeEvaluated.props(t,(0,io.toHash)(a),o.props));const i=a.filter(h=>!(0,io.alwaysValidSchema)(o,r[h]));if(i.length===0)return;const c=t.name("valid");for(const h of i)l(h)?d(h):(t.if((0,Il.propertyInData)(t,s,h,o.opts.ownProperties)),d(h),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(h),e.ok(c);function l(h){return o.opts.useDefaults&&!o.compositeRule&&r[h].default!==void 0}function d(h){e.subschema({keyword:"properties",schemaProp:h,dataProp:h},c)}}};ic.default=UP;var cc={};Object.defineProperty(cc,"__esModule",{value:!0});const xl=me,Gn=he,Al=Q,Ml=Q,FP={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,data:n,parentSchema:s,it:o}=e,{opts:a}=o,i=(0,xl.allSchemaProperties)(r),c=i.filter(_=>(0,Al.alwaysValidSchema)(o,r[_]));if(i.length===0||c.length===i.length&&(!o.opts.unevaluated||o.props===!0))return;const l=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==!0&&!(o.props instanceof Gn.Name)&&(o.props=(0,Ml.evaluatedPropsToName)(t,o.props));const{props:h}=o;m();function m(){for(const _ of i)l&&g(_),o.allErrors?y(_):(t.var(d,!0),y(_),t.if(d))}function g(_){for(const v in l)new RegExp(_).test(v)&&(0,Al.checkStrictMode)(o,`property ${v} matches pattern ${_} (use allowMatchingProperties)`)}function y(_){t.forIn("key",n,v=>{t.if((0,Gn._)`${(0,xl.usePattern)(e,_)}.test(${v})`,()=>{const f=c.includes(_);f||e.subschema({keyword:"patternProperties",schemaProp:_,dataProp:v,dataPropType:Ml.Type.Str},d),o.opts.unevaluated&&h!==!0?t.assign((0,Gn._)`${h}[${v}]`,!0):!f&&!o.allErrors&&t.if((0,Gn.not)(d),()=>t.break())})})}}};cc.default=FP;var lc={};Object.defineProperty(lc,"__esModule",{value:!0});const LP=Q,VP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,LP.alwaysValidSchema)(n,r)){e.fail();return}const s=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),e.failResult(s,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};lc.default=VP;var uc={};Object.defineProperty(uc,"__esModule",{value:!0});const HP=me,ZP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:HP.validateUnion,error:{message:"must match a schema in anyOf"}};uc.default=ZP;var dc={};Object.defineProperty(dc,"__esModule",{value:!0});const os=he,KP=Q,GP={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,os._)`{passingSchemas: ${e.passing}}`},WP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:GP,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,h)=>{let m;(0,KP.alwaysValidSchema)(s,d)?t.var(c,!0):m=e.subschema({keyword:"oneOf",schemaProp:h,compositeRule:!0},c),h>0&&t.if((0,os._)`${c} && ${a}`).assign(a,!1).assign(i,(0,os._)`[${i}, ${h}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,h),m&&e.mergeEvaluated(m,os.Name)})})}}};dc.default=WP;var fc={};Object.defineProperty(fc,"__esModule",{value:!0});const BP=Q,JP={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");const s=t.name("valid");r.forEach((o,a)=>{if((0,BP.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};fc.default=JP;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});const ws=he,Vf=Q,QP={message:({params:e})=>(0,ws.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,ws._)`{failingKeyword: ${e.ifClause}}`},YP={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:QP,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Vf.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=zl(n,"then"),o=zl(n,"else");if(!s&&!o)return;const a=t.let("valid",!0),i=t.name("_valid");if(c(),e.reset(),s&&o){const d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,l("then",d),l("else",d))}else s?t.if(i,l("then")):t.if((0,ws.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,h){return()=>{const m=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(m,a),h?t.assign(h,(0,ws._)`${d}`):e.setParams({ifClause:d})}}}};function zl(e,t){const r=e.schema[t];return r!==void 0&&!(0,Vf.alwaysValidSchema)(e,r)}hc.default=YP;var pc={};Object.defineProperty(pc,"__esModule",{value:!0});const XP=Q,e1={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,XP.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};pc.default=e1;Object.defineProperty(rc,"__esModule",{value:!0});const t1=Lr,r1=nc,n1=Vr,s1=sc,o1=oc,a1=Ff,i1=ac,c1=Gs,l1=ic,u1=cc,d1=lc,f1=uc,h1=dc,p1=fc,m1=hc,g1=pc;function _1(e=!1){const t=[d1.default,f1.default,h1.default,p1.default,m1.default,g1.default,i1.default,c1.default,a1.default,l1.default,u1.default];return e?t.push(r1.default,s1.default):t.push(t1.default,n1.default),t.push(o1.default),t}rc.default=_1;var mc={},gc={};Object.defineProperty(gc,"__esModule",{value:!0});const ze=he,y1={message:({schemaCode:e})=>(0,ze.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ze._)`{format: ${e}}`},v1={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:y1,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:h}=i;if(!c.validateFormats)return;s?m():g();function m(){const y=r.scopeValue("formats",{ref:h.formats,code:c.code.formats}),_=r.const("fDef",(0,ze._)`${y}[${a}]`),v=r.let("fType"),f=r.let("format");r.if((0,ze._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(v,(0,ze._)`${_}.type || "string"`).assign(f,(0,ze._)`${_}.validate`),()=>r.assign(v,(0,ze._)`"string"`).assign(f,_)),e.fail$data((0,ze.or)($(),E()));function $(){return c.strictSchema===!1?ze.nil:(0,ze._)`${a} && !${f}`}function E(){const T=d.$async?(0,ze._)`(${_}.async ? await ${f}(${n}) : ${f}(${n}))`:(0,ze._)`${f}(${n})`,k=(0,ze._)`(typeof ${f} == "function" ? ${T} : ${f}.test(${n}))`;return(0,ze._)`${f} && ${f} !== true && ${v} === ${t} && !${k}`}}function g(){const y=h.formats[o];if(!y){$();return}if(y===!0)return;const[_,v,f]=E(y);_===t&&e.pass(T());function $(){if(c.strictSchema===!1){h.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function E(k){const x=k instanceof RegExp?(0,ze.regexpCode)(k):c.code.formats?(0,ze._)`${c.code.formats}${(0,ze.getProperty)(o)}`:void 0,M=r.scopeValue("formats",{key:o,ref:k,code:x});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,ze._)`${M}.validate`]:["string",k,M]}function T(){if(typeof y=="object"&&!(y instanceof RegExp)&&y.async){if(!d.$async)throw new Error("async format in sync schema");return(0,ze._)`await ${f}(${n})`}return typeof v=="function"?(0,ze._)`${f}(${n})`:(0,ze._)`${f}.test(${n})`}}}};gc.default=v1;Object.defineProperty(mc,"__esModule",{value:!0});const $1=gc,w1=[$1.default];mc.default=w1;var Ar={};Object.defineProperty(Ar,"__esModule",{value:!0});Ar.contentVocabulary=Ar.metadataVocabulary=void 0;Ar.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ar.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Fi,"__esModule",{value:!0});const b1=Li,S1=Hi,E1=rc,k1=mc,ql=Ar,P1=[b1.default,S1.default,(0,E1.default)(),k1.default,ql.metadataVocabulary,ql.contentVocabulary];Fi.default=P1;var _c={},Ws={};Object.defineProperty(Ws,"__esModule",{value:!0});Ws.DiscrError=void 0;var Dl;(function(e){e.Tag="tag",e.Mapping="mapping"})(Dl||(Ws.DiscrError=Dl={}));Object.defineProperty(_c,"__esModule",{value:!0});const Er=he,Uo=Ws,Ul=at,R1=Fr,T1=Q,C1={message:({params:{discrError:e,tagName:t}})=>e===Uo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Er._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},j1={keyword:"discriminator",type:"object",schemaType:"object",error:C1,code(e){const{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),l=t.const("tag",(0,Er._)`${r}${(0,Er.getProperty)(i)}`);t.if((0,Er._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Uo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const g=m();t.if(!1);for(const y in g)t.elseIf((0,Er._)`${l} === ${y}`),t.assign(c,h(g[y]));t.else(),e.error(!1,{discrError:Uo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function h(g){const y=t.name("valid"),_=e.subschema({keyword:"oneOf",schemaProp:g},y);return e.mergeEvaluated(_,Er.Name),y}function m(){var g;const y={},_=f(s);let v=!0;for(let T=0;Tthis.addVocabulary(y)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const y=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(y,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=St;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=he;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var h=Nn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return h.default}});var m=Fr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(Oo,Oo.exports);var q1=Oo.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=q1,r=he,n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},o={message:({keyword:i,schemaCode:c})=>(0,r.str)`should be ${s[i].okStr} ${c}`,params:({keyword:i,schemaCode:c})=>(0,r._)`{comparison: ${s[i].okStr}, limit: ${c}}`};e.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:o,code(i){const{gen:c,data:l,schemaCode:d,keyword:h,it:m}=i,{opts:g,self:y}=m;if(!g.validateFormats)return;const _=new t.KeywordCxt(m,y.RULES.all.format.definition,"format");_.$data?v():f();function v(){const E=c.scopeValue("formats",{ref:y.formats,code:g.code.formats}),T=c.const("fmt",(0,r._)`${E}[${_.schemaCode}]`);i.fail$data((0,r.or)((0,r._)`typeof ${T} != "object"`,(0,r._)`${T} instanceof RegExp`,(0,r._)`typeof ${T}.compare != "function"`,$(T)))}function f(){const E=_.schema,T=y.formats[E];if(!T||T===!0)return;if(typeof T!="object"||T instanceof RegExp||typeof T.compare!="function")throw new Error(`"${h}": format "${E}" does not define "compare" function`);const k=c.scopeValue("formats",{key:E,ref:T,code:g.code.formats?(0,r._)`${g.code.formats}${(0,r.getProperty)(E)}`:void 0});i.fail$data($(k))}function $(E){return(0,r._)`${E}.compare(${l}, ${d}) ${s[h].fail} 0`}},dependencies:["format"]};const a=i=>(i.addKeyword(e.formatLimitDefinition),i);e.default=a})(tf);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=ef,n=tf,s=he,o=new s.Name("fullFormats"),a=new s.Name("fastFormats"),i=(l,d={keywords:!0})=>{if(Array.isArray(d))return c(l,d,r.fullFormats,o),l;const[h,m]=d.mode==="fast"?[r.fastFormats,a]:[r.fullFormats,o],g=d.formats||r.formatNames;return c(l,g,h,m),d.keywords&&(0,n.default)(l),l};i.get=(l,d="full")=>{const m=(d==="fast"?r.fastFormats:r.fullFormats)[l];if(!m)throw new Error(`Unknown format "${l}"`);return m};function c(l,d,h,m){var g,y;(g=(y=l.opts.code).formats)!==null&&g!==void 0||(y.formats=(0,s._)`require("ajv-formats/dist/formats").${m}`);for(const _ of d)l.addFormat(_,h[_])}e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})(Io,Io.exports);var D1=Io.exports;const U1=Bl(D1);function F1(){const e=new PS({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return U1(e),e}class L1{constructor(t){this._ajv=t??F1()}getValidator(t){const r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}}class V1{constructor(t){this._client=t}async*callToolStream(t,r=ur,n){const s=this._client,o={...n,task:(n==null?void 0:n.task)??(s.isToolTask(t.name)?{}:void 0)},a=s.requestStream({method:"tools/call",params:t},r,o),i=s.getToolOutputValidator(t.name);for await(const c of a){if(c.type==="result"&&i){const l=c.result;if(!l.structuredContent&&!l.isError){yield{type:"error",error:new se(ae.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(l.structuredContent)try{const d=i(l.structuredContent);if(!d.valid){yield{type:"error",error:new se(ae.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)};return}}catch(d){if(d instanceof se){yield{type:"error",error:d};return}yield{type:"error",error:new se(ae.InvalidParams,`Failed to validate structured content: ${d instanceof Error?d.message:String(d)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._client.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,n){return this._client.requestStream(t,r,n)}}function H1(e,t,r){var n;if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!((n=e.tools)!=null&&n.call))throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break}}function Z1(e,t,r){var n,s;if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!((n=e.sampling)!=null&&n.createMessage))throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!((s=e.elicitation)!=null&&s.create))throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break}}function as(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){const r=t,n=e.properties;for(const s of Object.keys(n)){const o=n[s];r[s]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(r[s]=o.default),r[s]!==void 0&&as(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&as(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&as(r,t)}}function K1(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};const t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}class G1 extends cd{constructor(t,r){super(r),this._clientInfo=t,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=(r==null?void 0:r.capabilities)??{},this._jsonSchemaValidator=(r==null?void 0:r.jsonSchemaValidator)??new L1,r!=null&&r.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){var r,n,s,o,a,i;t.tools&&((n=(r=this._serverCapabilities)==null?void 0:r.tools)!=null&&n.listChanged)&&this._setupListChangedHandler("tools",Aa,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",Ia,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",Ra,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new V1(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=jv(this._capabilities,t)}setRequestHandler(t,r){const n=ad(t),s=n==null?void 0:n.method;if(!s)throw new Error("Schema is missing a method literal");const o=id(s);if(typeof o!="string")throw new Error("Schema method literal must be a string");const a=o;if(a==="elicitation/create"){const i=async(c,l)=>{var $,E;const d=Ut(nd,c);if(!d.success){const T=d.error instanceof Error?d.error.message:String(d.error);throw new se(ae.InvalidParams,`Invalid elicitation request: ${T}`)}const{params:h}=d.data;h.mode=h.mode??"form";const{supportsFormMode:m,supportsUrlMode:g}=K1(this._capabilities.elicitation);if(h.mode==="form"&&!m)throw new se(ae.InvalidParams,"Client does not support form-mode elicitation requests");if(h.mode==="url"&&!g)throw new se(ae.InvalidParams,"Client does not support URL-mode elicitation requests");const y=await Promise.resolve(r(c,l));if(h.task){const T=Ut(pn,y);if(!T.success){const k=T.error instanceof Error?T.error.message:String(T.error);throw new se(ae.InvalidParams,`Invalid task creation result: ${k}`)}return T.data}const _=Ut(sd,y);if(!_.success){const T=_.error instanceof Error?_.error.message:String(_.error);throw new se(ae.InvalidParams,`Invalid elicitation result: ${T}`)}const v=_.data,f=h.mode==="form"?h.requestedSchema:void 0;if(h.mode==="form"&&v.action==="accept"&&v.content&&f&&(E=($=this._capabilities.elicitation)==null?void 0:$.form)!=null&&E.applyDefaults)try{as(f,v.content)}catch{}return v};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=Ut(Ma,c);if(!d.success){const v=d.error instanceof Error?d.error.message:String(d.error);throw new se(ae.InvalidParams,`Invalid sampling request: ${v}`)}const{params:h}=d.data,m=await Promise.resolve(r(c,l));if(h.task){const v=Ut(pn,m);if(!v.success){const f=v.error instanceof Error?v.error.message:String(v.error);throw new se(ae.InvalidParams,`Invalid task creation result: ${f}`)}return v.data}const y=h.tools||h.toolChoice?rd:td,_=Ut(y,m);if(!_.success){const v=_.error instanceof Error?_.error.message:String(_.error);throw new se(ae.InvalidParams,`Invalid sampling result: ${v}`)}return _.data};return super.setRequestHandler(t,i)}return super.setRequestHandler(t,r)}assertCapability(t,r){var n;if(!((n=this._serverCapabilities)!=null&&n[t]))throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{const n=await this.request({method:"initialize",params:{protocolVersion:Os,capabilities:this._capabilities,clientInfo:this._clientInfo}},Du,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!oy.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,t.setProtocolVersion&&t.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(t){var r,n,s,o,a;switch(t){case"logging/setLevel":if(!((r=this._serverCapabilities)!=null&&r.logging))throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!((n=this._serverCapabilities)!=null&&n.prompts))throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!((s=this._serverCapabilities)!=null&&s.resources))throw new Error(`Server does not support resources (required for ${t})`);if(t==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!((o=this._serverCapabilities)!=null&&o.tools))throw new Error(`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!((a=this._serverCapabilities)!=null&&a.completions))throw new Error(`Server does not support completions (required for ${t})`);break}}assertNotificationCapability(t){var r;switch(t){case"notifications/roots/list_changed":if(!((r=this._capabilities.roots)!=null&&r.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${t})`);break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${t})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${t})`);break}}assertTaskCapability(t){var r,n;H1((n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests,t,"Server")}assertTaskHandlerCapability(t){var r;this._capabilities&&Z1((r=this._capabilities.tasks)==null?void 0:r.requests,t,"Client")}async ping(t){return this.request({method:"ping"},kr,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},od,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},kr,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Qu,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Ta,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Sa,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Ea,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},Pa,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},kr,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},kr,r)}async callTool(t,r=ur,n){if(this.isToolTaskRequired(t.name))throw new se(ae.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const s=await this.request({method:"tools/call",params:t},r,n),o=this.getToolOutputValidator(t.name);if(o){if(!s.structuredContent&&!s.isError)throw new se(ae.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(s.structuredContent)try{const a=o(s.structuredContent);if(!a.valid)throw new se(ae.InvalidParams,`Structured content does not match the tool's output schema: ${a.errorMessage}`)}catch(a){throw a instanceof se?a:new se(ae.InvalidParams,`Failed to validate structured content: ${a instanceof Error?a.message:String(a)}`)}}return s}isToolTask(t){var r,n,s,o;return(o=(s=(n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests)==null?void 0:s.tools)!=null&&o.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){var r;this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const n of t){if(n.outputSchema){const o=this._jsonSchemaValidator.getValidator(n.outputSchema);this._cachedToolOutputValidators.set(n.name,o)}const s=(r=n.execution)==null?void 0:r.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(n.name),s==="required"&&this._cachedRequiredTaskTools.add(n.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){const n=await this.request({method:"tools/list",params:t},xa,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=Ky.safeParse(n);if(!o.success)throw new Error(`Invalid ${t} listChanged options: ${o.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);const{autoRefresh:a,debounceMs:i}=o.data,{onChanged:c}=n,l=async()=>{if(!a){c(null,null);return}try{const h=await s();c(null,h)}catch(h){const m=h instanceof Error?h:new Error(String(h));c(m,null)}},d=()=>{if(i){const h=this._listChangedDebounceTimers.get(t);h&&clearTimeout(h);const m=setTimeout(l,i);this._listChangedDebounceTimers.set(t,m)}else l()};this.setNotificationHandler(r,d)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var yc={};/*! + * content-type + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */var Fl=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,W1=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Hf=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,B1=/\\([\u000b\u0020-\u00ff])/g,J1=/([\\"])/g,Zf=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;yc.format=Q1;yc.parse=Y1;function Q1(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!Zf.test(r))throw new TypeError("invalid type");var n=r;if(t&&typeof t=="object")for(var s,o=Object.keys(t).sort(),a=0;a0&&!W1.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(J1,"\\$1")+'"'}function tR(e){this.parameters=Object.create(null),this.type=e}function rR(e){if(e)try{return yc.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Fo(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function nR(e=fetch,t){return t?async(r,n)=>{const s={...t,...n,headers:n!=null&&n.headers?{...Fo(t.headers),...Fo(n.headers)}:t.headers};return e(r,s)}:e}let vc;vc=globalThis.crypto;async function sR(e){return(await vc).getRandomValues(new Uint8Array(e))}async function oR(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length;let n="";for(;n.length128)throw`Expected a length between 43 and 128. Received ${e}.`;const t=await aR(e),r=await iR(t);return{code_verifier:t,code_challenge:r}}const Ke=f_().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ny.custom,message:"URL must be parseable",fatal:!0}),ep}).refine(e=>{const t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),lR=Be({resource:R().url(),authorization_servers:K(Ke).optional(),jwks_uri:R().url().optional(),scopes_supported:K(R()).optional(),bearer_methods_supported:K(R()).optional(),resource_signing_alg_values_supported:K(R()).optional(),resource_name:R().optional(),resource_documentation:R().optional(),resource_policy_uri:R().url().optional(),resource_tos_uri:R().url().optional(),tls_client_certificate_bound_access_tokens:ve().optional(),authorization_details_types_supported:K(R()).optional(),dpop_signing_alg_values_supported:K(R()).optional(),dpop_bound_access_tokens_required:ve().optional()}),Kf=Be({issuer:R(),authorization_endpoint:Ke,token_endpoint:Ke,registration_endpoint:Ke.optional(),scopes_supported:K(R()).optional(),response_types_supported:K(R()),response_modes_supported:K(R()).optional(),grant_types_supported:K(R()).optional(),token_endpoint_auth_methods_supported:K(R()).optional(),token_endpoint_auth_signing_alg_values_supported:K(R()).optional(),service_documentation:Ke.optional(),revocation_endpoint:Ke.optional(),revocation_endpoint_auth_methods_supported:K(R()).optional(),revocation_endpoint_auth_signing_alg_values_supported:K(R()).optional(),introspection_endpoint:R().optional(),introspection_endpoint_auth_methods_supported:K(R()).optional(),introspection_endpoint_auth_signing_alg_values_supported:K(R()).optional(),code_challenge_methods_supported:K(R()).optional(),client_id_metadata_document_supported:ve().optional()}),uR=Be({issuer:R(),authorization_endpoint:Ke,token_endpoint:Ke,userinfo_endpoint:Ke.optional(),jwks_uri:Ke,registration_endpoint:Ke.optional(),scopes_supported:K(R()).optional(),response_types_supported:K(R()),response_modes_supported:K(R()).optional(),grant_types_supported:K(R()).optional(),acr_values_supported:K(R()).optional(),subject_types_supported:K(R()),id_token_signing_alg_values_supported:K(R()),id_token_encryption_alg_values_supported:K(R()).optional(),id_token_encryption_enc_values_supported:K(R()).optional(),userinfo_signing_alg_values_supported:K(R()).optional(),userinfo_encryption_alg_values_supported:K(R()).optional(),userinfo_encryption_enc_values_supported:K(R()).optional(),request_object_signing_alg_values_supported:K(R()).optional(),request_object_encryption_alg_values_supported:K(R()).optional(),request_object_encryption_enc_values_supported:K(R()).optional(),token_endpoint_auth_methods_supported:K(R()).optional(),token_endpoint_auth_signing_alg_values_supported:K(R()).optional(),display_values_supported:K(R()).optional(),claim_types_supported:K(R()).optional(),claims_supported:K(R()).optional(),service_documentation:R().optional(),claims_locales_supported:K(R()).optional(),ui_locales_supported:K(R()).optional(),claims_parameter_supported:ve().optional(),request_parameter_supported:ve().optional(),request_uri_parameter_supported:ve().optional(),require_request_uri_registration:ve().optional(),op_policy_uri:Ke.optional(),op_tos_uri:Ke.optional(),client_id_metadata_document_supported:ve().optional()}),dR=A({...uR.shape,...Kf.pick({code_challenge_methods_supported:!0}).shape}),fR=A({access_token:R(),id_token:R().optional(),token_type:R(),expires_in:sy().optional(),scope:R().optional(),refresh_token:R().optional()}).strip(),hR=A({error:R(),error_description:R().optional(),error_uri:R().optional()}),Ll=Ke.optional().or(N("").transform(()=>{})),pR=A({redirect_uris:K(Ke),token_endpoint_auth_method:R().optional(),grant_types:K(R()).optional(),response_types:K(R()).optional(),client_name:R().optional(),client_uri:Ke.optional(),logo_uri:Ll,scope:R().optional(),contacts:K(R()).optional(),tos_uri:Ll,policy_uri:R().optional(),jwks_uri:Ke.optional(),jwks:la().optional(),software_id:R().optional(),software_version:R().optional(),software_statement:R().optional()}).strip(),mR=A({client_id:R(),client_secret:R().optional(),client_id_issued_at:fe().optional(),client_secret_expires_at:fe().optional()}).strip(),gR=pR.merge(mR);A({error:R(),error_description:R().optional()}).strip();A({token:R(),token_type_hint:R().optional()}).strip();function _R(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function yR({requestedResource:e,configuredResource:t}){const r=typeof e=="string"?new URL(e):new URL(e.href),n=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==n.origin||r.pathname.length=400&&e.status<500&&t!=="/"}async function jR(e,t,r,n){const s=new URL(e),o=(n==null?void 0:n.protocolVersion)??Os;let a;if(n!=null&&n.metadataUrl)a=new URL(n.metadataUrl);else{const c=TR(t,s.pathname);a=new URL(c,(n==null?void 0:n.metadataServerUrl)??s),a.search=s.search}let i=await Hl(a,o,r);if(!(n!=null&&n.metadataUrl)&&CR(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await Hl(c,o,r)}return i}function NR(e){const t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;let s=t.pathname;return s.endsWith("/")&&(s=s.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${s}`,t.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${s}`,t.origin),type:"oidc"}),n.push({url:new URL(`${s}/.well-known/openid-configuration`,t.origin),type:"oidc"}),n}async function Bf(e,{fetchFn:t=fetch,protocolVersion:r=Os}={}){var o;const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=NR(e);for(const{url:a,type:i}of s){const c=await $c(a,n,t);if(c){if(!c.ok){if(await((o=c.body)==null?void 0:o.cancel()),c.status>=400&&c.status<500)continue;throw new Error(`HTTP ${c.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}return i==="oauth"?Kf.parse(await c.json()):dR.parse(await c.json())}}}async function IR(e,t){let r,n;try{r=await Wf(e,{resourceMetadataUrl:t==null?void 0:t.resourceMetadataUrl},t==null?void 0:t.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(n=r.authorization_servers[0])}catch{}n||(n=String(new URL("/",e)));const s=await Bf(n,{fetchFn:t==null?void 0:t.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:s,resourceMetadata:r}}async function OR(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:s,state:o,resource:a}){let i;if(t){if(i=new URL(t.authorization_endpoint),!t.response_types_supported.includes(co))throw new Error(`Incompatible auth server: does not support response type ${co}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(lo))throw new Error(`Incompatible auth server: does not support code challenge method ${lo}`)}else i=new URL("/authorize",e);const c=await cR(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",co),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",lo),i.searchParams.set("redirect_uri",String(n)),o&&i.searchParams.set("state",o),s&&i.searchParams.set("scope",s),s!=null&&s.includes("offline_access")&&i.searchParams.append("prompt","consent"),a&&i.searchParams.set("resource",a.href),{authorizationUrl:i,codeVerifier:l}}function xR(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function Jf(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:o,fetchFn:a}){const i=t!=null&&t.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(o&&r.set("resource",o.href),s)await s(c,r,i,t);else if(n){const d=(t==null?void 0:t.token_endpoint_auth_methods_supported)??[],h=wR(n,d);bR(h,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await Gf(l);return fR.parse(await l.json())}async function AR(e,{metadata:t,clientInformation:r,refreshToken:n,resource:s,addClientAuthentication:o,fetchFn:a}){const i=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await Jf(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:a});return{refresh_token:n,...c}}async function MR(e,t,{metadata:r,resource:n,authorizationCode:s,fetchFn:o}={}){const a=e.clientMetadata.scope;let i;if(e.prepareTokenRequest&&(i=await e.prepareTokenRequest(a)),!i){if(!s)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");const l=await e.codeVerifier();i=xR(s,l,e.redirectUrl)}const c=await e.clientInformation();return Jf(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:o})}async function zR(e,{metadata:t,clientMetadata:r,scope:n,fetchFn:s}){let o;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");o=new URL(t.registration_endpoint)}else o=new URL("/register",e);const a=await(s??fetch)(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...n!==void 0?{scope:n}:{}})});if(!a.ok)throw await Gf(a);return gR.parse(await a.json())}class ho extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}}const Zl=10,qR=13,tr=32;function po(e){}function DR(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:t=po,onError:r=po,onRetry:n=po,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",h=0,m,g=!1;function y(k){if(g)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,k.charCodeAt(0)===239&&k.charCodeAt(1)===187&&k.charCodeAt(2)===191&&(k=k.slice(3))),a.length===0){const L=v(k);L!==""&&(a.push(L),i=L.length),_();return}if(k.indexOf(` +`)===-1&&k.indexOf("\r")===-1){a.push(k),i+=k.length,_();return}a.push(k);const x=a.join("");a.length=0,i=0;const M=v(x);M!==""&&(a.push(M),i=M.length),_()}function _(){o!==void 0&&(i+d.length<=o||(g=!0,a.length=0,i=0,l=void 0,d="",h=0,m=void 0,r(new ho(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function v(k){let x=0;if(k.indexOf("\r")===-1){let M=k.indexOf(` +`,x);for(;M!==-1;){if(x===M){h>0&&t({id:l,event:m,data:d}),l=void 0,d="",h=0,m=void 0,x=M+1,M=k.indexOf(` +`,x);continue}const L=k.charCodeAt(x);if(Kl(k,x,L)){const F=k.charCodeAt(x+5)===tr?x+6:x+5,V=k.slice(F,M);if(h===0&&k.charCodeAt(M+1)===Zl){t({id:l,event:m,data:V}),l=void 0,d="",m=void 0,x=M+2,M=k.indexOf(` +`,x);continue}d=h===0?V:`${d} +${V}`,h++}else Gl(k,x,L)?m=k.slice(k.charCodeAt(x+6)===tr?x+7:x+6,M)||void 0:f(k,x,M);x=M+1,M=k.indexOf(` +`,x)}return k.slice(x)}for(;x20?`${k.slice(0,20)}…`:k}"`,{type:"unknown-field",field:k,value:x,line:M}));break}}function E(){h>0&&t({id:l,event:m,data:d}),l=void 0,d="",h=0,m=void 0}function T(k={}){if(k.consume&&a.length>0){const x=a.join("");f(x,0,x.length)}c=!0,l=void 0,d="",h=0,m=void 0,a.length=0,i=0,g=!1}return{feed:y,reset:T}}function Kl(e,t,r){return r===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function Gl(e,t,r){return r===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}class UR extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:s}={}){let o;super({start(a){o=DR({onEvent:i=>{a.enqueue(i)},onError(i){typeof t=="function"&&t(i),(t==="terminate"||i.type==="max-buffer-size-exceeded")&&a.error(i)},onRetry:r,onComment:n,maxBufferSize:s})},transform(a){o.feed(a)}})}}const FR={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class br extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}}class LR{constructor(t,r){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r==null?void 0:r.requestInit,this._authProvider=r==null?void 0:r.authProvider,this._fetch=r==null?void 0:r.fetch,this._fetchWithInit=nR(r==null?void 0:r.fetch,r==null?void 0:r.requestInit),this._sessionId=r==null?void 0:r.sessionId,this._reconnectionOptions=(r==null?void 0:r.reconnectionOptions)??FR}async _authThenStart(){var r;if(!this._authProvider)throw new wr("No auth provider");let t;try{t=await Wn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(r=this.onerror)==null||r.call(this,n),n}if(t!=="AUTHORIZED")throw new wr;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var n;const t={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(t.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const r=Fo((n=this._requestInit)==null?void 0:n.headers);return new Headers({...t,...r})}async _startOrAuthSse(t){var n,s,o;const{resumptionToken:r}=t;try{const a=await this._commonHeaders();a.set("Accept","text/event-stream"),r&&a.set("last-event-id",r);const i=await(this._fetch??fetch)(this._url,{method:"GET",headers:a,signal:(n=this._abortController)==null?void 0:n.signal});if(!i.ok){if(await((s=i.body)==null?void 0:s.cancel()),i.status===401&&this._authProvider)return await this._authThenStart();if(i.status===405)return;throw new br(i.status,`Failed to open SSE stream: ${i.statusText}`)}this._handleSseStream(i.body,t,!0)}catch(a){throw(o=this.onerror)==null||o.call(this,a),a}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),s)}_scheduleReconnection(t,r=0){var o;const n=this._reconnectionOptions.maxRetries;if(r>=n){(o=this.onerror)==null||o.call(this,new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}const s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(a=>{var i;(i=this.onerror)==null||i.call(this,new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(t,r+1)})},s)}_handleSseStream(t,r,n){if(!t)return;const{onresumptiontoken:s,replayMessageId:o}=r;let a,i=!1,c=!1;(async()=>{var d,h,m,g;try{const y=t.pipeThrough(new TextDecoderStream).pipeThrough(new UR({onRetry:f=>{this._serverRetryMs=f}})).getReader();for(;;){const{value:f,done:$}=await y.read();if($)break;if(f.id&&(a=f.id,i=!0,s==null||s(f.id)),!!f.data&&(!f.event||f.event==="message"))try{const E=Jn.parse(JSON.parse(f.data));Qr(E)&&(c=!0,o!==void 0&&(E.id=o)),(d=this.onmessage)==null||d.call(this,E)}catch(E){(h=this.onerror)==null||h.call(this,E)}}(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(y){if((m=this.onerror)==null||m.call(this,new Error(`SSE stream disconnected: ${y}`)),(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(f){(g=this.onerror)==null||g.call(this,new Error(`Failed to reconnect: ${f instanceof Error?f.message:String(f)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new wr("No auth provider");if(await Wn(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new wr("Failed to authorize")}async close(){var t,r;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(t=this._abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this)}async send(t,r){var n,s,o,a,i,c;try{const{resumptionToken:l,onresumptiontoken:d}=r||{};if(l){this._startOrAuthSse({resumptionToken:l,replayMessageId:wo(t)?t.id:void 0}).catch(E=>{var T;return(T=this.onerror)==null?void 0:T.call(this,E)});return}const h=await this._commonHeaders();h.set("content-type","application/json"),h.set("accept","application/json, text/event-stream");const m={...this._requestInit,method:"POST",headers:h,body:JSON.stringify(t),signal:(n=this._abortController)==null?void 0:n.signal},g=await(this._fetch??fetch)(this._url,m),y=g.headers.get("mcp-session-id");if(y&&(this._sessionId=y),!g.ok){const E=await g.text().catch(()=>null);if(g.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new br(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:T,scope:k}=Vl(g);if(this._resourceMetadataUrl=T,this._scope=k,await Wn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new wr;return this._hasCompletedAuthFlow=!0,this.send(t)}if(g.status===403&&this._authProvider){const{resourceMetadataUrl:T,scope:k,error:x}=Vl(g);if(x==="insufficient_scope"){const M=g.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===M)throw new br(403,"Server returned 403 after trying upscoping");if(k&&(this._scope=k),T&&(this._resourceMetadataUrl=T),this._lastUpscopingHeader=M??void 0,await Wn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new wr;return this.send(t)}}throw new br(g.status,`Error POSTing to endpoint: ${E}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,g.status===202){await((s=g.body)==null?void 0:s.cancel()),wy(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(E=>{var T;return(T=this.onerror)==null?void 0:T.call(this,E)});return}const v=(Array.isArray(t)?t:[t]).filter(E=>"method"in E&&"id"in E&&E.id!==void 0).length>0,f=g.headers.get("content-type"),$=rR(f);if(v)if($==="text/event-stream")this._handleSseStream(g.body,{onresumptiontoken:d},!1);else if($==="application/json"){const E=await g.json(),T=Array.isArray(E)?E.map(k=>Jn.parse(k)):[Jn.parse(E)];for(const k of T)(o=this.onmessage)==null||o.call(this,k)}else throw await((a=g.body)==null?void 0:a.cancel()),new br(-1,`Unexpected content type: ${f}`);else await((i=g.body)==null?void 0:i.cancel())}catch(l){throw(c=this.onerror)==null||c.call(this,l),l}}get sessionId(){return this._sessionId}async terminateSession(){var t,r,n;if(this._sessionId)try{const s=await this._commonHeaders(),o={...this._requestInit,method:"DELETE",headers:s,signal:(t=this._abortController)==null?void 0:t.signal},a=await(this._fetch??fetch)(this._url,o);if(await((r=a.body)==null?void 0:r.cancel()),!a.ok&&a.status!==405)throw new br(a.status,`Failed to terminate session: ${a.statusText}`);this._sessionId=void 0}catch(s){throw(n=this.onerror)==null||n.call(this,s),s}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r==null?void 0:r.onresumptiontoken})}}const VR="https://mcp.excalidraw.com/mcp",HR="mcp.excalidraw.com",ZR="/api/v1/chat/mcp-apps/excalidraw",Qf="ui://excalidraw/mcp-app.html",KR=["read_me","create_view"],Yf=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),GR=256*1024,WR=1024*1024,BR=1024*1024,JR=240,QR=720,YR=525;function XR(e){return!Number.isFinite(e)||e<=0?YR:Math.max(JR,Math.min(QR,Math.round(e*3/4)))}const eT={excalidraw:{id:"excalidraw",endpoint:VR,hostname:HR,resourceUri:Qf,modelTools:KR,appTools:Yf}};function tT(e){return eT[e]}function rT(){return new URL(Dt(ZR),window.location.origin)}class nT{constructor(){le(this,"client",new G1({name:"pwc-chat-mcp-app-host",version:"1"}));le(this,"transport",new LR(rT(),{requestInit:{credentials:"include"}}));le(this,"connected");le(this,"bytes",0);le(this,"closed",!1)}connect(){return this.closed?Promise.reject(new Error("App host client is closed")):(this.connected||(this.connected=this.client.connect(this.transport).then(()=>{},t=>{throw this.connected=void 0,this.retire(),t})),this.connected)}async readResource(t){if(t!==Qf)throw new Error("Unapproved App resource");await this.connect();const n=(await this.client.readResource({uri:t})).contents[0];if(!n||!("text"in n)||typeof n.text!="string"||n.mimeType!=="text/html;profile=mcp-app")throw new Error("Incompatible App resource");this.consume(n.text,BR);const s=await iT(n.text);return{text:n.text,digest:s}}async callTool(t,r){if(!Yf.has(t))throw new Error("Unapproved App tool");const n=JSON.stringify(r);this.consume(n);try{await this.connect();const s=await this.client.callTool({name:t,arguments:r});return this.consume(JSON.stringify(s)),s}catch(s){throw this.retire(),s}}close(){this.closed=!0,this.connected=void 0,this.transport.close()}retire(){this.close(),Ht===this&&(Ht=void 0)}consume(t,r=GR){const n=new TextEncoder().encode(t).byteLength;if(n>r||this.bytes+n>WR)throw new Error("App request exceeds host limit");this.bytes+=n}}let Ht;function sT(){return Ht??(Ht=new nT),Ht}function oT(){Ht==null||Ht.close(),Ht=void 0}function aT(e){oT()}async function iT(e){const t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return[...new Uint8Array(r)].map(n=>n.toString(16).padStart(2,"0")).join("")}function cT(e,t){let r=!1,n=0;const s=()=>{r||!e.contentWindow||(r=!0,t())};e.addEventListener("load",s);const o=window.requestAnimationFrame(()=>{n=window.requestAnimationFrame(s)});return()=>{r=!0,e.removeEventListener("load",s),window.cancelAnimationFrame(o),window.cancelAnimationFrame(n)}}const lT=({block:e})=>{const t=G.useRef(null),r=G.useRef(null),n=G.useRef(!1),s=G.useRef(e),o=G.useRef(!1);s.current=e;const[a,i]=G.useState(),[c,l]=G.useState("loading"),[d,h]=G.useState(e.height),[m,g]=G.useState(!1),[y,_]=G.useState(0),v=G.useRef(null),f=e.input.elements,$=!!e.permissions.clipboardWrite;o.current=m;const E=G.useCallback(()=>{g(!1),document.fullscreenElement&&document.exitFullscreen()},[]),T=G.useCallback(()=>{var M,L;if(m){E();return}g(!0),(L=(M=v.current)==null?void 0:M.requestFullscreen)==null||L.call(M).catch(()=>{})},[E,m]),k=G.useCallback(()=>{aT(),i(void 0),l("loading"),_(M=>M+1)},[]);G.useEffect(()=>{const M=v.current;if(!M)return;const L=()=>{o.current||h(XR(M.clientWidth))};L();const F=new ResizeObserver(L);return F.observe(M),()=>F.disconnect()},[]),G.useEffect(()=>{if(!m)return;const M=v.current,L=V=>{V.key==="Escape"&&(document.fullscreenElement||E())},F=()=>{document.fullscreenElement||g(!1)};return window.addEventListener("keydown",L),document.addEventListener("fullscreenchange",F),()=>{window.removeEventListener("keydown",L),document.removeEventListener("fullscreenchange",F),document.fullscreenElement===M&&document.exitFullscreen()}},[E,m]),G.useEffect(()=>{tT(e.provider);{l("unavailable");return}},[y,e.provider,e.resource_uri]),G.useEffect(()=>{if(!a||c!=="ready")return;const M=t.current;if(!M)return;let L=null;const F=[],V=cT(M,()=>{M.contentWindow&&(L=new Xv(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...$?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:m?"fullscreen":"inline"}}),L.oncalltool=async({name:Z,arguments:B})=>{if(s.current.public_fork&&Z!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return sT().callTool(Z,B??{})},L.onopenlink=async({url:Z})=>{const B=new URL(Z);if(B.protocol!=="https:"||B.hostname!=="excalidraw.com")throw new Error("External navigation denied");if(!window.confirm("This export opens Excalidraw and uploads the diagram to its service. Continue?"))throw new Error("Export cancelled");return window.open(B.href,"_blank","noopener,noreferrer"),{}},L.onsizechange=()=>{},L.oninitialized=()=>{n.current=!0;try{const Z=JSON.parse(f),B={arguments:{elements:Array.isArray(Z)?c$(Z):Z}};for(const re of[0,50,200,750])F.push(window.setTimeout(()=>{r.current===L&&L.sendToolInput(B)},re));L.sendToolResult(s.current.result)}catch{l("error")}},r.current=L,L.connect(new Qv(M.contentWindow??void 0,M.contentWindow)).catch(()=>l("error")))});return()=>{V(),F.forEach(Z=>window.clearTimeout(Z)),n.current=!1,L==null||L.teardownResource({}).catch(()=>{}),r.current===L&&(r.current=null)}},[a,c,m,f,$,y]),G.useEffect(()=>{var M;c!=="ready"||!n.current||(M=r.current)==null||M.sendToolResult(e.result).catch(()=>{})},[e.result,c]);const x=c==="unavailable"||c==="incompatible"||c==="error";return b.jsxs("section",{ref:v,className:`chat-mcp-app${m?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[b.jsx("header",{children:b.jsx("button",{type:"button",onClick:T,children:m?"Exit fullscreen":"Fullscreen"})}),c==="loading"&&b.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),x&&b.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",b.jsx("button",{type:"button",onClick:k,children:"Retry diagram"})]}),a&&c==="ready"&&b.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:$?"clipboard-write":void 0,srcDoc:a,style:{height:d}},y)]})},Xf=()=>({open:!1,selectedKey:null,selected:null,selectedVersionId:null,tab:"preview",sourceFile:null,panelPercent:55,requestNonce:0,registry:{},autoOpened:{},manuallyClosed:{}});function uT(e,t){if(t.type==="reset")return{...Xf(),panelPercent:e.panelPercent};if(t.type==="register"){const r=e.registry[t.key];if(r&&JSON.stringify(r)===JSON.stringify(t.block))return e;const n={...e.registry,[t.key]:t.block},s=e.selectedKey===t.key?t.block:e.selected,o=(r==null?void 0:r.status)==="generating"&&t.block.status==="ready",a=t.autoOpenOnMount&&!r&&t.block.status==="ready"&&!Object.values(e.autoOpened).some(Boolean);return(o||a)&&!e.autoOpened[t.key]&&!e.manuallyClosed[t.key]?{...e,registry:n,open:!0,selectedKey:t.key,selected:t.block,selectedVersionId:t.block.version_id??null,tab:"preview",sourceFile:null,requestNonce:e.requestNonce+1,autoOpened:{...e.autoOpened,[t.key]:!0}}:{...e,registry:n,selected:s}}return t.type==="unregister"?e:t.type==="open"?{...e,open:!0,selectedKey:t.key,selected:t.block,selectedVersionId:t.block.version_id??null,tab:"preview",sourceFile:null,requestNonce:e.requestNonce+1,manuallyClosed:{...e.manuallyClosed,[t.key]:!1}}:t.type==="close"?{...e,open:!1,manuallyClosed:e.selectedKey?{...e.manuallyClosed,[e.selectedKey]:!0}:e.manuallyClosed}:t.type==="tab"?{...e,tab:t.tab}:t.type==="source"?{...e,sourceFile:t.path}:t.type==="version"?{...e,selectedVersionId:t.versionId,tab:"preview",sourceFile:null}:{...e,panelPercent:t.percent}}function ea(e){return e.publication_id||e.public_capability||e.version_id||`${e.scope}:${e.identifier}:${e.version??"pending"}`}const eh=G.createContext(null),GT=({children:e,workspaceKey:t,autoOpenOnMount:r=!1})=>{const[n,s]=G.useReducer(uT,void 0,Xf),o=G.useRef(null),a=G.useRef(t);G.useEffect(()=>{a.current!==t&&(a.current=t,o.current=null,s({type:"reset"}))},[t]);const i=G.useCallback(()=>{s({type:"close"}),window.setTimeout(()=>{var f;return(f=o.current)==null?void 0:f.focus()},0)},[]),c=G.useCallback(f=>s({type:"register",key:ea(f),block:f,autoOpenOnMount:r}),[r]),l=G.useCallback(f=>s({type:"unregister",key:f}),[]),d=G.useCallback((f,$)=>{o.current=$??null,s({type:"open",key:ea(f),block:f})},[]),h=G.useCallback(f=>s({type:"tab",tab:f}),[]),m=G.useCallback(f=>s({type:"source",path:f}),[]),g=G.useCallback(f=>s({type:"version",versionId:f}),[]),y=G.useCallback(f=>s({type:"width",percent:f}),[]),_=G.useCallback(()=>s({type:"reset"}),[]),v=G.useMemo(()=>({state:n,autoOpenOnMount:r,register:c,unregister:l,open:d,close:i,setTab:h,setSourceFile:m,setVersion:g,setPanelPercent:y,reset:_}),[r,i,d,c,_,y,m,h,g,n,l]);return b.jsx(eh.Provider,{value:v,children:e})};function wc(){const e=G.useContext(eh);if(!e)throw new Error("Poster artifacts require an ArtifactPanelProvider");return e}const dT="https://github.com/Chenruishuo/posterly/tree/b9f42e5578a49a27525a68f85376bb3bb25af86f";function fT(){if(typeof window>"u")return null;const e=window.location.pathname.match(/^\/share\/([^/]+)/u);return e?decodeURIComponent(e[1]):null}function th(e){if(e.scope==="public"){const n=fT();if(!n||!e.public_capability)return null;const s=`/api/v1/chat/shares/${encodeURIComponent(n)}/artifacts/${encodeURIComponent(e.public_capability)}`;return{preview:Dt(`${s}/preview`),png:Dt(`${s}/download/png`),pdf:Dt(`${s}/download/pdf`),manifest:null,source:null,gate:null,download:null}}if(!e.artifact_id||!e.version_id)return null;const t=`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}/versions/${encodeURIComponent(e.version_id)}`,r=(n,s)=>Dt(`${t}/${n}/${s.split("/").map(encodeURIComponent).join("/")}`);return{preview:Dt(`${t}/preview`),png:r("download","poster.png"),pdf:null,manifest:Dt(`${t}/manifest`),source:n=>r("source",n),gate:n=>r("source",n),download:n=>r("download",n)}}const rh=e=>({passed:"Passed",warnings:"Passed with warnings",failed:"Draft—checks failed"})[e??"passed"];function hT(){const[e,t]=G.useState(()=>{var r;return typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(max-width: 760px)").matches)});return G.useEffect(()=>{var s,o;const r=(s=window.matchMedia)==null?void 0:s.call(window,"(max-width: 760px)");if(!r)return;const n=()=>t(r.matches);return n(),(o=r.addEventListener)==null||o.call(r,"change",n),()=>{var a;return(a=r.removeEventListener)==null?void 0:a.call(r,"change",n)}},[]),e}const Wl=({forceDialog:e=!1,readerFallback:t=!1})=>{var k,x,M,L;const r=wc(),n=r.close,{state:s}=r,o=s.selected,a=hT(),i=e||a,c=G.useRef(null),l=G.useRef(!1),d=Bn({queryKey:["chat-artifact-versions",o==null?void 0:o.artifact_id],queryFn:async()=>{const F=await fetch(Dt(`/api/v1/chat/artifacts/${encodeURIComponent(o.artifact_id)}`),{credentials:"include",cache:"no-store"});if(!F.ok)throw new Error("Could not load poster versions");return(await F.json()).versions},enabled:s.open&&(o==null?void 0:o.scope)==="owner"&&!!o.artifact_id,staleTime:Number.POSITIVE_INFINITY}),h=(k=d.data)==null?void 0:k.find(F=>F.version_id===s.selectedVersionId),m=o&&h?{...o,version_id:h.version_id,version:h.version,gate_status:h.gate_status,total_bytes:h.total_bytes}:o,g=m?th(m):null,_=Bn({queryKey:["chat-artifact-manifest",m==null?void 0:m.version_id],queryFn:async()=>{const F=await fetch(g.manifest,{credentials:"include",cache:"no-store"});if(!F.ok)throw new Error("Could not load poster details");return F.json()},enabled:s.open&&(m==null?void 0:m.scope)==="owner"&&!!(g!=null&&g.manifest),staleTime:Number.POSITIVE_INFINITY}).data,v=s.sourceFile??(_==null?void 0:_.entrypoint)??null,f=Bn({queryKey:["chat-artifact-source",m==null?void 0:m.version_id,v],queryFn:async()=>{const F=await fetch(g.source(v),{credentials:"include",cache:"no-store"});if(!F.ok)throw new Error("Source could not be loaded");return F.text()},enabled:s.open&&s.tab==="source"&&(m==null?void 0:m.scope)==="owner"&&!!(v&&(g!=null&&g.source)),staleTime:Number.POSITIVE_INFINITY});if(G.useEffect(()=>{var V,Z;if(!s.open||!i)return;(Z=(V=c.current)==null?void 0:V.querySelector("[data-artifact-close]"))==null||Z.focus(),window.history.pushState({...window.history.state,pwcArtifactPanel:!0},""),l.current=!0;const F=()=>{l.current=!1,n()};return window.addEventListener("popstate",F),()=>window.removeEventListener("popstate",F)},[n,i,s.open]),G.useEffect(()=>{if(!s.open||!i)return;const F=V=>{if(V.key==="Escape"){V.preventDefault(),n(),l.current&&(l.current=!1,window.history.back());return}if(V.key!=="Tab"||!c.current)return;const Z=[...c.current.querySelectorAll('button:not([disabled]), a[href], select:not([disabled]), [tabindex]:not([tabindex="-1"])')];if(!Z.length)return;const B=Z[0],re=Z.at(-1);V.shiftKey&&document.activeElement===B?(V.preventDefault(),re.focus()):!V.shiftKey&&document.activeElement===re&&(V.preventDefault(),B.focus())};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[n,i,s.open]),!s.open||!m||!g)return null;const $=()=>{n(),i&&l.current&&(l.current=!1,window.history.back())},E=(x=_==null?void 0:_.downloads[0])==null?void 0:x.path,T=m.scope==="public"?g.pdf:E&&g.download?g.download(E):null;return b.jsxs("section",{ref:c,className:`chat-artifact-panel${i?" is-dialog":" is-docked"}${t?" is-reader-fallback":""}`,role:i?"dialog":"complementary","aria-modal":i?!0:void 0,"aria-label":m.title,"data-testid":"artifact-panel",children:[b.jsxs("header",{children:[b.jsxs("div",{children:[b.jsx("span",{children:"Posterly artifact"}),b.jsx("h2",{children:m.title})]}),(((M=d.data)==null?void 0:M.length)??0)>1&&b.jsxs("label",{className:"chat-artifact-version",children:["Version",b.jsx("select",{"aria-label":"Poster version",value:m.version_id,onChange:F=>r.setVersion(F.target.value),children:[...d.data??[]].reverse().map(F=>b.jsxs("option",{value:F.version_id,children:["v",F.version]},F.version_id))})]}),b.jsx("button",{type:"button","data-artifact-close":!0,"aria-label":i?"Back to conversation":"Close poster",onClick:$,children:b.jsx(ih,{})})]}),b.jsxs("nav",{"aria-label":"Poster views",children:[b.jsx("button",{type:"button","aria-pressed":s.tab==="preview",className:s.tab==="preview"?"active":"",onClick:()=>r.setTab("preview"),children:"Preview"}),m.scope==="owner"&&b.jsx("button",{type:"button","aria-pressed":s.tab==="source",className:s.tab==="source"?"active":"",onClick:()=>r.setTab("source"),children:"Source"})]}),b.jsx("div",{className:"chat-artifact-panel-body",children:s.tab==="preview"?b.jsx("img",{src:g.preview,alt:`Full preview of ${m.title}`}):b.jsxs("div",{className:"chat-artifact-source-workspace",children:[(((L=_==null?void 0:_.source_files)==null?void 0:L.length)??0)>1&&b.jsx("nav",{"aria-label":"Poster source files",children:_.source_files.map(F=>b.jsx("button",{type:"button","aria-pressed":v===F,onClick:()=>r.setSourceFile(F),children:F},F))}),b.jsx("pre",{children:b.jsx("code",{children:f.isError?"Source could not be loaded.":f.data??"Loading source…"})})]})}),b.jsxs("footer",{children:[b.jsxs("div",{className:"chat-artifact-metadata",children:[b.jsx("strong",{children:rh(m.gate_status)}),_&&b.jsxs("span",{children:[_.canvas.width," × ",_.canvas.height," ",_.canvas.unit," · ",_.canvas.orientation," · ",_.direction]}),_==null?void 0:_.gate_summary.map(F=>b.jsx("span",{children:F},F))]}),b.jsxs("div",{className:"chat-artifact-actions",children:[b.jsxs("a",{href:g.png,download:!0,children:[b.jsx(Sc,{})," PNG"]}),m.gate_status!=="failed"&&T&&b.jsxs("a",{href:T,download:!0,children:[b.jsx(Sc,{})," PDF"]}),m.scope==="owner"&&_&&g.source&&b.jsxs("a",{href:g.source(_.entrypoint),download:!0,children:[b.jsx(tu,{})," HTML"]}),m.scope==="owner"&&_&&g.gate&&b.jsx("a",{href:g.gate(_.gate_report),download:!0,children:"Gate report"}),b.jsxs("a",{href:dT,target:"_blank",rel:"noreferrer",children:[b.jsx(Eh,{})," Posterly source · AGPL-3.0"]})]})]})]})},pT=({block:e})=>{const t=wc(),r=t.register,n=t.unregister,s=ea(e);if(G.useEffect(()=>{r(e)},[e,r]),G.useEffect(()=>()=>n(s),[s,n]),e.status==="generating")return b.jsxs("div",{className:"chat-artifact-card chat-artifact-generating",role:"status",children:[b.jsx("span",{className:"chat-artifact-pulse","aria-hidden":"true"}),b.jsxs("span",{children:[b.jsx("strong",{children:e.title}),b.jsx("small",{children:"Publishing Posterly preview…"})]})]});if(e.status==="error")return b.jsxs("div",{className:"chat-artifact-card chat-artifact-error",role:"alert",children:[b.jsx(tu,{"aria-hidden":"true"}),b.jsxs("span",{children:[b.jsx("strong",{children:e.title}),b.jsx("small",{children:e.error_message??"Poster publication failed."})]})]});const o=th(e);if(!o)return null;const a=t.state.open&&t.state.selectedKey===s;return b.jsxs("button",{type:"button",className:`chat-artifact-card${a?" is-selected":""}`,"aria-pressed":a,onClick:i=>t.open(e,i.currentTarget),children:[b.jsx("img",{src:o.preview,alt:`Preview of ${e.title}`}),b.jsxs("span",{className:"chat-artifact-card-copy",children:[b.jsxs("span",{className:"chat-artifact-kicker",children:[b.jsx(Ph,{"aria-hidden":"true"})," Posterly · v",e.version]}),b.jsx("strong",{children:e.title}),b.jsx("small",{className:`chat-artifact-gate chat-artifact-gate-${e.gate_status}`,children:rh(e.gate_status)})]})]})};function mT(e){if(!e.authors.length)return"";const t=e.authors.slice(0,3).map(r=>r.name).join(", ");return e.authors.length>3?`${t}, et al.`:t}function gT(e){var r;if(e.conference)return e.conference;const t=(r=e.published)==null?void 0:r.slice(0,4);if(e.arxiv_id)return t?`arXiv ${t}`:"arXiv";if(e.source_url)try{return new URL(e.source_url).hostname.replace(/^www\./,"")}catch{}return t??"external"}function _T(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const yT="https://huggingface.co/pro",vT="https://huggingface.co/docs/inference-providers/pricing",$T="https://paperswithcode.co/chat",nh=()=>b.jsx("span",{className:"chat-caret"}),wT=e=>{var r;if(!e.streaming)return!1;const t=(r=e.blocks)==null?void 0:r.at(-1);return t?t.kind==="reasoning"?!t.active:t.kind==="tool"?t.status!=="running":!1:!0},bT=e=>{var g,y;const t=e.currentTarget,r=t.ownerDocument,n=(g=r.caretPositionFromPoint)==null?void 0:g.call(r,e.clientX,e.clientY),s=n?null:(y=r.caretRangeFromPoint)==null?void 0:y.call(r,e.clientX,e.clientY),o=(n==null?void 0:n.offsetNode)??(s==null?void 0:s.startContainer),a=(n==null?void 0:n.offset)??(s==null?void 0:s.startOffset);if(!(o instanceof Text)||a===void 0||!t.contains(o))return;const i=o.data,c=/[\p{L}\p{M}\p{N}_'-]/u;let l=Math.min(a,i.length),d=l;for(;l>0&&c.test(i[l-1]);)l-=1;for(;d{const r=[];let n=0;for(const s of[...t].sort((o,a)=>o.start-a.start)){const o=e.slice(s.start,s.end);s.starte.length||o!==s.title&&o!==`@${s.title}`||(r.push(e.slice(n,s.start)),r.push(b.jsxs("span",{className:"chat-inline-paper-mention",children:[b.jsx(Sh,{size:13,"aria-hidden":"true"}),b.jsx(eu,{routeId:s.route_id,className:"chat-inline-paper-link",children:o.startsWith("@")?o.slice(1):o})]},s.key)),n=s.end)}return r.push(e.slice(n)),b.jsx(b.Fragment,{children:r})},ET=({block:e,papers:t,citations:r,webCitations:n,onToggle:s})=>e.active?b.jsxs("div",{className:"chat-reason-live",children:[b.jsxs("div",{className:"chat-reason-live-head",children:[b.jsx(ta,{})," ",b.jsx("span",{children:"Thinking…"})]}),b.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[b.jsx(mo,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),b.jsx(nh,{})]})]}):b.jsxs("div",{className:"chat-reason-done",children:[b.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:s,"aria-expanded":e.open,children:[b.jsx(ph,{}),b.jsx("span",{children:"Thought for a few seconds"}),b.jsx(Xl,{open:e.open})]}),e.open&&b.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:b.jsx(mo,{text:e.text,papers:t,citations:r,webCitations:n})})]}),kT=({block:e,papers:t,onToggle:r})=>{var h,m,g,y;const n=e.status==="running",s=n&&e.argumentState==="streaming",o=e.schema_version===2||!!e.content,a=e.status==="error"||e.status==="denied",i=typeof e.args.query=="string"?e.args.query:"",c=typeof e.args.command=="string"?e.args.command:typeof e.args.file_path=="string"?e.args.file_path:i,l=((h=e.content)==null?void 0:h.map(_=>_.text).join(""))??"",d=s?"streaming arguments…":n?"running…":o?`${e.status} · ${e.took_ms??0} ms`:`${e.hits} results · ${e.took_ms} ms`;return b.jsxs("div",{className:`chat-tool${n?" chat-tool-running":""}${a?" chat-tool-failed":""}`,children:[b.jsxs("button",{type:"button",className:"chat-tool-head",onClick:r,"aria-expanded":e.open,children:[b.jsxs("span",{className:"chat-tool-head-left",children:[n?b.jsx(ta,{}):b.jsx(mh,{}),b.jsx("code",{className:"chat-tool-name",children:e.name}),b.jsx("span",{className:"chat-tool-query",children:o?c:`("${i}")`})]}),b.jsxs("span",{className:"chat-tool-head-right",children:[b.jsx("span",{className:"chat-tool-status",children:d}),b.jsx(Xl,{open:e.open})]})]}),e.open&&b.jsxs("div",{className:"chat-tool-body",children:[b.jsxs("div",{className:"chat-tool-args",children:[b.jsxs("span",{className:"chat-tool-label",children:["arguments",e.arguments_redacted?" · redacted":""]}),b.jsx("pre",{children:e.argumentState==="streaming"&&!e.arguments_redacted&&e.argumentText||JSON.stringify(e.args,null,2)})]}),!n&&o?b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"chat-tool-output-head",children:[b.jsx("span",{className:"chat-tool-label",children:"result"}),b.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(l),children:"Copy"})]}),b.jsx("pre",{className:"chat-tool-output",children:b.jsx("code",{children:l})}),((m=e.metadata)==null?void 0:m.output_truncated)&&b.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):n?null:b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((g=e.results)==null?void 0:g.length)??0," papers"]}),b.jsx("ol",{className:"chat-tool-results",children:(y=e.results)==null?void 0:y.map(_=>b.jsxs("li",{className:"chat-hit",children:[b.jsx("div",{className:"chat-hit-top",children:b.jsx(nu,{routeId:_.route_id,paper:t[_.route_id],className:"chat-hit-title",children:_.title})}),b.jsx("div",{className:"chat-hit-meta",children:[mT(_.metadata),gT(_.metadata)].filter(Boolean).join(" · ")}),b.jsxs("div",{className:"chat-hit-snippet",children:[_T(_),_.content_truncated&&b.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},_.route_id))})]})]})]})},PT=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>b.jsxs("div",{className:"chat-answer",children:[b.jsx(mo,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&b.jsx(nh,{})]}),RT=({block:e})=>b.jsx(lT,{block:e}),sh=e=>{const t=G.useRef(null),r=G.useCallback(()=>{const n=t.current;if(!n)return;n.style.height="auto";const s=Math.max(120,window.innerHeight*.4);n.style.height=`${Math.min(n.scrollHeight,s)}px`,n.style.overflowY=n.scrollHeight>s?"auto":"hidden"},[]);return G.useLayoutEffect(()=>{var n,s;(n=t.current)==null||n.focus(),(s=t.current)==null||s.setSelectionRange(e.length,e.length),r()},[r,e.length]),{textareaRef:t,resize:r}},TT=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=G.useState(t),[l,d]=G.useState(r),[h,m]=G.useState(!1),{textareaRef:g,resize:y}=sh(t);G.useLayoutEffect(y,[y,i]);const _=!!i.trim()&&i.length<=8e3,v=()=>{if(!_||h)return;m(!0),((a==null?void 0:a({text:i,paperMentions:[],...l?{paperSelection:l}:{}}))??(o==null?void 0:o(i))??!1)||m(!1)};return b.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:b.jsxs("div",{className:"chat-inline-editor",children:[l&&b.jsx(Cs,{selection:l,editable:!0,onRemove:()=>d(void 0)}),b.jsx("textarea",{ref:g,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:i,maxLength:8e3,onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Escape"?(f.preventDefault(),s==null||s()):f.key==="Enter"&&!f.shiftKey&&!f.nativeEvent.isComposing&&(f.preventDefault(),v())}}),n&&b.jsx("div",{className:"chat-inline-editor-notice",children:n}),b.jsxs("div",{className:"chat-inline-editor-actions",children:[b.jsx("button",{type:"button",onClick:s,children:"Cancel"}),b.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!_||h,onClick:v,children:"Send"})]})]})})},CT=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=G.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[h,m]=G.useState(!1),[g,y]=G.useState(0),{textareaRef:_,resize:v}=sh(t),f=Jl({draft:l,onChange:d,enabled:s,textareaRef:_});G.useLayoutEffect(v,[v,l.text]);const $=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),E=()=>{if(!$||h)return;m(!0),((c==null?void 0:c(l))??(i==null?void 0:i(l.text))??!1)||m(!1)};return b.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:b.jsxs("div",{className:"chat-inline-editor",children:[l.paperSelection&&b.jsx(Cs,{selection:l.paperSelection,editable:!0,onRemove:()=>d({text:l.text,paperMentions:l.paperMentions})}),b.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[b.jsx(Ql,{text:l.text,mentions:l.paperMentions,scrollTop:g,variant:"editor"}),b.jsx("textarea",{ref:_,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:l.text,maxLength:8e3,role:"combobox","aria-autocomplete":"list","aria-expanded":f.open,"aria-controls":f.open?f.pickerId:void 0,"aria-activedescendant":f.open&&f.results.length?`${f.optionIdPrefix}-${f.activeIndex}`:void 0,onChange:T=>f.updateText(T.target.value,T.target.selectionStart),onSelect:T=>f.refresh(T.currentTarget.selectionStart),onScroll:T=>y(T.currentTarget.scrollTop),onKeyDown:T=>{f.keyDown(T)||(T.key==="Escape"?(T.preventDefault(),a==null||a()):T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),E()))}}),b.jsx(Yl,{open:f.open,query:f.query,results:f.results,activeIndex:f.activeIndex,loading:f.loading,error:f.error,onSelect:f.select,id:f.pickerId,optionIdPrefix:f.optionIdPrefix})]}),!s&&l.paperMentions.length>0&&b.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),o&&b.jsx("div",{className:"chat-inline-editor-notice",children:o}),b.jsxs("div",{className:"chat-inline-editor-actions",children:[b.jsx("button",{type:"button",onClick:a,children:"Cancel"}),b.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!$||h,onClick:E,children:"Send"})]})]})})},WT=({id:e,text:t,paperMentions:r=[],paperSelection:n,paperMentionsEnabled:s=!1,editingAllowed:o=!1,editing:a=!1,editNotice:i,onEdit:c,onCancel:l,onResend:d,onResendDraft:h})=>{const[m,g]=G.useState(!1),y=G.useRef(null);G.useEffect(()=>()=>{y.current!==null&&window.clearTimeout(y.current)},[]);const _=async()=>{var v;if((v=navigator.clipboard)!=null&&v.writeText)try{await navigator.clipboard.writeText(t),g(!0),y.current!==null&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>g(!1),1500)}catch{}};return a?!s&&r.length===0?b.jsx(TT,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:h}):b.jsx(CT,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:h}):b.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":e,children:b.jsxs("div",{className:"chat-user-message-wrap",children:[n&&b.jsx(Cs,{selection:n}),b.jsx("div",{className:"chat-bubble",onDoubleClick:bT,children:b.jsx(ST,{text:t,mentions:r})}),b.jsxs("div",{className:"chat-user-actions",children:[b.jsx("button",{type:"button",className:"chat-user-action","aria-label":m?"Message copied":"Copy message",title:m?"Copied":"Copy",onClick:()=>void _(),children:m?b.jsx(ch,{"aria-hidden":"true"}):b.jsx(kh,{"aria-hidden":"true"})}),o&&b.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:c,children:b.jsx(Rh,{"aria-hidden":"true"})})]})]})})},BT=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var M,L,F;const[l,d]=G.useState(null),[h,m]=G.useState(!1),[g,y]=G.useState(!1),[_,v]=G.useState(!1),[f,$]=G.useState(""),E=G.useRef(null),T=`chat-feedback-panel-${e.id}`,k=c&&!e.streaming&&!e.error&&!!((M=e.blocks)!=null&&M.some(V=>V.kind==="answer"&&V.text.trim()));G.useEffect(()=>{var V;_&&((V=E.current)==null||V.focus())},[_]);const x=async(V,Z)=>{if(!h){m(!0),y(!1);try{Z===void 0?await bc.reportFeedback(e.id,V):await bc.reportFeedback(e.id,V,Z),d(V),v(!1),$("")}catch{y(!0)}finally{m(!1)}}};return b.jsx("div",{className:"chat-msg chat-msg-assistant",children:b.jsxs("div",{className:"chat-msg-blocks",children:[(L=e.blocks)==null?void 0:L.map((V,Z)=>{var ke;const B=`${e.id}-${Z}`,re="citations"in V&&V.citations!==void 0?V.citations:e.citations??[],H=Object.fromEntries(re.filter(ye=>(ye.kind==="catalog_paper"||ye.kind==="paper"||!ye.kind&&ye.route_id)&&ye.route_id).map(ye=>[ye.route_id,ye])),ie=Object.fromEntries(re.filter(ye=>(ye.kind==="external_source"||ye.kind==="web")&&ye.url).map(ye=>[ye.url,ye]));return V.kind==="reasoning"?b.jsx(ET,{block:V,papers:t,citations:H,webCitations:ie,onToggle:()=>r(e.id,Z)},B):V.kind==="tool"?b.jsx(kT,{block:V,papers:t,onToggle:()=>r(e.id,Z)},B):V.kind==="app"?b.jsx(RT,{block:V},V.instance_id||B):V.kind==="artifact"?b.jsx(pT,{block:V},V.publication_id||V.version_id||B):b.jsx(PT,{block:V,papers:t,citations:H,webCitations:ie,streaming:!!(e.streaming&&Z===(((ke=e.blocks)==null?void 0:ke.length)??0)-1)},B)}),wT(e)&&b.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:b.jsx("span",{className:"chat-thinking",children:(((F=e.blocks)==null?void 0:F.length)??0)===0?e.status??"Thinking…":"Thinking…"})}),e.error&&b.jsxs("div",{className:"chat-error",children:[b.jsx("span",{children:e.errorCode==="chat_disabled_interrupted"?"Chat was disabled while this response was running. The partial response is saved. Please try again later.":e.errorCode==="chat_session_quota_exceeded"?e.error:`The assistant hit an error: ${e.error}`}),["hf_inference_billing_required","hf_inference_credential_expired"].includes(e.errorCode??"")&&b.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"}),e.errorCode==="hf_inference_billing_exhausted"&&b.jsxs(b.Fragment,{children:[(a==null?void 0:a.account_type)==="Free"&&!a.bill_to?b.jsx("a",{href:yT,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):b.jsx("a",{href:(a==null?void 0:a.usage_url)??"/settings",target:a?"_blank":void 0,rel:a?"noreferrer":void 0,children:"Review Hugging Face usage and billing"}),b.jsx("a",{href:vT,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]}),e.errorCode==="openrouter_monthly_budget_exhausted"&&b.jsxs(b.Fragment,{children:[i?b.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):b.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),b.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]}),e.errorCode==="openrouter_staging_funding_disabled"&&b.jsx("a",{href:$T,children:"Continue on paperswithcode.co"}),e.errorCode==="openrouter_unavailable"&&b.jsxs(b.Fragment,{children:[b.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),b.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]}),e.errorCode==="openrouter_byok_billing_error"&&b.jsx("a",{href:"https://openrouter.ai/settings/credits",target:"_blank",rel:"noreferrer",children:"Review OpenRouter billing"}),["openrouter_byok_credential_invalid","openrouter_byok_rate_limit"].includes(e.errorCode??"")&&b.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"}),e.errorCode==="chat_session_quota_exceeded"&&(n||s)&&b.jsxs("span",{className:"chat-error-actions",children:[n&&b.jsx("button",{type:"button",disabled:o!==null,onClick:n,children:o==="old"?"Archiving…":"Archive chats older than 30 days"}),s&&b.jsx("button",{type:"button",disabled:o!==null,onClick:s,children:o==="oldest"?"Archiving…":"Archive oldest 50 chats"})]})]}),!e.streaming&&e.finishReason&&e.finishReason!=="success"&&b.jsx("div",{className:"chat-finish-note",children:["tool_limit","max_turns"].includes(e.finishReason)?"The assistant stopped at the execution limit.":`The assistant stopped early (${e.finishReason.replace(/_/g," ")}).`}),k&&b.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[b.jsx("span",{className:"chat-feedback-label",children:l===null?"Was this helpful?":"Thanks for your feedback"}),b.jsx("button",{type:"button",className:`chat-feedback-action${l===!0?" chat-feedback-action-selected":""}`,"aria-label":"Helpful response","aria-pressed":l===!0,disabled:h,onClick:()=>{v(!1),x(!0)},children:b.jsx(Ch,{"aria-hidden":"true"})}),b.jsx("button",{type:"button",className:`chat-feedback-action${l===!1?" chat-feedback-action-selected":""}`,"aria-label":"Unhelpful response","aria-pressed":l===!1,"aria-expanded":_,"aria-controls":T,disabled:h,onClick:()=>{y(!1),v(!0)},children:b.jsx(Th,{"aria-hidden":"true"})}),g&&b.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),k&&_&&b.jsxs("div",{className:"chat-feedback-panel",id:T,role:"group","aria-labelledby":`${T}-title`,children:[b.jsx("div",{className:"chat-feedback-panel-title",id:`${T}-title`,children:"Additional feedback"}),b.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${T}-comment`,children:"Tell us what went wrong (optional)"}),b.jsx("textarea",{ref:E,id:`${T}-comment`,className:"chat-feedback-comment",value:f,maxLength:500,rows:4,disabled:h,onChange:V=>$(V.target.value),onKeyDown:V=>{V.key==="Escape"&&(V.preventDefault(),v(!1))}}),b.jsxs("div",{className:"chat-feedback-panel-actions",children:[b.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:h,onClick:()=>void x(!1),children:"Skip"}),b.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:h,onClick:()=>void x(!1,f.trim()||void 0),children:h?"Submitting…":"Submit"})]})]})]})})},jT={chat:{breakpoint:760,left:360,right:360},shared:{breakpoint:760,left:360,right:360},reader:{breakpoint:1260,left:840,right:420}};function rr(e,t,r,n){if(!e)return Math.max(25,Math.min(75,t));const s=Math.max(25,n/e*100),o=Math.min(75,(e-r)/e*100);return Math.max(s,Math.min(o,t))}const JT=({children:e,variant:t})=>{const r=wc(),n=jT[t],s=G.useRef(null),o=G.useRef(null),a=G.useRef(null),i=G.useRef(null),[c,l]=G.useState(0),d=G.useRef(!1),h=G.useRef(r.state.panelPercent);G.useLayoutEffect(()=>{const f=s.current;if(!f)return;const $=()=>l(f.clientWidth||window.innerWidth);if($(),typeof ResizeObserver>"u")return;const E=new ResizeObserver($);return E.observe(f),()=>E.disconnect()},[]);const m=r.state.open&&c>=n.breakpoint,g=rr(c,r.state.panelPercent,n.left,n.right),y=f=>{var E;const $=rr(c,f,n.left,n.right);h.current=$,o.current&&(o.current.style.width=`${100-$}%`),a.current&&(a.current.style.width=`${$}%`),(E=i.current)==null||E.setAttribute("aria-valuenow",String(Math.round($)))},_=f=>{var E;const $=(E=s.current)==null?void 0:E.getBoundingClientRect();$!=null&&$.width&&y(($.right-f)/$.width*100)},v=()=>{d.current&&(d.current=!1,r.setPanelPercent(h.current))};return b.jsxs("div",{ref:s,className:`chat-artifact-workspace chat-artifact-workspace-${t}${m?" has-docked-artifact":""}`,"data-artifact-layout":m?"split":r.state.open?"dialog":"closed",children:[b.jsx("div",{ref:o,className:"chat-artifact-workspace-content",style:m?{width:`${100-g}%`}:void 0,children:e}),m&&b.jsxs(b.Fragment,{children:[b.jsx("div",{ref:i,className:"chat-artifact-resize-handle",role:"separator","aria-label":"Resize conversation and poster panels","aria-orientation":"vertical","aria-valuemin":Math.ceil(rr(c,0,n.left,n.right)),"aria-valuemax":Math.floor(rr(c,100,n.left,n.right)),"aria-valuenow":Math.round(g),tabIndex:0,onPointerDown:f=>{d.current=!0,f.currentTarget.setPointerCapture(f.pointerId),_(f.clientX)},onPointerMove:f=>{d.current&&_(f.clientX)},onPointerUp:v,onPointerCancel:v,onLostPointerCapture:v,onDoubleClick:()=>r.setPanelPercent(55),onKeyDown:f=>{(f.key==="ArrowLeft"||f.key==="ArrowRight")&&(f.preventDefault(),r.setPanelPercent(rr(c,g+(f.key==="ArrowLeft"?2:-2),n.left,n.right))),f.key==="Home"&&r.setPanelPercent(rr(c,25,n.left,n.right)),f.key==="End"&&r.setPanelPercent(rr(c,75,n.left,n.right))}}),b.jsx("div",{ref:a,className:"chat-artifact-workspace-pane",style:{width:`${g}%`},children:b.jsx(Wl,{})})]}),r.state.open&&!m&&b.jsx(Wl,{forceDialog:!0,readerFallback:t==="reader"})]})};export{GT as A,HT as C,WT as U,JT as a,BT as b,wc as u};